|
From: <ma...@pr...> - 2004-08-28 14:35:47
|
Update of /cvsroot/meshdb/www/ipdb/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15932/include Modified Files: network.php Added Files: stringutils.php variables.php Log Message: added some php utility functions, added html for login functionality --- NEW FILE: stringutils.php --- <? /* from: http://au2.php.net/manual/en/function.substr.php after ('@', 'bio...@on...'); returns 'online.ge' from the first occurrence of '@' before ('@', 'bio...@on...'); returns 'biohazard' from the first occurrence of '@' between ('@', '.', 'bio...@on...'); returns 'online' from the first occurrence of '@' after_last ('[', 'sin[90]*cos[180]'); returns '180]' from the last occurrence of '[' before_last ('[', 'sin[90]*cos[180]'); returns 'sin[90]*cos[' from the last occurrence of '[' between_last ('[', ']', 'sin[90]*cos[180]'); returns '180' from the last occurrence of '[' */ function after ($this, $inthat) { if (!is_bool(strpos($inthat, $this))) return substr($inthat, strpos($inthat,$this)+strlen($this)); }; function after_last ($this, $inthat) { if (!is_bool(strrevpos($inthat, $this))) return substr($inthat, strrevpos($inthat, $this)+strlen($this)); }; function before ($this, $inthat) { return substr($inthat, 0, strpos($inthat, $this)); }; function before_last ($this, $inthat) { return substr($inthat, 0, strrevpos($inthat, $this)); }; function between ($this, $that, $inthat) { return before($that, after($this, $inthat)); }; function between_last ($this, $that, $inthat) { return after_last($this, before_last($that, $inthat)); }; // USES function strrevpos($instr, $needle) { $rev_pos = strpos (strrev($instr), strrev($needle)); if ($rev_pos===false) return false; else return strlen($instr) - $rev_pos - strlen($needle); }; ?> --- NEW FILE: variables.php --- <? /* from http://www.massless.org/_tests/phpgetvars/?style=text */ /* VARIABLE FUNCTIONS */ /** * Returns the value of a variable from the globals collection. * * Returns the value of a variable from PHP global variables. * Accesses the value in a portable manner by testing for the presence * of the $_REQUEST object. * *@access public *@param string $strParam The name of the variable *@return string The value of the variable */ function getRequestVariable($strParam) { $value=""; if (!empty($_REQUEST)) { if (!empty($_REQUEST[$strParam])) {$value=$_REQUEST[$strParam];} } else { eval("global \$".$strParam."; \$value=\$".$strParam.";"); } return $value; } /** * Returns the value of a server variable from the globals collection. * * Returns the value of a server variable from PHP global variables. * Accesses the value in a portable manner by testing for the presence * of the $_SERVER object. * *@access public *@param string $strParam The name of the variable *@return string The value of the variable */ function getServerVariable($strParam) { $value=""; if (!empty($_SERVER)) { if (!empty($_SERVER[$strParam])) {$value=$_SERVER[$strParam];} } else { eval("global \$".$strParam."; \$value=\$".$strParam.";"); } return $value; } /** * Returns the value of a session variable from the globals collection. * * Returns the value of a session variable from PHP global variables. * Accesses the value in a portable manner by testing for the presence * of the $_SESSION object. * *@access public *@param string $strParam The name of the variable *@return string The value of the variable */ function getSessionVariable($strParam) { global $HTTP_SESSION_VARS; if (isset($_SESSION)) { if (isset($_SESSION[$strParam])) { return $_SESSION[$strParam]; } else {return false;} } else if (isset($HTTP_SESSION_VARS)) { if (isset($HTTP_SESSION_VARS[$strParam])) { return $HTTP_SESSION_VARS[$strParam]; } else {return false;} } } /** * Set the value of a session variable from the globals collection. * *@access public *@param string $strParam The name of the variable *@param string $value The value *@return void */ function setSessionVariable($strParam,$value) { global $HTTP_SESSION_VARS; if (isset($_SESSION)) { $_SESSION[$strParam]=$value; } else if (isset($HTTP_SESSION_VARS)) { eval("global \$".$strParam.";"); eval("\$".$strParam."=\"\";"); eval("\$".$strParam."= \"".$value."\";"); eval("session_register('".$strParam."');"); } } /** * Set the value of a session variable from the globals collection to some object. * *@access public *@param string $strParam The name of the variable *@param string $obj The object *@return void */ function setObjectInSession($strParam,$obj) { global $HTTP_SESSION_VARS; if (isset($_SESSION)) { $_SESSION[$strParam]=$obj; } else if (isset($HTTP_SESSION_VARS)) { $thisObj = $obj; $stringObj = serialize( $thisObj ); eval("global \$".$strParam.";"); eval("\$".$strParam."=\"\";"); eval("\$".$strParam."= \"\$stringObj\";"); eval("session_register('".$strParam."');"); } } /** * Get the value of a object in a session variable from the globals collection. * *@access public *@param string $strParam The name of the variable *@return object An object stored in session */ function getObjectFromSession($strParam) { global $HTTP_SESSION_VARS; if (isset($_SESSION)) { if (isset($_SESSION[$strParam])) { return $_SESSION[$strParam]; } else {return false;} } else if (isset($HTTP_SESSION_VARS)) { if (isset($HTTP_SESSION_VARS[$strParam])) { return unserialize($HTTP_SESSION_VARS[$strParam]); } else {return false;} } } /** * Unset the value of a session variable from the globals collection. * *@access public *@param string $strParam The name of the variable *@return void */ function unsetSessionVariable($strParam) { global $HTTP_SESSION_VARS; if (isset($_SESSION)) { if (isset($_SESSION[$strParam])) { unset($_SESSION[$strParam]); } else {return false;} } else if (isset($HTTP_SESSION_VARS)) { if (isset($HTTP_SESSION_VARS[$strParam])) { unset($HTTP_SESSION_VARS[$strParam]); } else {return false;} } } /** * Test for the existence of a session variable from the globals collection. * *@access public *@param string $strParam The name of the variable *@return boolean Whether the session variable exists */ function issetSessionVariable($strParam) { global $HTTP_SESSION_VARS; if (isset($_SESSION)) { if (isset($_SESSION[$strParam])) { return true; } else {return false;} } else if (isset($HTTP_SESSION_VARS)) { if (isset($HTTP_SESSION_VARS[$strParam])) { return true; } else {return false;} } } /** * Print all variables contained in the globals collection. */ function PrintAllServerVariables() { foreach($GLOBALS as $key=>$value) { print $key . " = " . $value . "<br />"; } } ?> Index: network.php =================================================================== RCS file: /cvsroot/meshdb/www/ipdb/include/network.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- network.php 1 Aug 2004 11:30:45 -0000 1.1 +++ network.php 28 Aug 2004 14:35:38 -0000 1.2 @@ -61,6 +61,7 @@ $first_bin = str_pad(decbin(ip2long($first)), 32, "0", STR_PAD_LEFT); $netmask_bin = str_pad(str_repeat("1", (integer)$netmask), 32, "0", STR_PAD_RIGHT); + $last_bin = ""; for ($i = 0; $i < 32; $i++) { if ($netmask_bin[$i] == "1") |