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; }
private function update() { global $config, $upload; $v = _request(array('event_id' => 0)); $sql = 'SELECT * FROM _events WHERE id = ?'; if (!$event_data = sql_fieldrow(sql_filter($sql, $v->event_id))) { return; } $filepath_1 = $config['events_path'] . 'future/'; $filepath_2 = $config['events_path'] . 'future/thumbnails/'; $f = $upload->process($filepath_1, 'event_image', 'jpg'); if ($upload->error) { _style('error', array( 'MESSAGE' => parse_error($upload->error)) ); return; } foreach ($f as $row) { $xa = $upload->resize($row, $filepath_1, $filepath_1, $v->event_id, array(600, 400), false, false, true); if ($xa === false) { continue; } $xb = $upload->resize($row, $filepath_1, $filepath_2, $v->event_id, array(100, 75), false, false); } $sql = 'UPDATE _events SET event_update = ? WHERE id = ?'; sql_query(sql_filter($sql, time(), $v->event_id)); return redirect(s_link('events', $event_data['event_alias'])); }
public function _help_edit() { global $user, $cache; $error = array(); $sub = $this->control->get_var('sub', ''); $id = $this->control->get_var('id', 0); $submit = _button(); switch ($sub) { case 'cat': $sql = 'SELECT c.*, m.* FROM _help_cat c, _help_modules m WHERE c.help_id = ? AND c.help_module = m.module_id'; if (!$cat_data = sql_fieldrow(sql_filter($sql, $id))) { fatal_error(); } $order = $this->control->get_var('order', ''); if (!empty($order)) { if (preg_match('/_(\d+)/', $order)) { $sig = '-'; $order = str_replace('_', '', $order); } else { $sig = '+'; } $sql = 'UPDATE _help_cat SET help_order = help_order ?? ?? WHERE help_id = ?'; sql_query(sql_filter($sql, $sig, $order, $id)); $this->_help_edit_move(); $cache->delete('help_cat'); redirect(s_link_control('comments', array('mode' => $this->mode))); } // IF order $module_id = $cat_data['help_module']; $help_es = $cat_data['help_es']; $help_en = $cat_data['help_en']; break; case 'faq': $sql = 'SELECT * FROM _help_faq WHERE faq_id = ?'; if (!$faq_data = sql_fieldrow(sql_filter($sql, $id))) { fatal_error(); } $question_es = $faq_data['faq_question_es']; $question_en = $faq_data['faq_question_en']; $answer_es = $faq_data['faq_answer_es']; $answer_en = $faq_data['faq_answer_en']; $help_id = $faq_data['help_id']; break; default: redirect(s_link_control('comments', array('mode' => $this->mode))); break; } // IF submit if ($submit) { switch ($sub) { case 'cat': $module_id = $this->control->get_var('module_id', 0); $help_es = $this->control->get_var('help_es', ''); $help_en = $this->control->get_var('help_en', ''); if (empty($help_es) || empty($help_en)) { $error[] = 'CONTROL_COMMENTS_HELP_EMPTY'; } // Update if (!sizeof($error)) { $sql_update = array( 'help_es' => $help_es, 'help_en' => $help_en, 'help_module' => (int) $module_id ); $sql = 'UPDATE _help_cat SET ?? WHERE help_id = ?'; sql_query(sql_filter($sql, sql_build('UPDATE', $sql_update), $id)); $cache->delete('help_cat'); redirect(s_link_control('comments', array('mode' => $this->mode))); } break; case 'faq': $question_es = $this->control->get_var('question_es', ''); $question_en = $this->control->get_var('question_en', ''); $answer_es = $this->control->get_var('answer_es', ''); $answer_en = $this->control->get_var('answer_en', ''); $help_id = $this->control->get_var('help_id', 0); if (empty($question_es) || empty($question_en) || empty($answer_es) || empty($answer_en)) { $error[] = 'CONTROL_COMMENTS_HELP_EMPTY'; } if (!sizeof($error)) { $sql = 'SELECT * FROM _help_cat WHERE help_id = ?'; if (!$cat_data = sql_fieldrow(sql_filter($sql, $help_id))) { $error[] = 'CONTROL_COMMENTS_HELP_NOCAT'; } } // Update if (!sizeof($error)) { $sql_update = array( 'help_id' => (int) $help_id, 'faq_question_es' => $question_es, 'faq_question_en' => $question_en, 'faq_answer_es' => $answer_es, 'faq_answer_en' => $answer_en ); $sql = 'UPDATE _help_faq SET ?? WHERE faq_id = ?'; sql_query(sql_filter($sql, sql_build('UPDATE', $sql_update), $id)); $cache->delete('help_faq'); redirect(s_link_control('comments', array('mode' => $this->mode))); } break; } // switch if (sizeof($error)) { _style('error', array( 'MESSAGE' => parse_error($error)) ); } } $this->nav(); $this->control->set_nav(array('mode' => $this->mode, 'manage' => $this->manage, 'sub' => $sub, 'id' => $id), 'CONTROL_EDIT'); $layout_vars = array( 'SUB' => $sub, 'S_HIDDEN' => s_hidden(array('module' => $this->control->module, 'mode' => $this->mode, 'manage' => $this->manage, 'sub' => $sub, 'id' => $id)) ); switch ($sub) { case 'cat': $sql = 'SELECT * FROM _help_modules ORDER BY module_id'; $result = sql_rowset($sql); $select_mod = ''; foreach ($result as $row) { $selected = ($row['module_id'] == $module_id); $select_mod .= '<option' . (($selected) ? ' class="bold"' : '') . ' value="' . $row['module_id'] . '"' . (($selected) ? ' selected' : '') . '>' . $row['module_name'] . '</option>'; } $layout_vars += array( 'MODULE' => $select_mod, 'HELP_ES' => $help_es, 'HELP_EN' => $help_en ); break; case 'faq': $sql = 'SELECT * FROM _help_cat ORDER BY help_id'; $result = sql_rowset($sql); $select_cat = ''; foreach ($result as $row) { $selected = ($row['help_id'] == $help_id); $select_cat .= '<option' . (($selected) ? ' class="bold"' : '') . ' value="' . $row['help_id'] . '"' . (($selected) ? ' selected' : '') . '>' . $row['help_es'] . ' | ' . $row['help_en'] . '</option>'; } $layout_vars += array( 'CATEGORY' => $select_cat, 'QUESTION_ES' => $question_es, 'QUESTION_EN' => $question_en, 'ANSWER_ES' => $answer_es, 'ANSWER_EN' => $answer_en ); break; } _style($layout_vars); return; }
public function _home() { global $config, $user, $cache, $upload; if (_button()) { $event_id = request_var('event_id', 0); $filepath_1 = $config['events_path'] . 'tmp/'; $filepath_2 = $config['events_path'] . 'gallery/'; $filepath_3 = $filepath_1 . $event_id . '/'; $filepath_4 = $filepath_3 . 'thumbnails/'; $f = $upload->process($filepath_1, 'add_zip', 'zip'); if (!sizeof($upload->error) && $f !== false) { @set_time_limit(0); foreach ($f as $row) { $zip_folder = unzip($filepath_1 . $row['filename'], $filepath_3, true); _rm($filepath_1 . $row['filename']); } if (!empty($zip_folder)) { $zip_folder = substr($zip_folder, 0, -1); $fp = @opendir($filepath_3 . $zip_folder); while ($file = @readdir($fp)) { if (!is_level($file)) { $ftp->ftp_rename($ftp->dfolder() . 'data/tmp/' . $event_id . '/' . $zip_folder . '/' . $file, $ftp->dfolder() . 'data/tmp/' . $event_id . '/' . $file); //@rename($filepath_3 . $zip_folder . '/' . $file, $filepath_3 . $file); } } @closedir($fp); _rm($filepath_3 . $zip_folder); } if (!@file_exists($filepath_4)) { a_mkdir($ftp->dfolder() . 'data/tmp/' . $event_id, 'thumbnails'); } $footer_data = ''; $filerow_list = w(); $count_images = $img = $event_pre = 0; $check_is = w(); if (@file_exists($filepath_2 . $event_id)) { $fp = @opendir($filepath_2 . $event_id); while ($filerow = @readdir($fp)) { if (preg_match('#(\d+)\.(jpg)#is', $filerow)) { $dis = getimagesize($filepath_2 . $event_id . $filerow); $disd = intval(_decode('4e6a4177')); if (($dis[0] > $dis[1] && $dis[0] < $disd) || ($dis[1] > $dis[0] && $dis[1] < $disd)) { $check_is[] = $filerow; continue; } $event_pre++; } } @closedir($fp); if (count($check_is)) { echo lang('dis_invalid'); foreach ($check_is as $row) { echo $row . '<br />'; } exit; } $img = $event_pre; } $filerow_list = array_dir($filepath_3); array_multisort($filerow_list, SORT_ASC, SORT_NUMERIC); foreach ($filerow_list as $filerow) { if (preg_match('#(\d+)\.(jpg)#is', $filerow)) { $row = $upload->_row($filepath_3, $filerow); if (!@copy($filepath_3 . $filerow, $row['filepath'])) { continue; } $img++; $xa = $upload->resize($row, $filepath_3, $filepath_3, $img, array(600, 450), false, true, true, 'w2'); if ($xa === false) { continue; } $xb = $upload->resize($row, $filepath_3, $filepath_4, $img, array(100, 75), false, false); $insert = array( 'event_id' => (int) $event_id, 'image' => (int) $img, 'width' => (int) $xa['width'], 'height' => (int) $xa['height'], 'allow_dl' => 1 ); sql_insert('events_images', $insert); $count_images++; } elseif (preg_match('#(info)\.(txt)#is', $filerow)) { $footer_data = $filerow; } } if (!empty($footer_data) && @file_exists($filepath_3 . $footer_data)) { $footer_info = @file($filepath_3 . $footer_data); foreach ($footer_info as $linerow) { $part = explode(':', $linerow); $part = array_map('trim', $part); $numbs = explode('-', $part[0]); $numbs[1] = (isset($numbs[1])) ? $numbs[1] : $numbs[0]; for ($i = ($numbs[0] + $event_pre), $end = ($numbs[1] + $event_pre + 1); $i < $end; $i++) { $sql = 'UPDATE _events_images SET image_footer = ? WHERE event_id = ? AND image = ?'; sql_query(sql_filter($sql, htmlencode($part[1]), $event_id, $i)); } } _rm($filepath_3 . $footer_data); } $sql = 'SELECT * FROM _events_colab WHERE colab_event = ? AND colab_uid = ?'; if (!$row = sql_fieldrow(sql_filter($sql, $event_ud, $user->d('user_id')))) { $sql_insert = array( 'colab_event' => $event_id, 'colab_uid' => $user->d('user_id') ); sql_insert('events_colab', $sql_insert); } $sql = 'UPDATE _events SET images = images + ?? WHERE id = ?'; sql_query(sql_filter($sql, $count_images, $event_id)); $ftp->ftp_rename($ftp->dfolder() . 'data/tmp/' . $event_id . '/', $ftp->dfolder() . 'data/events/gallery/' . $event_id . '/'); //@rename($filepath_3, $filepath_2 . $event_id); $ftp->ftp_quit(); redirect(s_link('events', $event_id)); } _style('error', array( 'MESSAGE' => parse_error($upload->error)) ); } $sql = 'SELECT * FROM _events WHERE date < ?? ORDER BY date DESC'; $result = sql_rowset(sql_filter($sql, (time() + 86400))); foreach ($result as $row) { _style('event_list', array( 'EVENT_ID' => $row['id'], 'EVENT_TITLE' => (($row['images']) ? '* ' : '') . $row['title'], 'EVENT_DATE' => $user->format_date($row['date'])) ); } return; }
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; }
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; }
private function upload() { global $config, $user, $cache, $upload; $limit = set_time_limit(0); $filepath = $config['artists_path'] . $this->object['ub'] . '/'; $filepath_1 = $filepath . 'media/'; $f = (artist_check($this->object['ub'] . ' media') !== false) ? $upload->process($filepath_1, 'create', 'mp3') : false; if ($f === false) { return; } else if (!sizeof($upload->error)) { $a = sql_total('_dl'); foreach ($f as $i => $row) { if (!$i) { require_once(ROOT . 'interfase/getid3/getid3.php'); $getID3 = new getID3; } $filename = $upload->rename($row, $a); $tags = $getID3->analyze($filename); $a++; $mt = new stdClass(); foreach (w('title genre album year') as $w) { $mt->$w = (isset($tags['tags']['id3v1'][$w][0])) ? htmlencode($tags['tags']['id3v1'][$w][0]) : ''; } $sql_insert = array( 'ud' => 1, 'ub' => $this->object['ub'], 'alias' => friendly($mt->title), 'title' => $mt->title, 'views' => 0, 'downloads' => 0, 'votes' => 0, 'posts' => 0, 'date' => time(), 'filesize' => @filesize($filename), 'duration' => $tags['playtime_string'], 'genre' => $mt->genre, 'album' => $mt->album, 'year' => $mt->year ); $media_id = sql_insert('dl', $sql_insert); } $sql = 'UPDATE _artists SET um = um + ?? WHERE ub = ?'; sql_query(sql_filter($sql, count($f), $a_id)); $cache->delete('downloads_list'); redirect(s_link('acp', array('artist_media', 'a' => $this->object['subdomain'], 'id' => $media_id))); } else { _style('error', array( 'MESSAGE' => parse_error($upload->error)) ); } return; }
function _help_edit() { global $bio, $core; $error = array(); $sub = $this->control->get_var('sub', ''); $id = $this->control->get_var('id', 0); $submit = isset($_POST['submit']) ? true : false; switch ($sub) { case 'cat': $sql = 'SELECT c.*, m.* FROM _help_cat c, _help_modules m WHERE c.help_id = ' . (int) $id . ' AND c.help_module = m.module_id'; $result = $db->sql_query($sql); if (!($cat_data = $db->sql_fetchrow($result))) { fatal_error(); } $db->sql_freeresult($result); $order = $this->control->get_var('order', ''); if (!empty($order)) { if (preg_match('/_([0-9]+)/', $order)) { $sig = '-'; $order = str_replace('_', '', $order); } else { $sig = '+'; } $sql = 'UPDATE _help_cat SET help_order = help_order ' . $sig . ' ' . (int) $order . ' WHERE help_id = ' . (int) $id; $db->sql_query($sql); $this->_help_edit_move(); $cache->unload('help_cat'); redirect(_link_control('comments', array('mode' => $this->mode))); } // IF order $module_id = $cat_data['help_module']; $help_es = $cat_data['help_es']; $help_en = $cat_data['help_en']; break; case 'faq': $sql = 'SELECT * FROM _help_faq WHERE faq_id = ' . (int) $id; $result = $db->sql_query($sql); if (!($faq_data = $db->sql_fetchrow($result))) { fatal_error(); } $db->sql_freeresult($result); $question_es = $faq_data['faq_question_es']; $question_en = $faq_data['faq_question_en']; $answer_es = $faq_data['faq_answer_es']; $answer_en = $faq_data['faq_answer_en']; $help_id = $faq_data['help_id']; break; default: redirect(_link_control('comments', array('mode' => $this->mode))); break; } // IF submit if ($submit) { switch ($sub) { case 'cat': $module_id = $this->control->get_var('module_id', 0); $help_es = $this->control->get_var('help_es', ''); $help_en = $this->control->get_var('help_en', ''); if (empty($help_es) || empty($help_en)) { $error[] = 'CONTROL_COMMENTS_HELP_EMPTY'; } // Update if (!sizeof($error)) { $sql_update = array('help_es' => $help_es, 'help_en' => $help_en, 'help_module' => (int) $module_id); $sql = 'UPDATE _help_cat SET ' . $db->sql_build_array('UPDATE', $sql_update) . ' WHERE help_id = ' . (int) $id; $db->sql_query($sql); $cache->unload('help_cat'); redirect(_link_control('comments', array('mode' => $this->mode))); } break; case 'faq': $question_es = $this->control->get_var('question_es', ''); $question_en = $this->control->get_var('question_en', ''); $answer_es = $this->control->get_var('answer_es', ''); $answer_en = $this->control->get_var('answer_en', ''); $help_id = $this->control->get_var('help_id', 0); if (empty($question_es) || empty($question_en) || empty($answer_es) || empty($answer_en)) { $error[] = 'CONTROL_COMMENTS_HELP_EMPTY'; } if (!sizeof($error)) { $sql = 'SELECT * FROM _help_cat WHERE help_id = ' . (int) $help_id; $result = $db->sql_query($sql); if (!($cat_data = $db->sql_fetchrow($result))) { $error[] = 'CONTROL_COMMENTS_HELP_NOCAT'; } } // Update if (!sizeof($error)) { $sql_update = array('help_id' => (int) $help_id, 'faq_question_es' => $question_es, 'faq_question_en' => $question_en, 'faq_answer_es' => $answer_es, 'faq_answer_en' => $answer_en); $sql = 'UPDATE _help_faq SET ' . $db->sql_build_array('UPDATE', $sql_update) . ' WHERE faq_id = ' . (int) $id; $db->sql_query($sql); $cache->unload('help_faq'); redirect(_link_control('comments', array('mode' => $this->mode))); } break; } // switch if (sizeof($error)) { _style('error', array('MESSAGE' => parse_error($error))); } } $this->nav(); $this->control->set_nav(array('mode' => $this->mode, 'manage' => $this->manage, 'sub' => $sub, 'id' => $id), 'CONTROL_EDIT'); $template_vars = array('SUB' => $sub, 'S_HIDDEN' => _hidden(array('module' => $this->control->module, 'mode' => $this->mode, 'manage' => $this->manage, 'sub' => $sub, 'id' => $id))); switch ($sub) { case 'cat': $sql = 'SELECT * FROM _help_modules ORDER BY module_id'; $result = $db->sql_query($sql); $select_mod = ''; while ($row = $db->sql_fetchrow($result)) { $selected = $row['module_id'] == $module_id; $select_mod .= '<option' . ($selected ? ' class="bold"' : '') . ' value="' . $row['module_id'] . '"' . ($selected ? ' selected' : '') . '>' . $row['module_name'] . '</option>'; } $db->sql_freeresult($result); $sv += array('MODULE' => $select_mod, 'HELP_ES' => $help_es, 'HELP_EN' => $help_en); break; case 'faq': $sql = 'SELECT * FROM _help_cat ORDER BY help_id'; $result = $db->sql_query($sql); $select_cat = ''; while ($row = $db->sql_fetchrow($result)) { $selected = $row['help_id'] == $help_id; $select_cat .= '<option' . ($selected ? ' class="bold"' : '') . ' value="' . $row['help_id'] . '"' . ($selected ? ' selected' : '') . '>' . $row['help_es'] . ' | ' . $row['help_en'] . '</option>'; } $db->sql_freeresult($result); $sv += array('CATEGORY' => $select_cat, 'QUESTION_ES' => $question_es, 'QUESTION_EN' => $question_en, 'ANSWER_ES' => $answer_es, 'ANSWER_EN' => $answer_en); break; } v_style($sv); return; }
public function _home() { global $config, $user, $cache, $upload; $error = w(); if (_button()) { $filepath = $config['events_path']; $filepath_1 = $filepath . 'future/'; $filepath_2 = $filepath_1 . 'thumbnails/'; $f = $upload->process($filepath_1, 'event_image', 'jpg'); if (!sizeof($upload->error) && $f !== false) { $img = sql_total('_events'); // Create vars $event_name = request_var('event_name', ''); $event_artists = request_var('event_artists', '', true); $event_year = request_var('event_year', 0); $event_month = request_var('event_month', 0); $event_day = request_var('event_day', 0); $event_hours = request_var('event_hours', 0); $event_minutes = request_var('event_minutes', 0); $event_current_topic = request_var('event_current_topic', 0); $v_date = gmmktime($event_hours, $event_minutes, 0, $event_month, $event_day, $event_year) - $user->timezone - $user->dst; foreach ($f as $row) { $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(100, 75), false, false); $event_alias = friendly($event_name); $insert = array( 'event_alias' => $event_alias, 'title' => $event_name, 'archive' => '', 'date' => (int) $v_date, 'event_update' => time() ); $event_id = sql_insert('events', $insert); // $artists_ary = explode(nr(), $event_artists); foreach ($artists_ary as $row) { $subdomain = get_subdomain($row); $sql = 'SELECT * FROM _artists WHERE subdomain = ?'; if ($a_row = sql_fieldrow(sql_filter($sql, $subdomain))) { $sql = 'SELECT * FROM _artists_events WHERE a_artist = ? AND a_event = ?'; if (!sql_fieldrow(sql_filter($sql, $a_row['ub'], $event_id))) { $sql_insert = array( 'a_artist' => $a_row['ub'], 'a_event' => $event_id ); sql_insert('artists_events', $sql_insert); } } } // Alice: Create topic $event_url = $config['events_url'] . 'future/' . $img . '.jpg'; $post_message = 'Evento publicado'; $post_time = time(); $forum_id = 21; $poster_id = 1433; $sql = 'SELECT * FROM _forum_topics WHERE topic_id = ?'; if (!$row_current_topic = sql_fieldrow(sql_filter($sql, $event_current_topic))) { $insert = array( 'topic_title' => $event_name, 'topic_poster' => $poster_id, 'topic_time' => $post_time, 'forum_id' => $forum_id, 'topic_locked' => 0, 'topic_announce' => 0, 'topic_important' => 0, 'topic_vote' => 1, 'topic_featured' => 1, 'topic_points' => 1 ); $topic_id = sql_insert('forum_topics', $insert); $event_current_topic = 0; } else { $topic_id = $event_current_topic; $post_message .= ' en la sección de eventos'; $sql = 'UPDATE _forum_topics SET topic_title = ? WHERE topic_id = ?'; sql_query(sql_filter($sql, $event_name, $topic_id)); } $post_message .= '.'; $insert = array( 'topic_id' => (int) $topic_id, 'forum_id' => $forum_id, 'poster_id' => $poster_id, 'post_time' => $post_time, 'poster_ip' => $user->ip, 'post_text' => $post_message, 'post_np' => '' ); $post_id = sql_insert('forum_posts', $insert); $sql = 'UPDATE _events SET event_topic = ? WHERE id = ?'; sql_query(sql_filter($sql, $topic_id, $event_id)); $insert = array( 'topic_id' => (int) $topic_id, 'vote_text' => '¿Asistirás a ' . $event_name . '?', 'vote_start' => time(), 'vote_length' => (int) ($poll_length * 86400) ); $poll_id = sql_insert('poll_options', $insert); $poll_options = array(1 => 'Si asistiré'); foreach ($poll_options as $option_id => $option_text) { $sql_insert = array( 'vote_id' => (int) $poll_id, 'vote_option_id' => (int) $option_id, 'vote_option_text' => $option_text, 'vote_result' => 0 ); sql_insert('poll_results', $sql_insert); $poll_option_id++; } $sql = 'UPDATE _forums SET forum_posts = forum_posts + 1, forum_last_topic_id = ?' . ((!$event_current_topic) ? ', 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, $poster_id)); // Notify $user->save_unread(UH_T, $topic_id); redirect(s_link('events', $event_alias)); } } _style('error', array( 'MESSAGE' => parse_error($upload->error)) ); } $sql = 'SELECT topic_id, topic_title FROM _forum_topics t LEFT OUTER JOIN _events e ON t.topic_id = e.event_topic WHERE e.event_topic IS NULL AND forum_id = 21 ORDER BY topic_time DESC'; $topics = sql_rowset($sql); foreach ($topics as $i => $row) { if (!$i) _style('topics'); _style('topics.row', array( 'TOPIC_ID' => $row['topic_id'], 'TOPIC_TITLE' => $row['topic_title']) ); } return; }
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; }
public function store() { global $user, $config; $this->param = explode('/', array_key(explode('//', $this->ref), 1)); $this->param = array_splice($this->param, 1, -1); $sql = ''; $id = (isset($this->param[3])) ? (int) $this->param[3] : 0; switch ($this->param[0]) { case 'a': if ($this->param[2] == 9) { $sql = 'SELECT * FROM _dl d, _artists a WHERE d.id = ? AND a.subdomain = ? AND d.ub = a.ub'; $sql = sql_filter($sql, $id, $this->param[1]); $this->data = array( 'DATA_TABLE' => '_dl', 'POST_TABLE' => 'dl_posts', 'HISTORY' => UH_M ); } else { $sql = 'SELECT * FROM _artists WHERE subdomain = ?'; $sql = sql_filter($sql, $this->param[1]); $this->data = array( 'DATA_TABLE' => '_artists', 'POST_TABLE' => 'artists_posts', 'HISTORY' => UH_C ); } break; case 'events': $event_field = (is_numb($this->param[1])) ? 'id' : 'event_alias'; $sql = 'SELECT * FROM _events WHERE ?? = ?'; $sql = sql_filter($sql, $event_field, $this->param[1]); $this->data = array( 'DATA_TABLE' => '_events', 'POST_TABLE' => 'events_posts', 'HISTORY' => UH_EP ); break; case 'news': $sql = 'SELECT * FROM _news WHERE news_id = ?'; $sql = sql_filter($sql, $this->param[1]); $this->data = array( 'DATA_TABLE' => '_news', 'POST_TABLE' => 'news_posts', 'HISTORY' => UH_NP ); break; case 'art': $sql = 'SELECT * FROM _art WHERE art_id = ?'; $sql = sql_filter($sql, $this->param[1]); $this->data = array( 'DATA_TABLE' => '_art', 'POST_TABLE' => 'art_posts', 'HISTORY' => UH_W ); break; case 'm': $sql = 'SELECT * FROM _members WHERE username_base = ?'; $sql = sql_filter($sql, $this->param[1]); $this->data = array( 'DATA_TABLE' => '_members', 'POST_TABLE' => 'members_posts', 'HISTORY' => UH_UPM ); break; default: fatal_error(); break; } if (empty($sql)) { fatal_error(); } if (!$post_data = sql_fieldrow($sql)) { fatal_error(); } $post_reply = 0; $error = w(); $update_sql = ''; $current_time = time(); $this->auth['user'] = $user->is('member'); $this->auth['adm'] = $user->is('founder'); /* // // Flood control // if (!$this->auth['adm'] && !$this->auth['mod']) { $where_sql = (!$this->auth['user']) ? "post_ip = '$user_ip'" : "poster_id = " . $userdata['user_id']; $sql = "SELECT MAX(post_time) AS last_datetime FROM " . $this->data['POST_TABLE'] . " WHERE $where_sql"; if ($row = sql_fieldrow($sql)) { if ((intval($row['last_datetime']) > 0) && ($current_time - intval($row['last_datetime'])) < 10) { $error[] = 'CHAT_FLOOD_CONTROL'; } } } */ // // Check if message is empty // if (!sizeof($error)) { $message = request_var('message', '', true); // Check message if (empty($message)) { $error[] = 'EMPTY_MESSAGE'; } } // // Insert processed data // if (!sizeof($error)) { $update_sql = ''; $post_reply = (isset($this->param[4]) && $this->param[4] == 'reply') ? $id : 0; $message = $this->prepare($message); $insert_data = array( 'post_reply' => (int) $post_reply, 'post_active' => 1, 'poster_id' => (int) $user->d('user_id'), 'post_ip' => (string) $user->ip, 'post_time' => (int) $current_time, 'post_text' => (string) $message ); switch ($this->param[0]) { case 'a': switch ($this->param[2]) { case 9: $insert_data['download_id'] = (int) $post_data['id']; $update_sql = sql_filter('posts = posts + 1 WHERE id = ?', $post_data['id']); $this->data['HISTORY_EXTRA'] = $post_data['ub']; break; case 12: default: $insert_data['post_ub'] = (int) $post_data['ub']; $update_sql = sql_filter('posts = posts + 1 WHERE ub = ?', $post_data['ub']); $this->data['HISTORY_EXTRA'] = $post_data['ub']; $this->data['REPLY_TO_SQL'] = sql_filter('SELECT p.poster_id, m.user_id FROM _artists_posts p, _members m WHERE p.post_id = ? AND p.poster_id = m.user_id AND m.user_type NOT IN (??)', $post_reply, USER_INACTIVE); break; } break; case 'events': $insert_data['event_id'] = (int) $post_data['id']; $update_sql = sql_filter('posts = posts + 1 WHERE id = ?', $post_data['id']); break; case 'news': $insert_data['news_id'] = (int) $post_data['news_id']; $update_sql = sql_filter('post_replies = post_replies + 1 WHERE news_id = ?', $post_data['news_id']); break; case 'art': $insert_data['art_id'] = (int) $post_data['art_id']; $update_sql = sql_filter('posts = posts + 1 WHERE art_id = ?', $post_data['art_id']); break; case 'm': $insert_data['userpage_id'] = (int) $post_data['user_id']; $update_sql = sql_filter('userpage_posts = userpage_posts + 1 WHERE user_id = ?', $post_data['user_id']); $this->data['HISTORY_EXTRA'] = $post_data['user_id']; break; } $post_id = sql_insert($this->data['POST_TABLE'], $insert_data); if ($update_sql != '') { $sql = 'UPDATE ' . $this->data['DATA_TABLE'] . ' SET ' . $update_sql; sql_query($sql); } $reply_to = 0; $history_extra = isset($this->data['HISTORY_EXTRA']) ? $this->data['HISTORY_EXTRA'] : 0; if ($post_reply && isset($this->data['REPLY_TO_SQL'])) { if ($reply_row = sql_fieldrow($this->data['REPLY_TO_SQL'])) { $reply_to = ($reply_row['user_id'] != GUEST) ? $reply_row['user_id'] : 0; } $user->delete_unread($this->data['HISTORY'], $post_reply); } $notify = true; if ($this->param[0] == 'm' && $user->d('user_id') == $post_data['user_id']) { $notify = false; } if ($notify) { if ($this->param[0] == 'm') { $emailer = new emailer(); $emailer->from('info'); $emailer->use_template('user_message'); $emailer->email_address($post_data['user_email']); $emailer->set_subject($user->d('username') . ' te envio un mensaje en Rock Republik'); $emailer->assign_vars(array( 'USERNAME_TO' => $post_data['username'], 'USERNAME_FROM' => $user->d('username'), 'USER_MESSAGE' => entity_decode($message), 'U_PROFILE' => s_link('m', $user->d('username_base'))) ); $emailer->send(); $emailer->reset(); $user->save_unread($this->data['HISTORY'], $post_id, $history_extra, $post_data['user_id']); } else { $user->save_unread($this->data['HISTORY'], $post_id, $history_extra, $reply_to, false); // Points //$user->points_add(1); } } // Userpage messages if ($this->param[0] == 'm') { $sql = 'SELECT post_id FROM _members_posts p, _members_unread u WHERE u.item = p.post_id AND p.userpage_id = ? AND p.poster_id = ?'; if ($rows = sql_rowset(sql_filter($sql, $user->d('user_id'), $post_data['user_id']), false, 'post_id')) { $sql = 'DELETE FROM _members_unread WHERE user_id = ? AND element = ? AND item IN (??)'; sql_query(sql_filter($sql, $user->d('user_id'), UH_UPM, implode(',', $rows))); } } } else { $user->setup(); $return_message = parse_error($error) . '<br /><br /><br /><a href="' . $ref . '">' . lang('click_return_lastpage') . '</a>'; trigger_error($return_message); } return; }
function do_login($box_text = '', $need_admin = false, $extra_vars = false) { global $config, $user; $error = w(); $action = request_var('mode', ''); if (empty($user->data)) { $user->init(false); } if (empty($user->lang)) { $user->setup(); } if ($user->is('bot')) { redirect(s_link()); } $code_invite = request_var('invite', ''); $admin = _button('admin'); $login = _button('login'); $submit = _button(); $need_auth = false; if ($admin) { $need_auth = true; } $v_fields = array( 'username' => '', 'email' => '', 'email_confirm' => '', 'key' => '', 'key_confirm' => '', 'gender' => 0, 'birthday_month' => 0, 'birthday_day' => 0, 'birthday_year' => 0, 'tos' => 0, 'ref' => 0 ); if (!empty($code_invite)) { $sql = 'SELECT i.invite_email, m.user_email FROM _members_ref_invite i, _members m WHERE i.invite_code = ? AND i.invite_uid = m.user_id'; if (!$invite_row = sql_fieldrow(sql_filter($sql, $code_invite))) { fatal_error(); } $v_fields['ref'] = $invite_row['user_email']; $v_fields['email'] = $invite_row['invite_email']; unset($invite_row); } switch ($action) { case 'in': if ($user->is('member') && !$admin) { redirect(s_link()); } if ($login && (!$user->is('member') || $admin)) { $username = request_var('username', ''); $password = request_var('password', ''); $ref = request_var('ref', ''); if (!empty($username) && !empty($password)) { $username_base = get_username_base($username); $sql = 'SELECT user_id, username, user_password, user_type, user_country, user_avatar, user_location, user_gender, user_birthday FROM _members WHERE username_base = ?'; if ($row = sql_fieldrow(sql_filter($sql, $username_base))) { $exclude_type = array(USER_INACTIVE); if (ValidatePassword($password, $row['user_password']) && (!in_array($row['user_type'], $exclude_type))) { $user->session_create($row['user_id'], $admin); if (!$row['user_country'] || !$row['user_location'] || !$row['user_gender'] || !$row['user_birthday'] || !$row['user_avatar']) { $ref = s_link('my', 'profile'); } else { $ref = (empty($ref) || (preg_match('#' . preg_quote($config['server_name']) . '/$#', $ref))) ? s_link('today') : $ref; } redirect($ref); } } } } break; case 'out': if ($user->is('member')) { $user->session_kill(); } redirect(s_link()); break; case 'up': if ($user->is('member')) { redirect(s_link('my profile')); } else if ($user->is('bot')) { redirect(s_link()); } $code = request_var('code', ''); if (!empty($code)) { if (!preg_match('#([a-z0-9]+)#is', $code)) { fatal_error(); } $sql = 'SELECT c.*, m.user_id, m.username, m.username_base, m.user_email FROM _crypt_confirm c, _members m WHERE c.crypt_code = ? AND c.crypt_userid = m.user_id'; if (!$crypt_data = sql_fieldrow(sql_filter($sql, $code))) { fatal_error(); } $user_id = $crypt_data['user_id']; $sql = 'UPDATE _members SET user_type = ? WHERE user_id = ?'; sql_query(sql_filter($sql, USER_NORMAL, $user_id)); $sql = 'DELETE FROM _crypt_confirm WHERE crypt_code = ? AND crypt_userid = ?'; sql_query(sql_filter($sql, $code, $user_id)); $emailer = new emailer(); $emailer->from('info'); $emailer->use_template('user_welcome_confirm'); $emailer->email_address($crypt_data['user_email']); $emailer->assign_vars(array( 'USERNAME' => $crypt_data['username']) ); $emailer->send(); $emailer->reset(); $user->session_create($user_id, 0); // if (empty($user->data)) { $user->init(); } if (empty($user->lang)) { $user->setup(); } $custom_vars = array( 'S_REDIRECT' => '', 'MESSAGE_TITLE' => lang('information'), 'MESSAGE_TEXT' => lang('membership_added_confirm') ); page_layout('INFORMATION', 'message', $custom_vars); } // /*$sql = 'SELECT * FROM _members_ref_assoc WHERE ref_uid = ?'; if ($ref_assoc = sql_fieldrow(sql_filter($sql, $user_id))) { if ($user_id != $ref_assoc['ref_orig']) { $user->points_add(3, $ref_assoc['ref_orig']); $sql_insert = array( 'user_id' => $user_id, 'buddy_id' => $ref_assoc['ref_orig'], 'friend_time' => time() ); sql_insert('members_friends', $sql_insert); $sql_insert = array( 'user_id' => $ref_assoc['ref_orig'], 'buddy_id' => $user_id, 'friend_time' => time() ); sql_insert('members_friends', $sql_insert); $user->save_unread(UH_FRIEND, $user_id, 0, $ref_assoc['ref_orig']); } $sql = 'DELETE FROM _members_ref_assoc WHERE ref_id = ?'; sql_query(sql_filter($sql, $ref_assoc['ref_id'])); } // $sql = 'SELECT * FROM _members_ref_invite WHERE invite_email = ?'; if ($row = sql_fieldrow(sql_filter($sql, $crypt_data['user_email']))) { $sql = 'DELETE FROM _members_ref_invite WHERE invite_code = ?'; sql_query(sql_filter($sql, $row['invite_code'])); } // $emailer = new emailer(); $emailer->from('info'); $emailer->use_template('user_welcome_confirm'); $emailer->email_address($crypt_data['user_email']); $emailer->assign_vars(array( 'USERNAME' => $crypt_data['username']) ); $emailer->send(); $emailer->reset(); // if (empty($user->data)) { $user->init(); } if (empty($user->lang)) { $user->setup(); } $custom_vars = array( 'S_REDIRECT' => '', 'MESSAGE_TITLE' => lang('information'), 'MESSAGE_TEXT' => lang('membership_added_confirm') ); page_layout('INFORMATION', 'message', $custom_vars); * */ if ($submit) { foreach ($v_fields as $k => $v) { $v_fields[$k] = request_var($k, $v); } if (empty($v_fields['username'])) { $error['username'] = '******'; } else { $len_username = strlen($v_fields['username']); if (($len_username < 2) || ($len_username > 20) || !get_username_base($v_fields['username'], true)) { $error['username'] = '******'; } if (!sizeof($error)) { $result = validate_username($v_fields['username']); if ($result['error']) { $error['username'] = $result['error_msg']; } } if (!sizeof($error)) { $v_fields['username_base'] = get_username_base($v_fields['username']); $sql = 'SELECT user_id FROM _members WHERE username_base = ?'; if (sql_field(sql_filter($sql, $v_fields['username_base']), 'user_id', 0)) { $error['username'] = '******'; } } if (!sizeof($error)) { $sql = 'SELECT ub FROM _artists WHERE subdomain = ?'; if (sql_field(sql_filter($sql, $v_fields['username_base']), 'ub', 0)) { $error['username'] = '******'; } } } if (empty($v_fields['email']) || empty($v_fields['email_confirm'])) { if (empty($v_fields['email'])) { $error['email'] = 'EMPTY_EMAIL'; } if (empty($v_fields['email_confirm'])) { $error['email_confirm'] = 'EMPTY_EMAIL_CONFIRM'; } } else { if ($v_fields['email'] == $v_fields['email_confirm']) { $result = validate_email($v_fields['email']); if ($result['error']) { $error['email'] = $result['error_msg']; } } else { $error['email'] = 'EMAIL_MISMATCH'; $error['email_confirm'] = 'EMAIL_MISMATCH'; } } if (!empty($v_fields['key']) && !empty($v_fields['key_confirm'])) { if ($v_fields['key'] != $v_fields['key_confirm']) { $error['key'] = 'PASSWORD_MISMATCH'; } else if (strlen($v_fields['key']) > 32) { $error['key'] = 'PASSWORD_LONG'; } } else { if (empty($v_fields['key'])) { $error['key'] = 'EMPTY_PASSWORD'; } elseif (empty($v_fields['key_confirm'])) { $error['key_confirm'] = 'EMPTY_PASSWORD_CONFIRM'; } } if (!$v_fields['birthday_month'] || !$v_fields['birthday_day'] || !$v_fields['birthday_year']) { $error['birthday'] = 'EMPTY_BIRTH_MONTH'; } if (!$v_fields['tos']) { $error['tos'] = 'AGREETOS_ERROR'; } if (!sizeof($error)) { //$v_fields['country'] = strtolower(geoip_country_code_by_name($user->ip)); $v_fields['country'] = 90; $v_fields['birthday'] = leading_zero($v_fields['birthday_year']) . leading_zero($v_fields['birthday_month']) . leading_zero($v_fields['birthday_day']); $member_data = array( 'user_type' => USER_INACTIVE, 'user_active' => 1, 'username' => $v_fields['username'], 'username_base' => $v_fields['username_base'], 'user_password' => HashPassword($v_fields['key']), 'user_regip' => $user->ip, 'user_session_time' => 0, 'user_lastpage' => '', 'user_lastvisit' => time(), 'user_regdate' => time(), 'user_level' => 0, 'user_posts' => 0, 'userpage_posts' => 0, 'user_points' => 0, 'user_timezone' => $config['board_timezone'], 'user_dst' => $config['board_dst'], 'user_lang' => $config['default_lang'], 'user_dateformat' => $config['default_dateformat'], 'user_country' => (int) $v_fields['country'], 'user_rank' => 0, 'user_avatar' => '', 'user_avatar_type' => 0, 'user_email' => $v_fields['email'], 'user_lastlogon' => 0, 'user_totaltime' => 0, 'user_totallogon' => 0, 'user_totalpages' => 0, 'user_gender' => $v_fields['gender'], 'user_birthday' => (string) $v_fields['birthday'], 'user_mark_items' => 0, 'user_topic_order' => 0, 'user_email_dc' => 1, 'user_refop' => 0, 'user_refby' => $v_fields['ref'] ); $user_id = sql_insert('members', $member_data); set_config('max_users', $config['max_users'] + 1); // Confirmation code $verification_code = md5(unique_id()); $insert = array( 'crypt_userid' => $user_id, 'crypt_code' => $verification_code, 'crypt_time' => $user->time ); sql_insert('crypt_confirm', $insert); // Emailer $emailer = new emailer(); if (!empty($v_fields['ref'])) { $valid_ref = email_format($v_fields['ref']); if ($valid_ref) { $sql = 'SELECT user_id FROM _members WHERE user_email = ?'; if ($ref_friend = sql_field(sql_filter($sql, $v_fields['ref']), 'user_id', 0)) { $sql_insert = array( 'ref_uid' => $user_id, 'ref_orig' => $ref_friend ); sql_insert('members_ref_assoc', $sql_insert); $sql_insert = array( 'user_id' => $user_id, 'buddy_id' => $ref_friend, 'friend_time' => time() ); sql_insert('members_friends', $sql_insert); } else { $invite_user = explode('@', $v_fields['ref']); $invite_code = substr(md5(unique_id()), 0, 6); $sql_insert = array( 'invite_code' => $invite_code, 'invite_email' => $v_fields['ref'], 'invite_uid' => $user_id ); sql_insert('members_ref_invite', $sql_insert); $emailer->from('info'); $emailer->use_template('user_invite'); $emailer->email_address($v_fields['ref']); $emailer->assign_vars(array( 'INVITED' => $invite_user[0], 'USERNAME' => $v_fields['username'], 'U_REGISTER' => s_link('my register a', $invite_code)) ); $emailer->send(); $emailer->reset(); } } } // Send confirm email $emailer->from('info'); $emailer->use_template('user_welcome'); $emailer->email_address($v_fields['email']); $emailer->assign_vars(array( 'USERNAME' => $v_fields['username'], 'U_ACTIVATE' => 'http:' . s_link('signup', $verification_code)) ); $emailer->send(); $emailer->reset(); $custom_vars = array( 'MESSAGE_TITLE' => lang('information'), 'MESSAGE_TEXT' => lang('membership_added') ); page_layout('INFORMATION', 'message', $custom_vars); /* $user->session_create($user_id, 0); redirect(s_link()); */ } } break; case 'r': if ($user->is('member')) { redirect(s_link('my profile')); } else if ($user->is('bot')) { redirect(s_link()); } $code = request_var('code', ''); if (request_var('r', 0)) { redirect(s_link()); } if (!empty($code)) { if (!preg_match('#([a-z0-9]+)#is', $code)) { fatal_error(); } $sql = 'SELECT c.*, m.user_id, m.username, m.username_base, m.user_email FROM _crypt_confirm c, _members m WHERE c.crypt_code = ? AND c.crypt_userid = m.user_id'; if (!$crypt_data = sql_fieldrow(sql_filter($sql, $code))) { fatal_error(); } if (_button()) { $password = request_var('newkey', ''); $password2 = request_var('newkey2', ''); if (!empty($password)) { if ($password === $password2) { $crypt_password = HashPassword($password); $sql = 'UPDATE _members SET user_password = ? WHERE user_id = ?'; sql_query(sql_filter($sql, $crypt_password, $crypt_data['user_id'])); $sql = 'DELETE FROM _crypt_confirm WHERE crypt_userid = ?'; sql_query(sql_filter($sql, $crypt_data['user_id'])); // Send email $emailer = new emailer(); $emailer->from('info'); $emailer->use_template('user_confirm_passwd', $config['default_lang']); $emailer->email_address($crypt_data['user_email']); $emailer->assign_vars(array( 'USERNAME' => $crypt_data['username'], 'PASSWORD' => $password, 'U_PROFILE' => s_link('m', $crypt_data['username_base'])) ); $emailer->send(); $emailer->reset(); // v_style(array( 'PAGE_MODE' => 'updated' )); } else { v_style(array( 'PAGE_MODE' => 'nomatch', 'S_CODE' => $code) ); } } else { v_style(array( 'PAGE_MODE' => 'nokey', 'S_CODE' => $code) ); } } else { v_style(array( 'PAGE_MODE' => 'verify', 'S_CODE' => $code) ); } } else if (_button()) { $email = request_var('address', ''); if (empty($email) || !email_format($email)) { fatal_error(); } $sql = 'SELECT * FROM _members WHERE user_email = ? AND user_active = 1 AND user_type NOT IN (??, ??) AND user_id NOT IN ( SELECT ban_userid FROM _banlist )'; if (!$userdata = sql_fieldrow(sql_filter($sql, $email, USER_INACTIVE, USER_FOUNDER))) { fatal_error(); } $emailer = new emailer(); $verification_code = md5(unique_id()); $sql = 'DELETE FROM _crypt_confirm WHERE crypt_userid = ?'; sql_query(sql_filter($sql, $userdata['user_id'])); $insert = array( 'crypt_userid' => $userdata['user_id'], 'crypt_code' => $verification_code, 'crypt_time' => $user->time ); sql_insert('crypt_confirm', $insert); // Send email $emailer->from('info'); $emailer->use_template('user_activate_passwd', $config['default_lang']); $emailer->email_address($userdata['user_email']); $emailer->assign_vars(array( 'USERNAME' => $userdata['username'], 'U_ACTIVATE' => s_link('signr', $verification_code)) ); $emailer->send(); $emailer->reset(); _style('reset_complete'); } break; default: break; } // // Signup data // if (sizeof($error)) { _style('error', array( 'MESSAGE' => parse_error($error)) ); } $s_genres_select = ''; $genres = array(1 => 'MALE', 2 => 'FEMALE'); foreach ($genres as $id => $value) { $s_genres_select .= '<option value="' . $id . '"' . (($v_fields['gender'] == $id) ? ' selected="true"' : '') . '>' . lang($value) . '</option>'; } $s_bday_select = ''; for ($i = 1; $i < 32; $i++) { $s_bday_select .= '<option value="' . $i . '"' . (($v_fields['birthday_day'] == $i) ? 'selected="true"' : '') . '>' . $i . '</option>'; } $s_bmonth_select = ''; $months = array(1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August', 9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December'); foreach ($months as $id => $value) { $s_bmonth_select .= '<option value="' . $id . '"' . (($v_fields['birthday_month'] == $id) ? ' selected="true"' : '') . '>' . $user->lang['datetime'][$value] . '</option>'; } $s_byear_select = ''; $current_year = date('Y'); for ($i = ($current_year - 1); $i > $current_year - 102; $i--) { $s_byear_select .= '<option value="' . $i . '"' . (($v_fields['birthday_year'] == $i) ? ' selected="true"' : '') . '>' . $i . '</option>'; } $v_fields['birthday'] = false; if (isset($error['birthday'])) { $v_fields['birthday'] = true; } $s_hidden = w(); if ($need_auth) { $s_hidden = array('admin' => 1); } if (!isset($v_fields['refby'])) { $v_fields['refby'] = ''; } $layout_vars = array( 'IS_NEED_AUTH' => $need_auth, 'IS_LOGIN' => $login, 'CUSTOM_MESSAGE' => $box_text, 'S_HIDDEN_FIELDS' => s_hidden($s_hidden), 'U_SIGNIN' => s_link('signin'), 'U_SIGNUP' => s_link('signup'), 'U_SIGNOUT' => s_link('signout'), 'U_PASSWORD' => s_link('signr'), 'V_USERNAME' => $v_fields['username'], 'V_KEY' => $v_fields['key'], 'V_KEY_CONFIRM' => $v_fields['key_confirm'], 'V_EMAIL' => $v_fields['email'], 'V_REFBY' => $v_fields['refby'], 'V_GENDER' => $s_genres_select, 'V_BIRTHDAY_DAY' => $s_bday_select, 'V_BIRTHDAY_MONTH' => $s_bmonth_select, 'V_BIRTHDAY_YEAR' => $s_byear_select, 'V_TOS' => ($v_fields['tos']) ? ' checked="true"' : '', 'PAGE_MODE' => '' ); foreach ($v_fields as $k => $v) { $layout_vars['E_' . strtoupper($k)] = (isset($error[$k])) ? true : false; } if ($login) { $ref = request_var('ref', ''); _style('error', array( 'LASTPAGE' => ($ref != '') ? $ref : s_link()) ); } $box_text = (!empty($box_text)) ? lang($box_text, $box_text) : ''; page_layout('LOGIN2', 'login', $layout_vars); }
} _style('select_type', array( 'CHAT_SELECT_TYPE' => $type_list) ); } $select_auth = ''; $auth_ary = w('CHAT_CH_ALL FRIENDS'); foreach ($auth_ary as $i => $langkey) { $select_auth .= '<option value="' . $i . '"' . (($i == $ch_auth) ? ' selected' : '') . '>' . lang($langkey) . '</option>'; } $template_vars += array( 'CHAT_SELECT_AUTH' => $select_auth, 'S_ACTION' => s_link('chat-create') ); if (sizeof($error)) { _style('error', array( 'MESSAGE' => parse_error($error)) ); } page_layout('CHAT_CREATE', 'chat_create', $template_vars); break; } redirect(s_link('chat')); ?>
function resultClangDisplay($version, $display = true) { global $totalFailed, $clangVersions; $totalDebian = $clangVersions[$version]; if (!$keyGET) { $errors = parse_error($version); ?> <?php echo $totalDebian; ?> packages have been rebuild. Among them, <?php echo $totalFailed; ?> (<?php echo round($totalFailed * 100 / $totalDebian, 1); ?> %) failed. <br /> Most of the errors are explained with test cases. <? if ($display) { displayVersion($version,""); } ?> <table class="data"> <tr><th>Type of error</th><th>Occurrence</th><th>clang % / Debian %</th><th></th></tr> <? foreach($errors as $key => $err) { if ($err['nb']>0) { if ($err['key']!="NO_CAT") { ?> <tr><td><?php echo $err["dsc"]; ?> <?if (isset($err['new'])) { echo "<small> - new in " . $err['new'] . "</small>"; }?> </td> <td><?php echo $err["nb"]; ?> </td> <td><?php echo round(100 * $err["nb"] / $totalFailed, 2); ?> % / <?php echo round(100 * $err["nb"] / $totalDebian, 2); ?> %</td> <td><a href="status.php?version=<?php echo $version; ?> &key=<?php echo $err['key']; ?> ">List of errors</a></td> <? /* ?> <td><?if (!is_file("errors/{$err['key']}.inc")) echo "no";?></td> <? */ ?> </tr> <? } else { // Key the no cat stuff $key_NO_CAT=$key; $err_NO_CAT=$err; } } } ?> <tr><td>Not categorized</td><td><?php echo $err_NO_CAT['nb']; ?> </td> <td><?php echo round(100 * $err_NO_CAT['nb'] / $totalFailed, 2); ?> % / <?php echo round(100 * $err_NO_CAT['nb'] / $totalDebian, 2); ?> %</td> <td><a href="status.php?version=<?php echo $version; ?> &key=NO_CAT">List of errors</a></td> </tr> </table> <?php } }