[ Index ]
 

Code source de GeekLog 1.4.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/public_html/staticpages/ -> index.php (source)

   1  <?php
   2  
   3  /* Reminder: always indent with 4 spaces (no tabs). */
   4  // +---------------------------------------------------------------------------+
   5  // | Static Page Geeklog Plugin 1.4.3                                          |
   6  // +---------------------------------------------------------------------------+
   7  // | index.php                                                                 |
   8  // |                                                                           |
   9  // | This is the main page for the Geeklog Static Page Plugin                  |
  10  // +---------------------------------------------------------------------------+
  11  // | Copyright (C) 2000-2006 by the following authors:                         |
  12  // |                                                                           |
  13  // | Authors: Tony Bibbs       - tony AT tonybibbs DOT com                     |
  14  // |          Tom Willett      - twillett AT users DOT sourceforge DOT net     |
  15  // |          Dirk Haun        - dirk AT haun-online DOT de                    |
  16  // +---------------------------------------------------------------------------+
  17  // |                                                                           |
  18  // | This program is free software; you can redistribute it and/or             |
  19  // | modify it under the terms of the GNU General Public License               |
  20  // | as published by the Free Software Foundation; either version 2            |
  21  // | of the License, or (at your option) any later version.                    |
  22  // |                                                                           |
  23  // | This program is distributed in the hope that it will be useful,           |
  24  // | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
  25  // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
  26  // | GNU General Public License for more details.                              |
  27  // |                                                                           |
  28  // | You should have received a copy of the GNU General Public License         |
  29  // | along with this program; if not, write to the Free Software Foundation,   |
  30  // | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
  31  // |                                                                           |
  32  // +---------------------------------------------------------------------------+
  33  //
  34  // $Id: index.php,v 1.33 2006/12/10 12:08:40 dhaun Exp $
  35  
  36  require_once  ('../lib-common.php');
  37  
  38  
  39  /**
  40  * Prepare static page for display.
  41  *
  42  * @param    string  $page       static page id
  43  * @param    array   $A          static page data
  44  * @param    int     $noboxes    the user's "noboxes" setting (see Preferences)
  45  * @return   string              HTML for the static page
  46  *
  47  */
  48  function display_page ($page, $A, $noboxes)
  49  {
  50      global $_CONF, $LANG01, $LANG11, $LANG_STATIC, $_IMAGE_TYPE, $_SP_CONF;
  51  
  52      $retval = '';
  53  
  54      if ($A['sp_format'] == 'allblocks' OR $A['sp_format'] == 'leftblocks') {
  55          $retval .= COM_siteHeader ('menu');
  56      } else {
  57          if ($A['sp_format'] <> 'blankpage') {
  58              $retval .= COM_siteHeader ('none');
  59          }
  60      }
  61      if (($A['sp_inblock'] == 1) && ($A['sp_format'] != 'blankpage')) {
  62          $retval .= COM_startBlock (stripslashes ($A['sp_title']), $A['sp_help'],
  63                          COM_getBlockTemplate ('_staticpages_block', 'header'));
  64      }
  65  
  66      $retval .= SP_render_content (stripslashes ($A['sp_content']), $A['sp_php']);
  67  
  68      if ($A['sp_format'] <> 'blankpage') {
  69          $curtime = COM_getUserDateTimeFormat ($A['sp_date']);
  70          $retval .= '<p align="center"><br>';
  71          if ($_SP_CONF['show_date'] == 1) {
  72              $retval .= $LANG_STATIC['lastupdated']. ' ' . $curtime[0];
  73          }
  74  
  75          if ($_SP_CONF['show_hits'] == 1) {
  76              if ($_SP_CONF['show_date'] == 1) {
  77                  $retval .= "; ";
  78              }
  79              $retval .= ' ' . COM_numberFormat ($A['sp_hits'])
  80                      . ' ' . $LANG_STATIC['hits'];
  81          }
  82  
  83          if ($_CONF['hideprintericon'] == 0) {
  84              $retval .= ' <a href="' . COM_buildURL ($_CONF['site_url'] . '/staticpages/index.php?page=' . $page . '&amp;mode=print') . '"><img src="' . $_CONF['layout_url'] . '/images/print.' . $_IMAGE_TYPE . '" alt="' . $LANG01[65] . '" title="' . $LANG_STATIC['printable_format'] . '" border="0"></a>';
  85          }
  86  
  87          if ((SEC_hasAccess ($A['owner_id'], $A['group_id'], $A['perm_owner'],
  88                  $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3) &&
  89                  SEC_hasRights ('staticpages.edit')) {
  90              $retval .= '<br><a href="' . $_CONF['site_admin_url']
  91                      . '/plugins/staticpages/index.php?mode=edit&amp;sp_id='
  92                      . $page . '">';
  93              $retval .= $LANG_STATIC['edit'] . '</a>';
  94          }
  95          $retval .= '</p>';
  96      }
  97      if (($A['sp_inblock'] == 1) && ($A['sp_format'] != 'blankpage')) {
  98          $retval .= COM_endBlock (COM_getBlockTemplate ('_staticpages_block',
  99                                                         'footer'));
 100      }
 101  
 102      if ($A['sp_format'] <> 'blankpage') {
 103          if (($A['sp_format'] == 'allblocks') && ($noboxes != 1)) {
 104              $retval .= COM_siteFooter (true);
 105          } else {
 106              $retval .= COM_siteFooter ();
 107          }
 108      }
 109  
 110      return $retval;
 111  }
 112  
 113  /**
 114  * Prepare static page for print (i.e. display as "printable version").
 115  *
 116  * @param    string  $page       static page id
 117  * @param    array   $A          static page data
 118  * @return   string              HTML for the static page
 119  *
 120  */
 121  function print_page ($page, $A)
 122  {
 123      global $_CONF;
 124  
 125      $template_path = staticpages_templatePath ();
 126      $print = new Template ($template_path);
 127      $print->set_file (array ('print' => 'printable.thtml'));
 128      $print->set_var ('site_url', $_CONF['site_url']);
 129      $print->set_var ('site_name', $_CONF['site_name']);
 130      $print->set_var ('site_slogan', $_CONF['site_slogan']);
 131  
 132      $print->set_var ('page_title', $_CONF['site_name'] . ' - '
 133                                     . stripslashes ($A['sp_title']));
 134      $print->set_var ('sp_url', COM_buildUrl ($_CONF['site_url']
 135                                 . '/staticpages/index.php?page=' . $page));
 136      $print->set_var ('sp_title', stripslashes ($A['sp_title']));
 137      $print->set_var ('sp_content',
 138              SP_render_content (stripslashes ($A['sp_content']), $A['sp_php']));
 139      $print->set_var ('sp_hits', COM_numberFormat ($A['sp_hits']));
 140      $print->parse ('output', 'print');
 141  
 142      return $print->finish ($print->get_var ('output'));
 143  }
 144  
 145  
 146  // MAIN
 147  $error = 0;
 148  
 149  if (!empty ($_USER['uid'])) {
 150      $noboxes = DB_getItem ($_TABLES['userindex'], 'noboxes',
 151                             "uid = '{$_USER['uid']}'");
 152  } else {
 153      $noboxes = 0;
 154  }
 155  
 156  COM_setArgNames (array ('page', 'mode'));
 157  $page = COM_applyFilter (COM_getArgument ('page'));
 158  $mode = COM_applyFilter (COM_getArgument ('mode'));
 159  if ($mode != 'print') {
 160      unset ($mode);
 161  }
 162  
 163  if (empty ($page)) {
 164      $error = 1;
 165  } else {
 166  
 167      $perms = SP_getPerms ();
 168      if (!empty ($perms)) {
 169          $perms = ' AND ' . $perms;
 170      }
 171      $sql = array();
 172      $sql['mysql'] = "SELECT sp_title,sp_content,sp_hits,sp_date,sp_format,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,sp_help,sp_php,sp_inblock FROM {$_TABLES['staticpage']} WHERE (sp_id = '$page')" . $perms;
 173      $sql['mssql'] = "SELECT sp_title,CAST(sp_content AS text) AS sp_content,sp_hits,sp_date,sp_format,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,sp_help,sp_php,sp_inblock FROM {$_TABLES['staticpage']} WHERE (sp_id = '$page')" . $perms;
 174      $result = DB_query ($sql);
 175      $count = DB_numRows ($result);
 176  
 177      if ($count == 0 || $count > 1) {
 178          $error = 1;
 179      }
 180  }
 181  
 182  if (!($error)) {
 183      $A = DB_fetchArray ($result);
 184      $_CONF['pagetitle'] = stripslashes ($A['sp_title']);
 185  
 186      if (!empty ($mode) && ($mode == 'print')) {
 187          $retval = print_page ($page, $A);
 188      } else {
 189          $retval = display_page ($page, $A, $noboxes);
 190      }
 191  
 192      // increment hit counter for page
 193      DB_query ("UPDATE {$_TABLES['staticpage']} SET sp_hits = sp_hits + 1 WHERE sp_id = '$page'");
 194  
 195  } else { // an error occured (page not found, access denied, ...)
 196  
 197      if (empty ($page)) {
 198          $failflg = 0;
 199      } else {
 200          $failflg = DB_getItem ($_TABLES['staticpage'], 'sp_nf', "sp_id='$page'");
 201      }
 202      if ($failflg) {
 203          $retval = COM_siteHeader ('menu');
 204          $retval .= COM_startBlock ($LANG_LOGIN[1], '',
 205                              COM_getBlockTemplate ('_msg_block', 'header'));
 206          $login = new Template ($_CONF['path_layout'] . 'submit');
 207          $login->set_file (array ('login' => 'submitloginrequired.thtml'));
 208          $login->set_var ('login_message', $LANG_LOGIN[2]);
 209          $login->set_var ('site_url', $_CONF['site_url']);
 210          $login->set_var ('lang_login', $LANG_LOGIN[3]);
 211          $login->set_var ('lang_newuser', $LANG_LOGIN[4]);
 212          $login->parse ('output', 'login');
 213          $retval .= $login->finish ($login->get_var ('output'));
 214          $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
 215          $retval .= COM_siteFooter (true);
 216      } else {
 217          $retval = COM_siteHeader ('menu');
 218          $retval .= COM_startBlock ($LANG_ACCESS['accessdenied'], '',
 219                              COM_getBlockTemplate ('_msg_block', 'header'));
 220          $retval .= $LANG_STATIC['deny_msg'];
 221          $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
 222          $retval .= COM_siteFooter (true);
 223      }
 224  }
 225  
 226  echo $retval;
 227  
 228  ?>


Généré le : Wed Nov 21 12:27:40 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics