+++ /dev/null
-<?php
-
-error_reporting(E_ALL | E_STRICT);
-set_time_limit(0);
-
-require('udp-inc.php');
-
-$port = 60825;
-$host = '0.0.0.0';
-
-$leaving = array('/leave', '/logout', '/bye', '/quit');
-$shutdown = array('/shutdown', '/halt');
-$masters = array('127.0.0.1');
-
-// create a streaming socket, of type TCP/IP
-$main_sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
-
-// set the option to reuse the port
-socket_set_option($main_sock, SOL_SOCKET, SO_REUSEADDR, 1);
-
-// "bind" the socket to the address to "localhost", on port $port
-// so this means that all connections on this port are now our resposibility to send/recv data, disconnect, etc..
-socket_bind($main_sock, $host, $port);
-
-// start listen for connections
-socket_listen($main_sock);
-
-// create a list of all the clients that will be connected to us..
-// add the listening socket to this list
-$clients = array($main_sock);
-
-out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Server listens on {$host}:{$port}");
-
-while (count($clients) > 0) {
- // create a copy, so $clients doesn't get modified by socket_select()
- $read = $clients;
-
- // get a list of all the clients that have data to be read from
- // if there are no clients with data, go to next iteration
- $left = @socket_select($read, $write = null, $except = null, 0, 150);
- if ($left < 1) {
- continue;
- }
-
- // check if there is a client trying to connect
- if (in_array($main_sock, $read)) {
- // accept the client, and add him to the $clients array
- $new_sock = socket_accept($main_sock);
- $clients[] = $new_sock;
-
- // send the client a welcome message
- socket_write($new_sock, "No noobs, but I'll make an exception. :)\n".
- "There are ".(count($clients) - 1)." client(s) connected to the server.\n");
-
- socket_getpeername($new_sock, $ip);
- out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:New client connected: {$ip}");
-
- // Notify all chatter
- if (count($clients) > 2) {
- foreach ($clients as $send_sock) {
- if ($send_sock != $main_sock && $send_sock != $new_sock) {
- socket_write($send_sock, "Server: Chatter has joined from {$ip}. There are now ".(count($clients) - 1)." clients.\n");
- }
- }
- }
-
- // remove the listening socket from the clients-with-data array
- $key = array_search($main_sock, $read);
- unset($read[$key]);
- }
-
- // loop through all the clients that have data to read from
- foreach ($read as $read_sock) {
- // Get client data
- socket_getpeername($read_sock, $ip);
-
- // read until newline or 1024 bytes
- // socket_read while show errors when the client is disconnected, so silence the error messages
- $data = @socket_read($read_sock, 1024, PHP_NORMAL_READ);
-
- // check if the client is disconnected
- if (($data === FALSE) || (in_array(strtolower(trim($data)), $leaving))) {
-
- // remove client for $clients array
- $key = array_search($read_sock, $clients);
- unset($clients[$key]);
- out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client from {$ip} disconnected. Left: ".(count($clients) - 1)."");
-
- // Notify all chatter
- if (count($clients) > 1) {
- foreach ($clients as $send_sock) {
- if ($send_sock != $main_sock) {
- socket_write($send_sock, "Server: Chatter from {$ip} has logged out. ".(count($clients) - 1)." client(s) left.\n");
- }
- }
- }
-
- // continue to the next client to read from, if any
- socket_write($read_sock, "Server: Good bye.\n");
- socket_shutdown($read_sock, 2);
- socket_close($read_sock);
- continue;
- } elseif (in_array(trim($data), $shutdown)) {
- // Is he allowed to shutdown?
- if (!in_array($ip, $masters)) {
- out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} has tried to shutdown the server!");
- socket_write($read_sock, "Server: You are not allowed to shutdown the server!\n");
- $data = "";
- continue;
- }
-
- // Close all connections a leave here
- foreach ($clients as $client) {
- // Send message to client
- if ($client !== $main_sock && $client != $read_sock) {
- socket_write($client, "Server: Shutting down! Thank you for joining us.\n");
- }
-
- // Quit him
- socket_shutdown($client, 2);
- socket_close($client);
- } // end foreach
-
- // Leave the loop
- $data = "";
- $clients = array();
- continue;
- }
-
- // trim off the trailing/beginning white spaces
- $data = trim($data);
-
- // Test for HTML codes
- $tags = strip_tags($data);
-
- // check if there is any data after trimming off the spaces
- if (!empty($data) && $tags == $data && count($clients) > 2) {
- // Send confirmation to "chatter"
- socket_write($read_sock, "\nServer: Message accepted.\n");
-
- // send this to all the clients in the $clients array (except the first one, which is a listening socket)
- foreach ($clients as $send_sock) {
-
- // if its the listening sock or the client that we got the message from, go to the next one in the list
- if ($send_sock == $main_sock || $send_sock == $read_sock)
- continue;
-
- // write the message to the client -- add a newline character to the end of the message
- socket_write($send_sock, "{$ip}:{$data}\n");
-
- } // end of broadcast foreach
- } elseif ($tags != $data) {
- // HTML codes are not allowed
- out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} has entered HTML code!");
- socket_write($read_sock, "Server: HTML is forbidden!\n");
- } elseif ((count($clients) == 2) && ($read_sock != $main_sock)) {
- // No one else will hear the "chatter"
- out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} speaks with himself.");
- socket_write($read_sock, "Server: No one will hear you!\n");
- }
- } // end of reading foreach
-}
-
-// close the listening socket
-socket_close($main_sock);
-
-?>
+++ /dev/null
-# This is a configuration for generating a "code-swarm" video from the hub
-# project. If you like to create such video, please use the following commands
-# on Linux-based systems (or similars):
-#
-# # Change to 'trunk' and get a logfile
-# cd ../trunk/
-# svn log -v > ~/SVN/codeswarm/hub.log
-# # Copy this hub.config over there
-# cp ../contrib/hub.config ~/SVN/codeswarm/
-# # Change there and convert the logfile
-# cd ~/SVN/codewarm/
-# python ./convert_logs/convert_logs.py -s hub.log -o hub.xml
-# # Run codewarm (you may have to alter the Xmx value)
-# ./run.sh hub.config
-# # Now the frames are called hub-swarm-XXXXXX.png, e.g. use mencoder:
-# mencoder "mf://hub-swarm*.png" -mf fps=25 -o hub-codeswarm.avi -ovc lavc -lavcopts vcodec=mpeg4
-# # This will producea similar movie to mine
-
-# Frame width
-Width=800
-
-# Frame height
-Height=600
-
-# Input file
-InputFile=hub.xml
-
-# Particle sprite file
-ParticleSpriteFile=src/particle.png
-
-#Font Settings
-Font=SansSerif
-BoldFont=SansSerif
-InfoFont=SansSerif
-FontSize=10
-BoldFontSize=14
-InfoFontSize=20
-
-# Project time per frame
-MillisecondsPerFrame=21600000
-
-# Maximum number of Background processes
-MaxThreads=4
-
-# Optional Method instead of MillisecondsPerFrame
-FramesPerDay=10
-
-# Background in R,G,B
-Background=0,0,0
-
-# Color assignment rules
-# Keep in order, do not skip numbers. Numbers start
-# at 1.
-#
-# Pattern: "Label", "regex", R,G,B, R,G,B
-# Label is optional. If it is omitted, the regex
-# will be used.
-#
-ColorAssign1="Docs",".*txt", 0,0,255, 0,0,255
-ColorAssign2="PHP",".*php", 0,255,255, 0,255,255
-ColorAssign3="Template",".*tpl", 102,0,255, 102,0,255
-ColorAssign4="CSS",".*css", 255,0,0, 255,0,0
-ColorAssign5="JavaScript",".*js", 255,255,0, 255,255,0
-ColorAssign6="Shell",".*sh", 119,68,119, 119,68,119
-ColorAssign7="XML",".*xml", 136,51,17, 136,51,17
-ColorAssign8="Code",".*ctp", 250,110,110, 250,110,130
-#ColorAssign9="Code8",".*src8.*", 238,102,68, 238,102,68
-#ColorAssign10=".*src9.*", 238,68,119, 238,68,119
-
-# Save each frame to an image?
-TakeSnapshots=true
-
-# Where to save each frame
-SnapshotLocation=hub-swarm-######.png
-
-# Draw names (combinatory) :
-# Draw sharp names?
-DrawNamesSharp=true
-# And draw a glow around names? (Runs slower)
-DrawNamesHalos=true
-
-# Draw files (combinatory) :
-# Draw sharp files
-DrawFilesSharp=false
-# Draw fuzzy files
-DrawFilesFuzzy=true
-# Draw jelly files
-DrawFilesJelly=true
-
-# Show the Legend at start
-ShowLegend=true
-
-# Show the History at start
-ShowHistory=true
-
-# Show the Activity histogram at bottom
-ShowActivity=true
-
-# Show the Date at start
-ShowDate=true
-
-# Show edges between authors and files, mostly for debug purpose
-ShowEdges=false
-
-# Turn on Debug counts.
-ShowDebug=false
-
-# Natural distance of files to people
-EdgeLength=25
-
-# Amount of life to decrement
-EdgeDecrement=-2
-FileDecrement=-2
-PersonDecrement=-1
-
-#Speeds.
-#Optional: NodeSpeed=7.0, If used, FileSpeed and PersonSpeed need not be set.
-#
-FileSpeed=7.0
-PersonSpeed=2.0
-
-#Masses
-FileMass=1.0
-PersonMass=10.0
-
-# Life of an Edge
-EdgeLife=250
-
-# Life of a File
-FileLife=200
-
-# Life of a Person
-PersonLife=255
-
-# Highlight percent.
-# This is the amount of time that the person or
-# file will be highlighted.
-HighlightPct=5
-
-## Physics engine selection and configuration
-# Directory physics engine config files reside in.
-PhysicsEngineConfigDir=physics_engine
-# Force calculation algorithms ("PhysicsEngineLegacy", "PhysicsEngineSimple"...) :
-PhysicsEngineSelection=PhysicsEngineLegacy
-
-# OpenGL is experimental. Use at your own risk.
-UseOpenGL=false
--- /dev/null
+<?php
+
+error_reporting(E_ALL | E_STRICT);
+set_time_limit(0);
+
+require('udp-inc.php');
+
+$port = 60825;
+$host = '0.0.0.0';
+
+$leaving = array('/leave', '/logout', '/bye', '/quit');
+$shutdown = array('/shutdown', '/halt');
+$masters = array('127.0.0.1');
+
+// create a streaming socket, of type TCP/IP
+$main_sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
+
+// set the option to reuse the port
+socket_set_option($main_sock, SOL_SOCKET, SO_REUSEADDR, 1);
+
+// "bind" the socket to the address to "localhost", on port $port
+// so this means that all connections on this port are now our resposibility to send/recv data, disconnect, etc..
+socket_bind($main_sock, $host, $port);
+
+// start listen for connections
+socket_listen($main_sock);
+
+// create a list of all the clients that will be connected to us..
+// add the listening socket to this list
+$clients = array($main_sock);
+
+out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Server listens on {$host}:{$port}");
+
+while (count($clients) > 0) {
+ // create a copy, so $clients doesn't get modified by socket_select()
+ $read = $clients;
+
+ // get a list of all the clients that have data to be read from
+ // if there are no clients with data, go to next iteration
+ $left = @socket_select($read, $write = null, $except = null, 0, 150);
+ if ($left < 1) {
+ continue;
+ }
+
+ // check if there is a client trying to connect
+ if (in_array($main_sock, $read)) {
+ // accept the client, and add him to the $clients array
+ $new_sock = socket_accept($main_sock);
+ $clients[] = $new_sock;
+
+ // send the client a welcome message
+ socket_write($new_sock, "No noobs, but I'll make an exception. :)\n".
+ "There are ".(count($clients) - 1)." client(s) connected to the server.\n");
+
+ socket_getpeername($new_sock, $ip);
+ out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:New client connected: {$ip}");
+
+ // Notify all chatter
+ if (count($clients) > 2) {
+ foreach ($clients as $send_sock) {
+ if ($send_sock != $main_sock && $send_sock != $new_sock) {
+ socket_write($send_sock, "Server: Chatter has joined from {$ip}. There are now ".(count($clients) - 1)." clients.\n");
+ }
+ }
+ }
+
+ // remove the listening socket from the clients-with-data array
+ $key = array_search($main_sock, $read);
+ unset($read[$key]);
+ }
+
+ // loop through all the clients that have data to read from
+ foreach ($read as $read_sock) {
+ // Get client data
+ socket_getpeername($read_sock, $ip);
+
+ // read until newline or 1024 bytes
+ // socket_read while show errors when the client is disconnected, so silence the error messages
+ $data = @socket_read($read_sock, 1024, PHP_NORMAL_READ);
+
+ // check if the client is disconnected
+ if (($data === FALSE) || (in_array(strtolower(trim($data)), $leaving))) {
+
+ // remove client for $clients array
+ $key = array_search($read_sock, $clients);
+ unset($clients[$key]);
+ out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client from {$ip} disconnected. Left: ".(count($clients) - 1)."");
+
+ // Notify all chatter
+ if (count($clients) > 1) {
+ foreach ($clients as $send_sock) {
+ if ($send_sock != $main_sock) {
+ socket_write($send_sock, "Server: Chatter from {$ip} has logged out. ".(count($clients) - 1)." client(s) left.\n");
+ }
+ }
+ }
+
+ // continue to the next client to read from, if any
+ socket_write($read_sock, "Server: Good bye.\n");
+ socket_shutdown($read_sock, 2);
+ socket_close($read_sock);
+ continue;
+ } elseif (in_array(trim($data), $shutdown)) {
+ // Is he allowed to shutdown?
+ if (!in_array($ip, $masters)) {
+ out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} has tried to shutdown the server!");
+ socket_write($read_sock, "Server: You are not allowed to shutdown the server!\n");
+ $data = "";
+ continue;
+ }
+
+ // Close all connections a leave here
+ foreach ($clients as $client) {
+ // Send message to client
+ if ($client !== $main_sock && $client != $read_sock) {
+ socket_write($client, "Server: Shutting down! Thank you for joining us.\n");
+ }
+
+ // Quit him
+ socket_shutdown($client, 2);
+ socket_close($client);
+ } // end foreach
+
+ // Leave the loop
+ $data = "";
+ $clients = array();
+ continue;
+ }
+
+ // trim off the trailing/beginning white spaces
+ $data = trim($data);
+
+ // Test for HTML codes
+ $tags = strip_tags($data);
+
+ // check if there is any data after trimming off the spaces
+ if (!empty($data) && $tags == $data && count($clients) > 2) {
+ // Send confirmation to "chatter"
+ socket_write($read_sock, "\nServer: Message accepted.\n");
+
+ // send this to all the clients in the $clients array (except the first one, which is a listening socket)
+ foreach ($clients as $send_sock) {
+
+ // if its the listening sock or the client that we got the message from, go to the next one in the list
+ if ($send_sock == $main_sock || $send_sock == $read_sock)
+ continue;
+
+ // write the message to the client -- add a newline character to the end of the message
+ socket_write($send_sock, "{$ip}:{$data}\n");
+
+ } // end of broadcast foreach
+ } elseif ($tags != $data) {
+ // HTML codes are not allowed
+ out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} has entered HTML code!");
+ socket_write($read_sock, "Server: HTML is forbidden!\n");
+ } elseif ((count($clients) == 2) && ($read_sock != $main_sock)) {
+ // No one else will hear the "chatter"
+ out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} speaks with himself.");
+ socket_write($read_sock, "Server: No one will hear you!\n");
+ }
+ } // end of reading foreach
+}
+
+// close the listening socket
+socket_close($main_sock);
+
+?>
--- /dev/null
+# This is a configuration for generating a "code-swarm" video from the hub
+# project. If you like to create such video, please use the following commands
+# on Linux-based systems (or similars):
+#
+# # Change to 'trunk' and get a logfile
+# cd ../trunk/
+# svn log -v > ~/SVN/codeswarm/hub.log
+# # Copy this hub.config over there
+# cp ../contrib/hub.config ~/SVN/codeswarm/
+# # Change there and convert the logfile
+# cd ~/SVN/codewarm/
+# python ./convert_logs/convert_logs.py -s hub.log -o hub.xml
+# # Run codewarm (you may have to alter the Xmx value)
+# ./run.sh hub.config
+# # Now the frames are called hub-swarm-XXXXXX.png, e.g. use mencoder:
+# mencoder "mf://hub-swarm*.png" -mf fps=25 -o hub-codeswarm.avi -ovc lavc -lavcopts vcodec=mpeg4
+# # This will producea similar movie to mine
+
+# Frame width
+Width=800
+
+# Frame height
+Height=600
+
+# Input file
+InputFile=hub.xml
+
+# Particle sprite file
+ParticleSpriteFile=src/particle.png
+
+#Font Settings
+Font=SansSerif
+BoldFont=SansSerif
+InfoFont=SansSerif
+FontSize=10
+BoldFontSize=14
+InfoFontSize=20
+
+# Project time per frame
+MillisecondsPerFrame=21600000
+
+# Maximum number of Background processes
+MaxThreads=4
+
+# Optional Method instead of MillisecondsPerFrame
+FramesPerDay=10
+
+# Background in R,G,B
+Background=0,0,0
+
+# Color assignment rules
+# Keep in order, do not skip numbers. Numbers start
+# at 1.
+#
+# Pattern: "Label", "regex", R,G,B, R,G,B
+# Label is optional. If it is omitted, the regex
+# will be used.
+#
+ColorAssign1="Docs",".*txt", 0,0,255, 0,0,255
+ColorAssign2="PHP",".*php", 0,255,255, 0,255,255
+ColorAssign3="Template",".*tpl", 102,0,255, 102,0,255
+ColorAssign4="CSS",".*css", 255,0,0, 255,0,0
+ColorAssign5="JavaScript",".*js", 255,255,0, 255,255,0
+ColorAssign6="Shell",".*sh", 119,68,119, 119,68,119
+ColorAssign7="XML",".*xml", 136,51,17, 136,51,17
+ColorAssign8="Code",".*ctp", 250,110,110, 250,110,130
+#ColorAssign9="Code8",".*src8.*", 238,102,68, 238,102,68
+#ColorAssign10=".*src9.*", 238,68,119, 238,68,119
+
+# Save each frame to an image?
+TakeSnapshots=true
+
+# Where to save each frame
+SnapshotLocation=hub-swarm-######.png
+
+# Draw names (combinatory) :
+# Draw sharp names?
+DrawNamesSharp=true
+# And draw a glow around names? (Runs slower)
+DrawNamesHalos=true
+
+# Draw files (combinatory) :
+# Draw sharp files
+DrawFilesSharp=false
+# Draw fuzzy files
+DrawFilesFuzzy=true
+# Draw jelly files
+DrawFilesJelly=true
+
+# Show the Legend at start
+ShowLegend=true
+
+# Show the History at start
+ShowHistory=true
+
+# Show the Activity histogram at bottom
+ShowActivity=true
+
+# Show the Date at start
+ShowDate=true
+
+# Show edges between authors and files, mostly for debug purpose
+ShowEdges=false
+
+# Turn on Debug counts.
+ShowDebug=false
+
+# Natural distance of files to people
+EdgeLength=25
+
+# Amount of life to decrement
+EdgeDecrement=-2
+FileDecrement=-2
+PersonDecrement=-1
+
+#Speeds.
+#Optional: NodeSpeed=7.0, If used, FileSpeed and PersonSpeed need not be set.
+#
+FileSpeed=7.0
+PersonSpeed=2.0
+
+#Masses
+FileMass=1.0
+PersonMass=10.0
+
+# Life of an Edge
+EdgeLife=250
+
+# Life of a File
+FileLife=200
+
+# Life of a Person
+PersonLife=255
+
+# Highlight percent.
+# This is the amount of time that the person or
+# file will be highlighted.
+HighlightPct=5
+
+## Physics engine selection and configuration
+# Directory physics engine config files reside in.
+PhysicsEngineConfigDir=physics_engine
+# Force calculation algorithms ("PhysicsEngineLegacy", "PhysicsEngineSimple"...) :
+PhysicsEngineSelection=PhysicsEngineLegacy
+
+# OpenGL is experimental. Use at your own risk.
+UseOpenGL=false
--- /dev/null
+<?php
+error_reporting(0);
+set_time_limit(0);
+
+/*
+ * Note: I could use mhash_count() here but I like to see unavailable hashers
+ * because this is important to me to choose the most-available hasher(s) and
+ * those with the best speed/secure tradeoff.
+ */
+$hasher = array(
+ MHASH_ADLER32,
+ MHASH_CRC32,
+ MHASH_CRC32B,
+ MHASH_GOST,
+ MHASH_HAVAL128,
+ MHASH_HAVAL160,
+ MHASH_HAVAL192,
+ MHASH_HAVAL224,
+ MHASH_HAVAL256,
+ MHASH_MD2,
+ MHASH_MD4,
+ MHASH_MD5,
+ MHASH_RIPEMD128,
+ MHASH_RIPEMD256,
+ MHASH_RIPEMD320,
+ MHASH_SHA1,
+ MHASH_SHA192,
+ MHASH_SHA224,
+ MHASH_SHA256,
+ MHASH_SHA384,
+ MHASH_SHA512,
+ MHASH_SNEFRU128,
+ MHASH_SNEFRU256,
+ MHASH_TIGER,
+ MHASH_TIGER128,
+ MHASH_TIGER160,
+ MHASH_WHIRLPOOL
+);
+
+$timers = array();
+$count = 500 * 1000;
+
+print 'Iterating ' . $count . ' times over all ' . count($hasher) . ' mhash hashers ...' . "\r\n";
+
+foreach ($hasher as $hash) {
+ // Is this no number, the hasher is not available
+ if (!is_int($hash)) {
+ $timers[str_replace('MHASH_', '', $hash)] = '- unavailable -';
+ continue;
+ } // END - if
+
+ $time = microtime(true);
+ for ($idx = 0; $idx <= $count; $idx++) {
+ $dummy = bin2hex(mhash($hash, 'mhash-test-abc-123-foo-bar'));
+ } // END - for
+
+ $timers[mhash_get_hash_name($hash)] = (microtime(true) - $time);
+ print '.';
+} // END - foreach
+
+print "\r\n\r\n";
+asort($timers);
+
+print 'Result from mhash() benchmark (in seconds per hasher):' . "\r\n";
+print_r($timers) . "\n";
+
+?>
--- /dev/null
+#!/bin/sh
+
+echo "Please use core/contrib/patch_core.sh instead!"
--- /dev/null
+#!/bin/sh
+
+if ! test -e "index.php"; then
+ echo "$0: Please execute this script from root directory."
+ exit 1
+fi
+
+echo "$0: Searching for deprecated PHP scripts ..."
+LIST1=`find -type f -name "*.php" -size 24c -exec grep -H "@DEPRECATED" {} \;`
+
+LIST="${LIST1} ${LIST2}"
+
+if test "${LIST}" != " "; then
+ echo "${LIST}" | cut -d ":" -f 1 | xargs svn --force del
+ sh ./todo-builder.sh
+fi
--- /dev/null
+<?php
+error_reporting(E_ALL | E_STRICT);
+
+define('ROUNDS', 10);
+define('MAX_FAILURES', 3000);
+
+require('udp-inc.php');
+
+global $hasher;
+
+function validate ($data) {
+ global $hasher;
+
+ switch ($hasher) {
+ case 'md5':
+ return md5($data);
+ break;
+
+ case 'sha1':
+ return sha1($data);
+ break;
+
+ case 'crc32':
+ return crc32($data);
+ break;
+
+ default:
+ out(__FUNCTION__, __LINE__, "Unknown hasher: ${hasher}");
+ break;
+ }
+}
+
+function sendBye ($socket) {
+ $replied = FALSE;
+ while (!$replied) {
+ // Try to send BYE
+ stream_socket_sendto($socket, 'BYE');
+
+ // Wait for an answer
+ $read = trim(stream_socket_recvfrom($socket, 1500, 0, $peer));
+ if (!empty($read)) {
+ // Did send BYE as well?
+ if ($read == 'BYE') {
+ // Okay
+ $replied = true;
+ } // END - if
+ } // END - if
+
+ // Sleep a little
+ if (function_exists('time_nanosleep')) time_nanosleep(0, 500000);
+ } // END - while
+}
+
+$data = array();
+$cnt = 0;
+$invalid = 0;
+$failed = 0;
+
+$ip = '127.0.0.1';
+if (isset($_SERVER['argv'][1])) {
+ $ip = $_SERVER['argv'][1];
+}
+
+$socket = stream_socket_client("udp://${ip}:9060", $errno, $errstr);
+
+if ((!is_resource($socket)) || ($errno > 0)) {
+ out(__FILE__, __LINE__, "ERROR: $errno - $errstr");
+ exit;
+}
+
+if (!stream_set_blocking($socket, FALSE)) {
+ out(__FILE__, __LINE__, "ERROR: Cannot set non-blocking mode!");
+ exit;
+}
+
+out(__FILE__, __LINE__, "Negotiating with host ${ip} ...");
+while (!feof($socket)) {
+ //*DEBUG: */ out(__FILE__, __LINE__, "Sending ping...");
+ stream_socket_sendto($socket, 'PING');
+
+ //*DEBUG: */ out(__FILE__, __LINE__, "Reading reply...");
+ $read = trim(stream_socket_recvfrom($socket, 1500, 0, $peer));
+
+ if ($failed == constant('MAX_FAILURES')) {
+ //*DEBUG: */ out(__FILE__, __LINE__, "Too many failures! (failed={$failed})");
+ break;
+ } // END - if
+
+ // Is the peer the same?
+ if (empty($peer)) {
+ out(__FILE__, __LINE__, "Connection lost? read={$read} (".strlen($read).")");
+ $failed++;
+ continue;
+ } elseif ($peer != "$ip:9060") {
+ out(__FILE__, __LINE__, "Peer mismatch: {$ip}!={$peer}");
+ $failed++;
+ continue;
+ }
+
+ if (empty($read)) {
+ $failed++;
+ //*DEBUG: */ out(__FILE__, __LINE__, "Empty line received. Is the server there?");
+ continue;
+ } elseif ($read == 'INVALID') {
+ $failed++;
+ out(__FILE__, __LINE__, "Server has not accepted our message.");
+ continue;
+ } else {
+ $failed = 0;
+ //*DEBUG: */ out(__FILE__, __LINE__, "Response {$read} received.");
+ }
+
+ $rec = explode(':', $read);
+
+ if (count($rec) < 2) {
+ out(__FILE__, __LINE__, "Invalid packet {$read} received. count=".count($rec));
+ $invalid++;
+ continue;
+ } // END - if
+
+ $time = trim($rec[0]);
+ $right = explode('=', trim($rec[1]));
+ $hash = trim($right[1]);
+ $hasher = trim($right[0]);
+
+ if (validate($time) != $hash) {
+ out(__FILE__, __LINE__, "Invalid: ({$time}/{$hash}/{$hasher})");
+ $invalid++;
+ continue;
+ } // END - if
+
+ if (!isset($data[$rec[0]])) {
+ if (count($data) > 0) {
+ print $data[$rec[0]-1]."\n";
+ $cnt++;
+ if ($cnt > constant('ROUNDS')) break;
+ }
+ $data[$rec[0]] = 0;
+ }
+ $data[$rec[0]]++;
+
+ // Sleep a little
+ if (function_exists('time_nanosleep')) time_nanosleep(0, 500000);
+} // END - while
+
+array_shift($data);
+
+// Send BYE
+sendBye($socket);
+
+stream_socket_shutdown($socket, STREAM_SHUT_RDWR);
+
+$avg = 0;
+$min = 0;
+$max = 0;
+
+foreach ($data as $cnt) {
+ if ($cnt > $max) {
+ $max = $cnt;
+ }
+ if (($cnt < $min) || ($min == 0)) {
+ $min = $cnt;
+ }
+ $avg += $cnt;
+} // END - foreach
+
+if (count($data) > 0) {
+ $avg = round($avg / count($data));
+} // END - if
+
+out(__FILE__, __LINE__, 'MIN/AVG/MAX=' . $min . '/' . $avg . '/' . $max . '');
+out(__FILE__, __LINE__, 'INVALID=' . $invalid . '');
+out(__FILE__, __LINE__, 'FAILED=' . $failed . '');
+
+?>
--- /dev/null
+<?php
+$GLOBALS['last_message'] = '';
+
+function out ($file, $line, $message, $displayDouble = FALSE) {
+ if (($GLOBALS['last_message'] != $message) || ($displayDouble)) {
+ print(basename($file) . '[' . $line . ']: ' . $message . "\n");
+ $GLOBALS['last_message'] = $message;
+ }
+}
+
+?>
--- /dev/null
+<?php
+
+$connections = array();
+$first = -1;
+
+require('udp-inc.php');
+
+error_reporting(E_ALL | E_STRICT);
+
+out(__FILE__, __LINE__, 'Opening server port...');
+$socket = stream_socket_server('udp://0.0.0.0:9060', $errno, $errstr, STREAM_SERVER_BIND);
+
+if ((!is_resource($socket)) || ($errno > 0)) {
+ out(__FILE__, __LINE__, $errstr . ' (' . $errno . ')');
+ exit;
+}
+
+if (!stream_set_blocking($socket, FALSE)) {
+ out(__FILE__, __LINE__, 'ERROR: Cannot set non-blocking mode!');
+ exit;
+}
+
+$pkt = '';
+
+out(__FILE__, __LINE__, 'Waiting for connections...');
+
+do {
+ $pkt = trim(stream_socket_recvfrom($socket, 1500, 0, $peer));
+
+ if ($pkt == 'PING') {
+ // Peer in list?
+ if (!isset($connections[$peer])) {
+ out(__FILE__, __LINE__, 'New peer ' . $peer . ' detected.');
+ $connections[$peer] = 1;
+ } elseif ($connections[$peer] == 0) {
+ out(__FILE__, __LINE__, 'Peer ' . $peer . ' has returned.');
+ $connections[$peer] = 1;
+ }
+
+ //out(__FILE__, __LINE__, 'Sending data to peer ' . $peer . '.');
+ stream_socket_sendto($socket, (time() . ':md5=' . md5(time())), 0, $peer);
+ } elseif ($pkt == 'BYE') {
+ // Peer in list?
+ if (!isset($connections[$peer])) {
+ out(__FILE__, __LINE__, 'Peer ' . $peer . ' is NOT in peer list.');
+ } else {
+ out(__FILE__, __LINE__, 'Peer ' . $peer . ' is leaving us.');
+ stream_socket_sendto($socket, 'BYE', 0, $peer);
+ $connections[$peer] = 0;
+ }
+ } elseif (!empty($peer)) {
+ out(__FILE__, __LINE__, 'Invalid packet ' . $pkt . ' from peer ' . $peer . '.');
+ stream_socket_sendto($socket, 'INVALID', 0, $peer);
+ } else {
+ // Waiting for packages
+ $pkt = '';
+ }
+
+ $test = (round(date('s', time()) / 10));
+ if ($first != $test) {
+ out(__FILE__, __LINE__, count($connections) . ' total connections so far.', true);
+ $first = $test;
+ }
+
+ // Sleep a little
+ if (function_exists('time_nanosleep')) time_nanosleep(0, 500000);
+} while ($pkt !== FALSE);
+
+?>
+++ /dev/null
-<?php
-error_reporting(0);
-set_time_limit(0);
-
-/*
- * Note: I could use mhash_count() here but I like to see unavailable hashers
- * because this is important to me to choose the most-available hasher(s) and
- * those with the best speed/secure tradeoff.
- */
-$hasher = array(
- MHASH_ADLER32,
- MHASH_CRC32,
- MHASH_CRC32B,
- MHASH_GOST,
- MHASH_HAVAL128,
- MHASH_HAVAL160,
- MHASH_HAVAL192,
- MHASH_HAVAL224,
- MHASH_HAVAL256,
- MHASH_MD2,
- MHASH_MD4,
- MHASH_MD5,
- MHASH_RIPEMD128,
- MHASH_RIPEMD256,
- MHASH_RIPEMD320,
- MHASH_SHA1,
- MHASH_SHA192,
- MHASH_SHA224,
- MHASH_SHA256,
- MHASH_SHA384,
- MHASH_SHA512,
- MHASH_SNEFRU128,
- MHASH_SNEFRU256,
- MHASH_TIGER,
- MHASH_TIGER128,
- MHASH_TIGER160,
- MHASH_WHIRLPOOL
-);
-
-$timers = array();
-$count = 500 * 1000;
-
-print 'Iterating ' . $count . ' times over all ' . count($hasher) . ' mhash hashers ...' . "\r\n";
-
-foreach ($hasher as $hash) {
- // Is this no number, the hasher is not available
- if (!is_int($hash)) {
- $timers[str_replace('MHASH_', '', $hash)] = '- unavailable -';
- continue;
- } // END - if
-
- $time = microtime(true);
- for ($idx = 0; $idx <= $count; $idx++) {
- $dummy = bin2hex(mhash($hash, 'mhash-test-abc-123-foo-bar'));
- } // END - for
-
- $timers[mhash_get_hash_name($hash)] = (microtime(true) - $time);
- print '.';
-} // END - foreach
-
-print "\r\n\r\n";
-asort($timers);
-
-print 'Result from mhash() benchmark (in seconds per hasher):' . "\r\n";
-print_r($timers) . "\n";
-
-?>
+++ /dev/null
-#!/bin/sh
-
-echo "Please use core/contrib/patch_core.sh instead!"
+++ /dev/null
-#!/bin/sh
-
-if ! test -e "index.php"; then
- echo "$0: Please execute this script from root directory."
- exit 1
-fi
-
-echo "$0: Searching for deprecated PHP scripts ..."
-LIST1=`find -type f -name "*.php" -size 24c -exec grep -H "@DEPRECATED" {} \;`
-
-LIST="${LIST1} ${LIST2}"
-
-if test "${LIST}" != " "; then
- echo "${LIST}" | cut -d ":" -f 1 | xargs svn --force del
- sh ./todo-builder.sh
-fi
+++ /dev/null
-<?php
-error_reporting(E_ALL | E_STRICT);
-
-define('ROUNDS', 10);
-define('MAX_FAILURES', 3000);
-
-require('udp-inc.php');
-
-global $hasher;
-
-function validate ($data) {
- global $hasher;
-
- switch ($hasher) {
- case 'md5':
- return md5($data);
- break;
-
- case 'sha1':
- return sha1($data);
- break;
-
- case 'crc32':
- return crc32($data);
- break;
-
- default:
- out(__FUNCTION__, __LINE__, "Unknown hasher: ${hasher}");
- break;
- }
-}
-
-function sendBye ($socket) {
- $replied = FALSE;
- while (!$replied) {
- // Try to send BYE
- stream_socket_sendto($socket, 'BYE');
-
- // Wait for an answer
- $read = trim(stream_socket_recvfrom($socket, 1500, 0, $peer));
- if (!empty($read)) {
- // Did send BYE as well?
- if ($read == 'BYE') {
- // Okay
- $replied = true;
- } // END - if
- } // END - if
-
- // Sleep a little
- if (function_exists('time_nanosleep')) time_nanosleep(0, 500000);
- } // END - while
-}
-
-$data = array();
-$cnt = 0;
-$invalid = 0;
-$failed = 0;
-
-$ip = '127.0.0.1';
-if (isset($_SERVER['argv'][1])) {
- $ip = $_SERVER['argv'][1];
-}
-
-$socket = stream_socket_client("udp://${ip}:9060", $errno, $errstr);
-
-if ((!is_resource($socket)) || ($errno > 0)) {
- out(__FILE__, __LINE__, "ERROR: $errno - $errstr");
- exit;
-}
-
-if (!stream_set_blocking($socket, FALSE)) {
- out(__FILE__, __LINE__, "ERROR: Cannot set non-blocking mode!");
- exit;
-}
-
-out(__FILE__, __LINE__, "Negotiating with host ${ip} ...");
-while (!feof($socket)) {
- //*DEBUG: */ out(__FILE__, __LINE__, "Sending ping...");
- stream_socket_sendto($socket, 'PING');
-
- //*DEBUG: */ out(__FILE__, __LINE__, "Reading reply...");
- $read = trim(stream_socket_recvfrom($socket, 1500, 0, $peer));
-
- if ($failed == constant('MAX_FAILURES')) {
- //*DEBUG: */ out(__FILE__, __LINE__, "Too many failures! (failed={$failed})");
- break;
- } // END - if
-
- // Is the peer the same?
- if (empty($peer)) {
- out(__FILE__, __LINE__, "Connection lost? read={$read} (".strlen($read).")");
- $failed++;
- continue;
- } elseif ($peer != "$ip:9060") {
- out(__FILE__, __LINE__, "Peer mismatch: {$ip}!={$peer}");
- $failed++;
- continue;
- }
-
- if (empty($read)) {
- $failed++;
- //*DEBUG: */ out(__FILE__, __LINE__, "Empty line received. Is the server there?");
- continue;
- } elseif ($read == 'INVALID') {
- $failed++;
- out(__FILE__, __LINE__, "Server has not accepted our message.");
- continue;
- } else {
- $failed = 0;
- //*DEBUG: */ out(__FILE__, __LINE__, "Response {$read} received.");
- }
-
- $rec = explode(':', $read);
-
- if (count($rec) < 2) {
- out(__FILE__, __LINE__, "Invalid packet {$read} received. count=".count($rec));
- $invalid++;
- continue;
- } // END - if
-
- $time = trim($rec[0]);
- $right = explode('=', trim($rec[1]));
- $hash = trim($right[1]);
- $hasher = trim($right[0]);
-
- if (validate($time) != $hash) {
- out(__FILE__, __LINE__, "Invalid: ({$time}/{$hash}/{$hasher})");
- $invalid++;
- continue;
- } // END - if
-
- if (!isset($data[$rec[0]])) {
- if (count($data) > 0) {
- print $data[$rec[0]-1]."\n";
- $cnt++;
- if ($cnt > constant('ROUNDS')) break;
- }
- $data[$rec[0]] = 0;
- }
- $data[$rec[0]]++;
-
- // Sleep a little
- if (function_exists('time_nanosleep')) time_nanosleep(0, 500000);
-} // END - while
-
-array_shift($data);
-
-// Send BYE
-sendBye($socket);
-
-stream_socket_shutdown($socket, STREAM_SHUT_RDWR);
-
-$avg = 0;
-$min = 0;
-$max = 0;
-
-foreach ($data as $cnt) {
- if ($cnt > $max) {
- $max = $cnt;
- }
- if (($cnt < $min) || ($min == 0)) {
- $min = $cnt;
- }
- $avg += $cnt;
-} // END - foreach
-
-if (count($data) > 0) {
- $avg = round($avg / count($data));
-} // END - if
-
-out(__FILE__, __LINE__, 'MIN/AVG/MAX=' . $min . '/' . $avg . '/' . $max . '');
-out(__FILE__, __LINE__, 'INVALID=' . $invalid . '');
-out(__FILE__, __LINE__, 'FAILED=' . $failed . '');
-
-?>
+++ /dev/null
-<?php
-$GLOBALS['last_message'] = '';
-
-function out ($file, $line, $message, $displayDouble = FALSE) {
- if (($GLOBALS['last_message'] != $message) || ($displayDouble)) {
- print(basename($file) . '[' . $line . ']: ' . $message . "\n");
- $GLOBALS['last_message'] = $message;
- }
-}
-
-?>
+++ /dev/null
-<?php
-
-$connections = array();
-$first = -1;
-
-require('udp-inc.php');
-
-error_reporting(E_ALL | E_STRICT);
-
-out(__FILE__, __LINE__, 'Opening server port...');
-$socket = stream_socket_server('udp://0.0.0.0:9060', $errno, $errstr, STREAM_SERVER_BIND);
-
-if ((!is_resource($socket)) || ($errno > 0)) {
- out(__FILE__, __LINE__, $errstr . ' (' . $errno . ')');
- exit;
-}
-
-if (!stream_set_blocking($socket, FALSE)) {
- out(__FILE__, __LINE__, 'ERROR: Cannot set non-blocking mode!');
- exit;
-}
-
-$pkt = '';
-
-out(__FILE__, __LINE__, 'Waiting for connections...');
-
-do {
- $pkt = trim(stream_socket_recvfrom($socket, 1500, 0, $peer));
-
- if ($pkt == 'PING') {
- // Peer in list?
- if (!isset($connections[$peer])) {
- out(__FILE__, __LINE__, 'New peer ' . $peer . ' detected.');
- $connections[$peer] = 1;
- } elseif ($connections[$peer] == 0) {
- out(__FILE__, __LINE__, 'Peer ' . $peer . ' has returned.');
- $connections[$peer] = 1;
- }
-
- //out(__FILE__, __LINE__, 'Sending data to peer ' . $peer . '.');
- stream_socket_sendto($socket, (time() . ':md5=' . md5(time())), 0, $peer);
- } elseif ($pkt == 'BYE') {
- // Peer in list?
- if (!isset($connections[$peer])) {
- out(__FILE__, __LINE__, 'Peer ' . $peer . ' is NOT in peer list.');
- } else {
- out(__FILE__, __LINE__, 'Peer ' . $peer . ' is leaving us.');
- stream_socket_sendto($socket, 'BYE', 0, $peer);
- $connections[$peer] = 0;
- }
- } elseif (!empty($peer)) {
- out(__FILE__, __LINE__, 'Invalid packet ' . $pkt . ' from peer ' . $peer . '.');
- stream_socket_sendto($socket, 'INVALID', 0, $peer);
- } else {
- // Waiting for packages
- $pkt = '';
- }
-
- $test = (round(date('s', time()) / 10));
- if ($first != $test) {
- out(__FILE__, __LINE__, count($connections) . ' total connections so far.', true);
- $first = $test;
- }
-
- // Sleep a little
- if (function_exists('time_nanosleep')) time_nanosleep(0, 500000);
-} while ($pkt !== FALSE);
-
-?>