コード例 #1
0
 /**
  * Charge le module demand�
  *
  */
 function loadModule()
 {
     $moduleName = $this->request->getModuleName();
     $db =& Db::getInstance();
     if (ereg('admin', $moduleName)) {
         $this->lang->reloadLangFile();
     }
     if (!$moduleName) {
         $moduleName = $this->defaultModuleName;
     }
     if ($moduleName == 'list_logos') {
         $authorized = true;
     } else {
         $b_writeDir = checkDirWritable();
         /**
          * very first : logo selection is allowed
          */
         /**
          * first look if installation is needed 
          */
         if (!is_file(INCLUDE_PATH . "/config/config.php") || !defined('DB_HOST') || !defined('SU_LOGIN') || !defined('INSTALL_OK')) {
             if (!Request::isCurrentModuleAnInstallModule()) {
                 Request::redirectToModule('install_welcome');
             }
             $authorized = true;
         } else {
             if (!$db->isReady() && substr_count(Request::getCurrentCompleteUrl(), 'mod=login') === 0 && substr_count(Request::getCurrentCompleteUrl(), 'mod=logout') === 0) {
                 Request::redirectToModule('admin_db_config');
             } else {
                 if ($b_writeDir === false) {
                     // case there is a write problem, we load server_info page to indicate the user the problem
                     $moduleName = 'admin_server_info';
                     $authorized = true;
                 } else {
                     if ($db->isReady()) {
                         if (version_compare($db->getVersion(), PHPMV_VERSION) == -1) {
                             $moduleName = 'admin_update';
                             $authorized = true;
                         } else {
                             if (version_compare($db->getVersion(), PHPMV_VERSION) == 1) {
                                 trigger_error("There is a problem : your database is more recent than your phpMyVisites files! Try to upload the last release of phpMyVisites on your server.", E_USER_ERROR);
                             }
                         }
                     }
                 }
             }
         }
     }
     /**
      * else it's ok! Load module
      */
     // update module in the object request, used for hidden field in the login form
     $this->request->setModuleName($moduleName);
     // manage the user, is he authorized to see this module ?
     $me =& User::getInstance();
     if (isset($authorized) || $me->isAuthorized($moduleName) || $this->request->isCrontabAllowed()) {
         $module = Module::factory($moduleName);
     } else {
         $module = Module::factory('login');
     }
     if (!is_subclass_of($module, 'Module')) {
         trigger_error('Unable to load: ' . $moduleName . ' module', E_USER_ERROR);
     }
     $module->init($this->request, null);
     $this->module =& $module;
 }
コード例 #2
0
function getSystemInformation(&$tpl)
{
    $infos = array();
    // directory to write
    $infos['dirs'] = checkDirWritable();
    // php version
    $infos['php_version'] = phpversion();
    $infos['php_ok'] = version_compare(PHP_VERSION_NEEDED, $infos['php_version']) === -1;
    $extensions = @get_loaded_extensions();
    // Gd version
    if (in_array('gd', $extensions)) {
        $gdInfo = gd_info();
        $infos['gd_version'] = $gdInfo['GD Version'];
        ereg("([0-9]{1})", $gdInfo['GD Version'], $gdVersion);
        $gdVersion[0] >= 2 ? $infos['gd_ok'] = true : ($infos['gd_ok'] = false);
        // Freetype
        $gdInfo['FreeType Support'] === true && function_exists('imagettfbbox') ? $infos['freetype_ok'] = true : ($infos['freetype_ok'] = false);
    }
    // Mysql + version
    if (in_array('mysql', $extensions)) {
        $infos['mysql_ok'] = true;
        $infos['mysql_version'] = getMysqlVersion();
    }
    // server version
    $infos['server_version'] = addslashes($_SERVER['SERVER_SOFTWARE']);
    // server os (linux)
    $infos['server_os'] = @php_uname();
    // servert time
    $infos['server_time'] = date('H:i:s');
    /*
    //Tous ce qui est relatif a XML
    if (in_array('xml', $extensions) 
    	&& function_exists('utf8_decode') 
    	&& function_exists('utf8_encode') )
    {
    	$infos['xml_ok'] = true;
    }
    */
    if (function_exists('set_time_limit')) {
        $infos['set_time_limit_ok'] = true;
    }
    if (function_exists('utf8_encode') && function_exists('utf8_decode')) {
        $infos['php_xml'] = true;
    }
    if (function_exists('mail')) {
        $infos['mail_ok'] = true;
    }
    //Registre global
    $infos['register_globals'] = ini_get('register_globals') != 0;
    if ($memoryValue = getMemoryValue()) {
        $infos['memory'] = $memoryValue . "M";
        if ($memoryValue < MEMORY_LIMIT) {
            $tpl->assign("memory_limit", "PHP's memory_limit is " . $infos['memory'] . ". If this is too low, phpMyVisites may not work correctly on high traffic websites! Attempting to raise limit to " . MEMORY_LIMIT . "M...");
            if (setMemoryLimit()) {
                $tpl->assign("memory_limit_ok", "Memory set to " . MEMORY_LIMIT . "M!");
                $infos['memory_ok'] = true;
            } else {
                $tpl->assign("memory_limit", "Failed to set memory_limit to 20M. If phpMyVisites doesn't work correctly, try to raise this limit to at least 20M, look in the php.ini file or ask your server administrator.");
            }
            $infos['memory'] = @ini_get('memory_limit');
        } else {
            $infos['memory_ok'] = true;
        }
    }
    // server uptime from mysql uptime
    $res = query('SHOW STATUS');
    if ($res) {
        while ($row = mysql_fetch_array($res)) {
            $serverStatus[$row[0]] = $row[1];
        }
        $infos['server_uptime'] = date("r", time() - $serverStatus['Uptime']);
    }
    return $infos;
}