electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 33c5f20853b337514525807ed7a16cba9c8828d7
parent ff639ceecea5bcd90a52565f39a0a29830c70a88
Author: ThomasV <thomasv@gitorious>
Date:   Wed, 23 Nov 2011 00:26:36 +0300

improved page

Diffstat:
Mserver/electrum.php | 36+++++++++++++++++++++++++++++++-----
Mserver/server.py | 2+-
2 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/server/electrum.php b/server/electrum.php @@ -1,5 +1,7 @@ <? - $query = $_POST['q']. "#"; + + function do_query($q){ + $q .= "#"; $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($socket === false) { @@ -10,14 +12,38 @@ if ($result === false) { echo "socket_connect() failed.\nReason: ($result) " . socket_strerror(socket_last_error($socket)) . "\n"; } - - socket_write($socket, $query, strlen($query)); - + socket_write($socket, $q, strlen($q)); $buf='ex'; if (false == ($bytes = socket_recv($socket, $buf, 2048, MSG_WAITALL))) { echo "socket_recv() failed; reason: " . socket_strerror(socket_last_error($socket)) . "\n"; } socket_close($socket); - echo $buf; + return $buf; + } + + $pass=''; + + $query = $_POST['q']; + if( !$query ) { + echo "Welcome to <a href=\"http://ecdsa.org/electrum/\">Electrum</a><br/>"; + echo "This server uses ports 80 (http), 443 (https) and 50000 (raw)<br/>"; + echo "Port 50000 is recommended for efficiency.<br/><br/>"; + + echo "Server status:<br/>"; + echo "Number of blocks: ". do_query( "('b','')" ) ."<br/>"; + echo "Current load: ". do_query( "('load',$pass)" ) ."<br/><br/>"; + + echo "List of active servers:<br/>\n"; + $str = do_query( "('peers','')" ); + preg_match_all("/(\d+\.\d+\.\d+\.\d+)/",$str,$matches,PREG_SET_ORDER); + echo "<ul>"; + foreach( $matches as $ip){ + echo "<li><a href=\"http://" . $ip[0] . "/electrum.php\">" . $ip[0] . "</a></li>"; + } + echo "</ul>"; + } else { + $buf = do_query($query); + echo $buf; + } ?> diff --git a/server/server.py b/server/server.py @@ -456,7 +456,7 @@ def irc_thread(): s.send('USERHOST %s\n'%item) elif '302' in line: # answer to /userhost k = line.index('302') - name = line[k+1] + name = line[k+2].split('=')[0] host = line[k+2].split('@')[1] peer_list[name] = host elif time.time() - t > 5*60: