language["$args[0]"])
{
if ($numargs < 2)
{
$phrase = $phrasetext;
}
else
{
$args[0] = $phrasetext;
if (($phrase = @call_user_func_array('sprintf', $args)) === false)
{
for ($i = 1; $i < $numargs; $i++)
{
$phrase = str_replace("%{$i}\$s", $args["$i"], $args[0]);
}
}
}
return preg_replace('#%([0-9].*?)\$s#', '[ARG \\1: UNDEFINED]', $phrase);
}
else
{
return "[UNDEFINED PHRASE: $args[0]]";
}
}
// ########################## Start sanitize #########################
function sanitize($toclean)
{
global $vars;
foreach ($toclean AS $varname => $cleaner)
{
$varvalue = $_REQUEST["$varname"];
switch (strtoupper($cleaner))
{
case 'STR':
$cleaned = trim($varvalue);
break;
case 'STR_NOHTML':
$cleaned = htmlspecialcharslike(trim($varvalue));
break;
case 'INT':
$cleaned = intval($varvalue);
break;
case 'FLOAT':
$cleaned = floatval($varvalue);
break;
default: break;
}
$vars["$varname"] = $cleaned;
}
}
// ##################### Start fetch_random_chars ####################
function fetch_random_chars($length = 0)
{
// Gimme a length!
if (!$length)
{
$length = rand(20, 65);
}
// Number of ints in our salt
$intcount = rand(0, intval($length / 2));
// Number of chars
$charcount = $length - $intcount;
// Upper-case chars
$upperchars = rand(1, intval($charcount / 2));
// Lower-case chars
$lowerchars = $charcount - $upperchars;
// Generate ints
for ($i = 0; $i < $intcount; $i++)
{
$string[] = rand(0, 9);
}
// Generate upper chars
for ($i = 0; $i < $upperchars; $i++)
{
$string[] = chr(rand(65, 90));
}
// Generate lower chars
for ($i = 0; $i < $lowerchars; $i++)
{
$string[] = chr(rand(97, 122));
}
// Randomly key the chars
foreach ($string AS $char)
{
$rand = mt_rand();
$newstr["$rand"] = $char;
}
// Sort the chars by thier random assignment
ksort($newstr);
// Flatten the array
$string = '';
foreach ($newstr AS $char)
{
$string .= $char;
}
return $string;
}
// ######################## Start mysetcookie ########################
function mysetcookie($name, $value = false, $sticky = true)
{
// Expire the cookie if it doesn't have a value
if (!$value)
{
setcookie($name, $value, time() - (2 * 900), '/');
}
else
{
// Make the cookie one that stays?
if ($sticky)
{
$expire = time() + 60 * 60 * 24 * 365;
}
else
{
$expire = 0;
}
setcookie($name, $value, $expire, '/');
}
}
// ############################ Start iff ############################
function iff($condition, $true, $false = null)
{
return ($condition) ? ($true) : ($false);
}
// ######################## Start exec_swap_bg #######################
function exec_swap_bg($class1 = 'alt1', $class2 = 'alt2')
{
global $row_class;
static $row_count;
$row_class = iff($row_count % 2, $class1, $class2);
$row_count++;
}
// ####################### Start addslasheslike ######################
// leave this named as such for easy typing
function addslasheslike($str)
{
static $mqgpc;
if (!isset($mqgpc))
{
$mqgpc = get_magic_quotes_gpc();
}
if ($mqgpc)
{
return $str;
}
else
{
return addslashes($str);
}
}
// #################### Start htmlspecialcharslike ###################
function htmlspecialcharslike($str)
{
return str_replace(array('"', '<', '>'), array('"', '<', '>'), $str);
}
// ##################### Start unhtmlspecialchars ####################
function unhtmlspecialchars($str)
{
return str_replace(array('"', '<', '>'), array('"', '<', '>'), $str);
}
// ################## Start fetch_user_display_name ##################
// preps a dispaly name if one isn't set
// should be able to be removed by the final version as registration should set this
function fetch_user_display_name(&$userinfo)
{
if (!$userinfo['displayname'])
{
$userinfo['displayname'] = ucwords(trim(str_replace(array('@', '.com', '.net', '.edu', '.org', '.info', '.biz'), ' ', $userinfo['email'])));
}
}
// ################## Start construct_option_select ##################
// creates a