function insert_cron_job($cron_arr) { $row = DB()->fetch_row("SELECT cron_title, cron_script FROM " . BB_CRON . " WHERE cron_title = '" . $_POST['cron_title'] . "' or cron_script = '" . $_POST['cron_script'] . "' "); if ($row) { global $lang; if ($_POST['cron_script'] == $row['cron_script']) { $langmode = $lang['SCRIPT_DUPLICATE']; } else { $langmode = $lang['TITLE_DUPLICATE']; } $message = $langmode . "<br /><br />" . sprintf($lang['CLICK_RETURN_JOBS_ADDED'], "<a href=\"javascript:history.back(-1)\">", "</a>") . "<br /><br />" . sprintf($lang['CLICK_RETURN_JOBS'], "<a href=\"admin_cron.php?mode=list\">", "</a>") . "<br /><br />" . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], "<a href=\"index.php?pane=right\">", "</a>"); bb_die($message); } $cron_active = $cron_arr['cron_active']; $cron_title = $cron_arr['cron_title']; $cron_script = $cron_arr['cron_script']; $schedule = $cron_arr['schedule']; $run_day = $cron_arr['run_day']; $run_time = $cron_arr['run_time']; $run_order = $cron_arr['run_order']; $last_run = $cron_arr['last_run']; $next_run = $cron_arr['next_run']; $run_interval = $cron_arr['run_interval']; $log_enabled = $cron_arr['log_enabled']; $log_file = $cron_arr['log_file']; $log_sql_queries = $cron_arr['log_sql_queries']; $disable_board = $cron_arr['disable_board']; $run_counter = $cron_arr['run_counter']; DB()->query("INSERT INTO " . BB_CRON . " (cron_active, cron_title, cron_script, schedule, run_day, run_time, run_order, last_run, next_run, run_interval, log_enabled, log_file, log_sql_queries, disable_board, run_counter) VALUES (\n\t{$cron_active}, '{$cron_title}', '{$cron_script}', '{$schedule}', '{$run_day}', '{$run_time}', '{$run_order}', '{$last_run}', '{$next_run}', '{$run_interval}', {$log_enabled}, '{$log_file}', {$log_sql_queries}, {$disable_board}, '{$run_counter}')"); }
/** * Check to make sure that a user is not making too many posts in a short amount of time. */ function bb_check_post_flood() { global $bbdb; $user_id = (int) $user_id; $throttle_time = bb_get_option('throttle_time'); if (bb_current_user_can('manage_options') || empty($throttle_time)) { return; } if (bb_is_user_logged_in()) { $bb_current_user = bb_get_current_user(); if (isset($bb_current_user->data->last_posted) && time() < $bb_current_user->data->last_posted + $throttle_time && !bb_current_user_can('throttle')) { if (defined('DOING_AJAX') && DOING_AJAX) { die(__('Slow down; you move too fast.')); } else { bb_die(__('Slow down; you move too fast.')); } } } else { if (($last_posted = bb_get_transient($_SERVER['REMOTE_ADDR'] . '_last_posted')) && time() < $last_posted + $throttle_time) { if (defined('DOING_AJAX') && DOING_AJAX) { die(__('Slow down; you move too fast.')); } else { bb_die(__('Slow down; you move too fast.')); } } } }
function bb_block_current_user() { global $bbdb; if ($id = bb_get_current_user_info('id')) { bb_update_usermeta($id, $bbdb->prefix . 'been_blocked', 1); } // Just for logging. bb_die(__("You've been blocked. If you think a mistake has been made, contact this site's administrator.")); }
function topic_info($topic_id) { global $lang; $sql = "\n\t\tSELECT\n\t\t\ttor.poster_id, tor.forum_id, tor.attach_id, tor.call_seed_time,\n\t\t\tt.topic_title, sn.seeders\n\t\tFROM " . BB_BT_TORRENTS . " tor\n\t\tLEFT JOIN " . BB_TOPICS . " t USING(topic_id)\n\t\tLEFT JOIN " . BB_BT_TRACKER_SNAP . " sn USING(topic_id)\n\t\tWHERE tor.topic_id = {$topic_id}\n\t"; if (!($torrent = DB()->fetch_row($sql))) { bb_die($lang['TOPIC_POST_NOT_EXIST']); } return $torrent; }
/** * Get attachment mod configuration */ function get_config() { global $bb_cfg; $attach_config = array(); $sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG; if (!($result = DB()->sql_query($sql))) { bb_die('Could not query attachment information'); } while ($row = DB()->sql_fetchrow($result)) { $attach_config[$row['config_name']] = trim($row['config_value']); } // We assign the original default board language here, because it gets overwritten later with the users default language $attach_config['board_lang'] = trim($bb_cfg['default_lang']); return $attach_config; }
function send_file_to_browser($attachment, $upload_dir) { global $bb_cfg, $lang, $userdata; $filename = $upload_dir == '' ? $attachment['physical_filename'] : $upload_dir . '/' . $attachment['physical_filename']; $gotit = false; if (@(!file_exists(@amod_realpath($filename)))) { bb_die($lang['ERROR_NO_ATTACHMENT'] . "<br /><br />" . $filename . "<br /><br />" . $lang['TOR_NOT_FOUND']); } else { $gotit = true; } // Correct the mime type - we force application/octet-stream for all files, except images // Please do not change this, it is a security precaution if (!strstr($attachment['mimetype'], 'image')) { $attachment['mimetype'] = 'application/octet-stream'; } //bt if (!(isset($_GET['original']) && !IS_USER)) { include INC_DIR . 'functions_torrent.php'; send_torrent_with_passkey($filename); } // Now the tricky part... let's dance header('Pragma: public'); $real_filename = clean_filename(basename($attachment['real_filename'])); $mimetype = $attachment['mimetype'] . ';'; $charset = "charset={$bb_cfg['lang'][$userdata['user_lang']]['encoding']};"; // Send out the Headers header("Content-Type: {$mimetype} {$charset} name=\"{$real_filename}\""); header("Content-Disposition: inline; filename=\"{$real_filename}\""); unset($real_filename); // Now send the File Contents to the Browser if ($gotit) { $size = @filesize($filename); if ($size) { header("Content-length: {$size}"); } readfile($filename); } else { bb_die($lang['ERROR_NO_ATTACHMENT'] . "<br /><br />" . $filename . "<br /><br />" . $lang['TOR_NOT_FOUND']); } exit; }
function update_table_bool($table_name, $key, $field_name, $field_def_val) { // Clear current status $sql = "UPDATE {$table_name}\n\t\tSET {$field_name} = {$field_def_val}\n\t\tWHERE 1"; if (!($result = DB()->sql_query($sql))) { bb_die('Could not update ' . $table_name); } if (isset($_POST[$field_name])) { // Get new status $in_sql = array(); foreach ($_POST[$field_name] as $i => $val) { $in_sql[] = intval($val); } // Update status if ($in_sql = join(',', $in_sql)) { $sql = "UPDATE {$table_name}\n\t\t\t\tSET {$field_name} = 1\n\t\t\t\tWHERE {$key} IN({$in_sql})"; if (!($result = DB()->sql_query($sql))) { bb_die('Could not update ' . $table_name); } } } return; }
} if (!bb_current_user_can('edit_post', $post_id)) { bb_die(__('Sorry, post is too old.')); } bb_check_admin_referer('edit-post_' . $post_id); if (0 != $bb_post->post_status && 'all' == $_GET['view']) { // We're trying to edit a deleted post add_filter('bb_is_first_where', 'bb_no_where'); } // Check possible anonymous user data $post_author = $post_email = $post_url = ''; if (!bb_get_user(get_post_author_id($post_id))) { if (!($post_author = sanitize_user(trim($_POST['author'])))) { bb_die(__('Every post needs an author name!')); } elseif (!($post_email = sanitize_email(trim($_POST['email'])))) { bb_die(__('Every post needs a valid email address!')); } if (!empty($_POST['url'])) { $post_url = esc_url(trim($_POST['url'])); } } // Loop through possible anonymous post data foreach (array('post_author', 'post_email', 'post_url') as $field) { if (!empty(${$field})) { $post_data[$field] = ${$field}; } } // Setup topic data if (bb_is_first($bb_post->post_id) && bb_current_user_can('edit_topic', $bb_post->topic_id)) { $post_data['topic_title'] = stripslashes($_POST['topic']); $post_data['topic_id'] = $bb_post->topic_id;
function bb_nonce_ays($action) { $title = __('bbPress Failure Notice'); $html .= "\t<div id='message' class='updated fade'>\n\t<p>" . esc_html(bb_explain_nonce($action)) . "</p>\n\t<p>"; if (nxt_get_referer()) { $html .= "<a href='" . remove_query_arg('updated', esc_url(nxt_get_referer())) . "'>" . __('Please try again.') . "</a>"; } $html .= "</p>\n\t</div>\n"; $html .= "</body>\n</html>"; bb_die($html, $title); }
<?php require_once './bb-load.php'; $forum_id = 0; bb_repermalink(); if (!$forum) { bb_die(__('Forum not found.')); } $bb_db_override = false; do_action('bb_forum.php_pre_db', $forum_id); if (!$bb_db_override) { if ($topics = get_latest_topics($forum_id, $page)) { bb_cache_last_posts($topics); } if ($stickies = get_sticky_topics($forum_id, $page)) { bb_cache_last_posts($stickies); } } bb_load_template('forum.php', array('bb_db_override', 'stickies'), $forum_id);
bb_die(__('Please enter a topic title')); } $args = array(); if (isset($post_author)) { $args['topic_poster_name'] = $args['topic_last_poster_name'] = $post_author; } $topic_id = bb_new_topic($topic, $forum_id, $tags, $args); } elseif (isset($_POST['topic_id'])) { $topic_id = (int) $_POST['topic_id']; bb_check_admin_referer('create-post_' . $topic_id); } if (bb_is_login_required() && !bb_current_user_can('write_post', $topic_id)) { bb_die(__('You are not allowed to post. Are you logged in?')); } if (!topic_is_open($topic_id)) { bb_die(__('This topic has been closed')); } $post_data = array('post_text' => stripslashes($_POST['post_content']), 'topic_id' => $topic_id); foreach (array('post_author', 'post_email', 'post_url') as $field) { if (!empty(${$field})) { $post_data[$field] = ${$field}; } } $post_id = bb_insert_post($post_data); $tags = trim($_POST['tags']); bb_add_topic_tags($topic_id, $tags); $topic = get_topic($topic_id, false); $link = get_post_link($post_id); if ($topic->topic_posts) { $link = add_query_arg('replies', $topic->topic_posts, $link); }
<?php require 'admin-action.php'; $topic_id = (int) $_GET['id']; $topic = get_topic($topic_id); if (!$topic) { bb_die(__('There is a problem with that topic, pardner.')); } if (!bb_current_user_can('close_topic', $topic_id)) { nxt_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER)); exit; } bb_check_admin_referer('close-topic_' . $topic_id); if (topic_is_open($topic_id)) { bb_close_topic($topic_id); $message = 'closed'; } else { bb_open_topic($topic_id); $message = 'opened'; } if ($sendto = nxt_get_referer()) { $sendto = remove_query_arg('message', $sendto); $sendto = add_query_arg('message', $message, $sendto); } else { $sendto = get_topic_link($topic_id); } bb_safe_redirect($sendto); exit;
<?php if (!defined('IN_FORUM')) { die('Hacking attempt'); } if (empty($_GET['u']) || empty($_GET['act_key'])) { bb_die('Bad request'); } $sql = "SELECT user_active, user_id, username, user_email, user_newpasswd, user_lang, user_actkey\n\tFROM " . BB_USERS . "\n\tWHERE user_id = " . intval($_GET[POST_USERS_URL]); if (!($result = DB()->sql_query($sql))) { bb_die('Could not obtain user information'); } if ($row = DB()->sql_fetchrow($result)) { if ($row['user_active'] && trim($row['user_actkey']) == '') { bb_die($lang['ALREADY_ACTIVATED']); } else { if (trim($row['user_actkey']) == trim($_GET['act_key']) && trim($row['user_actkey']) != '') { $sql_update_pass = $row['user_newpasswd'] != '' ? ", user_password = '******'user_newpasswd'])) . "', user_newpasswd = ''" : ''; $sql = "UPDATE " . BB_USERS . "\n\t\t\tSET user_active = 1, user_actkey = ''" . $sql_update_pass . "\n\t\t\tWHERE user_id = " . $row['user_id']; if (!($result = DB()->sql_query($sql))) { bb_die('Could not update users table'); } $message = $sql_update_pass == '' ? $lang['ACCOUNT_ACTIVE'] : $lang['PASSWORD_ACTIVATED']; bb_die($message); } else { bb_die($lang['WRONG_ACTIVATION']); } } } else { bb_die($lang['NO_SUCH_USER']); }
<?php define('IN_FORUM', true); define('BB_ROOT', './'); require BB_ROOT . 'common.php'; $user->session_start(); set_die_append_msg(); if (!IS_SUPER_ADMIN) { bb_die($lang['ONLY_FOR_SUPER_ADMIN']); } $confirm = request_var('confirm', ''); if ($confirm) { DB()->query("\n\t\tCREATE TEMPORARY TABLE tmp_buf_dlstatus (\n\t\t\tuser_id mediumint(9) NOT NULL default '0',\n\t\t\ttopic_id mediumint(8) unsigned NOT NULL default '0',\n\t\t\tuser_status tinyint(1) NOT NULL default '0',\n\t\t\tPRIMARY KEY (user_id, topic_id)\n\t\t) ENGINE = MyISAM\n\t"); DB()->query("\n\t\tINSERT INTO tmp_buf_dlstatus\n\t\t\t(user_id, topic_id, user_status)\n\t\tSELECT\n\t\t\tuser_id, topic_id, user_status\n\t\tFROM bb_bt_dlstatus_new\n\t"); DB()->query("\n\t\tREPLACE INTO bb_bt_dlstatus_main\n\t\t\t(user_id, topic_id, user_status)\n\t\tSELECT\n\t\t\tuser_id, topic_id, user_status\n\t\tFROM tmp_buf_dlstatus\n\t"); DB()->query("DROP TEMPORARY TABLE IF EXISTS tmp_buf_dlstatus"); DB()->query("RENAME TABLE bb_bt_dlstatus_main TO bb_bt_dlstatus"); DB()->query("DROP TABLE IF EXISTS bb_bt_dlstatus_mrg"); DB()->query("DROP TABLE IF EXISTS bb_bt_dlstatus_new"); bb_die('<h1 style="color: green">База данных обновлена</h1>'); } else { $msg = '<form method="POST">'; $msg .= '<h1 style="color: red">!!! Перед тем как нажать на кнопку, сделайте бекап базы данных !!!</h1><br />'; $msg .= '<input type="submit" name="confirm" value="Начать обновление Базы Данных (R571)" style="height: 30px; font:bold 14px Arial, Helvetica, sans-serif;" />'; $msg .= '</form>'; bb_die($msg); }
bb_die(__('No forums to update!')); } if ((int) $_POST['forum_id'] && isset($_POST['forum_name']) && '' !== $_POST['forum_name']) { bb_update_forum($_POST); } foreach (array('action', 'id') as $arg) { $sent_from = remove_query_arg($arg, $sent_from); } bb_safe_redirect(add_query_arg('message', 'updated', $sent_from)); exit; break; case 'delete': bb_check_admin_referer('delete-forums'); $forum_id = (int) $_POST['forum_id']; $move_topics_forum = (int) $_POST['move_topics_forum']; if (!bb_current_user_can('delete_forum', $forum_id)) { bb_die(__("You don't have the authority to kill off the forums.")); } if (isset($_POST['move_topics']) && $_POST['move_topics'] != 'delete') { bb_move_forum_topics($forum_id, $move_topics_forum); } if (!bb_delete_forum($forum_id)) { bb_die(__('Error occured while trying to delete forum')); } foreach (array('action', 'id') as $arg) { $sent_from = remove_query_arg($arg, $sent_from); } bb_safe_redirect(add_query_arg('message', 'deleted', $sent_from)); exit; break; }
<?php require_once 'admin-action.php'; $topic_id = absint($_POST['topic_id']); $forum_id = absint($_POST['forum_id']); if (!is_numeric($topic_id) || !is_numeric($forum_id)) { bb_die(__('Invalid topic or forum.')); } if (!bb_current_user_can('move_topic', $topic_id, $forum_id)) { nxt_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER)); exit; } bb_check_admin_referer('move-topic_' . $topic_id); $topic = get_topic($topic_id); $forum = bb_get_forum($forum_id); if (!$topic || !$forum) { bb_die(__('Your topic or forum caused all manner of confusion')); } bb_move_topic($topic_id, $forum_id); if (!($redirect = nxt_get_referer())) { $redirect = get_topic_link($topic_id); } bb_safe_redirect($redirect); exit;
/** * select default quota limit */ function default_quota_limit_select($select_name, $default_quota = 0) { global $lang; $sql = 'SELECT quota_limit_id, quota_desc FROM ' . BB_QUOTA_LIMITS . ' ORDER BY quota_limit ASC'; if (!($result = DB()->sql_query($sql))) { bb_die('Could not query quota limits table #2'); } $quota_select = '<select name="' . $select_name . '">'; $quota_name[0]['quota_limit_id'] = 0; $quota_name[0]['quota_desc'] = $lang['NO_QUOTA_LIMIT']; while ($row = DB()->sql_fetchrow($result)) { $quota_name[] = $row; } DB()->sql_freeresult($result); for ($i = 0; $i < sizeof($quota_name); $i++) { $selected = $quota_name[$i]['quota_limit_id'] == $default_quota ? ' selected="selected"' : ''; $quota_select .= '<option value="' . $quota_name[$i]['quota_limit_id'] . '"' . $selected . '>' . $quota_name[$i]['quota_desc'] . '</option>'; } $quota_select .= '</select>'; return $quota_select; }
/** * Build SQL statement from array (based on same method from phpBB3, idea from Ikonboard) * * Possible $query_type values: INSERT, INSERT_SELECT, MULTI_INSERT, UPDATE, SELECT */ function build_array($query_type, $input_ary, $data_already_escaped = false, $check_data_type_in_escape = true) { $fields = $values = $ary = $query = array(); $dont_escape = $data_already_escaped; $check_type = $check_data_type_in_escape; if (empty($input_ary) || !is_array($input_ary)) { $this->trigger_error(__FUNCTION__ . ' - wrong params: $input_ary'); } if ($query_type == 'INSERT') { foreach ($input_ary as $field => $val) { $fields[] = $field; $values[] = $this->escape($val, $check_type, $dont_escape); } $fields = join(', ', $fields); $values = join(', ', $values); $query = "({$fields})\nVALUES\n({$values})"; } else { if ($query_type == 'INSERT_SELECT') { foreach ($input_ary as $field => $val) { $fields[] = $field; $values[] = $this->escape($val, $check_type, $dont_escape); } $fields = join(', ', $fields); $values = join(', ', $values); $query = "({$fields})\nSELECT\n{$values}"; } else { if ($query_type == 'MULTI_INSERT') { foreach ($input_ary as $id => $sql_ary) { foreach ($sql_ary as $field => $val) { $values[] = $this->escape($val, $check_type, $dont_escape); } $ary[] = '(' . join(', ', $values) . ')'; $values = array(); } $fields = join(', ', array_keys($input_ary[0])); $values = join(",\n", $ary); $query = "({$fields})\nVALUES\n{$values}"; } else { if ($query_type == 'SELECT' || $query_type == 'UPDATE') { foreach ($input_ary as $field => $val) { $ary[] = "{$field} = " . $this->escape($val, $check_type, $dont_escape); } $glue = $query_type == 'SELECT' ? "\nAND " : ",\n"; $query = join($glue, $ary); } } } } if (!$query) { bb_die('<pre><b>' . __FUNCTION__ . "</b>: Wrong params for <b>{$query_type}</b> query type\n\n\$input_ary:\n\n" . htmlCHR(print_r($input_ary, true)) . '</pre>'); } return "\n" . $query . "\n"; }
<?php if (!empty($setmodules)) { if (IS_SUPER_ADMIN) { $module['TP']['TRACKER_CONFIG'] = basename(__FILE__); } return; } require './pagestart.php'; if (!IS_SUPER_ADMIN) { bb_die($lang['NOT_ADMIN']); } require INC_DIR . 'functions_admin_torrent.php'; $submit = isset($_POST['submit']); $confirmed = isset($_POST['confirm']); // All config names with default values $default_cfg_str = array('off_reason' => 'Tracker is disabled', 'browser_redirect_url' => 'http://demo.torrentpier.me/'); $default_cfg_bool = array('autoclean' => 1, 'off' => 0, 'compact_mode' => 1, 'update_dlstat' => 1, 'limit_active_tor' => 0, 'limit_concurrent_ips' => 0, 'retracker' => 1); $default_cfg_num = array('numwant' => 50, 'expire_factor' => 4, 'limit_seed_count' => 20, 'limit_leech_count' => 4, 'leech_expire_factor' => 60, 'limit_seed_ips' => 0, 'limit_leech_ips' => 0); // Set template vars set_tpl_vars($default_cfg_str, $tr_cfg); set_tpl_vars_lang($default_cfg_str); set_tpl_vars_bool($default_cfg_bool, $tr_cfg); set_tpl_vars_lang($default_cfg_bool); set_tpl_vars($default_cfg_num, $tr_cfg); set_tpl_vars_lang($default_cfg_num); $template->assign_vars(array('IGNORE_REPORTED_IP' => $bb_cfg['ignore_reported_ip'], 'ANNOUNCE_INTERVAL' => $bb_cfg['announce_interval'], 'PASSKEY_KEY' => $bb_cfg['passkey_key'], 'GOLD_SILVER_ENABLED' => $tr_cfg['gold_silver_enabled'], 'DISABLE_SUBMIT' => true, 'S_HIDDEN_FIELDS' => '', 'S_CONFIG_ACTION' => 'admin_bt_tracker_cfg.php')); print_page('admin_bt_tracker_cfg.tpl', 'admin');
/** * Delete Attachment(s) from post(s) (intern) */ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, $user_id = 0) { global $bb_cfg; // Generate Array, if it's not an array if ($post_id_array === 0 && $attach_id_array === 0 && $page === 0) { return; } if ($post_id_array === 0 && $attach_id_array !== 0) { $post_id_array = array(); if (!is_array($attach_id_array)) { if (strstr($attach_id_array, ', ')) { $attach_id_array = explode(', ', $attach_id_array); } else { if (strstr($attach_id_array, ',')) { $attach_id_array = explode(',', $attach_id_array); } else { $attach_id = intval($attach_id_array); $attach_id_array = array(); $attach_id_array[] = $attach_id; } } } // Get the post_ids to fill the array $p_id = 'post_id'; $sql = "SELECT {$p_id}\n\t\t\tFROM " . BB_ATTACHMENTS . ' WHERE attach_id IN (' . implode(', ', $attach_id_array) . ")\n\t\t\tGROUP BY {$p_id}"; if (!($result = DB()->sql_query($sql))) { bb_die('Could not select ids'); } $num_post_list = DB()->num_rows($result); if ($num_post_list == 0) { DB()->sql_freeresult($result); return; } while ($row = DB()->sql_fetchrow($result)) { $post_id_array[] = intval($row[$p_id]); } DB()->sql_freeresult($result); } if (!is_array($post_id_array)) { if (trim($post_id_array) == '') { return; } if (strstr($post_id_array, ', ')) { $post_id_array = explode(', ', $post_id_array); } else { if (strstr($post_id_array, ',')) { $post_id_array = explode(',', $post_id_array); } else { $post_id = intval($post_id_array); $post_id_array = array(); $post_id_array[] = $post_id; } } } if (!sizeof($post_id_array)) { return; } // First of all, determine the post id and attach_id if ($attach_id_array === 0) { $attach_id_array = array(); // Get the attach_ids to fill the array $whereclause = 'WHERE post_id IN (' . implode(', ', $post_id_array) . ')'; $sql = 'SELECT attach_id FROM ' . BB_ATTACHMENTS . " {$whereclause}\n\t\t\tGROUP BY attach_id"; if (!($result = DB()->sql_query($sql))) { bb_die('Could not select attachment id #1'); } $num_attach_list = DB()->num_rows($result); if ($num_attach_list == 0) { DB()->sql_freeresult($result); return; } while ($row = DB()->sql_fetchrow($result)) { $attach_id_array[] = (int) $row['attach_id']; } DB()->sql_freeresult($result); } if (!is_array($attach_id_array)) { if (strstr($attach_id_array, ', ')) { $attach_id_array = explode(', ', $attach_id_array); } else { if (strstr($attach_id_array, ',')) { $attach_id_array = explode(',', $attach_id_array); } else { $attach_id = intval($attach_id_array); $attach_id_array = array(); $attach_id_array[] = $attach_id; } } } if (!sizeof($attach_id_array)) { return; } $sql_id = 'post_id'; if (sizeof($post_id_array) && sizeof($attach_id_array)) { $sql = 'DELETE FROM ' . BB_ATTACHMENTS . ' WHERE attach_id IN (' . implode(', ', $attach_id_array) . ")\n\t\t\t\tAND {$sql_id} IN (" . implode(', ', $post_id_array) . ')'; if (!DB()->sql_query($sql)) { bb_die($lang['ERROR_DELETED_ATTACHMENTS']); } //bt if ($sql_id == 'post_id') { $sql = "SELECT topic_id FROM " . BB_BT_TORRENTS . " WHERE attach_id IN(" . implode(',', $attach_id_array) . ")"; if (!($result = DB()->sql_query($sql))) { bb_die($lang['ERROR_DELETED_ATTACHMENTS']); } $torrents_sql = array(); while ($row = DB()->sql_fetchrow($result)) { $torrents_sql[] = $row['topic_id']; } if ($torrents_sql = implode(',', $torrents_sql)) { // Remove peers from tracker $sql = "DELETE FROM " . BB_BT_TRACKER . "\n\t\t\t\t\tWHERE topic_id IN({$torrents_sql})"; if (!DB()->sql_query($sql)) { bb_die('Could not delete peers'); } } // Delete torrents $sql = "DELETE FROM " . BB_BT_TORRENTS . "\n\t\t\t\tWHERE attach_id IN(" . implode(',', $attach_id_array) . ")"; if (!DB()->sql_query($sql)) { bb_die($lang['ERROR_DELETED_ATTACHMENTS']); } } //bt end for ($i = 0; $i < sizeof($attach_id_array); $i++) { $sql = 'SELECT attach_id FROM ' . BB_ATTACHMENTS . ' WHERE attach_id = ' . (int) $attach_id_array[$i]; if (!($result = DB()->sql_query($sql))) { bb_die('Could not select Attachment id #2'); } $num_rows = DB()->num_rows($result); DB()->sql_freeresult($result); if ($num_rows == 0) { $sql = 'SELECT attach_id, physical_filename, thumbnail FROM ' . BB_ATTACHMENTS_DESC . ' WHERE attach_id = ' . (int) $attach_id_array[$i]; if (!($result = DB()->sql_query($sql))) { bb_die('Could not query attach description table'); } $num_rows = DB()->num_rows($result); if ($num_rows != 0) { $num_attach = $num_rows; $attachments = DB()->sql_fetchrowset($result); DB()->sql_freeresult($result); // delete attachments for ($j = 0; $j < $num_attach; $j++) { unlink_attach($attachments[$j]['physical_filename']); if (intval($attachments[$j]['thumbnail']) == 1) { unlink_attach($attachments[$j]['physical_filename'], MODE_THUMBNAIL); } $sql = 'DELETE FROM ' . BB_ATTACHMENTS_DESC . ' WHERE attach_id = ' . (int) $attachments[$j]['attach_id']; if (!DB()->sql_query($sql)) { bb_die($lang['ERROR_DELETED_ATTACHMENTS']); } } } else { DB()->sql_freeresult($result); } } } } // Now Sync the Topic/PM if (sizeof($post_id_array)) { $sql = 'SELECT topic_id FROM ' . BB_POSTS . ' WHERE post_id IN (' . implode(', ', $post_id_array) . ') GROUP BY topic_id'; if (!($result = DB()->sql_query($sql))) { bb_die('Could not select topic id'); } while ($row = DB()->sql_fetchrow($result)) { attachment_sync_topic($row['topic_id']); } DB()->sql_freeresult($result); } }
<?php require './bb-load.php'; bb_auth('logged_in'); if (!bb_is_user_logged_in()) { bb_die(__('You need to be logged in to add a tag.')); } $topic_id = (int) @$_POST['id']; $page = (int) @$_POST['page']; $tag = @$_POST['tag']; $tag = stripslashes($tag); bb_check_admin_referer('add-tag_' . $topic_id); $topic = get_topic($topic_id); if (!$topic) { bb_die(__('Topic not found.')); } if (bb_add_topic_tags($topic_id, $tag)) { wp_redirect(get_topic_link($topic_id, $page)); } else { bb_die(__('The tag was not added. Either the tag name was invalid or the topic is closed.')); } exit;
if ($_POST['mode'] == 'list') { if ($cron_action == 'run' && $jobs) { run_jobs($jobs); } else { if ($cron_action == 'delete' && $jobs) { delete_jobs($jobs); } else { if (($cron_action == 'disable' || $cron_action == 'enable') && $jobs) { toggle_active($jobs, $cron_action); } } } redirect('admin/' . basename(__FILE__) . '?mode=list'); } else { if (validate_cron_post($_POST) == 1) { if ($_POST['mode'] == 'edit') { update_cron_job($_POST); } else { if ($_POST['mode'] == 'add') { insert_cron_job($_POST); } else { bb_die('Mode error'); } } redirect('admin/' . basename(__FILE__) . '?mode=list'); } else { bb_die(validate_cron_post($_POST)); } } } print_page('admin_cron.tpl', 'admin');
} $dl_link_css = array(DL_STATUS_RELEASER => 'genmed', DL_STATUS_WILL => 'dlWill', DL_STATUS_DOWN => 'leechmed', DL_STATUS_COMPLETE => 'seedmed', DL_STATUS_CANCEL => 'dlCancel'); $dl_status_css = array(DL_STATUS_RELEASER => 'genmed', DL_STATUS_WILL => 'dlWill', DL_STATUS_DOWN => 'dlDown', DL_STATUS_COMPLETE => 'dlComplete', DL_STATUS_CANCEL => 'dlCancel'); // Exit if board is disabled via ON/OFF trigger or by admin if (($bb_cfg['board_disable'] || file_exists(BB_DISABLED)) && !defined('IN_ADMIN') && !defined('IN_AJAX') && !defined('IN_LOGIN')) { header('HTTP/1.0 503 Service Unavailable'); if ($bb_cfg['board_disable']) { // admin lock send_no_cache_headers(); bb_die('BOARD_DISABLE'); } else { if (file_exists(BB_DISABLED)) { // trigger lock cron_release_deadlock(); send_no_cache_headers(); bb_die('BOARD_DISABLE_CRON'); } } } // Cron functions function cron_release_deadlock() { if (file_exists(CRON_RUNNING)) { if (TIMENOW - filemtime(CRON_RUNNING) > 2400) { cron_enable_board(); cron_release_file_lock(); } } } function cron_release_file_lock() {
/** * Assign Variables and Definitions based on the fetched Attachments - internal * used by all displaying functions, the Data was collected before, it's only dependend on the template used. :) * before this function is usable, init_display_attachments have to be called for specific pages (pm, posting, review etc...) */ function display_attachments($post_id) { global $template, $upload_dir, $userdata, $allowed_extensions, $display_categories, $download_modes, $lang, $attachments, $upload_icons, $attach_config; $num_attachments = @sizeof($attachments['_' . $post_id]); if ($num_attachments == 0) { return; } $template->assign_block_vars('postrow.attach', array()); for ($i = 0; $i < $num_attachments; $i++) { // Some basic things... $filename = $upload_dir . '/' . basename($attachments['_' . $post_id][$i]['physical_filename']); $thumbnail_filename = $upload_dir . '/' . THUMB_DIR . '/t_' . basename($attachments['_' . $post_id][$i]['physical_filename']); $upload_image = ''; if ($attach_config['upload_img'] && empty($upload_icons[$attachments['_' . $post_id][$i]['extension']])) { $upload_image = '<img src="' . $attach_config['upload_img'] . '" alt="" border="0" />'; } else { if (trim($upload_icons[$attachments['_' . $post_id][$i]['extension']]) != '') { $upload_image = '<img src="' . $upload_icons[$attachments['_' . $post_id][$i]['extension']] . '" alt="" border="0" />'; } } $filesize = humn_size($attachments['_' . $post_id][$i]['filesize']); $display_name = htmlspecialchars($attachments['_' . $post_id][$i]['real_filename']); $comment = htmlspecialchars($attachments['_' . $post_id][$i]['comment']); $comment = str_replace("\n", '<br />', $comment); $denied = false; // Admin is allowed to view forbidden Attachments, but the error-message is displayed too to inform the Admin if (!in_array($attachments['_' . $post_id][$i]['extension'], $allowed_extensions)) { $denied = true; $template->assign_block_vars('postrow.attach.denyrow', array('L_DENIED' => sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachments['_' . $post_id][$i]['extension']))); } if (!$denied || IS_ADMIN) { // define category $image = FALSE; $thumbnail = FALSE; $link = FALSE; if (@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT && intval($attach_config['img_display_inlined'])) { if (intval($attach_config['img_link_width']) != 0 || intval($attach_config['img_link_height']) != 0) { list($width, $height) = image_getdimension($filename); if ($width == 0 && $height == 0) { $image = TRUE; } else { if ($width <= intval($attach_config['img_link_width']) && $height <= intval($attach_config['img_link_height'])) { $image = TRUE; } } } else { $image = TRUE; } } if (@intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT && $attachments['_' . $post_id][$i]['thumbnail'] == 1) { $thumbnail = TRUE; $image = FALSE; } if (!$image && !$thumbnail) { $link = TRUE; } if ($image) { // Images if ($attach_config['upload_dir'][0] == '/' || $attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':') { $img_source = BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id']; $download_link = TRUE; } else { $img_source = $filename; $download_link = FALSE; } $template->assign_block_vars('postrow.attach.cat_images', array('DOWNLOAD_NAME' => $display_name, 'S_UPLOAD_IMAGE' => $upload_image, 'IMG_SRC' => $img_source, 'FILESIZE' => $filesize, 'COMMENT' => $comment)); // Directly Viewed Image ... update the download count if (!$download_link) { $sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . ' SET download_count = download_count + 1 WHERE attach_id = ' . (int) $attachments['_' . $post_id][$i]['attach_id']; if (!DB()->sql_query($sql)) { bb_die('Could not update attachment download count'); } } } if ($thumbnail) { // Images, but display Thumbnail if ($attach_config['upload_dir'][0] == '/' || $attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':') { $thumb_source = BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'] . '&thumb=1'; } else { $thumb_source = $thumbnail_filename; } $template->assign_block_vars('postrow.attach.cat_thumb_images', array('DOWNLOAD_NAME' => $display_name, 'S_UPLOAD_IMAGE' => $upload_image, 'IMG_SRC' => BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'], 'IMG_THUMB_SRC' => $thumb_source, 'FILESIZE' => $filesize, 'COMMENT' => $comment)); } // bt if ($link && $attachments['_' . $post_id][$i]['extension'] === TORRENT_EXT) { include ATTACH_DIR . 'displaying_torrent.php'; } else { if ($link) { $target_blank = @intval($display_categories[$attachments['_' . $post_id][$i]['extension']]) == IMAGE_CAT ? 'target="_blank"' : ''; // display attachment $template->assign_block_vars('postrow.attach.attachrow', array('U_DOWNLOAD_LINK' => BB_ROOT . DOWNLOAD_URL . $attachments['_' . $post_id][$i]['attach_id'], 'S_UPLOAD_IMAGE' => $upload_image, 'DOWNLOAD_NAME' => $display_name, 'FILESIZE' => $filesize, 'COMMENT' => $comment, 'TARGET_BLANK' => $target_blank, 'DOWNLOAD_COUNT' => sprintf($lang['DOWNLOAD_NUMBER'], $attachments['_' . $post_id][$i]['download_count']))); } } } } }
$template->assign_vars(array('ROW_NUMBER' => $i + ($start + 1), 'GROUP_INFO' => true, 'PAGE_TITLE' => $lang['GROUP_CONTROL_PANEL'], 'GROUP_NAME' => htmlCHR($group_info['group_name']), 'GROUP_DESCRIPTION' => bbcode2html($group_info['group_description']), 'GROUP_SIGNATURE' => bbcode2html($group_info['group_signature']), 'GROUP_AVATAR' => get_avatar(GROUP_AVATAR_MASK . $group_id, $group_info['avatar_ext_id'], true), 'GROUP_DETAILS' => $group_details, 'GROUP_TIME' => !empty($group_info['group_time']) ? sprintf('%s <span class="posted_since">(%s)</span>', bb_date($group_info['group_time']), delta_time($group_info['group_time'])) : $lang['NONE'], 'MOD_USER' => profile_url($group_moderator), 'MOD_AVATAR' => $avatar, 'MOD_FROM' => $from, 'MOD_JOINED' => $joined, 'MOD_POSTS' => $posts, 'MOD_PM' => $pm, 'MOD_EMAIL' => $email, 'MOD_WWW' => $www, 'MOD_TIME' => !empty($group_info['mod_time']) ? bb_date($group_info['mod_time']) : $lang['NONE'], 'U_SEARCH_USER' => "search.php?mode=searchuser", 'U_SEARCH_RELEASES' => "tracker.php?srg={$group_id}", 'U_GROUP_RELEASES' => "group.php?view=releases&" . POST_GROUPS_URL . "={$group_id}", 'U_GROUP_MEMBERS' => "group.php?view=members&" . POST_GROUPS_URL . "={$group_id}", 'U_GROUP_CONFIG' => "group_edit.php?g={$group_id}", 'RELEASE_GROUP' => $group_info['release_group'] ? true : false, 'GROUP_TYPE' => $group_type, 'S_GROUP_OPEN_TYPE' => GROUP_OPEN, 'S_GROUP_CLOSED_TYPE' => GROUP_CLOSED, 'S_GROUP_HIDDEN_TYPE' => GROUP_HIDDEN, 'S_GROUP_OPEN_CHECKED' => $group_info['group_type'] == GROUP_OPEN ? ' checked="checked"' : '', 'S_GROUP_CLOSED_CHECKED' => $group_info['group_type'] == GROUP_CLOSED ? ' checked="checked"' : '', 'S_GROUP_HIDDEN_CHECKED' => $group_info['group_type'] == GROUP_HIDDEN ? ' checked="checked"' : '', 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_MODE_SELECT' => $select_sort_mode, 'S_ORDER_SELECT' => $select_sort_order, 'S_GROUP_ACTION' => "group.php?" . POST_GROUPS_URL . "={$group_id}")); switch ($view_mode) { case 'releases': // TODO Correct SQL to posts with attach and limit them, optimization if (!$group_info['release_group']) { set_die_append_msg(false, false, $group_id); bb_die($lang['NOT_A_RELEASE_GROUP']); } // Count releases for pagination $all_releases = DB()->fetch_rowset("\n\t\t\t\tSELECT p.topic_id, p.forum_id, p.poster_id, t.topic_title, t.topic_time, f.forum_name, u.username, u.avatar_ext_id, u.user_opt, u.user_rank\n\t\t\t\tFROM " . BB_POSTS . " p\n\t\t\t\tLEFT JOIN " . BB_TOPICS . " t ON(p.topic_id = t.topic_id)\n\t\t\t\tLEFT JOIN " . BB_FORUMS . " f ON(p.forum_id= f.forum_id)\n\t\t\t\tLEFT JOIN " . BB_USERS . " u ON(p.poster_id = u.user_id)\n\t\t\t\tWHERE p.poster_rg_id = {$group_id}\n\t\t\t\tORDER BY t.topic_time DESC\n\t\t\t\tLIMIT {$rel_limit}\n\t\t\t"); $count_releases = count($all_releases); generate_pagination(GROUP_URL . $group_id . "&view=releases", $count_releases, $per_page, $start); $sql = "\n\t\t\t\tSELECT p.topic_id, p.forum_id, p.poster_id, t.topic_title, t.topic_time, f.forum_name, u.username, u.avatar_ext_id, u.user_opt, u.user_rank\n\t\t\t\tFROM " . BB_POSTS . " p\n\t\t\t\tLEFT JOIN " . BB_TOPICS . " t ON(p.topic_id = t.topic_id)\n\t\t\t\tLEFT JOIN " . BB_FORUMS . " f ON(p.forum_id= f.forum_id)\n\t\t\t\tLEFT JOIN " . BB_USERS . " u ON(p.poster_id = u.user_id)\n\t\t\t\tWHERE p.poster_rg_id = {$group_id}\n\t\t\t\tORDER BY t.topic_time DESC\n\t\t\t\tLIMIT {$start}, {$per_page}\n\t\t\t"; if (!($releases = DB()->fetch_rowset($sql))) { set_die_append_msg(false, false, $group_id); bb_die($lang['NO_SEARCH_MATCH']); } foreach ($releases as $i => $release) { $row_class = !($i % 2) ? 'row1' : 'row2'; $template->assign_block_vars('releases', array('ROW_NUMBER' => $i + ($start + 1), 'ROW_CLASS' => $row_class, 'RELEASER' => profile_url(array('user_id' => $release['poster_id'], 'username' => $release['username'], 'user_rank' => $release['user_rank'])), 'AVATAR_IMG' => get_avatar($release['poster_id'], $release['avatar_ext_id'], !bf($release['user_opt'], 'user_opt', 'dis_avatar'), '', 50, 50), 'RELEASE_NAME' => sprintf('<a href="%s">%s</a>', TOPIC_URL . $release['topic_id'], htmlCHR($release['topic_title'])), 'RELEASE_TIME' => bb_date($release['topic_time']), 'RELEASE_FORUM' => sprintf('<a href="%s">%s</a>', FORUM_URL . $release['forum_id'], htmlCHR($release['forum_name'])))); } $template->assign_vars(array('RELEASES' => true)); break; case 'members': default: // Members $count_members = DB()->fetch_rowset("\n\t\t\t\tSELECT u.username, u.user_rank, u.user_id, u.user_opt, u.user_posts, u.user_regdate, u.user_from, u.user_website, u.user_email, ug.user_pending, ug.user_time\n\t\t\t\tFROM " . BB_USER_GROUP . " ug, " . BB_USERS . " u\n\t\t\t\tWHERE ug.group_id = {$group_id}\n\t\t\t\t\tAND ug.user_pending = 0\n\t\t\t\t\tAND ug.user_id <> " . $group_moderator['user_id'] . "\n\t\t\t\t\tAND u.user_id = ug.user_id\n\t\t\t\tORDER BY u.username\n\t\t\t"); $count_members = count($count_members); // Get user information for this group $modgroup_pending_count = 0; // Members
function check_name_dup($mode, $name, $die_on_error = true) { $name_sql = DB()->escape($name); if ($mode == 'cat') { $what_checked = 'category'; $sql = "SELECT cat_id FROM " . BB_CATEGORIES . " WHERE cat_title = '{$name_sql}'"; } else { $what_checked = 'forum'; $sql = "SELECT forum_id FROM " . BB_FORUMS . " WHERE forum_name = '{$name_sql}'"; } $name_is_dup = DB()->fetch_row($sql); if ($name_is_dup && $die_on_error) { bb_die('This ' . $what_checked . ' name taken, please choose something else'); } return $name_is_dup; }
<?php require_once './bb-load.php'; bb_repermalink(); // Temporary, refactor this! if (!$tag && $tag_name) { bb_die(__('Tag not found')); } if ($tag_name && $tag) { if ($topics = get_tagged_topics($tag->tag_id, $page)) { bb_cache_last_posts($topics); } bb_load_template('tag-single.php', array('tag', 'tag_name', 'topics'), $tag->tag_id); } else { bb_load_template('tags.php'); }
<?php if (!empty($setmodules)) { $module['GENERAL']['TERMS'] = basename(__FILE__); return; } require './pagestart.php'; require INC_DIR . 'bbcode.php'; if (isset($_POST['post']) && $bb_cfg['terms'] != $_POST['message']) { bb_update_config(array('terms' => $_POST['message'])); bb_die($lang['CONFIG_UPDATED']); } $template->assign_vars(array('S_ACTION' => 'admin_terms.php', 'EXT_LINK_NW' => $bb_cfg['ext_link_new_win'], 'MESSAGE' => $bb_cfg['terms'] ? $bb_cfg['terms'] : '', 'PREVIEW_HTML' => isset($_REQUEST['preview']) ? bbcode2html($_POST['message']) : '')); print_page('admin_terms.tpl', 'admin');
<?php require 'admin.php'; if (!bb_current_user_can('manage_tags')) { bb_die(__('You are not allowed to manage tags.')); } $tag_id = (int) $_POST['id']; $tag = stripslashes($_POST['tag']); bb_check_admin_referer('rename-tag_' . $tag_id); if (!($old_tag = bb_get_tag($tag_id))) { bb_die(__('Tag not found.')); } if ($tag = bb_rename_tag($tag_id, $tag)) { wp_redirect(bb_get_tag_link()); } else { bb_die(printf(__('There already exists a tag by that name or the name is invalid. <a href="%s">Try Again</a>'), wp_get_referer())); } exit;
bb_die('Could not query config information in admin_board'); } else { while ($row = DB()->sql_fetchrow($result)) { $config_name = $row['config_name']; $config_value = $row['config_value']; $default_config[$config_name] = $config_value; $new[$config_name] = isset($_POST[$config_name]) ? $_POST[$config_name] : $default_config[$config_name]; if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name]) { if ($config_name == 'seed_bonus_points' || $config_name == 'seed_bonus_release' || $config_name == 'bonus_upload' || $config_name == 'bonus_upload_price') { $new[$config_name] = serialize(str_replace(',', '.', $new[$config_name])); } bb_update_config(array($config_name => $new[$config_name])); } } if (isset($_POST['submit'])) { bb_die($lang['CONFIG_UPDATED'] . $return_links[$mode] . $return_links['index']); } } switch ($mode) { case 'config_mods': $template->assign_vars(array('S_CONFIG_ACTION' => 'admin_board.php?mode=config_mods', 'CONFIG_MODS' => true, 'MAGNET_LINKS_ENABLED' => $new['magnet_links_enabled'], 'GENDER' => $new['gender'], 'CALLSEED' => $new['callseed'], 'TOR_STATS' => $new['tor_stats'], 'SHOW_LATEST_NEWS' => $new['show_latest_news'], 'MAX_NEWS_TITLE' => $new['max_news_title'], 'LATEST_NEWS_COUNT' => $new['latest_news_count'], 'LATEST_NEWS_FORUM_ID' => $new['latest_news_forum_id'], 'SHOW_NETWORK_NEWS' => $new['show_network_news'], 'MAX_NET_TITLE' => $new['max_net_title'], 'NETWORK_NEWS_COUNT' => $new['network_news_count'], 'NETWORK_NEWS_FORUM_ID' => $new['network_news_forum_id'], 'WHOIS_INFO' => $new['whois_info'], 'SHOW_MOD_INDEX' => $new['show_mod_index'], 'BIRTHDAY_ENABLED' => $new['birthday_enabled'], 'BIRTHDAY_MAX_AGE' => $new['birthday_max_age'], 'BIRTHDAY_MIN_AGE' => $new['birthday_min_age'], 'BIRTHDAY_CHECK_DAY' => $new['birthday_check_day'], 'PREMOD' => $new['premod'], 'TOR_COMMENT' => $new['tor_comment'], 'NEW_TPLS' => $new['new_tpls'], 'SEED_BONUS_ENABLED' => $new['seed_bonus_enabled'], 'SEED_BONUS_TOR_SIZE' => $new['seed_bonus_tor_size'], 'SEED_BONUS_USER_REGDATE' => $new['seed_bonus_user_regdate'])); if ($new['seed_bonus_points'] && $new['seed_bonus_release']) { $seed_bonus = unserialize($new['seed_bonus_points']); $seed_release = unserialize($new['seed_bonus_release']); foreach ($seed_bonus as $i => $row) { if (!$row || !$seed_release[$i]) { continue; } $template->assign_block_vars('seed_bonus', array('RELEASE' => $seed_release[$i], 'POINTS' => $row)); } }