コード例 #1
0
 /**
  * check requirements
  *
  * @param array $data return theme variables
  * @return bool requirements met
  */
 private function _check_requirements(&$aData)
 {
     // proceed variable check if all requirements are true. If any of them is false, proceed is set false.
     $bProceed = true;
     //lets be optimistic!
     /**
      * check image HTML template
      *
      * @param bool $result
      */
     function check_HTML_image($result)
     {
         $aLabelYesNo = array('wrong', 'right');
         return sprintf('<img src="%s/installer/images/tick-%s.png" alt="Found" />', Yii::app()->baseUrl, $aLabelYesNo[$result]);
     }
     function is_writable_recursive($sDirectory)
     {
         $sFolder = opendir($sDirectory);
         while ($sFile = readdir($sFolder)) {
             if ($sFile != '.' && $sFile != '..' && (!is_writable($sDirectory . "/" . $sFile) || is_dir($sDirectory . "/" . $sFile) && !is_writable_recursive($sDirectory . "/" . $sFile))) {
                 closedir($sFolder);
                 return false;
             }
         }
         closedir($sFolder);
         return true;
     }
     /**
      * check for a specific PHPFunction, return HTML image
      *
      * @param string $function
      * @param string $image return
      * @return bool result
      */
     function check_PHPFunction($sFunctionName, &$sImage)
     {
         $bExists = function_exists($sFunctionName);
         $sImage = check_HTML_image($bExists);
         return $bExists;
     }
     /**
      * check if file or directory exists and is writeable, returns via parameters by reference
      *
      * @param string $path file or directory to check
      * @param int $type 0:undefined (invalid), 1:file, 2:directory
      * @param string $data to manipulate
      * @param string $base key for data manipulation
      * @param string $keyError key for error data
      * @return bool result of check (that it is writeable which implies existance)
      */
     function check_PathWriteable($path, $type, &$aData, $base, $keyError, $bRecursive = false)
     {
         $bResult = false;
         $aData[$base . 'Present'] = 'Not Found';
         $aData[$base . 'Writable'] = '';
         switch ($type) {
             case 1:
                 $exists = is_file($path);
                 break;
             case 2:
                 $exists = is_dir($path);
                 break;
             default:
                 throw new Exception('Invalid type given.');
         }
         if ($exists) {
             $aData[$base . 'Present'] = 'Found';
             if (!$bRecursive && is_writable($path) || $bRecursive && is_writable_recursive($path)) {
                 $aData[$base . 'Writable'] = 'Writable';
                 $bResult = true;
             } else {
                 $aData[$base . 'Writable'] = 'Unwritable';
             }
         }
         $bResult || ($aData[$keyError] = true);
         return $bResult;
     }
     /**
      * check if file exists and is writeable, returns via parameters by reference
      *
      * @param string $file to check
      * @param string $data to manipulate
      * @param string $base key for data manipulation
      * @param string $keyError key for error data
      * @return bool result of check (that it is writeable which implies existance)
      */
     function check_FileWriteable($file, &$data, $base, $keyError)
     {
         return check_PathWriteable($file, 1, $data, $base, $keyError);
     }
     /**
      * check if directory exists and is writeable, returns via parameters by reference
      *
      * @param string $directory to check
      * @param string $data to manipulate
      * @param string $base key for data manipulation
      * @param string $keyError key for error data
      * @return bool result of check (that it is writeable which implies existance)
      */
     function check_DirectoryWriteable($directory, &$data, $base, $keyError, $bRecursive = false)
     {
         return check_PathWriteable($directory, 2, $data, $base, $keyError, $bRecursive);
     }
     //  version check
     if (version_compare(PHP_VERSION, '5.3.0', '<')) {
         $bProceed = !($aData['verror'] = true);
     }
     if (convertPHPSizeToBytes(ini_get('memory_limit')) / 1024 / 1024 < 64 && ini_get('memory_limit') != -1) {
         $bProceed = !($aData['bMemoryError'] = true);
     }
     // mbstring library check
     if (!check_PHPFunction('mb_convert_encoding', $aData['mbstringPresent'])) {
         $bProceed = false;
     }
     // JSON library check
     if (!check_PHPFunction('json_encode', $aData['bJSONPresent'])) {
         $bProceed = false;
     }
     // ** file and directory permissions checking **
     // config directory
     if (!check_DirectoryWriteable(Yii::app()->getConfig('rootdir') . '/application/config', $aData, 'config', 'derror')) {
         $bProceed = false;
     }
     // templates directory check
     if (!check_DirectoryWriteable(Yii::app()->getConfig('tempdir') . '/', $aData, 'tmpdir', 'tperror', true)) {
         $bProceed = false;
     }
     //upload directory check
     if (!check_DirectoryWriteable(Yii::app()->getConfig('uploaddir') . '/', $aData, 'uploaddir', 'uerror', true)) {
         $bProceed = false;
     }
     // Session writable check
     $session = Yii::app()->session;
     /* @var $session CHttpSession */
     $sessionWritable = $session->get('saveCheck', null) === 'save';
     $aData['sessionWritable'] = $sessionWritable;
     $aData['sessionWritableImg'] = check_HTML_image($sessionWritable);
     if (!$sessionWritable) {
         // For recheck, try to set the value again
         $session['saveCheck'] = 'save';
         $bProceed = false;
     }
     // ** optional settings check **
     // gd library check
     if (function_exists('gd_info')) {
         $aData['gdPresent'] = check_HTML_image(array_key_exists('FreeType Support', gd_info()));
     } else {
         $aData['gdPresent'] = check_HTML_image(false);
     }
     // ldap library check
     check_PHPFunction('ldap_connect', $aData['ldapPresent']);
     // php zip library check
     check_PHPFunction('zip_open', $aData['zipPresent']);
     // zlib php library check
     check_PHPFunction('zlib_get_coding_type', $aData['zlibPresent']);
     // imap php library check
     check_PHPFunction('imap_open', $aData['bIMAPPresent']);
     return $bProceed;
 }
コード例 #2
0
 function getMaximumFileUploadSize()
 {
     return min(convertPHPSizeToBytes(ini_get('post_max_size')), convertPHPSizeToBytes(ini_get('upload_max_filesize')));
 }
コード例 #3
0
ファイル: precheck_view.php プロジェクト: sickpig/LimeSurvey
               <td>64MB</td>
               <td><?php 
if (isset($bMemoryError) && $bMemoryError) {
    ?>
<span style='font-weight:bold; color: red'><?php 
    eT("Too low");
    ?>
: <?php 
    echo convertPHPSizeToBytes(ini_get('memory_limit')) / 1024 / 1024;
    ?>
MB</span>
               <?php 
} elseif (ini_get('memory_limit') == '-1') {
    eT("Unlimited");
} else {
    echo convertPHPSizeToBytes(ini_get('memory_limit')) / 1024 / 1024;
    echo ' MB';
}
?>
</td>
        </tr>
        <tr>
               <td><?php 
eT("PHP PDO driver library");
?>
</td>
               <td><?php 
eT("At least one installed");
?>
</td>
               <td><?php 
コード例 #4
0
ファイル: utility.functions.php プロジェクト: hisapi/his
function getMaximumFileUploadSize()
{
    $get_min = min(convertPHPSizeToBytes(ini_get('post_max_size')), convertPHPSizeToBytes(ini_get('upload_max_filesize')));
    if ($get_min == convertPHPSizeToBytes(ini_get('post_max_size'))) {
        return ini_get('post_max_size');
    } else {
        return ini_get('upload_max_filesize');
    }
}
コード例 #5
0
ファイル: precheck_view.php プロジェクト: rouben/LimeSurvey
        <th class='text-center'><?php $clang->eT("Current"); ?></th>
 </tr>
 </thead>
 <tbody>
 <tr>
        <td><?php $clang->eT("PHP version"); ?></td>
        <td>5.3.0+</td>
        <td><?php if (isset($verror) && $verror) { ?><span style='font-weight:bold; color: red'><?php $clang->eT("Outdated"); ?>: <?php echo $phpVersion; ?></span>
        <?php } else { ?><?php echo $phpVersion ; ?> <?php } ?></td>
 </tr>
 <tr>
        <td><?php $clang->eT("Minimum memory available"); ?></td>
        <td>64MB</td>
        <td><?php
        if (isset($bMemoryError) && $bMemoryError) { ?><span style='font-weight:bold; color: red'><?php $clang->eT("Too low"); ?>: <?php echo convertPHPSizeToBytes(ini_get('memory_limit'))/1024/1024; ?>MB</span>
        <?php } elseif (ini_get('memory_limit')=='-1') $clang->eT("Unlimited"); else { echo convertPHPSizeToBytes(ini_get('memory_limit'))/1024/1024; echo ' MB';} ?></td>
 </tr>
 <tr>
        <td><?php $clang->eT("PHP PDO driver library"); ?></td>
        <td><?php $clang->eT("At least one installed"); ?></td>
        <td><?php if (count($dbtypes)==0) { ?><span style='font-weight:bold; color: red'><?php $clang->eT("None found"); ?></span>
        <?php } else { ?><?php echo implode(', ',$dbtypes); ?> <?php } ?></td>
 </tr>
 <tr>
        <td><?php $clang->eT("PHP mbstring library"); ?></td>
        <td><img src="<?php echo Yii::app()->baseUrl; ?>/installer/images/tick-right.png" alt="Yes" /></td>
        <td><?php echo $mbstringPresent; ?></td>
 </tr>
 <tr>
        <td><?php $clang->eT("PHP/PECL JSON library"); ?></td>
        <td><img src="<?php echo Yii::app()->baseUrl; ?>/installer/images/tick-right.png" alt="Yes" /></td>
コード例 #6
0
 protected function _init()
 {
     // Check for most necessary requirements
     // Now check for PHP & db version
     // Do not localize/translate this!
     $dieoutput = '';
     if (version_compare(PHP_VERSION, '5.3.3', '<')) {
         $dieoutput .= 'This script can only be run on PHP version 5.3.3 or later! Your version: ' . PHP_VERSION . '<br />';
     }
     if (!function_exists('mb_convert_encoding')) {
         $dieoutput .= "This script needs the PHP Multibyte String Functions library installed: See <a href='http://manual.limesurvey.org/wiki/Installation_FAQ'>FAQ</a> and <a href='http://de.php.net/manual/en/ref.mbstring.php'>PHP documentation</a><br />";
     }
     if ($dieoutput != '') {
         throw new CException($dieoutput);
     }
     if (ini_get("max_execution_time") < 1200) {
         @set_time_limit(1200);
     }
     // Maximum execution time - works only if safe_mode is off
     if (ini_get('memory_limit') != -1 && convertPHPSizeToBytes(ini_get("memory_limit")) < convertPHPSizeToBytes(Yii::app()->getConfig('memory_limit') . 'M')) {
         @ini_set("memory_limit", Yii::app()->getConfig('memory_limit') . 'M');
         // Set Memory Limit for big surveys
     }
     // The following function (when called) includes FireBug Lite if true
     defined('FIREBUG') or define('FIREBUG', Yii::app()->getConfig('use_firebug_lite'));
     //Every 50th time clean up the temp directory of old files (older than 1 day)
     //depending on the load the  probability might be set higher or lower
     if (rand(1, 50) == 1) {
         cleanTempDirectory();
     }
     //GlobalSettings Helper
     Yii::import("application.helpers.globalsettings");
     enforceSSLMode();
     // This really should be at the top but for it to utilise getGlobalSetting() it has to be here
     if (Yii::app()->getConfig('debug') == 1) {
         //For debug purposes - switch on in config.php
         @ini_set("display_errors", 1);
         error_reporting(E_ALL);
     } elseif (Yii::app()->getConfig('debug') == 2) {
         //For debug purposes - switch on in config.php
         @ini_set("display_errors", 1);
         error_reporting(E_ALL | E_STRICT);
     } else {
         @ini_set("display_errors", 0);
         error_reporting(0);
     }
     //SET LOCAL TIME
     $timeadjust = Yii::app()->getConfig("timeadjust");
     if (substr($timeadjust, 0, 1) != '-' && substr($timeadjust, 0, 1) != '+') {
         $timeadjust = '+' . $timeadjust;
     }
     if (strpos($timeadjust, 'hours') === false && strpos($timeadjust, 'minutes') === false && strpos($timeadjust, 'days') === false) {
         Yii::app()->setConfig("timeadjust", $timeadjust . ' hours');
     }
     //Yii::app()->setConfig('adminimageurl', Yii::app()->getConfig('styleurl').Yii::app()->getConfig('admintheme').'/images/');
     //Yii::app()->setConfig('adminstyleurl', Yii::app()->getConfig('styleurl').Yii::app()->getConfig('admintheme').'/');
 }
コード例 #7
0
function getMaximumFileUploadSize()
{
    // http://stackoverflow.com/questions/13076480/php-get-actual-maximum-upload-size
    return min(convertPHPSizeToBytes(ini_get('post_max_size')), convertPHPSizeToBytes(ini_get('upload_max_filesize')));
}