[ Index ]
 

Code source de e107 0.7.8

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/e107_admin/ -> footer.php (source)

   1  <?php
   2  /*
   3  + ----------------------------------------------------------------------------+
   4  |     e107 website system
   5  |
   6  |     ©Steve Dunstan 2001-2002
   7  |     http://e107.org
   8  |     jalist@e107.org
   9  |
  10  |     Released under the terms and conditions of the
  11  |     GNU General Public License (http://gnu.org).
  12  |
  13  |     $Source: /cvsroot/e107/e107_0.7/e107_admin/footer.php,v $
  14  |     $Revision: 1.25 $
  15  |     $Date: 2006/12/09 06:46:33 $
  16  |     $Author: e107coders $
  17  +----------------------------------------------------------------------------+
  18  */
  19  if (!defined('e107_INIT')) { exit; }
  20  $In_e107_Footer = TRUE;    // For registered shutdown function
  21  global $eTraffic, $error_handler, $db_time, $sql, $mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb, $ADMIN_FOOTER, $e107;
  22  
  23  //
  24  // SHUTDOWN SEQUENCE
  25  //
  26  // The following items have been carefully designed so page processing will finish properly
  27  // Please DO NOT re-order these items without asking first! You WILL break something ;)
  28  // These letters match the USER footer (that's why there is B.1,B.2)
  29  //
  30  // A Ensure sql and traffic objects exist
  31  // B.1 Clear cache if over a week old
  32  // B.2 Send the footer templated data
  33  // C Dump any/all traffic and debug information
  34  // [end of regular-page-only items]
  35  // D Close the database connection
  36  // E Themed footer code
  37  // F Configured footer scripts
  38  // G Browser-Server time sync script (must be the last one generated/sent)
  39  // H Final HTML (/body, /html)
  40  // I collect and send buffered page, along with needed headers
  41  //
  42  
  43  //
  44  // A Ensure sql and traffic objects exist
  45  //
  46  
  47  if(!is_object($sql)){
  48      // reinstigate db connection if another connection from third-party script closed it ...
  49      $sql = new db;
  50      $sql -> db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);
  51  }
  52  if (!is_object($eTraffic)) {
  53      $eTraffic = new e107_traffic;
  54      $eTraffic->Bump('Lost Traffic Counters');
  55  }
  56  //
  57  // B.1 Clear cache if over a week old
  58  //
  59  if (ADMIN == TRUE) {
  60      if ($pref['cachestatus']) {
  61          if (!$sql->db_Select('generic', '*', "gen_type='empty_cache'"))
  62          {
  63              $sql->db_Insert('generic', "0,'empty_cache','".time()."','0','','0',''");
  64          } else {
  65              $row = $sql->db_Fetch();
  66              if (($row['gen_datestamp']+604800) < time()) // If cache not cleared in last 7 days, clear it.
  67              {
  68                  require_once(e_HANDLER."cache_handler.php");
  69                  $ec = new ecache;
  70                  $ec->clear();
  71                  $sql->db_Update('generic', "gen_datestamp='".time()."' WHERE gen_type='empty_cache'");
  72              }
  73          }
  74      }
  75  }
  76  
  77  
  78  //
  79  // B.2 Send footer template
  80  //
  81  if(varset($e107_popup)!=1){
  82  
  83  if (strpos(e_SELF.'?'.e_QUERY, 'menus.php?configure') === FALSE) {
  84      parse_admin($ADMIN_FOOTER);
  85  }
  86  
  87  
  88  //
  89  // C Dump all debug and traffic information
  90  //
  91  $eTimingStop = microtime();
  92  global $eTimingStart;
  93  $rendertime = number_format($eTraffic->TimeDelta( $eTimingStart, $eTimingStop ), 4);
  94  $db_time    = number_format($db_time,4);
  95  $rinfo = '';
  96  
  97      if($pref['displayrendertime']){ $rinfo .= "Render time: {$rendertime} second(s); {$db_time} of that for queries. "; }
  98      if($pref['displaysql']){ $rinfo .= "DB queries: ".$sql -> db_QueryCount().". "; }
  99      if(isset($pref['display_memory_usage']) && $pref['display_memory_usage']){ $rinfo .= "Memory Usage: ".$e107->get_memory_usage(); }
 100      if(isset($pref['displaycacheinfo']) && $pref['displaycacheinfo']){ $rinfo .= $cachestring."."; }
 101      echo ($rinfo ? "\n<div style='text-align:center' class='smalltext'>{$rinfo}</div>\n" : "");
 102  
 103  
 104      if ((ADMIN || $pref['developer']) && E107_DEBUG_LEVEL) {
 105          global $db_debug;
 106          echo "\n<!-- DEBUG -->\n";
 107          $db_debug->Show_All();
 108      }
 109  
 110      /*
 111      changes by jalist 24/01/2005:
 112      show sql queries
 113      usage: add ?showsql to query string, must be admin
 114      */
 115  
 116      if(ADMIN && isset($queryinfo) && is_array($queryinfo))
 117      {
 118          $c=1;
 119          $mySQLInfo = $sql->mySQLinfo;
 120          echo "<table class='fborder' style='width: 100%;'>
 121          <tr>
 122          <td class='fcaption' style='width: 5%;'>ID</td><td class='fcaption' style='width: 95%;'>SQL Queries</td>\n</tr>\n";
 123          foreach ($queryinfo as $infovalue)
 124          {
 125              echo "<tr>\n<td class='forumheader3' style='width: 5%;'>{$c}</td><td class='forumheader3' style='width: 95%;'>{$infovalue}</td>\n</tr>\n";
 126              $c++;
 127          }
 128          echo "</table>";
 129      }
 130  
 131  } // End of regular-page footer (the above NOT done for popups)
 132  
 133  //
 134  // D Close DB connection. We're done talking to underlying MySQL
 135  //
 136      $sql -> db_Close();  // Only one is needed; the db is only connected once even with several $sql objects
 137  
 138      //
 139      // Just before we quit: dump quick timer if there is any
 140      // Works any time we get this far. Not calibrated, but it is quick and simple to use.
 141      // To use: eQTimeOn(); eQTimeOff();
 142      //
 143      $tmp = eQTimeElapsed();
 144      if (strlen($tmp)) {
 145          global $ns;
 146          $ns->tablerender('Quick Admin Timer',"Results: {$tmp} microseconds");
 147      }
 148  
 149  if ($pref['developer']) {
 150      global $oblev_at_start,$oblev_before_start;
 151      if (ob_get_level() != $oblev_at_start) {
 152          $oblev = ob_get_level();
 153          $obdbg = "<div style='text-align:center' class='smalltext'>Software defect detected; ob_*() level {$oblev} at end instead of ($oblev_at_start). POPPING EXTRA BUFFERS!</div>";
 154          while (ob_get_level() > $oblev_at_start) {
 155              ob_end_flush();
 156          }
 157          echo $obdbg;
 158      }
 159      // 061109 PHP 5 has a bug such that the starting level might be zero or one.
 160      // Until they work that out, we'll disable this message.
 161      // Devs can re-enable for testing as needed.
 162      //
 163      if (0 && $oblev_before_start != 0) {
 164          $obdbg = "<div style='text-align:center' class='smalltext'>Software warning; ob_*() level {$oblev_before_start} at start; this page not properly integrated into its wrapper.</div>";
 165          echo $obdbg;
 166      }
 167  }
 168  
 169  if((ADMIN == true || $pref['developer']) && $error_handler->debug == true) {
 170      echo "
 171      <br /><br />
 172      <div>
 173          <h3>PHP Errors:</h3><br />
 174          ".$error_handler->return_errors()."
 175      </div>
 176      ";
 177  }
 178  
 179  //
 180  // E Last themed footer code, usually JS
 181  //
 182  if (function_exists('theme_foot'))
 183  {
 184      echo theme_foot();
 185  }
 186  
 187  //
 188  // F any included JS footer scripts
 189  //
 190  global $footer_js;
 191  if(isset($footer_js) && is_array($footer_js))
 192  {
 193      $footer_js = array_unique($footer_js);
 194      foreach($footer_js as $fname)
 195      {
 196          echo "<script type='text/javascript' src='{$fname}'></script>\n";
 197          $js_included[] = $fname;
 198      }
 199  }
 200  
 201  //
 202  // G final JS script keeps user and server time in sync.
 203  //   It must be the last thing created before sending the page to the user.
 204  //
 205  // see e107.js and class2.php
 206  // This must be done as late as possible in page processing.
 207  $_serverTime=time();
 208  $lastSet = isset($_COOKIE['e107_tdSetTime']) ? $_COOKIE['e107_tdSetTime'] : 0;
 209  if (abs($_serverTime - $lastSet) > 120) {
 210      /* update time delay every couple of minutes.
 211      * Benefit: account for user time corrections and changes in internet delays
 212      * Drawback: each update may cause all server times to display a bit different
 213      */
 214      echo "<script type='text/javascript'>\n";
 215      echo "SyncWithServerTime('{$_serverTime}');
 216         </script>\n";
 217  }
 218  
 219  //
 220  // H Final HTML
 221  //
 222  echo "</body></html>";
 223  
 224  //
 225  // I Send the buffered page data, along with appropriate headers
 226  //
 227  $page = ob_get_clean();
 228  
 229  $etag = md5($page);
 230  header("Cache-Control: must-revalidate");
 231  header("ETag: {$etag}");
 232  
 233  $pref['compression_level'] = 6;
 234  if(isset($_SERVER["HTTP_ACCEPT_ENCODING"]) && strstr($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip")) {
 235      $browser_support = true;
 236  }
 237  if(ini_get("zlib.output_compression") == false && function_exists("gzencode")) {
 238      $server_support = true;
 239  }
 240  if($pref['compress_output'] == true && $server_support == true && $browser_support == true) {
 241      $level = intval($pref['compression_level']);
 242      $page = gzencode($page, $level);
 243      header("Content-Encoding: gzip", true);
 244      header("Content-Length: ".strlen($page), true);
 245      echo $page;
 246  } else {
 247      header("Content-Length: ".strlen($page), true);
 248      echo $page;
 249  }
 250  
 251  unset($In_e107_Footer);
 252  $e107_Clean_Exit=TRUE;    // For registered shutdown function -- let it know all is well!
 253  
 254  ?>


Généré le : Sun Apr 1 01:23:32 2007 par Balluche grâce à PHPXref 0.7