diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 904ac8538..09fe58352 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -9,8 +9,8 @@ * e107 Main * * $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $ - * $Revision: 1.87 $ - * $Date: 2009-11-28 15:34:46 $ + * $Revision: 1.88 $ + * $Date: 2009-12-02 16:51:02 $ * $Author: secretr $ */ @@ -26,16 +26,16 @@ class e107 * IPV6 string for localhost - as stored in DB */ const LOCALHOST_IP = '0000:0000:0000:0000:0000:ffff:7f00:0001'; - + public $server_path; - + public $e107_dirs = array(); - + /** * @var array SQL connection data */ protected $e107_config_mysql_info = array(); - + public $http_path; public $https_path; public $base_path; @@ -43,14 +43,14 @@ class e107 public $relative_base_path; public $_ip_cache; public $_host_name_cache; - + public $site_theme; - + /** * @var string Current request type (http or https) */ protected $HTTP_SCHEME; - + /** * Used for runtime caching of user extended struct * @@ -58,7 +58,7 @@ class e107 * @see get_user_data() */ public $extended_struct; - + /** * User login name * @@ -66,7 +66,7 @@ class e107 * @see init_session() */ public $currentUser = ''; - + /** * Run once load core shortcodes * while initialize SC parser @@ -74,42 +74,42 @@ class e107 * @var boolean */ protected static $_sc_core_loaded = false; - + /** * Singleton instance * Allow class extends - override {@link getInstance()} - * + * * @var e107 */ protected static $_instance = null; - + /** * e107 registry * * @var array */ private static $_registry = array(); - + /** * e107 core config object storage * * @var array */ protected static $_core_config_arr = array(); - + /** * e107 plugin config object storage * * @var array */ protected static $_plug_config_arr = array(); - + /** * Core handlers array - * For new/missing handler add + * For new/missing handler add * 'class name' => 'path' pair - * - * Used to auto-load core handlers + * + * Used to auto-load core handlers * TODO - we really need to alphabetically re-order this! * * @see getSingleton() @@ -159,28 +159,28 @@ class e107 'sitelinks' => '{e_HANDLER}sitelinks_class.php', 'redirection' => '{e_HANDLER}redirection_class.php' ); - + /** * Overload core handlers array * Format: 'core_class' => array('overload_class', 'overload_path'); - * + * * NOTE: to overload core singleton objects, you have to add record to * $_overload_handlers before the first singleton call. - * + * * Example: * array('e_form' => array('plugin_myplugin_form_handler' => '{e_PLUGIN}myplugin/includes/form/handler.php')); - * - * Used to auto-load core handlers - * - * @var array + * + * Used to auto-load core handlers + * + * @var array */ protected static $_overload_handlers = array(); - + /** * Constructor - * - * Use {@link getInstance()}, direct instantiating + * + * Use {@link getInstance()}, direct instantiating * is not possible for signleton objects * * @return void @@ -196,7 +196,7 @@ class e107 private function __clone() { } - + /** * Get singleton instance (php4 no more supported) * @@ -210,21 +210,21 @@ class e107 } return self::$_instance; } - + /** * Initialize environment path constants * Public proxy to the protected method {@link _init()} - * + * * @return e107 */ public function initCore($e107_paths, $e107_root_path, $e107_config_mysql_info) { return $this->_init($e107_paths, $e107_root_path, $e107_config_mysql_info); } - + /** * Resolve paths, will run only once - * + * * @return e107 */ protected function _init($e107_paths, $e107_root_path, $e107_config_mysql_info) @@ -236,35 +236,80 @@ class e107 // folder info $this->e107_dirs = $e107_paths; - + // mysql connection info $this->e107_config_mysql_info = $e107_config_mysql_info; - + // various constants - MAGIC_QUOTES_GPC, MPREFIX, ... $this->set_constants(); - + // build all paths $this->set_paths(); $this->file_path = $this->fix_windows_paths($e107_root_path)."/"; - + // set base path, SSL is auto-detected $this->set_base_path(false); - + // set some core URLs (e_LOGIN/SIGNUP) $this->set_urls(); - + // cleanup QUERY_STRING and friends, set related constants $this->set_request(); } return $this; } - + + /** + * Initialize environment path constants while installing e107 + * + * @return e107 + */ + public function initInstall($e107_paths, $e107_root_path) + { + // Do some security checks/cleanup, prepare the environment + $this->prepare_request(); + + // folder info + $this->e107_dirs = $e107_paths; + + // build all paths + $this->set_paths(); + $this->file_path = $this->fix_windows_paths($e107_root_path)."/"; + + // set base path, SSL is auto-detected + $this->set_base_path(false); + + // set some core URLs (e_LOGIN/SIGNUP) + $this->set_urls(); + + // cleanup QUERY_STRING and friends, set related constants + $this->set_request(); + + return $this; + } + + /** + * Set mysql data + * + * @return e107 + */ + public function initInstallSql($e107_config_mysql_info) + { + // mysql connection info + $this->e107_config_mysql_info = $e107_config_mysql_info; + + // various constants - MAGIC_QUOTES_GPC, MPREFIX, ... + $this->set_constants(); + + return $this; + } + /** * Get data from the registry * Returns $default if data not found * Replacement of cachevar() - * - * @param string $id + * + * @param string $id * @return mixed */ public static function getRegistry($id, $default = null) @@ -273,28 +318,28 @@ class e107 { return self::$_registry[$id]; } - + return $default; } - + /** * Add data to the registry - replacement of getcachedvars(). * $id is path-like unique id bind to the passed data. * If $data argument is null, $id will be removed from the registry. - * When removing objects from the registry, __destruct() method will be auto-executed + * When removing objects from the registry, __destruct() method will be auto-executed * if available - * + * * Naming standards (namespaces): * 'area/area_id/storage_type'
* where
* - area = 'core'|'plugin'|'external' (everything else) * - area_id = core handler id|plugin name (depends on area) * - (optional) storage_type = current data storage stack - * + * * Examples: * - 'core/e107/' - reserved for this class * - 'core/e107/singleton/' - singleton objects repo {@link getSingleton()} - * + * * @param string $id * @param mixed|null $data * @return void @@ -310,15 +355,15 @@ class e107 unset(self::$_registry[$id]); return; } - + if(!$allow_override && null !== self::getRegistry($id)) { return; } - + self::$_registry[$id] = $data; } - + /** * Get folder name (e107_config) * Replaces all $(*)_DIRECTORY globals @@ -332,7 +377,7 @@ class e107 $key = strtoupper($for).'_DIRECTORY'; return (isset($this->e107_dirs[$key]) ? $this->e107_dirs[$key] : ''); } - + /** * Get mysql config var (e107_config.php) * Replaces all $mySQL(*) globals @@ -346,10 +391,10 @@ class e107 $key = 'mySQL'.$for; return (isset($this->e107_config_mysql_info[$key]) ? $this->e107_config_mysql_info[$key] : ''); } - + /** * Get known handler path - * + * * @param string $class_name * @param boolean $parse_path [optional] parse path shortcodes * @return string|null @@ -361,14 +406,14 @@ class e107 { $ret = self::getParser()->replaceConstants($ret); } - + return $ret; } - + /** * Add handler to $_known_handlers array on runtime * If class name is array, method will add it (recursion) and ignore $path argument - * + * * @param array|string $class_name * @param string $path [optional] * @return void @@ -388,10 +433,10 @@ class e107 self::$_known_handlers[$class_name] = $path; } } - + /** * Check handler presence - * + * * @param string $class_name * @return boolean */ @@ -399,10 +444,10 @@ class e107 { return isset(self::$_known_handlers[$class_name]); } - + /** * Get overlod class and path (if any) - * + * * @param object $class_name * @param object $default_handler [optional] return data from $_known_handlers if no overload data available * @param object $parse_path [optional] parse path shortcodes @@ -418,12 +463,12 @@ class e107 return $ret; } - + /** * Overload present handler. - * If class name is array, method will add it (recursion) and + * If class name is array, method will add it (recursion) and * ignore $overload_class_name and $overload_path arguments - * + * * @param string $class_name * @param string $overload_name [optional] * @param string $overload_path [optional] @@ -444,10 +489,10 @@ class e107 self::$_overload_handlers[$class_name] = array($overload_class_name, $overload_path); } } - + /** * Check if handler is already overloaded - * + * * @param string $class_name * @return boolean */ @@ -455,7 +500,7 @@ class e107 { return isset(self::$_overload_handlers[$class_name]); } - + /** * Retrieve singleton object * @@ -467,13 +512,13 @@ class e107 public static function getSingleton($class_name, $path = true, $regpath = '') { $id = 'core/e107/singleton/'.$class_name.$regpath; - + //singleton object found - overload not possible if(self::getRegistry($id)) { return self::getRegistry($id); } - + //auto detection + overload check if(is_bool($path)) { @@ -503,7 +548,7 @@ class e107 return self::getRegistry($id); } - + /** * Retrieve object * Prepare for __autoload @@ -522,7 +567,7 @@ class e107 $path = self::getParser()->replaceConstants(self::$_known_handlers[$class_name]); } } - + //auto detection + overload check if(is_bool($path)) { @@ -539,12 +584,12 @@ class e107 $path = self::getHandlerPath($class_name); } } - + if($path && is_string($path) && !class_exists($class_name, false)) { e107_require_once($path); //no existence/security checks here! } - + if(class_exists($class_name, false)) { if(null !== $arguments) return new $class_name($arguments); @@ -554,7 +599,7 @@ class e107 trigger_error("Class {$class_name} not found!", E_USER_ERROR); return null; } - + /** * Retrieve core config handlers. * List of allowed $name values (aliases) could be found @@ -570,10 +615,10 @@ class e107 e107_require_once(e_HANDLER.'pref_class.php'); self::$_core_config_arr[$name] = new e_core_pref($name, true); } - + return self::$_core_config_arr[$name]; } - + /** * Retrieve core config handler preference value or the core preference array * Shorthand of self::getConfig()->get() @@ -587,7 +632,7 @@ class e107 { return empty($pref_name) ? self::getConfig()->getPref() : self::getConfig()->get($pref_name, $default); } - + /** * Advanced version of self::getPref(). $pref_name is parsed, * so that $pref_name = 'x/y/z' will search for value pref_data[x][y][z] @@ -602,7 +647,7 @@ class e107 { return self::getConfig()->getPref($pref_name, $default, $index); } - + /** * Retrieve plugin config handlers. * Multiple plugin preference DB rows are supported @@ -614,9 +659,9 @@ class e107 * - e107::getPluginConfig('myplug', 'row2'); * will search for e107_plugins/myplug/e_pref/myplug_row2_pref.php which * should contain class 'e_plugin_myplug_row2_pref' class (child of e_plugin_pref) - * + * * @param string $plug_name - * @param string $multi_row + * @param string $multi_row * @param boolean $load load from DB on startup * @return e_plugin_pref */ @@ -626,13 +671,13 @@ class e107 { e107_require_once(e_HANDLER.'pref_class.php'); $override_id = $plug_name.($multi_row ? "_{$multi_row}" : ''); - - //check (once) for custom plugin pref handler + + //check (once) for custom plugin pref handler if(is_readable(e_PLUGIN.$plug_name.'/e_pref/'.$override_id.'_pref.php')) { require_once(e_PLUGIN.$plug_name.'/e_pref/'.$override_id.'_pref.php'); $class_name = 'e_plugin_'.$override_id.'_pref'; - + //PHPVER: string parameter for is_subclass_of require PHP 5.0.3+ if(class_exists($class_name, false) && is_subclass_of('e_plugin_pref', $class_name)) //or e_pref ? { @@ -640,13 +685,13 @@ class e107 return self::$_plug_config_arr[$plug_name.$multi_row]; } } - + self::$_plug_config_arr[$plug_name.$multi_row] = new e_plugin_pref($plug_name, $multi_row, $load); } - + return self::$_plug_config_arr[$plug_name.$multi_row]; } - + /** * Retrieve plugin preference value. * Shorthand of self::getPluginConfig()->get() @@ -663,7 +708,7 @@ class e107 { return empty($pref_name) ? self::getPlugConfig($plug_name)->getPref() : self::getPlugConfig($plug_name)->get($pref_name, $default); } - + /** * Advanced version of self::getPlugPref(). $pref_name is parsed, * so that $pref_name = 'x/y/z' will search for value pref_data[x][y][z] @@ -678,7 +723,7 @@ class e107 { return self::getPlugConfig($plug_name)->getPref($pref_name, $default, $index); } - + /** * Get current theme preference. $pref_name is parsed, * so that $pref_name = 'x/y/z' will search for value pref_data[x][y][z] @@ -693,7 +738,7 @@ class e107 { return e107::getConfig()->getPref('sitetheme_pref/'.$pref_name, $default, $index); } - + /** * Retrieve text parser singleton object * @@ -703,9 +748,9 @@ class e107 { return self::getSingleton('e_parse', e_HANDLER.'e_parse_class.php'); } - - + + /** * Retrieve sc parser singleton object * @@ -713,17 +758,17 @@ class e107 */ public static function getScParser() { - $sc = self::getSingleton('e_shortcode', e_HANDLER.'shortcode_handler.php'); + $sc = self::getSingleton('e_shortcode', e_HANDLER.'shortcode_handler.php'); if(!self::$_sc_core_loaded) { $sc->loadCoreShortcodes(); self::$_sc_core_loaded = true; - } + } return $sc; } - + /** - * Retrieve DB singleton object based on the + * Retrieve DB singleton object based on the * $instance_id * * @param string $instance_id @@ -733,7 +778,7 @@ class e107 { return self::getSingleton('db', true, $instance_id); } - + /** * Retrieve event singleton object * @@ -743,7 +788,7 @@ class e107 { return self::getSingleton('ecache', true); } - + /** * Retrieve user class singleton object * @@ -763,9 +808,9 @@ class e107 public static function getRedirect() { return self::getSingleton('redirection', true); - } - - + } + + /** * Retrieve sitelinks singleton object * @@ -774,9 +819,9 @@ class e107 public static function getSitelinks() { return self::getSingleton('sitelinks', true); - } + } + - /** * Retrieve render singleton object * @@ -786,7 +831,7 @@ class e107 { return self::getSingleton('e107table'); } - + /** * Retrieve event singleton object * @@ -796,7 +841,7 @@ class e107 { return self::getSingleton('e107_event', true); } - + /** * Retrieve user-session singleton object * @@ -806,7 +851,7 @@ class e107 { return self::getSingleton('UserHandler', true); } - + /** * Retrieve array storage singleton object * @@ -816,7 +861,7 @@ class e107 { return self::getSingleton('ArrayData', true); } - + /** * Retrieve menu handler singleton object * @@ -826,7 +871,7 @@ class e107 { return self::getSingleton('e_menu', true); } - + /** * Retrieve URL singleton object * @@ -836,7 +881,7 @@ class e107 { return self::getSingleton('eURL', true); } - + /** * Retrieve file handler singleton or new fresh object * @@ -851,7 +896,7 @@ class e107 } return self::getObject('e_file', null, true); } - + /** * Retrieve form handler singleton or new fresh object * @@ -867,7 +912,7 @@ class e107 } return self::getObject('e_form', $tabindex, true); } - + /** * Retrieve admin log singleton object * @@ -887,7 +932,7 @@ class e107 { return self::getSingleton('convert', true); } - + /** * Retrieve notify handler singleton object * @@ -897,7 +942,7 @@ class e107 { return self::getSingleton('notify', true); } - + /** * Retrieve Xml handler singleton or new instance object * @param mixed $singleton false - new instance, true - singleton from default registry location, 'string' - registry path @@ -911,7 +956,7 @@ class e107 } return self::getObject('xmlClass', null, true); } - + /** * Retrieve User Extended handler singleton object * @return e107_user_extended @@ -920,7 +965,7 @@ class e107 { return self::getSingleton('e107_user_extended', true); } - + /** * Retrieve online users handler singleton object * @return e_online @@ -938,8 +983,8 @@ class e107 { return self::getSingleton('e_userperms', true); } - - + + /** * Retrieve comments handler singleton object * @return comment @@ -948,7 +993,7 @@ class e107 { return self::getSingleton('comment', true); } - + /** * Retrieve message handler singleton * @return eMessage @@ -963,7 +1008,7 @@ class e107 } return eMessage::getInstance(); } - + /** * Retrieve JS Manager singleton object * @@ -979,11 +1024,11 @@ class e107 } return e_jsmanager::getInstance(); } - + /** * Retrieve admin dispatcher instance. * It's instance is self registered (for now, this could change in the future) on initialization (__construct()) - * + * * @see e_admin_dispatcher * @return e_admin_dispatcher */ @@ -991,54 +1036,54 @@ class e107 { return self::getRegistry('admin/ui/dispatcher'); } - - - + + + /** * Retrieves config() from addons such as e_url.php, e_cron.php, e_sitelink.php * @param string $addonName eg. e_cron, e_url * @param string $className [optional] (if different from addonName) - * @return + * @return */ - public function getAddonConfig($addonName, $className = '') + public function getAddonConfig($addonName, $className = '') { $new_addon = array(); - + $filename = $addonName; // e.g. 'e_cron'; if(!$className) { $className = substr($filename, 2); // remove 'e_' - } - + } + $elist = self::getPref($filename.'_list'); if($elist) - { + { foreach(array_keys($elist) as $key) { if(is_readable(e_PLUGIN.$key.'/'.$filename.'.php')) { include_once(e_PLUGIN.$key.'/'.$filename.'.php'); - + $class_name = $key.'_'.$className; $array = self::callMethod($class_name, 'config'); - + if($array) { $new_addon[$key] = $array; } - + } } } - + return $new_addon; } /** - * Safe way to call user methods. + * Safe way to call user methods. * @param string $class_name * @param string $method_name - * @return + * @return */ public function callMethod($class_name, $method_name) { @@ -1054,15 +1099,15 @@ class e107 } else { - $mes->debug('Function '.$class_name.' :: '.$method_name.'() NOT found.'); - } + $mes->debug('Function '.$class_name.' :: '.$method_name.'() NOT found.'); + } } return FALSE; } /** * Get theme name or path. - * + * * @param mixed $for true (default) - auto-detect (current), admin - admin theme, front - site theme * @param string $path default empty string (return name only), 'abs' - absolute url path, 'rel' - relative server path * @return string @@ -1070,7 +1115,7 @@ class e107 public static function getThemeInfo($for = true, $path = '') { global $user_pref; // FIXME - user model, kill user_pref global - + if(true === $for) { $for = e_ADMIN_AREA ? 'admin' : 'front'; @@ -1080,7 +1125,7 @@ class e107 case 'admin': $for = e107::getPref('admintheme'); break; - + case 'front': $for = isset($user_pref['sitetheme']) ? $user_pref['sitetheme'] : e107::getPref('sitetheme'); break; @@ -1092,7 +1137,7 @@ class e107 case 'abs': $path = e_THEME_ABS.$for.'/'; break; - + case 'rel': default: $path = e_THEME.$for.'/'; @@ -1104,7 +1149,7 @@ class e107 /** * Retrieve core template path * Example: echo e107::coreTemplatePath('admin_icons'); - * + * * @see getThemeInfo() * @param string $id part of the path/file name without _template.php part * @param boolean $override default true @@ -1115,23 +1160,23 @@ class e107 $id = str_replace('..', '', $id); //simple security, '/' is allowed $override_path = $override ? self::getThemeInfo($override, 'rel').'templates/'.$id.'_template.php' : null; $default_path = e_THEME.'templates/'.$id.'_template.php'; - + return ($override_path && is_readable($override_path) ? $override_path : $default_path); } - + /** * Retrieve plugin template path - * Override path could be forced to front- or back-end via + * Override path could be forced to front- or back-end via * the $override parameter e.g. e107::templatePath(plug_name, 'my', 'front') - * Example: + * Example: * * echo e107::templatePath(plug_name, 'my'); * // result is something like: * // e107_themes/current_theme/templates/plug_name/my_template.php - * // or if not found + * // or if not found * // e107_plugins/plug_name/templates/my_template.php * - * + * * @see getThemeInfo() * @param string $plug_name plugin name * @param string $id part of the path/file name without _template.php part @@ -1147,62 +1192,62 @@ class e107 return ($override_path && is_readable($override_path) ? $override_path : $default_path); } - + /** - * Get core template. Use this method for templates, which are following the + * Get core template. Use this method for templates, which are following the * new template standards: * - template variables naming conventions * - one array variable per template only * - theme override is made now by current_theme/templates/ folder - * + * *

Results are cached (depending on $id and $override so it's safe to use - * this method e.g. in loop for retrieving a template string. If template (or template key) is not + * this method e.g. in loop for retrieving a template string. If template (or template key) is not * found, NULL is returned.

- * + * * Example usage: e107::getCoreTemplate('user', 'short_start'); * Will search for: * - e107_themes/current_frontend_theme/templates/user_template.php (if $override is true) * - e107_themes/templates/user_template.php (if override not found or $override is false) * - $USER_TEMPLATE array which contains all user templates * - $USER_TEMPLATE['short_start'] (if key is null, $USER_TEMPLATE will be returned) - * + * * @param string $id - file prefix, e.g. user for user_template.php * @param string|null $key * @param boolean $override see {@link getThemeInfo()) - * + * * @return string|array */ public static function getCoreTemplate($id, $key = null, $override = true) { $reg_path = 'core/e107/templates/'.$id.($override ? '/ext' : ''); $path = self::coreTemplatePath($id, $override); - + return self::_getTemplate($id, $key, $reg_path, $path); } - + /** - * Get plugin template. Use this method for plugin templates, which are following the + * Get plugin template. Use this method for plugin templates, which are following the * new template standards: * - template variables naming conventions * - one array variable per template only * - theme override is made now by current_theme/templates/plugin_name/ folder - * + * *

Results are cached (depending on $id and $override so it's safe to use - * this method e.g. in loop for retrieving a template string. If template (or template key) is not + * this method e.g. in loop for retrieving a template string. If template (or template key) is not * found, NULL is returned.

- * + * * Example usage: e107::getTemplate('user', 'short_start'); * Will search for: * - e107_themes/current_frontend_theme/templates/user_template.php (if $override is true) * - e107_themes/templates/user_template.php (if override not found or $override is false) * - $USER_TEMPLATE array which contains all user templates * - $USER_TEMPLATE['short_start'] (if key is null, $USER_TEMPLATE will be returned) - * + * * @param string $plug_name * @param string $id - file prefix, e.g. calendar for calendar_template.php * @param string|null $key * @param boolean $override see {@link getThemeInfo()) - * + * * @return string|array */ public static function getTemplate($plug_name, $id, $key = null, $override = true) @@ -1218,7 +1263,7 @@ class e107 * @param string $plugin_name * @param string $template_id [optional] if different from $plugin_name; * @param mixed $where true - current theme, 'admin' - admin theme, 'front' (default) - front theme - * @return array + * @return array */ public static function getLayouts($plugin_name, $template_id = '', $where = 'front', $filter_mask = '') { @@ -1231,7 +1276,7 @@ class e107 $id = (!$template_id) ? $plugin_name : $template_id; $tmp = self::getTemplate($plugin_name, $id, null, $where); } - + $templates = array(); $filter_mask = explode($filter_mask); foreach($tmp as $key => $val) @@ -1259,10 +1304,10 @@ class e107 { $templates[$key] = defset($val['__INFO__'][$key]['title'], $val['__INFO__'][$key]['title']); continue; - } + } $templates[$key] = implode(' ', array_map('ucfirst', explode('_', $key))); //TODO add LANS? } - return $templates; + return $templates; } /** @@ -1280,13 +1325,13 @@ class e107 { $regPath = $reg_path; $var = strtoupper($id).'_TEMPLATE'; - + if(null === self::getRegistry($regPath)) { (deftrue('E107_DEBUG_LEVEL') ? include_once($path) : @include_once($path)); self::setRegistry($regPath, (isset($$var) ? $$var : array())); } - + if(!$key) { return self::getRegistry($regPath); @@ -1294,7 +1339,7 @@ class e107 $ret = self::getRegistry($regPath); return ($ret && is_array($ret) && isset($ret[$key]) ? $ret[$key] : $ret); } - + /** * Load language file, replacement of include_lan() * @@ -1317,20 +1362,20 @@ class e107 } /** - * Routine looks in standard paths for language files associated with a plugin or + * Routine looks in standard paths for language files associated with a plugin or * theme - primarily for core routines, which won't know for sure where the author has put them. * $unitName is the name (directory path) of the plugin or theme * $type determines what is to be loaded: * - 'runtime' - the standard runtime language file for a plugin * - 'admin' - the standard admin language file for a plugin * - 'theme' - the standard language file for a plugin (these are usually pretty small, so one is enough) - * Otherwise, $type is treated as part of a filename within the plugin's language directory, - * prefixed with the current language. + * Otherwise, $type is treated as part of a filename within the plugin's language directory, + * prefixed with the current language. * Returns FALSE on failure (not found). * Returns the include_once error return if there is one * Otherwise returns an empty string. * Note - if the code knows precisely where the language file is located, use {@link getLan()} - * $pref['noLanguageSubs'] can be set TRUE to prevent searching for the English files if + * $pref['noLanguageSubs'] can be set TRUE to prevent searching for the English files if * the files for the current site language don't exist. * * @param string $unitName @@ -1345,7 +1390,7 @@ class e107 case 'runtime' : $searchPath[1] = e_PLUGIN.$unitName.'/languages/'.e_LANGUAGE.'_'.$unitName.'.php'; $searchPath[2] = e_PLUGIN.$unitName.'/languages/'.e_LANGUAGE.'/'.$unitName.'.php'; - $searchPath[3] = e_PLUGIN.$unitName.'/languages/'.e_LANGUAGE.'.php'; // menu language file. + $searchPath[3] = e_PLUGIN.$unitName.'/languages/'.e_LANGUAGE.'.php'; // menu language file. break; case 'admin' : $searchPath[1] = e_PLUGIN.$unitName.'/languages/'.e_LANGUAGE.'_admin_'.$unitName.'.php'; @@ -1372,7 +1417,7 @@ class e107 { return FALSE; // No point looking for the English files twice } - + foreach ($searchPath as $s) // Now look for the English files { $s = str_replace(e_LANGUAGE, 'English', $s); @@ -1384,18 +1429,18 @@ class e107 } return FALSE; // Nothing found } - + /** * Prepare e107 environment * This is done before e107_dirs initilization and [TODO] config include * @return e107 */ public function prepare_request() - { + { // TODO - better ajax detection method (headers when possible) 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... + //$GLOBALS['_E107'] - minimal mode - here because of the e_AJAX_REQUEST if(isset($GLOBALS['_E107']['minimal']) || e_AJAX_REQUEST) { @@ -1410,10 +1455,10 @@ class e107 unset($GLOBALS['_E107'][$v]); } } - + // remove ajax_used=1 from query string to avoid SELF problems, ajax should always be detected via e_AJAX_REQUEST constant $_SERVER['QUERY_STRING'] = str_replace(array('ajax_used=1', '&&'), array('', '&'), $_SERVER['QUERY_STRING']); - + // e107 uses relative url's, which are broken by "pretty" URL's. So for now we don't support / after .php if(($pos = strpos($_SERVER['PHP_SELF'], '.php/')) !== false) // redirect bad URLs to the correct one. { @@ -1431,7 +1476,7 @@ class e107 e107::ini_set('arg_separator.output', '&'); e107::ini_set('session.use_only_cookies', 1); e107::ini_set('session.use_trans_sid', 0); - + // Ensure thet '.' is the first part of the include path $inc_path = explode(PATH_SEPARATOR, ini_get('include_path')); if($inc_path[0] != '.') @@ -1441,10 +1486,10 @@ class e107 e107_ini_set('include_path', $inc_path); } unset($inc_path); - + return $this; } - + /** * Set base system path * @return e107 @@ -1455,7 +1500,7 @@ class e107 $this->base_path = $ssl_enabled ? $this->https_path : $this->http_path; return $this; } - + /** * Set various system environment constants * @return e107 @@ -1463,11 +1508,11 @@ class e107 public function set_constants() { define('MAGIC_QUOTES_GPC', (ini_get('magic_quotes_gpc') ? true : false)); - + define('MPREFIX', $this->getMySQLConfig('prefix')); // mysql prefix - + define('CHARSET', 'utf-8'); // set CHARSET for backward compatibility - + // Define the domain name and subdomain name. if($_SERVER['HTTP_HOST'] && is_numeric(str_replace(".","",$_SERVER['HTTP_HOST']))) { @@ -1477,16 +1522,16 @@ class e107 { $srvtmp = explode('.',str_replace('www.', '', $_SERVER['HTTP_HOST'])); } - + define('e_SUBDOMAIN', (count($srvtmp)>2 && $srvtmp[2] ? $srvtmp[0] : false)); // needs to be available to e107_config. - + if(e_SUBDOMAIN) { unset($srvtmp[0]); } - + define('e_DOMAIN',(count($srvtmp) > 1 ? (implode('.', $srvtmp)) : false)); // if it's an IP it must be set to false. - + define('e_UC_PUBLIC', 0); define('e_UC_MAINADMIN', 250); define('e_UC_READONLY', 251); @@ -1494,7 +1539,7 @@ class e107 define('e_UC_MEMBER', 253); define('e_UC_ADMIN', 254); define('e_UC_NOBODY', 255); - + return $this; } @@ -1509,15 +1554,15 @@ class e107 $FILES_DIRECTORY, $HANDLERS_DIRECTORY, $LANGUAGES_DIRECTORY, $HELP_DIRECTORY, $CACHE_DIRECTORY, $UPLOADS_DIRECTORY,$_E107, $MEDIA_DIRECTORY; - // global $NEWSIMAGES_DIRECTORY, $CUSTIMAGES_DIRECTORY; - + // global $NEWSIMAGES_DIRECTORY, $CUSTIMAGES_DIRECTORY; + // ssl_enabled pref not needed anymore, scheme is auto-detected $this->HTTP_SCHEME = 'http'; if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { $this->HTTP_SCHEME = 'https'; } - + $path = ""; $i = 0; if(!isset($_E107['cli'])) @@ -1566,9 +1611,9 @@ class e107 // HTTP relative paths // - if(!varset($MEDIA_DIRECTORY)) // BC/Upgrade Fix. + if(!varset($MEDIA_DIRECTORY)) // BC/Upgrade Fix. { - $MEDIA_DIRECTORY = 'e107_media/'; + $MEDIA_DIRECTORY = 'e107_media/'; } define("e_ADMIN", e_BASE.$ADMIN_DIRECTORY); @@ -1615,7 +1660,7 @@ class e107 define("e_CACHE", e_MEDIA."cache/"); } /* - + if($NEWSIMAGES_DIRECTORY) { define("e_NEWSIMAGE", e_BASE.$NEWSIMAGES_DIRECTORY); @@ -1692,9 +1737,9 @@ class e107 $PLUGINS_DIRECTORY = $this->getFolder('plugins'); $ADMIN_DIRECTORY = $this->getFolder('admin'); $eplug_admin = vartrue($GLOBALS['eplug_admin'], false); - + $page = substr(strrchr($_SERVER['PHP_SELF'], '/'), 1); - + define('e_PAGE', $page); define('e_SELF', $this->HTTP_SCHEME . '://' . $_SERVER['HTTP_HOST'] . ($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_FILENAME'])); @@ -1707,27 +1752,27 @@ class e107 $inAdminDir = FALSE; $isPluginDir = strpos(e_SELF,'/'.$PLUGINS_DIRECTORY) !== FALSE; // True if we're in a plugin $e107Path = str_replace($this->base_path, '', e_SELF); // Knock off the initial bits - + if ( (!$isPluginDir && strpos($e107Path, $ADMIN_DIRECTORY) === 0 ) // Core admin directory || ($isPluginDir && (strpos(e_PAGE,'admin_') === 0 || strpos($e107Path, 'admin/') !== FALSE)) // Plugin admin file or directory || (varsettrue($eplug_admin) || defsettrue('ADMIN_AREA')) // Admin forced ) { - $inAdminDir = TRUE; + $inAdminDir = TRUE; } - + // This should avoid further checks - NOTE: used in js_manager.php define('e_ADMIN_AREA', ($inAdminDir && !deftrue('USER_AREA'))); //Force USER_AREA added - + define('ADMINDIR', $ADMIN_DIRECTORY); - + define('SITEURLBASE', $this->HTTP_SCHEME.'://'.$_SERVER['HTTP_HOST']); define('SITEURL', SITEURLBASE.e_HTTP); - + return $this; } - + /** * Set request related constants * @return e107 @@ -1745,7 +1790,7 @@ class e107 } } } - + if (strpos($_SERVER['QUERY_STRING'], ']') && preg_match("#\[(.*?)](.*)#", $_SERVER['QUERY_STRING'], $matches)) { define('e_MENU', $matches[1]); @@ -1764,26 +1809,26 @@ class e107 $e_QUERY = $_SERVER['QUERY_STRING']; define('e_LANCODE', ''); } - + $e_QUERY = str_replace("&","&", self::getParser()->post_toForm($e_QUERY)); define('e_QUERY', $e_QUERY); - + define('e_TBQS', $_SERVER['QUERY_STRING']); $_SERVER['QUERY_STRING'] = e_QUERY; } - + /** * Check if current request is secure (https) - * @return + * @return */ public function isSecure() { return ($this->HTTP_SCHEME === 'https'); } - + /** * Check if current user is banned - * + * * Generates the queries to interrogate the ban list, then calls $this->check_ban(). * If the user is banned, $check_ban() never returns - so a return from this routine indicates a non-banned user. * @@ -1841,7 +1886,7 @@ class e107 * If $do_return, will always return with ban status - TRUE for OK, FALSE for banned. * If return permitted, will never display a message for a banned user; otherwise will display any message then exit * XXX - clean up - * + * * @param string $query * @param boolean $show_error * @param boolean $do_return @@ -1895,13 +1940,13 @@ class e107 * Returns TRUE if ban accepted. * Returns FALSE if ban not accepted (i.e. because on whitelist, or invalid IP specified) * FIXME - remove $admin_log global, add admin_log method getter instead - * + * * @param string $bantype * @param string $ban_message * @param string $ban_ip * @param integer $ban_user * @param string $ban_notes - * + * * @return boolean check result */ public function add_ban($bantype, $ban_message = '', $ban_ip = '', $ban_user = 0, $ban_notes = '') @@ -1939,7 +1984,7 @@ class e107 /** * Get the current user's IP address * returns the address in internal 'normalised' IPV6 format - so most code should continue to work provided the DB Field is big enougn - * + * * @return string */ public function getip() @@ -1960,7 +2005,7 @@ class e107 '#^169\.254\..*#' , // RFC3330 - Link-local, auto-DHCP '#^2(?:2[456789]|[345][0-9])\..*#' ); // Single check for Class D and Class E - + $ip = preg_replace($ip2, $ip, $ip3[1]); } } @@ -1980,7 +2025,7 @@ class e107 /** * Encode an IP address to internal representation. Returns string if successful; FALSE on error * Default separates fields with ':'; set $div='' to produce a 32-char packed hex string - * + * * @param string $ip * @param string $div divider * @return string encoded IP @@ -2031,7 +2076,7 @@ class e107 /** * Takes an encoded IP address - returns a displayable one - * Set $IP4Legacy TRUE to display 'old' (IPv4) addresses in the familiar dotted format, + * Set $IP4Legacy TRUE to display 'old' (IPv4) addresses in the familiar dotted format, * FALSE to display in standard IPV6 format * Should handle most things that can be thrown at it. * @@ -2099,7 +2144,7 @@ class e107 return $ret; } - + /** * Given a string which may be IP address, email address etc, tries to work out what it is * @@ -2138,10 +2183,10 @@ class e107 * Return a memory value formatted helpfully * $dp overrides the number of decimal places displayed - realistically, only 0..3 are sensible * FIXME e107->parseMemorySize() START - * - maybe we are in need of General Helper handler, this + the above ban/ip related methods + * - maybe we are in need of General Helper handler, this + the above ban/ip related methods * are not fitting e107 class logic anymore - * - change access to public static - more useful - * - out of (integer) range case? + * - change access to public static - more useful + * - out of (integer) range case? * 32 bit systems range: -2147483648 to 2147483647 * 64 bit systems range: -9223372036854775808 9223372036854775807 * {@link http://www.php.net/intval} @@ -2184,7 +2229,7 @@ class e107 /** * Get the current memory usage of the code * If $separator argument is null, raw data (array) will be returned - * + * * @param null|string $separator * @return string|array memory usage */ @@ -2201,10 +2246,10 @@ class e107 { $ret[] = 'Unknown'; } - + return (null !== $separator ? implode($separator, $ret) : $ret); } - + /** * Check if plugin is installed * @param string $plugname @@ -2215,12 +2260,12 @@ class e107 // Could add more checks here later if appropriate return self::getConfig()->isData('plug_installed/'.$plugname); } - + /** * Safe way to set ini var * @param string $var * @param string $value - * @return + * @return */ public static function ini_set($var, $value) { @@ -2233,32 +2278,32 @@ class e107 public function __get($name) { - switch ($name) + switch ($name) { case 'tp': $ret = e107::getParser(); break; - + case 'sql': $ret = e107::getDb(); break; - + case 'ecache': $ret = e107::getCache(); break; - + case 'arrayStorage': $ret = e107::getArrayStorage(); break; - + case 'e_event': $ret = e107::getEvent(); break; - + case 'ns': $ret = e107::getRender(); break; - + case 'url': $ret = e107::getUrl(); break; @@ -2270,25 +2315,25 @@ class e107 case 'override': $ret = e107::getSingleton('override', e_HANDLER.'override_class.php'); break; - + case 'notify': $ret = e107::getNotify(); break; - + case 'e_online': $ret = e107::getOnline(); break; - + case 'user_class': $ret = e107::getUserClass(); break; - + default: trigger_error('$e107->$'.$name.' not defined', E_USER_WARNING); - return null; + return null; break; } - + $this->{$name} = $ret; return $ret; } diff --git a/e107_handlers/mysql_class.php b/e107_handlers/mysql_class.php index b8ebd2803..bbcb5a069 100644 --- a/e107_handlers/mysql_class.php +++ b/e107_handlers/mysql_class.php @@ -9,9 +9,9 @@ * mySQL Handler * * $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $ - * $Revision: 1.67 $ - * $Date: 2009-12-01 20:05:54 $ - * $Author: e107steved $ + * $Revision: 1.68 $ + * $Date: 2009-12-02 16:51:00 $ + * $Author: secretr $ */ if(defined('MYSQL_LIGHT')) @@ -24,13 +24,15 @@ if(defined('MYSQL_LIGHT')) $sql = new db; $sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb); } -elseif(defined('E107_INSTALL')) +elseif(defined('E107_INSTALL')) { define('E107_DEBUG_LEVEL', 0); - define('e_QUERY', ''); - require_once("e107_config.php"); - define('MPREFIX', $mySQLprefix); - + //define('e_QUERY', ''); + //require_once("e107_config.php"); + //define('MPREFIX', $mySQLprefix); + require('e107_config.php'); + $sql_info = compact('mySQLserver', 'mySQLuser', 'mySQLpassword', 'mySQLdefaultdb', 'mySQLprefix'); + e107::getInstance()->initInstallSql($sql_info); $sql = new db; $sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb); } @@ -46,12 +48,12 @@ $db_ConnectionID = NULL; // Stores ID for the first DB connection used - which s /** * MySQL Abstraction class - * + * * @package e107 * @category e107_handlers - * @version $Revision: 1.67 $ - * @author $Author: e107steved $ - * + * @version $Revision: 1.68 $ + * @author $Author: secretr $ + * */ class e_db_mysql { @@ -70,13 +72,13 @@ class e_db_mysql { var $mySQLlanguage; var $mySQLinfo; var $tabset; - var $mySQLtableList = array(); // list of all Db tables. + var $mySQLtableList = array(); // list of all Db tables. var $mySQLtableListLanguage = array(); // Db table list for the currently selected language /** * MySQL Charset - * + * * @var string */ public $mySQLcharset; @@ -89,12 +91,12 @@ class e_db_mysql { */ public function __construct() { - + global $pref, $db_defaultPrefix; - e107::getSingleton('e107_traffic')->BumpWho('Create db object', 1); - + e107::getSingleton('e107_traffic')->BumpWho('Create db object', 1); + $this->mySQLPrefix = MPREFIX; // Set the default prefix - may be overridden - + $langid = (isset($pref['cookie_name'])) ? 'e107language_'.$pref['cookie_name'] : 'e107language_temp'; if (isset($pref['user_tracking']) && ($pref['user_tracking'] == 'session')) { @@ -168,7 +170,7 @@ class e_db_mysql { $this->dbError('dbConnect/SelectDB'); // Save the connection resource - if ($db_ConnectionID == NULL) + if ($db_ConnectionID == NULL) $db_ConnectionID = $this->mySQLaccess; return TRUE; } @@ -195,7 +197,7 @@ class e_db_mysql { * @desc Enter description here... * @access private */ - function db_Show_Performance() + function db_Show_Performance() { return $db_debug->Show_Performance(); } @@ -206,7 +208,7 @@ class e_db_mysql { * @desc add query to dblog table * @access private */ - function db_Write_log($log_type = '', $log_remark = '', $log_query = '') + function db_Write_log($log_type = '', $log_remark = '', $log_query = '') { global $tp, $e107; list($time_usec, $time_sec) = explode(" ", microtime()); @@ -220,7 +222,7 @@ class e_db_mysql { /** * This is the 'core' routine which handles much of the interface between other functions and the DB - * + * * If a SELECT query includes SQL_CALC_FOUND_ROWS, the value of FOUND_ROWS() is retrieved and stored in $this->total_results * @param string $query * @param unknown $rli @@ -229,12 +231,12 @@ class e_db_mysql { * For SELECT, SHOW, DESCRIBE, EXPLAIN and others returning a result set, returns a resource * TRUE indicates success in other cases */ - public function db_Query($query, $rli = NULL, $qry_from = '', $debug = FALSE, $log_type = '', $log_remark = '') + public function db_Query($query, $rli = NULL, $qry_from = '', $debug = FALSE, $log_type = '', $log_remark = '') { global $db_time,$db_mySQLQueryCount,$queryinfo; $db_mySQLQueryCount++; - if ($debug == 'now') + if ($debug == 'now') { echo "** $query
\n"; } @@ -242,7 +244,7 @@ class e_db_mysql { { $queryinfo[] = "{$qry_from}: $query"; } - if ($log_type != '') + if ($log_type != '') { $this->db_Write_log($log_type, $log_remark, $query); } @@ -270,7 +272,7 @@ class e_db_mysql { $this->total_results = $rc['FOUND_ROWS()']; } - if (E107_DEBUG_LEVEL) + if (E107_DEBUG_LEVEL) { global $db_debug; $aTrace = debug_backtrace(); @@ -280,12 +282,12 @@ class e_db_mysql { } else { $this->mySQLcurTable = ''; // clear before next query } - if(is_object($db_debug)) + if(is_object($db_debug)) { $buglink = is_null($rli) ? $this->mySQLaccess : $rli; $nFields = $db_debug->Mark_Query($query, $buglink, $sQryRes, $aTrace, $mytime, $pTable); - } - else + } + else { echo "what happened to db_debug??!!
"; } @@ -317,38 +319,38 @@ class e_db_mysql { $this->mySQLcurTable = $table; if ($arg != '' && $mode == 'default') { - if ($this->mySQLresult = $this->db_Query('SELECT '.$fields.' FROM '.$this->mySQLPrefix.$table.' WHERE '.$arg, NULL, 'db_Select', $debug, $log_type, $log_remark)) + if ($this->mySQLresult = $this->db_Query('SELECT '.$fields.' FROM '.$this->mySQLPrefix.$table.' WHERE '.$arg, NULL, 'db_Select', $debug, $log_type, $log_remark)) { $this->dbError('dbQuery'); return $this->db_Rows(); - } - else + } + else { $this->dbError("db_Select (SELECT $fields FROM ".$this->mySQLPrefix."{$table} WHERE {$arg})"); return FALSE; } - } - elseif ($arg != '' && $mode != 'default') + } + elseif ($arg != '' && $mode != 'default') { - if ($this->mySQLresult = $this->db_Query('SELECT '.$fields.' FROM '.$this->mySQLPrefix.$table.' '.$arg, NULL, 'db_Select', $debug, $log_type, $log_remark)) + if ($this->mySQLresult = $this->db_Query('SELECT '.$fields.' FROM '.$this->mySQLPrefix.$table.' '.$arg, NULL, 'db_Select', $debug, $log_type, $log_remark)) { $this->dbError('dbQuery'); return $this->db_Rows(); - } - else + } + else { $this->dbError("db_Select (SELECT {$fields} FROM ".$this->mySQLPrefix."{$table} {$arg})"); return FALSE; } - } - else + } + else { - if ($this->mySQLresult = $this->db_Query('SELECT '.$fields.' FROM '.$this->mySQLPrefix.$table, NULL, 'db_Select', $debug, $log_type, $log_remark)) + if ($this->mySQLresult = $this->db_Query('SELECT '.$fields.' FROM '.$this->mySQLPrefix.$table, NULL, 'db_Select', $debug, $log_type, $log_remark)) { $this->dbError('dbQuery'); return $this->db_Rows(); - } - else + } + else { $this->dbError("db_Select (SELECT {$fields} FROM ".$this->mySQLPrefix."{$table})"); return FALSE; @@ -375,20 +377,20 @@ class e_db_mysql { $this->mySQLcurTable = $table; if(is_array($arg)) { - if(isset($arg['WHERE'])) // use same array for update and insert. + if(isset($arg['WHERE'])) // use same array for update and insert. { unset($arg['WHERE']); } if(isset($arg['_REPLACE'])) { $REPLACE = TRUE; - unset($arg['_REPLACE']); + unset($arg['_REPLACE']); } else { - $REPLACE = FALSE; + $REPLACE = FALSE; } - + if(!isset($arg['_FIELD_TYPES']) && !isset($arg['data'])) { //Convert data if not using 'new' format @@ -421,16 +423,16 @@ class e_db_mysql { } $valList= implode(', ', $tmp); unset($tmp); - + if($REPLACE === FALSE) { - $query = "INSERT INTO `".$this->mySQLPrefix."{$table}` ({$keyList}) VALUES ({$valList})"; + $query = "INSERT INTO `".$this->mySQLPrefix."{$table}` ({$keyList}) VALUES ({$valList})"; } else { - $query = "REPLACE INTO `".$this->mySQLPrefix."{$table}` ({$keyList}) VALUES ({$valList})"; + $query = "REPLACE INTO `".$this->mySQLPrefix."{$table}` ({$keyList}) VALUES ({$valList})"; } - + } else { @@ -471,7 +473,7 @@ class e_db_mysql { function db_Replace($table, $arg, $debug = FALSE, $log_type = '', $log_remark = '') { $arg['_REPLACE'] = TRUE; - return $this->db_Insert($table, $arg, $debug, $log_type, $log_remark); + return $this->db_Insert($table, $arg, $debug, $log_type, $log_remark); } @@ -503,7 +505,7 @@ class e_db_mysql { global $db_ConnectionID; $this->mySQLaccess = $db_ConnectionID; } - + if (is_array($arg)) // Remove the need for a separate db_UpdateArray() function. { $new_data = ''; @@ -592,11 +594,11 @@ class e_db_mysql { case 'string': return "'{$fieldValue}'"; break; - - case 'float': + + case 'float': return (float) $fieldValue; break; - + case 'null': return ($fieldValue && $fieldValue !== 'NULL' ? "'{$fieldValue}'" : 'NULL'); break; @@ -668,9 +670,9 @@ class e_db_mysql { * * @access public */ - function db_Fetch($type = MYSQL_ASSOC) + function db_Fetch($type = MYSQL_ASSOC) { - if (!(is_int($type))) + if (!(is_int($type))) { $type=MYSQL_ASSOC; } @@ -679,11 +681,11 @@ class e_db_mysql { { $row = @mysql_fetch_array($this->mySQLresult,$type); e107::getSingleton('e107_traffic')->Bump('db_Fetch', $b); - if ($row) + if ($row) { $this->dbError('db_Fetch'); return $row; // Success - return data - } + } } $this->dbError('db_Fetch'); return FALSE; // Failure @@ -701,20 +703,20 @@ class e_db_mysql { * * @access public */ - function db_Count($table, $fields = '(*)', $arg = '', $debug = FALSE, $log_type = '', $log_remark = '') + function db_Count($table, $fields = '(*)', $arg = '', $debug = FALSE, $log_type = '', $log_remark = '') { $table = $this->db_IsLang($table); - if ($fields == 'generic') + if ($fields == 'generic') { $query=$table; - if ($this->mySQLresult = $this->db_Query($query, NULL, 'db_Count', $debug, $log_type, $log_remark)) + if ($this->mySQLresult = $this->db_Query($query, NULL, 'db_Count', $debug, $log_type, $log_remark)) { $rows = $this->mySQLrows = @mysql_fetch_array($this->mySQLresult); $this->dbError('db_Count'); return $rows['COUNT(*)']; - } - else + } + else { $this->dbError("db_Count ({$query})"); return FALSE; @@ -722,19 +724,19 @@ class e_db_mysql { } $this->mySQLcurTable = $table; - // normalize query arguments - only COUNT expected 'WHERE', not anymore + // normalize query arguments - only COUNT expected 'WHERE', not anymore if($arg && stripos(trim($arg), 'WHERE') !== 0) { $arg = 'WHERE '.$arg; } $query='SELECT COUNT'.$fields.' FROM '.$this->mySQLPrefix.$table.' '.$arg; - if ($this->mySQLresult = $this->db_Query($query, NULL, 'db_Count', $debug, $log_type, $log_remark)) + if ($this->mySQLresult = $this->db_Query($query, NULL, 'db_Count', $debug, $log_type, $log_remark)) { $rows = $this->mySQLrows = @mysql_fetch_array($this->mySQLresult); $this->dbError('db_Count'); return $rows[0]; - } - else + } + else { $this->dbError("db_Count({$query})"); return FALSE; @@ -754,7 +756,7 @@ class e_db_mysql { * * @access public */ - function db_Close() + function db_Close() { if(!$this->mySQLaccess) { @@ -778,7 +780,7 @@ class e_db_mysql { *
* @access public */ - function db_Delete($table, $arg = '', $debug = FALSE, $log_type = '', $log_remark = '') + function db_Delete($table, $arg = '', $debug = FALSE, $log_type = '', $log_remark = '') { $table = $this->db_IsLang($table); $this->mySQLcurTable = $table; @@ -790,28 +792,28 @@ class e_db_mysql { } - if (!$arg) + if (!$arg) { - if ($result = $this->mySQLresult = $this->db_Query('DELETE FROM '.$this->mySQLPrefix.$table, NULL, 'db_Delete', $debug, $log_type, $log_remark)) + if ($result = $this->mySQLresult = $this->db_Query('DELETE FROM '.$this->mySQLPrefix.$table, NULL, 'db_Delete', $debug, $log_type, $log_remark)) { $this->dbError('db_Delete'); return $result; - } - else + } + else { $this->dbError("db_Delete({$arg})"); return FALSE; } - } - else + } + else { - if ($result = $this->mySQLresult = $this->db_Query('DELETE FROM '.$this->mySQLPrefix.$table.' WHERE '.$arg, NULL, 'db_Delete', $debug, $log_type, $log_remark)) + if ($result = $this->mySQLresult = $this->db_Query('DELETE FROM '.$this->mySQLPrefix.$table.' WHERE '.$arg, NULL, 'db_Delete', $debug, $log_type, $log_remark)) { $tmp = mysql_affected_rows($this->mySQLaccess); $this->dbError('db_Delete'); return $tmp; - } - else + } + else { $this->dbError('db_Delete ('.$arg.')'); return FALSE; @@ -825,7 +827,7 @@ class e_db_mysql { * @desc Enter description here... * @access private */ - function db_Rows() + function db_Rows() { $rows = $this->mySQLrows = @mysql_num_rows($this->mySQLresult); $this->dbError('db_Rows'); @@ -839,7 +841,7 @@ class e_db_mysql { * @desc Enter description here... * @access private */ - function db_SetErrorReporting($mode) + function db_SetErrorReporting($mode) { $this->mySQLerror = $mode; } @@ -857,22 +859,22 @@ class e_db_mysql { public function db_Select_gen($query, $debug = FALSE, $log_type = '', $log_remark = '') { $this->tabset = FALSE; - - + + $query .= " "; // temp fix for failing regex below, when there is no space after the table name; - + if(strpos($query,'`#') !== FALSE) - { + { $query = preg_replace_callback("/\s`#([\w]*?)`\W/", array($this, 'ml_check'), $query); } elseif(strpos($query,'#') !== FALSE) { $query = preg_replace_callback("/\s#([\w]*?)\W/", array($this, 'ml_check'), $query); } - + $query = str_replace("#",$this->mySQLPrefix,$query); //FIXME - quick fix for those that slip-thru - //FIXME - this is a quick Fix for REGEXP queries, as used in admin_ui. + //FIXME - this is a quick Fix for REGEXP queries, as used in admin_ui. $query = str_replace("`#","`".$this->mySQLPrefix,$query); if ($this->mySQLresult === FALSE) @@ -899,7 +901,7 @@ class e_db_mysql { } function ml_check($matches) - { + { $table = $this->db_IsLang($matches[1]); if($this->tabset == false) { @@ -916,7 +918,7 @@ class e_db_mysql { * @desc Enter description here... * @access private */ - function db_Fieldname($offset) + function db_Fieldname($offset) { $result = @mysql_field_name($this->mySQLresult, $offset); return $result; @@ -928,7 +930,7 @@ class e_db_mysql { * @desc Enter description here... * @access private */ - function db_Field_info() + function db_Field_info() { $result = @mysql_fetch_field($this->mySQLresult); return $result; @@ -940,25 +942,25 @@ class e_db_mysql { * @desc Enter description here... * @access private */ - function db_Num_fields() + function db_Num_fields() { $result = @mysql_num_fields($this->mySQLresult); return $result; } /** - * Check for the existence of a matching language table when multi-language tables are active. + * Check for the existence of a matching language table when multi-language tables are active. * @param string $table Name of table, without the prefix. * @access private * @return name of the language table (eg. lan_french_news) */ - function db_IsLang($table,$multiple=FALSE) + function db_IsLang($table,$multiple=FALSE) { global $pref; - - //When running a multi-language site with english included. English must be the main site language. - - if ((!$this->mySQLlanguage || !$pref['multilanguage'] || $this->mySQLlanguage=='English') && $multiple==FALSE) + + //When running a multi-language site with english included. English must be the main site language. + + if ((!$this->mySQLlanguage || !$pref['multilanguage'] || $this->mySQLlanguage=='English') && $multiple==FALSE) { return $table; } @@ -968,14 +970,14 @@ class e_db_mysql { global $db_ConnectionID; $this->mySQLaccess = $db_ConnectionID; } - + if($multiple == FALSE) - { + { $mltable = "lan_".strtolower($this->mySQLlanguage.'_'.$table); return ($this->db_Table_exists($table,$this->mySQLlanguage)) ? $mltable : $table; } else // return an array of all matching language tables. eg [french]->e107_lan_news - { + { if(!is_array($table)) { $table = array($table); @@ -996,7 +998,7 @@ class e_db_mysql { } } } - + return (varset($lanlist)) ? $lanlist : FALSE; } // ------------------------- @@ -1010,17 +1012,17 @@ class e_db_mysql { * @desc returns fields as structured array * @access public */ - function db_getList($fields = 'ALL', $amount = FALSE, $maximum = FALSE, $ordermode=FALSE) + function db_getList($fields = 'ALL', $amount = FALSE, $maximum = FALSE, $ordermode=FALSE) { $list = array(); $counter = 1; - while ($row = $this->db_Fetch()) + while ($row = $this->db_Fetch()) { - foreach($row as $key => $value) + foreach($row as $key => $value) { - if (is_string($key)) + if (is_string($key)) { - if (strtoupper($fields) == 'ALL' || in_array ($key, $fields)) + if (strtoupper($fields) == 'ALL' || in_array ($key, $fields)) { if(!$ordermode) { @@ -1033,7 +1035,7 @@ class e_db_mysql { } } } - if ($amount && $amount == $counter || ($maximum && $counter > $maximum)) + if ($amount && $amount == $counter || ($maximum && $counter > $maximum)) { break; } @@ -1047,7 +1049,7 @@ class e_db_mysql { * @desc returns total number of queries made so far * @access public */ - function db_QueryCount() + function db_QueryCount() { global $db_mySQLQueryCount; return $db_mySQLQueryCount; @@ -1181,31 +1183,31 @@ class e_db_mysql { * @param string $lanMode [optional] When set to TRUE, searches for multilanguage tables * @return boolean TRUE if exists * - * NOTES: Slower (28ms) than "SELECT 1 FROM" (4-5ms), but doesn't produce MySQL errors. - * Multiple checks on a single page will only use 1 query. ie. faster on multiple calls. + * NOTES: Slower (28ms) than "SELECT 1 FROM" (4-5ms), but doesn't produce MySQL errors. + * Multiple checks on a single page will only use 1 query. ie. faster on multiple calls. */ public function db_Table_exists($table,$language='') { global $pref; $table = strtolower($table); // precaution for multilanguage - + if($language && ($language != $pref['sitelanguage'])) { if(!isset($this->mySQLtableListLanguage[$language])) { $this->mySQLtableListLanguage = $this->db_mySQLtableList($language); - } - return in_array('lan_'.strtolower($language)."_".$table,$this->mySQLtableListLanguage[$language]); + } + return in_array('lan_'.strtolower($language)."_".$table,$this->mySQLtableListLanguage[$language]); } else { if(!$this->mySQLtableList) { - $this->mySQLtableList = $this->db_mySQLtableList(); - } + $this->mySQLtableList = $this->db_mySQLtableList(); + } return in_array($table,$this->mySQLtableList); } - + } @@ -1221,39 +1223,39 @@ class e_db_mysql { { $table = array(); if($res = $this->db_Query("SHOW TABLES LIKE '".$this->mySQLPrefix."lan_".strtolower($language)."%' ")) - { + { while($rows = $this->db_Fetch(MYSQL_NUM)) { - $table[] = str_replace($this->mySQLPrefix,"",$rows[0]); + $table[] = str_replace($this->mySQLPrefix,"",$rows[0]); } } $ret = array($language=>$table); - return $ret; + return $ret; } else { - return $this->mySQLtableListLanguage[$language]; - } - } - + return $this->mySQLtableListLanguage[$language]; + } + } + if(!$this->mySQLtableList) { $table = array(); if($res = $this->db_Query("SHOW TABLES LIKE '".$this->mySQLPrefix."%' ")) - { + { while($rows = $this->db_Fetch(MYSQL_NUM)) { - $table[] = str_replace($this->mySQLPrefix,"",$rows[0]); + $table[] = str_replace($this->mySQLPrefix,"",$rows[0]); } } - return $table; + return $table; } else { return $this->mySQLtableList; } } - + public function db_ResetTableList() { $this->mySQLtableList = array(); @@ -1261,29 +1263,29 @@ class e_db_mysql { } /** - * Return a filtered list of DB tables. - * @param object $mode [optional] all|lan|nolan - * @return array + * Return a filtered list of DB tables. + * @param object $mode [optional] all|lan|nolan + * @return array */ public function db_TableList($mode='all') { - + if(!$this->mySQLtableList) { $this->mySQLtableList = $this->db_mySQLtableList(); } - + if($mode == 'all') { return $this->mySQLtableList; } - + if($mode == 'lan' || $mode=='nolan') { $nolan = array(); $lan = array(); - + foreach($this->mySQLtableList as $tab) { if(substr($tab,0,4)!='lan_') @@ -1292,28 +1294,28 @@ class e_db_mysql { } else { - $lan[] = $tab; - } + $lan[] = $tab; + } } - + return ($mode == 'lan') ? $lan : $nolan; } } - + function db_CopyTable($oldtable, $newtable, $drop = FALSE, $data = FALSE) { $old = $this->mySQLPrefix.strtolower($oldtable); $new = $this->mySQLPrefix.strtolower($newtable); - + if ($drop) { $this->db_Select_gen("DROP TABLE IF EXISTS {$new}"); } - + //Get $old table structure $this->db_Select_gen('SET SQL_QUOTE_SHOW_CREATE = 1'); - + $qry = "SHOW CREATE TABLE {$old}"; if ($this->db_Select_gen($qry)) { @@ -1324,14 +1326,14 @@ class e_db_mysql { } else { - return FALSE; + return FALSE; } - + if(!$this->db_Table_exists($newtable)) { $result = $this->db_Query($qry); } - + if ($data) //We need to copy the data too { $qry = "INSERT INTO {$new} SELECT * FROM {$old}"; @@ -1348,7 +1350,7 @@ class e_db_mysql { * @desc Calling method from within this class * @access private */ - function dbError($from) + function dbError($from) { $this->mySQLlastErrNum = mysql_errno(); $this->mySQLlastErrText = ''; @@ -1357,7 +1359,7 @@ class e_db_mysql { return ''; } $this->mySQLlastErrText = mysql_error(); // Get the error text. - if ($this->mySQLerror == TRUE) + if ($this->mySQLerror == TRUE) { message_handler('ADMIN_MESSAGE', 'mySQL Error! Function: '.$from.'. ['.$this->mySQLlastErrNum.' - '.$this->mySQLlastErrText.']', __LINE__, __FILE__); } @@ -1435,7 +1437,7 @@ class e_db_mysql { */ class db extends e_db_mysql { - + } ?> \ No newline at end of file diff --git a/e107_handlers/pref_class.php b/e107_handlers/pref_class.php index d68f7c66c..c2e140d6e 100644 --- a/e107_handlers/pref_class.php +++ b/e107_handlers/pref_class.php @@ -9,9 +9,9 @@ * e107 Preference Handler * * $Source: /cvs_backup/e107_0.8/e107_handlers/pref_class.php,v $ - * $Revision: 1.31 $ - * $Date: 2009-11-18 01:04:43 $ - * $Author: e107coders $ + * $Revision: 1.32 $ + * $Date: 2009-12-02 16:50:58 $ + * $Author: secretr $ */ if (!defined('e107_INIT')) { exit; } @@ -27,7 +27,7 @@ require_once(e_HANDLER.'model_class.php'); * @author SecretR * @copyright Copyright (c) 2009, e107 Inc. */ -class e_pref extends e_admin_model +class e_pref extends e_admin_model { /** * Preference ID - DB row value @@ -35,22 +35,22 @@ class e_pref extends e_admin_model * @var string */ protected $prefid; - + /** * Preference ID alias e.g. 'core' is an alias of prefid 'SitePrefs' * Used in e.g. server cache file name - * + * * @var string */ protected $alias; - + /** * Runtime cache, set on first data load * * @var string */ protected $pref_cache = ''; - + /** * Backward compatibility - serialized preferences * Note: serialized preference storage is deprecated @@ -58,7 +58,7 @@ class e_pref extends e_admin_model * @var boolean */ protected $serial_bc = false; - + /** * If true, $prefid.'_Backup' row will be created/updated * on every {@link save()} call @@ -66,7 +66,7 @@ class e_pref extends e_admin_model * @var boolean */ protected $set_backup = false; - + /** * Constructor * @@ -78,19 +78,19 @@ class e_pref extends e_admin_model function __construct($prefid, $alias = '', $data = array(), $sanitize_data = true) { require_once(e_HANDLER.'cache_handler.php'); - + $this->prefid = preg_replace('/[^\w\-]/', '', $prefid); if(empty($alias)) { $alias = $prefid; } $this->alias = preg_replace('/[^\w\-]/', '', $alias); - + $this->loadData($data, $sanitize_data); } - + /** - * Advanced getter - $pref_name could be path in format 'pref1/pref2/pref3' (multidimensional arrays support), + * Advanced getter - $pref_name could be path in format 'pref1/pref2/pref3' (multidimensional arrays support), * alias of {@link e_model::getData()} * If $pref_name is empty, all data array will be returned * @@ -103,11 +103,11 @@ class e_pref extends e_admin_model { return $this->getData($pref_name, $default, $index); } - + /** * Simple getter - $pref_name is not parsed (no multidimensional arrays support), alias of {@link e_model::get()} - * This is the prefered (performance wise) method when simple preference is retrieved - * + * This is the prefered (performance wise) method when simple preference is retrieved + * * @param string $pref_name * @param mixed $default * @return mixed @@ -116,11 +116,11 @@ class e_pref extends e_admin_model { return parent::get((string) $pref_name, $default); } - + /** * Advanced setter - $pref_name could be path in format 'pref1/pref2/pref3' (multidimensional arrays support) * If $pref_name is array, it'll be merged with existing preference data, non existing preferences will be added as well - * + * * @param string|array $pref_name * @param mixed $value * @return e_pref @@ -131,18 +131,18 @@ class e_pref extends e_admin_model //object reset not allowed, adding new pref is allowed if(empty($pref_name)) { - return $this; + return $this; } - + //Merge only allowed if(is_array($pref_name)) { $this->mergeData($pref_name, false, false, false); return $this; } - + parent::setData($pref_name, $value, false); - + //BC if($this->alias === 'core') { @@ -150,11 +150,11 @@ class e_pref extends e_admin_model } return $this; } - + /** * Advanced setter - $pref_name could be path in format 'pref1/pref2/pref3' (multidimensional arrays support) * Object data reseting is not allowed, adding new preferences is controlled by $strict parameter - * + * * @param string|array $pref_name * @param mixed $value * @param boolean $strict true - update only, false - same as setPref() @@ -166,18 +166,18 @@ class e_pref extends e_admin_model //object reset not allowed, adding new pref is not allowed if(empty($pref_name)) { - return $this; + return $this; } - + //Merge only allowed if(is_array($pref_name)) { $this->mergeData($pref_name, $strict, false, false); return $this; } - + parent::setData($pref_name, $value, $strict); - + //BC if($this->alias === 'core') { @@ -185,11 +185,11 @@ class e_pref extends e_admin_model } return $this; } - + /** * Simple setter - $pref_name is not parsed (no multidimensional arrays support) * Adding new pref is allowed - * + * * @param string $pref_name * @param mixed $value * @return e_pref @@ -202,7 +202,7 @@ class e_pref extends e_admin_model return $this; } parent::set((string) $pref_name, $value, false); - + //BC if($this->alias === 'core') { @@ -210,11 +210,11 @@ class e_pref extends e_admin_model } return $this; } - + /** * Simple setter - $pref_name is not parsed (no multidimensional arrays support) * Non existing setting will be not created - * + * * @param string $pref_name * @param mixed $value * @return e_pref @@ -227,7 +227,7 @@ class e_pref extends e_admin_model return $this; } parent::set((string) $pref_name, $value, true); - + //BC if($this->alias === 'core') { @@ -235,46 +235,46 @@ class e_pref extends e_admin_model } return $this; } - + /** * Add new (single) preference (ONLY if doesn't exist) * No multidimensional arrays support - * + * * @see addData() * @param string $pref_name * @param mixed $value * @return e_pref */ public function add($pref_name, $value) - { + { if(empty($pref_name) || !is_string($pref_name)) { return $this; } - + $this->addData($pref_name, $value); - return $this; + return $this; } - + /** * Add new preference or preference array (ONLY if it/they doesn't exist) * $pref_name could be path in format 'pref1/pref2/pref3' - * + * * @see addData() * @param string|array $pref_name * @param mixed $value * @return e_pref */ public function addPref($pref_name, $value = null) - { + { $this->addData($pref_name, $value); return $this; } - + /** * Remove single preference * $pref_name is not parsed as a path - * + * * @see e_model::remove() * @param string $pref_name * @return e_pref @@ -283,7 +283,7 @@ class e_pref extends e_admin_model { global $pref; parent::remove((string) $pref_name); - + //BC if($this->alias === 'core') { @@ -291,21 +291,21 @@ class e_pref extends e_admin_model } return $this; } - + /** * Remove single preference (parse $pref_name) * $pref_name could be path in format 'pref1/pref2/pref3' - * + * * @see removeData() * @param string $pref_name * @return e_pref */ public function removePref($pref_name) { - $this->removeData($pref_name); + $this->removeData($pref_name); return $this; } - + /** * Disallow public use of e_model::addData() * Disallow preference override @@ -325,11 +325,11 @@ class e_pref extends e_admin_model } return $this; } - + /** * Disallow public use of e_model::setData() * Only data merge possible - * + * * @param string|array $pref_name * @param mixed $value * @return e_pref @@ -339,18 +339,18 @@ class e_pref extends e_admin_model global $pref; if(empty($pref_name)) { - return $this; + return $this; } - + //Merge only allowed if(is_array($pref_name)) { $this->mergeData($pref_name, false, false, false); return $this; } - + parent::setData($pref_name, $value, false); - + //BC if($this->alias === 'core') { @@ -358,7 +358,7 @@ class e_pref extends e_admin_model } return $this; } - + /** * Disallow public use of e_model::removeData() * Object data reseting is not allowed @@ -370,7 +370,7 @@ class e_pref extends e_admin_model { global $pref; parent::removeData((string) $pref_name); - + //BC if($this->alias === 'core') { @@ -378,7 +378,7 @@ class e_pref extends e_admin_model } return $this; } - + /** * Reset object data * @@ -405,7 +405,7 @@ class e_pref extends e_admin_model } return $this; } - + /** * Load object data - public * @@ -426,10 +426,10 @@ class e_pref extends e_admin_model $pref = $this->getData(); } } - + return $this; } - + /** * Load object data * @@ -439,40 +439,40 @@ class e_pref extends e_admin_model protected function _load($force = false) { $id = $this->prefid; - $data = $force ? false : $this->getPrefCache(true); - + $data = $force ? false : $this->getPrefCache(true); + if($data !== false) { $this->pref_cache = e107::getArrayStorage()->WriteArray($data, false); //runtime cache $this->loadData($data, false); return $this; } - + if (e107::getDb()->db_Select('core', 'e107_value', "e107_name='{$id}'")) { $row = e107::getDb()->db_Fetch(); - + if($this->serial_bc) { - $data = unserialize($row['e107_value']); + $data = unserialize($row['e107_value']); $row['e107_value'] = e107::getArrayStorage()->WriteArray($data, false); } - else + else { $data = e107::getArrayStorage()->ReadArray($row['e107_value']); } - + $this->pref_cache = $row['e107_value']; //runtime cache $this->setPrefCache($row['e107_value'], true); } if(empty($data)) $data = array(); - + $this->loadData($data, false); return $this; } - + /** * Save object data to DB * @@ -488,49 +488,49 @@ class e_pref extends e_admin_model { return false; } - + if($from_post) { $this->mergePostedData(); //all posted data is sanitized and filtered vs preferences/_data_fields array } - + if($this->hasValidationError()) - { + { return false; } - + //FIXME - switch to new model system messages (separate eMessage namespaces) $emessage = e107::getMessage(); - + if(!$this->data_has_changed && !$force) { $emessage->add('Settings not saved as no changes were made.', E_MESSAGE_INFO, $session_messages); return 0; } - + //Save to DB if(!$this->hasError()) { if($this->serial_bc) { - $dbdata = serialize($this->getPref()); + $dbdata = serialize($this->getPref()); } - else + else { $dbdata = $this->toString(false); } - + if(e107::getDb()->db_Select_gen("REPLACE INTO `#core` (e107_name,e107_value) values ('{$this->prefid}', '".addslashes($dbdata)."') ")) { $this->data_has_changed = false; //reset status - + if($this->set_backup === true && !empty($this->pref_cache)) { if($this->serial_bc) { - $dbdata = serialize(e107::getArrayStorage()->ReadArray($this->pref_cache)); + $dbdata = serialize(e107::getArrayStorage()->ReadArray($this->pref_cache)); } - else + else { $dbdata = $this->pref_cache; } @@ -541,14 +541,14 @@ class e_pref extends e_admin_model } } $this->setPrefCache($this->toString(false), true); //reset pref cache - runtime & file - + $emessage->add('Settings successfully saved.', E_MESSAGE_SUCCESS, $session_messages); //BC if($this->alias === 'core') { $pref = $this->getData(); } - return true; + return true; } elseif(e107::getDb()->getLastErrorNumber()) { @@ -557,7 +557,7 @@ class e_pref extends e_admin_model return false; } } - + if($this->hasError()) { //add errors to the eMessage stack @@ -565,13 +565,13 @@ class e_pref extends e_admin_model $emessage->add('Settings not saved.', E_MESSAGE_ERROR, $session_messages); return false; } - else + else { $emessage->add('Settings not saved as no changes were made.', E_MESSAGE_INFO, $session_messages); return 0; } } - + /** * Get cached data from server cache file * @@ -584,10 +584,10 @@ class e_pref extends e_admin_model { $this->pref_cache = ecache::retrieve_sys('Config_'.$this->alias, 24 * 60, true); } - + return ($toArray && $this->pref_cache ? e107::getArrayStorage()->ReadArray($this->pref_cache) : $this->pref_cache); } - + /** * Convert data to a string and store it to a server cache file * If $cache_string is an array, it'll be converted to a string @@ -613,10 +613,10 @@ class e_pref extends e_admin_model } return $this; } - + /** * Clear pref cache - * + * * @param string $cache_name default to current alias * @param boolean $runtime clear runtime cache as well ($this->pref_cache) * @return e_pref @@ -630,7 +630,7 @@ class e_pref extends e_admin_model ecache::clear_sys('Config_'.(!empty($cache_name) ? $cache_name : $this->alias)); return $this; } - + /** * Validation * @@ -641,90 +641,90 @@ class e_pref extends e_admin_model { return parent::validate($data); } - + /** * Set $set_backup option * * @param boolean $optval * @return e_pref - * + * */ public function setOptionBackup($optval) { $this->set_backup = $optval; return $this; } - + /** * Set $serial_bc option * * @param boolean $optval * @return e_pref - * + * */ public function setOptionSerialize($optval) { $this->serial_bc = $optval; return $this; } - + /** * Override */ public function dbInsert() { } - + /** * Override */ public function dbUpdate() { } - + /** * Override */ public function dbReplace() { } - + /** * Override */ public function dbDelete() { } - + } /** * Handle core preferences - * + * * @package e107 * @category e107_handlers * @version 1.0 * @author SecretR * @copyright Copyright (c) 2009, e107 Inc. */ -final class e_core_pref extends e_pref -{ +final class e_core_pref extends e_pref +{ /** * Allowed core id array * * @var array */ public $aliases = array( - 'core' => 'SitePrefs', - 'core_backup' => 'SitePrefs_Backup', + 'core' => 'SitePrefs', + 'core_backup' => 'SitePrefs_Backup', 'core_old' => 'pref', - 'emote' => 'emote_default', //TODO include other emote packs of the user. - 'menu' => 'menu_pref', - 'search' => 'search_prefs', + 'emote' => 'emote_default', //TODO include other emote packs of the user. + 'menu' => 'menu_pref', + 'search' => 'search_prefs', 'notify' => 'notify_prefs', 'ipool' => 'IconPool' ); - + /** * Backward compatibility - list of prefid's which operate wit serialized data * @@ -743,31 +743,31 @@ final class e_core_pref extends e_pref { $pref_alias = $alias; $pref_id = $this->getConfigId($alias); - - if(!$pref_id) + + if(!$pref_id) { $pref_id = $pref_alias = ''; trigger_error('Core config ID '.$alias.' not found!', E_USER_WARNING); return; } - + if(in_array($pref_alias, $this->serial_bc_array)) { $this->setOptionSerialize(true); } - + if('core' === $pref_alias) { $this->setOptionBackup(true); } - + parent::__construct($pref_id, $pref_alias); if($load && $pref_id) { $this->load(); } } - + /** * Get config ID * Allowed values: key or value from $alias array @@ -785,7 +785,7 @@ final class e_core_pref extends e_pref } return false; } - + /** * Get config ID * Allowed values: key or value from $alias array @@ -803,14 +803,14 @@ final class e_core_pref extends e_pref /** * Handle plugin preferences - * + * * @package e107 * @category e107_handlers * @version 1.0 * @author SecretR * @copyright Copyright (c) 2009, e107 Inc. */ -class e_plugin_pref extends e_pref +class e_plugin_pref extends e_pref { /** * Unique plugin name @@ -818,7 +818,7 @@ class e_plugin_pref extends e_pref * @var string */ protected $plugin_id; - + /** * Constructor * Note: object data will be loaded only if the plugin is installed (no matter of the passed @@ -841,7 +841,7 @@ class e_plugin_pref extends e_pref $this->load(); } } - + /** * Retrive unique plugin name * @@ -872,7 +872,7 @@ class e_plugin_pref extends e_pref // Just to be safe I have changed a number of menu_pref edits to use setArray(). // -class prefs +class prefs { var $prefVals; var $prefArrays; @@ -885,7 +885,7 @@ class prefs // If $use_default is TRUE, $RowList entries are added to the default array. Otherwise only $RowList is used. // Returns TRUE on success (measured as getting at least one row of data); false on error. // Any data read is buffered (in serialised form) here - retrieve using get() - function ExtractPrefs($RowList = "", $use_default = FALSE) + function ExtractPrefs($RowList = "", $use_default = FALSE) { global $sql; $Args = ''; @@ -920,29 +920,29 @@ class prefs * @return string pref value, slashes already stripped. FALSE on error * @access public */ - function get($Name) + function get($Name) { if(isset($this->prefVals['core'][$Name])) { if($this->prefVals['core'][$Name] != '### ROW CACHE FALSE ###') { return $this->prefVals['core'][$Name]; // Dava from cache - } - else + } + else { return false; } } // Data not in cache - retrieve from DB - $get_sql = new db; // required so sql loops don't break using $tp->toHTML(). - if($get_sql->db_Select('core', '*', "`e107_name` = '{$Name}'", 'default')) + $get_sql = new db; // required so sql loops don't break using $tp->toHTML(). + if($get_sql->db_Select('core', '*', "`e107_name` = '{$Name}'", 'default')) { $row = $get_sql->db_Fetch(); $this->prefVals['core'][$Name] = $row['e107_value']; return $this->prefVals['core'][$Name]; - } - else + } + else { // Data not in DB - put a 'doesn't exist' entry in cache to save another DB access $this->prefVals['core'][$Name] = '### ROW CACHE FALSE ###'; return false; diff --git a/install_.php b/install_.php index 26b5be99e..81ee83ea0 100644 --- a/install_.php +++ b/install_.php @@ -9,9 +9,9 @@ * Installation file * * $Source: /cvs_backup/e107_0.8/install_.php,v $ -* $Revision: 1.55 $ -* $Date: 2009-11-24 20:40:35 $ -* $Author: e107steved $ +* $Revision: 1.56 $ +* $Date: 2009-12-02 16:51:04 $ +* $Author: secretr $ * */ @@ -20,10 +20,10 @@ define('MIN_PHP_VERSION', '5.0'); define('MIN_MYSQL_VERSION', '4.1.2'); // ensure CHARSET is UTF-8 if used -define('CHARSET', 'utf-8'); +//define('CHARSET', 'utf-8'); /* Default Options and Paths for Installer */ -$MySQLPrefix = 'e107_'; +$MySQLprefix = 'e107_'; $ADMIN_DIRECTORY = "e107_admin/"; $FILES_DIRECTORY = "e107_files/"; @@ -48,13 +48,13 @@ if(isset($_GET['object'])) } define("e107_INIT", TRUE); -define("e_UC_PUBLIC", 0); +/*define("e_UC_PUBLIC", 0); define("e_UC_MAINADMIN", 250); define("e_UC_READONLY", 251); define("e_UC_GUEST", 252); define("e_UC_MEMBER", 253); define("e_UC_ADMIN", 254); -define("e_UC_NOBODY", 255); +define("e_UC_NOBODY", 255);*/ define("E107_INSTALL",TRUE); @@ -143,9 +143,8 @@ function check_class($whatever) $e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'CACHE_DIRECTORY', 'DOWNLOADS_DIRECTORY', 'UPLOADS_DIRECTORY', 'MEDIA_DIRECTORY'); - $e107 = e107::getInstance(); -$e107->init($e107_paths, realpath(dirname(__FILE__))); +$e107->initInstall($e107_paths, realpath(dirname(__FILE__))); unset($e107_paths); function include_lan($path, $force = false) @@ -182,7 +181,7 @@ class e_install var $previous_steps; var $stage; var $post_data; - var $required = ""; //TODO - use for highlighting required fields with css/js. + var $required = ""; //TODO - use for highlighting required fields with css/js. function e_install() { @@ -201,7 +200,7 @@ class e_install } $this->get_lan_file(); $this->post_data = $_POST; - + $this->template->SetTag("required", ""); if(isset($this->previous_steps['language'])) { @@ -210,7 +209,7 @@ class e_install } } - + function renderPage() { if(!isset($_POST['stage'])) @@ -248,7 +247,7 @@ class e_install default: $this->raise_error("Install stage information from client makes no sense to me."); } - + if($_SERVER['QUERY_STRING'] == "debug") { $this->template->SetTag("debug_info", print_a($this,TRUE)); @@ -257,8 +256,8 @@ class e_install { $this->template->SetTag("debug_info", (count($this->debug_info) ? print_a($this->debug_info,TRUE)."Backtrace:
".print_a($this,TRUE) : "")); } - - echo $this->template->ParseTemplate(template_data(), TEMPLATE_TYPE_DATA); + + echo $this->template->ParseTemplate(template_data(), TEMPLATE_TYPE_DATA); } function raise_error($details) @@ -270,7 +269,7 @@ class e_install ) ); } - + function display_required() { if(!$this->required) @@ -282,7 +281,7 @@ class e_install { $this->template->SetTag("required","
". implode("
",$this->required)."
"); $this->required = array(); - } + } } private function stage_1() @@ -315,7 +314,7 @@ class e_install $page_info = nl2br(LANINS_023); $e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $output = " - +


@@ -366,8 +365,8 @@ class e_install $this->template->SetTag("stage_pre", LANINS_002); $this->template->SetTag("stage_num", LANINS_036); $this->template->SetTag("onload", "document.getElementById('name').focus()"); - - + + $this->previous_steps['mysql']['server'] = trim($_POST['server']); $this->previous_steps['mysql']['user'] = trim($_POST['name']); $this->previous_steps['mysql']['password'] = $_POST['password']; @@ -382,7 +381,7 @@ class e_install $e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $head = LANINS_039."

\n"; $output = " - +
@@ -445,11 +444,11 @@ class e_install } */ // Do brute force for now - Should be enough - + $DB_ALREADY_EXISTS = mysql_select_db($this->previous_steps['mysql']['db'], $res); - - //TODO Add option to continue install even if DB exists. - + + //TODO Add option to continue install even if DB exists. + if($this->previous_steps['mysql']['createdb'] == 1) { $query = 'CREATE DATABASE '.$this->previous_steps['mysql']['db'].' CHARACTER SET `utf8` '; @@ -458,11 +457,11 @@ class e_install { $query = 'ALTER DATABASE '.$this->previous_steps['mysql']['db'].' CHARACTER SET `utf8` '; } - + if (!$this->dbqry($query)) { $success = FALSE; - $page_content .= "

".LANINS_043.nl2br("\n\n".LANINS_083."\n".mysql_error().""); + $page_content .= "

".LANINS_043.nl2br("\n\n".LANINS_083."\n".mysql_error().""); } else { @@ -488,7 +487,7 @@ class e_install private function stage_4() { global $e_forms; - + $this->stage = 4; $this->template->SetTag("installation_heading", LANINS_001); @@ -609,7 +608,7 @@ class e_install * @return string HTML form of stage 5. */ - private function stage_5() + private function stage_5() { global $e_forms; $this->stage = 5; @@ -620,8 +619,8 @@ class e_install $this->template->SetTag("stage_num", LANINS_046); $this->template->SetTag("stage_title", LANINS_047); $this->template->SetTag("onload", "document.getElementById('u_name').focus()"); - - + + $e_forms->start_form("admin_info", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $output = "
@@ -660,17 +659,17 @@ class e_install $e_forms->add_button("submit", LANINS_035); $this->template->SetTag("stage_content", $e_forms->return_form()); } - + /** * Collect User's Website Preferences - * + * * @return string HTML form of stage 6. */ - private function stage_6() + private function stage_6() { global $e_forms; $this->stage = 6; - + // -------------------- Save Step 5 Data ------------------------- @@ -680,7 +679,7 @@ class e_install $_POST['u_name'] = str_replace(array("'", '"'), "", $_POST['u_name']); $this->previous_steps['admin']['user'] = $_POST['u_name']; } - + if(!vartrue($this->previous_steps['admin']['display']) || varset($_POST['d_name'])) { $_POST['d_name'] = str_replace(array("'", '"'), "", $_POST['d_name']); @@ -691,44 +690,44 @@ class e_install else { $this->previous_steps['admin']['display'] = $_POST['d_name']; - } + } } - + if(!vartrue($this->previous_steps['admin']['email']) || varset($_POST['email'])) { - $this->previous_steps['admin']['email'] = $_POST['email']; - } - + $this->previous_steps['admin']['email'] = $_POST['email']; + } + if(varset($_POST['pass1']) || !vartrue($this->previous_steps['admin']['password'])) - { + { if($_POST['pass1'] != $_POST['pass2']) { - $this->required['pass1'] = LANINS_049; // passwords don't match. + $this->required['pass1'] = LANINS_049; // passwords don't match. } elseif(!vartrue($_POST['pass1'])) { - $this->required['pass1'] = LANINS_077; + $this->required['pass1'] = LANINS_077; } else { $this->previous_steps['admin']['password'] = $_POST['pass1']; - } + } } - - + + // ------------- Validate Step 5 Data. -------------------------- - + if(!vartrue($this->previous_steps['admin']['user']) || !vartrue($this->previous_steps['admin']['password'])) { $this->required['u_name'] = LANINS_086; // } - + if(vartrue($this->required['u_name']) || vartrue($this->required['pass1'])) { - return $this->stage_5(); - } + return $this->stage_5(); + } + - // ------------- Step 6 Form -------------------------------- $this->display_required(); @@ -737,8 +736,8 @@ class e_install $this->template->SetTag("stage_num", LANINS_056); $this->template->SetTag("stage_title", LANINS_117); // Website Preferences; $this->template->SetTag("onload", "document.getElementById('sitename').focus()"); - - + + $e_forms->start_form("pref_info", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $output = "
@@ -751,7 +750,7 @@ class e_install
- + @@ -761,35 +760,35 @@ class e_install "; - + $themes = $this->get_themes(); - + foreach($themes as $val) { $themeInfo = $this->get_theme_xml($val); $title = vartrue($themeInfo['@attributes']['name']); $category = vartrue($themeInfo['category']); - + $output .= " - "; + "; } - + $output .= "
".LANINS_108."

".LANINS_110."
".LANINS_115." ".LANINS_116."
{$title} {$category}
- + ".LANINS_119." - + ".LANINS_112." - +
@@ -803,51 +802,51 @@ class e_install private function stage_7() { global $e_forms; - + $this->stage = 7; - + if(varset($_POST['sitename'])) { - $this->previous_steps['prefs']['sitename'] = $_POST['sitename']; + $this->previous_steps['prefs']['sitename'] = $_POST['sitename']; } - + if(varset($_POST['sitetheme'])) { - $this->previous_steps['prefs']['sitetheme'] = $_POST['sitetheme']; + $this->previous_steps['prefs']['sitetheme'] = $_POST['sitetheme']; } - + if(varset($_POST['generate_content'])) { - $this->previous_steps['generate_content'] = $_POST['generate_content']; + $this->previous_steps['generate_content'] = $_POST['generate_content']; } - + if(varset($_POST['install_plugins'])) { - $this->previous_steps['install_plugins'] = $_POST['install_plugins']; + $this->previous_steps['install_plugins'] = $_POST['install_plugins']; } - - // Validate. + + // Validate. if(!vartrue($this->previous_steps['prefs']['sitename'])) { - $this->required['sitename'] = LANINS_113; // 'Please enter a website name.'; // should be used to highlight the required field. (using css for example) + $this->required['sitename'] = LANINS_113; // 'Please enter a website name.'; // should be used to highlight the required field. (using css for example) } if(!vartrue($this->previous_steps['prefs']['sitetheme'])) - { + { $this->required['sitetheme'] = LANINS_114; // 'Please select a theme.'; - } - + } + if(vartrue($this->required['sitetheme']) || vartrue($this->required['sitename'])) { - return $this->stage_6(); + return $this->stage_6(); } - - // Data is okay - Continue. - + + // Data is okay - Continue. + // $this->previous_steps['prefs']['sitename'] = $_POST['sitename']; // $this->previous_steps['prefs']['sitetheme'] = $_POST['sitetheme']; // $this->previous_steps['generate_content'] = $_POST['generate_content']; - - + + $this->template->SetTag("installation_heading", LANINS_001); $this->template->SetTag("stage_pre", LANINS_002); $this->template->SetTag("stage_num", LANINS_058); @@ -857,14 +856,14 @@ class e_install $page = nl2br(LANINS_057); $this->finish_form(); $e_forms->add_button("submit", LANINS_035); - + $this->template->SetTag("stage_content", $page.$e_forms->return_form()); - + } private function stage_8() { - + global $e_forms; $this->stage = 8; @@ -872,7 +871,7 @@ class e_install $this->template->SetTag("stage_pre", LANINS_002); $this->template->SetTag("stage_num", LANINS_120); $this->template->SetTag("stage_title", LANINS_071); - + $config_file = ""; } else - { + { $errors = $this->create_tables(); - - if ($errors == true) { $page = $errors."
"; @@ -950,107 +947,105 @@ class e_install public function import_configuration() { // Basic stuff to get the handlers/classes to work. - - - $udirs = "admin/|plugins/|temp"; - $e_SELF = $_SERVER['PHP_SELF']; - $e_HTTP = preg_replace("#".$udirs."#i", "", substr($e_SELF, 0, strrpos($e_SELF, "/"))."/"); - - define("MAGIC_QUOTES_GPC", (ini_get('magic_quotes_gpc') ? true : false)); + + + // $udirs = "admin/|plugins/|temp"; + // $e_SELF = $_SERVER['PHP_SELF']; + // $e_HTTP = preg_replace("#".$udirs."#i", "", substr($e_SELF, 0, strrpos($e_SELF, "/"))."/"); + + //define("MAGIC_QUOTES_GPC", (ini_get('magic_quotes_gpc') ? true : false)); // define('CHARSET', 'utf-8'); // define("e_LANGUAGE", $this->previous_steps['language']); - define('e_SELF', 'http://'.$_SERVER['HTTP_HOST']) . ($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_FILENAME']); + // define('e_SELF', 'http://'.$_SERVER['HTTP_HOST']) . ($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_FILENAME']); $themeImportFile = array(); - $themeImportFile[0] = $this->e107->e107_dirs['THEMES_DIRECTORY'].$this->previous_steps['prefs']['sitetheme']."/install.xml"; - $themeImportFile[1] = $this->e107->e107_dirs['THEMES_DIRECTORY'].$this->previous_steps['prefs']['sitetheme']."/install/install.xml"; - $themeImportFile[3] = $this->e107->e107_dirs['FILES_DIRECTORY']. "default_install.xml"; - - + $themeImportFile[0] = $this->e107->e107_dirs['THEMES_DIRECTORY'].$this->previous_steps['prefs']['sitetheme']."/install.xml"; + $themeImportFile[1] = $this->e107->e107_dirs['THEMES_DIRECTORY'].$this->previous_steps['prefs']['sitetheme']."/install/install.xml"; + $themeImportFile[3] = $this->e107->e107_dirs['FILES_DIRECTORY']. "default_install.xml"; + if(vartrue($this->previous_steps['generate_content'])) { foreach($themeImportFile as $file) { if(is_readable($file)) { - $XMLImportfile = $file; + $XMLImportfile = $file; break; - } + } } } else { - $XMLImportfile = $this->e107->e107_dirs['FILES_DIRECTORY']. "default_install.xml"; + $XMLImportfile = $this->e107->e107_dirs['FILES_DIRECTORY']. "default_install.xml"; } - + $tp = e107::getParser(); - - define('PREVIEWTHEMENAME',""); // Notice Removal. - + + define('PREVIEWTHEMENAME',""); // Notice Removal. + include_lan($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$this->previous_steps['language']."/lan_prefs.php"); include_lan($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$this->previous_steps['language']."/admin/lan_theme.php"); - - //Create default plugin-table entries. + + //Create default plugin-table entries. // e107::getConfig('core')->clearPrefCache(); - e107::getSingleton('e107plugin')->update_plugins_table(); - + e107::getSingleton('e107plugin')->update_plugins_table(); + // Install Theme-required plugins if(vartrue($this->previous_steps['install_plugins'])) { if($themeInfo = $this->get_theme_xml($this->previous_steps['prefs']['sitetheme'])) { if(isset($themeInfo['plugins']['plugin'])) - { - foreach($themeInfo['plugins']['plugin'] as $k=>$plug) + { + foreach($themeInfo['plugins']['plugin'] as $k=>$plug) { - $this->install_plugin($plug['@attributes']['name']); + $this->install_plugin($plug['@attributes']['name']); } } } } - - - //FIXME - should be 'add' not 'replace' - but 'add' doesn't insert arrays correctly. + + + //FIXME - should be 'add' not 'replace' - but 'add' doesn't insert arrays correctly. e107::getXml()->e107Import($XMLImportfile,'replace'); // Add missing core pref values - e107::getSingleton('e107plugin')->save_addon_prefs(); // save plugin addon pref-lists. eg. e_latest_list. - + e107::getSingleton('e107plugin')->save_addon_prefs(); // save plugin addon pref-lists. eg. e_latest_list. + $tm = e107::getSingleton('themeHandler'); $tm->noLog = TRUE; $tm->setTheme($this->previous_steps['prefs']['sitetheme']); - + $pref = e107::getConfig('core')->getPref(); - - // Set Preferences defined during install - overwriting those that may exist in the XML. - + + // Set Preferences defined during install - overwriting those that may exist in the XML. + $this->previous_steps['prefs']['sitelanguage'] = $this->previous_steps['language']; $this->previous_steps['prefs']['sitelang_init'] = $this->previous_steps['language']; - + $this->previous_steps['prefs']['siteadmin'] = $this->previous_steps['admin']['display']; $this->previous_steps['prefs']['siteadminemail'] = $this->previous_steps['admin']['email']; $this->previous_steps['prefs']['install_date'] = time(); - $this->previous_steps['prefs']['siteurl'] = $e_HTTP; - - $this->previous_steps['prefs']['sitetag'] = LAN_PREF_2; - $this->previous_steps['prefs']['sitedisclaimer'] = LAN_PREF_3; - + $this->previous_steps['prefs']['siteurl'] = e_HTTP; + + $this->previous_steps['prefs']['sitetag'] = LAN_PREF_2; + $this->previous_steps['prefs']['sitedisclaimer'] = LAN_PREF_3; + $this->previous_steps['prefs']['replyto_name'] = $this->previous_steps['admin']['display']; $this->previous_steps['prefs']['replyto_email'] = $this->previous_steps['admin']['email']; - + $cookiename = str_replace(" ","_",$this->previous_steps['prefs']['sitename']); $this->previous_steps['prefs']['cookie_name'] = substr($cookiename,0,5)."cookie"; - + e107::getConfig('core')->setPref($this->previous_steps['prefs']); - e107::getConfig('core')->save(FALSE,TRUE); // save preferences made during install. - - // Create the admin user - replacing any that may be been included in the XML. + e107::getConfig('core')->save(FALSE,TRUE); // save preferences made during install. + + // Create the admin user - replacing any that may be been included in the XML. $ip = $_SERVER['REMOTE_ADDR']; $userp = "1, '{$this->previous_steps['admin']['display']}', '{$this->previous_steps['admin']['user']}', '', '".md5($this->previous_steps['admin']['password'])."', '', '{$this->previous_steps['admin']['email']}', '', '', 0, ".time().", 0, 0, 0, 0, 0, '{$ip}', 0, '', 0, 1, '', '', '0', '', ".time().", ''"; $this->dbqry("REPLACE INTO {$this->previous_steps['mysql']['prefix']}user VALUES ({$userp})" ); - mysql_close(); return false; - + } /** @@ -1059,12 +1054,12 @@ class e_install * @param string $plugpath - plugin folder name * @return void */ - public function install_plugin($plugpath) //FIXME - requires default plugin table entries, see above. + public function install_plugin($plugpath) //FIXME - requires default plugin table entries, see above. { e107::getDb()->db_Select_gen("SELECT * FROM #plugin WHERE plugin_path = '".$plugpath."' LIMIT 1"); - $row = e107::getDb()->db_Fetch(MYSQL_ASSOC); + $row = e107::getDb()->db_Fetch(MYSQL_ASSOC); e107::getSingleton('e107plugin')->install_plugin($row['plugin_id']); - return; + return; } @@ -1093,7 +1088,7 @@ class e_install { $this->previous_steps['language'] = "English"; } - + include_lan($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$this->previous_steps['language']."/lan_installer.php"); // $this->lan_file = "{$this->e107->e107_dirs['LANGUAGES_DIRECTORY']}{$this->previous_steps['language']}/lan_installer.php"; // if(is_readable($this->lan_file)) @@ -1124,55 +1119,55 @@ class e_install closedir($handle); return $lanlist; } - + function get_themes() { - + $handle = opendir($this->e107->e107_dirs['THEMES_DIRECTORY']); $lanlist = array(); while ($file = readdir($handle)) { if (is_dir($this->e107->e107_dirs['THEMES_DIRECTORY'].$file) && $file !='_blank') { - + if(is_readable("./{$this->e107->e107_dirs['THEMES_DIRECTORY']}{$file}/theme.xml")) { $lanlist[] = $file; } } - + } closedir($handle); - return $lanlist; + return $lanlist; } - + function get_theme_xml($theme_folder) { - + if(!defined("SITEURL")) { define("SITEURL",""); } $path = $this->e107->e107_dirs['THEMES_DIRECTORY'].$theme_folder."/theme.xml"; - + if(!is_readable($path)) { return FALSE; } - + require_once($this->e107->e107_dirs['HANDLERS_DIRECTORY']."theme_handler.php"); - - + + $tm = new themeHandler; $xmlArray = $tm->parse_theme_xml($theme_folder); - // $xml = e107::getXml(); + // $xml = e107::getXml(); // $xmlArray = $xml->loadXMLfile($path,'advanced'); - return (is_array($xmlArray)) ? $xmlArray : FALSE; + return (is_array($xmlArray)) ? $xmlArray : FALSE; } - + function finish_form($force_stage = false) { @@ -1250,24 +1245,23 @@ class e_install foreach ($result[0] as $sql_table) { $sql_table = preg_replace("/create table\s/si", "CREATE TABLE {$this->previous_steps['mysql']['prefix']}", $sql_table); - - // Drop existing tables before creating. + + // Drop existing tables before creating. $tmp = explode("\n",$sql_table); $drop_table = str_replace($srch,$repl,$tmp[0]); $this->dbqry($drop_table); - + if (!$this->dbqry($sql_table, $link)) { return nl2br(LANINS_061."\n\n".LANINS_083."\n".mysql_error($link).""); } } - return FALSE; - - + + //TODO - remove - Everything below this point should no longer be required. See import_configuration(); - + /* $datestamp = time(); @@ -1300,7 +1294,7 @@ class e_install require_once("{$this->e107->e107_dirs['FILES_DIRECTORY']}def_e107_prefs.php"); include_once("{$this->e107->e107_dirs['HANDLERS_DIRECTORY']}arraystorage_class.php"); - + $tmp = ArrayData::WriteArray($pref); $this->dbqry("INSERT INTO {$this->previous_steps['mysql']['prefix']}core VALUES ('SitePrefs', '{$tmp}')"); @@ -1408,7 +1402,7 @@ class e_install mysql_close(); return false; - + */ } @@ -1523,8 +1517,8 @@ function create_tables_unattended() $einstall->previous_steps['admin']['password'] = (isset($_GET['admin_password']) ? $_GET['admin_password'] : 'admin_password'); $einstall->previous_steps['admin']['email'] = (isset($_GET['admin_email']) ? $_GET['admin_email'] : 'admin_email@xxx.com'); - $einstall->previous_steps['generate_content'] = isset($_GET['gen']) ? intval($_GET['gen']) : 1; - $einstall->previous_steps['install_plugins'] = isset($_GET['plugins']) ? intval($_GET['plugins']) : 1; + $einstall->previous_steps['generate_content'] = isset($_GET['gen']) ? intval($_GET['gen']) : 1; + $einstall->previous_steps['install_plugins'] = isset($_GET['plugins']) ? intval($_GET['plugins']) : 1; $einstall->previous_steps['prefs']['sitename'] = isset($_GET['sitename']) ? urldecode($_GET['sitename']) : LANINS_113; $einstall->previous_steps['prefs']['sitetheme'] = isset($_GET['theme']) ? urldecode($_GET['theme']) : 'jayya'; @@ -1534,9 +1528,9 @@ function create_tables_unattended() $e107->init($e107_paths, realpath(dirname(__FILE__))); $einstall->e107 = &$e107; - - //FIXME - does not appear to work for import_configuration. ie. tables are blank except for user table. - + + //FIXME - does not appear to work for import_configuration. ie. tables are blank except for user table. + $einstall->create_tables(); $einstall->import_configuration(); return true; @@ -1587,7 +1581,7 @@ class SimpleTemplate { $TemplateData = str_replace($this->open_tag.$Tag['Tag'].$this->close_tag, $Tag['Data'], $TemplateData); } - + return $TemplateData; } } @@ -1713,7 +1707,7 @@ img{ padding: 10px; text-align: center; margin-bottom:15px; - background-color:#FFCECE; + background-color:#FFCECE; border: 1px solid #CC0000; }