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
 function getStore()
 {
     $varDirPath = realpath(eZSys::varDirectory());
     $store_path = $varDirPath . eZSys::fileSeparator() . 'openid_consumer';
     if (!file_exists($store_path) && !mkdir($store_path)) {
         //throw error
         exit(0);
     }
     $store = new Auth_OpenID_FileStore($store_path);
     return $store;
 }
 /**
  * tmp dir for mail parser
  *    ezvardir / cjw_newsletter/tmp/
  * @return string dirname
  */
 public function getTmpDir($createDirIfNotExists = true)
 {
     $varDir = eZSys::varDirectory();
     // $dir = $varDir . "/cjw_newsletter/tmp/";
     $dir = eZDir::path(array($varDir, 'cjw_newsletter', 'tmp'));
     $fileSep = eZSys::fileSeparator();
     $filePath = $dir . $fileSep;
     if ($createDirIfNotExists === true) {
         if (!file_exists($filePath)) {
             eZDir::mkdir($filePath, false, true);
         }
     }
     return $filePath;
 }
Example #4
0
 /**
  * Logs the string $logString to the logfile webservices.log
  * in the current log directory (usually var/log).
  * If logging is disabled, nothing is done.
  *
  * In dev mode, also writes to the eZP logs to ease debugging (this happens
  * regardless of the logging level set for the extension itself)
  */
 static function appendLogEntry($logString, $debuglevel)
 {
     $ini = eZINI::instance('site.ini');
     if ($ini->variable('DebugSettings', 'DebugOutput') == 'enabled' && $ini->variable('TemplateSettings', 'DevelopmentMode') == 'enabled') {
         switch ($debuglevel) {
             case 'info':
             case 'notice':
                 eZDebug::writeNotice($logString, 'ggwebservices');
                 break;
             case 'debug':
                 eZDebug::writeDebug($logString, 'ggwebservices');
                 break;
             case 'warning':
                 eZDebug::writeWarning($logString, 'ggwebservices');
                 break;
             case 'error':
             case 'critical':
                 eZDebug::writeError($logString, 'ggwebservices');
                 break;
         }
     }
     if (!self::isLoggingEnabled($debuglevel)) {
         return false;
     }
     $varDir = eZSys::varDirectory();
     $logDir = 'log';
     $logName = 'webservices.log';
     $fileName = $varDir . '/' . $logDir . '/' . $logName;
     if (!file_exists($varDir . '/' . $logDir)) {
         //include_once( 'lib/ezfile/classes/ezdir.php' );
         eZDir::mkdir($varDir . '/' . $logDir, 0775, true);
     }
     if ($logFile = fopen($fileName, 'a')) {
         $nowTime = date("Y-m-d H:i:s : ");
         $text = $nowTime . $logString;
         /*if ( $label )
           $text .= ' [' . $label . ']';*/
         fwrite($logFile, $text . "\n");
         fclose($logFile);
     }
 }
 /**
  * Constructs an empty CjwNewsletterLog instance
  *
  * This constructor is private as this class should be used as a
  * singleton. Use the getInstance() method instead to get an ezcLog instance.
  *
  * @param boolean $isCliMode
  * @return void
  */
 protected function __construct($isCliMode = false)
 {
     if ($isCliMode === true) {
         $this->isCliMode = true;
     }
     $this->reset();
     $log = $this;
     // "var/log"
     $ini = eZINI::instance();
     $varDir = eZSys::varDirectory();
     $iniLogDir = $ini->variable('FileSettings', 'LogDir');
     $permissions = octdec($ini->variable('FileSettings', 'LogFilePermissions'));
     $logDir = eZDir::path(array($varDir, $iniLogDir));
     $logNamePostfix = '';
     // Debug enabled
     $cjwNewsletterIni = eZINI::instance('cjw_newsletter.ini');
     if ($cjwNewsletterIni->variable('DebugSettings', 'Debug') == 'enabled') {
         $this->debug = true;
     }
     if ($isCliMode === true) {
         $logNamePostfix = 'cli_';
     }
     // Create the writers
     $generalFilename = "cjw_newsletter_" . $logNamePostfix . "general.log";
     $errorFilename = "cjw_newsletter_" . $logNamePostfix . "error.log";
     $writeAll = new ezcLogUnixFileWriter($logDir, $generalFilename);
     $writeErrors = new ezcLogUnixFileWriter($logDir, $errorFilename);
     // Check file permissions
     foreach (array($generalFilename, $errorFilename) as $file) {
         $path = eZDir::path(array($logDir, $file));
         if (substr(decoct(fileperms($path)), 2) !== $permissions) {
             @chmod($path, $permissions);
         }
     }
     $errorFilter = new ezcLogFilter();
     $errorFilter->severity = ezcLog::ERROR;
     $log->getMapper()->appendRule(new ezcLogFilterRule($errorFilter, $writeErrors, true));
     $log->getMapper()->appendRule(new ezcLogFilterRule(new ezcLogFilter(), $writeAll, true));
 }
Example #6
0
 static function printReport($newWindow = false, $as_html = true, $returnReport = false, $allowedDebugLevels = false, $useAccumulators = true, $useTiming = true, $useIncludedFiles = false)
 {
     if (!eZDebug::isDebugEnabled()) {
         return null;
     }
     $debug = eZDebug::instance();
     $report = $debug->printReportInternal($as_html, $returnReport & $newWindow, $allowedDebugLevels, $useAccumulators, $useTiming, $useIncludedFiles);
     if ($newWindow == true) {
         $debugFilePath = eZDir::path(array(eZSys::varDirectory(), 'cache', 'debug.html'));
         $debugFileURL = $debugFilePath;
         eZURI::transformURI($debugFileURL, true);
         print "\n<SCRIPT LANGUAGE='JavaScript'>\n<!-- hide this script from old browsers\n\nfunction showDebug()\n{\n    var debugWindow;\n\n    if  (navigator.appName == \"Microsoft Internet Explorer\")\n    {\n        //Microsoft Internet Explorer\n        debugWindow = window.open( '{$debugFileURL}', 'ezdebug', 'width=500,height=550,status,scrollbars,resizable,screenX=0,screenY=20,left=20,top=40');\n        debugWindow.document.close();\n        debugWindow.location.reload();\n    }\n    else if (navigator.appName == \"Opera\")\n    {\n        //Opera\n        debugWindow = window.open( '', 'ezdebug', 'width=500,height=550,status,scrollbars,resizable,screenX=0,screenY=20,left=20,top=40');\n        debugWindow.location.href=\"{$debugFileURL}\";\n        debugWindow.navigate(\"{$debugFileURL}\");\n    }\n    else\n    {\n        //Mozilla, Firefox, etc.\n        debugWindow = window.open( '', 'ezdebug', 'width=500,height=550,status,scrollbars,resizable,screenX=0,screenY=20,left=20,top=40');\n        debugWindow.document.location.href=\"{$debugFileURL}\";\n    };\n}\n\nshowDebug();\n\n// done hiding from old browsers -->\n</SCRIPT>\n";
         $header = "<html><head><title>eZ debug</title></head><body>";
         $footer = "</body></html>";
         $fp = fopen($debugFilePath, "w+");
         fwrite($fp, $header);
         fwrite($fp, $report);
         fwrite($fp, $footer);
         fclose($fp);
     } else {
         if ($returnReport) {
             return $report;
         }
     }
     return null;
 }
Example #7
0
 static function cacheDirectory()
 {
     $ini = eZINI::instance();
     $cacheDir = $ini->variable('FileSettings', 'CacheDir');
     if ($cacheDir[0] == "/") {
         return eZDir::path(array($cacheDir));
     } else {
         return eZDir::path(array(eZSys::varDirectory(), $cacheDir));
     }
 }
 static function printReport($newWindow = false, $as_html = true, $returnReport = false, $allowedDebugLevels = false, $useAccumulators = true, $useTiming = true, $useIncludedFiles = false)
 {
     if (!self::isDebugEnabled()) {
         return null;
     }
     $debug = self::instance();
     $report = $debug->printReportInternal($as_html, $returnReport & $newWindow, $allowedDebugLevels, $useAccumulators, $useTiming, $useIncludedFiles);
     if ($newWindow == true) {
         $debugFilePath = eZDir::path(array(eZSys::varDirectory(), 'cache', 'debug.html'));
         $debugFileURL = $debugFilePath;
         eZURI::transformURI($debugFileURL, true);
         print "\n<script type='text/javascript'>\n<!--\n\n(function()\n{\n    var debugWindow;\n\n    if  (navigator.appName == \"Microsoft Internet Explorer\")\n    {\n        //Microsoft Internet Explorer\n        debugWindow = window.open( '{$debugFileURL}', 'ezdebug', 'width=500,height=550,status,scrollbars,resizable,screenX=0,screenY=20,left=20,top=40');\n        debugWindow.document.close();\n        debugWindow.location.reload();\n    }\n    else if (navigator.appName == \"Opera\")\n    {\n        //Opera\n        debugWindow = window.open( '', 'ezdebug', 'width=500,height=550,status,scrollbars,resizable,screenX=0,screenY=20,left=20,top=40');\n        debugWindow.location.href=\"{$debugFileURL}\";\n        debugWindow.navigate(\"{$debugFileURL}\");\n    }\n    else\n    {\n        //Mozilla, Firefox, etc.\n        debugWindow = window.open( '', 'ezdebug', 'width=500,height=550,status,scrollbars,resizable,screenX=0,screenY=20,left=20,top=40');\n        debugWindow.document.location.href=\"{$debugFileURL}\";\n    };\n})();\n\n// -->\n</script>\n";
         $header = "<!DOCTYPE html><html><head><title>eZ debug</title></head><body>";
         $footer = "</body></html>";
         $fullPage = ezpEvent::getInstance()->filter('response/output', $header . $report . $footer);
         file_put_contents($debugFilePath, $fullPage);
     } else {
         if ($returnReport) {
             return $report;
         }
     }
     return null;
 }
 static function virtualInfoFileName()
 {
     $infoFile = eZSys::varDirectory() . '/webdav/root/info.txt';
     return $infoFile;
 }
Example #10
0
<?php

/**
 * Create a graph of files-per-minute by analyzing storage.log
 *
 * @author G. Giunta
 * @copyright (C) G. Giunta 2008-2016
 * @license Licensed under GNU General Public License v2.0. See file license.txt
 *
 * @todo add support for user-selected start and end date
 * @todo support coarser intervals than 60 secs
 * @todo
 */
$errormsg = "";
// nb: this dir is calculated the same way as ezlog does
$logfile = eZSys::varDirectory() . '/' . $ini->variable('FileSettings', 'LogDir') . '/storage.log';
// but storage log also is in var/log (created I think before siteaccess settings are loaded)
$logfile2 = 'var/log/storage.log';
if ($Params['viewmode'] == 'json') {
    if (!is_file($logfile) && !is_file($logfile2)) {
        /// @todo return a 404 error?
    }
    $data = ezLogsGrapher::asum(ezLogsGrapher::parseLog($logfile, $scale), ezLogsGrapher::parseLog($logfile2, $scale));
    ksort($data);
    $mtime = @filemtime($logfile);
    $mtime2 = @filemtime($logfile2);
    $mdate = gmdate('D, d M Y H:i:s', $mtime > $mtime2 ? $mtime : $mtime2) . ' GMT';
    header('Content-Type: application/json');
    header("Last-Modified: {$mdate}");
    echo json_encode($data);
    eZExecution::cleanExit();
Example #11
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);
 }
    'use-modules' => true,
    'use-extensions' => true,
    'debug-output' => false,
) );

$script->startup();
$script->initialize();

$cli = eZCLI::instance();

$options = $script->getOptions('[remove]', '', array(
    'remove'              => 'Remove old files else copy. Use remove option in a second pass'
));

$remove = isset($options['remove']) && $options['remove'] == true;
$varDir = eZSys::varDirectory();
$newStaticDir = StaticData::directory();

$fileUtils = eZClusterFileHandler::instance( $path );
if( $fileUtils->requiresClusterizing() ) {
    $dfsBackend = new eZDFSFileHandlerDFSBackend();
    $mountPoint = $dfsBackend->getMountPoint();
    $varDir = eZDir::path(array($mountPoint, $varDir));
    $newStaticDir = eZDir::path(array($mountPoint, $newStaticDir));
}

$clusterList = ClusterTool::globCluster();
$oldStaticDir = eZDir::path(array($varDir, 'static-data'));

$applicationList = array();
$rows = ApplicationObject::fetchObjectList(ApplicationObject::definition(), array('identifier'), null, null, null, false);
Example #13
0
 $exporter = new $availableExporters[$options['exporter']]();
 // Check formatter validity
 if (!isset($options['formatter'])) {
     $options['formatter'] = 'disquswxr';
 } else {
     if (!isset($availableFormatters[$options['formatter']])) {
         throw new Exception("Invalid formatter '{$options['formatter']}'. Valid formatters are: " . implode(', ', array_keys($availableFormatters)));
     }
 }
 $formatter = new $availableFormatters[$options['formatter']]();
 // Now export
 $cli->notice("Now exporting with {$exporter->getName()} exporter and {$formatter->getName()} formatter...");
 $processor = new ExportProcessor($exporter, $formatter);
 $processor->export();
 // Rendering or splitting ?
 $exportDir = eZSys::varDirectory();
 $exportBaseFilename = 'comments-export';
 $exportFormat = $processor->getExportFormat();
 if (isset($options['split'])) {
     $cli->notice('Now splitting final file.');
     $splittedData = $processor->split();
     $cli->notice('Total size before splitting is ' . number_format($splittedData->totalSize / 1024 / 1024, 2) . 'M');
     foreach ($splittedData->stringArray as $i => $data) {
         $filename = "{$exportBaseFilename}.{$i}.{$exportFormat}";
         $cli->notice("Now rendering {$exportDir}/{$filename}");
         eZFile::create("{$filename}", $exportDir, $data, true);
     }
 } else {
     $cli->notice("Now rendering to {$exportDir}/{$exportBaseFilename}.{$exportFormat}");
     eZFile::create("{$exportBaseFilename}.{$exportFormat}", $exportDir, $processor->render(), true);
 }
Example #14
0
 /**
  * @return the directory used for storing log files.
  */
 private function logDirectory()
 {
     $ini = eZINI::instance();
     $logDir = $ini->variable('FileSettings', 'LogDir');
     if ($logDir[0] == "/") {
         return eZDir::path(array($logDir));
     } else {
         return eZDir::path(array(eZSys::varDirectory(), $logDir));
     }
 }
$visitDate = $visits[$visitAnswer];

// 2 - get xmls

$hash = md5( serialize( array(
        'type'              => $nlType,
        'frequency'         => $nlFrequency,
        'customer_type'     => false,
        'specialty'         => false,
        'publisher_folder'  => false,
    ) ).$clusterIdentifier );

$dfsBackend = new eZDFSFileHandlerDFSBackend();
$mountPoint = $dfsBackend->getMountPoint();

$lastFile = false;
foreach( glob( $mountPoint.eZSys::varDirectory()."/rssCache/".$hash.'.xml.2*') as $file )
{
    preg_match( '#\.(?P<rssYear>[0-9]{4})(?P<rssMonth>[0-9]{2})(?P<rssDay>[0-9]{2})_(?P<rssHour>[0-9]{2})(?P<rssMinutes>[0-9]{2})\.log$#', $file, $m );
    $rssDate = mktime( $m['rssHour'], $m['rssMinutes'], 0, $m['rssMonth'], $m['rssDay'], $m['rssYear'] );
    if ( $rssDate > $visitDate )
        break;
    $lastFile = $file;
}

$cli->cli->output( "\nLast generated file before Creator Mail's visit:" );
$cli->cli->output( $lastFile );


$script->shutdown( 0 );
 static function rootDirectory()
 {
     $rootDir = eZSys::varDirectory() . '/webdav/root';
     if (!file_exists($rootDir)) {
         eZDir::mkdir($rootDir, false, true);
     }
     return $rootDir;
 }
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU General Public License for more details.
//
//   You should have received a copy of version 2.0 of the GNU General
//   Public License along with this program; if not, write to the Free
//   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//   MA 02110-1301, USA.
//
//
// ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
//
/*! \file send_newsletter.php
*/
set_time_limit(0);
// check if another instance of this script is already running and prevent execution if so
$pidfilename = eZDir::cleanPath(eZSys::varDirectory() . '/run/eznewsletter.pid');
if (file_exists($pidfilename)) {
    $pid = file_get_contents($pidfilename);
    $cli->error("A newsletter cronjob is already running.");
    $cli->error("Please wait until the process (PID: {$pid}) is finished.");
    $cli->error("If the script crashed during sendout, delete the PID file {$pidfilename} and restart the script.");
    exit;
}
if (false == file_exists(dirname($pidfilename))) {
    eZDir::mkdir(dirname($pidfilename), false, true);
}
if (!is_writeable(dirname($pidfilename))) {
    $cli->error("PID file not writeable ( {$pidfilename} ). Please add write access for cronjob.");
    exit(1);
}
$pidfile = fopen($pidfilename, 'w');
function getImportResultFilePath($importId)
{
    $fileSep = eZSys::fileSeparator();
    $dir = eZSys::varDirectory() . $fileSep . 'cjw_newsletter' . $fileSep . 'csvimport';
    $file = $importId . '-import_result.serialize';
    return $dir . $fileSep . $file;
}
Example #19
0
$module = $Params['Module'];
$http = eZHTTPTool::instance();
$tpl = eZTemplate::factory();
$errors = array();
$tpl->resetVariables();
if ($http->hasPostVariable('pdf_string')) {
    if ($http->postVariable('pdf_string') == '') {
        $errors[] = "Empty string";
    }
}
if (count($errors) == 0 and $http->hasPostVariable('pdf_string')) {
    $pdf = 'extension/stamppdf/design/standard/images/MugoCollaborationWorkflowProductSheet.pdf';
    $label = htmlspecialchars($http->postVariable('pdf_string'), ENT_QUOTES);
    $filename = time() . '_' . rand(1, 1000) . '.pdf';
    $stamp = eZSys::varDirectory() . DIRECTORY_SEPARATOR . 'cache/stamp_' . $filename;
    exec("convert -size 2550x3500 -bordercolor white -border 20x20 -transparent white -pointsize 64  -fill red -font Helvetica-Bold label:'{$label}'  {$stamp}");
    header("Content-Type: application/pdf");
    header("Cache-Control: no-cache");
    header("Accept-Ranges: none");
    header("Content-Disposition: attachment; filename=\"MugoCollaborationWorkflowProductSheet.pdf\"");
    ob_start();
    passthru("pdftk {$pdf} stamp {$stamp} output -");
    $output = ob_get_contents();
    ob_end_clean();
    unlink($stamp);
    print $output;
    eZExecution::cleanExit();
}
$tpl->setVariable('errors', $errors);
$Result = array();
 /**
  * Logs to var/log/webdav.log AND var/<site_name>/log/webdav.log.
  *
  * From eZ Publish.
  *
  * @param string $logString String to record
  * @param string $label Label to put in front of $logString
  */
 public static function appendLogEntry($logString, $label = false)
 {
     if (!isset(self::$useLogging)) {
         $webdavINI = eZINI::instance(self::WEBDAV_INI_FILE);
         self::$useLogging = $webdavINI->variable('GeneralSettings', 'Logging') === 'enabled';
     }
     if (self::$useLogging) {
         if (PHP_SAPI === 'cli') {
             // var_dump( $logString );
         } else {
             $varDir = realpath(eZSys::varDirectory());
             $logDir = 'log';
             $logName = 'webdav.log';
             $fileName = $varDir . DIRECTORY_SEPARATOR . $logDir . DIRECTORY_SEPARATOR . $logName;
             if (!file_exists($varDir . DIRECTORY_SEPARATOR . $logDir)) {
                 eZDir::mkdir($varDir . DIRECTORY_SEPARATOR . $logDir, 0775, true);
             }
             $logFile = fopen($fileName, 'a');
             $nowTime = date("Y-m-d H:i:s : ");
             $text = $nowTime . $logString;
             if ($label) {
                 $text .= ' [' . $label . ']';
             }
             fwrite($logFile, $text . "\n");
             fclose($logFile);
         }
     }
 }
        $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})/";
 /**
  * create the dir and filename for the current mailboxItem
  *
  * @return array array( 'file_path' => $filePath,
  *                 'file_dir'  => $dir,
  *                 'file_name' => $fileName )
  */
 public function getFilePathArray()
 {
     $mailboxItemId = $this->attribute('id');
     $mailboxId = $this->attribute('mailbox_id');
     $messageId = $this->attribute('message_id');
     $messageIdentifier = $this->attribute('message_identifier');
     $createTimestamp = $this->attribute('created');
     $varDir = eZSys::varDirectory();
     $year = date('Y', $createTimestamp);
     $month = date('m', $createTimestamp);
     $day = date('d', $createTimestamp);
     // $dir = $varDir . "/cjw_newsletter/mailbox/$mailboxId/$year/$month/$day/";
     $dir = eZDir::path(array($varDir, 'cjw_newsletter', 'mailbox', $mailboxId, $year, $month, $day));
     $fileName = "{$mailboxId}-{$year}{$month}{$day}-{$mailboxItemId}.mail";
     $fileSep = eZSys::fileSeparator();
     $filePath = $dir . $fileSep . $fileName;
     return array('file_path' => $filePath, 'file_dir' => $dir, 'file_name' => $fileName);
 }
Example #23
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();
$script = eZScript::instance(array("description" => "eZ Publish trashed images sanitizer script (#017781).", "use-session" => false, "use-modules" => false, "use-extensions" => true));
$script->startup();
$options = $script->getOptions("[n]", "", array("-q" => "Quiet mode", "n" => "Do not wait"));
$script->initialize();
$cli = eZCLI::instance();
if (!isset($options['n'])) {
    $cli->warning("This cleanup script will remove any images from trashed objects.");
    $cli->warning("For more details about this cleanup, take a look at: http://issues.ez.no/17781.");
    $cli->warning();
    $cli->warning("IT IS YOUR RESPONSABILITY TO TAKE CARE THAT NO ITEMS REMAINS IN TRASH BEFORE RUNNING THIS SCRIPT.");
    $cli->warning();
    $cli->warning("You have 30 seconds to break the script (press Ctrl-C).");
    sleep(30);
}
$fileHandler = eZINI::instance("file.ini")->variable("ClusteringSettings", "FileHandler");
$directory = eZSys::varDirectory() . "/storage/images";
switch (strtolower($fileHandler)) {
    case "ezfsfilehandler":
    case "ezfs2filehandler":
        array_map("filesystemCleanup", glob("{$directory}/*"));
        break;
    case "ezdbfilehandler":
        databaseCleanup($directory);
        break;
    case "ezdfsfilehandler":
        dfsCleanup($directory);
        break;
    default:
        $cli->error("Unsupported '{$fileHandler}' FileHandler.");
}
$script->shutdown();
Example #25
0
            if (file_exists($archivelog)) {
                $data = ezLogsGrapher::asum($data, ezLogsGrapher::parseLog($archivelog));
                $size += filesize($archivelog);
                $count++;
            }
        }
        $logFilesList[$logname] = array('path' => $logfile, 'count' => $count, 'size' => $size, 'modified' => $modified, 'link' => 'sysinfo/logview/' . $logname);
    }
}
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);
        }
    }