當前位置: 首頁>>代碼示例>>PHP>>正文


PHP utils::ConvertToBytes方法代碼示例

本文整理匯總了PHP中utils::ConvertToBytes方法的典型用法代碼示例。如果您正苦於以下問題:PHP utils::ConvertToBytes方法的具體用法?PHP utils::ConvertToBytes怎麽用?PHP utils::ConvertToBytes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在utils的用法示例。


在下文中一共展示了utils::ConvertToBytes方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: GetMaxUpload

 protected function GetMaxUpload()
 {
     $iMaxUpload = ini_get('upload_max_filesize');
     if (!$iMaxUpload) {
         $sRet = Dict::S('Attachments:UploadNotAllowedOnThisSystem');
     } else {
         $iMaxUpload = utils::ConvertToBytes($iMaxUpload);
         if ($iMaxUpload > 1024 * 1024 * 1024) {
             $sRet = Dict::Format('Attachment:Max_Go', sprintf('%0.2f', $iMaxUpload / (1024 * 1024 * 1024)));
         } else {
             if ($iMaxUpload > 1024 * 1024) {
                 $sRet = Dict::Format('Attachment:Max_Mo', sprintf('%0.2f', $iMaxUpload / (1024 * 1024)));
             } else {
                 $sRet = Dict::Format('Attachment:Max_Ko', sprintf('%0.2f', $iMaxUpload / 1024));
             }
         }
     }
     return $sRet;
 }
開發者ID:leandroborgeseng,項目名稱:bhtm,代碼行數:19,代碼來源:main.attachments.php

示例2: SetMemoryLimit

function SetMemoryLimit($oP)
{
    $sMemoryLimit = trim(ini_get('memory_limit'));
    if (empty($sMemoryLimit)) {
        // On some PHP installations, memory_limit does not exist as a PHP setting!
        // (encountered on a 5.2.0 under Windows)
        // In that case, ini_set will not work, let's keep track of this and proceed with the data load
        $oP->p("No memory limit has been defined in this instance of PHP");
    } else {
        // Check that the limit will allow us to load the data
        //
        $iMemoryLimit = utils::ConvertToBytes($sMemoryLimit);
        if ($iMemoryLimit < SAFE_MINIMUM_MEMORY) {
            if (ini_set('memory_limit', SAFE_MINIMUM_MEMORY) === FALSE) {
                $oP->p("memory_limit is too small: {$iMemoryLimit} and can not be increased by the script itself.");
            } else {
                $oP->p("memory_limit increased from {$iMemoryLimit} to " . SAFE_MINIMUM_MEMORY . ".");
            }
        }
    }
}
開發者ID:besmirzanaj,項目名稱:itop-code,代碼行數:21,代碼來源:backoffice.dataloader.php

示例3: GetFormElementForField


//.........這裏部分代碼省略.........
                 $sEditValue = $oAttDef->GetEditValue($value);
                 $sPreviousLog = is_object($value) ? $value->GetAsHTML($oPage, true, array('AttributeText', 'RenderWikiHtml')) : '';
                 $iEntriesCount = is_object($value) ? count($value->GetIndex()) : 0;
                 $sHidden = "<input type=\"hidden\" id=\"{$iId}_count\" value=\"{$iEntriesCount}\"/>";
                 // To know how many entries the case log already contains
                 $sHTMLValue = "<div class=\"caselog\" {$sStyle}><table style=\"width:100%;\"><tr><td>{$sHeader}<textarea style=\"border:0;width:100%\" title=\"{$sHelpText}\" name=\"attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}\" rows=\"8\" cols=\"40\" id=\"{$iId}\">" . htmlentities($sEditValue, ENT_QUOTES, 'UTF-8') . "</textarea>{$sPreviousLog}</td><td>{$sValidationField}</td></tr></table>{$sHidden}</div>";
                 $oPage->add_ready_script("\$('#{$iId}').bind('keyup change validate', function(evt, sFormId) { return ValidateCaseLogField('{$iId}', {$bMandatory}, sFormId) } );");
                 // Custom validation function
                 break;
             case 'HTML':
                 $oWidget = new UIHTMLEditorWidget($iId, $oAttDef, $sNameSuffix, $sFieldPrefix, $sHelpText, $sValidationField, $value, $bMandatory);
                 $sHTMLValue = $oWidget->Display($oPage, $aArgs);
                 break;
             case 'LinkedSet':
                 if ($oAttDef->IsIndirect()) {
                     $oWidget = new UILinksWidget($sClass, $sAttCode, $iId, $sNameSuffix, $oAttDef->DuplicatesAllowed(), $aArgs);
                 } else {
                     $oWidget = new UILinksWidgetDirect($sClass, $sAttCode, $iId, $sNameSuffix, $aArgs);
                 }
                 $aEventsList[] = 'validate';
                 $aEventsList[] = 'change';
                 $oObj = isset($aArgs['this']) ? $aArgs['this'] : null;
                 $sHTMLValue = $oWidget->Display($oPage, $value, array(), $sFormPrefix, $oObj);
                 break;
             case 'Document':
                 $aEventsList[] = 'validate';
                 $aEventsList[] = 'change';
                 $oDocument = $value;
                 // Value is an ormDocument object
                 $sFileName = '';
                 if (is_object($oDocument)) {
                     $sFileName = $oDocument->GetFileName();
                 }
                 $iMaxFileSize = utils::ConvertToBytes(ini_get('upload_max_filesize'));
                 $sHTMLValue = "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"{$iMaxFileSize}\" />\n";
                 $sHTMLValue .= "<input name=\"attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}[filename]\" type=\"hidden\" id=\"{$iId}\" \" value=\"" . htmlentities($sFileName, ENT_QUOTES, 'UTF-8') . "\"/>\n";
                 $sHTMLValue .= "<span id=\"name_{$iInputId}\">{$sFileName}</span><br/>\n";
                 $sHTMLValue .= "<input title=\"{$sHelpText}\" name=\"attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}[fcontents]\" type=\"file\" id=\"file_{$iId}\" onChange=\"UpdateFileName('{$iId}', this.value)\"/>&nbsp;{$sValidationField}\n";
                 break;
             case 'StopWatch':
                 $sHTMLValue = "The edition of a stopwatch is not allowed!!!";
                 break;
             case 'List':
                 // Not editable for now...
                 $sHTMLValue = '';
                 break;
             case 'One Way Password':
                 $aEventsList[] = 'validate';
                 $oWidget = new UIPasswordWidget($sAttCode, $iId, $sNameSuffix);
                 $sHTMLValue = $oWidget->Display($oPage, $aArgs);
                 // Event list & validation is handled  directly by the widget
                 break;
             case 'ExtKey':
                 $aEventsList[] = 'validate';
                 $aEventsList[] = 'change';
                 $oAllowedValues = MetaModel::GetAllowedValuesAsObjectSet($sClass, $sAttCode, $aArgs);
                 $sFieldName = $sFieldPrefix . $sAttCode . $sNameSuffix;
                 $aExtKeyParams = $aArgs;
                 $aExtKeyParams['iFieldSize'] = $oAttDef->GetMaxSize();
                 $aExtKeyParams['iMinChars'] = $oAttDef->GetMinAutoCompleteChars();
                 $sHTMLValue = UIExtKeyWidget::DisplayFromAttCode($oPage, $sAttCode, $sClass, $oAttDef->GetLabel(), $oAllowedValues, $value, $iId, $bMandatory, $sFieldName, $sFormPrefix, $aExtKeyParams);
                 $sHTMLValue .= "<!-- iFlags: {$iFlags} bMandatory: {$bMandatory} -->\n";
                 break;
             case 'RedundancySetting':
                 $sHTMLValue = '<table>';
                 $sHTMLValue .= '<tr>';
開發者ID:besmirzanaj,項目名稱:itop-code,代碼行數:67,代碼來源:cmdbabstract.class.inc.php

示例4: CheckServerConnection

 /**
  * Helper function check the connection to the database, verify a few conditions (minimum version, etc...) and (if connected)
  * enumerate the existing databases (if possible)
  * @return mixed false if the connection failed or array('checks' => Array of CheckResult, 'databases' => Array of database names (as strings) or null if not allowed)
  */
 static function CheckServerConnection($sDBServer, $sDBUser, $sDBPwd)
 {
     $aResult = array('checks' => array(), 'databases' => null);
     try {
         $oDBSource = new CMDBSource();
         $oDBSource->Init($sDBServer, $sDBUser, $sDBPwd);
         $aResult['checks'][] = new CheckResult(CheckResult::INFO, "Connection to '{$sDBServer}' as '{$sDBUser}' successful.");
         $aResult['checks'][] = new CheckResult(CheckResult::INFO, "Info - User privileges: " . $oDBSource->GetRawPrivileges());
         $sDBVersion = $oDBSource->GetDBVersion();
         if (version_compare($sDBVersion, self::MYSQL_MIN_VERSION, '>=')) {
             $aResult['checks'][] = new CheckResult(CheckResult::INFO, "Current MySQL version ({$sDBVersion}), greater than minimum required version (" . self::MYSQL_MIN_VERSION . ")");
             // Check some server variables
             $iMaxAllowedPacket = $oDBSource->GetServerVariable('max_allowed_packet');
             $iMaxUploadSize = utils::ConvertToBytes(ini_get('upload_max_filesize'));
             if ($iMaxAllowedPacket >= 500 + $iMaxUploadSize) {
                 $aResult['checks'][] = new CheckResult(CheckResult::INFO, "MySQL server's max_allowed_packet ({$iMaxAllowedPacket}) is big enough compared to upload_max_filesize ({$iMaxUploadSize}).");
             } else {
                 if ($iMaxAllowedPacket < $iMaxUploadSize) {
                     $aResult['checks'][] = new CheckResult(CheckResult::WARNING, "MySQL server's max_allowed_packet ({$iMaxAllowedPacket}) is not big enough. Please, consider setting it to at least " . (500 + $iMaxUploadSize) . ".");
                 }
             }
             $iMaxConnections = $oDBSource->GetServerVariable('max_connections');
             if ($iMaxConnections < 5) {
                 $aResult['checks'][] = new CheckResult(CheckResult::WARNING, "MySQL server's max_connections ({$iMaxConnections}) is not enough. Please, consider setting it to at least 5.");
             } else {
                 $aResult['checks'][] = new CheckResult(CheckResult::INFO, "MySQL server's max_connections is set to {$iMaxConnections}.");
             }
         } else {
             $aResult['checks'][] = new CheckResult(CheckResult::ERROR, "Error: Current MySQL version is ({$sDBVersion}), minimum required version (" . self::MYSQL_MIN_VERSION . ")");
         }
         try {
             $aResult['databases'] = $oDBSource->ListDB();
         } catch (Exception $e) {
             $aResult['databases'] = null;
         }
     } catch (Exception $e) {
         return false;
     }
     return $aResult;
 }
開發者ID:kira8565,項目名稱:ITOP203-ZHCN,代碼行數:45,代碼來源:setuputils.class.inc.php

示例5: define

 */
define('SAFE_MINIMUM_MEMORY', 64 * 1024 * 1024);
require_once '../approot.inc.php';
require_once APPROOT . '/application/utils.inc.php';
require_once APPROOT . '/setup/setuppage.class.inc.php';
require_once APPROOT . '/setup/moduleinstaller.class.inc.php';
$sMemoryLimit = trim(ini_get('memory_limit'));
if (empty($sMemoryLimit)) {
    // On some PHP installations, memory_limit does not exist as a PHP setting!
    // (encountered on a 5.2.0 under Windows)
    // In that case, ini_set will not work, let's keep track of this and proceed with the data load
    SetupPage::log_info("No memory limit has been defined in this instance of PHP");
} else {
    // Check that the limit will allow us to load the data
    //
    $iMemoryLimit = utils::ConvertToBytes($sMemoryLimit);
    if ($iMemoryLimit < SAFE_MINIMUM_MEMORY) {
        if (ini_set('memory_limit', SAFE_MINIMUM_MEMORY) === FALSE) {
            SetupPage::log_error("memory_limit is too small: {$iMemoryLimit} and can not be increased by the script itself.");
        } else {
            SetupPage::log_info("memory_limit increased from {$iMemoryLimit} to " . SAFE_MINIMUM_MEMORY . ".");
        }
    }
}
function FatalErrorCatcher($sOutput)
{
    if (preg_match('|<phpfatalerror>.*</phpfatalerror>|s', $sOutput, $aMatches)) {
        header("HTTP/1.0 500 Internal server error.");
        $errors = '';
        foreach ($aMatches as $sMatch) {
            $errors .= strip_tags($sMatch) . "\n";
開發者ID:kira8565,項目名稱:ITOP203-ZHCN,代碼行數:31,代碼來源:ajax.dataloader.php


注:本文中的utils::ConvertToBytes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。