[ Index ]
 

Code source de Joomla 1.0.13

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/administrator/includes/ -> admin.php (source)

   1  <?php
   2  /**
   3  * @version $Id: admin.php 7832 2007-07-03 01:30:02Z robs $
   4  * @package Joomla
   5  * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
   6  * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
   7  * Joomla! is free software. This version may have been modified pursuant
   8  * to the GNU General Public License, and as distributed it includes or
   9  * is derivative of works licensed under the GNU General Public License or
  10  * other free or open source software licenses.
  11  * See COPYRIGHT.php for copyright notices and details.
  12  */
  13  
  14  // no direct access
  15  defined( '_VALID_MOS' ) or die( 'Restricted access' );
  16  
  17  /**
  18  * @param string THe template position
  19  */
  20  function mosCountAdminModules(  $position='left' ) {
  21      global $database;
  22  
  23      $query = "SELECT COUNT( m.id )"
  24      . "\n FROM #__modules AS m"
  25      . "\n WHERE m.published = 1"
  26      . "\n AND m.position = " . $database->Quote( $position )
  27      . "\n AND m.client_id = 1"
  28      ;
  29      $database->setQuery( $query );
  30  
  31      return $database->loadResult();
  32  }
  33  /**
  34  * Loads admin modules via module position
  35  * @param string The position
  36  * @param int 0 = no style, 1 = tabbed
  37  */
  38  function mosLoadAdminModules( $position='left', $style=0 ) {
  39      global $database, $acl, $my;
  40  
  41      $cache =& mosCache::getCache( 'com_content' );
  42  
  43      $query = "SELECT id, title, module, position, content, showtitle, params"
  44      . "\n FROM #__modules AS m"
  45      . "\n WHERE m.published = 1"
  46      . "\n AND m.position = " . $database->Quote( $position )
  47      . "\n AND m.client_id = 1"
  48      . "\n ORDER BY m.ordering"
  49      ;
  50      $database->setQuery( $query );
  51      $modules = $database->loadObjectList();
  52      if($database->getErrorNum()) {
  53          echo "MA ".$database->stderr(true);
  54          return;
  55      }
  56  
  57      switch ($style) {
  58          case 1:
  59              // Tabs
  60              $tabs = new mosTabs(1);
  61              $tabs->startPane( 'modules-' . $position );
  62              foreach ($modules as $module) {
  63                  $params = new mosParameters( $module->params );
  64                  $editAllComponents     = $acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'all' );
  65                  // special handling for components module
  66                  if ( $module->module != 'mod_components' || ( $module->module == 'mod_components' && $editAllComponents ) ) {
  67                      $tabs->startTab( $module->title, 'module' . $module->id );
  68                      if ( $module->module == '' ) {
  69                          mosLoadCustomModule( $module, $params );
  70                      } else {
  71                          mosLoadAdminModule( substr( $module->module, 4 ), $params );
  72                      }
  73                      $tabs->endTab();
  74                  }
  75              }
  76              $tabs->endPane();
  77              break;
  78  
  79          case 2:
  80              // Div'd
  81              foreach ($modules as $module) {
  82                  $params = new mosParameters( $module->params );
  83                  echo '<div>';
  84                  if ( $module->module == '' ) {
  85                      mosLoadCustomModule( $module, $params );
  86                  } else {
  87                      mosLoadAdminModule( substr( $module->module, 4 ), $params );
  88                  }
  89                  echo '</div>';
  90              }
  91              break;
  92  
  93          case 0:
  94          default:
  95              foreach ($modules as $module) {
  96                  $params = new mosParameters( $module->params );
  97                  if ( $module->module == '' ) {
  98                      mosLoadCustomModule( $module, $params );
  99                  } else {
 100                      mosLoadAdminModule( substr( $module->module, 4 ), $params );
 101                  }
 102              }
 103              break;
 104      }
 105  }
 106  /**
 107  * Loads an admin module
 108  */
 109  function mosLoadAdminModule( $name, $params=NULL ) {
 110      global $mosConfig_absolute_path, $mosConfig_live_site, $task;
 111      global $database, $acl, $my, $mainframe, $option;
 112  
 113      // legacy support for $act
 114      $act = mosGetParam( $_REQUEST, 'act', '' );
 115  
 116      $name = str_replace( '/', '', $name );
 117      $name = str_replace( '\\', '', $name );
 118      $path = "$mosConfig_absolute_path/administrator/modules/mod_$name.php";
 119      if (file_exists( $path )) {
 120          require $path;
 121      }
 122  }
 123  
 124  function mosLoadCustomModule( &$module, &$params ) {
 125      global $mosConfig_absolute_path, $mosConfig_cachepath;
 126  
 127      $rssurl             = $params->get( 'rssurl', '' );
 128      $rssitems             = $params->get( 'rssitems', '' );
 129      $rssdesc             = $params->get( 'rssdesc', '' );
 130      $moduleclass_sfx     = $params->get( 'moduleclass_sfx', '' );
 131      $rsscache            = $params->get( 'rsscache', 3600 );
 132      $cachePath            = $mosConfig_cachepath .'/';
 133  
 134      echo '<table cellpadding="0" cellspacing="0" class="moduletable' . $moduleclass_sfx . '">';
 135  
 136      if ($module->content) {
 137          echo '<tr>';
 138          echo '<td>' . $module->content . '</td>';
 139          echo '</tr>';
 140      }
 141  
 142      // feed output
 143      if ( $rssurl ) {
 144          if (!is_writable( $cachePath )) {
 145              echo '<tr>';
 146              echo '<td>Please make cache directory writable.</td>';
 147              echo '</tr>';
 148          } else {
 149              $LitePath = $mosConfig_absolute_path .'/includes/Cache/Lite.php';
 150              require_once ( $mosConfig_absolute_path .'/includes/domit/xml_domit_rss_lite.php');
 151              $rssDoc = new xml_domit_rss_document_lite();
 152              $rssDoc->setRSSTimeout(5);
 153              $rssDoc->useHTTPClient(true);
 154              $rssDoc->useCacheLite(true, $LitePath, $cachePath, $rsscache);
 155              $success = $rssDoc->loadRSS( $rssurl );
 156  
 157              if ( $success )    {
 158                  $totalChannels = $rssDoc->getChannelCount();
 159  
 160                  for ($i = 0; $i < $totalChannels; $i++) {
 161                      $currChannel =& $rssDoc->getChannel($i);
 162  
 163                      $feed_title = $currChannel->getTitle();
 164                      $feed_title = mosCommonHTML::newsfeedEncoding( $rssDoc, $feed_title );
 165  
 166                      echo '<tr>';
 167                      echo '<td><strong><a href="'. $currChannel->getLink() .'" target="_child">';
 168                      echo $feed_title .'</a></strong></td>';
 169                      echo '</tr>';
 170  
 171                      if ($rssdesc) {
 172                          $feed_descrip = $currChannel->getDescription();
 173                          $feed_descrip = mosCommonHTML::newsfeedEncoding( $rssDoc, $feed_descrip );
 174  
 175                          echo '<tr>';
 176                          echo '<td>'. $feed_descrip .'</td>';
 177                          echo '</tr>';
 178                      }
 179  
 180                      $actualItems     = $currChannel->getItemCount();
 181                      $setItems         = $rssitems;
 182  
 183                      if ($setItems > $actualItems) {
 184                          $totalItems = $actualItems;
 185                      } else {
 186                          $totalItems = $setItems;
 187                      }
 188  
 189                      for ($j = 0; $j < $totalItems; $j++) {
 190                          $currItem =& $currChannel->getItem($j);
 191  
 192                          $item_title = $currItem->getTitle();
 193                          $item_title = mosCommonHTML::newsfeedEncoding( $rssDoc, $item_title );
 194  
 195                          $text         = $currItem->getDescription();
 196                          $text         = mosCommonHTML::newsfeedEncoding( $rssDoc, $text );
 197  
 198                          echo '<tr>';
 199                          echo '<td><strong><a href="'. $currItem->getLink() .'" target="_child">';
 200                          echo $item_title .'</a></strong> - '. $text .'</td>';
 201                          echo '</tr>';
 202                      }
 203                  }
 204              }
 205          }
 206      }
 207      echo '</table>';
 208  }
 209  
 210  function mosShowSource( $filename, $withLineNums=false ) {
 211      ini_set('highlight.html', '000000');
 212      ini_set('highlight.default', '#800000');
 213      ini_set('highlight.keyword','#0000ff');
 214      ini_set('highlight.string', '#ff00ff');
 215      ini_set('highlight.comment','#008000');
 216  
 217      if (!($source = @highlight_file( $filename, true ))) {
 218          return 'Operation Failed';
 219      }
 220      $source = explode("<br />", $source);
 221  
 222      $ln = 1;
 223  
 224      $txt = '';
 225      foreach( $source as $line ) {
 226          $txt .= "<code>";
 227          if ($withLineNums) {
 228              $txt .= "<font color=\"#aaaaaa\">";
 229              $txt .= str_replace( ' ', '&nbsp;', sprintf( "%4d:", $ln ) );
 230              $txt .= "</font>";
 231          }
 232          $txt .= "$line<br /><code>";
 233          $ln++;
 234      }
 235      return $txt;
 236  }
 237  
 238  function mosIsChmodable($file) {
 239      $perms = fileperms($file);
 240  
 241      if ( $perms !== FALSE ) {
 242          if (@chmod($file, $perms ^ 0001)) {
 243              @chmod($file, $perms);
 244  
 245              return TRUE;
 246          } // if
 247      }
 248  
 249      return FALSE;
 250  } // mosIsChmodable
 251  
 252  /**
 253  * @param string An existing base path
 254  * @param string A path to create from the base path
 255  * @param int Directory permissions
 256  * @return boolean True if successful
 257  */
 258  function mosMakePath($base, $path='', $mode = NULL) {
 259      global $mosConfig_dirperms;
 260  
 261      // convert windows paths
 262      $path = str_replace( '\\', '/', $path );
 263      $path = str_replace( '//', '/', $path );
 264  
 265      // check if dir exists
 266      if (file_exists( $base . $path )) return true;
 267  
 268      // set mode
 269      $origmask = NULL;
 270      if (isset($mode)) {
 271          $origmask = @umask(0);
 272      } else {
 273          if ($mosConfig_dirperms=='') {
 274              // rely on umask
 275              $mode = 0777;
 276          } else {
 277              $origmask = @umask(0);
 278              $mode = octdec($mosConfig_dirperms);
 279          } // if
 280      } // if
 281  
 282      $parts = explode( '/', $path );
 283      $n = count( $parts );
 284      $ret = true;
 285      if ($n < 1) {
 286          if (substr( $base, -1, 1 ) == '/') {
 287              $base = substr( $base, 0, -1 );
 288          }
 289          $ret = @mkdir($base, $mode);
 290      } else {
 291          $path = $base;
 292          for ($i = 0; $i < $n; $i++) {
 293              $path .= $parts[$i] . '/';
 294              if (!file_exists( $path )) {
 295                  if (!@mkdir(substr($path,0,-1),$mode)) {
 296                      $ret = false;
 297                      break;
 298                  }
 299              }
 300          }
 301      }
 302      if (isset($origmask)) {
 303          @umask($origmask);
 304      }
 305  
 306      return $ret;
 307  }
 308  
 309  function mosMainBody_Admin() {
 310      echo $GLOBALS['_MOS_OPTION']['buffer'];
 311  }
 312  
 313  /*
 314   * Added 1.0.11
 315   */
 316  function josSecurityCheck($width='95%') {
 317      $wrongSettingsTexts = array();
 318  
 319      if ( ini_get('magic_quotes_gpc') != '1' ) {
 320          $wrongSettingsTexts[] = 'PHP magic_quotes_gpc setting is `OFF` instead of `ON`';
 321      }
 322      if ( ini_get('register_globals') == '1' ) {
 323          $wrongSettingsTexts[] = 'PHP register_globals setting is `ON` instead of `OFF`';
 324      }
 325      if ( RG_EMULATION != 0 ) {
 326          $wrongSettingsTexts[] = 'Joomla! &quot;Register Globals Emulation&quot; setting is `ON`. &nbsp; To disable Register Globals Emulation, navigate to Site -> Global Configuration -> Server, select `OFF`, and save.<br /><span style="font-weight: normal; font-style: italic; color: #666;">Register Globals Emulation is `ON` by default for backward compatibility.</span>';
 327      }
 328  
 329      if ( count($wrongSettingsTexts) ) {
 330          ?>
 331          <div style="clear: both; margin: 3px; margin-top: 10px; padding: 5px 15px; display: block; float: left; border: 1px solid #cc0000; background: #ffffcc; text-align: left; width: <?php echo $width;?>;">
 332              <p style="color: #CC0000;">
 333                  Following PHP Server Settings are not optimal for <strong>Security</strong> and it is recommended to change them:
 334              </p>
 335              <ul style="margin: 0px; padding: 0px; padding-left: 15px; list-style: none;" >
 336                  <?php
 337                  foreach ($wrongSettingsTexts as $txt) {
 338                      ?>
 339                      <li style="min-height: 25px; padding-bottom: 5px; padding-left: 25px; color: red; font-weight: bold; background-image: url(../includes/js/ThemeOffice/warning.png); background-repeat: no-repeat; background-position: 0px 2px;" >
 340                          <?php
 341                          echo $txt;
 342                          ?>
 343                      </li>
 344                      <?php
 345                  }
 346                  ?>
 347              </ul>
 348              <p style="color: #666;">
 349                  Please check <a href="http://www.joomla.org/security10" target="_blank" style="color: blue; text-decoration: underline">the Official Joomla! Server Security post</a> for more information.
 350              </p>
 351          </div>
 352          <?php
 353      }
 354  }
 355  ?>


Généré le : Wed Nov 21 14:43:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics