[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

/admin/modules/config/ -> smilies.php (source)

   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: smilies.php 5676 2011-11-29 12:10: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->smilies, "index.php?module=config-smilies");
  19  
  20  $plugins->run_hooks("admin_config_smilies_begin");
  21  
  22  if($mybb->input['action'] == "add")
  23  {
  24      $plugins->run_hooks("admin_config_smilies_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['find']))
  34          {
  35              $errors[] = $lang->error_missing_text_replacement;
  36          }
  37  
  38          if(!trim($mybb->input['image']))
  39          {
  40              $errors[] = $lang->error_missing_path;
  41          }
  42  
  43          if(!trim($mybb->input['disporder']))
  44          {
  45              $errors[] = $lang->error_missing_order;
  46          }
  47          
  48          if(!$errors)
  49          {
  50              $new_smilie = array(
  51                  "name" => $db->escape_string($mybb->input['name']),
  52                  "find" => $db->escape_string($mybb->input['find']),
  53                  "image" => $db->escape_string($mybb->input['image']),
  54                  "disporder" => intval($mybb->input['disporder']),
  55                  "showclickable" => $db->escape_string($mybb->input['showclickable'])
  56              );
  57              
  58              $sid = $db->insert_query("smilies", $new_smilie);
  59  
  60              $cache->update_smilies();
  61              
  62              $plugins->run_hooks("admin_config_smilies_add_commit");
  63  
  64              // Log admin action
  65              log_admin_action($sid, $mybb->input['name']);
  66              
  67              flash_message($lang->success_smilie_added, 'success');
  68              admin_redirect("index.php?module=config-smilies");
  69          }
  70      }
  71      
  72      $page->add_breadcrumb_item($lang->add_smilie);
  73      $page->output_header($lang->smilies." - ".$lang->add_smilie);
  74      
  75      $sub_tabs['manage_smilies'] = array(
  76          'title' => $lang->manage_smilies,
  77          'link' => "index.php?module=config-smilies",
  78      );
  79      $sub_tabs['add_smilie'] = array(
  80          'title' => $lang->add_smilie,
  81          'link' => "index.php?module=config-smilies&amp;action=add",
  82          'description' => $lang->add_smilie_desc
  83      );
  84      $sub_tabs['add_multiple_smilies'] = array(
  85          'title' => $lang->add_multiple_smilies,
  86          'link' => "index.php?module=config-smilies&amp;action=add_multiple",
  87      );
  88      $sub_tabs['mass_edit'] = array(
  89          'title' => $lang->mass_edit,
  90          'link' => "index.php?module=config-smilies&amp;action=mass_edit"
  91      );
  92      
  93      $page->output_nav_tabs($sub_tabs, 'add_smilie');
  94      $form = new Form("index.php?module=config-smilies&amp;action=add", "post", "add");
  95      
  96      if($errors)
  97      {
  98          $page->output_inline_error($errors);
  99      }
 100      else
 101      {
 102          $mybb->input['image'] = 'images/smilies/';
 103          $mybb->input['showclickable'] = 1;
 104      }
 105      
 106      if(!$mybb->input['disporder'])
 107      {
 108          $query = $db->simple_select("smilies", "max(disporder) as dispordermax");
 109          $mybb->input['disporder'] = $db->fetch_field($query, "dispordermax")+1;
 110      }
 111      
 112      $form_container = new FormContainer($lang->add_smilie);
 113      $form_container->output_row($lang->name." <em>*</em>", "", $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
 114      $form_container->output_row($lang->text_replace." <em>*</em>", "", $form->generate_text_box('find', $mybb->input['find'], array('id' => 'find')), 'find');
 115      $form_container->output_row($lang->image_path." <em>*</em>", $lang->image_path_desc, $form->generate_text_box('image', $mybb->input['image'], array('id' => 'image')), 'image');
 116      $form_container->output_row($lang->display_order." <em>*</em>", $lang->display_order_desc, $form->generate_text_box('disporder', $mybb->input['disporder'], array('id' => 'disporder')), 'disporder');
 117      $form_container->output_row($lang->show_clickable." <em>*</em>", $lang->show_clickable_desc, $form->generate_yes_no_radio('showclickable', $mybb->input['showclickable']));
 118      $form_container->end();
 119  
 120      $buttons[] = $form->generate_submit_button($lang->save_smilie);
 121  
 122      $form->output_submit_wrapper($buttons);
 123      $form->end();
 124  
 125      $page->output_footer();
 126  }
 127  
 128  if($mybb->input['action'] == "edit")
 129  {
 130      $plugins->run_hooks("admin_config_smilies_edit");
 131      
 132      $query = $db->simple_select("smilies", "*", "sid='".intval($mybb->input['sid'])."'");
 133      $smilie = $db->fetch_array($query);
 134  
 135      // Does the smilie not exist?
 136      if(!$smilie['sid'])
 137      {
 138          flash_message($lang->error_invalid_smilie, 'error');
 139          admin_redirect("index.php?module=config-smilies");
 140      }
 141  
 142      if($mybb->request_method == "post")
 143      {
 144          if(!trim($mybb->input['name']))
 145          {
 146              $errors[] = $lang->error_missing_name;
 147          }
 148  
 149          if(!trim($mybb->input['find']))
 150          {
 151              $errors[] = $lang->error_missing_text_replacement;
 152          }
 153  
 154          if(!trim($mybb->input['image']))
 155          {
 156              $errors[] = $lang->error_missing_path;
 157          }
 158  
 159          if(!isset($mybb->input['disporder']))
 160          {
 161              $errors[] = $lang->error_missing_order;
 162          }
 163          
 164          if(!$errors)
 165          {
 166              $updated_smilie = array(
 167                  "name" => $db->escape_string($mybb->input['name']),
 168                  "find" => $db->escape_string($mybb->input['find']),
 169                  "image" => $db->escape_string($mybb->input['image']),
 170                  "disporder" => intval($mybb->input['disporder']),
 171                  "showclickable" => $db->escape_string($mybb->input['showclickable'])
 172              );
 173              
 174              $db->update_query("smilies", $updated_smilie, "sid = '".intval($mybb->input['sid'])."'");
 175              
 176              $cache->update_smilies();
 177              
 178              $plugins->run_hooks("admin_config_smilies_edit_commit");
 179  
 180              // Log admin action
 181              log_admin_action($smilie['sid'], $mybb->input['name']);
 182  
 183              flash_message($lang->success_smilie_updated, 'success');
 184              admin_redirect("index.php?module=config-smilies");
 185          }
 186      }
 187      
 188      $page->add_breadcrumb_item($lang->edit_smilie);
 189      $page->output_header($lang->smilies." - ".$lang->edit_smilie);
 190      
 191      $sub_tabs['edit_smilie'] = array(
 192          'title' => $lang->edit_smilie,
 193          'link' => "index.php?module=config-smilies&amp;action=edit",
 194          'description' => $lang->edit_smilie_desc
 195      );
 196      $sub_tabs['mass_edit'] = array(
 197          'title' => $lang->mass_edit,
 198          'link' => "index.php?module=config-smilies&amp;action=mass_edit",
 199      );
 200      
 201      $page->output_nav_tabs($sub_tabs, 'edit_smilie');
 202      $form = new Form("index.php?module=config-smilies&amp;action=edit", "post", "edit");
 203      
 204      echo $form->generate_hidden_field("sid", $smilie['sid']);
 205      
 206      if($errors)
 207      {
 208          $page->output_inline_error($errors);
 209      }
 210      else
 211      {
 212          $mybb->input = $smilie;
 213      }
 214  
 215      $form_container = new FormContainer($lang->edit_smilie);
 216      $form_container->output_row($lang->name." <em>*</em>", "", $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
 217      $form_container->output_row($lang->text_replace." <em>*</em>", "", $form->generate_text_box('find', $mybb->input['find'], array('id' => 'find')), 'find');
 218      $form_container->output_row($lang->image_path." <em>*</em>", $lang->image_path_desc, $form->generate_text_box('image', $mybb->input['image'], array('id' => 'image')), 'image');
 219      $form_container->output_row($lang->display_order." <em>*</em>", $lang->display_order_desc, $form->generate_text_box('disporder', $mybb->input['disporder'], array('id' => 'disporder')), 'disporder');
 220      $form_container->output_row($lang->show_clickable." <em>*</em>", $lang->show_clickable_desc, $form->generate_yes_no_radio('showclickable', $mybb->input['showclickable']));
 221      $form_container->end();
 222  
 223      $buttons[] = $form->generate_submit_button($lang->save_smilie);
 224      $buttons[] = $form->generate_reset_button($lang->reset);
 225  
 226      $form->output_submit_wrapper($buttons);
 227      $form->end();
 228  
 229      $page->output_footer();
 230  }
 231  
 232  if($mybb->input['action'] == "delete")
 233  {
 234      $plugins->run_hooks("admin_config_smilies_delete");
 235      
 236      $query = $db->simple_select("smilies", "*", "sid='".intval($mybb->input['sid'])."'");
 237      $smilie = $db->fetch_array($query);
 238  
 239      // Does the smilie not exist?
 240      if(!$smilie['sid'])
 241      {
 242          flash_message($lang->error_invalid_smilie, 'error');
 243          admin_redirect("index.php?module=config-smilies");
 244      }
 245  
 246      // User clicked no
 247      if($mybb->input['no'])
 248      {
 249          admin_redirect("index.php?module=config-smilies");
 250      }
 251  
 252      if($mybb->request_method == "post")
 253      {
 254          // Delete the smilie
 255          $db->delete_query("smilies", "sid='{$smilie['sid']}'");
 256  
 257          $cache->update_smilies();
 258          
 259          $plugins->run_hooks("admin_config_smilies_delete_commit");
 260  
 261          // Log admin action
 262          log_admin_action($smilie['sid'], $smilie['name']);
 263  
 264          flash_message($lang->success_smilie_updated, 'success');
 265          admin_redirect("index.php?module=config-smilies");
 266      }
 267      else
 268      {
 269          $page->output_confirm_action("index.php?module=config-smilies&amp;action=delete&amp;sid={$smilie['sid']}", $lang->confirm_smilie_deletion);
 270      }}
 271  
 272  if($mybb->input['action'] == "add_multiple")
 273  {
 274      $plugins->run_hooks("admin_config_smilies_add_multiple");
 275      
 276      if($mybb->request_method == "post")
 277      {
 278          if($mybb->input['step'] == 1)
 279          {
 280              $plugins->run_hooks("admin_config_smilies_add_multiple_step1");
 281              
 282              if(!trim($mybb->input['pathfolder']))
 283              {
 284                  $errors[] = $lang->error_missing_path_multiple;
 285              }
 286              
 287              $path = $mybb->input['pathfolder'];
 288              $dir = @opendir(MYBB_ROOT.$path);
 289              
 290              if(!$dir)
 291              {
 292                  $errors[] = $lang->error_invalid_path;
 293              }
 294              
 295              if($path && !is_array($errors))
 296              {
 297                  if(substr($path, -1, 1) !== "/")
 298                  {
 299                      $path .= "/";
 300                  }
 301                  
 302                  $query = $db->simple_select("smilies");
 303                  while($smilie = $db->fetch_array($query))
 304                  {
 305                      $asmilies[$smilie['image']] = 1;
 306                  }
 307                  
 308                  while($file = readdir($dir))
 309                  {
 310                      if($file != ".." && $file != ".")
 311                      {
 312                          $ext = get_extension($file);
 313                          if($ext == "gif" || $ext == "jpg" || $ext == "jpeg" || $ext == "png" || $ext == "bmp")
 314                          {
 315                              if(!$asmilies[$path.$file])
 316                              {
 317                                  $smilies[] = $file;
 318                              }
 319                          }
 320                      }
 321                  }
 322                  closedir($dir);
 323                  
 324                  if(count($smilies) == 0)
 325                  {
 326                      $errors[] = $lang->error_no_smilies;
 327                  }
 328              }
 329              
 330              if(!$errors)
 331              {
 332                  $page->add_breadcrumb_item($lang->add_multiple_smilies);
 333                  $page->output_header($lang->smilies." - ".$lang->add_multiple_smilies);
 334                  
 335                  $sub_tabs['manage_smilies'] = array(
 336                      'title' => $lang->manage_smilies,
 337                      'link' => "index.php?module=config-smilies",
 338                  );
 339                  $sub_tabs['add_smilie'] = array(
 340                      'title' => $lang->add_smilie,
 341                      'link' => "index.php?module=config-smilies&amp;action=add"
 342                  );
 343                  $sub_tabs['add_multiple_smilies'] = array(
 344                      'title' => $lang->add_multiple_smilies,
 345                      'link' => "index.php?module=config-smilies&amp;action=add_multiple",
 346                      'description' => $lang->add_multiple_smilies_desc
 347                  );
 348                  $sub_tabs['mass_edit'] = array(
 349                      'title' => $lang->mass_edit,
 350                      'link' => "index.php?module=config-smilies&amp;action=mass_edit"
 351                  );
 352                  
 353                  $page->output_nav_tabs($sub_tabs, 'add_multiple_smilies');
 354                  $form = new Form("index.php?module=config-smilies&amp;action=add_multiple", "post", "add_multiple");
 355                  echo $form->generate_hidden_field("step", "2");
 356                  echo $form->generate_hidden_field("pathfolder", $path);
 357                  
 358                  $form_container = new FormContainer($lang->add_multiple_smilies);
 359                  $form_container->output_row_header($lang->image, array("class" => "align_center", 'width' => '10%'));
 360                  $form_container->output_row_header($lang->name);
 361                  $form_container->output_row_header($lang->text_replace, array('width' => '20%'));
 362                  $form_container->output_row_header($lang->include, array("class" => "align_center", 'width' => '5%'));            
 363          
 364                  foreach($smilies as $key => $file)
 365                  {
 366                      $ext = get_extension($file);
 367                      $find = str_replace(".".$ext, "", $file);
 368                      $name = ucfirst($find);
 369                  
 370                      $form_container->output_cell("<img src=\"../".$path.$file."\" alt=\"\" /><br /><small>{$file}</small>", array("class" => "align_center", "width" => 1));
 371                      $form_container->output_cell($form->generate_text_box("name[{$file}]", $name, array('id' => 'name', 'style' => 'width: 98%')));
 372                      $form_container->output_cell($form->generate_text_box("find[{$file}]", ":".$find.":", array('id' => 'find', 'style' => 'width: 95%')));
 373                      $form_container->output_cell($form->generate_check_box("include[{$file}]", 1, "", array('checked' => 1)), array("class" => "align_center"));
 374                      $form_container->construct_row();
 375                  }
 376                  
 377                  if($form_container->num_rows() == 0)
 378                  {
 379                      flash_message($lang->error_no_images, 'error');
 380                      admin_redirect("index.php?module=config-smilies&action=add_multiple");
 381                  }
 382                  
 383                  $form_container->end();
 384                  
 385                  $buttons[] = $form->generate_submit_button($lang->save_smilies);
 386              
 387                  $form->output_submit_wrapper($buttons);
 388                  $form->end();
 389                  
 390                  $page->output_footer();
 391                  exit;
 392              }
 393          }
 394          else
 395          {
 396              $plugins->run_hooks("admin_config_smilies_add_multiple_step2");
 397              
 398              $path = $mybb->input['pathfolder'];
 399              reset($mybb->input['include']);
 400              $find = $mybb->input['find'];
 401              $name = $mybb->input['name'];
 402              
 403              if(empty($mybb->input['include']))
 404              {
 405                  flash_message($lang->error_none_included, 'error');
 406                  admin_redirect("index.php?module=config-smilies&action=add_multiple");
 407              }
 408              
 409              foreach($mybb->input['include'] as $image => $insert)
 410              {
 411                  if($insert)
 412                  {
 413                      $new_smilie = array(
 414                          "name" => $db->escape_string($name[$image]),
 415                          "find" => $db->escape_string($find[$image]),
 416                          "image" => $db->escape_string($path.$image),
 417                          "showclickable" => 1
 418                      );
 419                      $db->insert_query("smilies", $new_smilie);
 420                  }
 421              }
 422  
 423              $cache->update_smilies();
 424              
 425              $plugins->run_hooks("admin_config_smilies_add_multiple_commit");
 426  
 427              // Log admin action
 428              log_admin_action();
 429              
 430              flash_message($lang->success_multiple_smilies_added, 'success');
 431              admin_redirect("index.php?module=config-smilies");
 432          }
 433      }
 434      
 435      $page->add_breadcrumb_item($lang->add_multiple_smilies);
 436      $page->output_header($lang->smilies." - ".$lang->add_multiple_smilies);
 437      
 438      $sub_tabs['manage_smilies'] = array(
 439          'title' => $lang->manage_smilies,
 440          'link' => "index.php?module=config-smilies",
 441      );
 442      $sub_tabs['add_smilie'] = array(
 443          'title' => $lang->add_smilie,
 444          'link' => "index.php?module=config-smilies&amp;action=add"
 445      );
 446      $sub_tabs['add_multiple_smilies'] = array(
 447          'title' => $lang->add_multiple_smilies,
 448          'link' => "index.php?module=config-smilies&amp;action=add_multiple",
 449          'description' => $lang->add_multiple_smilies_desc
 450      );
 451      $sub_tabs['mass_edit'] = array(
 452          'title' => $lang->mass_edit,
 453          'link' => "index.php?module=config-smilies&amp;action=mass_edit"
 454      );
 455      
 456      $page->output_nav_tabs($sub_tabs, 'add_multiple_smilies');
 457      $form = new Form("index.php?module=config-smilies&amp;action=add_multiple", "post", "add_multiple");
 458      echo $form->generate_hidden_field("step", "1");
 459      
 460      if($errors)
 461      {
 462          $page->output_inline_error($errors);
 463      }
 464  
 465      $form_container = new FormContainer($lang->add_multiple_smilies);
 466      $form_container->output_row($lang->path_to_images, $lang->path_to_images_desc, $form->generate_text_box('pathfolder', $mybb->input['pathfolder'], array('id' => 'pathfolder')), 'pathfolder');
 467      $form_container->end();
 468  
 469      $buttons[] = $form->generate_submit_button($lang->show_smilies);
 470  
 471      $form->output_submit_wrapper($buttons);
 472      $form->end();
 473  
 474      $page->output_footer();
 475  }
 476  
 477  if($mybb->input['action'] == "mass_edit")
 478  {
 479      $plugins->run_hooks("admin_config_smilies_mass_edit");
 480      
 481      if($mybb->request_method == "post")
 482      {
 483          foreach($mybb->input['name'] as $sid => $name)
 484          {
 485              if($mybb->input['delete'][$sid] == 1)
 486              {
 487                  $db->delete_query("smilies", "sid = '{$sid}'", 1);
 488              }
 489              else
 490              {
 491                  $smilie = array(
 492                      "name" => $db->escape_string($mybb->input['name'][$sid]),
 493                      "find" => $db->escape_string($mybb->input['find'][$sid]),
 494                      "disporder" => intval($mybb->input['disporder'][$sid]),
 495                      "showclickable" => $db->escape_string($mybb->input['showclickable'][$sid])
 496                  );
 497                      
 498                  $db->update_query("smilies", $smilie, "sid = '{$sid}'");
 499              }
 500          }
 501          
 502          $cache->update_smilies();
 503          
 504          $plugins->run_hooks("admin_config_smilies_mass_edit_commit");
 505  
 506          // Log admin action
 507          log_admin_action();
 508  
 509          flash_message($lang->success_multiple_smilies_updated, 'success');
 510          admin_redirect("index.php?module=config-smilies");
 511      }
 512      
 513      $page->add_breadcrumb_item($lang->mass_edit);
 514      $page->output_header($lang->smilies." - ".$lang->mass_edit);
 515  
 516      $sub_tabs['manage_smilies'] = array(
 517          'title' => $lang->manage_smilies,
 518          'link' => "index.php?module=config-smilies",
 519      );
 520      $sub_tabs['add_smilie'] = array(
 521          'title' => $lang->add_smilie,
 522          'link' => "index.php?module=config-smilies&amp;action=add",
 523      );
 524      $sub_tabs['add_multiple_smilies'] = array(
 525          'title' => $lang->add_multiple_smilies,
 526          'link' => "index.php?module=config-smilies&amp;action=add_multiple",
 527      );
 528      $sub_tabs['mass_edit'] = array(
 529          'title' => $lang->mass_edit,
 530          'link' => "index.php?module=config-smilies&amp;action=mass_edit",
 531          'description' => $lang->mass_edit_desc
 532      );
 533      
 534      $page->output_nav_tabs($sub_tabs, 'mass_edit');
 535      
 536      $form = new Form("index.php?module=config-smilies&amp;action=mass_edit", "post", "mass_edit");
 537      
 538      if($errors)
 539      {
 540          $page->output_inline_error($errors);
 541      }
 542      else
 543      {
 544          $mybb->input['path'] = 'images/smilies/';
 545          $mybb->input['showclickable'] = 1;
 546      }
 547      
 548      if(!$mybb->input['disporder'])
 549      {
 550          $query = $db->simple_select("smilies", "max(disporder) as dispordermax");
 551          $mybb->input['disporder'] = $db->fetch_field($query, "dispordermax")+1;
 552      }
 553      
 554      $form_container = new FormContainer($lang->manage_smilies);
 555      $form_container->output_row_header($lang->image, array("class" => "align_center", 'width' => '1'));
 556      $form_container->output_row_header($lang->name);
 557      $form_container->output_row_header($lang->text_replace, array('width' => '20%'));
 558      $form_container->output_row_header($lang->order, array('width' => '5%'));
 559      $form_container->output_row_header($lang->mass_edit_show_clickable, array("width" => 165));
 560      $form_container->output_row_header($lang->smilie_delete, array("class" => "align_center", 'width' => '5%'));
 561      
 562      $query = $db->simple_select("smilies", "*", "", array('order_by' => 'disporder'));
 563      while($smilie = $db->fetch_array($query))
 564      {
 565          $smilie['image'] = str_replace("{theme:imgdir}", $theme['imgdir'], $smilie['image']);
 566          if(my_strpos($smilie['image'], "p://") || substr($smilie['image'], 0, 1) == "/") 
 567          {
 568              $image = $smilie['image'];
 569          }
 570          else
 571          {
 572              $image = "../".$smilie['image'];
 573          }
 574          
 575          $form_container->output_cell("<img src=\"{$image}\" alt=\"\" />", array("class" => "align_center", "width" => 1));
 576          $form_container->output_cell($form->generate_text_box("name[{$smilie['sid']}]", $smilie['name'], array('id' => 'name', 'style' => 'width: 98%')));
 577          $form_container->output_cell($form->generate_text_box("find[{$smilie['sid']}]", $smilie['find'], array('id' => 'find', 'style' => 'width: 95%')));
 578          $form_container->output_cell($form->generate_text_box("disporder[{$smilie['sid']}]", $smilie['disporder'], array('id' => 'disporder', 'style' => 'width: 80%')));
 579          $form_container->output_cell($form->generate_yes_no_radio("showclickable[{$smilie['sid']}]", $smilie['showclickable']), array("class" => "align_center"));
 580          $form_container->output_cell($form->generate_check_box("delete[{$smilie['sid']}]", 1, $mybb->input['delete']), array("class" => "align_center"));
 581          $form_container->construct_row();
 582      }
 583      
 584      if($form_container->num_rows() == 0)
 585      {
 586          $form_container->output_cell($lang->no_smilies, array('colspan' => 6));
 587          $form_container->construct_row();
 588      }
 589      
 590      $form_container->end();
 591      
 592      $buttons[] = $form->generate_submit_button($lang->save_smilies);
 593      $buttons[] = $form->generate_reset_button($lang->reset);
 594  
 595      $form->output_submit_wrapper($buttons);
 596      $form->end();
 597  
 598      $page->output_footer();
 599  }
 600  
 601  if(!$mybb->input['action'])
 602  {
 603      $plugins->run_hooks("admin_config_smilies_start");
 604      
 605      $page->output_header($lang->manage_smilies);
 606  
 607      $sub_tabs['manage_smilies'] = array(
 608          'title' => $lang->manage_smilies,
 609          'link' => "index.php?module=config-smilies",
 610          'description' => $lang->manage_smilies_desc
 611      );
 612      $sub_tabs['add_smilie'] = array(
 613          'title' => $lang->add_smilie,
 614          'link' => "index.php?module=config-smilies&amp;action=add",
 615      );
 616      $sub_tabs['add_multiple_smilies'] = array(
 617          'title' => $lang->add_multiple_smilies,
 618          'link' => "index.php?module=config-smilies&amp;action=add_multiple",
 619      );
 620      $sub_tabs['mass_edit'] = array(
 621          'title' => $lang->mass_edit,
 622          'link' => "index.php?module=config-smilies&amp;action=mass_edit",
 623      );
 624      
 625      $page->output_nav_tabs($sub_tabs, 'manage_smilies');
 626      
 627      $pagenum = intval($mybb->input['page']);    
 628      if($pagenum)
 629      {
 630          $start = ($pagenum-1) * 20;
 631      }
 632      else
 633      {
 634          $start = 0;
 635          $pagenum = 1;
 636      }
 637      
 638      
 639      $table = new Table;
 640      $table->construct_header($lang->image, array("class" => "align_center", "width" => 1));
 641      $table->construct_header($lang->name, array("width" => "35%"));
 642      $table->construct_header($lang->text_replace, array("width" => "35%"));
 643      $table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2));
 644      
 645      $query = $db->simple_select("smilies", "*", "", array('limit_start' => $start, 'limit' => 20, 'order_by' => 'disporder'));
 646      while($smilie = $db->fetch_array($query))
 647      {
 648          $smilie['image'] = str_replace("{theme:imgdir}", $theme['imgdir'], $smilie['image']);
 649          if(my_strpos($smilie['image'], "p://") || substr($smilie['image'], 0, 1) == "/") 
 650          {
 651              $image = $smilie['image'];
 652          }
 653          else
 654          {
 655              $image = "../".$smilie['image'];
 656          }
 657          
 658          $table->construct_cell("<img src=\"{$image}\" alt=\"\" />", array("class" => "align_center"));
 659          $table->construct_cell(htmlspecialchars_uni($smilie['name']));
 660          $table->construct_cell(htmlspecialchars_uni($smilie['find']));
 661          
 662          $table->construct_cell("<a href=\"index.php?module=config-smilies&amp;action=edit&amp;sid={$smilie['sid']}\">{$lang->edit}</a>", array("class" => "align_center"));
 663          $table->construct_cell("<a href=\"index.php?module=config-smilies&amp;action=delete&amp;sid={$smilie['sid']}&amp;my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_smilie_deletion}')\">{$lang->delete}</a>", array("class" => "align_center"));
 664          $table->construct_row();
 665      }
 666      
 667      if($table->num_rows() == 0)
 668      {
 669          $table->construct_cell($lang->no_smilies, array('colspan' => 5));
 670          $table->construct_row();
 671      }
 672      
 673      $table->output($lang->manage_smilies);
 674      
 675      $query = $db->simple_select("smilies", "COUNT(sid) as smilies");
 676      $total_rows = $db->fetch_field($query, "smilies");
 677      
 678      echo "<br />".draw_admin_pagination($pagenum, "20", $total_rows, "index.php?module=config-smilies&amp;page={page}");
 679  
 680      $page->output_footer();
 681  }
 682  ?>


Generated: Tue Oct 8 19:19:50 2013 Cross-referenced by PHPXref 0.7.1