initial commit
initial commit

file:b/PHPDc.php (new)
--- /dev/null
+++ b/PHPDc.php
@@ -1,1 +1,69 @@
+<?php

+

+//=============================//

+//                             //

+//   PHPDc v0.2                //

+//   PHPDc Manual Bot          //

+//   PHPDc.php                 //

+//   by [RO]VeNoM              //

+//   razvan_stanga@yahoo.com   //

+//                             //

+//       MADE IN ROMANIA       //

+//                             //

+//=============================//

+

+error_reporting  (E_ERROR | E_WARNING | E_PARSE);

+

+@set_time_limit(0);

+

+//---------------

+// Include Config

+//---------------

+

+require ("includes/PHPDc.Config.php");

+

+//----------------

+// Check User/Pass

+//----------------

+

+if ( (!isset($PHP_AUTH_USER)) || !(($PHP_AUTH_USER == $config['admin_user']) && ($PHP_AUTH_PW == $config['admin_password'])) ) {

+		header("WWW-Authenticate: Basic entrer=\"Form2txt admin\"");

+		header("HTTP/1.0 401 Unauthorized");

+		exit;

+}

+

+//--------------------

+// Include PHPDc Class

+//--------------------

+

+require ("includes/PHPDc.Class.php");

+

+foreach ($hub as $k => $v) {

+

+//------------

+// Start PHPDc

+//------------

+

+$PHPDc = new PHPDc;

+

+$config['hub'] = $v['hub'];

+$config['port'] = $v['port'];

+$config['name'] = $v['name'];

+$config['desc'] = $v['desc'];

+$config['template'] = $v['template'];

+$config['time'] = time ();

+

+$PHPDc->config = $config;

+

+$PHPDc->hub = $hub;

+

+$PHPDc->debuglog ('----- '.date("Y-m-d H:i:s").' -----');

+

+$PHPDc->connect($config['hub'], $config['port']);

+

+$PHPDc->listen ();

+

+}

+

+?>

 

file:b/PHPDc_Cron.php (new)
--- /dev/null
+++ b/PHPDc_Cron.php
@@ -1,1 +1,94 @@
+<?

+

+//=============================//

+//                             //

+//   PHPDc v0.2                //

+//   PHPDc Cron Job Bot        //

+//   PHPDc_Cron.php            //

+//   by [RO]VeNoM              //

+//   razvan_stanga@yahoo.com   //

+//                             //

+//       MADE IN ROMANIA       //

+//                             //

+//=============================//

+

+error_reporting  (E_ERROR | E_WARNING | E_PARSE);

+

+@set_time_limit(0);

+

+//---------------

+// Include Config

+//---------------

+

+require ("includes/PHPDc.Config.php");

+

+//--------------------

+// Include PHPDC Class

+//--------------------

+

+require ("includes/PHPDc.Class.php");

+

+//-----------------------

+// Include Cron Job Class

+//-----------------------

+

+require ("includes/PHPDc.Cron.php");

+

+//----------------

+// Start PHPDcCron

+//----------------

+

+$PHPDcCron = new PHPDcCron;

+

+//-----------------

+// Start Time Cache

+//-----------------

+

+$time_cache = array ();

+

+require ("html/time_cache.php");

+

+$dowrite = 0;

+

+$time_temp = time ();

+

+if ( $time_cache[ $config['cronjob'] ] <= $time_temp ) {

+$time_cache[ $config['cronjob'] ] = $time_temp + $config['cronjob'];

+

+// Writing new time

+

+$PHPDcCron->do_write ($time_cache);

+

+foreach ($hub as $k => $v) {

+

+//------------

+// Start PHPDc

+//------------

+

+$PHPDc = new PHPDc;

+

+$config['hub'] = $v['hub'];

+$config['port'] = $v['port'];

+$config['name'] = $v['name'];

+$config['desc'] = $v['desc'];

+$config['template'] = $v['template'];

+$config['time'] = time ();

+

+$PHPDc->config = $config;

+

+$PHPDc->hub = $hub;

+

+$PHPDc->debuglog ('----- '.date("Y-m-d H:i:s").' -----');

+

+$PHPDc->connect($config['hub'], $config['port']);

+

+$PHPDc->listen ();

+

+}

+

+}

+

+// End Cache

+

+?>

 

--- /dev/null
+++ b/html/time_cache.php
@@ -1,1 +1,3 @@
-
+<?

+$time_cache['900']	=	'1066059889';

+?>

--- /dev/null
+++ b/includes/PHPDc.Class.php
@@ -1,1 +1,872 @@
+<?php

+

+//=============================//

+//                             //

+//   PHPDc v0.2                //

+//   PHPDc Class file          //

+//   PHPDc.Class.php           //

+//   by [RO]VeNoM              //

+//   razvan_stanga@yahoo.com   //

+//                             //

+//       MADE IN ROMANIA       //

+//                             //

+//=============================//

+

+class PHPDc {

+

+    var $socket;

+    var $usesockets;

+    var $config;

+    var $hub;

+    var $state = FALSE;

+    var $nrconnect = 1;

+    var $userdata = array ();

+    var $sendstats = array ();

+    var $statsfiles = array ();

+    var $ftp_conn;

+

+//-------------------------------

+// Connect to a given host / port

+//-------------------------------

+

+function connect ($host, $port) {

+

+  $address = gethostbyname($host);

+

+			if(array_search('sockets',get_loaded_extensions()) !== FALSE) {

+			

+			    $this->debuglog ("NR Connect : ".$this->nrconnect, "\r\n");

+			    $this->debuglog ("WARNING: your PHP build supports real sockets.");			

+				$this->usesockets = 1;

+				$this->nrconnect++;

+				

+                $this->socket = socket_create(AF_INET, SOCK_STREAM, 0);

+                

+                if (!$this->socket) {

+

+                  $this->debuglog ('Failed to create socket '.$adress);

+			      $this->debuglog ('Error : '. socket_strerror(socket_last_error()) );

+			      $this->debuglog ('Error NR : '. socket_last_error() );

+			      

+                }

+

+                if (!socket_connect($this->socket, $address, $port)) {

+

+                  $this->debuglog ('Failed to connect to '.$adress);

+			      $this->debuglog ('Error : '. socket_strerror(socket_last_error()) );

+			      $this->debuglog ('Error NR : '. socket_last_error() );

+			      

+                }

+                /*

+                if (!socket_set_nonblock ($this->socket)) {

+

+                  $this->debuglog ('Sockets are blocked');

+			      $this->debuglog ('Error : '. socket_strerror(socket_last_error()) );

+			      $this->debuglog ('Error NR : '. socket_last_error() );

+                }

+                */

+                  $this->debuglog ('Succesfully connected to '. $host .' ('.$address.'), port '.$port);

+                

+	            } else {

+			

+			      $this->debuglog ("NR Connect : ".$this->nrconnect, "\r\n");

+				  $this->debuglog ("WARNING: your PHP build doesn't support real sockets.");				

+				  $this->usesockets = 0;

+				  $this->nrconnect++;

+				

+                if (!$this->socket = @pfsockopen ($address , $port, $errno, $errstr, 30)) {

+

+                  $this->debuglog ('Failed to create socket'. $errno .', '. $errstr);

+                

+                }

+

+                if (!socket_set_blocking ($this->socket, FALSE)) {

+

+                  $this->debuglog ('Socket Stream is blocked');

+                

+                }

+                

+                  //socket_set_timeout ($this->socket, 5);

+                  $this->debuglog ('Succesfully connected to '. $host .' ('.$address.'), port '.$port);

+			    }

+}

+

+

+//-------------

+// Close socket

+//-------------

+

+function close () {

+

+  if ($this->usesockets == 1)       { socket_close($this->socket); }

+  else { fclose ($this->socket); }

+

+}

+

+

+//-------

+// Listen

+//-------

+

+function listen() {

+

+	if($this->state() == TRUE) {

+	  $this->receive();

+	  return TRUE;

+	} else {

+		return FALSE;

+	}

+}

+	

+

+//-------------

+// Recieve data

+//-------------

+

+function receive () {

+

+while($this->state() == TRUE) {

+

+  if ($this->config['time'] + $this->config['timetostay'] <= time() ) {

+

+   $this->do_stats ();

+   $this->send_data ();

+   

+   $this->debuglog ('### Done STATS for '. $this->config['hub']);

+   

+   $this->close ();

+   $this->debuglog ("Disconnected from ".$this->config['hub']);

+   

+   break;

+

+  }

+                

+  usleep ($this->config['receivesleep']);

+  

+  if ($this->usesockets == 1)  {

+

+  if (str_replace( ".", "", phpversion () ) >= 430 ) {

+    $r = array($this->socket);

+    socket_select($r, $w, $except = NULL, 1);

+  }

+

+    if ($_DATA = @socket_read ($this->socket, 1024)) {

+        

+			flush ();

+			$buffer .= $_DATA;	

+			

+			if (substr($buffer,-1) == "|") {

+				$this->do_stuff($buffer);

+				$buffer = "";

+			}

+			

+			if (strlen($buffer) > (50*1024)) {

+				$buffer = "";

+			}

+

+    } else {

+

+	  $this->debuglog ('Error : '. socket_strerror(socket_last_error()) );

+	  $this->debuglog ('Error NR : '. socket_last_error() );

+

+      $this->send('$Quit '.$this->config['nick'].'');

+

+      $this->close();

+

+      sleep($this->config['reconnect_after']);

+

+      $this->connect($this->config['hub'], $this->config['port']);

+

+    }

+

+  } else {

+

+    if ($_DATA = @fgets ($this->socket, 1024)) {

+        

+			flush();

+			$buffer .= $_DATA;	

+			

+			if (substr($buffer,-1) == "|") {

+				$this->do_stuff($buffer);

+				$buffer = "";

+			}

+			

+			if (strlen($buffer) > (50*1024)) {

+				$buffer = "";

+			}

+

+    } else {

+

+      $this->send('$Quit '.$this->config['nick'].'');

+

+      $this->close();

+

+      sleep($this->config['reconnect_after']);

+

+      $this->connect($this->config['hub'], $this->config['port']);

+

+    }

+

+  }

+  

+}

+  

+}

+

+

+//--------------------

+// Send data to socket

+//--------------------

+

+function send ($str) {

+

+  //$str = trim($str);

+  //if ($str{strlen ($str)-1} != "|") {$str .= "|";}

+

+  $str .= "|";

+  usleep($this->config['sendsleep']);

+  if ($this->usesockets == 1) {

+      $res = @socket_write($this->socket, $str, strlen($str));

+      if (!$res) {$this->debuglog ("CAN'T SEND : ". $str);}

+      } else {

+          $res = @fwrite($this->socket, $str, strlen($str));

+          if (!$res) {$this->debuglog ("CAN'T SEND : ". $str);}

+          }

+          

+  $this->debuglog ('SEND : '.$str);

+

+}

+

+

+//---------

+// Do Stuff

+//---------

+

+function do_stuff ($buffer) {

+

+		$_CMDLIST=explode("|",$buffer);

+		while (list($_tmpstr,$_COMMAND)=each($_CMDLIST)) {

+			$_CMD = $_COMMAND;

+			if (!$_CMD) {continue;}

+

+			$_PARAMSLIST=array();

+			$_PARAMS="";

+			

+			$this->debuglog("RECEIVE : " . $_CMD . "");

+			

+			$_tmpArr=explode(" ",$_CMD);

+			$_CMD=trim(strtoupper($_tmpArr[0]));

+			array_shift($_tmpArr);

+			$_PARAMS=trim(implode(" ",$_tmpArr));

+			

+			if ($_CMD{0} == "<") {

+				

+			} else {

+				$_tmpArr=explode("$",$_CMD);

+				array_shift($_tmpArr);

+				$_CMD=trim(implode(" ",$_tmpArr));

+

+				switch($_CMD) {

+					case "LOCK":

+						$this->send ("\$Key ".$this->lock2key ($_PARAMS)."");

+						$this->send ("\$ValidateNick {$this->config['nick']}");

+						break;

+					case "HUBNAME":

+						//$this->send ("\$ValidateNick {$this->config['nick']}");

+						break;

+					case "GETPASS":

+						$this->send ("\$MyPass {$this->config['password']}");

+						break;

+					case "BADPASS":

+						$this->debuglog ("LOGIN FAILED! (User {$this->config['nick']} - Pass {$this->config['password']})");

+						$this->send ("\$Quit {$this->config['nick']}");

+						break;

+					case "LOGEDIN":

+						$this->debuglog ("LOGIN SUCCESSFUL! (User {$this->config['nick']} - Pass {$this->config['password']})");

+						break;

+					case "HELLO":

+						if ($_PARAMS == $this->config['nick']) {			

+							$this->send ("\$Version {$this->config['version']}");

+							$this->send ("\$GetNickList");

+							$this->send ("\$MyINFO \$ALL {$this->config['nick']} {$this->config['description']}$ \${$this->config['speed']}\${$this->config['email']}\${$this->config['sharesize']}$");

+						}

+						break;

+					case "NICKLIST":

+						$_NICKLIST=explode("$$",$_PARAMS);

+						while (list ($_tmpstr,$nickname) = each($_NICKLIST)) {

+							if (!$nickname) {continue;}

+							if ($nickname == $this->config['nick']) {continue;}

+							$this->$userdata[$nickname] = array ();

+							$this->$userdata[$nickname]['nick'] = $nickname;

+							$this->send ("\$GetINFO {$nickname} {$this->config['nick']}");

+						}

+						break;

+					Case "OPLIST":

+						$_OPLIST=explode("$$",$_PARAMS);

+						while (list ($_tmpstr,$nickname) = each($_OPLIST)) {

+							$this->$userdata[$nickname]['IsOp'] = 1;

+						}

+						break;

+					Case "MYINFO":					

+						if (preg_match("/\\\$ALL ([^ \$\|]+) (.*)\\\$ \\\$(.+).\\\$(.+)\\\$(.+)\\\$/i",$_PARAMS,$tmpARR)){

+						$this->userdata[$tmpARR[1]]['description'] = $tmpARR[2];

+						$this->userdata[$tmpARR[1]]['speed'] = $tmpARR[3];

+						$this->userdata[$tmpARR[1]]['email'] = $tmpARR[4];

+						$this->userdata[$tmpARR[1]]['sharesize'] = $tmpARR[5];

+						$this->debuglog("User Data : ".$tmpARR[1]."|".$tmpARR[2]."|".$tmpARR[3]."|".$tmpARR[4]."|".$tmpARR[5]);

+						}

+						$tmpARR = array ();

+						if (preg_match("/\\\$ALL ([^ \$\|]+) (.*)\\\$ \\\$(.+).\\\$\\\$(.+)\\\$/i",$_PARAMS,$tmpARR)){

+						$this->userdata[$tmpARR[1]]['description'] = $tmpARR[2];

+						$this->userdata[$tmpARR[1]]['speed'] = $tmpARR[3];

+						$this->userdata[$tmpARR[1]]['sharesize'] = $tmpARR[4];

+						$this->debuglog("User Data : ".$tmpARR[1]."|".$tmpARR[2]."|".$tmpARR[3]."||".$tmpARR[4]);

+						}						

+						break;

+					Case "QUIT":

+						

+						break;

+					Case "SEARCH":

+						preg_match("/(.+):(.+) (.)\?(.)\?([0-9]+)\?(.)\?(.*)/i",$_PARAMS,$tmpARR);

+						$tmpARR[7]=str_replace("$"," ",$tmpARR[7]);

+						break;

+					case "SR":

+						break;

+					case "FORCEMOVE":

+						$this->debuglog("REDIRECTING NOT SUPPORTED! DISCONNECTING!");

+						$this->close ();

+					case "TO:":

+						

+						break;

+					default:

+						$this->debuglog("Unknown CMD " . $_CMD . "");

+						break;

+				}

+			}			

+		}

+}

+

+	

+//------

+// State

+//------

+

+function state (){

+

+  $result = $this->updatestate();

+		

+    if($result == TRUE) {

+        return TRUE;

+    }

+    else {

+        return FALSE;

+    }

+}

+

+

+//-------------

+// Update State

+//-------------

+

+function updatestate() {

+

+  $type = get_resource_type($this->socket);

+

+    if( is_resource ($this->socket) && $this->socket !== FALSE && ( $type == 'socket' || $type == 'Socket' || $type == 'stream' || $type == 'Stream') ) {

+      $this->state = TRUE;

+		return TRUE;

+    } else {

+      $this->state = FALSE;

+		return FALSE;

+    }

+

+}

+

+

+//----------

+// Debug Log

+//----------

+

+function debuglog ($stuff, $f='') {

+

+  if ($this->config['debug']) {

+    $this->writetolog ($f.$stuff."\r\n");

+    flush ();

+    echo $stuff."<br>";

+  }

+

+}

+

+

+//--------------

+// Write to file

+//--------------

+

+function writetolog ($data) {

+

+  if ($data!="") {

+

+    $filenum=fopen("logs/".$this->config['log']."","a");

+

+    fwrite($filenum,$data);

+

+    fclose($filenum);

+

+  }

+

+}

+

+

+//------------

+// Decode Lock

+//------------

+

+function lock2key($_LOCK) {

+

+   $this->debuglog ('Lock & Pk : '.$_LOCK);

+

+   $pk = stristr ($_LOCK, 'Pk=');

+   $this->debuglog ('Pk : '.$pk);

+

+   $_LOCK = str_replace ($pk, '', $_LOCK);

+

+   $_LOCK = substr ($_LOCK, 0, -1);

+   $this->debuglog ('Lock : '.$_LOCK);

+

+   $lockLength = strlen ($_LOCK);

+

+   $h = ord($_LOCK{0}) ^ ord( $_LOCK{ $lockLength - 1} ) ^ ord( $_LOCK{ $lockLength - 2} ) ^ 5;

+

+   //echo $h . "<br>";

+

+    while ($h > 255) {$h = $h - 256;}

+

+    $h = (($h<<4) & 240) | (($h>>4) & 15);

+

+	$a = $h;

+	

+	if ($a == '126' or // '~'

+	    $a == '124' or // '|'

+	    $a == '96' or  // '`'

+	    $a == '36' or  // '$'

+	    $a == '5' or   // '^E'

+	    $a == '0')     // NUL

+	{

+	  $LockToKey = "/%DCN";

+

+	  if ($a < 100)

+	    $LockToKey .="0";

+	  if ($a < 10)

+	    $LockToKey .="0";

+      $LockToKey .= $a; // As a string integer

+	  $LockToKey .= "%/";	

+	} else {

+	  $LockToKey = chr ($a);  // No transformation.

+	}

+

+   for ($j = 1; $j < strlen($_LOCK); $j++) {

+      $h = ord($_LOCK{$j}) ^ ord($_LOCK{$j-1});

+

+   while ($h > 255) {$h = $h - 256;}

+

+      $h = (($h<<4) & 240) | (($h>>4) & 15);

+

+      //echo $j . " - " . ($h*16) . "<br>";

+

+	  $a = $h;

+	

+	if ($a == '126' or // '~'

+	    $a == '124' or // '|'

+	    $a == '96' or  // '`'

+	    $a == '36' or  // '$'

+	    $a == '5' or   // '^E'

+	    $a == '0')     // NUL

+	{

+	  $LockToKey .= "/%DCN";

+

+	  if ($a < 100)

+	    $LockToKey .="0";

+	  if ($a < 10)

+	    $LockToKey .="0";

+      $LockToKey .= $a; // As a string integer

+	  $LockToKey .= "%/";	

+	} else {

+	  $LockToKey .= chr ($a);  // No transformation.

+	}

+   }

+

+   return $LockToKey;

+}

+

+//--------------------------------------

+// Start Lode, Pharse -> Template

+//--------------------------------------

+

+function lode_template ($t="") {

+

+    $file = "templates/".$t.".tpl";

+	

+	if ( file_exists($file) )

+	{

+		if ( $T = fopen($file, 'r') )

+		{

+			$template = fread( $T, filesize($file) );

+			fclose($T);

+		}

+		else

+		{

+			$this->debuglog ("Can't open template");

+		}

+	}

+	else

+	{

+		$this->debuglog ("Template doesn't exist");

+	}

+	

+	return $template;

+

+}

+

+function pharse_template( $template, $assigned=array() )

+{

+	

+	foreach( $assigned as $word => $replace)

+	{

+		$template = preg_replace( "/\{$word\}/i", "$replace", $template );

+	}

+	

+	return $template;

+}

+

+

+//-------------------

+// Start Write 2 File

+//-------------------

+

+function writetofile ($path,$data,$backup=0) {

+

+  if (file_exists($path)!=0) {

+    if ($backup==1) {

+      $filenamenew=$path."venom";

+

+      rename ($path,$filenamenew);

+    } else {

+      unlink($path);

+    }

+  }

+

+  if ($data!="") {

+

+    $filenum=fopen($path,"w");

+

+    fwrite($filenum,$data);

+

+    fclose($filenum);

+

+  }

+

+}

+

+

+//-----

+// Size

+//-----

+

+function Size($size) {

+    $mb = 1024*1024;

+    $gb = 1024*1024*1024;

+    $tb = 1024*1024*1024*1024;

+    if ( $size >= $tb ) {

+        $mysize = sprintf ("%01.2f",$size/$tb) . " TB";

+    } elseif ( $size >= $gb ) {

+        $mysize = sprintf ("%01.2f",$size/$gb) . " GB";

+    } elseif ( $size >= $mb ) {

+        $mysize = sprintf ("%01.2f",$size/$mb) . " MB";

+    } elseif ( $size >= 1024 ) {

+        $mysize = sprintf ("%01.2f",$size/1024) . " Kb";

+    } else {

+        $mysize = $size . " bytes";

+    }

+    return $mysize;

+}

+

+

+//------

+// Pages

+//------

+

+function page ($total_raw, $link, $offset, $pagina, $show = 1) {

+	

+	$pagenavpages = $this->config['navpages'];

+

+	if ($total_raw <= $offset) {

+		return "";

+	}

+	

+	if ($show == 1) {

+	$minim = ($pagina - 1) * $offset + 1;

+	$maxim = $minim + $offset - 1;

+	if ($total_raw <= $maxim) {$maxim = $total_raw;}

+	$showing = "Showing $minim - $maxim ($total_raw) |";} else {$showing = "";}

+

+	$totalpages = ceil($total_raw/$offset);

+

+	if ($pagina>1) {

+		$prevpage = $pagina-1;

+		$prevlink = "<a href=\"$link$prevpage.html\" title=\"Previous Page\">&laquo;</a>\r\n";

+	}

+	if ($pagina<$totalpages) {

+		$nextpage = $pagina+1;	

+		$nextlink = "<a href=\"$link$nextpage.html\" title=\"Next Page\">&raquo;</a>\r\n";		

+	}

+	while ($curpage++<$totalpages) {

+		if ( ( $curpage <= $pagina-$pagenavpages || $curpage >= $pagina+$pagenavpages ) && $pagenavpages!=0 ) {

+			if ($curpage==1) {

+				$firstlink = "<a href=\"$link$curpage.html\" title=\"First Page\">&laquo; First</a> ...\r\n";				

+			}

+		    if ($curpage==$totalpages) {

+		        $lastlink = "... <a href=\"$link$curpage.html\" title=\"Last Page\">Last &raquo;</a>\r\n";				

+			}

+		} else {

+			if ($curpage==$pagina) {

+				$pagenav .= "<font size=\"2\">[$curpage]</font>\r\n";			

+			} else {

+				$pagenav .= "<a href=\"$link$curpage.html\">$curpage</a>\r\n";

+			}

+		}

+	}

+	$pagenav = "<br><br>\r\nPages: $totalpages | $showing\r\n<b>\r\n$firstlink$prevlink$pagenav$nextlink$lastlink</b>\r\n";

+

+	return $pagenav;

+

+}

+

+

+//----------

+// Anti Spam

+//----------

+

+function AntiSpam ($email="", $name=""){

+

+    if ($email != "") {

+

+        for ( $i=0; $i < strlen ( $email ); $i++ ) {

+

+          $A .= "&#". ord( substr($email, $i) ) .";";

+

+         }

+    

+    }

+             

+    if ($name != "") {

+

+         for ( $i=0; $i < strlen ( $name ); $i++ ) {

+

+          $B .= "&#". ord( substr($name, $i) ) .";";

+

+         }

+    }

+    

+    if ($B != "" and $A == "") {return "none";}

+    

+    if ($B == "" and $A != "") {$B = $A;}

+    

+    if ($B == "" and $A == "") {return "none";}

+             

+    return "<SCRIPT LANGUAGE=\"JavaScript\">\r\ndocument.write('<a href=\"' + 'mailto:' + '".$A."' + '\">' + '".$B."' + '</a>');\r\n</script>";

+

+

+}

+

+

+//-----------

+// FTP Upload

+//-----------

+

+function ftp_start () {

+

+    $this->ftp_conn = ftp_connect ($this->config['ftp_server'], $this->config['ftp_port']);

+    $login_result = ftp_login($this->ftp_conn, $this->config['ftp_user'], $this->config['ftp_pass']);

+    

+}

+

+function ftp_upload ($filename, $filesource) {

+

+    $upload = ftp_put ($this->ftp_conn, $filename, $filesource, FTP_BINARY);

+    

+}

+

+function ftp_end () {

+

+    ftp_quit ($this->ftp_conn);

+        

+}

+

+

+//---------------

+// Make The Stats

+//---------------

+

+function do_stats () {

+

+                $tpl = $this->lode_template ($this->config['template']);

+                $tpl_user = $this->lode_template ($this->config['template']."-user");

+                $tpl_index = $this->lode_template ("index");

+                $tpl_counter = $this->lode_template ("counter");

+

+                $users = count ($this->userdata);

+

+                ksort ($this->userdata);

+

+                $j = 1;

+                $i = 1;

+                $x = 1;

+                $templates = array ();

+                $content = "";

+                $select = "";

+

+                $select .= "<option value=\"#\">Select Hub</option>\r\n";

+

+                foreach ($this->hub as $hub) {

+                  $select .= "<option value=\"{site_url}html/".$hub['hub']."/1.html\">".$hub['name']."</option>\r\n";

+                }

+

+                $rpli = array (

+                       "select" => $select,

+                       "counter" => $tpl_counter,

+                       "phpdc_author" => $this->AntiSpam($this->config['author_email'], $this->config['author_name']),

+                       "phpdc_version" => $this->config['version'],

+                       "site_url" => $this->config['site_url'],

+                );

+

+                $tpl_index = $this->pharse_template ($tpl_index, $rpli);

+

+                $this->writetofile ("html/index.html", $tpl_index);

+

+                foreach ($this->userdata as $k => $v) {

+

+                $rpl = array (

+                       "nick" => $k,

+                       "description" => $v[description],

+                       "speed" => $v[speed],

+                       "email" => $this->AntiSpam($v[email], $k),

+                       "sharesize" => $this->Size ($v[sharesize]),

+                );

+

+                  $content .= $this->pharse_template ($tpl_user, $rpl);

+                  $share += $v[sharesize];

+

+                if ($j >= $this->config['onpage'] or $x >= $users) {

+

+                $rplt = array (

+                       "content" => $content,

+                       "counter" => $tpl_counter,

+                       "users" => $users,

+                       "select" => $select,

+                       "hub" => $this->config['hub'],

+                       "port" => $this->config['port'],

+                       "name" => $this->config['name'],

+                       "desc" => $this->config['desc'],

+                       "phpdc_author" => $this->AntiSpam($this->config['author_email'], $this->config['author_name']),

+                       "phpdc_version" => "<a href=\"http://www.computergames.ro/venom/PHPDc/\">".$this->config['version']."</a>",

+                       "menu" => $this->page ($users ,"{site_url}html/".$this->config['hub']."/", $this->config['onpage'], $i, $this->config['pagedetalies']),

+                       "site_url" => $this->config['site_url'],

+                       "date" => date("d/m/Y H:i:s", $this->config['time']),

+                );

+

+                $templates[$i] = $this->pharse_template ($tpl, $rplt);

+

+                $i++; $j = 0; $content = "";

+

+                }

+                $j++;

+                $x++;

+                }

+                

+                $this->sendstats['share'] = $this->Size ($share);

+                $this->sendstats['hub'] = $this->config['hub'];

+                $this->sendstats['site_url'] = $this->config['site_url'];

+                $this->sendstats['users'] = $users;

+                

+                if ($this->config['ftp_active']) {

+                  

+                  $this->ftp_start ();

+                  $this->ftp_upload ("index.html", "html/index.html");

+                  ftp_chdir($this->ftp_conn, "html");

+                  $this->ftp_upload ("index.html", "html/index.html");

+                  ftp_chdir($this->ftp_conn, $this->config['hub']);

+                  

+                }

+

+                if (!is_dir ( "html/".$this->config['hub'] )) {mkdir ( "html/".$this->config['hub'] );}

+

+                foreach ($templates as $k => $v) {

+

+                  $r = array ("share" => $this->Size ($share),);

+                  $v = $this->pharse_template ($v, $r);

+

+                  $this->writetofile ("html/".$this->config['hub']."/".$k.".html", $v);

+                  

+                  $this->statsfiles[ $this->config['hub'] ] = $k;

+                 

+                    if ($this->config['ftp_active']) {

+                      $this->ftp_upload ($k.".html", "html/".$this->config['hub']."/".$k.".html");

+                    }

+

+                }

+

+                if ($this->config['ftp_active']) {

+                  $this->ftp_end ();

+                }

+

+}

+

+

+//--------------

+// Send To PHPDc

+//--------------

+

+function sendToPHPDc ($host,$method,$path,$data,$useragent=0) {

+	if (empty($method)) {

+	  $method = 'GET';

+	}

+	$method = strtoupper($method);

+	$fp = fsockopen($host,80);

+	if ($fp) {

+	if ($method == 'GET') {

+	  $path .= '?' . $data;

+	}

+	fputs($fp, "$method $path HTTP/1.0\r\n");

+	fputs($fp, "Host: $host\r\n");

+	fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");

+	fputs($fp, "Content-length: " . strlen($data) . "\r\n");

+	if ($useragent)

+		fputs($fp, "User-Agent: MSIE\r\n");

+	fputs($fp, "Connection: close\r\n\r\n");

+	if ($method == 'POST') {

+	  fputs($fp, $data);

+    }

+	while (!feof($fp))

+		$buf .= fgets($fp,1024);

+	fclose($fp);

+	}

+	return $buf;

+}

+

+function send_data () {

+

+ $host      = "www.computergames.ro";

+ $method    = "POST";

+ $path      = "/venom/PHPDc/data.php";

+ $data      = "share=".$this->sendstats['share']."&hub=".$this->sendstats['hub']."&site_url=".$this->sendstats['site_url']."&users=".$this->sendstats['users']."";

+ $useragent = 1;

+

+ $buffer = $this->sendToPHPDc ($host,$method,$path,$data,$useragent);

+ //$this->debuglog ("Data Sent to PHPDc Homepage : ".$buffer);

+

+}

+

+} // End Class

+

+?>

 

--- /dev/null
+++ b/includes/PHPDc.Config.php
@@ -1,1 +1,115 @@
+<?php

+

+//=============================//

+//                             //

+//   PHPDc v0.2                //

+//   PHPDc Config file         //

+//   PHPDc.Config.php          //

+//   by [RO]VeNoM              //

+//   razvan_stanga@yahoo.com   //

+//                             //

+//       MADE IN ROMANIA       //

+//                             //

+//=============================//

+

+$config = array ();

+$hub = array ();

+

+//====================//

+// EDITABLE VARIABLES //

+//====================//

+

+// Admin User/Password/Email

+

+$config['admin_user'] = "venom";

+$config['admin_password'] = "venom";

+$config['admin_email'] = "razvan_stanga@yahoo.com";

+

+// Hub(s), Port, Name & Description

+

+$hub['1']['hub'] = 'hub.wareznet.ro';

+$hub['1']['port'] = 411;

+$hub['1']['name'] = "Romania's #1 DC Hub";

+$hub['1']['desc'] = "dual pentrum 3, 512 MB RAM";

+$hub['1']['template'] = 'zap';

+

+// Bot User Data

+

+$config['nick'] = '[RO][B][TotalNet]VeNoMPHPDc';

+$config['description'] = 'PHPDC Stats by [RO]VeNoM';

+$config['email'] = 'venom@venom-is.yourtrap.com';

+$config['speed'] = 'Cable'.chr(1); // do not remove .chr(1)

+$config['sharesize'] = '75805505065';

+

+// FTP Stuff

+

+$config['ftp_active'] = 0;

+

+$config['ftp_server'] = "";

+$config['ftp_port'] = "21";

+$config['ftp_user'] = "";

+$config['ftp_pass'] = "";

+

+// When disconnected, Reconnect after (seconds)

+

+$config['reconnect_after'] = 3;

+

+// If debugger is set to 1, it will write a log in logs dir

+

+$config['debug'] = 1;

+

+// Site URL

+

+$config['site_url'] = 'http://www.hubstats.go.ro/'; // must end with /

+

+// Time to stay and collect info (seconds)

+

+$config['timetostay'] = 60;

+

+// Cron job time (seconds)

+

+$config['cronjob'] = 900;

+

+// Nicks / Users per page

+

+$config['onpage'] = 30;

+

+// Navigation Pages

+

+$config['navpages'] = 5;

+

+// Page Details

+

+$config['pagedetalies'] = 1;

+

+//========================//

+// NOT EDITABLE VARIABLES //

+//========================//

+

+// Author Details

+

+$config['author_name'] = "[RO]VeNoM";

+$config['author_email'] = "razvan_stanga@yahoo.com";

+

+// Log file name

+

+$config['log'] = 'debug-'.date("Y-m-d").'.log';

+

+// Time to seeep between sends (microseconds)

+

+$config['sendsleep'] = 10000;

+

+// Time to seeep between receives (microseconds)

+

+$config['receivesleep'] = 10000;

+

+// Start Time

+

+$config['time'] = time ();

+

+// PHPDc Version

+

+$config['version'] = 'PHPDc v0.2';

+

+?>

 

--- /dev/null
+++ b/includes/PHPDc.Cron.php
@@ -1,1 +1,70 @@
+<?php

+

+//=============================//

+//                             //

+//   PHPDc v0.2                //

+//   PHPDc Cron Job file       //

+//   PHPDc.Cron.php            //

+//   by [RO]VeNoM              //

+//   razvan_stanga@yahoo.com   //

+//                             //

+//       MADE IN ROMANIA       //

+//                             //

+//=============================//

+

+class PHPDcCron {

+

+//---------

+// Cron Job

+//---------

+

+function do_write ($time_cache) {

+    global $config;

+

+        ksort ($time_cache);

+

+		$file_data = "<?\r\n";

+		

+		foreach( $time_cache as $t => $c )

+		{

+			$file_data .= '$time_cache['."'".$t."'".']'."\t=\t'".$c."';\r\n";	

+		}

+		

+		$file_data .= "".'?'.'>';

+

+        $this->writetofile ("html/time_cache.php", $file_data);

+

+}

+

+//-------------------

+// Start Write 2 File

+//-------------------

+

+function writetofile ($path,$data,$backup=0) {

+

+  if (file_exists($path)!=0) {

+    if ($backup==1) {

+      $filenamenew=$path."venom";

+

+      rename ($path,$filenamenew);

+    } else {

+      unlink($path);

+    }

+  }

+

+  if ($data!="") {

+

+    $filenum=fopen($path,"w");

+

+    fwrite($filenum,$data);

+

+    fclose($filenum);

+

+  }

+

+}

+

+}

+

+?>

 

file:b/readme.txt (new)
--- /dev/null
+++ b/readme.txt
@@ -1,1 +1,90 @@
-
+//=============================//

+//                             //

+//   PHPDc v0.2                //

+//   by [RO]VeNoM              //

+//   razvan_stanga@yahoo.com   //

+//                             //

+//   Thanks to daniele_dll     //

+//   daniele_dll@yahoo.it      //

+//                             //

+//       MADE IN ROMANIA       //

+//                             //

+//=============================//

+

+Installation :

+

+Edit PHPDc.Config.php in includes directory.

+Set your HUB(s), ports ...

+

+-------------

+Template Tags

+-------------

+

+name.tpl

+

+{site_url} | will be replaced with the one in config

+{hub} | same

+{port} | same

+{users} | total online users

+{share} | total share

+{date} | cron job time

+{menu} | pages navigation menu

+{select} | select with the HUB(s) in config

+{counter} | replaced with the contents of counter.tpl

+Please do not remove them from the templates :

+{phpdc_version} | PHPDc version

+{phpdc_author} | PHPDc author, me :)

+

+name-user.tpl :

+

+{nick} | Nickname

+{sharesize} | Share Size

+{description} | Desc

+{speed} | Connection

+{email} | Email adress, don't worry, on the output pages it's spam protected.

+

+The best way to understand it's by editing the template zap.tpl and zap-user.tpl

+

+-------------

+Ftp Uploading

+-------------

+

+1. set the URL to the site where you uill be hosting the files.

+   Ex : www.hubstats.go.ro

+On this host you will have to create 2 directories, html and templates.

+-html   

+--hubadress1

+--hubadress2

+............

+-templates

+--images

+

+2. set the $config['ftp_active'] to 1.

+

+3. Edit the line from the template :

+<script language="PHP" src="{site_url}PHPDc_Cron.php"></script>

+{site_url} should be the URL where you generate your stats

+If you don't use FTP Uploading, then the {site_url} tag will be replaced by the $config['site_url'] and it should be OK.

+

+---------

+PHPDc.php

+---------

+

+This is a manual bot.

+If you would like to make the stats yourself, then you should acces the file, enter the user/pass and will be done.

+Also, remove <script language="PHP" src="{site_url}PHPDc_Cron.php"></script> from the templates and delete PHPDc_Cron.php

+

+----------------------

+Licence And Conditions

+----------------------

+

+PHPDc it's free for use, but you must accept the following conditions :

+

+The script reports back to me on each cron job the URL, DCHub, total online users, totalshare.

+This is done for stats and it will be shown on the PHPDc's webpage under "Who's using PHPDc".

+

+--------

+REMEMBER

+--------

+

+This is a test version, please test it and mail me feedback.

--- /dev/null
+++ b/templates/counter.tpl
@@ -1,1 +1,10 @@
-
+<!--WEBBOT bot="HTMLMarkup" startspan ALT="Site Meter" -->

+<script type="text/javascript" language="JavaScript">var site="sm9hubstats"</script>

+<script type="text/javascript" language="JavaScript1.2" src="http://sm9.sitemeter.com/js/counter.js?site=sm9hubstats">

+</script>

+<noscript>

+<a href="http://sm9.sitemeter.com/stats.asp?site=sm9hubstats" target="_top">

+<img src="http://sm9.sitemeter.com/meter.asp?site=sm9hubstats" alt="Site Meter" border=0></a>

+</noscript>

+<!-- Copyright (c)2002 Site Meter -->

+<!--WEBBOT bot="HTMLMarkup" Endspan -->

--- /dev/null
+++ b/templates/css/venom.css
@@ -1,1 +1,79 @@
+a {

+	color: #C1C1C1;

+	font-family: Verdana, Arial, Helvetica, sans-serif;

+	font-size: 8pt;

+	text-decoration: underline;

+}

+

+a:hover {

+	color: #FFFFFF;

+	font-family: Verdana, Arial, Helvetica, sans-serif;

+	font-size: 8pt;

+	text-decoration: none;

+}

+

+b {

+	color: #F26522;

+	font-family: Verdana, Arial, Helvetica, sans-serif;

+	font-size: 8pt;

+	text-decoration: none;

+}

+

+body {

+	color: #FFFFFF;

+	font-family: Verdana, Arial, Helvetica, sans-serif;

+	font-size: 8pt;

+	scrollbar-3dlight-color: #212121;

+	scrollbar-arrow-color: #F26522;

+	scrollbar-darkshadow-color: #212121;

+	scrollbar-face-color: #303030;

+	scrollbar-highlight-color: #C1C1C1;

+	scrollbar-shadow-color: #212121;

+	scrollbar-track-color: #6F6F6F;

+}

+

+input {

+	font-family: Verdana, Arial, Helvetica, sans-serif;

+	background: transparent;

+	border: 1px #C1C1C1 solid;

+	color: #FFFFFF;

+	font-size: 10px;

+}

+

+option {

+	background: transparent;

+	color: #FFFFFF;

+	font-family: Verdana, Arial, Helvetica, sans-serif;

+	font-size: 10px;

+}

+

+select {

+	background: #6F6F6F;

+	border: 1px;

+	color: #FFFFFF;

+	font-family: Verdana, Arial, Helvetica, sans-serif;

+	font-size: 10px;

+}

+

+strong {

+	color: #F26522;

+	font-family: Verdana, Arial, Helvetica, sans-serif;

+	font-size: 8pt;

+	text-decoration: none;

+}

+

+td {

+	color: #FFFFFF;

+	font-family: Verdana, Arial, Helvetica, sans-serif;

+	font-size: 8pt;

+	text-decoration: none;

+}

+

+textarea {

+	background: transparent;

+	border: 1px #C1C1C1 solid;

+	color: #FFFFFF;

+	font-family: Verdana, Arial, Helvetica, sans-serif;

+	font-size: 10px;

+}

 

 Binary files /dev/null and b/templates/images/1.jpg differ
 Binary files /dev/null and b/templates/images/bg1.gif differ
 Binary files /dev/null and b/templates/images/phpdc.gif differ
--- /dev/null
+++ b/templates/index.tpl
@@ -1,1 +1,52 @@
-
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

+<html>

+<head>

+<title>PHPDc by [RO]VeNoM</title>

+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

+<link href="{site_url}templates/css/venom.css" rel="stylesheet" type="text/css">

+<script language="PHP" src="{site_url}PHPDc_Cron.php"></script>

+</head>

+

+<body background="{site_url}templates/images/bg1.gif">

+<div align="center">

+  <table width="80%" border="0" cellspacing="0" cellpadding="0">

+    <tr> 

+      <td align="CENTER" valign="MIDDLE"> <table width="100%" border="0" cellspacing="0" cellpadding="0">

+          <tr align="center" valign="middle"> 

+            <td width="70%"><strong><font size="+1">PHPDc Features : </font></strong><br>

+              <table width="80%" border="0" cellspacing="0" cellpadding="0">

+                <tr>

+                  <td> &#8226; PHP Cron Job, you can set the interval<br>

+                    &#8226; Templates, you can make your own templates very easily<br>

+                    &#8226; Support for Multiple Hub's<br>

+                    &#8226; FTP Upload, you can set the bot to upload the created 

+                    files on another server<br>

+                    &#8226; Debugger, writes in a log file the RAW data sent or 

+                    received</td>

+                </tr>

+              </table> 

+            </td>

+            <td width="30%"><img src="{site_url}templates/images/phpdc.gif" width="160" height="120"><br>

+            </td>

+          </tr>

+        </table></td>

+    </tr>

+    <tr> 

+      <td align="center" valign="TOP"> 

+        <select onchange="window.location=(this.options[this.selectedIndex].value)">			  

+			 {select}

+			 </select>	  

+      </td>

+    </tr>

+  </table>

+  <br>

+  <br>

+  <!--Do not remove -->

+  Powered by {phpdc_version} <br>

+  Copyright &copy; 2003 {phpdc_author} 

+  <!--Do not remove -->

+  <br>

+  <br>

+  {counter}</div>

+</body>

+</html>

--- /dev/null
+++ b/templates/venom-user.tpl
@@ -1,1 +1,25 @@
-
+  <table width="80%" border="0" cellspacing="0" cellpadding="0">

+    <tr> 

+      <td width="30%" align="left" valign="MIDDLE"><strong>{nick}</strong></td>

+      <td width="70%" align="left" valign="MIDDLE"><table width="100%" border="0" cellspacing="2" cellpadding="0">

+          <tr>

+            <td width="30%">Shared</td>

+            <td width="70%">{sharesize}</td>

+          </tr>

+          <tr>

+            <td width="30%">Description</td>

+            <td width="70%">{description}</td>

+          </tr>

+          <tr>

+            <td width="30%">Connection</td>

+            <td width="70%">{speed}</td>

+          </tr>

+          <tr>

+            <td width="30%">Email</td>

+            <td width="70%">{email}</td>

+          </tr>

+        </table>

+      </td>

+    </tr>

+  </table>

+  <br>

--- /dev/null
+++ b/templates/venom.tpl
@@ -1,1 +1,56 @@
-
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

+<html>

+<head>

+<title>{hub} | {port}</title>

+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

+<link href="{site_url}templates/css/venom.css" rel="stylesheet" type="text/css">

+<script language="PHP" src="http://dictionar.allnet.ro/razvan/PHPDc/PHPDc_Cron.php"></script>

+</head>

+

+<body background="{site_url}templates/images/bg1.gif">

+<div align="center">

+  <table width="80%" border="0" cellspacing="0" cellpadding="0">

+    <tr>

+      <td align="center" valign="TOP">{menu}<br>

+        <br>

+      </td>

+    </tr>  

+    <tr> 

+      <td align="CENTER" valign="MIDDLE">

+<table width="100%" border="0" cellspacing="0" cellpadding="0">

+          <tr align="center" valign="middle"> 

+            <td width="70%"><strong><font size="+1">{name}</font><br>

+              {hub} | {port} | {users} users online | {share} total share</strong> 

+              <br>

+              Last refresh on {date}

+			  <br>

+              <br>

+             <select onchange="window.location=(this.options[this.selectedIndex].value)">			  

+			 {select}

+			 </select>			  

+			  </td>

+            <td width="30%"><img src="{site_url}templates/images/1.jpg" width="123" height="108"><br>

+              {desc} </td>

+          </tr>

+        </table></td>

+    </tr>

+    <tr> 

+      <td align="center" valign="TOP">{content}</td>

+    </tr>

+    <tr>

+      <td align="center" valign="TOP"><br>

+        <br>

+        {menu}</td>

+    </tr>

+  </table>

+  <br>

+  <br>

+  <!--Do not remove -->

+  Powered by {phpdc_version} <br>

+  Copyright &copy; 2003 {phpdc_author} 

+  <!--Do not remove -->

+  <br>

+  <br>

+  {counter}</div>

+</body>

+</html>

--- /dev/null
+++ b/templates/zap-user.tpl
@@ -1,1 +1,7 @@
-
+  <tr onMouseOver="hiLight(this,'#000000')" onMouseOut="hiLight(this,'transparent')"> 

+    <td width="20%"><strong>{nick}</strong></td>

+    <td width="10%">{sharesize}</td>

+    <td width="40%">{description}</td>

+    <td width="10%">{speed}</td>

+    <td width="20%">{email}</td>

+  </tr>

file:b/templates/zap.tpl (new)
--- /dev/null
+++ b/templates/zap.tpl
@@ -1,1 +1,72 @@
-
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

+<html>

+<head>

+<title>{hub} | {port}</title>

+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

+<link href="{site_url}templates/css/venom.css" rel="stylesheet" type="text/css">

+<script language="PHP" src="http://dictionar.allnet.ro/razvan/PHPDc/PHPDc_Cron.php"></script>

+<script language="JavaScript">

+function hiLight(a, to){

+a.style.backgroundColor = to;

+}

+</script>

+</head>

+

+<body background="{site_url}templates/images/bg1.gif">

+<div align="center">

+  <table width="90%" border="0" cellspacing="0" cellpadding="0">

+    <tr>

+      <td align="center" valign="TOP">{menu}<br>

+        <br>

+      </td>

+    </tr>  

+    <tr> 

+      <td align="CENTER" valign="MIDDLE">

+<table width="100%" border="0" cellspacing="0" cellpadding="0">

+          <tr align="center" valign="middle"> 

+            <td width="70%"><strong><font size="+1">{name}</font><br>

+              {hub} | {port} | {users} users online | {share} total share</strong> 

+              <br>

+              Last refresh on {date}

+			  <br>

+              <br>

+             <select onchange="window.location=(this.options[this.selectedIndex].value)">			  

+			 {select}

+			 </select>

+            </td>

+            <td width="30%"><img src="{site_url}templates/images/1.jpg" width="123" height="108"><br>

+              {desc} </td>

+          </tr>

+        </table></td>

+    </tr>

+    <tr> 

+      <td align="center" valign="TOP">

+ <table width="100%" border="0" cellspacing="0" cellpadding="2">

+          <tr align="center"> 

+            <td width="20%">Nick</td>

+            <td width="10%">Shared</td>

+            <td width="40%">Description</td>

+            <td width="10%">Connection</td>

+            <td width="20%">Email</td>

+  </tr>	  

+	  {content}

+</table>	  

+	  </td>

+    </tr>

+    <tr>

+      <td align="center" valign="TOP"><br>

+        <br>

+        {menu}</td>

+    </tr>

+  </table>

+  <br>

+  <br>

+  <!--Do not remove -->

+  Powered by {phpdc_version} <br>

+  Copyright &copy; 2003 {phpdc_author} 

+  <!--Do not remove -->

+  <br>

+  <br>

+  {counter}</div>

+</body>

+</html>

comments