Пример #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);
 }
Пример #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();
 }
Пример #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);
 }
Пример #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');
 }
Пример #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;
         }
     }
 }
Пример #6
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);
 }
Пример #7
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']);
     }
 }