Index: trunk/globals.php
===================================================================
diff -u -N -r3145 -r3148
--- trunk/globals.php (.../globals.php) (revision 3145)
+++ trunk/globals.php (.../globals.php) (revision 3148)
@@ -1,58 +1,58 @@
\n") {
$resave = true;
}
$ln++;
- $line = trim($line);
- $line = eregi_replace(';[.]*','',$line);
- if(strlen($line) > 0) {
- //echo $line . " - ";
- if(eregi('^[[a-z]+]$',str_replace(' ', '', $line))) {
- //echo 'section';
- $section = substr($line,1,(strlen($line)-2));
+ $line = trim($line);
+ $line = eregi_replace(';[.]*','',$line);
+ if(strlen($line) > 0) {
+ //echo $line . " - ";
+ if(eregi('^[[a-z]+]$',str_replace(' ', '', $line))) {
+ //echo 'section';
+ $section = substr($line,1,(strlen($line)-2));
if ($parse_section) {
- $retval[$section] = array();
+ $retval[$section] = array();
}
continue;
- } elseif(eregi('=',$line)) {
- //echo 'main element';
- list($key,$val) = explode(' = ',$line);
+ } elseif(eregi('=',$line)) {
+ //echo 'main element';
+ list($key,$val) = explode(' = ',$line);
if (!$parse_section) {
- $retval[trim($key)] = str_replace('"', '', $val);
+ $retval[trim($key)] = str_replace('"', '', $val);
}
else {
- $retval[$section][trim($key)] = str_replace('"', '', $val);
+ $retval[$section][trim($key)] = str_replace('"', '', $val);
}
- } //end if
- //echo '
';
- } //end if
- } //end foreach
+ } //end if
+ //echo '
';
+ } //end if
+ } //end foreach
if ($resave) {
$fp = fopen($file, "w");
reset($contents);
fwrite($fp,'<'.'?'.'php die() ?'.">\n\n");
foreach($contents as $line) fwrite($fp,"$line");
fclose($fp);
- }
-
- return $retval;
+ }
+
+ return $retval;
}
}
@@ -95,16 +95,16 @@
function &GetADODBConnection()
{
static $DB = null;
-
+
global $g_DBType, $g_DBHost, $g_DBUser, $g_DBUserPassword, $g_DBName, $g_DebugMode;
global $ADODB_FETCH_MODE, $ADODB_COUNTRECS, $ADODB_CACHE_DIR, $pathtoroot;
-
+
if( !isset($DB) && strlen($g_DBType) > 0 )
{
$DB = ADONewConnection($g_DBType);
$connected = $DB->Connect($g_DBHost, $g_DBUser, $g_DBUserPassword, $g_DBName);
if(!$connected) die("Error connecting to database $g_DBHost
\n");
-
+
$ADODB_CACHE_DIR = $pathtoroot."cache";
$ADODB_FETCH_MODE = 2;
$ADODB_COUNTRECS = false;
@@ -118,7 +118,7 @@
echo 'In-Portal is probably not installed, or configuration file is missing.
';
echo 'Please use the installation script to fix the problem.
';
if ( !preg_match('/admin/', __FILE__) ) $ins = 'admin/';
-
+
echo 'Go to installation script
';
flush();
exit;
@@ -135,7 +135,7 @@
// dummy protection: get maximal resource id used actually and fix last_id used
$max_resourceid = 0;
-
+
$m = GetModuleArray();
foreach($m as $key=>$value)
{
@@ -145,7 +145,7 @@
include_once($path);
}
}
-
+
$table_info = $objModules->ExecuteFunction('GetModuleInfo', 'dupe_resourceids');
$sql_template = 'SELECT MAX(ResourceId) FROM '.GetTablePrefix().'%s';
@@ -164,7 +164,7 @@
$last_id = $db->GetOne('SELECT lastid FROM '.$table_name);
if ($last_id - 1 > $max_resourceid) $max_resourceid = $last_id - 1;
-
+
$id_diff = $db->GetOne('SELECT '.$max_resourceid.' + 1 - lastid FROM '.$table_name);
if($id_diff) $Increment += $id_diff;
@@ -207,36 +207,36 @@
return $s;
}
-function DeleteElement($array, $indice)
+function DeleteElement($array, $indice)
{
- for($i=$indice;$i -1)
unset($haystack[$gotcha]);
-}
+}
function TableCount($TableName, $where="",$JoinCats=1)
{
$db = &GetADODBConnection();
if(!$JoinCats)
- {
+ {
$sql = "SELECT count(*) as TableCount FROM $TableName";
}
else
$sql = "SELECT count(*) as TableCount FROM $TableName INNER JOIN ".GetTablePrefix()."CategoryItems ON ".GetTablePrefix()."CategoryItems.ItemResourceId=$TableName.ResourceId";
if(strlen($where)>0)
$sql .= " WHERE ".$where;
-
+
$rs = $db->Execute($sql);
-
+
// echo "SQL TABLE COUNT: ".$sql."
\n";
-
+
$res = $rs->fields["TableCount"];
return $res;
}
@@ -246,21 +246,21 @@
$sql = preg_replace('/SELECT(.*)FROM[ \n\r](.*)/is','SELECT COUNT(*) AS TableCount FROM $2', $sql);
$sql = preg_replace('/(.*)LIMIT(.*)/is','$1', $sql);
$sql = preg_replace('/(.*)ORDER BY(.*)/is','$1', $sql);
-
+
//echo $sql;
-
+
$db =& GetADODBConnection();
return $db->GetOne($sql);
}
-
+
function GetPageCount($ItemsPerPage,$NumItems)
{
if($ItemsPerPage==0 || $NumItems==0)
{
return 1;
- }
+ }
$value = $NumItems/$ItemsPerPage;
- return ceil($value);
+ return ceil($value);
}
@@ -278,14 +278,14 @@
function TableHasPrefix($t)
{
$pre = GetTablePrefix();
-
+
if(strlen($pre)>0)
{
if(substr($t,0,strlen($pre))==$pre)
{
return TRUE;
}
- else
+ else
return FALSE;
}
else
@@ -296,52 +296,52 @@
{
if(!TableHasPrefix($t))
$t = GetTablePrefix().$t;
-
+
return $t;
}
function ThisDomain()
{
global $objConfig, $g_Domain;
-
+
if($objConfig->Get("DomainDetect"))
{
$d = $_SERVER['HTTP_HOST'];
}
else
$d = $g_Domain;
-
+
return $d;
}
function GetIndexUrl($secure=0)
{
global $indexURL, $rootURL, $secureURL;
-
+
if ( class_exists('kApplication') )
{
$application =& kApplication::Instance();
return $application->BaseURL().'index.php';
}
-
+
switch($secure)
{
case 0:
$ret = $indexURL;
break;
-
+
case 1:
$ret = $secureURL."index.php";
break;
-
+
case 2:
$ret = $rootURL."index.php";
break;
-
+
default:
$ret = $i;
break;
- }
+ }
return $ret;
}
@@ -352,7 +352,7 @@
if(is_numeric($PerPage))
{
- if($PerPage==0)
+ if($PerPage==0)
$PerPage = 20;
$Start = ($Page-1)*$PerPage;
$limit = "LIMIT ".$Start.",".$PerPage;
@@ -362,14 +362,14 @@
return $limit;
}
-function filelist ($currentdir, $startdir=NULL,$ext=NULL)
+function filelist ($currentdir, $startdir=NULL,$ext=NULL)
{
global $pathchar;
//chdir ($currentdir);
// remember where we started from
- if (!$startdir)
+ if (!$startdir)
{
$startdir = $currentdir;
}
@@ -378,20 +378,20 @@
$files = array();
if(!$d)
- return $files;
+ return $files;
//list the files in the dir
- while (false !== ($file = readdir($d)))
+ while (false !== ($file = readdir($d)))
{
- if ($file != ".." && $file != ".")
+ if ($file != ".." && $file != ".")
{
- if (is_dir($currentdir."/".$file))
+ if (is_dir($currentdir."/".$file))
{
// If $file is a directory take a look inside
- $a = filelist ($currentdir."/".$file, $startdir,$ext);
+ $a = filelist ($currentdir."/".$file, $startdir,$ext);
if(is_array($a))
$files = array_merge($files,$a);
- }
- else
+ }
+ else
{
if($ext!=NULL)
{
@@ -408,12 +408,12 @@
closedir ($d);
return $files;
-}
+}
function DecimalToBin($dec,$WordLength=8)
{
$bits = array();
-
+
$str = str_pad(decbin($dec),$WordLength,"0",STR_PAD_LEFT);
for($i=$WordLength;$i>0;$i--)
{
@@ -432,7 +432,7 @@
$out=ereg_replace(">",">",$out);
$out=ereg_replace("\"",""",$out);
$out = str_replace("\n^br^", "\n
", $out);
- }
+ }
else
$out = str_replace("\n^br^", "\n", $out);
$out=addslashes($out);
@@ -464,15 +464,15 @@
function inp_unescape($in)
{
-// if (get_magic_quotes_gpc())
+// if (get_magic_quotes_gpc())
return $in;
$out=stripslashes($in);
return $out;
}
function inp_textarea_unescape($in)
{
-// if (get_magic_quotes_gpc())
+// if (get_magic_quotes_gpc())
return $in;
$out=stripslashes($in);
$out = str_replace("\n
", "\n", $out);
@@ -486,11 +486,11 @@
if(!strlen($OpenTag))
$OpenTag = "";
if(!strlen($CloseTag))
- $CloseTag = "";
-
+ $CloseTag = "";
+
$r = preg_split('((>)|(<))', $html, -1, PREG_SPLIT_DELIM_CAPTURE);
-
- foreach ($Keywords as $k) {
+
+ foreach ($Keywords as $k) {
for ($i = 0; $i < count($r); $i++) {
if ($r[$i] == "<") {
$i++; continue;
@@ -513,9 +513,9 @@
$ret = strip_tags($html);
foreach ($Keywords as $k)
- {
+ {
if(strlen($k))
- {
+ {
//$html = str_replace("<$k>", ":#:", $html);
//$html = str_replace("$k>", ":##:", $html);
//$html = strip_tags($html);
@@ -526,7 +526,7 @@
//$ret = str_replace(":##:", "$k>", $ret);
}
}
- return $ret;
+ return $ret;
}
*/
function ExtractDatePart($part,$datestamp)
@@ -535,31 +535,31 @@
{
case "month":
if($datestamp<=0)
- {
+ {
$ret = "";
}
else
$ret = adodb_date("m",$datestamp);
- break;
+ break;
case "day":
if($datestamp<=0)
- {
+ {
$ret = "";
}
else
$ret = adodb_date("d", $datestamp);
- break;
+ break;
case "year":
if($datestamp<=0)
- {
+ {
$ret = "";
}
else
$ret = adodb_date("Y", $datestamp);
break;
case "time_24hr":
if($datestamp<=0)
- {
+ {
$ret = "";
}
else
@@ -583,10 +583,10 @@
function GetLocalTime($TimeStamp,$TargetZone=NULL)
{
if($TargetZone==NULL)
- $TargetZone = $objConfig->Get("Config_Site_Time");
+ $TargetZone = $objConfig->Get("Config_Site_Time");
$server = $objConfig->Get("Config_Server_Time");
if($TargetZone!=$server)
- {
+ {
$offset = ($server - $TargetZone) * -1;
$TimeStamp = $TimeStamp + (3600 * $offset);
}
@@ -613,7 +613,7 @@
} else {
return -1; //if $need wasn´t found it returns "-1" , because it could return "0" if it´s found on position "0".
}
-}
+}
// --- bbcode processing function: begin ----
function PreformatBBCodes($text)
@@ -680,9 +680,9 @@
global $objConfig;
// convert phpbb bbcodes to in-bulletin bbcodes
$text = PreformatBBCodes($text);
-
+
// $tag_defs = 'b:;i:;u:;ul:type|align;font:color|face|size;url:href;img:src|border';
-
+
$tags_defs = $objConfig->Get('BBTags');
foreach(explode(';',$tags_defs) as $tag)
{
@@ -691,14 +691,14 @@
$tag_params = $tag[1]?array_flip(explode('|',$tag[1])):0;
$text = preg_replace('/\['.$tag_name.'(.*)\](.*)\[\/'.$tag_name.' *\]/Uise','CheckBBCodeAttribs("'.$tag_name.'",\'$1\',\'$2\',$tag_params);', $text);
}
-
+
// additional processing for [url], [*], [img] bbcode
$text = preg_replace('/(.*)<\/url>/Usi','$1',$text);
$text = preg_replace('/(.*)<\/font>/Usi','$1',$text); // skip empty fonts
$text = str_replace( Array('','[*]'),
Array('',''),
$text);
-
+
// bbcode [code]xxx[/code] processing
$text = preg_replace('/\[code\](.*)\[\/code\]/Uise', "ReplaceCodeBBCode('$1')", $text);
return $text;
@@ -719,7 +719,7 @@
$input_string='';
// $input_string='';
return $input_string;
-
+
if(false!==strpos($input_string,'<'.'?'))
{
$input_string=str_replace('<'.'?','<'.'?php',$input_string);
@@ -754,10 +754,10 @@
if (!function_exists( 'getmicrotime' ) ) {
function getmicrotime()
- {
- list($usec, $sec) = explode(" ",microtime());
- return ((float)$usec + (float)$sec);
- }
+ {
+ list($usec, $sec) = explode(" ",microtime());
+ return ((float)$usec + (float)$sec);
+ }
}
function SetMissingDataErrors($f)
@@ -766,27 +766,27 @@
$count = 0;
if(is_array($_POST))
- {
+ {
if(is_array($_POST["required"]))
- {
+ {
foreach($_POST["required"] as $r)
{
$found = FALSE;
if(is_array($_FILES))
{
if( isset($_FILES[$r]) && $_FILES[$r]['size'] > 0 ) $found = TRUE;
}
-
+
if(!strlen(trim($_POST[$r])) && !$found)
- {
+ {
$count++;
-
+
if (($r == "dob_day") || ($r == "dob_month") || ($r == "dob_year"))
- $r = "dob";
-
+ $r = "dob";
+
$tag = isset($_POST["errors"]) ? $_POST["errors"][$r] : '';
if(!strlen($tag))
- $tag = "lu_ferror_".$f."_".$r;
+ $tag = "lu_ferror_".$f."_".$r;
$FormError[$f][$r] = language($tag);
}
}
@@ -797,115 +797,115 @@
function makepassword($length=10)
{
- $pass_length=$length;
+ $pass_length=$length;
$p1=array('b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z');
- $p2=array('a','e','i','o','u');
- $p3=array('1','2','3','4','5','6','7','8','9');
- $p4=array('(','&',')',';','%'); // if you need real strong stuff
+ $p2=array('a','e','i','o','u');
+ $p3=array('1','2','3','4','5','6','7','8','9');
+ $p4=array('(','&',')',';','%'); // if you need real strong stuff
- // how much elements in the array
- // can be done with a array count but counting once here is faster
+ // how much elements in the array
+ // can be done with a array count but counting once here is faster
- $s1=21;// this is the count of $p1
- $s2=5; // this is the count of $p2
- $s3=9; // this is the count of $p3
- $s4=5; // this is the count of $p4
+ $s1=21;// this is the count of $p1
+ $s2=5; // this is the count of $p2
+ $s3=9; // this is the count of $p3
+ $s4=5; // this is the count of $p4
- // possible readable combinations
+ // possible readable combinations
- $c1='121'; // will be like 'bab'
- $c2='212'; // will be like 'aba'
- $c3='12'; // will be like 'ab'
- $c4='3'; // will be just a number '1 to 9' if you dont like number delete the 3
-// $c5='4'; // uncomment to active the strong stuff
+ $c1='121'; // will be like 'bab'
+ $c2='212'; // will be like 'aba'
+ $c3='12'; // will be like 'ab'
+ $c4='3'; // will be just a number '1 to 9' if you dont like number delete the 3
+// $c5='4'; // uncomment to active the strong stuff
- $comb='4'; // the amount of combinations you made above (and did not comment out)
+ $comb='4'; // the amount of combinations you made above (and did not comment out)
- for ($p=0;$p<$pass_length;)
- {
- mt_srand((double)microtime()*1000000);
- $strpart=mt_rand(1,$comb);
- // checking if the stringpart is not the same as the previous one
- if($strpart<>$previous)
- {
- $pass_structure.=${'c'.$strpart};
+ for ($p=0;$p<$pass_length;)
+ {
+ mt_srand((double)microtime()*1000000);
+ $strpart=mt_rand(1,$comb);
+ // checking if the stringpart is not the same as the previous one
+ if($strpart<>$previous)
+ {
+ $pass_structure.=${'c'.$strpart};
- // shortcutting the loop a bit
- $p=$p+strlen(${'c'.$strpart});
- }
- $previous=$strpart;
- }
+ // shortcutting the loop a bit
+ $p=$p+strlen(${'c'.$strpart});
+ }
+ $previous=$strpart;
+ }
- // generating the password from the structure defined in $pass_structure
- for ($g=0;$g0)
- $elapsed = getmicrotime() - $last;
-
+ $elapsed = getmicrotime() - $last;
+
if(strlen($el)>10)
- $el = substr($el,0,10);
+ $el = substr($el,0,10);
$indent = str_repeat(" ",$LogLevel);
$text = str_pad($text,$LogLevel,"==",STR_PAD_LEFT);
$LogData .= "$el:". round($elapsed,6).":$indent $text";
$last = getmicrotime();
if($writefile==TRUE && is_writable($g_LogFile))
{
- if(!$LogFile)
+ if(!$LogFile)
{
if(file_exists($g_LogFile))
unlink($g_LogFile);
$LogFile=@fopen($g_LogFile,"w");
}
if($LogFile)
- {
+ {
fputs($LogFile,$LogData);
}
}
}
}
-function ValidEmail($email)
+function ValidEmail($email)
{
if (eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}", $email))
{
return TRUE;
- }
- else
+ }
+ else
{
return FALSE;
}
-}
+}
function language($phrase,$LangId=0)
{
global $objSession, $objLanguageCache, $objLanguages;
if($LangId==0)
$LangId = $objSession->Get("Language");
-
+
if($LangId==0)
- $LangId = $objLanguages->GetPrimary();
+ $LangId = $objLanguages->GetPrimary();
$translation = $objLanguageCache->GetTranslation($phrase,$LangId);
@@ -915,22 +915,22 @@
function admin_language($phrase,$lang=0,$LinkMissing=FALSE)
{
global $objSession, $objLanguageCache, $objLanguages;
-
+
//echo "Language passed: $lang
";
-
+
if($lang==0)
$lang = $objSession->Get("Language");
//echo "Language from session: $lang
";
-
+
if($lang==0)
- $lang = $objLanguages->GetPrimary();
-
+ $lang = $objLanguages->GetPrimary();
+
//echo "Language after primary: $lang
";
//echo "Phrase: $phrase
";
$translation = $objLanguageCache->GetTranslation($phrase,$lang);
if($LinkMissing && substr($translation,0,1)=="!" && substr($translation,-1)=="!")
- {
+ {
$res = "$translation";
return $res;
}
@@ -940,7 +940,7 @@
function prompt_language($phrase,$lang=0)
{
- return admin_language($phrase,$lang,TRUE);
+ return admin_language($phrase,$lang,TRUE);
}
function GetPrimaryTranslation($Phrase)
@@ -966,7 +966,7 @@
$rs->MoveNext();
}
return $ret;
-}
+}
function CategoryItemNameCount($CategoryId,$Table,$Field,$Name)
{
@@ -983,7 +983,7 @@
$ret[] = $rs->fields[$Field];
$rs->MoveNext();
}
- return $ret;
+ return $ret;
}
function &GetItemCollection($ItemName)
@@ -1009,7 +1009,7 @@
return $var;
}
-
+
function UpdateCategoryCount($item_type,$CategoriesIds,$ListType='')
{
global $objCountCache, $objItemTypes;
@@ -1022,29 +1022,29 @@
$objCountCache->EraseGlobalTypeCache($item_type);
if($item_type)
{
- if(is_array($CategoriesIds))
+ if(is_array($CategoriesIds))
{
$CategoriesIds=implode(',',$CategoriesIds);
}
if (!$CategoriesIds)
{
-
+
}
-
+
if(!is_array($ListType)) $ListType=Array($ListType=>'opa');
-
+
$sql = 'SELECT ParentPath FROM '.GetTablePrefix().'Category WHERE CategoryId IN ('.$CategoriesIds.')';
$rs = $db->Execute($sql);
$parents = Array();
- while (!$rs->EOF)
+ while (!$rs->EOF)
{
$tmp=$rs->fields['ParentPath'];
$tmp=substr($tmp,1,strlen($tmp)-2);
$tmp=explode('|',$tmp);
foreach ($tmp as $tmp_cat_id) {
$parents[$tmp_cat_id]=1;
}
- $rs->MoveNext();
+ $rs->MoveNext();
}
$parents=array_keys($parents);
$list_types=array_keys($ListType);
@@ -1060,11 +1060,11 @@
{
die('wrong item type passed to "UpdateCategoryCount"');
}
-
+
/* if(is_object($item))
- {
+ {
$ItemType = $item->Get("ItemType");
-
+
$sql = "DELETE FROM ".$objCountCache->SourceTable." WHERE ItemType=$ItemType";
if( is_numeric($ListType) ) $sql .= " AND ListType=$ListType";
$objCountCache->adodbConnection->Execute($sql);
@@ -1099,12 +1099,12 @@
global $objSystemCache, $objSession, $objConfig;
if($objConfig->Get("SystemTagCache") && !$objSession->Get('PortalUserId'))
- {
+ {
$name = $tag;
if(is_array($attribs))
- {
+ {
foreach($attribs as $n => $val)
- {
+ {
$name .= "-".$val;
}
}
@@ -1123,9 +1123,9 @@
{
$name = $tag;
if(is_array($attribs))
- {
+ {
foreach($attribs as $a => $val)
- {
+ {
$name .= "-".$val;
}
}
@@ -1138,7 +1138,7 @@
global $objSystemCache, $objConfig;
if($objConfig->Get("SystemTagCache"))
- {
+ {
$where = "Name LIKE '$name%".$extraparams."'";
if(strlen($env))
$where .= " AND Context LIKE $env";
@@ -1159,7 +1159,7 @@
global $objSystemCache, $objConfig;
if($objConfig->Get("SystemTagCache"))
- {
+ {
$where = 'Module LIKE \''.$module.'\'';
if(strlen($tagname))
{
@@ -1176,7 +1176,7 @@
global $objSystemCache, $objConfig;
if($objConfig->Get("SystemTagCache"))
- {
+ {
$where = '';
$objSystemCache->DeleteCachedItem($where);
}
@@ -1201,11 +1201,11 @@
function GetDateFormat($LangId=0)
{
- global $objLanguages;
-
+ global $objLanguages;
+
if(!$LangId)
$LangId= $objLanguages->GetPrimary();
- $l = $objLanguages->GetItem($LangId);
+ $l = $objLanguages->GetItem($LangId);
if(is_object($l))
{
$fmt = $l->Get("DateFormat");
@@ -1220,18 +1220,18 @@
function GetTimeFormat($LangId=0)
{
- global $objLanguages;
-
+ global $objLanguages;
+
if(!$LangId)
$LangId= $objLanguages->GetPrimary();
- $l = $objLanguages->GetItem($LangId);
+ $l = $objLanguages->GetItem($LangId);
if(is_object($l))
{
$fmt = $l->Get("TimeFormat");
}
else
$fmt = "H:i:s";
- return $fmt;
+ return $fmt;
}
/**
@@ -1245,22 +1245,22 @@
function GetRegionalOption($optionName,$LangId=0)
{
global $objLanguages, $objSession;
-
+
if(!$LangId) $LangId=$objSession->Get('Language');
if(!$LangId) $LangId=$objLanguages->GetPrimary();
$l = $objLanguages->GetItem($LangId);
return is_object($l)?$l->Get($optionName):false;
}
function LangDate($TimeStamp=NULL,$LangId=0)
-{
+{
$fmt = GetDateFormat($LangId);
$ret = adodb_date($fmt,$TimeStamp);
return $ret;
}
function LangTime($TimeStamp=NULL,$LangId=0)
-{
+{
$fmt = GetTimeFormat($LangId);
$ret = adodb_date($fmt,$TimeStamp);
return $ret;
@@ -1269,24 +1269,24 @@
function LangNumber($Num,$DecPlaces=NULL,$LangId=0)
{
global $objLanguages;
-
+
if(!$LangId)
$LangId= $objLanguages->GetPrimary();
- $l = $objLanguages->GetItem($LangId);
+ $l = $objLanguages->GetItem($LangId);
if(is_object($l))
{
$ret = number_format($Num,$DecPlaces,$l->Get("DecimalPoint"),$l->Get("ThousandSep"));
}
- else
+ else
$ret = $num;
-
- return $ret;
+
+ return $ret;
}
function replacePngTags($x, $spacer="images/spacer.gif")
{
global $rootURL,$pathtoroot;
-
+
// make sure that we are only replacing for the Windows versions of Internet
// Explorer 5+, and not Opera identified as MSIE
$msie='/msie\s([5-9])\.?[0-9]*.*(win)/i';
@@ -1295,7 +1295,7 @@
!preg_match($msie,$_SERVER['HTTP_USER_AGENT']) ||
preg_match($opera,$_SERVER['HTTP_USER_AGENT']))
return $x;
-
+
// find all the png images in backgrounds
preg_match_all('/background-image:\s*url\(\'(.*\.png)\'\);/Uis',$x,$background);
for($i=0;$i\n";
-// echo "Full Tag: ".htmlentities($image)."
\n";
+// echo "Full Tag: ".htmlentities($image)."
\n";
//if(!$height || !$width)
//{
@@ -1361,7 +1361,7 @@
{
$height = imagesy($g);
$width = imagesx($g);
- }
+ }
//}
if(strlen($image_path)) $image_path.='/';
@@ -1370,10 +1370,10 @@
'px; height: '.$height.'px; filter: progid:DXImageTransform.'.
'Microsoft.AlphaImageLoader(src=\''.$image.'\', sizingMethod='.
'\'scale\')';
-
+
// now create the new tag from the old
$new_tag=str_replace($image,$replace_src_with,$original);
-
+
// now place the new tag into the content
$x=str_replace($original,$new_tag,$x);
}
@@ -1392,12 +1392,12 @@
{
// get dropdown values from custom field
$tmp =& new clsCustomField();
-
+
$tmp->LoadFromDatabase($field, 'FieldName');
$tmp_values = $tmp->Get('ValueList');
unset($tmp);
$tmp_values = explode(',', $tmp_values);
-
+
foreach($tmp_values as $mixed)
{
$elem = explode('=', trim($mixed));
@@ -1408,7 +1408,7 @@
function ResetPage($module_prefix, $page_variable = 'p')
{
- // resets page in specific module when category is changed
+ // resets page in specific module when category is changed
global $objSession;
if( !is_object($objSession) ) // when changing pages session doesn't exist -> InPortal BUG
{
@@ -1419,7 +1419,7 @@
$last_cat = $objSession->GetVariable('last_category');
$prev_cat = $objSession->GetVariable('prev_category');
//echo "Resetting Page [$prev_cat] -> [$last_cat]
";
-
+
if($prev_cat != $last_cat) $GLOBALS[$module_prefix.'_var_list'][$page_variable] = 1;
}
@@ -1436,22 +1436,22 @@
if(!$post_priority) // follow gpc_order in php.ini
return isset($_REQUEST[$name]) ? $_REQUEST[$name] : false;
else // get variable from post 1stly if not found then from get
- return isset($_POST[$name]) && $_POST[$name] !== false ? $_POST[$name] : ( isset($_GET[$name]) && $_GET[$name] ? $_GET[$name] : false );
+ return isset($_POST[$name]) && $_POST[$name] !== false ? $_POST[$name] : ( isset($_GET[$name]) && $_GET[$name] ? $_GET[$name] : false );
}
}
function SetVar($VarName, $VarValue)
{
- $_REQUEST[$VarName] = $VarValue;
+ $_REQUEST[$VarName] = $VarValue;
$_POST[$VarName] = $VarValue;
}
function PassVar(&$source)
{
- // source array + any count of key names in passed array
+ // source array + any count of key names in passed array
$params = func_get_args();
array_shift($params);
-
+
if( count($params) )
{
$ret = Array();
@@ -1469,7 +1469,7 @@
// used in case if some modules share
// common action parsed by kernel parser,
// but each module uses own EditStatus variable
-
+
$modules = Array('In-Link' => 'Link', 'In-News' => 'News', 'In-Bulletin' => 'Topic', 'In-Portal'=>'Review');
foreach($modules as $module => $prefix)
if( isset($array[$prefix.$postfix]) )
@@ -1499,15 +1499,15 @@
{
if (is_file($dir."/".$filename))
$totalsize+=filesize($dir."/".$filename);
-
+
if (is_dir($dir."/".$filename))
$totalsize+=dir_size($dir."/".$filename);
}
}
}
closedir($dirstream);
return $totalsize;
-}
+}
function size($bytes) {
// shows formatted file/directory size
@@ -1518,12 +1518,12 @@
$bytes /= 1024;
}
return round($bytes,2)." ".language($types[$current]);
-}
+}
function echod($str)
{
// echo debug output
- echo str_replace( Array('[',']'), Array('[', ']'), $str).'
';
+ echo str_replace( Array('[',']'), Array('[', ']'), $str).'
';
}
@@ -1533,13 +1533,13 @@
$result = Array();
foreach($to_lower as $field)
$result[ $field ] = $source[ strtolower($field) ];
-
+
if( is_array($mapping) )
{
foreach($mapping as $field_from => $field_to)
$result[$field_to] = $source[$field_from];
}
-
+
return $result;
}
@@ -1563,14 +1563,14 @@
{
// each action postprocessing stuff from admin
if( !isset($_REQUEST[$StatusField]) ) return false;
-
+
$list =& $GLOBALS[$ListObjectName];
if( !is_object($list) ) $list = new $ListClass();
$SFValue = $_REQUEST[$StatusField]; // status field value
switch($SFValue)
{
case 1: // User hit "Save" button
- $list->CopyFromEditTable($IDField);
+ $list->CopyFromEditTable($IDField);
break;
case 2: // User hit "Cancel" button
$list->PurgeEditTable($IDField);
@@ -1606,7 +1606,7 @@
function GetImportScripts()
{
- // return currently installed import scripts
+ // return currently installed import scripts
static $import_scripts = Array();
if( count($import_scripts) == 0 )
{
@@ -1618,16 +1618,16 @@
while(!$rs->EOF)
{
$rec =& $rs->fields;
- $import_scripts[] = Array( 'label' => $rec['is_label'], 'url' => $rec['is_script'],
+ $import_scripts[] = Array( 'label' => $rec['is_label'], 'url' => $rec['is_script'],
'enabled' => $rec['is_enabled'], 'field_prefix' => $rec['is_field_prefix'],
'id' => $rec['is_string_id'], 'required_fields' => $rec['is_requred_fields'],
'module' => strtolower($rec['is_Module']) );
- $rs->MoveNext();
+ $rs->MoveNext();
}
}
else
{
- $import_scripts = Array();
+ $import_scripts = Array();
}
}
return $import_scripts;
@@ -1638,19 +1638,19 @@
$scripts = GetImportScripts();
return isset($scripts[$id]) ? $scripts[$id] : false;
}
-function GetNextTemplate($current_template)
-{
- // used on front, returns next template to make
- // redirect to
- $dest = GetVar('dest', true);
- if(!$dest) $dest = GetVar('DestTemplate', true);
- return $dest ? $dest : $current_template;
+function GetNextTemplate($current_template)
+{
+ // used on front, returns next template to make
+ // redirect to
+ $dest = GetVar('dest', true);
+ if(!$dest) $dest = GetVar('DestTemplate', true);
+ return $dest ? $dest : $current_template;
}
// functions for dealign with enviroment variable construction
function GenerateModuleEnv($prefix, $var_list)
-{
+{
// globalize module varible arrays
$main =& $GLOBALS[$prefix.'_var_list'];
$update =& $GLOBALS[$prefix.'_var_list_update'];
@@ -1742,7 +1742,7 @@
*/
function IsDebugMode()
{
- return defined('DEBUG_MODE') && constant('DEBUG_MODE') == 1 ? 1 : 0;
+ return defined('DEBUG_MODE') && constant('DEBUG_MODE') == 1 ? 1 : 0;
}
/**
@@ -1752,7 +1752,7 @@
*/
function IsAdmin()
{
- return defined('ADMIN') && constant('ADMIN') == 1 ? 1 : 0;
+ return defined('ADMIN') && constant('ADMIN') == 1 ? 1 : 0;
}
/**
@@ -1800,7 +1800,7 @@
{
return -1;
}
- else
+ else
{
return 0;
}
@@ -1824,31 +1824,31 @@
}
$smaller = $bigger + $smaller;
}
-
+
if($first_abs > $second_abs) {
return 1;
}
elseif ($first_abs < $second_abs)
{
return -1;
}
- else
+ else
{
return 0;
}
}
function pr_bracket_comp($elem1, $elem2)
{
-
+
if ($elem1['MinQty']!="" && $elem1['MaxQty']=="" && $elem2['MinQty']!="" && $elem2['MaxQty']!="") return 1;
if ($elem1['MinQty']!="" && $elem1['MaxQty']=="" && $elem2['MinQty']=="" && $elem2['MaxQty']=="") return -1;
-
+
if ($elem1['MaxQty']=="" && $elem2['MaxQty']!="") return 1;
if ($elem1['MaxQty']!="" && $elem2['MaxQty']=="") return -1;
-
-
+
+
if( ($elem1['MaxQty']>$elem2['MaxQty'] && $elem2['MaxQty']!=-1) || ($elem1['MaxQty'] == -1 && $elem2['MaxQty'] != -1 ))
{
return 1;
@@ -1857,23 +1857,23 @@
{
return -1;
}
- else
+ else
{
return 0;
}
}
function ap_bracket_comp($elem1, $elem2)
{
-
+
if ($elem1['FromAmount']!="" && $elem1['ToAmount']=="" && $elem2['FromAmount']!="" && $elem2['ToAmount']!="") return 1;
if ($elem1['FromAmount']!="" && $elem1['ToAmount']=="" && $elem2['FromAmount']=="" && $elem2['ToAmount']=="") return -1;
-
+
if ($elem1['ToAmount']=="" && $elem2['ToAmount']!="") return 1;
if ($elem1['ToAmount']!="" && $elem2['ToAmount']=="") return -1;
-
-
+
+
if( ($elem1['ToAmount']>$elem2['ToAmount'] && $elem2['ToAmount']!=-1) || ($elem1['ToAmount'] == -1 && $elem2['ToAmount'] != -1 ))
{
return 1;
@@ -1882,7 +1882,7 @@
{
return -1;
}
- else
+ else
{
return 0;
}
@@ -1906,20 +1906,20 @@
}
$smaller = $bigger + $smaller;
}
-
+
if($first_abs > $second_abs) {
return 1;
}
elseif ($first_abs < $second_abs)
{
return -1;
}
- else
+ else
{
return 0;
}
}
-
+
function inp_htmlize($var, $strip = 0)
{
if( is_array($var) )
@@ -1946,7 +1946,7 @@
$cookie_path = IsAdmin() ? rtrim(BASE_PATH, '/').'/admin' : BASE_PATH;
setcookie($name, $value, $expire, $cookie_path, $_SERVER['HTTP_HOST']);
}
-
+
/**
* If we are on login required template, but we are not logged in, then logout user
*
@@ -1956,16 +1956,15 @@
{
if( !isset($condition) ) $condition = !admin_login();
if(!$condition) return false;
-
+
global $objSession, $adminURL;
if( !headers_sent() ) set_cookie(SESSION_COOKIE_NAME, ' ', time() - 3600);
$objSession->Logout();
if($pass_env) $redirect_params = 'env='.BuildEnv().'&'.$redirect_params;
-
header('Location: '.$adminURL.'/index.php?'.$redirect_params);
exit;
}
-
+
if( !function_exists('safeDefine') )
{
/**