Пример #1
0
function user_avatar_shortcode($parm = '')
{
    global $loop_uid;
    $height = e107::getPref("im_height");
    $width = e107::getPref("im_width");
    $tp = e107::getParser();
    if (intval($loop_uid) > 0 && trim($parm) == "") {
        $parm = $loop_uid;
    }
    if (is_numeric($parm)) {
        if ($parm == USERID) {
            $image = USERIMAGE;
        } else {
            $row = get_user_data(intval($parm));
            $image = $row['user_image'];
        }
    } elseif ($parm) {
        $image = $parm;
    } elseif (USERIMAGE) {
        $image = USERIMAGE;
    } else {
        $image = "";
    }
    if (vartrue($image)) {
        $img = strpos($image, "://") !== false ? $image : $tp->thumbUrl(e_MEDIA . "avatars/" . $image, "aw=" . $width . "&ah=" . $height);
        $text = "<img class='user-avatar e-tip' src='" . $img . "' alt='' style='width:" . $width . "px; height:" . $height . "px' />\n\t\t";
    } else {
        $img = $tp->thumbUrl(e_IMAGE . "generic/blank_avatar.jpg", "aw=" . $width . "&ah=" . $height);
        $text = "<img class='user-avatar' src='" . $img . "' alt='' />";
    }
    return $text;
}
Пример #2
0
 /**
  * Setup
  */
 function __construct()
 {
     $ns = e107::getRender();
     $pref = e107::getPref();
     $mes = e107::getMessage();
     $frm = e107::getForm();
     $this->backUrl = e_SELF;
     $core_data = file_get_contents(e_CORE . 'sql/core_sql.php');
     $this->tables['core'] = $this->getTables($core_data);
     $this->sqlLanguageTables = $this->getSqlLanguages();
     if (varset($pref['e_sql_list'])) {
         foreach ($pref['e_sql_list'] as $path => $file) {
             $filename = e_PLUGIN . $path . '/' . $file . '.php';
             if (is_readable($filename)) {
                 $id = str_replace('_sql', '', $file);
                 $data = file_get_contents($filename);
                 $this->tables[$id] = $this->getTables($data);
                 unset($data);
             } else {
                 $message = str_replace("[x]", $filename, DBVLAN_22);
                 $mes->add($message, E_MESSAGE_WARNING);
             }
         }
     }
 }
Пример #3
0
 function sendEmail()
 {
     $adminEmail = e107::getPref('siteadminemail');
     $adminName = e107::getPref('siteadmin');
     require_once e_HANDLER . "mail.php";
     $message = "Your Cron Job worked correctly. Sent at " . date("r") . ".";
     sendemail($adminEmail, "e107 - Crong Test Email", $message, $adminName, $adminEmail, $adminName);
 }
Пример #4
0
/**
 * Example usage:
 * <code>
 * <?php
 * $SOME_TEMPLATE = '{LANGUAGELINKS}'; // render default (available) lan list, include current query string
 * </code>
 *
 * <code>
 * <?php
 * $SOME_TEMPLATE = '{LANGUAGELINKS=English,Bulgarian}'; // render custom lan list, include current query string
 * </code>
 *
 * <code>
 * <?php
 * $SOME_TEMPLATE = '{LANGUAGELINKS=English,Bulgarian|noquery}'; // render custom lan list, exclude query
 * </code>
 *
 * <code>
 * <?php
 * $SOME_TEMPLATE = '{LANGUAGELINKS=|home}'; // render default (available) lan list, point always to site index
 * </code>
 *
 * @param string $parm
 */
function languagelinks_shortcode($parm = '')
{
    if (!defined('LANGLINKS_SEPARATOR')) {
        define('LANGLINKS_SEPARATOR', '&nbsp;|&nbsp;');
    }
    $tmp = explode('|', $parm, 2);
    $parm = $tmp[0];
    $parms = array();
    if (isset($tmp[1])) {
        parse_str($tmp[1], $parms);
    }
    // ignore Query string if required by parms or external code, false by default
    if (!defined('LANGLINKS_NOQUERY')) {
        define('LANGLINKS_NOQUERY', isset($parms['noquery']));
    }
    if (!defined('LANGLINKS_HOME')) {
        define('LANGLINKS_HOME', isset($parms['home']));
    }
    /*require_once(e_HANDLER.'language_class.php');
    	$slng = new language;*/
    $slng = e107::getLanguage();
    if (!empty($parm)) {
        $languageList = explode(',', $parm);
    } else {
        $languageList = $slng->installed();
        sort($languageList);
    }
    if (count($languageList) < 2) {
        return;
    }
    foreach ($languageList as $languageFolder) {
        $code = $slng->convert($languageFolder);
        $name = $slng->toNative($languageFolder);
        //$subdom = (isset($cursub[2])) ? $cursub[0] : '';
        if (e107::getPref('multilanguage_subdomain')) {
            $code = $languageFolder == e107::getPref('sitelanguage') ? 'www' : $code;
            if (LANGLINKS_HOME) {
                $link = str_replace($_SERVER['HTTP_HOST'], $code . '.' . e_DOMAIN, SITEURL);
            } else {
                $link = !LANGLINKS_NOQUERY ? str_replace($_SERVER['HTTP_HOST'], $code . '.' . e_DOMAIN, e_REQUEST_URL) : str_replace($_SERVER['HTTP_HOST'], $code . '.' . e_DOMAIN, e_REQUEST_SELF);
                // excludes query string
            }
        } else {
            // TODO - switch to elan=Language query when possible (now it'll break the old DOT query string format)
            if (LANGLINKS_HOME) {
                $link = SITEURL . '?elan=' . $code;
            } else {
                $e_QUERY = str_replace('[' . e_MENU . ']', "", e_QUERY);
                $link = !LANGLINKS_NOQUERY ? e_REQUEST_SELF . '?[' . $code . ']' . $e_QUERY : e_REQUEST_SELF . '?elan=' . $code;
            }
        }
        $class = $languageFolder == e_LANGUAGE ? 'languagelink_active' : 'languagelink';
        $ret[] = "\n<a class='{$class}' href='{$link}'>{$name}</a>";
    }
    return implode(LANGLINKS_SEPARATOR, $ret);
}
Пример #5
0
 function sc_cm_comment($parm = '')
 {
     $menu_pref = e107::getConfig('menu')->getPref();
     $tp = e107::getParser();
     $COMMENT = '';
     if ($menu_pref['comment_characters'] > 0) {
         $COMMENT = strip_tags($tp->toHTML($this->var['comment_comment'], TRUE, "emotes_off, no_make_clickable", "", e107::getPref('menu_wordwrap')));
         if ($tp->ustrlen($COMMENT) > $menu_pref['comment_characters']) {
             $COMMENT = $tp->text_truncate($COMMENT, $menu_pref['comment_characters'], '') . ($this->var['comment_url'] ? " <a href='" . $this->var['comment_url'] . "'>" : "") . defset($menu_pref['comment_postfix'], $menu_pref['comment_postfix']) . ($this->var['comment_url'] ? "</a>" : "");
         }
     }
     return $COMMENT;
 }
Пример #6
0
 function __construct()
 {
     // DO Not translate - debug info only.
     $log = e107::getAdminLog();
     if (E107_DEBUG_LEVEL > 0 || e107::getPref('developer')) {
         $dep = debug_backtrace(false);
         foreach ($dep as $d) {
             $log->addDebug("Deprecated ArrayStorage Class called by " . str_replace(e_ROOT, "", $d['file']) . " on line " . $d['line']);
         }
         $log->save('DEPRECATED', E_LOG_NOTICE, '', false, LOG_TO_ROLLING);
         e107::getMessage()->addDebug("Please remove references to <b>arraystorage_class.php</b> and use e107::serialize() and e107::unserialize() instead.");
     }
 }
Пример #7
0
 /**
  *	Send output to browser. 
  */
 function toHTML($code_text, $parm)
 {
     global $e107cache;
     $class = e107::getBB()->getClass('code');
     $pref = e107::getPref();
     $tp = e107::getParser();
     if ($pref['smiley_activate']) {
         if (!is_object($tp->e_emote)) {
             $tp->e_emote = new e_emoteFilter();
         }
         $code_text = $tp->e_emote->filterEmotesRev($code_text);
     }
     $search = array(E_NL, '&#092;', '&#036;', '&lt;');
     $replace = array("\r\n", "\\", '$', '<');
     $code_text = str_replace($search, $replace, $code_text);
     if (isset($pref['useGeshi']) && $pref['useGeshi'] && file_exists(e_PLUGIN . "geshi/geshi.php")) {
         $code_md5 = md5($code_text);
         if (!($CodeCache = $e107cache->retrieve('GeshiParsed_' . $code_md5))) {
             require_once e_PLUGIN . "geshi/geshi.php";
             if ($parm) {
                 $geshi = new GeSHi($code_text, $parm, e_PLUGIN . "geshi/geshi/");
             } else {
                 $geshi = new GeSHi($code_text, $pref['defaultLanGeshi'] ? $pref['defaultLanGeshi'] : 'php', e_PLUGIN . "geshi/geshi/");
             }
             $geshi->line_style1 = "font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;";
             $geshi->set_encoding('utf-8');
             $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
             $geshi->set_header_type(GESHI_HEADER_DIV);
             $CodeCache = $geshi->parse_code();
             $e107cache->set('GeshiParsed_' . $code_md5, $CodeCache);
         }
         $ret = "<code class='code_highlight code-box {$class}' style='unicode-bidi: embed; direction: ltr'>" . str_replace("&amp;", "&", $CodeCache) . "</code>";
     } else {
         $code_text = html_entity_decode($code_text, ENT_QUOTES, 'utf-8');
         $code_text = trim($code_text);
         $code_text = htmlspecialchars($code_text, ENT_QUOTES, 'utf-8');
         $srch = array('{', '}');
         $repl = array('&lbrace;', '&rbrace;');
         $code_text = str_replace($srch, $repl, $code_text);
         // avoid code getting parsed as templates or shortcodes.
         if ($parm == 'inline') {
             return "<code style='unicode-bidi: embed; direction: ltr'>" . $code_text . "</code>";
         }
         //	$highlighted_text = highlight_string($code_text, TRUE);
         // highlighted_text = str_replace(array("<code>","</code>"),"",$highlighted_text);
         $divClass = $parm ? $parm : 'code_highlight';
         $ret = "<pre class='prettyprint linenums " . $tp->toAttribute($divClass) . " code-box {$class}' style='unicode-bidi: embed; direction: ltr'>" . $code_text . "</pre>";
     }
     $ret = str_replace("[", "&#091;", $ret);
     return $ret;
 }
Пример #8
0
 function sc_cb_message($parm = '')
 {
     if ($this->var['cb_blocked']) {
         return CHATBOX_L6;
     }
     $pref = e107::getPref();
     $emotes_active = $pref['cb_emote'] ? 'USER_BODY, emotes_on' : 'USER_BODY, emotes_off';
     list($cb_uid, $cb_nick) = explode(".", $this->var['cb_nick'], 2);
     $cb_message = e107::getParser()->toHTML($this->var['cb_message'], false, $emotes_active, $cb_uid, $pref['menu_wordwrap']);
     return $cb_message;
     /*
     $replace[0] = "["; $replace[1] = "]";
     $search[0] = "&lsqb;"; $search[1] =  "&rsqb;";
     $cb_message = str_replace($search, $replace, $cb_message);
     */
 }
Пример #9
0
 function checkIncompatiblePlugins()
 {
     $mes = e107::getMessage();
     $installedPlugs = e107::getPref('plug_installed');
     $inCompatText = "";
     $incompatFolders = array_keys($this->incompat);
     foreach ($this->incompat as $folder => $version) {
         if (vartrue($installedPlugs[$folder]) && $version == $installedPlugs[$folder]) {
             $inCompatText .= "<li>" . $folder . " v" . $installedPlugs[$folder] . "</li>";
         }
     }
     if ($inCompatText) {
         $text = "<ul>" . $inCompatText . "</ul>";
         $mes->addWarning("The following plugins are not compatible with this version of e107 and should be uninstalled: " . $text . "<a class='btn' href='" . e_ADMIN . "plugin.php'>uninstall</a>");
     }
 }
Пример #10
0
 function e_emotefilter()
 {
     $pref = e107::getPref();
     if (!$pref['emotepack']) {
         $pref['emotepack'] = "default";
         save_prefs();
     }
     $this->emotes = e107::getConfig("emote")->getPref();
     if (!vartrue($this->emotes)) {
         return;
     }
     foreach ($this->emotes as $key => $value) {
         $value = trim($value);
         if ($value) {
             // Only 'activate' emote if there's a substitution string set
             $key = preg_replace("#!(\\w{3,}?)\$#si", ".\\1", $key);
             // Next two probably to sort out legacy issues - may not be required any more
             $key = preg_replace("#_(\\w{3})\$#", ".\\1", $key);
             $key = str_replace("!", "_", $key);
             $filename = e_IMAGE . "emotes/" . $pref['emotepack'] . "/" . $key;
             $fileloc = SITEURLBASE . e_IMAGE_ABS . "emotes/" . $pref['emotepack'] . "/" . $key;
             if (file_exists($filename)) {
                 if (strstr($value, " ")) {
                     $tmp = explode(" ", $value);
                     foreach ($tmp as $code) {
                         $this->search[] = " " . $code;
                         $this->search[] = "\n" . $code;
                         //TODO CSS class?
                         $this->replace[] = " <img src='" . $fileloc . "' alt='' style='vertical-align:middle; border:0' /> ";
                         $this->replace[] = "\n <img src='" . $fileloc . "' alt='' style='vertical-align:middle; border:0' /> ";
                     }
                     unset($tmp);
                 } else {
                     if ($value) {
                         $this->search[] = " " . $value;
                         $this->search[] = "\n" . $value;
                         //TODO CSS class?
                         $this->replace[] = " <img src='" . $filename . "' alt='' style='vertical-align:middle; border:0' /> ";
                         $this->replace[] = "\n <img src='" . $filename . "' alt='' style='vertical-align:middle; border:0' /> ";
                     }
                 }
             }
         } else {
             unset($this->emotes[$key]);
         }
     }
 }
Пример #11
0
 function render()
 {
     $tp = e107::getParser();
     $sql = e107::getDb('nfp');
     $pref = e107::getPref();
     $qry = $this->getQuery();
     if ($results = $sql->gen($qry)) {
         $text = "<ul>";
         while ($row = $sql->fetch()) {
             $datestamp = $tp->toDate($row['post_datestamp'], 'relative');
             $id = $row['thread_id'];
             $topic = $row['thread_datestamp'] == $row['post_datestamp'] ? '' : 'Re:';
             $topic .= strip_tags($tp->toHTML($row['thread_name'], true, 'emotes_off, no_make_clickable, parse_bb', '', $pref['menu_wordwrap']));
             $row['thread_sef'] = $this->forumObj->getThreadSef($row);
             if ($row['post_user_anon']) {
                 $poster = $row['post_user_anon'];
             } else {
                 if ($row['user_name']) {
                     $poster = "<a href='" . e107::getUrl()->create('user/profile/view', array('name' => $row['user_name'], 'id' => $row['post_user'])) . "'>{$row['user_name']}</a>";
                 } else {
                     $poster = '[deleted]';
                 }
             }
             $post = strip_tags($tp->toHTML($row['post_entry'], true, 'emotes_off, no_make_clickable', '', $pref['menu_wordwrap']));
             $post = $tp->text_truncate($post, $this->menuPref['characters'], $this->menuPref['postfix']);
             // Count previous posts for calculating proper (topic) page number for the current post.
             //	$postNum = $sql2->count('forum_post', '(*)', "WHERE post_id <= " . $row['post_id'] . " AND post_thread = " . $row['thread_id'] . " ORDER BY post_id ASC");
             //	$postPage = ceil($postNum / vartrue($this->plugPref['postspage'], 10)); // Calculate (topic) page number for the current post.
             //	$thread = $sql->retrieve('forum_thread', '*', 'thread_id = ' . $row['thread_id']); 	// Load thread for passing it to e107::url().
             // Create URL for post.
             // like: e107_plugins/forum/forum_viewtopic.php?f=post&id=1
             $url = e107::url('forum', 'topic', $row, array('query' => array('f' => 'post', 'id' => intval($row['post_id']))));
             $text .= "<li>";
             if ($this->menuPref['title']) {
                 $text .= "<a href='{$url}'>{$topic}</a><br />{$post}<br /><small class='text-muted muted'>" . LAN_FORUM_MENU_001 . " {$poster} {$datestamp}</small>";
             } else {
                 $text .= "<a href='{$url}'>" . LAN_FORUM_MENU_001 . "</a> {$poster} <small class='text-muted muted'>{$datestamp}</small><br />{$post}<br />";
             }
             $text .= "</li>";
         }
         $text .= "</ul>";
     } else {
         $text = LAN_FORUM_MENU_002;
     }
     $caption = varset($this->menuPref['caption'][e_LANGUAGE], $this->menuPref['caption']);
     e107::getRender()->tablerender($caption, $text, 'nfp_menu');
 }
Пример #12
0
 /**
  * Page Navigation
  * @example {PAGE_NAVIGATION: template=navdoc&auto=1} in your Theme template. 
  */
 function sc_page_navigation($parm = '')
 {
     //	$parm = eHelper::scParams($parm);
     $tmpl = e107::getCoreTemplate('chapter', vartrue($parm['template'], 'nav'), true, true);
     // always merge
     $template = $tmpl['showPage'];
     $request = $this->request;
     if ($request && is_array($request)) {
         switch ($request['action']) {
             case 'listBooks':
                 $parm['cbook'] = 'all';
                 $template = $tmpl['listBooks'];
                 if (e107::getPref('listBooks', false) == false) {
                     return false;
                 }
                 break;
             case 'listChapters':
                 $parm['cbook'] = $request['id'];
                 $template = $tmpl['listChapters'];
                 break;
             case 'listPages':
                 $parm['cchapter'] = $request['id'];
                 $template = $tmpl['listPages'];
                 break;
             case 'showPage':
                 $parm['cpage'] = $request['id'];
                 break;
         }
     }
     if ($parm) {
         $parm = http_build_query($parm, null, '&');
     } else {
         $parm = '';
     }
     $links = e107::getAddon('page', 'e_sitelink');
     $data = $links->pageNav($parm);
     if (isset($data['title']) && !vartrue($template['noAutoTitle'])) {
         // use chapter title
         $template['caption'] = $data['title'];
         $data = $data['body'];
     }
     if (empty($data)) {
         return;
     }
     return e107::getNav()->render($data, $template);
 }
Пример #13
0
 function profile($udata)
 {
     $pref = e107::getPref();
     if (!$pref['cb_user_addon']) {
         return array();
     }
     if (!($chatposts = e107::getRegistry('total_chatposts'))) {
         $chatposts = 0;
         // In case plugin not installed
         if (e107::isInstalled("chatbox_menu")) {
             $chatposts = e107::getDb()->count("chatbox");
         }
         e107::setRegistry('total_chatposts', $chatposts);
     }
     $perc = $chatposts > 0 ? round($udata['user_chats'] / $chatposts * 100, 2) : 0;
     $var = array(0 => array('label' => LAN_PLUGIN_CHATBOX_MENU_POSTS, 'text' => $udata['user_chats'] . " ( " . $perc . "% )"));
     return $var;
 }
Пример #14
0
 function create_code()
 {
     if ($user_func = e107::getOverride()->check($this, 'create_code')) {
         return call_user_func($user_func);
     }
     $pref = e107::getPref();
     $sql = e107::getDb();
     mt_srand((double) microtime() * 1000000);
     $maxran = 1000000;
     $rand_num = mt_rand(0, $maxran);
     $datekey = date("r");
     $rcode = hexdec(md5($_SERVER['HTTP_USER_AGENT'] . serialize($pref) . $rand_num . $datekey));
     $code = substr($rcode, 2, 6);
     $recnum = $this->random_number;
     $del_time = time() + 1200;
     $sql->db_Insert("tmp", "'{$recnum}',{$del_time},'{$code}'");
     return $recnum;
 }
Пример #15
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;
 }
Пример #16
0
/**
 * Print out upload form elements and/or process submitted uploads.
 * Your <form> tag must include: enctype='multipart/form-data' - in order to work.
 *
 * Example usage:
 * <code>
 * // Process uploaded file (sent by the form below), it'll print out message (if any)
 * if(isset($_POST['etrigger_uploadfiles']))
 * {
 * 		// NOTE: chmod permissions after upload are set to 0755
 * 		echo e107::getParser()->parseTemplate('{UPLOADFILE='.e_MEDIA.'public|process=1&upload_file_mask=jpg,jpeg,png,gif&upload_final_chmod=493}');
 * }
 *
 * // Render upload form
 * echo '<form action="'.e_SELF.'" enctype="multipart/form-data" method="post">';
 * echo e107::getParser()->parseTemplate('{UPLOADFILE='.e_MEDIA.'public|nowarn&trigger=etrigger_uploadfiles}');
 * echo '</form>';
 * </code>
 *
 * @todo Human readable *nix like permissions option (upload_final_chmod) e.g. 'rw-rw-r--' --> 0664, 'rwxrwxrwx' --> 0777
 *
 * @param string $parm upload_path|parameters (GET query format)
 * 	Available parameters:
 * 	- trigger [render] (string): name attribute of upload trigger button, default 'uploadfiles'
 * 	- name [render|processing] (string): name of upload (file) field, without array brackets ([]), default 'file_userfile'
 * 	- up_container [render] (string): the id attribute of upload container (containing upload field(s)), default 'up_container'
 * 	- up_row [render] (string): the id attribute of upload added fields (diuplicates), default 'upline'
 * 	- process [render|processing] ('0'|'1' boolean): main shortcode action, 0 - render markup, 1 - process uploaded files, default '0'
 *  - upload_file_mask [processing] (string): 'file_mask' parameter of process_uploaded_files() - comma-separated list of file types which if defined limits the allowed file types to those which are
 *  in both this list and the file specified by the 'filetypes' option. Enables restriction to, for example, image files. {@link process_uploaded_files()),
 *  default is empty string
 *  - upload_filetypes [processing] (string): 'filetypes' parameter of process_uploaded_files() - name of file containing list of valid file types, default is empty string
 * 	- upload_extra_file_types [processing] (string): 'extra_file_types' parameter of process_uploaded_files() - '0' (default) rejects totally unknown file extensions;
 *  '1' accepts totally unknown file extensions which are in $options['filetypes'] file; comma-separated list of additional permitted file extensions
 *	- upload_final_chmod [processing] (string): 'final_chmod' parameter of process_uploaded_files() - chmod() to be applied to uploaded files (0644 default).
 *	NOTE: you need to provide number with numerci base of decimal (as a string) which will be auto-converted to octal number
 *	Example: '493' --> 0755; '511' --> 0777
 *	- upload_max_upload_size [processing] (string): 'max_upload_size' parameter of process_uploaded_files() - maximum size of uploaded files in bytes,
 *	or as a string with a 'multiplier' letter (e.g. 16M) at the end, default is empty string
 *	- upload_overwrite [processing] ('0'|'1' boolean): 'overwrite' parameter of process_uploaded_files() - maximum number of files which can be uploaded - default is '0' (unlimited)
 *	- return_type [processing] ('0'|'message'|'result'): 'message' (default) - return messages (eMessage::render() method);
 *	'result' - return array generated by process_uploaded_files();
 *	'0' - return empty string;
 *	NOTE: upload messages are added to 'upload_shortcode' message namespace
 *	<code>
 *	// render messages manually (return_type=0)
 *	echo e107::getMessage()->render('upload_shortcode');
 *	// OR copy them to the default message namespace
 *	e107::getMessage()->moveStack('upload_shortcode', 'default');
 *	// Do something... and render all messages
 *	echo e107::getMessage()->render();
 *	<code>
 * @return mixed Based on 'return_type' parameter - string or uploaded array result
 */
function uploadfile_shortcode($parm)
{
    if (!FILE_UPLOADS) {
        return LAN_UPLOAD_SERVEROFF;
    }
    if (USER_AREA === TRUE && !check_class(e107::getPref('upload_class'))) {
        return LAN_DISABLED;
    }
    $parm = explode('|', $parm, 2);
    $path = $parm[0];
    if ($path && !is_writable($path)) {
        return LAN_UPLOAD_777 . " <b>" . str_replace("../", "", $path) . "</b>";
    }
    $parms = array();
    parse_str(varset($parm[1], ''), $parms);
    $parms = array_merge(array('trigger' => 'uploadfiles', 'name' => 'file_userfile', 'up_container' => 'up_container', 'up_row' => 'upline', 'process' => '0', 'upload_file_mask' => '', 'upload_filetypes' => '', 'upload_extra_file_types' => '0', 'upload_final_chmod' => '', 'upload_max_upload_size' => '0', 'upload_max_file_count' => '0', 'upload_overwrite' => '0', 'return_type' => 'message', 'disable_button' => '0'), $parms);
    // PROCESS UPLOADED FILES, optional usage by external code
    if ($parms['process']) {
        e107_require_once(e_HANDLER . 'upload_handler.php');
        $options = array('file_mask' => $parms['upload_file_mask'], 'filetypes' => $parms['upload_filetypes'], 'extra_file_types' => $parms['upload_extra_file_types'] ? true : false, 'final_chmod' => $parms['upload_final_chmod'] ? intval(intval($parms['upload_final_chmod']), 8) : 0644, 'max_upload_size' => $parms['upload_max_upload_size'], 'file_array_name' => $parms['name'], 'max_file_count' => $parms['upload_max_file_count'], 'overwrite' => $parms['upload_overwrite'] ? true : false);
        $uploaded = process_uploaded_files($path, false, $options);
        if ($uploaded) {
            $emessage = e107::getMessage();
            foreach ($uploaded as $finfo) {
                $emessage->addStack($finfo['message'], 'upload_shortcode', $finfo['error'] ? E_MESSAGE_ERROR : E_MESSAGE_SUCCESS);
            }
            if ($parms['return_type'] == 'message') {
                return $emessage->render('upload_shortcode');
            }
        }
        return $parms['return_type'] == 'result' ? $uploaded : '';
    }
    // RENDER FORM
    $onclickt = !isset($parms['nowarn']) ? " onclick=\"return jsconfirm('" . LAN_UPLOAD_CONFIRM . "')\"" : '';
    $onclickd = " onclick=\"duplicateHTML('{$parms['up_row']}','{$parms['up_container']}');\"";
    $name = $parms['name'] . '[]';
    $text .= "\n\t        <!-- Upload Shortcode -->\n\t\t\t<div>\n\t\t\t\t<div class='field-spacer'>\n\t\t\t\t\t<button class='action duplicate' type='button' value='no-value'{$onclickd}><span>" . LAN_UPLOAD_ADDFILE . "</span></button>";
    // Media Manager does the submit, not the shortcode.
    if (!$parms['disable_button']) {
        $text .= "<button class='upload' type='submit' name='{$parms['trigger']}' value='no-value'{$onclickt}><span>" . LAN_UPLOAD_FILES . "</span></button>";
    }
    $text .= "\n\t\t\t\t</div>\n\t\t\t\t<div id='{$parms['up_container']}'>\n\t\t\t\t\t<div id='{$parms['up_row']}' class='nowrap'>\n\t\t\t\t\t\t<input class='tbox file' type='file' name='{$name}' />\n\t\t\t        </div>\n\t\t\t\t</div>\n\t\t\t\t<div class='field-help'>Upload to: <strong>" . str_replace('../', '', $path) . "</strong></div>\n\t\t\t</div>\n\t\t\t<!-- End Upload Shortcode -->\n\t\t";
    return $text;
}
Пример #17
0
 function loadPlugin()
 {
     global $pref;
     $list = e107::getPref('e_tagwords_list');
     if ($list && is_array($list)) {
         foreach ($list as $e_tag) {
             if (is_readable(e_PLUGIN . $e_tag . "/e_tagwords.php")) {
                 require_once e_PLUGIN . $e_tag . "/e_tagwords.php";
                 $name = "e_tagwords_{$e_tag}";
                 if (class_exists($name)) {
                     if (!is_object($name)) {
                         $this->{$name} = new $name();
                     }
                     $this->tagwords[] = $e_tag;
                 }
             }
         }
     }
 }
Пример #18
0
 function __construct()
 {
     $pref = e107::getPref();
     $this->notify_prefs = e107::getConfig('notify')->getPref();
     $this->prefCleanup();
     $this->test();
     $recalibrate = FALSE;
     // load every e_notify.php file.
     if ($pref['e_notify_list']) {
         foreach ($pref['e_notify_list'] as $val) {
             $this->notify_prefs['plugins'][$val] = TRUE;
             if (is_readable(e_PLUGIN . $val . "/e_notify.php")) {
                 require_once e_PLUGIN . $val . '/e_notify.php';
                 if (class_exists($val . "_notify")) {
                     $legacy = 0;
                     // Newe.
                     $config_events = array();
                     $data = e107::callMethod($val . "_notify", 'config');
                     $config_category = str_replace("_menu", "", ucfirst($val)) . " Events";
                     foreach ($data as $v) {
                         $func = $v['function'];
                         $config_events[$func] = $v['name'];
                     }
                 } else {
                     $legacy = 1;
                     // Legacy Mode.
                 }
                 //		foreach ($config_events as $event_id => $event_text)
                 //   		{
                 //	$this -> notify_prefs['event'][$event_id] = array('class' => '255', 'email' => '', 'plugin'=> $val);
                 //		}
                 $this->pluginConfig[$val] = array('category' => $config_category, 'events' => $config_events, 'legacy' => $legacy);
                 $recalibrate = true;
             }
         }
     }
     //	print_a($this->pluginConfig);
     if ($recalibrate) {
         //	$s_prefs = $tp -> toDB($this -> notify_prefs);
         //	$s_prefs = $eArrayStorage -> WriteArray($s_prefs);
         //	$sql -> db_Update("core", "e107_value='".$s_prefs."' WHERE e107_name='notify_prefs'");
     }
 }
Пример #19
0
 public function actionTest()
 {
     echo '<h3>Social Login Tester</h3>';
     if (getperms('0')) {
         echo e107::getMessage()->addError("Please logout of e107 before testing the new-user login/signup procedure.")->render();
         return;
     }
     if (isset($_GET['lgt'])) {
         e107::getUser()->logout();
     }
     $profileData = null;
     $provider = e107::getUser()->getProvider();
     if ($provider) {
         $profileData = $provider->getUserProfile();
         if (!empty($profileData)) {
             print_a($profileData);
         }
     }
     echo 'Logged in: ' . (e107::getUser()->isUser() && !empty($profileData) ? '<span class="label label-success">true</span>' : '<span class="label label-danger">false</span>');
     $testUrl = SITEURL . "?route=system/xup/test";
     $providers = e107::getPref('social_login', array());
     foreach ($providers as $key => $var) {
         if ($var['enabled'] == 1) {
             echo '<h3>' . $key . '</h3><ul>';
             echo '<li><a class="btn btn-default" href="' . e107::getUrl()->create('system/xup/login?provider=' . $key . '&back=' . base64_encode($testUrl)) . '">Test login only with ' . $key . '</a></li>';
             echo '<li><a class="btn btn-default" href="' . e107::getUrl()->create('system/xup/signup?provider=' . $key . '&back=' . base64_encode($testUrl)) . '">Test signup/login with ' . $key . '</a></li>';
             echo "</ul>";
         }
         //	print_a($var);
     }
     echo '<br /><br /><a class="btn btn-default" href="' . e107::getUrl()->create('system/xup/test?lgt') . '">Test logout</a>';
     /*
     		echo '<h3>Facebook</h3>';
     		echo '<br /><a href="'.e107::getUrl()->create('system/xup/login?provider=Facebook').'">Test login with Facebook</a>';
     		echo '<br /><a href="'.e107::getUrl()->create('system/xup/signup?provider=Facebook').'">Test signup with Facebook</a>';
     		
     		echo '<h3>Twitter</h3>';
     		echo '<br /><a href="'.e107::getUrl()->create('system/xup/login?provider=Twitter').'">Test login with Twitter</a>';
     		echo '<br /><a href="'.e107::getUrl()->create('system/xup/signup?provider=Twitter').'">Test signup with Twitter</a>';
     */
 }
Пример #20
0
function usersearch_shortcode($parm)
{
    // FIXME - permissions, sql query
    if (!ADMIN || !e_AJAX_REQUEST) {
        return '<ul></ul>';
    }
    parse_str(str_replace('--', '&', $parm), $parm);
    $tp = e107::getParser();
    $sql = e107::getDb();
    $search_field = 'user_' . vartrue($parm['searchfld'], 'name');
    $info_field = $search_field == 'user_name' ? 'user_loginname' : 'user_name';
    $posted = $_POST[vartrue($parm['srcfld'], 'user_name')];
    if (!$posted) {
        return '<ul></ul>';
    }
    $allowed = array('user_id', 'user_name', 'user_loginname', 'user_customtitle', 'user_email');
    if (!in_array($search_field, $allowed)) {
        $search_field = 'user_name';
    }
    // search by email - based on site settings
    $emailSrch = '';
    if (e107::getPref('predefinedLoginName')) {
        if ($search_field != 'user_email') {
            $emailSrch = " OR user_email LIKE '" . $tp->toDb($posted) . "%'";
        }
    }
    $ret = "<ul>";
    $qry = "\n\t\tSELECT u.user_id, u.user_name, u.user_loginname, u.user_customtitle, u.user_email FROM #user AS u\n\t\tWHERE {$search_field} LIKE '" . $tp->toDb($posted) . "%'{$emailSrch}\n\t";
    if ($sql->db_Select_gen($qry)) {
        if ($emailSrch) {
            $info_field = 'user_email';
        }
        while ($row = $sql->db_Fetch()) {
            $ret .= "<li id='{$row['user_id']}'>{$row[$search_field]}<span class='informal'> [{$row['user_id']}] " . $row[$info_field] . $email . " </span></li>";
        }
    }
    $ret .= "</ul>";
    return $ret;
}
Пример #21
0
 function sc_contact_person($parm = '')
 {
     $tp = e107::getParser();
     $sql = e107::getDb();
     $pref = e107::getPref();
     if (varset($pref['sitecontacts']) == e_UC_ADMIN) {
         $query = "user_admin =1";
     } elseif (varset($pref['sitecontacts']) == e_UC_MAINADMIN) {
         $query = "user_admin = 1 AND (user_perms = '0' OR user_perms = '0.') ";
     } else {
         $query = "FIND_IN_SET(" . $pref['sitecontacts'] . ",user_class) ";
     }
     $text = "<select name='contact_person' class='tbox contact_person'>\n";
     $count = $sql->db_Select("user", "user_id,user_name", $query . " ORDER BY user_name");
     if ($count > 1) {
         while ($row = $sql->db_Fetch()) {
             $text .= "<option value='" . $row['user_id'] . "'>" . $row['user_name'] . "</option>\n";
         }
     } else {
         return;
     }
     $text .= "</select>";
     return $text;
 }
Пример #22
0
 /**
  * Register Plugin Shortcode Batch files (e_shortcode.php) for use site-wide.
  * Equivalent to multiple .sc files in the plugin's folder.
  *
  * @return e_parse_shortcode
  */
 protected function loadPluginShortcodes()
 {
     $pref = e107::getPref('e_shortcode_list');
     if (!$pref) {
         return $this;
     }
     foreach ($pref as $key => $val) {
         $globalOverride = $this->isBatchOverride($key . '_shortcodes');
         if ($globalOverride) {
             $path = e_CORE . 'override/shortcodes/batch/' . $key . '_shortcodes.php';
             $classFunc = 'override_' . $key . '_shortcodes';
         } else {
             $path = e_PLUGIN . $key . '/e_shortcode.php';
             $classFunc = $key . '_shortcodes';
         }
         if (!(include_once $path)) {
             // try to switch back to the batch origin in case it's an override
             if ($globalOverride) {
                 $path = e_PLUGIN . $key . '/e_shortcode.php';
                 $classFunc = $key . '_shortcodes';
                 if (!(include_once $path)) {
                     continue;
                 }
             } else {
                 continue;
             }
         }
         $this->registerClassMethods($classFunc, $path, false);
     }
     return $this;
 }
Пример #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', '');
     }
 }
Пример #24
0
     * Drawback: each update may cause all server times to display a bit different
     */
    echo "<script type='text/javascript'>\n";
    echo "\tSyncWithServerTime('', '{$_serverPath}', '{$_serverDomain}');\n";
    //tdOffset disabled as it can't live together with HTTP_IF_NONE_MATCH (page load speed)
    //echo "	SyncWithServerTime('{$_serverTime}', '{$_serverPath}', '{$_serverDomain}');\n";
    echo "</script>\n";
}
//
// H Final HTML
//
// browser cache control - FIXME - use this value as AJAX requests cache control!
// TODO - create the $bcache string via e107 class method, use it in the canCache() method
$uclist = e107::getUser()->getClassList();
sort($uclist, SORT_NUMERIC);
$bcache = (deftrue('e_NOCACHE') ? time() : e107::getPref('e_jslib_browser_cache')) . '.' . implode(',', $uclist);
echo "\n<!-- " . md5($bcache) . " -->\n";
unset($uclist, $bcache);
$show = deftrue('e_POWEREDBY_DISABLE') ? "none" : "block";
// Let search engines find us to increase e107.org ranking - even if hidden.
//XXX Must not contain IDs or Classes
// echo "<div style='text-align:center; display:".$show."; position: absolute; width:99%; height:20px; margin-top:-30px; z-index:30000; opacity:1.0; color: silver'>Proudly powered by <a style='color:silver' href='http://e107.org/' title='e107 Content Management System'>e107</a></div>";
unset($show);
echo "\n</body>\n</html>";
// Shutdown
$e107->destruct();
//
// I Send the buffered page data, along with appropriate headers
//
$page = ob_get_clean();
// New - see class2.php
Пример #25
0
 /**
  *	Update expiry time for IP addresses that have accessed the site while banned.
  *	Processes the entries in the 'ban retrigger' action file, and deletes the file
  *
  *	Needs to be called from a cron job, at least once per hour, and ideally every few minutes. Otherwise banned users who access
  *	the site in the period since the last call to this routine may be able to get in because their ban has expired. (Unlikely to be
  *	an issue in practice)
  *
  *	@return int number of IP addresses updated
  *
  *	@todo - implement cron job and test
  */
 public function banRetriggerAction()
 {
     //if (!e107::getPref('ban_retrigger')) return 0;		// Should be checked earlier
     $numEntry = 0;
     // Make sure this variable declared before passing it - total number of log entries.
     $ipAction = array();
     // Array of IP addresses to action
     $fileName = $this->ourConfigDir . eIPHandler::BAN_FILE_RETRIGGER_NAME . eIPHandler::BAN_FILE_EXTENSION;
     $entries = file($fileName);
     if (!is_array($entries)) {
         return 0;
         // Probably no retrigger actions
     }
     @unlink($fileName);
     // Delete the action file now we've read it in.
     // Scan the list completely before doing any processing - this will ensure we only process the most recent entry for each IP address
     while (count($entries) > 0) {
         $line = array_shift($entries);
         $info = $this->splitLogEntry($line);
         if ($info['banReason'] < 0) {
             $ipAction[$info['banIP']] = array('date' => $info['banDate'], 'reason' => $info['banReason']);
             // This will result in us gathering the most recent access from each IP address
         }
     }
     if (count($ipAction) == 0) {
         return 0;
     }
     // Nothing more to do
     // Now run through the database updating times
     $numRet = 0;
     $pref['ban_durations'] = e107::getPref('ban_durations');
     $ourDb = e107::getDB();
     // Should be able to use $sql, $sql2 at this point
     $writeDb = e107::getDB('sql2');
     foreach ($ipAction as $ipKey => $ipInfo) {
         if ($ourDb->select('banlist', '*', "`banlist_ip`='" . $ipKey . "'") === 1) {
             if ($row = $ourDb->fetch()) {
                 // @todo check next line
                 $writeDb->db_Update('banlist', '`banlist_banexpires` = ' . intval($row['banlist_banexpires'] + $pref['ban_durations'][$row['banlist_banreason']]));
                 $numRet++;
             }
         }
     }
     if ($numRet) {
         $this->writeBanListFiles('ip');
         // Just rewrite the ban list - the actual IP addresses won't have changed
     }
     return $numRet;
 }
Пример #26
0
 /**
  * Shortcodes - simple field getter (basic formatting)
  * THIS IS ONLY TEST, maybe useful for fields requiring simple formatting - it's a way too complicated for designers,
  * could be inner used inside the rest of news SCs.
  *
  * @param string $news_field name without the leading 'news_' prefix
  * @param mixed $default
  * @return string field value
  */
 public function sc_news_field($parm = '')
 {
     $tmp = explode('|', $parm, 2);
     $field = $tmp[0];
     if (!is_array($parm)) {
         parse_str(varset($tmp[1]), $parm);
     }
     $val = $this->field($field, '');
     //do more with $parm array, just an example here
     if (vartrue($parm['format'])) {
         switch ($parm['format']) {
             //USAGE: {NEWS_FIELD=body|format=html&arg=1,BODY} -> callback e107->toHTML($value, true, 'BODY');
             case 'html':
                 $method = 'toHTML';
                 $callback = e107::getParser();
                 $parm['arg'] = explode(',', varset($parm['arg']));
                 $parm['arg'][0] = vartrue($parm['arg'][0]) ? true : false;
                 //to boolean
                 $params = array($val);
                 //value is always the first callback argument
                 $params += $parm['arg'];
                 break;
                 //USAGE: {NEWS_FIELD=body|format=html_truncate&arg=200,...} -> callback e107->html_truncate($value, 200, '...');
             //USAGE: {NEWS_FIELD=body|format=html_truncate&arg=200,...} -> callback e107->html_truncate($value, 200, '...');
             case 'html_truncate':
                 $val = e107::getParser()->toHTML($val, true);
                 //USAGE: {NEWS_FIELD=title|format=text_truncate&arg=100,...} -> callback e107->text_truncate($value, 200, '...');
             //USAGE: {NEWS_FIELD=title|format=text_truncate&arg=100,...} -> callback e107->text_truncate($value, 200, '...');
             case 'text_truncate':
                 $method = $parm['format'];
                 $callback = e107::getParser();
                 $params = array($val);
                 //value is always the first callback argument
                 $params = array_merge($params, explode(',', $parm['arg']));
                 break;
                 //USAGE: {NEWS_FIELD=title|format=date} -> strftime($pref[shortdate], $value);
                 //USAGE: {NEWS_FIELD=title|format=date&arg=%Y} -> strftime('%Y', $value);
             //USAGE: {NEWS_FIELD=title|format=date} -> strftime($pref[shortdate], $value);
             //USAGE: {NEWS_FIELD=title|format=date&arg=%Y} -> strftime('%Y', $value);
             case 'date':
                 $method = $parm['format'];
                 $callback = e107::getParser();
                 $params = array($val);
                 //value is always the first callback argument
                 $params = array_merge($params, explode(',', $parm['arg']));
                 //should be done with date handler (awaiting for modifications)
                 return strftime(varset($parm['arg'], e107::getPref('shortdate')), $val);
                 break;
             default:
                 return $val;
                 break;
         }
         return call_user_func_array(array($callback, $method), $params);
     }
     return $val;
 }
Пример #27
0
 function setPageCookie()
 {
     if (!$this->pageID || !vartrue($_POST['page_pw'])) {
         return;
     }
     $pref = e107::getPref();
     $pref['pageCookieExpire'] = max($pref['pageCookieExpire'], 120);
     $hash = md5($_POST['page_pw'] . USERID);
     cookie($this->getCookieName(), $hash, time() + $pref['pageCookieExpire']);
     //header("location:".e_SELF."?".e_QUERY);
     //exit;
 }
Пример #28
0
function render_newscats()
{
    // --  CNN Style Categories. ----
    $tp = e107::getParser();
    $ns = e107::getRender();
    $pref = e107::getPref();
    if (isset($pref['news_cats']) && $pref['news_cats'] == '1') {
        $text3 = $tp->toHTML("{NEWS_CATEGORIES}", TRUE, 'TITLE');
        $ns->tablerender(LAN_NEWS_23, $text3, 'news_cat');
    }
}
Пример #29
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;
    }
}
Пример #30
0
 function render_infopanel_menu_options()
 {
     if (!getperms('0')) {
         return;
     }
     $frm = e107::getForm();
     $pref = e107::getPref();
     $text = "<div style='padding-left:20px'>";
     $menu_qry = 'SELECT * FROM #menus WHERE menu_id!= 0  GROUP BY menu_name ORDER BY menu_name';
     $settings = varset($pref['core-infopanel-menus'], array());
     if (e107::getDb()->db_Select_gen($menu_qry)) {
         while ($row = e107::getDb()->db_Fetch()) {
             $label = str_replace("_menu", "", $row['menu_name']);
             $path_to_menu = $row['menu_path'] . $row['menu_name'];
             $checked = $settings && in_array($path_to_menu, $settings) ? true : false;
             $text .= "\n<div class='left f-left list field-spacer' style='display:block;height:24px;width:200px;'>";
             $text .= $frm->checkbox_label($label, "e-mymenus[]", $path_to_menu, $checked);
             $text .= "</div>";
         }
     }
     $text .= "</div><div class='clear'>&nbsp;</div>";
     return $text;
 }