Пример #1
0
 function showProfile($uid)
 {
     if (!User::$IS_ONLINE) {
         hmsgDie('FAIL', 'Error: You must be logged in to view this users profile.');
     }
     if (is_empty($uid) && User::$IS_ONLINE) {
         $this->objPage->redirect('/' . root() . 'modules/profile/view/' . $this->objUser->grab('username'), 0);
         return;
     }
     $vars = $this->objPage->getVar('tplVars');
     $user = $this->objUser->getUserInfo($uid);
     if (!count($user)) {
         $this->objPage->setTitle('Profile > User doesnt exist.');
         hmsgDie('FAIL', 'Error: User doesnt exist.');
     }
     $this->objTPL->set_filenames(array('body' => 'modules/profile/template/viewProfile.tpl'));
     $this->objPage->setTitle('Profile > ' . $user['username']);
     $this->objPage->addCSSFile('/' . root() . 'modules/profile/contactInfo.css');
     $this->objPage->addJSFile('/' . root() . 'modules/profile/scripts/profile.js');
     $this->objPage->addPagecrumb(array(array('url' => '/' . root() . 'modules/profile/view/' . $user['username'], 'name' => 'Viewing ' . secureMe($user['username']) . '\'s profile')));
     $icons = $this->contactInfoLinks($user);
     $uProfile = $this->objUser->profile($user['id']);
     if (preg_match('_"color: ([^;]*);" title="([^"]*)">([^<]*)</font>_i', $uProfile, $m)) {
         $text = $m[2];
         $color = $m[1];
     }
     $this->objComments->start('PROFILE_COMMENTS', 'cpage', 'profile', $user['id'], 20, $user['id']);
     $this->objTPL->assign_block_vars('profile', array('USERNAME' => $uProfile, 'USERNAME_RAW' => $user['username'], 'AVATAR' => $this->objUser->parseAvatar($user['id']), 'TITLE' => !is_empty($title) ? secureMe($user['title']) : '<font color="' . $color . '">' . $text . '</font>', 'PM' => User::$IS_ONLINE ? '<a href="/' . root() . 'modules/pm/compose/' . $user['username'] . '"><img src="' . $vars['PM_compose'] . '" /></a>' : '', 'SIGNATURE' => contentParse($user['signature']), 'INTERESTS' => contentParse($user['interests']), 'ABOUT_ME' => contentParse($user['about']), 'L_LOCALTIME' => 'Local Time', 'LOCALTIME' => $this->objTime->mk_time(time(), 'D jS M h:ia', $user['timezone']), 'CONTACT_ICONS' => $icons, 'L_COMMENTS' => 'Comments', 'L_RECENTA' => 'Recent Activity', 'L_BIO' => 'User Bio'));
     if (!is_empty($user['about'])) {
         $this->objTPL->assign_block_vars('profile.ABOUT_ME', array());
     }
     if (!is_empty($user['interests'])) {
         $this->objTPL->assign_block_vars('profile.INTRESTS', array());
     }
     $bio_info = array();
     $bio_info[] = !is_empty($title) ? array('var' => 'User Title', 'val' => secureMe($user['title'])) : array('var' => 'User Privs', 'val' => '<font color="' . $color . '">' . $text . '</font>');
     $bio_info[] = array('var' => 'Registered Since', 'val' => $this->objTime->mk_time($user['registerdate'], 'l jS F Y @ h:ia'));
     $bio_info[] = array('var' => langVar('L_LAST_LOGGED_IN'), 'val' => $this->objTime->mk_time($user['timestamp']));
     if ($user['birthday'] != '00/00/0000') {
         $ex = explode('/', $user['birthday']);
         $tiem = gmmktime(0, 0, 0, $ex[1], $ex[0], $ex[2]);
         $bio_info[] = array('var' => 'Birthday', 'val' => $this->objTime->mk_time($tiem, 'D jS M'));
     }
     if (!is_empty($location)) {
         $bio_info[] = array('var' => 'Location', 'val' => $location);
     }
     $i = 0;
     foreach ($bio_info as $row) {
         $this->objTPL->assign_block_vars('profile.BINFO', array('VAR' => $row['var'], 'VAL' => $row['val'], 'ROW' => $i++ % 2 == 0 ? 'row_color1' : 'row_color2'));
     }
     $this->objTPL->assign_vars(array('RECENT_ACTIVITY_MSG' => msg('INFO', 'This part of the panel is still in development. Watch this space.', 'return')));
     $this->objTPL->parse('body', false);
 }
Пример #2
0
 public function outputForm($vars, $elements, $options = array())
 {
     //echo dump($elements);
     //make sure we have something to use before continuing
     if (is_empty($elements)) {
         $this->setError('Nothing to output');
         return false;
     }
     if (!isset($elements['field']) || is_empty($elements['field'])) {
         $this->setError('Fields are blank or undetectable, make sure they are set using \'field\' key.');
         return false;
     }
     //init the template, give it a rand id to stop it clashing with anything else
     $randID = inBetween('name="', '"', $vars['FORM_START']);
     $this->objTPL->set_filenames(array('form_body_' . $randID => 'modules/core/template/outputForm.tpl'));
     if (!doArgs('border', true, $options)) {
         $vars['EXTRA'] = ' class="noBorder"';
     }
     if (doArgs('id', false, $options)) {
         $vars['SECTION_ID'] = doArgs('id', null, $options);
     }
     $dediHeader = doArgs('dedicatedHeader', false, $options);
     $this->objTPL->assign_vars($vars);
     $this->objTPL->reset_block_vars('form_error');
     if (isset($elements['errors']) && !is_empty($elements['errors'])) {
         $this->objTPL->assign_block_vars('form_error', array('ERROR_MSG' => implode('<br />', $elements['errors'])));
     }
     $count = 0;
     $this->objTPL->reset_block_vars('field');
     //loop thru each element
     foreach ($elements['field'] as $label => $field) {
         if (is_empty($field)) {
             continue;
         }
         $formVars = array();
         //grab the description before we play with the $label
         $desc = $elements['desc'][$label];
         //upper care the words
         $label = ucwords($label);
         //if its a header, set it as one with a hr under
         if ($field == '_header_') {
             $label = sprintf(doArgs('header', '<h3>%s</h3><hr />', $options), $label);
         }
         $header = $field == '_header_' ? true : false;
         $this->objTPL->assign_block_vars('_form_row', array());
         if ($dediHeader && $header) {
             $this->objTPL->assign_block_vars('_form_row._header', array('TITLE' => $label));
         } else {
             //assign some vars to the template
             $this->objTPL->assign_block_vars('_form_row._field', array('F_ELEMENT' => $header ? null : $field, 'F_INFO' => doArgs('parseDesc', false, $options) ? contentParse($desc) : $desc, 'CLASS' => $header ? ' title' : ($count++ % 2 ? ' row_color2' : ' row_color1'), 'L_LABEL' => $label, 'L_LABELFOR' => inBetween('name="', '"', $field)));
             //if this isnt a 'header' then output the label
             if (!$header) {
                 $this->objTPL->assign_block_vars('_form_row._field._label', array());
             }
             //if we have a description, lets output it with the label
             if (!is_empty($desc)) {
                 $this->objTPL->assign_block_vars('_form_row._field._desc', array());
             }
         }
     }
     //return the html all nicely parsed etc
     return $this->objTPL->get_html('form_body_' . $randID);
 }
Пример #3
0
function menu_forum_posts($args)
{
    global $config, $objCore, $objModule;
    $limit = doArgs('limit', $objCore->config('rss', 'global_limit'), $args);
    $objCore->objTPL->set_filenames(array($args['uniqueId'] => 'modules/forum/template/block_forum.tpl'));
    //grab the last 50 threads, it makes sure we have something to show the user (hopefully)
    $query = $objCore->objSQL->getTable('SELECT t.*
            FROM `$Pforum_threads` t
            LEFT JOIN `$Pforum_posts` p
                ON t.id = p.thread_id
            GROUP BY t.id
            ORDER BY t.timestamp DESC
            LIMIT 50');
    //if empty show an error and quit
    if (is_empty($query)) {
        $objCore->objTPL->assign_block_vars('error', array('MESSAGE' => langVar('L_NO_POSTS')));
        return $objCore->objTPL->get_html($args['uniqueId']);
    }
    $catAuth = $objModule->getVar('auth');
    //if we are using the forum when this block is show, WIN! if not init the forum
    if ($objModule->name() != 'forum') {
        $objCore->autoLoadModule('forum', $objModule);
        $catAuth = $objModule->auth(AUTH_VIEW, AUTH_VIEW_ALL);
    }
    $count = 0;
    $return = '';
    $icons = $objCore->objPage->getVar('tplVars');
    $j = 0;
    foreach ($query as $thread) {
        if ($j >= $limit || !$catAuth[$thread['cat_id']]['auth_view']) {
            continue;
        }
        $icon_status = '_old';
        if (User::$IS_ONLINE) {
            $tracking_topics = array();
            $tracker = doArgs('forum_tracker', false, $_SESSION['user']);
            if (!is_empty($tracker)) {
                $tracking_threads = unserialize($tracker);
            }
            if (!is_empty($tracking_threads)) {
                foreach ($tracking_threads as $t) {
                    if (!doArgs('read', false, $t)) {
                        $icon_status = '_new';
                    }
                }
            }
        }
        switch ($thread['mode']) {
            case 1:
                $ico = 'IMG_announcement' . $icon_status;
                break;
            case 2:
                $ico = 'IMG_sticky' . $icon_status;
                break;
            default:
                $ico = 'IMG_posts' . $icon_status;
                break;
        }
        if ($thread['locked'] == 1) {
            $ico = 'IMG_locked';
        }
        $objCore->objTPL->assign_block_vars('threadRow', array('ID' => 'fblock_' . $j, 'CLASS' => $j % 2 == 0 ? 'row_color2' : 'row_color1', 'ICON' => $icons[$ico], 'HREF' => $objModule->generateThreadURL($thread) . '?mode=last_page#top', 'L_TITLE' => langVar('L_TITLE'), 'TR_TITLE' => strip_tags(contentParse($thread['subject'], false, false)), 'TITLE' => contentParse(truncate($thread['subject'], 25), false, false), 'L_AUTHOR' => langVar('L_AUTHOR'), 'AUTHOR' => $objCore->objUser->profile($thread['last_uid']), 'POSTED' => $objCore->objTime->timer($thread['posted'], time(), 'wd')));
        $j++;
    }
    $return = $objCore->objTPL->get_html($args['uniqueId']);
    $objCore->objTPL->reset_block_vars('threadRow');
    return $return;
}
/**
 * 显示页面
 * @param string $cache_file 缓存路径
 * @param bool $is_session 是否更新session
 * @param bool $is_return 是否返回页面内容
 * @return mixed
 */
function display($cache_file, $is_session = true, $is_return = false)
{
    global $_FANWE;
    $content = NULL;
    if (!empty($cache_file) && !file_exists($cache_file) && diskfreespace(PUBLIC_ROOT . './data/tpl/caches') > 1000000) {
        if (makeDir(preg_replace("/^(.*)\\/.*?\\.htm\$/is", "\\1", $cache_file))) {
            $css_script_php = '';
            if (isset($_FANWE['page_parses'])) {
                $css_script_php = "<?php\n" . '$_FANWE[\'CACHE_CSS_SCRIPT_PHP\']' . " = " . var_export($_FANWE['page_parses'], true) . ";\n?>";
            }
            $content = ob_get_contents();
            express($content);
            writeFile($cache_file, $css_script_php . $content);
        }
    }
    require_once fimport('dynamic/common');
    $module_dynamic = '';
    if (defined('MODULE_NAME') && MODULE_NAME != '') {
        $module_dynamic = fimport('dynamic/' . MODULE_NAME);
    }
    if (!empty($module_dynamic) && file_exists($module_dynamic)) {
        require_once $module_dynamic;
    }
    if ($content === NULL) {
        $content = ob_get_contents();
        express($content);
    }
    ob_end_clean();
    $content = preg_replace('/<!--dynamic\\s+(.+?)(?:|\\sargs=(.*?))-->/ies', "\\1('\\2');", $content);
    if (isset($_FANWE['CACHE_CSS_SCRIPT_PHP'])) {
        if (isset($_FANWE['CACHE_CSS_SCRIPT_PHP']['css'])) {
            foreach ($_FANWE['CACHE_CSS_SCRIPT_PHP']['css'] as $url) {
                cssParse($url);
            }
        }
        if (isset($_FANWE['CACHE_CSS_SCRIPT_PHP']['script'])) {
            foreach ($_FANWE['CACHE_CSS_SCRIPT_PHP']['script'] as $url) {
                scriptParse($url);
            }
        }
    }
    //格式化会员关注
    formatUserFollowTags($content);
    contentParse($content);
    if ($is_session) {
        updateSession();
    }
    if ($is_return) {
        return $content;
    }
    $_FANWE['gzip_compress'] ? ob_start('ob_gzhandler') : ob_start();
    echo $content;
}
Пример #5
0
 /**
  * Outputs a comment wrapped in template for ajax purposes
  *
  * @version     1.0
  * @since       0.8.0
  */
 function getLastComment($id)
 {
     $objTPL = coreObj::getTPL();
     $objSQL = coreObj::getDBO();
     $objUser = coreObj::getUser();
     $objTime = coreObj::getTime();
     //set the template for the comments
     $objTPL->set_filenames(array('ajComments' => 'modules/core/template/comments/ajaxComments.tpl'));
     $commentQuery = $objSQL->queryBuilder()->select('*')->from('#__comments')->where('id', '=', $id)->limit(1)->build();
     $comments = $objSQL->fetchAll($commentQuery);
     if (is_array($comments) && count($comments) > 0) {
         $objTPL->assign_block_vars('comment', array('ID' => $comments['id'], 'cID' => 'comment-' . $comments['id'], 'ROW' => $i % 2 ? 'row_color2' : 'row_color1', 'ALT_ROW' => $i % 2 ? 'row_color1' : 'row_color2', 'AUTHOR' => $objUser->profile($comments['author']), 'POSTED' => $objTime->mk_time($comments['timestamp']), 'POST' => contentParse($comments['comment'])));
         if (User::$IS_ADMIN || User::$IS_MOD || User::$IS_ONLINE && ($objUser->get('id') == $comments['author'] || $objUser->get('id') == $this->author_id)) {
             $objTPL->assign_block_vars('comment.functions', array('URL' => $this->aURL[0] . '?mode=deleteComment&id=' . $comments['id']));
         }
     }
     $this->objTPL->parse('ajComments', false);
     return $this->objTPL->get_html('ajComments');
 }
Пример #6
0
 /**
  * Outputs a comment wrapped in template for ajax purposes
  *
  * @version     1.0
  * @since       0.8.0
  */
 function getLastComment($id)
 {
     //set the template for the comments
     $this->objTPL->set_filenames(array('ajComments' => 'modules/core/template/comments/ajaxComments.tpl'));
     $comments = $this->objSQL->getLine($this->objSQL->prepare('SELECT * FROM `$Pcomments` WHERE id = "%d"', $id));
     $this->objTPL->assign_block_vars('comment', array('ID' => $comments['id'], 'cID' => 'comment-' . $comments['id'], 'ROW' => $i % 2 ? 'row_color2' : 'row_color1', 'ALT_ROW' => $i % 2 ? 'row_color1' : 'row_color2', 'AUTHOR' => $this->objUser->profile($comments['author']), 'POSTED' => $this->objTime->mk_time($comments['timestamp']), 'POST' => contentParse($comments['comment'])));
     if (User::$IS_ADMIN || User::$IS_MOD || User::$IS_ONLINE && ($this->objUser->grab('id') == $comments['author'] || $this->objUser->grab('id') == $this->author_id)) {
         $this->objTPL->assign_block_vars('comment.functions', array('URL' => $this->aURL[0] . '?mode=deleteComment&id=' . $comments['id']));
     }
     $this->objTPL->parse('ajComments', false);
     return $this->objTPL->get_html('ajComments');
 }
Пример #7
0
 /**
  * Performs action based on $action
  *
  * @version 1.0
  * @since   1.0.0
  * @author  xLink
  *
  * @param   string    $action
  */
 public function doAjax($action)
 {
     if (is_empty($action)) {
         $this->throwHTTP(500);
         return false;
     }
     switch ($action) {
         case 'sortForum':
             parse_str($_POST['order'], $order);
             if (!is_array($order) || !count($order)) {
                 $this->throwHTTP(401);
             }
             parse_str($_POST['state'], $state);
             if (!is_array($state) || !count($state)) {
                 $this->throwHTTP(401);
             }
             if (!is_array($order['sortable_forums']) || !count($order['sortable_forums'])) {
                 $this->throwHTTP(401);
             }
             foreach ($order['sortable_forums'] as $k) {
                 $go[$k] = $state[$k] == 1 ? 1 : 0;
             }
             echo print_r($go, true);
             $db = serialize($go);
             $_SESSION['user']['forum_cat_order'] = $db;
             $update['forum_cat_order'] = $db;
             $this->objUser->updateUserSettings($this->objUser->grab('id'), $update);
             break;
             //edit in place stuff
         //edit in place stuff
         case 'eip':
             $id = doArgs('id', 0, $_GET, 'is_number');
             $uid = $this->objUser->grab('id');
             if ($id == 0 || !User::$IS_ONLINE) {
                 die('Error: There was a problem with the form you submitted. Please try again.');
             }
             //grab the post were reffering to
             $post = $this->objSQL->getLine('SELECT * FROM `$Pforum_posts` WHERE id ="%s" LIMIT 1;', array($id));
             if (!$post) {
                 die('Error: There was a problem obtaining the post data. Error 0x01;');
             }
             //grab the required thread so we got something to work with..
             $thread = $this->objSQL->getLine('SELECT id, cat_id FROM `$Pforum_threads` WHERE id ="%s" LIMIT 1;', array($post['thread_id']));
             if (!$thread) {
                 die('Error: There was a problem obtaining the post data. Error 0x02;');
             }
             //now grab the cat id..
             $cat = $this->getForumInfo($thread['cat_id']);
             if (!$cat) {
                 die('Error: There was a problem obtaining the post data. Error 0x03;');
             }
             $catAuth = $this->auth[$cat['id']];
             if ($post['author'] != $uid && !$catAuth['auth_edit'] && !$catAuth['auth_mod'] && !IS_MOD) {
                 die('Error: This is not your post;');
             }
             //load or save?
             $action = doArgs('action', false, $_GET);
             if ($action == 'load') {
                 echo html_entity_decode($post['post']);
             } else {
                 if ($action == 'save') {
                     //what we have dosent match whats its supposed to be
                     if (doArgs('editorId', false, $_POST) != 'post_id_' . $id) {
                         die('Error: There was a problem with the form you submitted.');
                     }
                     unset($update);
                     $update['post'] = secureMe($_POST['value']);
                     $update['edited'] = $post['edited'] + 1;
                     $update['edited_uid'] = $uid;
                     $post_update = $this->objSQL->updateRow('forum_posts', $update, array('id ="%d"', $id));
                     if ($post_update) {
                         contentParse($_POST['value'], true);
                         exit;
                     } else {
                         die('Error: This is not your post, or there was a problem with saving the post. Error 0x02;');
                     }
                 }
             }
             break;
         case 'quote':
             $id = doArgs('id', 0, $_GET, 'is_number');
             $uid = $this->objUser->grab('id');
             if ($id == 0 || !User::$IS_ONLINE) {
                 die('Error: There was a problem with the form you submitted. Please try again.');
             }
             //grab the post were reffering to
             $post = $this->objSQL->getLine('SELECT * FROM `$Pforum_posts` WHERE id ="%s" LIMIT 1;', array($id));
             if (!$post) {
                 die('Error: There was a problem obtaining the post data. Error 0x01;');
             }
             //grab the required thread so we got something to work with..
             $thread = $this->objSQL->getLine('SELECT id, cat_id FROM `$Pforum_threads` WHERE id ="%s" LIMIT 1;', array($post['thread_id']));
             if (!$thread) {
                 die('Error: There was a problem obtaining the post data. Error 0x02;');
             }
             //now grab the cat id..
             $cat = $this->getForumInfo($thread['cat_id']);
             if (!$cat) {
                 die('Error: There was a problem obtaining the post data. Error 0x03;');
             }
             $catAuth = $this->auth[$cat['id']];
             if (!$catAuth['auth_read'] && !$catAuth['auth_mod'] && !IS_MOD) {
                 die('Error: This is not your post;');
             }
             $quote = "\n[quote=%s]\n%s\n[/quote]\n";
             echo sprintf($quote, $this->objUser->getUserInfo($post['author'], 'username'), $post['post']);
             break;
     }
     //everything that happens here dosent need to be output back to the parent template
     exit;
 }
Пример #8
0
        }
        if (User::$IS_ONLINE && !$acpCheck && !isset($_GET['ajax'])) {
            $objPage->redirect('/' . root() . 'index.php');
        }
        $objLogin->doLogin(isset($_GET['ajax']) && HTTP_AJAX ? true : false);
        break;
    case 'active':
        if (!isset($_GET['un']) || !isset($_GET['check'])) {
            hmsgDie('FAIL', 'Cannot activate your account, Please use all the url sent to you in the email');
        } else {
            if ($objUser->getUserInfo($_GET['un'], 'active') == 1) {
                hmsgDie('Info', 'You account is already active.');
            }
            if ($objLogin->activateAccount($_GET['un'], $_GET['check'])) {
                $objLogin->doError('0x08');
            } else {
                // Make this into a form
                hmsgDie('FAIL', contentParse('Cannot activate your account.
                Please email the site administrator at [email]' . $objCore->config('site', 'admin_email') . '[/email]'));
            }
        }
        break;
    case 'logout':
        $objLogin->logout($_GET['check']);
        break;
}
$objPage->showHeader(isset($_GET['ajax']) ? true : false);
if ($objTPL->output('body')) {
    msgDie('FAIL', 'No output received.');
}
$objPage->showFooter(isset($_GET['ajax']) ? true : false);
Пример #9
0
    hmsgDie('FAIL', 'Fatal Error - BBCode\'s not available.');
}
//
//--Module Setup
//
$file = cmsROOT . 'core/classes/class.module.php';
if (is_readable($file)) {
    require_once $file;
} else {
    hmsgDie('FAIL', 'Fatal Error - Modules cannot be loaded.');
}
//if site is closed, make it so, kill debug, no menu is needed, 'cmsCLOSED' can be used as a bypass
if ($objCore->config('site', 'site_closed') == 1 && !defined('cmsCLOSED')) {
    if ($objUser->grab('userlevel') != ADMIN) {
        $objSQL->debug = false;
        $objPage->setMenu(false);
        $objPage->setTitle('DISABLED');
        hmsgDie('INFO', 'Site has been disabled. ' . contentParse("\n" . $objCore->config('site', 'closed_msg')));
    } else {
        $objTPL->assign_block_vars('__MSG', array('MESSAGE' => langVar('L_MAINTENANCE')));
    }
}
//
//--Include the CMS's internal CRON
//
$file = cmsROOT . 'core/cron.php';
if (is_readable($file)) {
    require_once $file;
} else {
    hmsgDie('FAIL', 'Fatal Error - Cron cannot be found.');
}