/**
  * Loops through the authorization array
  * 
  */
 public function loop($array = null)
 {
     //reasons to fail
     if (is_null($array)) {
         return false;
     }
     if (!is_array($array)) {
         return false;
     }
     //Populating class properties
     $user =& JFactory::getUser();
     if ($user->guest) {
         $user->usertype = 'Public';
     }
     foreach ($array as $group => $pages) {
         foreach ($pages as $page) {
             //reasons to continue
             if (strlen(trim($group)) < 1) {
                 continue;
             }
             if (strlen(trim($page)) < 1) {
                 continue;
             }
             eHelper::eb_acl($page, $group);
         }
     }
     return true;
 }
Пример #2
0
 function sc_faq_question($parm = '')
 {
     $tp = e107::getParser();
     $parm = eHelper::scDualParams($parm);
     $param = $parm[1];
     $params = $parm[2];
     $new = e107::pref('faqs', 'new', 3);
     $newDate = strtotime($new . " days ago");
     $faqNew = $this->var['faq_datestamp'] > $newDate ? " faq-new" : "";
     if ($param == 'expand' && !empty($this->var['faq_answer'])) {
         $id = "faq_" . $this->var['faq_id'];
         $url = e107::url('faqs', 'item', $this->var, 'full');
         $question = $tp->toHTML($this->var['faq_question'], true, 'TITLE');
         $hide = $this->item != $this->var['faq_id'] ? 'e-hideme' : '';
         $text = "\n\t\t\t<a class='e-expandit faq-question{$faqNew}' href='#{$id}'>" . $question . "</a>\n\t\t\t<div id='{$id}' class='" . $hide . " faq-answer faq_answer clearfix {$faqNew}'>";
         $text .= $tp->toHTML($this->var['faq_answer'], true, 'BODY');
         $text .= "<div class='faq-extras'>";
         if (vartrue($params['tags']) && $this->var['faq_tags']) {
             $text .= "<div class='faq-tags'>" . LAN_FAQS_TAGS . ": " . $this->sc_faq_tags() . "</div>";
         }
         if ($this->datestamp == true) {
             $text .= "<div class='faq-datestamp'>" . $tp->toDate($this->var['faq_datestamp']) . "</div>";
         }
         if ($this->share == true) {
             $text .= "<div class='faq-share'>" . $tp->parseTemplate("{SOCIALSHARE: size=xs&type=basic&url=" . $url . "&title=" . $question . "&tags=" . $this->var['faq_tags'] . "}", true) . "</div>";
         }
         $text .= "</div></div>\n\t\t\t";
     } else {
         $text = $tp->toHTML($this->var['faq_question'], true, 'BODY');
     }
     return $text;
 }
Пример #3
0
 function compile($row)
 {
     $tp = e107::getParser();
     $res = array();
     $datestamp = $tp->toDate($row['thread_datestamp'], "long");
     if ($row['thread_parent']) {
         $title = $row['parent_name'];
     } else {
         $title = $row['thread_name'];
     }
     $link_id = $row['thread_id'];
     $uparams = array('id' => $row['user_id'], 'name' => $row['user_name']);
     $link = e107::getUrl()->create('user/profile/view', $uparams);
     $userlink = "<a href='" . $link . "'>" . $row['user_name'] . "</a>";
     $row['thread_sef'] = eHelper::title2sef($row['thread_name'], 'dashl');
     $forumTitle = "<a href='" . e107::url('forum', 'forum', $row) . "'>" . $row['forum_name'] . "</a>";
     $res['link'] = e107::url('forum', 'topic', $row, array('query' => array('f' => 'post', 'id' => $row['post_id'])));
     // e_PLUGIN."forum/forum_viewtopic.php?".$link_id.".post";
     $res['pre_title'] = '';
     // $title ? FOR_SCH_LAN_5.": " : "";
     $res['title'] = $title ? $forumTitle . " | " . $title : LAN_SEARCH_9;
     $res['pre_summary'] = "";
     $res['summary'] = $row['post_entry'];
     $res['detail'] = LAN_SEARCH_7 . $userlink . LAN_SEARCH_8 . $datestamp;
     return $res;
 }
Пример #4
0
 /**
  *	Translate to <p> tag
  */
 function toHTML($code_text, $parm)
 {
     if ($parm && !strpos($parm, '=')) {
         $parm = 'class=' . $parm;
     }
     $code_text = trim($code_text);
     $parms = eHelper::scParams($parm);
     $class = " " . e107::getBB()->getClass('p');
     // consistent classes across all themes.
     $id = varsettrue($parms['id']) ? ' id="' . eHelper::secureIdAttr($parms['id']) . '"' : '';
     $style = varsettrue($parms['style']) ? ' style="' . eHelper::secureStyleAttr($parms['style']) . '"' : '';
     return "<p{$id}{$class}{$style}>" . $code_text . '</p>';
 }
Пример #5
0
 /**
  * Busca o id da categoria/tag PAI
  *
  * @param integer $idcomponente
  * @param integer $idstart
  * @param boolean $tree
  * @param string  [categorias | tags]
  * @return object/JCRUD
  */
 function busca_categorias_tags_pai($idcomponente, $idstart = 0, $tabela = 'categorias')
 {
     $tb = $tabela == 'categorias' ? ECOMP_TABLE_CATEGORIAS : ECOMP_TABLE_TAGS;
     $t = new JCRUD($tb);
     $a = $t->busca("WHERE idcomponente = '{$idcomponente}' AND id = '{$idstart}'");
     if ($a->idpai != 0) {
         $tt = $t->busca("WHERE idcomponente = '{$idcomponente}' AND idpai = '{$idstart}'");
         foreach ($tt as $tr) {
             $a = eHelper::busca_categorias_tags_pai($idcomponente, $tr->id, $tabela);
         }
     }
     return $a->id;
 }
Пример #6
0
/**
 * Example usage (valid news data + option for full URL)
 * {URL=news/view/item|news_id=1&news_sef=sef-string&category_id=1&category_sef=category-sef&options[full]=1}
 */
function url_shortcode($parm)
{
    list($route, $parms) = eHelper::scDualParams($parm);
    if (empty($route)) {
        return '';
    }
    $options = array();
    if (isset($parms['options'])) {
        $options = $parms['options'];
        unset($parms['options']);
    }
    return e107::getUrl()->create($route, $parms, $options);
}
Пример #7
0
 /**
  *	Translate youtube bbcode into the appropriate HTML
  */
 function toHTML($code_text, $parm)
 {
     // transform to class, equal sign at 0 position is not well formed parm string
     if ($parm && !strpos($parm, '=')) {
         $parm = 'class=' . $parm;
     }
     $parms = eHelper::scParams($parm);
     $class = " " . e107::getBB()->getClass('block');
     $id = varsettrue($parms['id']) ? ' id=' . eHelper::secureIdAttr($parms['id']) : '';
     $style = varsettrue($parms['style']) ? ' style="' . eHelper::secureStyleAttr($parms['style']) . '"' : '';
     if (empty($code_text)) {
         $code_text = '<!-- -->';
     }
     return '<div' . $id . $class . $style . '>' . $code_text . '</div>';
 }
Пример #8
0
 /**
  *	Translate to <h*> tag
  */
 function toHTML($code_text, $parm)
 {
     $code_text = trim($code_text);
     if (empty($code_text)) {
         return '';
     }
     $bparms = eHelper::scDualParams($parm);
     $h = 'h' . ($bparms[1] ? intval($bparms[1]) : 2);
     $parms = $bparms[2];
     unset($bparms);
     $class = " " . e107::getBB()->getClass('h2');
     // consistent classes across all themes.
     $id = varsettrue($parms['id']) ? ' id=' . eHelper::secureIdAttr($parms['id']) : '';
     $style = varsettrue($parms['style']) ? ' style="' . eHelper::secureStyleAttr($parms['style']) . '"' : '';
     return "<{$h}{$id}{$class}{$style}>" . $code_text . "</{$h}>";
 }
Пример #9
0
 function toDB($code_text, $parm)
 {
     $parms = eHelper::scParams($parm);
     $safe = array();
     if (vartrue($parms['class'])) {
         $safe['class'] = eHelper::secureClassAttr($parms['class']);
     }
     if (vartrue($parms['id'])) {
         $safe['id'] = eHelper::secureIdAttr($parms['id']);
     }
     if (vartrue($parms['style'])) {
         $safe['style'] = eHelper::secureStyleAttr($parms['style']);
     }
     if ($safe) {
         return '[img ' . eHelper::buildAttr($safe) . ']' . $code_text . '[/img]';
     }
     return '[img]' . $code_text . '[/img]';
 }
Пример #10
0
 function upgrade_post($var)
 {
     $db = e107::getDb();
     $currentVersion = $var->current_plug['plugin_version'];
     if ($currentVersion == '1.0') {
         /* to fill SEF URL FOR categories*/
         $db = e107::getDb();
         if ($allRows = $db->retrieve('SELECT * FROM #links_page_cat', TRUE)) {
             foreach ($allRows as $row) {
                 $id = $row["link_category_id"];
                 $where = 'link_category_id = ' . $id;
                 $update = array('link_category_sef' => eHelper::title2sef($row['link_category_name']), 'WHERE' => $where);
                 $db->update('links_page_cat', $update);
             }
         }
         /* to set all existing links as active */
         $db = e107::getDb('links_page');
         $update = array('link_active' => 1);
         $db->update('links_page', $update);
     }
 }
Пример #11
0
 /**
  * Insert a new thread or a reply/quoted reply.
  */
 function insertPost()
 {
     $postInfo = array();
     $threadInfo = array();
     $threadOptions = array();
     $fp = new floodprotect();
     if (isset($_POST['newthread']) && trim($_POST['subject']) == '' || trim($_POST['post']) == '') {
         message_handler('ALERT', 5);
     } else {
         if ($fp->flood('forum_thread', 'thread_datestamp') == false && !ADMIN) {
             echo "<script type='text/javascript'>document.location.href='" . e_BASE . "index.php'</script>\n";
             exit;
         }
         $hasPoll = $this->action == 'nt' && varset($_POST['poll_title']) && $_POST['poll_option'][0] != '' && $_POST['poll_option'][1] != '';
         if (USER) {
             $postInfo['post_user'] = USERID;
             $threadInfo['thread_lastuser'] = USERID;
             $threadInfo['thread_user'] = USERID;
             $threadInfo['thread_lastuser_anon'] = '';
         } else {
             $postInfo['post_user_anon'] = $_POST['anonname'];
             $threadInfo['thread_lastuser_anon'] = $_POST['anonname'];
             $threadInfo['thread_user_anon'] = $_POST['anonname'];
         }
         $time = time();
         $postInfo['post_entry'] = $_POST['post'];
         $postInfo['post_forum'] = $this->data['forum_id'];
         $postInfo['post_datestamp'] = $time;
         $postInfo['post_ip'] = e107::getIPHandler()->getIP(FALSE);
         $threadInfo['thread_lastpost'] = $time;
         if (isset($_POST['no_emote'])) {
             $postInfo['post_options'] = serialize(array('no_emote' => 1));
         }
         //If we've successfully uploaded something, we'll have to edit the post_entry and post_attachments
         $newValues = array();
         if ($uploadResult = $this->processAttachments()) {
             foreach ($uploadResult as $ur) {
                 //$postInfo['post_entry'] .= $ur['txt'];
                 //	$_tmp = $ur['type'].'*'.$ur['file'];
                 //	if($ur['thumb']) { $_tmp .= '*'.$ur['thumb']; }
                 //	if($ur['fname']) { $_tmp .= '*'.$ur['fname']; }
                 $type = $ur['type'];
                 $newValues[$type][] = $ur['file'];
                 // $attachments[] = $_tmp;
             }
             //	$postInfo['_FIELD_TYPES']['post_attachments'] = 'array';
             $postInfo['post_attachments'] = e107::serialize($newValues);
             //FIXME XXX - broken encoding when saved to DB.
         }
         //		var_dump($uploadResult);
         switch ($this->action) {
             // Reply only.  Add the post, update thread record with latest post info.
             // Update forum with latest post info
             case 'rp':
                 $postInfo['post_thread'] = $this->id;
                 $newPostId = $this->forumObj->postAdd($postInfo);
                 break;
                 // New thread started.  Add the thread info (with lastest post info), add the post.
                 // Update forum with latest post info
             // New thread started.  Add the thread info (with lastest post info), add the post.
             // Update forum with latest post info
             case 'nt':
                 $threadInfo['thread_sticky'] = MODERATOR ? (int) $_POST['threadtype'] : 0;
                 $threadInfo['thread_name'] = $_POST['subject'];
                 $threadInfo['thread_forum_id'] = $this->id;
                 $threadInfo['thread_active'] = 1;
                 $threadInfo['thread_datestamp'] = $time;
                 if ($hasPoll) {
                     $threadOptions['poll'] = '1';
                 }
                 if (is_array($threadOptions) && count($threadOptions)) {
                     $threadInfo['thread_options'] = serialize($threadOptions);
                 } else {
                     $threadInfo['thread_options'] = '';
                 }
                 if ($postResult = $this->forumObj->threadAdd($threadInfo, $postInfo)) {
                     $newPostId = $postResult['postid'];
                     $newThreadId = $postResult['threadid'];
                     $this->data['thread_id'] = $newThreadId;
                     //	$this->data['thread_sef'] = $postResult['threadsef'];
                     $this->data['thread_sef'] = eHelper::title2sef($threadInfo['thread_name'], 'dashl');
                     if ($_POST['email_notify']) {
                         $this->forumObj->track('add', USERID, $newThreadId);
                     }
                 }
                 break;
         }
         e107::getMessage()->addDebug(print_a($postInfo, true));
         //	e107::getMessage()->addDebug(print_a($this,true));
         if ($postResult === -1 || $newPostId === -1) {
             require_once HEADERF;
             $message = LAN_FORUM_3006 . "<br ><a class='btn btn-default' href='" . $_SERVER['HTTP_REFERER'] . "'>Return</a>";
             $text = e107::getMessage()->addError($message)->render();
             e107::getRender()->tablerender(LAN_PLUGIN_FORUM_NAME, $text);
             // change to forum-title pref.
             require_once FOOTERF;
             exit;
         }
         $threadId = $this->action == 'nt' ? $newThreadId : $this->id;
         //If a poll was submitted, let's add it to the poll db
         if ($this->action == 'nt' && varset($_POST['poll_title']) && $_POST['poll_option'][0] != '' && $_POST['poll_option'][1] != '') {
             require_once e_PLUGIN . 'poll/poll_class.php';
             $_POST['iid'] = $threadId;
             $poll = new poll();
             $poll->submit_poll(2);
         }
         e107::getCache()->clear('newforumposts');
         //	$postInfo = $this->forumObj->postGet($newPostId, 'post');
         //	$forumInfo = $this->forumObj->forumGet($postInfo['post_forum']);
         //	$threadLink = e107::getUrl()->create('forum/thread/last', $postInfo);
         // 	$forumLink = e107::getUrl()->create('forum/forum/view', $forumInfo);
         $threadLink = e107::url('forum', 'topic', $this->data, 'full') . "&amp;last=1";
         $forumLink = e107::url('forum', 'forum', $this->data);
         if ($this->forumObj->prefs->get('redirect')) {
             $this->redirect($threadLink);
             //	header('location:'.e107::getUrl()->create('forum/thread/last', $postInfo, array('encode' => false, 'full' => true)));
             exit;
         } else {
             require_once HEADERF;
             $template = $this->getTemplate('posted');
             $SHORTCODES = array('THREADLINK' => $threadLink, 'FORUMLINK' => $forumLink);
             $txt = isset($_POST['newthread']) ? $template['thread'] : $template['reply'];
             $txt = e107::getParser()->parseTemplate($txt, true, $SHORTCODES);
             e107::getRender()->tablerender('Forums', e107::getMessage()->render() . $txt);
             require_once FOOTERF;
             exit;
         }
     }
 }
Пример #12
0
 /**
  * All possible parameters
  * {GALLERY_SLIDES=4|limit=16&template=MY_SLIDESHOW_SLIDE_ITEM}
  * first parameter is always number of slides, default is 3
  * limit - (optional) total limit of pcitures to be shown
  * template - (optional) template - name of template to be used for parsing the slideshow item
  */
 function sc_gallery_slides($parm)
 {
     $tp = e107::getParser();
     $this->slideMode = TRUE;
     $parms = eHelper::scDualParams($parm);
     $amount = $parms[1] ? intval($parms[1]) : 3;
     // vartrue(e107::getPlugPref('gallery','slideshow_perslide'),3);
     $parms = $parms[2];
     $limit = (int) vartrue($parms['limit'], 16);
     $list = e107::getMedia()->getImages('gallery_' . $this->sliderCat . '|gallery_image_' . $this->sliderCat, 0, $limit);
     $tmpl = e107::getTemplate('gallery', 'gallery');
     $tmpl = array_change_key_case($tmpl);
     // change template key to lowercase (BC fix)
     $tmpl_key = vartrue($parms['template'], 'slideshow_slide_item');
     $item_template = $tmpl[$tmpl_key];
     // e107::getTemplate('gallery','gallery', vartrue($parms['template'], 'SLIDESHOW_SLIDE_ITEM'));
     $catList = e107::getMedia()->getCategories('gallery');
     $cat = $catList['gallery_' . $this->sliderCat];
     $count = 1;
     foreach ($list as $row) {
         $this->setVars($row)->addVars($cat);
         $inner .= $count == 1 ? "\n\n<!-- SLIDE " . $count . " -->\n<div class='slide' id='gallery-item-" . $this->slideCount . "'>\n" : "";
         $inner .= "\n\t" . $tp->parseTemplate($item_template, TRUE) . "\n";
         $inner .= $count == $amount ? "\n</div>\n\n" : "";
         if ($count == $amount) {
             $count = 1;
             $this->slideCount++;
         } else {
             $count++;
         }
     }
     $inner .= $count != 1 ? "</div><!-- END SLIDES -->" : "";
     return $inner;
 }
Пример #13
0
 function view_all_query($srch = '')
 {
     $sql = e107::getDb();
     $tp = e107::getParser();
     $text = "";
     $insert = "";
     $item = false;
     $removeUrl = e107::url('faqs', 'index');
     if (!empty($srch)) {
         $srch = $tp->toDB($srch);
         $insert = " AND (f.faq_question LIKE '%" . $srch . "%' OR f.faq_answer LIKE '%" . $srch . "%' OR FIND_IN_SET ('" . $srch . "', f.faq_tags) ) ";
         $message = "<span class='label label-lg label-info'>" . $srch . " <a class='e-tip' title='Remove' href='" . $removeUrl . "'>×</a></span>";
         e107::getMessage()->setClose(false, E_MESSAGE_INFO)->setTitle(LAN_FAQS_FILTER_ACTIVE, E_MESSAGE_INFO)->addInfo($message);
         $text = e107::getMessage()->render();
     }
     if (!empty($_GET['id'])) {
         $srch = intval($_GET['id']);
         //	$insert = " AND (f.faq_id = ".$srch.") ";
         $item = $srch;
     }
     if (!empty($_GET['cat'])) {
         $srch = $tp->toDB($_GET['cat']);
         $insert = " AND (cat.faq_info_sef = '" . $srch . "') ";
     }
     if (!empty($_GET['tag'])) {
         $srch = $tp->toDB($_GET['tag']);
         $insert = " AND FIND_IN_SET ('" . $srch . "', f.faq_tags)  ";
         $message = "<span class='label label-lg label-info'>" . $srch . " <a class='e-tip' title='Remove' href='" . $removeUrl . "'>×</a></span>";
         e107::getMessage()->setClose(false, E_MESSAGE_INFO)->setTitle(LAN_FAQS_FILTER_ACTIVE, E_MESSAGE_INFO)->addInfo($message);
         $text = e107::getMessage()->render();
     }
     list($orderBy, $ascdesc) = explode('-', vartrue($this->pref['orderby'], 'faq_order-ASC'));
     $query = "SELECT f.*,cat.* FROM #faqs AS f LEFT JOIN #faqs_info AS cat ON f.faq_parent = cat.faq_info_id WHERE cat.faq_info_class IN (" . USERCLASS_LIST . ") " . $insert . " ORDER BY cat.faq_info_order, f." . $orderBy . " " . $ascdesc . " ";
     if (!$sql->gen($query)) {
         $message = !empty($srch) ? "<b>" . $srch . "</b> was not found in search results. <a class='e-tip' title='Reset' href='" . $removeUrl . "'>Reset</a>" : LAN_FAQS_NONE_AVAILABLE;
         return "<div class='alert alert-warning alert-block'>" . $message . "</div>";
         //TODO LAN
     }
     // -----------------
     $FAQ_LISTALL = e107::getTemplate('faqs', true, 'all');
     $prevcat = "";
     $sc = e107::getScBatch('faqs', true);
     $sc->counter = 1;
     $sc->tag = htmlspecialchars($tag, ENT_QUOTES, 'utf-8');
     $sc->category = $category;
     if (!empty($_GET['id'])) {
         $sc->item = intval($_GET['id']);
         $js = "\n\t\t\t\t\$( document ).ready(function() {\n                    \$('html, body').animate({ scrollTop:  \$('div#faq_" . $sc->item . "').offset().top - 300 }, 4000);\n\t\t\t\t});\n\n\t\t\t\t";
         e107::js('footer-inline', $js);
     }
     //	$text = $tp->parseTemplate($FAQ_START, true, $sc);
     //	$text = "";
     if ($this->pref['list_type'] == 'ol') {
         $reversed = $ascdesc == 'DESC' ? 'reversed ' : '';
         $tsrch = array('<ul ', '/ul>');
         $trepl = array('<ol ' . $reversed, '/ol>');
         $FAQ_LISTALL['start'] = str_replace($tsrch, $trepl, $FAQ_LISTALL['start']);
         $FAQ_LISTALL['end'] = str_replace($tsrch, $trepl, $FAQ_LISTALL['end']);
     }
     while ($rw = $sql->fetch()) {
         $rw['faq_sef'] = eHelper::title2sef($tp->toText($rw['faq_question']), 'dashl');
         $sc->setVars($rw);
         if ($sc->item == $rw['faq_id']) {
             $this->pageTitle = $rw['faq_question'];
             $this->pageDescription = $rw['faq_answer'];
         }
         if ($rw['faq_info_order'] != $prevcat) {
             if ($prevcat != '') {
                 $text .= $tp->parseTemplate($FAQ_LISTALL['end'], true, $sc);
             }
             $text .= "\n\n<!-- FAQ Start " . $rw['faq_info_order'] . "-->\n\n";
             $text .= $tp->parseTemplate($FAQ_LISTALL['start'], true, $sc);
             $start = TRUE;
         }
         $text .= $tp->parseTemplate($FAQ_LISTALL['item'], true, $sc);
         $prevcat = $rw['faq_info_order'];
         $sc->counter++;
     }
     $text .= $start ? $tp->parseTemplate($FAQ_LISTALL['end'], true, $sc) : "";
     //		$text .= $tp->parseTemplate($FAQ_END, true, $sc);
     return $text;
 }
Пример #14
0
function step5()
{
    $sql = e107::getDb();
    $ns = e107::getRender();
    $mes = e107::getMessage();
    $stepCaption = 'Step 5: Migrate forum data';
    if (!isset($_POST['move_forum_data'])) {
        $text = "This step will copy all of your forum configuration from the `forum` table into the `forum_new` table.<br />\n\t\tOnce the information is successfully copied, the existing 1.0 forum table will be renamed `forum_old` and the newly created `forum_new` table will be renamed `forum`.<br />\n\t\t<br /><br />";
        $text .= "\n\t\t<form method='post'>\n\t\t<input class='btn btn-success' data-loading-text='Please wait...' type='submit' name='move_forum_data' value='Proceed with forum data move' />\n\t\t</form>\n\t\t";
        $ns->tablerender($stepCaption, $mes->render() . $text);
        return;
    }
    $counts = array('parents' => 0, 'forums' => 0, 'subs' => 0);
    //XXX Typo on 'parents' ?
    if ($sql->select('forum')) {
        $forumList = $sql->db_getList();
        foreach ($forumList as $forum) {
            if ($forum['forum_parent'] == 0) {
                $counts['parents']++;
            } elseif ($forum['forum_sub'] != 0) {
                $counts['subs']++;
            } else {
                $counts['forums']++;
            }
            $tmp = $forum;
            $tmp['forum_threadclass'] = $tmp['forum_postclass'];
            $tmp['forum_options'] = '_NULL_';
            $tmp['forum_sef'] = eHelper::title2sef($forum['forum_name'], 'dashl');
            //			$tmp['_FIELD_TYPES'] = $ftypes['_FIELD_TYPES'];
            if ($sql->insert('forum_new', $tmp)) {
            } else {
                $mes->addError("Insert failed on " . print_a($tmp, true));
            }
        }
    } else {
        $counts = array('parents' => 'n/a', 'forums' => 'n/a', 'subs' => 'n/a');
    }
    $mes->addSuccess("\n\t\tForum data move results:\n\t\t<ul>\n\t\t<li>Number of forum parents processed: {$counts['parents']} </li>\n\t\t<li>Number of forums processed: {$counts['forums']} </li>\n\t\t<li>Number of sub forums processed: {$counts['subs']} </li>\n\t\t</ul>\n\t\t");
    $result = $sql->gen('RENAME TABLE `#forum`  TO `#forum_old` ') ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
    $mes->add("Renaming forum to forum_old", $result);
    $result = $sql->gen('RENAME TABLE `#forum_new`  TO `#forum` ') ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
    $mes->add("Renaming forum_new to forum", $result);
    $text = "\n\t\t<form method='post' action='" . e_SELF . "?step=6'>\n\t\t<input class='btn btn-success' type='submit' name='nextStep[6]' value='Proceed to step 6' />\n\t\t</form>\n\t\t";
    $ns->tablerender($stepCaption, $mes->render() . $text);
}
Пример #15
0
 /**
  * Create a user Media-Category.
  * @param $type string image | file | video
  * @param $userId int - leave empty for currently logged in user.
  * @param $userName string - leave blank for currently logged in user
  * @param $parms (optional) - for future use.
  * @return bool|int
  */
 public function createUserCategory($type = 'image', $userId = USERID, $userName = USERNAME, $parms = null)
 {
     if ($type != 'image' && ($type = 'file' && $type != 'video')) {
         return false;
     }
     $cat = 'user_' . $type . '_' . intval($userId);
     if (!e107::getDb()->gen('SELECT media_cat_id FROM #core_media_cat WHERE media_cat_category = "' . $cat . '" LIMIT 1')) {
         $insert = array('owner' => 'user', 'category' => $cat, 'title' => $userName, 'sef' => 'media-' . eHelper::title2sef($userName), 'diz' => '', 'class' => '', 'image' => '', 'order' => '');
         return $this->createCategory($insert);
     }
     return false;
 }
Пример #16
0
 function submit_item($news, $smessages = false)
 {
     $tp = e107::getParser();
     $sql = e107::getDb();
     $admin_log = e107::getAdminLog();
     $pref = e107::getPref();
     $e_event = e107::getEvent();
     $e107cache = e107::getCache();
     $emessage = e107::getMessage();
     $error = false;
     if (empty($news['news_title'])) {
         $error = true;
         $emessage->add('Validation error: News title can\'t be empty!', E_MESSAGE_ERROR, $smessages);
         if (!empty($news['news_sef'])) {
             $news['news_sef'] = eHelper::secureSef($news['news_sef']);
         }
     } else {
         // first format sef...
         if (empty($news['news_sef'])) {
             $news['news_sef'] = eHelper::title2sef($news['news_title']);
         } else {
             $news['news_sef'] = eHelper::secureSef($news['news_sef']);
         }
     }
     // ...then check it
     if (empty($news['news_sef'])) {
         $error = true;
         $emessage->add('Validation error: News SEF URL value is required field and can\'t be empty!', E_MESSAGE_ERROR, $smessages);
     } elseif ($sql->db_Count('news', '(news_id)', ($news['news_sef'] ? 'news_id<>' . intval($news['news_id']) . ' AND ' : '') . "news_sef='" . $tp->toDB($news['news_sef']) . "'")) {
         $error = true;
         $emessage->add('Validation error: News SEF URL is unique field - current value already in use! Please choose another SEF URL value.', E_MESSAGE_ERROR, $smessages);
     }
     if (empty($news['news_category'])) {
         $error = true;
         $emessage->add('Validation error: News category can\'t be empty!', E_MESSAGE_ERROR, $smessages);
     }
     $data = array();
     //DB Array
     $data['data']['news_title'] = $news['news_title'];
     $data['_FIELD_TYPES']['news_title'] = 'todb';
     $data['data']['news_sef'] = $news['news_sef'];
     $data['_FIELD_TYPES']['news_sef'] = 'todb';
     $data['data']['news_body'] = $news['news_body'];
     $data['_FIELD_TYPES']['news_body'] = 'todb';
     $data['data']['news_extended'] = $news['news_extended'];
     $data['_FIELD_TYPES']['news_extended'] = 'todb';
     $data['data']['news_datestamp'] = $news['news_datestamp'];
     $data['_FIELD_TYPES']['news_datestamp'] = 'int';
     $data['data']['news_author'] = $news['news_author'] ? $news['news_author'] : USERID;
     $data['_FIELD_TYPES']['news_author'] = 'int';
     $data['data']['news_category'] = $news['news_category'];
     $data['_FIELD_TYPES']['news_category'] = 'int';
     $data['data']['news_allow_comments'] = $news['news_allow_comments'];
     $data['_FIELD_TYPES']['news_allow_comments'] = 'int';
     $data['data']['news_start'] = $news['news_start'];
     $data['_FIELD_TYPES']['news_start'] = 'int';
     $data['data']['news_end'] = $news['news_end'];
     $data['_FIELD_TYPES']['news_end'] = 'int';
     $data['data']['news_class'] = $news['news_class'];
     $data['_FIELD_TYPES']['news_class'] = 'todb';
     $data['data']['news_render_type'] = $news['news_render_type'];
     $data['_FIELD_TYPES']['news_render_type'] = 'todb';
     //news_comment_total
     $data['data']['news_summary'] = $news['news_summary'];
     $data['_FIELD_TYPES']['news_summary'] = 'todb';
     $data['data']['news_thumbnail'] = $news['news_thumbnail'];
     $data['_FIELD_TYPES']['news_thumbnail'] = 'todb';
     $data['data']['news_sticky'] = $news['news_sticky'];
     $data['_FIELD_TYPES']['news_sticky'] = 'int';
     $data['data']['news_meta_keywords'] = eHelper::formatMetaKeys($news['news_meta_keywords']);
     $data['_FIELD_TYPES']['news_meta_keywords'] = 'todb';
     $data['data']['news_meta_description'] = eHelper::formatMetaDescription($news['news_meta_description']);
     //handle bbcodes
     $data['_FIELD_TYPES']['news_meta_description'] = 'todb';
     if ($error) {
         $data['error'] = true;
         return $data;
     }
     // Calculate short strings for admin logging - no need to clog up the log with potentially long items
     $logData = $data['data'];
     if (isset($logData['news_body'])) {
         $logData['news_body'] = $tp->text_truncate($tp->toDB($logData['news_body']), 300, '...');
     }
     if (isset($logData['news_extended'])) {
         $logData['news_extended'] = $tp->text_truncate($tp->toDB($logData['news_extended']), 300, '...');
     }
     //XXX - Now hooks are executed only if no mysql error is found. Should it stay so? Seems sensible to me!
     if ($news['news_id']) {
         // Updating existing item
         $data['WHERE'] = 'news_id=' . intval($news['news_id']);
         //$vals = "news_datestamp = '".intval($news['news_datestamp'])."', ".$author_insert." news_title='".$news['news_title']."', news_body='".$news['news_body']."', news_extended='".$news['news_extended']."', news_category='".intval($news['cat_id'])."', news_allow_comments='".intval($news['news_allow_comments'])."', news_start='".intval($news['news_start'])."', news_end='".intval($news['news_end'])."', news_class='".$tp->toDB($news['news_class'])."', news_render_type='".intval($news['news_rendertype'])."' , news_summary='".$news['news_summary']."', news_thumbnail='".$tp->toDB($news['news_thumbnail'])."', news_sticky='".intval($news['news_sticky'])."' WHERE news_id='".intval($news['news_id'])."' ";
         if ($sql->db_Update('news', $data)) {
             e107::getAdminLog()->logArrayAll('NEWS_09', $logData);
             $data['data']['news_id'] = $news['news_id'];
             e107::getEvent()->trigger('newsupd', $data['data']);
             e107::getEvent()->trigger('admin_news_updated', $data['data']);
             $message = LAN_UPDATED;
             $emessage->add(LAN_UPDATED, E_MESSAGE_SUCCESS, $smessages);
             e107::getCache()->clear('news.php');
             //FIXME - triggerHook should return array(message, message_type)
             $evdata = array('method' => 'update', 'table' => 'news', 'id' => $news['news_id'], 'plugin' => 'news', 'function' => 'submit_item');
             $emessage->add(e107::getEvent()->triggerHook($evdata), E_MESSAGE_INFO, $smessages);
         } else {
             if ($sql->getLastErrorNumber()) {
                 $error = true;
                 $emessage->add(LAN_NEWS_5, E_MESSAGE_ERROR, $smessages);
                 $message = "<strong>" . LAN_NEWS_5 . "</strong>";
             } else {
                 $data['data']['news_id'] = $news['news_id'];
                 $emessage->add(LAN_NO_CHANGE, E_MESSAGE_INFO, $smessages);
                 $message = "<strong>" . LAN_NO_CHANGE . "</strong>";
                 //FIXME - triggerHook should return array(message, message_type)
                 $evdata = array('method' => 'update', 'table' => 'news', 'id' => $news['news_id'], 'plugin' => 'news', 'function' => 'submit_item');
                 $emessage->add(e107::getEvent()->triggerHook($evdata), E_MESSAGE_INFO, $smessages);
             }
         }
     } else {
         // Adding item
         $data['data']['news_id'] = $sql->db_Insert('news', $data);
         $news['news_id'] = $data['data']['news_id'];
         //$news['news_id'] = $sql ->db_Insert('news', "0, '".$news['news_title']."', '".$news['news_body']."', '".$news['news_extended']."', ".intval($news['news_datestamp']).", ".intval($news['news_author']).", '".intval($news['cat_id'])."', '".intval($news['news_allow_comments'])."', '".intval($news['news_start'])."', '".intval($news['news_end'])."', '".$tp->toDB($news['news_class'])."', '".intval($news['news_rendertype'])."', '0' , '".$news['news_summary']."', '".$tp->toDB($news['news_thumbnail'])."', '".intval($news['news_sticky'])."' ")
         if ($data['data']['news_id']) {
             $data['news_id'] = $news['news_id'];
             $message = LAN_NEWS_6;
             $emessage->add(LAN_CREATED, E_MESSAGE_SUCCESS, $smessages);
             e107::getCache()->clear('news.php');
             //moved down - prevent wrong mysql_insert_id
             e107::getAdminLog()->logArrayAll('NEWS_08', $logData);
             e107::getEvent()->trigger('newspost', $data['data']);
             e107::getEvent()->trigger('admin_news_created', $data['data']);
             //XXX - triggerHook after trigger?
             $evdata = array('method' => 'create', 'table' => 'news', 'id' => $data['data']['news_id'], 'plugin' => 'news', 'function' => 'submit_item');
             $emessage->add($e_event->triggerHook($evdata), E_MESSAGE_INFO, $smessages);
         } else {
             $error = true;
             $message = "<strong>" . LAN_NEWS_7 . "</strong>";
             $emessage->add(LAN_UPDATED, E_MESSAGE_ERROR, $smessages);
         }
     }
     //return $message;
     $data['message'] = $message;
     $data['error'] = $error;
     return $data;
 }
Пример #17
0
 function submitPage($mode = FALSE, $type = FALSE)
 {
     global $e107cache, $admin_log, $e_event;
     $frm = e107::getForm();
     $sql = e107::getDb();
     $tp = e107::getParser();
     $ns = e107::getRender();
     $mes = e107::getMessage();
     $page_title = $tp->toDB($_POST['page_title']);
     //		print_a($_POST);
     //		if(is_array($_POST['data']) && is_array($_POST['subtitle']))
     $newData = array();
     foreach ($_POST as $k => $v) {
         if (substr($k, 0, 4) == 'data' && trim($v) != '') {
             list($tm, $key) = explode("_", $k);
             if ($mode == FALSE) {
                 $newData[] = "[newpage=" . $_POST['page_subtitle'][$key] . "]\n";
             }
             $newData[] = $v;
         }
         // return;
     }
     //	return;
     $newData = implode("\n\n", $newData);
     // echo nl2br($newData);
     $page_text = $tp->toDB($newData);
     $pauthor = $_POST['page_display_authordate_flag'] ? USERID : 0;
     // Ideally, this check should be done in the front-end.
     $update = 0;
     // Make sure some updates happen
     $page_sef = '';
     $page_metad = '';
     $page_metak = '';
     if (!$type) {
         if (!empty($_POST['page_sef'])) {
             $page_sef = eHelper::secureSef($_POST['page_sef']);
         }
         if (empty($page_sef)) {
             $page_sef = eHelper::title2sef($_POST['page_title']);
         }
         if (!empty($_POST['page_metadscr'])) {
             $page_metad = $tp->toDB(eHelper::formatMetaDescription($_POST['page_metadscr']));
         }
         if (!empty($_POST['page_metakeys'])) {
             $page_metak = eHelper::formatMetaKeys($_POST['page_metakeys']);
         }
     }
     if (!$type && (!$page_title || !$page_sef)) {
         e107::getMessage()->addError(CUSLAN_34, 'default', true);
         e107::getRedirect()->redirect(e_ADMIN_ABS . 'cpage.php');
     }
     // FIXME Causes false positives on Update.. - what is trying to be achieved with this check?
     /*
     if(!$type && $sql->db_Count('page', '(page_id)', ($mode ? "page_id != {$mode} AND " : '')."page_sef != '{$page_sef}'"))
     {
     	e107::getMessage()->addError(CUSLAN_34, 'default', true);
     	
     	e107::getMessage()->addDebug("type=".$type, 'default', true);
     	e107::getMessage()->addDebug("page_title=".$page_title, 'default', true);
     	e107::getMessage()->addDebug("page_sef=".$page_sef, 'default', true);
     	e107::getMessage()->addDebug("Mode=".$mode, 'default', true);					
     	
     	e107::getRedirect()->redirect(e_ADMIN_ABS.'cpage.php');
     }
     */
     if ($type && empty($_POST['menu_name'])) {
         e107::getMessage()->addError(CUSLAN_36, 'default', true);
         e107::getRedirect()->redirect(e_ADMIN_ABS . 'cpage.php');
     }
     if ($mode) {
         // Saving existing page/menu after edit
         // Don't think $_POST['page_ip_restrict'] is ever set.
         $menuname = $type && vartrue($_POST['menu_name']) ? ", page_theme = '" . $tp->toDB($_POST['menu_name']) . "'" : "";
         $status = $sql->db_Update("page", "page_title='{$page_title}', page_sef='{$page_sef}', page_chapter='" . intval($_POST['page_chapter']) . "', page_metakeys='{$page_metak}', page_metadscr='{$page_metad}', page_text='{$page_text}', page_datestamp='" . time() . "', page_author='{$pauthor}', page_rating_flag='" . intval($_POST['page_rating_flag']) . "', page_comment_flag='" . intval($_POST['page_comment_flag']) . "', page_password='******'page_password'] . "', page_class='" . $_POST['page_class'] . "', page_ip_restrict='" . varset($_POST['page_ip_restrict'], '') . "', page_template='" . $_POST['page_template'] . "' {$menuname} WHERE page_id='{$mode}'") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
         if ($status == E_MESSAGE_SUCCESS) {
             $update++;
         }
         $mes->add($message, $status);
         $admin_log->log_event('CPAGE_02', $mode . '[!br!]' . $page_title . '[!br!]' . $pauthor, E_LOG_INFORMATIVE, '');
         $e107cache->clear("page_{$mode}");
         $e107cache->clear("page-t_{$mode}");
         $data = array('method' => 'update', 'table' => 'page', 'id' => $mode, 'plugin' => 'page', 'function' => 'submitPage');
         $this->message = $e_event->triggerHook($data);
         if ($type) {
             $menu_name = $tp->toDB($_POST['menu_name']);
             // not to be confused with menu-caption.
             // Need to check whether menu already in table, else we can't distinguish between a failed update and no update needed
             if ($sql->db_Select('menus', 'menu_name', "`menu_path` = '{$mode}'")) {
                 // Updating existing entry
                 if ($sql->db_Update('menus', "menu_name='{$menu_name}' WHERE menu_path='{$mode}' ") !== FALSE) {
                     $update++;
                 }
             }
         }
         //$url = e107::getUrl()->sc('page/view', array('name' => $tp->post_toForm($_POST['page_title']), 'id' => $mode));
         /*
         				 
         				// Prevent links being updated in another language unless the table is present. 
         			if((($pref['sitelanguage'] != $sql->mySQLlanguage) && ($sql->mySQLlanguage!='')) && ($sql->db_IsLang("links")=='links'))
         			{
         				//echo "DISABLED LINK CREATION";
         				//echo ' Sitelan='.$pref['sitelanguage'];
         				//echo " Dblang=".$sql->mySQLlanguage;
         				//echo " Links=".$sql->db_IsLang("links");
         			
         				return;	
         			}
         				 
         				 
         				 
         				if ($_POST['page_link'])
         				{
         					// FIXME extremely ugly, just join on created link ID by new field page_link 
         					if ($sql->db_Select("links", "link_id", "link_url='".$url."' && link_name!='".$tp->toDB($_POST['page_link'])."'"))
         					{
         						$sql->db_Update("links", "link_name='".$tp->toDB($_POST['page_link'])."' WHERE link_url='".$url."'");
         						$update++;
         						$e107cache->clear("sitelinks");
         					}
         					else if (!$sql->db_Select("links", "link_id", "link_url='".$url."'"))
         					{
         						$sql->db_Insert("links", "0, '".$tp->toDB($_POST['page_link'])."', '".$url."', '', '', 1, 0, 0, 0, ".$_POST['page_class']);
         						$update++;
         						$e107cache->clear("sitelinks");
         					}
         				} else {
         					if ($sql->db_Select("links", "link_id", "link_url='".$url."'"))
         					{
         						$sql->db_Delete("links", "link_url='".$url."'");
         						$update++;
         						$e107cache->clear("sitelinks");
         					}
         				}*/
         $mes = e107::getMessage();
         $mes->autoMessage($update, 'update', LAN_UPDATED, false, false);
         // Display result of update
     } else {
         // New page/menu
         $menuname = $type ? $tp->toDB($_POST['menu_name']) : "";
         $addMsg = $type ? CUSLAN_51 : CUSLAN_27;
         $info = array('page_title' => $page_title, 'page_sef' => $page_sef, 'page_chapter' => varset($_POST['page_chapter'], 0), 'page_metakeys' => $page_metak, 'page_metadscr' => $page_metad, 'page_text' => $page_text, 'page_author' => $pauthor, 'page_datestamp' => time(), 'page_rating_flag' => varset($_POST['page_rating_flag'], 0), 'page_comment_flag' => varset($_POST['page_comment_flag'], ''), 'page_password' => varset($_POST['page_password'], ''), 'page_class' => varset($_POST['page_class'], e_UC_PUBLIC), 'page_ip_restrict' => '', 'page_theme' => $menuname, 'page_template' => varset($_POST['page_template'], ''));
         $pid = e107::getMessage()->autoMessage($sql->db_Insert('page', $info), 'insert', $addMsg, LAN_CREATED_FAILED, false);
         $admin_log->log_event('CPAGE_01', $menuname . '[!br!]' . $page_title . '[!br!]' . $pauthor, E_LOG_INFORMATIVE, '');
         if ($type) {
             $info = array('menu_name' => $menuname, 'menu_location' => 0, 'menu_order' => 0, 'menu_class' => '0', 'menu_pages' => '', 'menu_path' => $pid);
             e107::getMessage()->autoMessage($sql->db_Insert('menus', $info), 'insert', CUSLAN_52, LAN_CREATED_FAILED, false);
         }
         /*if(vartrue($_POST['page_link']))
         		{
         			//$link = 'page.php?'.$pid;
         			$url = e107::getUrl()->sc('page/view', array('name' => $tp->post_toForm($_POST['page_title']), 'id' => $pid));
         			if (!$sql->db_Select("links", "link_id", "link_name='".$tp->toDB($_POST['page_link'])."'"))
         			{
         				$linkname = $tp->toDB($_POST['page_link']);
         				$sql->db_Insert("links", "0, '{$linkname}', '{$url}', '', '', 1, 0, 0, 0, ".$_POST['page_class']);
         				$e107cache->clear("sitelinks");
         			}
         		}*/
         $data = array('method' => 'create', 'table' => 'page', 'id' => $pid, 'plugin' => 'page', 'function' => 'submitPage');
         $this->message = $e_event->triggerHook($data);
     }
 }
Пример #18
0
 public function beforeUpdate($new_data, $old_data, $id)
 {
     $mes = e107::getMessage();
     if ($new_data['media_cat_owner'] != "gallery") {
         $mes->addError(LAN_IMA_001);
         return FALSE;
     }
     if (empty($new_data['media_cat_sef'])) {
         $new_data['media_cat_sef'] = eHelper::title2sef($new_data['media_cat_title']);
     }
     return $new_data;
 }
Пример #19
0
 public function beforeUpdate($new_data, $old_data, $id)
 {
     if (empty($new_data['forum_sef']) && !empty($new_data['forum_name'])) {
         $new_data['forum_sef'] = eHelper::title2sef($new_data['forum_name']);
     }
     return $new_data;
 }
Пример #20
0
 function init()
 {
     $sql = e107::getDb();
     $tp = e107::getParser();
     $ns = e107::getRender();
     $frm = e107::getForm();
     require_once e_PLUGIN . 'forum/forum_class.php';
     $gen = e107::getDate();
     $forum = new e107forum();
     $total_posts = $sql->count('forum_post');
     $total_topics = $sql->count('forum_thread');
     $total_replies = $total_posts - $total_topics;
     $total_views = 0;
     $query = 'SELECT sum(thread_views) AS total FROM `#forum_thread` ';
     if ($sql->gen($query)) {
         $row = $sql->fetch();
         $total_views = $row['total'];
     }
     $firstpost = $sql->select('forum_post', 'post_datestamp', 'post_datestamp > 0 ORDER BY post_datestamp ASC LIMIT 0,1', 'default');
     $fp = $sql->fetch();
     $open_ds = $fp['post_datestamp'];
     $open_date = $gen->convert_date($open_ds, 'long');
     $open_since = $gen->computeLapse($open_ds);
     $open_days = floor((time() - $open_ds) / 86400);
     $postsperday = $open_days < 1 ? $total_posts : round($total_posts / $open_days);
     global $mySQLdefaultdb;
     $query = "SHOW TABLE STATUS FROM `{$mySQLdefaultdb}`";
     $sql->gen($query);
     $array = $sql->db_getList();
     foreach ($array as $table) {
         if ($table['Name'] == MPREFIX . 'forum_post') {
             $db_size = eHelper::parseMemorySize($table['Data_length']);
             $avg_row_len = eHelper::parseMemorySize($table['Avg_row_length']);
             break;
         }
     }
     $query = "\n\t\tSELECT ft.thread_id, ft.thread_user, ft.thread_name, ft.thread_total_replies, ft.thread_datestamp, f.forum_sef, f.forum_class, u.user_name, u.user_id FROM #forum_thread as ft\n\t\tLEFT JOIN #user AS u ON ft.thread_user = u.user_id\n\t\tLEFT JOIN #forum AS f ON f.forum_id = ft.thread_forum_id\n\t\tWHERE ft.thread_active > 0\n\t\tAND f.forum_class IN (" . USERCLASS_LIST . ")\n\t\tORDER BY ft.thread_total_replies DESC LIMIT 0,10";
     $sql->gen($query);
     $most_activeArray = $sql->db_getList();
     $query = "\n\t\tSELECT ft.*, f.forum_class, f.forum_sef, u.user_name, u.user_id FROM #forum_thread as ft\n\t\tLEFT JOIN #user AS u ON ft.thread_user = u.user_id\n\t\tLEFT JOIN #forum AS f ON f.forum_id = ft.thread_forum_id\n\t\tWHERE f.forum_class IN (" . USERCLASS_LIST . ")\n\t\tORDER BY ft.thread_views DESC LIMIT 0,10";
     $sql->gen($query);
     $most_viewedArray = $sql->db_getList();
     /*$sql->db_Select("user", "user_id, user_name, user_forums", "ORDER BY user_forums DESC LIMIT 0, 10", "no_where");
     		$posters = $sql -> db_getList();
     		$top_posters = array();
     		foreach($posters as $poster)
     		{
     			$percen = round(($poster['user_forums'] / $total_posts) * 100, 2);
     			$top_posters[] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['user_forums'], "percentage" => $percen);
     		}*/
     // get all replies
     $query = "\n\t\tSELECT COUNT(fp.post_id) AS post_count, u.user_name, u.user_id, fp.post_thread FROM #forum_post as fp\n\t\tLEFT JOIN #user AS u ON fp.post_user = u.user_id\n\t\tGROUP BY fp.post_user\n\t\tORDER BY post_count DESC LIMIT 0,10";
     $sql->gen($query);
     // 	$top_repliers_data = $sql->db_getList('ALL', false, false, 'user_id');
     $top_repliers_data = $sql->retrieve($query, true);
     // build top posters meanwhile
     $top_posters = array();
     $topReplier = array();
     foreach ($top_repliers_data as $poster) {
         $percent = round($poster['post_count'] / $total_posts * 100, 2);
         $topReplier[] = intval($poster['user_id']);
         $top_posters[] = array("user_id" => $poster['user_id'], "user_name" => vartrue($poster['user_name'], LAN_ANONYMOUS), "user_forums" => $poster['post_count'], "percentage" => $percent);
     }
     // end build top posters
     $ids = implode(',', $topReplier);
     // find topics by top 10 users
     $query = "\n\t\tSELECT COUNT(ft.thread_id) AS thread_count, u.user_id FROM #forum_thread as ft\n\t\tLEFT JOIN #user AS u ON ft.thread_user = u.user_id\n\t\tWHERE u.user_id IN ({$ids})\tGROUP BY ft.thread_user";
     $sql->gen($query);
     $top_repliers_data_c = $sql->db_getList('ALL', false, false, 'user_id');
     $top_repliers = array();
     foreach ($top_repliers_data as $uid => $poster) {
         $poster['post_count'] = $poster['post_count'] - $top_repliers_data_c[$uid]['thread_count'];
         $percent = round($poster['post_count'] / $total_replies * 100, 2);
         $top_repliers_sort[$uid] = $poster['post_count'];
         //$top_repliers[$uid] = $poster;
         $top_repliers_data[$uid]['user_forums'] = $poster['post_count'];
         $top_repliers_data[$uid]['percentage'] = $percent;
         //$top_repliers_data[$uid] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['post_count'], "percentage" => $percent);
     }
     // sort
     arsort($top_repliers_sort, SORT_NUMERIC);
     // build top repliers
     foreach ($top_repliers_sort as $uid => $c) {
         $top_repliers[] = $top_repliers_data[$uid];
     }
     // get all replies
     $query = "\n\t\tSELECT COUNT(ft.thread_id) AS thread_count, u.user_name, u.user_id FROM #forum_thread as ft\n\t\tLEFT JOIN #user AS u ON ft.thread_user = u.user_id\n\t\tGROUP BY ft.thread_user\n\t\tORDER BY thread_count DESC LIMIT 0,10";
     $sql->gen($query);
     $top_topic_starters_data = $sql->db_getList();
     $top_topic_starters = array();
     foreach ($top_topic_starters_data as $poster) {
         $percent = round($poster['thread_count'] / $total_topics * 100, 2);
         $top_topic_starters[] = array("user_id" => $poster['user_id'], "user_name" => vartrue($poster['user_name'], LAN_ANONYMOUS), "user_forums" => $poster['thread_count'], "percentage" => $percent);
     }
     /*
     			$query = "
     			SELECT SUBSTRING_INDEX(thread_user,'.',1) AS t_user, COUNT(SUBSTRING_INDEX(ft.thread_user,'.',1)) AS ucount, u.user_name, u.user_id FROM #forum_t as ft
     			LEFT JOIN #user AS u ON SUBSTRING_INDEX(ft.thread_user,'.',1) = u.user_id
     			WHERE ft.thread_parent=0
     			GROUP BY t_user
     			ORDER BY ucount DESC
     			LIMIT 0,10";
     			$sql -> db_Select_gen($query);
     			$posters = $sql -> db_getList();
     			$top_topic_starters = array();
     			foreach($posters as $poster)
     			{
     				$percen = round(($poster['ucount'] / $total_topics) * 100, 2);
     				$top_topic_starters[] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['ucount'], "percentage" => $percen);
     			}*/
     /*
     $query = "
     SELECT SUBSTRING_INDEX(thread_user,'.',1) AS t_user, COUNT(SUBSTRING_INDEX(ft.thread_user,'.',1)) AS ucount, u.user_name, u.user_id FROM #forum_t as ft
     LEFT JOIN #user AS u ON SUBSTRING_INDEX(ft.thread_user,'.',1) = u.user_id
     WHERE ft.thread_parent!=0
     GROUP BY t_user
     ORDER BY ucount DESC
     LIMIT 0,10";
     $sql -> db_Select_gen($query);
     $posters = $sql -> db_getList();
     
     $top_repliers = array();
     foreach($posters as $poster)
     {
     	$percen = round(($poster['ucount'] / $total_replies) * 100, 2);
     	$top_repliers[] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['ucount'], "percentage" => $percen);
     }
     */
     $text_0 = "\n\t\t<table style='width: 100%;' class='fborder table'>\n\t\t\t<tr><td style='width: 50%; text-align: right;'><b>" . LAN_FORUM_6001 . ":</b>&nbsp;&nbsp;</td><td style='width: 50%;'>{$open_date}</td></tr>\n\t\t\t<tr><td style='width: 50%; text-align: right;'><b>" . LAN_FORUM_6002 . ":</b>&nbsp;&nbsp;</td><td style='width: 50%;'>{$open_since}</td></tr>\n\t\t\t<tr><td style='width: 50%; text-align: right;'><b>" . LAN_FORUM_6003 . ":</b>&nbsp;&nbsp;</td><td style='width: 50%;'>{$total_posts}</td></tr>\n\t\t\t<tr><td style='width: 50%; text-align: right;'><b>" . LAN_FORUM_1007 . ":</b>&nbsp;&nbsp;</td><td style='width: 50%;'>{$total_topics}</td></tr>\n\t\t\t<tr><td style='width: 50%; text-align: right;'><b>" . LAN_FORUM_6004 . ":</b>&nbsp;&nbsp;</td><td style='width: 50%;'>{$total_replies}</td></tr>\n\t\t\t<tr><td style='width: 50%; text-align: right;'><b>" . LAN_FORUM_6005 . ":</b>&nbsp;&nbsp;</td><td style='width: 50%;'>{$total_views}</td></tr>\n\t\t\t<tr><td style='width: 50%; text-align: right;'><b>" . LAN_FORUM_6014 . ":</b>&nbsp;&nbsp;</td><td style='width: 50%;'>{$postsperday}</td></tr>\n\t\t\t<tr><td style='width: 50%; text-align: right;'><b>" . LAN_FORUM_6006 . ":</b>&nbsp;&nbsp;</td><td style='width: 50%;'>{$db_size}</td></tr>\n\t\t\t<tr><td style='width: 50%; text-align: right;'><b>" . LAN_FORUM_6007 . ":</b>&nbsp;&nbsp;</td><td style='width: 50%;'>{$avg_row_len}</td></tr>\n\t\t</table>";
     $text_1 = "\n\t\t<table style='width: 100%;' class='fborder table'>\n\t\t<thead>\n\t\t<tr>\n\t\t<th style='width: 10%; text-align: center;' class='fcaption'>" . LAN_FORUM_6008 . "</th>\n\t\t<th style='width: 40%;' class='fcaption'>" . LAN_FORUM_1003 . "</th>\n\t\t<th style='width: 10%; text-align: center;' class='fcaption'>" . LAN_FORUM_0003 . "</th>\n\t\t<th style='width: 20%; text-align: center;' class='fcaption'>" . LAN_FORUM_6009 . "</th>\n\t\t<th style='width: 20%; text-align: center;' class='fcaption'>" . LAN_DATE . "</th>\n\t\t</tr>\n\t\t</thead>\n\t\t";
     $count = 1;
     foreach ($most_activeArray as $ma) {
         if ($ma['user_name']) {
             //$uinfo = "<a href='".e_HTTP."user.php ?id.{$ma['user_id']}'>{$ma['user_name']}</a>"; //TODO SEf Url .
             $uparams = array('id' => $ma['user_id'], 'name' => $ma['user_name']);
             $link = e107::getUrl()->create('user/profile/view', $uparams);
             $uinfo = "<a href='" . $link . "'>" . $ma['user_name'] . "</a>";
         } else {
             $tmp = explode(chr(1), $ma['thread_anon']);
             $uinfo = $tp->toHTML($tmp[0]);
         }
         $ma['thread_sef'] = eHelper::title2sef($ma['thread_name'], 'dashl');
         $url = e107::url('forum', 'topic', $ma);
         $text_1 .= "\n\t\t\t<tr>\n\t\t\t<td style='width: 10%; text-align: center;' class='forumheader3'>{$count}</td>\n\t\t\t<td style='width: 40%;' class='forumheader3'><a href='" . $url . "'>{$ma['thread_name']}</a></td>\n\t\t\t<td style='width: 10%; text-align: center;' class='forumheader3'>{$ma['thread_total_replies']}</td>\n\t\t\t<td style='width: 20%; text-align: center;' class='forumheader3'>{$uinfo}</td>\n\t\t\t<td style='width: 20%; text-align: center;' class='forumheader3'>" . $gen->convert_date($ma['thread_datestamp'], "forum") . "</td>\n\t\t\t</tr>\n\t\t\t";
         $count++;
     }
     $text_1 .= "</table>";
     $text_2 = "\n\t\t<table style='width: 100%;' class='fborder table'>\n\t\t<thead>\n\t\t<tr>\n\t\t<th style='width: 10%; text-align: center;' class='fcaption'>" . LAN_FORUM_6008 . "</th>\n\t\t<th style='width: 40%;' class='fcaption'>" . LAN_FORUM_1003 . "</th>\n\t\t<th style='width: 10%; text-align: center;' class='fcaption'>" . LAN_FORUM_1005 . "</th>\n\t\t<th style='width: 20%; text-align: center;' class='fcaption'>" . LAN_FORUM_6009 . "</th>\n\t\t<th style='width: 20%; text-align: center;' class='fcaption'>" . LAN_DATE . "</th>\n\t\t</tr>\n\t\t</thead>\n\t\t";
     $count = 1;
     foreach ($most_viewedArray as $ma) {
         if ($ma['user_name']) {
             //$uinfo = "<a href='".e_HTTP."user.php ?id.{$ma['user_id']}'>".$ma['user_name']."</a>";  //TODO SEf Url .
             $uparams = array('id' => $ma['user_id'], 'name' => $ma['user_name']);
             $link = e107::getUrl()->create('user/profile/view', $uparams);
             $uinfo = "<a href='" . $link . "'>" . $ma['user_name'] . "</a>";
         } else {
             $tmp = explode(chr(1), $ma['thread_anon']);
             $uinfo = $tp->toHTML($tmp[0]);
         }
         $ma['thread_sef'] = eHelper::title2sef($ma['thread_name'], 'dashl');
         $url = e107::url('forum', 'topic', $ma);
         $text_2 .= "\n\t\t\t<tr>\n\t\t\t<td style='width: 10%; text-align: center;' class='forumheader3'>{$count}</td>\n\t\t\t<td style='width: 40%;' class='forumheader3'><a href='" . $url . "'>" . $ma['thread_name'] . "</a></td>\n\t\t\t<td style='width: 10%; text-align: center;' class='forumheader3'>" . $ma['thread_views'] . "</td>\n\t\t\t<td style='width: 20%; text-align: center;' class='forumheader3'>" . $uinfo . "</td>\n\t\t\t<td style='width: 20%; text-align: center;' class='forumheader3'>" . $gen->convert_date($ma['thread_datestamp'], "forum") . "</td>\n\t\t\t</tr>\n\t\t\t";
         $count++;
     }
     $text_2 .= "</table>";
     $text_3 = "\n\t\t<table style='width: 100%;' class='fborder table'>\n\t\t<thead>\n\t\t<tr>\n\t\t<th style='width: 10%; text-align: center;' class='fcaption'>" . LAN_FORUM_6008 . "</th>\n\t\t<th style='width: 20%;' class='fcaption'>" . LAN_NAME . "</th>\n\t\t<th style='width: 10%; text-align: center;' class='fcaption'>" . LAN_FORUM_2032 . "</th>\n\t\t<th style='width: 10%; text-align: center;' class='fcaption'>%</th>\n\t\t<th style='width: 50%; text-align: center;' class='fcaption'>&nbsp;</th>\n\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t";
     $count = 1;
     foreach ($top_posters as $ma) {
         $text_3 .= "<tr>\n\t\t\t<td style='width: 10%; text-align: center;' class='forumheader3'>{$count}</td>\n\t\t\t<td style='width: 20%;' class='forumheader3'><a href='" . e107::getUrl()->create('user/profile/view', $ma) . "'>" . $ma['user_name'] . "</a></td>\n\t\t\t<td style='width: 10%; text-align: center;' class='forumheader3'>" . $ma['user_forums'] . "</td>\n\t\t\t<td style='width: 10%; text-align: center;' class='forumheader3'>" . $ma['percentage'] . "%</td>\n\t\t\t<td style='width: 50%;' class='forumheader3'>" . $this->showBar($ma['percentage']) . "\n\t\t\t</td>\n\t\t\t</tr>\n\t\t\t";
         $count++;
     }
     $text_3 .= "</tbody>\n\t\t</table>\n\t\t";
     $text_4 = "\n\t\t<table style='width: 100%;' class='fborder table'>\n\t\t<thead>\n\t\t<tr>\n\t\t<th style='width: 10%; text-align: center;' class='fcaption'>" . LAN_FORUM_6008 . "</th>\n\t\t<th style='width: 20%;' class='fcaption'>" . LAN_NAME . "</th>\n\t\t<th style='width: 10%; text-align: center;' class='fcaption'>" . LAN_FORUM_2032 . "</th>\n\t\t<th style='width: 10%; text-align: center;' class='fcaption'>%</th>\n\t\t<th style='width: 50%; text-align: center;' class='fcaption'>&nbsp;</th>\n\t\t</tr>\n\t\t</thead>\n\t\t";
     $count = 1;
     foreach ($top_topic_starters as $ma) {
         $text_4 .= "<tr>\n\t\t\t<td style='width: 10%; text-align: center;' class='forumheader3'>{$count}</td>\n\t\t\t<td style='width: 20%;' class='forumheader3'><a href='" . e107::getUrl()->create('user/profile/view', $ma) . "'>" . $ma['user_name'] . "</a></td>\n\t\t\t<td style='width: 10%; text-align: center;' class='forumheader3'>" . $ma['user_forums'] . "</td>\n\t\t\t<td style='width: 10%; text-align: center;' class='forumheader3'>" . $ma['percentage'] . "%</td>\n\t\t\t<td style='width: 50%; text-align: center;' class='forumheader3'>" . $this->showBar($ma['percentage']) . "</td>\n\t\t\t</tr>\n\t\t\t";
         $count++;
     }
     $text_4 .= "</table>";
     $text_5 = "\n\t\t<table style='width: 100%;' class='fborder table'>\n\t\t<thead>\n\t\t<tr>\n\t\t<th style='width: 10%; text-align: center;' class='fcaption'>" . LAN_FORUM_6008 . "</th>\n\t\t<th style='width: 20%;' class='fcaption'>" . LAN_NAME . "</th>\n\t\t<th style='width: 10%; text-align: center;' class='fcaption'>" . LAN_FORUM_2032 . "</th>\n\t\t<th style='width: 10%; text-align: center;' class='fcaption'>%</th>\n\t\t<th style='width: 50%; text-align: center;' class='fcaption'>&nbsp;</th>\n\t\t</tr>\n\t\t</thead>\n\t\t";
     $count = 1;
     foreach ($top_repliers as $ma) {
         $text_5 .= "\n\t\t\t<tr>\n\t\t\t<td style='width: 10%; text-align: center;' class='forumheader3'>{$count}</td>\n\t\t\t<td style='width: 20%;' class='forumheader3'><a href='" . e107::getUrl()->create('user/profile/view', $ma) . "'>" . $ma['user_name'] . "</a></td>\n\t\t\t<td style='width: 10%; text-align: center;' class='forumheader3'>" . $ma['user_forums'] . "</td>\n\t\t\t<td style='width: 10%; text-align: center;' class='forumheader3'>" . $ma['percentage'] . "%</td>\n\t\t\t<td style='width: 50%; text-align: center;' class='forumheader3'>" . $this->showBar($ma['percentage']) . "</td>\n\t\t\t</tr>\n\t\t\t";
         $count++;
     }
     $text_5 .= '</table>';
     if (deftrue('BOOTSTRAP')) {
         $tabs = array();
         $tabs[0] = array('caption' => LAN_FORUM_6000, 'text' => $text_0);
         $tabs[1] = array('caption' => LAN_FORUM_0011, 'text' => $text_1);
         $tabs[2] = array('caption' => LAN_FORUM_6010, 'text' => $text_2);
         $tabs[3] = array('caption' => LAN_FORUM_0010, 'text' => $text_3);
         $tabs[4] = array('caption' => LAN_FORUM_6011, 'text' => $text_4);
         $tabs[5] = array('caption' => LAN_FORUM_6012, 'text' => $text_5);
         $frm = e107::getForm();
         $breadarray = array(array('text' => e107::pref('forum', 'title', LAN_PLUGIN_FORUM_NAME), 'url' => e107::url('forum', 'index')), array('text' => LAN_FORUM_6013, 'url' => null));
         $text = $frm->breadcrumb($breadarray);
         $text = "<div id='forum-stats'>" . $text . e107::getForm()->tabs($tabs) . "</div>";
     } else {
         $text = "\n\t\t\t<h3>" . LAN_FORUM_6000 . "</h3>" . $text_0 . "<h3>" . LAN_FORUM_0011 . "</h3>" . $text_1 . "<h3>" . LAN_FORUM_6010 . "</h3>" . $text_2 . "<h3>" . LAN_FORUM_0010 . "</h3>" . $text_3 . "<h3>" . LAN_FORUM_6011 . "</h3>" . $text_4 . "<h3>" . LAN_FORUM_6012 . "</h3>" . $text_5;
     }
     $text .= "<div class='center'>" . e107::getForm()->pagination(e107::url('forum', 'index'), LAN_BACK) . "</div>";
     $ns->tablerender(LAN_FORUM_6013, $text);
 }
Пример #21
0
 public function moduleRows($data)
 {
     $text = '';
     $tp = e107::getParser();
     $frm = e107::getForm();
     if (empty($data)) {
         return "\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan='2'>" . LAN_EURL_EMPTY . "</td>\n\t\t\t\t</tr>\n\t\t\t";
     }
     $PLUGINS_DIRECTORY = e107::getFolder("PLUGINS");
     $srch = array("{SITEURL}", "{e_PLUGIN_ABS}");
     $repl = array(SITEURL, SITEURL . $PLUGINS_DIRECTORY);
     foreach ($data as $obj) {
         $admin = $obj->config->admin();
         $section = vartrue($admin['labels'], array());
         $rowspan = count($obj->locations) + 1;
         $module = $obj->module;
         $generate = vartrue($admin['generate'], array());
         /*
         			$info .= "
               <tr>
                   <td rowspan='$rowspan'><a class='e-tip' style='display:block' title='".LAN_EURL_LOCATION.$path."'>
                   ".vartrue($section['name'], eHelper::labelize($obj->module))."
                   </a></td>
              </tr>
           ";
         */
         $opt = "";
         $info = "<table class='table table-striped'>";
         foreach ($obj->locations as $index => $location) {
             $objSub = $obj->defaultLocation != $location ? eDispatcher::getConfigObject($obj->module, $location) : false;
             if ($objSub) {
                 $admin = $objSub->admin();
                 $section = vartrue($admin['labels'], array());
             } elseif ($obj->defaultLocation != $location) {
                 $section = array();
             }
             $id = 'eurl-' . str_replace('_', '-', $obj->module) . '-' . $index;
             $checked = varset($obj->current[$module]) == $location ? ' checked="checked"' : '';
             $path = eDispatcher::getConfigPath($module, $location, false);
             if (!is_readable($path)) {
                 $path = str_replace('/url.php', '/', $tp->replaceConstants(eDispatcher::getConfigPath($module, $location, true), true)) . ' <em>(' . LAN_EURL_LOCATION_NONE . ')</em>';
                 $diz = LAN_EURL_DEFAULT;
             } else {
                 $path = $tp->replaceConstants(eDispatcher::getConfigPath($module, $location, true), true);
                 $diz = basename($path) != 'url.php' ? LAN_EURL_FRIENDLY : LAN_EURL_DEFAULT;
             }
             $label = vartrue($section['label'], $index == 0 ? LAN_EURL_DEFAULT : eHelper::labelize(ltrim(strstr($location, '/'), '/')));
             $cssClass = $checked ? 'e-showme' : 'e-hideme';
             $cssClass = 'e-hideme';
             // always hidden for now, some interface changes could come after pre-alpha
             $exampleUrl = array();
             if (!empty($section['examples'])) {
                 foreach ($section['examples'] as $ex) {
                     $exampleUrl[] = str_replace($srch, $repl, $ex);
                 }
             }
             if (strpos($path, 'noid') !== false) {
                 //     $exampleUrl .= "  &nbsp; &Dagger;";    //XXX Add footer - denotes more CPU required. ?
             }
             $selected = varset($obj->current[$module]) == $location ? "selected='selected'" : '';
             $opt .= "<option value='{$location}' {$selected} >" . $diz . ": " . $exampleUrl[0] . "</option>";
             $info .= "<tr><td>" . $label . "\n\t\t\t\t\t\n\t\t\t\t\t</td>\n\t\t\t\t\t<td><strong>" . LAN_EURL_LOCATION . "</strong>: " . $path . "\n                    <p>" . vartrue($section['description'], LAN_EURL_PROFILE_INFO) . "</p><small>" . implode("<br />", $exampleUrl) . "</small></td>\n                    \n                    \n                    \n                    </tr>\n\t\t\t\t";
         }
         $info .= "</table>";
         $title = vartrue($section['name'], eHelper::labelize($obj->module));
         $text .= "\n                <tr>\n                    <td>" . $this->moreInfo($title, $info) . "</td>\n                    <td><select name='eurl_config[{$module}]' class='input-block-level'>" . $opt . "</select></td>\n                    <td>";
         $bTable = $admin['generate']['table'];
         $bInput = $admin['generate']['input'];
         $bOutput = $admin['generate']['output'];
         $bPrimary = $admin['generate']['primary'];
         $text .= is_array($admin['generate']) ? $frm->admin_button('rebuild[' . $bTable . ']', $bPrimary . "::" . $bInput . "::" . $bOutput, 'delete', LAN_EURL_REBUILD) : "";
         $text .= "</td>\n               </tr>";
     }
     /*
     		For Miro - intuitive interface example. All configs are contained within one e_url.php file. 
     		Root namespacing automatically calculated based on selection. 
     		ie. choosing option 1 below will set root namespacing for news. 
     		Known bug (example): 
      News title: Nothing's Gonna Change my World!
      Currently becomes: /Nothing%26%23039%3Bs%20Gonna%20Change%20my%20World%21
     Should become: /nothings-gonna-change-my-world
     Good SEF reference: http://davidwalsh.name/generate-search-engine-friendly-urls-php-function
     
     [Miro] Solution comes from the module itself, not related with URL assembling in anyway (as per latest Skype discussion)
     */
     // Global On/Off Switch Example
     // [Miro] there is no reason of switch, everything could go through single entry point at any time, without a need of .htaccess (path info)
     // Control is coming per configuration file.
     $example = "\n\t\t<tr><td>Enable Search-Engine-Friendly URLs</td>\n\t\t<td><input type='checkbox' name='SEF-active' value='1' />\n\t\t</td></tr>";
     //Entry Example (Hidden unless the above global switch is active)
     $example .= "\n\t\t\n\t\t<tr><td>News</td>\n\t\t\t\t\t<td style='padding:0px'>\n\t\t\t\t\t<table style='width:600px;margin-left:0px'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><input type='radio' class='radio' name='example' />Default</td><td>/news.php?item.1</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><input type='radio' class='radio' name='example' />News Namespace and News Title</td><td>/news/news-item-title</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><input type='radio' class='radio' name='example' />Year and News Title</td><td>/2011/news-item-title</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><input type='radio' class='radio' name='example' />Year/Month and News Title</td><td>/2011/08/news-item-title</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><input type='radio' class='radio' name='example' />Year/Month/Day and News Title</td><td>/2011/08/27/news-item-title</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><input type='radio' class='radio' name='example' />News Category and News Title</td><td>/news-category/news-item-title</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t";
     // For 0.8 Beta
     $example .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><input type='radio' class='radio' name='example' />Custom</td><td><input class='tbox' type='text' name='custom-news' value='' /></td>\n\t\t\t\t\t\t</tr>";
     $example .= "</table>";
     $example .= "</td>\n\t\t\t\t\t</tr>";
     return $text;
 }
Пример #22
0
function fpages($thread_info, $replies)
{
    global $forum;
    $tp = e107::getParser();
    $pages = ceil($replies / $forum->prefs->get('postspage'));
    $thread_info['thread_sef'] = eHelper::title2sef($thread_info['thread_name'], 'dashl');
    $urlparms = $thread_info;
    $text = '';
    if ($pages > 1) {
        if ($pages > 6) {
            for ($a = 0; $a <= 2; $a++) {
                $aa = $a + 1;
                $text .= $text ? ' ' : '';
                //	$urlparms['page'] = $aa;
                //	$url = e107::getUrl()->create('forum/thread/view', $urlparms);
                $title = $tp->lanVars(LAN_GOTOPAGEX, $aa);
                $url = e107::url('forum', 'topic', $urlparms) . '&amp;p=' . $aa;
                $opts[] = "<a data-toggle='tooltip' title=\"" . $title . "\" href='{$url}'>{$aa}</a>";
            }
            $text .= ' ... ';
            for ($a = $pages - 3; $a <= $pages - 1; $a++) {
                $aa = $a + 1;
                $text .= $text ? ' ' : '';
                //	$urlparms['page'] = $aa;
                //	$url = e107::getUrl()->create('forum/thread/view', $urlparms);
                $title = $tp->lanVars(LAN_GOTOPAGEX, $aa);
                $url = e107::url('forum', 'topic', $urlparms) . '&amp;p=' . $aa;
                $opts[] = "<a data-toggle='tooltip' title=\"" . $title . "\" href='{$url}'>{$aa}</a>";
            }
        } else {
            for ($a = 0; $a <= $pages - 1; $a++) {
                $aa = $a + 1;
                $text .= $text ? ' ' : '';
                //	$urlparms['page'] = $aa;
                //	$url = e107::getUrl()->create('forum/thread/view', $urlparms);
                $title = $tp->lanVars(LAN_GOTOPAGEX, $aa);
                $url = e107::url('forum', 'topic', $urlparms) . '&amp;p=' . $aa;
                $opts[] = "<a data-toggle='tooltip' title=\"" . $title . "\" href='{$url}'>{$aa}</a>";
            }
        }
        if (deftrue('BOOTSTRAP')) {
            $text = "<ul class='pagination pagination-sm forum-viewforum-pagination'>\n\t\t\t\t\t\t<li>";
            $text .= implode("</li><li>", $opts);
            // ."</div>";
            $text .= "</li></ul>";
        } else {
            $text = implode("", $opts);
            // ."</div>";
        }
    } else {
        $text = '';
    }
    return $text;
}
Пример #23
0
 /**
  * Auto-thumbnailing now allowed.
  * New sc parameter standards
  * Exampes: 
  * - {NEWSTHUMBNAIL=link|w=200} render link with thumbnail max width 200px
  * - {NEWSTHUMBNAIL=|w=200} same as above
  * - {NEWSTHUMBNAIL=src|aw=200&ah=200} return thumb link only, size forced to 200px X 200px (smart thumbnailing close to how Facebook is doing it)
  * 
  * First parameter values: link|src|tag
  * Second parameter format: aw|w=xxx&ah|ah=xxx
  * 
  * @see eHelper::scDualParams()
  * @see eHelper::scParams()
  * XXX Also returns Video thumbnails. 
  */
 function sc_newsthumbnail($parm = '')
 {
     $tmp = $this->handleMultiple($parm, 'all');
     $newsThumb = $tmp['file'];
     $class = 'news-thumbnail-' . $tmp['count'];
     if (!$newsThumb && $parm != 'placeholder') {
         return '';
     }
     if ($vThumb = e107::getParser()->toVideo($newsThumb, array('thumb' => 'src'))) {
         $src = $vThumb;
         $_src = '#';
     } else {
         $parms = eHelper::scDualParams($parm);
         if (empty($parms[2])) {
             $parms[2] = array('aw' => e107::getParser()->thumbWidth(), 'ah' => e107::getParser()->thumbHeight());
         }
         if (isset($parms[2]['legacy']) && $parms[2]['legacy'] == true) {
             if ($newsThumb[0] != '{') {
                 $newsThumb = '{e_IMAGE}newspost_images/' . $newsThumb;
             }
             $tmp = str_replace('newspost_images/thumb_', 'newspost_images/', $newsThumb);
             // swap out thumb for image.
             if (is_readable(e_IMAGE . $tmp)) {
                 $newsThumb = $tmp;
             }
             unset($parms[2]);
         }
         // We store SC path in DB now + BC
         $_src = $src = $newsThumb[0] == '{' || $parms[1] == 'placeholder' ? e107::getParser()->replaceConstants($newsThumb, 'abs') : e_IMAGE_ABS . "newspost_images/" . $newsThumb;
         if ($parms[2] || $parms[1] == 'placeholder') {
             $src = e107::getParser()->thumbUrl($src, $parms[2]);
         }
     }
     switch ($parms[1]) {
         case 'src':
             return $src;
             break;
         case 'tag':
             return "<img class='news_image " . $class . "' src='" . $src . "' alt='' style='" . $this->param['thumbnail'] . "' />";
             break;
         case 'img':
             return "<a href='" . $_src . "' rel='external image'><img class='news_image " . $class . "' src='" . $src . "' alt='' style='" . $this->param['thumbnail'] . "' /></a>";
             break;
         default:
             return "<a href='" . e107::getUrl()->create('news/view/item', $this->news_item) . "'><img class='news_image img-responsive img-rounded " . $class . "' src='" . $src . "' alt='' style='" . $this->param['thumbnail'] . "' /></a>";
             break;
     }
 }
Пример #24
0
 protected function move2download($upload)
 {
     if (!$upload['upload_active']) {
         return 0;
     }
     $media = e107::getMedia();
     $uploadPath = e_UPLOAD;
     if (!file_exists($uploadPath . $upload['upload_file'])) {
         $this->getModel()->addValidationError(LAN_FILE_NOT_FOUND);
         return false;
     }
     $downloadPath = $media->importFile($upload['upload_file'], 'download_file', $uploadPath . $upload['upload_file'], array('media_caption' => $upload['upload_name']));
     if (false === $downloadPath) {
         $this->getModel()->addValidationError(UPLLAN_66);
         return false;
     }
     $imagePath = null;
     if ($upload['upload_ss'] && file_exists($uploadPath . $upload['upload_ss'])) {
         $imagePath = $media->importFile($upload['upload_ss'], '_common_image', $uploadPath . $upload['upload_ss'], array('media_caption' => $upload['upload_name'] . ' ' . LAN_PREVIEW));
     }
     $author = $upload['upload_poster'] ? e107::getSystemUser($upload['upload_poster'])->getRealName() : LAN_ANONYMOUS;
     $dl = array('download_name' => $upload['upload_name'], 'download_url' => $downloadPath, 'download_sef' => eHelper::title2sef($upload['upload_name']), 'download_author' => $author, 'download_author_email' => $upload['upload_email'], 'download_author_website' => $upload['upload_website'], 'download_description' => $upload['upload_description'], 'download_keywords' => null, 'download_filesize' => $upload['upload_filesize'], 'download_requested' => 0, 'download_category' => $upload['upload_category'], 'download_active' => 1, 'download_datestamp' => $upload['upload_datestamp'], 'download_thumb' => null, 'download_image' => $imagePath, 'download_comment' => 1, 'download_class' => e_UC_MEMBER, 'download_visible' => e_UC_MEMBER, 'download_mirror' => null, 'download_mirror_type' => 0);
     $sql = e107::getDb('activate');
     $id = $sql->insert('download', $dl);
     if (!$id) {
         $this->getModel()->addValidationError(UPLLAN_68 . ' #' . $sql->getLastErrorNumber() . ' ' . $sql->getLastErrorText());
         e107::getMessage()->addDebug($sql->getLastQuery());
         return;
     }
     return $id;
 }
Пример #25
0
 *
 * Admin BootLoader
 *
 * $URL$
 * $Id$
*/
if (!defined('e107_INIT')) {
    exit;
}
header('Content-type: text/html; charset=utf-8', TRUE);
if (!empty($_GET['iframe'])) {
    define('e_IFRAME', true);
}
// .e-sef-generate routine.
if (ADMIN && defset('e_ADMIN_UI') && varset($_POST['mode']) == 'sef' && !empty($_POST['source']) && e_AJAX_REQUEST) {
    $d = array('converted' => eHelper::title2sef($_POST['source']));
    echo json_encode($d);
    exit;
}
### Language files
e107::coreLan('header', true);
e107::coreLan('footer', true);
$_globalLans = e107::pref('core', 'lan_global_list');
$_plugins = e107::getPref('plug_installed');
if (!empty($_plugins) && !empty($_globalLans) && is_array($_plugins) && count($_plugins) > 0) {
    $_plugins = array_keys($_plugins);
    foreach ($_plugins as $_p) {
        if (in_array($_p, $_globalLans) && defset('e_CURRENT_PLUGIN') != $_p) {
            continue;
        }
        e107::loadLanFiles($_p, 'admin');
Пример #26
0
 function preCreate()
 {
     if ($_GET['action'] == "edit" && !$_POST['preview']) {
         if (!isset($_POST['submit_news'])) {
             if (e107::getDb()->select('news', '*', 'news_id=' . intval($_GET['id']))) {
                 $row = e107::getDb()->fetch();
                 //		$this->noPermissions();
                 $_POST['news_title'] = $row['news_title'];
                 $_POST['news_sef'] = $row['news_sef'];
                 $_POST['news_body'] = $row['news_body'];
                 $_POST['news_author'] = $row['news_author'];
                 $_POST['news_extended'] = $row['news_extended'];
                 $_POST['news_allow_comments'] = $row['news_allow_comments'];
                 $_POST['news_class'] = $row['news_class'];
                 $_POST['news_summary'] = $row['news_summary'];
                 $_POST['news_sticky'] = $row['news_sticky'];
                 $_POST['news_datestamp'] = $_POST['news_datestamp'] ? $_POST['news_datestamp'] : $row['news_datestamp'];
                 $_POST['cat_id'] = $row['news_category'];
                 $_POST['news_start'] = $row['news_start'];
                 $_POST['news_end'] = $row['news_end'];
                 $_POST['comment_total'] = e107::getDb()->db_Count("comments", "(*)", " WHERE comment_item_id={$row['news_id']} AND comment_type='0'");
                 $_POST['news_render_type'] = $row['news_render_type'];
                 $_POST['news_thumbnail'] = $row['news_thumbnail'];
                 $_POST['news_meta_keywords'] = $row['news_meta_keywords'];
                 $_POST['news_meta_description'] = $row['news_meta_description'];
             }
         } else {
             if (!empty($_POST['news_meta_keywords'])) {
                 $_POST['news_meta_keywords'] = eHelper::formatMetaKeys($_POST['news_meta_keywords']);
             }
         }
     }
 }
Пример #27
0
 public function renderCache()
 {
     $comments = '';
     if ($this->cacheData['COMMENT_FLAG']) {
         $vars = new e_vars(array('comments' => $this->pageComment(true)));
         $comments = e107::getScBatch('page', null, 'cpage')->setVars($vars)->cpagecomments();
     }
     define('e_PAGETITLE', eHelper::formatMetaTitle($this->cacheData['TITLE']));
     define('META_DESCRIPTION', $this->cacheData['META_DSCR']);
     define('META_KEYWORDS', $this->cacheData['META_KEYS']);
     if ($this->debug) {
         echo "<b>Reading page from cache</b><br />";
     }
     return str_replace('[[PAGECOMMENTS]]', $comments, $this->cacheData['PAGE']);
 }
Пример #28
0
 function renderForm()
 {
     /*
     		$template = "
     		<div class='form-group'>
             <label for='firstname' class='col-sm-3 control-label'>First Name:**</label>
             <div class='col-sm-9'>
                     <input id='firstname' class=\"form-control tbox\" type=\"text\" name=\"FIRSTNAME\" size=\"20\" maxlength=\"20\" value=\"". $_POST['FIRSTNAME']. "\" required />
             </div>
          	 </div>	";
     */
     $ns = e107::getRender();
     $tp = e107::getParser();
     $text = "<div style='text-align:center'>\n\t\t\t<form enctype='multipart/form-data' method='post' onsubmit='return frmVerify()' action='" . e_SELF . "'>\n\t\t\t<table style='" . USER_WIDTH . "' class='table fborder'>\n\t\t\t<colgroup>\n\t\t\t<col style='width:30%' />\n\t\t\t<col style='width:70%' />\n\t\t\t</colgroup>\n\t\t\t<tr>\n\t\t\t<td class='forumheader3'>" . DOWLAN_11 . ":</td>\n\t\t\t<td class='forumheader3'>";
     require_once e_CORE . "shortcodes/batch/download_shortcodes.php";
     $dlparm = isset($download_category) ? $download_category : "";
     $text .= $tp->parseTemplate("{DOWNLOAD_CATEGORY_SELECT={$dlparm}}", true, $download_shortcodes);
     //FIXME - move to e_upload.php
     $text .= "</td>\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t<td style='text-align:center' class='forumheader3'>" . LAN_419 . "</td>\n\t\t\t<td class='forumheader3'>";
     //	$text .= "<b>".LAN_406."</b><br />".LAN_419.":";
     $a_filetypes = get_filetypes();
     if (count($a_filetypes) == 0) {
         $ns->tablerender(LAN_417, LAN_UL_025);
         return;
     }
     $max_upload_size = calc_max_upload_size(-1);
     // Find overriding maximum upload size
     $max_upload_size = set_max_size($a_filetypes, $max_upload_size);
     if (ADMIN) {
         $upper_limit = calc_max_upload_size();
         $allowed_filetypes = "<table class='table table-striped table-bordered'><tr><th class='text-center'>" . LAN_UL_023 . "&nbsp;&nbsp;</th><th style='text-align:right'>" . LAN_UL_024 . "</th></tr>";
         foreach ($a_filetypes as $type => $size) {
             $allowed_filetypes .= "<tr><td>{$type}</td><td style='text-align:right'>" . eHelper::parseMemorySize($size, 0) . "</td></tr>";
         }
         $allowed_filetypes .= "</table>";
     } else {
         $a_filetypes = array_keys($a_filetypes);
         $allowed_filetypes = implode(' | ', $a_filetypes);
     }
     $text .= " " . $allowed_filetypes;
     $text .= "<div class='alert alert-block alert-danger'>" . LAN_407 . "<br />" . LAN_418 . eHelper::parseMemorySize($max_upload_size, 0) . " (" . LAN_UL_022 . ")<br />";
     $text .= "<span style='text-decoration:underline'>" . LAN_408 . "</span> " . LAN_420;
     $text .= "</div>";
     $text .= "</td></tr>";
     //TODO Replcae all form inputs with $frm methods.
     if (!USER) {
         $text .= "<tr>\n\t\t\t<td class='forumheader3'>" . LAN_61 . "</td>\n\t\t\t<td class='forumheader3'><input class='tbox form-control' style='width:90%' name='file_poster' type='text' size='50' maxlength='100' value='{$poster}' /></td>\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t<td class='forumheader3'><span style='text-decoration:underline'>" . LAN_112 . "</span></td>\n\t\t\t<td class='forumheader3'><input class='tbox form-control' style='width:90%' name='file_email' id='user_email' type='text' size='50' maxlength='100' value='" . $postemail . "' required /></td>\n\t\t\t</tr>";
     }
     $text .= "\n\t\t\t<tr>\n\t\t\t<td class='forumheader3'><span style='text-decoration:underline'>" . LAN_409 . "</span></td>\n\t\t\t<td class='forumheader3'><input class='tbox form-control' style='width:90%'  name='file_name' id='file_name' type='text' size='50' maxlength='100' required /></td>\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t<td class='forumheader3'>" . LAN_410 . "</td>\n\t\t\t<td class='forumheader3'><input class='tbox form-control' style='width:90%' name='file_version' type='text' size='10' maxlength='10' /></td>\n\t\t\t</tr>\n\t\t\n\t\t\n\t\t\t<tr>\n\t\t\t<td class='forumheader3'><span style='text-decoration:underline'>" . LAN_411 . "</span></td>\n\t\t\t<td class='forumheader3'><input class='tbox' style='width:90%'  id='file_realpath' name='file_userfile[]' type='file' size='47' /></td>\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t<td class='forumheader3'>" . LAN_412 . "</td>\n\t\t\t<td class='forumheader3'><input class='tbox' style='width:90%' name='file_userfile[]' type='file' size='47' /></td>\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t<td class='forumheader3'><span style='text-decoration:underline'>" . LAN_413 . "</span></td>\n\t\t\t<td class='forumheader3'><textarea class='tbox form-control' style='width:90%' name='file_description' id='file_description' cols='59' rows='6' required></textarea></td>\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t<td class='forumheader3'>" . LAN_144 . "</td>\n\t\t\t<td class='forumheader3'><input class='tbox form-control' style='width:90%' name='file_website' type='text' size='50' maxlength='100' value='" . (defined(USERURL) ? USERURL : "") . "' /></td>\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t<td class='forumheader3'>" . LAN_414 . "<br /><span class='smalltext'>" . LAN_415 . "</span></td>\n\t\t\t<td class='forumheader3'><input class='tbox form-control' style='width:90%' name='file_demo' type='text' size='50' maxlength='100' /></td>\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t<td style='text-align:center' colspan='2' class='forumheader'><input class='btn btn-primary button' type='submit' name='upload' value='" . LAN_416 . "' /></td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t\t</form>\n\t\t\t</div>";
     $ns->tablerender(LAN_417, $text);
 }
Пример #29
0
 //
 if (!deftrue('e_IFRAME')) {
     parseheader(varset($ph) ? $cust_footer : $FOOTER);
 }
 $eTimingStop = microtime();
 global $eTimingStart;
 $clockTime = e107::getSingleton('e107_traffic')->TimeDelta($eTimingStart, $eTimingStop);
 $dbPercent = 100.0 * $db_time / $clockTime;
 // Format for display or logging
 $rendertime = number_format($clockTime, 2);
 // Clock time during page render
 $db_time = number_format($db_time, 2);
 // Clock time in DB render
 $dbPercent = number_format($dbPercent, 0);
 // DB as percent of clock
 $memuse = eHelper::getMemoryUsage();
 // Memory at end, in B/KB/MB/GB ;)
 $queryCount = $sql->db_QueryCount();
 $rinfo = '';
 $logLine = '';
 if ($pref['log_page_accesses']) {
     // Collect the first batch of data to log
     $logLine .= "'" . ($now = time()) . "','" . gmstrftime('%y-%m-%d %H:%M:%S', $now) . "','" . e107::getIPHandler()->getIP(FALSE) . "','" . e_PAGE . '?' . e_QUERY . "','" . $rendertime . "','" . $db_time . "','" . $queryCount . "','" . $memuse . "','" . $_SERVER['HTTP_USER_AGENT'] . "','{$_SERVER["REQUEST_METHOD"]}'";
 }
 if (function_exists('getrusage')) {
     $ru = getrusage();
     $cpuUTime = $ru['ru_utime.tv_sec'] + $ru['ru_utime.tv_usec'] * 1.0E-6;
     $cpuSTime = $ru['ru_stime.tv_sec'] + $ru['ru_stime.tv_usec'] * 1.0E-6;
     $cpuUStart = $eTimingStartCPU['ru_utime.tv_sec'] + $eTimingStartCPU['ru_utime.tv_usec'] * 1.0E-6;
     $cpuSStart = $eTimingStartCPU['ru_stime.tv_sec'] + $eTimingStartCPU['ru_stime.tv_usec'] * 1.0E-6;
     $cpuStart = $cpuUStart + $cpuSStart;
Пример #30
0
 /**
  * Auto-thumbnailing now allowed.
  * New sc parameter standards
  * Exampes: 
  * - {CPAGETHUMBNAIL=e_MEDIA/images/someimage.jpg|type=tag&w=200} render link with thumbnail max width 200px
  * - {CPAGETHUMBNAIL=images/someimage.jpg|w=200} same as above
  * - {CPAGETHUMBNAIL=images/someimage.jpg|type=src&aw=200&ah=200} return thumb link only, size forced to 200px X 200px (smart thumbnailing close to how Facebook is doing it)
  * 
  * @see eHelper::scDualParams()
  * @see eHelper::scParams()
  */
 function sc_cpagethumbnail($parm = '')
 {
     $parms = eHelper::scDualParams($parm);
     if (empty($parms[1])) {
         return '';
     }
     $tp = e107::getParser();
     $path = rawurldecode($parms[1]);
     if (substr($path, 0, 2) === 'e_') {
         $path = str_replace($tp->getUrlConstants('raw'), $tp->getUrlConstants('sc'), $path);
     } elseif ($path[0] !== '{') {
         $path = '{e_MEDIA}' . $path;
     }
     $thumb = $tp->thumbUrl($path);
     $type = varset($parms[2]['type'], 'tag');
     switch ($type) {
         case 'src':
             return $thumb;
             break;
         case 'link':
             return '<a href="' . $tp->replaceConstants($path, 'abs') . '" class="cpage-image" rel="external image"><img class="cpage-image" src="' . $src . '" alt="' . varset($parms[1]['alt']) . '" /></a>';
             break;
         case 'tag':
         default:
             return '<img class="cpage-image" src="' . $thumb . '" alt="' . varset($parms[1]['alt']) . '" />';
             break;
     }
 }