<?
/*************************************************************************************
COPYRIGHT NOTICE
This copyright notice must appear at the top of all scripts which are part of
the Web Application Gateway package.
Copyright (C) 2001-2008 Gregory Engel
All rights reserved
8547 E Arapahoe Rd, #J-504
Greenwood Village, CO 80112 USA
hide@address.com
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
A copy is included with the WAG package and is found in the text file gpl.txt
You should have received a copy of the GNU General Public License (gpl.txt, gpl.html)
along with the WAG distribution package; if not, the GNU General Public License can
be found at http://www.gnu.org/copyleft/gpl.html, or by writing to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA.
This script is part of the Web Application Gateway (WAG) Project. The WAG software
is free, subject to the terms of the GNU General Public License as published by the
Free Software Foundation, either version 2 of the License, or (at your option) any
later version.
$Revision: 43 $
$LastChangedDate: 2008-01-14 14:12:43 -0700 (Mon, 14 Jan 2008) $
$LastChangedBy: gpeangel $
*************************************************************************************/
function generatePassword ($length = 8)
{
$password = "";
$possible = "0123456789BCDFGHJKLMNPQRSTUVWXYZbcdfghjkmnpqrstvwxyz";
$i = 0;
while ($i < $length)
{
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
if (!strstr($password, $char))
{
$password .= $char;
$i++;
}
}
return $password;
}
/* function is_email($email)
{
return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $email));
} */
function readFolder($data_folder)
{
chdir($data_folder);
$data_folder = getcwd();
$handle=@opendir($data_folder);
$lng_counter = 0;
$ary_temp = array();
while (@$file = readdir ($handle))
{
if(!preg_match("/^\./", $file))
{
if (is_dir($file))
{
if (is_file($data_folder."/".$file."/inf.php"))
{
$ary_temp[$lng_counter][] = $data_folder."/".$file."/inf.php";
$ary_temp[$lng_counter][] = $file;
$lng_counter = $lng_counter + 1;
}
}
}
}
return $ary_temp;
}
function wagErrorHandler($error_number, $error_message, $filename, $linenum, $vars)
{
switch($error_message)
{
case "app_config_file_permission_denied":
$_SESSION["WAGATEWAY"]["system_error_message"] .= "<li>The web server does not have permission to create an application configuration file. The web server needs read/write permissions to the WAG application directory.</li>";
break;
case "app_config_file_write_denied":
$_SESSION["WAGATEWAY"]["system_error_message"] .= "<li>The configuration file is not writable. The install script must be able to write to this file in order to store the configuration parameters for the application.</li>";
break;
case "app_database_connection_error":
$_SESSION["WAGATEWAY"]["data_error"][$error_message] = "<li>Database Connection Error</li><blockquote><b>Error Message:</b> ".mysql_errno().": ".mysql_error()."</blockquote>";
break;
case "app_database_select_error":
$_SESSION["WAGATEWAY"]["data_error"][$error_message] = "<li>Database Selection Error</li><blockquote><b>Error Message:</b> ".mysql_errno().": ".mysql_error()."</blockquote>";
break;
case "app_database_install_error":
$_SESSION["WAGATEWAY"]["data_error"][$error_message] = "<li>Database Installation Error</li><blockquote><b>Error Message:</b> ".mysql_errno().": ".mysql_error()."</blockquote>";
break;
case "config_file_permission_denied":
$_SESSION["WAGATEWAY"]["system_error_message"] .= "<li>The web server does not have permission to create a configuration file. The web server needs read/write permissions to the WAG installation directory.</li>";
break;
case "config_file_write_denied":
$_SESSION["WAGATEWAY"]["system_error_message"] .= "<li>The configuration file, <b>config.php</b>, is not writable. The install script must be able to write to this file in order to store the configuration parameters for WAG.</li>";
break;
case "database_connection_error":
$_SESSION["WAGATEWAY"]["data_error"][] = $error_message;
$_SESSION["WAGATEWAY"]["data_error"][$error_message] = "<li>Database Connection Error</li><blockquote><b>Error Message:</b> ".mysql_errno().": ".mysql_error()."</blockquote>";
break;
case "database_select_error":
$_SESSION["WAGATEWAY"]["data_error"][] = $error_message;
$_SESSION["WAGATEWAY"]["data_error"][$error_message] = "<li>Database Selection Error</li><blockquote><b>Error Message:</b> ".mysql_errno().": ".mysql_error()."</blockquote>";
break;
case "database_install_error":
$_SESSION["WAGATEWAY"]["data_error"][] = $error_message;
$_SESSION["WAGATEWAY"]["data_error"][$error_message] = "<li>Database Installation Error</li><blockquote><b>Error Message:</b> ".mysql_errno().": ".mysql_error()."</blockquote>";
break;
default:
if ($_SESSION["WAGATEWAY"]["DEBUG_ON"] == 1)
{
$_SESSION["WAGATEWAY"]["system_error_message"] .= "<li>Unknown Error</li><blockquote>".$error_message." (line ".$linenum.")</blockquote>";
}
break;
}
}
function createGUID()
{
srand((double)microtime()*1000000);
$r = rand;
$u = uniqid(getmypid().$r.(double)microtime()*1000000,1);
$m = md5($u);
return($m);
}
/* function fix_magic_quotes($var = NULL, $sybase = NULL)
{
// fix_magic_quotes function originally found at:
//
// http://education.nyphp.org/phundamentals/PH_storingretrieving.php
//
// PHundamentals are distributed under a Creative Commons license:
//
// http://creativecommons.org/licenses/by-nc-nd/2.0/
// if sybase style quoting isn't specified, use ini setting
if ( !isset($sybase))
{
$sybase = ini_get ('magic_quotes_sybase');
}
// if no var is specified, fix all affected superglobals
if (!isset ($var))
{
// if magic quotes is enabled
if (get_magic_quotes_gpc())
{
// workaround because magic_quotes does not change $_SERVER['argv']
$argv = $_SERVER['argv'];
// fix all affected arrays
foreach(array('_ENV', '_REQUEST', '_GET', '_POST', '_COOKIE', '_SERVER') as $var)
{
$GLOBALS[$var] = fix_magic_quotes($GLOBALS[$var], $sybase);
}
$_SERVER['argv'] = $argv;
// turn off magic quotes, this is so scripts which
// are sensitive to the setting will work correctly
ini_set ('magic_quotes_gpc', 0);
}
// disable magic_quotes_sybase
if($sybase)
{
ini_set('magic_quotes_sybase', 0);
}
// disable magic_quotes_runtime
set_magic_quotes_runtime(0);
return TRUE;
}
// if var is an array, fix each element
if(is_array($var))
{
foreach($var as $key => $val)
{
$var[$key] = fix_magic_quotes($val, $sybase);
}
return $var;
}
// if var is a string, strip slashes
if(is_string($var))
{
return $sybase ? str_replace ('\'\'', '\'', $var) : stripslashes ($var);
}
// otherwise ignore
return $var;
} */
?>