Created
February 14, 2010 15:19
-
-
Save gdude2002/304088 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Traceback (most recent call last): | |
File "/usr/local/lib/python2.6/site-packages/twisted/python/log.py", line 84, in callWithLogger | |
return callWithContext({"system": lp}, func, *args, **kw) | |
File "/usr/local/lib/python2.6/site-packages/twisted/python/log.py", line 69, in callWithContext | |
return context.call({ILogContext: newCtx}, func, *args, **kw) | |
File "/usr/local/lib/python2.6/site-packages/twisted/python/context.py", line 59, in callWithContext | |
return self.currentContext().callWithContext(ctx, func, *args, **kw) | |
File "/usr/local/lib/python2.6/site-packages/twisted/python/context.py", line 37, in callWithContext | |
return func(*args,**kw) | |
--- <exception caught here> --- | |
File "/usr/local/lib/python2.6/site-packages/twisted/internet/selectreactor.py", line 146, in _doReadOrWrite | |
why = getattr(selectable, method)() | |
File "/usr/local/lib/python2.6/site-packages/twisted/internet/tcp.py", line 463, in doRead | |
return self.protocol.dataReceived(data) | |
File "/usr/local/lib/python2.6/site-packages/twisted/protocols/basic.py", line 231, in dataReceived | |
why = self.lineReceived(line) | |
File "/home/gdude2002/archives/myne/myne/controller.py", line 28, in lineReceived | |
data = simplejson.loads(line) | |
File "build/bdist.linux-i686/egg/simplejson/__init__.py", line 307, in loads | |
File "build/bdist.linux-i686/egg/simplejson/decoder.py", line 335, in decode | |
File "build/bdist.linux-i686/egg/simplejson/decoder.py", line 351, in raw_decode | |
exceptions.ValueError: Expecting property name: line 1 column 1 (char 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<section id="content" class="body center"> | |
<?php | |
$socketdie = "No information avaliable"; | |
function runcmd($cmd, $data = NULL ){ | |
global $socket; | |
$jsondata = json_encode(array ('password'=>'bingy','command'=>$cmd, $data[0]=>$data[1]))."\r\n"; | |
socket_send($socket, $jsondata, strlen($jsondata),0); | |
if (($bytes = socket_recv($socket, $buf, 16384, NULL)) == false) die($socketdie); | |
//echo "raw data = ".$buf."<br>"; | |
return json_decode($buf); | |
} | |
?> | |
<? | |
if(($socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP))== false) die($socketdie); | |
if(socket_connect($socket, '127.0.0.1', 50012) == false) die($socketdie); | |
?> | |
<? | |
$admins = array(); | |
$worlds = runcmd("userworlds"); | |
foreach (runcmd("admins")->admins as $n => $name) | |
switch($name){ | |
case "gov": | |
case "littlelink": | |
case "link.": | |
case "worldagent": | |
case "blackandblue": | |
case "arbot": | |
case "ax01": break; | |
default: $admins[$name] = 1; break; | |
} | |
foreach (runcmd("users")->users as $n => $name) $users[$name] = 1; | |
$adminsonline = array(); | |
foreach ($users as $name => $n) | |
foreach ($admins as $aname => $an) | |
if($name == $aname) $adminsonline[$aname] =1; | |
sort($worlds->worlds); | |
ksort($users); | |
ksort($admins); | |
echo "<h2>Statistics</h2>\n"; | |
echo "<ul>\n"; | |
echo "<li>" . count($worlds->worlds) . " worlds online </li>\n"; | |
if(count($users)) echo "<li>" . count($users) . " user" . (count($users) > 1 ? "s":"") . "</li>\n"; | |
if(count($adminsonline)) echo "<li>" . count($adminsonline)." admin" . (count($adminsonline) > 1 ? "s":"") . "</li>\n"; | |
echo "</ul>\n"; | |
echo "<h2>Users</h2>\n"; | |
echo "<ul>\n"; | |
$n = 0; | |
foreach($users as $name => $stat){ | |
if(!$admins[$name]){ | |
echo "<li>" . $name . "</li>\n"; | |
} | |
$n++; | |
} | |
echo "</ul>\n"; | |
echo "<h3>Admins</h3>\n"; | |
echo "<ul>\n"; | |
$n = 0; | |
foreach($admins as $name => $stat){ | |
echo "<li>" . $name . ($adminsonline[$name] ? " (online)" : "") . "</li>\n"; | |
$n++; | |
} | |
echo "</ul>\n"; | |
echo "<h3>Worlds</h3>\n"; | |
$bgphase = 0; | |
foreach ($worlds->worlds as $n => $worldinfo){ | |
$userinfo = array(); | |
if(!$bgphase) $bgphase=1; | |
else $bgphase=0; | |
$info = $worldinfo[2]; | |
echo "<b>".$worldinfo[0]."</b>\n". | |
($info->private ? "(Private)" : "(Public)"). | |
($info->locked ? "(Locked)" : ""). | |
($info->physics ? "(Physics)" : "")."\n<br>\n"; | |
foreach ($info->writers as $n => $value) $userinfo[$value] = "Writer: "; | |
foreach ($info->ops as $n => $value) $userinfo[$value] = "Op: "; | |
sort($worldinfo[1]); | |
echo "<ul>\n"; | |
foreach ($worldinfo[1] as $n => $name){ | |
echo "<li>"; | |
if(!$admins[strtolower($name)]) echo ($userinfo[$name]? $userinfo[$name]: "Viewer: "); | |
else echo "Admin: "; | |
echo $name."</li>\n"; | |
} | |
echo "</ul>\n"; | |
} | |
socket_close($socket); | |
?> | |
</section> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import json | |
import threading | |
import time | |
import sys | |
class mysocket (threading.Thread): | |
def __init__(self, sock=None): | |
threading.Thread.__init__(self) | |
if sock is None: | |
self.sock = socket.socket( | |
socket.AF_INET, socket.SOCK_STREAM) | |
else: | |
self.sock = sock | |
self.con() | |
def con(self): | |
self.sock.connect(("pearsoncoles.com", 50012)) | |
sent = False | |
# time.sleep(5) | |
try: | |
while True: | |
if not sent: | |
self.mysend(str({'': None, 'password': 'bingy', 'command': 'admins'})+"\r\n") | |
sent = True | |
print self.myreceive() | |
else: | |
print self.myreceive() | |
except KeyboardInterrupt: | |
print "Connection closed." | |
exit | |
def mysend(self, msg): | |
totalsent = 0 | |
self.sock.send(str(msg)) | |
def myreceive(self): | |
msg = '' | |
chunk = self.sock.recv(1024) | |
if len(chunk) == 0 or chunk == None: | |
print "Connection closed!" | |
sys.exit | |
else: | |
msg = msg + chunk | |
return msg | |
mysocket().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment