Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 535

Přidáno uživatelem Michal Kliment před asi 15 roky(ů)

Mensi optimalizace - nyni by mel freenetis fungovat i v PHP 5.3. Mensi
oprava bugu pri instalaci.

Zobrazit rozdíly:

freenetis/trunk/kohana/application/vendors/phpgacl/gacl.class.php
require_once( ADODB_DIR .'/adodb-pager.inc.php');
if (is_object($this->_db)) {
$this->db = &$this->_db;
$this->db = $this->_db;
} else {
$this->db = ADONewConnection($this->_db_type);
//Use NUM for slight performance/memory reasons.
......
return FALSE;
}
$row =& $rs->FetchRow();
$row = $rs->FetchRow();
/*
* Return ACL ID. This is the key to "hooking" extras like pricing assigned to ACLs etc... Very useful.
......
$allow = FALSE;
}
$retarr = array('acl_id' => &$row[0], 'return_value' => &$row[2], 'allow' => $allow);
$retarr = array('acl_id' => $row[0], 'return_value' => $row[2], 'allow' => $allow);
} else {
// Permission denied.
$retarr = array('acl_id' => NULL, 'return_value' => NULL, 'allow' => FALSE);
......
* Return the query that we ran if in debug mode.
*/
if ($debug == TRUE) {
$retarr['query'] = &$query;
$retarr['query'] = $query;
}
//Cache data.
freenetis/trunk/kohana/application/vendors/phpgacl/adodb/adodb.inc.php
function ADODB_TransMonitor($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection)
function ADODB_TransMonitor($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
{
//print "Errorno ($fn errno=$errno m=$errmsg) ";
$thisConnection->_transOK = false;
......
else echo strip_tags($msg);
if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); // do not flush if output buffering enabled - useless - thx to Jesse Mullan
if (!empty($ADODB_FLUSH) AND ob_get_length() !== false) flush(); // do not flush if output buffering enabled - useless - thx to Jesse Mullan
}
function Time()
{
$rs =& $this->_Execute("select $this->sysTimeStamp");
if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields));
$rs =$this->_Execute("select $this->sysTimeStamp");
if ($rs AND !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields));
return false;
}
......
return $this->qstr($s,get_magic_quotes_gpc());
}
function q(&$s)
function q($s)
{
#if (!empty($this->qNull)) if ($s == 'null') return $s;
$s = $this->qstr($s,false);
......
/**
* PEAR DB Compat - do not use internally.
*/
function &Query($sql, $inputarr=false)
function Query($sql, $inputarr=false)
{
$rs = &$this->Execute($sql, $inputarr);
if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error();
$rs = $this->Execute($sql, $inputarr);
if (!$rs AND defined('ADODB_PEAR')) return ADODB_PEAR_Error();
return $rs;
}
......
/**
* PEAR DB Compat - do not use internally
*/
function &LimitQuery($sql, $offset, $count, $params=false)
function LimitQuery($sql, $offset, $count, $params=false)
{
$rs = &$this->SelectLimit($sql, $count, $offset, $params);
if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error();
$rs = $this->SelectLimit($sql, $count, $offset, $params);
if (!$rs AND defined('ADODB_PEAR')) return ADODB_PEAR_Error();
return $rs;
}
......
/*
InParameter and OutParameter are self-documenting versions of Parameter().
*/
function InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false)
function InParameter($stmt,$var,$name,$maxLen=4000,$type=false)
{
return $this->Parameter($stmt,$var,$name,false,$maxLen,$type);
}
/*
*/
function OutParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false)
function OutParameter($stmt,$var,$name,$maxLen=4000,$type=false)
{
return $this->Parameter($stmt,$var,$name,true,$maxLen,$type);
......
@param [$type] The data type of $var. Legal values depend on driver.
*/
function Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false)
function Parameter($stmt,$var,$name,$isOutput=false,$maxLen=4000,$type=false)
{
return false;
}
......
$this->raiseErrorFn = $errfn;
$this->_transOK = true;
if ($this->debug && $this->transCnt > 0) ADOConnection::outp("Bad Transaction: StartTrans called within BeginTrans");
if ($this->debug AND $this->transCnt > 0) ADOConnection::outp("Bad Transaction: StartTrans called within BeginTrans");
$this->BeginTrans();
$this->transOff = 1;
}
......
$this->raiseErrorFn = $this->_oldRaiseFn;
$this->transOff = 0;
if ($this->_transOK && $autoComplete) {
if ($this->_transOK AND $autoComplete) {
if (!$this->CommitTrans()) {
$this->_transOK = false;
if ($this->debug) ADOConnection::outp("Smart Commit failed");
......
* @param [inputarr] holds the input data to bind to. Null elements will be set to null.
* @return RecordSet or false
*/
function &Execute($sql,$inputarr=false)
function Execute($sql,$inputarr=false)
{
if ($this->fnExecute) {
$fn = $this->fnExecute;
$ret =& $fn($this,$sql,$inputarr);
$ret =$fn($this,$sql,$inputarr);
if (isset($ret)) return $ret;
}
if ($inputarr) {
......
$element0 = reset($inputarr);
# is_object check because oci8 descriptors can be passed in
$array_2d = is_array($element0) && !is_object(reset($element0));
$array_2d = is_array($element0) AND !is_object(reset($element0));
//remove extra memory copy of input -mikefedyk
unset($element0);
if (!is_array($sql) && !$this->_bindInputArray) {
if (!is_array($sql) AND !$this->_bindInputArray) {
$sqlarr = explode('?',$sql);
if (!$array_2d) $inputarr = array($inputarr);
......
} else if ($i != sizeof($sqlarr))
ADOConnection::outp( "Input array does not match ?: ".htmlspecialchars($sql));
$ret =& $this->_Execute($sql);
$ret =$this->_Execute($sql);
if (!$ret) return $ret;
}
} else {
......
$stmt = $sql;
foreach($inputarr as $arr) {
$ret =& $this->_Execute($stmt,$arr);
$ret =$this->_Execute($stmt,$arr);
if (!$ret) return $ret;
}
} else {
$ret =& $this->_Execute($sql,$inputarr);
$ret =$this->_Execute($sql,$inputarr);
}
}
} else {
$ret =& $this->_Execute($sql,false);
$ret =$this->_Execute($sql,false);
}
return $ret;
}
function &_Execute($sql,$inputarr=false)
function _Execute($sql,$inputarr=false)
{
if ($this->debug) {
global $ADODB_INCLUDED_LIB;
......
}
if ($this->_queryID === true) { // return simplified recordset for inserts/updates/deletes with lower overhead
$rs =& new ADORecordSet_empty();
$rs = new ADORecordSet_empty();
return $rs;
}
// return real recordset from select statement
$rsclass = $this->rsPrefix.$this->databaseType;
$rs = new $rsclass($this->_queryID,$this->fetchMode);
$rs->connection = &$this; // Pablo suggestion
$rs->connection = $this; // Pablo suggestion
$rs->Init();
if (is_array($sql)) $rs->sql = $sql[0];
else $rs->sql = $sql;
......
global $ADODB_COUNTRECS;
if ($ADODB_COUNTRECS) {
if (!$rs->EOF) {
$rs = &$this->_rs2rs($rs,-1,-1,!is_array($sql));
$rs = $this->_rs2rs($rs,-1,-1,!is_array($sql));
$rs->_queryID = $this->_queryID;
} else
$rs->_numOfRows = 0;
......
$createseq = $this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID));
$rs = $this->Execute($getnext);
}
if ($rs && !$rs->EOF) $this->genID = reset($rs->fields);
if ($rs AND !$rs->EOF) $this->genID = reset($rs->fields);
else $this->genID = 0; // false
if ($rs) $rs->Close();
......
*/
function Insert_ID($table='',$column='')
{
if ($this->_logsql && $this->lastInsID) return $this->lastInsID;
if ($this->_logsql AND $this->lastInsID) return $this->lastInsID;
if ($this->hasInsertID) return $this->_insertid($table,$column);
if ($this->debug) {
ADOConnection::outp( '<p>Insert_ID error</p>');
......
{
if ($this->hasAffectedRows) {
if ($this->fnExecute === 'adodb_log_sql') {
if ($this->_logsql && $this->_affected !== false) return $this->_affected;
if ($this->_logsql AND $this->_affected !== false) return $this->_affected;
}
$val = $this->_affectedrows();
return ($val < 0) ? false : $val;
......
{
// owner not used in base class - see oci8
$p = array();
$objs =& $this->MetaColumns($table);
$objs =$this->MetaColumns($table);
if ($objs) {
foreach($objs as $v) {
if (!empty($v->primary_key))
......
* @param [secs2cache] is a private parameter only used by jlim
* @return the recordset ($rs->databaseType == 'array')
*/
function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
{
if ($this->hasTop && $nrows > 0) {
if ($this->hasTop AND $nrows > 0) {
// suggested by Reinhard Balling. Access requires top after distinct
// Informix requires first before distinct - F Riosa
$ismssql = (strpos($this->databaseType,'mssql') !== false);
......
'/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.((integer)$nrows).' ',$sql);
if ($secs2cache != 0) {
$ret =& $this->CacheExecute($secs2cache, $sql,$inputarr);
$ret =$this->CacheExecute($secs2cache, $sql,$inputarr);
} else {
$ret =& $this->Execute($sql,$inputarr);
$ret =$this->Execute($sql,$inputarr);
}
return $ret; // PHP5 fix
} else if ($ismssql){
......
$ADODB_COUNTRECS = false;
if ($offset>0){
if ($secs2cache != 0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr);
else $rs = &$this->Execute($sql,$inputarr);
if ($secs2cache != 0) $rs = $this->CacheExecute($secs2cache,$sql,$inputarr);
else $rs = $this->Execute($sql,$inputarr);
} else {
if ($secs2cache != 0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr);
else $rs = &$this->Execute($sql,$inputarr);
if ($secs2cache != 0) $rs = $this->CacheExecute($secs2cache,$sql,$inputarr);
else $rs = $this->Execute($sql,$inputarr);
}
$ADODB_COUNTRECS = $savec;
if ($rs && !$rs->EOF) {
$rs =& $this->_rs2rs($rs,$nrows,$offset);
if ($rs AND !$rs->EOF) {
$rs =$this->_rs2rs($rs,$nrows,$offset);
}
//print_r($rs);
return $rs;
......
*
* @param rs the recordset to serialize
*/
function &SerializableRS(&$rs)
function SerializableRS($rs)
{
$rs2 =& $this->_rs2rs($rs);
$rs2 =$this->_rs2rs($rs);
$ignore = false;
$rs2->connection =& $ignore;
$rs2->connection =$ignore;
return $rs2;
}
......
* @param [offset] offset by number of rows (optional)
* @return the new recordset
*/
function &_rs2rs(&$rs,$nrows=-1,$offset=-1,$close=true)
function _rs2rs($rs,$nrows=-1,$offset=-1,$close=true)
{
if (! $rs) {
$false = 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 ?
$rs = $rs; // required to prevent crashing in 4.2.1, but does not happen in 4.3.1 -- why ?
return $rs;
}
if (($dbtype == 'array' || $dbtype == 'csv') && $nrows == -1 && $offset == -1) {
if (($dbtype == 'array' || $dbtype == 'csv') AND $nrows == -1 AND $offset == -1) {
$rs->MoveFirst();
$rs = &$rs; // required to prevent crashing in 4.2.1, but does not happen in 4.3.1-- why ?
$rs = $rs; // required to prevent crashing in 4.2.1, but does not happen in 4.3.1-- why ?
return $rs;
}
$flds = array();
......
$flds[] = $rs->FetchField($i);
}
$arr =& $rs->GetArrayLimit($nrows,$offset);
$arr =$rs->GetArrayLimit($nrows,$offset);
//print_r($arr);
if ($close) $rs->Close();
$arrayClass = $this->arrayClass;
$rs2 = new $arrayClass();
$rs2->connection = &$this;
$rs2->connection = $this;
$rs2->sql = $rs->sql;
$rs2->dataProvider = $this->dataProvider;
$rs2->InitArrayFields($arr,$flds);
......
/*
* Return all rows. Compat with PEAR DB
*/
function &GetAll($sql, $inputarr=false)
function GetAll($sql, $inputarr=false)
{
$arr =& $this->GetArray($sql,$inputarr);
$arr =$this->GetArray($sql,$inputarr);
return $arr;
}
function &GetAssoc($sql, $inputarr=false,$force_array = false, $first2cols = false)
function GetAssoc($sql, $inputarr=false,$force_array = false, $first2cols = false)
{
$rs =& $this->Execute($sql, $inputarr);
$rs =$this->Execute($sql, $inputarr);
if (!$rs) {
$false = false;
return $false;
}
$arr =& $rs->GetAssoc($force_array,$first2cols);
$arr =$rs->GetAssoc($force_array,$first2cols);
return $arr;
}
function &CacheGetAssoc($secs2cache, $sql=false, $inputarr=false,$force_array = false, $first2cols = false)
function CacheGetAssoc($secs2cache, $sql=false, $inputarr=false,$force_array = false, $first2cols = false)
{
if (!is_numeric($secs2cache)) {
$first2cols = $force_array;
$force_array = $inputarr;
}
$rs =& $this->CacheExecute($secs2cache, $sql, $inputarr);
$rs =$this->CacheExecute($secs2cache, $sql, $inputarr);
if (!$rs) {
$false = false;
return $false;
}
$arr =& $rs->GetAssoc($force_array,$first2cols);
$arr =$rs->GetAssoc($force_array,$first2cols);
return $arr;
}
......
$ADODB_COUNTRECS = false;
$ret = false;
$rs = &$this->Execute($sql,$inputarr);
$rs = $this->Execute($sql,$inputarr);
if ($rs) {
if (!$rs->EOF) $ret = reset($rs->fields);
$rs->Close();
......
function CacheGetOne($secs2cache,$sql=false,$inputarr=false)
{
$ret = false;
$rs = &$this->CacheExecute($secs2cache,$sql,$inputarr);
$rs = $this->CacheExecute($secs2cache,$sql,$inputarr);
if ($rs) {
if (!$rs->EOF) $ret = reset($rs->fields);
$rs->Close();
......
function GetCol($sql, $inputarr = false, $trim = false)
{
$rv = false;
$rs = &$this->Execute($sql, $inputarr);
$rs = $this->Execute($sql, $inputarr);
if ($rs) {
$rv = array();
if ($trim) {
......
function CacheGetCol($secs, $sql = false, $inputarr = false,$trim=false)
{
$rv = false;
$rs = &$this->CacheExecute($secs, $sql, $inputarr);
$rs = $this->CacheExecute($secs, $sql, $inputarr);
if ($rs) {
if ($trim) {
while (!$rs->EOF) {
......
return $rv;
}
function &Transpose(&$rs)
function Transpose($rs)
{
$rs2 =& $this->_rs2rs($rs);
$rs2 =$this->_rs2rs($rs);
$false = false;
if (!$rs2) return $false;
......
* @param sql SQL statement
* @param [inputarr] input bind array
*/
function &GetArray($sql,$inputarr=false)
function GetArray($sql,$inputarr=false)
{
global $ADODB_COUNTRECS;
$savec = $ADODB_COUNTRECS;
$ADODB_COUNTRECS = false;
$rs =& $this->Execute($sql,$inputarr);
$rs =$this->Execute($sql,$inputarr);
$ADODB_COUNTRECS = $savec;
if (!$rs)
if (defined('ADODB_PEAR')) {
......
$false = false;
return $false;
}
$arr =& $rs->GetArray();
$arr =$rs->GetArray();
$rs->Close();
return $arr;
}
function &CacheGetAll($secs2cache,$sql=false,$inputarr=false)
function CacheGetAll($secs2cache,$sql=false,$inputarr=false)
{
return $this->CacheGetArray($secs2cache,$sql,$inputarr);
}
function &CacheGetArray($secs2cache,$sql=false,$inputarr=false)
function CacheGetArray($secs2cache,$sql=false,$inputarr=false)
{
global $ADODB_COUNTRECS;
$savec = $ADODB_COUNTRECS;
$ADODB_COUNTRECS = false;
$rs =& $this->CacheExecute($secs2cache,$sql,$inputarr);
$rs =$this->CacheExecute($secs2cache,$sql,$inputarr);
$ADODB_COUNTRECS = $savec;
if (!$rs)
......
$false = false;
return $false;
}
$arr =& $rs->GetArray();
$arr =$rs->GetArray();
$rs->Close();
return $arr;
}
......
* @param sql SQL statement
* @param [inputarr] input bind array
*/
function &GetRow($sql,$inputarr=false)
function GetRow($sql,$inputarr=false)
{
global $ADODB_COUNTRECS;
$crecs = $ADODB_COUNTRECS;
$ADODB_COUNTRECS = false;
$rs =& $this->Execute($sql,$inputarr);
$rs =$this->Execute($sql,$inputarr);
$ADODB_COUNTRECS = $crecs;
if ($rs) {
......
return $false;
}
function &CacheGetRow($secs2cache,$sql=false,$inputarr=false)
function CacheGetRow($secs2cache,$sql=false,$inputarr=false)
{
$rs =& $this->CacheExecute($secs2cache,$sql,$inputarr);
$rs =$this->CacheExecute($secs2cache,$sql,$inputarr);
if ($rs) {
$arr = false;
if (!$rs->EOF) $arr = $rs->fields;
......
* @param [inputarr] array of bind variables
* @return the recordset ($rs->databaseType == 'array')
*/
function &CacheSelectLimit($secs2cache,$sql,$nrows=-1,$offset=-1,$inputarr=false)
function CacheSelectLimit($secs2cache,$sql,$nrows=-1,$offset=-1,$inputarr=false)
{
if (!is_numeric($secs2cache)) {
if ($sql === false) $sql = -1;
if ($offset == -1) $offset = false;
// sql, nrows, offset,inputarr
$rs =& $this->SelectLimit($secs2cache,$sql,$nrows,$offset,$this->cacheSecs);
$rs =$this->SelectLimit($secs2cache,$sql,$nrows,$offset,$this->cacheSecs);
} else {
if ($sql === false) ADOConnection::outp( "Warning: \$sql missing from CacheSelectLimit()");
$rs =& $this->SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
$rs =$this->SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
}
return $rs;
}
......
return;
}
if (strlen($ADODB_CACHE_DIR) > 1 && !$sql) {
if (strlen($ADODB_CACHE_DIR) > 1 AND !$sql) {
/*if (strncmp(PHP_OS,'WIN',3) === 0)
$dir = str_replace('/', '\\', $ADODB_CACHE_DIR);
else */
......
return;
}
if (strlen($ADODB_CACHE_DIR) > 1 && !$sql) {
if (strlen($ADODB_CACHE_DIR) > 1 AND !$sql) {
if (strncmp(PHP_OS,'WIN',3) === 0) {
$cmd = 'del /s '.str_replace('/','\\',$ADODB_CACHE_DIR).'\adodb_*.cache';
} else {
......
if (!isset($notSafeMode)) $notSafeMode = !ini_get('safe_mode');
$dir = ($notSafeMode) ? $ADODB_CACHE_DIR.'/'.substr($m,0,2) : $ADODB_CACHE_DIR;
if ($createdir && $notSafeMode && !file_exists($dir)) {
if ($createdir AND $notSafeMode AND !file_exists($dir)) {
$oldu = umask(0);
if (!mkdir($dir,0771))
if ($this->debug) ADOConnection::outp( "Unable to mkdir $dir for $sql");
......
* @param [inputarr] holds the input data to bind to
* @return RecordSet or false
*/
function &CacheExecute($secs2cache,$sql=false,$inputarr=false)
function CacheExecute($secs2cache,$sql=false,$inputarr=false)
{
......
if ($secs2cache > 0){
if ($this->memCache)
$rs = &getmemCache($md5file,$err,$secs2cache, $this->memCacheHost, $this->memCachePort);
$rs = getmemCache($md5file,$err,$secs2cache, $this->memCacheHost, $this->memCachePort);
else
$rs = &csv2rs($md5file,$err,$secs2cache,$this->arrayClass);
$rs = csv2rs($md5file,$err,$secs2cache,$this->arrayClass);
$this->numCacheHits += 1;
} else {
$err='Timeout 1';
......
if (!$rs) {
// no cached rs found
if ($this->debug) {
if (get_magic_quotes_runtime() && !$this->memCache) {
if (get_magic_quotes_runtime() AND !$this->memCache) {
ADOConnection::outp("Please disable magic_quotes_runtime - it corrupts cache files :(");
}
if ($this->debug !== -1) ADOConnection::outp( " $md5file cache failure: $err (see sql below)");
}
$rs = &$this->Execute($sqlparam,$inputarr);
$rs = $this->Execute($sqlparam,$inputarr);
if ($rs && $this->memCache) {
$rs = &$this->_rs2rs($rs); // read entire recordset into memory immediately
if ($rs AND $this->memCache) {
$rs = $this->_rs2rs($rs); // read entire recordset into memory immediately
if(!putmemCache($md5file, $rs, $this->memCacheHost, $this->memCachePort, $this->memCacheCompress, $this->debug)) {
if ($fn = $this->raiseErrorFn)
$fn($this->databaseType,'CacheExecute',-32000,"Cache write error",$md5file,$sql,$this);
......
} else
if ($rs) {
$eof = $rs->EOF;
$rs = &$this->_rs2rs($rs); // read entire recordset into memory immediately
$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 ($this->debug) ADOConnection::outp( " Cache write error");
}
if ($rs->EOF && !$eof) {
if ($rs->EOF AND !$eof) {
$rs->MoveFirst();
//$rs = &csv2rs($md5file,$err);
$rs->connection = &$this; // Pablo suggestion
$rs->connection = $this; // Pablo suggestion
}
} else
......
$fn($this, $secs2cache, $sql, $inputarr);
}
// ok, set cached object found
$rs->connection = &$this; // Pablo suggestion
$rs->connection = $this; // Pablo suggestion
if ($this->debug){
$inBrowser = isset($_SERVER['HTTP_USER_AGENT']);
......
$forceUpdate means that even if the data has not changed, perform update.
*/
function& AutoExecute($table, $fields_values, $mode = 'INSERT', $where = FALSE, $forceUpdate=true, $magicq=false)
function AutoExecute($table, $fields_values, $mode = 'INSERT', $where = FALSE, $forceUpdate=true, $magicq=false)
{
$false = false;
$sql = 'SELECT * FROM '.$table;
......
return $false;
}
$rs =& $this->SelectLimit($sql,1);
$rs =$this->SelectLimit($sql,1);
if (!$rs) return $false; // table does not exist
$rs->tableName = $table;
......
*
* "Jonathan Younger" <jyounger@unilab.com>
*/
function GetUpdateSQL(&$rs, $arrFields,$forceUpdate=false,$magicq=false,$force=null)
function GetUpdateSQL($rs, $arrFields,$forceUpdate=false,$magicq=false,$force=null)
{
global $ADODB_INCLUDED_LIB;
......
* Note: This function should only be used on a recordset
* that is run against a single table.
*/
function GetInsertSQL(&$rs, $arrFields,$magicq=false,$force=null)
function GetInsertSQL($rs, $arrFields,$magicq=false,$force=null)
{
global $ADODB_INCLUDED_LIB;
if (!isset($force)) {
......
$old = $this->_logsql;
$this->_logsql = $enable;
if ($enable && !$old) $this->_affected = false;
if ($enable AND !$old) $this->_affected = false;
return $old;
}
......
if (empty($this->_metars)) {
$rsclass = $this->rsPrefix.$this->databaseType;
$this->_metars =& new $rsclass(false,$this->fetchMode);
$this->_metars->connection =& $this;
$this->_metars = new $rsclass(false,$this->fetchMode);
$this->_metars->connection =$this;
}
return $this->_metars->MetaType($t,$len,$fieldobj);
}
......
}
}
function &GetActiveRecordsClass($class, $table,$whereOrderBy=false,$bindarr=false, $primkeyArr=false)
function GetActiveRecordsClass($class, $table,$whereOrderBy=false,$bindarr=false, $primkeyArr=false)
{
global $_ADODB_ACTIVE_DBS;
......
$arr = array();
foreach($rows as $row) {
$obj =& new $class($table,$primkeyArr,$this);
$obj = new $class($table,$primkeyArr,$this);
if ($obj->ErrorMsg()){
$this->_errorMsg = $obj->ErrorMsg();
return $false;
}
$obj->Set($row);
$arr[] =& $obj;
$arr[] =$obj;
}
return $arr;
}
function &GetActiveRecords($table,$where=false,$bindarr=false,$primkeyArr=false)
function GetActiveRecords($table,$where=false,$bindarr=false,$primkeyArr=false)
{
$arr =& $this->GetActiveRecordsClass('ADODB_Active_Record', $table, $where, $bindarr, $primkeyArr);
$arr =$this->GetActiveRecordsClass('ADODB_Active_Record', $table, $where, $bindarr, $primkeyArr);
return $arr;
}
......
*
* @return array of tables for current database.
*/
function &MetaTables($ttype=false,$showSchema=false,$mask=false)
function MetaTables($ttype=false,$showSchema=false,$mask=false)
{
global $ADODB_FETCH_MODE;
......
$ADODB_FETCH_MODE = $save;
if ($rs === false) return $false;
$arr =& $rs->GetArray();
$arr =$rs->GetArray();
$arr2 = array();
if ($hast = ($ttype && isset($arr[0][1]))) {
if ($hast = ($ttype AND isset($arr[0][1]))) {
$showt = strncmp($ttype,'T',1);
}
......
}
function _findschema(&$table,&$schema)
function _findschema($table,$schema)
{
if (!$schema && ($at = strpos($table,'.')) !== false) {
if (!$schema AND ($at = strpos($table,'.')) !== false) {
$schema = substr($table,0,$at);
$table = substr($table,$at+1);
}
......
*
* @return array of ADOFieldObjects for current table.
*/
function &MetaColumns($table,$normalize=true)
function MetaColumns($table,$normalize=true)
{
global $ADODB_FETCH_MODE;
......
$fld = new ADOFieldObject();
$fld->name = $rs->fields[0];
$fld->type = $rs->fields[1];
if (isset($rs->fields[3]) && $rs->fields[3]) {
if (isset($rs->fields[3]) AND $rs->fields[3]) {
if ($rs->fields[3]>0) $fld->max_length = $rs->fields[3];
$fld->scale = $rs->fields[4];
if ($fld->scale>0) $fld->max_length += 1;
......
)
)
*/
function &MetaIndexes($table, $primary = false, $owner = false)
function MetaIndexes($table, $primary = false, $owner = false)
{
$false = false;
return $false;
......
*
* @return array of column names for current table.
*/
function &MetaColumnNames($table, $numIndexes=false,$useattnum=false /* only for postgres */)
function MetaColumnNames($table, $numIndexes=false,$useattnum=false /* only for postgres */)
{
$objarr =& $this->MetaColumns($table);
$objarr =$this->MetaColumns($table);
if (!is_array($objarr)) {
$false = false;
return $false;
......
*/
function DBDate($d)
{
if (empty($d) && $d !== 0) return 'null';
if (empty($d) AND $d !== 0) return 'null';
if (is_string($d) && !is_numeric($d)) {
if (is_string($d) AND !is_numeric($d)) {
if ($d === 'null' || strncmp($d,"'",1) === 0) return $d;
if ($this->isoDates) return "'$d'";
$d = ADOConnection::UnixDate($d);
......
*/
function DBTimeStamp($ts)
{
if (empty($ts) && $ts !== 0) return 'null';
if (empty($ts) AND $ts !== 0) return 'null';
# strlen(14) allows YYYYMMDDHHMMSS format
if (!is_string($ts) || (is_numeric($ts) && strlen($ts)<14))
if (!is_string($ts) || (is_numeric($ts) AND strlen($ts)<14))
return adodb_date($this->fmtTimeStamp,$ts);
if ($ts === 'null') return $ts;
if ($this->isoDates && strlen($ts) !== 14) return "'$ts'";
if ($this->isoDates AND strlen($ts) !== 14) return "'$ts'";
$ts = ADOConnection::UnixTimeStamp($ts);
return adodb_date($this->fmtTimeStamp,$ts);
......
return adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year);
}
if (is_numeric($v) && strlen($v) !== 8) return $v;
if (is_numeric($v) AND strlen($v) !== 8) return $v;
if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|",
($v), $rr)) return false;
......
"|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|",
($v), $rr)) return false;
if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0;
if ($rr[1] <= TIMESTAMP_FIRST_YEAR AND $rr[2]<= 1) return 0;
// h-m-s-MM-DD-YY
if (!isset($rr[5])) return adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
......
$tt = $this->UnixDate($v);
// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
if (($tt === false || $tt == -1) && $v != false) return $v;
if (($tt === false || $tt == -1) AND $v != false) return $v;
else if ($tt == 0) return $this->emptyDate;
else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR
}
......
{
if (!isset($v)) return $this->emptyTimeStamp;
# strlen(14) allows YYYYMMDDHHMMSS format
if (is_numeric($v) && strlen($v)<14) return ($gmt) ? adodb_gmdate($fmt,$v) : adodb_date($fmt,$v);
if (is_numeric($v) AND strlen($v)<14) return ($gmt) ? adodb_gmdate($fmt,$v) : adodb_date($fmt,$v);
$tt = $this->UnixTimeStamp($v);
// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
if (($tt === false || $tt == -1) && $v != false) return $v;
if (($tt === false || $tt == -1) AND $v != false) return $v;
if ($tt == 0) return $this->emptyTimeStamp;
return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt);
}
......
* NOTE: phpLens uses a different algorithm and does not use PageExecute().
*
*/
function &PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0)
function PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0)
{
global $ADODB_INCLUDED_LIB;
if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php');
if ($this->pageExecuteCountRows) $rs =& _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $secs2cache);
else $rs =& _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache);
if ($this->pageExecuteCountRows) $rs = _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $secs2cache);
else $rs = _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache);
return $rs;
}
......
* @param [inputarr] array of bind variables
* @return the recordset ($rs->databaseType == 'array')
*/
function &CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false)
function CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false)
{
/*switch($this->dataProvider) {
case 'postgres':
......
break;
default: $secs2cache = 0; break;
}*/
$rs =& $this->PageExecute($sql,$nrows,$page,$inputarr,$secs2cache);
$rs =$this->PageExecute($sql,$nrows,$page,$inputarr,$secs2cache);
return $rs;
}
......
$this->_numOfRows = 0;
$this->_numOfFields = 0;
}
if ($this->_numOfRows != 0 && $this->_numOfFields && $this->_currentRow == -1) {
if ($this->_numOfRows != 0 AND $this->_numOfFields AND $this->_currentRow == -1) {
$this->_currentRow = 0;
if ($this->EOF = ($this->_fetch() === false)) {
......
*
* @return an array indexed by the rows (0-based) from the recordset
*/
function &GetArray($nRows = -1)
function GetArray($nRows = -1)
{
global $ADODB_EXTENSION; if ($ADODB_EXTENSION) {
$results = adodb_getall($this,$nRows);
......
}
$results = array();
$cnt = 0;
while (!$this->EOF && $nRows != $cnt) {
while (!$this->EOF AND $nRows != $cnt) {
$results[] = $this->fields;
$this->MoveNext();
$cnt++;
......
return $results;
}
function &GetAll($nRows = -1)
function GetAll($nRows = -1)
{
$arr =& $this->GetArray($nRows);
$arr =$this->GetArray($nRows);
return $arr;
}
......
*
* @return an array indexed by the rows (0-based) from the recordset
*/
function &GetArrayLimit($nrows,$offset=-1)
function GetArrayLimit($nrows,$offset=-1)
{
if ($offset <= 0) {
$arr =& $this->GetArray($nrows);
$arr =$this->GetArray($nrows);
return $arr;
}
......
$results = array();
$cnt = 0;
while (!$this->EOF && $nrows != $cnt) {
while (!$this->EOF AND $nrows != $cnt) {
$results[$cnt++] = $this->fields;
$this->MoveNext();
}
......
*
* @return an array indexed by the rows (0-based) from the recordset
*/
function &GetRows($nRows = -1)
function GetRows($nRows = -1)
{
$arr =& $this->GetArray($nRows);
$arr =$this->GetArray($nRows);
return $arr;
}
......
* @return an associative array indexed by the first column of the array,
* or false if the data has less than 2 cols.
*/
function &GetAssoc($force_array = false, $first2cols = false)
function GetAssoc($force_array = false, $first2cols = false)
{
global $ADODB_EXTENSION;
......
$numIndex = isset($this->fields[0]);
$results = array();
if (!$first2cols && ($cols > 2 || $force_array)) {
if (!$first2cols AND ($cols > 2 || $force_array)) {
if ($ADODB_EXTENSION) {
if ($numIndex) {
while (!$this->EOF) {
......
}
}
$ref =& $results; # workaround accelerator incompat with PHP 4.4 :(
$ref =$results; # workaround accelerator incompat with PHP 4.4 :(
return $ref;
}
......
*/
function UserTimeStamp($v,$fmt='Y-m-d H:i:s')
{
if (is_numeric($v) && strlen($v)<14) return adodb_date($fmt,$v);
if (is_numeric($v) AND strlen($v)<14) return adodb_date($fmt,$v);
$tt = $this->UnixTimeStamp($v);
// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
if (($tt === false || $tt == -1) && $v != false) return $v;
if (($tt === false || $tt == -1) AND $v != false) return $v;
if ($tt === 0) return $this->emptyTimeStamp;
return adodb_date($fmt,$tt);
}
......
{
$tt = $this->UnixDate($v);
// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
if (($tt === false || $tt == -1) && $v != false) return $v;
if (($tt === false || $tt == -1) AND $v != false) return $v;
else if ($tt == 0) return $this->emptyDate;
else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR
}
......
*
* @return false or array containing the current record
*/
function &FetchRow()
function FetchRow()
{
if ($this->EOF) {
$false = false;
......
*
* @return DB_OK or error object
*/
function FetchInto(&$arr)
function FetchInto($arr)
{
if ($this->EOF) return (defined('PEAR_ERROR_RETURN')) ? new PEAR_Error('EOF',-1): false;
$arr = $this->fields;
......
$this->EOF = true;
/* -- tested error handling when scrolling cursor -- seems useless.
$conn = $this->connection;
if ($conn && $conn->raiseErrorFn && ($errno = $conn->ErrorNo())) {
if ($conn AND $conn->raiseErrorFn AND ($errno = $conn->ErrorNo())) {
$fn = $conn->raiseErrorFn;
$fn($conn->databaseType,'MOVENEXT',$errno,$conn->ErrorMsg().' ('.$this->sql.')',$conn->host,$conn->database);
}
......
if ($rowNumber < $this->_currentRow) return false;
global $ADODB_EXTENSION;
if ($ADODB_EXTENSION) {
while (!$this->EOF && $this->_currentRow < $rowNumber) {
while (!$this->EOF AND $this->_currentRow < $rowNumber) {
adodb_movenext($this);
}
} else {
while (! $this->EOF && $this->_currentRow < $rowNumber) {
while (! $this->EOF AND $this->_currentRow < $rowNumber) {
$this->_currentRow++;
if (!$this->_fetch()) $this->EOF = true;
......
*
* $upper 0 = lowercase, 1 = uppercase, 2 = whatever is returned by FetchField
*/
function &GetRowAssoc($upper=1)
function GetRowAssoc($upper=1)
{
$record = array();
// if (!$this->fields) return $record;
......
$lnumrows = $this->_numOfRows;
// the database doesn't support native recordcount, so we do a workaround
if ($lnumrows == -1 && $this->connection) {
if ($lnumrows == -1 AND $this->connection) {
IF ($table) {
if ($condition) $condition = " WHERE " . $condition;
$resultrows = &$this->connection->Execute("SELECT COUNT(*) FROM $table $condition");
$resultrows = $this->connection->Execute("SELECT COUNT(*) FROM $table $condition");
if ($resultrows) $lnumrows = reset($resultrows->fields);
}
}
......
*
* @return the ADOFieldObject for that column, or false.
*/
function &FetchField($fieldoffset)
function FetchField($fieldoffset)
{
// must be defined by child class
}
......
* Get the ADOFieldObjects of all columns in an array.
*
*/
function& FieldTypesArray()
function FieldTypesArray()
{
$arr = array();
for ($i=0, $max=$this->_numOfFields; $i < $max; $i++)
......
*
* @return the object with the properties set to the fields of the current row
*/
function &FetchObj()
function FetchObj()
{
$o =& $this->FetchObject(false);
$o =$this->FetchObject(false);
return $o;
}
......
*
* @return the object with the properties set to the fields of the current row
*/
function &FetchObject($isupper=true)
function FetchObject($isupper=true)
{
if (empty($this->_obj)) {
$this->_obj = new ADOFetchObj();
......
*
* Fixed bug reported by tim@orotech.net
*/
function &FetchNextObj()
function FetchNextObj()
{
$o =& $this->FetchNextObject(false);
$o =$this->FetchNextObject(false);
return $o;
}
......
*
* Fixed bug reported by tim@orotech.net
*/
function &FetchNextObject($isupper=true)
function FetchNextObject($isupper=true)
{
$o = false;
if ($this->_numOfRows != 0 && !$this->EOF) {
if ($this->_numOfRows != 0 AND !$this->EOF) {
$o = $this->FetchObject($isupper);
$this->_currentRow++;
if ($this->_fetch()) return $o;
......
return 'B';
case 'D':
if (!empty($this->connection) && !empty($this->connection->datetime)) return 'T';
if (!empty($this->connection) AND !empty($this->connection->datetime)) return 'T';
return 'D';
default:
if ($t == 'LONG' && $this->dataProvider == 'oci8') return 'B';
if ($t == 'LONG' AND $this->dataProvider == 'oci8') return 'B';
return $tmap;
}
}
......
//adodb_pr($newarr);
$this->_skiprow1 = false;
$this->_array =& $newarr;
$this->_array =$newarr;
$this->_colnames = $hdr;
adodb_probetypes($newarr,$this->_types);
......
* unless paramter $colnames is used.
* @param fieldarr holds an array of ADOFieldObject's.
*/
function InitArrayFields(&$array,&$fieldarr)
function InitArrayFields($array,$fieldarr)
{
$this->_array =& $array;
$this->_array =$array;
$this->_skiprow1= false;
if ($fieldarr) {
$this->_fieldobjects =& $fieldarr;
$this->_fieldobjects =$fieldarr;
}
$this->Init();
}
function &GetArray($nRows=-1)
function GetArray($nRows=-1)
{
if ($nRows == -1 && $this->_currentRow <= 0 && !$this->_skiprow1) {
if ($nRows == -1 AND $this->_currentRow <= 0 AND !$this->_skiprow1) {
return $this->_array;
} else {
$arr =& ADORecordSet::GetArray($nRows);
$arr = ADORecordSet::GetArray($nRows);
return $arr;
}
}
......
return $this->fields[$this->bind[strtoupper($colname)]];
}
function &FetchField($fieldOffset = -1)
function FetchField($fieldOffset = -1)
{
if (isset($this->_fieldobjects)) {
return $this->_fieldobjects[$fieldOffset];
......
function _seek($row)
{
if (sizeof($this->_array) && 0 <= $row && $row < $this->_numOfRows) {
if (sizeof($this->_array) AND 0 <= $row AND $row < $this->_numOfRows) {
$this->_currentRow = $row;
if ($this->_skiprow1) $row += 1;
$this->fields = $this->_array[$row];
......
/**
* synonym for ADONewConnection for people like me who cannot remember the correct name
*/
function &NewADOConnection($db='')
function NewADOConnection($db='')
{
$tmp =& ADONewConnection($db);
$tmp = ADONewConnection($db);
return $tmp;
}
......
*
* @return the freshly created instance of the Connection class.
*/
function &ADONewConnection($db='')
function ADONewConnection($db='')
{
GLOBAL $ADODB_NEWCONNECTION, $ADODB_LASTDB;
......
return $drivername;
}
function &NewPerfMonitor(&$conn)
function NewPerfMonitor($conn)
{
$false = false;
$drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType,true);
......
return $perf;
}
function &NewDataDictionary(&$conn,$drivername=false)
function NewDataDictionary($conn,$drivername=false)
{
$false = false;
if (!$drivername) $drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType);
......
$class = "ADODB2_$drivername";
$dict = new $class();
$dict->dataProvider = $conn->dataProvider;
$dict->connection = &$conn;
$dict->connection = $conn;
$dict->upperName = strtoupper($drivername);
$dict->quote = $conn->nameQuote;
if (!empty($conn->_connectionID))
freenetis/trunk/kohana/application/config/routes.php
* Permitted URI characters. Note that "?", "#", and "=" are URL characters, and
* should not be added here.
*/
$config['_allowed'] = '-a-z 0-9~%.,:_';
//$config['_allowed'] = '-a-z 0-9~%.,:_';
/**
* Default route to use when no URI segments are available.
......
);
// Clean up
unset($lang);
unset($lang);
freenetis/trunk/kohana/application/controllers/members.php
{
$user_model=new User_Model();
$value = trim($input->value);
if(!ereg("^[0-9]{9,9}$",$value))
if(!preg_match("/^[0-9]{9,9}$/",$value))
{
$input->add_error('required', url_lang::lang('texts.Bad phone format.'));
}
......
$member_model = new Member_Model();
$members = $member_model->where(array('variable_symbol' => $value, 'id!=' => $this->member_id))->find_all();
$total = count($members);
if (!ereg("^[0-9]{1,10}$", $value))
if (!preg_match("/^[0-9]{1,10}$/", $value))
{
$input->add_error('required', url_lang::lang('texts.Bad variable symbol format.'));
}
......
}
}
?>
?>
freenetis/trunk/kohana/application/controllers/installation.php
function valid_phone($input)
{
$value = trim($input->value);
if(!ereg("^[0-9]{9,9}$", $value))
//if(!ereg("^[0-9]{9,9}$", $value))
if(!preg_match("/^[0-9]{9,9}$/", $value))
{
$input->add_error('required', url_lang::lang('texts.Bad phone format.'));
}
freenetis/trunk/kohana/application/controllers/works.php
if (!$this->acl_check_view('Users_Controller','work',$user->member_id))
Controller::error(ACCESS);
$this->session->set('ssUser_id',$user->id);
$headline = url_lang::lang('texts.List of works of user').' '.$user->name;
$headline = url_lang::lang('texts.List of works of user').' '.$user->name.' '.$user->surname;
$work_model = new Job_Model();
// confirmed works
$confirmed_works = $work_model->get_confirmed_works_of_user($user->id);
......
}
?>
?>
freenetis/trunk/kohana/application/libraries/MY_Controller.php
$this->db->query('START TRANSACTION;');
try
{
foreach ($this->upgrade_sql[$i] as $query)
foreach ($upgrade_sql[$i] as $query)
$this->db->query($query);
}
catch (Kohana_Database_Exception $e)
freenetis/trunk/kohana/system/config/routes.php
* Permitted URI characters. Note that "?", "#", and "=" are URL characters, and
* should not be added here.
*/
$config['_allowed'] = '-a-z 0-9~%.,:_';
//$config['_allowed'] = '-a-z 0-9~%.,:_';
/**
* Default route to use when no URI segments are available.
*/
$config['_default'] = 'login';
$config['_default'] = 'login';

Také k dispozici: Unified diff