function sendMail(ezcMail $mail)
 {
     $separator = "/";
     $mail->appendExcludeHeaders(array('to', 'subject'));
     $headers = rtrim($mail->generateHeaders());
     // rtrim removes the linebreak at the end, mail doesn't want it.
     if (count($mail->to) + count($mail->cc) + count($mail->bcc) < 1) {
         throw new ezcMailTransportException('No recipient addresses found in message header.');
     }
     $additionalParameters = "";
     if (isset($mail->returnPath)) {
         $additionalParameters = "-f{$mail->returnPath->email}";
     }
     $sys = eZSys::instance();
     $fname = time() . '-' . rand() . '.mail';
     $qdir = eZSys::siteDir() . eZSys::varDirectory() . $separator . 'mailq';
     $data = $headers . ezcMailTools::lineBreak();
     $data .= ezcMailTools::lineBreak();
     $data .= $mail->generateBody();
     $data = preg_replace('/(\\r\\n|\\r|\\n)/', "\r\n", $data);
     $success = eZFile::create($fname, $qdir, $data);
     if ($success === false) {
         throw new ezcMailTransportException('The email could not be sent by sendmail');
     }
 }
Example #2
0
        if ($cacheItem['path'] == 'var/cache/ini') {
            $cachedir = eZSys::siteDir() . '/' . $cacheItem['path'];
        } else {
            $cachedir = eZSys::cacheDirectory() . '/' . $cacheItem['path'];
        }
        $count = sysInfoTools::countFilesInDir($cachedir);
        $cacheFilesList[$cacheItem['name']]['count'] = $count;
        if ($count) {
            $cacheFilesList[$cacheItem['name']]['size'] = number_format(sysInfoTools::countFilesSizeInDir($cachedir));
        } else {
            $cacheFilesList[$cacheItem['name']]['size'] = "";
        }
    }
}
// q: are we 100% sure that the eZ5 cache is always at that location?
if (class_exists('Symfony\\Component\\HttpKernel\\Kernel') && is_dir($ezp5CacheDir = eZSys::siteDir() . '/../ezpublish/cache')) {
    foreach (glob($ezp5CacheDir . '/*', GLOB_ONLYDIR) as $envDir) {
        $env = basename($envDir);
        foreach (glob($envDir . '/*', GLOB_ONLYDIR) as $cacheDir) {
            $cache = basename($cacheDir);
            $cacheName = "Symfony/{$env}/{$cache}";
            $count = sysInfoTools::countFilesInDir($cacheDir);
            $cacheFilesList[$cacheName] = array('path' => "ezpublish/cache/{$env}/{$cache}", 'size' => $count ? number_format(sysInfoTools::countFilesSizeInDir($cacheDir)) : "", 'count' => $count);
        }
    }
}
if ($Params['viewmode'] == 'json') {
    $response_type = $Params['viewmode'];
    $response_data = $cacheFilesList;
    return;
}
Example #3
0
/**
 * Display a log file
 *
 * @author G. Giunta
 * @copyright (C) G. Giunta 2014-2016
 * @license Licensed under GNU General Public License v2.0. See file license.txt
 *
 * @todo add support for if-modified-since, etag headers
 */
$module = $Params['Module'];
$desiredLog = str_replace(':', '/', $Params['logfile']);
$logName = '';
$isDebugLog = false;
$desiredLogPath = dirname($desiredLog);
if ($desiredLogPath != 'var/log' && $desiredLogPath != eZSys::varDirectory() . '/' . $ini->variable('FileSettings', 'LogDir') && $desiredLogPath != 'symfony') {
    return $module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
}
if ($desiredLogPath == 'symfony') {
    $logfile = eZSys::siteDir() . '/../ezpublish/logs/' . basename($desiredLog);
} else {
    $logfile = eZSys::siteDir() . '/' . $desiredLog;
}
if (!file_exists($logfile)) {
    return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
} else {
    $mdate = gmdate('D, d M Y H:i:s', filemtime($logfile)) . ' GMT';
    header('Content-Type: text/plain');
    header("Last-Modified: {$mdate}");
    readfile($logfile);
    eZExecution::cleanExit();
}
        $parameters['pass'] = $mailSettings->variable($account, 'Password');
    }
    if (testConnection($parameters)) {
        $serverlist[$i] = $parameters;
        $i++;
    }
}
if (count($serverlist) == 0) {
    $cli->output("No valid mailserver accounts found!");
    exit(1);
}
$cli->output("Available accounts: " . count($serverlist));
// get mail-files
$sys = eZSys::instance();
$separator = $sys->osType() == 'win32' ? "\\" : "/";
$qdir = eZSys::siteDir() . eZSys::varDirectory() . $separator . 'mailq' . $separator;
$cli->output("Fetching mail source files");
$mailFiles = glob($qdir . '*.mail');
$cli->output("Sending " . count($mailFiles) . " emails");
$robinCounter = 0;
$active_server = 1;
$time_start = microtime_float2();
$smtp = getConnection($active_server, $serverlist);
$allowPersistent = $mailSettings->variable('SMTPClusterSettings', 'PersistentConnection') == 'enabled' ? true : false;
for ($i = 0; $i < count($mailFiles); $i++) {
    // sending message
    $email = file_get_contents($mailFiles[$i]);
    $lines = file($mailFiles[$i]);
    // get from and to
    $regex = regexEmail();
    $expression = "/({$regex})/";
Example #5
0
 function createFile($message)
 {
     $sys = eZSys::instance();
     $lineBreak = $sys->osType() == 'win32' ? "\r\n" : "\n";
     $separator = $sys->osType() == 'win32' ? "\\" : "/";
     $fname = time() . '-' . rand() . '.sms';
     $qdir = eZSys::siteDir() . eZSys::varDirectory() . $separator . 'mailq';
     $data = $message;
     $data = preg_replace('/(\\r\\n|\\r|\\n)/', "\r\n", $data);
     // echo 'eZFile::create('.$fname.', '.$qdir.', '.$data.');';
     eZFile::create($fname, $qdir, $data);
 }
Example #6
0
foreach (scandir('var/log') as $log) {
    $logfile = "var/log/{$log}";
    if (is_file($logfile) && substr($log, -4) == '.log' && !in_array($log, array('error.log', 'warning.log', 'debug.log', 'notice.log', 'strict.log'))) {
        $logFilesList[$log] = array('path' => $logfile, 'count' => '[1]', 'size' => filesize($logfile), 'modified' => filemtime($logfile), 'link' => 'sysinfo/customlogview/' . str_replace(array('/', '\\'), ':', $logfile));
    }
}
$logDir = eZSys::varDirectory() . '/' . $ini->variable('FileSettings', 'LogDir');
foreach (scandir($logDir) as $log) {
    $logfile = "{$logDir}/{$log}";
    if (is_file($logfile) && substr($log, -4) == '.log') {
        $logFilesList[$log] = array('path' => $logfile, 'count' => '[1]', 'size' => filesize($logfile), 'modified' => filemtime($logfile), 'link' => 'sysinfo/customlogview/' . str_replace(array('/', '\\'), ':', $logfile));
    }
}
// q: are we 100% sure that the eZ5 logs are always at that location?
if (class_exists('Symfony\\Component\\HttpKernel\\Kernel') && is_dir($ezp5CacheDir = eZSys::siteDir() . '/../ezpublish/cache')) {
    $logDir = eZSys::siteDir() . '/../ezpublish/logs';
    foreach (scandir($logDir) as $log) {
        $logfile = "{$logDir}/{$log}";
        if (is_file($logfile) && substr($log, -4) == '.log') {
            $logFilesList[$log] = array('path' => "Symfony/{$log}", 'count' => '[1]', 'size' => filesize($logfile), 'modified' => filemtime($logfile), 'link' => 'sysinfo/customlogview/' . 'symfony:' . $log);
        }
    }
}
// windows friendly
foreach ($logFilesList as &$desc) {
    $desc['path'] = str_replace('\\', '/', $desc['path']);
}
if ($Params['viewmode'] == 'json') {
    $response_type = $Params['viewmode'];
    $response_data = $logFilesList;
    return;
Example #7
0
foreach ($cacheList as $cacheItem) {
    if ($cacheItem['path'] != false && $cacheItem['enabled']) {
        $cacheDirsList[$cacheItem['id']] = $cacheItem['path'];
        $cacheDirsList2[$cacheItem['id']] = false;
    }
}
if ($http->hasPostVariable('SearchText') && $http->hasPostVariable('SearchCaches')) {
    $ini = eZINI::instance();
    $cachedir = eZSys::cacheDirectory();
    //$cachedir .= "/" .$ini->variable( 'ContentSettings', 'CacheDir' );
    $searchtext = $http->postVariable('SearchText');
    $is_regexp = $http->hasPostVariable('SearchType') && $http->postVariable('SearchType') == 'Regexp';
    foreach ($http->postVariable('SearchCaches') as $cache) {
        if (array_key_exists($cache, $cacheDirsList)) {
            // take care: this is hardcoded from knowledge of cache structure...
            if ($cacheDirsList[$cache] == 'var/cache/ini') {
                $filelist = array_merge($filelist, sysInfoTools::searchInFiles($searchtext, eZSys::siteDir() . '/' . $cacheDirsList[$cache], $is_regexp));
            } else {
                $filelist = array_merge($filelist, sysInfoTools::searchInFiles($searchtext, $cachedir . '/' . $cacheDirsList[$cache], $is_regexp));
            }
            $cacheDirsList2[$cache] = true;
        }
    }
    //print_r($filelist);
}
$tpl->setVariable('filelist', $filelist);
$tpl->setVariable('list_count', count($filelist));
$tpl->setVariable('searchtext', $searchtext);
$tpl->setVariable('cachelist', $cacheDirsList2);
$tpl->setVariable('deletedfiles', $deletedfiles);
$tpl->setVariable('is_regexp', $is_regexp);