Beehive PHP Cross Reference Discussion Forums

Source: /json.php - 158 lines - 6151 bytes - Summary - Text - Print

   1  <?php
   2  
   3  /*======================================================================
   4  Copyright Project Beehive Forum 2002
   5  
   6  This file is part of Beehive Forum.
   7  
   8  Beehive Forum is free software; you can redistribute it and/or modify
   9  it under the terms of the GNU General Public License as published by
  10  the Free Software Foundation; either version 3 of the License, or
  11  (at your option) any later version.
  12  
  13  Beehive Forum is distributed in the hope that it will be useful,
  14  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16  GNU General Public License for more details.
  17  
  18  You should have received a copy of the GNU General Public License
  19  along with Beehive; if not, write to the Free Software
  20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  21  USA
  22  ======================================================================*/
  23  
  24  // Bootstrap
  25  require_once  'boot.php';
  26  
  27  // Required includes
  28  require_once  BH_INCLUDE_PATH . 'cache.inc.php';
  29  require_once  BH_INCLUDE_PATH . 'constants.inc.php';
  30  require_once  BH_INCLUDE_PATH . 'format.inc.php';
  31  require_once  BH_INCLUDE_PATH . 'forum.inc.php';
  32  require_once  BH_INCLUDE_PATH . 'html.inc.php';
  33  require_once  BH_INCLUDE_PATH . 'server.inc.php';
  34  // End Required includes
  35  
  36  // User font size
  37  if (isset($_SESSION['FONT_SIZE']) && is_numeric($_SESSION['FONT_SIZE'])) {
  38      $font_size = max(min($_SESSION['FONT_SIZE'], 15), 5);
  39  } else {
  40      $font_size = 10;
  41  }
  42  
  43  // User style
  44  if (isset($_SESSION['STYLE']) && strlen(trim($_SESSION['STYLE'])) > 0) {
  45      $user_style = $_SESSION['STYLE'];
  46  } else {
  47      $user_style = forum_get_setting('default_style', 'strlen', 'default');
  48  }
  49  
  50  // User emoticons
  51  if (isset($_SESSION['EMOTICONS']) && strlen(trim($_SESSION['EMOTICONS'])) > 0) {
  52      $user_emoticons = $_SESSION['EMOTICONS'];
  53  } else {
  54      $user_emoticons = forum_get_setting('default_emoticons', 'strlen', 'default');
  55  }
  56  
  57  // Get the user's saved left frame width.
  58  if (isset($_SESSION['LEFT_FRAME_WIDTH']) && is_numeric($_SESSION['LEFT_FRAME_WIDTH'])) {
  59      $left_frame_width = max(100, $_SESSION['LEFT_FRAME_WIDTH']);
  60  } else {
  61      $left_frame_width = 280;
  62  }
  63  
  64  // Get the attachment max file size (default: 2MB)
  65  if (($attachment_size_limit = forum_get_setting('attachment_size_limit', 'is_numeric', false)) === false) {
  66      $attachment_size_limit = convert_shorthand_filesize(ini_get('upload_max_filesize'));
  67  }
  68  
  69  // Construct the Javascript / JSON array
  70  $json_data = array(
  71      'webtag' => $webtag,
  72      'uid' => $_SESSION['UID'],
  73      'lang' => array(
  74          'loadingdotdotdot' => gettext("Loading..."),
  75          'imageresized' => gettext("This image has been resized (original size %dx%d). To view the full-size image click here."),
  76          'deleteattachmentconfirmation' => gettext("Are you sure you want to delete the selected attachments?"),
  77          'deletemessagesconfirmation' => gettext("Are you sure you want to delete all of the selected messages?"),
  78          'unquote' => gettext("Unquote"),
  79          'quote' => gettext("Quote"),
  80          'searchsuccessfullycompleted' => gettext("Search successfully completed."),
  81          'confirmmarkasread' => gettext("Are you sure you want to mark the selected threads as read?"),
  82          'waitdotdotdot' => gettext("Wait..."),
  83          'more' => gettext("More"),
  84          'pollquestion' => gettext("Poll Question"),
  85          'deletequestion' => gettext("Delete question"),
  86          'allowmultipleoptions' => gettext("Allow multiple options to be selected"),
  87          'addnewoption' => gettext("Add new option"),
  88          'deleteoption' => gettext("Delete option"),
  89          'code' => gettext('Code'),
  90          'retry' => gettext('Retry'),
  91          'cancel' => gettext('Cancel'),
  92          'delete' => gettext('Delete'),
  93          'upload' => gettext('Upload'),
  94      ),
  95      'images' => array(),
  96      'font_size' => $font_size,
  97      'user_style' => $user_style,
  98      'emoticons' => $user_emoticons,
  99      'top_frame' => html_get_top_page(),
 100      'left_frame_width' => max(100, $left_frame_width),
 101      'forum_path' => server_get_forum_path(),
 102      'use_mover_spoiler' => (isset($_SESSION['USE_MOVER_SPOILER']) && $_SESSION['USE_MOVER_SPOILER'] == 'Y') ? 'Y' : 'N',
 103      'show_share_links' => (isset($_SESSION['SHOW_SHARE_LINKS']) && $_SESSION['SHOW_SHARE_LINKS'] == 'Y') ? 'Y' : 'N',
 104      'attachment_size_limit' => $attachment_size_limit,
 105      'frames' => array(
 106          'index' => html_get_frame_name('index'),
 107          'admin' => html_get_frame_name('admin'),
 108          'start' => html_get_frame_name('start'),
 109          'discussion' => html_get_frame_name('discussion'),
 110          'user' => html_get_frame_name('user'),
 111          'pm' => html_get_frame_name('pm'),
 112          'main' => html_get_frame_name('main'),
 113          'ftop' => html_get_frame_name('ftop'),
 114          'fnav' => html_get_frame_name('fnav'),
 115          'left' => html_get_frame_name('left'),
 116          'right' => html_get_frame_name('right'),
 117          'pm_folders' => html_get_frame_name('pm_folders'),
 118          'pm_messages' => html_get_frame_name('pm_messages')
 119      )
 120  );
 121  
 122  if (($images_array = glob("styles/$user_style/images/*")) !== false) {
 123  
 124      foreach ($images_array as $image_filename) {
 125  
 126          $image_filename = basename($image_filename);
 127          $json_data['images'][$image_filename] = html_style_image($image_filename);
 128      }
 129  }
 130  
 131  // Decide on the correct Content-Type and encoding
 132  // of the content. This allows Beehive to reload the
 133  // JSON data via the same script, either for use
 134  // in a <script> tag or via AJAX.
 135  if (isset($_GET['json'])) {
 136  
 137      $content_type = 'application/json';
 138  
 139      $content = json_encode($json_data);
 140  
 141  } else {
 142  
 143      $content_type = 'text/javascript';
 144  
 145      $content = sprintf('var beehive = $.extend({}, beehive, %s);
 146                          $(document).ready(function() {
 147                            $(beehive).trigger("init");
 148                          });', json_encode($json_data));
 149  }
 150  
 151  // Send correct Content-Type header
 152  header(sprintf('Content-type: %s; charset=UTF-8', $content_type), true);
 153  
 154  // Check the cache of the file.
 155  cache_check_last_modified(time(), md5($_SESSION['UID'] . $_SESSION['LOGON'] . $content));
 156  
 157  // Output the content
 158  echo $content;

title

Description

title

Description

title

Description

title

title

Body