Example #1
0
 function process($source = '')
 {
     global $_E107, $pref;
     e107::getCache()->CachePageMD5 = '_';
     e107::getCache()->set('emailLastBounce', time(), TRUE, FALSE, TRUE);
     $strEmail = !$source ? $this->mailRead(-1) : file_get_contents(e_HANDLER . "eml/" . $source);
     if (!$strEmail) {
         return;
     }
     $multiArray = Bouncehandler::get_the_facts($strEmail);
     $head = BounceHandler::parse_head($strEmail);
     $e107_userid = isset($head['X-e107-id']) ? intval($head['X-e107-id']) : $this->getHeader($strEmail, 'X-e107-id');
     if ($_E107['debug']) {
         require_once e_HANDLER . "mail.php";
         $message = "Your Bounce Handler is working. The data of the email you sent is displayed below.<br />";
         if ($e107_userid) {
             $message .= "A user-id was detected in the email you sent: <b>" . $e107_userid . "</b><br />";
         }
         $message .= "<br />";
         $message .= "<pre>" . print_r($multiArray, TRUE) . "</pre>";
         $message .= "<pre>" . $strEmail . "</pre>";
         sendemail($pref['siteadminemail'], SITENAME . " :: Bounce-Handler.", $message, $pref['siteadmin'], $pref['siteadminemail'], $pref['siteadmin']);
     }
     if ($e107_userid && $this->setUser_Bounced($e107_userid) == TRUE) {
         return;
     }
     /*		echo "<pre>";
     		print_r($multiArray);
     		echo "</pre>"; 
     */
     foreach ($multiArray as $the) {
         $the['user_id'] = $head['X-e107-id'];
         $the['user_email'] = $the['recipient'];
         unset($the['recipient']);
         switch ($the['action']) {
             case 'failed':
                 e107::getEvent()->trigger('email-bounce-failed', $the);
                 $this->setUser_Bounced($the['user_email']);
                 break;
             case 'transient':
                 //    $num_attempts  = delivery_attempts($the['user_email']);
                 e107::getEvent()->trigger('email-bounce-transient', $the);
                 if ($num_attempts > 10) {
                     $this->setUser_Bounced($the['user_email'], $the['user_id']);
                 } else {
                     //       insert_into_queue($the['user_email'], ($num_attempts+1));
                 }
                 break;
             case 'autoreply':
                 e107::getEvent()->trigger('email-bounce-autoreply', $the);
                 //  postpone($the['user_email'], '7 days');
                 break;
             default:
                 //don't do anything
                 break;
         }
     }
 }
Example #2
0
 /**
  * Retrieve menus, check visibility against
  * current user classes and current page url
  *
  */
 public function init()
 {
     global $_E107;
     if (vartrue($_E107['cli'])) {
         return;
     }
     $menu_layout_field = THEME_LAYOUT != e107::getPref('sitetheme_deflayout') ? THEME_LAYOUT : "";
     e107::getCache()->CachePageMD5 = md5(e_LANGUAGE . $menu_layout_field);
     //FIXME add a function to the cache class for this.
     // $menu_data = e107::getCache()->retrieve_sys("menus_".USERCLASS_LIST."_".md5(e_LANGUAGE.$menu_layout_field));
     $menu_data = e107::getCache()->retrieve_sys("menus_" . USERCLASS_LIST);
     $menu_data = e107::getArrayStorage()->ReadArray($menu_data);
     $eMenuArea = array();
     // $eMenuList = array();
     //	$eMenuActive	= array();  // DEPRECATED
     if (!is_array($menu_data)) {
         $menu_qry = 'SELECT * FROM #menus WHERE menu_location > 0 AND menu_class IN (' . USERCLASS_LIST . ') AND menu_layout = "' . $menu_layout_field . '" ORDER BY menu_location,menu_order';
         if (e107::getDb()->db_Select_gen($menu_qry)) {
             while ($row = e107::getDb()->db_Fetch()) {
                 $eMenuArea[$row['menu_location']][] = $row;
             }
         }
         $menu_data['menu_area'] = $eMenuArea;
         $menuData = e107::getArrayStorage()->WriteArray($menu_data, false);
         e107::getCache()->set_sys('menus_' . USERCLASS_LIST, $menuData);
         //	e107::getCache()->set_sys('menus_'.USERCLASS_LIST.'_'.md5(e_LANGUAGE.$menu_layout_field), $menuData);
     } else {
         $eMenuArea = $menu_data['menu_area'];
     }
     $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;
 }
Example #3
0
 function sc_admin_coreupdate($parm = '')
 {
     $che = e107::getCache();
     $mes = e107::getMessage();
     $che->setMD5(e_LANGUAGE);
     $cacheData = $che->retrieve("releasecheck", 3600, TRUE);
     // 2.0.1 | 'up-to-date' | false ;
     $cacheData = 2.1;
     // XXX Remove to test for real.
     return false;
     // XXX Remove to test for real.
     if ($cacheData) {
         return $this->cronUpdateRender($parm, $cacheData);
     }
     require_once e_HANDLER . "cron_class.php";
     $cron = new _system_cron();
     if ($result = $cron->checkCoreUpdate()) {
         return $this->cronUpdateRender($parm, $cacheData);
     }
 }
Example #4
0
    /**
     * Get all Glyphs
     */
    function getGlyphs($type = 'fa4', $prefix = '')
    {
        $icons = array();
        if ($type == 'bs2') {
            $matches = array('glass', 'music', 'search', 'envelope', 'heart', 'star', 'star-empty', 'user', 'film', 'th-large', 'th', 'th-list', 'ok', 'remove', 'zoom-in', 'zoom-out', 'off', 'signal', 'cog', 'trash', 'home', 'file', 'time', 'road', 'download-alt', 'download', 'upload', 'inbox', 'play-circle', 'repeat', 'refresh', 'list-alt', 'lock', 'flag', 'headphones', 'volume-off', 'volume-down', 'volume-up', 'qrcode', 'barcode', 'tag', 'tags', 'book', 'bookmark', 'print', 'camera', 'font', 'bold', 'italic', 'text-height', 'text-width', 'align-left', 'align-center', 'align-right', 'align-justify', 'list', 'indent-left', 'indent-right', 'facetime-video', 'picture', 'pencil', 'map-marker', 'adjust', 'tint', 'edit', 'share', 'check', 'move', 'step-backward', 'fast-backward', 'backward', 'play', 'pause', 'stop', 'forward', 'fast-forward', 'step-forward', 'eject', 'chevron-left', 'chevron-right', 'plus-sign', 'minus-sign', 'remove-sign', 'ok-sign', 'question-sign', 'info-sign', 'screenshot', 'remove-circle', 'ok-circle', 'ban-circle', 'arrow-left', 'arrow-right', 'arrow-up', 'arrow-down', 'share-alt', 'resize-full', 'resize-small', 'plus', 'minus', 'asterisk', 'exclamation-sign', 'gift', 'leaf', 'fire', 'eye-open', 'eye-close', 'warning-sign', 'plane', 'calendar', 'random', 'comment', 'magnet', 'chevron-up', 'chevron-down', 'retweet', 'shopping-cart', 'folder-close', 'folder-open', 'resize-vertical', 'resize-horizontal', 'hdd', 'bullhorn', 'bell', 'certificate', 'thumbs-up', 'thumbs-down', 'hand-right', 'hand-left', 'hand-up', 'hand-down', 'circle-arrow-right', 'circle-arrow-left', 'circle-arrow-up', 'circle-arrow-down', 'globe', 'wrench', 'tasks', 'filter', 'briefcase', 'fullscreen');
            foreach ($matches as $match) {
                $icons[] = $prefix . $match;
            }
            return $icons;
        }
        if ($type == 'bs3') {
            $matches = array('adjust', 'align-center', 'align-justify', 'align-left', 'align-right', 'arrow-down', 'arrow-left', 'arrow-right', 'arrow-up', 'asterisk', 'backward', 'ban-circle', 'barcode', 'bell', 'bold', 'book
			', 'bookmark', 'briefcase', 'bullhorn', 'calendar', 'camera', 'certificate', 'check', 'chevron-down', 'chevron-left', 'chevron-right', 'chevron-up', 'circle-arrow-down', 'circle-arrow-left', 'circle-arrow-right
			', 'circle-arrow-up', 'cloud', 'cloud-download', 'cloud-upload', 'cog', 'collapse-down', 'collapse-up', 'comment', 'compressed', 'copyright-mark', 'credit-card', 'cutlery', 'dashboard', 'download', 'download-alt
			', 'earphone', 'edit', 'eject', 'envelope', 'euro', 'exclamation-sign', 'expand', 'export', 'eye-close', 'eye-open', 'facetime-video', 'fast-backward', 'fast-forward', 'file', 'film', 'filter', 'fire', 'flag
			', 'flash', 'floppy-disk', 'floppy-open', 'floppy-remove', 'floppy-save', 'floppy-saved', 'folder-close', 'folder-open', 'font', 'forward', 'fullscreen', 'gbp', 'gift
			', 'glass', 'globe', 'hand-down', 'hand-left', 'hand-right', 'hand-up', 'hd-video', 'hdd', 'header', 'headphones', 'heart', 'heart-empty', 'home', 'import', 'inbox', 'indent-left', 'indent-right', 'info-sign', 'italic', 'leaf', 'link', 'list
			', 'list-alt', 'lock', 'log-in', 'log-out', 'magnet', 'map-marker', 'minus', 'minus-sign', 'move', 'music', 'new-window', 'off', 'ok', 'ok-circle', 'ok-sign', 'open', 'paperclip', 'pause', 'pencil', 'phone', 'phone-alt', 'picture
			', 'plane', 'play', 'play-circle', 'plus', 'plus-sign', 'print', 'pushpin', 'qrcode', 'question-sign', 'random', 'record', 'refresh', 'registration-mark', 'remove', 'remove-circle', 'remove-sign', 'repeat', 'resize-full', 'resize-horizontal
			', 'resize-small', 'resize-vertical', 'retweet', 'road', 'save', 'saved', 'screenshot', 'sd-video', 'search', 'send', 'share', 'share-alt', 'shopping-cart', 'signal', 'sort', 'sort-by-alphabet', 'sort-by-alphabet-alt
			', 'sort-by-attributes', 'sort-by-attributes-alt', 'sort-by-order', 'sort-by-order-alt', 'sound-5-1', 'sound-6-1', 'sound-7-1', 'sound-dolby', 'sound-stereo', 'star', 'stats', 'step-backward', 'step-forward', 'stop
			', 'subtitles', 'tag', 'tags', 'tasks', 'text-height', 'text-width', 'th', 'th-large', 'th-list', 'thumbs-down', 'thumbs-up', 'time', 'tint', 'tower', 'transfer', 'trash', 'tree-conifer', 'tree-deciduous', 'unchecked', 'upload
			', 'usd', 'user', 'volume-down', 'volume-off', 'volume-up', 'warning-sign', 'wrench', 'zoom-in', 'zoom-out');
            foreach ($matches as $match) {
                $icons[] = $prefix . $match;
            }
            return $icons;
        }
        $cache = e107::getCache();
        $cache->setMD5('_' . $prefix . $type);
        if ($data = $cache->retrieve($type, 360, true)) {
            return e107::unserialize($data);
        }
        if ($type == 'fa4') {
            $pattern = '/\\.(fa-(?:\\w+(?:-)?)+):before/';
            $subject = e107::getFile()->getRemoteContent('http://netdna.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.css');
            //	print_a($subject);
        } elseif ($type == 'fa3') {
            $pattern = '/\\.(icon-(?:\\w+(?:-)?)+):before/';
            $subject = file_get_contents(e_WEB_JS . 'font-awesome/css/font-awesome.css');
        }
        preg_match_all($pattern, $subject, $matches, PREG_SET_ORDER);
        foreach ($matches as $match) {
            $icons[] = $prefix . substr($match[1], 3);
        }
        $data = e107::serialize($icons);
        $cache->set($type, $data, true);
        return $icons;
    }
Example #5
0
            if ($sql->insert('newsfeed', $feed)) {
                $admin_log->logArrayAll('NEWSFD_01', $feed);
                $mes->addSuccess(LAN_CREATED);
            } else {
                $mes->addError(LAN_CREATED_FAILED . ': ' . $sql->mySQLerror);
            }
        } elseif (isset($_POST['updateFeed'])) {
            $feed['WHERE'] = "newsfeed_id=" . intval($_POST['newsfeed_id']);
            if ($sql->update('newsfeed', $feed)) {
                $admin_log->logArrayAll('NEWSFD_02', $feed);
                $mes->addSuccess(LAN_UPDATED);
            } else {
                $mes->addInfo(LAN_NO_CHANGE . ': ' . $sql->mySQLerror);
            }
        }
        e107::getCache()->clear(NEWSFEED_LIST_CACHE_TAG);
        // This should actually clear all the newsfeed data in one go
    } else {
        $mes->addError(LAN_REQUIRED_BLANK);
    }
}
$ns->tablerender($caption, $mes->render() . $text);
if ($action == "delete") {
    $sql->db_Delete('newsfeed', 'newsfeed_id=' . $id);
    e107::getLog()->add('NEWSFD_03', 'ID: ' . $id, E_LOG_INFORMATIVE, '');
    $mes->addSuccess(LAN_DELETED);
}
$ns->tablerender($caption, $mes->render() . $text);
if ($headline_total = $sql->db_Select("newsfeed")) {
    $nfArray = $sql->rows();
    $text = "\n\t<table class='table table-striped'>\n\t<colgroup>\n\t\t<col style='width: 5%; text-align: center;' />\n\t\t<col style='width: 40%;' />\n\t\t<col style='width: 10%; text-align: center;' />\n\t\t<col style='width: 25%; text-align: center;' />\n\t\t<col style='width: 10%; text-align: center;' />\n\t</colgroup>\n\t<thead>\n\t<tr>\n\t\t<th>" . LAN_ID . "</th>\n\t\t<th>" . LAN_NAME . "</th>\n\t\t<th>" . NFLAN_26 . "</th>\n\t\t<th>" . NFLAN_12 . "</th>\n\t\t<th class='center options'>" . LAN_OPTIONS . "</th>\n\t</tr>\n\t</thead>\n";
Example #6
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;
}
Example #7
0
 function delete_extended($_name)
 {
     $ue = e107::getUserExt();
     $log = e107::getAdminLog();
     $mes = e107::getMessage();
     if ($ue->user_extended_remove($_name, $_name)) {
         $log->add('EUF_07', $_name, E_LOG_INFORMATIVE);
         $mes->addSuccess(LAN_DELETED . " [" . $_name . "]");
         e107::getCache()->clear_sys('user_extended_struct', true);
     } else {
         $mes->addError(LAN_ERROR . " [" . $_name . "]");
     }
 }
Example #8
0
 public function afterDelete($del_data, $id)
 {
     e107::getCache()->clear_sys('forum_perms');
 }
Example #9
0
 public function afterUpdate($new_data, $old_data, $id)
 {
     e107::getCache()->clear("wmessage");
 }
Example #10
0
function show_prefs($mailAdmin)
{
    global $pref;
    $e107 = e107::getInstance();
    $frm = e107::getForm();
    $mes = e107::getMessage();
    e107::getCache()->CachePageMD5 = '_';
    $lastload = e107::getCache()->retrieve('emailLastBounce', FALSE, TRUE, TRUE);
    $lastBounce = round((time() - $lastload) / 60);
    $lastBounceText = $lastBounce > 1256474 ? "<b>Never</b>" : "<b>" . $lastBounce . " minutes </b>ago.";
    $text = "\n\t\t<form method='post' action='" . e_SELF . "?" . e_QUERY . "' id='mailsettingsform'>\n\t\t<fieldset id='mail'>\n\t\t<legend>" . LAN_MAILOUT_110 . "</legend>\n\t\t<table class='table adminform'>\n\t\t<colgroup>\n\t\t\t<col class='col-label' />\n\t\t\t<col class='col-control' />\n\t\t</colgroup>\n\t\t<tbody>\n\t\t<tr>\n\t\t\t<td>" . LAN_MAILOUT_110 . "<br /></td>\n\t\t\t<td>" . $frm->admin_button('testemail', LAN_MAILOUT_112, 'other') . "&nbsp;\n\t\t\t<input name='testaddress' class='tbox' type='text' size='40' maxlength='80' value=\"" . (varset($_POST['testaddress']) ? $_POST['testaddress'] : USEREMAIL) . "\" />\n\t\t\t</td>\n\t\t</tr>\n\n\t\t<tr>\n\t\t<td style='vertical-align:top'>" . LAN_MAILOUT_115 . "<br /></td>\n\t\t<td>\n\t\t<select class='tbox' name='mailer' onchange='disp(this.value)'>\n";
    $mailers = array('php', 'smtp', 'sendmail');
    foreach ($mailers as $opt) {
        $sel = $pref['mailer'] == $opt ? "selected='selected'" : '';
        $text .= "<option value='{$opt}' {$sel}>{$opt}</option>\n";
    }
    $text .= "</select> <span class='field-help'>" . LAN_MAILOUT_116 . "</span><br />";
    // SMTP. -------------->
    $smtp_opts = explode(',', varset($pref['smtp_options'], ''));
    $smtpdisp = $pref['mailer'] != 'smtp' ? "style='display:none;'" : '';
    $text .= "<div id='smtp' {$smtpdisp}>\n\t\t<table class='table adminlist' style='margin-right:auto;margin-left:0px;border:0px'>\n\t\t<colgroup>\n\t\t\t<col class='col-label' />\n\t\t\t<col class='col-control' />\n\t\t</colgroup>\n\t\t";
    $text .= "\n\t\t<tr>\n\t\t<td>" . LAN_MAILOUT_87 . ":&nbsp;&nbsp;</td>\n\t\t<td>\n\t\t<input class='tbox' type='text' name='smtp_server' size='40' value='" . $pref['smtp_server'] . "' maxlength='50' />\n\t\t</td>\n\t\t</tr>\n\n\t\t<tr>\n\t\t<td>" . LAN_MAILOUT_88 . ":&nbsp;(" . LAN_OPTIONAL . ")&nbsp;&nbsp;</td>\n\t\t<td style='width:50%;' >\n\t\t<input class='tbox' type='text' name='smtp_username' size='40' value=\"" . $pref['smtp_username'] . "\" maxlength='50' />\n\t\t</td>\n\t\t</tr>\n\n\t\t<tr>\n\t\t<td>" . LAN_MAILOUT_89 . ":&nbsp;(" . LAN_OPTIONAL . ")&nbsp;&nbsp;</td>\n\t\t<td>\n\t\t<input class='tbox' type='password' name='smtp_password' size='40' value='" . $pref['smtp_password'] . "' maxlength='50' />\n\t\t</td>\n\t\t</tr>\n\n\t\t<tr>\n\t\t<td>" . LAN_MAILOUT_90 . "</td><td>\n\t\t<select class='tbox' name='smtp_options'>\n\n\t\t<option value=''>" . LAN_MAILOUT_96 . "</option>\n";
    $selected = in_array('secure=SSL', $smtp_opts) ? " selected='selected'" : '';
    $text .= "<option value='smtp_ssl'{$selected}>" . LAN_MAILOUT_92 . "</option>\n";
    $selected = in_array('secure=TLS', $smtp_opts) ? " selected='selected'" : '';
    $text .= "<option value='smtp_tls'{$selected}>" . LAN_MAILOUT_93 . "</option>\n";
    $selected = in_array('pop3auth', $smtp_opts) ? " selected='selected'" : '';
    $text .= "<option value='smtp_pop3auth'{$selected}>" . LAN_MAILOUT_91 . "</option>\n";
    $text .= "</select>\n<br />" . LAN_MAILOUT_94 . "</td></tr>";
    $text .= "<tr>\n\t\t<td>" . LAN_MAILOUT_57 . "</td><td>\n\t\t";
    $checked = varsettrue($pref['smtp_keepalive']) ? "checked='checked'" : '';
    $text .= "<input type='checkbox' name='smtp_keepalive' value='1' {$checked} />\n\t\t</td>\n\t\t</tr>";
    $checked = in_array('useVERP', $smtp_opts) ? "checked='checked'" : "";
    $text .= "<tr>\n\t\t<td>" . LAN_MAILOUT_95 . "</td><td>\n\t\t<input type='checkbox' name='smtp_useVERP' value='1' {$checked} />\n\t\t</td>\n\t\t</tr>\n\t\t</table></div>";
    /* FIXME - posting SENDMAIL path triggers Mod-Security rules. 
    // Sendmail. -------------->
    	$senddisp = ($pref['mailer'] != 'sendmail') ? "style='display:none;'" : '';
    	$text .= "<div id='sendmail' {$senddisp}><table style='margin-right:0px;margin-left:auto;border:0px'>";
    	$text .= "
    	<tr>
    	<td>".LAN_MAILOUT_20.":&nbsp;&nbsp;</td>
    	<td>
    	<input class='tbox' type='text' name='sendmail' size='60' value=\"".(!$pref['sendmail'] ? "/usr/sbin/sendmail -t -i -r ".$pref['siteadminemail'] : $pref['sendmail'])."\" maxlength='80' />
    	</td>
    	</tr>
    
    	</table></div>";
    */
    $text .= "</td>\n\t</tr>\n\n\n\t<tr>\n\t\t<td>" . LAN_MAILOUT_222 . "</td>\n\t\t<td>";
    $text .= $mailAdmin->sendStyleSelect(varset($pref['mail_sendstyle'], 'textonly'), 'mail_sendstyle');
    $text .= "<span class='field-help'>" . LAN_MAILOUT_223 . "</span>\n\t\t</td>\n\t</tr>\n\n\n\t\n\t<tr>\n\t\t<td>" . LAN_MAILOUT_25 . "</td>\n\t\t<td> " . LAN_MAILOUT_26 . "\n\t\t<input class='tbox e-spinner' size='3' type='text' name='mail_pause' value='" . $pref['mail_pause'] . "' /> " . LAN_MAILOUT_27 . "<input class='tbox e-spinner' size='3' type='text' name='mail_pausetime' value='" . $pref['mail_pausetime'] . "' /> " . LAN_MAILOUT_29 . ".<br />\n\t\t<span class='field-help'>" . LAN_MAILOUT_30 . "</span>\n\t\t</td>\n\t</tr>\n\n\t\n\t<tr>\n\t\t<td>" . LAN_MAILOUT_156 . "</td>\n\t\t<td><input class='tbox e-spinner' size='3' type='text' name='mail_workpertick' value='" . varset($pref['mail_workpertick'], 5) . "' />\n\t\t<span class='field-help'>" . LAN_MAILOUT_157 . "</span>\n\t\t</td>\n\t</tr>\n";
    if (isset($pref['e_mailout_list'])) {
        // Allow selection of email address sources
        $text .= "<tr>\n\t\t<td>" . LAN_MAILOUT_77 . "</td>\n\t\t<td> \n\t  ";
        $mail_enable = explode(',', $pref['mailout_enabled']);
        foreach ($pref['e_mailout_list'] as $mailer => $v) {
            $check = in_array($mailer, $mail_enable) ? "checked='checked'" : "";
            $text .= "&nbsp;<input type='checkbox' name='mail_mailer_enabled[]' value='{$mailer}' {$check} /> {$mailer}<br />";
        }
        $text .= "</td></tr>\n";
    }
    list($mail_log_option, $mail_log_email) = explode(',', varset($pref['mail_log_options'], '0,0'));
    $check = $mail_log_email == 1 ? " checked='checked'" : "";
    $text .= "<tr>\n\t\t<td>" . LAN_MAILOUT_72 . "</td>\n\t\t<td> \n\t\t<select class='tbox' name='mail_log_option'>\n\n\t\t<option value='0'" . ($mail_log_option == 0 ? " selected='selected'" : '') . ">" . LAN_MAILOUT_73 . "</option>\n\n\t\t<option value='1'" . ($mail_log_option == 1 ? " selected='selected'" : '') . ">" . LAN_MAILOUT_74 . "</option>\n\n\t\t<option value='2'" . ($mail_log_option == 2 ? " selected='selected'" : '') . ">" . LAN_MAILOUT_75 . "</option>\n\n\t\t<option value='3'" . ($mail_log_option == 3 ? " selected='selected'" : '') . ">" . LAN_MAILOUT_119 . "</option>\n\n\t\t</select>\n\n\t\t<input type='checkbox' name='mail_log_email' value='1' {$check} />" . LAN_MAILOUT_76 . "</td>\n\t</tr>\n";
    $text .= "</table></fieldset>\n\t<fieldset id='core-mail-prefs-bounce'>\n\t\t<legend>" . LAN_MAILOUT_31 . "</legend>\n\t\t<table class='table adminform'>\n\t\t<colgroup>\n\t\t\t<col class='col-label' />\n\t\t\t<col class='col-control' />\n\t\t</colgroup>\n\t\t<tbody>\n\t<tr>\n\t\t<td>" . LAN_MAILOUT_231 . "</td><td>";
    // bounce divs = mail_bounce_none, mail_bounce_auto, mail_bounce_mail
    $autoDisp = $pref['mail_bounce'] != 'auto' ? "style='display:none;'" : '';
    $autoMail = $pref['mail_bounce'] != 'mail' ? "style='display:none;'" : '';
    $bounceOpts = array('none' => LAN_MAILOUT_232, 'auto' => LAN_MAILOUT_233, 'mail' => LAN_MAILOUT_234);
    $text .= "<select name='mail_bounce' class='tbox' onchange='bouncedisp(this.value)'>\n<option value=''>&nbsp;</option>\n";
    foreach ($bounceOpts as $k => $v) {
        $selected = $pref['mail_bounce'] == $k ? " selected='selected'" : '';
        $text .= "<option value='{$k}'{$selected}>{$v}</option>\n";
    }
    $text .= "</select>\n</td>\n\t</tr></tbody></table>\n\n\n\t\t<table class='adminform' id='mail_bounce_auto' {$autoDisp}>\n\t\t<colgroup>\n\t\t\t<col class='col-label' />\n\t\t\t<col class='col-control' />\n\t\t</colgroup>\n\t\t<tbody>\n\t\t<tr><td>" . LAN_MAILOUT_32 . "</td><td><input class='tbox' size='40' type='text' name='mail_bounce_email2' value=\"" . $pref['mail_bounce_email'] . "\" /></td></tr>\n\t\n\t<tr>\n\t\t<td>" . LAN_MAILOUT_233 . "</td><td><b>" . e_DOCROOT . e107::getFolder('handlers') . "bounce_handler.php</b>";
    if (!is_readable(e_HANDLER . 'bounce_handler.php')) {
        $text .= "<br /><span class='required'>" . LAN_MAILOUT_161 . '</span>';
    } elseif (!is_executable(e_HANDLER . 'bounce_handler.php')) {
        $text .= "<br /><span class='required'>" . LAN_MAILOUT_162 . '</span>';
    }
    $text .= "<br /><span class='field-help'>" . LAN_MAILOUT_235 . "</span></td></tr>\n\t<tr><td>" . LAN_MAILOUT_236 . "</td><td>" . $lastBounceText . "</td></tr>\n\t</tbody></table>";
    // Parameters for mail-account based bounce processing
    $text .= "\n\t\t<table class='table adminform' id='mail_bounce_mail' {$autoMail}>\n\t\t<colgroup>\n\t\t\t<col class='col-label' />\n\t\t\t<col class='col-control' />\n\t\t</colgroup>\n\t\t<tbody>\n\t\t<tr><td>" . LAN_MAILOUT_32 . "</td><td><input class='tbox' size='40' type='text' name='mail_bounce_email' value=\"" . $pref['mail_bounce_email'] . "\" /></td></tr>\n\t\t<tr><td>" . LAN_MAILOUT_33 . "</td><td><input class='tbox' size='40' type='text' name='mail_bounce_pop3' value=\"" . $pref['mail_bounce_pop3'] . "\" /></td></tr>\n\t\t<tr><td>" . LAN_MAILOUT_34 . "</td><td><input class='tbox' size='40' type='text' name='mail_bounce_user' value=\"" . $pref['mail_bounce_user'] . "\" /></td></tr>\n\t\t<tr><td>" . LAN_MAILOUT_35 . "</td><td><input class='tbox' size='40' type='text' name='mail_bounce_pass' value=\"" . $pref['mail_bounce_pass'] . "\" /></td></tr>\n\t\t<tr><td>" . LAN_MAILOUT_120 . "</td><td><select class='tbox' name='mail_bounce_type'>\n\n\t\t\t<option value=''>&nbsp;</option>\n\n\t\t\t<option value='pop3'" . ($pref['mail_bounce_type'] == 'pop3' ? " selected='selected'" : "") . ">" . LAN_MAILOUT_121 . "</option>\n\n\t\t\t<option value='pop3/notls'" . ($pref['mail_bounce_type'] == 'pop3/notls' ? " selected='selected'" : "") . ">" . LAN_MAILOUT_122 . "</option>\n\n\t\t\t<option value='pop3/tls'" . ($pref['mail_bounce_type'] == 'pop3/tls' ? " selected='selected'" : "") . ">" . LAN_MAILOUT_123 . "</option>\n\n\t\t\t<option value='imap'" . ($pref['mail_bounce_type'] == 'imap' ? " selected='selected'" : "") . ">" . LAN_MAILOUT_124 . "</option>\n\n\t\t</select></td></tr>\n\n\t\t";
    $check = $pref['mail_bounce_delete'] == 1 ? " checked='checked'" : "";
    $text .= "<tr><td>" . LAN_MAILOUT_36 . "</td><td><input type='checkbox' name='mail_bounce_delete' value='1' {$check} /></td></tr>";
    $check = $pref['mail_bounce_auto'] == 1 ? " checked='checked'" : "";
    $text .= "<tr><td>" . LAN_MAILOUT_245 . "</td><td><input type='checkbox' name='mail_bounce_auto' value='1' {$check} /><span class='field-help'>&nbsp;" . LAN_MAILOUT_246 . "</span></td></tr>\n\n\t</tbody>\n\t</table></fieldset>\n\n\t<div class='buttons-bar center'>" . $frm->admin_button('updateprefs', LAN_MAILOUT_28, 'update') . "</div>\n\n\t</form>";
    $caption = ADLAN_136 . ' :: ' . LAN_PREFS;
    $e107->ns->tablerender($caption, $mes->render() . $text);
}
Example #11
0
File: cron.php Project: notzen/e107
$_E107['cli'] = TRUE;
$_E107['debug'] = false;
$_E107['no_online'] = TRUE;
$_E107['no_forceuserupdate'] = TRUE;
$_E107['no_menus'] = TRUE;
// we allow theme init as cron jobs might need to access current theme templates (e.g. custom email templates)
require_once realpath(dirname(__FILE__) . "/class2.php");
$pwd = $_E107['debug'] && $_SERVER['QUERY_STRING'] ? $_SERVER['QUERY_STRING'] : trim($_SERVER['argv'][1]);
if ($pref['e_cron_pwd'] != $pwd) {
    require_once e_HANDLER . "mail.php";
    $message = "Your Cron Schedule is not configured correctly. Your passwords do not match.\n\t\t<br /><br /> \n\t\tSent from cron: " . $pwd . "<br />\n\t\tStored in e107: " . $pref['e_cron_pwd'] . "<br /><br />\n\t\tYou should regenerate the cron command in admin and enter it again in your server configuration. \n\t\t";
    sendemail($pref['siteadminemail'], "e107 - Cron Schedule Misconfigured.", $message, $pref['siteadmin'], $pref['siteadminemail'], $pref['siteadmin']);
    exit;
}
e107::getCache()->CachePageMD5 = '_';
e107::getCache()->set('cronLastLoad', time(), TRUE, FALSE, TRUE);
// from the plugin directory:
// realpath(dirname(__FILE__)."/../../")."/";
$list = array();
$sql = e107::getDb();
if ($sql->db_Select("cron", 'cron_function,cron_tab', 'cron_active =1')) {
    while ($row = $sql->db_Fetch(MYSQL_ASSOC)) {
        list($class, $function) = explode("::", $row['cron_function'], 2);
        $key = $class . "__" . $function;
        $list[$key] = array('path' => $class, 'active' => 1, 'tab' => $row['cron_tab'], 'function' => $function, 'class' => $class);
    }
}
// foreach($pref['e_cron_pref'] as $func=>$cron)
// {
// if($cron['active']==1)
// {
Example #12
0
<?php

/**
 * Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
 * $Id$
 * 
 * News categories menu
 */
if (!defined('e107_INIT')) {
    exit;
}
$cacheString = 'nq_news_categories_menu_' . md5(serialize($parm));
$cached = e107::getCache()->retrieve($cacheString);
if (false === $cached) {
    e107::plugLan('news');
    if (is_string($parm)) {
        parse_str($parm, $parms);
    } else {
        $parms = $parm;
    }
    $ctree = e107::getObject('e_news_category_tree', null, e_HANDLER . 'news_class.php');
    $template = e107::getTemplate('news', 'news_menu', 'category');
    $cached = $ctree->loadActive()->render($template, $parms, true);
    e107::getCache()->set($cacheString, $cached);
}
echo $cached;
Example #13
0
 /**
  * @param $id of the post
  */
 function updateReply()
 {
     $mes = e107::getMessage();
     $ns = e107::getRender();
     if (empty($_POST['post'])) {
         $mes->addError(LAN_FORUM_3007);
         return;
     }
     if ($this->isAuthor() == false) {
         $mes->addError(LAN_FORUM_3009);
         return;
     }
     $postVals['post_edit_datestamp'] = time();
     $postVals['post_edit_user'] = USERID;
     $postVals['post_entry'] = $_POST['post'];
     $this->forumObj->postUpdate($this->data['post_id'], $postVals);
     e107::getCache()->clear('newforumposts');
     //	$url = e107::getUrl()->create('forum/thread/post', "id={$this->data['post_id']}", 'encode=0&full=1'); // XXX what data is available, find thread name
     $url = e107::url('forum', 'topic', $this->data);
     // ."&f=post";
     $this->redirect($url);
     exit;
 }
Example #14
0
 private function processActivationLink()
 {
     global $userMethods;
     $sql = e107::getDb();
     $tp = e107::getParser();
     $ns = e107::getRender();
     $log = e107::getLog();
     $pref = e107::pref('core');
     $qs = explode('.', e_QUERY);
     if ($qs[0] == 'activate' && (count($qs) == 3 || count($qs) == 4) && $qs[2]) {
         // FIXME TODO use generic multilanguage selection => e107::coreLan();
         // return the message in the correct language.
         if (isset($qs[3]) && strlen($qs[3]) == 2) {
             require_once e_HANDLER . 'language_class.php';
             $slng = new language();
             $the_language = $slng->convert($qs[3]);
             if (is_readable(e_LANGUAGEDIR . $the_language . '/lan_' . e_PAGE)) {
                 include e_LANGUAGEDIR . $the_language . '/lan_' . e_PAGE;
             } else {
                 include_lan(e_LANGUAGEDIR . e_LANGUAGE . '/lan_' . e_PAGE);
             }
         } else {
             include_lan(e_LANGUAGEDIR . e_LANGUAGE . '/lan_' . e_PAGE);
         }
         e107::getCache()->clear("online_menu_totals");
         if ($sql->select("user", "*", "user_sess='" . $tp->toDB($qs[2], true) . "' ")) {
             if ($row = $sql->fetch()) {
                 $dbData = array();
                 $dbData['WHERE'] = " user_sess='" . $tp->toDB($qs[2], true) . "' ";
                 $dbData['data'] = array('user_ban' => '0', 'user_sess' => '');
                 // Set initial classes, and any which the user can opt to join
                 if ($init_class = $userMethods->userClassUpdate($row, 'userfull')) {
                     //print_a($init_class); exit;
                     $dbData['data']['user_class'] = $init_class;
                 }
                 $userMethods->addNonDefaulted($dbData);
                 validatorClass::addFieldTypes($userMethods->userVettingInfo, $dbData);
                 $newID = $sql->update('user', $dbData);
                 if ($newID === false) {
                     $log->e_log_event(10, debug_backtrace(), 'USER', 'Verification Fail', print_r($row, true), false, LOG_TO_ROLLING);
                     $ns->tablerender(LAN_SIGNUP_75, LAN_SIGNUP_101);
                     return false;
                 }
                 // Log to user audit log if enabled
                 $log->user_audit(USER_AUDIT_EMAILACK, $row);
                 e107::getEvent()->trigger('userveri', $row);
                 // Legacy event
                 e107::getEvent()->trigger('user_signup_activated', $row);
                 e107::getEvent()->trigger('userfull', $row);
                 // 'New' event
                 if (varset($pref['autologinpostsignup'])) {
                     require_once e_HANDLER . 'login.php';
                     $usr = new userlogin();
                     $usr->login($row['user_loginname'], md5($row['user_name'] . $row['user_password'] . $row['user_join']), 'signup', '');
                 }
                 $text = "<div class='alert alert-success'>" . LAN_SIGNUP_74 . " <a href='index.php'>" . LAN_SIGNUP_22 . "</a> " . LAN_SIGNUP_23 . "<br />" . LAN_SIGNUP_24 . " " . SITENAME . "</div>";
                 $ns->tablerender(LAN_SIGNUP_75, $text);
             }
         } else {
             // Invalid activation code
             $log->e_log_event(10, debug_backtrace(), 'USER', 'Invalid Verification URL', print_r($qs, true), false, LOG_TO_ROLLING);
             echo e107::getMessage()->addError("Invalid URL")->render();
             //	header("location: ".e_BASE."index.php");
             return false;
         }
     }
 }
Example #15
0
 public function afterDelete($deleted_data, $id, $deleted_check)
 {
     e107::getCache()->clear_sys(LW_CACHE_TAG);
 }
Example #16
0
 public function observe()
 {
     if (isset($_POST['submit_download'])) {
         $this->submit_download();
     }
     if (isset($_POST['updatedownlaodoptions'])) {
         $this->saveSettings();
     }
     if (isset($_POST['submit_mirror'])) {
         $this->submit_mirror();
     }
     if (isset($_POST)) {
         e107::getCache()->clear("download_cat");
     }
 }
Example #17
0
function wmessage_shortcode($parm = '')
{
    if ($parm == 'hide') {
        return;
    }
    $e107 = e107::getInstance();
    $e107cache = e107::getCache();
    $pref = e107::getPref();
    $front_url = '';
    /* DEPRECATED - see auto-detect in header_default.php 
    	$prefwmsc = varset($pref['wmessage_sc'], FALSE);
    	if (($prefwmsc && $parm == 'header') || (!$prefwmsc && ($parm !='header')) )
    	{	// Two places it might be invoked - allow one or the other
    	//	return;
    	}
    	*/
    if ($parm != 'force') {
        $full_url = 'news.php';
        // Set a default in case
        $front_qry = '';
        $uc_array = explode(',', USERCLASS_LIST);
        if (varset($pref['frontpage'])) {
            foreach ($pref['frontpage'] as $fk => $fp) {
                if (in_array($fk, $uc_array)) {
                    $full_url = $fp;
                    break;
                }
            }
            list($front_url, $front_qry) = explode('?', $full_url . '?');
            // extra '?' ensure the array is filled
        }
    }
    if (strpos($front_url, 'http') === FALSE) {
        $front_url = SITEURL . $front_url;
    }
    if (deftrue('e_FRONTPAGE') || $parm == 'force' || e_SELF == $front_url && ($parm == 'ignore_query' || e_QUERY == $front_qry)) {
        // Actually want to display a welcome message here
        $ns = e107::getRender();
        $tp = e107::getParser();
        $sql = e107::getDb();
        if ($cacheData = $e107cache->retrieve('wmessage')) {
            echo $cacheData;
            return;
        }
        if (!defined('WMFLAG')) {
            $qry = "\n\t\t\tSELECT * FROM #generic\n\t\t\tWHERE gen_type ='wmessage' AND gen_intdata IN (" . USERCLASS_LIST . ')';
            $wmessage = array();
            $wmessageCaption = array();
            $wmcaption = '';
            if ($sql->gen($qry)) {
                while ($row = $sql->fetch()) {
                    $wmessage[] = $tp->toHTML($row['gen_chardata'], TRUE, 'BODY, defs', 'admin');
                    $wmessageCaption[] = $tp->toHTML($row['gen_ip'], TRUE, 'TITLE');
                    if (!$wmcaption) {
                        $wmcaption = $tp->toHTML($row['gen_ip'], TRUE, 'TITLE');
                    }
                }
            }
            if (isset($wmessage) && $wmessage) {
                ob_start();
                if (intval($pref['wm_enclose']) === 2) {
                    $carousel = array();
                    foreach ($wmessage as $k => $v) {
                        $carousel['slide-' . $k] = array('caption' => $wmessageCaption[$k], 'text' => $ns->tablerender($wmessageCaption[$k], $v, 'wm', true));
                    }
                    echo e107::getForm()->carousel('wmessage-carousel', $carousel);
                } elseif (intval($pref['wm_enclose']) === 1) {
                    $ns->tablerender($wmcaption, implode("<br />", $wmessage), 'wm');
                } else {
                    echo "<div class='wmessage'>";
                    echo $wmcaption ? $wmcaption . '<br />' : '';
                    echo implode('<br />', $wmessage);
                    echo "</div>";
                }
                $cache_data = ob_get_flush();
                $e107cache->set('wmessage', $cache_data);
            }
        }
    }
}
Example #18
0
 function clearCache()
 {
     $ecache = e107::getCache();
     $ecache->clear("news.php");
     //TODO change it to 'news_*' everywhere
     $ecache->clear("news_", false, true);
     //NEW global news cache prefix
     $ecache->clear("othernews");
     //TODO change it to 'news_othernews' everywhere
     $ecache->clear("othernews2");
     //TODO change it to 'news_othernews2' everywhere
     //$ecache->clear("nq_news_"); - supported by cache::clear() now
     //$ecache->clear("nomd5_news_"); supported by cache::clear() now
     return $this;
 }
Example #19
0
 function delete_extended($_name)
 {
     global $ue, $admin_log;
     $emessage = eMessage::getInstance();
     if ($ue->user_extended_remove($_name, $_name)) {
         $admin_log->log_event('EUF_07', $_name, E_LOG_INFORMATIVE, '');
         $emessage->add(EXTLAN_30 . " [" . $_name . "]", E_MESSAGE_SUCCESS);
         e107::getCache()->clear_sys('user_extended_struct', true);
     } else {
         $emessage->add(LAN_ERROR . " [" . $_name . "]", E_MESSAGE_ERROR);
     }
 }
Example #20
0
            $text .= $ix->render_newsitem($row, 'return', '', $OTHERNEWS_STYLE, $param);
            $text .= "\n</td>\n";
            if (($t + 1) % $nbr_cols == 0) {
                $text .= "</tr>";
                $t++;
            } else {
                $t++;
            }
        }
        while ($t % $nbr_cols != 0) {
            $text .= "<td style='width:{$wid}'>&nbsp;</td>\n";
            $text .= ($t + 1) % $nbr_cols == 0 ? "</tr>" : "";
            $t++;
        }
        $text .= "</table>";
    } else {
        $loop = 0;
        while ($row = $sql->fetch()) {
            $active = $loop == 0 ? 'active' : '';
            $TMPL = str_replace("{ACTIVE}", $active, $OTHERNEWS_STYLE);
            $text .= $ix->render_newsitem($row, 'return', '', $TMPL, $param);
            $loop++;
        }
    }
    $text .= $tp->parseTemplate($template['end'], true);
    // Save Data
    ob_start();
    $ns->tablerender($caption, $text, 'other_news');
    $cache_data = ob_get_flush();
    e107::getCache()->set("nq_othernews", $cache_data);
}
Example #21
0
            require_once e_CORE . "templates/trackback_template.php";
        }
        $text = "";
        foreach ($tbArray as $trackback) {
            extract($trackback);
            $TITLE = $trackback_title;
            $EXCERPT = $trackback_excerpt;
            $BLOGNAME = "<a href='{$trackback_url}' rel='external'>{$trackback_blogname}</a>";
            $text .= preg_replace("/\\{(.*?)\\}/e", '$\\1', $TRACKBACK);
        }
        if ($TRACKBACK_RENDER_METHOD) {
            $ns->tablerender("<a name='track'></a>" . COMLAN_315, $text);
        } else {
            echo "<a name='track'></a>" . $text;
        }
    } else {
        echo "<a name='track'></a>" . COMLAN_316;
    }
    if (ADMIN && getperms("B")) {
        echo "<div style='text-align:right'><a href='" . e_PLUGIN_ABS . "trackback/modtrackback.php?" . $id . "'>" . COMLAN_317 . "</a></div><br />";
    }
}
//if (!strstr(e_QUERY, "poll"))
// If output buffering started, cache the result
if ($comment_ob_start) {
    $cache = ob_get_contents();
    e107::getCache()->set("comment.php?{$table}.{$field}", $cache);
    ob_end_flush();
    // dump the buffer we started
}
require_once FOOTERF;
Example #22
0
 /** 
  * Function to retrieve Menu data from tables.
  */
 private function getDataLegacy()
 {
     $sql = e107::getDb();
     $menu_layout_field = THEME_LAYOUT != e107::getPref('sitetheme_deflayout') ? THEME_LAYOUT : "";
     //	e107::getCache()->CachePageMD5 = md5(e_LANGUAGE.$menu_layout_field); // Disabled by line 93 of Cache class.
     //FIXME add a function to the cache class for this.
     $menu_data = e107::getCache()->retrieve_sys("menus_" . USERCLASS_LIST . "_" . md5(e_LANGUAGE . $menu_layout_field));
     //	$menu_data = e107::getCache()->retrieve_sys("menus_".USERCLASS_LIST);
     $menu_data = e107::getArrayStorage()->ReadArray($menu_data);
     //	$menu_data = e107::getArrayStorage()->ReadArray($menu_data);
     $eMenuArea = array();
     // $eMenuList = array();
     //	$eMenuActive	= array();  // DEPRECATED
     if (!is_array($menu_data)) {
         $menu_qry = 'SELECT * FROM #menus WHERE menu_location > 0 AND menu_class IN (' . USERCLASS_LIST . ') AND menu_layout = "' . $menu_layout_field . '" ORDER BY menu_location,menu_order';
         if ($sql->gen($menu_qry)) {
             while ($row = $sql->fetch()) {
                 $eMenuArea[$row['menu_location']][] = $row;
             }
         }
         $menu_data['menu_area'] = $eMenuArea;
         $menuData = e107::getArrayStorage()->WriteArray($menu_data, false);
         //	e107::getCache()->set_sys('menus_'.USERCLASS_LIST, $menuData);
         e107::getCache()->set_sys('menus_' . USERCLASS_LIST . '_' . md5(e_LANGUAGE . $menu_layout_field), $menuData);
     } else {
         $eMenuArea = $menu_data['menu_area'];
     }
     return $eMenuArea;
 }
Example #23
0
 function prefsPage()
 {
     if (!getperms('0')) {
         return;
     }
     $pref = e107::getPref();
     $e107 = e107::getInstance();
     $frm = e107::getForm();
     $mes = e107::getMessage();
     $ns = e107::getRender();
     if ($pref['mail_bounce'] == 'auto' && !empty($pref['mail_bounce_email']) && !is_executable(e_HANDLER . "bounce_handler.php")) {
         $mes->addWarning('Your bounce_handler.php file is NOT executable');
     }
     e107::getCache()->CachePageMD5 = '_';
     $lastload = e107::getCache()->retrieve('emailLastBounce', FALSE, TRUE, TRUE);
     $lastBounce = round((time() - $lastload) / 60);
     $lastBounceText = $lastBounce > 1256474 ? "<span class='label label-important label-danger'>Never</span>" : "<span class='label label-success'>" . $lastBounce . " minutes ago.</span>";
     $text = "\n\t\t<form method='post' action='" . e_SELF . "?" . e_QUERY . "' id='mailsettingsform'>\n\t\t<fieldset id='mail'>\n\t\t<legend>" . LAN_MAILOUT_110 . "</legend>\n\t\t<table class='table adminform'>\n\t\t<colgroup>\n\t\t\t<col class='col-label' />\n\t\t\t<col class='col-control' />\n\t\t</colgroup>\n\t\t<tbody>\n\t\t<tr>\n\t\t\t<td>" . LAN_MAILOUT_110 . "<br /></td>\n\t\t\t<td class='form-inline'><div class='input-append'>" . $frm->admin_button('testemail', LAN_MAILOUT_112, 'other') . "&nbsp;\n\t\t\t<input name='testaddress' class='tbox input-xlarge' type='text' size='40' maxlength='80' value=\"" . (varset($_POST['testaddress']) ? $_POST['testaddress'] : USEREMAIL) . "\" />\n\t\t\t <span style='padding-left:5px'>" . $this->mailAdmin->sendStyleSelect(varset($_POST['testtemplate'], 'textonly'), 'testtemplate') . "</span>\n\t\t\t</div></td>\n\t\t</tr>\n\n\t\t<tr>\n\t\t<td>" . LAN_MAILOUT_77 . "</td>\n\t\t<td> ";
     $mail_enable = explode(',', vartrue($pref['mailout_enabled'], 'core'));
     $coreCheck = in_array('core', $mail_enable) ? "checked='checked'" : "";
     $text .= $frm->checkbox('mail_mailer_enabled[]', 'core', $coreCheck, 'users');
     if (!empty($pref['e_mailout_list'])) {
         foreach ($pref['e_mailout_list'] as $mailer => $v) {
             $check = in_array($mailer, $mail_enable) ? "checked='checked'" : "";
             $text .= $frm->checkbox('mail_mailer_enabled[]', $mailer, $check, $mailer);
             //	$text .= "&nbsp;<input type='checkbox' name='mail_mailer_enabled[]' value='{$mailer}' {$check} /> {$mailer}<br />";
         }
     }
     $text .= "</td></tr>\t\n\t\t\n\t\t\n\t\t<tr>\n\t\t<td style='vertical-align:top'>" . LAN_MAILOUT_115 . "<br /></td>\n\t\t<td>\n\t\t<select class='tbox input-xxlarge' name='mailer' onchange='disp(this.value)'>\n";
     $mailers = array('php', 'smtp', 'sendmail');
     foreach ($mailers as $opt) {
         $sel = $pref['mailer'] == $opt ? "selected='selected'" : '';
         $text .= "<option value='{$opt}' {$sel}>{$opt}</option>\n";
     }
     $text .= "</select> <span class='field-help'>" . LAN_MAILOUT_116 . "</span><br />";
     // SMTP. -------------->
     $smtp_opts = explode(',', varset($pref['smtp_options'], ''));
     $smtpdisp = $pref['mailer'] != 'smtp' ? "style='display:none;'" : '';
     $text .= "<div id='smtp' {$smtpdisp}>\n\t\t<table class='table adminlist' style='margin-right:auto;margin-left:0px;border:0px'>\n\t\t<colgroup>\n\t\t\t<col class='col-label' />\n\t\t\t<col class='col-control' />\n\t\t</colgroup>\n\t\t";
     $text .= "\n\t\t<tr>\n\t\t<td>" . LAN_MAILOUT_87 . ":&nbsp;&nbsp;</td>\n\t\t<td>\n\t\t<input class='tbox' type='text' name='smtp_server' size='40' value='" . $pref['smtp_server'] . "' maxlength='50' />\n\t\t</td>\n\t\t</tr>\n\n\t\t<tr>\n\t\t<td>" . LAN_MAILOUT_88 . ":&nbsp;(" . LAN_OPTIONAL . ")&nbsp;&nbsp;</td>\n\t\t<td style='width:50%;' >\n\t\t<input class='tbox' type='text' name='smtp_username' size='40' value=\"" . $pref['smtp_username'] . "\" maxlength='50' />\n\t\t</td>\n\t\t</tr>\n\n\t\t<tr>\n\t\t<td>" . LAN_MAILOUT_89 . ":&nbsp;(" . LAN_OPTIONAL . ")&nbsp;&nbsp;</td>\n\t\t<td>\n\t\t<input class='tbox' type='password' name='smtp_password' size='40' value='" . $pref['smtp_password'] . "' maxlength='50' />\n\t\t</td>\n\t\t</tr>\n\n\t\t<tr>\n\t\t<td>" . LAN_MAILOUT_90 . "</td><td>\n\t\t<select class='tbox' name='smtp_options'>\n\n\t\t\n\t\t<option value=''>" . LAN_MAILOUT_96 . "</option>\n";
     $selected = in_array('secure=SSL', $smtp_opts) ? " selected='selected'" : '';
     $text .= "<option value='smtp_ssl'{$selected}>" . LAN_MAILOUT_92 . "</option>\n";
     $selected = in_array('secure=TLS', $smtp_opts) ? " selected='selected'" : '';
     $text .= "<option value='smtp_tls'{$selected}>" . LAN_MAILOUT_93 . "</option>\n";
     $selected = in_array('pop3auth', $smtp_opts) ? " selected='selected'" : '';
     $text .= "<option value='smtp_pop3auth'{$selected}>" . LAN_MAILOUT_91 . "</option>\n";
     $text .= "</select>\n<br />" . LAN_MAILOUT_94 . "</td></tr>";
     $text .= "<tr>\n\t\t<td>" . LAN_MAILOUT_57 . "</td><td>\n\t\t";
     $checked = vartrue($pref['smtp_keepalive']) ? "checked='checked'" : '';
     $text .= "<input type='checkbox' name='smtp_keepalive' value='1' {$checked} />\n\t\t</td>\n\t\t</tr>";
     $checked = in_array('useVERP', $smtp_opts) ? "checked='checked'" : "";
     $text .= "<tr>\n\t\t<td>" . LAN_MAILOUT_95 . "</td><td>\n\t\t<input type='checkbox' name='smtp_useVERP' value='1' {$checked} />\n\t\t</td>\n\t\t</tr>\n\t\t</table></div>";
     /* FIXME - posting SENDMAIL path triggers Mod-Security rules. 
     	// Sendmail. -------------->
     		$senddisp = ($pref['mailer'] != 'sendmail') ? "style='display:none;'" : '';
     		$text .= "<div id='sendmail' {$senddisp}><table style='margin-right:0px;margin-left:auto;border:0px'>";
     		$text .= "
     		<tr>
     		<td>".LAN_MAILOUT_20.":&nbsp;&nbsp;</td>
     		<td>
     		<input class='tbox' type='text' name='sendmail' size='60' value=\"".(!$pref['sendmail'] ? "/usr/sbin/sendmail -t -i -r ".$pref['siteadminemail'] : $pref['sendmail'])."\" maxlength='80' />
     		</td>
     		</tr>
     	
     		</table></div>";
     	*/
     $text .= "</td>\n\t</tr>\n\n\n\t<tr>\n\t\t<td>" . LAN_MAILOUT_222 . "</td>\n\t\t<td>";
     $text .= $this->mailAdmin->sendStyleSelect(varset($pref['mail_sendstyle'], 'textonly'), 'mail_sendstyle');
     $text .= "<span class='field-help'>" . LAN_MAILOUT_223 . "</span>\n\t\t</td>\n\t</tr>\n\n\n\t\n\t<tr>\n\t\t<td>" . LAN_MAILOUT_25 . "</td>\n\t\t<td class='form-inline'> " . LAN_MAILOUT_26 . " " . $frm->number('mail_pause', $pref['mail_pause']) . " " . LAN_MAILOUT_27 . " " . $frm->number('mail_pausetime', $pref['mail_pausetime']) . " " . LAN_MAILOUT_29 . ".<br />\n\t\t<span class='field-help'>" . LAN_MAILOUT_30 . "</span>\n\t\t</td>\n\t</tr>\n\n\t\n\t<tr>\n\t\t<td>" . LAN_MAILOUT_156 . "</td>\n\t\t<td>" . $frm->number('mail_workpertick', varset($pref['mail_workpertick'], 5)) . "<span class='field-help'>" . LAN_MAILOUT_157 . "</span>\n\t\t</td>\n\t</tr>\n\t\n\t\n\t";
     list($mail_log_option, $mail_log_email) = explode(',', varset($pref['mail_log_options'], '0,0'));
     $check = $mail_log_email == 1 ? " checked='checked'" : "";
     $logOptions = array(LAN_MAILOUT_73, LAN_MAILOUT_74, LAN_MAILOUT_75, LAN_MAILOUT_119);
     $text .= "<tr>\n\t\t<td>" . LAN_MAILOUT_72 . "</td>\n\t\t<td class='form-inline'>\n\t\t" . $frm->select('mail_log_option', $logOptions, $mail_log_option);
     $text .= " " . $frm->checkbox('mail_log_email', 1, $check, 'label=' . LAN_MAILOUT_76);
     $text .= "</td></tr>\n";
     /*
     $text .= "
     	<select class='tbox' name='mail_log_option'>\n
     	<option value='0'".(($mail_log_option==0) ? " selected='selected'" : '').">".LAN_MAILOUT_73."</option>\n
     	<option value='1'".(($mail_log_option==1) ? " selected='selected'" : '').">".LAN_MAILOUT_74."</option>\n
     	<option value='2'".(($mail_log_option==2) ? " selected='selected'" : '').">".LAN_MAILOUT_75."</option>\n
     	<option value='3'".(($mail_log_option==3) ? " selected='selected'" : '').">".LAN_MAILOUT_119."</option>\n
     	</select>\n
     	<input type='checkbox' name='mail_log_email' value='1' {$check} />".LAN_MAILOUT_76.
     	"</td>
     </tr>\n";
     */
     if (function_exists('openssl_pkey_new') && deftrue('e_DEVELOPER')) {
         $text .= "<tr><td>DomainKeys Identified Mail (DKIM)</td><td class='form-inline'>" . $frm->button('DKIM_generate', 1, 'primary', 'Generate Public/Private keys') . "\n\t\t<span class='label label-warning'>Developer Mode Only</span></td></tr>";
     }
     $text .= "</table></fieldset>\n\t<fieldset id='core-mail-prefs-bounce'>\n\t\t<legend>" . LAN_MAILOUT_31 . "</legend>\n\t\t<table class='table adminform'>\n\t\t<colgroup>\n\t\t\t<col class='col-label' />\n\t\t\t<col class='col-control' />\n\t\t</colgroup>\n\t\t<tbody>\n\t<tr>\n\t\t<td>" . LAN_MAILOUT_231 . "</td><td>";
     // bounce divs = mail_bounce_none, mail_bounce_auto, mail_bounce_mail
     $autoDisp = $pref['mail_bounce'] != 'auto' ? "style='display:none;'" : '';
     $autoMail = $pref['mail_bounce'] != 'mail' ? "style='display:none;'" : '';
     $bounceOpts = array('none' => LAN_MAILOUT_232, 'auto' => LAN_MAILOUT_233, 'mail' => LAN_MAILOUT_234);
     $text .= "<select name='mail_bounce' class='tbox' onchange='bouncedisp(this.value)'>\n<option value=''>&nbsp;</option>\n";
     foreach ($bounceOpts as $k => $v) {
         $selected = $pref['mail_bounce'] == $k ? " selected='selected'" : '';
         $text .= "<option value='{$k}'{$selected}>{$v}</option>\n";
     }
     $text .= "</select>\n</td>\n\t</tr></tbody></table>\n\n\n\t\t<table class='adminform' id='mail_bounce_auto' {$autoDisp}>\n\t\t<colgroup>\n\t\t\t<col class='col-label' />\n\t\t\t<col class='col-control' />\n\t\t</colgroup>\n\t\t<tbody>\n\t\t<tr>\n\t\t\t<td>" . LAN_EMAIL . "</td>\n\t\t\t<td><div class='input-append'>" . $frm->text('mail_bounce_email2', $pref['mail_bounce_email'], 40, 'size=xlarge');
     if (!empty($pref['mail_bounce_email'])) {
         $text .= $frm->admin_button('send_bounce_test', 'Send Test', 'primary', 'Test');
     }
     $text .= "</div></td>\n\t\t</tr>\n\t\n\t<tr>\n\t\t<td>" . LAN_MAILOUT_233 . "</td><td><b>" . e_ROOT . e107::getFolder('handlers') . "bounce_handler.php</b>";
     $status = '';
     if (!is_readable(e_HANDLER . 'bounce_handler.php')) {
         $status = LAN_MAILOUT_161;
     } elseif (!is_executable(e_HANDLER . 'bounce_handler.php')) {
         $status = LAN_MAILOUT_162;
     } else {
         //	$text .= " ".ADMIN_TRUE_ICON;
     }
     if (!empty($status)) {
         $text .= "&nbsp;&nbsp;<span class='label label-warning'>" . $status . "</span>";
     }
     $text .= "<div>" . LAN_MAILOUT_235 . "</div>\n\t\n\t\n\t</td></tr>\n\t<tr><td>" . LAN_MAILOUT_236 . "</td><td>" . $lastBounceText . "</td></tr>";
     $text .= "\n\t</tbody></table>";
     // Parameters for mail-account based bounce processing
     $text .= "\n\t\t<table class='table adminform' id='mail_bounce_mail' {$autoMail}>\n\t\t<colgroup>\n\t\t\t<col class='col-label' />\n\t\t\t<col class='col-control' />\n\t\t</colgroup>\n\t\t<tbody>";
     $bouncePrefs = array('mail_bounce_email' => LAN_EMAIL, 'mail_bounce_pop3' => LAN_MAILOUT_33, 'mail_bounce_user' => LAN_MAILOUT_34, 'mail_bounce_pass' => LAN_PASSWORD);
     foreach ($bouncePrefs as $key => $label) {
         $text .= "<tr><td>" . $label . "</td><td>" . $frm->text($key, $pref[$key], 40, 'size=xlarge') . "</td></tr>";
     }
     /*	
     $text .= "
     	<tr><td>".LAN_MAILOUT_32."</td><td><input class='tbox' size='40' type='text' name='mail_bounce_email' value=\"".$pref['mail_bounce_email']."\" /></td></tr>
     	<tr><td>".LAN_MAILOUT_33."</td><td><input class='tbox' size='40' type='text' name='mail_bounce_pop3' value=\"".$pref['mail_bounce_pop3']."\" /></td></tr>
     	<tr><td>".LAN_MAILOUT_34."</td><td><input class='tbox' size='40' type='text' name='mail_bounce_user' value=\"".$pref['mail_bounce_user']."\" /></td></tr>
     	<tr><td>".LAN_PASSWORD."</td><td><input class='tbox' size='40' type='text' name='mail_bounce_pass' value=\"".$pref['mail_bounce_pass']."\" /></td></tr>
     ";
     */
     $text .= "\t\n\t\t<tr><td>" . LAN_MAILOUT_120 . "</td><td><select class='tbox' name='mail_bounce_type'>\n\n\t\t\t<option value=''>&nbsp;</option>\n\n\t\t\t<option value='pop3'" . ($pref['mail_bounce_type'] == 'pop3' ? " selected='selected'" : "") . ">" . LAN_MAILOUT_121 . "</option>\n\n\t\t\t<option value='pop3/notls'" . ($pref['mail_bounce_type'] == 'pop3/notls' ? " selected='selected'" : "") . ">" . LAN_MAILOUT_122 . "</option>\n\n\t\t\t<option value='pop3/tls'" . ($pref['mail_bounce_type'] == 'pop3/tls' ? " selected='selected'" : "") . ">" . LAN_MAILOUT_123 . "</option>\n\n\t\t\t<option value='imap'" . ($pref['mail_bounce_type'] == 'imap' ? " selected='selected'" : "") . ">" . LAN_MAILOUT_124 . "</option>\n\n\t\t</select></td></tr>\n\n\t\t";
     $check = $pref['mail_bounce_delete'] == 1 ? " checked='checked'" : "";
     $text .= "<tr><td>" . LAN_MAILOUT_36 . "</td><td><input type='checkbox' name='mail_bounce_delete' value='1' {$check} /></td></tr>";
     $check = $pref['mail_bounce_auto'] == 1 ? " checked='checked'" : "";
     $text .= "<tr><td>" . LAN_MAILOUT_245 . "</td><td><input type='checkbox' name='mail_bounce_auto' value='1' {$check} /><span class='field-help'>&nbsp;" . LAN_MAILOUT_246 . "</span></td></tr>\n\t\t\t\t";
     $text .= "\n\t</tbody>\n\t</table></fieldset>\n\n\t<div class='buttons-bar center'>" . $frm->admin_button('updateprefs', LAN_MAILOUT_28, 'update') . "</div>\n\n\t</form>";
     return $text;
     //	$caption = ADLAN_136.SEP.LAN_PREFS;
     //	$ns->tablerender($caption, $mes->render(). $text);
 }
Example #24
0
 function submit_item($news, $smessages = false)
 {
     $tp = e107::getParser();
     $sql = e107::getDb();
     $admin_log = e107::getAdminLog();
     $pref = e107::getPref();
     $e_event = e107::getEvent();
     $e107cache = e107::getCache();
     $emessage = e107::getMessage();
     $error = false;
     if (empty($news['news_title'])) {
         $error = true;
         $emessage->add('Validation error: News title can\'t be empty!', E_MESSAGE_ERROR, $smessages);
         if (!empty($news['news_sef'])) {
             $news['news_sef'] = eHelper::secureSef($news['news_sef']);
         }
     } else {
         // first format sef...
         if (empty($news['news_sef'])) {
             $news['news_sef'] = eHelper::title2sef($news['news_title']);
         } else {
             $news['news_sef'] = eHelper::secureSef($news['news_sef']);
         }
     }
     // ...then check it
     if (empty($news['news_sef'])) {
         $error = true;
         $emessage->add('Validation error: News SEF URL value is required field and can\'t be empty!', E_MESSAGE_ERROR, $smessages);
     } elseif ($sql->db_Count('news', '(news_id)', ($news['news_sef'] ? 'news_id<>' . intval($news['news_id']) . ' AND ' : '') . "news_sef='" . $tp->toDB($news['news_sef']) . "'")) {
         $error = true;
         $emessage->add('Validation error: News SEF URL is unique field - current value already in use! Please choose another SEF URL value.', E_MESSAGE_ERROR, $smessages);
     }
     if (empty($news['news_category'])) {
         $error = true;
         $emessage->add('Validation error: News category can\'t be empty!', E_MESSAGE_ERROR, $smessages);
     }
     $data = array();
     //DB Array
     $data['data']['news_title'] = $news['news_title'];
     $data['_FIELD_TYPES']['news_title'] = 'todb';
     $data['data']['news_sef'] = $news['news_sef'];
     $data['_FIELD_TYPES']['news_sef'] = 'todb';
     $data['data']['news_body'] = $news['news_body'];
     $data['_FIELD_TYPES']['news_body'] = 'todb';
     $data['data']['news_extended'] = $news['news_extended'];
     $data['_FIELD_TYPES']['news_extended'] = 'todb';
     $data['data']['news_datestamp'] = $news['news_datestamp'];
     $data['_FIELD_TYPES']['news_datestamp'] = 'int';
     $data['data']['news_author'] = $news['news_author'] ? $news['news_author'] : USERID;
     $data['_FIELD_TYPES']['news_author'] = 'int';
     $data['data']['news_category'] = $news['news_category'];
     $data['_FIELD_TYPES']['news_category'] = 'int';
     $data['data']['news_allow_comments'] = $news['news_allow_comments'];
     $data['_FIELD_TYPES']['news_allow_comments'] = 'int';
     $data['data']['news_start'] = $news['news_start'];
     $data['_FIELD_TYPES']['news_start'] = 'int';
     $data['data']['news_end'] = $news['news_end'];
     $data['_FIELD_TYPES']['news_end'] = 'int';
     $data['data']['news_class'] = $news['news_class'];
     $data['_FIELD_TYPES']['news_class'] = 'todb';
     $data['data']['news_render_type'] = $news['news_render_type'];
     $data['_FIELD_TYPES']['news_render_type'] = 'todb';
     //news_comment_total
     $data['data']['news_summary'] = $news['news_summary'];
     $data['_FIELD_TYPES']['news_summary'] = 'todb';
     $data['data']['news_thumbnail'] = $news['news_thumbnail'];
     $data['_FIELD_TYPES']['news_thumbnail'] = 'todb';
     $data['data']['news_sticky'] = $news['news_sticky'];
     $data['_FIELD_TYPES']['news_sticky'] = 'int';
     $data['data']['news_meta_keywords'] = eHelper::formatMetaKeys($news['news_meta_keywords']);
     $data['_FIELD_TYPES']['news_meta_keywords'] = 'todb';
     $data['data']['news_meta_description'] = eHelper::formatMetaDescription($news['news_meta_description']);
     //handle bbcodes
     $data['_FIELD_TYPES']['news_meta_description'] = 'todb';
     if ($error) {
         $data['error'] = true;
         return $data;
     }
     // Calculate short strings for admin logging - no need to clog up the log with potentially long items
     $logData = $data['data'];
     if (isset($logData['news_body'])) {
         $logData['news_body'] = $tp->text_truncate($tp->toDB($logData['news_body']), 300, '...');
     }
     if (isset($logData['news_extended'])) {
         $logData['news_extended'] = $tp->text_truncate($tp->toDB($logData['news_extended']), 300, '...');
     }
     //XXX - Now hooks are executed only if no mysql error is found. Should it stay so? Seems sensible to me!
     if ($news['news_id']) {
         // Updating existing item
         $data['WHERE'] = 'news_id=' . intval($news['news_id']);
         //$vals = "news_datestamp = '".intval($news['news_datestamp'])."', ".$author_insert." news_title='".$news['news_title']."', news_body='".$news['news_body']."', news_extended='".$news['news_extended']."', news_category='".intval($news['cat_id'])."', news_allow_comments='".intval($news['news_allow_comments'])."', news_start='".intval($news['news_start'])."', news_end='".intval($news['news_end'])."', news_class='".$tp->toDB($news['news_class'])."', news_render_type='".intval($news['news_rendertype'])."' , news_summary='".$news['news_summary']."', news_thumbnail='".$tp->toDB($news['news_thumbnail'])."', news_sticky='".intval($news['news_sticky'])."' WHERE news_id='".intval($news['news_id'])."' ";
         if ($sql->db_Update('news', $data)) {
             e107::getAdminLog()->logArrayAll('NEWS_09', $logData);
             $data['data']['news_id'] = $news['news_id'];
             e107::getEvent()->trigger('newsupd', $data['data']);
             e107::getEvent()->trigger('admin_news_updated', $data['data']);
             $message = LAN_UPDATED;
             $emessage->add(LAN_UPDATED, E_MESSAGE_SUCCESS, $smessages);
             e107::getCache()->clear('news.php');
             //FIXME - triggerHook should return array(message, message_type)
             $evdata = array('method' => 'update', 'table' => 'news', 'id' => $news['news_id'], 'plugin' => 'news', 'function' => 'submit_item');
             $emessage->add(e107::getEvent()->triggerHook($evdata), E_MESSAGE_INFO, $smessages);
         } else {
             if ($sql->getLastErrorNumber()) {
                 $error = true;
                 $emessage->add(LAN_NEWS_5, E_MESSAGE_ERROR, $smessages);
                 $message = "<strong>" . LAN_NEWS_5 . "</strong>";
             } else {
                 $data['data']['news_id'] = $news['news_id'];
                 $emessage->add(LAN_NO_CHANGE, E_MESSAGE_INFO, $smessages);
                 $message = "<strong>" . LAN_NO_CHANGE . "</strong>";
                 //FIXME - triggerHook should return array(message, message_type)
                 $evdata = array('method' => 'update', 'table' => 'news', 'id' => $news['news_id'], 'plugin' => 'news', 'function' => 'submit_item');
                 $emessage->add(e107::getEvent()->triggerHook($evdata), E_MESSAGE_INFO, $smessages);
             }
         }
     } else {
         // Adding item
         $data['data']['news_id'] = $sql->db_Insert('news', $data);
         $news['news_id'] = $data['data']['news_id'];
         //$news['news_id'] = $sql ->db_Insert('news', "0, '".$news['news_title']."', '".$news['news_body']."', '".$news['news_extended']."', ".intval($news['news_datestamp']).", ".intval($news['news_author']).", '".intval($news['cat_id'])."', '".intval($news['news_allow_comments'])."', '".intval($news['news_start'])."', '".intval($news['news_end'])."', '".$tp->toDB($news['news_class'])."', '".intval($news['news_rendertype'])."', '0' , '".$news['news_summary']."', '".$tp->toDB($news['news_thumbnail'])."', '".intval($news['news_sticky'])."' ")
         if ($data['data']['news_id']) {
             $data['news_id'] = $news['news_id'];
             $message = LAN_NEWS_6;
             $emessage->add(LAN_CREATED, E_MESSAGE_SUCCESS, $smessages);
             e107::getCache()->clear('news.php');
             //moved down - prevent wrong mysql_insert_id
             e107::getAdminLog()->logArrayAll('NEWS_08', $logData);
             e107::getEvent()->trigger('newspost', $data['data']);
             e107::getEvent()->trigger('admin_news_created', $data['data']);
             //XXX - triggerHook after trigger?
             $evdata = array('method' => 'create', 'table' => 'news', 'id' => $data['data']['news_id'], 'plugin' => 'news', 'function' => 'submit_item');
             $emessage->add($e_event->triggerHook($evdata), E_MESSAGE_INFO, $smessages);
         } else {
             $error = true;
             $message = "<strong>" . LAN_NEWS_7 . "</strong>";
             $emessage->add(LAN_UPDATED, E_MESSAGE_ERROR, $smessages);
         }
     }
     //return $message;
     $data['message'] = $message;
     $data['error'] = $error;
     return $data;
 }
Example #25
0
 function init()
 {
     if (E107_DEBUG_LEVEL > 0) {
         $this->fields['media_url']['inline'] = true;
     }
     $sql = e107::getDb();
     //	$sql->db_Select_gen("SELECT media_cat_title, media_title_nick FROM #core_media as m LEFT JOIN #core_media_cat as c ON m.media_category = c.media_cat_owner GROUP BY m.media_category");
     $sql->gen("SELECT media_cat_title, media_cat_owner, media_cat_category FROM `#core_media_cat`");
     while ($row = $sql->fetch()) {
         $cat = $row['media_cat_category'];
         $owner = $row['media_cat_owner'];
         $this->owner[$owner] = $owner;
         $this->ownercats[$owner . '|' . $cat] = $row['media_cat_title'];
         $this->cats[$cat] = $row['media_cat_title'];
     }
     asort($this->cats);
     $tmp = $sql->retrieve('core_media', 'media_type', 'media_type !="" GROUP BY media_type', true);
     $mimeTypes = array();
     foreach ($tmp as $val) {
         $id = $val['media_type'];
         $mimeTypes[$id] = $id;
     }
     asort($mimeTypes);
     $this->fields['media_category']['writeParms'] = $this->cats;
     $this->fields['media_type']['writeParms'] = $mimeTypes;
     $pref = e107::getPref();
     $tp = e107::getParser();
     $fl = e107::getFile();
     $path = e_THEME . $pref['sitetheme'] . "/fonts/";
     $fDir = $fl->get_files(e_THEME . $pref['sitetheme'] . "/fonts/", ".ttf", '', 2);
     $fonts = array(0 => 'None');
     foreach ($fDir as $f) {
         $id = $tp->createConstants($f['path'] . $f['fname'], 'rel');
         $fonts[$id] = $f['fname'];
     }
     $this->prefs['watermark_font']['writeParms'] = $fonts;
     $this->prefs['watermark_font']['readParms'] = $fonts;
     $wm_pos = array('BR' => "Bottom Right", 'BL' => "Bottom Left", 'TR' => "Top Right", 'TL' => "Top Left", 'C' => "Center", 'R' => "Right", 'L' => "Left", 'T' => "Top", 'B' => "Bottom", '*' => "Tile");
     $this->prefs['watermark_pos']['writeParms'] = $wm_pos;
     $this->prefs['watermark_pos']['readParms'] = $wm_pos;
     e107::getCache()->clearAll('image');
     //	print_a($_GET);
     if ($this->getAction() == 'youtube') {
         $parm = array('search' => $_GET['search']);
         echo $this->videoTab($parm);
         exit;
     }
     if ($this->getAction() == 'glyph') {
         $parm = array('search' => $_GET['search']);
         echo $this->glyphTab($parm);
         exit;
     }
     if ($this->getAction() == 'nav') {
         //echo $this->navPage();\
         //	$this->getResponse()->setIframeMod(); // disable header/footer menus etc.
         //	print_a($_GET);
     }
     if (varset($_POST['batch_import_selected'])) {
         $this->batchImport();
     }
     if (varset($_POST['batch_import_delete'])) {
         $this->batchDelete();
     }
     if (varset($_POST['update_options'])) {
         $this->updateSettings();
     }
     // filepicker stuff.
     if ($this->getQuery('mode') == 'dialog') {
         if (!ADMIN) {
             exit;
         }
     }
     if ($this->getQuery('iframe')) {
         e107::js('tinymce4', 'plugins/compat3x/tiny_mce_popup.js');
         $this->getResponse()->setIframeMod();
         // disable header/footer menus etc.
         if (!$this->getQuery('for')) {
             $this->setPosted('media_category', "_common");
             $this->getModel()->set('media_category', "_common");
         } elseif ($this->getMediaCategory($this->getQuery('for'))) {
             $this->setPosted('media_category', $this->getQuery('for'));
             if (!$this->getId()) {
                 $this->getModel()->set('media_category', $this->getQuery('for'));
             }
         }
     }
 }
Example #26
0
 function lastRefresh()
 {
     $pref = e107::getPref();
     $mes = e107::getMessage();
     $frm = e107::getForm();
     e107::getCache()->CachePageMD5 = '_';
     $lastload = e107::getCache()->retrieve('cronLastLoad', false, true, true);
     $ago = time() - $lastload;
     $active = $ago < 1200 ? true : false;
     // longer than 20 minutes, so lets assume it's inactive.
     $status = $active ? LAN_ENABLED : LAN_DISABLED;
     // "Enabled" : "Offline";
     $mins = floor($ago / 60);
     $secs = $ago % 60;
     $srch = array("[x]", "[y]");
     $repl = array($mins, $secs);
     $lastRun = $mins ? str_replace($srch, $repl, LAN_CRON_9) : str_replace($srch, $repl, LAN_CRON_10);
     // FIX: check syntax
     $lastRefresh = $ago < 10000 ? $lastRun : LAN_NEVER;
     $mes->addInfo(LAN_STATUS . ": <b>" . $status . "</b>");
     $mes->addInfo(LAN_CRON_11 . ": <b>" . $this->activeCrons . "</b>");
     $mes->addInfo(LAN_CRON_12 . ": " . $lastRefresh . "<br /><br />");
     // extensions of exe, com, bat and cmd.
     $isWin = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
     $actualPerm = substr(decoct(fileperms(e_BASE . "cron.php")), 3);
     if ($isWin) {
         $mes->addWarning(LAN_CRON_13);
     }
     if (!$isWin && $actualPerm != 755) {
         $mes->addWarning(LAN_CRON_14);
     } elseif (!$active) {
         $setpwd_message = $frm->open("generate") . "<small>" . LAN_CRON_15 . ":</small><br /><pre style='color:black'>" . e_ROOT . "cron.php token=" . $pref['e_cron_pwd'] . ' >/dev/null 2>&1';
         $setpwd_message .= "</pre><small>" . LAN_CRON_16 . "</small>";
         if (e_DOMAIN && file_exists("/usr/local/cpanel/version")) {
             $setpwd_message .= "<div style='margin-top:10px'><a rel='external' class='btn btn-primary' href='" . e_HTTP . "cpanel'>Go to cPanel</a></div>";
         }
         $setpwd_message .= "<br /><br />" . $frm->admin_button('generate_pwd', 1, 'delete', 'Generate new cron password', array('class' => 'btn btn-small'));
         $setpwd_message .= $frm->close();
         $mes->add($setpwd_message, E_MESSAGE_INFO);
     }
 }
Example #27
0
File: page.php Project: armpit/e107
 function pageComment($page_comment_flag)
 {
     if ($page_comment_flag) {
         $cobj = e107::getComment();
         if (isset($_POST['commentsubmit'])) {
             $cobj->enter_comment($_POST['author_name'], $_POST['comment'], "page", $this->pageID, $pid, $_POST['subject']);
             $e107cache = e107::getCache();
             $e107cache->clear("comment.page." . $this->pageID);
             $e107cache->clear($this->cacheString);
         }
         return $cobj->compose_comment("page", "comment", $this->pageID, 0, $this->title, false, true);
     }
 }
Example #28
0
 /**
  * Add a comment to an item
  * e-token POST value should be always valid when using this method.
  *
  * @param string|array $data - $author_name or array of all values.
  * @param unknown_type $comment
  * @param unknown_type $table
  * @param integer $id - reference of item in source table to which comment is linked
  * @param unknown_type $pid - parent comment id when it's a reply to a specific comment. t
  * @param unknown_type $subject
  * @param unknown_type $rateindex
  */
 function enter_comment($data, $comment = '', $table = '', $id = '', $pid = '', $subject = '', $rateindex = FALSE)
 {
     //rateindex	: the posted value from the rateselect box (without the urljump) (see function rateselect())
     if ($this->engine != 'e107') {
         return;
     }
     if (is_array($data)) {
         $table = $data['comment_type'];
         $id = intval($data['comment_item_id']);
         $pid = intval($data['comment_pid']);
         $subject = $data['comment_subject'];
         $comment = $data['comment_comment'];
         $author_name = $data['comment_author_name'];
         $comment_share = intval($data['comment_share']);
         $comment_datestamp = $data['comment_datestamp'];
     } else {
         $author_name = $data;
         //BC Fix.
     }
     global $e107, $rater;
     $sql = e107::getDb();
     $sql2 = e107::getDb('sql2');
     $tp = e107::getParser();
     $pref = e107::getPref();
     if ($this->getCommentPermissions() != 'rw') {
         return;
     }
     if ($user_func = e107::getOverride()->check($this, 'enter_comment')) {
         return call_user_func($user_func, array('data' => $data, 'comment' => $comment, 'table' => $table, 'id' => $id, 'pid' => $pid, 'subject' => $subject, 'rateindex' => $rateindex));
     }
     if (!isset($_POST['e-token'])) {
         $_POST['e-token'] = '';
     }
     // check posted token
     if (!e107::getSession()->check(false)) {
         return false;
     }
     // This will return false on error
     if (isset($_GET['comment']) && $_GET['comment'] == 'edit') {
         $eaction = 'edit';
         $editpid = $_GET['comment_id'];
     } elseif (strstr(e_QUERY, "edit")) {
         $eaction = "edit";
         $tmp = explode(".", e_QUERY);
         $count = 0;
         foreach ($tmp as $t) {
             if ($t == "edit") {
                 $editpid = $tmp[$count + 1];
                 break;
             }
             $count++;
         }
     }
     $type = $this->getCommentType($table);
     $comment = $tp->toDB($comment);
     $subject = $tp->toDB($subject);
     $cuser_id = 0;
     $cuser_name = 'Anonymous';
     // Preset as an anonymous comment
     if (!$sql->select("comments", "*", "comment_comment='" . $comment . "' AND comment_item_id='" . intval($id) . "' AND comment_type='" . $tp->toDB($type, true) . "' ")) {
         if ($_POST['comment']) {
             if (USER == TRUE) {
                 $cuser_id = USERID;
                 $cuser_name = USERNAME;
                 $cuser_mail = USEREMAIL;
             } elseif ($_POST['author_name'] != '') {
                 if ($sql2->select("user", "*", "user_name='" . $tp->toDB($_POST['author_name']) . "' ")) {
                     if ($sql2->select("user", "*", "user_name='" . $tp->toDB($_POST['author_name']) . "' AND user_ip='" . $tp->toDB($ip, true) . "' ")) {
                         //list($cuser_id, $cuser_name) = $sql2->db_Fetch();
                         $tmp = $sql2->fetch();
                         $cuser_id = $tmp['user_id'];
                         $cuser_name = $tmp['user_name'];
                         $cuser_mail = $tmp['user_email'];
                     } else {
                         define("emessage", COMLAN_310);
                     }
                 } else {
                     $cuser_name = $tp->toDB($author_name);
                 }
             }
             if (!defined("emessage")) {
                 $ip = $e107->getip();
                 // Store IP 'in the raw' - could be IPv4 or IPv6. Its always returned in a normalised form
                 $_t = time();
                 if ($editpid) {
                     $comment .= "\n[ " . COMLAN_319 . " [time=short]" . time() . "[/time] ]";
                     $sql->update("comments", "comment_comment='{$comment}' WHERE comment_id='" . intval($editpid) . "' ");
                     e107::getCache()->clear("comment");
                     return;
                 }
                 //FIXME - don't sanitize, pass raw data to e_event, use DB array (inner db sanitize)
                 $edata_li = array('comment_pid' => intval($pid), 'comment_item_id' => $id, 'comment_subject' => $subject, 'comment_author_id' => $cuser_id, 'comment_author_name' => $cuser_name, 'comment_author_email' => $tp->toDB($cuser_mail), 'comment_datestamp' => $_t, 'comment_comment' => $comment, 'comment_blocked' => $this->moderateComment($pref['comments_moderate']) ? 2 : 0, 'comment_ip' => $ip, 'comment_type' => $tp->toDB($type, true), 'comment_lock' => 0, 'comment_share' => $comment_share);
                 //SecretR: new event 'prepostcomment' - allow plugin hooks - e.g. Spam Check
                 $edata_li_hook = array_merge($edata_li, array('comment_nick' => $cuser_id . '.' . $cuser_name, 'comment_time' => $_t));
                 if (e107::getEvent()->trigger("prepostcomment", $edata_li_hook)) {
                     return false;
                     //3rd party code interception
                 }
                 //allow 3rd party code to modify insert data
                 if (is_array($edata_li_hook)) {
                     foreach (array_keys($edata_li) as $k) {
                         if (isset($edata_li_hook[$k])) {
                             $edata_li[$k] = $edata_li_hook[$k];
                             //sanitize?
                             continue;
                         }
                         if ($k === 'break') {
                             $break = $edata_li_hook[$k];
                         }
                     }
                 }
                 unset($edata_li_hook);
                 if (!($inserted_id = $sql->insert("comments", $edata_li))) {
                     //echo "<b>".COMLAN_323."</b> ".COMLAN_11;
                     if (e_AJAX_REQUEST) {
                         return "Error";
                     }
                     e107::getMessage()->addStack(COMLAN_11, 'postcomment', E_MESSAGE_ERROR);
                 } else {
                     if (USER == true) {
                         $sql->update("user", "user_comments=user_comments+1, user_lastpost='" . time() . "' WHERE user_id='" . USERID . "' ");
                     }
                     // Next item for backward compatibility
                     $edata_li["comment_nick"] = $cuser_id . '.' . $cuser_name;
                     $edata_li["comment_time"] = $_t;
                     $edata_li["comment_id"] = $inserted_id;
                     //Why?
                     /*unset($edata_li['comment_pid']);
                     		unset($edata_li['comment_author_email']);
                     		unset($edata_li['comment_ip']);*/
                     e107::getEvent()->trigger("postcomment", $edata_li);
                     e107::getCache()->clear("comment");
                     if ((empty($type) || $type == "news") && !$this->moderateComment($pref['comments_moderate'])) {
                         $sql->update("news", "news_comment_total=news_comment_total+1 WHERE news_id=" . intval($id));
                     }
                     //if rateindex is posted, enter the rating from this user
                     //	if ($rateindex)
                     //	{
                     //		$rater->enterrating($rateindex);
                     //	}
                     return $inserted_id;
                     // return the ID number so it can be used. true;
                 }
             }
         }
     } else {
         define("emessage", COMLAN_312);
     }
     if (defined("emessage")) {
         if (e_AJAX_REQUEST) {
             return emessage;
         }
         message_handler("ALERT", emessage);
     }
     return false;
 }
Example #29
0
e107::getAdminUI()->runPage();
require_once e_ADMIN . "footer.php";
exit;
/// ------------------------------- Legacy Code -------------------------------
require_once e_ADMIN . "auth.php";
$imagedir = e_IMAGE . "admin_images/";
require_once e_PLUGIN . 'rss_menu/rss_shortcodes.php';
$rss = new rss();
global $tp;
$mes = e107::getMessage();
// Delete entry
if (isset($_POST['delete'])) {
    $d_idt = array_keys($_POST['delete']);
    $message = $sql->db_Delete("rss", "rss_id=" . intval($d_idt[0])) ? LAN_DELETED : LAN_DELETED_FAILED;
    e107::getLog()->add('RSS_01', 'ID: ' . intval($d_idt[0]) . ' - ' . $message, E_LOG_INFORMATIVE, '');
    e107::getCache()->clear("rss");
}
// Create rss feed
if (isset($_POST['create_rss'])) {
    $message = $rss->dbrss("create");
}
// Update rss feed
if (isset($_POST['update_rss'])) {
    $message = $rss->dbrss("update");
}
// Import rss feed
if (isset($_POST['import_rss'])) {
    $message = $rss->dbrssimport();
}
// Update_limit
if (isset($_POST['update_limit'])) {
Example #30
0
            e107::getAdminLog()->flushMessages(CACLAN_25);
            break;
            // used in standard page output and internal JS includes
        // used in standard page output and internal JS includes
        case 'empty_browsercache':
            e107::getCache()->clearAll('browser');
            e107::getAdminLog()->flushMessages(CACLAN_25);
            break;
            // all
        // all
        default:
            e107::getCache()->clearAll('content');
            e107::getCache()->clearAll('system');
            e107::getCache()->clearAll('db');
            e107::getCache()->clearAll('image');
            e107::getCache()->clearAll('browser');
            e107::getAdminLog()->flushMessages(CACLAN_26);
            break;
    }
}
$syscache_files = glob(e_CACHE_CONTENT . 'S_*.*');
$cache_files = glob(e_CACHE_CONTENT . 'C_*.*');
$imgcache_files = glob(e_CACHE_IMAGE . '*.cache.bin');
$dbcache_files = glob(e_CACHE_DB . '*.php');
$syscache_files_num = count($syscache_files);
$cache_files_num = count($cache_files);
$imgcache_files_num = count($imgcache_files);
$dbcache_files_num = count($dbcache_files);
$syscache_label = $syscache_files_num . ' ' . ($syscache_files_num != 1 ? CACLAN_19 : CACLAN_18);
$contentcache_label = $cache_files_num . ' ' . ($cache_files_num != 1 ? CACLAN_19 : CACLAN_18);
$imgcache_label = $imgcache_files_num . ' ' . ($imgcache_files_num != 1 ? CACLAN_19 : CACLAN_18);