\n",str_replace(">",">",str_replace("\n<","\n<",str_replace("<","<",str_replace("\&","&",str_replace("&&","&&",$a))))))); $a="<".substr($a,4,strlen($a)-8).">"; $xml=new SimpleXMLElement($a); //$xml=simplexml_load_file("commands.js"); $i=0; foreach($xml->children() as $child) { $newfunction=true; $childname=$child->getName(); $ifpl=""; $what="None"; $param="None"; foreach($child->attributes() as $a=>$b) { if ($a=="rel" && $b!="") { $newfunction=false; $childname=$b; } else if ($a=="what" && $b!="") { $what=$b; } else if ($a=="param" && $b!="") { $param=$b; } else if ($a=="pl" && $b!="") { $pl=$b; $apl.="\nelse if (pl==\"".$pl."\") pl_".strtolower($pl)."()"; $ifpl="\npl=\"".$pl."\""; foreach($child->children() as $nchild) { $plfunctions.="\n\nfunction pl_".strtolower($pl)."() {".$nchild."}"; } } } if (!$newfunction) { foreach($xml->children() as $childb) { if ($childb->getName()==$childname) { foreach($childb->attributes() as $ab=>$bb) { if ($ab=="what" && $bb!="") { if ($what!="None") { $bb=$what; } $what=$bb." (does the same as [".$childb->getName()."])"; } else if ($ab=="param" && $bb!="") { if ($param!="None") { $bb=$param; } $param=$bb." (the same as [".$childb->getName()."])"; } } } } } else { $allfunctions.="\n\nfunction command_".$child->getName()."() {".$ifpl.$child."}"; } $determinefunction.="\nelse if (ca==\"".$child->getName()."\") command_".$childname."()"; $determinewhat.="\nelse if (cb==\"".$child->getName()."\") return \"Description: ".$what."\\nParameters: ".$param."\""; $allcommands[$i]="\\n".$child->getName().": ".$what; $allcommandsdetailed[$i]="\\nThe \\\"".$child->getName()."\\\" command\\nDescription: ".$what."\\nParameters: ".$param."\\n"; //$allcommands.="\\n".$child->getName().": ".$what; //$allcommandsdetailed.="\\nThe \\\"".$child->getName()."\\\" command\\nDescription: ".$what."\\nParameters: ".$param."\\n"; $commandexists.=" || cb==\"".$child->getName()."\""; $i++; } $allfunctions=substr($allfunctions,2); $determinewhat=substr($determinewhat,6); sort($allcommands); while (list($key, $val) = each($allcommands)) { $nallcommands.=$val; } sort($allcommandsdetailed); while (list($key, $val) = each($allcommandsdetailed)) { $nallcommandsdetailed.=$val; } $allcommands=""; $allcommandsdetailed=""; $allcommands=substr($nallcommands,2); $allcommandsdetailed=substr($nallcommandsdetailed,2); $commandexists=substr($commandexists,4); include("functions.js"); echo "\n\n".$allfunctions.$plfunctions; ?> function add(sometext,l,ll) { nn="\n\n" if (l) nn="\n" if (ll) nn="" t.value+=sometext+nn+pl+">" t.focus() } function resize() { if (self.innerHeight) h=self.innerHeight else if (document.documentElement && document.documentElement.clientHeight) h=document.documentElement.clientHeight else if (document.body) h=document.body.clientHeight t.style.height=h-2+"px" scrolldown() } function focusafterawhile() { if (focuswait) { focuswait=false setTimeout("focusafterawhile()",250) } else t.focus() } function scrolldown() { th=t.scrollHeight if (th>h) t.scrollTop=th } function onenter(e) { if (!enterdown) { if (window.event) keycode=window.event.keyCode else if (e) keycode=e.which enterdown=true setTimeout("onenter()",50) } else { enterdown=false if (keycode!=13) return msga=t.value.split("\n") msgl=msga.length msg=msga[msgl-2].substr(1+pl.length) //msg=msg.toLowerCase() msgl=msg.length if (ie() || opera()) { msgl-=1 msg=msg.substr(0,msgl) } msgps=new Array() c=0 cc=0 qtd=false for (i=0; i else add("Error! The command \""+ca+"\" doesn't exist! Type help for help.") } else { if (ca=="") add("",true,true) else if (ca=="/exit") exit() } if (opera()) setCaretToEnd(t) scrolldown() } } function start() { document.title="webCLI" stylelink=document.createElement("link") stylelink.href="style.css" stylelink.type="text/css" stylelink.rel="stylesheet" head=document.getElementsByTagName("head")[0] head.appendChild(stylelink) enterdown=false allcommands="" allcommandsdetailed="" anirunning=false svsn=0 svs=new Array() startmessage="webCLI [version 0.01]\nwebCLI is free software. No warranty blah blah." if (opera()) beware="\nYou are using Opera, and webCLI is, for some reason, not working perfectly in Opera. Most of it works, though. You might want to consider using Firefox, where webCLI works perfectly." else if (ie()) beware="\nYou are using Internet Explorer, and webCLI works okay in this browser. However, you might want to consider using Firefox, where webCLI works perfectly." else beware="" pl="" cookie=navigator.cookieEnabled if (cookie) { var coie=getCookie("mem") if (coie) { coie=coie.split("\n") csvn=coie.length } else csvn=0 } img1=new Image() img1.src="img/m1.png" img2=new Image() img2.src="img/m2.png" img3=new Image() img3.src="img/m3.png" img4=new Image() img4.src="img/road.png" bdy=document.body t=document.createElement("textarea") bdy.appendChild(t) resize() t.innerHTML="" add(startmessage+beware,true) focuswait=true if (ie() || opera()) setCaretToEnd(t) focusafterawhile() } window.onload=start window.onresize=resize document.onkeydown=onenter