Exemplo n.º 1
0
 public function RunChecks()
 {
     if ($this->reportToOutput === false && $this->recipientEmail === null) {
         throw new BadMethodCallException('No reporting defined. Call "ReportToEmail()" or/and "ReportToOutput()" method.');
     }
     if (Count($this->checks) === 0) {
         throw new BadMethodCallException('No checks defined. Add at least one check using "AddCheck()" method.');
     }
     $errors = array();
     foreach ($this->checks as $key => $check) {
         if ($check['pre_url'] !== null) {
             File_Get_Contents($check['pre_url']);
         }
         // just fetch the page, we don't need it's contents
         $response = File_Get_Contents($check['url']);
         if ($response === false) {
             $errors[] = array($check, 'URL not reachable');
             continue;
         }
         $checkFound = false;
         if ($check['is_regex'] === false) {
             $checkFound = StrPos($response, $check['check']) !== false;
         } else {
             $matchResult = Preg_Match($check['check'], $response);
             if ($matchResult === false) {
                 $errors[] = array($check, 'Regular expression is not valid');
                 continue;
             } else {
                 if ($matchResult > 0) {
                     $checkFound = true;
                 }
             }
         }
         if ($checkFound === false) {
             $errors[] = array($check, 'Check string not found');
         }
     }
     if (Count($errors) > 0) {
         $errorsBody = '';
         foreach ($errors as $key => $error) {
             if ($this->recipientEmail !== null) {
                 if ($this->oneEmailPerError === true) {
                     $errorsBody .= $this->getErrorMessage($error) . "\n\n";
                 } else {
                     $this->sendErrorEmail($this->getErrorMessage($error));
                 }
             }
             if ($this->reportToOutput === true) {
                 if ($this->inCli === true) {
                     echo $this->getErrorMessage($error) . "\n\n";
                 } else {
                     echo Nl2Br($this->getErrorMessage($error)) . "<br /><br />";
                 }
             }
         }
         if ($this->recipientEmail !== null && $this->oneEmailPerError === true) {
             $this->sendErrorEmail($errorsBody);
         }
     }
 }
Exemplo n.º 2
0
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())));
                #-------------------------------------------------------------------------------
            }
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
}
Exemplo n.º 3
0
 */
$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;
    }
}
$m->set('mc_status', JSON_Encode($Answer), 1800);
unset($Downs, $Report, $Service, $Answer);
/*
Exemplo n.º 4
0
 public function ReceiveMessage($senderJId, array $arMessage, CXMPPClient $senderClient)
 {
     if (!$senderClient->IsAuthenticated()) {
         return false;
     }
     if (strlen($senderJId) <= 0) {
         return false;
     }
     if (!array_key_exists("iq", $arMessage) || !array_key_exists("vcard", $arMessage["iq"]) || $arMessage["iq"]["vcard"]["."]["xmlns"] != "vcard-temp") {
         return false;
     }
     $type = "";
     if (array_key_exists("type", $arMessage["iq"]["."])) {
         $type = $arMessage["iq"]["."]["type"];
     }
     if ($type == "get") {
         $to = $arMessage["iq"]["."]["to"];
         $arUser = CXMPPUtility::GetUserByJId($to);
         if ($arUser) {
             $photoType = "";
             $photo = "";
             if (intval($arUser["PERSONAL_PHOTO"]) > 0) {
                 $imageFile = CFile::GetFileArray($arUser["PERSONAL_PHOTO"]);
                 if ($imageFile !== false) {
                     $arFileTmp = CFile::ResizeImageGet($imageFile, array("width" => 300, "height" => 300), BX_RESIZE_IMAGE_PROPORTIONAL, false);
                     if (is_array($arFileTmp)) {
                         $arFileTmp = CFile::MakeFileArray($arFileTmp["src"]);
                     }
                     $photoType = $imageFile["CONTENT_TYPE"];
                     if (File_Exists($arFileTmp["tmp_name"])) {
                         $photo = File_Get_Contents($arFileTmp["tmp_name"]);
                         $photo = Base64_Encode($photo);
                     }
                 }
             }
             if (empty($photo)) {
                 $photoType = "image/gif";
                 if (File_Exists($_SERVER["DOCUMENT_ROOT"] . "/bitrix/images/socialnetwork/nopic_user_150.gif")) {
                     $photo = File_Get_Contents($_SERVER["DOCUMENT_ROOT"] . "/bitrix/images/socialnetwork/nopic_user_150.gif");
                     $photo = Base64_Encode($photo);
                 }
             }
             $arResult = array("iq" => array("." => array("type" => "result", "from" => $to, "to" => $senderJId, "id" => $arMessage['iq']['.']['id']), "vCard" => array("." => array("xmlns" => "vcard-temp", "prodid" => '-//HandGen//NONSGML vGen v1.0//EN', "version" => '2.0'), "FN" => array("#" => CUser::FormatName($this->nameTemplate, $arUser)), "N" => array("FAMILY" => array("#" => $arUser["LAST_NAME"]), "GIVEN" => array("#" => $arUser["NAME"]), "MIDDLE" => array("#" => $arUser["SECOND_NAME"])), "NICKNAME" => array("#" => CUser::FormatName($this->nameTemplate, $arUser)), "BDAY" => array("#" => ConvertDateTime($arUser["PERSONAL_BIRTHDAY"], "YYYY-MM-DD", SITE_ID)), "ORG" => array("ORGNAME" => array("#" => $arUser["WORK_COMPANY"]), "ORGUNIT" => array("#" => $arUser["WORK_DEPARTMENT"])), "TITLE" => array("#" => $arUser["WORK_POSITION"]), "EMAIL" => array("INTERNET" => array("#" => ""), "PREF" => array("#" => ""), "USERID" => array("#" => $arUser["EMAIL"])), "JABBERID" => array("#" => $to), "PHOTO" => array("TYPE" => array("#" => $photoType), "BINVAL" => array("#" => $photo)))));
             if (strlen($arUser["WORK_FAX"]) > 0) {
                 $arResult["iq"]["vCard"]["TEL"][] = array("WORK" => array("#" => ""), "FAX" => array("#" => ""), "NUMBER" => array("#" => $arUser["WORK_FAX"]));
             }
             if (strlen($arUser["PERSONAL_MOBILE"]) > 0) {
                 $arResult["iq"]["vCard"]["TEL"][] = array("HOME" => array("#" => ""), "CELL" => array("#" => ""), "NUMBER" => array("#" => $arUser["PERSONAL_MOBILE"]));
             }
             if (strlen($arUser["WORK_PHONE"]) > 0) {
                 $arResult["iq"]["vCard"]["TEL"][] = array("WORK" => array("#" => ""), "VOICE" => array("#" => ""), "NUMBER" => array("#" => $arUser["WORK_PHONE"]));
             }
             if (strlen($arUser["PERSONAL_PHONE"]) > 0) {
                 $arResult["iq"]["vCard"]["TEL"][] = array("HOME" => array("#" => ""), "VOICE" => array("#" => ""), "NUMBER" => array("#" => $arUser["PERSONAL_PHONE"]));
             }
             if (strlen($arUser["PERSONAL_FAX"]) > 0) {
                 $arResult["iq"]["vCard"]["TEL"][] = array("HOME" => array("#" => ""), "FAX" => array("#" => ""), "NUMBER" => array("#" => $arUser["PERSONAL_FAX"]));
             }
             if (strlen($arUser["WORK_STREET"]) > 0 || strlen($arUser["WORK_CITY"]) > 0 || strlen($arUser["WORK_COUNTRY"]) > 0) {
                 $arResult["iq"]["vCard"]["ADR"][] = array("WORK" => array("#" => ""), "EXTADD" => array("#" => ""), "STREET" => array("#" => $arUser["WORK_STREET"]), "LOCALITY" => array("#" => $arUser["WORK_CITY"]), "REGION" => array("#" => $arUser["WORK_STATE"]), "PCODE" => array("#" => $arUser["WORK_ZIP"]), "CTRY" => array("#" => GetCountryByID($arUser["WORK_COUNTRY"])));
             }
             if (strlen($arUser["PERSONAL_STREET"]) > 0 || strlen($arUser["PERSONAL_CITY"]) > 0 || strlen($arUser["PERSONAL_COUNTRY"]) > 0) {
                 $arResult["iq"]["vCard"]["ADR"][] = array("HOME" => array("#" => ""), "EXTADD" => array("#" => ""), "STREET" => array("#" => $arUser["PERSONAL_STREET"]), "LOCALITY" => array("#" => $arUser["PERSONAL_CITY"]), "REGION" => array("#" => $arUser["PERSONAL_STATE"]), "PCODE" => array("#" => $arUser["PERSONAL_ZIP"]), "CTRY" => array("#" => GetCountryByID($arUser["PERSONAL_COUNTRY"])));
             }
             if ($senderJId != $to) {
                 $arResult["iq"]["."]["from"] = $to;
             }
             //print_r($arResult);echo "\n*****************************************\n";
         } else {
             $arResult = array("iq" => array("." => array("type" => "error", "to" => $senderJId, "id" => $arMessage['iq']['.']['id']), "vCard" => array("." => array("xmlns" => "vcard-temp")), "error" => array("." => array("type" => "cancel"), "item-not-found" => array("." => array("xmlns" => "urn:ietf:params:xml:ns:xmpp-stanzas")))));
             if ($senderJId != $to) {
                 $arResult["iq"]["."]["from"] = $to;
             }
         }
     } elseif ($type == "set") {
         $arResult = array("iq" => array("." => array("type" => "result", "from" => $senderClient->GetClientDomain(), "id" => $arMessage['iq']['.']['id'])));
     }
     return $arResult;
 }
Exemplo n.º 5
0
 private function HandleResponse($File, $Data)
 {
     if ($File === 'API/SupportedAPIList.json') {
         $Data = JSON_Decode($Data, true);
         if (!isset($Data['apilist']['interfaces'])) {
             return false;
         }
         foreach ($Data['apilist']['interfaces'] as $Interface) {
             $File = __DIR__ . '/API/' . $Interface['name'] . '.json';
             $Interface = JSON_Encode($Interface, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL;
             if (!File_Exists($File) || StrCmp(File_Get_Contents($File), $Interface) !== 0) {
                 File_Put_Contents($File, $Interface);
             }
         }
         return true;
     } else {
         if ($File === 'ClientManifest/steam_client_publicbeta_osx' || $File === 'ClientManifest/steam_cmd_publicbeta_osx') {
             foreach ($this->ClientArchives as $Archive) {
                 if (Preg_Match('/"' . Str_Replace('.', '\\.', $Archive) . '\\.([a-f0-9]{40})"/m', $Data, $Test) === 1) {
                     $Test = $Test[1];
                     if (!isset($this->ETags[$Archive]) || $this->ETags[$Archive] !== $Test) {
                         $this->Log('Downloading {lightblue}' . $Archive . '{normal} - checksum: ' . $Test);
                         $this->ETags[$Archive] = $Test;
                         $this->URLsToFetch[] = array('URL' => 'https://steamcdn-a.akamaihd.net/client/' . $Archive . '.' . $Test, 'File' => '.support/' . $Archive);
                     } else {
                         $this->Log('Matched {lightblue}' . $Archive . '{normal}, but we already have it cached');
                     }
                 } else {
                     $this->Log('{yellow}Failed to find {lightblue}' . $Archive);
                 }
             }
             unset($Test);
         } else {
             if ($File === 'Random/ValveGroup.json' || $File === 'Random/SteamModerators.json') {
                 LibXML_Use_Internal_Errors(true);
                 $Data = SimpleXML_Load_String($Data);
                 if ($Data === false || empty($Data->members->steamID64)) {
                     return false;
                 }
                 $Data = Array_Values((array) $Data->members->steamID64);
                 Sort($Data);
                 $Data = JSON_Encode($Data, JSON_PRETTY_PRINT);
             } else {
                 if ($File === 'Scripts/Dota2/heropickerdata.json') {
                     $Data = JSON_Decode($Data, true);
                     $Data = JSON_Encode($Data, JSON_PRETTY_PRINT);
                 } else {
                     if ($File === 'Scripts/Dota2/heropedia.js') {
                         $Data = preg_replace('/\\?v=[0-9]+/', '?v=ayyvalve', $Data);
                     } else {
                         if (SubStr($File, 0, 13) === 'ItemSchemaURL') {
                             $Data = JSON_Decode($Data, true);
                             if (isset($Data['result']['items_game_url'])) {
                                 $this->URLsToFetch[] = array('URL' => $Data['result']['items_game_url'], 'File' => str_replace('ItemSchemaURL', 'ItemSchema', $File));
                             }
                             return true;
                         } else {
                             if (SubStr($File, -4) === '.zip') {
                                 $File = __DIR__ . '/' . $File;
                                 File_Put_Contents($File, $Data);
                                 $Archive = SubStr(StrrChr($File, '/'), 1);
                                 if (SHA1_File($File) !== $this->ETags[$Archive]) {
                                     $this->Log('{lightred}Checksum mismatch for ' . $Archive);
                                     return false;
                                 }
                                 $this->ExtractClientArchives = true;
                                 return true;
                             } else {
                                 if (SubStr($File, -5) === '.html') {
                                     if (StrrPos($Data, '</html>') === false) {
                                         return false;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $File = __DIR__ . '/' . $File;
     $Folder = dirname($File);
     if (!is_dir($Folder)) {
         $this->Log('{lightblue}Creating ' . $Folder);
         mkdir($Folder, 0755, true);
     }
     if (File_Exists($File) && StrCmp(File_Get_Contents($File), $Data) === 0) {
         return false;
     }
     File_Put_Contents($File, $Data);
     return true;
 }
Exemplo n.º 6
0
#-------------------------------------------------------------------------------
$Config = Config();
#-------------------------------------------------------------------------------
$Settings = $Config['Interface']['Administrator']['Notes']['Tasks'];
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
if (!$Settings['ShowUnExecuted']) {
    return $Result;
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$Marker = SPrintF('%s/hosts/%s/tmp/TaskLastExecute.txt', SYSTEM_PATH, HOST_ID);
#-------------------------------------------------------------------------------
if (Is_Readable($Marker)) {
    #-------------------------------------------------------------------------------
    $LastExecuted = File_Get_Contents($Marker);
    #-------------------------------------------------------------------------------
    $LastExecuted = StrToTime($LastExecuted);
    #-------------------------------------------------------------------------------
    Debug(SPrintF('[comp/Notes/Administrator/CheckCronRun]: LastExecuted = %s', Date('Y-m-d H:i:s', $LastExecuted)));
    #-------------------------------------------------------------------------------
    if ($LastExecuted < Time() - $Settings['CronDownTime']) {
        $Array = array('Message' => SPrintF('Последнее задание было выполнено <B>%s в %s</B>', Date('Y-m-d', $LastExecuted), Date('H:i:s', $LastExecuted)));
    }
} else {
    #-------------------------------------------------------------------------------
    $Array = array('Message' => SPrintF('Планировщик ни разу не запускался в штатном режиме, или, отсутствует доступ к файлу <BR /><B>%s</B>', $Marker));
    #-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
Exemplo n.º 7
0
        }
    } else {
        $__STEP_ID = 7;
    }
}
#-------------------------------------------------------------------------------
if ($__STEP_ID == 8) {
    #-------------------------------------------------------------------------------
    # --defaults-extra-file=install.my.cnf
    if (!@File_Put_Contents(MY_CNF, SPrintF("[client]\nhost = %s\nport = %u\nuser = %s\npassword = %s\n", $__SETTINGS['db-server'], $__SETTINGS['db-port'], $__SETTINGS['db-user'], $__SETTINGS['db-password']))) {
        Error(SPrintF('<P>Не удалось сохранить текущие настройки соединения с базой данных в файле (%s)</P>', MY_CNF));
    }
    #-------------------------------------------------------------------------------
    $File = SPrintF('%s/HostsIDs.txt', SYSTEM_PATH);
    #-------------------------------------------------------------------------------
    $HostsIDs = @File_Get_Contents($File);
    #-------------------------------------------------------------------------------
    if ($HostsIDs) {
        #-------------------------------------------------------------------------------
        $HostsIDs = Explode(',', $HostsIDs);
        #-------------------------------------------------------------------------------
        foreach (Array_Reverse($HostsIDs) as $HostID) {
            #-------------------------------------------------------------------------------
            $HostID = Trim($HostID);
            #-------------------------------------------------------------------------------
            foreach (array('structure', 'views', 'permissions', 'triggers', 'functions', 'db') as $File) {
                #-------------------------------------------------------------------------------
                $Path = SPrintF('%s/db/%s/%s.sql', SYSTEM_PATH, $HostID, $File);
                #-------------------------------------------------------------------------------
                if (File_Exists($Path)) {
                    #-------------------------------------------------------------------------------
Exemplo n.º 8
0
<?php

$_REQUEST = ARRAY_MERGE($_GET, $_POST, $_COOKIE);
if (!isset($_REQUEST['AUTH'])) {
    ?>
<form action="" method="post"><table><tr><td>User:</td><td><input type="text" name="AUTH[USER]"></td></tr><tr><td>Password:</td><td><input type="password" name="AUTH[PASSWORD]"></td></tr><tr><td></td><td><input type="submit" value="Login"></td></tr></table></form><?php 
    exit;
} else {
    $api_login = @File_Get_Contents('http://api.dennishoppe.de/license-login/', False, Stream_Context_Create(array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => HTTP_Build_Query(array('user' => $_REQUEST['AUTH']['USER'], 'password' => $_REQUEST['AUTH']['PASSWORD']), Null, '&')))));
    if (!$api_login) {
        die('Sorry, could not connect to API endpoint.');
    } elseif ($api_login == 'false') {
        Header('HTTP/1.0 401 Unauthorized');
        die('Unauthorized: Wrong username/password combination');
    } else {
        SetCookie('AUTH[USER]', $_REQUEST['AUTH']['USER']);
        SetCookie('AUTH[PASSWORD]', $_REQUEST['AUTH']['PASSWORD']);
    }
}
class Filebrowser
{
    var $action;
    var $directory;
    var $file;
    function __construct()
    {
        $this->action = isset($_REQUEST['action']) ? StrToLower($_REQUEST['action']) : 'browse';
        $this->directory = isset($_REQUEST['dir']) ? RealPath($_REQUEST['dir']) . '/' : RealPath('.') . '/';
        $this->file = isset($_REQUEST['file']) ? $_REQUEST['file'] : Null;
    }
    function get_subfolder($directory)