1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 14:46:56 +02:00

Shortcode path fixes

This commit is contained in:
CaMer0n
2010-02-10 21:53:56 +00:00
parent 2d835f43d0
commit caa79b6454
18 changed files with 685 additions and 683 deletions

View File

@@ -93,7 +93,7 @@ if($register_globals == true)
// MOVED TO $e107->prepare_request() // MOVED TO $e107->prepare_request()
// TODO - better ajax detection method (headers when possible) // TODO - better ajax detection method (headers when possible)
//define('e_AJAX_REQUEST', isset($_REQUEST['ajax_used'])); //define('e_AJAX_REQUEST', isset($_REQUEST['ajax_used']));
//unset($_REQUEST['ajax_used']); // removed because it's auto-appended from JS (AJAX), could break something... //unset($_REQUEST['ajax_used']); // removed because it's auto-appended from JS (AJAX), could break something...
// //
//if(isset($_E107['minimal']) || e_AJAX_REQUEST) //if(isset($_E107['minimal']) || e_AJAX_REQUEST)
//{ //{
@@ -331,7 +331,7 @@ if (!$ADMIN_DIRECTORY && !$DOWNLOADS_DIRECTORY)
// J: MYSQL INITIALIZATION // J: MYSQL INITIALIZATION
// //
e107::getSingleton('e107_traffic'); // We start traffic counting ASAP e107::getSingleton('e107_traffic'); // We start traffic counting ASAP
//$eTraffic->Calibrate($eTraffic); //$eTraffic->Calibrate($eTraffic);
e107_require_once(e_HANDLER.'mysql_class.php'); e107_require_once(e_HANDLER.'mysql_class.php');
@@ -437,7 +437,7 @@ $pref = e107::getPref();
//this could be part of e107->init() method now, prefs will be auto-initialized //this could be part of e107->init() method now, prefs will be auto-initialized
//when proper called (e107::getPref()) //when proper called (e107::getPref())
// $e107->set_base_path(); moved to init(). // $e107->set_base_path(); moved to init().
//DEPRECATED, BC, call e107::getConfig('menu')->get('pref_name') only when needed //DEPRECATED, BC, call e107::getConfig('menu')->get('pref_name') only when needed
$menu_pref = e107::getConfig('menu')->getPref(); //extract menu prefs $menu_pref = e107::getConfig('menu')->getPref(); //extract menu prefs
@@ -736,8 +736,8 @@ if(isset($pref['notify']) && $pref['notify'] == true)
$sql -> db_Mark_Time('Start: Init session'); $sql -> db_Mark_Time('Start: Init session');
init_session(); init_session();
//DEPRECATED but necessary. BC Fix. //DEPRECATED but necessary. BC Fix.
function getip() function getip()
{ {
return e107::ipDecode(USERIP); return e107::ipDecode(USERIP);
} }
@@ -1019,14 +1019,14 @@ define('TIMEOFFSET', $e_deltaTime);
$sql->db_Mark_Time('(Start: Find/Load Theme)'); $sql->db_Mark_Time('(Start: Find/Load Theme)');
if(e_ADMIN_AREA) // Load admin phrases ASAP if(e_ADMIN_AREA) // Load admin phrases ASAP
{ {
e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_admin.php'); e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_admin.php');
} }
if(!defined('THEME')) if(!defined('THEME'))
{ {
if (e_ADMIN_AREA && varsettrue($pref['admintheme'])) if (e_ADMIN_AREA && varsettrue($pref['admintheme']))
{ {
//We have now e_IFRAME mod and USER_AREA force //We have now e_IFRAME mod and USER_AREA force
@@ -1315,8 +1315,8 @@ function getperms($arg, $ap = ADMINPERMS)
{ {
return false; return false;
} }
if ($ap === '0' || $ap === '0.') // BC fix. if ($ap === '0' || $ap === '0.') // BC fix.
{ {
return true; return true;
} }
@@ -1324,14 +1324,14 @@ function getperms($arg, $ap = ADMINPERMS)
if ($arg == 'P' && preg_match("#(.*?)/".e107::getInstance()->getFolder('plugins')."(.*?)/(.*?)#", e_SELF, $matches)) if ($arg == 'P' && preg_match("#(.*?)/".e107::getInstance()->getFolder('plugins')."(.*?)/(.*?)#", e_SELF, $matches))
{ {
$sql = e107::getDb('psql'); $sql = e107::getDb('psql');
if ($sql->db_Select('plugin', 'plugin_id', "plugin_path = '".$matches[2]."' LIMIT 1 ")) if ($sql->db_Select('plugin', 'plugin_id', "plugin_path = '".$matches[2]."' LIMIT 1 "))
{ {
$row = $sql->db_Fetch(); $row = $sql->db_Fetch();
$arg = 'P'.$row['plugin_id']; $arg = 'P'.$row['plugin_id'];
} }
} }
$ap_array = explode('.',$ap); $ap_array = explode('.',$ap);
if(in_array($arg,$ap_array)) if(in_array($arg,$ap_array))
@@ -1574,17 +1574,17 @@ function init_session()
# - return boolean # - return boolean
# - scope public # - scope public
*/ */
global $pref, $user_pref, $currentUser, $e107, $_E107; global $pref, $user_pref, $currentUser, $e107, $_E107;
$sql = e107::getDb(); $sql = e107::getDb();
$tp = e107::getParser(); $tp = e107::getParser();
$eArrayStorage = e107::getArrayStorage(); $eArrayStorage = e107::getArrayStorage();
define('USERIP', $e107->getip()); define('USERIP', $e107->getip());
if(varset($_E107['cli'])) if(varset($_E107['cli']))
{ {
define('USER', true); define('USER', true);
@@ -1596,7 +1596,7 @@ function init_session()
define('USERCLASS', ''); define('USERCLASS', '');
define('USEREMAIL', ''); define('USEREMAIL', '');
define('USERCLASS_LIST', ''); define('USERCLASS_LIST', '');
define('USERCLASS', ''); define('USERCLASS', '');
return; return;
} }
@@ -1624,7 +1624,7 @@ function init_session()
if (empty($uid) || empty($upw)) if (empty($uid) || empty($upw))
{ {
//$_SESSION[] = e_SELF."?".e_QUERY; //$_SESSION[] = e_SELF."?".e_QUERY;
cookie(e_COOKIE, '', (time() - 2592000)); cookie(e_COOKIE, '', (time() - 2592000));
$_SESSION[e_COOKIE] = ""; $_SESSION[e_COOKIE] = "";
session_destroy(); session_destroy();
@@ -1688,7 +1688,7 @@ function init_session()
define('ADMINEMAIL', $result['user_email']); define('ADMINEMAIL', $result['user_email']);
define('ADMINPWCHANGE', $result['user_pwchange']); define('ADMINPWCHANGE', $result['user_pwchange']);
e107::getRedirect()->setPreviousUrl(); e107::getRedirect()->setPreviousUrl();
} }
else else
{ {
@@ -2096,54 +2096,54 @@ function plugInstalled($plugname)
/** /**
* Magic class autoload. * Magic class autoload.
* We are raising plugin structure standard here - plugin auto-loading works ONLY if * We are raising plugin structure standard here - plugin auto-loading works ONLY if
* classes live inside 'includes' folder. * classes live inside 'includes' folder.
* Example: plugin_myplug_admin_ui -> * Example: plugin_myplug_admin_ui ->
* <code> * <code>
* <?php * <?php
* // __autoload() will look in e_PLUGIN.'myplug/includes/admin/ui.php for this class * // __autoload() will look in e_PLUGIN.'myplug/includes/admin/ui.php for this class
* // e_admin_ui is core handler, so it'll be autoloaded as well * // e_admin_ui is core handler, so it'll be autoloaded as well
* class plugin_myplug_admin_ui extends e_admin_ui * class plugin_myplug_admin_ui extends e_admin_ui
* { * {
* *
* } * }
* *
* // __autoload() will look in e_PLUGIN.'myplug/shortcodes/my_shortcodes.php for this class * // __autoload() will look in e_PLUGIN.'myplug/shortcodes/my_shortcodes.php for this class
* // e_admin_ui is core handler, so it'll be autoloaded as well * // e_admin_ui is core handler, so it'll be autoloaded as well
* class plugin_myplug_my_shortcodes extends e_admin_ui * class plugin_myplug_my_shortcodes extends e_admin_ui
* { * {
* *
* } * }
* </code> * </code>
* TODO - use spl_autoload[_*] for core autoloading some day (PHP5 > 5.1.2) * TODO - use spl_autoload[_*] for core autoloading some day (PHP5 > 5.1.2)
* TODO - at this time we could create e107 version of spl_autoload_register - e_event->register/trigger('autoload') * TODO - at this time we could create e107 version of spl_autoload_register - e_event->register/trigger('autoload')
* *
* @todo plugname/e_shortcode.php auto-detection (hard, near impossible at this time) - we need 'plugin_' prefix to * @todo plugname/e_shortcode.php auto-detection (hard, near impossible at this time) - we need 'plugin_' prefix to
* distinguish them from the core batches * distinguish them from the core batches
* *
* @param string $className * @param string $className
* @return void * @return void
*/ */
function __autoload($className) function __autoload($className)
{ {
//Security... //Security...
if (strpos($className, '/') !== false) if (strpos($className, '/') !== false)
{ {
return; return;
} }
$tmp = explode('_', $className); $tmp = explode('_', $className);
$filename = ''; $filename = '';
switch($tmp[0]) switch($tmp[0])
{ {
case 'plugin': // plugin handlers/shortcode batches case 'plugin': // plugin handlers/shortcode batches
array_shift($tmp); // remove 'plugin' array_shift($tmp); // remove 'plugin'
$end = array_pop($tmp); // check for 'shortcodes' end phrase $end = array_pop($tmp); // check for 'shortcodes' end phrase
if (!isset($tmp[0]) || !$tmp[0]) return; // In case we get an empty class part if (!isset($tmp[0]) || !$tmp[0]) return; // In case we get an empty class part
// Currently only batches inside shortcodes/ folder are auto-detected, // Currently only batches inside shortcodes/ folder are auto-detected,
// read the todo for e_shortcode.php related problems // read the todo for e_shortcode.php related problems
if('shortcodes' == $end) if('shortcodes' == $end)
{ {
$filename = e_PLUGIN.$tmp[0].'/shortcodes/'; // plugname/shortcodes/ $filename = e_PLUGIN.$tmp[0].'/shortcodes/'; // plugname/shortcodes/
@@ -2155,35 +2155,35 @@ function __autoload($className)
{ {
$tmp[] = $end; // not a shortcode batch - append the end phrase again $tmp[] = $end; // not a shortcode batch - append the end phrase again
} }
// Handler check // Handler check
$tmp[0] .= '/includes'; //folder 'includes' is not part of the class name $tmp[0] .= '/includes'; //folder 'includes' is not part of the class name
$filename = e_PLUGIN.implode('/', $tmp).'.php'; $filename = e_PLUGIN.implode('/', $tmp).'.php';
//TODO add debug screen Auto-loaded classes - ['plugin: '.$filename.' - '.$className]; //TODO add debug screen Auto-loaded classes - ['plugin: '.$filename.' - '.$className];
break; break;
default: //core libraries, core shortcode batches default: //core libraries, core shortcode batches
// core SC batch check // core SC batch check
$end = array_pop($tmp); $end = array_pop($tmp);
if('shortcodes' == $end) if('shortcodes' == $end)
{ {
$filename = e_FILE.'shortcode/batch/'.$className.'.php'; // core shortcode batch $filename = e_CORE.'shortcodes/batch/'.$className.'.php'; // core shortcode batch
break; break;
} }
$filename = e107::getHandlerPath($className, true); $filename = e107::getHandlerPath($className, true);
//TODO add debug screen Auto-loaded classes - ['core: '.$filename.' - '.$className]; //TODO add debug screen Auto-loaded classes - ['core: '.$filename.' - '.$className];
break; break;
} }
if($filename) if($filename)
{ {
// autoload doesn't REQUIRE files, because this will break things like call_user_func() // autoload doesn't REQUIRE files, because this will break things like call_user_func()
include($filename); include($filename);
} }
} }
// register __autoload if possible to prevent its override by // register __autoload if possible to prevent its override by
// 3rd party spl_autoload_register calls // 3rd party spl_autoload_register calls
if(function_exists('spl_autoload_register')) if(function_exists('spl_autoload_register'))
{ {

View File

@@ -154,7 +154,7 @@ if(SITECONTACTINFO && $CONTACT_INFO)
if(isset($pref['sitecontacts']) && $pref['sitecontacts'] != 255) if(isset($pref['sitecontacts']) && $pref['sitecontacts'] != 255)
{ {
require_once(e_FILE."shortcode/batch/contact_shortcodes.php"); require_once(e_CORE."shortcodes/batch/contact_shortcodes.php");
$text = $tp->parseTemplate($CONTACT_FORM, TRUE, $contact_shortcodes); $text = $tp->parseTemplate($CONTACT_FORM, TRUE, $contact_shortcodes);
if(trim($text) != "") if(trim($text) != "")

View File

@@ -77,7 +77,7 @@ if(isset($_POST['exportXmlFile']))
$emessage = eMessage::getInstance(); $emessage = eMessage::getInstance();
$emessage->add(LAN_SUCCESS, E_MESSAGE_SUCCESS); $emessage->add(LAN_SUCCESS, E_MESSAGE_SUCCESS);
} }
} }
require_once ("auth.php"); require_once ("auth.php");
@@ -86,7 +86,7 @@ $frm = new e_form();
$st = new system_tools; $st = new system_tools;
/* No longer needed after XML feature added. /* No longer needed after XML feature added.
if(isset($_POST['backup_core']) || $_GET['mode']=='backup_core') if(isset($_POST['backup_core']) || $_GET['mode']=='backup_core')
{ {
@@ -111,14 +111,14 @@ require_once ("footer.php");
class system_tools class system_tools
{ {
public $_options = array(); public $_options = array();
function __construct() function __construct()
{ {
global $mySQLdefaultdb; global $mySQLdefaultdb;
$this->_options = array( $this->_options = array(
"db_update" => array('diz'=>DBLAN_15, 'label'=>DBLAN_16), "db_update" => array('diz'=>DBLAN_15, 'label'=>DBLAN_16),
"verify_sql" => array('diz'=>DBLAN_4, 'label'=>DBLAN_5), "verify_sql" => array('diz'=>DBLAN_4, 'label'=>DBLAN_5),
@@ -132,90 +132,90 @@ class system_tools
'sc_override_scan' => array('diz'=>DBLAN_55, 'label'=> DBLAN_56), 'sc_override_scan' => array('diz'=>DBLAN_55, 'label'=> DBLAN_56),
'convert_to_utf8' => array('diz'=>'Convert Database to UTF-8','label'=>'Convert DB to UTF-8') 'convert_to_utf8' => array('diz'=>'Convert Database to UTF-8','label'=>'Convert DB to UTF-8')
); );
//TODO Merge db_verify.php into db.php
//TODO Merge db_verify.php into db.php
if(isset($_POST['delplug'])) if(isset($_POST['delplug']))
{ {
$this->delete_plugin_entry($_POST['pref_type']); $this->delete_plugin_entry($_POST['pref_type']);
} }
if(isset($_POST['upload'])) if(isset($_POST['upload']))
{ {
$this->importXmlFile(); $this->importXmlFile();
} }
if(isset($_POST['delpref']) || (isset($_POST['delpref_checked']) && isset($_POST['delpref2']))) if(isset($_POST['delpref']) || (isset($_POST['delpref_checked']) && isset($_POST['delpref2'])))
{ {
$this->del_pref_val($_POST['pref_type']); $this->del_pref_val($_POST['pref_type']);
} }
if(isset($_POST['verify_sql_record']) || varset($_GET['mode'])=='verify_sql_record' || isset($_POST['check_verify_sql_record']) || isset($_POST['delete_verify_sql_record'])) if(isset($_POST['verify_sql_record']) || varset($_GET['mode'])=='verify_sql_record' || isset($_POST['check_verify_sql_record']) || isset($_POST['delete_verify_sql_record']))
{ {
// $this->verify_sql_record(); - currently performed in db_verify.php // $this->verify_sql_record(); - currently performed in db_verify.php
} }
if(isset($_POST['importForm']) || $_GET['mode']=='importForm') if(isset($_POST['importForm']) || $_GET['mode']=='importForm')
{ {
$this->importForm(); $this->importForm();
} }
if(isset($_POST['convert_to_utf8']) || $_GET['mode']=='convert_to_utf8') if(isset($_POST['convert_to_utf8']) || $_GET['mode']=='convert_to_utf8')
{ {
$this->convertUTF8Form(); $this->convertUTF8Form();
} }
if(isset($_POST['exportForm']) || $_GET['mode']=='exportForm') if(isset($_POST['exportForm']) || $_GET['mode']=='exportForm')
{ {
$this->exportXmlForm(); $this->exportXmlForm();
} }
if(isset($_POST['optimize_sql']) || $_GET['mode']=='optimize_sql') if(isset($_POST['optimize_sql']) || $_GET['mode']=='optimize_sql')
{ {
$this->optimizesql($mySQLdefaultdb); $this->optimizesql($mySQLdefaultdb);
} }
if(isset($_POST['pref_editor']) || $_GET['mode']=='pref_editor' || isset($_POST['delpref']) || isset($_POST['delpref_checked'])) if(isset($_POST['pref_editor']) || $_GET['mode']=='pref_editor' || isset($_POST['delpref']) || isset($_POST['delpref_checked']))
{ {
$type = isset($_GET['type']) ? $_GET['type'] : "core"; $type = isset($_GET['type']) ? $_GET['type'] : "core";
$this->pref_editor($type); $this->pref_editor($type);
} }
if(isset($_POST['sc_override_scan']) || $_GET['mode']=='sc_override_scan') if(isset($_POST['sc_override_scan']) || $_GET['mode']=='sc_override_scan')
{ {
$this->scan_override(); $this->scan_override();
} }
if(isset($_POST['plugin_scan']) || e_QUERY == "plugin" || isset($_POST['delplug']) || $_GET['mode']=='plugin_scan') if(isset($_POST['plugin_scan']) || e_QUERY == "plugin" || isset($_POST['delplug']) || $_GET['mode']=='plugin_scan')
{ {
$this->plugin_viewscan(); $this->plugin_viewscan();
} }
if(vartrue($_POST['perform_utf8_convert'])) if(vartrue($_POST['perform_utf8_convert']))
{ {
$this->perform_utf8_convert(); $this->perform_utf8_convert();
} }
if(!vartrue($_GET['mode'])) if(!vartrue($_GET['mode']))
{ {
$this->render_options(); $this->render_options();
} }
} }
private function convertUTF8Form() private function convertUTF8Form()
{ {
$emessage = e107::getMessage(); $emessage = e107::getMessage();
$frm = e107::getForm(); $frm = e107::getForm();
//TODO a function to call the e107_config information in e107_class.php. //TODO a function to call the e107_config information in e107_class.php.
require(e_BASE."e107_config.php"); require(e_BASE."e107_config.php");
$dbtable = $mySQLdefaultdb; $dbtable = $mySQLdefaultdb;
//TODO LAN //TODO LAN
$message = ' $message = '
This function will permanently modify all tables in your database. ('.$mySQLdefaultdb.')<br /> This function will permanently modify all tables in your database. ('.$mySQLdefaultdb.')<br />
@@ -234,7 +234,7 @@ class system_tools
<strong>Be sure</strong> you followed all steps of the upgrade process first.</li> <strong>Be sure</strong> you followed all steps of the upgrade process first.</li>
<li>It should work without troubles for databases of sites using only UTF-8 charset. Probably not with other charsets.</li> <li>It should work without troubles for databases of sites using only UTF-8 charset. Probably not with other charsets.</li>
<li>The function uses the information_schema database for now.</li> <li>The function uses the information_schema database for now.</li>
</ul> </ul>
'; ';
$emessage->add($message, E_MESSAGE_WARNING); $emessage->add($message, E_MESSAGE_WARNING);
@@ -248,70 +248,70 @@ class system_tools
</div> </div>
</fieldset> </fieldset>
</form>"; </form>";
e107::getRender()->tablerender("Convert Database to UTF-8", $emessage->render().$text); e107::getRender()->tablerender("Convert Database to UTF-8", $emessage->render().$text);
} }
private function perform_utf8_convert() private function perform_utf8_convert()
{ {
require(e_BASE."e107_config.php"); require(e_BASE."e107_config.php");
$dbtable = $mySQLdefaultdb; $dbtable = $mySQLdefaultdb;
//TODO Add a check to be sure the database is not already utf-8. //TODO Add a check to be sure the database is not already utf-8.
// yep, needs more methods - possibly a class in e107_handler // yep, needs more methods - possibly a class in e107_handler
$sql = e107::getDb(); $sql = e107::getDb();
$mes = e107::getMessage(); $mes = e107::getMessage();
$ERROR = FALSE; $ERROR = FALSE;
if(!mysql_query("USE information_schema;")) if(!mysql_query("USE information_schema;"))
{ {
$mes->add("Couldn't read information_schema", E_MESSAGE_ERROR); $mes->add("Couldn't read information_schema", E_MESSAGE_ERROR);
return; return;
} }
$queries = array(); $queries = array();
$queries[] = $this->getQueries("SELECT CONCAT('ALTER TABLE ', table_name, ' MODIFY ', column_name, ' ', REPLACE(column_type, 'char', 'binary'), ';') FROM columns WHERE table_schema = '".$dbtable."' and data_type LIKE '%char%';"); $queries[] = $this->getQueries("SELECT CONCAT('ALTER TABLE ', table_name, ' MODIFY ', column_name, ' ', REPLACE(column_type, 'char', 'binary'), ';') FROM columns WHERE table_schema = '".$dbtable."' and data_type LIKE '%char%';");
$queries[] = $this->getQueries("SELECT CONCAT('ALTER TABLE ', table_name, ' MODIFY ', column_name, ' ', REPLACE(column_type, 'text', 'blob'), ';') FROM columns WHERE table_schema = '".$dbtable."' and data_type LIKE '%text%';"); $queries[] = $this->getQueries("SELECT CONCAT('ALTER TABLE ', table_name, ' MODIFY ', column_name, ' ', REPLACE(column_type, 'text', 'blob'), ';') FROM columns WHERE table_schema = '".$dbtable."' and data_type LIKE '%text%';");
$queries2 = array(); $queries2 = array();
$queries2[] = $this->getQueries("SELECT CONCAT('ALTER TABLE ', table_name, ' MODIFY ', column_name, ' ', column_type, ' CHARACTER SET utf8;') FROM columns WHERE table_schema = '".$dbtable."' and data_type LIKE '%char%';"); $queries2[] = $this->getQueries("SELECT CONCAT('ALTER TABLE ', table_name, ' MODIFY ', column_name, ' ', column_type, ' CHARACTER SET utf8;') FROM columns WHERE table_schema = '".$dbtable."' and data_type LIKE '%char%';");
$queries2[] = $this->getQueries("SELECT CONCAT('ALTER TABLE ', table_name, ' MODIFY ', column_name, ' ', column_type, ' CHARACTER SET utf8;') FROM columns WHERE table_schema = '".$dbtable."' and data_type LIKE '%text%';"); $queries2[] = $this->getQueries("SELECT CONCAT('ALTER TABLE ', table_name, ' MODIFY ', column_name, ' ', column_type, ' CHARACTER SET utf8;') FROM columns WHERE table_schema = '".$dbtable."' and data_type LIKE '%text%';");
mysql_query("USE ".$dbtable); mysql_query("USE ".$dbtable);
foreach($queries as $qry) foreach($queries as $qry)
{ {
foreach($qry as $q) foreach($qry as $q)
{ {
if(!$sql->db_Query($q)) if(!$sql->db_Query($q))
{ {
$mes->add($q, E_MESSAGE_ERROR); $mes->add($q, E_MESSAGE_ERROR);
$ERROR = TRUE; $ERROR = TRUE;
} }
} }
} }
//------------ //------------
$result = mysql_list_tables($dbtable); $result = mysql_list_tables($dbtable);
while ($row = mysql_fetch_array($result, MYSQL_NUM)) while ($row = mysql_fetch_array($result, MYSQL_NUM))
{ {
$table = $row[0]; $table = $row[0];
$tab_query = "ALTER TABLE ".$table." charset=utf8; "; $tab_query = "ALTER TABLE ".$table." charset=utf8; ";
if(!$sql->db_Query($tab_query)) if(!$sql->db_Query($tab_query))
{ {
$mes->add($tab_query, E_MESSAGE_ERROR); $mes->add($tab_query, E_MESSAGE_ERROR);
$ERROR = TRUE; $ERROR = TRUE;
} }
} }
// --------------- // ---------------
foreach($queries2 as $qry) foreach($queries2 as $qry)
{ {
foreach($qry as $q) foreach($qry as $q)
@@ -319,32 +319,32 @@ class system_tools
if(!$sql->db_Query($q)) if(!$sql->db_Query($q))
{ {
$mes->add($q, E_MESSAGE_ERROR); $mes->add($q, E_MESSAGE_ERROR);
$ERROR = TRUE; $ERROR = TRUE;
} }
} }
} }
//------------ //------------
$lastQry = "ALTER DATABASE `".$dbtable."` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;"; $lastQry = "ALTER DATABASE `".$dbtable."` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;";
if(!$sql->db_Query($lastQry)) if(!$sql->db_Query($lastQry))
{ {
$mes->add($lastQry, E_MESSAGE_ERROR); $mes->add($lastQry, E_MESSAGE_ERROR);
} }
elseif($ERROR != TRUE) elseif($ERROR != TRUE)
{ {
$message = "Database Converted successfully to UTF-8. <br /> $message = "Database Converted successfully to UTF-8. <br />
Please now add the following line to your e107_config.php file:<br /> Please now add the following line to your e107_config.php file:<br />
<b>\$mySQLcharset = 'utf8';</b> <b>\$mySQLcharset = 'utf8';</b>
"; ";
$mes->add($message, E_MESSAGE_SUCCESS); $mes->add($message, E_MESSAGE_SUCCESS);
} }
} }
function getQueries($query) function getQueries($query)
{ {
if(!$result = mysql_query($query)) if(!$result = mysql_query($query))
@@ -354,49 +354,49 @@ class system_tools
} }
while ($row = mysql_fetch_array($result, MYSQL_NUM)) while ($row = mysql_fetch_array($result, MYSQL_NUM))
{ {
$qry[] = $row[0]; $qry[] = $row[0];
} }
return $qry; return $qry;
} }
/** /**
* Delete selected preferences. * Delete selected preferences.
* @return none * @return none
*/ */
private function del_pref_val($mode='core') private function del_pref_val($mode='core')
{ {
global $emessage; global $emessage;
$deleted_list = ""; $deleted_list = "";
$config = ($mode == 'core' || $mode='') ? e107::getConfig('core') : e107::getPlugConfig($mode); $config = ($mode == 'core' || $mode='') ? e107::getConfig('core') : e107::getPlugConfig($mode);
// Single Pref Deletion using button // Single Pref Deletion using button
if(varset($_POST['delpref'])) if(varset($_POST['delpref']))
{ {
$delpref = key($_POST['delpref']); $delpref = key($_POST['delpref']);
if($config->remove($delpref)) if($config->remove($delpref))
{ {
$deleted_list .= "<li>".$delpref."</li>"; $deleted_list .= "<li>".$delpref."</li>";
} }
} }
// Multiple Pref deletion using checkboxes // Multiple Pref deletion using checkboxes
if(varset($_POST['delpref2'])) if(varset($_POST['delpref2']))
{ {
foreach($_POST['delpref2'] as $k => $v) foreach($_POST['delpref2'] as $k => $v)
{ {
if($config->remove($k)) if($config->remove($k))
{ {
$deleted_list .= "<li>".$k."</li>"; $deleted_list .= "<li>".$k."</li>";
} }
} }
} }
if($deleted_list && $config->save()) if($deleted_list && $config->save())
{ {
$emessage->add(LAN_DELETED."<ul>".$deleted_list."</ul>"); $emessage->add(LAN_DELETED."<ul>".$deleted_list."</ul>");
e107::getCache()->clear(); e107::getCache()->clear();
} }
@@ -406,7 +406,7 @@ class system_tools
private function delete_plugin_entry() private function delete_plugin_entry()
{ {
global $sql, $emessage; global $sql, $emessage;
$del = array_keys($_POST['delplug']); $del = array_keys($_POST['delplug']);
if($sql->db_Delete("plugin", "plugin_id='".intval($del[0])."' LIMIT 1")) if($sql->db_Delete("plugin", "plugin_id='".intval($del[0])."' LIMIT 1"))
{ {
@@ -416,7 +416,7 @@ class system_tools
{ {
$emessage->add(LAN_DELETED_FAILED, E_MESSAGE_WARNING); $emessage->add(LAN_DELETED_FAILED, E_MESSAGE_WARNING);
} }
} }
@@ -424,11 +424,11 @@ class system_tools
/** /**
* Render Options * Render Options
* @return none * @return none
*/ */
private function render_options() private function render_options()
{ {
$frm = e107::getSingleton('e_form'); $frm = e107::getSingleton('e_form');
$text = " $text = "
<form method='post' action='".e_SELF."' id='core-db-main-form'> <form method='post' action='".e_SELF."' id='core-db-main-form'>
<fieldset id='core-db-plugin-scan'> <fieldset id='core-db-plugin-scan'>
@@ -439,7 +439,7 @@ class system_tools
<col style='width: 40%'></col> <col style='width: 40%'></col>
</colgroup> </colgroup>
<tbody>"; <tbody>";
foreach($this->_options as $key=>$val) foreach($this->_options as $key=>$val)
{ {
$text .= "<tr> $text .= "<tr>
@@ -447,12 +447,12 @@ class system_tools
<td> <td>
".$frm->radio('db_execute', $key).$frm->label($val['label'], 'db_execute', $key)." ".$frm->radio('db_execute', $key).$frm->label($val['label'], 'db_execute', $key)."
</td> </td>
</tr>\n"; </tr>\n";
} }
$text .= " $text .= "
</tbody> </tbody>
</table> </table>
<div class='buttons-bar center'> <div class='buttons-bar center'>
@@ -461,36 +461,36 @@ class system_tools
</fieldset> </fieldset>
</form> </form>
"; ";
$emessage = eMessage::getInstance(); $emessage = eMessage::getInstance();
e107::getRender()->tablerender(DBLAN_10, $emessage->render().$text); e107::getRender()->tablerender(DBLAN_10, $emessage->render().$text);
} }
/** /**
* Import XML Form * Import XML Form
* @return none * @return none
*/ */
private function importForm() private function importForm()
{ {
// Get largest allowable file upload // Get largest allowable file upload
$frm = e107::getSingleton('e_form'); $frm = e107::getSingleton('e_form');
require_once(e_HANDLER.'upload_handler.php'); require_once(e_HANDLER.'upload_handler.php');
$max_file_size = get_user_max_upload(); $max_file_size = get_user_max_upload();
$text = " $text = "
<form enctype='multipart/form-data' method='post' action='".e_SELF."?mode=".$_GET['mode']."'> <form enctype='multipart/form-data' method='post' action='".e_SELF."?mode=".$_GET['mode']."'>
<table cellpadding='0' cellspacing='0' class='adminform'> <table cellpadding='0' cellspacing='0' class='adminform'>
<colgroup span='2'> <colgroup span='2'>
<col class='col-label' /> <col class='col-label' />
<col class='col-control' /> <col class='col-control' />
</colgroup> </colgroup>
<tbody> <tbody>
<tr> <tr>
<td>".LAN_UPLOAD."</td> <td>".LAN_UPLOAD."</td>
@@ -502,138 +502,138 @@ class system_tools
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div class='center buttons-bar'>"; <div class='center buttons-bar'>";
$text .= $frm->admin_button('upload', LAN_UPLOAD, 'submit', LAN_UPLOAD); $text .= $frm->admin_button('upload', LAN_UPLOAD, 'submit', LAN_UPLOAD);
$text .= " $text .= "
</div> </div>
</form>\n"; </form>\n";
$emessage = eMessage::getInstance(); $emessage = eMessage::getInstance();
e107::getRender()->tablerender(DBLAN_59, $emessage->render().$text); e107::getRender()->tablerender(DBLAN_59, $emessage->render().$text);
} }
/** /**
* Export XML Dump * Export XML Dump
* @return none * @return none
*/ */
private function exportXmlForm() private function exportXmlForm()
{ {
$emessage = eMessage::getInstance(); $emessage = eMessage::getInstance();
$frm = e107::getSingleton('e_form'); $frm = e107::getSingleton('e_form');
//TODO LANs //TODO LANs
$text = "<form method='post' action='".e_SELF."?".e_QUERY."' id='core-db-export-form'> $text = "<form method='post' action='".e_SELF."?".e_QUERY."' id='core-db-export-form'>
<fieldset id='core-db-export'> <fieldset id='core-db-export'>
<legend class='e-hideme'>Export Options</legend> <legend class='e-hideme'>Export Options</legend>
<table cellpadding='0' cellspacing='0' class='adminlist'> <table cellpadding='0' cellspacing='0' class='adminlist'>
<colgroup span='2'> <colgroup span='2'>
<col style='width: 80%'></col> <col style='width: 80%'></col>
<col style='width: 20%'></col> <col style='width: 20%'></col>
</colgroup> </colgroup>
<thead> <thead>
<tr> <tr>
<th>".$frm->checkbox_toggle('check-all-verify', 'xml_prefs')." Preferences</th> <th>".$frm->checkbox_toggle('check-all-verify', 'xml_prefs')." Preferences</th>
<th class='right'>Rows</th> <th class='right'>Rows</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
"; ";
$pref_types = e107::getConfig()->aliases; $pref_types = e107::getConfig()->aliases;
unset($pref_types['core_old'],$pref_types['core_backup']); unset($pref_types['core_old'],$pref_types['core_backup']);
// $exclusions = array('core_old'=>1,'core_backup'=>1); // $exclusions = array('core_old'=>1,'core_backup'=>1);
// $filteredprefs = array_diff($pref_types,$exclusions); // $filteredprefs = array_diff($pref_types,$exclusions);
foreach($pref_types as $key=>$description) foreach($pref_types as $key=>$description)
{ {
$checked = ($_POST['xml_prefs'][$key] == $key) ? 1: 0; $checked = ($_POST['xml_prefs'][$key] == $key) ? 1: 0;
$text .= "<tr> $text .= "<tr>
<td> <td>
".$frm->checkbox("xml_prefs[".$key."]", $key, $checked)." ".$frm->checkbox("xml_prefs[".$key."]", $key, $checked)."
".LAN_PREFS.": ".$key."</td> ".LAN_PREFS.": ".$key."</td>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr>"; </tr>";
} }
$text .= "</tbody> $text .= "</tbody>
</table> </table>
<table cellpadding='0' cellspacing='0' class='adminlist'> <table cellpadding='0' cellspacing='0' class='adminlist'>
<colgroup span='2'> <colgroup span='2'>
<col style='width: 80%'></col> <col style='width: 80%'></col>
<col style='width: 20%'></col> <col style='width: 20%'></col>
</colgroup> </colgroup>
<thead> <thead>
<tr> <tr>
<th>".$frm->checkbox_toggle('check-all-verify', 'xml_tables')."Tables</th> <th>".$frm->checkbox_toggle('check-all-verify', 'xml_tables')."Tables</th>
<th class='right'>Rows</th> <th class='right'>Rows</th>
</tr> </tr>
</thead> </thead>
<tbody>\n"; <tbody>\n";
$tables = table_list(); $tables = table_list();
foreach($tables as $name=>$count) foreach($tables as $name=>$count)
{ {
$checked = ($_POST['xml_tables'][$name] == $name) ? 1: 0; $checked = ($_POST['xml_tables'][$name] == $name) ? 1: 0;
$text .= "<tr> $text .= "<tr>
<td> <td>
".$frm->checkbox("xml_tables[".$name."]", $name, $checked)." Table Data: ".$name." ".$frm->checkbox("xml_tables[".$name."]", $name, $checked)." Table Data: ".$name."
</td> </td>
<td class='right'>$count</td> <td class='right'>$count</td>
</tr>"; </tr>";
} }
$text .=" $text .="
</tbody> </tbody>
</table> </table>
<table cellpadding='0' cellspacing='0' class='adminlist'> <table cellpadding='0' cellspacing='0' class='adminlist'>
<colgroup span='2'> <colgroup span='2'>
<col style='width: 80%'></col> <col style='width: 80%'></col>
<col style='width: 20%'></col> <col style='width: 20%'></col>
</colgroup> </colgroup>
<thead> <thead>
<tr> <tr>
<th colspan='2'>".LAN_OPTIONS."</th> <th colspan='2'>".LAN_OPTIONS."</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td colspan='2'>"; <td colspan='2'>";
$checked = (vartrue($_POST['package_images'])) ? 1: 0; $checked = (vartrue($_POST['package_images'])) ? 1: 0;
$text .= $frm->checkbox("package_images",'package_images', $checked)." Convert paths and package images and xml into: <i>".e107::getParser()->replaceConstants(EXPORT_PATH)."</i> $text .= $frm->checkbox("package_images",'package_images', $checked)." Convert paths and package images and xml into: <i>".e107::getParser()->replaceConstants(EXPORT_PATH)."</i>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div class='buttons-bar center'> <div class='buttons-bar center'>
".$frm->admin_button('exportXmlFile', "Export File", 'exportXmlFile')." ".$frm->admin_button('exportXmlFile', "Export File", 'exportXmlFile')."
</div> </div>
</fieldset> </fieldset>
</form> "; </form> ";
e107::getRender()->tablerender("Export Options",$emessage->render(). $text); e107::getRender()->tablerender("Export Options",$emessage->render(). $text);
} }
/** /**
@@ -646,15 +646,15 @@ class system_tools
foreach($ret['success'] as $table) foreach($ret['success'] as $table)
{ {
eMessage::getInstance()->add("Inserted $table", E_MESSAGE_SUCCESS); eMessage::getInstance()->add("Inserted $table", E_MESSAGE_SUCCESS);
} }
foreach($ret['failed'] as $table) foreach($ret['failed'] as $table)
{ {
eMessage::getInstance()->add("Failed to Insert $table", E_MESSAGE_ERROR); eMessage::getInstance()->add("Failed to Insert $table", E_MESSAGE_ERROR);
} }
} }
/** /**
* Optimize SQL * Optimize SQL
* @return none * @return none
@@ -667,11 +667,11 @@ class system_tools
{ {
mysql_query("OPTIMIZE TABLE ".$row[0]); mysql_query("OPTIMIZE TABLE ".$row[0]);
} }
// $emessage->add(DBLAN_11." $mySQLdefaultdb ".DBLAN_12, E_MESSAGE_SUCCESS); // $emessage->add(DBLAN_11." $mySQLdefaultdb ".DBLAN_12, E_MESSAGE_SUCCESS);
e107::getRender()->tablerender(DBLAN_7, DBLAN_11." $mySQLdefaultdb ".DBLAN_12); e107::getRender()->tablerender(DBLAN_7, DBLAN_11." $mySQLdefaultdb ".DBLAN_12);
} }
/** /**
* Preferences Editor * Preferences Editor
* @return string text for display * @return string text for display
@@ -679,36 +679,36 @@ class system_tools
private function pref_editor($type='core') private function pref_editor($type='core')
{ {
//TODO Add drop-down for editing personal perfs also. ie. user pref of self. (admin) //TODO Add drop-down for editing personal perfs also. ie. user pref of self. (admin)
global $pref, $e107, $emessage, $frm;
global $pref, $e107, $emessage, $frm;
$config = ($type == 'core') ? e107::getConfig('core') : e107::getPlugConfig($type); $config = ($type == 'core') ? e107::getConfig('core') : e107::getPlugConfig($type);
$spref = $config->getPref(); $spref = $config->getPref();
ksort($spref); ksort($spref);
$text = " $text = "
<form method='post' action='".e_ADMIN."db.php?mode=".$_GET['mode']."&amp;type=".$type."' id='pref_edit'> <form method='post' action='".e_ADMIN."db.php?mode=".$_GET['mode']."&amp;type=".$type."' id='pref_edit'>
<fieldset id='core-db-pref-edit'> <fieldset id='core-db-pref-edit'>
<legend class='e-hideme'>".DBLAN_20."</legend>"; <legend class='e-hideme'>".DBLAN_20."</legend>";
$text .= "<select class='tbox' name='type_select' onchange='urljump(this.options[selectedIndex].value)' > $text .= "<select class='tbox' name='type_select' onchange='urljump(this.options[selectedIndex].value)' >
<option value='".e_ADMIN."db.php?mode=".$_GET['mode']."&amp;type=core'>Core</option>\n"; <option value='".e_ADMIN."db.php?mode=".$_GET['mode']."&amp;type=core'>Core</option>\n";
// e107::getConfig($type)->aliases // e107::getConfig($type)->aliases
e107::getDb()->db_Select_gen("SELECT e107_name FROM #core WHERE e107_name LIKE ('plugin_%') ORDER BY e107_name"); e107::getDb()->db_Select_gen("SELECT e107_name FROM #core WHERE e107_name LIKE ('plugin_%') ORDER BY e107_name");
while ($row = e107::getDb()->db_Fetch()) while ($row = e107::getDb()->db_Fetch())
{ {
$key = str_replace("plugin_","",$row['e107_name']); $key = str_replace("plugin_","",$row['e107_name']);
$selected = (varset($_GET['type'])==$key) ? "selected='selected'" : ""; $selected = (varset($_GET['type'])==$key) ? "selected='selected'" : "";
$text .= "<option value='".e_ADMIN."db.php?mode=".$_GET['mode']."&amp;type=".$key."' {$selected}>".ucwords($key)."</option>\n"; $text .= "<option value='".e_ADMIN."db.php?mode=".$_GET['mode']."&amp;type=".$key."' {$selected}>".ucwords($key)."</option>\n";
} }
$text .= "</select></div> $text .= "</select></div>
<table cellpadding='0' cellspacing='0' class='adminlist'> <table cellpadding='0' cellspacing='0' class='adminlist'>
<colgroup span='4'> <colgroup span='4'>
@@ -727,12 +727,12 @@ class system_tools
</thead> </thead>
<tbody> <tbody>
"; ";
foreach($spref as $key => $val) foreach($spref as $key => $val)
{ {
$ptext = (is_array($val)) ? "<pre>".print_r($val, TRUE)."</pre>" : htmlspecialchars($val, ENT_QUOTES, 'utf-8'); $ptext = (is_array($val)) ? "<pre>".print_r($val, TRUE)."</pre>" : htmlspecialchars($val, ENT_QUOTES, 'utf-8');
$ptext = $e107->tp->textclean($ptext, 80); $ptext = $e107->tp->textclean($ptext, 80);
$text .= " $text .= "
<tr> <tr>
<td class='center autocheck e-pointer'>".$frm->checkbox("delpref2[$key]", 1)."</td> <td class='center autocheck e-pointer'>".$frm->checkbox("delpref2[$key]", 1)."</td>
@@ -742,7 +742,7 @@ class system_tools
</tr> </tr>
"; ";
} }
$text .= " $text .= "
</tbody> </tbody>
</table> </table>
@@ -753,25 +753,26 @@ class system_tools
</div> </div>
</fieldset> </fieldset>
</form>\n\n"; </form>\n\n";
e107::getRender()->tablerender(DBLAN_10.' :: '.DBLAN_20." :: ".ucwords($type), $emessage->render().$text); e107::getRender()->tablerender(DBLAN_10.' :: '.DBLAN_20." :: ".ucwords($type), $emessage->render().$text);
return $text; return $text;
} }
/** /**
* Preferences Editor * Preferences Editor
* @return none * @return none
*/ */
private function scan_override() private function scan_override()
{ {
global $pref, $emessage; global $pref, $emessage;
require_once(e_HANDLER.'file_class.php'); require_once(e_HANDLER.'file_class.php');
$f = new e_file; $f = new e_file;
$scList = ''; $scList = '';
$fList = $f->get_files(e_FILE.'shortcode/override', '\.sc$');
$fList = $f->get_files(e_SYSTEM.'override/shortcodes', '\.sc$');
if(count($fList)) if(count($fList))
{ {
$tmp = array(); $tmp = array();
@@ -791,38 +792,38 @@ class system_tools
/** /**
* Plugin Folder Scanner * Plugin Folder Scanner
* @return none * @return none
*/ */
private function plugin_viewscan() private function plugin_viewscan()
{ {
$error_messages = array(0 => DBLAN_31, 1 => DBLAN_32, 2 => DBLAN_33, 3 => DBLAN_34); $error_messages = array(0 => DBLAN_31, 1 => DBLAN_32, 2 => DBLAN_33, 3 => DBLAN_34);
$error_image = array("integrity_pass.png", "integrity_fail.png", "warning.png", "blank.png"); $error_image = array("integrity_pass.png", "integrity_fail.png", "warning.png", "blank.png");
global $e107; global $e107;
$sql = e107::getDb(); $sql = e107::getDb();
$tp = e107::getParser(); $tp = e107::getParser();
$frm = e107::getForm(); $frm = e107::getForm();
$emessage = e107::getMessage(); $emessage = e107::getMessage();
require_once (e_HANDLER."plugin_class.php"); require_once (e_HANDLER."plugin_class.php");
$ep = new e107plugin(); $ep = new e107plugin();
$ep->update_plugins_table(); // scan for e_xxx changes and save to plugin table. $ep->update_plugins_table(); // scan for e_xxx changes and save to plugin table.
$ep->save_addon_prefs(); // generate global e_xxx_list prefs from plugin table. $ep->save_addon_prefs(); // generate global e_xxx_list prefs from plugin table.
/* we all are awaiting for PHP5 only support - method chaining... /* we all are awaiting for PHP5 only support - method chaining...
$emessage->add(DBLAN_22.' - '.DBLAN_23, E_MESSAGE_SUCCESS) $emessage->add(DBLAN_22.' - '.DBLAN_23, E_MESSAGE_SUCCESS)
->add("<a href='".e_SELF."'>".LAN_BACK."</a>", E_MESSAGE_SUCCESS) ->add("<a href='".e_SELF."'>".LAN_BACK."</a>", E_MESSAGE_SUCCESS)
->add(DBLAN_30); ->add(DBLAN_30);
*/ */
$emessage->add(DBLAN_23, E_MESSAGE_SUCCESS); $emessage->add(DBLAN_23, E_MESSAGE_SUCCESS);
$emessage->add("<a href='".e_SELF."'>".LAN_BACK."</a>", E_MESSAGE_SUCCESS); $emessage->add("<a href='".e_SELF."'>".LAN_BACK."</a>", E_MESSAGE_SUCCESS);
$emessage->add(DBLAN_30); $emessage->add(DBLAN_30);
$text = " $text = "
<form method='post' action='".e_ADMIN."db.php?mode=".$_GET['mode']."' id='plug_edit'> <form method='post' action='".e_ADMIN."db.php?mode=".$_GET['mode']."' id='plug_edit'>
<fieldset id='core-db-plugin-scan'> <fieldset id='core-db-plugin-scan'>
@@ -844,19 +845,19 @@ class system_tools
</thead> </thead>
<tbody> <tbody>
"; ";
$sql->db_Select("plugin", "*", "plugin_id !='' order by plugin_path ASC"); // Must order by path to pick up duplicates. (plugin names may change). $sql->db_Select("plugin", "*", "plugin_id !='' order by plugin_path ASC"); // Must order by path to pick up duplicates. (plugin names may change).
$previous = ''; $previous = '';
while($row = $sql->db_Fetch()) while($row = $sql->db_Fetch())
{ {
e107::loadLanFiles($row['plugin_path'],'admin'); e107::loadLanFiles($row['plugin_path'],'admin');
$text .= " $text .= "
<tr> <tr>
<td>".$e107->tp->toHtml($row['plugin_name'], FALSE, "defs,emotes_off")."</td> <td>".$e107->tp->toHtml($row['plugin_name'], FALSE, "defs,emotes_off")."</td>
<td>".$row['plugin_path']."</td> <td>".$row['plugin_path']."</td>
<td>"; <td>";
if(trim($row['plugin_addons'])) if(trim($row['plugin_addons']))
{ {
//XXX - $nl_code = ''; - OLD VAR? //XXX - $nl_code = ''; - OLD VAR?
@@ -873,12 +874,12 @@ class system_tools
$text .= "</div>"; $text .= "</div>";
} }
} }
$text .= " $text .= "
</td> </td>
<td class='center'> <td class='center'>
"; ";
if($previous == $row['plugin_path']) if($previous == $row['plugin_path'])
{ {
$delid = $row['plugin_id']; $delid = $row['plugin_id'];
@@ -898,14 +899,14 @@ class system_tools
"; ";
$previous = $row['plugin_path']; $previous = $row['plugin_path'];
} }
$text .= " $text .= "
</tbody> </tbody>
</table> </table>
</fieldset> </fieldset>
</form> </form>
"; ";
e107::getRender()->tablerender(DBLAN_10.' - '.DBLAN_22, $emessage->render().$text); e107::getRender()->tablerender(DBLAN_10.' - '.DBLAN_22, $emessage->render().$text);
} }
} }
@@ -915,14 +916,14 @@ class system_tools
function db_adminmenu() function db_adminmenu()
{ {
global $st; global $st;
foreach($st->_options as $key=>$val) foreach($st->_options as $key=>$val)
{ {
$var[$key]['text'] = $val['label']; $var[$key]['text'] = $val['label'];
$var[$key]['link'] = e_SELF."?mode=".$key; $var[$key]['link'] = e_SELF."?mode=".$key;
} }
e_admin_menu(DBLAN_10, $_GET['mode'], $var); e_admin_menu(DBLAN_10, $_GET['mode'], $var);
} }
@@ -938,28 +939,28 @@ function exportXmlFile($prefs,$tables,$package=FALSE,$debug=FALSE)
$xml = e107::getSingleton('xmlClass'); $xml = e107::getSingleton('xmlClass');
$tp = e107::getParser(); $tp = e107::getParser();
$emessage = eMessage::getInstance(); $emessage = eMessage::getInstance();
//TODO LANs //TODO LANs
if(vartrue($package)) if(vartrue($package))
{ {
$xml->convertFilePaths = TRUE; $xml->convertFilePaths = TRUE;
$xml->filePathDestination = EXPORT_PATH; $xml->filePathDestination = EXPORT_PATH;
$xml->filePathPrepend = array( $xml->filePathPrepend = array(
'news_thumbnail' => "{e_IMAGE}newspost_images/" 'news_thumbnail' => "{e_IMAGE}newspost_images/"
); );
$desinationFolder = $tp->replaceConstants($xml->filePathDestination); $desinationFolder = $tp->replaceConstants($xml->filePathDestination);
if(!is_writable($desinationFolder)) if(!is_writable($desinationFolder))
{ {
$emessage->add($desinationFolder." is not writable", E_MESSAGE_ERROR); $emessage->add($desinationFolder." is not writable", E_MESSAGE_ERROR);
return ; return ;
} }
} }
if($xml->e107Export($prefs,$tables,$debug)) if($xml->e107Export($prefs,$tables,$debug))
{ {
@@ -976,8 +977,8 @@ function exportXmlFile($prefs,$tables,$package=FALSE,$debug=FALSE)
} }
else else
{ {
$emessage->add("Couldn't copy: ".$newfile, E_MESSAGE_ERROR); $emessage->add("Couldn't copy: ".$newfile, E_MESSAGE_ERROR);
} }
} }
} }
} }
@@ -989,8 +990,8 @@ function exportXmlFile($prefs,$tables,$package=FALSE,$debug=FALSE)
function table_list() function table_list()
{ {
// grab default language lists. // grab default language lists.
//TODO - a similar function is in db_verify.php. Should probably all be moved to mysql_class.php. //TODO - a similar function is in db_verify.php. Should probably all be moved to mysql_class.php.
$exclude = array(); $exclude = array();
$exclude[] = "core"; $exclude[] = "core";
$exclude[] = "rbinary"; $exclude[] = "rbinary";
@@ -1000,19 +1001,19 @@ function table_list()
$exclude[] = "upload"; $exclude[] = "upload";
$exclude[] = "user_extended_country"; $exclude[] = "user_extended_country";
$exclude[] = "plugin"; $exclude[] = "plugin";
$coreTables = e107::getDb()->db_TableList('nolan'); $coreTables = e107::getDb()->db_TableList('nolan');
$tables = array_diff($coreTables,$exclude); $tables = array_diff($coreTables,$exclude);
foreach($tables as $e107tab) foreach($tables as $e107tab)
{ {
$count = e107::getDb()->db_Select_gen("SELECT * FROM #".$e107tab); $count = e107::getDb()->db_Select_gen("SELECT * FROM #".$e107tab);
if($count) if($count)
{ {
$tabs[$e107tab] = $count; $tabs[$e107tab] = $count;
} }
} }
return $tabs; return $tabs;
@@ -1035,7 +1036,7 @@ function backup_core()
*/ */
function verify_sql_record() // deprecated by db_verify.php ( i think). function verify_sql_record() // deprecated by db_verify.php ( i think).
{ {
global $emessage, $sql, $sql2, $sql3, $frm, $e107, $tp; global $emessage, $sql, $sql2, $sql3, $frm, $e107, $tp;

View File

@@ -17,7 +17,7 @@
define('DOWNLOAD_DEBUG',FALSE); define('DOWNLOAD_DEBUG',FALSE);
require_once("../class2.php"); require_once("../class2.php");
if (!getperms("R")) if (!getperms("R"))
{ {
header("location:".e_BASE."index.php"); header("location:".e_BASE."index.php");
exit; exit;
@@ -68,7 +68,7 @@ $pst->save_preset("admin_downloads"); // unique name for the preset
$sub_action = ''; $sub_action = '';
if (e_QUERY) if (e_QUERY)
{ {
$tmp = explode(".", e_QUERY); $tmp = explode(".", e_QUERY);
$action = $tmp[0]; $action = $tmp[0];
@@ -109,7 +109,7 @@ if($public_array = $fl->get_files(e_UPLOAD))
if ($sql->db_Select("rbinary")) if ($sql->db_Select("rbinary"))
{ {
while ($row = $sql->db_Fetch()) while ($row = $sql->db_Fetch())
{ {
extract($row); extract($row);
$file_array[] = "Binary ".$binary_id."/".$binary_name; $file_array[] = "Binary ".$binary_id."/".$binary_name;
@@ -135,13 +135,13 @@ if(isset($_POST))
$e107cache->clear("download_cat"); $e107cache->clear("download_cat");
} }
if (isset($_POST['add_category'])) if (isset($_POST['add_category']))
{ {
$download->create_category($sub_action, $id); $download->create_category($sub_action, $id);
} }
if (isset($_POST['submit_download'])) if (isset($_POST['submit_download']))
{ {
$download->submit_download($sub_action, $id); $download->submit_download($sub_action, $id);
$action = "main"; $action = "main";
@@ -281,15 +281,15 @@ if ($action == "dlm")
} }
if ($action == "create") if ($action == "create")
{ {
$download->create_download($sub_action, $id); $download->create_download($sub_action, $id);
} }
if ($delete == 'category') if ($delete == 'category')
{ {
if (admin_update($sql->db_Delete('download_category', 'download_category_id='.$del_id), 'delete', DOWLAN_49." #".$del_id." ".DOWLAN_36)) if (admin_update($sql->db_Delete('download_category', 'download_category_id='.$del_id), 'delete', DOWLAN_49." #".$del_id." ".DOWLAN_36))
{ {
$sql->db_Delete('download_category', 'download_category_parent='.$del_id); $sql->db_Delete('download_category', 'download_category_parent='.$del_id);
$admin_log->log_event('DOWNL_04',$del_id,E_LOG_INFORMATIVE,''); $admin_log->log_event('DOWNL_04',$del_id,E_LOG_INFORMATIVE,'');
@@ -297,13 +297,13 @@ if ($delete == 'category')
} }
if ($action == 'cat') if ($action == 'cat')
{ {
$download->show_categories($sub_action, $id); $download->show_categories($sub_action, $id);
} }
if ($delete == 'main') if ($delete == 'main')
{ {
$result = admin_update($sql->db_Delete('download', 'download_id='.$del_id), 'delete', DOWLAN_27." #".$del_id." ".DOWLAN_36); $result = admin_update($sql->db_Delete('download', 'download_id='.$del_id), 'delete', DOWLAN_27." #".$del_id." ".DOWLAN_36);
if($result) if($result)
@@ -316,14 +316,14 @@ if ($delete == 'main')
} }
if (isset($message)) if (isset($message))
{ {
$ns->tablerender("", "<div style='text-align:center'><b>".$message."</b></div>"); $ns->tablerender("", "<div style='text-align:center'><b>".$message."</b></div>");
} }
if (!e_QUERY || $action == "main") if (!e_QUERY || $action == "main")
{ {
$download->show_existing_items($action, $sub_action, $id, $from, $amount); $download->show_existing_items($action, $sub_action, $id, $from, $amount);
} }
@@ -331,7 +331,7 @@ if (!e_QUERY || $action == "main")
if ($action == "opt") if ($action == "opt")
{ {
global $pref, $ns; global $pref, $ns;
$agree_flag = $pref['agree_flag']; $agree_flag = $pref['agree_flag'];
@@ -545,7 +545,7 @@ exit;
class download class download
{ {
function show_existing_items($action, $sub_action, $id, $from, $amount) function show_existing_items($action, $sub_action, $id, $from, $amount)
{ {
global $sql, $rs, $ns, $tp, $mySQLdefaultdb, $pref; global $sql, $rs, $ns, $tp, $mySQLdefaultdb, $pref;
$text = "<div style='text-align:center'><div style='padding : 1px; ".ADMIN_WIDTH."; margin-left: auto; margin-right: auto;'>"; $text = "<div style='text-align:center'><div style='padding : 1px; ".ADMIN_WIDTH."; margin-left: auto; margin-right: auto;'>";
@@ -569,7 +569,7 @@ class download
$query = "SELECT d.*, dc.* FROM `#download` AS d LEFT JOIN `#download_category` AS dc ON dc. download_category_id = d.download_category"; $query = "SELECT d.*, dc.* FROM `#download` AS d LEFT JOIN `#download_category` AS dc ON dc. download_category_id = d.download_category";
if (isset($_POST['searchquery']) && $_POST['searchquery'] != "") if (isset($_POST['searchquery']) && $_POST['searchquery'] != "")
{ {
$query .= " WHERE download_url REGEXP('".$_POST['searchquery']."') OR download_author REGEXP('".$_POST['searchquery']."') OR download_description REGEXP('".$_POST['searchquery']."') "; $query .= " WHERE download_url REGEXP('".$_POST['searchquery']."') OR download_author REGEXP('".$_POST['searchquery']."') OR download_description REGEXP('".$_POST['searchquery']."') ";
foreach($search_display as $disp) foreach($search_display as $disp)
@@ -577,13 +577,13 @@ class download
$query .= " OR $disp REGEXP('".$_POST['searchquery']."') "; $query .= " OR $disp REGEXP('".$_POST['searchquery']."') ";
} }
$query .= " ORDER BY {$sortorder} {$sortdirection}"; $query .= " ORDER BY {$sortorder} {$sortdirection}";
} }
else else
{ {
$query .= " ORDER BY ".($sub_action ? $sub_action : $sortorder)." ".($id ? $id : $sortdirection)." LIMIT $from, $amount"; $query .= " ORDER BY ".($sub_action ? $sub_action : $sortorder)." ".($id ? $id : $sortdirection)." LIMIT $from, $amount";
} }
if ($dl_count = $sql->db_Select_gen($query)) if ($dl_count = $sql->db_Select_gen($query))
{ {
$text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform")." $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform")."
<table class='fborder' style='width:99%'> <table class='fborder' style='width:99%'>
@@ -608,11 +608,11 @@ class download
$text .="<td style='width:10%' class='fcaption'>".LAN_OPTIONS."</td></tr>"; $text .="<td style='width:10%' class='fcaption'>".LAN_OPTIONS."</td></tr>";
while ($row = $sql->db_Fetch()) while ($row = $sql->db_Fetch())
{ {
$text .= "<tr><td style='width:5%;vertical-align:top' class='forumheader3'>".$row['download_id']."</td>"; $text .= "<tr><td style='width:5%;vertical-align:top' class='forumheader3'>".$row['download_id']."</td>";
// Display Chosen options // Display Chosen options
foreach($search_display as $disp) foreach($search_display as $disp)
{ {
$text .= "<td class='forumheader3' style='vertical-align:top'>"; $text .= "<td class='forumheader3' style='vertical-align:top'>";
@@ -645,16 +645,16 @@ class download
break; break;
case "download_active" : case "download_active" :
if($row[$disp]== 1) if($row[$disp]== 1)
{ {
$text .= "<img src='".ADMIN_TRUE_ICON_PATH."' title='".DOWLAN_123."' alt='' style='cursor:help' />\n"; $text .= "<img src='".ADMIN_TRUE_ICON_PATH."' title='".DOWLAN_123."' alt='' style='cursor:help' />\n";
} }
elseif($row[$disp]== 2) elseif($row[$disp]== 2)
{ {
$text .= "<img src='".ADMIN_TRUE_ICON_PATH."' title='".DOWLAN_124."' alt='' style='cursor:help' /><img src='".ADMIN_TRUE_ICON_PATH."' title='".DOWLAN_124."' alt='' style='cursor:help' />\n"; $text .= "<img src='".ADMIN_TRUE_ICON_PATH."' title='".DOWLAN_124."' alt='' style='cursor:help' /><img src='".ADMIN_TRUE_ICON_PATH."' title='".DOWLAN_124."' alt='' style='cursor:help' />\n";
} }
else else
{ {
$text .= "<img src='".ADMIN_FALSE_ICON_PATH."' title='".DOWLAN_122."' alt='' style='cursor:help' />\n"; $text .= "<img src='".ADMIN_FALSE_ICON_PATH."' title='".DOWLAN_122."' alt='' style='cursor:help' />\n";
} }
break; break;
case "download_comment" : case "download_comment" :
@@ -675,8 +675,8 @@ class download
</tr>"; </tr>";
} }
$text .= "</table></form>"; $text .= "</table></form>";
} }
else else
{ // 'No downloads yet' { // 'No downloads yet'
$text .= "<div style='text-align:center'>".DOWLAN_6."</div>"; $text .= "<div style='text-align:center'>".DOWLAN_6."</div>";
} }
@@ -684,7 +684,7 @@ class download
// Next-Previous. // Next-Previous.
$downloads = $sql->db_Count("download"); $downloads = $sql->db_Count("download");
if ($downloads > $amount && !$_POST['searchquery']) if ($downloads > $amount && !$_POST['searchquery'])
{ {
$parms = "{$downloads},{$amount},{$from},".e_SELF."?".(e_QUERY ? "$action.$sub_action.$id." : "main.{$sortorder}.{$sortdirection}.")."[FROM]"; $parms = "{$downloads},{$amount},{$from},".e_SELF."?".(e_QUERY ? "$action.$sub_action.$id." : "main.{$sortorder}.{$sortdirection}.")."[FROM]";
$text .= "<br />".$tp->parseTemplate("{NEXTPREV={$parms}}"); $text .= "<br />".$tp->parseTemplate("{NEXTPREV={$parms}}");
@@ -795,10 +795,10 @@ class download
function create_download($sub_action, $id) function create_download($sub_action, $id)
{ {
global $cal,$tp, $sql, $fl, $rs, $ns, $file_array, $image_array, $thumb_array,$pst; global $cal,$tp, $sql, $fl, $rs, $ns, $file_array, $image_array, $thumb_array,$pst;
require_once(e_FILE."shortcode/batch/download_shortcodes.php"); require_once(e_CORE."shortcodes/batch/download_shortcodes.php");
$mirrorArray = array(); $mirrorArray = array();
@@ -808,15 +808,15 @@ class download
$preset = $pst->read_preset("admin_downloads"); // read preset values into array $preset = $pst->read_preset("admin_downloads"); // read preset values into array
extract($preset); extract($preset);
if (!$sql->db_Select("download_category")) if (!$sql->db_Select("download_category"))
{ {
$ns->tablerender(ADLAN_24, "<div style='text-align:center'>".DOWLAN_5."</div>"); $ns->tablerender(ADLAN_24, "<div style='text-align:center'>".DOWLAN_5."</div>");
return; return;
} }
$download_active = 1; $download_active = 1;
if ($sub_action == "edit" && !$_POST['submit']) if ($sub_action == "edit" && !$_POST['submit'])
{ {
if ($sql->db_Select("download", "*", "download_id=".$id)) if ($sql->db_Select("download", "*", "download_id=".$id))
{ {
$row = $sql->db_Fetch(); $row = $sql->db_Fetch();
extract($row); extract($row);
@@ -825,9 +825,9 @@ class download
} }
} }
if ($sub_action == "dlm" && !$_POST['submit']) if ($sub_action == "dlm" && !$_POST['submit'])
{ {
if ($sql->db_Select("upload", "*", "upload_id=".$id)) if ($sql->db_Select("upload", "*", "upload_id=".$id))
{ {
$row = $sql->db_Fetch(); $row = $sql->db_Fetch();
@@ -874,11 +874,11 @@ class download
"; ";
$counter = 0; $counter = 0;
while (isset($file_array[$counter])) while (isset($file_array[$counter]))
{ {
$fpath = str_replace(e_DOWNLOAD,"",$file_array[$counter]['path']).$file_array[$counter]['fname']; $fpath = str_replace(e_DOWNLOAD,"",$file_array[$counter]['path']).$file_array[$counter]['fname'];
$selected = ''; $selected = '';
if (stristr($fpath, $download_url) !== FALSE) if (stristr($fpath, $download_url) !== FALSE)
{ {
$selected = " selected='selected'"; $selected = " selected='selected'";
$found = 1; $found = 1;
@@ -889,7 +889,7 @@ class download
} }
$dt = 'display:none'; $dt = 'display:none';
if (preg_match("/http:|ftp:/", $download_url)) if (preg_match("/http:|ftp:/", $download_url))
{ {
$download_url_external = $download_url; $download_url_external = $download_url;
$download_url = ''; $download_url = '';
@@ -897,12 +897,12 @@ class download
} }
$etext = " - (".DOWLAN_68.")"; $etext = " - (".DOWLAN_68.")";
if (file_exists(e_UPLOAD.$download_url)) if (file_exists(e_UPLOAD.$download_url))
{ {
$etext = ""; $etext = "";
} }
if (!$found && $download_url) if (!$found && $download_url)
{ {
$text .= "<option value='".$download_url."' selected='selected'>".$download_url.$etext."</option>\n"; $text .= "<option value='".$download_url."' selected='selected'>".$download_url.$etext."</option>\n";
} }
@@ -947,7 +947,7 @@ class download
<select name='download_mirror_name[]' class='tbox'> <select name='download_mirror_name[]' class='tbox'>
<option value=''>&nbsp;</option>"; <option value=''>&nbsp;</option>";
foreach ($mirrorList as $mirror) foreach ($mirrorList as $mirror)
{ {
extract($mirror); extract($mirror);
$text .= "<option value='{$mirror_id}'".($mirror_id == $mirrorArray[($count-1)]['id'] ? " selected='selected'" : "").">{$mirror_name}</option>\n"; $text .= "<option value='{$mirror_id}'".($mirror_id == $mirrorArray[($count-1)]['id'] ? " selected='selected'" : "").">{$mirror_name}</option>\n";
@@ -1199,7 +1199,7 @@ class download
// Actually save a new or edited download to the DB // Actually save a new or edited download to the DB
function submit_download($sub_action, $id) function submit_download($sub_action, $id)
{ {
global $tp, $sql, $DOWNLOADS_DIRECTORY, $e_event; global $tp, $sql, $DOWNLOADS_DIRECTORY, $e_event;
@@ -1300,7 +1300,7 @@ class download
$dlInfo['download_comment'] = $tp->toDB($_POST['download_comment']); $dlInfo['download_comment'] = $tp->toDB($_POST['download_comment']);
$dlInfo['download_class'] = intval($_POST['download_class']); $dlInfo['download_class'] = intval($_POST['download_class']);
$dlInfo['download_visible'] =intval($_POST['download_visible']); $dlInfo['download_visible'] =intval($_POST['download_visible']);
if (preg_match("#(.*?)/(.*?)/(.*?) (.*?):(.*?):(.*?)$#", $_POST['download_datestamp'], $matches)) if (preg_match("#(.*?)/(.*?)/(.*?) (.*?):(.*?):(.*?)$#", $_POST['download_datestamp'], $matches))
{ {
$dlInfo['download_datestamp'] = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); $dlInfo['download_datestamp'] = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]);
@@ -1311,8 +1311,8 @@ class download
} }
if($_POST['update_datestamp']) if($_POST['update_datestamp'])
{ {
$dlInfo['download_datestamp'] = time(); $dlInfo['download_datestamp'] = time();
} }
$mirrorStr = ""; $mirrorStr = "";
@@ -1375,10 +1375,10 @@ class download
$dlInfo['download_datestamp'] = $time; // This is what 0.7 did, regardless of settings $dlInfo['download_datestamp'] = $time; // This is what 0.7 did, regardless of settings
unset($dlInfo['download_class']); // Also replicating 0.7 unset($dlInfo['download_class']); // Also replicating 0.7
$e_event->trigger('dlupdate', $dlInfo); $e_event->trigger('dlupdate', $dlInfo);
} }
else else
{ {
if (admin_update($download_id = $sql->db_Insert('download',array_merge($dlInfo,$dlMirrors)), 'insert', DOWLAN_1." (<a href='".e_BASE."download.php?view.".$download_id."'>".$_POST['download_name']."</a>)")) if (admin_update($download_id = $sql->db_Insert('download',array_merge($dlInfo,$dlMirrors)), 'insert', DOWLAN_1." (<a href='".e_BASE."download.php?view.".$download_id."'>".$_POST['download_name']."</a>)"))
{ {
$dlInfo['download_id'] = $download_id; $dlInfo['download_id'] = $download_id;
$this->downloadLog('DOWNL_05',$dlInfo,$dlMirrors); $this->downloadLog('DOWNL_05',$dlInfo,$dlMirrors);
@@ -1386,7 +1386,7 @@ class download
unset($dlInfo['download_class']); // Also replicating 0.7 unset($dlInfo['download_class']); // Also replicating 0.7
$e_event->trigger("dlpost", $dlInfo); $e_event->trigger("dlpost", $dlInfo);
if ($_POST['remove_upload']) if ($_POST['remove_upload'])
{ {
$sql->db_Update("upload", "upload_active='1' WHERE upload_id='".$_POST['remove_id']."'"); $sql->db_Update("upload", "upload_active='1' WHERE upload_id='".$_POST['remove_id']."'");
$mes = "<br />".$_POST['download_name']." ".DOWLAN_104; $mes = "<br />".$_POST['download_name']." ".DOWLAN_104;
@@ -1699,17 +1699,17 @@ class download
$download_category_icon .= trim(chr(1).$tp->toDB($_POST['download_category_icon_empty'])); $download_category_icon .= trim(chr(1).$tp->toDB($_POST['download_category_icon_empty']));
} }
if ($id) if ($id)
{ {
admin_update($sql->db_Update("download_category", "download_category_name='{$download_category_name}', download_category_description='{$download_category_description}', download_category_icon ='{$download_category_icon}', download_category_parent= '{$download_categoory_parent}', download_category_class='{$download_category_class}' WHERE download_category_id='{$id}'"), 'update', DOWLAN_48); admin_update($sql->db_Update("download_category", "download_category_name='{$download_category_name}', download_category_description='{$download_category_description}', download_category_icon ='{$download_category_icon}', download_category_parent= '{$download_categoory_parent}', download_category_class='{$download_category_class}' WHERE download_category_id='{$id}'"), 'update', DOWLAN_48);
$admin_log->log_event('DOWNL_03',$download_category_name.'[!br!]'.$download_category_description,E_LOG_INFORMATIVE,''); $admin_log->log_event('DOWNL_03',$download_category_name.'[!br!]'.$download_category_description,E_LOG_INFORMATIVE,'');
} }
else else
{ {
admin_update($sql->db_Insert("download_category", "0, '{$download_category_name}', '{$download_category_description}', '{$download_category_icon}', '{$download_categoory_parent}', '{$download_category_class}', 0 "), 'insert', DOWLAN_47); admin_update($sql->db_Insert("download_category", "0, '{$download_category_name}', '{$download_category_description}', '{$download_category_icon}', '{$download_categoory_parent}', '{$download_category_class}', 0 "), 'insert', DOWLAN_47);
$admin_log->log_event('DOWNL_02',$download_category_name.'[!br!]'.$download_category_description,E_LOG_INFORMATIVE,''); $admin_log->log_event('DOWNL_02',$download_category_name.'[!br!]'.$download_category_description,E_LOG_INFORMATIVE,'');
} }
if ($sub_action == "sn") if ($sub_action == "sn")
{ {
$sql->db_Delete("tmp", "tmp_time='{$id}' "); $sql->db_Delete("tmp", "tmp_time='{$id}' ");
} }
@@ -1874,8 +1874,8 @@ class download
{ {
admin_update($sql -> db_Update("download_mirror", "mirror_name='{$name}', mirror_url='{$url}', mirror_image='".$tp->toDB($_POST['mirror_image'])."', mirror_location='{$location}', mirror_description='{$description}' WHERE mirror_id=".intval($_POST['id'])), 'update', DOWLAN_133); admin_update($sql -> db_Update("download_mirror", "mirror_name='{$name}', mirror_url='{$url}', mirror_image='".$tp->toDB($_POST['mirror_image'])."', mirror_location='{$location}', mirror_description='{$description}' WHERE mirror_id=".intval($_POST['id'])), 'update', DOWLAN_133);
$admin_log->log_event('DOWNL_13','ID: '.intval($_POST['id']).'[!br!]'.$logString,E_LOG_INFORMATIVE,''); $admin_log->log_event('DOWNL_13','ID: '.intval($_POST['id']).'[!br!]'.$logString,E_LOG_INFORMATIVE,'');
} }
else else
{ {
admin_update($sql -> db_Insert("download_mirror", "0, '{$name}', '{$url}', '".$tp->toDB($_POST['mirror_image'])."', '{$location}', '{$description}', 0"), 'insert', DOWLAN_134); admin_update($sql -> db_Insert("download_mirror", "0, '{$name}', '{$url}', '".$tp->toDB($_POST['mirror_image'])."', '{$location}', '{$description}', 0"), 'insert', DOWLAN_134);
$admin_log->log_event('DOWNL_12',$logString,E_LOG_INFORMATIVE,''); $admin_log->log_event('DOWNL_12',$logString,E_LOG_INFORMATIVE,'');
@@ -1925,7 +1925,7 @@ class download
} // end class. } // end class.
function download_adminmenu($parms) function download_adminmenu($parms)
{ {
global $download; global $download;
global $action; global $action;

View File

@@ -34,7 +34,7 @@ if (isset($_POST['submit-mye107']) || varset($_POST['submit-mymenus']))
} }
//TODO LANs throughout. //TODO LANs throughout.
// ---------------------- Start Panel -------------------------------- // ---------------------- Start Panel --------------------------------
@@ -43,7 +43,7 @@ if (isset($_POST['submit-mye107']) || varset($_POST['submit-mymenus']))
{ {
$user_pref['core-infopanel-mye107'] = $pref['core-infopanel-default']; $user_pref['core-infopanel-mye107'] = $pref['core-infopanel-default'];
} }
$iconlist = array_merge($array_functions_assoc, getPluginLinks(E_16_PLUGMANAGER, "array")); $iconlist = array_merge($array_functions_assoc, getPluginLinks(E_16_PLUGMANAGER, "array"));
$text .= " $text .= "
@@ -68,13 +68,13 @@ if (isset($_POST['submit-mye107']) || varset($_POST['submit-mymenus']))
$text .= render_links($val['link'], $val['title'], $val['caption'], $val['perms'], $val['icon_32'], "div"); $text .= render_links($val['link'], $val['title'], $val['caption'], $val['perms'], $val['icon_32'], "div");
} }
} }
$text .= "<div class='clear'>&nbsp;</div> $text .= "<div class='clear'>&nbsp;</div>
</div> </div>
</div> </div>
</div>"; </div>";
// ------------------------------- e107 News -------------------------------- // ------------------------------- e107 News --------------------------------
$text .= " $text .= "
<div id='core-infopanel_news' class='f-left' style='width:49%'> <div id='core-infopanel_news' class='f-left' style='width:49%'>
@@ -82,21 +82,21 @@ if (isset($_POST['submit-mye107']) || varset($_POST['submit-mymenus']))
<div class='main_caption bevel left'><b>e107 News</b></div> <div class='main_caption bevel left'><b>e107 News</b></div>
<div class='left block-text'>"; <div class='left block-text'>";
// TODO Load with Ajax // TODO Load with Ajax
/* /*
$xml = e107::getXml(); $xml = e107::getXml();
$vars = $xml->loadXMLfile('http://www.e107.org/e107_plugins/rss_menu/rss.php?1.2', true, true); $vars = $xml->loadXMLfile('http://www.e107.org/e107_plugins/rss_menu/rss.php?1.2', true, true);
$text .= print_r($vars,TRUE); $text .= print_r($vars,TRUE);
*/ */
$text .= " $text .= "
RSS News feed from e107.org goes here. RSS News feed from e107.org goes here.
</div> </div>
</div> </div>
</div> </div>
"; ";
// ---------------------Latest Stuff --------------------------- // ---------------------Latest Stuff ---------------------------
$text .= " $text .= "
<div id='core-infopanel_latest' class='f-left' style='width:49%' > <div id='core-infopanel_latest' class='f-left' style='width:49%' >
@@ -104,7 +104,7 @@ $text .= "
<table cellspacing='0' cellpadding='0'> <table cellspacing='0' cellpadding='0'>
<tr> <tr>
<td style='padding:0px'>"; <td style='padding:0px'>";
require_once (e_FILE."shortcode/batch/admin_shortcodes.php"); require_once (e_CORE."shortcodes/batch/admin_shortcodes.php");
$text .= $tp->parseTemplate("{ADMIN_LATEST}"); $text .= $tp->parseTemplate("{ADMIN_LATEST}");
$text .= "</td><td style='padding:0px'>"; $text .= "</td><td style='padding:0px'>";
$text .= $tp->parseTemplate("{ADMIN_STATUS}"); $text .= $tp->parseTemplate("{ADMIN_STATUS}");
@@ -112,15 +112,15 @@ $text .= "
</div> </div>
</div> </div>
"; ";
// ---------------------- Who's Online ------------------------ // ---------------------- Who's Online ------------------------
// TODO Could use a new _menu item instead. // TODO Could use a new _menu item instead.
$text .= " $text .= "
<div id='core-infopanel_online' class='f-left' style='width:49%'> <div id='core-infopanel_online' class='f-left' style='width:49%'>
<div style='border:1px solid silver;margin:10px'> <div style='border:1px solid silver;margin:10px'>
<div class='main_caption bevel left'><b>Who's Online</b></div> <div class='main_caption bevel left'><b>Who's Online</b></div>
<div class='left block-text'> <div class='left block-text'>
<table cellpadding='0' cellspacing='0' class='adminlist'> <table cellpadding='0' cellspacing='0' class='adminlist'>
<colgroup span='3'> <colgroup span='3'>
@@ -153,7 +153,7 @@ $text .= "
"; ";
} }
} }
$text .= "</tbody></table></div> $text .= "</tbody></table></div>
</div> </div>
</div> </div>
@@ -201,7 +201,7 @@ function renderOnlineName($val)
{ {
return "Guest"; return "Guest";
} }
return $val; return $val;
} }
function render_info_panel($caption, $text) function render_info_panel($caption, $text)
@@ -237,7 +237,7 @@ function render_infopanel_icons()
$frm = e107::getSingleton('e_form'); $frm = e107::getSingleton('e_form');
global $iconlist,$pluglist, $user_pref; global $iconlist,$pluglist, $user_pref;
$text = ""; $text = "";
foreach ($iconlist as $key=>$icon) foreach ($iconlist as $key=>$icon)
{ {
@@ -271,7 +271,7 @@ function render_infopanel_menu_options()
$text = ""; $text = "";
$menu_qry = 'SELECT * FROM #menus WHERE menu_id!= 0 GROUP BY menu_name ORDER BY menu_name'; $menu_qry = 'SELECT * FROM #menus WHERE menu_id!= 0 GROUP BY menu_name ORDER BY menu_name';
$settings = varset($user_pref['core-infopanel-menus'],array()); $settings = varset($user_pref['core-infopanel-menus'],array());
if (e107::getDb()->db_Select_gen($menu_qry)) if (e107::getDb()->db_Select_gen($menu_qry))
{ {
while ($row = e107::getDb()->db_Fetch()) while ($row = e107::getDb()->db_Fetch())

View File

@@ -30,8 +30,8 @@ $codes = array(
'admin_status', 'admin_status',
'admin_update', 'admin_update',
'admin_userlan', 'admin_userlan',
'admin_menumanager', 'admin_menumanager',
); );
register_shortcode('admin_shortcodes', $codes, e_FILE.'shortcode/batch/admin_shortcodes_class.php'); register_shortcode('admin_shortcodes', $codes, e_CORE.'shortcodes/batch/admin_shortcodes_class.php');
?> ?>

View File

@@ -22,7 +22,7 @@ if (!defined('e107_INIT'))
} }
include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_comment.php"); include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_comment.php");
global $comment_shortcodes; global $comment_shortcodes;
require_once (e_FILE."shortcode/batch/comment_shortcodes.php"); require_once (e_CORE."shortcodes/batch/comment_shortcodes.php");
/** /**
* Enter description here... * Enter description here...
* *
@@ -40,7 +40,7 @@ class comment
5 => 'docs', 5 => 'docs',
6 => 'bugtrack' 6 => 'bugtrack'
); );
/** /**
* Display the comment editing form * Display the comment editing form
* *
@@ -349,13 +349,13 @@ class comment
{ {
//rateindex : the posted value from the rateselect box (without the urljump) (see function rateselect()) //rateindex : the posted value from the rateselect box (without the urljump) (see function rateselect())
global $e_event,$e107,$pref,$rater; global $e_event,$e107,$pref,$rater;
$sql = e107::getDb(); $sql = e107::getDb();
$sql2 = e107::getDb('sql2'); $sql2 = e107::getDb('sql2');
$tp = e107::getParser(); $tp = e107::getParser();
$e107cache = e107::getCache(); $e107cache = e107::getCache();
if (isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE) if (isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE)
{ {
return; return;
@@ -428,54 +428,54 @@ class comment
$e107cache->clear("comment"); $e107cache->clear("comment");
return; return;
} }
//FIXME - don't sanitize, pass raw data to e_event, use DB array (inner db sanitize) //FIXME - don't sanitize, pass raw data to e_event, use DB array (inner db sanitize)
$edata_li = array( $edata_li = array(
// comment_id - auto-assigned // comment_id - auto-assigned
'comment_pid' => intval($pid), 'comment_pid' => intval($pid),
'comment_item_id' => $id, 'comment_item_id' => $id,
'comment_subject' => $subject, 'comment_subject' => $subject,
'comment_author_id' => $cuser_id, 'comment_author_id' => $cuser_id,
'comment_author_name' => $cuser_name, 'comment_author_name' => $cuser_name,
'comment_author_email' => $tp->toDB($cuser_mail), 'comment_author_email' => $tp->toDB($cuser_mail),
'comment_datestamp' => $_t, 'comment_datestamp' => $_t,
'comment_comment' => $comment, 'comment_comment' => $comment,
'comment_blocked' => 0, //Not blocked by default 'comment_blocked' => 0, //Not blocked by default
'comment_ip' => $ip, 'comment_ip' => $ip,
'comment_type' => $tp->toDB($type, true), 'comment_type' => $tp->toDB($type, true),
'comment_lock' => 0 //Not locked by default 'comment_lock' => 0 //Not locked by default
); );
//SecretR: new event 'prepostcomment' - allow plugin hooks - e.g. Spam Check //SecretR: new event 'prepostcomment' - allow plugin hooks - e.g. Spam Check
$edata_li_hook = array_merge($edata_li, array('comment_nick' => $cuser_id.'.'.$cuser_name, 'comment_time' => $_t)); $edata_li_hook = array_merge($edata_li, array('comment_nick' => $cuser_id.'.'.$cuser_name, 'comment_time' => $_t));
if($e_event->trigger("prepostcomment", $edata_li_hook)) if($e_event->trigger("prepostcomment", $edata_li_hook))
{ {
return false; //3rd party code interception return false; //3rd party code interception
} }
//allow 3rd party code to modify insert data //allow 3rd party code to modify insert data
if(is_array($edata_li_hook)) if(is_array($edata_li_hook))
{ {
foreach (array_keys($edata_li) as $k) foreach (array_keys($edata_li) as $k)
{ {
if(isset($edata_li_hook[$k])) if(isset($edata_li_hook[$k]))
{ {
$edata_li[$k] = $edata_li_hook[$k]; //sanitize? $edata_li[$k] = $edata_li_hook[$k]; //sanitize?
continue; continue;
} }
if($k === 'break') if($k === 'break')
{ {
$break = $edata_li_hook[$k]; $break = $edata_li_hook[$k];
} }
} }
} }
unset($edata_li_hook); unset($edata_li_hook);
if (!($inserted_id = $sql->db_Insert("comments", $edata_li))) if (!($inserted_id = $sql->db_Insert("comments", $edata_li)))
{ {
//echo "<b>".COMLAN_323."</b> ".COMLAN_11; //echo "<b>".COMLAN_323."</b> ".COMLAN_11;
e107::getMessage()->addStack(COMLAN_11, 'postcomment', E_MESSAGE_ERROR); e107::getMessage()->addStack(COMLAN_11, 'postcomment', E_MESSAGE_ERROR);
} }
else else
{ {
@@ -487,21 +487,21 @@ class comment
$edata_li["comment_nick"] = $cuser_id.'.'.$cuser_name; $edata_li["comment_nick"] = $cuser_id.'.'.$cuser_name;
$edata_li["comment_time"] = $_t; $edata_li["comment_time"] = $_t;
$edata_li["comment_id"] = $inserted_id; $edata_li["comment_id"] = $inserted_id;
//Why? //Why?
/*unset($edata_li['comment_pid']); /*unset($edata_li['comment_pid']);
unset($edata_li['comment_author_email']); unset($edata_li['comment_author_email']);
unset($edata_li['comment_ip']);*/ unset($edata_li['comment_ip']);*/
$e_event->trigger("postcomment", $edata_li); $e_event->trigger("postcomment", $edata_li);
$e107cache->clear("comment"); $e107cache->clear("comment");
//TODO - should be handled by news //TODO - should be handled by news
if (!$type || $type == "news") if (!$type || $type == "news")
{ {
$sql->db_Update("news", "news_comment_total=news_comment_total+1 WHERE news_id=".intval($id)); $sql->db_Update("news", "news_comment_total=news_comment_total+1 WHERE news_id=".intval($id));
} }
//if rateindex is posted, enter the rating from this user //if rateindex is posted, enter the rating from this user
if ($rateindex) if ($rateindex)
{ {
@@ -535,7 +535,7 @@ class comment
{ {
return $table; return $table;
} }
switch ($table) switch ($table)
{ {
case "news": case "news":
@@ -569,7 +569,7 @@ class comment
} }
return $type; return $type;
} }
/** /**
* Convert type number to (core) table string * Convert type number to (core) table string
* @param integer|string $type * @param integer|string $type
@@ -589,7 +589,7 @@ class comment
} }
} }
} }
/** /**
* Enter description here... * Enter description here...
* *
@@ -631,17 +631,17 @@ class comment
// Query no longer used // Query no longer used
// $count_comments = $this -> count_comments($table, $id, $pid=FALSE); // $count_comments = $this -> count_comments($table, $id, $pid=FALSE);
$type = $this->getCommentType($table); $type = $this->getCommentType($table);
$query = $pref['nested_comments'] ? $query = $pref['nested_comments'] ?
"SELECT c.*, u.*, ue.* FROM #comments AS c "SELECT c.*, u.*, ue.* FROM #comments AS c
LEFT JOIN #user AS u ON c.comment_author_id = u.user_id LEFT JOIN #user AS u ON c.comment_author_id = u.user_id
LEFT JOIN #user_extended AS ue ON c.comment_author_id = ue.user_extended_id LEFT JOIN #user_extended AS ue ON c.comment_author_id = ue.user_extended_id
WHERE c.comment_item_id='".intval($id)."' AND c.comment_type='".$tp->toDB($type, true)."' AND c.comment_pid='0' ORDER BY c.comment_datestamp" WHERE c.comment_item_id='".intval($id)."' AND c.comment_type='".$tp->toDB($type, true)."' AND c.comment_pid='0' ORDER BY c.comment_datestamp"
: :
"SELECT c.*, u.*, ue.* FROM #comments AS c "SELECT c.*, u.*, ue.* FROM #comments AS c
LEFT JOIN #user AS u ON c.comment_author_id = u.user_id LEFT JOIN #user AS u ON c.comment_author_id = u.user_id
LEFT JOIN #user_extended AS ue ON c.comment_author_id = ue.user_extended_id LEFT JOIN #user_extended AS ue ON c.comment_author_id = ue.user_extended_id
WHERE c.comment_item_id='".intval($id)."' AND c.comment_type='".$tp->toDB($type, true)."' ORDER BY c.comment_datestamp"; WHERE c.comment_item_id='".intval($id)."' AND c.comment_type='".$tp->toDB($type, true)."' ORDER BY c.comment_datestamp";
$text = ""; $text = "";
$comment = ''; $comment = '';
$modcomment = ''; $modcomment = '';
@@ -649,10 +649,10 @@ class comment
$ret['comment'] = ''; $ret['comment'] = '';
if ($comment_total = $sql->db_Select_gen($query)) if ($comment_total = $sql->db_Select_gen($query))
{ {
$width = 0; $width = 0;
//Shortcodes could use $sql, so just grab all results //Shortcodes could use $sql, so just grab all results
$rows = $sql->db_getList(); $rows = $sql->db_getList();
//while ($row = $sql->db_Fetch()) //while ($row = $sql->db_Fetch())
foreach ($rows as $row) foreach ($rows as $row)
{ {
@@ -732,9 +732,9 @@ class comment
global $sql; global $sql;
$authors = array(); $authors = array();
$qry = " $qry = "
SELECT DISTINCT(comment_author_id) AS author SELECT DISTINCT(comment_author_id) AS author
FROM #comments FROM #comments
WHERE comment_item_id='{$id}' AND comment_type='{$comment_type}' WHERE comment_item_id='{$id}' AND comment_type='{$comment_type}'
GROUP BY author GROUP BY author
"; ";
if ($sql->db_Select_gen($qry)) if ($sql->db_Select_gen($qry))
@@ -775,9 +775,9 @@ class comment
{ {
return $data; return $data;
} }
$files = e107::getPref('e_comment_list'); $files = e107::getPref('e_comment_list');
foreach ($files as $file=>$perms) foreach ($files as $file=>$perms)
{ {
unset($e_comment, $key); unset($e_comment, $key);

View File

@@ -17,7 +17,7 @@
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
class news { class news {
protected static $_rewrite_data = array(); protected static $_rewrite_data = array();
protected static $_rewrite_map = null; protected static $_rewrite_map = null;
@@ -26,80 +26,80 @@ class news {
function submit_item($news, $smessages = false) function submit_item($news, $smessages = false)
{ {
global $e107cache, $e_event, $pref, $admin_log; global $e107cache, $e_event, $pref, $admin_log;
$tp = e107::getParser(); $tp = e107::getParser();
$sql = e107::getDb(); $sql = e107::getDb();
require_once (e_HANDLER."message_handler.php"); require_once (e_HANDLER."message_handler.php");
$emessage = eMessage::getInstance(); $emessage = eMessage::getInstance();
$error = false; $error = false;
if(empty($news['news_title'])) if(empty($news['news_title']))
{ {
$error = true; $error = true;
$emessage->add('Validation error: News title can\'t be empty!', E_MESSAGE_ERROR, $smessages); $emessage->add('Validation error: News title can\'t be empty!', E_MESSAGE_ERROR, $smessages);
} }
if(empty($news['news_category'])) if(empty($news['news_category']))
{ {
$error = true; $error = true;
$emessage->add('Validation error: News category can\'t be empty!', E_MESSAGE_ERROR, $smessages); $emessage->add('Validation error: News category can\'t be empty!', E_MESSAGE_ERROR, $smessages);
} }
$data = array(); $data = array();
//DB Array //DB Array
$data['data']['news_title'] = $news['news_title']; $data['data']['news_title'] = $news['news_title'];
$data['_FIELD_TYPES']['news_title'] = 'todb'; $data['_FIELD_TYPES']['news_title'] = 'todb';
$data['data']['news_body'] = $news['news_body']; $data['data']['news_body'] = $news['news_body'];
$data['_FIELD_TYPES']['news_body'] = 'todb'; $data['_FIELD_TYPES']['news_body'] = 'todb';
$data['data']['news_extended'] = $news['news_extended']; $data['data']['news_extended'] = $news['news_extended'];
$data['_FIELD_TYPES']['news_extended'] = 'todb'; $data['_FIELD_TYPES']['news_extended'] = 'todb';
$data['data']['news_datestamp'] = $news['news_datestamp']; $data['data']['news_datestamp'] = $news['news_datestamp'];
$data['_FIELD_TYPES']['news_datestamp'] = 'int'; $data['_FIELD_TYPES']['news_datestamp'] = 'int';
$data['data']['news_author'] = $news['news_author'] ? $news['news_author'] : USERID; $data['data']['news_author'] = $news['news_author'] ? $news['news_author'] : USERID;
$data['_FIELD_TYPES']['news_author'] = 'int'; $data['_FIELD_TYPES']['news_author'] = 'int';
$data['data']['news_category'] = $news['news_category']; $data['data']['news_category'] = $news['news_category'];
$data['_FIELD_TYPES']['news_category'] = 'int'; $data['_FIELD_TYPES']['news_category'] = 'int';
$data['data']['news_allow_comments'] = $news['news_allow_comments']; $data['data']['news_allow_comments'] = $news['news_allow_comments'];
$data['_FIELD_TYPES']['news_allow_comments'] = 'int'; $data['_FIELD_TYPES']['news_allow_comments'] = 'int';
$data['data']['news_start'] = $news['news_start']; $data['data']['news_start'] = $news['news_start'];
$data['_FIELD_TYPES']['news_start'] = 'int'; $data['_FIELD_TYPES']['news_start'] = 'int';
$data['data']['news_end'] = $news['news_end']; $data['data']['news_end'] = $news['news_end'];
$data['_FIELD_TYPES']['news_end'] = 'int'; $data['_FIELD_TYPES']['news_end'] = 'int';
$data['data']['news_class'] = $news['news_class']; $data['data']['news_class'] = $news['news_class'];
$data['_FIELD_TYPES']['news_class'] = 'todb'; $data['_FIELD_TYPES']['news_class'] = 'todb';
$data['data']['news_render_type'] = $news['news_render_type']; $data['data']['news_render_type'] = $news['news_render_type'];
$data['_FIELD_TYPES']['news_render_type'] = 'int'; $data['_FIELD_TYPES']['news_render_type'] = 'int';
//news_comment_total //news_comment_total
$data['data']['news_summary'] = $news['news_summary']; $data['data']['news_summary'] = $news['news_summary'];
$data['_FIELD_TYPES']['news_summary'] = 'todb'; $data['_FIELD_TYPES']['news_summary'] = 'todb';
$data['data']['news_thumbnail'] = $news['news_thumbnail']; $data['data']['news_thumbnail'] = $news['news_thumbnail'];
$data['_FIELD_TYPES']['news_thumbnail'] = 'todb'; $data['_FIELD_TYPES']['news_thumbnail'] = 'todb';
$data['data']['news_sticky'] = $news['news_sticky']; $data['data']['news_sticky'] = $news['news_sticky'];
$data['_FIELD_TYPES']['news_sticky'] = 'int'; $data['_FIELD_TYPES']['news_sticky'] = 'int';
$data['data']['news_meta_keywords'] = $news['news_meta_keywords']; $data['data']['news_meta_keywords'] = $news['news_meta_keywords'];
$data['_FIELD_TYPES']['news_meta_keywords'] = 'todb'; $data['_FIELD_TYPES']['news_meta_keywords'] = 'todb';
$data['data']['news_meta_description'] = strip_tags($tp->toHTML($news['news_meta_description'], true)); //handle bbcodes $data['data']['news_meta_description'] = strip_tags($tp->toHTML($news['news_meta_description'], true)); //handle bbcodes
$data['_FIELD_TYPES']['news_meta_description'] = 'todb'; $data['_FIELD_TYPES']['news_meta_description'] = 'todb';
$datarw = array(); $datarw = array();
$datarw['data']['news_rewrite_id'] = $news['news_rewrite_id']; $datarw['data']['news_rewrite_id'] = $news['news_rewrite_id'];
$datarw['_FIELD_TYPES']['news_rewrite_id'] = 'int'; $datarw['_FIELD_TYPES']['news_rewrite_id'] = 'int';
@@ -107,7 +107,7 @@ class news {
$datarw['_FIELD_TYPES']['news_rewrite_string'] = 'todb'; $datarw['_FIELD_TYPES']['news_rewrite_string'] = 'todb';
$datarw['data']['news_rewrite_type'] = 1; $datarw['data']['news_rewrite_type'] = 1;
$datarw['_FIELD_TYPES']['news_rewrite_type'] = 'int'; $datarw['_FIELD_TYPES']['news_rewrite_type'] = 'int';
if($error) if($error)
{ {
$data['error'] = true; $data['error'] = true;
@@ -121,10 +121,10 @@ class news {
//XXX - Now hooks are executed only if no mysql error is found. Should it stay so? Seems sensible to me! //XXX - Now hooks are executed only if no mysql error is found. Should it stay so? Seems sensible to me!
if ($news['news_id']) if ($news['news_id'])
{ {
// Updating existing item // Updating existing item
$data['WHERE'] = 'news_id='.intval($news['news_id']); $data['WHERE'] = 'news_id='.intval($news['news_id']);
//$vals = "news_datestamp = '".intval($news['news_datestamp'])."', ".$author_insert." news_title='".$news['news_title']."', news_body='".$news['news_body']."', news_extended='".$news['news_extended']."', news_category='".intval($news['cat_id'])."', news_allow_comments='".intval($news['news_allow_comments'])."', news_start='".intval($news['news_start'])."', news_end='".intval($news['news_end'])."', news_class='".$tp->toDB($news['news_class'])."', news_render_type='".intval($news['news_rendertype'])."' , news_summary='".$news['news_summary']."', news_thumbnail='".$tp->toDB($news['news_thumbnail'])."', news_sticky='".intval($news['news_sticky'])."' WHERE news_id='".intval($news['news_id'])."' "; //$vals = "news_datestamp = '".intval($news['news_datestamp'])."', ".$author_insert." news_title='".$news['news_title']."', news_body='".$news['news_body']."', news_extended='".$news['news_extended']."', news_category='".intval($news['cat_id'])."', news_allow_comments='".intval($news['news_allow_comments'])."', news_start='".intval($news['news_start'])."', news_end='".intval($news['news_end'])."', news_class='".$tp->toDB($news['news_class'])."', news_render_type='".intval($news['news_rendertype'])."' , news_summary='".$news['news_summary']."', news_thumbnail='".$tp->toDB($news['news_thumbnail'])."', news_sticky='".intval($news['news_sticky'])."' WHERE news_id='".intval($news['news_id'])."' ";
if ($sql->db_Update('news', $data)) if ($sql->db_Update('news', $data))
{ {
@@ -136,14 +136,14 @@ class news {
{ {
$error = true; $error = true;
} }
e107::getEvent()->trigger('newsupd', $data['data']); e107::getEvent()->trigger('newsupd', $data['data']);
$message = LAN_NEWS_21; $message = LAN_NEWS_21;
$emessage->add(LAN_NEWS_21, E_MESSAGE_SUCCESS, $smessages); $emessage->add(LAN_NEWS_21, E_MESSAGE_SUCCESS, $smessages);
e107::getCache()->clear('news.php'); e107::getCache()->clear('news.php');
//FIXME - triggerHook should return array(message, message_type) //FIXME - triggerHook should return array(message, message_type)
$evdata = array('method'=>'update', 'table'=>'news', 'id'=>$news['news_id'], 'plugin'=>'news', 'function'=>'submit_item'); $evdata = array('method'=>'update', 'table'=>'news', 'id'=>$news['news_id'], 'plugin'=>'news', 'function'=>'submit_item');
$emessage->add(e107::getEvent()->triggerHook($evdata), E_MESSAGE_INFO, $smessages); $emessage->add(e107::getEvent()->triggerHook($evdata), E_MESSAGE_INFO, $smessages);
@@ -174,7 +174,7 @@ class news {
$emessage->add(LAN_NEWS_46, E_MESSAGE_INFO, $smessages); $emessage->add(LAN_NEWS_46, E_MESSAGE_INFO, $smessages);
$message = "<strong>".LAN_NEWS_46."</strong>"; $message = "<strong>".LAN_NEWS_46."</strong>";
} }
//FIXME - triggerHook should return array(message, message_type) //FIXME - triggerHook should return array(message, message_type)
$evdata = array('method'=>'update', 'table'=>'news', 'id'=>$news['news_id'], 'plugin'=>'news', 'function'=>'submit_item'); $evdata = array('method'=>'update', 'table'=>'news', 'id'=>$news['news_id'], 'plugin'=>'news', 'function'=>'submit_item');
$emessage->add(e107::getEvent()->triggerHook($evdata), E_MESSAGE_INFO, $smessages); $emessage->add(e107::getEvent()->triggerHook($evdata), E_MESSAGE_INFO, $smessages);
@@ -183,7 +183,7 @@ class news {
} }
} }
else else
{ {
// Adding item // Adding item
$data['data']['news_id'] = $sql->db_Insert('news', $data); $data['data']['news_id'] = $sql->db_Insert('news', $data);
$news['news_id'] = $data['data']['news_id']; $news['news_id'] = $data['data']['news_id'];
@@ -194,18 +194,18 @@ class news {
$message = LAN_NEWS_6; $message = LAN_NEWS_6;
$emessage->add(LAN_NEWS_6, E_MESSAGE_SUCCESS, $smessages); $emessage->add(LAN_NEWS_6, E_MESSAGE_SUCCESS, $smessages);
e107::getCache()->clear('news.php'); e107::getCache()->clear('news.php');
//moved down - prevent wrong mysql_insert_id //moved down - prevent wrong mysql_insert_id
e107::getAdminLog()->logArrayAll('NEWS_08', $logData); e107::getAdminLog()->logArrayAll('NEWS_08', $logData);
//manage rewrites //manage rewrites
if('error' === $this->handleRewriteSubmit('insert', $data['data'], $datarw, $smessages)) if('error' === $this->handleRewriteSubmit('insert', $data['data'], $datarw, $smessages))
{ {
$error = true; $error = true;
} }
e107::getEvent()->trigger('newspost', $data['data']); e107::getEvent()->trigger('newspost', $data['data']);
//XXX - triggerHook after trigger? //XXX - triggerHook after trigger?
$evdata = array('method'=>'create', 'table'=>'news', 'id'=>$data['data']['news_id'], 'plugin'=>'news', 'function'=>'submit_item'); $evdata = array('method'=>'create', 'table'=>'news', 'id'=>$data['data']['news_id'], 'plugin'=>'news', 'function'=>'submit_item');
$emessage->add($e_event->triggerHook($evdata), E_MESSAGE_INFO, $smessages); $emessage->add($e_event->triggerHook($evdata), E_MESSAGE_INFO, $smessages);
@@ -221,9 +221,9 @@ class news {
/* FIXME - trackback should be hooked! */ /* FIXME - trackback should be hooked! */
if($news['news_id'] && $pref['trackbackEnabled']) if($news['news_id'] && $pref['trackbackEnabled'])
{ {
$excerpt = e107::getParser()->text_truncate(strip_tags(e107::getParser()->post_toHTML($news['news_body'])), 100, '...'); $excerpt = e107::getParser()->text_truncate(strip_tags(e107::getParser()->post_toHTML($news['news_body'])), 100, '...');
// $id=mysql_insert_id(); // $id=mysql_insert_id();
$permLink = $e107->base_path."comment.php?comment.news.".intval($news['news_id']); $permLink = $e107->base_path."comment.php?comment.news.".intval($news['news_id']);
@@ -233,14 +233,14 @@ class news {
if($_POST['trackback_urls']) if($_POST['trackback_urls'])
{ {
$urlArray = explode("\n", $_POST['trackback_urls']); $urlArray = explode("\n", $_POST['trackback_urls']);
foreach($urlArray as $pingurl) foreach($urlArray as $pingurl)
{ {
if(!$terror = $trackback->sendTrackback($permLink, $pingurl, $news['news_title'], $excerpt)) if(!$terror = $trackback->sendTrackback($permLink, $pingurl, $news['news_title'], $excerpt))
{ {
$message .= "<br />successfully pinged {$pingurl}."; $message .= "<br />successfully pinged {$pingurl}.";
$emessage->add("Successfully pinged {$pingurl}.", E_MESSAGE_SUCCESS, $smessages); $emessage->add("Successfully pinged {$pingurl}.", E_MESSAGE_SUCCESS, $smessages);
} }
else else
{ {
$message .= "<br />was unable to ping {$pingurl}<br />[ Error message returned was : '{$terror}'. ]"; $message .= "<br />was unable to ping {$pingurl}<br />[ Error message returned was : '{$terror}'. ]";
$emessage->add("was unable to ping {$pingurl}<br />[ Error message returned was : '{$terror}'. ]", E_MESSAGE_ERROR, $smessages); $emessage->add("was unable to ping {$pingurl}<br />[ Error message returned was : '{$terror}'. ]", E_MESSAGE_ERROR, $smessages);
@@ -282,11 +282,11 @@ class news {
$data['error'] = $error; $data['error'] = $error;
return $data; return $data;
} }
/** /**
* Manage SEF URL string for current news * Manage SEF URL string for current news
* FIXME - news rewrites should go to different handler * FIXME - news rewrites should go to different handler
* *
* @param string $action insert|update * @param string $action insert|update
* @param array $news_data XXX - could be changed to news_id only (integer) * @param array $news_data XXX - could be changed to news_id only (integer)
* @param array $rewrite_data * @param array $rewrite_data
@@ -297,13 +297,13 @@ class news {
{ {
$rewrite_data['data']['news_rewrite_source'] = $news_data['news_id']; $rewrite_data['data']['news_rewrite_source'] = $news_data['news_id'];
$rewrite_data['_FIELD_TYPES']['news_rewrite_source'] = 'int'; $rewrite_data['_FIELD_TYPES']['news_rewrite_source'] = 'int';
$old_rewrite_data = array(); $old_rewrite_data = array();
if(e107::getDb()->db_Select('news_rewrite', '*', 'news_rewrite_source='.intval($rewrite_data['data']['news_rewrite_source']).' AND news_rewrite_type='.intval($rewrite_data['data']['news_rewrite_type']))) if(e107::getDb()->db_Select('news_rewrite', '*', 'news_rewrite_source='.intval($rewrite_data['data']['news_rewrite_source']).' AND news_rewrite_type='.intval($rewrite_data['data']['news_rewrite_type'])))
{ {
$old_rewrite_data = e107::getDb()->db_Fetch(); $old_rewrite_data = e107::getDb()->db_Fetch();
} }
//Delete if required //Delete if required
if (empty($rewrite_data['data']['news_rewrite_string'])) if (empty($rewrite_data['data']['news_rewrite_string']))
{ {
@@ -314,7 +314,7 @@ class news {
e107::getAdminLog()->logArrayAll('NEWS_13', $old_rewrite_data); e107::getAdminLog()->logArrayAll('NEWS_13', $old_rewrite_data);
return true; return true;
} }
return false; return false;
} }
@@ -337,10 +337,10 @@ class news {
eMessage::getInstance()->add('mySQL error #'.e107::getDb()->getLastErrorNumber().': '.e107::getDb()->getLastErrorText(), E_MESSAGE_DEBUG, $session_message); eMessage::getInstance()->add('mySQL error #'.e107::getDb()->getLastErrorNumber().': '.e107::getDb()->getLastErrorText(), E_MESSAGE_DEBUG, $session_message);
return 'error'; return 'error';
break; break;
case 'update': case 'update':
$id = intval($rewrite_data['data']['news_rewrite_id']); $id = intval($rewrite_data['data']['news_rewrite_id']);
unset($rewrite_data['data']['news_rewrite_id']); unset($rewrite_data['data']['news_rewrite_id']);
if($id) if($id)
{ {
$rewrite_data['WHERE'] = 'news_rewrite_id='.$id; $rewrite_data['WHERE'] = 'news_rewrite_id='.$id;
@@ -353,7 +353,7 @@ class news {
return true; return true;
} }
elseif (e107::getDb()->getLastErrorNumber()) elseif (e107::getDb()->getLastErrorNumber())
{ {
eMessage::getInstance()->add('Friendly URL string related problem detected!', E_MESSAGE_ERROR, $session_message); eMessage::getInstance()->add('Friendly URL string related problem detected!', E_MESSAGE_ERROR, $session_message);
if(1062 == e107::getDb()->getLastErrorNumber()) //detect duplicate mysql errnum if(1062 == e107::getDb()->getLastErrorNumber()) //detect duplicate mysql errnum
{ {
@@ -362,14 +362,14 @@ class news {
eMessage::getInstance()->add('mySQL error #'.e107::getDb()->getLastErrorNumber().': '.e107::getDb()->getLastErrorText(), E_MESSAGE_DEBUG, $session_message); eMessage::getInstance()->add('mySQL error #'.e107::getDb()->getLastErrorNumber().': '.e107::getDb()->getLastErrorText(), E_MESSAGE_DEBUG, $session_message);
return 'error'; return 'error';
} }
$rewrite_data['data']['news_rewrite_id'] = $id; $rewrite_data['data']['news_rewrite_id'] = $id;
if($old_rewrite_data) self::clearRewriteCache($old_rewrite_data['news_rewrite_string']); if($old_rewrite_data) self::clearRewriteCache($old_rewrite_data['news_rewrite_string']);
self::setRewriteCache($rewrite_data['data']['news_rewrite_string'], $rewrite_data['data']); self::setRewriteCache($rewrite_data['data']['news_rewrite_string'], $rewrite_data['data']);
return false; return false;
} }
$rewrite_data['data']['news_rewrite_id'] = 0; $rewrite_data['data']['news_rewrite_id'] = 0;
if($rewrite_data['data']['news_rewrite_id'] = e107::getDb()->db_Insert('news_rewrite', $rewrite_data)) if($rewrite_data['data']['news_rewrite_id'] = e107::getDb()->db_Insert('news_rewrite', $rewrite_data))
{ {
@@ -378,7 +378,7 @@ class news {
e107::getAdminLog()->logArrayAll('NEWS_12', $rewrite_data['data']); e107::getAdminLog()->logArrayAll('NEWS_12', $rewrite_data['data']);
return true; return true;
} }
eMessage::getInstance()->add('Friendly URL string related problem detected!', E_MESSAGE_ERROR, $session_message); eMessage::getInstance()->add('Friendly URL string related problem detected!', E_MESSAGE_ERROR, $session_message);
if(1062 == e107::getDb()->getLastErrorNumber()) //detect duplicate mysql errnum if(1062 == e107::getDb()->getLastErrorNumber()) //detect duplicate mysql errnum
{ {
@@ -388,10 +388,10 @@ class news {
return 'error'; return 'error';
break; break;
} }
return false; return false;
} }
public static function retrieveRewriteString($news_id, $type = 1) public static function retrieveRewriteString($news_id, $type = 1)
{ {
//XXX - Best way we have now, discuss //XXX - Best way we have now, discuss
@@ -416,7 +416,7 @@ class news {
} }
unset($tmp); unset($tmp);
} }
//convert type if needed //convert type if needed
if(is_string($type)) if(is_string($type))
{ {
@@ -426,16 +426,16 @@ class news {
case 'extend': case 'extend':
$type = 1; $type = 1;
break; break;
default: default:
$type = 2; $type = 2;
break; break;
} }
} }
return (isset(self::$_rewrite_map[$type][$news_id]) ? self::$_rewrite_map[$type][$news_id] : ''); return (isset(self::$_rewrite_map[$type][$news_id]) ? self::$_rewrite_map[$type][$news_id] : '');
} }
public static function retrieveRewriteData($sefstr, $force = true) public static function retrieveRewriteData($sefstr, $force = true)
{ {
//check runtime cache //check runtime cache
@@ -443,55 +443,55 @@ class news {
{ {
return self::$_rewrite_data[$sefstr]; return self::$_rewrite_data[$sefstr];
} }
//check server cache if allowed //check server cache if allowed
if(!$force && ($ret = self::getRewriteCache($sefstr, true))) if(!$force && ($ret = self::getRewriteCache($sefstr, true)))
{ {
self::$_rewrite_data[$sefstr] = $ret; self::$_rewrite_data[$sefstr] = $ret;
return self::$_rewrite_data[$sefstr]; return self::$_rewrite_data[$sefstr];
} }
//search DB //search DB
$ret = array(); $ret = array();
if(e107::getDb()->db_Select('news_rewrite', '*', "news_rewrite_string='".e107::getParser()->toDB($sefstr)."'")) if(e107::getDb()->db_Select('news_rewrite', '*', "news_rewrite_string='".e107::getParser()->toDB($sefstr)."'"))
{ {
$ret = e107::getDb()->db_Fetch(); $ret = e107::getDb()->db_Fetch();
} }
//set runtime cache //set runtime cache
self::$_rewrite_data[$sefstr] = $ret; self::$_rewrite_data[$sefstr] = $ret;
//set server cache //set server cache
if($ret) if($ret)
{ {
self::setRewriteCache($sefstr, $ret); self::setRewriteCache($sefstr, $ret);
} }
return self::$_rewrite_data[$sefstr]; return self::$_rewrite_data[$sefstr];
} }
public static function getRewriteCache($sefstr, $toArray = true) public static function getRewriteCache($sefstr, $toArray = true)
{ {
$sefstr = md5($sefstr); $sefstr = md5($sefstr);
$ret = ecache::retrieve_sys('news_sefurl'.$sefstr, false, true); $ret = ecache::retrieve_sys('news_sefurl'.$sefstr, false, true);
if($ret && $toArray) if($ret && $toArray)
{ {
return e107::getArrayStorage()->ReadArray($ret); return e107::getArrayStorage()->ReadArray($ret);
} }
return $ret; return $ret;
} }
public static function clearRewriteCache($sefstr = '') public static function clearRewriteCache($sefstr = '')
{ {
if($sefstr) $sefstr = md5($sefstr); if($sefstr) $sefstr = md5($sefstr);
ecache::clear_sys("news_sefurl".$sefstr); ecache::clear_sys("news_sefurl".$sefstr);
} }
public static function setRewriteCache($sefstr, $data) public static function setRewriteCache($sefstr, $data)
{ {
$sefstr = md5($sefstr); $sefstr = md5($sefstr);
if(is_array($data)) $data = e107::getArrayStorage()->WriteArray($data, false); if(is_array($data)) $data = e107::getArrayStorage()->WriteArray($data, false);
ecache::set_sys("news_sefurl".$sefstr, $data, true); ecache::set_sys("news_sefurl".$sefstr, $data, true);
} }
@@ -534,8 +534,8 @@ class news {
$tmp['caticon'] = (defined("NEWSLIST_CATICON")) ? NEWSLIST_CATICON : ICONSTYLE; $tmp['caticon'] = (defined("NEWSLIST_CATICON")) ? NEWSLIST_CATICON : ICONSTYLE;
if(!$param) $param = array(); if(!$param) $param = array();
$param = array_merge($tmp, $param); $param = array_merge($tmp, $param);
// Next three images aren't always defined by the caller, even if most of $param is. // Next three images aren't always defined by the caller, even if most of $param is.
if (!isset($param['image_nonew_small'])) if (!isset($param['image_nonew_small']))
@@ -589,7 +589,7 @@ class news {
} }
$loop_uid = $news['news_author']; $loop_uid = $news['news_author'];
require_once(e_FILE.'shortcode/batch/news_shortcodes.php'); require_once(e_CORE.'shortcodes/batch/news_shortcodes.php');
setScVar('news_shortcodes', 'news_item', $news); setScVar('news_shortcodes', 'news_item', $news);
setScVar('news_shortcodes', 'param', $param); setScVar('news_shortcodes', 'param', $param);
$text = $e107->tp->parseTemplate($NEWS_PARSE, true); $text = $e107->tp->parseTemplate($NEWS_PARSE, true);
@@ -622,10 +622,10 @@ class news {
require_once(e_HANDLER.'model_class.php'); require_once(e_HANDLER.'model_class.php');
class e_news_item extends e_model class e_news_item extends e_model
{ {
protected $_loaded_once = false; protected $_loaded_once = false;
/** /**
* Shortcodes - simple field getter (basic formatting) * Shortcodes - simple field getter (basic formatting)
* THIS IS ONLY TEST, maybe useful for fields requiring simple formatting - it's a way too complicated for designers, * THIS IS ONLY TEST, maybe useful for fields requiring simple formatting - it's a way too complicated for designers,
@@ -639,20 +639,20 @@ class e_news_item extends e_model
{ {
$tmp = explode('|', $parm, 2); $tmp = explode('|', $parm, 2);
$field = $tmp[0]; $field = $tmp[0];
if(!is_array($parm)) if(!is_array($parm))
{ {
parse_str(varset($tmp[1]), $parm); parse_str(varset($tmp[1]), $parm);
} }
$val = $this->get($field, ''); $val = $this->get($field, '');
//do more with $parm array, just an example here //do more with $parm array, just an example here
if(varsettrue($parm['format'])) if(varsettrue($parm['format']))
{ {
switch ($parm['format']) switch ($parm['format'])
{ {
//USAGE: {NEWS_FIELD=body|format=html&arg=1,BODY} -> callback e107->toHTML($value, true, 'BODY'); //USAGE: {NEWS_FIELD=body|format=html&arg=1,BODY} -> callback e107->toHTML($value, true, 'BODY');
case 'html': case 'html':
$method = 'toHTML'; $method = 'toHTML';
$callback = e107::getParser(); $callback = e107::getParser();
$parm['arg'] = explode(',', varset($parm['arg'])); $parm['arg'] = explode(',', varset($parm['arg']));
@@ -660,11 +660,11 @@ class e_news_item extends e_model
$params = array($val); //value is always the first callback argument $params = array($val); //value is always the first callback argument
$params += $parm['arg']; $params += $parm['arg'];
break; break;
//USAGE: {NEWS_FIELD=body|format=html_truncate&arg=200,...} -> callback e107->html_truncate($value, 200, '...'); //USAGE: {NEWS_FIELD=body|format=html_truncate&arg=200,...} -> callback e107->html_truncate($value, 200, '...');
case 'html_truncate': case 'html_truncate':
$val = e107::getParser()->toHTML($val, true); $val = e107::getParser()->toHTML($val, true);
//USAGE: {NEWS_FIELD=title|format=text_truncate&arg=100,...} -> callback e107->text_truncate($value, 200, '...'); //USAGE: {NEWS_FIELD=title|format=text_truncate&arg=100,...} -> callback e107->text_truncate($value, 200, '...');
case 'text_truncate': case 'text_truncate':
$method = $parm['format']; $method = $parm['format'];
@@ -672,7 +672,7 @@ class e_news_item extends e_model
$params = array($val); //value is always the first callback argument $params = array($val); //value is always the first callback argument
$params = array_merge($params, explode(',', $parm['arg'])); $params = array_merge($params, explode(',', $parm['arg']));
break; break;
//USAGE: {NEWS_FIELD=title|format=date} -> strftime($pref[shortdate], $value); //USAGE: {NEWS_FIELD=title|format=date} -> strftime($pref[shortdate], $value);
//USAGE: {NEWS_FIELD=title|format=date&arg=%Y} -> strftime('%Y', $value); //USAGE: {NEWS_FIELD=title|format=date&arg=%Y} -> strftime('%Y', $value);
case 'date': case 'date':
@@ -683,18 +683,18 @@ class e_news_item extends e_model
//should be done with date handler (awaiting for modifications) //should be done with date handler (awaiting for modifications)
return strftime(varset($parm['arg'], e107::getPref('shortdate')), $val); return strftime(varset($parm['arg'], e107::getPref('shortdate')), $val);
break; break;
default: default:
return $val; return $val;
break; break;
} }
return call_user_func_array(array($callback, $method), $params); return call_user_func_array(array($callback, $method), $params);
} }
return $val; return $val;
} }
/** /**
* Shorthand getter for news fields * Shorthand getter for news fields
* *
@@ -706,7 +706,7 @@ class e_news_item extends e_model
{ {
return parent::get('news_'.$news_field, $default); return parent::get('news_'.$news_field, $default);
} }
/** /**
* Load news item by id * Load news item by id
* *
@@ -720,13 +720,13 @@ class e_news_item extends e_model
{ {
$id = intval($id); $id = intval($id);
$nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'"; $nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
$query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n $query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
WHERE n.news_id={$id} AND n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.") WHERE n.news_id={$id} AND n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.")
AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().")"; AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().")";
if(e107::getDb()->db_Select_gen($query)) if(e107::getDb()->db_Select_gen($query))
{ {
$this->setData(e107::getDb()->db_Fetch()); $this->setData(e107::getDb()->db_Fetch());
@@ -737,7 +737,7 @@ class e_news_item extends e_model
} }
} }
class e_news_tree extends e_model class e_news_tree extends e_model
{ {
/** /**
* Current tree news category id * Current tree news category id
@@ -745,12 +745,12 @@ class e_news_tree extends e_model
* @var integer * @var integer
*/ */
protected $_current_category_id; protected $_current_category_id;
/** /**
* @var array * @var array
*/ */
protected $_tree_db_total = array(); protected $_tree_db_total = array();
/** /**
* Constructor * Constructor
* *
@@ -763,7 +763,7 @@ class e_news_tree extends e_model
$this->load($category_id); $this->load($category_id);
} }
} }
/** /**
* Set current category Id * Set current category Id
* *
@@ -775,11 +775,11 @@ class e_news_tree extends e_model
$this->_current_category_id = intval($category_id); $this->_current_category_id = intval($category_id);
return $this; return $this;
} }
/** /**
* Get news item object from the tree * Get news item object from the tree
* Preparing for future news SEF string (string $name) * Preparing for future news SEF string (string $name)
* *
* @param string|integer $name * @param string|integer $name
* @param integer $category_id optional category Id * @param integer $category_id optional category Id
* @return e_news_item * @return e_news_item
@@ -792,7 +792,7 @@ class e_news_tree extends e_model
} }
return $this->getData('__tree/'.$category_id.'/'.$name); return $this->getData('__tree/'.$category_id.'/'.$name);
} }
/** /**
* Set news item object * Set news item object
* *
@@ -810,7 +810,7 @@ class e_news_tree extends e_model
$this->setData('__tree/'.$category_id.'/'.$name, new e_news_item($data)); $this->setData('__tree/'.$category_id.'/'.$name, new e_news_item($data));
return $this; return $this;
} }
/** /**
* Set new category tree * Set new category tree
* *
@@ -827,7 +827,7 @@ class e_news_tree extends e_model
$this->setData('__tree/'.$category_id, $tree); $this->setData('__tree/'.$category_id, $tree);
return $this; return $this;
} }
/** /**
* Get tree by category id * Get tree by category id
* *
@@ -842,7 +842,7 @@ class e_news_tree extends e_model
} }
return $this->getData('__tree/'.$category_id); return $this->getData('__tree/'.$category_id);
} }
/** /**
* Total records found (DB) * Total records found (DB)
* @param integer $category_id [optional] * @param integer $category_id [optional]
@@ -856,7 +856,7 @@ class e_news_tree extends e_model
} }
return (isset($this->_tree_db_total[$category_id]) ? $this->_tree_db_total[$category_id] : 0); return (isset($this->_tree_db_total[$category_id]) ? $this->_tree_db_total[$category_id] : 0);
} }
/** /**
* Load tree by category id * Load tree by category id
* *
@@ -871,13 +871,13 @@ class e_news_tree extends e_model
if(is_string($qry_data)) { parse_str($qry_data, $qry_data); } if(is_string($qry_data)) { parse_str($qry_data, $qry_data); }
$limit_from = varset($qry_data['limit_from'], 0); $limit_from = varset($qry_data['limit_from'], 0);
$limit_to = varset($qry_data['limit_to'], e107::getPref('newspost', 15)); $limit_to = varset($qry_data['limit_to'], e107::getPref('newspost', 15));
$order = varset($qry_data['order'], 'n.news_sticky DESC, n.news_datestamp DESC'); $order = varset($qry_data['order'], 'n.news_sticky DESC, n.news_datestamp DESC');
$this->setCurrentCategoryId($category_id); $this->setCurrentCategoryId($category_id);
//TODO - file cache $cacheString = md5($category_id.$limit_from.$order.e_CLASS_REGEXP); //TODO - file cache $cacheString = md5($category_id.$limit_from.$order.e_CLASS_REGEXP);
if($force || !$this->isTree()) if($force || !$this->isTree())
{ {
$nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'"; $nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
@@ -891,12 +891,12 @@ class e_news_tree extends e_model
WHERE{$where} n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") WHERE{$where} n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().")
AND n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.")
ORDER BY ".e107::getParser()->toDB($order)." LIMIT ".intval($limit_from).",".intval($limit_to); ORDER BY ".e107::getParser()->toDB($order)." LIMIT ".intval($limit_from).",".intval($limit_to);
$tree = array(); $tree = array();
if(e107::getDb()->db_Select_gen($query)) if(e107::getDb()->db_Select_gen($query))
{ {
$this->_tree_db_total[$category_id] = (integer) e107::getDb()->total_results; $this->_tree_db_total[$category_id] = (integer) e107::getDb()->total_results;
while (true) while (true)
{ {
$row = e107::getDb()->db_Fetch(); $row = e107::getDb()->db_Fetch();
@@ -908,22 +908,22 @@ class e_news_tree extends e_model
} }
} }
$this->setTree($tree); $this->setTree($tree);
} }
return $this; return $this;
} }
function isTree($category_id = null) function isTree($category_id = null)
{ {
if(null === $category_id) if(null === $category_id)
{ {
$category_id = $this->_current_category_id; $category_id = $this->_current_category_id;
} }
return $this->isData('__tree/'.$category_id); return $this->isData('__tree/'.$category_id);
} }
function isNode($name, $category_id = null) function isNode($name, $category_id = null)
{ {
if(null === $category_id) if(null === $category_id)
@@ -932,7 +932,7 @@ class e_news_tree extends e_model
} }
return $this->isData('__tree/'.$category_id.'/'.$name); return $this->isData('__tree/'.$category_id.'/'.$name);
} }
function hasNode($name, $category_id = null) function hasNode($name, $category_id = null)
{ {
if(null === $category_id) if(null === $category_id)
@@ -956,38 +956,38 @@ class e_news_category_item extends e_model
{ {
return parent::get('category_'.$category_field, $default); return parent::get('category_'.$category_field, $default);
} }
public function sc_news_category_title($parm = '') public function sc_news_category_title($parm = '')
{ {
if('attribute' == $parm) return e107::getParser()->toAttribute($this->get('name')); if('attribute' == $parm) return e107::getParser()->toAttribute($this->get('name'));
return $this->get('name'); return $this->get('name');
} }
public function sc_news_category_url($parm = '') public function sc_news_category_url($parm = '')
{ {
$url = e107::getUrl()->create('core:news', 'main', 'action=list&id='.$this->getId().'&sef='.$this->get('rewrite_string')); $url = e107::getUrl()->create('core:news', 'main', 'action=list&id='.$this->getId().'&sef='.$this->get('rewrite_string'));
switch($parm) switch($parm)
{ {
case 'link': case 'link':
return '<a href="'.$url.'" class="news-category">'.$this->sc_news_category_title().'</a>'; return '<a href="'.$url.'" class="news-category">'.$this->sc_news_category_title().'</a>';
break; break;
case 'link_icon': case 'link_icon':
return '<a href="'.$url.'" class="news-category">'.$this->sc_news_category_icon().'&nbsp;'.$this->sc_news_category_title().'</a>'; return '<a href="'.$url.'" class="news-category">'.$this->sc_news_category_icon().'&nbsp;'.$this->sc_news_category_title().'</a>';
break; break;
default: default:
return $url; return $url;
break; break;
} }
} }
public function sc_news_category_link() public function sc_news_category_link()
{ {
return $this->sc_news_category_url('link'); return $this->sc_news_category_url('link');
} }
public function sc_news_category_icon($parm = '') public function sc_news_category_icon($parm = '')
{ {
if(!$this->get('icon')) if(!$this->get('icon'))
@@ -998,7 +998,7 @@ class e_news_category_item extends e_model
{ {
$src = e107::getParser()->replaceConstants($this->get('icon')); $src = e107::getParser()->replaceConstants($this->get('icon'));
} }
else else
{ {
$src = e_IMAGE_ABS.'icons/'.$this->get('icon'); $src = e_IMAGE_ABS.'icons/'.$this->get('icon');
} }
@@ -1010,13 +1010,13 @@ class e_news_category_item extends e_model
case 'link': case 'link':
return '<a href="'.$this->sc_news_category_url().'" class="news-category" title="'.$this->sc_news_category_title('attribute').'"><img src="'.$src.'" class="icon news-category" alt="'.$this->sc_news_category_title('attribute').'" /></a>'; return '<a href="'.$this->sc_news_category_url().'" class="news-category" title="'.$this->sc_news_category_title('attribute').'"><img src="'.$src.'" class="icon news-category" alt="'.$this->sc_news_category_title('attribute').'" /></a>';
break; break;
default: default:
return '<img src="'.$src.'" class="icon news-category" alt="'.$this->sc_news_category_title('attribute').'" />'; return '<img src="'.$src.'" class="icon news-category" alt="'.$this->sc_news_category_title('attribute').'" />';
break; break;
} }
} }
public function sc_news_category_news_count($parm = '') public function sc_news_category_news_count($parm = '')
{ {
if(!$this->is('category_news_count')) if(!$this->is('category_news_count'))
@@ -1025,7 +1025,7 @@ class e_news_category_item extends e_model
} }
return (string) $this->get('news_count'); return (string) $this->get('news_count');
} }
} }
class e_news_category_tree extends e_model class e_news_category_tree extends e_model
@@ -1034,14 +1034,14 @@ class e_news_category_tree extends e_model
* @var array * @var array
*/ */
protected $_tree_db_total = array(); protected $_tree_db_total = array();
/** /**
* Get category news item object from the tree * Get category news item object from the tree
* If $force_empty is true and corresponding category object can't be found, * If $force_empty is true and corresponding category object can't be found,
* empty object will be set/returned if * empty object will be set/returned if
* *
* @param integer $category_id * @param integer $category_id
* @param boolean $force_empty * @param boolean $force_empty
* @return e_news_category_item * @return e_news_category_item
*/ */
function getNode($category_id, $force_empty = false) function getNode($category_id, $force_empty = false)
@@ -1052,10 +1052,10 @@ class e_news_category_tree extends e_model
$default = new e_news_category(); $default = new e_news_category();
$this->setNode($category_id, $default); $this->setNode($category_id, $default);
} }
return $this->getData('__tree/'.$category_id, $default); return $this->getData('__tree/'.$category_id, $default);
} }
/** /**
* Set category news item object * Set category news item object
* *
@@ -1071,10 +1071,10 @@ class e_news_category_tree extends e_model
} }
$this->_tree_total = null; $this->_tree_total = null;
$this->setData('__tree/'.$category_id, $category_object); $this->setData('__tree/'.$category_id, $category_object);
return $this; return $this;
} }
/** /**
* Set news category tree array * Set news category tree array
* *
@@ -1085,10 +1085,10 @@ class e_news_category_tree extends e_model
{ {
$this->_tree_total = null; $this->_tree_total = null;
$this->setData('__tree', $tree); $this->setData('__tree', $tree);
return $this; return $this;
} }
/** /**
* Get news category tree array * Get news category tree array
* *
@@ -1098,10 +1098,10 @@ class e_news_category_tree extends e_model
{ {
return $this->getData('__tree', array()); return $this->getData('__tree', array());
} }
/** /**
* Total records found (DB) * Total records found (DB)
* *
* @return integer * @return integer
*/ */
function getTreeTotal() function getTreeTotal()
@@ -1112,10 +1112,10 @@ class e_news_category_tree extends e_model
} }
return $this->_tree_total; return $this->_tree_total;
} }
/** /**
* Load category data from the DB * Load category data from the DB
* *
* @param boolean $force * @param boolean $force
* @return e_news_category_tree * @return e_news_category_tree
*/ */
@@ -1131,7 +1131,7 @@ class e_news_category_tree extends e_model
{ {
$qry = " $qry = "
SELECT nc.*, ncr.news_rewrite_string AS category_rewrite_string, ncr.news_rewrite_id AS category_rewrite_id FROM #news_category AS nc SELECT nc.*, ncr.news_rewrite_string AS category_rewrite_string, ncr.news_rewrite_id AS category_rewrite_id FROM #news_category AS nc
LEFT JOIN #news_rewrite AS ncr ON nc.category_id=ncr.news_rewrite_source AND ncr.news_rewrite_type=2 LEFT JOIN #news_rewrite AS ncr ON nc.category_id=ncr.news_rewrite_source AND ncr.news_rewrite_type=2
ORDER BY nc.category_order ASC ORDER BY nc.category_order ASC
"; ";
} }
@@ -1139,11 +1139,11 @@ class e_news_category_tree extends e_model
{ {
$qry = "SELECT * FROM #news_category ORDER BY category_order ASC"; $qry = "SELECT * FROM #news_category ORDER BY category_order ASC";
} }
$tree = array(); $tree = array();
$sql = e107::getDb(); $sql = e107::getDb();
$sql->db_Mark_Time('news_category_tree'); $sql->db_Mark_Time('news_category_tree');
if($sql->db_Select_gen($qry)) if($sql->db_Select_gen($qry))
{ {
while($row = $sql->db_Fetch()) while($row = $sql->db_Fetch())
@@ -1152,13 +1152,13 @@ class e_news_category_tree extends e_model
} }
} }
$this->setTree($tree); $this->setTree($tree);
return $this; return $this;
} }
/** /**
* Load active categories only (containing active news items) * Load active categories only (containing active news items)
* *
* @param boolean $force * @param boolean $force
* @return e_news_category_tree * @return e_news_category_tree
*/ */
@@ -1176,7 +1176,7 @@ class e_news_category_tree extends e_model
{ {
$qry = " $qry = "
SELECT COUNT(n.news_id) AS category_news_count, nc.*, ncr.news_rewrite_string AS category_rewrite_string, ncr.news_rewrite_id AS category_rewrite_id FROM #news_category AS nc SELECT COUNT(n.news_id) AS category_news_count, nc.*, ncr.news_rewrite_string AS category_rewrite_string, ncr.news_rewrite_id AS category_rewrite_id FROM #news_category AS nc
LEFT JOIN #news_rewrite AS ncr ON nc.category_id=ncr.news_rewrite_source AND ncr.news_rewrite_type=2 LEFT JOIN #news_rewrite AS ncr ON nc.category_id=ncr.news_rewrite_source AND ncr.news_rewrite_type=2
LEFT JOIN #news AS n ON n.news_category=nc.category_id LEFT JOIN #news AS n ON n.news_category=nc.category_id
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.") WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.")
AND n.news_start < ".$time." AND (n.news_end=0 || n.news_end>".$time.") AND n.news_start < ".$time." AND (n.news_end=0 || n.news_end>".$time.")
@@ -1195,11 +1195,11 @@ class e_news_category_tree extends e_model
ORDER BY nc.category_order ASC ORDER BY nc.category_order ASC
"; ";
} }
$tree = array(); $tree = array();
$sql = e107::getDb(); $sql = e107::getDb();
$sql->db_Mark_Time('news_category_tree'); $sql->db_Mark_Time('news_category_tree');
if($sql->db_Select_gen($qry)) if($sql->db_Select_gen($qry))
{ {
while($row = $sql->db_Fetch()) while($row = $sql->db_Fetch())
@@ -1208,13 +1208,13 @@ class e_news_category_tree extends e_model
} }
} }
$this->setTree($tree); $this->setTree($tree);
return $this; return $this;
} }
/** /**
* Render Category tree * Render Category tree
* *
* @param array $parms [return, parsesc=>1|0, mode=>string] * @param array $parms [return, parsesc=>1|0, mode=>string]
* @param boolean $tablerender * @param boolean $tablerender
* @param array $force_template template override * @param array $force_template template override
@@ -1226,36 +1226,36 @@ class e_news_category_tree extends e_model
{ {
return ''; return '';
} }
$template = $force_template; //TODO template search, more template freedom, tree shortcodes $template = $force_template; //TODO template search, more template freedom, tree shortcodes
$ret = array(); $ret = array();
$tp = e107::getParser(); $tp = e107::getParser();
if(!isset($parms['parsesc'])) $parms['parsesc'] = true; if(!isset($parms['parsesc'])) $parms['parsesc'] = true;
$parsesc = $parms['parsesc'] ? true : false; $parsesc = $parms['parsesc'] ? true : false;
foreach ($this->getTree() as $cat) foreach ($this->getTree() as $cat)
{ {
$ret[] = $tp->parseTemplate($template['item'], $parsesc, $cat); $ret[] = $tp->parseTemplate($template['item'], $parsesc, $cat);
} }
if($ret) if($ret)
{ {
$separator = varset($template['separator'], ''); $separator = varset($template['separator'], '');
$ret = implode($separator, $ret); $ret = implode($separator, $ret);
$return = isset($parms['return']) ? true : false; $return = isset($parms['return']) ? true : false;
if($tablerender) if($tablerender)
{ {
$caption = vartrue($parms['caption']) ? defset($parms['caption'], $parms['caption']) : LAN_NEWSCAT_MENU_TITLE; // found in plugins/news/languages/English.php $caption = vartrue($parms['caption']) ? defset($parms['caption'], $parms['caption']) : LAN_NEWSCAT_MENU_TITLE; // found in plugins/news/languages/English.php
$mod = true === $tablerender ? 'news_categories_menu' : $tablerender; $mod = true === $tablerender ? 'news_categories_menu' : $tablerender;
return e107::getRender()->tablerender($caption, $ret, varset($parms['mode'], $mod), $return); return e107::getRender()->tablerender($caption, $ret, varset($parms['mode'], $mod), $return);
} }
if($return) return $ret; if($return) return $ret;
echo $ret; echo $ret;
} }
return ''; return '';
} }
} }

View File

@@ -80,14 +80,14 @@ function display_help($tagid="helpb", $mode = 1, $addtextfunc = "addtext", $help
$BBCODE_TEMPLATE = $temp[$mode]; $BBCODE_TEMPLATE = $temp[$mode];
} }
if(is_readable(e_FILE."shortcode/batch/bbcode_shortcodes.php")) if(is_readable(e_CORE."shortcodes/batch/bbcode_shortcodes.php"))
{ {
require_once(e_FILE."shortcode/batch/bbcode_shortcodes.php"); require_once(e_CORE."shortcodes/batch/bbcode_shortcodes.php");
return $tp->parseTemplate($BBCODE_TEMPLATE); return $tp->parseTemplate($BBCODE_TEMPLATE);
} }
else else
{ {
return "ERROR: ".e_FILE."shortcode/batch/bbcode_shortcodes.php IS NOT READABLE."; return "ERROR: ".e_CORE."shortcodes/batch/bbcode_shortcodes.php IS NOT READABLE.";
} }
} }
@@ -230,7 +230,7 @@ function PreImage_Select($formid) {
// Parameter '$bbcode_filedir' removed - not used in code. // Parameter '$bbcode_filedir' removed - not used in code.
function PreFile_Select($formid='prefile_selector') function PreFile_Select($formid='prefile_selector')
{ {
require_once(e_HANDLER."userclass_class.php"); require_once(e_HANDLER."userclass_class.php");
global $IMAGES_DIRECTORY, $fl; global $IMAGES_DIRECTORY, $fl;

View File

@@ -31,7 +31,7 @@ if (!defined('e107_INIT')) { exit; }
function register_shortcode($classFunc, $codes, $path='', $force = false) function register_shortcode($classFunc, $codes, $path='', $force = false)
{ {
$sc = e107::getScParser(); $sc = e107::getScParser();
//If codes is set to true, let's go get a list of shortcode methods //If codes is set to true, let's go get a list of shortcode methods
if(/*is_bool($codes) && */$codes === true) //double check fix if(/*is_bool($codes) && */$codes === true) //double check fix
{ {
@@ -46,14 +46,14 @@ function register_shortcode($classFunc, $codes, $path='', $force = false)
} }
unset($tmp); unset($tmp);
} }
//Register object feature //Register object feature
$classObj = null; $classObj = null;
if(is_object($classFunc)) if(is_object($classFunc))
{ {
$classObj = $classFunc; $classObj = $classFunc;
$classFunc = get_class($classObj); $classFunc = get_class($classObj);
} }
//We only register these shortcodes if they have not already been registered in some manner //We only register these shortcodes if they have not already been registered in some manner
@@ -68,7 +68,7 @@ function register_shortcode($classFunc, $codes, $path='', $force = false)
$sc->registered_codes[$code] = array('type' => 'class', 'path' => $path, 'class' => $classFunc); $sc->registered_codes[$code] = array('type' => 'class', 'path' => $path, 'class' => $classFunc);
} }
} }
//register object if required //register object if required
if(null !== $classObj && !isset($sc->scClasses[$classFunc])) if(null !== $classObj && !isset($sc->scClasses[$classFunc]))
{ {
@@ -139,7 +139,7 @@ function initShortcodeClass($class, $force = false)
} }
} }
class e_shortcode class e_shortcode
{ {
@@ -161,18 +161,19 @@ class e_shortcode
$this->loadThemeShortcodes(); $this->loadThemeShortcodes();
$this->loadPluginShortcodes(); $this->loadPluginShortcodes();
$this->loadPluginSCFiles(); $this->loadPluginSCFiles();
} }
/** /**
* Register any shortcode from the shortcode/override/ directory * Register any shortcode from the shortcodes/override/ directory
* *
* @return void * @return void
*/ */
//FIXME - should use e_SYSTEM/override/
protected function loadOverrideShortcodes() protected function loadOverrideShortcodes()
{ {
$pref = e107::getConfig('core')->getPref(); $pref = e107::getConfig('core')->getPref();
if(varset($pref['sc_override'])) if(varset($pref['sc_override']))
{ {
$tmp = explode(',', $pref['sc_override']); $tmp = explode(',', $pref['sc_override']);
@@ -184,7 +185,7 @@ class e_shortcode
} }
} }
} }
/** /**
* Register any shortcodes that were registered by the theme * Register any shortcodes that were registered by the theme
* $register_sc[] = 'MY_THEME_CODE' * $register_sc[] = 'MY_THEME_CODE'
@@ -194,7 +195,7 @@ class e_shortcode
protected function loadThemeShortcodes() protected function loadThemeShortcodes()
{ {
global $register_sc; global $register_sc;
if(isset($register_sc) && is_array($register_sc)) if(isset($register_sc) && is_array($register_sc))
{ {
foreach($register_sc as $code) foreach($register_sc as $code)
@@ -207,8 +208,8 @@ class e_shortcode
} }
} }
} }
/** /**
* Register all .sc files found in plugin directories (via pref) * Register all .sc files found in plugin directories (via pref)
* *
@@ -217,7 +218,7 @@ class e_shortcode
protected function loadPluginSCFiles() protected function loadPluginSCFiles()
{ {
$pref = e107::getConfig('core')->getPref(); $pref = e107::getConfig('core')->getPref();
if(varset($pref['shortcode_list'], '') != '') if(varset($pref['shortcode_list'], '') != '')
{ {
foreach($pref['shortcode_list'] as $path => $namearray) foreach($pref['shortcode_list'] as $path => $namearray)
@@ -252,7 +253,7 @@ class e_shortcode
protected function loadPluginShortcodes() protected function loadPluginShortcodes()
{ {
$pref = e107::getConfig('core')->getPref(); $pref = e107::getConfig('core')->getPref();
if(!vartrue($pref['e_shortcode_list'])) if(!vartrue($pref['e_shortcode_list']))
{ {
return; return;
@@ -267,7 +268,7 @@ class e_shortcode
$path = e_PLUGIN.$key.'/e_shortcode.php'; $path = e_PLUGIN.$key.'/e_shortcode.php';
$classFunc = $key.'_shortcodes'; $classFunc = $key.'_shortcodes';
$this->scClasses[$classFunc] = new $classFunc; $this->scClasses[$classFunc] = new $classFunc;
$tmp = get_class_methods($classFunc); $tmp = get_class_methods($classFunc);
foreach($tmp as $c) foreach($tmp as $c)
{ {
@@ -295,7 +296,7 @@ class e_shortcode
$coreBatchList = array('admin_shortcodes.php'); $coreBatchList = array('admin_shortcodes.php');
foreach($coreBatchList as $cb) foreach($coreBatchList as $cb)
{ {
include_once(e_FILE.'shortcode/batch/'.$cb); include_once(e_CORE.'shortcodes/batch/'.$cb);
} }
} }
@@ -303,7 +304,7 @@ class e_shortcode
{ {
return in_array($code, $this->registered_codes); return in_array($code, $this->registered_codes);
} }
public function resetScClass($className, $object) public function resetScClass($className, $object)
{ {
if($this->isScClass($className)) if($this->isScClass($className))
@@ -311,7 +312,7 @@ class e_shortcode
$this->scClasses[$className] = $object; $this->scClasses[$className] = $object;
} }
} }
function isScClass($className) function isScClass($className)
{ {
return isset($this->scClasses[$className]); return isset($this->scClasses[$className]);
@@ -326,7 +327,7 @@ class e_shortcode
{ {
$saveParseSCFiles = $this->parseSCFiles; // In case of nested call $saveParseSCFiles = $this->parseSCFiles; // In case of nested call
$this->parseSCFiles = $useSCFiles; $this->parseSCFiles = $useSCFiles;
if(is_object($eVars)) { if(is_object($eVars)) {
$this->eVars = $eVars; $this->eVars = $eVars;
} }
@@ -335,13 +336,13 @@ class e_shortcode
if(is_object($extraCodes)) if(is_object($extraCodes))
{ {
$classname = get_class($extraCodes); $classname = get_class($extraCodes);
//register once //register once
if(!$this->isScClass($classname)) if(!$this->isScClass($classname))
{ {
register_shortcode($extraCodes, true); register_shortcode($extraCodes, true);
} }
//always overwrite object //always overwrite object
$this->scClasses[$classname] = $extraCodes; $this->scClasses[$classname] = $extraCodes;
} }
@@ -445,14 +446,14 @@ class e_shortcode
} }
if(method_exists($this->scClasses[$_class], $_method)) if(method_exists($this->scClasses[$_class], $_method))
{ {
$ret = $this->scClasses[$_class]->$_method($parm, $sc_mode); $ret = $this->scClasses[$_class]->$_method($parm, $sc_mode);
} }
else else
{ {
echo $_class.'::'.$_method.' NOT FOUND!<br />'; echo $_class.'::'.$_method.' NOT FOUND!<br />';
} }
break; break;
case 'func': case 'func':
@@ -474,7 +475,7 @@ class e_shortcode
break; break;
case 'override': case 'override':
$scFile = e_FILE.'shortcode/override/'.strtolower($code).'.sc'; $scFile = e_FILE.'shortcodes/override/'.strtolower($code).'.sc';
break; break;
case 'theme': case 'theme':
@@ -487,13 +488,13 @@ class e_shortcode
{ {
// Code is not registered, let's look for .sc or .php file // Code is not registered, let's look for .sc or .php file
// .php file takes precedence over .sc file // .php file takes precedence over .sc file
if(is_readable(e_FILE.'shortcode/'.strtolower($code).'.php')) if(is_readable(e_CORE.'shortcodes/single/'.strtolower($code).'.php'))
{ {
$_function = strtolower($code).'_shortcode'; $_function = strtolower($code).'_shortcode';
$_class = strtolower($code); $_class = strtolower($code);
include_once(e_FILE.'shortcode/'.strtolower($code).'.php'); include_once(e_CORE.'shortcodes/single/'.strtolower($code).'.php');
if(class_exists($_class, false)) // prevent __autoload - performance if(class_exists($_class, false)) // prevent __autoload - performance
{ {
$ret = call_user_func(array($_class,$_function), $parm); $ret = call_user_func(array($_class,$_function), $parm);
@@ -505,7 +506,7 @@ class e_shortcode
} }
else else
{ {
$scFile = e_FILE.'shortcode/'.strtolower($code).'.sc'; $scFile = e_CORE.'shortcodes/single/'.strtolower($code).'.sc';
} }
} }
if ($scFile && file_exists($scFile)) if ($scFile && file_exists($scFile))
@@ -523,7 +524,7 @@ class e_shortcode
if(E107_DBG_SC && $scFile) if(E107_DBG_SC && $scFile)
{ {
// echo (isset($scFile)) ? "<br />sc_file= ".str_replace(e_FILE.'shortcode/', '', $scFile).'<br />' : ''; // echo (isset($scFile)) ? "<br />sc_file= ".str_replace(e_CORE.'shortcodes/single/', '', $scFile).'<br />' : '';
// echo "<br />sc= <b>$code</b>"; // echo "<br />sc= <b>$code</b>";
} }
} }

View File

@@ -52,7 +52,7 @@ $menu_pref = e107::getConfig('menu')->getPref('');
if(isset($campaign)) if(isset($campaign))
{ {
$parm = $campaign; $parm = $campaign;
$bannersccode = file_get_contents(e_FILE.'shortcode/banner.sc'); $bannersccode = file_get_contents(e_CORE.'shortcodes/single/banner.sc');
$BANNER = eval($bannersccode); $BANNER = eval($bannersccode);
$txt = $BANNER_MENU_START; $txt = $BANNER_MENU_START;
$txt .= preg_replace("/\{(.*?)\}/e", '$\1', $BANNER_MENU); $txt .= preg_replace("/\{(.*?)\}/e", '$\1', $BANNER_MENU);
@@ -80,11 +80,11 @@ else
$parms[] = $menu_pref['banner_campaign']; $parms[] = $menu_pref['banner_campaign'];
} }
} }
$txt = $BANNER_MENU_START; $txt = $BANNER_MENU_START;
foreach ($parms as $parm) foreach ($parms as $parm)
{ {
$bannersccode = file_get_contents(e_FILE.'shortcode/banner.sc'); $bannersccode = file_get_contents(e_CORE.'shortcodes/banner.sc');
$BANNER = eval($bannersccode); $BANNER = eval($bannersccode);
$txt .= preg_replace("/\{(.*?)\}/e", '$\1', $BANNER_MENU); $txt .= preg_replace("/\{(.*?)\}/e", '$\1', $BANNER_MENU);
} }

View File

@@ -2,63 +2,63 @@
//error_reporting(E_ALL); //error_reporting(E_ALL);
if (e_ADMIN_AREA !== TRUE) if (e_ADMIN_AREA !== TRUE && e107::isInstalled('facebook'))
{ {
e107::getEvent()->register('logout',array('e_facebook','fb_logout'),e_PLUGIN.'facebook/facebook_function.php'); e107::getEvent()->register('logout',array('e_facebook','fb_logout'),e_PLUGIN.'facebook/facebook_function.php');
global $fb; global $fb;
$fb = e107::getSingleton('e_facebook',e_PLUGIN.'facebook/facebook_function.php'); $fb = e107::getSingleton('e_facebook',e_PLUGIN.'facebook/facebook_function.php');
include_once (e_PLUGIN.'facebook/facebook_function.php'); include_once (e_PLUGIN.'facebook/facebook_function.php');
if (function_exists('prevent_cache_headers')) if (function_exists('prevent_cache_headers'))
{ {
prevent_cache_headers(); prevent_cache_headers();
} }
define('XMLNS', "xmlns:fb='http://www.facebook.com/2008/fbml'"); define('XMLNS', "xmlns:fb='http://www.facebook.com/2008/fbml'");
global $pref; global $pref;
if ($pref['disable_emailcheck'] == 0) // Ensure "Make entering an email address optional" is setted to "ON"; if ($pref['disable_emailcheck'] == 0) // Ensure "Make entering an email address optional" is setted to "ON";
{ {
$pref['disable_emailcheck'] = 1; $pref['disable_emailcheck'] = 1;
save_prefs(); save_prefs();
} }
if (e_QUERY == 'facebook') // when clicked it inserts a new User in e107. if (e_QUERY == 'facebook') // when clicked it inserts a new User in e107.
{ {
Fb_Connect_Me(); Fb_Connect_Me();
} }
if (e_QUERY == 'login') // simple Re-Login after logged out from e107 if (e_QUERY == 'login') // simple Re-Login after logged out from e107
{ {
$fb->fb_login(); // Fb_LogIn(); $fb->fb_login(); // Fb_LogIn();
} }
if (e_QUERY == 'logout') // simulate Facebook logOut when logged out from e107 if (e_QUERY == 'logout') // simulate Facebook logOut when logged out from e107
{ {
// Fb_LogOut(); // Fb_LogOut();
} }
if (e_QUERY == 'facebook_switch') if (e_QUERY == 'facebook_switch')
{ {
Switch_Facebook_User(); Switch_Facebook_User();
} }
if (USERID && (e_QUERY == 'facebook_link') && $fb->fb_uid) // if (USERID && (e_QUERY == 'facebook_link') && $fb->fb_uid) //
{ {
// $fb->Add_Facebook_Connect_User('', USERID); // $fb->Add_Facebook_Connect_User('', USERID);
$fb->addFacebookUser(); $fb->addFacebookUser();
} }
if (e_QUERY == 'facebook_delete') if (e_QUERY == 'facebook_delete')
{ {
Delete_Duplicate_Facebook_User(); Delete_Duplicate_Facebook_User();
} }
@@ -71,29 +71,29 @@ if (e_ADMIN_AREA !== TRUE)
* rendering takes over. otherwise, it might miss some elements in the doc. * rendering takes over. otherwise, it might miss some elements in the doc.
* *
*/ */
global $onload_js; global $onload_js;
$text .= render_facebook_init_js($fb->fb_uid); $text .= render_facebook_init_js($fb->fb_uid);
// Print out all onload function calls // Print out all onload function calls
if ($onload_js) if ($onload_js)
{ {
$text .= '<script type="text/javascript">'.'window.onload = function() { '.$onload_js.' };'.'</script>'; $text .= '<script type="text/javascript">'.'window.onload = function() { '.$onload_js.' };'.'</script>';
} }
return $text; return $text;
} }
/** /**
* *
* Facebook Deprecated get Feed Story trough Template Bundle 2009 * Facebook Deprecated get Feed Story trough Template Bundle 2009
* *
function getTemplateData() { function getTemplateData() {
$template_data = array( $template_data = array(
'post_title' => $_POST[ 'subject' ], 'post_title' => $_POST[ 'subject' ],
'body' => $_POST[ 'comment' ], 'body' => $_POST[ 'comment' ],
@@ -102,13 +102,13 @@ if (e_ADMIN_AREA !== TRUE)
'blogname' => SITENAME, 'blogname' => SITENAME,
'blogdesc' => SITEDESCRIPTION, 'blogdesc' => SITEDESCRIPTION,
'siteurl' => SITEURLBASE); 'siteurl' => SITEURLBASE);
return $template_data; return $template_data;
} }
*/ */
/** /**
* get Feed Story infos to send to Facebook * get Feed Story infos to send to Facebook
* *
@@ -121,22 +121,22 @@ if (e_ADMIN_AREA !== TRUE)
{ {
//global $pref; //global $pref;
//$stream = facebook_client()->api_client->stream_get('','','','','',''.$pref[ 'Facebook_App-Bundle' ].'',''); //$stream = facebook_client()->api_client->stream_get('','','','','',''.$pref[ 'Facebook_App-Bundle' ].'','');
// $stream = facebook_client()->api_client->stream_publish($_POST[ 'comment' ]); // $stream = facebook_client()->api_client->stream_publish($_POST[ 'comment' ]);
return $_POST['comment']; return $_POST['comment'];
} }
/** /**
* if comment is submitted and "publish_to_facebook" is checked send a copy to Facebook * if comment is submitted and "publish_to_facebook" is checked send a copy to Facebook
* *
*/ */
if (isset($_POST['commentsubmit']) && ($_POST['publish_to_facebook'] == true)) if (isset($_POST['commentsubmit']) && ($_POST['publish_to_facebook'] == true))
{ {
register_feed_form_js(); register_feed_form_js();
} }
} }

View File

@@ -96,7 +96,7 @@ if(NEWS_REWRITE)
//item //item
$rewrite_join = 'LEFT JOIN #news_rewrite AS nr ON n.news_id=nr.news_rewrite_source AND nr.news_rewrite_type=1'; $rewrite_join = 'LEFT JOIN #news_rewrite AS nr ON n.news_id=nr.news_rewrite_source AND nr.news_rewrite_type=1';
$rewrite_cols = ', nr.*'; $rewrite_cols = ', nr.*';
//category //category
$rewrite_join_cat = 'LEFT JOIN #news_rewrite AS ncr ON n.news_category=ncr.news_rewrite_source AND ncr.news_rewrite_type=2'; $rewrite_join_cat = 'LEFT JOIN #news_rewrite AS ncr ON n.news_category=ncr.news_rewrite_source AND ncr.news_rewrite_type=2';
$rewrite_cols_cat = ', ncr.news_rewrite_id AS news_category_rewrite_id, ncr.news_rewrite_string AS news_category_rewrite_string '; $rewrite_cols_cat = ', ncr.news_rewrite_id AS news_category_rewrite_id, ncr.news_rewrite_string AS news_category_rewrite_string ';
@@ -130,8 +130,8 @@ if ($action == 'cat' || $action == 'all')
// show archive of all news items using list-style template. // show archive of all news items using list-style template.
$news_total = $sql->db_Count("news", "(*)", "WHERE news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND news_start < ".time()." AND (news_end=0 || news_end>".time().")"); $news_total = $sql->db_Count("news", "(*)", "WHERE news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND news_start < ".time()." AND (news_end=0 || news_end>".time().")");
$query = " $query = "
SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon, SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon,
nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols} nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols}
FROM #news AS n FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
@@ -150,7 +150,7 @@ if ($action == 'cat' || $action == 'all')
if(!defined("NEWSLIST_LIMIT")) { define("NEWSLIST_LIMIT",10); } if(!defined("NEWSLIST_LIMIT")) { define("NEWSLIST_LIMIT",10); }
$query = " $query = "
SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon, nc.category_meta_keywords, SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon, nc.category_meta_keywords,
nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols} nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols}
FROM #news AS n FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
@@ -162,13 +162,13 @@ if ($action == 'cat' || $action == 'all')
ORDER BY n.news_datestamp DESC ORDER BY n.news_datestamp DESC
LIMIT ".intval($newsfrom).",".NEWSLIST_LIMIT; LIMIT ".intval($newsfrom).",".NEWSLIST_LIMIT;
} }
$newsList = array(); $newsList = array();
if($sql->db_Select_gen($query)) if($sql->db_Select_gen($query))
{ {
$newsList = $sql->db_getList(); $newsList = $sql->db_getList();
} }
if($action == 'cat') setNewsFrontMeta($newsList[1], 'category'); if($action == 'cat') setNewsFrontMeta($newsList[1], 'category');
elseif($category_name) elseif($category_name)
{ {
@@ -199,14 +199,14 @@ if ($action == 'cat' || $action == 'all')
</div>\n"; </div>\n";
} }
$param = array(); $param = array();
$param['itemlink'] = (defined("NEWSLIST_ITEMLINK")) ? NEWSLIST_ITEMLINK : ""; $param['itemlink'] = (defined("NEWSLIST_ITEMLINK")) ? NEWSLIST_ITEMLINK : "";
$param['thumbnail'] =(defined("NEWSLIST_THUMB")) ? NEWSLIST_THUMB : "border:0px"; $param['thumbnail'] =(defined("NEWSLIST_THUMB")) ? NEWSLIST_THUMB : "border:0px";
$param['catlink'] = (defined("NEWSLIST_CATLINK")) ? NEWSLIST_CATLINK : ""; $param['catlink'] = (defined("NEWSLIST_CATLINK")) ? NEWSLIST_CATLINK : "";
$param['caticon'] = (defined("NEWSLIST_CATICON")) ? NEWSLIST_CATICON : ICONSTYLE; $param['caticon'] = (defined("NEWSLIST_CATICON")) ? NEWSLIST_CATICON : ICONSTYLE;
$param['current_action'] = $action; $param['current_action'] = $action;
foreach($newsList as $row) foreach($newsList as $row)
{ {
$text .= $ix->render_newsitem($row, 'return', '', $NEWSLISTSTYLE, $param); $text .= $ix->render_newsitem($row, 'return', '', $NEWSLISTSTYLE, $param);
@@ -241,7 +241,7 @@ if ($action == 'cat' || $action == 'all')
//------------------------------------------------------ //------------------------------------------------------
// DISPLAY SINGLE ITEM IN EXTENDED FORMAT HERE // DISPLAY SINGLE ITEM IN EXTENDED FORMAT HERE
//------------------------------------------------------ //------------------------------------------------------
if ($action == 'extend') if ($action == 'extend')
{ // --> Cache { // --> Cache
if($newsCachedPage = checkCache($cacheString)) if($newsCachedPage = checkCache($cacheString))
{ {
@@ -253,8 +253,8 @@ if ($action == 'extend')
if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled']) if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled'])
{ {
$query = " $query = "
SELECT COUNT(tb.trackback_pid) AS tb_count, n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, SELECT COUNT(tb.trackback_pid) AS tb_count, n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name,
nc.category_icon, nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols} nc.category_icon, nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols}
FROM #news AS n FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
@@ -269,37 +269,37 @@ if ($action == 'extend')
else else
{ {
$query = " $query = "
SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon, nc.category_meta_keywords, SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon, nc.category_meta_keywords,
nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols} nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols}
FROM #news AS n FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
{$rewrite_join} {$rewrite_join}
{$rewrite_join_cat} {$rewrite_join_cat}
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' WHERE n.news_class REGEXP '".e_CLASS_REGEXP."'
AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND NOT (n.news_class REGEXP ".$nobody_regexp.")
AND n.news_start < ".time()." AND n.news_start < ".time()."
AND (n.news_end=0 || n.news_end>".time().") AND (n.news_end=0 || n.news_end>".time().")
AND n.news_id=".intval($sub_action); AND n.news_id=".intval($sub_action);
} }
if ($sql->db_Select_gen($query)) if ($sql->db_Select_gen($query))
{ {
$news = $sql->db_Fetch(); $news = $sql->db_Fetch();
$id = $news['news_category']; // Use category of this news item to generate next/prev links $id = $news['news_category']; // Use category of this news item to generate next/prev links
//***NEW [SecretR] - comments handled inside now //***NEW [SecretR] - comments handled inside now
e107::setRegistry('news/page_allow_comments', !$news['news_allow_comments']); e107::setRegistry('news/page_allow_comments', !$news['news_allow_comments']);
if(!$news['news_allow_comments'] && isset($_POST['commentsubmit'])) if(!$news['news_allow_comments'] && isset($_POST['commentsubmit']))
{ {
$pid = intval(varset($_POST['pid'], 0)); // ID of the specific comment being edited (nested comments - replies) $pid = intval(varset($_POST['pid'], 0)); // ID of the specific comment being edited (nested comments - replies)
$clean_authorname = $_POST['author_name']; $clean_authorname = $_POST['author_name'];
$clean_comment = $_POST['comment']; $clean_comment = $_POST['comment'];
$clean_subject = $_POST['subject']; $clean_subject = $_POST['subject'];
e107::getSingleton('comment')->enter_comment($clean_authorname, $clean_comment, 'news', $sub_action, $pid, $clean_subject); e107::getSingleton('comment')->enter_comment($clean_authorname, $clean_comment, 'news', $sub_action, $pid, $clean_subject);
} }
//More SEO //More SEO
setNewsFrontMeta($news); setNewsFrontMeta($news);
/* /*
@@ -318,8 +318,8 @@ if ($action == 'extend')
if (!isset($news['news_extended'])) $news['news_extended'] = ''; if (!isset($news['news_extended'])) $news['news_extended'] = '';
$news['news_extended'].="<div style='text-align:center;'><a href='".e_SELF."?cat.".$id."'>".LAN_NEWS_85."</a> &nbsp; <a href='".e_SELF."'>".LAN_NEWS_84."</a></div>"; $news['news_extended'].="<div style='text-align:center;'><a href='".e_SELF."?cat.".$id."'>".LAN_NEWS_85."</a> &nbsp; <a href='".e_SELF."'>".LAN_NEWS_84."</a></div>";
$prev_query = "SELECT news_id, news_title FROM `#news` $prev_query = "SELECT news_id, news_title FROM `#news`
WHERE `news_id` < ".intval($sub_action)." AND `news_category`=".$id." AND `news_class` REGEXP '".e_CLASS_REGEXP."' WHERE `news_id` < ".intval($sub_action)." AND `news_category`=".$id." AND `news_class` REGEXP '".e_CLASS_REGEXP."'
AND NOT (`news_class` REGEXP ".$nobody_regexp.") AND NOT (`news_class` REGEXP ".$nobody_regexp.")
AND `news_start` < ".time()." AND (`news_end`=0 || `news_end` > ".time().') ORDER BY `news_id` DESC LIMIT 1'; AND `news_start` < ".time()." AND (`news_end`=0 || `news_end` > ".time().') ORDER BY `news_id` DESC LIMIT 1';
$sql->db_Select_gen($prev_query); $sql->db_Select_gen($prev_query);
$prev_news = $sql->db_Fetch(); $prev_news = $sql->db_Fetch();
@@ -328,8 +328,8 @@ if ($action == 'extend')
$news['news_extended'].="<div style='float:right;'><a href='".e_SELF."?extend.".$prev_news['news_id']."'>".LAN_NEWS_86."</a></div>"; $news['news_extended'].="<div style='float:right;'><a href='".e_SELF."?extend.".$prev_news['news_id']."'>".LAN_NEWS_86."</a></div>";
} }
$next_query = "SELECT news_id, news_title FROM `#news` AS n $next_query = "SELECT news_id, news_title FROM `#news` AS n
WHERE `news_id` > ".intval($sub_action)." AND `news_category` = ".$id." AND `news_class` REGEXP '".e_CLASS_REGEXP."' WHERE `news_id` > ".intval($sub_action)." AND `news_category` = ".$id." AND `news_class` REGEXP '".e_CLASS_REGEXP."'
AND NOT (`news_class` REGEXP ".$nobody_regexp.") AND NOT (`news_class` REGEXP ".$nobody_regexp.")
AND `news_start` < ".time()." AND (`news_end`=0 || `news_end` > ".time().') ORDER BY `news_id` ASC LIMIT 1'; AND `news_start` < ".time()." AND (`news_end`=0 || `news_end` > ".time().') ORDER BY `news_id` ASC LIMIT 1';
$sql->db_Select_gen($next_query); $sql->db_Select_gen($next_query);
$next_news = $sql->db_Fetch(); $next_news = $sql->db_Fetch();
@@ -341,10 +341,10 @@ if ($action == 'extend')
} }
require_once(HEADERF); require_once(HEADERF);
$param = array(); $param = array();
$param['current_action'] = $action; $param['current_action'] = $action;
ob_start(); ob_start();
$ix->render_newsitem($news, 'extend', '', '', $param); $ix->render_newsitem($news, 'extend', '', '', $param);
if(e107::getRegistry('news/page_allow_comments')) if(e107::getRegistry('news/page_allow_comments'))
@@ -384,7 +384,7 @@ switch ($action)
$sub_action = intval($sub_action); $sub_action = intval($sub_action);
// $news_total = $sql->db_Count("news", "(*)", "WHERE news_category={$sub_action} AND news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND news_start < ".time()." AND (news_end=0 || news_end>".time().")"); // $news_total = $sql->db_Count("news", "(*)", "WHERE news_category={$sub_action} AND news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND news_start < ".time()." AND (news_end=0 || news_end>".time().")");
$query = " $query = "
SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name,
nc.category_icon, nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols} nc.category_icon, nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols}
FROM #news AS n FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
@@ -404,7 +404,7 @@ switch ($action)
if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled']) if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled'])
{ {
$query = " $query = "
SELECT COUNT(tb.trackback_pid) AS tb_count, n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, SELECT COUNT(tb.trackback_pid) AS tb_count, n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name,
nc.category_icon, nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols} nc.category_icon, nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols}
FROM #news AS n FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
@@ -449,7 +449,7 @@ switch ($action)
$startdate = mktime(0, 0, 0, $month, $day, $year); $startdate = mktime(0, 0, 0, $month, $day, $year);
$enddate = mktime(23, 59, 59, $month, $lastday, $year); $enddate = mktime(23, 59, 59, $month, $lastday, $year);
$query = " $query = "
SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name,
nc.category_icon, nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols} nc.category_icon, nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols}
FROM #news AS n FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
@@ -477,8 +477,8 @@ switch ($action)
// Get number of news item to show // Get number of news item to show
if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled']) { if(isset($pref['trackbackEnabled']) && $pref['trackbackEnabled']) {
$query = " $query = "
SELECT SQL_CALC_FOUND_ROWS COUNT(tb.trackback_pid) AS tb_count, n.*, u.user_id, u.user_name, u.user_customtitle, SELECT SQL_CALC_FOUND_ROWS COUNT(tb.trackback_pid) AS tb_count, n.*, u.user_id, u.user_name, u.user_customtitle,
nc.category_name, nc.category_icon, nc.category_meta_keywords, nc.category_meta_description, nc.category_name, nc.category_icon, nc.category_meta_keywords, nc.category_meta_description,
COUNT(*) AS tbcount{$rewrite_cols_cat}{$rewrite_cols} COUNT(*) AS tbcount{$rewrite_cols_cat}{$rewrite_cols}
FROM #news AS n FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
@@ -495,7 +495,7 @@ switch ($action)
else else
{ {
$query = " $query = "
SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon, SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon,
nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols} nc.category_meta_keywords, nc.category_meta_description{$rewrite_cols_cat}{$rewrite_cols}
FROM #news AS n FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id LEFT JOIN #user AS u ON n.news_author = u.user_id
@@ -657,7 +657,7 @@ else
// #### normal newsitems, rendered via render_newsitem(), the $query is changed above (no other changes made) --------- // #### normal newsitems, rendered via render_newsitem(), the $query is changed above (no other changes made) ---------
$param = array(); $param = array();
$param['current_action'] = $action; $param['current_action'] = $action;
$i= 1; $i= 1;
while(isset($newsAr[$i]) && $i <= $interval) { while(isset($newsAr[$i]) && $i <= $interval) {
$news = $newsAr[$i]; $news = $newsAr[$i];
@@ -695,7 +695,7 @@ function show_newsarchive($newsAr, $i = 1)
global $ns, $gen, $pref, $tp, $news_archive_shortcodes, $NEWSARCHIVE, $news2; global $ns, $gen, $pref, $tp, $news_archive_shortcodes, $NEWSARCHIVE, $news2;
// do not show the news archive on the news.php?item.X page (but only on the news mainpage) // do not show the news archive on the news.php?item.X page (but only on the news mainpage)
require_once(e_FILE.'shortcode/batch/news_archives.php'); require_once(e_CORE.'shortcodes/batch/news_archives.php');
$textnewsarchive = ''; $textnewsarchive = '';
ob_start(); ob_start();
@@ -843,29 +843,29 @@ function setNewsFrontMeta($news, $type='news')
{ {
define('e_PAGETITLE', $news['news_title']); define('e_PAGETITLE', $news['news_title']);
} }
if($news['news_meta_keywords'] && !defined('META_KEYWORDS')) if($news['news_meta_keywords'] && !defined('META_KEYWORDS'))
{ {
define('META_KEYWORDS', $news['news_meta_keywords']); define('META_KEYWORDS', $news['news_meta_keywords']);
} }
if($news['news_meta_description'] && !defined('META_DESCRIPTION')) if($news['news_meta_description'] && !defined('META_DESCRIPTION'))
{ {
define('META_DESCRIPTION', $news['news_meta_description']); define('META_DESCRIPTION', $news['news_meta_description']);
} }
return; return;
} }
if($news['category_name'] && !defined('e_PAGETITLE')) if($news['category_name'] && !defined('e_PAGETITLE'))
{ {
define('e_PAGETITLE', $news['category_name']); define('e_PAGETITLE', $news['category_name']);
} }
if($news['category_meta_keywords'] && !defined('META_KEYWORDS')) if($news['category_meta_keywords'] && !defined('META_KEYWORDS'))
{ {
define('META_KEYWORDS', $news['category_meta_keywords']); define('META_KEYWORDS', $news['category_meta_keywords']);
} }
if($news['category_meta_description'] && !defined('META_DESCRIPTION')) if($news['category_meta_description'] && !defined('META_DESCRIPTION'))
{ {
define('META_DESCRIPTION', $news['category_meta_description']); define('META_DESCRIPTION', $news['category_meta_description']);

View File

@@ -39,9 +39,9 @@ require_once(e_HANDLER.'validator_class.php');
$userMethods = e107::getSession(); $userMethods = e107::getSession();
$userMethods->deleteExpired(); // Delete time-expired partial registrations $userMethods->deleteExpired(); // Delete time-expired partial registrations
require_once(e107::coreTemplatePath('signup')); //correct way to load a core template. require_once(e107::coreTemplatePath('signup')); //correct way to load a core template.
include_once(e_FILE.'shortcode/batch/signup_shortcodes.php'); include_once(e_CORE.'shortcodes/batch/signup_shortcodes.php');
$signup_imagecode = ($pref['signcode'] && extension_loaded('gd')); $signup_imagecode = ($pref['signcode'] && extension_loaded('gd'));
$text = ''; $text = '';
@@ -257,7 +257,7 @@ if($signup_imagecode)
if (USER || ($pref['user_reg'] == 0) || (vartrue($pref['auth_method'],'e107') != 'e107')) if (USER || ($pref['user_reg'] == 0) || (vartrue($pref['auth_method'],'e107') != 'e107'))
{ {
header('location: '.e_HTTP.'index.php'); header('location: '.e_HTTP.'index.php');
} }

View File

@@ -3,7 +3,7 @@
+ ----------------------------------------------------------------------------+ + ----------------------------------------------------------------------------+
| e107 website system | e107 website system
| |
| Copyright (C) 2008-2009 e107 Inc | Copyright (C) 2008-2009 e107 Inc
| http://e107.org | http://e107.org
| |
| |
@@ -28,7 +28,7 @@ header('Content-type: text/html; charset=utf-8');
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE); include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE);
require_once(e_FILE.'shortcode/batch/sitedown_shortcodes.php'); require_once(e_CORE.'shortcodes/batch/sitedown_shortcodes.php');
if (!$SITEDOWN_TABLE) if (!$SITEDOWN_TABLE)
{ {

View File

@@ -3,7 +3,7 @@
+ ----------------------------------------------------------------------------+ + ----------------------------------------------------------------------------+
| e107 website system | e107 website system
| |
| Copyright (C) 2008-2009 e107 Inc | Copyright (C) 2008-2009 e107 Inc
| http://e107.org | http://e107.org
| |
| |
@@ -19,7 +19,7 @@
require_once("class2.php"); require_once("class2.php");
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE); include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE);
if (!$pref['upload_enabled'] || $pref['upload_class'] == 255) if (!$pref['upload_enabled'] || $pref['upload_class'] == 255)
{ {
header("location: ".e_BASE."index.php"); header("location: ".e_BASE."index.php");
exit; exit;
@@ -29,7 +29,7 @@ require_once(HEADERF);
if (!defined("USER_WIDTH")){ define("USER_WIDTH","width:97%"); } if (!defined("USER_WIDTH")){ define("USER_WIDTH","width:97%"); }
if (!check_class($pref['upload_class'])) if (!check_class($pref['upload_class']))
{ {
$text = "<div style='text-align:center'>".LAN_UL_002."</div>"; $text = "<div style='text-align:center'>".LAN_UL_002."</div>";
$ns->tablerender(LAN_UL_020, $text); $ns->tablerender(LAN_UL_020, $text);
@@ -40,9 +40,9 @@ if (!check_class($pref['upload_class']))
$message = ''; $message = '';
$postemail =''; $postemail ='';
if (isset($_POST['upload'])) if (isset($_POST['upload']))
{ {
if (($_POST['file_email'] || USER == TRUE) && $_POST['file_name'] && $_POST['file_description'] && $_POST['download_category']) if (($_POST['file_email'] || USER == TRUE) && $_POST['file_name'] && $_POST['file_description'] && $_POST['download_category'])
{ {
require_once(e_HANDLER."upload_handler.php"); require_once(e_HANDLER."upload_handler.php");
// $uploaded = file_upload(e_FILE."public/", "unique"); // $uploaded = file_upload(e_FILE."public/", "unique");
@@ -53,7 +53,7 @@ if (isset($_POST['upload']))
{ {
$message = LAN_UL_021.'<br />'; $message = LAN_UL_021.'<br />';
} }
// Now see if we have a code file // Now see if we have a code file
if (count($uploaded) > 0) if (count($uploaded) > 0)
{ {
@@ -67,7 +67,7 @@ if (isset($_POST['upload']))
$message .= $uploaded[0]['message'].'<br />'; $message .= $uploaded[0]['message'].'<br />';
} }
} }
// Now see if we have an image file // Now see if we have an image file
if (count($uploaded) > 1) if (count($uploaded) > 1)
{ {
@@ -134,9 +134,9 @@ if (isset($_POST['upload']))
$e_event->trigger("fileupload", $edata_fu); $e_event->trigger("fileupload", $edata_fu);
$message .= "<br />".LAN_404; $message .= "<br />".LAN_404;
} }
} }
} }
else else
{ // Error - missing data { // Error - missing data
require_once(e_HANDLER."message_handler.php"); require_once(e_HANDLER."message_handler.php");
message_handler("ALERT", 5); message_handler("ALERT", 5);
@@ -163,7 +163,7 @@ $text = "<div style='text-align:center'>
<td class='forumheader3'>".DOWLAN_11.":</td> <td class='forumheader3'>".DOWLAN_11.":</td>
<td class='forumheader3'>"; <td class='forumheader3'>";
require_once(e_FILE."shortcode/batch/download_shortcodes.php"); require_once(e_CORE."shortcodes/batch/download_shortcodes.php");
$dlparm = (isset($download_category)) ? $download_category : ""; $dlparm = (isset($download_category)) ? $download_category : "";
$text .= $tp->parseTemplate("{DOWNLOAD_CATEGORY_SELECT={$dlparm}}",true,$download_shortcodes); $text .= $tp->parseTemplate("{DOWNLOAD_CATEGORY_SELECT={$dlparm}}",true,$download_shortcodes);
@@ -214,7 +214,7 @@ $text .= " ".$allowed_filetypes."<br />".LAN_407."<br />
$text .= "<span style='text-decoration:underline'>".LAN_408."</span> ".LAN_420."</td> $text .= "<span style='text-decoration:underline'>".LAN_408."</span> ".LAN_420."</td>
</tr>"; </tr>";
if (!USER) if (!USER)
{ // Prompt for name, email { // Prompt for name, email
$text .= "<tr> $text .= "<tr>
<td class='forumheader3'>".LAN_61."</td> <td class='forumheader3'>".LAN_61."</td>

View File

@@ -23,7 +23,7 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE);
global $user; global $user;
$user['user_id'] = USERID; $user['user_id'] = USERID;
require_once(e_FILE."shortcode/batch/user_shortcodes.php"); require_once(e_CORE."shortcodes/batch/user_shortcodes.php");
require_once(e_HANDLER."form_handler.php"); require_once(e_HANDLER."form_handler.php");
if (isset($_POST['delp'])) if (isset($_POST['delp']))

View File

@@ -32,13 +32,13 @@ define("US_DEBUG",FALSE);
//define('US_DEBUG', false); //define('US_DEBUG', false);
if (!USER) if (!USER)
{ // Must be logged in to change settings { // Must be logged in to change settings
header('location:'.e_BASE.'index.php'); header('location:'.e_BASE.'index.php');
exit(); exit();
} }
if ((!ADMIN || !getperms("4")) && e_QUERY && e_QUERY != "update" ) if ((!ADMIN || !getperms("4")) && e_QUERY && e_QUERY != "update" )
{ {
header('location:'.e_BASE.'usersettings.php'); header('location:'.e_BASE.'usersettings.php');
exit(); exit();
@@ -56,8 +56,8 @@ $ue = new e107_user_extended;
$userMethods = e107::getSession(); $userMethods = e107::getSession();
require_once (e_HANDLER.'ren_help.php'); require_once (e_HANDLER.'ren_help.php');
include_once (e107::coreTemplatePath('usersettings')); //correct way to load a core template. include_once (e107::coreTemplatePath('usersettings')); //correct way to load a core template.
include_once (e_FILE.'shortcode/batch/usersettings_shortcodes.php'); include_once (e_CORE.'shortcodes/batch/usersettings_shortcodes.php');
require_once (e_HANDLER.'calendar/calendar_class.php'); require_once (e_HANDLER.'calendar/calendar_class.php');
$cal = new DHTML_Calendar(true); $cal = new DHTML_Calendar(true);
@@ -284,7 +284,7 @@ if (isset($_POST['updatesettings']))
unset($changedUserData['user_loginname']); unset($changedUserData['user_loginname']);
} }
} }
else else
{ // Invalid data - from hooked in trigger event { // Invalid data - from hooked in trigger event
$message = "<div style='text-align:center'>".$ret."</div>"; $message = "<div style='text-align:center'>".$ret."</div>";
$caption = LAN_OK; $caption = LAN_OK;
@@ -297,7 +297,7 @@ elseif (isset($_POST['SaveValidatedInfo']))
if (!$adminEdit && !empty($_POST['updated_data']) && !empty($_POST['currentpassword']) && !empty($_POST['updated_key'])) if (!$adminEdit && !empty($_POST['updated_data']) && !empty($_POST['currentpassword']) && !empty($_POST['updated_key']))
{ // Got some data confirmed with password entry { // Got some data confirmed with password entry
$new_data = base64_decode($_POST['updated_data']); $new_data = base64_decode($_POST['updated_data']);
if (md5($new_data) != $_POST['updated_key']) if (md5($new_data) != $_POST['updated_key'])
{ // Should only happen if someone's fooling around { // Should only happen if someone's fooling around
echo 'Mismatch on validation key<br />'; echo 'Mismatch on validation key<br />';
exit(); exit();
@@ -306,7 +306,7 @@ elseif (isset($_POST['SaveValidatedInfo']))
if (isset($_POST['updated_extended'])) if (isset($_POST['updated_extended']))
{ {
$new_extended = base64_decode($_POST['updated_extended']); $new_extended = base64_decode($_POST['updated_extended']);
if (md5($new_extended) != $_POST['extended_key']) if (md5($new_extended) != $_POST['extended_key'])
{ // Should only happen if someone's fooling around { // Should only happen if someone's fooling around
echo 'Mismatch on validity key<br />'; echo 'Mismatch on validity key<br />';
exit(); exit();
@@ -369,7 +369,7 @@ if ($dataToSave)
} }
else else
{ {
if ((isset($changedUserData['user_loginname']) && $userMethods->isPasswordRequired('user_loginname')) if ((isset($changedUserData['user_loginname']) && $userMethods->isPasswordRequired('user_loginname'))
|| (isset($changedUserData['user_email']) && $userMethods->isPasswordRequired('user_email'))) || (isset($changedUserData['user_email']) && $userMethods->isPasswordRequired('user_email')))
{ {
if ($_uid) if ($_uid)
@@ -691,7 +691,7 @@ $ns->tablerender(LAN_USET_39, $text);
// If a field is required, returns a red asterisk // If a field is required, returns a red asterisk
function req($field) function req($field)
{ {
$ret = ""; $ret = "";
if ($field == 2) if ($field == 2)
@@ -710,12 +710,12 @@ function delete_file($fname, $dir = 'avatars/')
global $sql; global $sql;
$fname = trim($fname); $fname = trim($fname);
if (!$fname) return false; if (!$fname) return false;
if (preg_match("#Binary (.*?)/#", $fname, $match)) if (preg_match("#Binary (.*?)/#", $fname, $match))
{ {
return $sql -> db_Delete("rbinary", "binary_id='".$tp -> toDB($match[1])."'"); return $sql -> db_Delete("rbinary", "binary_id='".$tp -> toDB($match[1])."'");
} }
elseif (file_exists(e_UPLOAD.$dir.$fname)) elseif (file_exists(e_UPLOAD.$dir.$fname))
{ {
unlink(e_UPLOAD.$dir.$fname); unlink(e_UPLOAD.$dir.$fname);
return true; return true;
@@ -724,7 +724,7 @@ function delete_file($fname, $dir = 'avatars/')
} }
function headerjs() function headerjs()
{ {
global $cal; global $cal;
$script = "<script type=\"text/javascript\"> $script = "<script type=\"text/javascript\">