[ Index ]

PHP Cross Reference of MyBB 1.8.38

title

Body

[close]

/admin/inc/ -> class_page.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.8
   4   * Copyright 2014 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://www.mybb.com
   7   * License: http://www.mybb.com/about/license
   8   *
   9   */
  10  
  11  /*
  12   * MyBB Admin CP Page Generation Class
  13   */
  14  class DefaultPage
  15  {
  16  
  17      /**
  18       * @var string The current style in use.
  19       */
  20      public $style;
  21  
  22      /**
  23       * @var array The primary menu items.
  24       */
  25      public $menu = array();
  26  
  27      /**
  28       * @var string The side bar menu items.
  29       */
  30      public $submenu = '';
  31  
  32      /**
  33       * @var string The module we're currently in.
  34       */
  35      public $active_module;
  36  
  37      /**
  38       * @var string The action we're currently performing.
  39       */
  40      public $active_action;
  41  
  42      /**
  43       * @var string Content for the side bar of the page if we have one.
  44       */
  45      public $sidebar;
  46  
  47      /**
  48       * @var array The breadcrumb trail leading up to this page.
  49       */
  50      public $_breadcrumb_trail = array();
  51  
  52      /**
  53       * @var string Any additional information to add between the <head> tags.
  54       */
  55      public $extra_header = "";
  56  
  57      /**
  58       * @var string Any additional messages to add after the flash messages are shown.
  59       */
  60      public $extra_messages = array();
  61  
  62      /**
  63       * @var string Show a post verify error
  64       */
  65      public $show_post_verify_error = '';
  66  
  67      /**
  68       * @var string
  69       */
  70      public $_menu;
  71  
  72      /**
  73       * Output the page header.
  74       *
  75       * @param string $title The title of the page.
  76       */
  77  	function output_header($title="")
  78      {
  79          global $mybb, $admin_session, $lang, $plugins;
  80  
  81          $args = array(
  82              'this' => &$this,
  83              'title' => &$title,
  84          );
  85  
  86          $plugins->run_hooks("admin_page_output_header", $args);
  87  
  88          if(!$title)
  89          {
  90              $title = $lang->mybb_admin_panel;
  91          }
  92  
  93          $rtl = "";
  94          if($lang->settings['rtl'] == 1)
  95          {
  96              $rtl = " dir=\"rtl\"";
  97          }
  98  
  99          echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
 100          echo "<html xmlns=\"http://www.w3.org/1999/xhtml\"{$rtl}>\n";
 101          echo "<head profile=\"http://gmpg.org/xfn/1\">\n";
 102          echo "    <title>".$title."</title>\n";
 103          echo "    <meta name=\"author\" content=\"MyBB Group\" />\n";
 104          echo "    <meta name=\"copyright\" content=\"Copyright ".COPY_YEAR." MyBB Group.\" />\n";
 105          echo "    <link rel=\"stylesheet\" href=\"styles/".$this->style."/main.css?ver=1813\" type=\"text/css\" />\n";
 106          echo "    <link rel=\"stylesheet\" href=\"styles/".$this->style."/modal.css?ver=1813\" type=\"text/css\" />\n";
 107  
 108          // Load stylesheet for this module if it has one
 109          if(file_exists(MYBB_ADMIN_DIR."styles/{$this->style}/{$this->active_module}.css"))
 110          {
 111              echo "    <link rel=\"stylesheet\" href=\"styles/{$this->style}/{$this->active_module}.css\" type=\"text/css\" />\n";
 112          }
 113  
 114          echo "    <script type=\"text/javascript\" src=\"../jscripts/jquery.js?ver=1823\"></script>\n";
 115          echo "    <script type=\"text/javascript\" src=\"../jscripts/jquery.plugins.min.js?ver=1821\"></script>\n";
 116          echo "    <script type=\"text/javascript\" src=\"../jscripts/general.js?ver=1821\"></script>\n";
 117          echo "    <script type=\"text/javascript\" src=\"./jscripts/admincp.js?ver=1821\"></script>\n";
 118          echo "    <script type=\"text/javascript\" src=\"./jscripts/tabs.js\"></script>\n";
 119  
 120          echo "    <link rel=\"stylesheet\" href=\"jscripts/jqueryui/css/redmond/jquery-ui.min.css\" />\n";
 121          echo "    <link rel=\"stylesheet\" href=\"jscripts/jqueryui/css/redmond/jquery-ui.structure.min.css\" />\n";
 122          echo "    <link rel=\"stylesheet\" href=\"jscripts/jqueryui/css/redmond/jquery-ui.theme.min.css\" />\n";
 123          echo "    <script src=\"jscripts/jqueryui/js/jquery-ui.min.js?ver=1813\"></script>\n";
 124  
 125          // Stop JS elements showing while page is loading (JS supported browsers only)
 126          echo "  <style type=\"text/css\">.popup_button { display: none; } </style>\n";
 127          echo "  <script type=\"text/javascript\">\n".
 128                  "//<![CDATA[\n".
 129                  "    document.write('<style type=\"text/css\">.popup_button { display: inline; } .popup_menu { display: none; }<\/style>');\n".
 130                  "//]]>\n".
 131                  "</script>\n";
 132  
 133          echo "    <script type=\"text/javascript\">
 134  //<![CDATA[
 135  var loading_text = '{$lang->loading_text}';
 136  var cookieDomain = '{$mybb->settings['cookiedomain']}';
 137  var cookiePath = '{$mybb->settings['cookiepath']}';
 138  var cookiePrefix = '{$mybb->settings['cookieprefix']}';
 139  var cookieSecureFlag = '{$mybb->settings['cookiesecureflag']}';
 140  var imagepath = '../images';
 141  
 142  lang.unknown_error = \"{$lang->unknown_error}\";
 143  lang.saved = \"{$lang->saved}\";
 144  //]]>
 145  </script>\n";
 146          echo $this->extra_header;
 147          echo "</head>\n";
 148          echo "<body>\n";
 149          echo "<div id=\"container\">\n";
 150          echo "    <div id=\"logo\"><h1><span class=\"invisible\">{$lang->mybb_admin_cp}</span></h1></div>\n";
 151          $username = htmlspecialchars_uni($mybb->user['username']);
 152          echo "    <div id=\"welcome\"><span class=\"logged_in_as\">{$lang->logged_in_as} <a href=\"index.php?module=user-users&amp;action=edit&amp;uid={$mybb->user['uid']}\" class=\"username\">{$username}</a></span> | <a href=\"{$mybb->settings['bburl']}\" target=\"_blank\" class=\"forum\">{$lang->view_board}</a> | <a href=\"index.php?action=logout&amp;my_post_key={$mybb->post_code}\" class=\"logout\">{$lang->logout}</a></div>\n";
 153          echo $this->_build_menu();
 154          echo "    <div id=\"page\">\n";
 155          echo "        <div id=\"left_menu\">\n";
 156          echo $this->submenu;
 157          echo $this->sidebar;
 158          echo "        </div>\n";
 159          echo "        <div id=\"content\">\n";
 160          echo "            <div class=\"breadcrumb\">\n";
 161          echo $this->_generate_breadcrumb();
 162          echo "            </div>\n";
 163          echo "           <div id=\"inner\">\n";
 164          if(isset($admin_session['data']['flash_message']) && $admin_session['data']['flash_message'])
 165          {
 166              $message = $admin_session['data']['flash_message']['message'];
 167              $type = $admin_session['data']['flash_message']['type'];
 168              echo "<div id=\"flash_message\" class=\"{$type}\">\n";
 169              echo "{$message}\n";
 170              echo "</div>\n";
 171              update_admin_session('flash_message', '');
 172          }
 173  
 174          if(!empty($this->extra_messages) && is_array($this->extra_messages))
 175          {
 176              foreach($this->extra_messages as $message)
 177              {
 178                  switch($message['type'])
 179                  {
 180                      case 'success':
 181                      case 'error':
 182                          echo "<div id=\"flash_message\" class=\"{$message['type']}\">\n";
 183                          echo "{$message['message']}\n";
 184                          echo "</div>\n";
 185                          break;
 186                      default:
 187                          $this->output_error($message['message']);
 188                          break;
 189                  }
 190              }
 191          }
 192  
 193          if($this->show_post_verify_error == true)
 194          {
 195              $this->output_error($lang->invalid_post_verify_key);
 196          }
 197      }
 198  
 199      /**
 200       * Output the page footer.
 201       *
 202       * @param bool $quit
 203       */
 204  	function output_footer($quit=true)
 205      {
 206          global $mybb, $maintimer, $db, $lang, $plugins;
 207  
 208          $args = array(
 209              'this' => &$this,
 210              'quit' => &$quit,
 211          );
 212  
 213          $plugins->run_hooks("admin_page_output_footer", $args);
 214  
 215          $memory_usage = get_friendly_size(get_memory_usage());
 216  
 217          $totaltime = format_time_duration($maintimer->stop());
 218          $querycount = $db->query_count;
 219  
 220          if(my_strpos(getenv("REQUEST_URI"), "?"))
 221          {
 222              $debuglink = htmlspecialchars_uni(getenv("REQUEST_URI")) . "&amp;debug=1#footer";
 223          }
 224          else
 225          {
 226              $debuglink = htmlspecialchars_uni(getenv("REQUEST_URI")) . "?debug=1#footer";
 227          }
 228  
 229          echo "            </div>\n";
 230          echo "        </div>\n";
 231          echo "    <br style=\"clear: both;\" />";
 232          echo "    <br style=\"clear: both;\" />";
 233          echo "    </div>\n";
 234          echo "<div id=\"footer\"><p class=\"generation\">".$lang->sprintf($lang->generated_in, $totaltime, $debuglink, $querycount, $memory_usage)."</p><p class=\"powered\">Powered By <a href=\"https://mybb.com/\" target=\"_blank\" rel=\"noopener\">MyBB</a>, &copy; 2002-".COPY_YEAR." <a href=\"https://mybb.com/\" target=\"_blank\" rel=\"noopener\">MyBB Group</a>.</p></div>\n";
 235          if($mybb->debug_mode)
 236          {
 237              echo $db->explain;
 238          }
 239          echo "</div>\n";
 240          echo "</body>\n";
 241          echo "</html>\n";
 242  
 243          if($quit != false)
 244          {
 245              exit;
 246          }
 247      }
 248  
 249      /**
 250       * Add an item to the page breadcrumb trail.
 251       *
 252       * @param string $name The name of the item to add.
 253       * @param string $url The URL to the item we're adding (if there is one)
 254       */
 255  	function add_breadcrumb_item($name, $url="")
 256      {
 257          $this->_breadcrumb_trail[] = array("name" => $name, "url" => $url);
 258      }
 259  
 260      /**
 261       * Generate a breadcrumb trail.
 262       *
 263       * @return bool|string
 264       */
 265  	function _generate_breadcrumb()
 266      {
 267          if(!is_array($this->_breadcrumb_trail))
 268          {
 269              return false;
 270          }
 271          $trail = "";
 272          foreach($this->_breadcrumb_trail as $key => $crumb)
 273          {
 274              if(isset($this->_breadcrumb_trail[$key+1]))
 275              {
 276                  $trail .= "<a href=\"".$crumb['url']."\">".$crumb['name']."</a>";
 277                  if(isset($this->_breadcrumb_trail[$key+2]))
 278                  {
 279                      $trail .= " &raquo; ";
 280                  }
 281              }
 282              else
 283              {
 284                  $trail .= "<span class=\"active\">".$crumb['name']."</span>";
 285              }
 286          }
 287          return $trail;
 288      }
 289  
 290      /**
 291       * Output a success message.
 292       *
 293       * @param string $message The message to output.
 294       */
 295  	function output_success($message)
 296      {
 297          echo "<div class=\"success\">{$message}</div>\n";
 298      }
 299  
 300      /**
 301       * Output an alert/warning message.
 302       *
 303       * @param string $message The message to output.
 304       * @param string $id The ID of the alert/warning (optional)
 305       */
 306  	function output_alert($message, $id="")
 307      {
 308          if($id)
 309          {
 310              $id = " id=\"{$id}\"";
 311          }
 312          echo "<div class=\"alert\"{$id}>{$message}</div>\n";
 313      }
 314  
 315      /**
 316       * Output an inline message.
 317       *
 318       * @param string $message The message to output.
 319       */
 320  	function output_inline_message($message)
 321      {
 322          echo "<div class=\"inline_message\">{$message}</div>\n";
 323      }
 324  
 325      /**
 326       * Output a single error message.
 327       *
 328       * @param string $error The message to output.
 329       */
 330  	function output_error($error)
 331      {
 332          echo "<div class=\"error\">\n";
 333          echo "{$error}\n";
 334          echo "</div>\n";
 335      }
 336  
 337      /**
 338       * Output one or more inline error messages.
 339       *
 340       * @param array $errors Array of error messages to output.
 341       */
 342  	function output_inline_error($errors)
 343      {
 344          global $lang;
 345  
 346          if(!is_array($errors))
 347          {
 348              $errors = array($errors);
 349          }
 350          echo "<div class=\"error\">\n";
 351          echo "<p><em>{$lang->encountered_errors}</em></p>\n";
 352          echo "<ul>\n";
 353          foreach($errors as $error)
 354          {
 355              echo "<li>{$error}</li>\n";
 356          }
 357          echo "</ul>\n";
 358          echo "</div>\n";
 359      }
 360  
 361      /**
 362       * Generate the login page.
 363       *
 364       * @param string $message The any message to output on the page if there is one.
 365       * @param string $class The class name of the message (defaults to success)
 366       */
 367  	function show_login($message="", $class="success")
 368      {
 369          global $plugins, $lang, $cp_style, $mybb;
 370  
 371          $args = array(
 372              'this' => &$this,
 373              'message' => &$message,
 374              'class' => &$class
 375          );
 376  
 377          $plugins->run_hooks('admin_page_show_login_start', $args);
 378  
 379          $copy_year = COPY_YEAR;
 380  
 381          $login_container_width = "";
 382          $login_label_width = "";
 383  
 384          // If the language string for "Username" is too cramped then use this to define how much larger you want the gap to be (in px)
 385          if(isset($lang->login_field_width))
 386          {
 387              $login_label_width = " style=\"width: ".((int)$lang->login_field_width+100)."px;\"";
 388              $login_container_width = " style=\"width: ".(410+((int)$lang->login_field_width))."px;\"";
 389          }
 390  
 391          $login_page = <<<EOF
 392  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 393  <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
 394  <head profile="http://gmpg.org/xfn/1">
 395  <title>{$lang->mybb_admin_login}</title>
 396  <meta name="author" content="MyBB Group" />
 397  <meta name="copyright" content="Copyright {$copy_year} MyBB Group." />
 398  <link rel="stylesheet" href="./styles/{$cp_style}/login.css" type="text/css" />
 399  <script type="text/javascript" src="../jscripts/jquery.js?ver=1823"></script>
 400  <script type="text/javascript" src="../jscripts/general.js?ver=1821"></script>
 401  <script type="text/javascript" src="./jscripts/admincp.js?ver=1821"></script>
 402  <script type="text/javascript">
 403  //<![CDATA[
 404      loading_text = '{$lang->loading_text}';
 405  //]]>
 406  </script>
 407  </head>
 408  <body>
 409  <div id="container"{$login_container_width}>
 410      <div id="header">
 411          <div id="logo">
 412              <h1><a href="../" title="{$lang->return_to_forum}"><span class="invisible">{$lang->mybb_acp}</span></a></h1>
 413  
 414          </div>
 415      </div>
 416      <div id="content">
 417          <h2>{$lang->please_login}</h2>
 418  EOF;
 419          if($message)
 420          {
 421              $login_page .= "<p id=\"message\" class=\"{$class}\"><span class=\"text\">{$message}</span></p>";
 422          }
 423          // Make query string nice and pretty so that user can go to his/her preferred destination
 424          $query_string = '';
 425          if($_SERVER['QUERY_STRING'])
 426          {
 427              $query_string = '?'.preg_replace('#adminsid=(.{32})#i', '', $_SERVER['QUERY_STRING']);
 428              $query_string = preg_replace('#my_post_key=(.{32})#i', '', $query_string);
 429              $query_string = str_replace('action=logout', '', $query_string);
 430              $query_string = preg_replace('#&+#', '&', $query_string);
 431              $query_string = str_replace('?&', '?', $query_string);
 432              $query_string = htmlspecialchars_uni($query_string);
 433          }
 434          switch($mybb->settings['username_method'])
 435          {
 436              case 0:
 437                  $lang_username = $lang->username;
 438                  break;
 439              case 1:
 440                  $lang_username = $lang->username1;
 441                  break;
 442              case 2:
 443                  $lang_username = $lang->username2;
 444                  break;
 445              default:
 446                  $lang_username = $lang->username;
 447                  break;
 448          }
 449  
 450          // Secret PIN
 451          global $config;
 452          if(isset($config['secret_pin']) && $config['secret_pin'] != '')
 453          {
 454              $secret_pin = "<div class=\"label\"{$login_label_width}><label for=\"pin\">{$lang->secret_pin}</label></div>
 455              <div class=\"field\"><input type=\"password\" name=\"pin\" id=\"pin\" class=\"text_input\" /></div>";
 456          }
 457          else
 458          {
 459              $secret_pin = '';
 460          }
 461  
 462          $login_lang_string = $lang->enter_username_and_password;
 463  
 464          switch($mybb->settings['username_method'])
 465          {
 466              case 0: // Username only
 467                  $login_lang_string = $lang->sprintf($login_lang_string, $lang->login_username);
 468                  break;
 469              case 1: // Email only
 470                  $login_lang_string = $lang->sprintf($login_lang_string, $lang->login_email);
 471                  break;
 472              case 2: // Username and email
 473              default:
 474                  $login_lang_string = $lang->sprintf($login_lang_string, $lang->login_username_and_password);
 475                  break;
 476          }
 477  
 478             $this_file = htmlspecialchars_uni($_SERVER['SCRIPT_NAME']);
 479  
 480          $login_page .= <<<EOF
 481          <p>{$login_lang_string}</p>
 482          <form method="post" action="{$this_file}{$query_string}">
 483          <div class="form_container">
 484  
 485              <div class="label"{$login_label_width}><label for="username">{$lang_username}</label></div>
 486  
 487              <div class="field"><input type="text" name="username" id="username" class="text_input initial_focus" /></div>
 488  
 489              <div class="label"{$login_label_width}><label for="password">{$lang->password}</label></div>
 490              <div class="field"><input type="password" name="password" id="password" class="text_input" /></div>
 491              {$secret_pin}
 492          </div>
 493          <p class="submit">
 494              <span class="forgot_password">
 495                  <a href="../member.php?action=lostpw">{$lang->lost_password}</a>
 496              </span>
 497  
 498              <input type="submit" value="{$lang->login}" />
 499              <input type="hidden" name="do" value="login" />
 500          </p>
 501          </form>
 502      </div>
 503  </div>
 504  </body>
 505  </html>
 506  EOF;
 507  
 508          $args = array(
 509              'this' => &$this,
 510              'login_page' => &$login_page
 511          );
 512  
 513          $plugins->run_hooks('admin_page_show_login_end', $args);
 514  
 515          echo $login_page;
 516          exit;
 517      }
 518  
 519  	function show_2fa()
 520      {
 521          global $lang, $cp_style, $mybb;
 522  
 523          $copy_year = COPY_YEAR;
 524  
 525          $mybb2fa_page = <<<EOF
 526  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 527  <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
 528  <head profile="http://gmpg.org/xfn/1">
 529  <title>{$lang->my2fa}</title>
 530  <meta name="author" content="MyBB Group" />
 531  <meta name="copyright" content="Copyright {$copy_year} MyBB Group." />
 532  <link rel="stylesheet" href="./styles/{$cp_style}/login.css" type="text/css" />
 533  <script type="text/javascript" src="../jscripts/jquery.js?ver=1823"></script>
 534  <script type="text/javascript" src="../jscripts/general.js?ver=1821"></script>
 535  <script type="text/javascript" src="./jscripts/admincp.js?ver=1821"></script>
 536  <script type="text/javascript">
 537  //<![CDATA[
 538      loading_text = '{$lang->loading_text}';
 539  //]]>
 540  </script>
 541  </head>
 542  <body>
 543  <div id="container">
 544      <div id="header">
 545          <div id="logo">
 546              <h1><a href="../" title="{$lang->return_to_forum}"><span class="invisible">{$lang->mybb_acp}</span></a></h1>
 547          </div>
 548      </div>
 549      <div id="content">
 550          <h2>{$lang->my2fa}</h2>
 551  EOF;
 552          // Make query string nice and pretty so that user can go to his/her preferred destination
 553          $query_string = '';
 554          if($_SERVER['QUERY_STRING'])
 555          {
 556              $query_string = '?'.preg_replace('#adminsid=(.{32})#i', '', $_SERVER['QUERY_STRING']);
 557              $query_string = preg_replace('#my_post_key=(.{32})#i', '', $query_string);
 558              $query_string = str_replace('action=logout', '', $query_string);
 559              $query_string = preg_replace('#&+#', '&', $query_string);
 560              $query_string = str_replace('?&', '?', $query_string);
 561              $query_string = htmlspecialchars_uni($query_string);
 562          }
 563          $mybb2fa_page .= <<<EOF
 564          <p>{$lang->my2fa_code}</p>
 565          <form method="post" action="index.php{$query_string}">
 566          <div class="form_container">
 567              <div class="label"><label for="code">{$lang->my2fa_label}</label></div>
 568              <div class="field"><input type="text" name="code" id="code" class="text_input initial_focus" /></div>
 569          </div>
 570          <p class="submit">
 571              <input type="submit" value="{$lang->login}" />
 572              <input type="hidden" name="do" value="do_2fa" />
 573          </p>
 574          </form>
 575      </div>
 576  </div>
 577  </body>
 578  </html>
 579  EOF;
 580          echo $mybb2fa_page;
 581          exit;
 582      }
 583  
 584      /**
 585       * Generate the lockout page
 586       *
 587       */
 588  	function show_lockedout()
 589      {
 590          global $lang, $mybb, $cp_style;
 591  
 592          $copy_year = COPY_YEAR;
 593          $allowed_attempts = (int)$mybb->settings['maxloginattempts'];
 594          $lockedout_message = $lang->sprintf($lang->error_mybb_admin_lockedout_message, $allowed_attempts);
 595  
 596          print <<<EOF
 597  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 598  <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
 599  <head profile="http://gmpg.org/xfn/1">
 600  <title>{$lang->mybb_admin_cp} - {$lang->error_mybb_admin_lockedout}</title>
 601  <meta name="author" content="MyBB Group" />
 602  <meta name="copyright" content="Copyright {$copy_year} MyBB Group." />
 603  <link rel="stylesheet" href="./styles/{$cp_style}/login.css" type="text/css" />
 604  </head>
 605  <body>
 606  <div id="container">
 607      <div id="header">
 608          <div id="logo">
 609              <h1><a href="../" title="{$lang->return_to_forum}"><span class="invisible">{$lang->mybb_acp}</span></a></h1>
 610  
 611          </div>
 612      </div>
 613      <div id="content">
 614          <h2>{$lang->error_mybb_admin_lockedout}</h2>
 615          <div class="alert">{$lockedout_message}</div>
 616      </div>
 617  </div>
 618  </body>
 619  </html>
 620  EOF;
 621      exit;
 622      }
 623  
 624      /**
 625       * Generate the lockout unlock page
 626       *
 627       * @param string $message The any message to output on the page if there is one.
 628       * @param string $class The class name of the message (defaults to success)
 629       */
 630  	function show_lockout_unlock($message="", $class="success")
 631      {
 632          global $lang, $mybb, $cp_style;
 633  
 634          $copy_year = COPY_YEAR;
 635  
 636          $login_label_width = "";
 637  
 638          // If the language string for "Username" is too cramped then use this to define how much larger you want the gap to be (in px)
 639          if(isset($lang->login_field_width))
 640          {
 641              $login_label_width = " style=\"width: ".((int)$lang->login_field_width+100)."px;\"";
 642          }
 643  
 644          switch($mybb->settings['username_method'])
 645          {
 646              case 0:
 647                  $lang_username = $lang->username;
 648                  break;
 649              case 1:
 650                  $lang_username = $lang->username1;
 651                  break;
 652              case 2:
 653                  $lang_username = $lang->username2;
 654                  break;
 655              default:
 656                  $lang_username = $lang->username;
 657                  break;
 658          }
 659  
 660          if($message)
 661          {
 662              $message = "<p id=\"message\" class=\"{$class}\"><span class=\"text\">{$message}</span></p>";
 663          }
 664  
 665          print <<<EOF
 666  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 667  <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
 668  <head profile="http://gmpg.org/xfn/1">
 669  <title>{$lang->mybb_admin_cp} - {$lang->lockout_unlock}</title>
 670  <meta name="author" content="MyBB Group" />
 671  <meta name="copyright" content="Copyright {$copy_year} MyBB Group." />
 672  <link rel="stylesheet" href="./styles/{$cp_style}/login.css" type="text/css" />
 673  </head>
 674  <body>
 675  <div id="container">
 676      <div id="header">
 677          <div id="logo">
 678              <h1><a href="../" title="{$lang->return_to_forum}"><span class="invisible">{$lang->mybb_acp}</span></a></h1>
 679  
 680          </div>
 681      </div>
 682      <div id="content">
 683          <h2>{$lang->lockout_unlock}</h2>
 684          {$message}
 685          <p>{$lang->enter_username_and_token}</p>
 686          <form method="post" action="index.php">
 687          <div class="form_container">
 688  
 689              <div class="label"{$login_label_width}><label for="username">{$lang_username}</label></div>
 690  
 691              <div class="field"><input type="text" name="username" id="username" class="text_input initial_focus" /></div>
 692  
 693              <div class="label"{$login_label_width}><label for="token">{$lang->unlock_token}</label></div>
 694              <div class="field"><input type="text" name="token" id="token" class="text_input" /></div>
 695          </div>
 696          <p class="submit">
 697              <span class="forgot_password">
 698                  <a href="../member.php?action=lostpw">{$lang->lost_password}</a>
 699              </span>
 700  
 701              <input type="submit" value="{$lang->unlock_account}" />
 702              <input type="hidden" name="action" value="unlock" />
 703          </p>
 704          </form>
 705      </div>
 706  </div>
 707  </body>
 708  </html>
 709  EOF;
 710      exit;
 711      }
 712  
 713      /**
 714       * Add an item to the primary navigation menu.
 715       *
 716       * @param string $title The title of the menu item.
 717       * @param string $id The ID of the menu item. This should correspond with the module the menu will run.
 718       * @param string $link The link to follow when the menu item is clicked.
 719       * @param int $order The display order of the menu item. Lower display order means closer to start of the menu.
 720       * @param array $submenu Array of sub menu items if there are any.
 721       */
 722  	function add_menu_item($title, $id, $link, $order=10, $submenu=array())
 723      {
 724          $this->_menu[$order][] = array(
 725              "title" => $title,
 726              "id" => $id,
 727              "link" => $link,
 728              "submenu" => $submenu
 729          );
 730      }
 731  
 732      /**
 733       * Build the actual navigation menu.
 734       *
 735       * @return bool|string
 736       */
 737  	function _build_menu()
 738      {
 739          if(!is_array($this->_menu))
 740          {
 741              return false;
 742          }
 743          $build_menu = "<div id=\"menu\">\n<ul>\n";
 744          ksort($this->_menu);
 745          foreach($this->_menu as $items)
 746          {
 747              foreach($items as $menu_item)
 748              {
 749                  $menu_item['link'] = htmlspecialchars_uni($menu_item['link']);
 750                  if($menu_item['id'] == $this->active_module)
 751                  {
 752                      $sub_menu = $menu_item['submenu'];
 753                      $sub_menu_title = $menu_item['title'];
 754                      $build_menu .= "<li><a href=\"{$menu_item['link']}\" class=\"active\">{$menu_item['title']}</a></li>\n";
 755  
 756                  }
 757                  else
 758                  {
 759                      $build_menu .= "<li><a href=\"{$menu_item['link']}\">{$menu_item['title']}</a></li>\n";
 760                  }
 761              }
 762          }
 763          $build_menu .= "</ul>\n</div>";
 764  
 765          if(!empty($sub_menu))
 766          {
 767              $this->_build_submenu($sub_menu_title, $sub_menu);
 768          }
 769          return $build_menu;
 770      }
 771  
 772      /**
 773       * Build a navigation sub menu if we have one.
 774       *
 775       * @param string $title A title for the sub menu.
 776       * @param array $items Array of items for the sub menu.
 777       */
 778  	function _build_submenu($title, $items)
 779      {
 780          if(is_array($items))
 781          {
 782              $sidebar = new sideBarItem($title);
 783              $sidebar->add_menu_items($items, $this->active_action);
 784              $this->submenu .= $sidebar->get_markup();
 785          }
 786      }
 787  
 788      /**
 789       * Output a Javascript based tab control on to the page.
 790       *
 791       * @param array $tabs Array of tabs in name => title format. Name should correspond to the name of a DIV containing the tab content.
 792       * @param boolean $observe_onload Whether or not to run the event onload or instantly
 793       * @param string $id The ID to use for the tabs for if you run multiple instances of the tabbing control in one html page
 794       */
 795  	function output_tab_control($tabs=array(), $observe_onload=true, $id="tabs")
 796      {
 797          global $plugins;
 798          $tabs = $plugins->run_hooks("admin_page_output_tab_control_start", $tabs);
 799          echo "<ul class=\"tabs\" id=\"{$id}\">\n";
 800          $tab_count = count($tabs);
 801          $done = 1;
 802          foreach($tabs as $anchor => $title)
 803          {
 804              $class = "";
 805              if($tab_count == $done)
 806              {
 807                  $class .= " last";
 808              }
 809              if($done == 1)
 810              {
 811                  $class .= " first";
 812              }
 813              ++$done;
 814              echo "<li class=\"{$class}\"><a href=\"#tab_{$anchor}\">{$title}</a></li>\n";
 815          }
 816          echo "</ul>\n";
 817          $plugins->run_hooks("admin_page_output_tab_control_end", $tabs);
 818      }
 819  
 820      /**
 821       * Output a series of primary navigation tabs for swithcing between items within a particular module/action.
 822       *
 823       * @param array $tabs Nested array of tabs containing possible keys of align, link_target, link_rel, link, title.
 824       * @param string $active The name of the active tab. Corresponds with the key of each tab item.
 825       */
 826  	function output_nav_tabs($tabs=array(), $active='')
 827      {
 828          global $plugins;
 829          $tabs = $plugins->run_hooks("admin_page_output_nav_tabs_start", $tabs);
 830          echo "<div class=\"nav_tabs\">";
 831          echo "\t<ul>\n";
 832          foreach($tabs as $id => $tab)
 833          {
 834              $class = '';
 835              if($id == $active)
 836              {
 837                  $class = ' active';
 838              }
 839              if(isset($tab['align']) == "right")
 840              {
 841                  $class .= " right";
 842              }
 843              $target = '';
 844              if(isset($tab['link_target']))
 845              {
 846                  $target = " target=\"{$tab['link_target']}\"";
 847              }
 848              $rel = '';
 849              if(isset($tab['link_rel']))
 850              {
 851                  $rel = " rel=\"{$tab['link_rel']}\"";
 852              }
 853              if(!isset($tab['link']))
 854              {
 855                  $tab['link'] = '';
 856              }
 857              echo "\t\t<li class=\"{$class}\"><a href=\"{$tab['link']}\"{$target}{$rel}>{$tab['title']}</a></li>\n";
 858              $target = '';
 859          }
 860          echo "\t</ul>\n";
 861          if(!empty($tabs[$active]['description']))
 862          {
 863              echo "\t<div class=\"tab_description\">{$tabs[$active]['description']}</div>\n";
 864          }
 865          echo "</div>";
 866          $arguments = array('tabs' => $tabs, 'active' => $active);
 867          $plugins->run_hooks("admin_page_output_nav_tabs_end", $arguments);
 868      }
 869  
 870      /**
 871       * Output a page asking if a user wishes to continue performing a specific action.
 872       *
 873       * @param string $url The URL to be forwarded to.
 874       * @param string $message The confirmation message to output.
 875       * @param string $title The title to use in the output header
 876       */
 877  	function output_confirm_action($url, $message="", $title="")
 878      {
 879          global $lang, $plugins;
 880  
 881          $args = array(
 882              'this' => &$this,
 883              'url' => &$url,
 884              'message' => &$message,
 885              'title' => &$title,
 886          );
 887  
 888          $plugins->run_hooks('admin_page_output_confirm_action', $args);
 889  
 890          if(!$message)
 891          {
 892              $message = $lang->confirm_action;
 893          }
 894          $this->output_header($title);
 895          $form = new Form($url, 'post');
 896  
 897          echo "<div class=\"confirm_action\">\n";
 898          echo "<p>{$message}</p>\n";
 899          echo "<br />\n";
 900          echo "<p class=\"buttons\">\n";
 901          echo $form->generate_submit_button($lang->yes, array('class' => 'button_yes'));
 902          echo $form->generate_submit_button($lang->no, array("name" => "no", 'class' => 'button_no'));
 903          echo "</p>\n";
 904          echo "</div>\n";
 905  
 906          $form->end();
 907          $this->output_footer();
 908      }
 909  
 910      /**
 911       * Build a clickable MyCode editor for the Admin CP.
 912       *
 913       * @param string $bind The ID of the textarea to bind the editor to.
 914       * @param string $editor_language The language string for the editor.
 915       * @param bool $smilies Whether or not smilies should be included
 916       * @return string The build MyCode editor Javascript.
 917       */
 918  	function build_codebuttons_editor($bind, $editor_language, $smilies)
 919      {
 920          global $lang, $mybb, $smiliecache, $smiliecount, $cache;
 921  
 922          // Smilies
 923          $emoticon = "";
 924          $emoticons_enabled = "false";
 925          if($smilies)
 926          {
 927              if($mybb->settings['smilieinserter'] && $mybb->settings['smilieinsertercols'] && $mybb->settings['smilieinsertertot'])
 928              {
 929                  $emoticon = ",emoticon";
 930              }
 931              $emoticons_enabled = "true";
 932  
 933              if(!$smiliecount)
 934              {
 935                  $smilie_cache = $cache->read("smilies");
 936                  if(!is_array($smilie_cache))
 937                  {
 938                      $smilie_cache = array();
 939                  }
 940                  $smiliecount = count($smilie_cache);
 941              }
 942  
 943              if(!$smiliecache)
 944              {
 945                  if(!is_array($smilie_cache))
 946                  {
 947                      $smilie_cache = $cache->read("smilies");
 948                  }
 949                  foreach($smilie_cache as $smilie)
 950                  {
 951                      $smilie['image'] = str_replace("{theme}", "images", $smilie['image']);
 952                      $smiliecache[$smilie['sid']] = $smilie;
 953                  }
 954              }
 955  
 956              unset($smilie);
 957  
 958              if(is_array($smiliecache))
 959              {
 960                  reset($smiliecache);
 961  
 962                  $dropdownsmilies = $moresmilies = $hiddensmilies = "";
 963                  $i = 0;
 964  
 965                  foreach($smiliecache as $smilie)
 966                  {
 967                      $finds = explode("\n", $smilie['find']);
 968                      $finds_count = count($finds);
 969  
 970                      // Only show the first text to replace in the box
 971                      $find = str_replace(array('\\', '"'), array('\\\\', '\"'), htmlspecialchars_uni($finds[0]));
 972                      $image = str_replace(array('\\', '"'), array('\\\\', '\"'), htmlspecialchars_uni($smilie['image']));
 973                      if(substr($image, 0, 4) != "http")
 974                      {
 975                          $image = $mybb->settings['bburl']."/".$image;
 976                      }
 977  
 978                      if(!$mybb->settings['smilieinserter'] || !$mybb->settings['smilieinsertercols'] || !$mybb->settings['smilieinsertertot'] || !$smilie['showclickable'])
 979                      {
 980                          $hiddensmilies .= '"'.$find.'": "'.$image.'",';
 981                      }
 982                      elseif($i < $mybb->settings['smilieinsertertot'])
 983                      {
 984                          $dropdownsmilies .= '"'.$find.'": "'.$image.'",';
 985                          ++$i;
 986                      }
 987                      else
 988                      {
 989                          $moresmilies .= '"'.$find.'": "'.$image.'",';
 990                      }
 991  
 992                      for($j = 1; $j < $finds_count; ++$j)
 993                      {
 994                          $find = str_replace(array('\\', '"'), array('\\\\', '\"'), htmlspecialchars_uni($finds[$j]));
 995                          $hiddensmilies .= '"'.$find.'": "'.$image.'",';
 996                      }
 997                  }
 998              }
 999          }
1000  
1001          $basic1 = $basic2 = $align = $font = $size = $color = $removeformat = $email = $link = $list = $code = $sourcemode = "";
1002  
1003          if($mybb->settings['allowbasicmycode'] == 1)
1004          {
1005              $basic1 = "bold,italic,underline,strike|";
1006              $basic2 = "horizontalrule,";
1007          }
1008  
1009          if($mybb->settings['allowalignmycode'] == 1)
1010          {
1011              $align = "left,center,right,justify|";
1012          }
1013  
1014          if($mybb->settings['allowfontmycode'] == 1)
1015          {
1016              $font = "font,";
1017          }
1018  
1019          if($mybb->settings['allowsizemycode'] == 1)
1020          {
1021              $size = "size,";
1022          }
1023  
1024          if($mybb->settings['allowcolormycode'] == 1)
1025          {
1026              $color = "color,";
1027          }
1028  
1029          if($mybb->settings['allowfontmycode'] == 1 || $mybb->settings['allowsizemycode'] == 1 || $mybb->settings['allowcolormycode'] == 1)
1030          {
1031              $removeformat = "removeformat|";
1032          }
1033  
1034          if($mybb->settings['allowemailmycode'] == 1)
1035          {
1036              $email = "email,";
1037          }
1038  
1039          if($mybb->settings['allowlinkmycode'] == 1)
1040          {
1041              $link = "link,unlink";
1042          }
1043  
1044          if($mybb->settings['allowlistmycode'] == 1)
1045          {
1046              $list = "bulletlist,orderedlist|";
1047          }
1048  
1049          if($mybb->settings['allowcodemycode'] == 1)
1050          {
1051              $code = "code,php,";
1052          }
1053  
1054          if($mybb->user['sourceeditor'] == 1)
1055          {
1056              $sourcemode = "MyBBEditor.sourceMode(true);";
1057          }
1058  
1059          return <<<EOF
1060  
1061  <script type="text/javascript">
1062  var partialmode = {$mybb->settings['partialmode']},
1063  opt_editor = {
1064      plugins: "undo",
1065      format: "bbcode",
1066      bbcodeTrim: true,
1067      style: "../jscripts/sceditor/styles/jquery.sceditor.mybb.css",
1068      rtl: {$lang->settings['rtl']},
1069      locale: "mybblang",
1070      enablePasteFiltering: true,
1071      autoUpdate: true,
1072      emoticonsEnabled: {$emoticons_enabled},
1073      emoticons: {
1074          // Emoticons to be included in the dropdown
1075          dropdown: {
1076              {$dropdownsmilies}
1077          },
1078          // Emoticons to be included in the more section
1079          more: {
1080              {$moresmilies}
1081          },
1082          // Emoticons that are not shown in the dropdown but will still be converted. Can be used for things like aliases
1083          hidden: {
1084              {$hiddensmilies}
1085          }
1086      },
1087      emoticonsCompat: true,
1088      toolbar: "{$basic1}{$align}{$font}{$size}{$color}{$removeformat}{$basic2}image,{$email}{$link}|video{$emoticon}|{$list}{$code}quote|maximize,source",
1089  };
1090  {$editor_language}
1091  $(function() {
1092      $("#{$bind}").sceditor(opt_editor);
1093  
1094      MyBBEditor = $("#{$bind}").sceditor("instance");
1095      {$sourcemode}
1096  });
1097  </script>
1098  EOF;
1099      }
1100  }
1101  
1102  /**
1103   * A class for generating side bar blocks.
1104   */
1105  class DefaultSidebarItem
1106  {
1107      /**
1108       * @var string The title of the side bar block.
1109       */
1110      private $_title;
1111  
1112      /**
1113       * @var string The contents of the side bar block.
1114       */
1115      private $_contents;
1116  
1117      /**
1118       * Constructor. Set the title of the side bar block.
1119       *
1120       * @param string $title The title of the side bar block.
1121       */
1122  	function __construct($title="")
1123      {
1124          $this->_title = $title;
1125      }
1126  
1127      /**
1128       * Add menus item to the side bar block.
1129       *
1130       * @param array $items Array of menu items to add. Each menu item should be a nested array of id, link and title.
1131       * @param string $active The ID of the active menu item if there is one.
1132       */
1133  	function add_menu_items($items, $active)
1134      {
1135          global $run_module;
1136  
1137          $this->_contents = "<ul class=\"menu\">";
1138          foreach($items as $item)
1139          {
1140              if(!check_admin_permissions(array("module" => $run_module, "action" => $item['id']), false))
1141              {
1142                  continue;
1143              }
1144  
1145              $class = "";
1146              if($item['id'] == $active)
1147              {
1148                  $class = "active";
1149              }
1150              $item['link'] = htmlspecialchars_uni($item['link']);
1151              $this->_contents .= "<li class=\"{$class}\"><a href=\"{$item['link']}\">{$item['title']}</a></li>\n";
1152          }
1153          $this->_contents .= "</ul>";
1154      }
1155  
1156      /**
1157       * Sets custom html to the contents variable
1158       *
1159       * @param string $html The custom html to set
1160       */
1161  	function set_contents($html)
1162      {
1163          $this->_contents = $html;
1164      }
1165  
1166      /**
1167       * Fetch the HTML markup for the side bar box.
1168       *
1169       * @return string
1170       */
1171  	function get_markup()
1172      {
1173          $markup = "<div class=\"left_menu_box\">\n";
1174          $markup .= "<div class=\"title\">{$this->_title}</div>\n";
1175          if($this->_contents)
1176          {
1177              $markup .= $this->_contents;
1178          }
1179          $markup .= "</div>\n";
1180          return $markup;
1181      }
1182  }
1183  
1184  /**
1185   * Generate a Javascript based popup menu.
1186   */
1187  class DefaultPopupMenu
1188  {
1189      /**
1190       * @var string The title of the popup menu to be shown on the button.
1191       */
1192      private $_title;
1193  
1194      /**
1195       * @var string The ID of this popup menu. Must be unique.
1196       */
1197      private $_id;
1198  
1199      /**
1200       * @var string Built HTML for the items in the popup menu.
1201       */
1202      private $_items;
1203  
1204      /**
1205       * Initialise a new popup menu.
1206       *
1207       * @var string $id The ID of the popup menu.
1208       * @var string $title The title of the popup menu.
1209       */
1210  	function __construct($id, $title='')
1211      {
1212          $this->_id = $id;
1213          $this->_title = $title;
1214      }
1215  
1216      /**
1217       * Add an item to the popup menu.
1218       *
1219       * @param string $text The title of this item.
1220       * @param string $link The page this item should link to.
1221       * @param string $onclick The onclick event handler if we have one.
1222       */
1223  	function add_item($text, $link, $onclick='')
1224      {
1225          if($onclick)
1226          {
1227              $onclick = " onclick=\"{$onclick}\"";
1228          }
1229          $this->_items .= "<div class=\"popup_item_container\"><a href=\"{$link}\"{$onclick} class=\"popup_item\">{$text}</a></div>\n";
1230      }
1231  
1232      /**
1233       * Fetch the contents of the popup menu.
1234       *
1235       * @return string The popup menu.
1236       */
1237  	function fetch()
1238      {
1239          $popup = "<div class=\"popup_menu\" id=\"{$this->_id}_popup\">\n{$this->_items}</div>\n";
1240          if($this->_title)
1241          {
1242              $popup .= "<a href=\"javascript:;\" id=\"{$this->_id}\" class=\"popup_button\">{$this->_title}</a>\n";
1243          }
1244          $popup .= "<script type=\"text/javascript\">\n";
1245          $popup .= "$(\"#{$this->_id}\").popupMenu();\n";
1246          $popup .= "</script>\n";
1247          return $popup;
1248      }
1249  
1250      /**
1251       * Outputs a popup menu to the browser.
1252       */
1253  	function output()
1254      {
1255          echo $this->fetch();
1256      }
1257  }


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref