Index: trunk/core/units/general/inp1_parser.php
===================================================================
diff -u -N -r8397 -r8436
--- trunk/core/units/general/inp1_parser.php (.../inp1_parser.php) (revision 8397)
+++ trunk/core/units/general/inp1_parser.php (.../inp1_parser.php) (revision 8436)
@@ -62,16 +62,14 @@
function InitParser()
{
- global $objTemplate, $CurrentTheme, $objThemes, $objLanguageCache, $var_list;
+ global $objTemplate, $CurrentTheme, $objThemes, $var_list;
if ($this->InpParsetInited) return true;
$theme_id = $this->Application->IsAdmin() ? 1 : $this->Application->GetVar('m_theme');
if ($theme_id) {
$CurrentTheme = $objThemes->GetItem($theme_id);
$timeout = $CurrentTheme->Get('CacheTimeout');
- $objLanguageCache->LoadTemplateCache($var_list['t'], $timeout, $theme_id);
- $objLanguageCache->LoadCachedVars($this->Application->GetVar('m_lang'));
$objTemplate = new clsTemplateList(FULL_PATH.THEMES_PATH.'/');
}
@@ -83,7 +81,7 @@
{
$this->InportalInited = true;
/*global $pathtoroot, $FrontEnd, $indexURL, $rootURL, $secureURL, $var_list, $CurrentTheme,
- $objThemes, $objConfig, $m_var_list, $timeout, $objLanguages, $objLanguageCache,
+ $objThemes, $objConfig, $m_var_list, $timeout, $objLanguages,
$TemplateRoot, $objTemplate, $html, $objSession, $Errors, $objCatList, $objUsers,
$env, $mod_prefix, $ExtraVars, $timestart, $timeend, $timeout, $sqlcount, $totalsql,
$template_path, $modules_loaded, $mod_root_cats, $objModules, $objItemTypes;*/
@@ -101,7 +99,7 @@
$template_path, $mod_root_cats, $value, $mod, $ItemTypes,
$ParserFiles, $SessionQueryString, $var_list, $objSession,
$orderByClause, $TemplateRoot, $ip, $UseSession, $Action, $CookieTest, $sessionId,
- $var_list_update, $CurrentTheme, $UserID, $objCurrentUser, $objLanguageCache,
+ $var_list_update, $CurrentTheme, $UserID, $objCurrentUser,
$folder_name, $objLinkList, $tag_override, $timeZones, $siteZone, $serverZone,
$lastExpire, $diffZone, $date, $nowDate, $lastExpireDate, $SearchPerformed,
$TotalMessagesSent, $ado, $adminDir, $rootURL, $secureURL, $html, $timeout,
@@ -149,8 +147,6 @@
}
LogEntry("Output Complete\n");
- $objLanguageCache->SaveTemplateCache();
- LogEntry("Templates Cached\n");
$timeend = getmicrotime();
$diff = $timeend - $timestart;
Index: trunk/core/kernel/utility/debugger.php
===================================================================
diff -u -N -r8413 -r8436
--- trunk/core/kernel/utility/debugger.php (.../debugger.php) (revision 8413)
+++ trunk/core/kernel/utility/debugger.php (.../debugger.php) (revision 8436)
@@ -104,7 +104,7 @@
*
* @param string $ip_list semi-column (by default) separated ip address list
* @param string $separator ip address separator (default ";")
- *
+ *
* @return bool
*/
function ipMatch($ip_list, $separator = ';')
@@ -117,10 +117,10 @@
break;
}
}
-
+
return $ip_match;
}
-
+
/**
* Set's default values to constants debugger uses
*
@@ -265,16 +265,16 @@
{
$dump_mode = 'var_dump';
$dumpVars = func_get_args();
-
+
if ($dumpVars[count($dumpVars) - 1] === 'STRICT') {
$dump_mode = 'strict_var_dump';
array_pop($dumpVars);
}
-
+
foreach ($dumpVars as $varValue) {
$this->Data[] = Array('value' => $varValue, 'debug_type' => $dump_mode);
}
-
+
}
function prepareHTML($dataIndex)
@@ -299,7 +299,7 @@
case 'strict_var_dump':
return $this->highlightString( var_export($Data['value'], true) );
break;
-
+
case 'trace':
ini_set('memory_limit', '500M');
$trace =& $Data['trace'];
@@ -344,19 +344,29 @@
$total = $this->ProfilerTotals[$totals_key];
$div_width = Array();
- $total_width = ($this->getWindowWidth()-10);
+ $total_width = ($this->getWindowWidth() - 10);
$div_width['before'] = round(($total_before / $total) * $total_width);
$div_width['current'] = round(($runtime / $total) * $total_width);
$div_width['left'] = round((($total - $total_before - $runtime) / $total) * $total_width);
$ret = 'Name: '.$Data['description'].'
';
+ $additional = isset($Data['additional']) ? $Data['additional'] : Array ();
if (isset($Data['file'])) {
+ array_unshift($additional, Array('name' => 'File', 'value' => $this->getFileLink($Data['file'], $Data['line'], basename($Data['file']).':'.$Data['line'])));
+ }
+ array_unshift($additional, Array('name' => 'Runtime', 'value' => $runtime.'s'));
+
+ foreach ($additional as $mixed_param) {
+ $ret .= '['.$mixed_param['name'].': '.$mixed_param['value'].'] ';
+ }
+
+ /*if (isset($Data['file'])) {
$ret .= '[Runtime: '.$runtime.'s] [File: '.$this->getFileLink($Data['file'], $Data['line'], basename($Data['file']).':'.$Data['line']).']
';
}
else {
- $ret .= 'Runtime: '.$runtime.'s
';
- }
+ $ret .= 'Runtime: '.$runtime.'s
';
+ }*/
$ret .= '
"; print_r($element); echo ""; $extra_attribs = ExtraAttributes($element->attributes); if(strtolower($element->name)==$this->TagPrefix) - { - $field = strtolower($element->attributes["_field"]); + { + $field = strtolower($element->attributes["_field"]); switch($field) - { + { case "id": $ret = $this->Get("LanguageId"); break; @@ -271,7 +271,7 @@ case "link": $t = $element->attributes["_template"]; if(strlen($t)) - { + { $var_list_update["t"] = $t; } else @@ -290,7 +290,7 @@ case "icon": $ret = ""; $icon = $this->Get("IconURL"); - + if(strlen($icon)>0) { $file = $TemplateRoot."/".$icon; @@ -342,12 +342,12 @@ } function SetPrimary($lang_id) - { + { $sql = "UPDATE ".$this->SourceTable." SET PrimaryLang=0 "; $this->adodbConnection->Execute($sql); $l = $this->GetItem($lang_id); - $l->Set('PrimaryLang', 1); - $l->Set('Enabled', 1); + $l->Set('PrimaryLang', 1); + $l->Set('Enabled', 1); $l->Update(); $this->m_Primary = $lang_id; } @@ -356,20 +356,20 @@ { static $skip_quering = false; if ($skip_quering) return $this->m_Primary; - + if(!$this->m_Primary) { $sql = 'SELECT '.$Field.' FROM '.$this->SourceTable.' WHERE PrimaryLang = 1'; $this->m_Primary = $this->adodbConnection->GetOne($sql); $skip_quering = true; } - + return $this->m_Primary; } - + function LoadAllLanguages() { - $sql = "SELECT * FROM ".$this->SourceTable; + $sql = "SELECT * FROM ".$this->SourceTable; $this->Query_Item($sql); } @@ -408,7 +408,7 @@ $new_id=$db->GetOne($sql); $db->Execute('UPDATE '.$this->SourceTable.' SET PrimaryLang = 1, Enabled = 1 WHERE LanguageId = '.$new_id); } - $l->Delete(); + $l->Delete(); } function CopyFromEditTable() @@ -424,9 +424,9 @@ while($rs && !$rs->EOF) { $data = $rs->fields; - $c = $this->AddItemFromArray($data); + $c = $this->AddItemFromArray($data); $c->Dirty(); - + if($c->Get('PrimaryLang') == 1) { $c->Set('Enabled',1); @@ -446,18 +446,18 @@ $id = $c->Get("LanguageId"); $phrase_table = $objSession->GetEditTable("Phrase"); $message_table = $objSession->GetEditTable("EmailMessage"); - $sql = "UPDATE $phrase_table SET LanguageId=$id WHERE LanguageId=$oldid"; + $sql = "UPDATE $phrase_table SET LanguageId=$id WHERE LanguageId=$oldid"; $this->adodbConnection->Execute($sql); - $sql = "UPDATE $message_table SET LanguageId=$id WHERE LanguageId=$oldid"; - $this->adodbConnection->Execute($sql); + $sql = "UPDATE $message_table SET LanguageId=$id WHERE LanguageId=$oldid"; + $this->adodbConnection->Execute($sql); } $rs->MoveNext(); } unset($GLOBALS['_CopyFromEditTable']); } function ExportPhrases($file,$LangIds=NULL,$PhraseTypes=null) - { + { $output = array(); $this->Clear(); $where_parts = Array(); @@ -468,41 +468,41 @@ $objXML = new xml_doc(); $RootNode =& $objXML->getTagByID($objXML->createTag("LANGUAGES")); - + $ret = 0; if($this->NumItems()>0) - { + { $phrase_where = isset($PhraseTypes) ? ' AND PhraseType IN ('.$PhraseTypes.')' : ''; $event_where = isset($PhraseTypes) ? ' AND Type+1 IN ('.$PhraseTypes.')' : ''; foreach($this->Items as $l) - { + { $LangRoot =& $objXML->getTagByID($RootNode->addChild($objXML,"LANGUAGE",array("PackName"=>$l->Get("PackName")),"")); $LangRoot->addChild($objXML,"DATEFORMAT",array(),$l->Get("DateFormat")); $LangRoot->addChild($objXML,"TIMEFORMAT",array(),$l->Get("TimeFormat")); $LangRoot->addChild($objXML,"DECIMAL",array(),$l->Get("DecimalPoint")); $LangRoot->addChild($objXML,"THOUSANDS",array(),$l->Get("ThousandSep")); $LangRoot->addChild($objXML,"CHARSET",array(),$l->Get("Charset")); $PhraseRoot =& $objXML->getTagByID($LangRoot->addChild($objXML,"PHRASES")); - + $sql = "SELECT * FROM ".GetTablePrefix()."Phrase WHERE LanguageId=".$l->Get("LanguageId").$phrase_where; $rs=$this->adodbConnection->Execute($sql); while($rs && ! $rs->EOF) { $PhraseRoot->addChild($objXML,"PHRASE",array("Label"=>$rs->fields["Phrase"],"Type"=>$rs->fields["PhraseType"]),base64_encode($rs->fields["Translation"])); $rs->MoveNext(); } - + $EventRoot =& $objXML->getTagByID($LangRoot->addChild($objXML,"EVENTS")); $ev = GetTablePrefix()."Events"; $em = GetTablePrefix()."EmailMessage"; $sql = "SELECT $em.*,$ev.Event,$ev.Type FROM $em INNER JOIN $ev ON ($em.EventId=$ev.EventId) WHERE LanguageId=".$l->Get("LanguageId").$event_where; - $rs = $this->adodbConnection->Execute($sql); + $rs = $this->adodbConnection->Execute($sql); while($rs && !$rs->EOF) - { - $EventRoot->AddChild($objXML,"EVENT",array("MessageType"=>$rs->fields["MessageType"],"Event"=>$rs->fields["Event"],"Type"=>$rs->fields["Type"]),base64_encode($rs->fields["Template"])); + { + $EventRoot->AddChild($objXML,"EVENT",array("MessageType"=>$rs->fields["MessageType"],"Event"=>$rs->fields["Event"],"Type"=>$rs->fields["Type"]),base64_encode($rs->fields["Template"])); $rs->MoveNext(); - } + } } $objXML->generate(); $objXML->xml = str_replace("&","&",$objXML->xml); @@ -514,12 +514,12 @@ } function ReadImportTable($TableName, $SetEnabled=0, $Types="0,1", $OverwitePhrases=FALSE, $MaxInserts=100, $Offset=0) - { + { global $objPhraseList; - + if(!is_object($objPhraseList)) $objPhraseList = new clsPhraseList(); - + $PhraseList = new clsPhraseList(); $TypeArray = explode(",",$Types); $Inserts = 0; @@ -536,7 +536,7 @@ if(is_object($p)) { if($OverwitePhrases) - { + { //$p->debuglevel=1; $p->Set("Translation",$i->Get("Translation")); //echo $i->Get("Translation")."
Bad $rs in %s. Connection or SQL invalid. Try using $connection->debug=true;
'); - + adodb_safeDefine('ADODB_FETCH_DEFAULT',0); adodb_safeDefine('ADODB_FETCH_NUM',1); adodb_safeDefine('ADODB_FETCH_ASSOC',2); adodb_safeDefine('ADODB_FETCH_BOTH',3); - + /* Controls ADODB_FETCH_ASSOC field-name case. Default is 2, use native case-names. This currently works only with mssql, odbc, oci8po and ibase derived drivers. - + 0 = assoc lowercase field names. $rs->fields['orderid'] 1 = assoc uppercase field names. $rs->fields['ORDERID'] 2 = use native-case field names. $rs->fields['OrderID'] */ if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2); - + // allow [ ] @ ` and . in table names adodb_safeDefine('ADODB_TABLE_REGEX','([]0-9a-z_\`\.\@\[-]*)'); - - + + if (!defined('ADODB_PREFETCH_ROWS')) define('ADODB_PREFETCH_ROWS',10); - /** + /** * Set ADODB_DIR to the directory where this file resides... * This constant was formerly called $ADODB_RootPath */ if (!defined('ADODB_DIR')) define('ADODB_DIR',dirname(__FILE__)); - + if (!defined('TIMESTAMP_FIRST_YEAR')) define('TIMESTAMP_FIRST_YEAR',100); - - //============================================================================================== + + //============================================================================================== // GLOBAL VARIABLES - //============================================================================================== + //============================================================================================== - GLOBAL + GLOBAL $ADODB_vers, // database version $ADODB_Database, // last database driver used $ADODB_COUNTRECS, // count number of records returned - slows down query $ADODB_CACHE_DIR, // directory to cache recordsets $ADODB_EXTENSION, // ADODB extension installed $ADODB_COMPAT_PATCH, // If $ADODB_COUNTRECS and this is true, $rs->fields is available on EOF $ADODB_FETCH_MODE; // DEFAULT, NUM, ASSOC or BOTH. Default follows native driver default... - - //============================================================================================== + + //============================================================================================== // GLOBAL SETUP - //============================================================================================== - + //============================================================================================== + if (!defined('ADODB_PHPVER')) { if (strnatcmp(PHP_VERSION,'4.3.0')>=0) { define('ADODB_PHPVER',0x4300); @@ -112,14 +112,14 @@ } $ADODB_EXTENSION = defined('ADODB_EXTENSION'); //if (extension_loaded('dbx')) define('ADODB_DBX',1); - + /** Accepts $src and $dest arrays, replacing string $data */ function ADODB_str_replace($src, $dest, $data) { if (ADODB_PHPVER >= 0x4050) return str_replace($src,$dest,$data); - + $s = reset($src); $d = reset($dest); while ($s !== false) { @@ -129,109 +129,109 @@ } return $data; } - + function ADODB_Setup() { - GLOBAL + GLOBAL $ADODB_vers, // database version $ADODB_Database, // last database driver used $ADODB_COUNTRECS, // count number of records returned - slows down query $ADODB_CACHE_DIR, // directory to cache recordsets $ADODB_FETCH_MODE; - + $ADODB_FETCH_MODE = ADODB_FETCH_DEFAULT; - + if (!isset($ADODB_CACHE_DIR)) { $ADODB_CACHE_DIR = '/tmp'; } else { // do not accept url based paths, eg. http:/ or ftp:/ - if (strpos($ADODB_CACHE_DIR,'://') !== false) + if (strpos($ADODB_CACHE_DIR,'://') !== false) die("Illegal path http:// or ftp://"); } - - + + // Initialize random number generator for randomizing cache flushes srand(((double)microtime())*1000000); - + /** * Name of last database driver loaded into memory. Set by ADOLoadCode(). */ $ADODB_Database = ''; - + /** * ADODB version as a string. */ $ADODB_vers = 'V3.60 16 June 2003 (c) 2000-2003 John Lim (jlim@natsoft.com.my). All rights reserved. Released BSD & LGPL.'; - + /** - * Determines whether recordset->RecordCount() is used. + * Determines whether recordset->RecordCount() is used. * Set to false for highest performance -- RecordCount() will always return -1 then * for databases that provide "virtual" recordcounts... */ - $ADODB_COUNTRECS = true; + $ADODB_COUNTRECS = true; } - - - //============================================================================================== + + + //============================================================================================== // CHANGE NOTHING BELOW UNLESS YOU ARE CODING - //============================================================================================== - + //============================================================================================== + ADODB_Setup(); - //============================================================================================== + //============================================================================================== // CLASS ADOFieldObject - //============================================================================================== + //============================================================================================== /** * Helper class for FetchFields -- holds info on a column */ - class ADOFieldObject { + class ADOFieldObject { var $name = ''; var $max_length=0; var $type=""; // additional fields by dannym... (danny_milo@yahoo.com) - var $not_null = false; + var $not_null = false; // actually, this has already been built-in in the postgres, fbsql AND mysql module? ^-^ // so we can as well make not_null standard (leaving it at "false" does not harm anyways) - var $has_default = false; // this one I have done only in mysql and postgres for now ... + var $has_default = false; // this one I have done only in mysql and postgres for now ... // others to come (dannym) var $default_value; // default, if any, and supported. Check has_default first. } - - + + function ADODB_TransMonitor($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection) { //print "Errorno ($fn errno=$errno m=$errmsg) "; - + $thisConnection->_transOK = false; if ($thisConnection->_oldRaiseFn) { $fn = $thisConnection->_oldRaiseFn; $fn($dbms, $fn, $errno, $errmsg, $p1, $p2,$thisConnection); } } - - //============================================================================================== + + //============================================================================================== // CLASS ADOConnection - //============================================================================================== - + //============================================================================================== + /** * Connection object. For connecting to databases, and executing queries. - */ + */ class ADOConnection { // - // PUBLIC VARS + // PUBLIC VARS // var $dataProvider = 'native'; - var $databaseType = ''; /// RDBMS currently in use, eg. odbc, mysql, mssql - var $database = ''; /// Name of database to be used. - var $host = ''; /// The hostname of the database server - var $user = ''; /// The username which is used to connect to the database server. + var $databaseType = ''; /// RDBMS currently in use, eg. odbc, mysql, mssql + var $database = ''; /// Name of database to be used. + var $host = ''; /// The hostname of the database server + var $user = ''; /// The username which is used to connect to the database server. var $password = ''; /// Password for the username. For security, we no longer store it. var $debug = false; /// if set to true will output sql statements var $maxblobsize = 256000; /// maximum size of blobs or large text fields -- some databases die otherwise like foxpro - var $concat_operator = '+'; /// default concat operator -- change to || for Oracle/Interbase + var $concat_operator = '+'; /// default concat operator -- change to || for Oracle/Interbase var $fmtDate = "'Y-m-d'"; /// used by DBDate() as the default date format used by the database var $fmtTimeStamp = "'Y-m-d, h:i:s A'"; /// used by DBTimeStamp as the default timestamp fmt. var $true = '1'; /// string that represents TRUE for a database @@ -260,9 +260,9 @@ var $sysDate = false; /// name of function that returns the current date var $sysTimeStamp = false; /// name of function that returns the current timestamp var $arrayClass = 'ADORecordSet_array'; /// name of class used to generate array recordsets, which are pre-downloaded recordsets - + var $noNullStrings = false; /// oracle specific stuff - if true ensures that '' is converted to ' ' - var $numCacheHits = 0; + var $numCacheHits = 0; var $numCacheMisses = 0; var $pageExecuteCountRows = true; var $uniqueSort = false; /// indicates that all fields in order by must be unique @@ -271,77 +271,77 @@ var $ansiOuter = false; /// whether ansi outer join syntax supported var $autoRollback = false; // autoRollback on PConnect(). var $poorAffectedRows = false; // affectedRows not working or unreliable - + var $fnExecute = false; var $fnCacheExecute = false; var $blobEncodeType = false; // false=not required, 'I'=encode to integer, 'C'=encode to char var $dbxDriver = false; - + // // PRIVATE VARS // var $_oldRaiseFn = false; var $_transOK = null; - var $_connectionID = false; /// The returned link identifier whenever a successful database connection is made. + var $_connectionID = false; /// The returned link identifier whenever a successful database connection is made. var $_errorMsg = ''; /// A variable which was used to keep the returned last error message. The value will - /// then returned by the errorMsg() function - + /// then returned by the errorMsg() function + var $_queryID = false; /// This variable keeps the last created result link identifier - + var $_isPersistentConnection = false; /// A boolean variable to state whether its a persistent connection or normal connection. */ var $_bindInputArray = false; /// set to true if ADOConnection.Execute() permits binding of array parameters. var $autoCommit = true; /// do not modify this yourself - actually private var $transOff = 0; /// temporarily disable transactions var $transCnt = 0; /// count of nested transactions - + var $fetchMode=false; - + /** * Constructor */ - function ADOConnection() + function ADOConnection() { die('Virtual Class -- cannot instantiate'); } - + /** Get server version info... - - @returns An array with 2 elements: $arr['string'] is the description string, + + @returns An array with 2 elements: $arr['string'] is the description string, and $arr[version] is the version (also a string). */ function ServerInfo() { return array('description' => '', 'version' => ''); } - + function _findvers($str) { if (preg_match('/([0-9]+\.([0-9\.])+)/',$str, $arr)) return $arr[1]; else return ''; } - + /** * All error messages go through this bottleneck function. * You can define your own handler by defining the function name in ADODB_OUTP. */ function outp($msg,$newline=true) { global $HTTP_SERVER_VARS; - + if (defined('ADODB_OUTP')) { $fn = ADODB_OUTP; $fn($msg,$newline); return; } - + if ($newline) $msg .= "$ss
\nInsert_ID error
'); return false; } - - + + /** * Portable Insert ID. Pablo RocaAffected_Rows error
',false); return false; } - - + + /** * @return the last error message */ function ErrorMsg() { return '!! '.strtoupper($this->dataProvider.' '.$this->databaseType).': '.$this->_errorMsg; } - - + + /** * @return the last error number. Normally 0 means no error. */ - function ErrorNo() + function ErrorNo() { return ($this->_errorMsg) ? -1 : 0; } - + function MetaError($err=false) { include_once(ADODB_DIR."/adodb-error.inc.php"); if ($err === false) $err = $this->ErrorNo(); return adodb_error($this->dataProvider,$this->databaseType,$err); } - + function MetaErrorMsg($errno) { include_once(ADODB_DIR."/adodb-error.inc.php"); return adodb_errormsg($errno); } - + /** * @returns an array with the primary key columns in it. */ @@ -960,24 +960,24 @@ if (sizeof($p)) return $p; return false; } - - + + /** * Choose a database to connect to. Many databases do not support this. * * @param dbName is the name of the database to select * @return true or false */ - function SelectDB($dbName) + function SelectDB($dbName) {return false;} - - + + /** - * Will select, getting rows from $offset (1-based), for $nrows. + * Will select, getting rows from $offset (1-based), for $nrows. * This simulates the MySQL "select * from table limit $offset,$nrows" , and * the PostgreSQL "select * from table limit $nrows offset $offset". Note that * MySQL and PostgreSQL parameter ordering is the opposite of the other. - * eg. + * eg. * SelectLimit('select * from table',3); will return rows 1 to 3 (1-based) * SelectLimit('select * from table',3,2); will return rows 3 to 5 (1-based) * @@ -995,14 +995,14 @@ function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$arg3=false,$secs2cache=0) { if ($this->hasTop && $nrows > 0) { - // suggested by Reinhard Balling. Access requires top after distinct + // suggested by Reinhard Balling. Access requires top after distinct // Informix requires first before distinct - F Riosa $ismssql = (strpos($this->databaseType,'mssql') !== false); if ($ismssql) $isaccess = false; else $isaccess = (strpos($this->databaseType,'access') !== false); - + if ($offset <= 0) { - + // access includes ties in result if ($isaccess) { $sql = preg_replace( @@ -1028,14 +1028,14 @@ } } } - + // if $offset>0, we want to skip rows, and $ADODB_COUNTRECS is set, we buffer rows // 0 to offset-1 which will be discarded anyway. So we disable $ADODB_COUNTRECS. global $ADODB_COUNTRECS; - + $savec = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; - + if ($offset>0){ if ($secs2cache>0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr,$arg3); else $rs = &$this->Execute($sql,$inputarr,$arg3); @@ -1050,8 +1050,8 @@ //print_r($rs); return $rs; } - - + + /** * Convert database recordset to an array recordset * input recordset's cursor should be at beginning, and @@ -1065,7 +1065,7 @@ function &_rs2rs(&$rs,$nrows=-1,$offset=-1,$close=true) { if (! $rs) return false; - + $dbtype = $rs->databaseType; if (!$dbtype) { $rs = &$rs; // required to prevent crashing in 4.2.1, but does not happen in 4.3.1 -- why ? @@ -1083,23 +1083,23 @@ $arr =& $rs->GetArrayLimit($nrows,$offset); //print_r($arr); if ($close) $rs->Close(); - + $arrayClass = $this->arrayClass; - + $rs2 = new $arrayClass(); $rs2->connection = &$this; $rs2->sql = $rs->sql; $rs2->dataProvider = $this->dataProvider; $rs2->InitArrayFields($arr,$flds); return $rs2; } - - + + function &GetArray($sql, $inputarr=false) { return $this->GetAll($sql,$inputarr); } - + /** * Return first element of first row of sql statement. Recordset is disposed * for you. @@ -1112,31 +1112,31 @@ global $ADODB_COUNTRECS; $crecs = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; - + $ret = false; $rs = &$this->Execute($sql,$inputarr); - if ($rs) { + if ($rs) { if (!$rs->EOF) $ret = reset($rs->fields); $rs->Close(); - } + } $ADODB_COUNTRECS = $crecs; return $ret; } - + function CacheGetOne($secs2cache,$sql=false,$inputarr=false) { $ret = false; $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); - if ($rs) { + if ($rs) { if (!$rs->EOF) $ret = reset($rs->fields); $rs->Close(); - } - + } + return $ret; } - + function GetCol($sql, $inputarr = false, $trim = false) - { + { $rv = false; $rs = &$this->Execute($sql, $inputarr); @@ -1154,10 +1154,10 @@ } $rs->Close(); } - + return $rv; } - + function CacheGetCol($secs, $sql = false, $inputarr = false,$trim=false) { $rv = false; @@ -1178,21 +1178,21 @@ } return $rv; } - + /* Calculate the offset of a date for a particular database and generate appropriate SQL. Useful for calculating future/past dates and storing in a database. - + If dayFraction=1.5 means 1.5 days from now, 1.0/24 for 1 hour. */ function OffsetDate($dayFraction,$date=false) - { + { if (!$date) $date = $this->sysDate; return '('.$date.'+'.$dayFraction.')'; } - - + + /** * Return all rows. Compat with PEAR DB * @@ -1202,40 +1202,40 @@ function &GetAll($sql,$inputarr=false) { global $ADODB_COUNTRECS; - + $savec = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; $rs = $this->Execute($sql,$inputarr); $ADODB_COUNTRECS = $savec; - - if (!$rs) + + if (!$rs) if (defined('ADODB_PEAR')) return ADODB_PEAR_Error(); else return false; $arr =& $rs->GetArray(); $rs->Close(); return $arr; } - + function &CacheGetAll($secs2cache,$sql=false,$inputarr=false) { global $ADODB_COUNTRECS; - + $savec = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; $rs = $this->CacheExecute($secs2cache,$sql,$inputarr); $ADODB_COUNTRECS = $savec; - - if (!$rs) + + if (!$rs) if (defined('ADODB_PEAR')) return ADODB_PEAR_Error(); else return false; - + $arr =& $rs->GetArray(); $rs->Close(); return $arr; } - - - + + + /** * Return one row of sql statement. Recordset is disposed for you. * @@ -1247,20 +1247,20 @@ global $ADODB_COUNTRECS; $crecs = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; - + $rs = $this->Execute($sql,$inputarr); - + $ADODB_COUNTRECS = $crecs; if ($rs) { $arr = array(); if (!$rs->EOF) $arr = $rs->fields; $rs->Close(); return $arr; } - + return false; } - + function &CacheGetRow($secs2cache,$sql=false,$inputarr=false) { $rs = $this->CacheExecute($secs2cache,$sql,$inputarr); @@ -1272,9 +1272,9 @@ } return false; } - + /** - * Insert or replace a single record. Note: this is not the same as MySQL's replace. + * Insert or replace a single record. Note: this is not the same as MySQL's replace. * ADOdb's Replace() uses update-insert semantics, not insert-delete-duplicates of MySQL. * Also note that no table locking is done currently, so it is possible that the * record be inserted twice by two programs... @@ -1290,15 +1290,15 @@ * * Currently blob replace not supported * - * returns 0 = fail, 1 = update, 2 = insert + * returns 0 = fail, 1 = update, 2 = insert */ - + function Replace($table, $fieldArray, $keyCol, $autoQuote=false, $has_autoinc=false) { if (count($fieldArray) == 0) return 0; $first = true; $uSet = ''; - + if (!is_array($keyCol)) { $keyCol = array($keyCol); } @@ -1308,14 +1308,14 @@ $fieldArray[$k] = $v; } if (in_array($k,$keyCol)) continue; // skip UPDATE if is key - + if ($first) { - $first = false; + $first = false; $uSet = "$k=$v"; } else $uSet .= ",$k=$v"; } - + $first = true; foreach ($keyCol as $v) { if ($first) { @@ -1325,55 +1325,55 @@ $where .= " and $v=$fieldArray[$v]"; } } - + if ($uSet) { $update = "UPDATE $table SET $uSet WHERE $where"; - + $rs = $this->Execute($update); if ($rs) { if ($this->poorAffectedRows) { /* - The Select count(*) wipes out any errors that the update would have returned. + The Select count(*) wipes out any errors that the update would have returned. http://phplens.com/lens/lensforum/msgs.php?id=5696 */ if ($this->ErrorNo()<>0) return 0; - + # affected_rows == 0 if update field values identical to old values - # for mysql - which is silly. - + # for mysql - which is silly. + $cnt = $this->GetOne("select count(*) from $table where $where"); if ($cnt > 0) return 1; // record already exists } else if (($this->Affected_Rows()>0)) return 1; } - + } // print "Error=".$this->ErrorNo().'
';
$first = true;
foreach($fieldArray as $k => $v) {
if ($has_autoinc && in_array($k,$keyCol)) continue; // skip autoinc col
-
+
if ($first) {
- $first = false;
+ $first = false;
$iCols = "$k";
$iVals = "$v";
} else {
$iCols .= ",$k";
$iVals .= ",$v";
- }
+ }
}
- $insert = "INSERT INTO $table ($iCols) VALUES ($iVals)";
+ $insert = "INSERT INTO $table ($iCols) VALUES ($iVals)";
$rs = $this->Execute($insert);
return ($rs) ? 2 : 0;
}
-
-
+
+
/**
- * Will select, getting rows from $offset (1-based), for $nrows.
+ * Will select, getting rows from $offset (1-based), for $nrows.
* This simulates the MySQL "select * from table limit $offset,$nrows" , and
* the PostgreSQL "select * from table limit $nrows offset $offset". Note that
* MySQL and PostgreSQL parameter ordering is the opposite of the other.
- * eg.
+ * eg.
* CacheSelectLimit(15,'select * from table',3); will return rows 1 to 3 (1-based)
* CacheSelectLimit(15,'select * from table',3,2); will return rows 3 to 5 (1-based)
*
@@ -1388,7 +1388,7 @@
* @return the recordset ($rs->databaseType == 'array')
*/
function &CacheSelectLimit($secs2cache,$sql,$nrows=-1,$offset=-1,$inputarr=false, $arg3=false)
- {
+ {
if (!is_numeric($secs2cache)) {
if ($sql === false) $sql = -1;
if ($offset == -1) $offset = false;
@@ -1399,20 +1399,20 @@
return $this->SelectLimit($sql,$nrows,$offset,$inputarr,$arg3,$secs2cache);
}
}
-
+
/**
- * Flush cached recordsets that match a particular $sql statement.
+ * Flush cached recordsets that match a particular $sql statement.
* If $sql == false, then we purge all files in the cache.
*/
function CacheFlush($sql=false,$inputarr=false)
{
global $ADODB_CACHE_DIR;
-
+
if (strlen($ADODB_CACHE_DIR) > 1 && !$sql) {
if (strpos(strtoupper(PHP_OS),'WIN') !== false) {
$cmd = 'del /s '.str_replace('/','\\',$ADODB_CACHE_DIR).'\adodb_*.cache';
} else {
- $cmd = 'rm -rf '.$ADODB_CACHE_DIR.'/??/adodb_*.cache';
+ $cmd = 'rm -rf '.$ADODB_CACHE_DIR.'/??/adodb_*.cache';
// old version 'rm -f `find '.$ADODB_CACHE_DIR.' -name adodb_*.cache`';
}
if ($this->debug) {
@@ -1421,12 +1421,12 @@
exec($cmd);
}
return;
- }
+ }
$f = $this->_gencachename($sql.serialize($inputarr),false);
adodb_write_file($f,''); // is adodb_write_file needed?
@unlink($f);
}
-
+
/**
* Private function to generate filename for caching.
* Filename is generated based on:
@@ -1436,30 +1436,30 @@
* - database name
* - userid
*
- * We create 256 sub-directories in the cache directory ($ADODB_CACHE_DIR).
- * Assuming that we can have 50,000 files per directory with good performance,
+ * We create 256 sub-directories in the cache directory ($ADODB_CACHE_DIR).
+ * Assuming that we can have 50,000 files per directory with good performance,
* then we can scale to 12.8 million unique cached recordsets. Wow!
*/
function _gencachename($sql,$createdir)
{
global $ADODB_CACHE_DIR;
-
+
$m = md5($sql.$this->databaseType.$this->database.$this->user);
$dir = $ADODB_CACHE_DIR.'/'.substr($m,0,2);
if ($createdir && !file_exists($dir)) {
$oldu = umask(0);
- if (!mkdir($dir,0771))
+ if (!mkdir($dir,0771))
if ($this->debug) ADOConnection::outp( "Unable to mkdir $dir for $sql");
umask($oldu);
}
return $dir.'/adodb_'.$m.'.cache';
}
-
-
+
+
/**
* Execute SQL, caching recordsets.
*
- * @param [secs2cache] seconds to cache data, set to 0 to force query.
+ * @param [secs2cache] seconds to cache data, set to 0 to force query.
* This is an optional parameter.
* @param sql SQL statement to execute
* @param [inputarr] holds the input data to bind to
@@ -1475,10 +1475,10 @@
$secs2cache = $this->cacheSecs;
}
include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
-
+
$md5file = $this->_gencachename($sql.serialize($inputarr),true);
$err = '';
-
+
if ($secs2cache > 0){
$rs = &csv2rs($md5file,$err,$secs2cache);
$this->numCacheHits += 1;
@@ -1500,7 +1500,7 @@
$eof = $rs->EOF;
$rs = &$this->_rs2rs($rs); // read entire recordset into memory immediately
$txt = _rs2serialize($rs,false,$sql); // serialize
-
+
if (!adodb_write_file($md5file,$txt,$this->debug)) {
if ($fn = $this->raiseErrorFn) {
$fn($this->databaseType,'CacheExecute',-32000,"Cache write error",$md5file,$sql,$this);
@@ -1509,10 +1509,10 @@
}
if ($rs->EOF && !$eof) {
$rs->MoveFirst();
- //$rs = &csv2rs($md5file,$err);
+ //$rs = &csv2rs($md5file,$err);
$rs->connection = &$this; // Pablo suggestion
- }
-
+ }
+
} else
@unlink($md5file);
} else {
@@ -1522,28 +1522,28 @@
}
// ok, set cached object found
$rs->connection = &$this; // Pablo suggestion
- if ($this->debug){
+ if ($this->debug){
global $HTTP_SERVER_VARS;
-
+
$inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']);
$ttl = $rs->timeCreated + $secs2cache - time();
$s = is_array($sql) ? $sql[0] : $sql;
if ($inBrowser) $s = ''.htmlspecialchars($s).'';
-
+
ADOConnection::outp( " $md5file reloaded, ttl=$ttl [ $s ]");
}
}
return $rs;
}
-
-
+
+
/**
* Generates an Update Query based on an existing recordset.
* $arrFields is an associative array of fields with the value
* that should be assigned.
*
* Note: This function should only be used on a recordset
- * that is run against a single table and sql should only
+ * that is run against a single table and sql should only
* be a simple select stmt with no groupby/orderby/limit
*
* "Jonathan Younger" ADONewConnection: Unable to load database driver '$db'
\n");
$ok = false;
}
-
+
return $ok;
}
-
+
function adodb_backtrace($print=true)
{
$s = '';
if (PHPVERSION() >= 4.3) {
-
+
$MAXSTRLEN = 64;
-
+
$s = '';
$traceArr = debug_backtrace();
array_shift($traceArr);
$tabs = sizeof($traceArr)-1;
-
+
foreach ($traceArr as $arr) {
$args = array();
for ($i=0; $i < $tabs; $i++) $s .= ' ';
@@ -3386,7 +3386,7 @@
else if (is_array($v)) $args[] = 'Array['.sizeof($v).']';
else if (is_object($v)) $args[] = 'Object:'.get_class($v);
else if (is_bool($v)) $args[] = $v ? 'true' : 'false';
- else {
+ else {
$v = (string) @$v;
$str = htmlspecialchars(substr($v,0,$MAXSTRLEN));
if (strlen($v) > $MAXSTRLEN) $str .= '...';
@@ -3397,12 +3397,12 @@
$s .= @sprintf(" # line %4d, file: %s",
$arr['line'],$arr['file'],$arr['file']);
$s .= "\n";
- }
+ }
$s .= '
';
if ($print) print $s;
}
return $s;
}
-
+
} // defined
?>
\ No newline at end of file
Index: trunk/kernel/include/modules.php
===================================================================
diff -u -N -r8029 -r8436
--- trunk/kernel/include/modules.php (.../modules.php) (revision 8029)
+++ trunk/kernel/include/modules.php (.../modules.php) (revision 8436)
@@ -967,7 +967,6 @@
/*create the global current user object */
$UserID=$objSession->Get("PortalUserId");
$objCurrentUser = new clsPortalUser($UserID);
-$objLanguageCache = new clsLanguageCache($m_var_list["lang"]);
/* include each module's action.php script */
LogEntry("Loading Module action scripts\n");
Index: trunk/kernel/include/error.php
===================================================================
diff -u -N -r3282 -r8436
--- trunk/kernel/include/error.php (.../error.php) (revision 3282)
+++ trunk/kernel/include/error.php (.../error.php) (revision 8436)
@@ -4,7 +4,7 @@
{
var $m_Message;
var $m_Field;
-
+
function clsError($message,$field)
{
$this->SetMessage($message);
@@ -15,25 +15,25 @@
{
return $this->m_Message;
}
-
- function SetMessage($value)
+
+ function SetMessage($value)
{
$this->m_Message = $value;
}
-
- function GetField()
+
+ function GetField()
{
return $this->m_Field;
}
-
- function SetField($value)
+
+ function SetField($value)
{
$this->m_Field = $value;
}
-
+
}
-class clsErrorManager
+class clsErrorManager
{
var $m_errorsMap = array();
@@ -61,7 +61,7 @@
{
return $this->config[$property];
}
-
+
function Set($property, $value)
{
$varname = "m_".$property;
@@ -70,7 +70,7 @@
function ClearErrors()
- {
+ {
unset($this->m_Errors);
$this->m_CurrentError = 0;
$this->m_UserErrors = array();
@@ -80,26 +80,26 @@
{
$this->m_Language=$lang;
}
-
+
function AddAdminUserError($errorLang)
{
$this->m_UserErrors[] = $errorLang;
}
-
+
function GetAdminUserErrors()
{
return $this->m_UserErrors;
- }
+ }
function AddError($errorPhrase, $errorField=NULL,$arg1 = NULL,$arg2 = NULL,$arg3 = NULL,$arg4 = NULL,$fatal=FALSE)
{
- global $g_DebugMode, $objLanguageCache, $g_ErrorLog;
-
-
+ global $g_DebugMode, $g_ErrorLog;
+
+
$errorText = "";
//$arg3::$arg4\t$errorPhrase\t$arg1 #arg2
- $errorText = "%s::%s\t%s\t%s %s\n";
+ $errorText = "%s::%s\t%s\t%s %s\n";
$errorMessage = sprintf($errorText,$arg3,$arg4,$errorPhrase,$arg1,$arg2);
$error = new clsError($errorMessage, $errorField);
@@ -130,7 +130,7 @@
else
{
return "";
- }
+ }
}
function GetNextError()
@@ -143,7 +143,7 @@
return FALSE;
}
-
+
function HandleErrors($postBackUrl)
{
@@ -191,9 +191,9 @@
function Permission_Error($message)
-{
+{
global $PermissionError;
-
+
$PermissionError = $message;
/* here we can do some logging or other cool stuff */
}
Index: trunk/core/kernel/db/db_connection.php
===================================================================
diff -u -N -r8104 -r8436
--- trunk/core/kernel/db/db_connection.php (.../db_connection.php) (revision 8104)
+++ trunk/core/kernel/db/db_connection.php (.../db_connection.php) (revision 8436)
@@ -13,23 +13,23 @@
* @access private
*/
var $dbType = 'mysql';
-
+
/**
* Created connection handle
*
* @var resource
* @access private
*/
var $connectionID = null;
-
+
/**
* Handle of currenty processed recordset
*
* @var resource
* @access private
*/
var $queryID = null;
-
+
/**
* DB type specific function mappings
*
@@ -53,7 +53,7 @@
* @access private
*/
var $errorCode = 0;
-
+
/**
* Error message
*
@@ -77,7 +77,7 @@
* @var string
*/
var $lastQuery = '';
-
+
/**
* Initializes connection class with
* db type to used in future
@@ -157,7 +157,7 @@
/*if (!isset($this->metaFunctions[$name])) {
$this->metaFunctions[$name] = $name;
}*/
-
+
return $this->dbType.'_'.$name;
}
@@ -402,7 +402,7 @@
}
// set 2nd checkpoint: begin
if(!$isSkipTable) {
- $debugger->profileFinish('sql_'.$queryID);
+ $debugger->profileFinish('sql_'.$queryID, null, null, $this->getAffectedRows());
$debugger->profilerAddTotal('sql', 'sql_'.$queryID);
}
$this->Destroy();
@@ -412,7 +412,7 @@
else {
// set 2nd checkpoint: begin
if(!$isSkipTable) {
- $debugger->profileFinish('sql_'.$queryID);
+ $debugger->profileFinish('sql_'.$queryID, null, null, $this->getAffectedRows());
$debugger->profilerAddTotal('sql', 'sql_'.$queryID);
}
// set 2nd checkpoint: end
@@ -572,7 +572,7 @@
return $this->ChangeQuery($sql);
}
-
+
/**
* Allows to detect table's presense in database
*
@@ -582,15 +582,15 @@
function TableFound($table_name)
{
static $table_found = Array();
-
+
if (!preg_match('/^'.preg_quote(TABLE_PREFIX, '/').'(.*)/', $table_name)) {
$table_name = TABLE_PREFIX.$table_name;
}
-
+
if (!isset($table_found[$table_name])) {
$table_found[$table_name] = $this->Query('SHOW TABLES LIKE "'.$table_name.'"');
}
-
+
return $table_found[$table_name];
}
}