本文整理汇总了PHP中XenForo_Helper_File::log方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Helper_File::log方法的具体用法?PHP XenForo_Helper_File::log怎么用?PHP XenForo_Helper_File::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Helper_File
的用法示例。
在下文中一共展示了XenForo_Helper_File::log方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateConfig
public static function updateConfig($key, $value)
{
/** @var XenForo_Application $app */
$app = XenForo_Application::getInstance();
$path = $app->getRootDir() . '/library/config.php';
$originalContents = file_get_contents($path);
$varNamePattern = '#(\\n|^)(?<varName>\\$config';
foreach (explode('.', $key) as $i => $keyPart) {
// try to match the quote
$varNamePattern .= '\\[([\'"]?)' . preg_quote($keyPart, '#') . '\\' . ($i + 3) . '\\]';
}
$varNamePattern .= ').+(\\n|$)#';
$candidates = array();
$offset = 0;
while (true) {
if (!preg_match($varNamePattern, $originalContents, $matches, PREG_OFFSET_CAPTURE, $offset)) {
break;
}
$offset = $matches[0][1] + strlen($matches[0][0]);
$candidates[] = $matches;
}
if (count($candidates) !== 1) {
XenForo_Helper_File::log(__METHOD__, sprintf('count($candidates) = %d', count($candidates)));
return;
}
$matches = reset($candidates);
$replacement = $matches[1][0] . $matches['varName'][0] . ' = ' . var_export($value, true) . ';' . $matches[5][0];
$contents = substr_replace($originalContents, $replacement, $matches[0][1], strlen($matches[0][0]));
DevHelper_Generator_File::writeFile($path, $contents, true, false);
}
示例2: deleteAllCached
public static function deleteAllCached()
{
foreach (self::$_cached as $url => $tempFile) {
if (XenForo_Application::debugMode()) {
$fileSize = @filesize($tempFile);
}
$deleted = @unlink($tempFile);
if (XenForo_Application::debugMode()) {
XenForo_Helper_File::log(__CLASS__, call_user_func_array('sprintf', array('delete %s -> %s, %s, %d bytes', $url, $tempFile, $deleted ? 'succeeded' : 'failed', !empty($fileSize) ? $fileSize : 0)));
}
}
self::$_cached = array();
}
示例3: assertNoErrors
public static function assertNoErrors(XenForo_DataWriter $dw, $checkMethod, $dataType)
{
switch (strtolower($checkMethod)) {
case 'delete':
case 'predelete':
$checkMethod = 'preDelete';
break;
case 'save':
case 'presave':
default:
$checkMethod = 'preSave';
break;
}
$dw->{$checkMethod}();
if ($errors = $dw->getErrors()) {
$errorString = implode("\n\t", $errors);
XenForo_Helper_File::log('webdav-error', sprintf("%s:\n\t%s\n\t%s", $dataType, $dw->get('title'), $errorString), false);
// Note that in order to have Dreamweaver actually show an error, we have to use 'Forbidden'.
throw new Sabre_DAV_Exception_Forbidden($errorString);
}
}
示例4: _makeRequest
public function _makeRequest($method, $path = '', $params = null, $headers = array(), $data = null)
{
if (empty($params)) {
$params = array();
}
if (!is_array($headers)) {
$headers = array($headers);
}
if (isset($headers['Content-MD5'])) {
unset($headers['Content-MD5']);
}
if (is_resource($data)) {
throw new Zend_Service_Amazon_S3_Exception("No support for stream data");
}
$data = strval($data);
$headers['x-amz-content-sha256'] = Zend_Crypt::hash('sha256', $data);
$headers['x-amz-date'] = sprintf('%sT%sZ', gmdate('Ymd', XenForo_Application::$time), gmdate('His', XenForo_Application::$time));
$headers['Host'] = parse_url($this->_endpoint, PHP_URL_HOST);
$retryCount = 0;
// build the end point (with path)
$endpoint = clone $this->_endpoint;
$path = '/' . $path;
$endpoint->setPath($path);
$this->addSignatureAws4($method, $path, $params, $headers);
$client = self::getHttpClient();
$client->resetParameters();
$client->setUri($endpoint);
$client->setAuth(false);
$client->setHeaders($headers);
if (is_array($params)) {
foreach ($params as $name => $value) {
$client->setParameterGet($name, $value);
}
}
if ($method == 'PUT' && $data !== null) {
if (!isset($headers['Content-type'])) {
$headers['Content-type'] = self::getMimeType($path);
}
$client->setRawData($data, $headers['Content-type']);
}
do {
$retry = false;
$response = $client->request($method);
$responseCode = $response->getStatus();
if (XenForo_Application::debugMode() && $responseCode != 200) {
XenForo_Helper_File::log(__METHOD__, sprintf("%s %s -> %d %s\n\n", $method, var_export($headers, true), $responseCode, $response->getBody()));
}
// some 5xx errors are expected, so retry automatically
if ($responseCode >= 500 && $responseCode < 600 && $retryCount <= 5) {
$retry = true;
$retryCount++;
sleep($retryCount / 4 * $retryCount);
} elseif ($responseCode == 307) {
// need to redirect, new S3 endpoint given
// this should never happen as Zend_Http_Client will redirect automatically
} elseif ($responseCode == 100) {
// 'OK to Continue';
}
} while ($retry);
return $response;
}
示例5: _saveConfig
private static function _saveConfig(array $config)
{
$configOptionId = self::_getConfigOptionId($config['apiUrl']);
/** @var XenForo_DataWriter_Option $optionDw */
$optionDw = XenForo_DataWriter::create('XenForo_DataWriter_Option');
$optionDw->setExistingData($configOptionId);
$optionDw->set('option_value', $config);
if ($optionDw->save()) {
XenForo_Application::getOptions()->set($configOptionId, $config);
if (XenForo_Application::debugMode()) {
XenForo_Helper_File::log(__CLASS__, sprintf('%s($apiUrl=%s)', __METHOD__, $config['apiUrl']));
}
return true;
}
return false;
}
示例6: assertNoDwErrors
public function assertNoDwErrors(XenForo_DataWriter $dw, $checkMethod, $dataType)
{
switch (strtolower($checkMethod)) {
case 'delete':
case 'predelete':
$checkMethod = 'preDelete';
break;
case 'save':
case 'presave':
default:
$checkMethod = 'preSave';
break;
}
$dw->{$checkMethod}();
if ($errors = $dw->getErrors()) {
$filePath = $this->getDirectory($dw->getMergedData()) . self::$s . $this->getFileName($dw->getMergedData());
if (count($errors) == 1) {
$error = htmlspecialchars_decode($errors[key($errors)]);
// Yes Nathan, I could use regex but fuu
if (strpos($error, 'Line ') === 0) {
$pos = strpos($error, ':');
$line = substr($error, 5, $pos - 5);
$error = trim(substr($error, $pos + 1));
}
$errorString = 'E: ' . $dataType . ' Error: ' . $error . " in " . $filePath;
if (isset($line)) {
$errorString .= ", line {$line} \n\n";
} else {
$errorString .= "\n\n";
}
} else {
foreach ($errors as &$err) {
$err = htmlspecialchars_decode($err);
}
$errorString = 'E: ' . $dataType . " Error: \nin " . $filePath . "\n";
$errorString .= implode("\n", $errors) . "\n\n";
}
XenForo_Helper_File::log('devtools-error', str_replace("\n", ' ', $errorString));
$this->printDebugInfo($errorString);
die;
// throwing wasn't working with console so just doing this
throw new XenForo_Exception($errorString);
}
}