本文整理汇总了PHP中File_Exists函数的典型用法代码示例。如果您正苦于以下问题:PHP File_Exists函数的具体用法?PHP File_Exists怎么用?PHP File_Exists使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了File_Exists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Styles_HostsIDs
function Styles_HostsIDs($Element)
{
/****************************************************************************/
$__args_types = array('string');
#-----------------------------------------------------------------------------
$__args__ = Func_Get_Args();
eval(FUNCTION_INIT);
/****************************************************************************/
$Result = array();
#-----------------------------------------------------------------------------
$HostsIDs = $GLOBALS['HOST_CONF']['HostsIDs'];
#-----------------------------------------------------------------------------
if (isset($_COOKIE['StyleID'])) {
Array_UnShift($HostsIDs, $_COOKIE['StyleID']);
}
#-----------------------------------------------------------------------------
foreach ($HostsIDs as $HostID) {
#---------------------------------------------------------------------------
$Path = SPrintF('%s/styles/%s/%s', SYSTEM_PATH, $HostID, $Element);
#---------------------------------------------------------------------------
if (File_Exists($Path)) {
$Result[] = $HostID;
}
}
#-----------------------------------------------------------------------------
if (Count($Result) < 1) {
return ERROR | @Trigger_Error(SPrintF('[Styles_HostsIDs]: не удалось найти хосты для элемента (%s)', $Element));
}
#-----------------------------------------------------------------------------
return $Result;
}
示例2: applyTemplate
/**
* Metainformation catalogue
* --------------------------------------------------
*
* Lib_XML for MicKa
*
* @link http://www.bnhelp.cz
* @package Micka
* @category Metadata
* @version 20121206
*
*/
function applyTemplate($xmlSource, $xsltemplate)
{
$rs = FALSE;
if (File_Exists(CSW_XSL . '/' . $xsltemplate)) {
if (!extension_loaded("xsl")) {
if (substr(PHP_OS, 0, 3) == "WIN") {
dl("php_xsl.dll");
} else {
dl("php_xsl.so");
}
}
$xp = new XsltProcessor();
$xml = new DomDocument();
$xsl = new DomDocument();
$xml->loadXML($xmlSource);
$xsl->load(CSW_XSL . '/' . $xsltemplate);
$xp->importStyleSheet($xsl);
//$xp->setParameter("","lang",$lang);
$xp->setParameter("", "user", $_SESSION['u']);
$rs = $xp->transformToXml($xml);
}
if ($rs === FALSE) {
setMickaLog('applyTemplate === FALSE', 'ERROR', 'micka_lib_xml.php');
}
return $rs;
}
示例3: init
public static function init()
{
#-------------------------------------------------------------------------------
if (self::$instance === NULL) {
#-------------------------------------------------------------------------------
try {
#-------------------------------------------------------------------------------
Debug("[system/classes/auto/CacheManager.class.php]: Start initializing cache system.");
#-------------------------------------------------------------------------------
if (Extension_Loaded(MemcachedCache::EXT_NAME) && File_Exists(SPrintF('%s/.memcached', SYSTEM_PATH))) {
#-------------------------------------------------------------------------------
Debug('[system/classes/auto/CacheManager.class.php]: Force load MemcachedCache');
#-------------------------------------------------------------------------------
self::$instance = MemcachedCache::getInstance();
#-------------------------------------------------------------------------------
} else {
if (Extension_Loaded(APCCache::EXT_NAME)) {
#-------------------------------------------------------------------------------
Debug('[system/classes/auto/CacheManager.class.php]: Load APCCache');
#-------------------------------------------------------------------------------
self::$instance = APCCache::getInstance();
#-------------------------------------------------------------------------------
} else {
if (Extension_Loaded(MemcachedCache::EXT_NAME)) {
#-------------------------------------------------------------------------------
Debug('[system/classes/auto/CacheManager.class.php]: Load MemcachedCache');
#-------------------------------------------------------------------------------
self::$instance = MemcachedCache::getInstance();
#-------------------------------------------------------------------------------
} else {
#-------------------------------------------------------------------------------
throw new Exception("Any supported cache not installed in your sysytem.");
}
}
}
#-------------------------------------------------------------------------------
Debug("Cache system has been initialized.");
#-------------------------------------------------------------------------------
} catch (Exception $e) {
#-------------------------------------------------------------------------------
Debug("Cache system has not been installed: " . $e->getTraceAsString());
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
return self::$instance;
#-------------------------------------------------------------------------------
}
示例4: WriteToLog
function WriteToLog($txt, $level)
{
$this->logLevel = IntVal(COption::GetOptionString("mail", "smtp_log_level", "4"));
if ($this->logLevel < $level) {
return;
}
if (MicroTime(true) - $this->startPeriodTimeTruncate > 600) {
if ($this->logFile) {
FClose($this->logFile);
}
$this->logFile = null;
if (File_Exists($_SERVER["DOCUMENT_ROOT"] . $this->logFileName)) {
$logSize = @FileSize($_SERVER["DOCUMENT_ROOT"] . $this->logFileName);
$logSize = IntVal($logSize);
if ($logSize > $this->logMaxSize) {
if (($fp = @FOpen($_SERVER["DOCUMENT_ROOT"] . $this->logFileName, "rb")) && ($fp1 = @FOpen($_SERVER["DOCUMENT_ROOT"] . $this->logFileName . "_", "wb"))) {
$iSeekLen = IntVal($logSize - $this->logMaxSize / 2.0);
FSeek($fp, $iSeekLen);
@FWrite($fp1, "Truncated " . Date("Y-m-d H:i:s") . "\n---------------------------------\n");
do {
$data = FRead($fp, 8192);
if (StrLen($data) == 0) {
break;
}
@FWrite($fp1, $data);
} while (true);
@FClose($fp);
@FClose($fp1);
@Copy($_SERVER["DOCUMENT_ROOT"] . $this->logFileName . "_", $_SERVER["DOCUMENT_ROOT"] . $this->logFileName);
@UnLink($_SERVER["DOCUMENT_ROOT"] . $this->logFileName . "_");
}
}
ClearStatCache();
}
$this->startPeriodTimeTruncate = MicroTime(true);
}
if (!$this->logFile || $this->logFile == null) {
$this->logFile = FOpen($_SERVER["DOCUMENT_ROOT"] . $this->logFileName, "a");
}
if (!$this->logFile) {
echo "Can't write to log\n---------------------------------\n";
return;
}
FWrite($this->logFile, Date("Y-m-d H:i:s") . "\t" . trim($txt) . "\n");
FFlush($this->logFile);
//if ($level > 4)
echo trim($txt) . "\n---------------------------------\n";
}
示例5: HTMLDoc_CreatePDF
function HTMLDoc_CreatePDF($ModeID, $HTML, $Prefix = '/')
{
/****************************************************************************/
$__args_types = array('string', 'string,object', 'string');
#-----------------------------------------------------------------------------
$__args__ = Func_Get_Args();
eval(FUNCTION_INIT);
/****************************************************************************/
if (Is_Object($HTML)) {
#---------------------------------------------------------------------------
$Tables = $HTML->GetByTagName('TABLE');
#---------------------------------------------------------------------------
for ($i = 0; $i < Count($Tables); $i++) {
#-------------------------------------------------------------------------
$Table =& $Tables[$i];
#-------------------------------------------------------------------------
switch (@$Table->Attribs['class']) {
case 'Standard':
$Table->AddAttribs(array('border' => 2, 'cellspacing' => 0, 'cellpadding' => 5), TRUE);
break;
default:
# No more...
}
}
#---------------------------------------------------------------------------
$Tds = $HTML->GetByTagName('TD');
#---------------------------------------------------------------------------
for ($i = 0; $i < Count($Tds); $i++) {
#-------------------------------------------------------------------------
$Td =& $Tds[$i];
#-------------------------------------------------------------------------
switch (@$Td->Attribs['class']) {
case 'Head':
$Td->AddAttribs(array('bgcolor' => '#ADC1F0'), TRUE);
break;
case 'Separator':
$Td->AddAttribs(array('bgcolor' => '#EAEAEA'), TRUE);
break;
default:
# No more...
}
}
#---------------------------------------------------------------------------
$Imgs = $HTML->GetByTagName('IMG');
#---------------------------------------------------------------------------
for ($i = 0; $i < Count($Imgs); $i++) {
#-------------------------------------------------------------------------
$Img =& $Imgs[$i];
#-------------------------------------------------------------------------
$Img->AddAttribs(array('src' => SPrintF('%s/%s', $Prefix, $Img->Attribs['src'])), TRUE);
}
#---------------------------------------------------------------------------
$HTML = $HTML->Build();
}
#-----------------------------------------------------------------------------
$Config = Config();
#-----------------------------------------------------------------------------
$Settings = $Config['HTMLDOC'];
#-----------------------------------------------------------------------------
$Modes = $Settings['Modes'];
#-----------------------------------------------------------------------------
$Mode = isset($Modes[$ModeID]) ? $Modes[$ModeID] : $ModeID;
#-----------------------------------------------------------------------------
$Tmp = System_Element('tmp');
if (Is_Error($Tmp)) {
return ERROR | @Trigger_Error('[HTMLDoc_CreatePDF]: временная папка не найдена');
}
#-----------------------------------------------------------------------------
$Logs = SPrintF('%s/logs', $Tmp);
#-----------------------------------------------------------------------------
if (!File_Exists($Logs)) {
#---------------------------------------------------------------------------
if (!@MkDir($Logs, 0777, TRUE)) {
return ERROR | @Trigger_Error(500);
}
}
#-----------------------------------------------------------------------------
$HTML = @Mb_Convert_Encoding($HTML, $Settings['ConvertToCharset']);
if (!$HTML) {
return ERROR | @Trigger_Error('[HTMLDoc_CreatePDF]: не удалось преобразовать кодировку');
}
#-----------------------------------------------------------------------------
$UniqID = UniqID('HTMLDOC');
#-----------------------------------------------------------------------------
$File = IO_Write($Path = SPrintF('%s/%s', $Tmp, $UniqID), $HTML);
Debug($File);
if (Is_Error($File)) {
return ERROR | @Trigger_Error('[HTMLDoc_CreatePDF]: не удалось создать временный файл');
}
#-----------------------------------------------------------------------------
$Command = SPrintF('htmldoc %s %s', $Mode, $Path);
#-----------------------------------------------------------------------------
Debug($Command);
#-----------------------------------------------------------------------------
if (!PutENV('HTMLDOC_NOCGI=1')) {
return ERROR | @Trigger_Error('[HTMLDoc_CreatePDF]: не удалось установить переменную окружения HTMLDOC_NOCGI');
}
#-----------------------------------------------------------------------------
$HTMLDOC = @Proc_Open($Command, array(array('pipe', 'r'), array('pipe', 'w'), array('file', $Log = SPrintF('%s/HTMLDOC.log', $Logs), 'a')), $Pipes);
if (!Is_Resource($HTMLDOC)) {
//.........这里部分代码省略.........
示例6: SPrintF
echo SPrintF("Очистка временной директории компилированных шаблонов\n");
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
if (File_Exists(SPrintF('%s/WhatsApp', $Tmp))) {
#-------------------------------------------------------------------------------
if (Is_Error(IO_RmDir(SPrintF('%s///WhatsApp', $Tmp)))) {
return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
echo SPrintF("Очистка временной директории WhatsApp\n");
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
if (File_Exists($MyCnf)) {
UnLink($MyCnf);
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$IsUpdate = DB_Update('Config', array('Value' => 'TRUE'), array('Where' => "`Param` = 'IsInitDB'"));
if (Is_Error($IsUpdate)) {
return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$IsFlush = CacheManager::flush();
if (!$IsFlush) {
@Trigger_Error(500);
}
#-------------------------------------------------------------------------------
示例7: Img
function Img($Image, $Dw = 200, $Dh = 300, $Type = 2)
{
if (!File_Exists($Image)) {
return False;
}
#如果需要生成缩略图,则将原图拷贝一下重新给$Image赋值
// IF($Type!=1){
Copy($Image, Str_Replace(".", "_x.", $Image));
$Image = Str_Replace(".", "_x.", $Image);
// }
var_dump($Image);
#取得文件的类型,根据不同的类型建立不同的对象
$ImgInfo = GetImageSize($Image);
var_dump($ImgInfo);
switch ($ImgInfo[2]) {
case 1:
$Img = @ImageCreateFromGIF($Image);
break;
case 2:
$Img = @ImageCreateFromJPEG($Image);
break;
case 3:
$Img = @ImageCreateFromPNG($Image);
break;
}
#如果对象没有创建成功,则说明非图片文件
if (empty($Img)) {
#如果是生成缩略图的时候出错,则需要删掉已经复制的文件
if ($Type != 1) {
Unlink($Image);
}
return False;
}
#如果是执行调整尺寸操作则
if ($Type == 1) {
$w = ImagesX($Img);
$h = ImagesY($Img);
$width = $w;
$height = $h;
if ($width > $Dw) {
$Par = $Dw / $width;
$width = $Dw;
$height = $height * $Par;
if ($height > $Dh) {
$Par = $Dh / $height;
$height = $Dh;
$width = $width * $Par;
}
} elseif ($height > $Dh) {
$Par = $Dh / $height;
$height = $Dh;
$width = $width * $Par;
if ($width > $Dw) {
$Par = $Dw / $width;
$width = $Dw;
$height = $height * $Par;
}
} else {
$width = $width;
$height = $height;
}
$nImg = ImageCreateTrueColor($width, $height);
#新建一个真彩色画布
ImageCopyReSampled($nImg, $Img, 0, 0, 0, 0, $width, $height, $w, $h);
#重采样拷贝部分图像并调整大小
ImageJpeg($nImg, $Image);
#以JPEG格式将图像输出到浏览器或文件
return True;
#如果是执行生成缩略图操作则
} else {
$w = ImagesX($Img);
$h = ImagesY($Img);
$width = $w;
$height = $h;
$nImg = ImageCreateTrueColor($Dw, $Dh);
if ($h / $w > $Dh / $Dw) {
#高比较大
$width = $Dw;
$height = $h * $Dw / $w;
$IntNH = $height - $Dh;
ImageCopyReSampled($nImg, $Img, 0, -$IntNH / 1.8, 0, 0, $Dw, $height, $w, $h);
} else {
#宽比较大
$height = $Dh;
$width = $w * $Dh / $h;
$IntNW = $width - $Dw;
ImageCopyReSampled($nImg, $Img, -$IntNW / 1.8, 0, 0, 0, $width, $Dh, $w, $h);
}
ImageJpeg($nImg, $Image);
return True;
}
}
示例8: IO_Write
function IO_Write($Path, $Data, $IsRewrite = FALSE, $Wait = 3)
{
/******************************************************************************/
$__args_types = array('string', 'string', 'boolean', 'integer');
#-------------------------------------------------------------------------------
$__args__ = Func_Get_Args();
eval(FUNCTION_INIT);
/******************************************************************************/
Debug(SPrintF('[IO_Write]: запись в файл (%s)', $Path));
#-------------------------------------------------------------------------------
if (File_Exists($Path)) {
#-------------------------------------------------------------------------------
$Start = Time() + $Wait;
#-------------------------------------------------------------------------------
do {
} while (!Is_Writable($Path) && Time() < $Start);
#-------------------------------------------------------------------------------
} else {
#-------------------------------------------------------------------------------
$Folder = DirName($Path);
#-------------------------------------------------------------------------------
if (!File_Exists($Folder)) {
#-------------------------------------------------------------------------------
Debug(SPrintF('[IO_Write]: создание директории (%s)', $Folder));
#-------------------------------------------------------------------------------
if (!@MkDir($Folder, 0777, TRUE)) {
return ERROR | @Trigger_Error(SPrintF('[IO_Write]: не возможно создать директорию (%s)', $Folder));
}
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
$File = @Fopen($Path, $IsRewrite ? 'w' : 'a');
if (!$File) {
return ERROR | @Trigger_Error('[IO_Write]: ошибка открытия файла');
}
#-------------------------------------------------------------------------------
if (!@Fwrite($File, $Data)) {
return ERROR | @Trigger_Error('[IO_Write]: ошибка записи в файл');
}
#-------------------------------------------------------------------------------
if (!@Fclose($File)) {
return ERROR | @Trigger_Error('[IO_Write]: ошибка закрытия файла');
}
#-------------------------------------------------------------------------------
# почему закомменчено - не знаю. так было.
#if(Preg_Match('/\/tmp\//',$Path))
# if(!@ChMod($Path,0666))
# @Trigger_Error('[IO_Write]: ошибка установки прав на файл');
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
return TRUE;
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
}
示例9: __ShutDown_Function__
function __ShutDown_Function__()
{
global $__SETTINGS, $__MESSAGES, $__ERRORS;
echo '</TABLE>';
if (Count($__MESSAGES)) {
echo '<H2>Сообщения:</H2><UL class="Standard">';
foreach ($__MESSAGES as $__MESSAGE) {
echo SPrintF('<LI>%s</LI>', $__MESSAGE);
}
echo '</UL>';
}
if (Count($__ERRORS)) {
echo '<H2>Ошибки выполнения:</H2><UL class="Standard">';
foreach ($__ERRORS as $__ERROR) {
echo SPrintF('<LI><PRE>%s</PRE></LI>', $__ERROR);
}
echo '</UL>';
}
if (File_Exists(SPrintF('%s/INSTALL', SYSTEM_PATH))) {
if (!@File_Put_Contents(SETTINGS_FILE, JSON_Encode($__SETTINGS))) {
echo SPrintF('<P>Не удалось сохранить текущие настройки установки в файле (%s)</P>', SETTINGS_FILE);
}
}
echo <<<EOD
</BODY>
</HTML>
EOD;
}
示例10: SPrintF
$dPort = 3306;
}
#-------------------------------------------------------------------------------
$MYSQL_BIN = @$_ENV['MYSQL_BIN'];
#-------------------------------------------------------------------------------
if ($MYSQL_BIN) {
echo SPrintF("Use mysql in (%s)\n", $MYSQL_BIN);
} else {
$MYSQL_BIN = 'c:\\Program Files\\MySQL\\MySQL Server 5.1\\bin\\mysql.exe';
}
#-------------------------------------------------------------------------------
foreach (array('structure', 'views', 'permissions', 'triggers', 'functions', 'db') as $File) {
#-----------------------------------------------------------------------------
$Path = SPrintF('./../../db/%s/%s.sql', $jHost, $File);
#-----------------------------------------------------------------------------
if (File_Exists($Path)) {
#---------------------------------------------------------------------------
echo SPrintF("Install %s\n", $File);
#---------------------------------------------------------------------------
$MySQL = SPrintF('%s -u %s --password=%s --host=%s --port=%u %s', $MYSQL_BIN, $dUser, $dPassword, $dServer, $dPort, $dName);
#---------------------------------------------------------------------------
$Result = Exec(SPrintF('%s < %s 2>&1', $MySQL, $Path));
#---------------------------------------------------------------------------
if ($Result) {
#-------------------------------------------------------------------------
echo SPrintF("%s\n", $Result);
#-------------------------------------------------------------------------
exit("Error\n");
}
}
}
示例11: array
#-------------------------------------------------------------------------------
$DOM->AddAttribs('MenuLeft', array('args' => 'Administrator/AddIns'));
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$DOM->AddText('Title', 'Дополнения → Обслуживание системы → Логи системы');
#-------------------------------------------------------------------------------
$Tmp = System_Element('tmp');
if (Is_Error($Tmp)) {
return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
$Logs = SPrintF('%s/logs', $Tmp);
#-------------------------------------------------------------------------------
$NoBody = new Tag('NOBODY');
#-------------------------------------------------------------------------------
if (File_Exists($Logs)) {
#-----------------------------------------------------------------------------
$Files = IO_Scan($Logs);
if (Is_Error($Files)) {
return ERROR | @Trigger_Error(500);
}
#-----------------------------------------------------------------------------
$Table = $Options = array();
#-----------------------------------------------------------------------------
if (Count($Files)) {
#---------------------------------------------------------------------------
Sort($Files);
#---------------------------------------------------------------------------
foreach ($Files as $File) {
$Options[$File] = $File;
}
示例12: Memcached
<?php
/*
* Main reporting code
*/
$m = new Memcached();
$m->addServer('/var/run/memcached/memcached.sock', 0);
$MakeMojangNewsRequest = false;
if (!($PSA = $m->get('mc_status_mojang'))) {
$MakeMojangNewsRequest = true;
}
require __DIR__ . '/MinecraftStatusChecker.class.php';
$MinecraftStatus = new MinecraftStatusChecker($MakeMojangNewsRequest);
$Answer = array('v' => 10, 'last_updated' => Date('H:i:s T'), 'report' => $MinecraftStatus->GetReport());
unset($MakeMojangNewsRequest, $MinecraftStatus);
if (File_Exists('psa.txt')) {
if ($PSA != false) {
$PSA .= '<hr class="dotted">';
}
$PSA .= File_Get_Contents('psa.txt');
}
if ($PSA != false) {
$Answer['psa'] = $PSA;
unset($PSA);
}
$Raw = $Answer['report'];
foreach ($Raw as $Service => $Report) {
$Downs = (int) $m->get('mc_status_' . $Service);
if ($Report['status'] === MinecraftStatusChecker::STATUS_OFFLINE) {
$Answer['report'][$Service]['downtime'] = '±' . ++$Downs;
}
示例13: SPrintF
<?php
#-------------------------------------------------------------------------------
/** @author Alex Keda, for www.host-food.ru */
/******************************************************************************/
/******************************************************************************/
$ConfigPath = SPrintF('%s/hosts/%s/config/Config.xml', SYSTEM_PATH, HOST_ID);
#-------------------------------------------------------------------------------
if (File_Exists($ConfigPath)) {
#-------------------------------------------------------------------------------
$File = IO_Read($ConfigPath);
if (Is_Error($File)) {
return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
$XML = String_XML_Parse($File);
if (Is_Exception($XML)) {
return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
$Config = $XML->ToArray();
#-------------------------------------------------------------------------------
$Config = $Config['XML'];
#-------------------------------------------------------------------------------
} else {
#-------------------------------------------------------------------------------
$Config = array();
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
示例14: File_Exists
<?php
/** Enter point. */
include File_Exists('INSTALL') ? './install/index.php' : './core/Load.php';
示例15: __Error_Handler__
function __Error_Handler__($Number, $Error, $File, $Line)
{
#-------------------------------------------------------------------------------
$Message = SPrintF('[!!%s]-%s в линии %s файла %s', $Number, $Error, $Line, $File);
#-------------------------------------------------------------------------------
$__ERR_CODE =& $GLOBALS['__ERR_CODE'];
#-------------------------------------------------------------------------------
if ((int) $Error && $__ERR_CODE == 100) {
$__ERR_CODE = $Error;
}
#-------------------------------------------------------------------------------
Debug(SPrintF('[!] %s', $Message));
//Debug(SPrintF('[!] %s',debug_print_backtrace()));
#-------------------------------------------------------------------------------
//Error_Reporting(E_ALL);
#-------------------------------------------------------------------------------
if (Error_Reporting()) {
#-------------------------------------------------------------------------------
$JBsErrorID = SPrintF('%s[%s]', HOST_ID, Md5(Implode(':', array($Number, $Error, $Line, $File))));
#-------------------------------------------------------------------------------
$__SYSLOG =& $GLOBALS['__SYSLOG'];
#-------------------------------------------------------------------------------
$Log = Implode("\n", $__SYSLOG);
#-------------------------------------------------------------------------------
Report($JBsErrorID, $JBsErrorID);
#-------------------------------------------------------------------------------
foreach (array(SYSTEM_PATH, '/tmp') as $Folder) {
#-------------------------------------------------------------------------------
$Path = SPrintF('%s/jbs-errors.log', $Folder);
#-------------------------------------------------------------------------------
if (File_Exists($Path)) {
if (FileSize($Path) > 1024 * 1024) {
UnLink($Path);
}
}
#-------------------------------------------------------------------------------
umask(077);
#-------------------------------------------------------------------------------
if (!@File_Put_Contents($Path, SPrintF("%s\n\n%s\n\n", $JBsErrorID, $Log), FILE_APPEND)) {
#-------------------------------------------------------------------------------
Debug(SPrintF('[__Error_Handler__]: не удалось осуществить запись ошибки в системный лог (%s)', $Path));
#-------------------------------------------------------------------------------
continue;
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
break;
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
if (File_Exists(SPrintF('%s/DEBUG.OUT', SYSTEM_PATH)) || !isset($_SERVER["REMOTE_PORT"])) {
#-------------------------------------------------------------------------------
exit($Log);
} else {
#-------------------------------------------------------------------------------
$Errors = array(100 => 'Ошибка выполнения', 101 => 'Неизвестный результат', 201 => 'Неверные параметры', 400 => 'Ошибка данных', 500 => 'Системная ошибка', 600 => 'Ошибка политики безопасности', 601 => 'Неверный реферер', 602 => 'Отсутствует реферер', 603 => 'Неверный ключ CSRF', 700 => 'Нарушение политики прав');
#-------------------------------------------------------------------------------
$FilePath = SPrintF('%s/hosts/root/templates/modules/Trigger.Error.html', SYSTEM_PATH);
#-------------------------------------------------------------------------------
if (Is_Readable($FilePath)) {
#-------------------------------------------------------------------------------
$Result = @File_Get_Contents($FilePath);
#-------------------------------------------------------------------------------
} else {
#-------------------------------------------------------------------------------
$Result = SPrintF("Cannot read error file: %s<BR />\nError: %%s<BR />\n<!--%%s-->\nErrorID: %%s\n<!--%%s-->", $FilePath);
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
$String = SPrintF('%s (%s)', $Errors[$__ERR_CODE], $__ERR_CODE);
#-------------------------------------------------------------------------------
@Header(SPrintF('JBs-ErrorID: %s', $JBsErrorID));
#-------------------------------------------------------------------------------
if (isset($_POST['XMLHttpRequest'])) {
#-------------------------------------------------------------------------------
$Answer = array('Error' => array('CodeID' => $__ERR_CODE, 'String' => $String), 'Status' => 'Error');
#-------------------------------------------------------------------------------
exit(JSON_Encode($Answer));
#-------------------------------------------------------------------------------
} else {
#-------------------------------------------------------------------------------
exit(SPrintF($Result, $String, $String, $JBsErrorID, Date('Y', Time())));
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
}