Esempio n. 1
0
 function index()
 {
     $vars = array();
     $authorizer = check_model::getInstance();
     $vars['nagavitor'] = $this->forum->get_nagavitor();
     $vars['cat_id'] = $this->validate->get->getInt('id');
     if ($vars['cat_id']) {
         if (!$authorizer->is_cat_id($vars['cat_id'])) {
             cpg_die(ERROR, Lang::item('error.wrong_cat_id'), __FILE__, __LINE__);
         }
     }
     $vars['user_posts'] = $this->forum->get_user_post_count();
     $vars['last_visit'] = $this->forum->get_last_visit_time();
     $cats = $this->forum->get_category($vars['cat_id'], 'cat_id, name');
     $vars['categories'] = array();
     foreach ($cats as $cat) {
         $newcat = array();
         $newcat['name'] = $cat['name'];
         $newcat['id'] = $cat['cat_id'];
         $boards = $this->forum->get_first_level_board($cat['cat_id'], 'board_id,name,description,last_msg_id,topics,posts,child_level');
         $newcat['boards'] = array();
         foreach ($boards as $board) {
             $last_message = $this->forum->get_message_data($board['last_msg_id'], 'subject, poster_id, poster_time');
             $newboard = array();
             $newboard['icon'] = 'plugins/forum/forum/html/images/icon_board_new.gif';
             $newboard['id'] = $board['board_id'];
             $newboard['name'] = $board['name'];
             $newboard['description'] = $board['description'];
             $newboard['last_post_id'] = $board['last_msg_id'];
             $newboard['last_post_title'] = $last_message['subject'];
             $newboard['last_post_time'] = $last_message['poster_time'];
             $newboard['last_post_author_id'] = $last_message['poster_id'];
             $newboard['last_post_author_name'] = get_username($last_message['poster_id']);
             $newboard['topics'] = $board['topics'];
             $newboard['replies'] = $board['posts'];
             $newboard['childs'] = $this->forum->get_child_board($board['board_id'], $board['child_level'], 'board_id, name');
             $newcat['boards'][] = $newboard;
             unset($newboard);
         }
         $vars['categories'][] = $newcat;
         unset($newcat);
     }
     $recents = $this->forum->get_latest_message();
     $vars['recents'] = $recents;
     $vars['stats'] = $this->forum->get_statistics();
     $vars['newest_members'] = $this->forum->get_latest_user();
     $vars['active_members'] = $this->forum->get_active_user();
     $this->view->render('home/index', $vars);
 }
Esempio n. 2
0
 function render($template, $vars = array(), $debug = FALSE)
 {
     if ($debug) {
         echo '<pre>';
         var_dump($vars);
         echo '</pre>';
     }
     if (is_array($vars) && count($vars) > 0) {
         $this->setVars($vars);
     }
     $viewPath = $this->getViewPath($template);
     if (!file_exists($viewPath)) {
         cpg_die(ERROR, sprintf(Lang::item('error.missing_vw_file'), $viewPath), __FILE__, __LINE__);
     }
     extract($this->vars);
     // checking model
     $authorizer = check_model::getInstance();
     ob_start();
     include_once $viewPath;
     $fr_contents = ob_get_contents();
     ob_end_clean();
     if (empty($fr_title) || !$fr_title) {
         $fr_title = $vars[nagavitor][0][1] . " - " . Config::item('fr_title');
     }
     include_once $this->getMainPath();
 }
Esempio n. 3
0
 function locked()
 {
     $authorizer = check_model::getInstance();
     $topic_id = $this->validate->get->getInt('id');
     if (!$authorizer->is_topic_id($topic_id)) {
         cpg_die(ERROR, Lang::item('error.wrong_topic_id'), __FILE__, __LINE__);
     }
     if (!$authorizer->can_moderator_topic($topic_id)) {
         cpg_die(ERROR, Lang::item('error.perm_denied'), __FILE__, __LINE__);
     }
     $this->forum->lock_topic($topic_id);
     forum::redirect('forum.php?c=topic&id=' . $topic_id);
 }
Esempio n. 4
0
 function remove_avatar()
 {
     $authorizer = check_model::getInstance();
     // user or not
     if (!$authorizer->is_user()) {
         cpg_die(ERROR, Lang::item('error.perm_denied'), __FILE__, __LINE__);
     }
     $data['fr_avatar'] = '';
     $this->forum->edit_profile(USER_ID, $data);
     forum::redirect('forum.php?c=profile');
 }
Esempio n. 5
0
 function can_delete_msg($msg_id)
 {
     // own message
     $this->db->select('poster_id');
     $this->db->where('msg_id', $msg_id);
     $query = $this->db->get(Config::item('TABLE_FR_MESSAGES'));
     $row = $query->row();
     if ($row->poster_id == USER_ID) {
         $authorizer = check_model::getInstance();
         return $authorizer->can_delete_own_msg();
     } else {
         if (GALLERY_ADMIN_MODE) {
             return TRUE;
         } else {
             return FALSE;
         }
     }
 }
Esempio n. 6
0
foreach ($messages as $message) {
    echo "<a name=\"{$message['id']}\"></a>";
    echo table::open();
    echo table::tds(array(array('class' => 'tableh1', 'width' => '170px', 'text' => html::profile_anchor($message['poster_id'], $message['poster_name'])), array('class' => 'tableh1', 'text' => table::open(2) . table::tds(array(array('text' => html::img($message['icon'], '65%') . NBSP . sprintf(Lang::item('topic.topic_title'), html::b(html::anchor('forum.php?c=message&id=' . $message['id'], $message['name'])), time::decode($message['time']))), array('align' => 'right', 'text' => html::anchor('forum.php?c=message&m=single&id=' . $message['id'], html::b('#' . $message['pos']))))) . table::close())));
    echo table::tds(array(array('class' => 'tablef', 'valign' => 'top', 'align' => 'left', 'text' => html::span(sprintf(Lang::item('topic.user_profile'), html::img($message['avatar'], Config::item('fr_avatar_size')), $message['poster_group'], $message['poster_posts'], $message['poster_registed']))), array('class' => 'tableb', 'valign' => 'top', 'text' => forum::format_message($message['post']) . (trim($message['signature']) != '' ? sprintf(Lang::item('topic.signature'), forum::format_message($message['signature'])) : ''))));
    echo table::tds(array(array('class' => 'tablef', 'text' => html::button('profile.php?uid=' . $message['poster_id'], Lang::item('topic.profile')) . NBSP), array('class' => 'tablef', 'text' => (function_exists('get_bbcode_tags') ? html::button('forum.php?c=topic&m=reply&id=' . $topic_id . '&quote=' . $message['id'], Lang::item('common.quote')) . NBSP : '') . ($authorizer->can_edit_msg($message['id']) ? html::button('forum.php?c=message&m=edit&id=' . $message['id'], Lang::item('common.modify')) . NBSP : '') . ($authorizer->can_delete_msg($message['id']) ? html::jsbutton("button_confirm('" . Lang::item('message.confirm_delete') . "','forum.php?c=message&m=delete&id={$message['id']}');", Lang::item('common.delete')) : ''))));
    echo table::close();
}
if (count($messages) == 0) {
    echo table::open();
    echo table::td(Lang::item('topic.no_message'), 1, 'tableb');
    echo table::close();
}
// paging
echo table::open();
echo table::tds(array(array('class' => 'tableb', 'text' => table::open(2) . table::tds(array(array('width' => '70%', 'align' => 'left', 'text' => Lang::item('board.page') . forum::paging($paging)), array('width' => '30%', 'align' => 'right', 'text' => (check_model::can_reply($topic_id) ? html::jsbutton('show_section(\'fastreply\');', Lang::item('topic.fast_reply')) . NBSP . html::button('forum.php?c=topic&m=reply&id=' . $topic_id, Lang::item('topic.reply')) : '') . NBSP . ($authorizer->is_user() ? html::jsbutton("button_confirm('" . ($authorizer->is_notify_topic($topic_id) ? Lang::item('topic.disable_notify') : Lang::item('topic.active_notify')) . "','" . ($authorizer->is_notify_topic($topic_id) ? 'forum.php?c=topic&m=unnotify&id=' . $topic_id : 'forum.php?c=topic&m=notify&id=' . $topic_id) . "');", Lang::item('topic.notify')) . NBSP : '')))) . table::close())));
echo html::spacer();
echo table::open();
echo table::tds(array(array('class' => 'tableb', 'text' => table::open(2) . table::tds(array(array('width' => '66%', 'text' => ($authorizer->can_moderator_topic($topic_id) ? html::button('forum.php?c=topic&m=locked&id=' . $topic_id, $authorizer->is_locked($topic_id) ? Lang::item('topic.unlock_topic') : Lang::item('topic.lock_topic')) . NBSP : '') . ($authorizer->can_moderator_topic($topic_id) ? html::button('forum.php?c=topic&m=sticky&id=' . $topic_id, $authorizer->is_sticky($topic_id) ? Lang::item('topic.unsticky_topic') : Lang::item('topic.sticky_topic')) . NBSP : '') . ($authorizer->can_moderator_topic($topic_id) ? html::jsbutton("button_confirm('" . Lang::item('topic.confirm_delete') . "','forum.php?c=topic&m=delete&id={$topic_id}');", Lang::item('topic.delete_topic')) . NBSP : '') . ($authorizer->can_moderator_topic($topic_id) ? html::button('forum.php?c=topic&m=move&id=' . $topic_id, Lang::item('topic.move_topic')) : '')), array('width' => '33%', 'align' => 'right', 'text' => forum::redirect_box($cbs, $board_id)))) . table::close())));
echo table::close();
echo "<div id=\"fastreply\" style=\"display: none;\">";
echo table::open();
echo form::open('forum.php?c=topic&m=reply&id=' . $topic_id, 'fastreply', 'post');
echo table::td(Lang::item('topic.topic_reply'), 4);
echo table::tds(array(array('class' => 'tableb', 'width' => '30%', 'text' => Lang::item('topic.subject')), array('class' => 'tableb', 'width' => '70%', 'text' => form::text('subject', Lang::item('topic.re') . $topic_name))));
if (Config::item('fr_msg_icons') == 1) {
    echo table::tds(array(array('class' => 'tableb', 'text' => Lang::item('topic.message_icon')), array('class' => 'tableb', 'text' => forum::generate_message_icons('icon', $icons, 'icon1'))));
}
echo table::tds(array(array('class' => 'tableb', 'text' => NBSP), array('class' => 'tableb', 'text' => forum::generate_bbcode_tags('fastreply', 'body'))));
echo table::tds(array(array('class' => 'tableb', 'text' => Lang::item('topic.message')), array('class' => 'tableb', 'text' => form::textarea('body'))));
global $CONFIG;
Esempio n. 7
0
 function newtopic()
 {
     include BASE_DIR . 'include' . DS . 'smilies.inc.php';
     include BASE_DIR . 'include' . DS . 'mailer.inc.php';
     $vars = array();
     $errors = array();
     $authorizer = check_model::getInstance();
     $vars['board_id'] = $this->validate->get->getInt('id');
     if (!$authorizer->is_board_id($vars['board_id'])) {
         cpg_die(ERROR, Lang::item('error.wrong_board_id'), __FILE__, __LINE__);
     }
     if (!$authorizer->can_create_topic($vars['board_id'])) {
         cpg_die(ERROR, Lang::item('error.perm_denied'), __FILE__, __LINE__);
     }
     $vars['nagavitor'] = $this->forum->get_nagavitor();
     $vars['icons'] = $this->forum->get_icons();
     $data = array('icon' => 'icon1');
     if ($this->validate->post->keyExists('submit')) {
         $data = array('icon' => $this->validate->post->getRaw('icon'), 'subject' => $this->validate->post->getEscaped('subject'), 'body' => $this->validate->post->getRaw('body'), 'poster_time' => time(), 'poster_id' => USER_ID, 'poster_name' => USER_NAME, 'poster_ip' => Config::item('hdr_ip'), 'smileys_enabled' => 1);
         if (Config::item('fr_msg_icons') == 0 && $data['icon'] == '') {
             $data['icon'] = 'icon1';
         }
         if ($data['subject'] == '') {
             $errors[] = Lang::item('error.empty_subject');
         }
         if ($data['icon'] == '') {
             $errors[] = Lang::item('error.no_msg_icon');
         }
         if ($data['body'] == '') {
             $errors[] = Lang::item('error.empty_body');
         }
         if (strlen($data['body']) > Config::item('fr_msg_max_size') && Config::item('fr_msg_max_size')) {
             $data['body'] = substr($data['body'], 0, Config::item('fr_msg_max_size'));
         }
         global $CONFIG;
         if ($CONFIG['comment_captcha'] == 1 || $CONFIG['comment_captcha'] == 2 && !USER_ID) {
             if (!captcha_plugin_enabled('comment')) {
                 global $lang_errors;
                 $superCage = Inspekt::makeSuperCage();
                 require "include/captcha.inc.php";
                 $matches = $superCage->post->getMatched('confirmCode', '/^[a-zA-Z0-9]+$/');
                 if (!$matches[0] || !PhpCaptcha::Validate($matches[0])) {
                     $errors[] = $lang_errors['captcha_error'];
                 }
             } else {
                 CPGPluginAPI::action('captcha_comment_validate', null);
             }
         }
         if (count($errors) == 0) {
             if ($authorizer->double_post()) {
                 cpg_die(ERROR, Lang::item('error.already_post'), __FILE__, __LINE__);
             } else {
                 $topic_id = $this->forum->insert_topic($vars['board_id'], $data);
                 // to-do: send notify email
                 $users = $this->forum->get_notify_user($vars['board_id'], '');
                 foreach ($users as $user) {
                     if ($user['user_id'] == USER_ID) {
                         continue;
                     }
                     $user = $this->forum->get_user_data($user['user_id'], 'user_email');
                     // prepare email
                     $email_subject = Lang::item('board.board_new_topic') . $data['subject'];
                     $email_body = sprintf(Lang::item('board.notify_email'), $data['subject'], Config::item('fr_prefix_url') . forum::link('topic', '', $topic_id), Config::item('fr_prefix_url') . forum::link('topic', '', $topic_id), Config::item('fr_prefix_url') . forum::link('board', 'notify', $vars['board_id']), Config::item('fr_prefix_url') . forum::link('board', 'notify', $vars['board_id']), Config::item('fr_title'));
                     // send mail
                     cpg_mail($user['user_email'], $email_subject, $email_body, 'text/html', Config::item('fr_title'), Config::item('gallery_admin_email'));
                     // set send = 0
                     $this->forum->set_board_notify($vars['board_id'], 0, $user['user_id']);
                 }
                 // set notify ?
                 if ($this->validate->post->getInt('notify') === 1) {
                     $this->forum->set_topic_notify($topic_id, $this->validate->post->getInt('notify'));
                 }
                 forum::message(Lang::item('common.message'), sprintf(Lang::item('topic.new_topic_success'), $data['subject']), 'forum.php?c=topic&id=' . $topic_id);
             }
         }
     }
     $vars['errors'] = $errors;
     $vars['form'] = $data;
     $this->view->render('board/newtopic', $vars);
 }
Esempio n. 8
0
 function delete()
 {
     $authorizer = check_model::getInstance();
     $msg_id = $this->validate->get->getInt('id');
     if (!$authorizer->is_msg_id($msg_id)) {
         cpg_die(ERROR, Lang::item('error.wrong_msg_id'), __FILE__, __LINE__);
     }
     if (!$authorizer->can_delete_msg($msg_id)) {
         cpg_die(ERROR, Lang::item('error.perm_denied'), __FILE__, __LINE__);
     }
     $msg = $this->forum->get_message_data($msg_id, 'subject,topic_id');
     $this->forum->delete_message($msg_id);
     if ($this->forum->get_message_count($msg['topic_id']) == 0) {
         $topic = $this->forum->get_topic_data($msg['topic_id'], 'board_id');
         $this->forum->delete_topic($msg['topic_id']);
         forum::message(Lang::item('common.message'), sprintf(Lang::item('message.del_msg_success'), $msg['subject']), 'forum.php?c=board&id=' . $topic['board_id']);
     } else {
         forum::message(Lang::item('common.message'), sprintf(Lang::item('message.del_msg_success'), $msg['subject']), 'forum.php?c=topic&id=' . $msg['topic_id']);
     }
 }