function update_post_stats(&$mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$user_id) { $sign = ($mode == 'delete') ? '- 1' : '+ 1'; $forum_update_sql = "forum_posts = forum_posts $sign"; $topic_update_sql = ''; if ($mode == 'delete') { if ($post_data['last_post']) { if ($post_data['first_post']) { $forum_update_sql .= ', forum_topics = forum_topics - 1'; } else { $topic_update_sql .= 'topic_replies = topic_replies - 1'; $sql = 'SELECT MAX(post_id) AS last_post_id FROM _forum_posts WHERE topic_id = ?'; if ($last_post_id = sql_field(sql_filter($sql, $topic_id), 'last_post_id', 0)) { $topic_update_sql .= sql_filter(', topic_last_post_id = ?', $last_post_id); } } if ($post_data['last_topic']) { $sql = 'SELECT MAX(topic_id) AS last_topic_id FROM _forum_posts WHERE forum_id = ?'; if ($last_topic_id = sql_field(sql_filter($sql, $forum_id), 'last_topic_id', 0)) { $forum_update_sql .= ($last_topic_id) ? ', forum_topic_post_id = ' . $last_topic_id : ', forum_last_topic_id = 0'; } } } else if ($post_data['first_post']) { $sql = 'SELECT MIN(post_id) AS first_post_id FROM _forum_posts WHERE topic_id = ?'; if ($first_post_id = sql_field(sql_filter($sql, $topic_id), 'first_post_id', 0)) { $topic_update_sql .= 'topic_replies = topic_replies - 1, topic_first_post_id = ' . $first_post_id; } } else { $topic_update_sql .= 'topic_replies = topic_replies - 1'; } } else if ($mode != 'poll_delete') { $forum_update_sql .= ", forum_last_topic_id = $topic_id" . (($mode == 'newtopic') ? ", forum_topics = forum_topics $sign" : ""); $topic_update_sql = "topic_last_post_id = $post_id" . (($mode == 'reply') ? ", topic_replies = topic_replies $sign" : ", topic_first_post_id = $post_id"); } else { $topic_update_sql .= 'topic_vote = 0'; } $sql = 'UPDATE _forums SET ' . $forum_update_sql . ' WHERE forum_id = ' . $forum_id; sql_query($sql); if ($topic_update_sql != '') { $sql = "UPDATE _forum_topics SET $topic_update_sql WHERE topic_id = $topic_id"; sql_query($sql); } if ($mode != 'poll_delete') { $sql = "UPDATE _members SET user_posts = user_posts $sign WHERE user_id = $user_id"; sql_query($sql); } $current_time = time(); $minutes = date('is', $current_time); $hour_now = $current_time - (60 * ($minutes[0] . $minutes[1])) - ($minutes[2] . $minutes[3]); $sql = "UPDATE _site_stats SET " . (($mode == 'newtopic' || $post_data['first_post']) ? 'new_topics = new_topics' : 'new_posts = new_posts') . $sign . ' WHERE date = ' . intval($hour_now); sql_query($sql); if (!sql_affectedrows()) { $sql = 'INSERT INTO _site_stats (date, '.(($mode == 'newtopic' || $post_data['first_post']) ? 'new_topics': 'new_posts').') VALUES (' . $hour_now . ', 1)'; sql_query($sql); } $sql = 'SELECT ug.user_id, g.group_id as g_id, u.user_posts, g.group_count, g.group_count_max FROM _groups g, _members u LEFT JOIN _members_group ug ON g.group_id = ug.group_id AND ug.user_id = ? WHERE u.user_id = ? AND g.group_single_user = 0 AND g.group_count_enable = 1 AND g.group_moderator <> ?'; $result = sql_rowset(sql_filter($sql, $user_id, $user_id, $user_id)); foreach ($result as $group_data) { $user_already_added = (empty($group_data['user_id'])) ? false : true; $user_add = ($group_data['group_count'] == $group_data['user_posts'] && $user_id!=GUEST) ? true : false; $user_remove = ($group_data['group_count'] > $group_data['user_posts'] || $group_data['group_count_max'] < $group_data['user_posts']) ? true : false; //user join a autogroup if ($user_add && !$user_already_added) { $sql_insert = array( 'group_id' => $group_data['g_id'], 'user_id' => $user_id, 'user_pending' => 0 ); sql_insert('members_group', $sql_insert); } else if ( $user_already_added && $user_remove) { //remove user from auto group $sql = 'DELETE FROM _members_group WHERE group_id = ? AND user_id = ?'; sql_query(sql_filter($sql, $group_data['g_id'], $user_id)); } } return; }
public function _home() { global $config, $cache; if (!_button()) { $sql = 'SELECT ub, name FROM _artists ORDER BY name'; return _rowset_style($sql, 'artists'); } $name = request_var('name', ''); $sql = 'SELECT * FROM _artists WHERE name = ?'; if (!$a_data = sql_fieldrow(sql_filter($sql, $name))) { fatal_error(); } $sql = 'SELECT m.user_id, m.user_email FROM _artists_auth a, _members m WHERE a.ub = ? AND a.user_id = m.user_id'; $result = sql_rowset(sql_filter($sql, $a_data['ub'])); $mods = w(); foreach ($result as $row) { $mods[] = $row['user_id']; } if (count($mods)) { foreach ($mods as $i => $each) { $sql = 'SELECT COUNT(user_id) AS total FROM _artists_auth WHERE user_id = ?'; $total = sql_field(sql_filter($sql, $each), 'total', 0); if ($total > 1) { unset($mods[$i]); } } } if (count($mods)) { $sql = 'UPDATE _members SET user_auth_control = 0 WHERE user_id IN (??)'; $d_sql[] = sql_filter($sql, _implode(',', $mods)); } $ary_sql = array( 'DELETE FROM _artists WHERE ub = ?', 'DELETE FROM _artists_auth WHERE ub = ?', 'DELETE FROM _artists_fav WHERE ub = ?', 'DELETE FROM _artists_images WHERE ub = ?', 'DELETE FROM _artists_log WHERE ub = ?', 'DELETE FROM _artists_lyrics WHERE ub = ?', 'DELETE FROM _artists_posts WHERE post_ub = ?', 'DELETE FROM _artists_stats WHERE ub = ?', 'DELETE FROM _artists_viewers WHERE ub = ?', 'DELETE FROM _artists_voters WHERE ub = ?', 'DELETE FROM _artists_votes WHERE ub = ?', 'DELETE FROM _forum_topics WHERE topic_ub = ?', 'DELETE FROM _dl WHERE ub = ?' ); $d_sql = sql_filter($ary_sql, $a_data['ub']); $sql = 'SELECT topic_id FROM _forum_topics WHERE topic_ub = ?'; if ($topics = sql_rowset(sql_filter($sql, $a_data['ub']), false, 'topic_id')) { $d_sql[] = sql_filter('DELETE FROM _forum_posts WHERE topic_id IN (??)', _implode(',', $topics)); } $sql = 'SELECT id FROM _dl WHERE ub = ?'; if ($downloads = sql_rowset(sql_filter($sql, $a_data['ub']), false, 'id')) { $ary_sql = array( 'DELETE FROM _dl_fav WHERE dl_id IN (??)', 'DELETE FROM _dl_posts WHERE download_id IN (??)', 'DELETE FROM _dl_vote WHERE ud IN (??)', 'DELETE FROM _dl_voters WHERE ud IN (??)' ); $d_sql = array_merge($d_sql, sql_filter($ary_sql, _implode(',', $downloads))); } if (!_rm($config['artists_path'] . $a_data['ub'])) { _pre('Error al eliminar directorio de artista.', true); } sql_query($d_sql); // Cache $cache->delete('ub_list a_last_images'); redirect(s_link('a')); }
function sql_total($table) { return sql_field("SHOW TABLE STATUS LIKE '" . $table . "'", 'Auto_increment', 0); }
public function _home() { global $config, $user, $comments; $this->_artist(); if (_button()) { $message = request_var('message', ''); $message = $comments->prepare($message); $sql = 'UPDATE _artists SET bio = ? WHERE ub = ?'; sql_query(sql_filter($sql, $message, $this->object['ub'])); _style('updated'); } $sql = 'SELECT bio FROM _artists WHERE ub = ?'; $bio = sql_field(sql_filter($sql, $this->object['ub']), 'bio'); v_style(array( 'MESSAGE' => $bio) ); return; }
public function home() { global $core, $bio; $v = $this->__(array_merge(w('a r'), _array_keys(w('s'), 0))); if (!empty($v->a)) { } if (!empty($v->r)) { $sql = 'SELECT * FROM _objects o, _objects_type t, _bio b, _objects_rel_assoc ra, _objects_rel_type rt WHERE t.type_alias = ? AND rt.type_alias = ? AND o.object_bio = b.bio_id AND ra.assoc_object = o.object_id AND ra.assoc_rel_type = rt.type_id ORDER BY o.object_time LIMIT ??, ??'; $news = sql_rowset(sql_filter($sql, 'news', $v->r, $v->s, $core->v('objects_per_page'))); $sql = 'SELECT COUNT(object_id) AS total FROM _objects o, _objects_type t, _objects_rel_assoc ra, _objects_rel_type rt WHERE t.type_alias = ? AND rt.type_alias = ? AND ra.assoc_object = o.object_id AND ra.assoc_rel_type = rt.type_id'; $news_total = sql_field(sql_filter($sql, 'news', $v->r), 'total', 0); } else { $sql = 'SELECT * FROM _objects o, _objects_type t, _bio b WHERE t.type_alias = ? AND o.object_type = t.type_id AND o.object_bio = b.bio_id ORDER BY o.object_time LIMIT ??, ??'; $news = sql_rowset(sql_filter($sql, 'news', $v->s, $core->v('objects_per_page'))); $sql = 'SELECT COUNT(object_id) AS total FROM _objects o, _objects_type t WHERE t.type_alias = ? AND o.object_type = t.type_id'; $news_total = sql_field(sql_filter($sql, 'news'), 'total', 0); } foreach ($news as $i => $row) { if (!$i) { _style('news', _pagination(_link('news'), 's:%d', $news_total + 1, $core->v('objects_per_page'), $v->s)); } $_row = array('ID' => $row->object_id, 'BIO' => $row->object_bio, 'SUBJECT' => $row->object_subject, 'CONTENT' => _message($row->object_content), 'TIME' => $bio->format_date($row->object_time)); _style('news.row', array_merge($_row, $this->_profile($row))); } $sql = 'SELECT * FROM _objects_rel_type ORDER BY type_alias'; $rel_type = sql_rowset($sql); foreach ($rel_type as $i => $row) { if (!$i) { _style('rel_type', array('NEWS_URL' => _link('news'))); } $row->type_alias = _link('news', array('r' => $row->type_alias)); _style('rel_type.row', $row); } return; }
public function _home() { global $config, $user, $cache, $upload; if (_button()) { $news_id = request_var('news_id', 0); $sql = 'SELECT news_id FROM _news WHERE news_id = ?'; if (!sql_field(sql_filter($sql, $news_id), 'news_id', 0)) { fatal_error(); } $filepath_1 = $config['news_path']; $f = $upload->process($filepath_1, 'add_image', 'jpg'); if (!sizeof($upload->error) && $f !== false) { foreach ($f as $row) { $xa = $upload->resize($row, $filepath_1, $filepath_1, $news_id, array(100, 75), false, false, true); } redirect(s_link()); } _style('error', array( 'MESSAGE' => parse_error($upload->error)) ); } $sql = 'SELECT * FROM _news ORDER BY post_time DESC'; $result = sql_rowset($sql); foreach ($result as $row) { _style('news_list', array( 'NEWS_ID' => $row['news_id'], 'NEWS_TITLE' => $row['post_subject']) ); } return; }
public function _home() { global $config, $user, $cache; $this->id = request_var('msg_id', 0); $sql = 'SELECT * FROM _members_posts WHERE post_id = ?'; if (!$this->object = sql_fieldrow(sql_filter($sql, $this->id))) { fatal_error(); } $this->object = (object) $this->object; if (!$user->is('founder') && $user->d('user_id') != $this->object->userpage_id) { fatal_error(); } $sql = 'SELECT username_base FROM _members WHERE user_id = ?'; $username_base = sql_field(sql_filter($sql, $this->object->userpage_id), 'username_base', ''); $sql = 'DELETE FROM _members_posts WHERE post_id = ?'; sql_query(sql_filter($sql, $this->id)); $sql = 'UPDATE _members SET userpage_posts = userpage_posts - 1 WHERE user_id = ?'; sql_query(sql_filter($sql, $this->object->userpage_id)); $user->delete_unread(UH_UPM, $this->id); if ($this->object->post_time > points_start_date() && $this->object->post_time < 1203314400) { //$user->points_remove(1, $this->object->poster_id); } return redirect(s_link('m', $username_base)); }
public function _home() { global $config, $user, $cache, $comments; $sql = 'SELECT * FROM _members_unread WHERE element = ? GROUP BY item'; $result = sql_rowset(sql_filter($sql, UH_T)); foreach ($result as $row) { $sql2 = 'SELECT topic_id FROM _forum_topics WHERE topic_id = ?'; if (!sql_field(sql_filter($sql, $row['item']), 'topic_id', 0)) { $user->delete_all_unread(UH_T, $row['item']); } } _pre('Deleted', true); return; }
public function auth() { global $user; if ($user->is('founder') || ($this->data['ch_founder'] == $user->d('user_id'))) { return true; } // // Check friends // if ($this->data['ch_auth'] == 2) { $sql = 'SELECT * FROM _members_friends WHERE (user_id = ? AND buddy_id = ?) OR (user_id = ? AND buddy_id = ?)'; if (sql_fieldrow(sql_filter($sql, $this->data['ch_founder'], $user->d('user_id'), $user->d('user_id'), $this->data['ch_founder']))) { return true; } return false; } /* 0 - No Access 1 - Founder 2 - Member */ $sql = 'SELECT ch_auth FROM _chat_auth WHERE ch_id = ? AND ch_user_id = ?'; if ($ch_auth = sql_field(sql_filter($sql, $this->data['ch_id'], $user->d('user_id')), 'ch_auth', 0)) { switch ($ch_auth) { case 0: return false; break; case 1: $this->data['is_founder'] = true; break; case 2: $this->data['is_member'] = true; break; } } else { if ($this->data['ch_auth']) { return false; } } return true; }
public function run() { global $config, $auth, $user, $comments; $topic_id = request_var('t', 0); $post_id = request_var('p', 0); if (!$topic_id && !$post_id) { fatal_error(); } // // Get topic data // if ($post_id) { $sql_from = ', _forum_posts p, _forum_posts p2, _members m '; $sql_where = sql_filter('p.post_id = ? AND p.poster_id = m.user_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= ?', $post_id, $post_id); $sql_count = ', p.post_text, m.username AS reply_username, COUNT(p2.post_id) AS prev_posts, p.post_deleted'; $sql_order = ' GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_locked, t.topic_replies, t.topic_time, t.topic_important, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_locked, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_announce, f.auth_pollcreate, f.auth_vote ORDER BY p.post_id ASC'; } else { $sql_from = $sql_count = $sql_order = ''; $sql_where = sql_filter('t.topic_id = ?', $topic_id); } $sql = 'SELECT t.*, f.*' . $sql_count . ' FROM _forum_topics t, _forums f' . $sql_from . ' WHERE ' . $sql_where . ' AND f.forum_id = t.forum_id' . $sql_order; if (!$topic_data = sql_fieldrow($sql)) { fatal_error(); } switch ($topic_data['forum_alias']) { case 'events': $sql = 'SELECT event_alias FROM _events WHERE event_topic = ?'; if ($event_alias = sql_field(sql_filter($sql, $topic_data['topic_id']), 'event_alias', '')) { redirect(s_link('events', $event_alias)); } break; } // // Hide deleted posts if (isset($topic_data['post_deleted']) && $topic_data['post_deleted']) { fatal_error(); } // // Check mod auth $mod_auth = $user->is('mod'); // // Init vars // $forum_id = (int) $topic_data['forum_id']; $topic_id = (int) $topic_data['topic_id']; $topic_url = s_link('topic', $topic_id); $reply = request_var('reply', 0); $start = request_var('offset', 0); $submit_reply = _button('post'); $submit_vote = _button('vote'); $post_message = ''; $post_reply_message = ''; $post_np = ''; $current_time = time(); $error = $is_auth = w(); if (!$post_id && $reply) { $reply = 0; } // // Start member auth // $is_auth = $auth->forum(AUTH_ALL, $forum_id, $topic_data); if ($submit_reply || $submit_vote) { $auth_key = ($submit_reply) ? 'auth_reply' : 'auth_vote'; if (((!$is_auth['auth_view'] || !$is_auth['auth_read'])) || !$is_auth[$auth_key]) { if (!$user->is('member')) { do_login(); } $can_reply_closed = $auth->option(w('forum topics delete')); if (!$can_reply_closed && ($topic_data['forum_locked'] || $topic_data['topic_locked'])) { $error[] = 'TOPIC_LOCKED'; if ($submit_vote && !$topic_data['topic_vote']) { $error[] = 'POST_HAS_NO_POLL'; } } if (!sizeof($error)) { redirect($topic_url); } } if (!sizeof($error)) { if ($submit_vote) { $vote_option = request_var('vote_id', 0); if ($vote_option) { $sql = 'SELECT vd.vote_id FROM _poll_options vd, _poll_results vr WHERE vd.topic_id = ? AND vr.vote_id = vd.vote_id AND vr.vote_option_id = ? GROUP BY vd.vote_id'; if ($vote_id = sql_field(sql_filter($sql, $topic_id, $vote_option), 'vote_id', 0)) { $sql = 'SELECT * FROM _poll_voters WHERE vote_id = ? AND vote_user_id = ?'; if (!sql_fieldrow(sql_filter($sql, $vote_id, $user->d('user_id')))) { $sql = 'UPDATE _poll_results SET vote_result = vote_result + 1 WHERE vote_id = ? AND vote_option_id = ?'; sql_query(sql_filter($sql, $vote_id, $vote_option)); $insert_vote = array( 'vote_id' => (int) $vote_id, 'vote_user_id' => (int) $user->d('user_id'), 'vote_user_ip' => $user->ip, 'vote_cast' => (int) $vote_option ); sql_insert('poll_voters', $insert_vote); } } } redirect(s_link('topic', $topic_id)); } else { $post_message = request_var('message', '', true); $post_np = request_var('np', ''); if ($reply) { $post_reply_message = request_var('reply_message', '', true); } // Check message if (empty($post_message)) { $error[] = 'EMPTY_MESSAGE'; } if (!sizeof($error) && !$mod_auth) { $sql = 'SELECT MAX(post_time) AS last_post_time FROM _forum_posts WHERE poster_id = ?'; if ($last_post_time = sql_field(sql_filter($sql, $user->d('user_id')))) { if (intval($last_post_time) > 0 && ($current_time - intval($last_post_time)) < intval($config['flood_interval'])) { $error[] = 'FLOOD_ERROR'; } } } if (!sizeof($error)) { $update_topic = w(); if (strstr($post_message, '-Anuncio-') && $user->is('mod')) { $topic_announce = 1; $post_message = str_replace('-Anuncio-', '', $post_message); $update_topic['topic_announce'] = $topic_announce; } if (strstr($post_message, '-Cerrado-') && $user->is('mod')) { $topic_locked = 1; $post_message = str_replace('-Cerrado-', '', $post_message); $update_topic['topic_locked'] = $topic_locked; } $post_message = $comments->prepare($post_message); if ($reply && $post_reply_message != '') { $post_reply_message = preg_replace('#(^|[\n ]|\()(http|https|ftp)://([a-z0-9\-\.,\?!%\*_:;~\\&$@/=\+]+)(gif|jpg|jpeg|png)#ie', '', $post_reply_message); } if ($reply && empty($post_reply_message)) { $post_reply_message = '...'; } if ($reply && $post_reply_message != '') { $post_message = '<blockquote><strong>' . $topic_data['reply_username'] . "</strong>" . nr(false, 2) . $post_reply_message . '</blockquote><br /> ' . $post_message; } else { $reply = 0; } $insert_data = array( 'topic_id' => (int) $topic_id, 'forum_id' => (int) $forum_id, 'poster_id' => (int) $user->d('user_id'), 'post_time' => (int) $current_time, 'poster_ip' => $user->ip, 'post_text' => $post_message, 'post_np' => $post_np ); if ($reply) { $insert_data['post_reply'] = $post_id; } $post_id = sql_insert('forum_posts', $insert_data); $user->delete_unread(UH_T, $topic_id); $user->save_unread(UH_T, $topic_id); if (!in_array($forum_id, forum_for_team_array()) && $topic_data['topic_points']) { //$user->points_add(1); } // $a_list = forum_for_team_list($forum_id); if (count($a_list)) { $sql_delete_unread = 'DELETE FROM _members_unread WHERE element = ? AND item = ? AND user_id NOT IN (??)'; sql_query(sql_filter($sql_delete_unread, 8, $topic_id, implode(', ', $a_list))); } $update_topic['topic_last_post_id'] = $post_id; if ($topic_locked) { topic_feature($topic_id, 0); } $sql = 'UPDATE _forums SET forum_posts = forum_posts + 1, forum_last_topic_id = ? WHERE forum_id = ?'; sql_query(sql_filter($sql, $topic_id, $forum_id)); $sql = 'UPDATE _forum_topics SET topic_replies = topic_replies + 1, ' . sql_build('UPDATE', $update_topic) . sql_filter(' WHERE topic_id = ?', $topic_id); sql_query($sql); $sql = 'UPDATE _members SET user_posts = user_posts + 1 WHERE user_id = ?'; sql_query(sql_filter($sql, $user->d('user_id'))); redirect(s_link('post', $post_id) . '#' . $post_id); } } } } if (!$is_auth['auth_view'] || !$is_auth['auth_read']) { if (!$user->is('member')) { do_login(); } fatal_error(); } if ($post_id) { $start = floor(($topic_data['prev_posts'] - 1) / (int) $config['posts_per_page']) * (int) $config['posts_per_page']; $user->d('user_topic_order', 0); } if ($user->is('member')) { // // Is user watching this topic? // $sql = 'SELECT notify_status FROM _forum_topics_fav WHERE topic_id = ? AND user_id = ?'; if (!sql_field(sql_filter($sql, $topic_id, $user->d('user_id')), 'notify_status')) { if (_button('watch')) { $sql_insert = array( 'user_id' => $user->d('user_id'), 'topic_id' => $topic_id, 'notify_status' => 0 ); sql_insert('forum_topics_fav', $sql_insert); redirect($topic_url . (($start) ? 's' . $start . '/' : '')); } _style('watch_topic'); } } // // Get all data for the topic // $get_post_id = ($reply) ? 'post_id' : 'topic_id'; $get_post_data['p.' . $get_post_id] = ${$get_post_id}; if (!$user->is('founder')) { $get_post_data['p.post_deleted'] = 0; } $sql = 'SELECT p.*, u.user_id, u.username, u.username_base, u.user_avatar, u.user_posts, u.user_gender, u.user_rank, u.user_sig FROM _forum_posts p, _members u WHERE u.user_id = p.poster_id AND p.post_deleted = 0 AND ' . sql_build('SELECT', $get_post_data) . ' ORDER BY p.post_time ' . (($user->d('user_topic_order')) ? 'DESC' : 'ASC') . ((!$reply) ? ' LIMIT ' . (int) $start . ', ' . (int) $config['posts_per_page'] : ''); if (!$messages = sql_rowset($sql)) { if ($topic_data['topic_replies'] + 1) { fatal_error(); } redirect(s_link('topic', $topic_id)); } // // Re-count topic replies // if ($user->is('founder')) { $sql = 'SELECT COUNT(p.post_id) AS total FROM _forum_posts p, _members u WHERE p.topic_id = ? AND u.user_id = p.poster_id'; if ($total = sql_field(sql_filter($sql, $topic_id), 'total')) { $topic_data['topic_replies2'] = $total - 1; } } // // Update the topic views // if (!$start && !$user->is('founder')) { $sql = 'UPDATE _forum_topics SET topic_views = topic_views + 1 WHERE topic_id = ?'; sql_query(sql_filter($sql, $topic_id)); } // // If the topic contains a poll, then process it // if ($topic_data['topic_vote']) { $sql = 'SELECT vd.vote_id, vd.vote_text, vd.vote_start, vd.vote_length, vr.vote_option_id, vr.vote_option_text, vr.vote_result FROM _poll_options vd, _poll_results vr WHERE vd.topic_id = ? AND vr.vote_id = vd.vote_id ORDER BY vr.vote_option_order, vr.vote_option_id ASC'; if ($vote_info = sql_rowset(sql_filter($sql, $topic_id))) { $sql = 'SELECT vote_id FROM _poll_voters WHERE vote_id = ? AND vote_user_id = ?'; $user_voted = sql_field(sql_filter($sql, $vote_info[0]['vote_id'], $user->d('user_id')), 'vote_id', 0); $poll_expired = ($vote_info[0]['vote_length']) ? (($vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < $current_time) ? true : 0) : 0; _style('poll', array( 'POLL_TITLE' => $vote_info[0]['vote_text']) ); if ($user_voted || $poll_expired || !$is_auth['auth_vote'] || $topic_data['topic_locked']) { $vote_results_sum = 0; foreach ($vote_info as $row) { $vote_results_sum += $row['vote_result']; } _style('poll.results'); foreach ($vote_info as $row) { $vote_percent = ($vote_results_sum > 0) ? $row['vote_result'] / $vote_results_sum : 0; _style('poll.results.item', array( 'CAPTION' => $row['vote_option_text'], 'RESULT' => $row['vote_result'], 'PERCENT' => sprintf("%.1d", ($vote_percent * 100))) ); } } else { _style('poll.options', array( 'S_VOTE_ACTION' => $topic_url) ); foreach ($vote_info as $row) { _style('poll.options.item', array( 'POLL_OPTION_ID' => $row['vote_option_id'], 'POLL_OPTION_CAPTION' => $row['vote_option_text']) ); } } } } // // Advanced auth // $controls = $user_profile = w(); $unset_user_profile = w('user_id user_posts user_gender'); _style('posts'); foreach ($messages as $row) { if ($user->is('member')) { $poster = ($row['user_id'] != GUEST) ? $row['username'] : (($row['post_username'] != '') ? $row['post_username'] : lang('guest')); $controls[$row['post_id']]['reply'] = s_link('post', $row['post_id'], 'reply'); if ($mod_auth) { $controls[$row['post_id']]['edit'] = s_link('acp', array('forums_post_modify', 'msg_id' => $row['post_id'])); $controls[$row['post_id']]['delete'] = s_link('acp', array('forums_post_delete', 'msg_id' => $row['post_id'])); } } $user_profile[$row['user_id']] = $comments->user_profile($row, '', $unset_user_profile); $data = array( 'POST_ID' => $row['post_id'], 'POST_DATE' => $user->format_date($row['post_time']), 'MESSAGE' => $comments->parse_message($row['post_text']), 'PLAYING' => $row['post_np'], 'DELETED' => $row['post_deleted'], 'UNREAD' => 0 ); foreach ($user_profile[$row['user_id']] as $key => $value) { $data[strtoupper($key)] = $value; } _style('posts.item', $data); _style('posts.item.' . (($row['user_id'] != GUEST) ? 'username' : 'guestuser')); if (isset($controls[$row['post_id']])) { _style('posts.item.controls'); foreach ($controls[$row['post_id']] as $item => $url) { _style('posts.item.controls.'.$item, array('URL' => $url)); } } } // // Display Member topic auth // /* if ($mod_auth) { $mod = array((($topic_data['topic_important']) ? 'important' : 'normal'), 'delete', 'move', ((!$topic_data['topic_locked']) ? 'lock' : 'unlock'), 'split', 'merge'); $mod_topic = w(); foreach ($mod as $item) { if ($auth->option(array('forum', 'topics', $item))) { $mod_topic[strtoupper($item)] = s_link('acp', array('topic', topic' => $topic_id, 'mode' => $item)); } } if (sizeof($mod_topic)) { _style('auth'); foreach ($mod_topic as $k => $v) { _style('auth.item', array( 'URL' => $v, 'LANG' => lang($k . '_topic')) ); } } } */ build_num_pagination($topic_url . 's%d/', ($topic_data['topic_replies'] + 1), $config['posts_per_page'], $start, '', 'TOPIC_'); // // Posting box if (sizeof($error)) { _style('post_error', array( 'MESSAGE' => parse_error($error)) ); } $can_reply_closed = $auth->option(array('forum', 'topics', 'delete')); if ((!$topic_data['forum_locked'] && !$topic_data['topic_locked']) || $can_reply_closed) { if ($user->is('member')) { if ($is_auth['auth_reply']) { $s_post_action = (($reply) ? s_link('post', $post_id, 'reply') : $topic_url) . '#e'; _style('post_box', array( 'MESSAGE' => $post_message, 'NP' => $post_np, 'S_POST_ACTION' => $s_post_action) ); if ($reply) { if (empty($post_reply_message)) { $post_reply_message = $comments->remove_quotes($topic_data['post_text']); } if (!empty($post_reply_message)) { $rx = array('#(^|[\n ]|\()(http|https|ftp)://([a-z0-9\-\.,\?!%\*_:;~\\&$@/=\+]+)(gif|jpg|jpeg|png)#is', '#\[yt:[0-9a-zA-Z\-\=\_]+\]#is', '#\[sb\]#is', '#\[\/sb\]#is'); $post_reply_message = preg_replace($rx, '', $post_reply_message); } if (empty($post_reply_message)) { $post_reply_message = '...'; } _style('post_box.reply', array( 'MESSAGE' => $post_reply_message) ); } } } } // MOD: Featured topic if ($user->is('mod')) { $v_lang = ($topic_data['topic_featured']) ? 'REM' : 'ADD'; _style('feature', array( 'U_FEAT' => s_link('acp', array('forums_topic_feature', 'msg_id', $topic_data['topic_id'])), 'V_LANG' => lang('topic_featured_' . $v_lang)) ); } // // Send vars to template // v_style(array( 'FORUM_NAME' => $topic_data['forum_name'], 'TOPIC_TITLE' => $topic_data['topic_title'], 'TOPIC_REPLIES' => $topic_data['topic_replies'], 'S_TOPIC_ACTION' => $topic_url . (($start) ? 's' . $start . '/' : ''), 'U_VIEW_FORUM' => s_link('forum', $topic_data['forum_alias'])) ); $layout_file = 'topic'; if (@file_exists('./template/custom/topics_' . $forum_id . '.htm')) { $layout_file = 'custom/topics_' . $forum_id; } if (@file_exists('./template/custom/topic_' . $topic_id . '.htm')) { $layout_file = 'custom/topic_' . $topic_id; } $this->_title = $topic_data['topic_title']; $this->_template = $layout_file; return; }
protected final function bio_follower($local, $remote = false) { if ($remote === false) { global $bio; $remote = $bio->v('bio_id'); } $sql = 'SELECT follower_id FROM _bio_followers WHERE follower_local = ? AND follower_remote = ? AND follower_active = ? LIMIT 1'; if (sql_field(sql_filter($sql, $local, $remote, 1), 'follower_id', 0)) { return true; } return false; }
public function _rate_home() { $v = $this->__(array('img' => '', 'rec' => '')); $v2 = w(); foreach ($v as $kv => $vv) { $v2[$kv] = decode($vv); } $address_id = 0; $sql = 'SELECT * FROM _email WHERE email_id = ?'; if ($email = sql_fieldrow(sql_filter($sql, $v2['img']))) { $sql = 'SELECT address_id FROM ?? WHERE address_id = ?'; $address_id = sql_field(sql_filter($sql, $email['email_data'], $v2['rec']), 'address_id', 0); } $filepath = XFS . 'space/emails/' . $v2['img'] . '.jpg'; if (!@file_exists($filepath) || !$email || !$address_id) { header('Content-Type: text/html; charset=iso-8859-1'); header("HTTP/1.1 404 Not Found"); echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>404 Not Found</title> </head><body> <h1>Not Found</h1> <p>The requested URL /i' . $v['img'] . '-' . $v['rec'] . '.jpg was not found on this server.</p> </body></html> '; exit; } $sql = 'UPDATE ?? SET address_viewed = ? WHERE address_id = ?'; sql_query(sql_filter($sql, $email['email_data'], time(), $v2['rec'])); header('Content-Type: image/jpeg'); @readfile($filepath); exit; }
private function create() { $v = _request(array('event' => 0)); if (_empty($v)) { return; } $sql = 'SELECT id, event_alias FROM _events WHERE id = ?'; if (!$event = sql_fieldrow(sql_filter($sql, $v->event))) { return; } $sql = 'SELECT ub FROM _artists_events WHERE a_artist = ? AND a_event = ?'; if (sql_field(sql_filter($sql, $this->object['ub'], $v->event))) { return; } $sql_insert = array( 'a_artist' => $this->object['ub'], 'a_event' => $event['id'] ); sql_insert('artists_events', $sql_insert); return redirect(s_link('events', $event['event_alias'])); }
public function _panel() { global $user, $config, $template; $this->data['layout'] = request_var('layout', ''); $this->_auth(); if (!$this->data['layout']) { $this->data['layout'] = 'main'; } switch ($this->data['layout']) { case 'website': case 'favorites': case 'vote': $this->call_layout(); break; default: $this->_make(true); /* Build nav menu */ /*$s_layout = w(); $s_layout['a']['_01'] = true; $s_layout['a']['_02'] = ($this->data['bio'] != '') ? true : false; $s_layout['a']['_04'] = ($this->data['images'] > 1) ? true : false; $s_layout['a']['_06'] = ($this->data['lirics'] > 0) ? true : false; $s_layout['a']['_09'] = ($this->data['layout'] == 9) ? true : false; $s_layout['a']['_12'] = ($this->data['layout'] == 12) ? true : false; $s_layout['a']['_18'] = ($this->data['a_video'] > 0) ? true : false; */ $available = w(); foreach ($this->layout as $i => $row) { if ($this->data['layout'] == $row['tpl']) { $this->data['template'] = $row['tpl']; } if ($this->{'_' . $row['tpl']}()) { $available[$row['tpl']] = true; _style('nav', array( 'LANG' => lang($row['text'])) ); if ($this->data['layout'] == $row['tpl']) { _style('nav.strong'); } else { $tpl = ($row['tpl'] == 'main') ? '' : $row['tpl']; _style('nav.a', array( 'URL' => s_link('a', $this->data['subdomain'], $tpl)) ); } } } if (!isset($available[$this->data['layout']])) { redirect(s_link('a', $this->data['subdomain'])); } $this->_make(); //_pre($available, true); /*foreach ($this->layout as $item => $data) { $s_layout['x'][$item] = $data['code']; if ($data['text'] == '') { $s_layout['e'][$item] = $data['code']; } if (isset($s_layout['a'][$item]) && $s_layout['a'][$item] && $data['tpl'] != '') { $s_layout['s'][$data['code']] = $data; } if (($this->data['layout'] == $data['code']) && $data['tpl'] != '') { $this->data['template'] = $data['tpl']; } } if (!in_array($this->data['layout'], $s_layout['x']) || (!isset($s_layout['s'][$this->data['layout']]) && !in_array($this->data['layout'], $s_layout['e']))) { redirect(s_link('a', $this->data['subdomain'])); }*/ // // Call selected layout // $this->call_layout(); // // Build nav // /*foreach ($s_layout['s'] as $data) { _style('nav', array( 'LANG' => lang($data['text'])) ); if ($this->data['layout'] == $data['code']) { _style('nav.strong'); continue; } if ($data['code'] === 1) $data['code'] = ''; _style('nav.a', array( 'URL' => s_link('a', $this->data['subdomain'], $data['code'])) ); }*/ // // Update stats // if (!$this->auth['mod']) { $update_views = false; $current_time = time(); $current_month = date('Ym', $current_time); if ($this->auth['user']) { $sql_viewers = array( 'datetime' => (int) $current_time, 'user_ip' => $user->ip ); $sql_viewers2 = array( 'ub' => (int) $this->data['ub'], 'user_id' => (int) $user->d('user_id') ); $sql = 'UPDATE _artists_viewers SET ?? WHERE ??'; sql_query(sql_filter($sql, sql_build('UPDATE', $sql_viewers), sql_build('SELECT', $sql_viewers2))); if (!sql_affectedrows()) { $update_views = true; $sql_stats = array('ub' => (int) $this->data['ub'], 'date' => (int) $current_month); sql_insert('artists_viewers', $sql_viewers + $sql_viewers2); $sql = 'UPDATE _artists_stats SET members = members + 1 WHERE ??'; sql_query(sql_filter($sql, sql_build('SELECT', $sql_stats))); if (!sql_affectedrows()) { $sql_insert = array( 'members' => 1, 'guests' => 0 ); sql_insert('artists_stats', $sql_stats + $sql_insert); } $sql = 'SELECT user_id FROM _artists_viewers WHERE ub = ? ORDER BY datetime DESC LIMIT 10, 1'; if ($row = sql_fieldrow(sql_filter($sql, $this->data['ub']))) { $sql = 'DELETE FROM _artists_viewers WHERE ub = ? AND user_id = ?'; sql_query(sql_filter($sql, $this->data['ub'], $row['user_id'])); } } } $_ps = request_var('ps', 0); if ((($this->auth['user'] && $update_views) || (!$this->auth['user'] && $this->data['layout'] == 1)) && !$_ps) { $sql = 'UPDATE _artists SET views = views + 1 WHERE ub = ?'; sql_query(sql_filter($sql, $this->data['ub'])); $this->data['views']++; if ((!$this->auth['user'] && $this->data['layout'] == 1) && !$_ps) { $sql_stats = array( 'ub' => (int) $this->data['ub'], 'date' => (int) $current_month ); $sql = 'UPDATE _artists_stats SET guests = guests + 1 WHERE ??'; sql_query(sql_filter($sql, sql_build('SELECT', $sql_stats))); if (!sql_affectedrows()) { $sql_insert = array( 'members' => 0, 'guests' => 1 ); sql_insert('artists_stats', $sql_stats + $sql_insert); } } } } // // Own events // $timezone = $config['board_timezone'] * 3600; list($d, $m, $y) = explode(' ', gmdate('j n Y', time() + $user->timezone + $user->dst)); $midnight = gmmktime(0, 0, 0, $m, $d, $y) - $user->timezone - $user->dst; $g = getdate($midnight); $week = mktime(0, 0, 0, $m, ($d + (7 - ($g['wday'] - 1)) - (!$g['wday'] ? 7 : 0)), $y) - $timezone; $sql = 'SELECT * FROM _events e, _artists_events ae WHERE ae.a_artist = ? AND ae.a_event = e.id ORDER BY e.date'; $result = sql_rowset(sql_filter($sql, $this->data['ub'])); $events = w(); foreach ($result as $row) { if ($row['date'] >= $midnight) { if ($row['date'] >= $midnight && $row['date'] < $midnight + 86400) { $events['is_today'][] = $row; } else if ($row['date'] >= $midnight + 86400 && $row['date'] < $midnight + (86400 * 2)) { $events['is_tomorrow'][] = $row; } else if ($row['date'] >= $midnight + (86400 * 2) && $row['date'] < $week) { $events['is_week'][] = $row; } else { $events['is_future'][] = $row; } } else if ($row['images']) { $events['is_gallery'][] = $row; } } if (isset($events['is_gallery']) && sizeof($events['is_gallery'])) { $gallery = $events['is_gallery']; @krsort($gallery); _style('events_gallery'); foreach ($gallery as $row) { _style('events_gallery.item', array( 'URL' => s_link('events', $row['event_alias']), 'TITLE' => $row['title'], 'DATETIME' => $user->format_date($row['date'], lang('date_format'))) ); } unset($events['is_gallery']); } if (sizeof($events)) { _style('events_future'); foreach ($events as $is_date => $data) { _style('events_future.set', array( 'L_TITLE' => lang('ue_' . $is_date)) ); foreach ($data as $item) { _style('events_future.set.row', array( 'ITEM_ID' => $item['id'], 'TITLE' => $item['title'], 'DATE' => $user->format_date($item['date']), 'THUMBNAIL' => $config['events_url'] . 'future/thumbnails/' . $item['id'] . '.jpg', 'SRC' => $config['events_url'] . 'future/' . $item['id'] . '.jpg') ); } } } // // Poll // $user_voted = false; if ($this->auth['user'] && !$this->auth['mod']) { $sql = 'SELECT * FROM _artists_voters WHERE ub = ? AND user_id = ?'; if (sql_fieldrow(sql_filter($sql, $this->data['ub'], $user->d('user_id')))) { $user_voted = true; } } _style('ub_poll'); if ($this->auth['mod'] || !$this->auth['user'] || $user_voted) { $sql = 'SELECT option_id, vote_result FROM _artists_votes WHERE ub = ? ORDER BY option_id'; $results = sql_rowset(sql_filter($sql, $this->data['ub']), 'option_id', 'vote_result'); _style('ub_poll.results'); foreach ($this->voting['ub'] as $item) { $vote_result = (isset($results[$item])) ? intval($results[$item]) : 0; $vote_percent = ($this->data['votes'] > 0) ? $vote_result / $this->data['votes'] : 0; _style('ub_poll.results.item', array( 'CAPTION' => lang('ub_vc' . $item), 'RESULT' => $vote_result, 'PERCENT' => sprintf("%.1d", ($vote_percent * 100))) ); } } else { _style('ub_poll.options', array( 'S_VOTE_ACTION' => s_link('a', $this->data['subdomain'], 'vote')) ); foreach ($this->voting['ub'] as $item) { _style('ub_poll.options.item', array( 'ID' => $item, 'CAPTION' => lang('ub_vc' . $item)) ); } } // // Downloads // if ($this->data['um'] || $this->data['uv']) { $sql = 'SELECT * FROM _dl WHERE ub = ? ORDER BY ud, title'; $this->ud_song = sql_rowset(sql_filter($sql, $this->data['ub']), 'ud', false, true); foreach ($this->ud_song as $key => $data) { $download_type = $this->dl_type($key); _style('ud_block', array('LANG' => $download_type['lang'])); foreach ($data as $song) { _style('ud_block.item', array( 'TITLE' => $song['title']) ); if (isset($this->dl_data['id']) && ($song['id'] == $this->dl_data['id'])) { _style('ud_block.item.strong'); continue; } _style('ud_block.item.a', array( 'URL' => s_link('a', $this->data['subdomain'], 'downloads', $song['id'])) ); } } } // // Fan count // $sql = 'SELECT COUNT(user_id) AS fan_count FROM _artists_fav WHERE ub = ? ORDER BY joined DESC'; $fan_count = sql_field(sql_filter($sql, $this->data['ub']), 'fan_count', 0); // // Make fans // if (!$this->auth['mod'] && !$this->auth['smod']) { _style('make_fans', array( 'FAV_URL' => s_link('a', $this->data['subdomain'], 'favorites'), 'FAV_LANG' => ($this->auth['fav']) ? '' : lang('ub_fav_add')) ); } // // Set template // v_style(array( 'INACTIVE' => !$this->data['a_active'], 'UNAME' => $this->data['name'], 'GENRE' => $this->data['genre'], 'POSTS' => number_format($this->data['posts']), 'VOTES' => number_format($this->data['votes']), 'FANS' => $fan_count, 'L_FANS' => ($fan_count == 1) ? lang('fan') : lang('fans'), 'LOCATION' => ($this->data['local']) ? (($this->data['location'] != '') ? $this->data['location'] . ', ' : '') . 'Guatemala' : $this->data['location']) ); $template->set_filenames(array( 'a_body' => 'artists.' . $this->data['template'] . '.htm') ); $template->assign_var_from_handle('UB_BODY', 'a_body'); break; } return; }
public function object() { global $auth, $user, $config, $comments, $upload; $mode = request_var('mode', ''); switch ($mode) { case 'view': case 'fav': case 'rsvp': $download_id = request_var('download_id', 0); if (!$download_id) { redirect(s_link('events', $this->v('event_alias'))); } switch ($mode) { case 'view': $sql = 'SELECT e.*, COUNT(e2.image) AS prev_images FROM _events_images e, _events_images e2 WHERE e.event_id = ? AND e.event_id = e2.event_id AND e.image = ? AND e2.image <= ? GROUP BY e.image ORDER BY e.image ASC'; $sql = sql_filter($sql, $this->v('id'), $download_id, $download_id); break; case 'rsvp': $sql = ''; break; default: $sql = 'SELECT e2.* FROM _events_images e2 LEFT JOIN _events e ON e.id = e2.event_id WHERE e2.event_id = ? AND e2.image = ?'; $sql = sql_filter($sql, $this->v('id'), $download_id); break; } if (!empty($sql)) { if (!$imagedata = sql_fieldrow($sql)) { redirect(s_link('events', $this->v('event_alias'))); } } break; } switch ($mode) { case 'fav': if (!$user->is('member')) { do_login(); } $sql = 'SELECT * FROM _events_fav WHERE event_id = ? AND image_id = ? AND member_id = ?'; if ($row = sql_fieldrow(sql_filter($sql, $this->v('id'), $imagedata['image'], $user->d('user_id')))) { $sql = 'UPDATE _events_fav SET fav_date = ? WHERE event_id = ? AND image_id = ?'; sql_query(sql_filter($sql, time(), $this->v('id'), $imagedata['image'])); } else { $sql_insert = array( 'event_id' => (int) $this->v('id'), 'image_id' => (int) $imagedata['image'], 'member_id' => (int) $user->d('user_id'), 'fav_date' => time() ); sql_insert('events_fav', $sql_insert); } redirect(s_link('events', $this->v('event_alias'), $imagedata['image'], 'view')); break; case 'rsvp': $choice = array_key(array_keys(request_var('choice', array(0 => ''))), 0); $topic_id = $this->v('event_topic'); if (!$topic_id) { fatal_error(); } if (!$choice) { redirect(s_link('events', $this->v('event_alias'))); } if (!$user->is('member')) { do_login(); } $sql = 'SELECT vd.vote_id FROM _poll_options vd, _poll_results vr WHERE vd.topic_id = ? AND vr.vote_id = vd.vote_id AND vr.vote_option_id = ? GROUP BY vd.vote_id'; if (!$vote_id = sql_field(sql_filter($sql, $topic_id, $choice), 'vote_id', 0)) { fatal_error(); } $sql = 'SELECT * FROM _poll_voters WHERE vote_id = ? AND vote_user_id = ?'; if (!sql_fieldrow(sql_filter($sql, $vote_id, $user->d('user_id')))) { $sql = 'UPDATE _poll_results SET vote_result = vote_result + 1 WHERE vote_id = ? AND vote_option_id = ?'; sql_query(sql_filter($sql, $vote_id, $choice)); $insert_vote = array( 'vote_id' => (int) $vote_id, 'vote_user_id' => (int) $user->d('user_id'), 'vote_user_ip' => $user->ip, 'vote_cast' => (int) $choice ); sql_insert('poll_voters', $insert_vote); } redirect(s_link('events', $this->v('event_alias'))); break; case 'view': default: /** * Generate thumbnail for events list. */ if ($user->is('colab') && !$this->v('images') && _button('create_thumbnail')) { $location_large = $config['events_path'] . 'future/' . $this->v('id') . '.jpg'; $location_mini = $config['events_path'] . 'mini/' . $this->v('id') . '.jpg'; $x1 = request_var('x1', 0); $y1 = request_var('y1', 0); $x2 = request_var('x2', 0); $y2 = request_var('y2', 0); $w = request_var('w', 0); $h = request_var('h', 0); //Scale the image to the thumb_width set above $scale = $config['events_thumb_width'] / $w; $cropped = $upload->resizeThumbnailImage($location_mini, $location_large, $w, $h, $x1, $y1, $scale); redirect(s_link('events')); } /** * Normal operations */ $t_offset = request_var('offset', 0); if ($mode == 'view') { $sql = 'UPDATE _events_images SET views = views + 1 WHERE event_id = ? AND image = ?'; sql_query(sql_filter($sql, $this->v('id'), $imagedata['image'])); _style('selected', array( 'IMAGE' => $config['events_url'] . 'gallery/' . $this->v('id') . '/' . $imagedata['image'] . '.jpg', 'WIDTH' => $imagedata['width'], 'HEIGHT' => $imagedata['height'], 'FOOTER' => $imagedata['image_footer']) ); if ($user->is('founder')) { _style('selected.update', array( 'URL' => s_link('async eif'), 'EID' => $this->v('id'), 'PID' => $imagedata['image']) ); } $is_fav = false; if ($user->is('member')) { $sql = 'SELECT member_id FROM _events_fav WHERE event_id = ? AND image_id = ? AND member_id = ?'; if (sql_field(sql_filter($sql, $this->v('id'), $imagedata['image'], $user->d('user_id')), 'member_id', 0)) { $is_fav = true; } } if (!$is_fav || !$user->is('member')) { _style('selected.fav', array( 'URL' => s_link('events', $this->v('id'), $imagedata['image'], 'fav')) ); } } else { if (!$t_offset && $user->is('founder')) { $sql = 'UPDATE _events SET views = views + 1 WHERE id = ?'; sql_query(sql_filter($sql, $this->v('id'))); } } $sql = 'SELECT t.topic_id, t.topic_title, t.topic_locked, t.topic_replies, t.topic_time, t.topic_important, t.topic_vote, t.topic_featured, t.topic_points, t.topic_last_post_id, f.forum_alias, f.forum_name, f.forum_locked, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_announce, f.auth_pollcreate, f.auth_vote FROM _forum_topics t, _forums f WHERE t.topic_id = ? AND f.forum_id = t.forum_id'; if (!$event_topic = sql_fieldrow(sql_filter($sql, $this->v('event_topic')))) { fatal_error(); } $mod_auth = $user->is('mod'); $error = w(); $forum_id = $event_topic['forum_id']; $submit_reply = _button('post'); $reply = request_var('reply', 0); if ($reply) { $post_reply = request_var('p', 0); $sql = 'SELECT p.*, u.user_id, u.username FROM _forum_posts p, _members u WHERE p.post_id = ? AND u.user_id = p.poster_id AND p.post_deleted = 0'; if (!$post_data = sql_fieldrow(sql_filter($sql, $post_reply))) { redirect(s_link('events', $this->v('event_alias'))); } } $is_auth = $auth->forum(AUTH_ALL, $forum_id, $event_topic); $u_event_alias = s_link('events', $this->v('event_alias')); $u_event_publish = ($reply) ? s_link('events', $this->v('event_alias'), $post_reply, 'reply') : $u_event_alias; if ($submit_reply) { $auth_key = 'auth_reply'; if (((!$is_auth['auth_view'] || !$is_auth['auth_read'])) || !$is_auth[$auth_key]) { if (!$user->is('member')) { do_login(); } $can_reply_closed = $auth->option(array('forum', 'topics', 'delete')); if (!$can_reply_closed && ($event_topic['forum_locked'] || $event_topic['topic_locked'])) { $error[] = 'TOPIC_LOCKED'; } if (sizeof($error)) { redirect($u_event_alias); } } $post_message = request_var('message', '', true); if ($reply) { $post_reply_message = request_var('reply_message', '', true); } // Check message if (empty($post_message)) { $error[] = 'EMPTY_MESSAGE'; } if (sizeof($error)) { redirect($u_event_alias); } if (!$mod_auth) { $sql = 'SELECT MAX(post_time) AS last_post_time FROM _forum_posts WHERE poster_id = ?'; if ($last_post_time = sql_field(sql_filter($sql, $user->d('user_id')))) { if (intval($last_post_time) > 0 && ($current_time - intval($last_post_time)) < intval($config['flood_interval'])) { $error[] = 'FLOOD_ERROR'; } } } if (sizeof($error)) { redirect($u_event_alias); } $update_topic = w(); if (strstr($post_message, '-Anuncio-') && $user->is('mod')) { $topic_announce = 1; $post_message = str_replace('-Anuncio-', '', $post_message); $update_topic['topic_announce'] = $topic_announce; } if (strstr($post_message, '-Cerrado-') && $user->is('mod')) { $topic_locked = 1; $post_message = str_replace('-Cerrado-', '', $post_message); $update_topic['topic_locked'] = $topic_locked; } $post_message = $comments->prepare($post_message); if ($reply && $post_reply_message != '') { $post_reply_message = preg_replace('#(^|[\n ]|\()(http|https|ftp)://([a-z0-9\-\.,\?!%\*_:;~\\&$@/=\+]+)(gif|jpg|jpeg|png)#ie', '', $post_reply_message); } if ($reply && empty($post_reply_message)) { $post_reply_message = '...'; } if ($reply && $post_reply_message != '') { $post_message = '<blockquote><strong>' . $post_data['username'] . "</strong>" . nr(false, 2) . $post_reply_message . '</blockquote><br /> ' . $post_message; } else { $reply = 0; } $insert_data = array( 'topic_id' => (int) $this->v('event_topic'), 'forum_id' => (int) $forum_id, 'poster_id' => (int) $user->d('user_id'), 'post_time' => time(), 'poster_ip' => $user->ip, 'post_text' => $post_message, 'post_np' => '' ); if ($reply) { $insert_data['post_reply'] = $post_reply; } $post_id = sql_insert('forum_posts', $insert_data); $user->delete_unread(UH_T, $this->v('event_topic')); $user->save_unread(UH_T, $this->v('event_topic')); // $a_list = forum_for_team_list($forum_id); if (count($a_list)) { $sql_delete_unread = 'DELETE FROM _members_unread WHERE element = ? AND item = ? AND user_id NOT IN (??)'; sql_query(sql_filter($sql, 8, $this->v('event_topic'), implode(', ', $a_list))); } $update_topic['topic_last_post_id'] = $post_id; if ($topic_locked) { topic_feature($topic_id, 0); } $sql = 'UPDATE _forums SET forum_posts = forum_posts + 1, forum_last_topic_id = ? WHERE forum_id = ?'; sql_query(sql_filter($sql, $this->v('event_topic'), $forum_id)); $sql = 'UPDATE _forum_topics SET topic_replies = topic_replies + 1, ' . sql_build('UPDATE', $update_topic) . sql_filter(' WHERE topic_id = ?', $this->v('event_topic')); sql_query($sql); $sql = 'UPDATE _members SET user_posts = user_posts + 1 WHERE user_id = ?'; sql_query(sql_filter($sql, $user->d('user_id'))); redirect($u_event_alias); } // Get event thumbnails $t_per_page = 18; if ($mode == 'view' && $download_id) { $val = 1; $sql = 'SELECT MAX(image) AS total FROM _events_images WHERE event_id = ?'; if ($maximage = sql_field(sql_filter($sql, $this->v('id')), 'total', 0)) { $val = ($download_id == $maximage) ? 2 : 1; } $t_offset = floor(($imagedata['prev_images'] - $val) / $t_per_page) * $t_per_page; } if ($this->v('images')) { $exception_sql = (isset($download_id) && $download_id) ? sql_filter(' AND g.image <> ? ', $download_id) : ''; $sql = 'SELECT g.* FROM _events e, _events_images g WHERE e.id = ? AND e.id = g.event_id ' . $exception_sql . ' ORDER BY g.image ASC LIMIT ??, ??'; if (!$result = sql_rowset(sql_filter($sql, $this->v('id'), $t_offset, $t_per_page))) { redirect(s_link('events', $this->v('id'))); } build_num_pagination(s_link('events', $this->v('id'), 's%d'), $this->v('images'), $t_per_page, $t_offset, 'IMG_'); _style('thumbnails'); foreach ($result as $row) { _style('thumbnails.item', array( 'URL' => s_link('events', $this->v('event_alias'), $row['image'], 'view'), 'IMAGE' => $config['events_url'] . 'gallery/' . $this->v('id') . '/thumbnails/' . $row['image'] . '.jpg', 'RIMAGE' => $config['events_url'] . 'gallery/' . $this->v('id') . '/' . $row['image'] . '.jpg', 'FOOTER' => $row['image_footer'], 'WIDTH' => $row['width'], 'HEIGHT' => $row['height']) ); } // Credits $sql = 'SELECT * FROM _events_colab c, _members m WHERE c.colab_event = ? AND c.colab_uid = m.user_id ORDER BY m.username'; if ($result = sql_rowset(sql_filter($sql, $this->v('id')))) { _style('collab'); foreach ($result as $row) { _style('collab.row', array( 'PROFILE' => s_link('m', $row['username_base']), 'USERNAME' => $row['username']) ); } } } else { _style('event_flyer', array( 'IMAGE_SRC' => $config['events_url'] . 'future/' . $this->v('id') . '.jpg?u=' . $this->v('event_update')) ); $location_mini = $config['events_path'] . 'mini/' . $this->v('id') . '.jpg'; if ($user->is('colab') && !$this->v('images') && !@file_exists($location_mini)) { $large_filepath = $config['events_path'] . 'future/' . $this->v('id') . '.jpg'; _style('event_flyer.thumbnail', array( 'ACTION' => $u_event_alias, 'SCALE' => ($config['events_thumb_height'] / $config['events_thumb_width']), 'THUMB_WIDTH' => $config['events_thumb_width'], 'THUMB_HEIGHT' => $config['events_thumb_height'], 'LARGE_WIDTH' => $upload->getWidth($large_filepath), 'LARGE_HEIGHT' => $upload->getHeight($large_filepath) )); } } list($d, $m, $y) = explode(' ', gmdate('j n Y', time() + $user->timezone + $user->dst)); $midnight = gmmktime(0, 0, 0, $m, $d, $y) - $user->timezone - $user->dst; $event_date = $user->format_date($this->v('date'), 'j F Y \a \l\a\s H:i') . ' horas.'; if ($this->v('date') >= $midnight) { if ($this->v('date') >= $midnight && $this->v('date') < $midnight + 86400) { $event_date_format = lang('event_today'); } else if ($this->v('date') >= $midnight + 86400 && $this->v('date') < $midnight + (86400 * 2)) { $event_date_format = lang('event_tomorrow'); } else { $event_date_format = sprintf(lang('event_after'), $event_date); } } else { if ($this->v('date') >= ($midnight - 86400)) { $event_date_format = lang('event_yesterday'); } else { $event_date_format = sprintf(lang('event_before'), $event_date); } } v_style(array( 'EVENT_NAME' => $this->v('title'), 'EVENT_DATE' => $event_date_format, 'EVENT_URL' => $u_event_alias, 'EVENT_PUBLISH' => $u_event_publish) ); $posts_offset = request_var('ps', 0); $topic_id = $this->v('event_topic'); // START RSVP if ($topic_id) { $sql = 'SELECT vd.vote_id, vd.vote_text, vd.vote_start, vd.vote_length, vr.vote_option_id, vr.vote_option_text, vr.vote_result FROM _poll_options vd, _poll_results vr WHERE vd.topic_id = ? AND vr.vote_id = vd.vote_id ORDER BY vr.vote_option_order, vr.vote_option_id ASC'; if ($vote_info = sql_rowset(sql_filter($sql, $topic_id))) { $sql = 'SELECT vote_id FROM _poll_voters WHERE vote_id = ? AND vote_user_id = ?'; $user_voted = sql_field(sql_filter($sql, $vote_info[0]['vote_id'], $user->d('user_id')), 'vote_id', 0); $poll_expired = ($vote_info[0]['vote_length']) ? (($vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time()) ? true : false) : false; _style('poll', array( 'POLL_TITLE' => $vote_info[0]['vote_text']) ); if ($user_voted || $poll_expired) { _style('poll.results'); foreach ($vote_info as $row) { if ($this->v('date') >= $midnight) { $caption = ($row['vote_result'] == 1) ? lang('rsvp_future_one') : lang('rsvp_future_more'); } else { $caption = ($row['vote_result'] == 1) ? lang('rsvp_past_one') : lang('rsvp_past_more'); } _style('poll.results.item', array( 'CAPTION' => $caption, 'RESULT' => $row['vote_result']) ); break; } } else { _style('poll.options', array( 'S_VOTE_ACTION' => s_link('events', $this->v('event_alias'), 1, 'rsvp')) ); foreach ($vote_info as $row) { $caption = ($this->v('date') >= $midnight) ? lang('rsvp_future') : lang('rsvp_past'); _style('poll.options.item', array( 'ID' => $row['vote_option_id'], 'CAPTION' => $caption) ); break; } } } } // END RSVP $sql = 'SELECT p.*, u.user_id, u.username, u.username_base, u.user_avatar, u.user_posts, u.user_gender, u.user_rank FROM _forum_posts p, _members u WHERE p.topic_id = ? AND u.user_id = p.poster_id AND p.post_deleted = 0 ORDER BY p.post_time DESC LIMIT ??, ??'; if (!$messages = sql_rowset(sql_filter($sql, $topic_id, $posts_offset, $config['posts_per_page']))) { redirect(s_link('events', $this->v('event_alias'))); } if (!$posts_offset) { //unset($messages[0]); } $i = 0; foreach ($messages as $row) { if (!$i) { $controls = w(); $user_profile = w(); $unset_user_profile = array('user_id', 'user_posts', 'user_gender'); _style('messages'); } if ($user->is('member')) { $controls[$row['post_id']]['reply'] = s_link('events', $this->v('event_alias'), $row['post_id'], 'reply'); if ($mod_auth) { $controls[$row['post_id']]['edit'] = s_link('acp', array('forums_post_modify', 'msg_id' => $row['post_id'])); $controls[$row['post_id']]['delete'] = s_link('acp', array('forums_post_delete', 'msg_id' => $row['post_id'])); } } $user_profile[$row['user_id']] = $comments->user_profile($row, '', $unset_user_profile); $data = array( 'POST_ID' => $row['post_id'], 'DATETIME' => $user->format_date($row['post_time']), 'MESSAGE' => $comments->parse_message($row['post_text']), 'PLAYING' => $row['post_np'], 'DELETED' => $row['post_deleted'] ); foreach ($user_profile[$row['user_id']] as $key => $value) { $data[strtoupper($key)] = $value; } _style('messages.row', $data); if (isset($controls[$row['post_id']])) { _style('messages.row.controls'); foreach ($controls[$row['post_id']] as $item => $url) { _style('messages.row.controls.' . $item, array( 'URL' => $url) ); } } $i++; } build_num_pagination(s_link('events', $this->v('event_alias'), 'ps%d'), $event_topic['topic_replies'], $config['posts_per_page'], $posts_offset, 'MSG_'); $publish_ref = ($posts_offset) ? s_link('events', $this->v('event_alias'), 's' . $t_offset) : s_link('events', $this->v('event_alias')); // Posting box if ($user->is('member')) { _style('publish', array( 'REF' => $publish_ref) ); if ($reply) { if (empty($post_reply_message)) { $post_reply_message = $comments->remove_quotes($post_data['post_text']); } if (!empty($post_reply_message)) { $rx = array('#(^|[\n ]|\()(http|https|ftp)://([a-z0-9\-\.,\?!%\*_:;~\\&$@/=\+]+)(gif|jpg|jpeg|png)#is', '#\[yt:[0-9a-zA-Z\-\=\_]+\]#is', '#\[sb\]#is', '#\[\/sb\]#is'); $post_reply_message = preg_replace($rx, '', $post_reply_message); } if (empty($post_reply_message)) { $post_reply_message = '...'; } _style('publish.reply', array( 'MESSAGE' => $post_reply_message) ); } } break; } $this->_title = $this->v('title'); $this->_template = 'events.view'; return true; }
function sync_topic_move($id) { $last_topic = 0; $total_posts = 0; $total_topics = 0; // $sql = 'SELECT COUNT(post_id) AS total FROM _forum_posts WHERE forum_id = ?'; $total_posts = sql_field(sql_filter($sql, $id), 'total', 0); $sql = 'SELECT MAX(topic_id) as last_topic, COUNT(topic_id) AS total FROM _forum_topics WHERE forum_id = ?'; if ($row = sql_fieldrow(sql_filter($sql, $id))) { $last_topic = $row['last_topic']; $total_topics = $row['total']; } // $sql = 'UPDATE _forums SET forum_last_topic_id = ?, forum_posts = ?, forum_topics = ? WHERE forum_id = ?'; sql_query(sql_filter($sql, $last_topic, $total_posts, $total_topics, $id)); return; }
public function _home() { global $config, $user, $cache, $comments; $this->id = request_var('msg_id', 0); $sql = 'SELECT * FROM _forum_posts WHERE post_id = ?'; if (!$this->object->post = sql_fieldrow(sql_filter($sql, $this->id))) { fatal_error(); } $this->object->post = (object) $this->object->post; $sql = 'SELECT * FROM _forum_topics WHERE topic_id = ?'; if (!$this->object->topic = sql_fieldrow(sql_filter($sql, $this->object->post->topic_id))) { fatal_error(); } $this->object->topic = (object) $this->object->topic; if (_button()) { $topic_title = request_var('topic_title', ''); $post_message = $comments->prepare(request_var('message', '', true)); if (!empty($topic_title) && $topic_title != $this->object->topic->topic_title) { $sql = 'UPDATE _forum_topics SET topic_title = ? WHERE topic_id = ?'; sql_query(sql_filter($sql, $topic_title, $this->object->topic->topic_id)); $sql = 'SELECT id FROM _events WHERE event_topic = ?'; if ($this->object->event_id = sql_field(sql_filter($sql, $this->object->topic->topic_id), 'id', 0)) { $sql = 'UPDATE _events SET title = ? WHERE id = ?'; sql_query(sql_filter($sql, $topic_title, $this->object->event_id)); } } if ($post_message != $this->object->post->post_text) { $sql = 'UPDATE _forum_posts SET post_text = ? WHERE post_id = ?'; sql_query(sql_filter($sql, $post_message, $this->id)); $rev = array( 'rev_post' => $this->id, 'rev_uid' => $user->d('user_id'), 'rev_time' => time(), 'rev_ip' => $user->ip, 'rev_text' => $this->object->post->post_text ); sql_insert('forum_posts_rev', $rev); } redirect(s_link('post', $this->id)); } v_style(array( 'V_TOPIC' => ($user->is('founder')) ? $this->object->topic->topic_title : '', 'V_MESSAGE' => $this->object->post->post_text) ); //return page_layout('Editar', 'modcp.edit', $tv); }
private function upload() { global $config, $upload; $a_1 = artist_check($this->object['ub'] . ' x1'); $a_2 = artist_check($this->object['ub'] . ' gallery'); $a_3 = artist_check($this->object['ub'] . ' thumbnails'); if (!$a_1 || !$a_2 || !$a_3) { return; } $filepath = $config['artists_path'] . $this->object['ub'] . '/'; $filepath_1 = $filepath . 'x1/'; $filepath_2 = $filepath . 'gallery/'; $filepath_3 = $filepath . 'thumbnails/'; $f = $upload->process($filepath_1, 'add_image', 'jpg'); if (!sizeof($upload->error) && $f !== false) { $sql = 'SELECT MAX(image) AS total FROM _artists_images WHERE ub = ?'; $img = sql_field(sql_filter($sql, $this->object['ub']), 'total', 0); $a = 0; foreach ($f as $row) { $img++; $xa = $upload->resize($row, $filepath_1, $filepath_1, $img, array(600, 400), false, false, true); if ($xa === false) { continue; } $xb = $upload->resize($row, $filepath_1, $filepath_2, $img, array(300, 225), false, false); $xc = $upload->resize($row, $filepath_2, $filepath_3, $img, array(100, 75), false, false); $insert = array( 'ub' => (int) $this->object['ub'], 'image' => (int) $img, 'width' => $xa->width, 'height' => $xa->height ); sql_insert('artists_images', $insert); $a++; } if ($a) { $sql = 'UPDATE _artists SET images = images + ?? WHERE ub = ?'; sql_query(sql_filter($sql, $a, $this->object['ub'])); } redirect(s_link('acp', array('artist_gallery', 'a' => $this->object['subdomain']))); } _style('error', array( 'MESSAGE' => parse_error($upload->error)) ); return; }
public function cache($a_sql, $sid = '', $private = true) { global $user; $filter_values = array($sid); $sql = 'SELECT cache_query FROM _search_cache WHERE cache_sid = ?'; if ($private) { $sql .= ' AND cache_uid = ?'; $filter_values[] = $user->d('user_id'); } $query = sql_field(sql_filter($sql, $filter_values), 'cache_query', ''); if (!empty($sid) && empty($query)) { _fatal(); } if (empty($query) && !empty($a_sql)) { $sid = md5(unique_id()); $insert = array( 'cache_sid' => $sid, 'cache_query' => $a_sql, 'cache_uid' => $user->d('user_id'), 'cache_time' => time() ); $sql = 'INSERT INTO _search_cache' . $this->build('INSERT', $insert); $this->query($sql); $query = $a_sql; } $all_rows = 0; if (!empty($query)) { $result = $this->query($query); $all_rows = $this->numrows($result); $this->freeresult($result); } $has_limit = false; if (preg_match('#LIMIT (\d+)(\, (\d+))?#is', $query, $limits)) { $has_limit = $limits[1]; } return array('sid' => $sid, 'query' => $query, 'limit' => $has_limit, 'total' => $all_rows); }
private function profile() { global $user, $config, $comments, $cache, $upload; $error = w(); $fields = w('public_email timezone dateformat location sig msnm yim lastfm website occ interests os fav_genres fav_artists rank color'); $length_ary = w('location sig msnm yim website occ interests os fav_genres fav_artists'); $_fields = new stdClass; foreach ($fields as $field) { $_fields->$field = $user->d('user_' . $field); } $_fields->avatar = $user->d('user_avatar'); $_fields->gender = $user->d('user_gender'); $_fields->hideuser = $user->d('user_hideuser'); $_fields->email_dc = $user->d('user_email_dc'); $_fields->birthday_day = (int) substr($user->d('user_birthday'), 6, 2); $_fields->birthday_month = (int) substr($user->d('user_birthday'), 4, 2); $_fields->birthday_year = (int) substr($user->d('user_birthday'), 0, 4); if (_button()) { foreach ($_fields as $field => $value) { $_fields->$field = request_var($field, $value); } $_fields->password1 = request_var('password1', ''); $_fields->password2 = request_var('password2', ''); $_fields->hideuser = _button('hideuser'); $_fields->email_dc = _button('email_dc'); if (!empty($_fields->password1)) { if (empty($_fields->password2)) { $error[] = 'EMPTY_PASSWORD2'; } if (!sizeof($error)) { if ($_fields->password1 != $_fields->password2) { $error[] = 'PASSWORD_MISMATCH'; } else if (strlen($_fields->password1) > 30) { $error[] = 'PASSWORD_LONG'; } } } unset($_fields->password1, $_fields->password2); foreach ($length_ary as $field) { if (strlen($_fields->$field) < 2) { $_fields->$field = ''; } } if (!empty($_fields->website)) { if (!preg_match('#^http[s]?:\/\/#i', $_fields->website)) { $_fields->website = 'http://' . $_fields->website; } if (!preg_match('#^http[s]?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $_fields->website)) { $_fields->website = ''; } } if (!empty($_fields->rank)) { $rank_word = explode(' ', $_fields->rank); if (sizeof($rank_word) > 10) { $error[] = 'RANK_TOO_LONG'; } if (!sizeof($error)) { $rank_limit = 15; foreach ($rank_word as $each) { if (preg_match_all('#\&.*?\;#is', $each, $each_preg)) { foreach ($each_preg[0] as $each_preg_each) { $rank_limit += (strlen($each_preg_each) - 1); } } if (strlen($each) > $rank_limit) { $error[] = 'RANK_TOO_LONG'; break; } } } } // Rank if (!empty($_fields->rank) && !sizeof($error)) { $sql = 'SELECT rank_id FROM _ranks WHERE rank_title = ?'; if (!$rank_id = sql_field(sql_filter($sql, $_fields->rank), 'rank_id', 0)) { $insert = array( 'rank_title' => $_fields->rank, 'rank_min' => -1, 'rank_max' => -1, 'rank_special' => 1 ); $rank_id = sql_insert('ranks', $insert); } if ($user->d('user_rank')) { $sql = 'SELECT user_id FROM _members WHERE user_rank = ?'; $size_rank = sql_rowset(sql_filter($sql, $user->d('user_rank')), false, 'user_id'); if (sizeof($size_rank) == 1) { $sql = 'DELETE FROM _ranks WHERE rank_id = ?'; sql_query(sql_filter($sql, $user->d('user_rank'))); } } $_fields->rank = $rank_id; $cache->delete('ranks'); } if (!$_fields->birthday_month || !$_fields->birthday_day || !$_fields->birthday_year) { $error[] = 'EMPTY_BIRTH_MONTH'; } // Update user avatar if (!sizeof($error)) { $upload->avatar_process($user->d('username_base'), $_fields, $error); } if (!sizeof($error)) { if (!empty($_fields->sig)) { $_fields->sig = $comments->prepare($_fields->sig); } $_fields->birthday = (string) (leading_zero($_fields->birthday_year) . leading_zero($_fields->birthday_month) . leading_zero($_fields->birthday_day)); unset($_fields->birthday_day, $_fields->birthday_month, $_fields->birthday_year); $_fields->dateformat = 'd M Y H:i'; $_fields->hideuser = $user->d('user_hideuser'); $_fields->email_dc = $user->d('user_email_dc'); $member_data = w(); foreach ($_fields as $field => $value) { if ($value != $user->d($field)) { $member_data['user_' . $field] = $_fields->$field; } } if (sizeof($member_data)) { $sql = 'UPDATE _members SET ' . sql_build('UPDATE', $member_data) . sql_filter(' WHERE user_id = ?', $user->d('user_id')); $sql = 'UPDATE _members SET ?? WHERE user_id = ?'; sql_query(sql_filter($sql, sql_build('UPDATE', $member_data), $user->d('user_id'))); } redirect(s_link('m', $user->d('username_base'))); } } if (sizeof($error)) { _style('error', array( 'MESSAGE' => parse_error($error)) ); } if ($user->d('user_avatar')) { _style('current_avatar', array( 'IMAGE' => $config['assets_url'] . 'avatars/' . $user->d('user_avatar')) ); } $s_genders_select = ''; foreach (array(1 => 'MALE', 2 => 'FEMALE') as $id => $value) { $s_genders_select .= '<option value="' . $id . '"' . (($_fields->gender == $id) ? ' selected="true"' : '') . '>' . lang($value) . '</option>'; } _style('gender', array( 'GENDER_SELECT' => $s_genders_select) ); $s_day_select = ''; for ($i = 1; $i < 32; $i++) { $s_day_select .= '<option value="' . $i . '"' . (($_fields->birthday_day == $i) ? ' selected="true"' : '') . '>' . $i . '</option>'; } $s_month_select = ''; $months = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); foreach ($months as $id => $value) { $s_month_select .= '<option value="' . ($id + 1) . '"' . (($_fields->birthday_month == ($id + 1)) ? ' selected="true"' : '') . '>' . $user->lang['datetime'][$value] . '</option>'; } $s_year_select = ''; for ($i = 2005; $i > 1899; $i--) { $s_year_select .= '<option value="' . $i . '"' . (($_fields->birthday_year == $i) ? ' selected="true"' : '') . '>' . $i . '</option>'; } _style('birthday', array( 'DAY' => $s_day_select, 'MONTH' => $s_month_select, 'YEAR' => $s_year_select) ); $dateset = w(); $dateformat_select = ''; foreach ($dateset as $id => $value) { $dateformat_select .= '<option value="' . $id . '"' . (($value == $_fields->dateformat) ? ' selected="selected"' : '') . '>' . $user->format_date(time(), $value) . '</option>'; } $timezone_select = ''; foreach ($user->lang['zones'] as $id => $value) { $timezone_select .= '<option value="' . $id . '"' . (($id == $_fields->timezone) ? ' selected="selected"' : '') . '>' . $value . '</option>'; } unset($_fields->timezone, $_fields->dateformat); if ($user->d('rank')) { $sql = 'SELECT rank_title FROM _ranks WHERE rank_id = ?'; $_fields->rank = sql_field(sql_filter($sql, $user->d('rank')), 'rank_title', '--'); } $output_vars = array( 'DATEFORMAT' => $dateformat_select, 'TIMEZONE' => $timezone_select, 'HIDEUSER_SELECTED' => ($_fields->hideuser) ? ' checked="checked"' : '', 'EMAIL_DC_SELECTED' => ($_fields->email_dc) ? ' checked="checked"' : '' ); foreach ($_fields as $field => $value) { $output_vars[strtoupper($field)] = $value; } v_style($output_vars); $this->_title = 'MEMBER_OPTIONS'; $this->_template = 'profile'; return; }
protected function _attend_home() { global $bio; if (!is_ghost()) { _fatal(); } if (!$bio->v('auth_member')) { _login(); } $v = $this->__(_array_keys(w('event option'), 0)); if (!$v['event'] || !$v['option']) { _fatal(); } $sql = 'SELECT event_id FROM _events WHERE event_id = ?'; if (!sql_fieldrow($sql, $v['event'])) { _fatal(); } $sql = 'SELECT type_id FROM _events_attend_type WHERE type_id = ?'; if (!sql_fieldrow(sql_filter($sql, $v['option']))) { _fatal(); } $sql = 'SELECT attend_id FROM _events_attend WHERE attend_event = ? AND attend_uid = ?'; if ($attend_id = sql_field(sql_filter($sql, $v['event'], $bio->v('bio_id')), 'attend_id', 0)) { $sql = 'UPDATE _events SET attend_option = ? WHERE attend_id = ?'; sql_query(sql_filter($sql, $v['option'], $attend_id)); } else { $sql_insert = array('attend_event' => $v['event'], 'attend_uid' => $bio->v('bio_id'), 'attend_option' => $v['option'], 'attend_time' => time()); sql_put('_events_attend', $sql_insert); } return $this->e('~OK'); }
protected function _random_home() { global $bio, $warning; $v = $this->__(w('type')); switch ($v->type) { case 'artist': case 'user': $sql = 'SELECT b.bio_alias FROM _bio b, _bio_type t WHERE t.type_alias = ? AND b.bio_type = t.type_id ORDER BY RAND() LIMIT 1'; $alias = sql_field(sql_filter($sql, $v->type), 'bio_alias', ''); $link = _link('alias', $alias); break; case 'event': $sql = 'SELECT * FROM _events WHERE ORDER BY RAND() LIMIT 1'; break; default: $warning->now(); break; } return; }
function nobody() { global $core; if (!$a = $core->cache_load('nobody')) { $sql = 'SELECT user_id FROM _members WHERE user_username = ?'; if ($a = sql_field(sql_filter($sql, 'nobody'), 'user_id', '')) { $core->cache_store('nobody', $a); } } return $a; }
protected function _total_home() { global $warning; $v = $this->__(w('id 0')); $sql = 'SELECT * FROM _press WHERE press_id = ?'; if (!($press = sql_fieldrow(sql_filter($sql, $v->id)))) { $warning->now(); } $sql = 'SELECT COUNT(user_id) AS total FROM _bio WHERE bio_lastvisit >= ? AND bio_country = 90 AND bio_status = 1 AND bio_id <> 1'; $total = sql_field(sql_filter($sql, $press->press_lastvisit), 'total', 0); $sql = 'SELECT COUNT(bio_id) AS total FROM _bio'; $all = sql_field($sql, 'total', 0); $this->e($total . ' . ' . $all); }
public function _home() { global $config, $user, $cache; if (!_button()) { return false; } $from_topic = request_var('from_topic', 0); $to_topic = request_var('to_topic', 0); if (!$from_topic || !$to_topic || $from_topic == $to_topic) { fatal_error(); } $sql = 'SELECT * FROM _forum_topics WHERE topic_id = ?'; if (!$row = sql_fieldrow(sql_filter($sql, $from_topic))) { fatal_error(); } $sql = 'SELECT * FROM _forum_topics WHERE topic_id = ?'; if (!$row = sql_fieldrow(sql_filter($sql, $to_topic))) { fatal_error(); } $from_forum_id = (int) $row['forum_id']; $from_poll = (int) $row['topic_vote']; $to_forum_id = (int) $row['forum_id']; $to_poll = (int) $row['topic_vote']; if ($from_poll) { if ($to_poll) { $sql = 'SELECT vote_id FROM _poll_options WHERE topic_id = ?'; if ($vote_id = sql_field(sql_filter($sql, $from_topic), 'vote_id', 0)) { $sql = array( sql_filter('DELETE FROM _poll_voters WHERE vote_id = ?', $vote_id), sql_filter('DELETE FROM _poll_results WHERE vote_id = ?', $vote_id), sql_filter('DELETE FROM _poll_options WHERE vote_id = ?', $vote_id) ); sql_query($sql); } } else { $sql = 'UPDATE _poll_options SET topic_id = ? WHERE topic_id = ?'; sql_query(sql_filter($sql, $to_topic, $from_topic)); } } // Update destination toic $sql = 'SELECT topic_views FROM _forum_topics WHERE topic_id = ?'; if ($topic_views = sql_field(sql_filter($sql, $from_topic), 'topic_views', 0)) { $sql = 'UPDATE _forum_topics SET topic_views = topic_views + ?? WHERE topic_id = ?'; sql_query(sql_filter($sql, $topic_views, $to_topic)); } // // $sql = 'SELECT * FROM _forum_topics_fav WHERE topic_id = ?'; $user_ids = sql_rowset(sql_filter($sql, $to_topic), false, 'user_id'); $sql_user = (sizeof($user_ids)) ? ' AND user_id NOT IN (' . _implode(', ', $user_ids) . ')' : ''; $sql = array( sql_filter('UPDATE _forum_topics_fav SET topic_id = ? WHERE topic_id = ?', $to_topic, $from_topic) . $sql_user, sql_filter('DELETE FROM _forum_topics_fav WHERE topic_id = ?', $from_topic), sql_filter('UPDATE _forum_posts SET forum_id = ?, topic_id = ? WHERE topic_id = ?', $to_forum_id, $to_topic, $from_topic), sql_filter('DELETE FROM _forum_topics WHERE topic_id = ?', $from_topic), sql_filter('DELETE FROM _members_unread WHERE element = ? AND item = ?', UH_T, $from_topic), ); if ($from_poll && !$to_poll) { $sql[] = sql_filter('UPDATE _forum_topics SET topic_vote = 1 WHERE topic_id = ?', $to_topic); } sql_query($sql); $user->save_unread(UH_T, $to_topic); if (in_array($to_forum_id, array(20, 39))) { topic_feature($to_topic, 0); topic_arkane($to_topic, 0); } sync_topic_merge('topic', $to_topic); sync_topic_merge('forum', $to_forum_id); if ($from_forum_id != $to_forum_id) { sync_topic_merge('forum', $from_forum_id); } return; }
public function dl_fav() { if (!$this->auth['user']) { do_login(); } global $user; $is_fav = false; $sql = 'SELECT dl_id FROM _dl_fav WHERE dl_id = ? AND user_id = ?'; if (sql_field(sql_filter($sql, $this->dl_data['id'], $user->d('user_id')), 'dl_id', 0)) { $is_fav = true; } $url = s_link('a', $this->data['subdomain'], 'downloads', $this->dl_data['id']); if ($is_fav) { redirect($url); } $sql_insert = array( 'dl_id' => $this->dl_data['id'], 'user_id' => $user->d('user_id'), 'favtime' => time() ); sql_insert('dl_fav', $sql_insert); $sql = 'UPDATE _members SET user_dl_favs = user_dl_favs + 1 WHERE user_id = ?'; sql_query(sql_filter($sql, $user->d('user_id'))); return redirect($url); }
function page_layout($page_title, $htmlpage, $custom_vars = false, $js_keepalive = true) { global $config, $user, $cache, $starttime, $template; // // gzip_compression // if (strstr($user->browser,'compatible') || strstr($user->browser,'Gecko')) { ob_start('ob_gzhandler'); } monetize(); // Get today items count $sql = 'SELECT COUNT(element) AS total FROM _members_unread WHERE user_id = ?'; $today_count = sql_field(sql_filter($sql, $user->d('user_id')), 'total', 0); // // Send headers // header('Cache-Control: private, no-cache="set-cookie", pre-check=0, post-check=0'); header('Expires: 0'); header('Pragma: no-cache'); // // Footer // $u_session = ($user->is('member')) ? 'out' : 'in'; if (preg_match('#.*?my/confirm.*?#is', $user->d('session_page'))) { $user->d('session_page', ''); } $common_vars = array( 'PAGE_TITLE' => lang($page_title, $page_title), '_SELF' => _page(), 'U_REGISTER' => s_link('signup'), 'U_SESSION' => s_link('sign' . $u_session), 'U_PROFILE' => s_link('m', $user->d('username_base')), 'U_EDITPROFILE' => s_link('my profile'), 'U_PASSWORD' => s_link('signr'), 'U_DC' => s_link('my dc'), 'U_HOME' => s_link(), 'U_FAQ' => s_link('faq'), 'U_WHATS_NEW' => s_link('today'), 'U_ARTISTS' => s_link('a'), 'U_AWARDS' => s_link('awards'), 'U_RADIO' => s_link('radio'), 'U_BROADCAST' => s_link('broadcast'), 'U_NEWS' => s_link('news'), 'U_EVENTS' => s_link('events'), 'U_FORUM' => s_link('board'), 'U_COMMUNITY' => s_link('community'), 'U_ALLIES' => s_link('allies'), 'U_TOS' => s_link('tos'), 'U_HELP' => s_link('help'), 'U_RSS_NEWS' => s_link('rss', 'news'), 'U_RSS_ARTISTS' => s_link('rss', 'artists'), 'U_COMMENTS' => s_link('comments'), 'U_EMOTICONS' => s_link('emoticons'), 'U_ACP' => (isset($template->vars['U_ACP'])) ? $template->vars['U_ACP'] : ($user->is('artist') || $user->is('mod') ? s_link('acp') : ''), 'S_YEAR' => date('Y'), 'S_UPLOAD' => upload_maxsize(), 'S_GIT' => $config['git_push_time'], 'S_KEYWORDS' => $config['meta_keys'], 'S_DESCRIPTION' => $config['meta_desc'], 'S_SERVER' => '//' . $config['server_name'], 'S_ASSETS' => $config['assets_url'], 'S_DIST' => '/dist/', 'S_SQL' => ($user->d('is_founder')) ? sql_queries() . 'q | ' : '', 'S_REDIRECT' => $user->d('session_page'), 'S_USERNAME' => $user->d('username'), 'S_MEMBER' => $user->is('member'), 'S_TODAY_COUNT' => (($today_count == 1) ? sprintf(lang('unread_item_count'), $today_count) : sprintf(lang('unread_items_count'), $today_count)) ); if ($custom_vars !== false) { $common_vars += $custom_vars; } $mtime = explode(' ', microtime()); $common_vars['S_TIME'] = sprintf('%.2f', ($mtime[0] + $mtime[1] - $starttime)); v_style($common_vars); $template->set_filenames(array( 'body' => $htmlpage . '.htm') ); $template->pparse('body'); sql_close(); exit; }
public function poll() { global $user, $auth, $config, $cache; if (!$topic_id = $cache->get('last_poll_id')) { $sql = 'SELECT t.topic_id FROM _forum_topics t LEFT JOIN _poll_options v ON t.topic_id = v.topic_id WHERE t.forum_id = ? AND t.topic_locked = 0 AND t.topic_vote = 1 ORDER BY t.topic_time DESC LIMIT 1'; if ($row = sql_fieldrow(sql_filter($sql, $config['main_poll_f']))) { $topic_id = $row['topic_id']; $cache->save('last_poll_id', $topic_id); } } $topic_id = (int) $topic_id; if (!$topic_id) { return; } $sql = 'SELECT t.topic_id, t.topic_locked, t.topic_time, t.topic_replies, t.topic_important, t.topic_vote, f.forum_locked, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_announce, f.auth_pollcreate, f.auth_vote FROM _forum_topics t, _forums f WHERE t.topic_id = ? AND f.forum_id = t.forum_id'; if (!$topic_data = sql_fieldrow(sql_filter($sql, $topic_id))) { return false; } $forum_id = (int) $topic_data['forum_id']; $sql = 'SELECT vd.*, vr.* FROM _poll_options vd, _poll_results vr WHERE vd.topic_id = ? AND vr.vote_id = vd.vote_id ORDER BY vr.vote_option_id ASC'; if (!$vote_info = sql_rowset(sql_filter($sql, $topic_id))) { return false; } if ($user->is('member')) { $is_auth = w(); $is_auth = $auth->forum(AUTH_VOTE, $forum_id, $topic_data); $sql = 'SELECT vote_user_id FROM _poll_voters WHERE vote_id = ? AND vote_user_id = ?'; $user_voted = (sql_field(sql_filter($sql, $vote_info[0]['vote_id'], $user->d('user_id')), 'vote_user_id', false)) ? true : false; } $poll_expired = ($vote_info[0]['vote_length']) ? (($vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < $current_time) ? true : 0) : 0; _style('poll', array( 'U_POLL_TOPIC' => s_link('topic', $topic_id), 'S_REPLIES' => $topic_data['topic_replies'], 'U_POLL_FORUM' => s_link('forum', $config['main_poll_f']), 'POLL_TITLE' => $vote_info[0]['vote_text']) ); if (!$user->is('member') || $user_voted || $poll_expired || !$is_auth['auth_vote'] || $topic_data['topic_locked']) { $vote_results_sum = 0; foreach ($vote_info as $row) { $vote_results_sum += $row['vote_result']; } _style('poll.results'); foreach ($vote_info as $row) { $vote_percent = ($vote_results_sum) ? $row['vote_result'] / $vote_results_sum : 0; _style('poll.results.item', array( 'CAPTION' => $row['vote_option_text'], 'RESULT' => $row['vote_result'], 'PERCENT' => sprintf("%.1d", ($vote_percent * 100))) ); } } else { _style('poll.options', array( 'S_VOTE_ACTION' => s_link('topic', $topic_id)) ); foreach ($vote_info as $row) { _style('poll.options.item', array( 'POLL_OPTION_ID' => $row['vote_option_id'], 'POLL_OPTION_CAPTION' => $row['vote_option_text']) ); } } return true; }
public function run() { global $config, $auth, $user, $comments, $cache; $forum_id = request_var('f', ''); $start = request_var('offset', 0); $submit_topic = _button('post'); if (empty($forum_id)) { fatal_error(); } $is_int_forumid = false; if (preg_match('#^(\d+)$#is', $forum_id)) { $is_int_forumid = true; $forum_id = intval($forum_id); $sql = 'SELECT * FROM _forums WHERE forum_id = ?'; $sql = sql_filter($sql, $forum_id); } else { $sql = 'SELECT * FROM _forums WHERE forum_alias = ?'; $sql = sql_filter($sql, $forum_id); } if (!$forum_row = sql_fieldrow($sql)) { fatal_error(); } if ($is_int_forumid) { redirect(s_link('forum', $forum_row['forum_alias']), true); } $forum_id = $forum_row['forum_id']; // // Start auth check // $is_auth = w(); $is_auth = $auth->forum(AUTH_ALL, $forum_id, $forum_row); if (!$is_auth['auth_view'] || !$is_auth['auth_read']) { if (!$user->is('member')) { do_login(); } fatal_error(); } $error_msg = ''; $post_title = ''; $post_message = ''; $post_np = ''; $poll_title = ''; $poll_options = ''; $poll_length = ''; $current_time = time(); if ($submit_topic) { $topic_important = _button('topictype'); $auth_key = ($topic_important) ? 'auth_announce' : 'auth_post'; if ($forum_row['forum_locked'] && !$is_auth['auth_mod']) { $error_msg .= (($error_msg != '') ? '<br />' : '') . lang('forum_locked'); } if (!$is_auth[$auth_key]) { if (!$user->is('member')) { do_login(); } if (empty($error_msg)) { redirect($topic_url); } } if (empty($error_msg)) { $post_title = request_var('topic_title', ''); $post_message = request_var('message', '', true); $post_np = request_var('np', '', true); $poll_title = ''; $poll_options = ''; $poll_length = 0; if ($is_auth['auth_pollcreate']) { $poll_title = request_var('poll_title', ''); $poll_options = request_var('poll_options', ''); $poll_length = request_var('poll_length', 0); } // Check subject if (empty($post_title)) { $error_msg .= (($error_msg != '') ? '<br />' : '') . lang('empty_subject'); } // Check message if (empty($post_message)) { $error_msg .= (($error_msg != '') ? '<br />' : '') . lang('empty_message'); } if (!empty($poll_options)) { $real_poll_options = w(); $poll_options = explode(nr(), $poll_options); foreach ($poll_options as $option) { if ($option != '') { $real_poll_options[] = $option; } } $sizeof_poll_options = sizeof($real_poll_options); if ($sizeof_poll_options < 2) { $error_msg .= (($error_msg != '') ? '<br />' : '') . lang('few_poll_options'); } else if ($sizeof_poll_options > $config['max_poll_options']) { $error_msg .= (($error_msg != '') ? '<br />' : '') . lang('many_poll_options'); } else if ($poll_title == '') { $error_msg .= (($error_msg != '') ? '<br />' : '') . lang('empty_poll_title'); } } if (empty($error_msg) && !$is_auth['auth_mod']) { $sql = 'SELECT MAX(post_time) AS last_post_time FROM _forum_posts WHERE poster_id = ?'; if ($last_post_time = sql_field(sql_filter($sql, $user->d('user_id')))) { if (intval($last_post_time) > 0 && ($current_time - intval($last_post_time)) < intval($config['flood_interval'])) { $error_msg .= (($error_msg != '') ? '<br />' : '') . lang('flood_error'); } } } if (empty($error_msg)) { $topic_announce = 0; $topic_locked = 0; if ((strstr($post_message, '-Anuncio-') && $user->is('all')) || in_array($forum_id, array(15, 16, 17))) { $topic_announce = 1; $post_message = str_replace('-Anuncio-', '', $post_message); } if (strstr($post_message, '-Cerrado-') && $user->is('mod')) { $topic_locked = 1; $post_message = str_replace('-Cerrado-', '', $post_message); } $post_message = $comments->prepare($post_message); $topic_vote = (!empty($poll_title) && $sizeof_poll_options >= 2) ? 1 : 0; if (!$user->is('founder')) { $post_title = strnoupper($post_title); } $insert_data['TOPIC'] = array( 'topic_title' => $post_title, 'topic_poster' => (int) $user->d('user_id'), 'topic_time' => (int) $current_time, 'forum_id' => (int) $forum_id, 'topic_locked' => $topic_locked, 'topic_announce' => $topic_announce, 'topic_important' => (int) $topic_important, 'topic_vote' => (int) $topic_vote, 'topic_featured' => 1, 'topic_points' => 1 ); $topic_id = sql_insert('forum_topics', $insert_data['TOPIC']); $insert_data['POST'] = array( 'topic_id' => (int) $topic_id, 'forum_id' => (int) $forum_id, 'poster_id' => (int) $user->d('user_id'), 'post_time' => (int) $current_time, 'poster_ip' => $user->ip, 'post_text' => $post_message, 'post_np' => $post_np ); $post_id = sql_insert('forum_posts', $insert_data['POST']); if ($topic_vote) { $insert_data['POLL'] = array( 'topic_id' => (int) $topic_id, 'vote_text' => $poll_title, 'vote_start' => (int) $current_time, 'vote_length' => (int) ($poll_length * 86400) ); $poll_id = sql_insert('poll_options', $insert_data['POLL']); $poll_option_id = 1; foreach ($real_poll_options as $option) { $insert_data['POLLRESULTS'] = array( 'vote_id' => (int) $poll_id, 'vote_option_id' => (int) $poll_option_id, 'vote_option_text' => $option, 'vote_result' => 0 ); sql_insert('poll_results', $insert_data['POLLRESULTS']); $poll_option_id++; } if ($forum_id == $config['main_poll_f']) { $cache->delete('last_poll_id'); } } $user->save_unread(UH_T, $topic_id); if (!in_array($forum_id, forum_for_team_array())) { //$user->points_add(2); } $a_list = forum_for_team_list($forum_id); if (count($a_list)) { $sql_delete_unread = 'DELETE FROM _members_unread WHERE element = ? AND item = ? AND user_id NOT IN (??)'; sql_query(sql_filter($sql_delete_unread, 8, $topic_id, implode(', ', $a_list))); } if (count($a_list) || in_array($forum_id, array(20, 39))) { topic_feature($topic_id, 0); topic_arkane($topic_id, 0); } $sql = 'UPDATE _forums SET forum_posts = forum_posts + 1, forum_last_topic_id = ?, forum_topics = forum_topics + 1 WHERE forum_id = ?'; sql_query(sql_filter($sql, $topic_id, $forum_id)); $sql = 'UPDATE _forum_topics SET topic_first_post_id = ?, topic_last_post_id = ? WHERE topic_id = ?'; sql_query(sql_filter($sql, $post_id, $post_id, $topic_id)); $sql = 'UPDATE _members SET user_posts = user_posts + 1 WHERE user_id = ?'; sql_query(sql_filter($sql, $user->d('user_id'))); redirect(s_link('topic', $topic_id)); } } } // // End Submit // $topics_count = ($forum_row['forum_topics']) ? $forum_row['forum_topics'] : 1; $topics = new stdClass(); $total = new stdClass(); // // All announcement data // $sql = 'SELECT t.*, u.user_id, u.username, u.username_base, u2.user_id as user_id2, u2.username as username2, u2.username_base as username_base2, p.post_time, p.post_username as post_username2 FROM _forum_topics t, _members u, _forum_posts p, _members u2 WHERE t.forum_id = ? AND t.topic_poster = u.user_id AND p.post_id = t.topic_last_post_id AND p.poster_id = u2.user_id AND t.topic_announce = 1 ORDER BY t.topic_last_post_id DESC'; $topics->important = sql_rowset(sql_filter($sql, $forum_id)); $total->important = (is_array($topics->important)) ? count($topics->important) : 0; // // Grab all the topics data for this forum // $sql = 'SELECT t.*, u.user_id, u.username, u.username_base, u2.user_id as user_id2, u2.username as username2, u2.username_base as username_base2, p.post_username, p2.post_username AS post_username2, p2.post_time FROM _forum_topics t, _members u, _forum_posts p, _forum_posts p2, _members u2 WHERE t.forum_id = ? AND t.topic_poster = u.user_id AND p.post_id = t.topic_first_post_id AND p2.post_id = t.topic_last_post_id AND u2.user_id = p2.poster_id AND t.topic_announce = 0 ORDER BY t.topic_important DESC, /*t.topic_last_post_id*/p2.post_time DESC LIMIT ??, ??'; $topics->normal = sql_rowset(sql_filter($sql, $forum_id, $start, $config['topics_per_page'])); $total->normal = (is_array($topics->normal)) ? count($topics->normal) : 0; // // Total topics ... // //$total_topics += $total_announcements; //$total_topics = $total->important + $total->normal; // // Post URL generation for templating vars // if ($is_auth['auth_post'] || $is_auth['auth_mod']) { _style('topic_create', array( 'L_POST_NEW_TOPIC' => ($forum_row['forum_locked']) ? lang('forum_locked') : lang('post_newtopic')) ); } // // Dump out the page header and load viewforum template // v_style(array( 'FORUM_ID' => $forum_id, 'FORUM_NAME' => $forum_row['forum_name'], 'U_VIEW_FORUM' => s_link('forum', $forum_row['forum_alias'])) ); // // End header // // // Let's build the topics // $i = 0; foreach ($topics as $alias => $list) { foreach ($list as $j => $row) { if (!$i) { _style('topics'); $topics_count -= $total->important; build_num_pagination(s_link('forum', $forum_row['forum_alias'], 's%d'), $topics_count, $config['topics_per_page'], $start, '', 'TOPICS_'); } if (!$j) { _style('topics.alias', array( 'NAME' => lang('topic_' . $alias), 'SHOW' => ($total->important && $total->normal > 1)) ); } $row = (object) $row; if ($row->user_id != GUEST) { $row->author = '<a href="' . s_link('m', $row->username_base2) . '">' . $row->username2 . '</a>'; } else { $row->author = '<span>*' . (($row->post_username2 != '') ? $row->post_username2 : lang('guest')) . '</span>'; } if ($row->user_id2 != GUEST) { $row->poster = '<a href="' . s_link('m', $row->username_base2) . '">' . $row->username2 . '</a>'; } else { $row->poster = '<span>*' . (($row->post_username2 != '') ? $row->post_username2 : lang('guest')) . '</span>'; } _style('topics.alias.row', array( 'FORUM_ID' => $forum_id, 'TOPIC_ID' => $row->topic_id, 'TOPIC_AUTHOR' => $row->author, 'REPLIES' => $row->topic_replies, 'VIEWS' => ($user->is('founder')) ? $row->topic_views : '', 'TOPIC_TITLE' => $row->topic_title, 'TOPIC_CREATION_TIME' => $user->format_date($row->topic_time), 'LAST_POST_TIME' => $user->format_date($row->post_time), 'LAST_POST_AUTHOR' => $row->poster, 'U_TOPIC' => s_link('topic', $row->topic_id)) ); $i++; } } if (!$topics_count) { if ($start) { redirect(s_link('forum', $forum_row['forum_alias']), true); } _style('no_topics'); } // // Posting box // if (!empty($error_msg) || (!$is_auth['auth_mod'] && $forum_row['forum_locked']) || (!$is_auth['auth_post'] && $forum_row['auth_post'] == AUTH_REG) || $is_auth['auth_post']) { if ($is_auth['auth_post']) { if (!empty($poll_options)) { $poll_options = implode(nr(), $poll_options); } _style('publish', array( 'S_POST_ACTION' => s_link('forum', $forum_row['forum_alias']), 'TOPIC_TITLE' => $post_title, 'MESSAGE' => $post_message, 'NP' => $post_np, 'POLL_TITLE' => $poll_title, 'POLL_OPTIONS' => $poll_options, 'POLL_LENGTH' => $poll_length) ); if ($is_auth['auth_pollcreate']) { _style('publish.poll'); if (empty($poll_options)) { _style('publish.poll.hide'); } } } if (!empty($error_msg)) { _style('publish.alert', array( 'MESSAGE' => $error_msg) ); } } $layout_file = 'topics'; $use_m_template = 'custom/forum_' . $forum_id; if (@file_exists(ROOT . 'template/' . $use_m_template . '.htm')) { $layout_file = $use_m_template; } $this->_title = $forum_row['forum_name']; $this->_template = $layout_file; return; }
protected function _biography_home() { global $bio; $v = $this->__(w('s')); $sql = 'SELECT bio_details FROM _bio WHERE bio_id = ?'; $details = sql_field(sql_filter($sql, $bio->v('bio_id'), 'bio_details', '')); $s_hidden = array('module' => $this->control->module, 'a' => $bio->v('bio_alias'), 'x1' => $this->x(1), 'manage' => 'edit'); v_style(array('MESSAGE' => $details, 'S_HIDDEN' => _hidden($s_hidden))); if ($v->s == 'u') { _style('updated'); } }