Example #1
0
 function forum_post_rep($data)
 {
     $e107 = e107::getInstance();
     include_lan(e_PLUGIN . 'forum/languages/' . e_LANGUAGE . '/lan_forum_notify.php');
     $message = 'todo';
     $e107->notify->send('forum_post_rep', FORUM_NT_9, $message);
 }
Example #2
0
 /**
  * constructor
  *
  * @param string $mode the mode of the caller (default, admin)
  * @return void
  *
  */
 function listclass($mode = '')
 {
     global $TEMPLATE_LIST_NEW, $list_shortcodes;
     $this->plugin_dir = e_PLUGIN . "list_new/";
     $this->e107 = e107::getInstance();
     //language
     include_lan($this->plugin_dir . "languages/" . e_LANGUAGE . ".php");
     //template
     if (is_readable(THEME . "list_template.php")) {
         require_once THEME . "list_template.php";
     } else {
         require_once $this->plugin_dir . "list_template.php";
     }
     $this->template = $TEMPLATE_LIST_NEW;
     //shortcodes
     require_once $this->plugin_dir . "list_shortcodes.php";
     //		$this->shortcodes = $list_shortcodes;
     $this->shortcodes = new list_shortcodes();
     $this->shortcodes->rc = $this;
     if ($mode == 'admin') {
         require_once $this->plugin_dir . "list_admin_class.php";
         $this->admin = new list_admin($this);
     }
     //default sections (present in this list plugin)
     $this->defaultArray = array("news", "comment", "members");
 }
Example #3
0
 public function __construct()
 {
     $tp = e107::getParser();
     $ns = e107::getRender();
     $mes = e107::getMessage();
     $this->e107 = e107::getInstance();
     // TODO remove?
     foreach ($_POST as $key => $value) {
         $key = $tp->toDB($key);
         if (strpos($key, 'nlmailnow') === 0) {
             $this->releaseIssue($key);
             break;
         }
     }
     if (isset($_POST['delete'])) {
         $this->deleteNewsletter();
     }
     if (isset($_POST['createNewsletter'])) {
         $this->createNewsletter();
     }
     if (isset($_POST['createIssue'])) {
         $this->createIssue();
     }
     if ($mes) {
         $ns->tablerender($caption, $mes->render() . $text);
     }
 }
Example #4
0
 public function __construct($override = FALSE)
 {
     global $pref;
     $this->e107 = e107::getInstance();
     if ($override === FALSE || !is_array($override)) {
         // Set up from prefs
         $override['mail_bounce_user'] = $pref['mail_bounce_user'];
         $override['mail_bounce_pass'] = $pref['mail_bounce_pass'];
         $override['mail_bounce_email'] = $pref['mail_bounce_email'];
         $override['mail_bounce_pop3'] = $pref['mail_bounce_pop3'];
         $override['mail_bounce_type'] = varset($pref['mail_bounce_type'], 'pop3');
     }
     if ($override['mail_bounce_type'] == 'imap') {
         $port = varset($override['mail_bounce_port'], '143');
         $strConnect = '{' . $override['mail_bounce_pop3'] . ':' . $port . '}INBOX';
     } else {
         $port = varset($override['mail_bounce_port'], '110');
         // POP3 port
         $servertype = '/' . varset($override['mail_bounce_type'], 'pop3');
         $strConnect = '{' . $override['mail_bounce_pop3'] . ':' . $port . $servertype . '}INBOX';
     }
     $this->server = $strConnect;
     $this->username = $override['mail_bounce_user'];
     $this->password = $override['mail_bounce_pass'];
     $this->email = $override['mail_bounce_email'];
     $this->delBounce = $pref['mail_bounce_delete'] ? true : false;
 }
Example #5
0
 /**
  * Constructor - init paths
  * @todo FIX e107 (new folder structure), simplify all this, e.g. e107::getInstance()->initMinimal($path_to_e107_config);
  *
  * @return void
  */
 public function __construct()
 {
     // initial path
     $self = realpath(dirname(__FILE__));
     // Config
     include $self . '/e107_config.php';
     $tmp = $self . '/' . $HANDLERS_DIRECTORY;
     //Core functions - now API independent
     @(require $tmp . '/core_functions.php');
     //e107 class
     @(require $tmp . '/e107_class.php');
     $e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'DOWNLOADS_DIRECTORY', 'UPLOADS_DIRECTORY', 'MEDIA_DIRECTORY', 'CACHE_DIRECTORY', 'LOGS_DIRECTORY', 'WEB_DIRECTORY', 'SYSTEM_DIRECTORY', 'CORE_DIRECTORY');
     //	$sql_info = array(); //compact('mySQLserver', 'mySQLuser', 'mySQLpassword', 'mySQLdefaultdb', 'mySQLprefix', 'mySQLcharset');
     //e107::getInstance()->initCore($e107_paths, $self, $sql_info, varset($e107_CONFIG, array()));
     $e107 = e107::getInstance();
     $e107->site_path = substr(md5($mySQLdefaultdb . "." . $mySQLprefix), 0, 10);
     $e107->prepare_request();
     $e107->setDirs($e107_paths, varset($E107_CONFIG, array()));
     $e107->set_constants();
     $e107->set_paths();
     $e107->file_path = $e107->fix_windows_paths($self) . "/";
     $e107->set_base_path();
     $e107->set_request(false);
     $e107->set_urls(false);
     unset($tmp, $self);
     // basic Admin area detection - required for proper path parsing
     define('ADMIN', strpos(e_SELF, $e107->getFolder('admin') !== false || strpos(e_PAGE, 'admin') !== false));
     $e107->set_urls(false);
     $pref = $e107->getPref();
     //TODO optimize/benchmark
     $this->_watermark = array('activate' => vartrue($pref['watermark_activate'], false), 'text' => vartrue($pref['watermark_text']), 'size' => vartrue($pref['watermark_size'], 20), 'pos' => vartrue($pref['watermark_pos'], "BR"), 'color' => vartrue($pref['watermark_color'], 'fff'), 'font' => vartrue($pref['watermark_font']), 'margin' => vartrue($pref['watermark_margin'], 30), 'shadowcolor' => vartrue($pref['watermark_shadowcolor'], '000000'), 'opacity' => vartrue($pref['watermark_opacity'], 20));
     $this->_thumbQuality = vartrue($pref['thumbnail_quality'], 65);
     // parse request
     $this->parseRequest();
 }
Example #6
0
function forum_thread_moderate($p)
{
    $e107 = e107::getInstance();
    $sql = e107::getDb();
    foreach ($p as $key => $val) {
        if (preg_match("#(.*?)_(\\d+)_x#", $key, $matches)) {
            $act = $matches[1];
            $id = (int) $matches[2];
            switch ($act) {
                case 'lock':
                    $sql->update('forum_thread', 'thread_active=0 WHERE thread_id=' . $id);
                    return LAN_FORUM_CLOSE;
                    break;
                case 'unlock':
                    $sql->update('forum_thread', 'thread_active=1 WHERE thread_id=' . $id);
                    return LAN_FORUM_OPEN;
                    break;
                case 'stick':
                    $sql->update('forum_thread', 'thread_sticky=1 WHERE thread_id=' . $id);
                    return LAN_FORUM_STICK;
                    break;
                case 'unstick':
                    $sql->update('forum_thread', 'thread_sticky=0 WHERE thread_id=' . $id);
                    return LAN_FORUM_UNSTICK;
                    break;
                case 'deleteThread':
                    return forumDeleteThread($id);
                    break;
                case 'deletePost':
                    return forumDeletePost($id);
                    break;
            }
        }
    }
}
Example #7
0
 function e_tagwords_download()
 {
     $this->e107 = e107::getInstance();
     $this->settings = array();
     $this->settings['plugin'] = "";
     $this->settings['table'] = "download";
     $this->settings['db_id'] = "download_id";
     $this->settings['caption'] = "download";
 }
Example #8
0
 function e_tagwords_news()
 {
     $this->e107 = e107::getInstance();
     $this->settings = array();
     $this->settings['plugin'] = "";
     $this->settings['table'] = "news";
     $this->settings['db_id'] = "news_id";
     $this->settings['caption'] = "LAN_TAG_CORE_NEWS_1";
 }
Example #9
0
 function e_tagwords_page()
 {
     $this->e107 = e107::getInstance();
     $this->settings = array();
     $this->settings['plugin'] = "";
     $this->settings['table'] = "page";
     $this->settings['db_id'] = "page_id";
     $this->settings['caption'] = "LAN_TAG_CORE_CPAGES_1";
 }
Example #10
0
 function __construct($eVars = null)
 {
     parent::__construct($eVars);
     $this->e107 = e107::getInstance();
     $pref = e107::getPref();
     $this->commentsDisabled = vartrue($pref['comments_disabled']);
     if (!empty($pref['comments_engine'])) {
         $this->commentsEngine = $pref['comments_engine'];
     }
 }
Example #11
0
 function procBanRetrigger()
 {
     //global $pref;
     if (CRON_RETRIGGER_DEBUG) {
         $e107 = e107::getInstance();
         $e107->admin_log->e_log_event(10, debug_backtrace(), 'DEBUG', 'CRON Ban retrigger', 'Retrigger processing started', FALSE, LOG_TO_ROLLING);
     }
     require_once e_HANDLER . 'iphandler_class.php';
     $ipManager = new banlistManager();
     $ipManager->banRetriggerAction();
     if (CRON_RETRIGGER_DEBUG) {
         $e107->admin_log->e_log_event(10, debug_backtrace(), 'DEBUG', 'CRON Ban Retrigger', 'Retrigger processing completed', FALSE, LOG_TO_ROLLING);
     }
 }
Example #12
0
 /**
  * Process Posted Data.
  * @param $ui admin-ui object
  */
 public function process($ui)
 {
     $data = $ui->getPosted();
     e107::getMessage()->addDebug(print_a($data, true));
     if ($data['news_id'] && $this->active) {
         $excerpt = e107::getParser()->text_truncate(strip_tags(e107::getParser()->post_toHTML($data['news_body'])), 100, '...');
         //			$id=mysql_insert_id();
         $permLink = e107::getInstance()->base_path . "comment.php?comment.news." . intval($data['news_id']);
         require_once e_PLUGIN . "trackback/trackbackClass.php";
         $trackback = new trackbackClass();
         if ($data['x_trackback_urls']) {
             $urlArray = explode("\n", $data['x_trackback_urls']);
             foreach ($urlArray as $pingurl) {
                 if (!($terror = $trackback->sendTrackback($permLink, $pingurl, $data['news_title'], $excerpt))) {
                     e107::getMessage()->add("Successfully pinged {$pingurl}.", E_MESSAGE_SUCCESS);
                 } else {
                     e107::getMessage()->add("was unable to ping {$pingurl}<br />[ Error message returned was : '{$terror}'. ]", E_MESSAGE_ERROR);
                 }
             }
         }
         /*
         	if(isset($_POST['pingback_urls']))
         	{
         		if ($urlArray = $trackback->getPingUrls($data['news_body'])) //FIXME - missing method!!!
         		{
         			foreach($urlArray as $pingurl)
         			{
         
         				if ($trackback->sendTrackback($permLink, $pingurl, $data['news_title'], $excerpt))
         				{
         
         					e107::getMessage()->add("Successfully pinged {$pingurl}.", E_MESSAGE_SUCCESS);
         				}
         				else
         				{
         
         					e107::getMessage()->add("Pingback to {$pingurl} failed ...", E_MESSAGE_ERROR);
         				}
         			}
         		}
         		else
         		{
         
         			e107::getMessage()->add("No pingback addresses were discovered", E_MESSAGE_INFO, $smessages);
         		}
         	}
         */
     }
     /* end trackback */
 }
Example #13
0
function theme_adminmenu()
{
    global $mode;
    $mode = e_QUERY;
    $e107 =& e107::getInstance();
    $var['main']['text'] = TPVLAN_33;
    $var['main']['link'] = e_SELF;
    $var['admin']['text'] = TPVLAN_34;
    $var['admin']['link'] = e_SELF . "?admin";
    $var['choose']['text'] = TPVLAN_51;
    $var['choose']['link'] = e_SELF . "?choose";
    $var['upload']['text'] = TPVLAN_38;
    $var['upload']['link'] = e_SELF . "?upload";
    $selected = e_QUERY ? e_QUERY : "main";
    e_admin_menu(TPVLAN_26, $selected, $var);
}
Example #14
0
File: url.php Project: armpit/e107
 /**
  * Describe all pm routes. 
  * Routes vs legacy queries:
  * list/ 			-> {no query} 
  * list/category	-> download.php?action=list&id={category-id}
  * view/item 		-> download.php?action=view&id={download-id}
  * request/item 	-> request.php?{download-id}
  */
 public function create($route, $params = array(), $options = array())
 {
     if (is_string($route)) {
         $route = explode('/', $route, 2);
     }
     if (!varset($route[0]) || 'index' == $route[0]) {
         $route[0] = 'list';
     }
     $base = e107::getInstance()->getFolder('plugins') . 'download/';
     //	var_dump($options, $route, $params);
     //	print_a($route);
     if ($route[0] == 'list') {
         if (!isset($params['id']) && isset($params['download_category_id'])) {
             $params['id'] = $params['download_category_id'];
         }
         switch ($route[1]) {
             case 'index':
                 $this->legacyQueryString = '';
                 return $base . 'download.php';
                 break;
             case 'category':
                 $url = 'action=list&id=' . $params['id'];
                 if (isset($params['from'])) {
                     $url .= "&from=" . $params['from'] . "&view=" . $params['view'] . "&order=" . $params['order'] . "&sort=" . $params['sort'];
                 }
                 $this->legacyQueryString = $url;
                 return $base . 'download.php?' . $url;
                 break;
         }
     } elseif ($route[0] == 'view') {
         if (!isset($params['id']) && isset($params['download_id'])) {
             $params['id'] = $params['download_id'];
         }
         switch ($route[1]) {
             case 'item':
                 $this->legacyQueryString = 'action=view&id=' . $params['id'];
                 return $base . 'download.php?action=view&id=' . $params['id'];
                 break;
         }
     } elseif ($route[0] == 'request') {
         $this->legacyQueryString = $params['id'];
         return $base . 'request.php?' . $params['id'];
     }
     return false;
 }
Example #15
0
 function sc_banner($parm = '')
 {
     $e107 = e107::getInstance();
     $sql = e107::getDb();
     $tp = e107::getParser();
     $ret = '';
     $text = '';
     mt_srand((double) microtime() * 1000000);
     $seed = mt_rand(1, 2000000000);
     $time = time();
     $query = " (banner_startdate=0 OR banner_startdate <= {$time}) AND (banner_enddate=0 OR banner_enddate > {$time}) AND (banner_impurchased=0 OR banner_impressions<=banner_impurchased)" . ($parm ? " AND banner_campaign='" . $tp->toDB($parm) . "'" : '') . "\n\t\tAND banner_active IN (" . USERCLASS_LIST . ")\n\t\tORDER BY RAND({$seed}) LIMIT 1";
     if ($sql->select('banner', 'banner_id, banner_image, banner_clickurl, banner_description', $query)) {
         $row = $sql->fetch();
         return $this->renderBanner($row);
     } else {
         return '&nbsp;';
     }
 }
Example #16
0
 public function init()
 {
     if (e_AJAX_REQUEST) {
         $tp = e107::getParser();
         if (!empty($_POST['pk']) && !empty($_POST['value'])) {
             $cfg = e107::getConfig();
             list($plug, $key) = explode("|", $_POST['pk']);
             if (is_string($cfg->get('e_url_alias'))) {
                 $cfg->setPostedData('e_url_alias', array(e_LAN => array($plug => array($key => $tp->filter($_POST['value'])))), false);
             } else {
                 $cfg->setPref('e_url_alias/' . e_LAN . '/' . $plug . "/" . $key, $tp->filter($_POST['value']));
             }
             $cfg->save(true, true, true);
         }
         //	file_put_contents(e_LOG."e_url.log", print_r($cfg->get('e_url_alias'),true));
         exit;
     }
     $htaccess = file_exists(e_BASE . ".htaccess");
     if (function_exists('apache_get_modules')) {
         $modules = apache_get_modules();
         $modRewrite = in_array('mod_rewrite', $modules);
     } else {
         $modRewrite = true;
         //we don't really know.
     }
     if ($modRewrite === false) {
         e107::getMessage()->addInfo("Apache mod_rewrite was not found on this server and is required to use this feature. ");
         e107::getMessage()->addDebug(print_a($modules, true));
     }
     if ($htaccess && $modRewrite && !deftrue('e_MOD_REWRITE')) {
         e107::getMessage()->addInfo("Mod-rewrite is disabled. To enable, please add the following line to your <b>e107_config.php</b> file:<br /><pre>define('e_MOD_REWRITE',true);</pre>");
     }
     if (is_array($_POST['rebuild'])) {
         $table = key($_POST['rebuild']);
         list($primary, $input, $output) = explode("::", $_POST['rebuild'][$table]);
         $this->rebuild($table, $primary, $input, $output);
     }
     $this->api = e107::getInstance();
     $this->addTitle(LAN_EURL_NAME);
     if ($this->getAction() != 'settings') {
         return;
     }
 }
Example #17
0
File: url.php Project: armpit/e107
 public function create($route, $params = array(), $options = array())
 {
     if (is_string($route)) {
         $route = explode('/', $route, 2);
     }
     if (!varset($route[0]) || 'index' == $route[0]) {
         $route[0] = 'tagwords';
     }
     if (!varset($route[1])) {
         $route[1] = 'tagwords';
     }
     $base = e107::getInstance()->getFolder('plugins') . 'tagwords/';
     if ($route[0] == 'tagwords' || $route[0] == "search") {
         if (isset($params['q'])) {
             return $base . 'tagwords.php?q=' . $params['q'];
         } else {
             return $base . 'tagwords.php';
         }
     }
 }
Example #18
0
 public function __construct()
 {
     $this->e107 = e107::getInstance();
     foreach ($_POST as $key => $value) {
         $key = $this->e107->tp->toDB($key);
         if (strpos($key, 'nlmailnow') === 0) {
             $this->releaseIssue($key);
             break;
         }
     }
     if (isset($_POST['delete'])) {
         $this->deleteNewsletter();
     }
     if (isset($_POST['createNewsletter'])) {
         $this->createNewsletter();
     }
     if (isset($_POST['createIssue'])) {
         $this->createIssue();
     }
     if ($this->message) {
         $this->e107->ns->tablerender('', "<div style='text-align:center'><b>" . $this->message . '</b></div>');
     }
 }
Example #19
0
 function __construct()
 {
     global $pref, $TEMPLATE_TAGWORDS, $tagwords_shortcodes;
     $this->e107 = e107::getInstance();
     //language
     e107::includeLan(e_PLUGIN . "tagwords/languages/" . e_LANGUAGE . ".php");
     //shortcodes
     //require_once(e_PLUGIN.'tagwords/tagwords_shortcodes.php');
     $this->shortcodes = e107::getScBatch('tagwords', TRUE);
     //$this->shortcodes = $tagwords_shortcodes;
     //template
     if (is_readable(THEME . "tagwords_template.php")) {
         require_once THEME . "tagwords_template.php";
     } else {
         require_once e_PLUGIN . "tagwords/tagwords_template.php";
     }
     $this->template = $TEMPLATE_TAGWORDS;
     $this->pref = $this->get_prefs();
     //load plugin and core tagword areas
     $this->loadPlugin();
     $this->loadCore();
     //prepare and assign key'ed tagwords data
     $this->mapper();
 }
Example #20
0
 function sc_banner($parm)
 {
     $e107 = e107::getInstance();
     $ret = '';
     $text = '';
     mt_srand((double) microtime() * 1000000);
     $seed = mt_rand(1, 2000000000);
     $time = time();
     $query = " (banner_startdate=0 OR banner_startdate <= {$time}) AND (banner_enddate=0 OR banner_enddate > {$time}) AND (banner_impurchased=0 OR banner_impressions<=banner_impurchased)" . ($parm ? " AND banner_campaign='" . $e107->tp->toDB($parm) . "'" : '') . "\n\t\tAND banner_active IN (" . USERCLASS_LIST . ")\n\t\tORDER BY RAND({$seed}) LIMIT 1";
     if ($e107->sql->db_Select('banner', 'banner_id, banner_image, banner_clickurl', $query)) {
         $row = $e107->sql->db_Fetch();
         if (!$row['banner_image']) {
             return "<a href='" . e_HTTP . 'banner.php?' . $row['banner_id'] . "' rel='external'>no image assigned to this banner</a>";
         }
         $fileext1 = substr(strrchr($row['banner_image'], '.'), 1);
         $e107->sql->db_Update('banner', 'banner_impressions=banner_impressions+1 WHERE banner_id=' . (int) $row['banner_id']);
         switch ($fileext1) {
             case 'swf':
                 return "\n\t\t\t\t\t<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"468\" height=\"60\">\n\n\t\t\t\t\t<param name=\"movie\" value=\"" . e_IMAGE_ABS . "banners/" . $row['banner_image'] . "\">\n\n\t\t\t\t\t<param name=\"quality\" value=\"high\">\n\n\t\t\t\t\t<param name=\"SCALE\" value=\"noborder\">\n\n\t\t\t\t\t<embed src=\"" . e_IMAGE_ABS . "banners/" . $row['banner_image'] . "\" width=\"468\" height=\"60\" scale=\"noborder\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\"></embed>\n\t\t\t\t\t</object>\n\t\t\t\t\t";
                 break;
             case 'html':
             case 'js':
             case 'php':
                 // Code - may 'echo' text, or may return it as a value
                 $file_data = file_get_contents(e_IMAGE . 'banners/' . $row['banner_image']);
                 return $file_data;
                 break;
             default:
                 $ban_ret = "<img src='" . e_IMAGE_ABS . 'banners/' . $row['banner_image'] . "' alt='" . $row['banner_clickurl'] . "' style='border:0' />";
                 break;
         }
         return "<a href='" . e_HTTP . 'banner.php?' . $row['banner_id'] . "' rel='external'>" . $ban_ret . '</a>';
     } else {
         return '&nbsp;';
     }
 }
Example #21
0
function parse_forum($f, $restricted_string = '')
{
    global $FORUM_MAIN_FORUM, $gen, $forum, $newflag_list, $forumList;
    $fVars = new e_vars();
    $e107 = e107::getInstance();
    $tp = e107::getParser();
    if (USER && is_array($newflag_list) && in_array($f['forum_id'], $newflag_list)) {
        $fVars->NEWFLAG = "<a href='" . $e107->url->create('forum/forum/mfar', $f) . "'>" . IMAGE_new . '</a>';
    } else {
        $fVars->NEWFLAG = IMAGE_nonew;
    }
    if (substr($f['forum_name'], 0, 1) == '*') {
        $f['forum_name'] = substr($f['forum_name'], 1);
    }
    $f['forum_name'] = $tp->toHTML($f['forum_name'], true, 'no_hook');
    $f['forum_description'] = $tp->toHTML($f['forum_description'], true, 'no_hook');
    //$url= $e107->url->create('forum/forum/view', $f);
    $url = e107::url('forum', 'forum', $f);
    $fVars->FORUMNAME = "<a href='" . $url . "'>{$f['forum_name']}</a>";
    $fVars->FORUMDESCRIPTION = $f['forum_description'] . ($restricted_string ? "<br /><span class='smalltext'><i>{$restricted_string}</i></span>" : "");
    $fVars->THREADS = $f['forum_threads'];
    $fVars->REPLIES = $f['forum_replies'];
    $fVars->FORUMSUBFORUMS = '';
    $badgeReplies = $f['forum_replies'] ? "badge-info" : "";
    $badgeThreads = $f['forum_threads'] ? "badge-info" : "";
    $fVars->THREADSX = "<span class='badge {$badgeThreads}'>" . $f['forum_threads'] . "</span>";
    $fVars->REPLIESX = "<span class='badge {$badgeReplies}'>" . $f['forum_replies'] . "</span>";
    if (is_array($forumList['subs'][$f['forum_id']])) {
        list($lastpost_datestamp, $lastpost_thread) = explode('.', $f['forum_lastpost_info']);
        $ret = parse_subs($forumList, $f['forum_id'], $lastpost_datestamp);
        $fVars->FORUMSUBFORUMS = "<br /><div class='smalltext'>" . LAN_FORUM_0069 . ": {$ret['text']}</div>";
        $fVars->THREADS += $ret['threads'];
        $fVars->REPLIES += $ret['replies'];
        if (isset($ret['lastpost_info'])) {
            $f['forum_lastpost_info'] = $ret['lastpost_info'];
            $f['forum_lastpost_user'] = $ret['lastpost_user'];
            $f['forum_lastpost_user_anon'] = $ret['lastpost_user_anon'];
            $f['user_name'] = $ret['user_name'];
        }
    }
    if ($f['forum_lastpost_info']) {
        list($lastpost_datestamp, $lastpost_thread) = explode('.', $f['forum_lastpost_info']);
        if ($f['user_name']) {
            $lastpost_name = "<a href='" . $e107->url->create('user/profile/view', array('name' => $f['user_name'], 'id' => $f['forum_lastpost_user'])) . "'>{$f['user_name']}</a>";
        } else {
            $lastpost_name = $tp->toHTML($f['forum_lastpost_user_anon']);
        }
        $lastpost = $forum->threadGetLastpost($lastpost_thread);
        //XXX TODO inefficient to have SQL query here.
        $fVars->LASTPOSTUSER = $lastpost_name;
        // {forum_sef}/{thread_id}-{thread_sef}
        $urlData = array('forum_sef' => $f['forum_sef'], 'thread_id' => $lastpost['post_thread'], 'thread_sef' => $lastpost['thread_sef']);
        $url = e107::url('forum', 'topic', $urlData) . "?last=1#post-" . $lastpost['post_id'];
        $fVars->LASTPOSTDATE .= "<a href='" . $url . "'>" . $gen->computeLapse($lastpost_datestamp, time(), false, false, 'short') . "</a>";
        $lastpost_datestamp = $gen->convert_date($lastpost_datestamp, 'forum');
        $fVars->LASTPOST = $lastpost_datestamp . '<br />' . $lastpost_name . " <a href='" . $e107->url->create('forum/thread/last', array('name' => $lastpost_name, 'id' => $lastpost_thread)) . "'>" . IMAGE_post2 . '</a>';
    } else {
        $fVars->LASTPOSTUSER = "";
        $fVars->LASTPOSTDATE = "-";
        $fVars->LASTPOST = '-';
    }
    return $tp->simpleParse($FORUM_MAIN_FORUM, $fVars);
}
Example #22
0
File: url.php Project: armpit/e107
 /**
  * NOTE we have double 'forum' but this is the best way to map new-old forum URLs to the new routing engine
  * Additionally, 'forum' controller is descriptive, and leading 'forum' module name could be easiely changed (URL aliases administration page)
  */
 public function create($route, $params = array(), $options = array())
 {
     $amp = varset($options['encode']) ? '&amp;' : '&';
     if (is_string($route)) {
         $route = explode('/', $route, 2);
     }
     if (!varset($route[0]) || 'index' == $route[0]) {
         $route[0] = 'forum';
     }
     if (!varset($route[1])) {
         $route[1] = 'main';
     }
     $base = e107::getInstance()->getFolder('plugins') . 'forum/';
     //var_dump($options, $route, $params);
     if ($route[0] == 'forum') {
         if (!isset($params['id']) && isset($params['forum_id'])) {
             $params['id'] = $params['forum_id'];
         }
         // if(isset($params['forum_name'])) $params['name'] = $params['forum_name']; - not used in this config
         switch ($route[1]) {
             case 'view':
                 $page = varset($params['page']) ? $amp . 'p=' . $params['page'] : '';
                 return $base . "forum_viewforum.php?id={$params['id']}{$page}";
                 break;
             case 'track':
                 return $base . 'forum.php?track';
                 break;
             case 'index':
             case 'main':
                 return $base . 'forum.php';
                 break;
             case 'post':
                 return $base . "forum_post.php?f={$params['type']}{$amp}id={$params['id']}";
                 break;
             case 'rules':
                 return $base . 'forum.php?f=rules';
                 break;
             case 'mfar':
                 return $base . 'forum.php?f=mfar' . $amp . 'id=' . $params['id'];
                 break;
         }
     } elseif ($route[0] == 'thread') {
         if (!isset($params['id']) && isset($params['thread_id'])) {
             $params['id'] = $params['thread_id'];
         }
         // if(isset($params['thread_name'])) $params['name'] = $params['thread_name']; - not used in this config
         switch ($route[1]) {
             case 'new':
                 return $base . "forum_post.php?f=nt{$amp}id={$params['id']}";
                 break;
             case 'reply':
                 return $base . "forum_post.php?f=rp{$amp}id={$params['id']}";
                 break;
             case 'view':
                 $page = varset($params['page']) ? $amp . 'p=' . $params['page'] : '';
                 return $base . "forum_viewtopic.php?id={$params['id']}{$page}";
                 break;
             case 'last':
                 return $base . "forum_viewtopic.php?id={$params['id']}{$amp}last=1";
                 break;
             case 'post':
                 return $base . "forum_viewtopic.php?f=post{$amp}id={$params['id']}";
                 break;
             case 'report':
                 $page = isset($params['page']) ? (int) $params['page'] : 0;
                 return $base . "forum_viewtopic.php?f=report{$amp}id={$params['id']}{$amp}post={$params['post']}{$amp}p={$page}";
                 break;
             case 'edit':
                 return $base . "forum_post.php?f=edit{$amp}id={$params['id']}{$amp}post={$params['post']}";
                 break;
             case 'move':
                 return $base . "forum_conf.php?f=move{$amp}id={$params['id']}";
                 break;
             case 'split':
                 return $base . "forum_conf.php?f=split{$amp}id={$params['id']}";
                 break;
             case 'quote':
                 return $base . "forum_post.php?f=quote{$amp}id={$params['id']}{$amp}post={$params['post']}";
                 break;
             case 'next':
                 return $base . "forum_viewtopic.php?f=next{$amp}id={$params['id']}";
                 break;
             case 'prev':
                 return $base . "forum_viewtopic.php?f=prev{$amp}id={$params['id']}";
                 break;
             case 'track':
                 return $base . "forum_viewtopic.php?f=track{$amp}id={$params['id']}";
                 break;
             case 'untrack':
                 return $base . "forum_viewtopic.php?f=untrack{$amp}id={$params['id']}";
                 break;
             case 'track_toggle':
                 return $base . "forum_viewtopic.php?f=track_toggle{$amp}id={$params['id']}";
                 break;
         }
     }
     return false;
 }
Example #23
0
 /**
  * Go online
  * @param boolean $online_tracking
  * @param boolean $flood_control
  * @return void
  */
 public function goOnline($online_tracking = false, $flood_control = false)
 {
     // global $pref, $e_event; // Not needed as globals
     //global $online_timeout, $online_warncount, $online_bancount;	// Not needed as globals
     //global $members_online, $total_online;						// Not needed as globals
     global $listuserson;
     // FIXME - remove it, make it property, call e_online signleton - e107::getOnline()
     $e107 = e107::getInstance();
     $sql = e107::getDb();
     $user = e107::getUser();
     if ($online_tracking || $flood_control) {
         $online_timeout = 300;
         list($ban_access_guest, $ban_access_member) = explode(',', e107::getPref('ban_max_online_access', '100,200'));
         $online_bancount = max($ban_access_guest, 50);
         // Safety net for incorrect values
         if ($user->isUser()) {
             $online_bancount = max($online_bancount, $ban_access_member);
         }
         $online_warncount = $online_bancount * 0.9;
         // Set warning threshold at 90% of ban threshold
         //TODO Add support for all queries.
         // $page = (strpos(e_SELF, 'forum_') !== FALSE) ? e_SELF.'.'.e_QUERY : e_SELF;
         // $page = (strpos(e_SELF, 'comment') !== FALSE) ? e_SELF.'.'.e_QUERY : $page;
         // $page = (strpos(e_SELF, 'content') !== FALSE) ? e_SELF.'.'.e_QUERY : $page;
         $page = e_REQUEST_URI;
         // mod rewrite & single entry support
         // FIXME parse url, trigger registered e_online callbacks
         $page = e107::getParser()->toDB($page, true);
         /// @todo - try not to use toDB() - triggers prefilter
         $ip = e107::getIPHandler()->getIP(FALSE);
         $udata = $user->isUser() && USER ? $user->getId() . '.' . $user->getName() : '0';
         // USER check required to make sure they logged in without an error.
         $agent = $_SERVER['HTTP_USER_AGENT'];
         // XXX - more exceptions, e.g. hide online location for admins/users (pref), e_jlsib.php, etc
         // XXX - more advanced flod timing when  e_AJAX_REQUEST, e.g. $ban_access_ajax = 300
         $update_page = deftrue('e_AJAX_REQUEST') ? '' : ", online_location='{$page}'";
         $insert_query = array('online_timestamp' => time(), 'online_flag' => 0, 'online_user_id' => $udata, 'online_ip' => $ip, 'online_location' => $page, 'online_pagecount' => 1, 'online_active' => 0, 'online_agent' => $agent, 'online_language' => e_LAN);
         // !deftrue('e_AJAX_REQUEST')
         // TODO add option to hide users from online list? boolean online_hide field?
         // don't do anything if main admin logged in as another user
         if ($user->isUser() && !$user->getParentId()) {
             // Find record that matches IP or visitor, or matches user info
             if ($sql->select('online', '*', "(`online_ip` = '{$ip}' AND `online_user_id` = '0') OR `online_user_id` = '{$udata}'")) {
                 $row = $sql->fetch();
                 if ($row['online_user_id'] == $udata) {
                     //Matching user record
                     if ($row['online_timestamp'] < time() - $online_timeout) {
                         //It has been at least 'online_timeout' seconds since this user's info last logged
                         //Update user record with timestamp, current IP, current page and set pagecount to 1
                         $query = "online_timestamp='" . time() . "', online_ip='{$ip}'{$update_page}, online_pagecount=1, `online_active` = 1 WHERE online_user_id='{$row['online_user_id']}'";
                     } else {
                         if (!$user->isAdmin()) {
                             $row['online_pagecount']++;
                         }
                         // Update user record with current IP, current page and increment pagecount
                         $query = "online_ip='{$ip}'{$update_page}, `online_pagecount` = '" . intval($row['online_pagecount']) . "', `online_active` = 1 WHERE `online_user_id` = '{$row['online_user_id']}'";
                     }
                 } else {
                     //Found matching visitor record (ip only) for this user
                     if ($row['online_timestamp'] < time() - $online_timeout) {
                         // It has been at least 'timeout' seconds since this user has connected
                         // Update record with timestamp, current IP, current page and set pagecount to 1
                         $query = "`online_timestamp` = '" . time() . "', `online_user_id` = '{$udata}'{$update_page}, `online_pagecount` = 1,  `online_active` = 1 WHERE `online_ip` = '{$ip}' AND `online_user_id` = '0'";
                     } else {
                         // Another visit within the timeout period
                         if (!$user->isAdmin()) {
                             $row['online_pagecount']++;
                         }
                         //Update record with current IP, current page and increment pagecount
                         $query = "`online_user_id` = '{$udata}'{$update_page}, `online_pagecount` = " . intval($row['online_pagecount']) . ", `online_active` =1  WHERE `online_ip` = '{$ip}' AND `online_user_id` = '0'";
                     }
                 }
                 $sql->update('online', $query);
             } else {
                 $sql->insert('online', $insert_query);
             }
         } elseif (!$user->getParentId()) {
             //Current page request is from a guest
             if ($sql->select('online', '*', "`online_ip` = '{$ip}' AND `online_user_id` = '0'")) {
                 // Recent visitor
                 $row = $sql->fetch();
                 if ($row['online_timestamp'] < time() - $online_timeout) {
                     //Update record with timestamp, current page, and set pagecount to 1
                     $query = "`online_timestamp` = '" . time() . "'{$update_page}, `online_pagecount` = 1 WHERE `online_ip` = '{$ip}' AND `online_user_id` = '0'";
                 } else {
                     //Update record with current page and increment pagecount
                     $row['online_pagecount']++;
                     //   echo "here {$online_pagecount}";
                     $query = "`online_pagecount` = {$row['online_pagecount']}{$update_page} WHERE `online_ip` = '{$ip}' AND `online_user_id` = '0'";
                 }
                 $sql->update('online', $query);
             } else {
                 // New visitor
                 $sql->insert('online', $insert_query);
             }
         }
         if ($user->isAdmin() || e107::getPref('autoban') != 1 && e107::getPref('autoban') != 2 || !isset($row['online_pagecount'])) {
             $row['online_pagecount'] = 1;
         }
         // Always allow localhost - any problems are usually semi-intentional!
         if (varset($row['online_ip']) != '127.0.0.1' && varset($row['online_ip']) != e107::LOCALHOST_IP && varset($row['online_ip']) != e107::LOCALHOST_IP2) {
             // Check for excessive access
             if ($row['online_pagecount'] > $online_bancount) {
                 e107::lan('core', 'banlist', true);
                 //e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_banlist.php'
                 $reason = e107::getParser()->lanVars(BANLAN_78, $row['online_pagecount']);
                 //  str_replace('--HITS--',$row['online_pagecount'], BANLAN_78)
                 if (true === e107::getIPHandler()->add_ban(2, $reason, $ip, 0)) {
                     e107::getEvent()->trigger('flood', $ip);
                     //BC
                     e107::getEvent()->trigger('user_ban_flood', $ip);
                     exit;
                 }
             } elseif ($row['online_pagecount'] >= $online_warncount) {
                 echo "<div style='text-align:center; font: 11px verdana, tahoma, arial, helvetica, sans-serif;'><b>" . LAN_WARNING . "</b><br /><br />" . CORE_LAN6 . "<br /></div>";
                 exit;
             }
         }
         // Delete records for users (and guests) not seen for a while
         // FIXME - DB optimization - mark records as deleted (online_deleted=1), delete once per hour (could be pref) via e_cron
         // FIXME - Additional prefs for this (it does 2-3 more queries no matter someone need them), could be also separate method
         // Speed up ajax requests
         if (!deftrue('e_AJAX_REQUEST')) {
             $sql->delete('online', '`online_timestamp` < ' . (time() - $online_timeout));
             // FIXME - don't use constants below, save data in class vars, call e_online signleton - e107::getOnline()
             //	$total_online = $sql->db_Count('online'); // 1 less query! :-)
             if ($total_online = $sql->gen('SELECT o.*,u.user_image FROM #online AS o LEFT JOIN #user AS u ON o.online_user_id = u.user_id WHERE o.online_pagecount > 0 ORDER BY o.online_timestamp DESC')) {
                 $member_list = '';
                 $members_online = 0;
                 $listuserson = array();
                 while ($row = $sql->fetch()) {
                     $row['online_bot'] = $this->isBot($row['online_agent']);
                     // Sort into usable format and add bot field.
                     $user = array('user_location' => $row['online_location'], 'user_bot' => $this->isBot($row['online_agent']), 'user_agent' => $row['online_agent'], 'user_ip' => $row['online_ip'], 'user_currentvisit' => $row['online_timestamp'], 'user_online' => $row['online_flag'], 'user_pagecount' => $row['online_pagecount'], 'user_active' => $row['online_active'], 'user_image' => vartrue($row['user_image'], false), 'online_user_id' => $row['online_user_id'], 'user_language' => $row['online_language']);
                     if ($row['online_user_id'] != 0) {
                         $vals = explode('.', $row['online_user_id'], 2);
                         $user['user_id'] = $vals[0];
                         $user['user_name'] = $vals[1];
                         $member_list .= "<a href='" . SITEURL . "user.php?id.{$vals[0]}'>{$vals[1]}</a> ";
                         $listuserson[$row['online_user_id']] = $row['online_location'];
                         $this->users[] = $user;
                         $members_online++;
                     } else {
                         $user['user_id'] = 0;
                         $user['user_name'] = 'guest';
                         // Maybe should just be an empty string?
                         $this->guests[] = $user;
                     }
                 }
             }
             define('TOTAL_ONLINE', $total_online);
             define('MEMBERS_ONLINE', $members_online);
             define('GUESTS_ONLINE', $total_online - $members_online);
             define('ON_PAGE', $sql->db_Count('online', '(*)', "WHERE `online_location` = '{$page}' "));
             define('MEMBER_LIST', $member_list);
             //update most ever online
             $olCountPrefs = e107::getConfig('history');
             // Get historic counts of members on line
             $olCountPrefs->setParam('nologs', true);
             if ($total_online > $olCountPrefs->get('most_members_online') + $olCountPrefs->get('most_guests_online')) {
                 $olCountPrefs->set('most_members_online', MEMBERS_ONLINE);
                 $olCountPrefs->set('most_guests_online', GUESTS_ONLINE);
                 $olCountPrefs->set('most_online_datestamp', time());
                 $olCountPrefs->save(false, true, false);
             }
         }
     } else {
         define('e_TRACKING_DISABLED', true);
         // Used in forum, online menu
         define('TOTAL_ONLINE', '');
         define('MEMBERS_ONLINE', '');
         define('GUESTS_ONLINE', '');
         define('ON_PAGE', '');
         define('MEMBER_LIST', '');
     }
 }
Example #24
0
 function list_shortcodes()
 {
     $this->e107 = e107::getInstance();
     $this->rc = '';
 }
Example #25
0
// These letters match the ADMIN footer (that's why there is B.1,B.2)
//
// A Ensure sql and traffic objects exist
// [Next few ONLY if a regular page; not done for popups]
// B.1 Clear cache (if admin page, not here)
// B.2 Send the footer templated data
// C Dump any/all traffic and debug information
// [end of regular-page-only items]
// D Close the database connection
// E Themed footer code
// F Configured footer scripts
// G Browser-Server time sync script (must be the last one generated/sent)
// H Final HTML (/body, /html)
// I collect and send buffered page, along with needed headers
//
$e107 = e107::getInstance();
$sql = e107::getDb();
$pref = e107::getPref();
if (varset($e107_popup) != 1) {
    //
    // B.1 Clear cache (admin-only)
    //
    //
    // B.2 Send footer template, stop timing, send simple page stats
    //
    if (!deftrue('e_IFRAME')) {
        parseheader(varset($ph) ? $cust_footer : $FOOTER);
    }
    $eTimingStop = microtime();
    global $eTimingStart;
    $clockTime = e107::getSingleton('e107_traffic')->TimeDelta($eTimingStart, $eTimingStop);
Example #26
0
/**
 * Core NEXTPREV shortcode
 * Comma separated parameters are now deprecated.
 * Parameter string should be formatted as if it were the query string passed via a URL:
 * <code>$parm = 'total=10&amount=5&current=0&type=...'</code>
 *
 * Parameter list:
 * - total (integer) [required]: total records/pages
 * - amount (integer| string 'all') [required]: Records per page, always 1 when we counting pages (see 'type' parameter), ignored where tmpl_prefix is not set and 'old_np' pref is false
 * - current (integer)[required]: Current record/page
 * - type (string page|record) [optional]: What kind of navigation logic we need, default is 'record' (the old way)
 *
 * - url (rawurlencode'd string) [required]: URL template, will be rawurldecode'd after parameters are parsed to array, '--AMP--' strings will be replaced with '&amp;'
 * 	NOTE: URL should be DOUBLE encoded, which means you need to encode the query only of passed URL (W3C standards) and rawurlencode the whole URL string
 * The reason to do this is to not break the whole shortcode $parm string, shortcode itself is doing decode once, which means we'll end up with correct, W3C compliant URL string
 * 'url' now supports url::module/controller/action?id=xxx--AMP--name=yyy--AMP--page=--FROM--::full=1 and route::news/list/category::id=xxx--AMP--name=yyy--AMP--page=--FROM--::full=1 formats
 *
 * Preffered 'FROM' template is now '--FROM--' (instead '[FROM]')
 * - caption (rawurlencode'd string) [optional]: Label, rawurldecode'd after parameters are parsed to array, language constants are supported
 * - pagetitle (rawurlencode'd string) [optional]: Page labels, rawurldecode'd after parameters are parsed to array,
 * separated by '|', if present they will be used as lablels instead page numbers; language constants are supported
 * - plugin (string) [optional]: plugin name used for template loading
 * - tmpl_prefix (string) [optional]: template keys prefix; core supported are 'default' and 'dropdown', default depends on 'old_np' pref
 * - navcount (integer) [optional]: number of navigation items to be shown, minimal allowed value is 4, default is 10
 * - nonavcount (no value) [optional]: if is set it'll disable navigation counting (navcount will be ignored)
 * - bullet (string) [optional]: currently it should contain the markup to be prepended to the navigation item title
 *
 * WARNING: You have to do rawuldecode() on url, caption and title parameter values (before passing them to the shortcode)
 * or you'll break the whole script
 *
 * TODO - add create URL support when new URL handler is ready
 *
 * @param string $parm
 * @return string page navigation bar HTML
 */
function nextprev_shortcode($parm = '')
{
    $e107 = e107::getInstance();
    $pref = e107::getPref();
    $tp = e107::getParser();
    e107::coreLan('np');
    /**
     * The NEW way.
     * New parameter requirements formatted as a GET string.
     * Template support.
     */
    if (strpos($parm, 'total=') !== false) {
        parse_str($parm, $parm);
        // Calculate
        $total_items = intval($parm['total']);
        $check_render = true;
        if (vartrue($parm['glyphs']) && deftrue('BOOTSTRAP')) {
            $LAN_NP_FIRST = $tp->toGlyph("icon-fast-backward.glyph", false);
            $LAN_NP_PREVIOUS = $tp->toGlyph("icon-backward.glyph", false);
            $LAN_NP_NEXT = $tp->toGlyph("icon-forward.glyph", false);
            $LAN_NP_LAST = $tp->toGlyph("icon-fast-forward", false);
        } else {
            $LAN_NP_FIRST = LAN_NP_FIRST;
            $LAN_NP_PREVIOUS = LAN_NP_PREVIOUS;
            $LAN_NP_NEXT = LAN_NP_NEXT;
            $LAN_NP_LAST = LAN_NP_LAST;
        }
        // search for template keys - default_start, default_end etc.
        if (isset($parm['tmpl_prefix'])) {
            // forced
            $tprefix = vartrue($parm['tmpl_prefix'], 'default');
            //$perpage = $parm['amount'] !== 'all' ? intval($parm['amount']) : $total_items;
        } elseif (isset($parm['tmpl'])) {
            // forced
            $tprefix = vartrue($parm['tmpl'], 'default');
            //$perpage = $parm['amount'] !== 'all' ? intval($parm['amount']) : $total_items;
        } elseif ($pref['old_np']) {
            $tprefix = 'default';
            //$perpage = $parm['amount'] !== 'all' ? intval($parm['amount']) : $total_items;
        } else {
            $tprefix = 'dropdown';
            //$parm['amount'] = 'all';
        }
        if ($tprefix == 'default' && deftrue('BOOTSTRAP')) {
            $tprefix = 'bootstrap';
        }
        $tprefix .= '_';
        if ($parm['amount'] === 'all') {
            $perpage = 1;
            // amount is ignored
            $check_render = $total_items > 1;
        } else {
            $perpage = intval($parm['amount']);
        }
        if (!$check_render) {
            return '';
        }
        // TODO - rename old_np to something more meaningful
        $current_start = intval($parm['current']);
        $nptype = varset($parm['type'], 'record');
        switch ($nptype) {
            case 'page':
                $perpage = 1;
                $current_page = $current_start;
                $first_page = 1;
                $next_page = $current_page + 1;
                $prev_page = $current_page - 1;
                $total_pages = $last_page = $total_items;
                $index_add = 1;
                break;
            default:
                $total_pages = ceil($total_items / $perpage);
                $last_page = ceil($total_pages * $perpage) - $perpage;
                $current_page = $current_start / $perpage + 1;
                $next_page = $current_page * $perpage;
                $prev_page = $current_start - $perpage;
                $first_page = 0;
                $index_add = 0;
                break;
        }
        if ($total_pages <= 1) {
            return '';
        }
        // urldecoded once by parse_str()
        if (substr($parm['url'], 0, 7) == 'route::') {
            // New - use URL assembling engine
            // Format is: route::module/controller/action::urlParams::urlOptions
            // Example: route::news/list/category::id=xxx--AMP--name=yyy--AMP--page=--FROM--::full=1
            // WARNING - url parameter string have to be rawurlencode-ed BEFORE passed to the shortcode, or it'll break everything
            $urlParms = explode('::', str_replace('--AMP--', '&', $parm['url']));
            $url = str_replace('--FROM--', '[FROM]', $e107->url->create($urlParms[1], $urlParms[2], varset($urlParms[3])));
        } elseif (substr($parm['url'], 0, 5) == 'url::') {
            // New - use URL assembling engine
            // Format is: url::module/controller/action?id=xxx--AMP--name=yyy--AMP--page=--FROM--::full=1
            // WARNING - url parameter string have to be rawurlencode-ed BEFORE passed to the shortcode, or it'll break everything
            $urlParms = explode('::', str_replace('--AMP--', '&', $parm['url']));
            $url = str_replace('--FROM--', '[FROM]', $e107->url->create($urlParms[1], array(), varset($urlParms[2])));
        } else {
            $url = str_replace(array('--FROM--', '--AMP--'), array('[FROM]', '&amp;'), $parm['url']);
        }
        // Simple parser vars
        $e_vars = new e_vars(array('total_pages' => $total_pages, 'current_page' => $current_page));
        // urldecoded by parse_str()
        if (!varset($parm['caption'])) {
            $e_vars->caption = 'LAN_NP_CAPTION';
        }
        // Advanced multilingual support: 'Page [x] of [y]' -> match the exact argument, result would be 'Page 1 of 20'
        $e_vars->caption = $tp->lanVars(defset($e_vars->caption, $e_vars->caption), array('x' => $current_page, 'y' => $total_pages));
        // sprintXX(defset($e_vars->caption, $e_vars->caption), $current_page, $total_pages);
        // urldecoded by parse_str()
        $pagetitle = explode('|', vartrue($parm['pagetitle']));
        // new - bullet support
        $bullet = vartrue($parm['bullet'], '');
        // no navigation counter
        if (isset($parm['nonavcount'])) {
            $navcount = $total_pages;
            $navmid = 0;
        } else {
            // navigation number settings
            $navcount = abs(intval(vartrue($parm['navcount'], 10)));
            // prevent infinite loop!
            if ($navcount < 4) {
                $navcount = 4;
            }
            $navmid = floor($navcount / 2);
        }
        // get template - nextprev_template.php, support for plugin template locations - myplug/templates/nextprev_template.php
        $tmpl = e107::getTemplate(varset($parm['plugin'], null), 'nextprev');
        // init advanced navigation visibility
        $show_first = $show_prev = $current_page != 1;
        $show_last = $show_next = $current_page != $total_pages;
        // Render
        // Parse via simpleParse()
        $tp = e107::getParser();
        // Nextprev navigation start
        $ret = $tp->simpleParse($tmpl[$tprefix . 'start'], $e_vars);
        // caption, e.g. 'Page 1 of 20' box
        if ($e_vars->caption) {
            $ret .= $tp->simpleParse($tmpl[$tprefix . 'nav_caption'], $e_vars);
        }
        $ret_array = array();
        // Show from 1 to $navcount || $total_pages
        if ($current_page <= $navmid || $total_pages <= $navcount) {
            $loop_start = 0;
            $loop_end = $navcount;
            $show_first = false;
            if ($navcount >= $total_pages) {
                $loop_end = $total_pages;
                $show_last = false;
            }
        } else {
            if ($current_page + $navmid >= $total_pages) {
                $loop_start = $total_pages - $navcount;
                if ($loop_start < 0) {
                    $loop_start = 0;
                }
                $loop_end = $total_pages;
                $show_last = false;
            } else {
                $loop_start = $current_page - $navmid;
                $loop_end = $current_page + ($navcount - $navmid);
                // odd/even $navcount support
                if ($loop_start < 0) {
                    $loop_start = 0;
                } elseif ($loop_end > $total_pages) {
                    $loop_end = $total_pages;
                    $show_last = false;
                }
            }
        }
        // Add 'first', 'previous' navigation
        if ($show_prev) {
            if ($show_first && !empty($tmpl[$tprefix . 'nav_first'])) {
                $e_vars->url = str_replace('[FROM]', $first_page, $url);
                $e_vars->label = $LAN_NP_FIRST;
                $e_vars->url_label = LAN_NP_URLFIRST;
                $ret_array[] = $tp->simpleParse($tmpl[$tprefix . 'nav_first'], $e_vars);
            }
            if (!empty($tmpl[$tprefix . 'nav_prev'])) {
                $e_vars->url = str_replace('[FROM]', $prev_page, $url);
                $e_vars->label = $LAN_NP_PREVIOUS;
                $e_vars->url_label = LAN_NP_URLPREVIOUS;
                $ret_array[] = $tp->simpleParse($tmpl[$tprefix . 'nav_prev'], $e_vars);
            }
        }
        $e_vars_loop = new e_vars();
        $e_vars_loop->bullet = stripslashes($bullet);
        // fix magicquotes
        $ret_items = array();
        for ($c = $loop_start; $c < $loop_end; $c++) {
            $label = '';
            if (varset($pagetitle[$c])) {
                $label = defset($pagetitle[$c], $pagetitle[$c]);
            }
            $e_vars_loop->url = str_replace('[FROM]', $perpage * ($c + $index_add), $url);
            $e_vars_loop->label = $label ? $tp->toHTML(stripslashes($label), false, 'TITLE') : $c + 1;
            //quick fix servers with magicquotes - stripslashes()
            if ($c + 1 == $current_page) {
                $e_vars_loop->url_label = $label ? $tp->toAttribute($label) : LAN_NP_URLCURRENT;
                $ret_items[] = $tp->simpleParse($tmpl[$tprefix . 'item_current'], $e_vars_loop);
            } else {
                $e_vars_loop->url_label = $label ? $tp->toAttribute($label) : LAN_NP_GOTO;
                $e_vars_loop->url_label = str_replace("[x]", $c + 1, $e_vars_loop->url_label);
                $ret_items[] = $tp->simpleParse($tmpl[$tprefix . 'item'], $e_vars_loop);
            }
        }
        $ret_array[] = $tp->simpleParse($tmpl[$tprefix . 'items_start'], $e_vars) . implode($tmpl[$tprefix . 'separator'], $ret_items) . $tp->simpleParse($tmpl[$tprefix . 'items_end'], $e_vars);
        unset($ret_items, $e_vars_loop);
        if ($show_next) {
            if (!empty($tmpl[$tprefix . 'nav_next'])) {
                $e_vars->url = str_replace('[FROM]', $next_page, $url);
                $e_vars->label = $LAN_NP_NEXT;
                $e_vars->url_label = LAN_NP_URLNEXT;
                $ret_array[] = $tp->simpleParse($tmpl[$tprefix . 'nav_next'], $e_vars);
            }
            if ($show_last && !empty($tmpl[$tprefix . 'nav_last'])) {
                $e_vars->url = str_replace('[FROM]', $last_page, $url);
                //$last_page
                $e_vars->label = $LAN_NP_LAST;
                $e_vars->url_label = LAN_NP_URLLAST;
                $ret_array[] = $tp->simpleParse($tmpl[$tprefix . 'nav_last'], $e_vars);
            }
        }
        $ret .= implode($tmpl[$tprefix . 'separator'], $ret_array);
        // Nextprev navigation end
        $ret .= $tp->simpleParse($tmpl[$tprefix . 'end'], $e_vars);
        unset($e_vars, $ret_array);
        return $ret;
    } else {
        $parm_count = substr_count($parm, ',');
        while ($parm_count < 5) {
            $parm .= ',';
            $parm_count++;
        }
        $p = explode(',', $parm, 6);
        $total_items = intval($p[0]);
        $perpage = intval($p[1]);
        // page number instead record start now supported
        if (is_numeric($p[2])) {
            $current_start = intval($p[2]);
            $current_page = $current_start / $perpage + 1;
            $total_pages = ceil($total_items / $perpage);
            $index_add = 0;
        } else {
            $perpage = 1;
            $current_start = intval(array_pop(explode(':', $p[2], 2)));
            $current_page = $current_start;
            $total_pages = $total_items;
            $index_add = 1;
        }
        if ($total_items < $perpage) {
            return '';
        }
        $url = trim($p[3]);
        $caption = trim($p[4]);
        $pagetitle = explode('|', trim($p[5]));
        $caption = !$caption || $caption == 'off' ? LAN_GOPAGE . '&nbsp;' : $caption;
        while (substr($url, -1) == '.') {
            $url = substr($url, 0, -1);
        }
    }
    if ($total_pages > 1) {
        if (vartrue($pref['old_np'])) {
            $NP_PRE_ACTIVE = '';
            $NP_POST_ACTIVE = '';
            $NP_STYLE = '';
            if (!defined('NEXTPREV_NOSTYLE') || NEXTPREV_NOSTYLE == FALSE) {
                $NP_PRE_ACTIVE = '[';
                $NP_POST_ACTIVE = '] ';
                $NP_STYLE = "style='text-decoration:underline'";
            }
            //	Use OLD nextprev method
            $nppage = '';
            $nppage .= "\n\n<!-- Start of Next/Prev -->\n\n";
            if ($total_pages > 10) {
                //$current_page = ($current_start/$perpage)+1;
                for ($c = 0; $c <= 2; $c++) {
                    if ($perpage * ($c + $index_add) == $current_start) {
                        $nppage .= $NP_PRE_ACTIVE . "<span class='nextprev_current' {$NP_STYLE} >" . ($c + 1) . "</span>" . $NP_POST_ACTIVE . "\n";
                    } else {
                        $link = str_replace("[FROM]", $perpage * ($c + $index_add), $url);
                        $nppage .= "<a class='nextprev_link' href='{$link}'>" . ($c + 1) . "</a> \n";
                    }
                }
                if ($current_page >= 3 && $current_page <= 5) {
                    for ($c = 3; $c <= $current_page; $c++) {
                        if ($perpage * ($c + $index_add) == $current_start) {
                            $nppage .= $NP_PRE_ACTIVE . "<span class='nextprev_current' {$NP_STYLE} >" . ($c + 1) . "</span>" . $NP_POST_ACTIVE . "\n";
                        } else {
                            $link = str_replace("[FROM]", $perpage * ($c + $index_add), $url);
                            $nppage .= "<a class='nextprev_link' href='{$link}'>" . ($c + 1) . "</a> \n";
                        }
                    }
                } else {
                    if ($current_page >= 6 && $current_page <= $total_pages - 5) {
                        $nppage .= " ... ";
                        for ($c = $current_page - 2; $c <= $current_page; $c++) {
                            if ($perpage * ($c + $index_add) == $current_start) {
                                $nppage .= $NP_PRE_ACTIVE . "<span class='nextprev_current' {$NP_STYLE} >" . ($c + 1) . "</span>" . $NP_POST_ACTIVE . "\n";
                            } else {
                                $link = str_replace("[FROM]", $perpage * ($c + $index_add), $url);
                                $nppage .= "<a class='nextprev_link' href='{$link}'>" . ($c + 1) . "</a> \n";
                            }
                        }
                    }
                }
                $nppage .= " ... ";
                if ($current_page + 5 > $total_pages && $current_page != $total_pages) {
                    $tmp = $current_page - 2;
                } else {
                    $tmp = $total_pages - 3;
                }
                for ($c = $tmp; $c <= $total_pages - 1; $c++) {
                    if ($perpage * ($c + $index_add) == $current_start) {
                        $nppage .= $NP_PRE_ACTIVE . "<span class='nextprev_current' {$NP_STYLE} >" . ($c + 1) . "</span>" . $NP_POST_ACTIVE . "\n";
                    } else {
                        $link = str_replace("[FROM]", $perpage * ($c + $index_add), $url);
                        $nppage .= "<a class='nextprev_link' href='{$link}'>" . ($c + 1) . "</a> \n";
                    }
                }
            } else {
                for ($c = 0; $c < $total_pages; $c++) {
                    if ($perpage * ($c + $index_add) == $current_start) {
                        $nppage .= $NP_PRE_ACTIVE . "<span class='nextprev_current' {$NP_STYLE} >" . ($c + 1) . "</span>" . $NP_POST_ACTIVE . "\n";
                    } else {
                        $link = str_replace("[FROM]", $perpage * ($c + $index_add), $url);
                        $nppage .= "<a class='nextprev_link' href='{$link}'>" . ($c + 1) . "</a> \n";
                    }
                }
            }
            $nppage .= "\n\n<!-- End of Next/Prev -->\n\n";
            return $caption . $nppage;
        }
        // Use NEW nextprev method
        $np_parm['template'] = "<span class='form-group form-inline'>[PREV]&nbsp;&nbsp;[DROPDOWN]&nbsp;&nbsp;[NEXT]<span>";
        $np_parms['prev'] = '&nbsp;&nbsp;&lt;&lt;&nbsp;&nbsp;';
        $np_parms['next'] = '&nbsp;&nbsp;&gt;&gt;&nbsp;&nbsp;';
        $np_parms['np_class'] = 'tbox npbutton btn btn-default';
        $np_parms['dropdown_class'] = 'tbox npdropdown form-control';
        $caption = '';
        // legacy has no caption.
        if ($cached_parms = getcachedvars('nextprev')) {
            $tmp = $cached_parms;
            foreach ($tmp as $key => $val) {
                $np_parms[$key] = $val;
            }
        }
        $prev = '';
        $next = '';
        if ($current_page > 1) {
            $prevstart = $current_start - $perpage;
            if (substr($url, 0, 5) == 'url::') {
                $urlParms = explode('::', $url);
                $urlParms[2] = str_replace('[FROM]', $prevstart, $urlParms[2]);
                $link = $e107->url->create($urlParms[1], $urlParms[2], varset($urlParms[3]));
            } else {
                $link = str_replace('[FROM]', $prevstart, $url);
            }
            $prev = "<a class='{$np_parms['np_class']}' style='text-decoration:none' href='{$link}'>{$np_parms['prev']}</a>";
        }
        if ($current_page < $total_pages) {
            $nextstart = $current_start + $perpage;
            if (substr($url, 0, 5) == 'url::') {
                $urlParms = explode('::', $url);
                $urlParms[2] = str_replace('[FROM]', $nextstart, $urlParms[2]);
                $link = $e107->url->create($urlParms[1], $urlParms[2], varset($urlParms[3]));
            } else {
                $link = str_replace('[FROM]', $nextstart, $url);
            }
            $next = "<a class='{$np_parms['np_class']}' style='text-decoration:none' href='{$link}'>{$np_parms['next']}</a>";
        }
        $dropdown = "<select class='{$np_parms['dropdown_class']}' name='pageSelect' onchange='location.href=this.options[selectedIndex].value'>";
        for ($i = 1; $i <= $total_pages; $i++) {
            $sel = '';
            if ($current_page == $i) {
                $sel = " selected='selected' ";
            }
            $newstart = ($i - 1 + $index_add) * $perpage;
            if (substr($url, 0, 5) == 'url::') {
                $urlParms = explode('::', $url);
                $urlParms[2] = str_replace('[FROM]', $newstart, $urlParms[2]);
                $link = $e107->url->create($urlParms[1], $urlParms[2], varset($urlParms[3]));
            } else {
                $link = str_replace('[FROM]', $newstart, $url);
            }
            $c = $i - 1 + $index_add;
            $title = isset($pagetitle[$c]) && $pagetitle[$c] ? $pagetitle[$c] : $i;
            $dropdown .= "<option value='{$link}' {$sel}>{$title}</option>\n";
        }
        $dropdown .= '</select>';
        $ret = $np_parm['template'];
        // Set default
        if (isset($np_parms['template']) && $np_parms['template']) {
            $ret = $np_parms['template'];
            // Use override
        }
        $ret = str_replace('[DROPDOWN]', $dropdown, $ret);
        $ret = str_replace('[PREV]', $prev, $ret);
        $ret = str_replace('[NEXT]', $next, $ret);
        return $caption . $ret;
    }
}
Example #27
0
function headerjs()
{
    $e107 = e107::getInstance();
    // These functions need to be removed and replaced with the generic jsconfirm() function.
    $headerjs = "<script type=\"text/javascript\">\n\tfunction confirm_(mode, forum_id, forum_name) {\n\t\tif (mode == 'sr') {\n\t\t\treturn confirm(\"" . $e107->tp->toJS(FORLAN_117) . "\");\n\t\t} else if(mode == 'parent') {\n\t\t\treturn confirm(\"" . $e107->tp->toJS(FORLAN_81) . " [ID: \" + forum_name + \"]\");\n\t\t} else {\n\t\t\treturn confirm(\"" . $e107->tp->toJS(FORLAN_82) . " [ID: \" + forum_name + \"]\");\n\t\t}\n\t}\n\t</script>";
    return $headerjs;
}
Example #28
0
 /**
  * Create and substitute e107 constants in passed URL
  *
  * @param string $url
  * @param integer $mode 0-folders, 1-relative ('rel'), 2-absolute ('abs'), 3-full ('full') (with domain), 4-absolute & relative ('mix') (combination of 1,2,3)
  * @return string
  */
 public function createConstants($url, $mode = 0)
 {
     //FIXME - create constants for absolute paths and site URL's
     if (!is_numeric($mode)) {
         switch ($mode) {
             case 'rel':
                 $mode = 1;
                 break;
             case 'abs':
                 $mode = 2;
                 break;
             case 'full':
                 $mode = 3;
                 break;
             case 'mix':
                 $mode = 4;
                 break;
             case 'nice':
                 $mode = 5;
                 break;
         }
     }
     $e107 = e107::getInstance();
     switch ($mode) {
         case 0:
             // folder name only.
             $tmp = array('{e_MEDIA_FILE}' => $e107->getFolder('media_files'), '{e_MEDIA_VIDEO}' => $e107->getFolder('media_videos'), '{e_MEDIA_IMAGE}' => $e107->getFolder('media_images'), '{e_MEDIA_ICON}' => $e107->getFolder('media_icons'), '{e_MEDIA_AVATAR}' => $e107->getFolder('media_avatars'), '{e_WEB_JS}' => $e107->getFolder('web_js'), '{e_WEB_CSS}' => $e107->getFolder('web_css'), '{e_WEB_IMAGE}' => $e107->getFolder('web_images'), '{e_WEB_PACK}' => $e107->getFolder('web_packs'), '{e_IMAGE}' => $e107->getFolder('images'), '{e_PLUGIN}' => $e107->getFolder('plugins'), '{e_FILE}' => $e107->getFolder('files'), '{e_THEME}' => $e107->getFolder('themes'), '{e_DOWNLOAD}' => $e107->getFolder('downloads'), '{e_ADMIN}' => $e107->getFolder('admin'), '{e_HANDLER}' => $e107->getFolder('handlers'), '{e_MEDIA}' => $e107->getFolder('media'), '{e_WEB}' => $e107->getFolder('web'));
             break;
         case 1:
             // relative path only
             $tmp = array('{e_MEDIA_FILE}' => e_MEDIA_FILE, '{e_MEDIA_VIDEO}' => e_MEDIA_VIDEO, '{e_MEDIA_IMAGE}' => e_MEDIA_IMAGE, '{e_MEDIA_ICON}' => e_MEDIA_ICON, '{e_MEDIA_AVATAR}' => e_MEDIA_AVATAR, '{e_WEB_JS}' => e_WEB_JS, '{e_WEB_CSS}' => e_WEB_CSS, '{e_WEB_IMAGE}' => e_WEB_IMAGE, '{e_WEB_PACK}' => e_WEB_PACK, '{e_IMAGE}' => e_IMAGE, '{e_PLUGIN}' => e_PLUGIN, '{e_FILE}' => e_FILE, '{e_THEME}' => e_THEME, '{e_DOWNLOAD}' => e_DOWNLOAD, '{e_ADMIN}' => e_ADMIN, '{e_HANDLER}' => e_HANDLER, '{e_MEDIA}' => e_MEDIA, '{e_WEB}' => e_WEB);
             break;
         case 2:
             // absolute path only
             $tmp = array('{e_MEDIA_FILE}' => e_MEDIA_FILE_ABS, '{e_MEDIA_VIDEO}' => e_MEDIA_VIDEO_ABS, '{e_MEDIA_IMAGE}' => e_MEDIA_IMAGE_ABS, '{e_MEDIA_ICON}' => e_MEDIA_ICON_ABS, '{e_MEDIA_AVATAR}' => e_MEDIA_AVATAR_ABS, '{e_WEB_JS}' => e_JS_ABS, '{e_WEB_CSS}' => e_CSS_ABS, '{e_WEB_IMAGE}' => e_WEB_IMAGE_ABS, '{e_WEB_PACK}' => e_PACK_ABS, '{e_IMAGE}' => e_IMAGE_ABS, '{e_PLUGIN}' => e_PLUGIN_ABS, '{e_FILE}' => e_FILE_ABS, '{e_THEME}' => e_THEME_ABS, '{e_DOWNLOAD}' => e_HTTP . 'request.php?', '{e_ADMIN}' => e_ADMIN_ABS, '{e_MEDIA}' => e_MEDIA_ABS, '{e_WEB}' => e_WEB_ABS, '{e_BASE}' => e_HTTP);
             break;
         case 3:
             // full path (e.g http://domain.com/e107_images/)
             $tmp = array('{e_MEDIA_FILE}' => SITEURLBASE . e_MEDIA_FILE_ABS, '{e_MEDIA_VIDEO}' => SITEURLBASE . e_MEDIA_VIDEO_ABS, '{e_MEDIA_IMAGE}' => SITEURLBASE . e_MEDIA_IMAGE_ABS, '{e_MEDIA_ICON}' => SITEURLBASE . e_MEDIA_ICON_ABS, '{e_MEDIA_AVATAR}' => SITEURLBASE . e_MEDIA_AVATAR_ABS, '{e_WEB_JS}' => SITEURLBASE . e_JS_ABS, '{e_WEB_CSS}' => SITEURLBASE . e_CSS_ABS, '{e_WEB_IMAGE}' => SITEURLBASE . e_WEB_IMAGE_ABS, '{e_WEB_PACK}' => SITEURLBASE . e_PACK_ABS, '{e_IMAGE}' => SITEURLBASE . e_IMAGE_ABS, '{e_PLUGIN}' => SITEURLBASE . e_PLUGIN_ABS, '{e_FILE}' => SITEURLBASE . e_FILE_ABS, '{e_THEME}' => SITEURLBASE . e_THEME_ABS, '{e_DOWNLOAD}' => SITEURLBASE . e_HTTP . 'request.php?', '{e_ADMIN}' => SITEURLBASE . e_ADMIN_ABS, '{e_MEDIA}' => SITEURLBASE . e_MEDIA_ABS, '{e_WEB}' => SITEURLBASE . e_WEB_ABS, '{e_BASE}' => SITEURL);
             break;
         case 4:
             // absolute & relative paths
             $url = $this->createConstants($url, 3);
             $url = $this->createConstants($url, 2);
             $url = $this->createConstants($url, 1);
             return $url;
             break;
         case 5:
             // nice urls - e.g. e_MEDIA_VIDEO/mystream.flv
             $url = $this->createConstants($url, 4);
             return str_replace($this->getUrlConstants('sc'), $this->getUrlConstants('raw'), $url);
             break;
         default:
             $tmp = array();
             break;
     }
     foreach ($tmp as $key => $val) {
         $len = strlen($val);
         if (substr($url, 0, $len) == $val) {
             // replace the first instance only
             return substr_replace($url, $key, 0, $len);
         }
     }
     return $url;
 }
Example #29
0
 function clear_cache()
 {
     $e107 = e107::getInstance();
     $e107->ecache->clear_sys('nomd5_extended_struct');
 }
Example #30
0
 function toggle_track()
 {
     global $forum, $thread;
     $e107 = e107::getInstance();
     if (!USER || !isset($_GET['id'])) {
         return;
     }
     if ($thread->threadInfo['track_userid']) {
         $forum->track('del', USERID, $_GET['id']);
         $img = IMAGE_untrack;
     } else {
         $forum->track('add', USERID, $_GET['id']);
         $img = IMAGE_track;
     }
     if (e_AJAX_REQUEST) {
         $url = $e107->url->create('forum/thread/view', array('name' => $this->threadInfo['thread_name'], 'id' => $thread->threadId));
         echo "<a href='{$url}' id='forum-track-trigger'>{$img}</a>";
         exit;
     }
 }