Esempio n. 1
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;
 }
Esempio n. 2
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);
     }
 }
Esempio n. 3
0
 public function beforeUpdate($new_data, $old_data, $id)
 {
     if (!empty($new_data['news_thumbnail'])) {
         $new_data['news_thumbnail'] = $this->processThumbs($new_data['news_thumbnail']);
     }
     if (isset($new_data['news_datestamp']) && empty($new_data['news_datestamp'])) {
         $new_data['news_datestamp'] = time();
     }
     if (isset($new_data['news_sef']) && empty($new_data['news_sef']) && !empty($new_data['news_title'])) {
         $new_data['news_sef'] = eHelper::title2sef($new_data['news_title']);
     }
     if (!empty($new_data['news_author'])) {
         $tmp = explode(chr(35), $new_data['news_author']);
         $new_data['news_author'] = intval($tmp[0]);
     }
     if (E107_DBG_SQLQUERIES) {
         e107::getMessage()->addInfo("<h3>Raw _POST data</h3>" . print_a($_POST, true));
     }
     return $new_data;
 }
Esempio n. 4
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;
 }
Esempio n. 5
0
function forum_track()
{
    global $forum;
    $trackPref = $forum->prefs->get('track');
    if (empty($trackPref)) {
        echo "Disabled";
        return false;
    }
    $FORUM_TEMPLATE = null;
    include e_PLUGIN . 'forum/templates/forum_template.php';
    // Override with theme template
    if (file_exists(THEME . 'forum_template.php')) {
        include THEME . 'forum_template.php';
    } elseif (file_exists(THEME . 'templates/forum/forum_template.php')) {
        require THEME . 'templates/forum/forum_template.php';
    }
    $IMAGE_nonew_small = IMAGE_nonew_small;
    $IMAGE_new_small = IMAGE_new_small;
    if (is_array($FORUM_TEMPLATE) && deftrue('BOOTSTRAP', false)) {
        $FORUM_TRACK_START = $FORUM_TEMPLATE['track']['start'];
        // $FORUM_TEMPLATE['track-start'];
        $FORUM_TRACK_MAIN = $FORUM_TEMPLATE['track']['item'];
        // $FORUM_TEMPLATE['track-main'];
        $FORUM_TRACK_END = $FORUM_TEMPLATE['track']['end'];
        // $FORUM_TEMPLATE['track-end'];
        $IMAGE_nonew_small = IMAGE_nonew;
        $IMAGE_new_small = IMAGE_new;
    }
    $sql = e107::getDb();
    $tp = e107::getParser();
    if ($trackedThreadList = $forum->getTrackedThreadList(USERID, 'list')) {
        $viewed = $forum->threadGetUserViewed();
        $qry = "SELECT t.*,th.*, f.* FROM `#forum_track` AS t\n\t\tLEFT JOIN `#forum_thread` AS th ON t.track_thread = th.thread_id\n\t\tLEFT JOIN `#forum` AS f ON th.thread_forum_id = f.forum_id\n\t\tWHERE t.track_userid = " . USERID . " ORDER BY th.thread_lastpost DESC";
        $forum_trackstring = '';
        $data = array();
        if ($sql->gen($qry)) {
            while ($row = $sql->fetch(MYSQL_ASSOC)) {
                $row['thread_sef'] = eHelper::title2sef($row['thread_name'], 'dashl');
                $data['NEWIMAGE'] = $IMAGE_nonew_small;
                if ($row['thread_datestamp'] > USERLV && !in_array($row['thread_id'], $viewed)) {
                    $data['NEWIMAGE'] = $IMAGE_new_small;
                }
                $buttonId = "forum-track-button-" . intval($row['thread_id']);
                $forumUrl = e107::url('forum', 'forum', $row);
                $threadUrl = e107::url('forum', 'topic', $row, array('query' => array('last' => 1)));
                // ('forum/thread/view', $row); // configs will be able to map thread_* vars to the url
                $data['TRACKPOSTNAME'] = "<a href='" . $forumUrl . "'>" . $row['forum_name'] . "</a> / <a href='" . $threadUrl . "'>" . $tp->toHTML($row['thread_name']) . '</a>';
                //	$data['UNTRACK'] = "<a class='btn btn-default' href='".e_SELF."?untrack.".$row['thread_id']."'>".LAN_FORUM_0070."</a>";
                $data['UNTRACK'] = "<a id='" . $buttonId . "' href='#' title=\"" . LAN_FORUM_3040 . "\" data-token='" . e_TOKEN . "' data-forum-insert='" . $buttonId . "'  data-forum-post='" . $row['thread_forum_id'] . "' data-forum-thread='" . $row['thread_id'] . "' data-forum-action='track' name='track' class='btn btn-primary' >" . IMAGE_track . "</a>";
                $forum_trackstring .= $tp->simpleParse($FORUM_TRACK_MAIN, $data);
            }
        }
        //	print_a($FORUM_TRACK_START);
        if (deftrue('BOOTSTRAP')) {
            $breadarray = array(array('text' => e107::pref('forum', 'title', LAN_PLUGIN_FORUM_NAME), 'url' => e107::url('forum', 'index')), array('text' => LAN_FORUM_0030, 'url' => null));
            $data['FORUM_BREADCRUMB'] = e107::getForm()->breadcrumb($breadarray);
        }
        $forum_track_start = $tp->simpleParse($FORUM_TRACK_START, $data);
        $forum_track_end = $tp->simpleParse($FORUM_TRACK_END, $data);
        // $ns->tablerender($forum->prefs->get('title'), $forum_track_start.$forum_trackstring.$forum_track_end, array('forum', 'main1'));
        $tracktext = $forum_track_start . $forum_trackstring . $forum_track_end;
    }
    $text = '';
    $text .= $tracktext;
    $text .= "<div class='center'>" . e107::getForm()->pagination(e107::url('forum', 'index'), LAN_BACK) . "</div>";
    e107::getRender()->tablerender(LAN_FORUM_0030, $text, array('forum', 'forum_track'));
}
Esempio n. 6
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);
     }
 }
Esempio n. 7
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;
 }
Esempio n. 8
0
 /**
  * Rebuild SEF Urls for a particular table
  * @param $table
  * @param primary field id. 
  * @param input field (title)
  * @param output field (sef)
  */
 private function rebuild($table, $primary, $input, $output)
 {
     if (empty($table) || empty($input) || empty($output) || empty($primary)) {
         e107::getMessage()->addError("Missing Generator data");
         return;
     }
     $sql = e107::getDb();
     $data = $sql->retrieve($table, $primary . "," . $input, $input . " != '' ", true);
     $success = 0;
     $failed = 0;
     foreach ($data as $row) {
         $sef = eHelper::title2sef($row[$input]);
         if ($sql->update($table, $output . " = '" . $sef . "' WHERE " . $primary . " = " . intval($row[$primary]) . " LIMIT 1") !== false) {
             $success++;
         } else {
             $failed++;
         }
         // echo $row[$input]." => ".$output ." = '".$sef."'  WHERE ".$primary. " = ".intval($row[$primary]). " LIMIT 1 <br />";
     }
     if ($success) {
         e107::getMessage()->addSuccess($success . LAN_EURL_SURL_UPD);
     }
     if ($failed) {
         e107::getMessage()->addError($failed . LAN_EURL_SURL_NUPD);
     }
 }
Esempio n. 9
0
 /**
  * Zip up folders and files 
  * @param array $filePaths
  * @param string $newFile
  */
 public function zip($filePaths = null, $newFile = '', $options = array())
 {
     if (empty($newFile)) {
         $newFile = e_BACKUP . eHelper::title2sef(SITENAME) . "_" . date("Y-m-d-H-i-s") . ".zip";
     }
     if (is_null($filePaths)) {
         return "No file-paths set!";
     }
     require_once e_HANDLER . 'pclzip.lib.php';
     $archive = new PclZip($newFile);
     $removePath = !empty($options['remove_path']) ? $options['remove_path'] : e_BASE;
     if ($archive->create($filePaths, PCLZIP_OPT_REMOVE_PATH, $removePath) == 0) {
         $error = $archive->errorInfo(true);
         e107::getAdminLog()->addError($error)->save('FILE', E_LOG_NOTICE);
         return false;
     } else {
         return $newFile;
     }
 }
Esempio n. 10
0
 function beforeCreate($newdata, $olddata)
 {
     $newdata['menu_name'] = preg_replace('/[^\\w-*]/', '-', $newdata['menu_name']);
     if (empty($newdata['page_sef'])) {
         if (!empty($newdata['page_title'])) {
             $newdata['page_sef'] = eHelper::title2sef($newdata['page_title']);
         } elseif (!empty($newdata['menu_name'])) {
             $newdata['page_sef'] = eHelper::title2sef($newdata['menu_name']);
         }
     } else {
         $newdata['page_sef'] = eHelper::secureSef($newdata['page_sef']);
     }
     $sef = e107::getParser()->toDB($newdata['page_sef']);
     if (e107::getDb()->count('page', '(*)', "page_sef='{$sef}'")) {
         e107::getMessage()->addError(CUSLAN_57);
         return false;
     }
     return $newdata;
 }
Esempio n. 11
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']);
             $message = LAN_NEWS_21;
             $emessage->add(LAN_NEWS_21, 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_NEWS_46, E_MESSAGE_INFO, $smessages);
                 $message = "<strong>" . LAN_NEWS_46 . "</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_NEWS_6, 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']);
             //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_NEWS_7, E_MESSAGE_ERROR, $smessages);
         }
     }
     /* FIXME - trackback should be hooked!	*/
     if ($news['news_id'] && $pref['trackbackEnabled']) {
         $excerpt = e107::getParser()->text_truncate(strip_tags(e107::getParser()->post_toHTML($news['news_body'])), 100, '...');
         //			$id=mysql_insert_id();
         $permLink = $e107->base_path . "comment.php?comment.news." . intval($news['news_id']);
         require_once e_PLUGIN . "trackback/trackbackClass.php";
         $trackback = new trackbackClass();
         if ($_POST['trackback_urls']) {
             $urlArray = explode("\n", $_POST['trackback_urls']);
             foreach ($urlArray as $pingurl) {
                 if (!($terror = $trackback->sendTrackback($permLink, $pingurl, $news['news_title'], $excerpt))) {
                     $message .= "<br />successfully pinged {$pingurl}.";
                     $emessage->add("Successfully pinged {$pingurl}.", E_MESSAGE_SUCCESS, $smessages);
                 } else {
                     $message .= "<br />was unable to ping {$pingurl}<br />[ Error message returned was : '{$terror}'. ]";
                     $emessage->add("was unable to ping {$pingurl}<br />[ Error message returned was : '{$terror}'. ]", E_MESSAGE_ERROR, $smessages);
                 }
             }
         }
         if (isset($_POST['pingback_urls'])) {
             if ($urlArray = $trackback->getPingUrls($news['news_body'])) {
                 foreach ($urlArray as $pingurl) {
                     if ($trackback->sendTrackback($permLink, $pingurl, $news['news_title'], $excerpt)) {
                         $message .= "<br />successfully pinged {$pingurl}.";
                         $emessage->add("Successfully pinged {$pingurl}.", E_MESSAGE_SUCCESS, $smessages);
                     } else {
                         $message .= "Pingback to {$pingurl} failed ...";
                         $emessage->add("Pingback to {$pingurl} failed ...", E_MESSAGE_ERROR, $smessages);
                     }
                 }
             } else {
                 $message .= "<br />No pingback addresses were discovered";
                 $emessage->add("No pingback addresses were discovered", E_MESSAGE_INFO, $smessages);
             }
         }
     }
     /* end trackback */
     //return $message;
     $data['message'] = $message;
     $data['error'] = $error;
     return $data;
 }
Esempio n. 12
0
    while (@ob_end_clean()) {
    }
    if (varset($_GET['mode']) == 'backup') {
        echo "Starting file backup...<br />";
        $data = array();
        $data[] = e_MEDIA;
        $data[] = e_LOG;
        $data[] = e_IMPORT;
        $data[] = e_TEMP;
        $data[] = e_SYSTEM . "filetypes.xml";
        $data[] = e_THEME . e107::getPref('sitetheme');
        $plugins = e107::getPlugin()->getOtherPlugins();
        foreach ($plugins as $dir) {
            $data[] = e_PLUGIN . $dir;
        }
        $newFile = eHelper::title2sef(SITENAME) . "_" . date("Y-m-d-H-i-s");
        $zip = e107::getFile()->zip($data, e_BACKUP . $newFile . ".zip");
        echo DBLAN_60 . " <small>(" . $zip . ")</small><br />";
        echo DBLAN_61 . "<br />";
        $dbfile = e107::getDb()->backup('*', $newFile . ".sql", array('nologs' => 1, 'droptable' => 1));
        echo DBLAN_62 . " <small>(" . $dbfile . ")</small>";
        e107::getAdminLog()->addSuccess($zip . " " . $dbfile, false)->save(DBLAN_63);
    }
    exit;
}
require_once "auth.php";
$st = new system_tools();
/* No longer needed after XML feature added.

if(isset($_POST['backup_core']) || $_GET['mode']=='backup_core')
{
Esempio n. 13
0
 function threadGetNextPrev($which, $threadId, $forumId, $lastpost)
 {
     $sql = e107::getDb();
     $forumId = (int) $forumId;
     $lastpost = (int) $lastpost;
     $dir = $which == 'next' ? '<' : '>';
     $qry = "\n\t\t\tSELECT t.thread_id, t.thread_name, f.forum_id, f.forum_sef FROM `#forum_thread` AS t\n\t\t\tLEFT JOIN `#forum` AS f ON t.thread_forum_id = f.forum_id\n\t\t\tWHERE t.thread_forum_id = {$forumId}\n\t\t\tAND t.thread_lastpost {$dir} {$lastpost}\n\t\t\tORDER BY\n\t\t\tt.thread_sticky DESC,\n\t\t\tt.thread_lastpost ASC\n\t\t\tLIMIT 1";
     //		e107::getMessage()->addDebug(ucfirst($which)." Thread Qry: ".$qry);
     if ($sql->gen($qry)) {
         $row = $sql->fetch();
         $row['thread_sef'] = eHelper::title2sef($row['thread_name'], 'dashl');
         //		e107::getMessage()->addInfo(ucfirst($which).print_a($row,true));
         return $row;
         //	return $row['thread_id'];
     } else {
         //	e107::getMessage()->addDebug(ucfirst($which)." Thread Qry Returned Nothing: ".$qry);
     }
     return false;
 }
Esempio n. 14
0
 function _observe_update_category()
 {
     if (!getperms('0|7')) {
         $this->noPermissions();
     }
     $this->setId(intval($_POST['category_id']));
     if (!$this->getId()) {
         return;
     }
     //FIXME - lan, e_model based news administration model
     $this->error = false;
     if (empty($_POST['category_name'])) {
         $this->show_message('Validation Error: Missing Category name', E_MESSAGE_ERROR);
         $this->error = true;
         if (!empty($_POST['category_sef'])) {
             $_POST['category_sef'] = eHelper::secureSef($_POST['category_sef']);
         }
     } else {
         // first format sef...
         if (empty($_POST['category_sef'])) {
             $_POST['category_sef'] = eHelper::title2sef($_POST['category_name']);
         } else {
             $_POST['category_sef'] = eHelper::secureSef($_POST['category_sef']);
         }
     }
     // ...then check it
     if (empty($_POST['category_sef'])) {
         $this->error = true;
         $this->show_message('Validation error: News Category SEF URL value is required field and can\'t be empty!', E_MESSAGE_ERROR);
     } elseif (e107::getDb()->db_Count('news_category', '(category_id)', "category_id<>" . $this->getId() . " AND category_sef='" . (e107::getParser()->toDB($_POST['category_sef']) . "'"))) {
         $this->error = true;
         $this->show_message('Validation error: News Category SEF URL is unique field - current value already in use! Please choose another SEF URL value.', E_MESSAGE_ERROR);
     }
     if (!$this->error) {
         $updatea = array();
         $updatea['data']['category_icon'] = $_POST['category_icon'];
         $updatea['_FIELD_TYPES']['category_icon'] = 'todb';
         $updatea['data']['category_name'] = $_POST['category_name'];
         $updatea['_FIELD_TYPES']['category_name'] = 'todb';
         $updatea['data']['category_sef'] = $_POST['category_sef'];
         $updatea['_FIELD_TYPES']['category_sef'] = 'todb';
         $updatea['data']['category_meta_description'] = strip_tags($_POST['category_meta_description']);
         $updatea['_FIELD_TYPES']['category_meta_description'] = 'str';
         $updatea['data']['category_meta_keywords'] = $_POST['category_meta_keywords'];
         $updatea['_FIELD_TYPES']['category_meta_keywords'] = 'str';
         $updatea['data']['category_manager'] = $_POST['category_manager'];
         $updatea['_FIELD_TYPES']['category_manager'] = 'int';
         $updatea['data']['category_order'] = $_POST['category_order'];
         $updatea['_FIELD_TYPES']['category_order'] = 'int';
         $updatea['WHERE'] = 'category_id=' . $this->getId();
         $inserta = array();
         $rid = 0;
         $upcheck = e107::getDb()->db_Update("news_category", $updatea);
         $rwupcheck = false;
         if ($upcheck || !e107::getDb()->getLastErrorNumber()) {
             if ($upcheck || $rwupcheck) {
                 //admin log now supports DB array and method chaining
                 $updatea['data']['category_id'] = $this->getId();
                 if ($upcheck) {
                     e107::getAdminLog()->log_event('NEWS_05', $updatea['data'], E_LOG_INFORMATIVE, '');
                 }
                 if ($rwupcheck && $inserta['data']) {
                     e107::getAdminLog()->log_event('NEWS_10', $inserta['data'], E_LOG_INFORMATIVE, '');
                 }
                 $this->show_message(NWSLAN_36, E_MESSAGE_SUCCESS);
                 $this->clear_cache();
                 //TODO - add to WIKI docs
                 e107::getEvent()->trigger("newscatupd", array_merge($updatea['data'], $inserta['data']));
             } else {
                 $this->show_message(LAN_NO_CHANGE);
             }
             $this->setId(0);
         } else {
             $this->error = true;
             $this->setSubAction('edit');
             $this->show_message('mySQL Error detected!', E_MESSAGE_ERROR);
             $this->show_message('#' . e107::getDb()->getLastErrorNumber() . ': ' . e107::getDb()->getLastErrorText(), E_MESSAGE_DEBUG);
             return;
         }
     }
 }
Esempio n. 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;
 }
Esempio n. 16
0
File: faqs.php Progetto: armpit/e107
 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;
 }
Esempio n. 17
0
 public function beforeUpdate($new_data, $old_data, $id)
 {
     if (!empty($new_data['news_thumbnail'])) {
         $new_data['news_thumbnail'] = $this->processThumbs($new_data['news_thumbnail']);
     }
     if (empty($new_data['news_datestamp'])) {
         $new_data['news_datestamp'] = time();
     }
     if (empty($new_data['news_sef']) && !empty($new_data['news_title'])) {
         $new_data['news_sef'] = eHelper::title2sef($new_data['news_title']);
     }
     if (!empty($new_data['news_author'])) {
         $tmp = explode(chr(35), $new_data['news_author']);
         $new_data['news_author'] = intval($tmp[0]);
     }
     return $new_data;
 }
Esempio n. 18
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);
 }
Esempio n. 19
0
 function submit_download()
 {
     global $e107, $tp, $sql, $DOWNLOADS_DIRECTORY, $e_event;
     $action = $this->action;
     $subAction = $this->subAction;
     $id = $this->id;
     $sql = e107::getDb();
     $tp = e107::getParser();
     $fl = e107::getFile();
     $mes = e107::getMessage();
     $dlInfo = array();
     $dlMirrors = array();
     if ($subAction == 'edit') {
         if ($_POST['download_url_external'] == '') {
             $_POST['download_filesize_external'] = FALSE;
         }
     }
     if (!empty($_POST['download_url_external']) && empty($_POST['download_url']) && !empty($_POST['download_filesize_unit'])) {
         $dlInfo['download_url'] = $tp->toDB($_POST['download_url_external']);
         //	$filesize = intval($_POST['download_filesize_external']);
         $filesize = $this->calc_filesize($_POST['download_filesize_external'], $_POST['download_filesize_unit']);
     } else {
         $dlInfo['download_url'] = $tp->toDB($_POST['download_url']);
         if ($_POST['download_filesize_external']) {
             $filesize = intval($_POST['download_filesize_external']);
         } else {
             if (strpos($DOWNLOADS_DIRECTORY, "/") === 0 || strpos($DOWNLOADS_DIRECTORY, ":") >= 1) {
                 $filesize = filesize($DOWNLOADS_DIRECTORY . $dlInfo['download_url']);
             } elseif ($dlInfo['download_url'][0] == '{') {
                 $filesize = filesize($tp->replaceConstants($dlInfo['download_url']));
             } else {
                 $filesize = filesize(e_BASE . $DOWNLOADS_DIRECTORY . $dlInfo['download_url']);
             }
         }
     }
     if (!$filesize) {
         if ($sql->select("upload", "upload_filesize", "upload_file='{$dlInfo['download_url']}'")) {
             $row = $sql->fetch();
             $filesize = $row['upload_filesize'];
         }
     }
     $dlInfo['download_filesize'] = $filesize;
     //  ----   Move Images and Files ------------
     if ($_POST['move_image']) {
         if ($_POST['download_thumb']) {
             $oldname = e_UPLOAD . $_POST['download_thumb'];
             $newname = e_FILE . "downloadthumbs/" . $_POST['download_thumb'];
             if (!$this->move_file($oldname, $newname)) {
                 return;
             }
         }
         if ($_POST['download_image']) {
             $oldname = e_UPLOAD . $_POST['download_image'];
             $newname = e_FILE . "downloadimages/" . $_POST['download_image'];
             if (!$this->move_file($oldname, $newname)) {
                 return;
             }
         }
     }
     if ($_POST['move_file'] && $_POST['download_url']) {
         $oldname = e_UPLOAD . $_POST['download_url'];
         $newname = $_POST['move_file'] . $_POST['download_url'];
         if (!$this->move_file($oldname, $newname)) {
             return;
         }
         $dlInfo['download_url'] = str_replace(e_DOWNLOAD, "", $newname);
     }
     // ------------------------------------------
     $dlInfo['download_description'] = $tp->toDB($_POST['download_description']);
     $dlInfo['download_name'] = $tp->toDB($_POST['download_name']);
     $dlInfo['download_sef'] = vartrue($_POST['download_sef']) ? eHelper::secureSef($_POST['download_sef']) : eHelper::title2sef($_POST['download_name']);
     $dlInfo['download_keywords'] = $tp->toDB($_POST['download_keywords']);
     $dlInfo['download_author'] = $tp->toDB($_POST['download_author']);
     $dlInfo['download_author_email'] = $tp->toDB($_POST['download_author_email']);
     $dlInfo['download_author_website'] = $tp->toDB($_POST['download_author_website']);
     $dlInfo['download_category'] = intval($_POST['download_category']);
     $dlInfo['download_active'] = intval($_POST['download_active']);
     $dlInfo['download_thumb'] = $tp->toDB($_POST['download_thumb']);
     $dlInfo['download_image'] = $tp->toDB($_POST['download_image']);
     $dlInfo['download_comment'] = $tp->toDB($_POST['download_comment']);
     $dlInfo['download_class'] = $tp->toDB($_POST['download_class']);
     $dlInfo['download_visible'] = $tp->toDB($_POST['download_visible']);
     $dlInfo['download_datestamp'] = e107::getDate()->convert($_POST['download_datestamp'], 'inputdate');
     if ($_POST['update_datestamp']) {
         $dlInfo['download_datestamp'] = time();
     }
     $mirrorStr = "";
     $mirrorFlag = FALSE;
     // See if any mirrors defined
     // Need to check all the possible mirror names - might have deleted the first one if we're in edit mode
     if (count($_POST['download_mirror_name'])) {
         foreach ($_POST['download_mirror_name'] as $mn) {
             if ($mn) {
                 $mirrorFlag = TRUE;
                 break;
             }
         }
     }
     if ($mirrorFlag) {
         $mirrors = count($_POST['download_mirror_name']);
         $mirrorArray = array();
         $newMirrorArray = array();
         if ($id && $sql->select('download', 'download_mirror', 'download_id = ' . $id)) {
             if ($row = $sql->fetch()) {
                 $mirrorArray = $this->makeMirrorArray($row['download_mirror'], TRUE);
             }
         }
         for ($a = 0; $a < $mirrors; $a++) {
             $mid = trim($_POST['download_mirror_name'][$a]);
             $murl = trim($_POST['download_mirror'][$a]);
             $msize = trim($_POST['download_mirror_size'][$a]);
             if ($mid && $murl) {
                 $newMirrorArray[$mid] = array('id' => $mid, 'url' => $murl, 'requests' => 0, 'filesize' => $msize);
                 if (DOWNLOAD_DEBUG && !$id) {
                     $newMirrorArray[$mid]['requests'] = intval($_POST['download_mirror_requests'][$a]);
                 }
             }
         }
         // Now copy across any existing usage figures
         foreach ($newMirrorArray as $k => $m) {
             if (isset($mirrorArray[$k])) {
                 $newMirrorArray[$k]['requests'] = $mirrorArray[$k]['requests'];
             }
         }
         $mirrorStr = $this->compressMirrorArray($newMirrorArray);
     }
     $dlMirrors['download_mirror'] = $mirrorStr;
     $dlMirrors['download_mirror_type'] = intval($_POST['download_mirror_type']);
     if ($id) {
         // Process triggers before calling admin_update so trigger messages can be shown
         $data = array('method' => 'update', 'table' => 'download', 'id' => $id, 'plugin' => 'download', 'function' => 'update_download');
         $hooks = $e107->e_event->triggerHook($data);
         $mes->add($hooks, E_MESSAGE_SUCCESS);
         $updateArray = array_merge($dlInfo, $dlMirrors);
         $updateArray['WHERE'] = 'download_id=' . intval($id);
         $mes->addAuto($sql->db_Update('download', $updateArray), 'update', DOWLAN_2 . " (<a href='" . e_PLUGIN . "download/download.php?view." . $id . "'>" . $_POST['download_name'] . "</a>)");
         $dlInfo['download_id'] = $id;
         $this->downloadLog('DOWNL_06', $dlInfo, $dlMirrors);
         $dlInfo['download_datestamp'] = $time;
         // This is what 0.7 did, regardless of settings
         unset($dlInfo['download_class']);
         // Also replicating 0.7
         $e_event->trigger('dlupdate', $dlInfo);
         // @deprecated
         e107::getEvent()->trigger('admin_download_update', $dlInfo);
     } else {
         if ($download_id = $sql->insert('download', array_merge($dlInfo, $dlMirrors))) {
             // Process triggers before calling admin_update so trigger messages can be shown
             $data = array('method' => 'create', 'table' => 'download', 'id' => $download_id, 'plugin' => 'download', 'function' => 'create_download');
             $hooks = $e107->e_event->triggerHook($data);
             $mes->add($hooks, E_MESSAGE_SUCCESS);
             $mes->addAuto($download_id, 'insert', DOWLAN_1 . " (<a href='" . e_PLUGIN . "download/download.php?view." . $download_id . "'>" . $_POST['download_name'] . "</a>)");
             $dlInfo['download_id'] = $download_id;
             $this->downloadLog('DOWNL_05', $dlInfo, $dlMirrors);
             $dlInfo['download_datestamp'] = $time;
             // This is what 0.7 did, regardless of settings
             unset($dlInfo['download_class']);
             // Also replicating 0.7
             $e_event->trigger("dlpost", $dlInfo);
             // @deprecated
             e107::getEvent()->trigger('admin_download_create', $dlInfo);
             if ($_POST['remove_upload']) {
                 $sql->db_Update("upload", "upload_active='1' WHERE upload_id='" . $_POST['remove_id'] . "'");
                 $mess = "<br/>" . $_POST['download_name'] . " " . DOWLAN_104;
                 $mess .= "<br/><br/><a href='" . e_ADMIN . "upload.php'>" . DOWLAN_105 . "</a>";
                 $this->show_message($mess);
             }
         }
     }
 }
Esempio n. 20
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;
 }
Esempio n. 21
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);
}
Esempio n. 22
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');
Esempio n. 23
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;
         }
     }
 }
Esempio n. 24
0
 function submit_item($news, $smessages = false)
 {
     $tp = e107::getParser();
     $sql = e107::getDb();
     $admin_log = e107::getAdminLog();
     $pref = e107::getPref();
     $e_event = e107::getEvent();
     $e107cache = e107::getCache();
     $emessage = e107::getMessage();
     $error = false;
     if (empty($news['news_title'])) {
         $error = true;
         $emessage->add('Validation error: News title can\'t be empty!', E_MESSAGE_ERROR, $smessages);
         if (!empty($news['news_sef'])) {
             $news['news_sef'] = eHelper::secureSef($news['news_sef']);
         }
     } else {
         // first format sef...
         if (empty($news['news_sef'])) {
             $news['news_sef'] = eHelper::title2sef($news['news_title']);
         } else {
             $news['news_sef'] = eHelper::secureSef($news['news_sef']);
         }
     }
     // ...then check it
     if (empty($news['news_sef'])) {
         $error = true;
         $emessage->add('Validation error: News SEF URL value is required field and can\'t be empty!', E_MESSAGE_ERROR, $smessages);
     } elseif ($sql->db_Count('news', '(news_id)', ($news['news_sef'] ? 'news_id<>' . intval($news['news_id']) . ' AND ' : '') . "news_sef='" . $tp->toDB($news['news_sef']) . "'")) {
         $error = true;
         $emessage->add('Validation error: News SEF URL is unique field - current value already in use! Please choose another SEF URL value.', E_MESSAGE_ERROR, $smessages);
     }
     if (empty($news['news_category'])) {
         $error = true;
         $emessage->add('Validation error: News category can\'t be empty!', E_MESSAGE_ERROR, $smessages);
     }
     $data = array();
     //DB Array
     $data['data']['news_title'] = $news['news_title'];
     $data['_FIELD_TYPES']['news_title'] = 'todb';
     $data['data']['news_sef'] = $news['news_sef'];
     $data['_FIELD_TYPES']['news_sef'] = 'todb';
     $data['data']['news_body'] = $news['news_body'];
     $data['_FIELD_TYPES']['news_body'] = 'todb';
     $data['data']['news_extended'] = $news['news_extended'];
     $data['_FIELD_TYPES']['news_extended'] = 'todb';
     $data['data']['news_datestamp'] = $news['news_datestamp'];
     $data['_FIELD_TYPES']['news_datestamp'] = 'int';
     $data['data']['news_author'] = $news['news_author'] ? $news['news_author'] : USERID;
     $data['_FIELD_TYPES']['news_author'] = 'int';
     $data['data']['news_category'] = $news['news_category'];
     $data['_FIELD_TYPES']['news_category'] = 'int';
     $data['data']['news_allow_comments'] = $news['news_allow_comments'];
     $data['_FIELD_TYPES']['news_allow_comments'] = 'int';
     $data['data']['news_start'] = $news['news_start'];
     $data['_FIELD_TYPES']['news_start'] = 'int';
     $data['data']['news_end'] = $news['news_end'];
     $data['_FIELD_TYPES']['news_end'] = 'int';
     $data['data']['news_class'] = $news['news_class'];
     $data['_FIELD_TYPES']['news_class'] = 'todb';
     $data['data']['news_render_type'] = $news['news_render_type'];
     $data['_FIELD_TYPES']['news_render_type'] = 'todb';
     //news_comment_total
     $data['data']['news_summary'] = $news['news_summary'];
     $data['_FIELD_TYPES']['news_summary'] = 'todb';
     $data['data']['news_thumbnail'] = $news['news_thumbnail'];
     $data['_FIELD_TYPES']['news_thumbnail'] = 'todb';
     $data['data']['news_sticky'] = $news['news_sticky'];
     $data['_FIELD_TYPES']['news_sticky'] = 'int';
     $data['data']['news_meta_keywords'] = eHelper::formatMetaKeys($news['news_meta_keywords']);
     $data['_FIELD_TYPES']['news_meta_keywords'] = 'todb';
     $data['data']['news_meta_description'] = eHelper::formatMetaDescription($news['news_meta_description']);
     //handle bbcodes
     $data['_FIELD_TYPES']['news_meta_description'] = 'todb';
     if ($error) {
         $data['error'] = true;
         return $data;
     }
     // Calculate short strings for admin logging - no need to clog up the log with potentially long items
     $logData = $data['data'];
     if (isset($logData['news_body'])) {
         $logData['news_body'] = $tp->text_truncate($tp->toDB($logData['news_body']), 300, '...');
     }
     if (isset($logData['news_extended'])) {
         $logData['news_extended'] = $tp->text_truncate($tp->toDB($logData['news_extended']), 300, '...');
     }
     //XXX - Now hooks are executed only if no mysql error is found. Should it stay so? Seems sensible to me!
     if ($news['news_id']) {
         // Updating existing item
         $data['WHERE'] = 'news_id=' . intval($news['news_id']);
         //$vals = "news_datestamp = '".intval($news['news_datestamp'])."', ".$author_insert." news_title='".$news['news_title']."', news_body='".$news['news_body']."', news_extended='".$news['news_extended']."', news_category='".intval($news['cat_id'])."', news_allow_comments='".intval($news['news_allow_comments'])."', news_start='".intval($news['news_start'])."', news_end='".intval($news['news_end'])."', news_class='".$tp->toDB($news['news_class'])."', news_render_type='".intval($news['news_rendertype'])."' , news_summary='".$news['news_summary']."', news_thumbnail='".$tp->toDB($news['news_thumbnail'])."', news_sticky='".intval($news['news_sticky'])."' WHERE news_id='".intval($news['news_id'])."' ";
         if ($sql->db_Update('news', $data)) {
             e107::getAdminLog()->logArrayAll('NEWS_09', $logData);
             $data['data']['news_id'] = $news['news_id'];
             e107::getEvent()->trigger('newsupd', $data['data']);
             e107::getEvent()->trigger('admin_news_updated', $data['data']);
             $message = LAN_UPDATED;
             $emessage->add(LAN_UPDATED, E_MESSAGE_SUCCESS, $smessages);
             e107::getCache()->clear('news.php');
             //FIXME - triggerHook should return array(message, message_type)
             $evdata = array('method' => 'update', 'table' => 'news', 'id' => $news['news_id'], 'plugin' => 'news', 'function' => 'submit_item');
             $emessage->add(e107::getEvent()->triggerHook($evdata), E_MESSAGE_INFO, $smessages);
         } else {
             if ($sql->getLastErrorNumber()) {
                 $error = true;
                 $emessage->add(LAN_NEWS_5, E_MESSAGE_ERROR, $smessages);
                 $message = "<strong>" . LAN_NEWS_5 . "</strong>";
             } else {
                 $data['data']['news_id'] = $news['news_id'];
                 $emessage->add(LAN_NO_CHANGE, E_MESSAGE_INFO, $smessages);
                 $message = "<strong>" . LAN_NO_CHANGE . "</strong>";
                 //FIXME - triggerHook should return array(message, message_type)
                 $evdata = array('method' => 'update', 'table' => 'news', 'id' => $news['news_id'], 'plugin' => 'news', 'function' => 'submit_item');
                 $emessage->add(e107::getEvent()->triggerHook($evdata), E_MESSAGE_INFO, $smessages);
             }
         }
     } else {
         // Adding item
         $data['data']['news_id'] = $sql->db_Insert('news', $data);
         $news['news_id'] = $data['data']['news_id'];
         //$news['news_id'] = $sql ->db_Insert('news', "0, '".$news['news_title']."', '".$news['news_body']."', '".$news['news_extended']."', ".intval($news['news_datestamp']).", ".intval($news['news_author']).", '".intval($news['cat_id'])."', '".intval($news['news_allow_comments'])."', '".intval($news['news_start'])."', '".intval($news['news_end'])."', '".$tp->toDB($news['news_class'])."', '".intval($news['news_rendertype'])."', '0' , '".$news['news_summary']."', '".$tp->toDB($news['news_thumbnail'])."', '".intval($news['news_sticky'])."' ")
         if ($data['data']['news_id']) {
             $data['news_id'] = $news['news_id'];
             $message = LAN_NEWS_6;
             $emessage->add(LAN_CREATED, E_MESSAGE_SUCCESS, $smessages);
             e107::getCache()->clear('news.php');
             //moved down - prevent wrong mysql_insert_id
             e107::getAdminLog()->logArrayAll('NEWS_08', $logData);
             e107::getEvent()->trigger('newspost', $data['data']);
             e107::getEvent()->trigger('admin_news_created', $data['data']);
             //XXX - triggerHook after trigger?
             $evdata = array('method' => 'create', 'table' => 'news', 'id' => $data['data']['news_id'], 'plugin' => 'news', 'function' => 'submit_item');
             $emessage->add($e_event->triggerHook($evdata), E_MESSAGE_INFO, $smessages);
         } else {
             $error = true;
             $message = "<strong>" . LAN_NEWS_7 . "</strong>";
             $emessage->add(LAN_UPDATED, E_MESSAGE_ERROR, $smessages);
         }
     }
     //return $message;
     $data['message'] = $message;
     $data['error'] = $error;
     return $data;
 }
Esempio n. 25
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;
}