Forum Moderators: coopster
<?php
session_start();
//global $faction;
//$faction ='';
$file = "../Ticker/ticker.xml";
//-------------------------------------------------save to the XML file---------------------------------------------
$strToFile = "";
if(strtoupper(trim($faction)) == "SAVE"){ //line 9
$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]++; ///Line 48
}
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 'YES';?></option>
<option value=<?php
echo 'NO';
if($display == "NO")
echo " selected";
?>><?php echo'NO';?></option>
</select>
</td></tr>
<td valign="top">Event Updates:</td>
<td><textarea id="newmessage" name="newmessage" cols="30" rows="3" wrap="soft" onKeyUp="count(this)"></textarea><br />
<!--<div>char: <span id="cont"><?php echo strlen('$newmessage');?></span>/400</div> -->
<input type="button" name=btnAdd value="Add" onClick="addMessage()"></td>
</tr>
<!---- New Added-->
<tr><td colspan="2"><hr noshade width="70%"></td></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>
<script language="javascript">
function count(textObj)
{
var maxlen = 400;
//alert(textObj.value);
var text = textObj.value;
if(text.length >= maxlen)
text = text.substr(0, maxlen);
textObj.value = text;
document.getElementById('cont').innerHTML = text.length;
//var cont = getElementById('cont');
//alert(cont);*/
}
function cancel(page)
{
location.replace(page);
}
function addMessage()
{
if(document.forms[0].newmessage.value.length > 0)
{
messages[messages.length-1] = document.forms[0].newmessage.value;
submitForm();
}
else
alert("Please Specify a message to add"); //'Please specify a message to add
}
function deleteMessage(loc)
{
for(i = loc; i < messages.length-1; i++)
messages[i] = messages[i+1];
submitForm();
}
function saveMessagesArray()
{
var temp = "";
var temp2 = "";
for(i = 0; i < messages.length; i++)
{
if( messages[i] != null )
{
if(temp.length > 0)
temp = temp + "-,";
temp2 = messages[i].replace(/</g,"(");
temp2 = temp2.replace(/>/g,")");
temp2 = temp2.replace(/&/g,"and");
temp2 = temp2.replace(/-,/g,",");
temp = temp + temp2;
}
}
document.forms[0].messagesArray.value = temp;
}
function moveUp(loc)
{
temp = messages[loc-1];
messages[loc-1] = messages[loc];
messages[loc] = temp;
submitForm();
}
function moveDown(loc)
{
temp = messages[loc+1];
messages[loc+1] = messages[loc];
messages[loc] = temp;
submitForm()();
}
function submitForm()
{
saveMessagesArray();
document.forms[0].faction.value = "save";
document.forms[0].submit();
}
</script>
function startElement($parser, $name, $attrs)
{
global $depth,$currTag;
$currTag = strtoupper(trim($name));
//$depth++;
$depth[$parser]++; ///Line 48
}
function sayHello($name)
{
echo 'Hi ' . $name;
}
$name = 'Wittner';
function sayHello($name)
{
echo 'Hi ' . $name;
}