Forum Moderators: coopster
<?php
session_start();
//global $faction;
$faction ='';
$file = "../Ticker/ticker.xml";
//-------------------------------------------------save to the XML file---------------------------------------------
$strToFile = "";
if(strtoupper(trim($faction)) == "SAVE")
{
$strToFile = $strToFile."<xml id='xmlNews'>\n";
$strToFile = $strToFile."<display>".$sclTickerStatus."</display>\n";
$strToFile = $strToFile."<ticker>\n";
$arrMessages = split("-,",$messagesArray);
for($i = 0; $i < count($arrMessages); $i++)
$strToFile = $strToFile."<message>".$arrMessages[$i]."</message>\n";
//$strToFile = $strToFile."<message>".$TickerMsg[$i]."</message>\n";
$strToFile = $strToFile."</ticker>\n";
$strToFile = $strToFile."</xml>";
//------------------
if (file_exists($file))
{
unlink ($file);
}
$handle = fopen($file,'a+');
if (fwrite($handle, $strToFile) === FALSE)
{
echo 'View Reports'; //View reports
}
fclose($handle);
}
//-----------------------------------------------------XML Parser---------------------------------------------------
global $currTag, $display, $mArray;
$mArray=array();
$depth =array();
function startElement($parser,$name,$attrs)
{
global $depth,$currTag;
$currTag = strtoupper(trim($name));
//$depth++;
$depth[parser]++;
}
function characterData($parser,$data)
{
global $currTag, $display, $mArray;
$curData = trim($data);
if(strlen($curData)>0)
{
if($currTag == "DISPLAY")
$display = strtoupper($curData);
if($currTag == "MESSAGE")
{
$mArray[count($mArray)] = $curData;
}
}
}
function endElement($parser,$name)
{
global $depth;
//$depth--;
$depth[$parser]--;
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser,"startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!($fp = fopen($file, "r")))
{
echo 'Error Reading Message'; //Error reading Message
}
while ($data = fread($fp, 4096))
{
if (!xml_parse($xml_parser, $data, feof($fp)))
{
echo 'Error Reading Message';
}
}
xml_parser_free($xml_parser);
//----------------------------------------------------------------------------------------------
echo "<script>";
echo "var messages= new Array(".(count($mArray)+1).");";
for($l=0; $l<count($mArray); $l++)
{
echo "messages[".$l."]='".$mArray[$l]."';";
}
echo "</script>";
?>
<form name="item" action="directing.php?page=events" method="post">
<input name="faction" type="hidden">
<input name="messagesArray" type="hidden">
<table align="center" class="tableForm" width="75%" cellspacing="10">
<tr>
<td>Status:</td>
<td><select name="sclTickerStatus" onChange="submitForm()">
<option value=<?php
echo 'YES';
if($display == "YES")
echo " selected";
?>><?php echo 'On';?></option>
<option value=<?php
echo 'NO';
if($display == "NO")
echo " selected";
?>><?php echo'Off';?></option>
</select>
</td>
</tr>
<tr>
<td valign="top">Event Updates:</td>
<td><textarea id="newmessage" name="newmessage" cols="30" rows="3"></textarea><br />
<input type="button" name=btnAdd value="Add" onClick="addMessage()">
</td>
</tr>
<!---- New Added-->
<tr>
<td colspan="2"><hr noshade width="70%"></td>
</tr>
<tr></tr>
<?php
echo "<tr><td colspan=2>";
echo "<table width=100% border=0 bordercolor='#000000' cellpadding=2 cellspacing=0>";
for($l=0; $l<count($mArray); $l++)
{
echo "<tr class=".($l%2==0?"dark":"light")."><td width=10% align=center valign=center><b>".($l+1)."</b></td><td>".$mArray[$l];
echo "</td><td width=10%>";
if($l != 0)
echo "<a href='javascript:moveUp(".$l.");'><img src='../controlpanel/img/up.gif' border=0> </a>";
if($l != count($mArray)-1)
echo "<a href='javascript:moveDown(".$l.");'><img src='../controlpanel/img/down.gif'' border=0> </a>";
echo "</td><td width=1%><input type=button value='Delete' onClick='deleteMessage(".$l.")'></td></tr>";
}
echo "</table>";
echo "</td></tr>";
?>
</td></tr>
<!--- End of New Added-->
</table>
</form>