[ Index ] |
PHP Cross Reference of MyBB |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * MyBB 1.6 4 * Copyright 2010 MyBB Group, All Rights Reserved 5 * 6 * Website: http://mybb.com 7 * License: http://mybb.com/about/license 8 * 9 * $Id: spiders.php 5832 2012-05-24 08:08:19Z Tomm $ 10 */ 11 12 // Disallow direct access to this file for security reasons 13 if(!defined("IN_MYBB")) 14 { 15 die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined."); 16 } 17 18 $page->add_breadcrumb_item($lang->spiders_bots, "index.php?module=config-spiders"); 19 20 $plugins->run_hooks("admin_config_spiders_begin"); 21 22 if($mybb->input['action'] == "add") 23 { 24 $plugins->run_hooks("admin_config_spiders_add"); 25 26 if($mybb->request_method == "post") 27 { 28 if(!trim($mybb->input['name'])) 29 { 30 $errors[] = $lang->error_missing_name; 31 } 32 33 if(!trim($mybb->input['useragent'])) 34 { 35 $errors[] = $lang->error_missing_agent; 36 } 37 38 if(!$errors) 39 { 40 $new_spider = array( 41 "name" => $db->escape_string($mybb->input['name']), 42 "theme" => intval($mybb->input['theme']), 43 "language" => $db->escape_string($mybb->input['language']), 44 "usergroup" => intval($mybb->input['usergroup']), 45 "useragent" => $db->escape_string($mybb->input['useragent']), 46 "lastvisit" => 0 47 ); 48 $sid = $db->insert_query("spiders", $new_spider); 49 50 $cache->update_spiders(); 51 52 $plugins->run_hooks("admin_config_spiders_add_commit"); 53 54 // Log admin action 55 log_admin_action($sid, $mybb->input['name']); 56 57 flash_message($lang->success_bot_created, 'success'); 58 admin_redirect("index.php?module=config-spiders"); 59 } 60 } 61 62 $page->add_breadcrumb_item($lang->add_new_bot); 63 $page->output_header($lang->spiders_bots." - ".$lang->add_new_bot); 64 65 $sub_tabs['spiders'] = array( 66 'title' => $lang->spiders_bots, 67 'link' => "index.php?module=config-spiders", 68 ); 69 $sub_tabs['add_spider'] = array( 70 'title' => $lang->add_new_bot, 71 'link' => "index.php?module=config-spiders&action=add", 72 'description' => $lang->add_new_bot_desc 73 ); 74 75 $page->output_nav_tabs($sub_tabs, "add_spider"); 76 77 $form = new Form("index.php?module=config-spiders&action=add", "post"); 78 79 if($errors) 80 { 81 $page->output_inline_error($errors); 82 } 83 84 $form_container = new FormContainer($lang->add_new_bot); 85 $form_container->output_row($lang->name." <em>*</em>", $lang->name_desc, $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name'); 86 $form_container->output_row($lang->user_agent." <em>*</em>", $lang->user_agent_desc, $form->generate_text_box('useragent', $mybb->input['useragent'], array('id' => 'useragent')), 'useragent'); 87 88 $languages = array('' => $lang->use_board_default); 89 $languages = array_merge($languages, $lang->get_languages()); 90 $form_container->output_row($lang->language_str, $lang->language_desc, $form->generate_select_box("language", $languages, $mybb->input['language'], array("id" => "language")), 'language'); 91 92 $form_container->output_row($lang->theme, $lang->theme_desc, build_theme_select("theme", $mybb->input['theme'], 0, "", true)); 93 94 $query = $db->simple_select("usergroups", "*", "", array("order_by" => "title", "order_dir" => "asc")); 95 while($usergroup = $db->fetch_array($query)) 96 { 97 $usergroups[$usergroup['gid']] = $usergroup['title']; 98 } 99 if(!$mybb->input['usergroup']) 100 { 101 $mybb->input['usergroup'] = 1; 102 } 103 $form_container->output_row($lang->user_group, $lang->user_group_desc, $form->generate_select_box("usergroup", $usergroups, $mybb->input['usergroup'], array("id" => "usergroup")), 'usergroup'); 104 105 106 $form_container->end(); 107 $buttons[] = $form->generate_submit_button($lang->save_bot); 108 $form->output_submit_wrapper($buttons); 109 $form->end(); 110 111 $page->output_footer(); 112 } 113 114 if($mybb->input['action'] == "delete") 115 { 116 $plugins->run_hooks("admin_config_spiders_delete"); 117 118 $query = $db->simple_select("spiders", "*", "sid='".intval($mybb->input['sid'])."'"); 119 $spider = $db->fetch_array($query); 120 121 // Does the spider not exist? 122 if(!$spider['sid']) 123 { 124 flash_message($lang->error_invalid_bot, 'error'); 125 admin_redirect("index.php?module=config-spiders"); 126 } 127 128 // User clicked no 129 if($mybb->input['no']) 130 { 131 admin_redirect("index.php?module=config-spiders"); 132 } 133 134 if($mybb->request_method == "post") 135 { 136 // Delete the spider 137 $db->delete_query("spiders", "sid='{$spider['sid']}'"); 138 139 $cache->update_spiders(); 140 141 $plugins->run_hooks("admin_config_spiders_delete_commit"); 142 143 // Log admin action 144 log_admin_action($spider['sid'], $spider['name']); 145 146 flash_message($lang->success_bot_deleted, 'success'); 147 admin_redirect("index.php?module=config-spiders"); 148 } 149 else 150 { 151 $page->output_confirm_action("index.php?module=config-spiders&action=delete&sid={$spider['sid']}", $lang->confirm_bot_deletion); 152 } 153 } 154 155 if($mybb->input['action'] == "edit") 156 { 157 $plugins->run_hooks("admin_config_spiders_edit"); 158 159 $query = $db->simple_select("spiders", "*", "sid='".intval($mybb->input['sid'])."'"); 160 $spider = $db->fetch_array($query); 161 162 // Does the spider not exist? 163 if(!$spider['sid']) 164 { 165 flash_message($lang->error_invalid_bot, 'error'); 166 admin_redirect("index.php?module=config-spiders"); 167 } 168 169 if($mybb->request_method == "post") 170 { 171 if(!trim($mybb->input['name'])) 172 { 173 $errors[] = $lang->error_missing_name; 174 } 175 176 if(!trim($mybb->input['useragent'])) 177 { 178 $errors[] = $lang->error_missing_agent; 179 } 180 181 if(!$errors) 182 { 183 $updated_spider = array( 184 "name" => $db->escape_string($mybb->input['name']), 185 "theme" => intval($mybb->input['theme']), 186 "language" => $db->escape_string($mybb->input['language']), 187 "usergroup" => intval($mybb->input['usergroup']), 188 "useragent" => $db->escape_string($mybb->input['useragent']) 189 ); 190 $db->update_query("spiders", $updated_spider, "sid='{$spider['sid']}'"); 191 192 $cache->update_spiders(); 193 194 $plugins->run_hooks("admin_config_spiders_edit_commit"); 195 196 // Log admin action 197 log_admin_action($spider['sid'], $mybb->input['name']); 198 199 flash_message($lang->success_bot_updated, 'success'); 200 admin_redirect("index.php?module=config-spiders"); 201 } 202 } 203 204 $page->add_breadcrumb_item($lang->edit_bot); 205 $page->output_header($lang->spiders_bots." - ".$lang->edit_bot); 206 207 $sub_tabs['edit_spider'] = array( 208 'title' => $lang->edit_bot, 209 'link' => "index.php?module=config-spiders&action=edit&sid={$spider['sid']}", 210 'description' => $lang->edit_bot_desc 211 ); 212 213 $page->output_nav_tabs($sub_tabs, "edit_spider"); 214 215 $form = new Form("index.php?module=config-spiders&action=edit&sid={$spider['sid']}", "post"); 216 217 if($errors) 218 { 219 $page->output_inline_error($errors); 220 $spider_data = $mybb->input; 221 } 222 else 223 { 224 $spider_data = $spider; 225 } 226 227 $form_container = new FormContainer($lang->edit_bot); 228 $form_container->output_row($lang->name." <em>*</em>", $lang->name_desc, $form->generate_text_box('name', $spider_data['name'], array('id' => 'name')), 'name'); 229 $form_container->output_row($lang->user_agent." <em>*</em>", $lang->user_agent_desc, $form->generate_text_box('useragent', $spider_data['useragent'], array('id' => 'useragent')), 'useragent'); 230 231 $languages = array('' => $lang->use_board_default); 232 $languages = array_merge($languages, $lang->get_languages()); 233 $form_container->output_row($lang->language_str, $lang->language_desc, $form->generate_select_box("language", $languages, $spider_data['language'], array("id" => "language")), 'language'); 234 235 $form_container->output_row($lang->theme, $lang->theme_desc, build_theme_select("theme", $spider_data['theme'], 0, "", true)); 236 237 $query = $db->simple_select("usergroups", "*", "", array("order_by" => "title", "order_dir" => "asc")); 238 while($usergroup = $db->fetch_array($query)) 239 { 240 $usergroups[$usergroup['gid']] = $usergroup['title']; 241 } 242 if(!$spider_data['usergroup']) 243 { 244 $spider_data['usergroup'] = 1; 245 } 246 $form_container->output_row($lang->user_group, $lang->user_group_desc, $form->generate_select_box("usergroup", $usergroups, $spider_data['usergroup'], array("id" => "usergroup")), 'usergroup'); 247 248 $form_container->end(); 249 $buttons[] = $form->generate_submit_button($lang->save_bot); 250 $form->output_submit_wrapper($buttons); 251 $form->end(); 252 253 $page->output_footer(); 254 } 255 256 if(!$mybb->input['action']) 257 { 258 $plugins->run_hooks("admin_config_spiders_start"); 259 260 $page->output_header($lang->spiders_bots); 261 262 $sub_tabs['spiders'] = array( 263 'title' => $lang->spiders_bots, 264 'link' => "index.php?module=config-spiders", 265 'description' => $lang->spiders_bots_desc 266 ); 267 $sub_tabs['add_spider'] = array( 268 'title' => $lang->add_new_bot, 269 'link' => "index.php?module=config-spiders&action=add" 270 ); 271 272 $page->output_nav_tabs($sub_tabs, "spiders"); 273 274 $table = new Table; 275 $table->construct_header($lang->bot); 276 $table->construct_header($lang->last_visit, array("class" => "align_center", "width" => 200)); 277 $table->construct_header($lang->controls, array("class" => "align_center", "width" => 150, "colspan" => 2)); 278 279 $query = $db->simple_select("spiders", "*", "", array("order_by" => "lastvisit", "order_dir" => "desc")); 280 while($spider = $db->fetch_array($query)) 281 { 282 $spider['name'] = htmlspecialchars_uni($spider['name']); 283 if($spider['lastvisit']) 284 { 285 $lastvisit = my_date($mybb->settings['dateformat'], $spider['lastvisit']).", ".my_date($mybb->settings['timeformat'], $spider['lastvisit']); 286 } 287 else 288 { 289 $lastvisit = $lang->never; 290 } 291 $table->construct_cell("<a href=\"index.php?module=config-spiders&action=edit&sid={$spider['sid']}\"><strong>{$spider['name']}</strong></a>"); 292 $table->construct_cell($lastvisit, array("class" => "align_center", "width" => 200)); 293 $table->construct_cell("<a href=\"index.php?module=config-spiders&action=edit&sid={$spider['sid']}\">{$lang->edit}</a>", array("class" => "align_center", "width" => 75)); 294 $table->construct_cell("<a href=\"index.php?module=config-spiders&action=delete&sid={$spider['sid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_bot_deletion}');\">{$lang->delete}</a>", array("class" => "align_center", "width" => 75)); 295 $table->construct_row(); 296 } 297 298 if($table->num_rows() == 0) 299 { 300 $table->construct_cell($lang->no_bots, array("colspan" => 4)); 301 $table->construct_row(); 302 } 303 304 $table->output($lang->spiders_bots); 305 306 $page->output_footer(); 307 } 308 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Oct 8 19:19:50 2013 | Cross-referenced by PHPXref 0.7.1 |