1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 04:38:27 +01:00

PDO Install enabled. PHP Notice fixes.

This commit is contained in:
Cameron 2016-02-12 19:28:35 -08:00
parent b64033a2a1
commit fb609aaab6
13 changed files with 164 additions and 99 deletions

View File

@ -2123,7 +2123,7 @@ class error_handler
{
$error['short'] = "<span class='label label-".$this->color[$type]."'>".$this->label[$type]."</span> {$message}, Line {$line} of {$file}<br />\n";
$error['short'] = "<span class='label label-".$this->color[$type]."'>".$this->label[$type]."</span> {$message}, Line <mark>{$line}</mark> of {$file}<br />\n";
if($this->xdebug)
{
@ -2144,7 +2144,7 @@ class error_handler
if ($startup_error || E107_DBG_BASIC || E107_DBG_ERRBACKTRACE)
{
// $error['short'] = "Warning: {$message}, Line {$line} of {$file}<br />\n";
$error['short'] = "<span class='label label-".$this->color[$type]."'>".$this->label[$type]."</span> {$message}, Line {$line} of {$file}<br />\n";
$error['short'] = "<span class='label label-".$this->color[$type]."'>".$this->label[$type]."</span> {$message}, Line <mark>{$line}</mark> of {$file}<br />\n";
if($this->xdebug)
{
@ -2164,7 +2164,7 @@ class error_handler
case E_USER_ERROR:
if ($this->debug == true)
{
$error['short'] = "&nbsp;&nbsp;&nbsp;&nbsp;Internal Error Message: {$message}, Line {$line} of {$file}<br />\n";
$error['short'] = "&nbsp;&nbsp;&nbsp;&nbsp;Internal Error Message: {$message}, Line <mark>{$line}</mark> of {$file}<br />\n";
$trace = debug_backtrace();
$backtrace[0] = (isset($trace[1]) ? $trace[1] : "");
$backtrace[1] = (isset($trace[2]) ? $trace[2] : "");
@ -2189,7 +2189,7 @@ class error_handler
array_pop($array);
$text = "<table class='table table-bordered table-striped'>
$text = "<table class='table table-bordered table-striped table-condensed'>
<tr class='danger'><th>#</th><th>Function</th><th>Location</th></tr>";
foreach($array as $key=>$val)
{
@ -2230,8 +2230,9 @@ class error_handler
foreach ($this->errors as $key => $value)
{
$ret .= "\t<tr>\n\t\t<td class='forumheader3' >{$value['short']}</td><td><input class='btn btn-info button e-expandit' data-target = 'bt_{$key}' type ='button' style='cursor: hand; cursor: pointer;' size='30' value='Back Trace' />\n";
$ret .= "</td>\n\t</tr>";
$ret .= "\t<tr>\n<td style='display: none;' colspan='2' id='bt_{$key}'>".$this->render_trace($value['trace'])."</td></tr>\n";
$ret .= "</td>\n\t</tr>";
if($index == 0) { $index = 1; } else { $index = 0; }
}

View File

@ -29,6 +29,7 @@ if ($parm == '')
{ /* unordered list */
$listtext = "<ul class='bbcode'>";
$trailer = "</ul>";
$type = '';
}
else
{

View File

@ -88,7 +88,7 @@ class cpage_shortcodes extends e_shortcode
function sc_cpagesubtitle()
{
$subtitle = $this->var['sub_title'];
$subtitle = varset($this->var['sub_title']);
return $subtitle ? e107::getParser()->toHTML($subtitle, true, 'TITLE') : '';
}

View File

@ -60,6 +60,12 @@ else
define('E107_DEBUG_LEVEL', 0);
}
if(!defined('e_DEBUG'))
{
$e_DEBUG = (E107_DEBUG_LEVEL > 0) ? true: false;
define('e_DEBUG', $e_DEBUG);
}
//
// Define all debug constants -- each one will be zero or a value
// They all have different values and can be 'or'ed together

View File

@ -625,7 +625,7 @@ class e107
* @param string $for prefix|server|user|password|defaultdb - leave blank for full array.
* @return string or array
*/
function getMySQLConfig($for='')
public static function getMySQLConfig($for='')
{
$key = 'mySQL'.$for;
$self = self::getInstance();
@ -798,7 +798,18 @@ class e107
if($path && is_string($path) && !class_exists($class_name, false))
{
e107_require_once($path); //no existence/security checks here!
global $e107_debug, $_E107;
if(($e107_debug || isset($_E107['debug']) || (defined('e_DEBUG') && e_DEBUG === true) ))
{
require_once($path);
}
else
{
@require_once($path);
}
// remove the need for external function.
//e107_require_once() is available without class2.php. - see core_functions.php
}
if(class_exists($class_name, false))
@ -1359,7 +1370,7 @@ class e107
/**
* Retrieve override handler singleton object
*
* @return notify
* @return override
*/
public static function getOverride()
{
@ -2536,7 +2547,7 @@ class e107
$path = e_PLUGIN.$plugin.'/languages/'.$fname.'.php';
}
if(E107_DBG_INCLUDES)
if(deftrue('E107_DBG_INCLUDES'))
{
e107::getMessage()->addDebug("Attempting to Load: ".$path);
}
@ -3224,7 +3235,7 @@ class e107
{
define('MAGIC_QUOTES_GPC', (ini_get('magic_quotes_gpc') ? true : false));
define('MPREFIX', $this->getMySQLConfig('prefix')); // mysql prefix
define('MPREFIX', self::getMySQLConfig('prefix')); // mysql prefix
define('CHARSET', 'utf-8'); // set CHARSET for backward compatibility
@ -3273,11 +3284,7 @@ class e107
define('e_UC_MEMBER', 253);
define('e_UC_ADMIN', 254);
define('e_UC_NOBODY', 255);
if(!defined('e_DEBUG'))
{
define('e_DEBUG', false);
}
return $this;
}

View File

@ -36,7 +36,12 @@ class e107_event
function __construct()
{
// e107::lan('core','notify'); //FIXME e_LANGUAGE is not defined at this point.
}
function coreList()
{
$this->coreEvents = array( // used by e_notify admin area.
@ -84,14 +89,7 @@ class e107_event
);
}
function coreList()
{
return $this->coreEvents;
}

View File

@ -66,41 +66,36 @@ $db_ConnectionID = NULL; // Stores ID for the first DB connection used - which s
class e_db_mysql
{
// TODO switch to protected vars where needed
public $mySQLserver;
public $mySQLuser;
protected $mySQLpassword;
protected $mySQLdefaultdb;
public $mySQLPrefix;
protected $mySQLaccess;
public $mySQLresult;
public $mySQLrows;
public $mySQLerror = ''; // Error reporting mode - TRUE shows messages
public $mySQLserver;
public $mySQLuser;
protected $mySQLpassword;
protected $mySQLdefaultdb;
public $mySQLPrefix;
protected $mySQLaccess;
public $mySQLresult;
public $mySQLrows;
public $mySQLerror = ''; // Error reporting mode - TRUE shows messages
protected $mySQLlastErrNum = 0; // Number of last error - now protected, use getLastErrorNumber()
protected $mySQLlastErrText = ''; // Text of last error - now protected, use getLastErrorText()
protected $mySQLlastQuery = '';
protected $mySQLlastErrNum = 0; // Number of last error - now protected, use getLastErrorNumber()
protected $mySQLlastErrText = ''; // Text of last error - now protected, use getLastErrorText()
protected $mySQLlastQuery = '';
public $mySQLcurTable;
public $mySQLlanguage;
public $mySQLinfo;
public $tabset;
public $mySQLtableList = array(); // list of all Db tables.
public $mySQLcurTable;
public $mySQLlanguage;
public $mySQLinfo;
public $tabset;
public $mySQLtableList = array(); // list of all Db tables.
public $mySQLtableListLanguage = array(); // Db table list for the currently selected language
public $mySQLtablelist = array();
public $mySQLtableListLanguage = array(); // Db table list for the currently selected language
public $mySQLtablelist = array();
protected $dbFieldDefs = array(); // Local cache - Field type definitions for _FIELD_DEFS and _NOTNULL arrays
/**
* MySQL Charset
*
* @var string
*/
public $mySQLcharset;
public $mySqlServerInfo = '?'; // Server info - needed for various things
public $mySQLcharset;
public $mySqlServerInfo = '?'; // Server info - needed for various things
public $total_results = false; // Total number of results
public $total_results = false; // Total number of results
private $pdo = false; // using PDO or not.
private $pdo = false; // using PDO or not.
/**
* Constructor - gets language options from the cookie or session
@ -448,13 +443,14 @@ class e_db_mysql
// print_a($prep);
// echo "<hr>";
// $sQryRes = $prep->execute($query);
try
{
$sQryRes = is_null($rli) ? $this->mySQLaccess->query($query) : $rli->query($query);
}
catch(PDOException $ex)
{
// $sQryRes = null;
$sQryRes = false;
}
}
@ -507,7 +503,7 @@ class e_db_mysql
if(is_object($db_debug))
{
$buglink = is_null($rli) ? $this->mySQLaccess : $rli;
$nFields = $db_debug->Mark_Query($query, $buglink, $sQryRes, $aTrace, $mytime, $pTable);
$db_debug->Mark_Query($query, $buglink, $sQryRes, $aTrace, $mytime, $pTable);
}
else
{
@ -861,6 +857,16 @@ class e_db_mysql
public function rowCount($result=null)
{
if($this->pdo)
{
if(!$this->mySQLresult)
{
return -1;
}
}
$rows = $this->mySQLrows = ($this->pdo) ? $this->mySQLresult->rowCount() : mysql_num_rows($this->mySQLresult);
$this->dbError('db_Rows');
return $rows;

View File

@ -40,7 +40,7 @@ class notify
{
$active = e107::getConfig()->get('notify');
if(empty($active) && e_PAGE == 'notify.php')
if(empty($active) && defset('e_PAGE') == 'notify.php')
{
e107::getMessage()->addDebug('Notify is disabled!');
return false;

View File

@ -1432,7 +1432,7 @@ class e107plugin
}
// Load install language file and set lan_global pref.
$this->XmlLanguageFiles($function, $plug_vars['languageFiles'], 'pre'); // First of all, see if there's a language file specific to install
$this->XmlLanguageFiles($function, varset($plug_vars['languageFiles']), 'pre'); // First of all, see if there's a language file specific to install
// Next most important, if installing or upgrading, check that any dependencies are met
if ($canContinue && ($function != 'uninstall') && isset($plug_vars['dependencies']))
@ -2116,7 +2116,7 @@ class e107plugin
$data['title'] = $v['@value'];
$data['sef'] = vartrue($v['@attributes']['sef']);
// $data['type'] = $v['@attributes']['type']; //TODO
$data['class'] = $this->getPerm($v['@attributes']['perm'], 'member');
$data['class'] = $this->getPerm(varset($v['@attributes']['perm']), 'member');
$status = e107::getMedia()->createCategory($data) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
$mes->add("Adding Media Category: {$data['category']}", $status);

View File

@ -21,7 +21,7 @@ class secure_image
protected $BASE_DIR;
public $FONT_COLOR = "90,90,90";
function secure_image()
function __construct()
{
/*
@ -30,36 +30,74 @@ class secure_image
return call_user_func($user_func);
}
* */
list($usec, $sec) = explode(" ", microtime());
$this->random_number = str_replace(".", "", $sec.$usec);
$imgp = dirname(__FILE__);
if (substr($imgp,-1,1) != DIRECTORY_SEPARATOR) $imgp .= DIRECTORY_SEPARATOR;
$imgp = str_replace('/', DIRECTORY_SEPARATOR, $imgp);
@include($imgp.'..'.DIRECTORY_SEPARATOR.'e107_config.php');
if(!isset($mySQLserver))
{
if(defined('e_DEBUG'))
{
echo "FAILED TO LOAD e107_config.php in secure_img_handler.php";
}
exit;
}
// FIX - new prefered configuration format - $E107_CONFIG
if(isset($E107_CONFIG))
{
extract($E107_CONFIG);
}
$this->THIS_DIR = $imgp;
$this->BASE_DIR = realpath($imgp.'..'.DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
$this->HANDLERS_DIRECTORY = $HANDLERS_DIRECTORY;
$this->FONTS_DIRECTORY = isset($CORE_DIRECTORY) ? $CORE_DIRECTORY."fonts/" : "e107_core/fonts/";
// $this->IMAGES_DIRECTORY = str_replace('/', DIRECTORY_SEPARATOR, $IMAGES_DIRECTORY);
$this->IMAGES_DIRECTORY = $IMAGES_DIRECTORY;
$this->MYSQL_INFO = array('db' => $mySQLdefaultdb, 'server' => $mySQLserver, 'user' => $mySQLuser, 'password' => $mySQLpassword, 'prefix' => $mySQLprefix);
if(class_exists('e107'))
{
$this->BASE_DIR = e_BASE;
$CORE_DIRECTORY = e107::getFolder('CORE');
$this->HANDLERS_DIRECTORY = e107::getFolder('HANDLERS');
$this->FONTS_DIRECTORY = !empty($CORE_DIRECTORY) ? $CORE_DIRECTORY."fonts/" : "e107_core/fonts/";
// $this->IMAGES_DIRECTORY = str_replace('/', DIRECTORY_SEPARATOR, $IMAGES_DIRECTORY);
$this->IMAGES_DIRECTORY = e107::getFolder('IMAGES');
$this->MYSQL_INFO = array(
'mySQLdefaultdb' => e107::getMySQLConfig('defaultdb'),
'mySQLserver' => e107::getMySQLConfig('server'),
'mySQLuser' => e107::getMySQLConfig('user'),
'mySQLpassword' => e107::getMySQLConfig('password'),
'mySQLprefix' => e107::getMySQLConfig('prefix')
);
}
else
{
$imgp = dirname(__FILE__);
if (substr($imgp,-1,1) != DIRECTORY_SEPARATOR) $imgp .= DIRECTORY_SEPARATOR;
$imgp = str_replace('/', DIRECTORY_SEPARATOR, $imgp);
$HANDLERS_DIRECTORY = '';
$IMAGES_DIRECTORY = '';
$mySQLdefaultdb = '';
$mySQLuser = '';
$mySQLpassword = '';
$mySQLprefix= '';
@include($imgp.'..'.DIRECTORY_SEPARATOR.'e107_config.php');
if(!isset($mySQLserver))
{
if(defined('e_DEBUG'))
{
echo "FAILED TO LOAD e107_config.php in secure_img_handler.php";
}
exit;
}
// FIX - new prefered configuration format - $E107_CONFIG
if(isset($E107_CONFIG))
{
extract($E107_CONFIG);
}
$this->THIS_DIR = $imgp;
$this->BASE_DIR = realpath($imgp.'..'.DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
$this->HANDLERS_DIRECTORY = $HANDLERS_DIRECTORY;
$this->FONTS_DIRECTORY = isset($CORE_DIRECTORY) ? $CORE_DIRECTORY."fonts/" : "e107_core/fonts/";
// $this->IMAGES_DIRECTORY = str_replace('/', DIRECTORY_SEPARATOR, $IMAGES_DIRECTORY);
$this->IMAGES_DIRECTORY = $IMAGES_DIRECTORY;
$this->MYSQL_INFO = array(
'mySQLdefaultdb' => $mySQLdefaultdb,
'mySQLserver' => $mySQLserver,
'mySQLuser' => $mySQLuser,
'mySQLpassword' => $mySQLpassword,
'mySQLprefix' => $mySQLprefix);
}
}
function create_code()
@ -80,7 +118,7 @@ class secure_image
$code = substr($rcode, 2, 6);
$recnum = $this->random_number;
$del_time = time()+1200;
$sql->db_Insert("tmp", "'{$recnum}',{$del_time},'{$code}'");
$sql->insert("tmp", "'{$recnum}',{$del_time},'{$code}'");
return $recnum;
}
@ -97,9 +135,9 @@ class secure_image
$sql = e107::getDb();
$tp = e107::getParser();
if ($sql->db_Select("tmp", "tmp_info", "tmp_ip = '".$tp -> toDB($rec_num)."'")) {
$row = $sql->db_Fetch();
$sql->db_Delete("tmp", "tmp_ip = '".$tp -> toDB($rec_num)."'");
if ($sql->select("tmp", "tmp_info", "tmp_ip = '".$tp -> toDB($rec_num)."'")) {
$row = $sql->fetch();
$sql->delete("tmp", "tmp_ip = '".$tp -> toDB($rec_num)."'");
//list($code, $path) = explode(",", $row['tmp_info']);
$code = intval($row['tmp_info']);
return ($checkstr == $code);
@ -126,8 +164,7 @@ class secure_image
return LAN_INVALID_CODE;
}
return true;
}
@ -196,7 +233,10 @@ class secure_image
$frm = e107::getForm();
return $frm->hidden("rand_num", $this->random_number).$frm->text("code_verify", "", 20, array("size"=>20,"title"=> LAN_ENTER_CODE,'required'=>1, 'placeholder'=>LAN_ENTER_CODE));
}
/**
* @return mixed|string
*/
function renderLabel()
{
if ($user_func = e107::getOverride()->check($this,'renderLabel'))
@ -206,10 +246,13 @@ class secure_image
return LAN_ENTER_CODE;
}
/**
* Render the generated Image. Called without class2 environment (standalone).
* @param $qcode
* @param string $color
* @return mixed
*/
function render($qcode, $color='')
{
@ -228,16 +271,19 @@ class secure_image
return call_user_func($user_func,$qcode);
}
if(!is_numeric($qcode)){ exit; }
$recnum = preg_replace('#\D#',"",$qcode);
$imgtypes = array('png'=>"png",'gif'=>"gif",'jpg'=>"jpeg",);
@mysql_connect($this->MYSQL_INFO['server'], $this->MYSQL_INFO['user'], $this->MYSQL_INFO['password']) || die('db connection failed');
@mysql_select_db($this->MYSQL_INFO['db']);
/** @FIXME - needs to use mysql class. */
$result = mysql_query("SELECT tmp_info FROM {$this->MYSQL_INFO['prefix']}tmp WHERE tmp_ip = '{$recnum}'");
@mysql_connect($this->MYSQL_INFO['mySQLserver'], $this->MYSQL_INFO['mySQLuser'], $this->MYSQL_INFO['mySQLpassword']) || die('db connection failed');
@mysql_select_db($this->MYSQL_INFO['mySQLdefaultdb']);
$result = mysql_query("SELECT tmp_info FROM {$this->MYSQL_INFO['mySQLprefix']}tmp WHERE tmp_ip = '{$recnum}'");
if(!$result || !($row = mysql_fetch_array($result, MYSQL_ASSOC)))
{
// echo "Render Failed";

View File

@ -2228,7 +2228,7 @@ class themeHandler
{
$notadmin = vartrue($val['@attributes']['admin']) ? false : true;
$vars['css'][] = array("name" => $val['@attributes']['file'], "info"=> $val['@attributes']['name'], "nonadmin"=>$notadmin, 'scope'=>$val['@attributes']['scope']);
$vars['css'][] = array("name" => $val['@attributes']['file'], "info"=> $val['@attributes']['name'], "nonadmin"=>$notadmin, 'scope'=> vartrue($val['@attributes']['scope']));
}
unset($vars['stylesheets']);

View File

@ -237,8 +237,8 @@ class e_install
if(defined('PDO::ATTR_DRIVER_NAME')) // TODO Uncomment when ready.
{
// $this->pdo = true;
// define('e_PDO', true);
$this->pdo = true;
define('e_PDO', true);
}
if(!empty($this->previous_steps['mysql']['prefix']))

View File

@ -733,7 +733,7 @@ class pageClass
$ret = e107::getParser()->parseTemplate($ret, true, $this->batch);
if($vars->cachecontrol) $this->setCache($ret, $this->batch->sc_cpagetitle(), $this->page['page_comment_flag']);
if(is_object($vars) && $vars->cachecontrol) $this->setCache($ret, $this->batch->sc_cpagetitle(), $this->page['page_comment_flag']);
//return str_replace('[[PAGECOMMENTS]]', $this->batch->cpagecomments(), $ret);
$this->pageOutput = array('text' => str_replace('[[PAGECOMMENTS]]', $this->batch->cpagecomments(), $ret), 'caption'=>$arr['caption'],'mode'=>$arr['mode']);