示例#1
0
 /**
  * Install a block from a Module method
  *
  * @version 1.0
  * @since   1.0
  * @author  Daniel Noel-Davies
  *
  * @param   string  $var       Parameter Description
  *
  */
 public function installFromModule($module, $method)
 {
     $objModule = Core_Classes_coreObj::getModule();
     $objSQL = Core_Classes_coreObj::getDBO();
     $details = $objModule->getDetails($module);
     // Check method is callable and the module is enabled
     // Not okay
     if ($details === false || $objModule->moduleInstalled() === false) {
         // Error + return false
         trigger_error('Module x is not installed, No block was created');
         return false;
     }
     $data = array('uniqueid' => randcode(8), 'label' => '', 'title' => '', 'region_name' => '', 'order' => '', 'enabled' => '', 'info' => json_encode(), 'args' => json_encode(), 'whitelist' => '', 'content' => '');
     // Add into db + display status
     $query = $objSQL->queryBuilder()->insertInto('#__blocks')->set($data)->build();
     $result = $objSQL->insert($query);
     if ($result) {
         return true;
     }
     return false;
 }
 public function dashboard()
 {
     $objTPL = Core_Classes_coreObj::getTPL();
     $objTPL->set_filenames(array('body' => cmsROOT . 'modules/core/views/admin/dashboard/default.tpl'));
     $blocks = array();
     // for( $i = 0; $i < 10; $i++ ) {
     //     $blocks[randcode(10)] = array(
     //         'COL'     => rand(1,3) * 4,
     //     );
     // }
     $blocks[randcode(10)] = array('COL' => 3 * 4);
     $blocks[randcode(10)] = array('COL' => 1 * 4);
     $blocks[randcode(10)] = array('COL' => 1 * 4);
     $blocks[randcode(10)] = array('COL' => 1 * 4);
     $blocks[randcode(10)] = array('COL' => 2 * 4);
     $blocks[randcode(10)] = array('COL' => 1 * 4);
     $blocks[randcode(10)] = array('COL' => 1 * 4);
     $blocks[randcode(10)] = array('COL' => 2 * 4);
     $this->displayPortlets($blocks);
     $objTPL->parse('body', false);
 }
示例#3
0
 /**
  * Allows a user to view a thread
  *
  * @version 2.0
  * @since   1.0.0
  * @author  xLink
  *
  * @param   int         $id
  */
 public function viewThread($id)
 {
     $vars = $this->objPage->getVar('tplVars');
     $this->objTPL->set_filenames(array('body' => 'modules/forum/template/forum_thread.tpl'));
     //grab the thread
     $thread = $this->objSQL->getLine('SELECT t.*, COUNT(DISTINCT p.id) as posts
             FROM `$Pforum_threads` t
             LEFT JOIN `$Pforum_posts` p
                 ON p.thread_id = t.id
             WHERE t.id = %d', array($id));
     //make sure it exists
     if (is_empty($thread['id'])) {
         $this->throwHTTP(404);
         return;
     }
     //grab the cat
     $cat = $this->getForumInfo($thread['cat_id']);
     $cat = $cat[0];
     //grab the auth and make sure they /can/ see it
     $threadAuth = $this->auth[$thread['cat_id']];
     if (!$threadAuth['auth_view'] || !$threadAuth['auth_read']) {
         $this->objPage->setTitle(langVar('B_FORUM') . ' > ' . langVar('P_PERMISSION_DENIED'));
         hmsgDie('INFO', langVar('L_AUTH_MSG', $threadAuth['auth_read_type']));
         return;
     }
     //sort out the breadcrumbs & page title
     $threadTitle = secureMe($thread['subject']);
     $threadUrl = $this->generateThreadURL($thread);
     $page_name = array(langVar('B_FORUM'), $cat['title'], !is_empty($threadTitle) ? $threadTitle : langVar('F_VIEWF'));
     $this->objPage->setTitle(implode(' > ', $page_name));
     $this->getSubCrumbs($thread['cat_id']);
     $this->objPage->addPagecrumb(array(array('url' => $threadUrl, 'name' => $threadTitle)));
     //update views
     if (!isset($_SESSION['site']['forum']['view'][$thread['tid']])) {
         $this->objSQL->query('UPDATE `$Pforum_threads` SET views = (views+1) WHERE id = %d LIMIT 1', array($id));
         $_SESSION['site']['forum']['view'][$thread['tid']] = 1;
     }
     //if the user is online
     if (User::$IS_ONLINE) {
         //do thread tracker part of the tour
         $tracker = doArgs('forum_tracker', false, $_SESSION['user']);
         $tracking_threads = array();
         if (!is_empty($tracker)) {
             $tracking_threads = unserialize($tracker);
         }
         //find the thread row in the array or create a new one
         if (!is_empty($tracking_threads)) {
             foreach ($tracking_threads as $k => $v) {
                 if ($tracking_threads[$k]['id'] == $id) {
                     $tracking_threads[$k][$id]['read'] = true;
                     $tracking_threads[$k][$id]['last_poster'] = time();
                 }
             }
         } else {
             $tracking_threads[$id]['read'] = true;
             $tracking_threads[$id]['last_poster'] = time();
         }
         //now update the user row
         unset($update);
         $_SESSION['user']['forum_tracker'] = $update['forum_tracker'] = serialize($tracking_threads);
         $this->objUser->updateUserSettings($this->objUser->grab('id'), $update);
         unset($update);
         //update the users watch status
         $this->objSQL->updateRow('forum_watch', array('seen' => 1), array('user_id ="%d" AND thread_id ="%d"', $this->objUser->grab('id'), $id));
         // && read notification if needed
         $this->objNotify->clearNotifications($id, true);
     }
     //setup a new pagination obj
     $objPagination = new pagination('page', 10, $thread['posts']);
     //see if the user wants us to jump to the last page
     if (doArgs('mode', false, $_GET) == 'last_page') {
         $objPagination->goLastPage();
     }
     //check for guest restrictions
     $limit = $objPagination->getSqlLimit();
     if (!User::$IS_ONLINE && $this->config('forum', 'guest_restriction')) {
         $this->objTPL->assign_block_vars('error', array('ERROR' => langVar('L_VIEW_GUEST')));
         $limit = '1;';
     }
     //grab the thread posts
     $posts = $this->objSQL->getTable('SELECT * FROM `$Pforum_posts` WHERE thread_id = %d ORDER by timestamp, id ASC LIMIT %s', array($id, $limit));
     //assign some vars to the tpl
     $this->objTPL->assign_vars(array('THREAD_TITLE' => $threadTitle, 'PAGINATION' => $objPagination->getPagination(true), 'JUMPBOX' => $this->objForm->start('jump' . randcode(2)) . $this->buildJumpBox('jumpbox', $this->buildJumpBoxArray(), $thread['cat_id'], false) . $this->objForm->finish(), 'JUMPBOX2' => $this->objForm->start('jump' . randcode(2)) . $this->buildJumpBox('jumpbox2', $this->buildJumpBoxArray(), $thread['cat_id'], false) . $this->objForm->finish()));
     //setup the watch thread trigger
     $watchThread = $this->objSQL->getInfo('forum_watch', array('user_id ="%s" AND thread_id ="%s"', $this->objUser->grab('id'), $id));
     $this->objTPL->assign_var('WATCH', USER::$IS_ONLINE ? '<a href="' . $threadUrl . '?mode=' . ($watchThread ? 'unwatch' : 'watch') . '">' . langVar($watchThread ? 'L_UNWATCH_THREAD' : 'L_WATCH_THREAD') . '</a>' : null);
     //check if the thread is currently locked
     if ($thread['locked'] == 0) {
         $quick_reply = doArgs('forum_quickreply', false, $_SESSION['user']);
         //test if we get to output quick reply
         if ($quick_reply && ($threadAuth['auth_reply'] || $threadAuth['auth_mod'] || User::$IS_MOD)) {
             $_SESSION['site']['forum'][$id]['id'] = $id;
             $_SESSION['site']['forum'][$id]['sessid'] = $sessid = md5($this->objUser->grab('username') . $id);
             //assign the form to the tpl
             $this->objTPL->assign_vars(array('F_START' => $this->objForm->start('qreply', array('method' => 'POST', 'action' => $threadUrl . '?mode=qreply')), 'F_END' => $this->objForm->finish(), 'HIDDEN' => $this->objForm->inputbox('sessid', 'hidden', $sessid) . $this->objForm->inputbox('id', 'hidden', $id) . $this->objForm->inputbox('quick_reply', 'hidden', 'true'), 'L_QUICK_REPLY' => langVar('L_QUICK_REPLY'), 'F_QUICK_REPLY' => $this->objForm->textarea('post', '', array('extra' => ' tabindex="2"', 'style' => 'width:100%;height:50px;border:0;padding:0;', 'placeholder' => langVar('L_QR_PLACEHOLDER'))), 'POST_OPTIONS' => langVar('L_OPTIONS'), 'OPTIONS' => $this->objForm->checkbox('autoLock', null, false) . ' ' . langVar('L_QR_LOCK_THREAD') . (!$watchThread ? $this->objForm->checkbox($this->objUser->grab('autowatch'), 'watch_topic') . ' Watch Topic.' : NULL), 'SUBMIT' => $this->objForm->button('submit', 'Post', array('extra' => ' tabindex="3"'))));
             $this->objTPL->assign_block_vars('qreply', array('TEXT' => langVar('L_QUICK_REPLY')));
             if ($threadAuth['auth_mod'] || User::$IS_MOD) {
                 $this->objTPL->assign_block_vars('qreply.options', array());
             }
         }
         if ($threadAuth['auth_reply'] || $threadAuth['auth_mod'] || User::$IS_MOD) {
             $this->objTPL->assign_block_vars('reply', array('URL' => $threadUrl . '?mode=reply', 'TEXT' => langVar('L_POST_REPLY'), 'IMG' => $thread['locked'] == 1 ? '<img src="' . $vars['FIMG_locked'] . '" />' : '<img src="' . $vars['FIMG_reply'] . '" />'));
         }
     } else {
         $this->objTPL->assign_block_vars('reply', array('URL' => $threadUrl . '?mode=unlock', 'TEXT' => langVar('L_THREAD_LOCKED'), 'IMG' => $thread['locked'] == 1 ? '<img src="' . $vars['FIMG_locked'] . '" />' : NULL));
     }
     $this->objTPL->assign_var('POSTS', $this->outputPosts($posts, $thread));
     $this->objTPL->parse('body', false);
 }
示例#4
0
<?php

/*======================================================================*\
||              Cybershade CMS - Your CMS, Your Way                     ||
\*======================================================================*/
if (!defined('INDEX_CHECK')) {
    die('Error: Cannot access directly.');
}
$sql = array();
$now = $objSQL->escape(time());
$version = $objSQL->escape(str_replace('V', '', $version));
$admUsername = $objSQL->escape($_SESSION['adm']['username']);
$admPasswd = $objSQL->escape($objUser->mkPassword($_SESSION['adm']['password']));
$admEmail = $objSQL->escape($_SESSION['adm']['email']);
$admKey = $objSQL->escape(randcode(6));
$ckeauth = $objSQL->escape(randcode(6));
$dst = date('I') == 0 ? 1 : 0;
$timezone = 0;
//$userIp = getIP();
$fields = array('title', 'slogan', 'description', 'keywords', 'time');
foreach ($fields as $f) {
    if (doArgs($f, false, $_SESSION['POST'][$f])) {
        ${$f} = $objSQL->escape($_SESSION['POST'][$f]);
        continue;
    }
}
//
//--Core System
//
//--Config
$sql[] = <<<SQL