当前位置: 首页>>代码示例>>PHP>>正文


PHP OX_getMemoryLimitSizeInBytes函数代码示例

本文整理汇总了PHP中OX_getMemoryLimitSizeInBytes函数的典型用法代码示例。如果您正苦于以下问题:PHP OX_getMemoryLimitSizeInBytes函数的具体用法?PHP OX_getMemoryLimitSizeInBytes怎么用?PHP OX_getMemoryLimitSizeInBytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了OX_getMemoryLimitSizeInBytes函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: OX_increaseMemoryLimit

function OX_increaseMemoryLimit($setMemory)
{
    $phpMemoryLimitInBytes = OX_getMemoryLimitSizeInBytes();
    if ($phpMemoryLimitInBytes == -1) {
        return true;
    }
    if ($setMemory > $phpMemoryLimitInBytes) {
        if (@ini_set('memory_limit', $setMemory) === false) {
            return false;
        }
    }
    return true;
}
开发者ID:JackyKit,项目名称:revive-adserver,代码行数:13,代码来源:ti.php

示例2: _checkCriticalPHP

 /**
  * A private method to test the configuration of the user's PHP environment.#
  *
  * Tests the following values, and in the event of a fatal error or a
  * warning, the value set is listed below:
  *
  *  - The PHP version
  *      Sets: $this->aInfo['PHP']['warning']['version']
  *
  *  - The PHP configuration's memory_limit value
  *      Sets: $this->aInfo['PHP']['warning']['memory_limit']
  *
  *  - The PHP configuration's safe_mode value
  *      Sets: $this->aInfo['PHP']['error']['safe_mode']
  *
  *  - The PHP configuration's magic_quotes_runtime value
  *      Sets: $this->aInfo['PHP']['error']['magic_quotes_runtime']
  *
  *  - The PHP configuration's file_uploads value
  *      Sets: $this->aInfo['PHP']['error']['file_uploads']
  *
  *  - The PHP configuration's pcre extension
  *      Sets: $this->aInfo['PHP']['error']['pcre']
  *
  *  - The PHP configuration's xml extension
  *      Sets: $this->aInfo['PHP']['error']['xml']
  *
  *  - The PHP configuration's zlib extension
  *      Sets: $this->aInfo['PHP']['error']['zlib']
  *
  *  - The PHP configuration's database (both mysql and pgsql) extensions
  *      Sets: $this->aInfo['PHP']['error']['mysql']
  *
  *  - The PHP configuration's spl extension
  *      Sets: $this->aInfo['PHP']['error']['spl']
  *
  *  - The PHP configuration's timeout settings
  *      Sets: $this->aInfo['PHP']['error']['timeout']
  *
  * Otherwise, if there are no errors or warnings, then $this->aInfo['PHP']['error']
  * is set to "false".
  *
  * @access private
  * @return integer One of the following values:
  *                      - OA_ENV_ERROR_PHP_NOERROR
  *                      - OA_ENV_ERROR_PHP_VERSION
  *                      - OA_ENV_ERROR_PHP_SAFEMODE
  *                      - OA_ENV_ERROR_PHP_MAGICQ
  *                 Note that sometimes an error value is returned, sometimes
  *                 not, even if there is an actual error - this appears to be
  *                 a historical hangover, where the information set in the
  *                 $this->aInfo array has gradually assumed more importance
  *                 than the return value.
  *
  * @TODO Address the return value oddness, by removing all return values, and
  *       simply rely on the $this->aInfo array, perhaps?
  */
 function _checkCriticalPHP()
 {
     // Test the PHP version
     if (!function_exists('version_compare')) {
         // The user's PHP version is very old - it doesn't
         // even have the version_compare() function!
         $result = OA_ENV_ERROR_PHP_VERSION;
     } else {
         if (version_compare($this->aInfo['PHP']['actual']['version'], $this->aInfo['PHP']['expected']['version'], "<")) {
             $result = OA_ENV_ERROR_PHP_VERSION;
         } else {
             $result = OA_ENV_ERROR_PHP_NOERROR;
         }
     }
     if ($result == OA_ENV_ERROR_PHP_VERSION) {
         $this->aInfo['PHP']['warning']['version'] = "Version {$this->aInfo['PHP']['actual']['version']} is below the minimum supported version of {$this->aInfo['PHP']['expected']['version']}." . "<br />You should upgrade your PHP to at least {$this->aInfo['PHP']['expected']['version']} in order to install " . PRODUCT_NAME . ". " . "Please see the <a href='" . PRODUCT_DOCSURL . "/faq'>FAQ</a> for more information.";
     } else {
         $this->aInfo['PHP']['error'] = false;
     }
     // Test the original memory_limit
     if (!$this->checkOriginalMemory()) {
         $this->aInfo['PHP']['warning']['memory_limit'] = PRODUCT_NAME . " requires a minimum of " . OX_getMemoryLimitSizeInBytes() / 1048576 . " MB to run successfully, although " . "some parts of the application will increase this limitation if required. The current 'memory_limit' value is set to " . $this->aInfo['PHP']['actual']['original_memory_limit'] / 1048576 . " MB, so " . PRODUCT_NAME . " has automatically increased " . "this limit. If possible, please increase the 'memory_limit' value in your server's php.ini file to a minimum of " . OX_getMemoryLimitSizeInBytes() / 1048576 . " MB before continuing.";
     }
     // Ensure that the original memory_limit is not displayed in the systems screen
     unset($this->aInfo['PHP']['actual']['original_memory_limit']);
     // Test the PHP configuration's safe_mode value
     if ($this->aInfo['PHP']['actual']['safe_mode']) {
         $result = OA_ENV_ERROR_PHP_SAFEMODE;
         $this->aInfo['PHP']['error']['safe_mode'] = 'The safe_mode option must be OFF';
     }
     // Test the PHP configuration's magic_quotes_runtime value
     if ($this->aInfo['PHP']['actual']['magic_quotes_runtime']) {
         $result = OA_ENV_ERROR_PHP_MAGICQ;
         $this->aInfo['PHP']['error']['magic_quotes_runtime'] = 'The magic_quotes_runtime option must be OFF';
     }
     // Test the PHP configuration's file_uploads value
     if (!$this->aInfo['PHP']['actual']['file_uploads']) {
         $this->aInfo['PHP']['error']['file_uploads'] = 'The file_uploads option must be ON';
     }
     // Test the required PHP extensions are loaded
     if (!$this->aInfo['PHP']['actual']['pcre']) {
         $this->aInfo['PHP']['error']['pcre'] = 'The pcre extension must be loaded';
     }
//.........这里部分代码省略.........
开发者ID:Jaree,项目名称:revive-adserver,代码行数:101,代码来源:EnvironmentManager.php

示例3: _checkCriticalPHP

 /**
  * A private method to test the configuration of the user's PHP environment.#
  *
  * Tests the following values, and in the event of a fatal error or a
  * warning, the value set is listed below:
  *
  *  - The PHP version
  *      Sets: $this->aInfo['PHP']['warning'][OA_ENV_ERROR_PHP_VERSION]
  *
  *  - The PHP configuration's memory_limit value
  *      Sets: $this->aInfo['PHP']['warning'][OA_ENV_WARNING_MEMORY]
  *
  *  - The PHP configuration's safe_mode value
  *      Sets: $this->aInfo['PHP']['error'][OA_ENV_ERROR_PHP_SAFEMODE]
  *
  *  - The PHP configuration's magic_quotes_runtime value
  *      Sets: $this->aInfo['PHP']['error'][OA_ENV_ERROR_PHP_MAGICQ]
  *
  *  - The PHP configuration's file_uploads value
  *      Sets: $this->aInfo['PHP']['error'][OA_ENV_ERROR_PHP_UPLOADS]
  *
  *  - The PHP configuration's pcre extension
  *      Sets: $this->aInfo['PHP']['error'][OA_ENV_ERROR_PHP_PCRE]
  *
  *  - The PHP configuration's xml extension
  *      Sets: $this->aInfo['PHP']['error'][OA_ENV_ERROR_PHP_XML]
  *
  *  - The PHP configuration's zlib extension
  *      Sets: $this->aInfo['PHP']['error'][OA_ENV_ERROR_PHP_ZLIB]
  *
  *  - The PHP configuration's database (both mysql and pgsql) extensions
  *      Sets: $this->aInfo['PHP']['error'][OA_ENV_ERROR_PHP_MYSQL]
  *
  *  - The PHP configuration's timeout settings
  *      Sets: $this->aInfo['PHP']['error'][OA_ENV_ERROR_PHP_TIMEOUT]
  *
  * Otherwise, if there are no errors or warnings, then $this->aInfo['PHP']['error']
  * is set to "false".
  *
  * @access private
  * @return integer One of the following values:
  *                      - OA_ENV_ERROR_PHP_NOERROR
  *                      - OA_ENV_ERROR_PHP_VERSION
  *                      - OA_ENV_ERROR_PHP_VERSION_NEWER
  *                      - OA_ENV_ERROR_PHP_SAFEMODE
  *                      - OA_ENV_ERROR_PHP_MAGICQ
  *                 Note that sometimes an error value is returned, sometimes
  *                 not, even if there is an actual error - this appears to be
  *                 a historical hangover, where the information set in the
  *                 $this->aInfo array has gradually assumed more importance
  *                 than the return value.
  *
  * @TODO Address the return value oddness, by removing all return values, and
  *       simply rely on the $this->aInfo array, perhaps?
  */
 function _checkCriticalPHP()
 {
     // Test the PHP version
     if (function_exists('version_compare')) {
         $result = version_compare($this->aInfo['PHP']['actual']['version'], $this->aInfo['PHP']['expected']['version'], "<");
         if ($result) {
             $result = OA_ENV_ERROR_PHP_VERSION;
         } elseif (!empty($this->aInfo['PHP']['expected']['version_new'])) {
             $result = version_compare($this->aInfo['PHP']['actual']['version'], $this->aInfo['PHP']['expected']['version_new'], ">=");
             if ($result) {
                 $result = OA_ENV_ERROR_PHP_VERSION_NEWER;
             } else {
                 $result = OA_ENV_ERROR_PHP_NOERROR;
             }
         } else {
             $result = OA_ENV_ERROR_PHP_NOERROR;
         }
     } else {
         // The user's PHP version is well old - it doesn't
         // even have the version_compare() function!
         $result = OA_ENV_ERROR_PHP_VERSION;
     }
     if ($result == OA_ENV_ERROR_PHP_VERSION) {
         $this->aInfo['PHP']['warning'][OA_ENV_ERROR_PHP_VERSION] = "Version {$this->aInfo['PHP']['actual']['version']} is below the minimum supported version of {$this->aInfo['PHP']['expected']['version']}." . "<br />Although you can install OpenX, this is not a supported version, and it is not possible to guarantee that everything will work correctly. " . "Please see the <a href='" . OX_PRODUCT_DOCSURL . "/faq/php-unsupported'>FAQ</a> for more information.";
     } elseif ($result == OA_ENV_ERROR_PHP_VERSION_NEWER) {
         $this->aInfo['PHP']['warning'][OA_ENV_ERROR_PHP_VERSION_NEWER] = "Version {$this->aInfo['PHP']['actual']['version']} is not supported yet." . "<br />Although you can install OpenX, this is not a supported version, and it is not possible to guarantee that everything will work correctly. " . "Please see the <a href='" . OX_PRODUCT_DOCSURL . "/faq/php-unsupported'>FAQ</a> for more information.";
     } else {
         $this->aInfo['PHP']['error'] = false;
     }
     // Test the original memory_limit
     if (!$this->checkOriginalMemory()) {
         $this->aInfo['PHP']['warning'][OA_ENV_WARNING_MEMORY] = MAX_PRODUCT_NAME . " requires a minimum of " . OX_getMemoryLimitSizeInBytes() / 1048576 . " MB to run successfully, although " . "some parts of the application will increase this limitation if required. The current 'memory_limit' value is set to " . $this->aInfo['PHP']['actual']['original_memory_limit'] / 1048576 . " MB, so " . MAX_PRODUCT_NAME . " has automatically increased " . "this limit. If possible, please increase the 'memory_limit' value in your server's php.ini file to a minimum of " . OX_getMemoryLimitSizeInBytes() / 1048576 . " MB before continuing.";
     }
     // Ensure that the original memory_limit is not displayed in the systems screen
     unset($this->aInfo['PHP']['actual']['original_memory_limit']);
     // Test the PHP configuration's safe_mode value
     if ($this->aInfo['PHP']['actual']['safe_mode']) {
         $result = OA_ENV_ERROR_PHP_SAFEMODE;
         $this->aInfo['PHP']['error'][OA_ENV_ERROR_PHP_SAFEMODE] = 'The safe_mode option must be OFF';
     }
     // Test the PHP configuration's magic_quotes_runtime value
     if ($this->aInfo['PHP']['actual']['magic_quotes_runtime']) {
         $result = OA_ENV_ERROR_PHP_MAGICQ;
         $this->aInfo['PHP']['error'][OA_ENV_ERROR_PHP_MAGICQ] = 'The magic_quotes_runtime option must be OFF';
     }
//.........这里部分代码省略.........
开发者ID:villos,项目名称:tree_admin,代码行数:101,代码来源:EnvironmentManager.php

示例4: _checkCriticalPHP

 /**
  * A private method to test the configuration of the user's PHP environment.#
  *
  * Tests the following values, and in the event of a fatal error or a
  * warning, the value set is listed below:
  *
  *  - The PHP version
  *      Sets: $this->aInfo['PHP']['warning']['version']
  *
  *  - The PHP configuration's memory_limit value
  *      Sets: $this->aInfo['PHP']['warning']['memory_limit']
  *
  *  - The PHP configuration's safe_mode value
  *      Sets: $this->aInfo['PHP']['error']['safe_mode']
  *
  *  - The PHP configuration's magic_quotes_runtime value
  *      Sets: $this->aInfo['PHP']['error']['magic_quotes_runtime']
  *
  *  - The PHP configuration's file_uploads value
  *      Sets: $this->aInfo['PHP']['error']['file_uploads']
  *
  *  - The PHP configuration's pcre extension
  *      Sets: $this->aInfo['PHP']['error']['pcre']
  *
  *  - The PHP configuration's xml extension
  *      Sets: $this->aInfo['PHP']['error']['xml']
  *
  *  - The PHP configuration's zlib extension
  *      Sets: $this->aInfo['PHP']['error']['zlib']
  *
  *  - The PHP configuration's database (both mysql and pgsql) extensions
  *      Sets: $this->aInfo['PHP']['error']['mysql']
  *
  *  - The PHP configuration's spl extension
  *      Sets: $this->aInfo['PHP']['error']['spl']
  *
  *  - The PHP configuration's timeout settings
  *      Sets: $this->aInfo['PHP']['error']['timeout']
  *
  * Otherwise, if there are no errors or warnings, then $this->aInfo['PHP']['error']
  * is set to "false".
  *
  * @access private
  * @return integer One of the following values:
  *                      - OA_ENV_ERROR_PHP_NOERROR
  *                      - OA_ENV_ERROR_PHP_VERSION
  *                      - OA_ENV_ERROR_PHP_VERSION_54
  *                      - OA_ENV_ERROR_PHP_VERSION_55
  *                      - OA_ENV_ERROR_PHP_SAFEMODE
  *                      - OA_ENV_ERROR_PHP_MAGICQ
  *                 Note that sometimes an error value is returned, sometimes
  *                 not, even if there is an actual error - this appears to be
  *                 a historical hangover, where the information set in the
  *                 $this->aInfo array has gradually assumed more importance
  *                 than the return value.
  *
  * @TODO Address the return value oddness, by removing all return values, and
  *       simply rely on the $this->aInfo array, perhaps?
  */
 function _checkCriticalPHP()
 {
     // Due to https://bugs.php.net/bug.php?id=65367 we need to blacklist PHP
     // 5.4.0-5.4.19 and 5.5.0-5.5.1
     // Test the PHP version
     if (function_exists('version_compare')) {
         if (version_compare($this->aInfo['PHP']['actual']['version'], $this->aInfo['PHP']['expected']['version'], "<")) {
             $result = OA_ENV_ERROR_PHP_VERSION;
         } elseif (version_compare($this->aInfo['PHP']['actual']['version'], '5.4.0', ">=") && version_compare($this->aInfo['PHP']['actual']['version'], '5.4.20', "<")) {
             if (preg_match('#^5\\.4\\.4-14\\+deb7u(\\d+)$#', $this->aInfo['PHP']['actual']['version'], $m) && $m[1] >= 9) {
                 // Thanks Debian for backporting the fix into 5.4.4-14+deb7u9
                 $result = OA_ENV_ERROR_PHP_NOERROR;
             } else {
                 $result = OA_ENV_ERROR_PHP_VERSION_54;
             }
         } elseif (version_compare($this->aInfo['PHP']['actual']['version'], '5.5.0', ">=") && version_compare($this->aInfo['PHP']['actual']['version'], '5.5.2', "<")) {
             $result = OA_ENV_ERROR_PHP_VERSION_55;
         } else {
             $result = OA_ENV_ERROR_PHP_NOERROR;
         }
     } else {
         // The user's PHP version is well old - it doesn't
         // even have the version_compare() function!
         $result = OA_ENV_ERROR_PHP_VERSION;
     }
     if ($result == OA_ENV_ERROR_PHP_VERSION) {
         $this->aInfo['PHP']['warning']['version'] = "Version {$this->aInfo['PHP']['actual']['version']} is below the minimum supported version of {$this->aInfo['PHP']['expected']['version']}." . "<br />Although you can install " . PRODUCT_NAME . ", this is not a supported version, and it is not possible to guarantee that everything will work correctly. " . "Please see the <a href='" . PRODUCT_DOCSURL . "/faq'>FAQ</a> for more information.";
     } elseif ($result == OA_ENV_ERROR_PHP_VERSION_54 || $result == OA_ENV_ERROR_PHP_VERSION_55) {
         $this->aInfo['PHP']['error']['version'] = "Version {$this->aInfo['PHP']['actual']['version']} is not supported due to a bug that prevents " . PRODUCT_NAME . " from working properly." . "<br />You should upgrade your PHP to at least 5.4.20 or 5.5.2 in order to propery install " . PRODUCT_NAME . ". " . "Please see the <a href='" . PRODUCT_DOCSURL . "/faq'>FAQ</a> for more information.";
         // Exit immediately
         return $result;
     } else {
         $this->aInfo['PHP']['error'] = false;
     }
     // Test the original memory_limit
     if (!$this->checkOriginalMemory()) {
         $this->aInfo['PHP']['warning']['memory_limit'] = PRODUCT_NAME . " requires a minimum of " . OX_getMemoryLimitSizeInBytes() / 1048576 . " MB to run successfully, although " . "some parts of the application will increase this limitation if required. The current 'memory_limit' value is set to " . $this->aInfo['PHP']['actual']['original_memory_limit'] / 1048576 . " MB, so " . PRODUCT_NAME . " has automatically increased " . "this limit. If possible, please increase the 'memory_limit' value in your server's php.ini file to a minimum of " . OX_getMemoryLimitSizeInBytes() / 1048576 . " MB before continuing.";
     }
     // Ensure that the original memory_limit is not displayed in the systems screen
     unset($this->aInfo['PHP']['actual']['original_memory_limit']);
     // Test the PHP configuration's safe_mode value
//.........这里部分代码省略.........
开发者ID:SamWinchester,项目名称:revive-adserver,代码行数:101,代码来源:EnvironmentManager.php

示例5: RV_checkSystemInitialRequirements


//.........这里部分代码省略.........
        return -1;
    }
    // Test for existence of "parse_url" and "strpos", which are
    // special cases required for the display of the error message
    // in the event of anything failing in this test!
    if (!function_exists('parse_url')) {
        $aErrors[] = $errorString1 . 'parse_url' . $errorString2;
        $isSystemOK = false;
        if ($return === true) {
            $return = -2;
        }
    }
    if (!function_exists('strpos')) {
        $aErrors[] = $errorString1 . 'strpos' . $errorString2;
        $isSystemOK = false;
        if ($return === true) {
            $return = -2;
        }
    }
    // Test for existence of "array_intersect", "explode", "ini_get"
    // and "trim", which are all required as part of the code to test
    // which functions are in the "disabled_functions" list below...
    if (!function_exists('array_intersect')) {
        $aErrors[] = $errorString1 . 'array_intersect' . $errorString2;
        $isSystemOK = false;
        if ($return === true) {
            $return = -3;
        }
    }
    if (!function_exists('explode')) {
        $aErrors[] = $errorString1 . 'explode' . $errorString2;
        $isSystemOK = false;
        if ($return === true) {
            $return = -3;
        }
    }
    if (!function_exists('ini_get')) {
        $aErrors[] = $errorString1 . 'ini_get' . $errorString2;
        $isSystemOK = false;
        if ($return === true) {
            $return = -3;
        }
    }
    if (!function_exists('trim')) {
        $aErrors[] = $errorString1 . 'trim' . $errorString2;
        $isSystemOK = false;
        if ($return === true) {
            $return = -3;
        }
    }
    // Test the disabled functons list with required functions list
    // defined above in $aRequiredFunctions
    $aDisabledFunctions = explode(',', ini_get('disable_functions'));
    foreach ($aDisabledFunctions as $key => $value) {
        $aDisabledFunctions[$key] = trim($value);
    }
    $aNeededFunctions = array_intersect($aDisabledFunctions, $aRequiredFunctions);
    if (count($aNeededFunctions) > 0) {
        $isSystemOK = false;
        if ($return === true) {
            $return = -3;
        }
        foreach ($aNeededFunctions as $functionName) {
            $aErrors[] = $errorString1 . $functionName . $errorString2;
        }
    }
    // Check PHP version, as use of the minimum required version of PHP > 5.5.9
    // may result in parse errors, which we want to avoid
    $errorMessage = "PHP version 5.5.9, or greater, was not detected.";
    if (function_exists('version_compare')) {
        $result = version_compare(phpversion(), '5.5.9', '<');
        if ($result) {
            $aErrors[] = $errorMessage;
            $isSystemOK = false;
            if ($return === true) {
                $return = -3;
            }
        }
    }
    // Check minimum memory requirements are okay (24MB)
    $minimumRequiredMemory = OX_getMinimumRequiredMemory();
    $phpMemoryLimit = OX_getMemoryLimitSizeInBytes();
    if ($phpMemoryLimit > 0 && $phpMemoryLimit < $minimumRequiredMemory) {
        // The memory limit is too low, but can it be increased?
        $memoryCanBeSet = OX_checkMemoryCanBeSet();
        if (!$memoryCanBeSet) {
            $minimumRequiredMemoryInMB = $minimumRequiredMemory / 1048576;
            $errorMessage = 'The PHP "memory_limit" value is set to less than the required minimum of ' . $minimumRequiredMemoryInMB . 'MB, but because the built in PHP function "ini_set" ' . 'has been disabled, the memory limit cannot be automatically increased.';
            $aErrors[] = $errorMessage;
            $isSystemOK = false;
            if ($return === true) {
                $return = -4;
            }
        }
    }
    if (!$isSystemOK) {
        return $return;
    }
    return true;
}
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:101,代码来源:pre-check.php


注:本文中的OX_getMemoryLimitSizeInBytes函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。