Esempio n. 1
0
 /**
  * Retrieve menus, check visibility against
  * current user classes and current page url
  *
  */
 public function init()
 {
     global $_E107;
     if (vartrue($_E107['cli'])) {
         return;
     }
     //	print_a($eMenuArea);
     if (varset($_SERVER['E_DEV_MENU']) == 'true') {
         $layouts = e107::getPref('menu_layouts');
         if (!is_array($layouts)) {
             $converted = $this->convertMenuTable();
             e107::getConfig('core')->set('menu_layouts', $converted)->save();
         }
         $eMenuArea = $this->getData(THEME_LAYOUT);
         //print_a($eMenuArea);
     } else {
         $eMenuArea = $this->getDataLegacy();
     }
     $total = array();
     foreach ($eMenuArea as $area => $val) {
         foreach ($val as $row) {
             if ($this->isVisible($row)) {
                 $path = str_replace("/", "", $row['menu_path']);
                 if (!isset($total[$area])) {
                     $total[$area] = 0;
                 }
                 $this->eMenuActive[$area][] = $row;
                 $total[$area]++;
             }
         }
     }
     e107::getRender()->eMenuTotal = $total;
 }
Esempio n. 2
0
 /**
  * Register core and plugin notification events.
  */
 public function registerEvents()
 {
     $active = e107::getConfig()->get('notify');
     if (empty($active) && e_PAGE == 'notify.php') {
         e107::getMessage()->addDebug('Notify is disabled!');
         return false;
     }
     $e_event = e107::getEvent();
     if (varset($this->notify_prefs['event'])) {
         foreach ($this->notify_prefs['event'] as $id => $status) {
             $include = null;
             if ($status['class'] != e_UC_NOBODY) {
                 if (varset($status['include'])) {
                     $include = e_PLUGIN . $status['include'] . "/e_notify.php";
                     if (varset($status['legacy']) != 1) {
                         $class = $status['include'] . "_notify";
                         $method = $id;
                         $e_event->register($id, array($class, $method), $include);
                     } else {
                         $e_event->register($id, 'notify_' . $id, $include);
                     }
                 } else {
                     if (method_exists($this, 'notify_' . $id)) {
                         $e_event->register($id, array('notify', 'notify_' . $id));
                     } else {
                         $e_event->register($id, array('notify', 'generic'));
                         // use generic notification.
                     }
                 }
             }
         }
     }
     //	e107::getEvent()->debug();
 }
Esempio n. 3
0
File: e_rss.php Progetto: gitye/e107
 /**
  * Generate the Feed Data
  * @param string $parms
  * @return array
  */
 function data($parms = '')
 {
     $pref = e107::getConfig()->getPref();
     $tp = e107::getParser();
     $this->showImages = vartrue($pref['rss_shownewsimage'], false);
     $this->summaryDescription = vartrue($pref['rss_summarydiz'], false);
     $render = $pref['rss_othernews'] != 1 ? "AND (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type))" : "";
     $nobody_regexp = "'(^|,)(" . str_replace(",", "|", e_UC_NOBODY) . ")(,|\$)'";
     $topic = !empty($parms['id']) && is_numeric($parms['id']) ? " AND news_category = " . intval($parms['id']) : '';
     $limit = vartrue($parms['limit'], 10);
     $rssQuery = "SELECT n.*, u.user_id, u.user_name, u.user_email, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n\n\t\t\t\tLEFT JOIN #user AS u ON n.news_author = u.user_id\n\t\t\t\tLEFT JOIN #news_category AS nc ON n.news_category = nc.category_id\n\t\t\t\tWHERE n.news_class IN (" . USERCLASS_LIST . ") AND NOT (n.news_class REGEXP " . $nobody_regexp . ") AND n.news_start < " . time() . " AND (n.news_end=0 || n.news_end>" . time() . ") {$render} {$topic} ORDER BY n.news_datestamp DESC LIMIT 0," . $limit;
     $sql = e107::getDb();
     $sql->gen($rssQuery);
     $tmp = $sql->db_getList();
     $rss = array();
     $i = 0;
     foreach ($tmp as $value) {
         $rss[$i]['title'] = $value['news_title'];
         $rss[$i]['link'] = e107::getUrl()->create('news/view/item', $value, 'full=1');
         $rss[$i]['author'] = $value['user_name'];
         $rss[$i]['author_email'] = $value['user_email'];
         $rss[$i]['category_name'] = $tp->toHTML($value['category_name'], TRUE, 'defs');
         $rss[$i]['category_link'] = SITEURL . "news.php?cat." . $value['news_category'];
         //TODO SEFURL.
         $rss[$i]['datestamp'] = $value['news_datestamp'];
         $rss[$i]['description'] = $this->getDescription($value);
         if ($value['news_allow_comments'] && $pref['comments_disabled'] != 1) {
             $rss[$i]['comment'] = "http://" . $_SERVER['HTTP_HOST'] . e_HTTP . "comment.php?comment.news." . $value['news_id'];
         }
         $rss[$i]['media'] = $this->getMedia($value);
         $i++;
     }
     return $rss;
 }
Esempio n. 4
0
 function process()
 {
     $pref = e107::getConfig();
     $theme_pref = array();
     $theme_pref['example'] = $_POST['_blank_example'];
     $theme_pref['fb_tabs_cols'] = intval($_POST['fb_tabs_cols']);
     $pref->set('sitetheme_pref', $theme_pref);
     return $pref->dataHasChanged();
 }
Esempio n. 5
0
 function process()
 {
     $pref = e107::getConfig();
     $theme_pref = array();
     $theme_pref['example'] = $_POST['e1074a_example'];
     $theme_pref['example2'] = $_POST['e1074a_example2'];
     $pref->set('sitetheme_pref', $theme_pref);
     return $pref->dataHasChanged();
 }
Esempio n. 6
0
 function process()
 {
     $pref = e107::getConfig();
     $tp = e107::getParser();
     $theme_pref = array();
     $theme_pref['example'] = $tp->toDb($_POST['_blank_example']);
     $theme_pref['example2'] = $tp->toDb($_POST['_blank_example2']);
     $pref->set('sitetheme_pref', $theme_pref);
     return $pref->dataHasChanged();
 }
Esempio n. 7
0
 function checkTimezone()
 {
     $mes = e107::getMessage();
     $timezone = e107::pref('core', 'timezone');
     if (e107::getDate()->isValidTimezone($timezone) == false) {
         $mes->addWarning("Your timezone setting (" . $timezone . ") is invalid. It has been reset to UTC. To Modify, please go to Admin -> Preferences -> Date Display Options.", 'default', true);
         e107::getConfig()->set('timezone', 'UTC')->save(false, true, false);
         $this->refresh = true;
     }
 }
Esempio n. 8
0
 function process()
 {
     $pref = e107::getConfig();
     $tp = e107::getParser();
     $theme_pref = array();
     $theme_pref['nav_alignment'] = $_POST['nav_alignment'];
     $theme_pref['usernav_placement'] = $_POST['usernav_placement'];
     $theme_pref['branding'] = $_POST['branding'];
     $pref->set('sitetheme_pref', $theme_pref);
     return $pref->dataHasChanged();
 }
Esempio n. 9
0
 function upgrade_required()
 {
     $list = e107::getConfig()->get('e_meta_list');
     if (in_array('tinymce4', $list)) {
         return true;
     }
     if (file_exists(e_PLUGIN . "tinymce4/e_meta.php")) {
         e107::getMessage()->addInfo("Please delete the outdated file <b>" . e_PLUGIN . "tinymce4/e_meta.php</b> and then run the updating process.");
         //	print_a(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,8));
         return true;
     }
     return false;
 }
Esempio n. 10
0
 function sc_cm_comment($parm = '')
 {
     $menu_pref = e107::getConfig('menu')->getPref();
     $tp = e107::getParser();
     $COMMENT = '';
     if ($menu_pref['comment_characters'] > 0) {
         $COMMENT = strip_tags($tp->toHTML($this->var['comment_comment'], TRUE, "emotes_off, no_make_clickable", "", e107::getPref('menu_wordwrap')));
         if ($tp->ustrlen($COMMENT) > $menu_pref['comment_characters']) {
             $COMMENT = $tp->text_truncate($COMMENT, $menu_pref['comment_characters'], '') . ($this->var['comment_url'] ? " <a href='" . $this->var['comment_url'] . "'>" : "") . defset($menu_pref['comment_postfix'], $menu_pref['comment_postfix']) . ($this->var['comment_url'] ? "</a>" : "");
         }
     }
     return $COMMENT;
 }
Esempio n. 11
0
 function notify()
 {
     global $e_event;
     $this->notify_prefs = e107::getConfig("notify")->getPref();
     if (varset($this->notify_prefs['event'])) {
         foreach ($this->notify_prefs['event'] as $id => $status) {
             if ($status['class'] != 255) {
                 $e_event->register($id, 'notify_' . $id);
             }
         }
     }
     include_lan(e_LANGUAGEDIR . e_LANGUAGE . '/lan_notify.php');
 }
Esempio n. 12
0
 function __construct()
 {
     $mes = e107::getMessage();
     $frm = e107::getForm();
     $tp = e107::getParser();
     //	$this->simulation();
     $mailoutPlugins = e107::getConfig()->get('e_mailout_list');
     if (empty($_GET['id'])) {
         return;
     }
     $tmp = base64_decode($_GET['id']);
     parse_str($tmp, $data);
     $data['plugin'] = $tp->filter($data['plugin'], 'str');
     $data['email'] = $tp->filter($data['email'], 'email');
     e107::getMessage()->addDebug(print_a($data, true));
     $plugin = vartrue($data['plugin'], false);
     if (empty($data) || !e107::isInstalled($plugin) || !in_array($plugin, $mailoutPlugins)) {
         $this->invalidURL();
         return;
     }
     $ml = e107::getAddon($plugin, 'e_mailout');
     if (!empty($data['userclass'])) {
         $data['userclass'] = intval($data['userclass']);
         $listName = e107::getUserClass()->getName($data['userclass']);
     } else {
         $listName = $ml->mailerName;
     }
     if (vartrue($_POST['remove']) && !empty($data)) {
         if ($ml->unsubscribe('process', $data) != false) {
             $text = "<p><b>" . $data['email'] . "</b> has been removed from " . $listName . ".</p>";
             $mes->addSuccess($text);
         } else {
             $text = "<p>There was a problem when attempting to remove <b>" . $data['email'] . "</b> from " . $listName . ".</p>";
             $mes->addError($text);
         }
         echo "<div class='container'>" . $mes->render() . "</div>";
         return;
     }
     if ($ml->unsubscribe('check', $data) != false) {
         $text = "<p>We are very sorry for the inconvenience. <br />Please click the button below to remove <b>" . $data['email'] . "</b> from <i>" . $listName . "</i>.</p>";
         $text .= $frm->open('unsub', 'post', e_REQUEST_URI);
         $text .= $frm->button('remove', 'Remove ', 'submit');
         $text .= $frm->close();
         $mes->setTitle('Unsubscribe', E_MESSAGE_INFO)->addInfo($text);
         echo "<div class='container'>" . $mes->render() . "</div>";
         return;
     } else {
         $this->invalidURL();
         return;
     }
 }
Esempio n. 13
0
 function __construct()
 {
     $pref = e107::getPref();
     $this->use_imagecode = e107::getConfig()->get('logcode');
     $this->sec = e107::getSecureImg();
     $this->usernameLabel = '';
     $this->allowEmailLogin = $pref['allowEmailLogin'];
     if ($pref['allowEmailLogin'] == 1) {
         $this->usernameLabel = LAN_LOGINMENU_49;
     }
     if ($pref['allowEmailLogin'] == 2) {
         $this->usernameLabel = LAN_LOGINMENU_50;
     }
 }
Esempio n. 14
0
 function e_emotefilter()
 {
     $pref = e107::getPref();
     if (!$pref['emotepack']) {
         $pref['emotepack'] = "default";
         save_prefs();
     }
     $this->emotes = e107::getConfig("emote")->getPref();
     if (!vartrue($this->emotes)) {
         return;
     }
     foreach ($this->emotes as $key => $value) {
         $value = trim($value);
         if ($value) {
             // Only 'activate' emote if there's a substitution string set
             $key = preg_replace("#!(\\w{3,}?)\$#si", ".\\1", $key);
             // Next two probably to sort out legacy issues - may not be required any more
             $key = preg_replace("#_(\\w{3})\$#", ".\\1", $key);
             $key = str_replace("!", "_", $key);
             $filename = e_IMAGE . "emotes/" . $pref['emotepack'] . "/" . $key;
             $fileloc = SITEURLBASE . e_IMAGE_ABS . "emotes/" . $pref['emotepack'] . "/" . $key;
             if (file_exists($filename)) {
                 if (strstr($value, " ")) {
                     $tmp = explode(" ", $value);
                     foreach ($tmp as $code) {
                         $this->search[] = " " . $code;
                         $this->search[] = "\n" . $code;
                         //TODO CSS class?
                         $this->replace[] = " <img src='" . $fileloc . "' alt='' style='vertical-align:middle; border:0' /> ";
                         $this->replace[] = "\n <img src='" . $fileloc . "' alt='' style='vertical-align:middle; border:0' /> ";
                     }
                     unset($tmp);
                 } else {
                     if ($value) {
                         $this->search[] = " " . $value;
                         $this->search[] = "\n" . $value;
                         //TODO CSS class?
                         $this->replace[] = " <img src='" . $filename . "' alt='' style='vertical-align:middle; border:0' /> ";
                         $this->replace[] = "\n <img src='" . $filename . "' alt='' style='vertical-align:middle; border:0' /> ";
                     }
                 }
             }
         } else {
             unset($this->emotes[$key]);
         }
     }
 }
Esempio n. 15
0
 function upgrade_required()
 {
     if (!e107::getDb()->isTable('forum_thread')) {
         return true;
     }
     if (!e107::getDb()->field('forum_thread', 'thread_id')) {
         return true;
         // true to trigger an upgrade alert, and false to not.
     }
     if (e107::getDb()->field('forum_thread', 'thread_sef')) {
         e107::getDb()->gen("ALTER TABLE `#forum_thread` DROP `thread_sef` ");
     }
     $legacyMenuPref = e107::getConfig('menu')->getPref();
     if (isset($legacyMenuPref['newforumposts_caption'])) {
     }
     return false;
 }
Esempio n. 16
0
 function sc_logo($parm)
 {
     parse_str($parm);
     // Optional {LOGO=file=file_name} or {LOGO=link=url} or {LOGO=file=file_name&link=url}
     // Paths to image file, link are relative to site base
     $tp = e107::getParser();
     $logopref = e107::getConfig('core')->get('sitelogo');
     $logo = $tp->replaceConstants($logopref);
     if (vartrue($logopref) && is_readable($logo)) {
         $logo = $tp->replaceConstants($logopref, 'abs');
         $path = $tp->replaceConstants($logopref);
     } elseif (isset($file) && $file && is_readable($file)) {
         $logo = e_HTTP . $file;
         // HTML path
         $path = e_BASE . $file;
         // PHP path
     } else {
         if (is_readable(THEME . 'images/e_logo.png')) {
             $logo = THEME_ABS . 'images/e_logo.png';
             // HTML path
             $path = THEME . 'images/e_logo.png';
             // PHP path
         } else {
             $logo = e_IMAGE_ABS . 'logo.png';
             // HTML path
             $path = e_IMAGE . 'logo.png';
             // PHP path
         }
     }
     $dimensions = getimagesize($path);
     $image = "<img class='logo' src='" . $logo . "' style='width: " . $dimensions[0] . "px; height: " . $dimensions[1] . "px' alt='" . SITENAME . "' />\n";
     if (isset($link) && $link) {
         if ($link == 'index') {
             $image = "<a href='" . e_HTTP . "index.php'>" . $image . "</a>";
         } else {
             $image = "<a href='" . e_HTTP . $link . "'>" . $image . "</a>";
         }
     }
     return $image;
 }
Esempio n. 17
0
 public function init()
 {
     if (!empty($_POST['save_social'])) {
         $cfg = e107::getConfig();
         $cfg->setPref('social_login', $_POST['social_login']);
         $cfg->setPref('social_login_active', $_POST['social_login_active']);
         $cfg->setPref('xurl', $_POST['xurl']);
         $cfg->save(true, true, true);
     }
     $tp = e107::getParser();
     require_once e_PLUGIN . "social/e_shortcode.php";
     $obj = new social_shortcodes();
     $providers = $obj->getProviders();
     foreach ($providers as $k => $v) {
         $this->prefs['sharing_providers']['writeParms']['optArray'][$k] = $k;
     }
     //	print_a($bla);
     // Single/ Social  Login / / copied from hybridAuth config.php so it's easy to add more.
     // Used Below.
     $this->social_logins = array("OpenID" => array("enabled" => true), "Yahoo" => array("enabled" => true), "AOL" => array("enabled" => true), "Facebook" => array("enabled" => true, "keys" => array("id" => "", "secret" => ""), "trustForwarded" => false, "scope" => "", "display" => ""), "Foursquare" => array("enabled" => true, "keys" => array("id" => "", "secret" => "")), "Github" => array("enabled" => true, "keys" => array("id" => "", "secret" => "")), "Google" => array("enabled" => true, "keys" => array("id" => "", "secret" => ""), "scope" => ""), "LinkedIn" => array("enabled" => true, "keys" => array("key" => "", "secret" => "")), "Live" => array("enabled" => true, "keys" => array("id" => "", "secret" => "")), "Twitter" => array("enabled" => true, "keys" => array("key" => "", "secret" => "")));
     $this->social_external = array("Facebook" => "https://developers.facebook.com/apps", "Twitter" => "https://dev.twitter.com/apps/new", "Google" => "https://code.google.com/apis/console/", "Live" => "https://manage.dev.live.com/ApplicationOverview.aspx", "LinkedIn" => "https://www.linkedin.com/secure/developer", "Foursquare" => "https://www.foursquare.com/oauth/", "Github" => "https://github.com/settings/applications/new");
 }
Esempio n. 18
0
 /**
  * @return bool
  */
 public function initialPageSubmit()
 {
     if (empty($_POST['set_initial_classes'])) {
         return false;
     }
     $pref['init_class_stage'] = intval($_POST['init_class_stage']);
     $temp = array();
     foreach ($_POST['init_classes'] as $ic) {
         $temp[] = intval($ic);
     }
     $newval = implode(',', $temp);
     $pref['initial_user_classes'] = $newval;
     e107::getConfig()->setPref($pref)->save(true, true, true);
 }
Esempio n. 19
0
 function filter_plugins($plugs)
 {
     $smile_pref = e107::getConfig()->getPref('smiley_activate');
     $admin_only = array("ibrowser");
     $plug_array = explode(",", $plugs);
     foreach ($plug_array as $val) {
         if (in_array($val, $admin_only) && !ADMIN) {
             continue;
         }
         if (!$smile_pref && $val == "emoticons") {
             continue;
         }
         $tinymce_plugins[] = $val;
     }
     return $tinymce_plugins;
 }
Esempio n. 20
0
function update_706_to_800($type = '')
{
    global $pref, $e107info;
    global $sysprefs, $eArrayStorage;
    //$mes = new messageLog;		// Combined logging and message displaying handler
    //$mes = e107::getMessage();
    $log = e107::getAdminLog();
    // Used for combined logging and message displaying
    $sql = e107::getDb();
    $sql2 = e107::getDb('sql2');
    $tp = e107::getParser();
    $ns = e107::getRender();
    e107::getCache()->clearAll('db');
    e107::getCache()->clearAll('system');
    // List of unwanted $pref values which can go
    $obs_prefs = array('frontpage_type', 'rss_feeds', 'log_lvcount', 'zone', 'upload_allowedfiletype', 'real', 'forum_user_customtitle', 'utf-compatmode', 'frontpage_method', 'standards_mode', 'image_owner', 'im_quality', 'signup_option_timezone', 'modules', 'plug_sc', 'plug_bb', 'plug_status', 'plug_latest', 'subnews_hide_news', 'upload_storagetype');
    // List of DB tables not required (includes a few from 0.6xx)
    $obs_tables = array('flood', 'headlines', 'stat_info', 'stat_counter', 'stat_last', 'session', 'preset', 'tinymce');
    // List of DB tables newly required  (defined in core_sql.php) (The existing dblog table gets renamed)
    // No Longer required. - automatically checked against core_sql.php.
    //	$new_tables = array('audit_log', 'dblog', 'news_rewrite', 'core_media', 'core_media_cat','cron', 'mail_recipients', 'mail_content');
    // List of core prefs that need to be converted from serialized to e107ArrayStorage.
    $serialized_prefs = array("'emote'", "'menu_pref'", "'search_prefs'", "'emote_default'", "'pm_prefs'");
    $create_dir = array(e_MEDIA, e_SYSTEM, e_CACHE, e_CACHE_CONTENT, e_CACHE_IMAGE, e_CACHE_DB, e_LOG, e_BACKUP, e_CACHE_URL, e_TEMP, e_IMPORT);
    foreach ($create_dir as $dr) {
        if (!is_dir($dr)) {
            mkdir($dr, 0755);
        }
    }
    // List of changed DB tables (defined in core_sql.php)
    // No Longer required. - automatically checked against core_sql.php.
    // (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster)
    // $changed_tables = array('user', 'dblog', 'admin_log', 'userclass_classes', 'banlist', 'menus',
    // 'plugin', 'news', 'news_category', 'online', 'page', 'links', 'comments');
    // List of changed DB tables from core plugins (defined in pluginname_sql.php file)
    // key = plugin directory name. Data = comma-separated list of tables to check
    // (primarily those which have changed significantly; for the odd field write some explicit code - it'll run faster)
    // No Longer required. - automatically checked by db-verify
    /* $pluginChangedTables = array('linkwords' => 'linkwords',
    								'featurebox' => 'featurebox',
    								'links_page' => 'links_page',
    								'poll' => 'polls',
    								'content' => 'pcontent'
    								);
    	 
    	 */
    /*
    	$setCorePrefs = array( //modified prefs during upgrade.
    		'adminstyle' 		=> 'infopanel',
    		'admintheme' 		=> 'bootstrap',
    		'admincss'			=> 'admin_style.css',
    		'resize_dimensions' => array(
    			'news-image' 	=> array('w' => 250, 'h' => 250),
    			'news-bbcode' 	=> array('w' => 250, 'h' => 250),
    			'page-bbcode' 	=> array('w' => 250, 'h' => 250)
    		)
    	);
    */
    $do_save = TRUE;
    // List of changed menu locations.
    $changeMenuPaths = array(array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'sitebutton_menu'), array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'compliance_menu'), array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'powered_by_menu'), array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'sitebutton_menu'), array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'counter_menu'), array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'latestnews_menu'), array('oldpath' => 'compliance_menu', 'newpath' => 'siteinfo', 'menu' => 'compliance_menu'), array('oldpath' => 'powered_by_menu', 'newpath' => 'siteinfo', 'menu' => 'powered_by_menu'), array('oldpath' => 'sitebutton_menu', 'newpath' => 'siteinfo', 'menu' => 'sitebutton_menu'), array('oldpath' => 'counter_menu', 'newpath' => 'siteinfo', 'menu' => 'counter_menu'), array('oldpath' => 'usertheme_menu', 'newpath' => 'user', 'menu' => 'usertheme_menu'), array('oldpath' => 'userlanguage_menu', 'newpath' => 'user', 'menu' => 'userlanguage_menu'), array('oldpath' => 'lastseen_menu', 'newpath' => 'online', 'menu' => 'lastseen_menu'), array('oldpath' => 'other_news_menu', 'newpath' => 'news', 'menu' => 'other_news_menu'), array('oldpath' => 'other_news_menu', 'newpath' => 'news', 'menu' => 'other_news2_menu'), array('oldpath' => 'user_menu', 'newpath' => 'user', 'menu' => 'usertheme_menu'), array('oldpath' => 'user_menu', 'newpath' => 'user', 'menu' => 'userlanguage_menu'), array('oldpath' => 'poll_menu', 'newpath' => 'poll', 'menu' => 'poll_menu'), array('oldpath' => 'banner_menu', 'newpath' => 'banner', 'menu' => 'banner_menu'), array('oldpath' => 'online_menu', 'newpath' => 'online', 'menu' => 'online_menu'));
    // List of DB tables (key) and field (value) which need changing to accommodate IPV6 addresses
    $ip_upgrade = array('download_requests' => 'download_request_ip', 'submitnews' => 'submitnews_ip', 'tmp' => 'tmp_ip', 'chatbox' => 'cb_ip');
    $db_parser = new db_table_admin();
    // Class to read table defs and process them
    $do_save = FALSE;
    // Set TRUE to update prefs when update complete
    $updateMessages = array();
    // Used to log actions for the admin log - TODO: will go once all converted to new class
    $just_check = $type == 'do' ? FALSE : TRUE;
    // TRUE if we're just seeing whether an update is needed
    //	if (!$just_check)
    //	{
    //	foreach(vartrue($setCorePrefs) as $k=>$v)
    //	{
    //		$pref[$k] = $v;
    //	}
    //	}
    if (!$just_check) {
        $log->logMessage(LAN_UPDATE_14 . $e107info['e107_version'], E_MESSAGE_NODISPLAY);
    }
    $statusTexts = array(E_MESSAGE_SUCCESS => 'Success', E_MESSAGE_ERROR => 'Fail', E_MESSAGE_INFO => 'Info');
    if (isset($pref['forum_user_customtitle']) && !isset($pref['signup_option_customtitle'])) {
        if ($just_check) {
            return update_needed('pref: forum_user_customtitle needs to be renamed');
        }
        $pref['signup_option_customtitle'] = $pref['forum_user_customtitle'];
        unset($pref['forum_user_customtitle']);
        $log->logMessage(LAN_UPDATE_20 . 'customtitle', E_MESSAGE_SUCCESS);
        $do_save = TRUE;
    }
    // convert all serialized core prefs to e107 ArrayStorage;
    $serialz_qry = "SUBSTRING( e107_value,1,5)!='array' AND e107_value !='' ";
    $serialz_qry .= "AND e107_name IN (" . implode(",", $serialized_prefs) . ") ";
    if (e107::getDb()->select("core", "*", $serialz_qry)) {
        if ($just_check) {
            return update_needed('Convert serialized core prefs');
        }
        while ($row = e107::getDb()->fetch(MYSQL_ASSOC)) {
            $status = e107::getDb('sql2')->update('core', "e107_value=\"" . convert_serialized($row['e107_value']) . "\" WHERE e107_name='" . $row['e107_name'] . "'") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
            $log->addDebug(LAN_UPDATE_22 . $row['e107_name'] . ": " . $status);
        }
    }
    if (e107::getDb()->select("core", "*", "e107_name='pm_prefs' LIMIT 1")) {
        if ($just_check) {
            return update_needed('Rename the pm prefs');
        }
        e107::getDb()->update("core", "e107_name='plugin_pm' WHERE e107_name = 'pm_prefs'");
    }
    //@TODO de-serialize the user_prefs also.
    // Banlist
    if (!$sql->field('banlist', 'banlist_id')) {
        if ($just_check) {
            return update_needed('Banlist table requires updating.');
        }
        $sql->gen("ALTER TABLE #banlist DROP PRIMARY KEY");
        $sql->gen("ALTER TABLE `#banlist` ADD `banlist_id` INT( 11 ) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
    }
    // Move the maximum online counts from menu prefs to a separate pref - 'history'
    e107::getCache()->clearAll('system');
    $menuConfig = e107::getConfig('menu', true, true);
    if ($menuConfig->get('most_members_online') || $menuConfig->get('most_guests_online') || $menuConfig->get('most_online_datestamp')) {
        $status = E_MESSAGE_DEBUG;
        if ($just_check) {
            return update_needed('Move online counts from menupref');
        }
        $newPrefs = e107::getConfig('history');
        foreach (array('most_members_online', 'most_guests_online', 'most_online_datestamp') as $v) {
            if (FALSE === $newPrefs->get($v, FALSE)) {
                if (FALSE !== $menuConfig->get($v, FALSE)) {
                    $newPrefs->set($v, $menuConfig->get($v));
                } else {
                    $newPrefs->set($v, 0);
                }
            }
            $menuConfig->remove($v);
        }
        $result = $newPrefs->save(false, true, false);
        if ($result === TRUE) {
            $resultMessage = 'Historic member counts updated';
            $result = $menuConfig->save(false, true, false);
            // Only re-save if successul.
        } elseif ($result === FALSE) {
            $resultMessage = 'moving historic member counts';
            $status = E_MESSAGE_ERROR;
        } else {
            // No change
            $resultMessage = 'Historic member counts already updated';
            $status = E_MESSAGE_INFO;
        }
        // $result = $menuConfig->save(false, true, false);	// Save updated menuprefs - without the counts - don't delete them if it fails.
        //$updateMessages[] = $statusTexts[$status].': '.$resultMessage;		// Admin log message
        $log->logMessage($resultMessage, $status);
        // User message
    }
    // ++++++++ Modify Menu Paths +++++++.
    if (varset($changeMenuPaths)) {
        foreach ($changeMenuPaths as $val) {
            $qry = "SELECT menu_path FROM `#menus` WHERE menu_name = '" . $val['menu'] . "' AND (menu_path='" . $val['oldpath'] . "' || menu_path='" . $val['oldpath'] . "/' ) LIMIT 1";
            if ($sql->gen($qry)) {
                if ($just_check) {
                    return update_needed('Menu path changed required:  ' . $val['menu'] . ' ');
                }
                $updqry = "menu_path='" . $val['newpath'] . "/' WHERE menu_name = '" . $val['menu'] . "' AND (menu_path='" . $val['oldpath'] . "' || menu_path='" . $val['oldpath'] . "/' ) ";
                $status = $sql->update('menus', $updqry) ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR;
                $log->logMessage(LAN_UPDATE_23 . '<b>' . $val['menu'] . '</b> : ' . $val['oldpath'] . ' => ' . $val['newpath'], $status);
                // LAN_UPDATE_25;
                // catch_error($sql);
            }
        }
    }
    // Leave this one here.. just in case..
    //delete record for online_extended_menu (now only using one online menu)
    if ($sql->db_Select('menus', '*', "menu_path='online_extended_menu' || menu_path='online_extended_menu/'")) {
        if ($just_check) {
            return update_needed("The Menu table needs to have some paths corrected in its data.");
        }
        $row = $sql->db_Fetch();
        //if online_extended is activated, we need to activate the new 'online' menu, and delete this record
        if ($row['menu_location'] != 0) {
            $status = $sql->update('menus', "menu_name='online_menu', menu_path='online/' WHERE menu_path='online_extended_menu' || menu_path='online_extended_menu/' ") ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR;
            $log->logMessage(LAN_UPDATE_23 . "<b>online_menu</b> : online/", $status);
        } else {
            //else if the menu is not active
            //we need to delete the online_extended menu row, and change the online_menu to online
            $sql->delete('menus', " menu_path='online_extended_menu' || menu_path='online_extended_menu/' ");
            $log->logMessage(LAN_UPDATE_31, E_MESSAGE_DEBUG);
        }
        catch_error($sql);
    }
    //change menu_path for online_menu (if it still exists)
    if ($sql->db_Select('menus', 'menu_path', "menu_path='online_menu' || menu_path='online_menu/'")) {
        if ($just_check) {
            return update_needed('change menu_path for online menu');
        }
        $status = $sql->update('menus', "menu_path='online/' WHERE menu_path='online_menu' || menu_path='online_menu/' ") ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR;
        $log->logMessage(LAN_UPDATE_23 . "<b>online_menu</b> : online/", $status);
        catch_error($sql);
    }
    if (!$just_check) {
        // Alert Admin to delete deprecated menu folders.
        $chgPath = array();
        foreach ($changeMenuPaths as $cgpArray) {
            if (is_dir(e_PLUGIN . $cgpArray['oldpath'])) {
                if (!in_array($cgpArray['oldpath'], $chgPath)) {
                    $chgPath[] = $cgpArray['oldpath'];
                }
            }
        }
        if (count($chgPath)) {
            $log->addWarning(LAN_UPDATE_57 . ' ');
            array_unique($chgPath);
            asort($chgPath);
            foreach ($chgPath as $cgp) {
                $log->addWarning(e_PLUGIN_ABS . "<b>" . $cgp . "</b>");
            }
        }
    }
    //---------------------------------------------------------
    //			Comments - split user field
    //---------------------------------------------------------
    if ($sql->db_Field('comments', 'comment_author')) {
        if ($just_check) {
            return update_needed('Comment table author field update');
        }
        if (!$sql->db_Field('comments', 'comment_author_id') && !$sql->gen("ALTER TABLE `#comments`\r\n\t\t\t\tADD COLUMN comment_author_id int(10) unsigned NOT NULL default '0' AFTER `comment_author`,\r\n\t\t\t\tADD COLUMN comment_author_name varchar(100) NOT NULL default '' AFTER `comment_author_id`")) {
            // Flag error
            // $commentMessage = LAN_UPDAXXTE_34;
            $log->logMessage(LAN_UPDATE_21 . "comments", E_MESSAGE_ERROR);
        } else {
            if (FALSE === $sql->update('comments', "comment_author_id=SUBSTRING_INDEX(`comment_author`,'.',1),  comment_author_name=SUBSTRING(`comment_author` FROM POSITION('.' IN `comment_author`)+1)")) {
                // Flag error
                $log->logMessage(LAN_UPDATE_21 . 'comments', E_MESSAGE_ERROR);
            } else {
                // Delete superceded field - comment_author
                if (!$sql->gen("ALTER TABLE `#comments` DROP COLUMN `comment_author`")) {
                    // Flag error
                    $log->logMessage(LAN_UPDATE_24 . 'comments - comment_author', E_MESSAGE_ERROR);
                }
            }
        }
        $log->logMessage(LAN_UPDATE_21 . 'comments', E_MESSAGE_DEBUG);
    }
    //	Add index to download history
    // Deprecated by db-verify-class
    // if (FALSE !== ($temp = addIndexToTable('download_requests', 'download_request_datestamp', $just_check, $updateMessages)))
    // {
    // if ($just_check)
    // {
    // return update_needed($temp);
    // }
    // }
    // Extra index to tmp table
    // Deprecated by db-verify-class
    // if (FALSE !== ($temp = addIndexToTable('tmp', 'tmp_time', $just_check, $updateMessages)))
    // {
    // if ($just_check)
    // {
    // return update_needed($temp);
    // }
    // }
    // Extra index to rss table (if used)
    // Deprecated by db-verify-class
    // if (FALSE !== ($temp = addIndexToTable('rss', 'rss_name', $just_check, $updateMessages, TRUE)))
    // {
    // if ($just_check)
    // {
    // return update_needed($temp);
    // }
    // }
    // Front page prefs (logic has changed)
    if (!isset($pref['frontpage_force'])) {
        if ($just_check) {
            return update_needed('Change front page prefs');
        }
        $pref['frontpage_force'] = array(e_UC_PUBLIC => '');
        $fpdef = vartrue($pref['frontpage']['all']) == 'index.php' ? 'index.php' : 'news.php';
        $pref['frontpage'] = array(e_UC_PUBLIC => $fpdef);
        // $_pdateMessages[] = LAN_UPDATE_38; //FIXME
        $log->logMessage(LAN_UPDATE_20 . "frontpage", E_MESSAGE_DEBUG);
        $do_save = TRUE;
    }
    // Check need for user timezone before we delete the field
    if (vartrue($pref['signup_option_timezone'])) {
        if ($sql->db_Field('user', 'user_timezone', '', TRUE) && !$sql->db_Field('user_extended', 'user_timezone', '', TRUE)) {
            if ($just_check) {
                return update_needed('Move user timezone info');
            }
            if (!copy_user_timezone()) {
                // Error doing the transfer
                //$updateMessages[] = LAN_UPDATE_42;
                $log->logMessage(LAN_UPDATE_42, E_MESSAGE_ERROR);
                return FALSE;
            }
            //$updateMessages[] = LAN_UPDATE_41;
            $log->logMessage(LAN_UPDATE_41, E_MESSAGE_DEBUG);
        }
    }
    // Tables defined in core_sql.php to be RENAMED.
    // Next bit will be needed only by the brave souls who used an early CVS - probably delete before release
    if ($sql->isTable('rl_history') && !$sql->isTable('dblog')) {
        if ($just_check) {
            return update_needed('Rename rl_history to dblog');
        }
        $sql->gen('ALTER TABLE `' . MPREFIX . 'rl_history` RENAME `' . MPREFIX . 'dblog`');
        //$updateMessages[] = LAN_UPDATE_44;
        $log->logMessage(LAN_UPDATE_44, E_MESSAGE_DEBUG);
        catch_error($sql);
    }
    //---------------------------------
    if ($sql->isTable('dblog') && !$sql->isTable('admin_log')) {
        if ($just_check) {
            return update_needed('Rename dblog to admin_log');
        }
        $sql->gen('ALTER TABLE `' . MPREFIX . 'dblog` RENAME `' . MPREFIX . 'admin_log`');
        catch_error($sql);
        //$updateMessages[] = LAN_UPDATE_43;
        $log->logMessage(LAN_UPDATE_43, E_MESSAGE_DEBUG);
    }
    // New tables required (list at top. Definitions in core_sql.php)
    // ALL DEPRECATED by db_verify class.. see below.
    /*
    	foreach ($new_tables as $nt)
    	{
    		if (!$sql->isTable($nt))
    		{
    			if ($just_check) return update_needed('Add table: '.$nt);
    			// Get the definition
    			$defs = $db_parser->get_table_def($nt,e_ADMIN.'sql/core_sql.php');
    			if (count($defs)) // **** Add in table here
    			{	
    				$status = $sql->gen('CREATE TABLE `'.MPREFIX.$defs[0][1].'` ('.$defs[0][2].') TYPE='.$defs[0][3]) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
    			//	$updateMessages[] = LAN_UPDATE_45.$defs[0][1];		
    				$log->logMessage(LAN_UPDATE_27.$defs[0][1], $status);
    				// catch_error($sql);
    			}
    			else
    			{  // error parsing defs file
    				$log->logMessage(LAN_UPDATE_46.$defs[0][1], E_MESSAGE_ERROR);
    			}
    			unset($defs);
    		}
    	}
    	
    	
    	// Tables whose definition needs changing significantly
         $debugLevel = E107_DBG_SQLDETAILS;
    	foreach ($changed_tables as $ct)
    	{
    	  $req_defs = $db_parser->get_table_def($ct,e_ADMIN."sql/core_sql.php");
    	  $req_fields = $db_parser->parse_field_defs($req_defs[0][2]);					// Required definitions
    	  if ($debugLevel)
    	  {
    	  	$log->logMessage("Required table structure: <br />".$db_parser->make_field_list($req_fields), E_MESSAGE_DEBUG);			
    	  } 
    	  if ((($actual_defs = $db_parser->get_current_table($ct)) === FALSE) || !is_array($actual_defs))			// Adds current default prefix
    	  {
    			$log->logMessage("Couldn't get table structure: ".$ct, E_MESSAGE_DEBUG);		
    	  }
    	  else
    	  {
    //		echo $db_parser->make_table_list($actual_defs);
    		$actual_fields = $db_parser->parse_field_defs($actual_defs[0][2]);
    		if ($debugLevel)
    		{
    			$log->logMessage("Actual table structure: <br />".$db_parser->make_field_list($actual_fields), E_MESSAGE_DEBUG);		
    		} 
    		$diffs = $db_parser->compare_field_lists($req_fields,$actual_fields);
    		if (count($diffs[0]))
    		{  // Changes needed
    		  	if ($just_check) return update_needed("Field changes rqd; table: ".$ct);
    		
    			// Do the changes here
    		  	if ($debugLevel)
    		  	{
    		  		$log->logMessage("List of changes found:<br />".$db_parser->make_changes_list($diffs), E_MESSAGE_DEBUG);		
    		  	} 
    		  
    			$qry = 'ALTER TABLE '.MPREFIX.$ct.' '.implode(', ',$diffs[1]);
    		  
    			if ($debugLevel)
    			{
    				$log->logMessage("Update Query used: ".$qry, E_MESSAGE_DEBUG);	
    			} 
    		  
    			$status = $sql->gen($qry) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; 
    			$log->logMessage(LAN_UPDATE_21.$ct, $status);
    		  	catch_error($sql);
    		}
    	  }
    	}
    	// Plugin tables whose definition needs changing significantly
    	foreach ($pluginChangedTables as $plugName => $plugList)
    	{
    		if (e107::isInstalled($plugName))
    		{
    			$ttc = explode(',',$plugList);
    			foreach ($ttc as $ct)
    			{
    				$sqlDefs = e_PLUGIN.$plugName.'/'.str_replace('_menu','',$plugName).'_sql.php';		// Filename containing definitions
    //				echo "Looking at file: {$sqlDefs}, table {$ct}<br />";
    				$req_defs = $db_parser->get_table_def($ct,$sqlDefs);
    				if (!is_array($req_defs))
    				{
    					echo "Couldn't get definitions from file {$sqlDefs}<br />";
    					continue;
    				}
    				$req_fields = $db_parser->parse_field_defs($req_defs[0][2]);					// Required definitions
    				if (E107_DBG_SQLDETAILS)
    				{
    				  $message = "Required plugin table structure: <br />".$db_parser->make_field_list($req_fields);
    				  
    				  $log->logMessage($message, E_MESSAGE_DEBUG);
    				  	
    				} 
    				if ((($actual_defs = $db_parser->get_current_table($ct)) === FALSE) || !is_array($actual_defs))			// Adds current default prefix
    				{
    //	    			echo "Couldn't get table structure: {$ct}<br />";
    				}
    				else
    				{
    //					echo $db_parser->make_table_list($actual_defs);
    					$actual_fields = $db_parser->parse_field_defs($actual_defs[0][2]);
    					if (E107_DBG_SQLDETAILS)
    					{					
    						$message= "Actual table structure: <br />".$db_parser->make_field_list($actual_fields);
    						$log->logMessage($message, E_MESSAGE_DEBUG);
    					} 
    					$diffs = $db_parser->compare_field_lists($req_fields,$actual_fields);
    					if (count($diffs[0]))
    					{  // Changes needed
    						if (E107_DBG_SQLDETAILS)
    						{
    							$message = "List of changes found:<br />".$db_parser->make_changes_list($diffs);
    							$log->logMessage($message, E_MESSAGE_DEBUG);	
    						} 
    						if ($just_check) return update_needed("Field changes rqd; plugin table: ".$ct);
    						// Do the changes here
    						$qry = 'ALTER TABLE '.MPREFIX.$ct.' '.implode(', ',$diffs[1]);
    						if (E107_DBG_SQLDETAILS)
    						{
    							 $message = "Update Query used: ".$qry."<br />";
    							 $log->logMessage($message, E_MESSAGE_DEBUG);	
    						}
    						$sql->gen($qry);
    						$updateMessages[] = LAN_UPDATE_51.$ct;  
    						$log->logMessage(LAN_UPDATE_51.$ct, E_MESSAGE_SUCCESS);
    						catch_error($sql);
    					}
    				}
    			}
    		}
    	}
    */
    // Obsolete tables (list at top)
    $sql->mySQLtableList = false;
    // clear the cached table list.
    foreach ($obs_tables as $ot) {
        if ($sql->isTable($ot)) {
            if ($just_check) {
                return update_needed("Delete table: " . $ot);
            }
            $status = $sql->gen('DROP TABLE `' . MPREFIX . $ot . '`') ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR;
            $log->logMessage(LAN_UPDATE_25 . $ot, $status);
        }
    }
    // Tables where IP address field needs updating to accommodate IPV6
    // Set to varchar(45) - just in case something uses the IPV4 subnet (see http://en.wikipedia.org/wiki/IPV6#Notation)
    foreach ($ip_upgrade as $t => $f) {
        if ($sql->isTable($t)) {
            // Check for table - might add some core plugin tables in here
            if ($field_info = $sql->db_Field($t, $f, '', TRUE)) {
                if (strtolower($field_info['Type']) != 'varchar(45)') {
                    if ($just_check) {
                        return update_needed('Update IP address field ' . $f . ' in table ' . $t);
                    }
                    $status = $sql->gen("ALTER TABLE `" . MPREFIX . $t . "` MODIFY `{$f}` VARCHAR(45) NOT NULL DEFAULT '';") ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR;
                    $log->logMessage(LAN_UPDATE_26 . $t . ' - ' . $f, $status);
                    // catch_error($sql);
                }
            } else {
                // Got a strange error here
            }
        }
    }
    // Obsolete prefs (list at top)
    // Intentionally do this last - we may check some of them during the update
    $accum = array();
    foreach ($obs_prefs as $p) {
        if (isset($pref[$p])) {
            if ($just_check) {
                return update_needed('Remove obsolete prefs');
            }
            unset($pref[$p]);
            $do_save = TRUE;
            $log->addDebug('Removed obsolete pref: ' . $p);
            //	$accum[] = $p;
        }
    }
    /* -------------- Upgrade Entire Table Structure - Multi-Language Supported ----------------- */
    // ONLY ever add fields, never deletes.
    require_once e_HANDLER . "db_verify_class.php";
    $dbv = new db_verify();
    if ($plugUpgradeReq = e107::getPlugin()->updateRequired()) {
        $exclude = array_keys($plugUpgradeReq);
        // search xxxxx_setup.php and check for 'upgrade_required()' == true.
        asort($exclude);
    } else {
        $exclude = false;
    }
    $dbv->compareAll($exclude);
    // core & plugins, but not plugins calling for an update with xxxxx_setup.php
    if (count($dbv->errors)) {
        if ($just_check) {
            $mes = e107::getMessage();
            $log->addDebug(print_a($dbv->errors, true));
            return update_needed("Database Tables require updating.");
        }
        $dbv->compileResults();
        $dbv->runFix();
        // Fix entire core database structure and plugins too.
    }
    // print_a($dbv->results);
    // print_a($dbv->fixList);
    //TODO - send notification messages to Log.
    if ($sql->field('page', 'page_theme') && $sql->gen("SELECT * FROM `#page` WHERE page_theme != '' AND menu_title = '' LIMIT 1")) {
        if ($just_check) {
            return update_needed("Pages/Menus Table requires updating.");
        }
        if ($sql->update('page', "menu_name = page_theme, menu_title = page_title, menu_text = page_text, menu_template='default', page_title = '', page_text = '' WHERE page_theme !='' AND menu_title = '' AND menu_text = '' ")) {
            $sql->gen("ALTER TABLE `#page` DROP page_theme ");
            $mes = e107::getMessage();
            $log->addDebug("Successfully updated pages/menus table to new format. ");
        }
    }
    if ($sql->field('plugin', 'plugin_releaseUrl')) {
        if ($just_check) {
            return update_needed('plugin_releaseUrl is deprecated and needs to be removed. ');
        }
        if ($sql->gen("ALTER TABLE `#plugin` DROP `plugin_releaseUrl`")) {
            $log->addDebug("Successfully removed plugin_releaseUrl. ");
        }
    }
    // --- Notify Prefs
    //	$notify_prefs = $sysprefs -> get('notify_prefs');
    //	$notify_prefs = $eArrayStorage -> ReadArray($notify_prefs);
    e107::getCache()->clearAll('system');
    $notify_prefs = e107::getConfig('notify', true, true)->getPref();
    $nt_changed = 0;
    if (vartrue($notify_prefs['event'])) {
        foreach ($notify_prefs['event'] as $e => $d) {
            if (isset($d['type'])) {
                if ($just_check) {
                    return update_needed('Notify pref: ' . $e . ' outdated');
                }
                switch ($d['type']) {
                    case 'main':
                        $notify_prefs['event'][$e]['class'] = e_UC_MAINADMIN;
                        break;
                    case 'class':
                        // Should already have class defined
                        break;
                    case 'email':
                        $notify_prefs['event'][$e]['class'] = 'email';
                        break;
                    case 'off':
                        // Need to disable
                    // Need to disable
                    default:
                        $notify_prefs['event'][$e]['class'] = e_UC_NOBODY;
                        // Just disable if we don't know what else to do
                }
                $nt_changed++;
                $notify_prefs['event'][$e]['legacy'] = 1;
                unset($notify_prefs['event'][$e]['type']);
            }
        }
    }
    if ($nt_changed) {
        $s_prefs = $tp->toDB($notify_prefs);
        $s_prefs = $eArrayStorage->WriteArray($s_prefs);
        // Could we use $sysprefs->set($s_prefs,'notify_prefs') instead - avoids caching problems  ????
        $status = $sql->update("core", "e107_value='" . $s_prefs . "' WHERE e107_name='notify_prefs'") !== FALSE ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR;
        $message = str_replace('--COUNT--', $nt_changed, LAN_UPDATE_20);
        $log->logMessage($message, $status);
    }
    // ---------------  Saved emails - copy across
    if (!$just_check && $sql->db_Select('generic', '*', "gen_type='massmail'")) {
        if ($just_check) {
            return update_needed('Copy across saved emails');
        }
        require_once e_HANDLER . 'mail_manager_class.php';
        $mailHandler = new e107MailManager();
        $i = 0;
        while ($row = $sql->db_Fetch(MYSQL_ASSOC)) {
            $mailRecord = array('mail_create_date' => $row['gen_datestamp'], 'mail_creator' => $row['gen_user_id'], 'mail_title' => $row['gen_ip'], 'mail_subject' => $row['gen_ip'], 'mail_body' => $row['gen_chardata'], 'mail_content_status' => MAIL_STATUS_SAVED);
            $mailHandler->mailtoDb($mailRecord, TRUE);
            $mailHandler->saveEmail($mailRecord, TRUE);
            $sql2->delete('generic', 'gen_id=' . intval($row['gen_id']));
            // Delete as we go in case operation fails part way through
            $i++;
        }
        unset($mailHandler);
        $log->logMessage(str_replace('--COUNT--', $i, LAN_UPDATE_28));
    }
    // -------------------  Populate Plugin Table With Changes ------------------
    if (!isset($pref['shortcode_legacy_list'])) {
        if ($just_check) {
            return update_needed('Legacy shortcode conversion');
        }
        // Reset, legacy and new shortcode list will be generated in plugin update routine
        $pref['shortcode_legacy_list'] = array();
        $pref['shortcode_list'] = array();
        save_prefs();
        $ep = e107::getPlugin();
        $ep->update_plugins_table($mode);
        // scan for e_xxx changes and save to plugin table.
        $ep->save_addon_prefs($mode);
        // generate global e_xxx_list prefs from plugin table.
    }
    // This has to be done after the table is upgraded
    if ($sql->select('plugin', 'plugin_category', "plugin_category = ''")) {
        if ($just_check) {
            return update_needed('Update plugin table');
        }
        require_once e_HANDLER . 'plugin_class.php';
        $ep = new e107plugin();
        $ep->update_plugins_table('update');
        //	$_pdateMessages[] = LAN_UPDATE_XX24;
        //	catch_error($sql);
    }
    //-- Media-manger import --------------------------------------------------
    // Autogenerate filetypes.xml if not found.
    if (!is_readable(e_SYSTEM . "filetypes.xml")) {
        $data = '<?xml version="1.0" encoding="utf-8"?>
<e107Filetypes>
	<class name="253" type="zip,gz,jpg,jpeg,png,gif,xml" maxupload="2M" />
</e107Filetypes>';
        file_put_contents(e_SYSTEM . "filetypes.xml", $data);
    }
    $root_media = str_replace(basename(e_MEDIA) . "/", "", e_MEDIA);
    $user_media_dirs = array("images", "avatars", "avatars/default", "avatars/upload", "files", "temp", "videos", "icons");
    // check for old paths and rename.
    if (is_dir($root_media . "images") || is_dir($root_media . "temp")) {
        foreach ($user_media_dirs as $md) {
            @rename($root_media . $md, e_MEDIA . $md);
        }
    }
    // create sub-directories if they do not exist.
    if (!is_dir(e_MEDIA . "images") || !is_dir(e_MEDIA . "temp") || !is_dir(e_AVATAR_UPLOAD) || !is_dir(e_AVATAR_DEFAULT)) {
        foreach ($user_media_dirs as $md) {
            if (!is_dir(e_MEDIA . $md)) {
                mkdir(e_MEDIA . $md);
            }
        }
    }
    // Move Avatars to new location
    $av1 = e107::getFile()->get_files(e_FILE . 'public/avatars', '.jpg|.gif|.png|.GIF|.jpeg|.JPG|.PNG');
    $av2 = e107::getFile()->get_files(e_IMAGE . 'avatars', '.jpg|.gif|.png|.GIF|.jpeg|.JPG|.PNG');
    $avatar_images = array_merge($av1, $av2);
    if (count($avatar_images)) {
        if ($just_check) {
            return update_needed('Avatar paths require updating.');
        }
        foreach ($avatar_images as $av) {
            $apath = strstr($av['path'], 'public/') ? e_AVATAR_UPLOAD : e_AVATAR_DEFAULT;
            @rename($av['path'] . $av['fname'], $apath . $av['fname']);
        }
    }
    // -------------------------------
    if (!e107::isInstalled('download') && $sql->gen("SELECT * FROM #links WHERE link_url LIKE 'download.php%' AND link_class != '" . e_UC_NOBODY . "' LIMIT 1")) {
        if ($just_check) {
            return update_needed('Download Plugin needs to be installed.');
        }
        //	e107::getSingleton('e107plugin')->install('download',array('nolinks'=>true));
        e107::getSingleton('e107plugin')->refresh('download');
    }
    if (!e107::isInstalled('banner') && $sql->isTable('banner')) {
        if ($just_check) {
            return update_needed('Banner Table found, but plugin not installed. Needs to be refreshed.');
        }
        e107::getSingleton('e107plugin')->refresh('banner');
    }
    // ---------------------------------
    $med = e107::getMedia();
    // Media Category Update
    if ($sql->db_Field("core_media_cat", "media_cat_nick")) {
        $count = $sql->gen("SELECT * FROM `#core_media_cat` WHERE media_cat_nick = '_common'  ");
        if ($count == 1) {
            if ($just_check) {
                return update_needed('Media-Manager Categories needs to be updated.');
            }
            $sql->update('core_media_cat', "media_cat_owner = media_cat_nick, media_cat_category = media_cat_nick WHERE media_cat_nick REGEXP '_common|news|page|_icon_16|_icon_32|_icon_48|_icon_64' ");
            $sql->update('core_media_cat', "media_cat_owner = '_icon', media_cat_category = media_cat_nick WHERE media_cat_nick REGEXP '_icon_16|_icon_32|_icon_48|_icon_64' ");
            $sql->update('core_media_cat', "media_cat_owner = 'download', media_cat_category='download_image' WHERE media_cat_nick = 'download' ");
            $sql->update('core_media_cat', "media_cat_owner = 'download', media_cat_category='download_thumb' WHERE media_cat_nick = 'downloadthumb' ");
            $sql->update('core_media_cat', "media_cat_owner = 'news', media_cat_category='news_thumb' WHERE media_cat_nick = 'newsthumb' ");
            $log->addDebug("core-media-cat Categories and Ownership updated");
            if ($sql->gen("ALTER TABLE `" . MPREFIX . "core_media_cat` DROP `media_cat_nick`")) {
                $log->addDebug("core-media-cat `media_cat_nick` field removed.");
            }
            //		$query = "INSERT INTO `".MPREFIX."core_media_cat` (`media_cat_id`, `media_cat_owner`, `media_cat_category`, `media_cat_title`, `media_cat_diz`, `media_cat_class`, `media_cat_image`, `media_cat_order`) VALUES
            //		(0, 'gallery', 'gallery_1', 'Gallery 1', 'Visible to the public at /gallery.php', 0, '', 0);
            ///		";
            //
            //		if(mysql_query($query))
            //		{
            //			$log->addDebug("Added core-media-cat Gallery.");
            //		}
        }
    }
    // Media Update
    $count = $sql->gen("SELECT * FROM `#core_media` WHERE media_category = 'newsthumb' OR media_category = 'downloadthumb'  LIMIT 1 ");
    if ($count == 1) {
        if ($just_check) {
            return update_needed('Media-Manager Data needs to be updated.');
        }
        $sql->update('core_media', "media_category='download_image' WHERE media_category = 'download' ");
        $sql->update('core_media', "media_category='download_thumb' WHERE media_category = 'downloadthumb' ");
        $sql->update('core_media', "media_category='news_thumb' WHERE media_category = 'newsthumb' ");
        $log->addDebug("core-media Category names updated");
    }
    // Media Update - core media and core-file.
    $count = $sql->gen("SELECT * FROM `#core_media` WHERE media_category = '_common' LIMIT 1 ");
    if ($count == 1) {
        if ($just_check) {
            return update_needed('Media-Manager Category Data needs to be updated.');
        }
        $sql->update('core_media', "media_category='_common_image' WHERE media_category = '_common' ");
        $log->addDebug("core-media _common Category updated");
    }
    // Media Update - core media and core-file. CATEGORY
    $count = $sql->gen("SELECT * FROM `#core_media_cat` WHERE media_cat_category = '_common' LIMIT 1 ");
    if ($count == 1) {
        if ($just_check) {
            return update_needed('Media-Manager Category Data needs to be updated.');
        }
        $sql->update('core_media_cat', "media_cat_category='_common_image' WHERE media_cat_category = '_common' ");
        $sql->gen("INSERT INTO `" . MPREFIX . "core_media_cat` VALUES(0, '_common', '_common_file', '(Common Area)', 'Media in this category will be available in all areas of admin. ', 253, '', 0);");
        $sql->gen("INSERT INTO `" . MPREFIX . "core_media_cat` VALUES(0, 'download', 'download_file', 'Download Files', '', 253, '', 0);");
        $log->addDebug("core-media-cat _common Category updated");
    }
    $count = $sql->gen("SELECT * FROM `#core_media_cat` WHERE `media_cat_owner` = '_common' LIMIT 1 ");
    if ($count != 1) {
        if ($just_check) {
            return update_needed('Add Media-Manager Categories and Import existing images.');
        }
        $e107_core_media_cat = array(array('media_cat_id' => 0, 'media_cat_owner' => '_common', 'media_cat_category' => '_common_image', 'media_cat_title' => '(Common Images)', 'media_cat_sef' => '', 'media_cat_diz' => 'Media in this category will be available in all areas of admin.', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '0'), array('media_cat_id' => 0, 'media_cat_owner' => '_common', 'media_cat_category' => '_common_file', 'media_cat_title' => '(Common Files)', 'media_cat_sef' => '', 'media_cat_diz' => 'Media in this category will be available in all areas of admin.', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '0'), array('media_cat_id' => 0, 'media_cat_owner' => 'news', 'media_cat_category' => 'news', 'media_cat_title' => 'News', 'media_cat_sef' => '', 'media_cat_diz' => 'Will be available in the news area.', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '1'), array('media_cat_id' => 0, 'media_cat_owner' => 'page', 'media_cat_category' => 'page', 'media_cat_title' => 'Custom Pages', 'media_cat_sef' => '', 'media_cat_diz' => 'Will be available in the custom pages area of admin.', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '0'), array('media_cat_id' => 0, 'media_cat_owner' => 'download', 'media_cat_category' => 'download_image', 'media_cat_title' => 'Download Images', 'media_cat_sef' => '', 'media_cat_diz' => '', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '0'), array('media_cat_id' => 0, 'media_cat_owner' => 'download', 'media_cat_category' => 'download_thumb', 'media_cat_title' => 'Download Thumbnails', 'media_cat_sef' => '', 'media_cat_diz' => '', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '0'), array('media_cat_id' => 0, 'media_cat_owner' => 'download', 'media_cat_category' => 'download_file', 'media_cat_title' => 'Download Files', 'media_cat_sef' => '', 'media_cat_diz' => '', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '0'), array('media_cat_id' => 0, 'media_cat_owner' => 'news', 'media_cat_category' => 'news_thumb', 'media_cat_title' => 'News Thumbnails (Legacy)', 'media_cat_sef' => '', 'media_cat_diz' => 'Legacy news thumbnails.', 'media_cat_class' => '253', 'media_cat_image' => '', 'media_cat_order' => '1'));
        foreach ($e107_core_media_cat as $insert) {
            $sql->insert('core_media_cat', $insert);
        }
        //	$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, '_common', '_common_image', '(Common Images)', '', 'Media in this category will be available in all areas of admin. ', 253, '', 1);");
        //	$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, '_common', '_common_file', '(Common Files)', '', 'Media in this category will be available in all areas of admin. ', 253, '', 2);");
        //	$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'news', 'news', 'News', '', 'Will be available in the news area. ', 253, '', 3);");
        //	$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'page', 'page', 'Custom Pages', '', 'Will be available in the custom pages area of admin. ', 253, '', 4);");
        //	$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'download', 'download_image','', 'Download Images', '', 253, '', 5);");
        //	$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'download', 'download_thumb', '', 'Download Thumbnails', '', 253, '', 6);");
        //	$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'download', 'download_file', '', 'Download Files', '', 253, '', 7);");
        //	mysql_query("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'gallery', 'gallery_1', 'Gallery', 'Visible to the public at /gallery.php', 0, '', 0);");
        //	$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'news', 'news_thumb', 'News Thumbnails (Legacy)', '', 'Legacy news thumbnails. ', 253, '', 8);");
        $med->import('news_thumb', e_IMAGE . 'newspost_images', "^thumb_");
        $med->import('news', e_IMAGE . 'newspost_images');
        $med->import('page', e_IMAGE . 'custom');
    } else {
        //		$log->addDebug("Media COUNT was ".$count. " LINE: ".__LINE__);
    }
    // Check for Legacy Download Images.
    $fl = e107::getFile();
    $dl_images = $fl->get_files(e_FILE . 'downloadimages');
    if (count($dl_images) && !$sql->gen("SELECT * FROM `#core_media` WHERE `media_category` = 'download_image' ")) {
        if ($just_check) {
            return update_needed('Import Download Images into Media Manager');
        }
        $med->import('download_image', e_FILE . 'downloadimages');
        $med->import('download_thumb', e_FILE . 'downloadthumbs');
    }
    $dl_files = $fl->get_files(e_FILE . 'downloads', "", "standard", 5);
    // don't use e_DOWNLOAD or a loop may occur.
    $publicFilter = array('_FT', '^thumbs\\.db$', '^Thumbs\\.db$', '.*\\._$', '^\\.htaccess$', '^\\.cvsignore$', '^\\.ftpquota$', '^index\\.html$', '^null\\.txt$', '\\.bak$', '^.tmp');
    // Default file filter (regex format)
    //	$publicFilter = array(1);
    $public_files = $fl->get_files(e_FILE . 'public', '', $publicFilter);
    if ((count($dl_files) || count($public_files)) && !$sql->gen("SELECT * FROM `#core_media` WHERE `media_category` = 'download_file' ")) {
        if ($just_check) {
            return update_needed('Import ' . count($dl_files) . ' Download File(s) and ' . count($public_files) . ' Public File(s) into Media Manager');
        }
        if ($sql->gen("SELECT download_url FROM `#download` ")) {
            $allowed_types = array();
            while ($row = $sql->fetch()) {
                $ext = strrchr($row['download_url'], ".");
                $suffix = ltrim($ext, ".");
                if (!isset($allowed_types[$suffix])) {
                    $allowed_types[$suffix] = $suffix;
                }
            }
            $allowed_types = array_unique($allowed_types);
        } else {
            $allowed_types = array('zip', 'gz', 'pdf');
        }
        $fmask = '[a-zA-z0-9_-]+\\.(' . implode('|', $allowed_types) . ')$';
        $med->import('download_file', e_DOWNLOAD, $fmask);
        $med->import('_common_file', e_FILE . 'public', $fmask);
    }
    $count = $sql->gen("SELECT * FROM `#core_media_cat` WHERE media_cat_owner='_icon'  ");
    if (!$count) {
        if ($just_check) {
            return update_needed('Add icons to media-manager');
        }
        $query = "INSERT INTO `" . MPREFIX . "core_media_cat` (`media_cat_id`, `media_cat_owner`, `media_cat_category`, `media_cat_title`, `media_cat_diz`, `media_cat_class`, `media_cat_image`, `media_cat_order`) VALUES\r\n\t\t(0, '_icon', '_icon_16', 'Icons 16px', 'Available where icons are used in admin. ', 253, '', 0),\r\n\t\t(0, '_icon', '_icon_32', 'Icons 32px', 'Available where icons are used in admin. ', 253, '', 0),\r\n\t\t(0, '_icon', '_icon_48', 'Icons 48px', 'Available where icons are used in admin. ', 253, '', 0),\r\n\t\t(0, '_icon', '_icon_64', 'Icons 64px', 'Available where icons are used in admin. ', 253, '', 0);\r\n\t\t";
        if (!$sql->gen($query)) {
            // echo "mysyql error";
            // error or already exists.
        }
        $med->importIcons(e_PLUGIN);
        $med->importIcons(e_IMAGE . "icons/");
        $med->importIcons(e_THEME . $pref['sitetheme'] . "/images/");
        $log->addDebug("Icon category added");
    }
    // Search Clean up ----------------------------------
    $searchPref = e107::getConfig('search');
    if ($searchPref->getPref('core_handlers/news')) {
        if ($just_check) {
            return update_needed('Core search handlers need to be updated.');
        }
        $searchPref->removePref('core_handlers/news')->save(false, true, false);
    }
    if ($searchPref->getPref('core_handlers/downloads')) {
        if ($just_check) {
            return update_needed('Core search handlers need to be updated.');
        }
        $searchPref->removePref('core_handlers/downloads')->save(false, true, false);
    }
    if ($searchPref->getPref('core_handlers/pages')) {
        if ($just_check) {
            return update_needed('Core search handlers need to be updated.');
        }
        $searchPref->removePref('core_handlers/pages')->save(false, true, false);
        e107::getSingleton('e107plugin')->refresh('page');
    }
    // Clean up news keywords. - remove spaces between commas.
    if ($sql->select('news', 'news_id', "news_meta_keywords LIKE '%, %' LIMIT 1")) {
        if ($just_check) {
            return update_needed('News keywords contain spaces between commas and needs to be updated. ');
        }
        $sql->update('news', "news_meta_keywords = REPLACE(news_meta_keywords, ', ', ',')");
    }
    // Any other images should be imported manually via Media Manager batch-import.
    // ------------------------------------------------------------------
    // Check that custompages have been imported from current theme.php file
    if (!$just_check) {
        if (!is_array($pref['sitetheme_layouts']) || !vartrue($pref['sitetheme_deflayout'])) {
            $th = e107::getSingleton('themeHandler');
            $tmp = $th->getThemeInfo($pref['sitetheme']);
            if ($th->setTheme($pref['sitetheme'], false)) {
                $log->addDebug("Updated SiteTheme prefs");
            } else {
                $log->addDebug("Couldn't update SiteTheme prefs");
            }
        }
        $log->toFile('upgrade_v1_to_v2');
        if ($do_save) {
            save_prefs();
            $log->logMessage(LAN_UPDATE_50);
            //	$log->logMessage(implode(', ', $accum), E_MESSAGE_NODISPLAY);
            //$updateMessages[] = LAN_UPDATE_50.implode(', ',$accum); 	// Note for admin log
        }
        $log->flushMessages('UPDATE_01');
        // Write admin log entry, update message handler
    } else {
        $log->toFile('upgrade_v1_to_v2_check');
    }
    //FIXME grab message-stack from $log for the log.
    //if ($just_check) return TRUE;
    //e107::getLog()->add('UPDATE_01',LAN_UPDATE_14.$e107info['e107_version'].'[!br!]'.implode('[!br!]',$updateMessages),E_LOG_INFORMATIVE,'');	// Log result of actual update
    return $just_check;
}
Esempio n. 21
0
        }
        $valString = implode(',', $vals);
        if ($sql->db_Insert('generic', $vals)) {
            $message = DOWLAN_117;
            e107::getLog()->add('DOWNL_09', $valString, E_LOG_INFORMATIVE, '');
        } else {
            $message = DOWLAN_118;
        }
        unset($vals);
    }
}
if (isset($_POST['updatelimits'])) {
    $tmp = $_POST['download_limits'] == 'on' ? 1 : 0;
    if ($pref['download_limits'] != $tmp) {
        $pref['download_limits'] = $tmp;
        e107::getConfig()->set('download_limits', $tmp)->save(false);
        $message .= DOWLAN_126 . "<br/>";
    }
    foreach (array_keys($_POST['count_num']) as $idLim) {
        $idLim = intval($idLim);
        if (!$_POST['count_num'][$idLim] && !$_POST['count_days'][$idLim] && !$_POST['bw_num'][$idLim] && !$_POST['bw_days'][$idLim]) {
            //All entries empty - Remove record
            if ($sql->db_Delete('generic', "gen_id = {$idLim}")) {
                $message .= $idLim . " - " . DOWLAN_119 . "<br/>";
                e107::getLog()->add('DOWNL_11', 'ID: ' . $idLim, E_LOG_INFORMATIVE, '');
            } else {
                $message .= $idLim . " - " . DOWLAN_120 . "<br/>";
            }
        } else {
            $vals = array();
            foreach (array('bw_num', 'bw_days', 'count_num', 'count_days') as $k => $lName) {
Esempio n. 22
0
 /**
  * Converts the supplied text (presumed to be from user input) to a format suitable for storing in a database table.
  *
  * @param string $data
  * @param boolean $nostrip [optional] Assumes all data is GPC ($_GET, $_POST, $_COOKIE) unless indicate otherwise by setting this var to TRUE.
  * 				If magic quotes is enabled on the server and you do not tell toDB() that the data is non GPC then slashes will be stripped when they should not be.
  * @param boolean $no_encode [optional] This parameter should nearly always be FALSE. It is used by the save_prefs() function to preserve HTML content within prefs even when
  * 				the save_prefs() function has been called by a non admin user / user without html posting permissions.
  * @param boolean $mod [optional] The 'no_html' and 'no_php' modifiers blanket prevent HTML and PHP posting regardless of posting permissions. (used in logging)
  *		The 'pReFs' value is for internal use only, when saving prefs, to prevent sanitisation of HTML.
  * @param boolean $original_author [optional]
  * @return string
  * @todo complete the documentation of this essential method
  */
 public function toDB($data, $nostrip = FALSE, $no_encode = FALSE, $mod = FALSE, $original_author = FALSE)
 {
     $core_pref = e107::getConfig();
     if (is_array($data)) {
         foreach ($data as $key => $var) {
             //Fix - sanitize keys as well
             $ret[$this->toDB($key, $nostrip, $no_encode, $mod, $original_author)] = $this->toDB($var, $nostrip, $no_encode, $mod, $original_author);
         }
         return $ret;
     }
     if (MAGIC_QUOTES_GPC == TRUE && $nostrip == FALSE) {
         $data = stripslashes($data);
     }
     if ($mod != 'pReFs') {
         $data = $this->preFilter($data);
         if (!check_class($core_pref->get('post_html', e_UC_MAINADMIN)) || !check_class($core_pref->get('post_script', e_UC_MAINADMIN))) {
             $data = $this->dataFilter($data);
         }
     }
     if (check_class($core_pref->get('post_html'))) {
         $no_encode = TRUE;
     }
     if ($core_pref->get('html_abuse')) {
         if ($this->htmlAbuseFilter($data)) {
             $no_encode = FALSE;
         }
     }
     if (is_numeric($original_author) && !check_class($core_pref->get('post_html'), '', $original_author)) {
         $no_encode = FALSE;
     }
     if ($no_encode === TRUE && strpos($mod, 'no_html') === FALSE) {
         $search = array('$', '"', "'", '\\', '<?');
         $replace = array('&#036;', '&quot;', '&#039;', '&#092;', '&lt;?');
         $ret = str_replace($search, $replace, $data);
     } else {
         $data = htmlspecialchars($data, ENT_QUOTES, 'UTF-8');
         $data = str_replace('\\', '&#092;', $data);
         $ret = preg_replace("/&amp;#(\\d*?);/", "&#\\1;", $data);
     }
     // XXX - php_bbcode pref missing?
     if (strpos($mod, 'no_php') !== FALSE || !check_class($core_pref->get('php_bbcode'))) {
         $ret = preg_replace("#\\[(php)#i", "&#91;\\1", $ret);
     }
     return $ret;
 }
Esempio n. 23
0
    $sub_action = varset($tmp[1]);
    $id = varset($tmp[2]);
    unset($tmp);
} elseif (!getperms('0')) {
    $action = 'tools';
}
if (isset($_POST['submit_prefs']) && isset($_POST['mainsitelanguage']) && getperms('0')) {
    unset($temp);
    $changes = array();
    $temp['multilanguage'] = $_POST['multilanguage'];
    $temp['multilanguage_subdomain'] = $_POST['multilanguage_subdomain'];
    $temp['multilanguage_domain'] = $_POST['multilanguage_domain'];
    $temp['sitelanguage'] = $_POST['mainsitelanguage'];
    $temp['adminlanguage'] = $_POST['mainadminlanguage'];
    $temp['noLanguageSubs'] = $_POST['noLanguageSubs'];
    e107::getConfig()->setPref($temp)->save(true);
    e107::getSession()->clear('e_language');
}
// ----------------- delete tables ---------------------------------------------
if (isset($_POST['del_existing']) && $_POST['lang_choices'] && getperms('0')) {
    $lang = strtolower($_POST['lang_choices']);
    foreach ($tabs as $del_table) {
        if ($sql->db_Table_exists($lang . "_" . $del_table, TRUE)) {
            //	echo $del_table." exists<br />";
            $qry = "DROP TABLE " . $mySQLprefix . "lan_" . $lang . "_" . $del_table;
            if (mysql_query($qry)) {
                $msg = $tp->lanVars(LANG_LAN_100, $_POST['lang_choices'] . ' ' . $del_table);
                $message .= $msg . '[!br!]';
                $mes->addSuccess($msg);
            } else {
                $msg = $tp->lanVars(LANG_LAN_101, $_POST['lang_choices'] . ' ' . $del_table);
Esempio n. 24
0
 private function renderLanguageTableInfo()
 {
     $text = '';
     if (e107::getConfig()->get('multilanguage')) {
         $curTable = $this->getController()->getTableName();
         $sitelanguage = e107::getConfig()->get('sitelanguage');
         if ($curTable != e107::getDb()->db_IsLang($curTable)) {
             $lang = e107::getDb()->mySQLlanguage;
         } else {
             $lang = $sitelanguage;
         }
         $def = deftrue('LAN_UI_USING_DATABASE_TABLE', 'Using [x] database table');
         $diz = e107::getParser()->lanVars($def, $lang);
         // "Using ".$lang." database table";
         $class = $sitelanguage == $lang ? "default" : "";
         $text = "<span class='adminui-language-table-info " . $class . " e-tip' title=\"" . $diz . "\">";
         $text .= e107::getParser()->toGlyph('fa-hdd-o');
         // '<i class="icon-hdd"></i> ';
         $text .= e107::getLanguage()->toNative($lang) . "</span>";
         return $text;
     }
     return false;
 }
Esempio n. 25
0
 function saveMailPrefs(&$mes)
 {
     if (!getperms('0')) {
         return;
     }
     //$pref = e107::getPref();
     $e107 = e107::getInstance();
     $tp = e107::getParser();
     $mes = e107::getMessage();
     $bounceOpts = array('none' => LAN_MAILOUT_232, 'auto' => LAN_MAILOUT_233, 'mail' => LAN_MAILOUT_234);
     unset($temp);
     if (!in_array($_POST['mailer'], array('smtp', 'sendmail', 'php'))) {
         $_POST['mailer'] = 'php';
     }
     $temp['mailer'] = $_POST['mailer'];
     // Allow qmail as an option as well - works much as sendmail
     if (strpos($_POST['sendmail'], 'sendmail') !== FALSE || strpos($_POST['sendmail'], 'qmail') !== FALSE) {
         $temp['sendmail'] = $tp->toDB($_POST['sendmail']);
     } else {
         $temp['sendmail'] = '';
     }
     $temp['smtp_server'] = $tp->toDB($_POST['smtp_server']);
     $temp['smtp_username'] = $tp->toDB($_POST['smtp_username']);
     $temp['smtp_password'] = $tp->toDB($_POST['smtp_password']);
     $smtp_opts = array();
     switch (trim($_POST['smtp_options'])) {
         case 'smtp_ssl':
             $smtp_opts[] = 'secure=SSL';
             break;
         case 'smtp_tls':
             $smtp_opts[] = 'secure=TLS';
             break;
         case 'smtp_pop3auth':
             $smtp_opts[] = 'pop3auth';
             break;
     }
     if (vartrue($_POST['smtp_keepalive'])) {
         $smtp_opts[] = 'keepalive';
     }
     if (vartrue($_POST['smtp_useVERP'])) {
         $smtp_opts[] = 'useVERP';
     }
     $temp['smtp_options'] = implode(',', $smtp_opts);
     $temp['mail_sendstyle'] = $tp->toDB($_POST['mail_sendstyle']);
     $temp['mail_pause'] = intval($_POST['mail_pause']);
     $temp['mail_pausetime'] = intval($_POST['mail_pausetime']);
     $temp['mail_workpertick'] = intval($_POST['mail_workpertick']);
     $temp['mail_workpertick'] = min($temp['mail_workpertick'], 1000);
     $temp['mail_bounce'] = isset($bounceOpts[$_POST['mail_bounce']]) ? $_POST['mail_bounce'] : 'none';
     $temp['mail_bounce_auto'] = 0;
     // Make sure this is always defined
     switch ($temp['mail_bounce']) {
         case 'none':
             $temp['mail_bounce_email'] = '';
             break;
         case 'auto':
             $temp['mail_bounce_email'] = $tp->toDB($_POST['mail_bounce_email2']);
             break;
         case 'mail':
             $temp['mail_bounce_email'] = $tp->toDB($_POST['mail_bounce_email']);
             $temp['mail_bounce_auto'] = intval($_POST['mail_bounce_auto']);
             break;
     }
     $temp['mail_bounce_pop3'] = $tp->toDB($_POST['mail_bounce_pop3']);
     $temp['mail_bounce_user'] = $tp->toDB($_POST['mail_bounce_user']);
     $temp['mail_bounce_pass'] = $tp->toDB($_POST['mail_bounce_pass']);
     $temp['mail_bounce_type'] = $tp->toDB($_POST['mail_bounce_type']);
     $temp['mail_bounce_delete'] = intval(varset($_POST['mail_bounce_delete'], 0));
     $temp['mailout_enabled'] = implode(',', varset($_POST['mail_mailer_enabled'], ''));
     $temp['mail_log_options'] = intval($_POST['mail_log_option']) . ',' . intval($_POST['mail_log_email']);
     foreach ($temp as &$t) {
         if ($t === NULL) {
             $t = '';
         }
     }
     $pref = e107::pref('core');
     // Core Prefs Array.
     if (e107::getAdminLog()->logArrayDiffs($temp, $pref, 'MAIL_03')) {
         e107::getConfig()->updatePref($temp);
         e107::getConfig()->save(false);
         // Only save if changes - generates its own message
     } else {
         $mes->addInfo(LAN_NO_CHANGE);
     }
 }
Esempio n. 26
0
    }
    if (strstr($online_location, "admin")) {
        $class_check = FALSE;
        $online_location_page = ADMINAREA;
    }
    $ONLINE_TABLE_ICON = varsettrue($pref['plug_installed']['pm']) && $oid != USERID ? $tp->parseTemplate("{SENDPM={$oid}}", 'sendpm.sc') : "<img src='" . e_PLUGIN . "online_extended_menu/images/user.png' alt='' style='vertical-align:middle' />";
    $ONLINE_TABLE_USERNAME = "******" . e_BASE . "user.php?id.{$oid}'>{$oname}</a>";
    $ONLINE_TABLE_LOCATION = $class_check ? "<a href='{$online_location}'>{$online_location_page}</a>" : $online_location_page;
    $textstring .= preg_replace("/\\{(.*?)\\}/e", '$\\1', $ONLINE_TABLE);
}
$ONLINE_TABLE_MEMBERS_ONLINE = ONLINE_EL1 . GUESTS_ONLINE;
$ONLINE_TABLE_GUESTS_ONLINE = ONLINE_EL2 . MEMBERS_ONLINE;
if (!isset($gen) || !is_object($gen)) {
    $gen = new convert();
}
$siteHistory = e107::getConfig('history')->getPref('');
$datestamp = $gen->convert_date($siteHistory['most_online_datestamp'], "short");
$ONLINE_TABLE_MOST_EVER_ONLINE = ONLINE_EL8 . ($siteHistory['most_members_online'] + $siteHistory['most_guests_online']);
$ONLINE_TABLE_MOST_MEMBERS_ONLINE = ONLINE_EL2 . $siteHistory['most_members_online'];
$ONLINE_TABLE_MOST_GUESTS_ONLINE = ONLINE_EL1 . $siteHistory['most_guests_online'];
$ONLINE_TABLE_DATESTAMP = $datestamp;
$total_members = $sql->db_Count("user", "(*)", "where user_ban = 0");
if ($total_members > 1) {
    $newest_member = $sql->db_Select("user", "user_id, user_name", "user_ban=0 ORDER BY user_join DESC LIMIT 0,1");
    $row = $sql->db_Fetch();
    $ONLINE_TABLE_MEMBERS_TOTAL = "<br />" . ONLINE_EL5 . ": " . $total_members;
    $ONLINE_TABLE_MEMBERS_NEWEST = "<br />" . ONLINE_EL6 . ": " . (USER ? "<a href='" . e_BASE . "user.php?id." . $row['user_id'] . "'>" . $row['user_name'] . "</a>" : $row['user_name']);
}
$text = '';
if (count($listuserson)) {
    $textstart = preg_replace("/\\{(.*?)\\}/e", '$\\1', $ONLINE_TABLE_START);
Esempio n. 27
0
 function pluginUpgrade()
 {
     $pref = e107::getPref();
     $admin_log = e107::getAdminLog();
     $plugin = e107::getPlugin();
     $sql = e107::getDb();
     $mes = e107::getMessage();
     $plug = $plugin->getinfo($this->id);
     $_path = e_PLUGIN . $plug['plugin_path'] . '/';
     if (file_exists($_path . 'plugin.xml')) {
         $plugin->install_plugin_xml($this->id, 'upgrade');
     } else {
         include e_PLUGIN . $plug['plugin_path'] . '/plugin.php';
         $func = $eplug_folder . '_upgrade';
         if (function_exists($func)) {
             $text .= call_user_func($func);
         }
         if (is_array($upgrade_alter_tables)) {
             $result = $plugin->manage_tables('upgrade', $upgrade_alter_tables);
             if (true !== $result) {
                 //$text .= EPL_ADLAN_9.'<br />';
                 $mes->addWarning(EPL_ADLAN_9)->addDebug($result);
             } else {
                 $text .= EPL_ADLAN_7 . "<br />";
             }
         }
         if (is_array($upgrade_add_prefs)) {
             $plugin->manage_prefs('add', $upgrade_add_prefs);
             $text .= EPL_ADLAN_8 . '<br />';
         }
         if (is_array($upgrade_remove_prefs)) {
             $plugin->manage_prefs('remove', $upgrade_remove_prefs);
         }
         if (is_array($upgrade_add_array_pref)) {
             foreach ($upgrade_add_array_pref as $key => $val) {
                 $plugin->manage_plugin_prefs('add', $key, $eplug_folder, $val);
             }
         }
         if (is_array($upgrade_remove_array_pref)) {
             foreach ($upgrade_remove_array_pref as $key => $val) {
                 $plugin->manage_plugin_prefs('remove', $key, $eplug_folder, $val);
             }
         }
         $plugin->manage_search('upgrade', $eplug_folder);
         $plugin->manage_notify('upgrade', $eplug_folder);
         $eplug_addons = $plugin->getAddons($eplug_folder);
         $info = $plugin->getinfo($this->id);
         $name = deftrue($info['plugin_name'], $info['plugin_name']) . " v" . $eplug_version . "({e_PLUGIN}" . $info['plugin_path'] . ")";
         e107::getLog()->add('PLUGMAN_02', $name, E_LOG_INFORMATIVE, '');
         $text .= isset($eplug_upgrade_done) ? '<br />' . $eplug_upgrade_done : "<br />" . LAN_UPGRADE_SUCCESSFUL;
         $sql->update('plugin', "plugin_version ='{$eplug_version}', plugin_addons='{$eplug_addons}' WHERE plugin_id='{$this->id}' ");
         $pref['plug_installed'][$plug['plugin_path']] = $eplug_version;
         // Update the version
         e107::getConfig('core')->setPref($pref);
         $plugin->rebuildUrlConfig();
         e107::getConfig('core')->save();
     }
     $mes->addSuccess($text);
     $plugin->save_addon_prefs('update');
 }
Esempio n. 28
0
 function __construct()
 {
     $this->core_perms = array("C" => array(ADLAN_74, E_16_CACHE, E_32_CACHE), "F" => array(ADLAN_58, E_16_EMOTE, E_32_EMOTE), "G" => array(ADLAN_60, E_16_FRONT, E_32_FRONT), "L" => array(ADLAN_132, E_16_LANGUAGE, E_32_LANGUAGE), "T" => array(ADLAN_66, E_16_META, E_32_META), "1" => array(LAN_PREFS, E_16_PREFS, E_32_PREFS), "X" => array(LAN_SEARCH, E_16_SEARCH, E_32_SEARCH), "I" => array(ADLAN_138, E_16_LINKS, E_32_LINKS), "8" => array(ADMSLAN_27, E_16_LINKS, E_32_LINKS), "K" => array(ADLAN_159, E_16_EURL, E_32_EURL), "3" => array(ADLAN_8, E_16_ADMIN, E_32_ADMIN), "4" => array(LAN_USER_MANAGEALL, E_16_USER, E_32_USER), "U0" => array(ADLAN_34, E_16_USER, E_32_USER), "U1" => array(LAN_USER_QUICKADD, E_16_USER, E_32_USER), "U2" => array(LAN_USER_OPTIONS, E_16_USER, E_32_USER), "U3" => array(LAN_USER_RANKS, E_16_USER, E_32_USER), "W" => array(ADLAN_136, E_16_MAIL, E_32_MAIL), "5" => array(ADLAN_42, E_16_CUST, E_32_CUST), "J" => array(ADLAN_42, E_16_CUST, E_32_CUST), "H" => array(ADLAN_0, E_16_NEWS, E_32_NEWS), "H0" => array(ADLAN_0 . " (" . LAN_CREATE . ")", E_16_NEWS, E_32_NEWS), "H1" => array(ADLAN_0 . " (" . LAN_EDIT . ")", E_16_NEWS, E_32_NEWS), "H2" => array(ADLAN_0 . " (" . LAN_DELETE . ")", E_16_NEWS, E_32_NEWS), "H3" => array(ADLAN_0 . " (" . LAN_CATEGORY . " - " . LAN_CREATE . ")", E_16_NEWS, E_32_NEWS), "H4" => array(ADLAN_0 . " (" . LAN_CATEGORY . " - " . LAN_EDIT . ")", E_16_NEWS, E_32_NEWS), "H5" => array(ADLAN_0 . " (" . LAN_CATEGORY . " - " . LAN_DELETE . ")", E_16_NEWS, E_32_NEWS), "N" => array(ADLAN_0 . " (" . LAN_SUBMITTED . ")", E_16_NEWS, E_32_NEWS), "V" => array(ADLAN_31, E_16_UPLOADS, E_32_UPLOADS), "M" => array(ADLAN_28, E_16_WELCOME, E_32_WELCOME), "Y" => array(ADLAN_147, E_16_INSPECT, E_32_INSPECT), "9" => array(ADLAN_40, E_16_MAINTAIN, E_32_MAINTAIN), "O" => array(ADLAN_149, E_16_NOTIFY, E_32_NOTIFY), "U" => array(ADLAN_157, E_16_CRON, E_32_CRON), "S" => array(ADLAN_155, E_16_ADMINLOG, E_32_ADMINLOG), "B" => array(LAN_COMMENTMAN, E_16_COMMENT, E_32_COMMENT), "6" => array(LAN_MEDIAMANAGER, E_16_FILE, E_32_FILE), "A" => array(LAN_MEDIAMANAGER . " (" . LAN_ALL . ")", E_16_IMAGES, E_32_IMAGES), "A1" => array(LAN_MEDIAMANAGER . " (" . LAN_UPLOAD . "/" . LAN_IMPORT . ")", E_16_IMAGES, E_32_IMAGES), "A2" => array(LAN_MEDIAMANAGER . " (" . LAN_CATEGORIES . ")", E_16_IMAGES, E_32_IMAGES), "2" => array(ADLAN_6, E_16_MENUS, E_32_MENUS));
     $sql = e107::getDb('sql2');
     $tp = e107::getParser();
     $plg = e107::getPlugin();
     $allPlugins = $plg->getall(1);
     // Needs all for 'reading' and 'installed' for writing.
     foreach ($allPlugins as $k => $row2) {
         if ($plg->parse_plugin($row2['plugin_path'])) {
             $plug_vars = $plg->plug_vars;
             $this->plugin_perms["P" . $row2['plugin_id']] = array($tp->toHTML($row2['plugin_name'], FALSE, 'RAWTEXT,defs'));
             $this->plugin_perms["P" . $row2['plugin_id']][1] = $plg->getIcon($row2['plugin_path'], 16);
             $this->plugin_perms["P" . $row2['plugin_id']][2] = $plg->getIcon($row2['plugin_path'], 32);
         }
     }
     //	echo $plg->getIcon('forum');
     //	$sql->db_Select("plugin", "*", "plugin_installflag='1'");
     //	while ($row2 = $sql->db_Fetch())
     //	{
     //		$this->plugin_perms[("P".$row2['plugin_id'])] = array($tp->toHTML($row2['plugin_name'], FALSE, 'RAWTEXT,defs'));
     //	$this->plugin_perms[("P".$row2['plugin_id'])][1] = $plg->getIcon('forum')
     //	}
     asort($this->plugin_perms);
     $this->plugin_perms = array("Z" => array('0' => ADLAN_98)) + $this->plugin_perms;
     if (e107::getConfig()->getPref('multilanguage')) {
         $lanlist = explode(",", e_LANLIST);
         sort($lanlist);
         foreach ($lanlist as $langs) {
             $this->language_perms[$langs] = array("0" => $langs);
         }
     }
     if (getperms('0')) {
         $this->main_perms = array('0' => array('0' => ADMSLAN_58));
     }
     // Note: Using array_merge or array_merge_recursive will corrupt the array.
     $this->full_perms = $this->core_perms + $this->plugin_perms + $this->language_perms + $this->main_perms;
 }
Esempio n. 29
0
 /**
  * Go online
  * @param boolean $online_tracking
  * @param boolean $flood_control
  * @return void
  */
 public function goOnline($online_tracking = false, $flood_control = false)
 {
     // global $pref, $e_event; // Not needed as globals
     //global $online_timeout, $online_warncount, $online_bancount;	// Not needed as globals
     //global $members_online, $total_online;						// Not needed as globals
     global $listuserson;
     // FIXME - remove it, make it property, call e_online signleton - e107::getOnline()
     $e107 = e107::getInstance();
     $sql = e107::getDb();
     $user = e107::getUser();
     if ($online_tracking || $flood_control) {
         $online_timeout = 300;
         list($ban_access_guest, $ban_access_member) = explode(',', e107::getPref('ban_max_online_access', '100,200'));
         $online_bancount = max($ban_access_guest, 50);
         // Safety net for incorrect values
         if ($user->isUser()) {
             $online_bancount = max($online_bancount, $ban_access_member);
         }
         $online_warncount = $online_bancount * 0.9;
         // Set warning threshold at 90% of ban threshold
         //TODO Add support for all queries.
         // $page = (strpos(e_SELF, 'forum_') !== FALSE) ? e_SELF.'.'.e_QUERY : e_SELF;
         // $page = (strpos(e_SELF, 'comment') !== FALSE) ? e_SELF.'.'.e_QUERY : $page;
         // $page = (strpos(e_SELF, 'content') !== FALSE) ? e_SELF.'.'.e_QUERY : $page;
         $page = e_REQUEST_URI;
         // mod rewrite & single entry support
         // FIXME parse url, trigger registered e_online callbacks
         $page = e107::getParser()->toDB($page, true);
         /// @todo - try not to use toDB() - triggers prefilter
         $ip = e107::getIPHandler()->getIP(FALSE);
         $udata = $user->isUser() && USER ? $user->getId() . '.' . $user->getName() : '0';
         // USER check required to make sure they logged in without an error.
         $agent = $_SERVER['HTTP_USER_AGENT'];
         // XXX - more exceptions, e.g. hide online location for admins/users (pref), e_jlsib.php, etc
         // XXX - more advanced flod timing when  e_AJAX_REQUEST, e.g. $ban_access_ajax = 300
         $update_page = deftrue('e_AJAX_REQUEST') ? '' : ", online_location='{$page}'";
         $insert_query = array('online_timestamp' => time(), 'online_flag' => 0, 'online_user_id' => $udata, 'online_ip' => $ip, 'online_location' => $page, 'online_pagecount' => 1, 'online_active' => 0, 'online_agent' => $agent, 'online_language' => e_LAN);
         // !deftrue('e_AJAX_REQUEST')
         // TODO add option to hide users from online list? boolean online_hide field?
         // don't do anything if main admin logged in as another user
         if ($user->isUser() && !$user->getParentId()) {
             // Find record that matches IP or visitor, or matches user info
             if ($sql->select('online', '*', "(`online_ip` = '{$ip}' AND `online_user_id` = '0') OR `online_user_id` = '{$udata}'")) {
                 $row = $sql->fetch();
                 if ($row['online_user_id'] == $udata) {
                     //Matching user record
                     if ($row['online_timestamp'] < time() - $online_timeout) {
                         //It has been at least 'online_timeout' seconds since this user's info last logged
                         //Update user record with timestamp, current IP, current page and set pagecount to 1
                         $query = "online_timestamp='" . time() . "', online_ip='{$ip}'{$update_page}, online_pagecount=1, `online_active` = 1 WHERE online_user_id='{$row['online_user_id']}'";
                     } else {
                         if (!$user->isAdmin()) {
                             $row['online_pagecount']++;
                         }
                         // Update user record with current IP, current page and increment pagecount
                         $query = "online_ip='{$ip}'{$update_page}, `online_pagecount` = '" . intval($row['online_pagecount']) . "', `online_active` = 1 WHERE `online_user_id` = '{$row['online_user_id']}'";
                     }
                 } else {
                     //Found matching visitor record (ip only) for this user
                     if ($row['online_timestamp'] < time() - $online_timeout) {
                         // It has been at least 'timeout' seconds since this user has connected
                         // Update record with timestamp, current IP, current page and set pagecount to 1
                         $query = "`online_timestamp` = '" . time() . "', `online_user_id` = '{$udata}'{$update_page}, `online_pagecount` = 1,  `online_active` = 1 WHERE `online_ip` = '{$ip}' AND `online_user_id` = '0'";
                     } else {
                         // Another visit within the timeout period
                         if (!$user->isAdmin()) {
                             $row['online_pagecount']++;
                         }
                         //Update record with current IP, current page and increment pagecount
                         $query = "`online_user_id` = '{$udata}'{$update_page}, `online_pagecount` = " . intval($row['online_pagecount']) . ", `online_active` =1  WHERE `online_ip` = '{$ip}' AND `online_user_id` = '0'";
                     }
                 }
                 $sql->update('online', $query);
             } else {
                 $sql->insert('online', $insert_query);
             }
         } elseif (!$user->getParentId()) {
             //Current page request is from a guest
             if ($sql->select('online', '*', "`online_ip` = '{$ip}' AND `online_user_id` = '0'")) {
                 // Recent visitor
                 $row = $sql->fetch();
                 if ($row['online_timestamp'] < time() - $online_timeout) {
                     //Update record with timestamp, current page, and set pagecount to 1
                     $query = "`online_timestamp` = '" . time() . "'{$update_page}, `online_pagecount` = 1 WHERE `online_ip` = '{$ip}' AND `online_user_id` = '0'";
                 } else {
                     //Update record with current page and increment pagecount
                     $row['online_pagecount']++;
                     //   echo "here {$online_pagecount}";
                     $query = "`online_pagecount` = {$row['online_pagecount']}{$update_page} WHERE `online_ip` = '{$ip}' AND `online_user_id` = '0'";
                 }
                 $sql->update('online', $query);
             } else {
                 // New visitor
                 $sql->insert('online', $insert_query);
             }
         }
         if ($user->isAdmin() || e107::getPref('autoban') != 1 && e107::getPref('autoban') != 2 || !isset($row['online_pagecount'])) {
             $row['online_pagecount'] = 1;
         }
         // Always allow localhost - any problems are usually semi-intentional!
         if (varset($row['online_ip']) != '127.0.0.1' && varset($row['online_ip']) != e107::LOCALHOST_IP && varset($row['online_ip']) != e107::LOCALHOST_IP2) {
             // Check for excessive access
             if ($row['online_pagecount'] > $online_bancount) {
                 e107::lan('core', 'banlist', true);
                 //e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_banlist.php'
                 $reason = e107::getParser()->lanVars(BANLAN_78, $row['online_pagecount']);
                 //  str_replace('--HITS--',$row['online_pagecount'], BANLAN_78)
                 if (true === e107::getIPHandler()->add_ban(2, $reason, $ip, 0)) {
                     e107::getEvent()->trigger('flood', $ip);
                     //BC
                     e107::getEvent()->trigger('user_ban_flood', $ip);
                     exit;
                 }
             } elseif ($row['online_pagecount'] >= $online_warncount) {
                 echo "<div style='text-align:center; font: 11px verdana, tahoma, arial, helvetica, sans-serif;'><b>" . LAN_WARNING . "</b><br /><br />" . CORE_LAN6 . "<br /></div>";
                 exit;
             }
         }
         // Delete records for users (and guests) not seen for a while
         // FIXME - DB optimization - mark records as deleted (online_deleted=1), delete once per hour (could be pref) via e_cron
         // FIXME - Additional prefs for this (it does 2-3 more queries no matter someone need them), could be also separate method
         // Speed up ajax requests
         if (!deftrue('e_AJAX_REQUEST')) {
             $sql->delete('online', '`online_timestamp` < ' . (time() - $online_timeout));
             // FIXME - don't use constants below, save data in class vars, call e_online signleton - e107::getOnline()
             //	$total_online = $sql->db_Count('online'); // 1 less query! :-)
             if ($total_online = $sql->gen('SELECT o.*,u.user_image FROM #online AS o LEFT JOIN #user AS u ON o.online_user_id = u.user_id WHERE o.online_pagecount > 0 ORDER BY o.online_timestamp DESC')) {
                 $member_list = '';
                 $members_online = 0;
                 $listuserson = array();
                 while ($row = $sql->fetch()) {
                     $row['online_bot'] = $this->isBot($row['online_agent']);
                     // Sort into usable format and add bot field.
                     $user = array('user_location' => $row['online_location'], 'user_bot' => $this->isBot($row['online_agent']), 'user_agent' => $row['online_agent'], 'user_ip' => $row['online_ip'], 'user_currentvisit' => $row['online_timestamp'], 'user_online' => $row['online_flag'], 'user_pagecount' => $row['online_pagecount'], 'user_active' => $row['online_active'], 'user_image' => vartrue($row['user_image'], false), 'online_user_id' => $row['online_user_id'], 'user_language' => $row['online_language']);
                     if ($row['online_user_id'] != 0) {
                         $vals = explode('.', $row['online_user_id'], 2);
                         $user['user_id'] = $vals[0];
                         $user['user_name'] = $vals[1];
                         $member_list .= "<a href='" . SITEURL . "user.php?id.{$vals[0]}'>{$vals[1]}</a> ";
                         $listuserson[$row['online_user_id']] = $row['online_location'];
                         $this->users[] = $user;
                         $members_online++;
                     } else {
                         $user['user_id'] = 0;
                         $user['user_name'] = 'guest';
                         // Maybe should just be an empty string?
                         $this->guests[] = $user;
                     }
                 }
             }
             define('TOTAL_ONLINE', $total_online);
             define('MEMBERS_ONLINE', $members_online);
             define('GUESTS_ONLINE', $total_online - $members_online);
             define('ON_PAGE', $sql->db_Count('online', '(*)', "WHERE `online_location` = '{$page}' "));
             define('MEMBER_LIST', $member_list);
             //update most ever online
             $olCountPrefs = e107::getConfig('history');
             // Get historic counts of members on line
             $olCountPrefs->setParam('nologs', true);
             if ($total_online > $olCountPrefs->get('most_members_online') + $olCountPrefs->get('most_guests_online')) {
                 $olCountPrefs->set('most_members_online', MEMBERS_ONLINE);
                 $olCountPrefs->set('most_guests_online', GUESTS_ONLINE);
                 $olCountPrefs->set('most_online_datestamp', time());
                 $olCountPrefs->save(false, true, false);
             }
         }
     } else {
         define('e_TRACKING_DISABLED', true);
         // Used in forum, online menu
         define('TOTAL_ONLINE', '');
         define('MEMBERS_ONLINE', '');
         define('GUESTS_ONLINE', '');
         define('ON_PAGE', '');
         define('MEMBER_LIST', '');
     }
 }
Esempio n. 30
0
 /**
  * Set Config object
  * @return e_admin_ui
  */
 protected function _setConfig()
 {
     $this->_pref = e107::getConfig();
     $dataFields = $validateRules = array();
     foreach ($this->prefs as $key => $att) {
         // create dataFields array
         $dataFields[$key] = vartrue($att['data'], 'string');
         // create validation array
         if (vartrue($att['validate'])) {
             $validateRules[$key] = array(true === $att['validate'] ? 'required' : $att['validate'], varset($att['rule']), $att['title'], varset($att['error'], $att['help']));
         }
         /* Not implemented in e_model yet
         			elseif(vartrue($att['check']))
         			{
         				$validateRules[$key] = array($att['check'], varset($att['rule']), $att['title'], varset($att['error'], $att['help']));
         			}*/
     }
     $this->_pref->setDataFields($dataFields)->setValidationRules($validateRules);
     return $this;
 }