Exemple #1
0
function isResmac()
{
    global $application;
    $restorationIP = $application['restoration']['machinesIP'];
    if (APPMODE === 'restoration') {
        $ipv4 = ipv4();
        if (is_array($restorationIP)) {
            $result = in_array($ipv4, $restorationIP);
        } elseif ($ipv4 == $restorationIP) {
            $result = true;
        } else {
            $result = false;
        }
    } else {
        $result = false;
    }
    return $result;
}
 public static function isMachinesIP()
 {
     $projects = \Config::get('Project');
     $restorationIP = $projects['restoration']['machinesIP'];
     if (PROJECT_MODE === 'restoration') {
         $ipv4 = ipv4();
         if (is_array($restorationIP)) {
             $result = in_array($ipv4, $restorationIP);
         } elseif ($ipv4 == $restorationIP) {
             $result = true;
         } else {
             $result = false;
         }
     } else {
         $result = false;
     }
     return (bool) $result;
 }
function report($subject = 'unknown', $message = '', $destination = 'message', $time = '')
{
    if (!Config::get('Log', 'createFile')) {
        return false;
    }
    $logDir = APP_DIR . 'Logs/';
    $extension = '.log';
    if (!is_dir($logDir)) {
        Folder::create($logDir, 0777);
    }
    if (is_file($logDir . suffix($destination, $extension))) {
        if (empty($time)) {
            $time = Config::get('Log', 'fileTime');
        }
        $createDate = File::createDate($logDir . suffix($destination, $extension), 'd.m.Y');
        $endDate = strtotime("{$time}", strtotime($createDate));
        $endDate = date('Y.m.d', $endDate);
        if (date('Y.m.d') > $endDate) {
            File::delete($logDir . suffix($destination, $extension));
        }
    }
    $message = "IP: " . ipv4() . " | Subject: " . $subject . ' | Date: ' . date('d.m.Y h:i:s') . " | Message: " . $message . eol();
    error_log($message, 3, $logDir . suffix($destination, $extension));
}
Exemple #4
0
function report(string $subject, string $message, string $destination = '', string $time = '') : bool
{
    if (!Config::get('General', 'log')['createFile']) {
        return false;
    }
    if (empty($destination)) {
        $destination = str_replace(' ', '-', $subject);
    }
    $logDir = STORAGE_DIR . 'Logs/';
    $extension = '.log';
    if (!is_dir($logDir)) {
        Folder::create($logDir, 0755);
    }
    if (is_file($logDir . suffix($destination, $extension))) {
        if (empty($time)) {
            $time = Config::get('General', 'log')['fileTime'];
        }
        $createDate = File::createDate($logDir . suffix($destination, $extension), 'd.m.Y');
        $endDate = strtotime("{$time}", strtotime($createDate));
        $endDate = date('Y.m.d', $endDate);
        if (date('Y.m.d') > $endDate) {
            File::delete($logDir . suffix($destination, $extension));
        }
    }
    $message = 'IP: ' . ipv4() . ' | Subject: ' . $subject . ' | Date: ' . Date::set('{dayNumber0}.{monthNumber0}.{year} {H024}:{minute}:{second}') . ' | Message: ' . $message . EOL;
    return error_log($message, 3, $logDir . suffix($destination, $extension));
}