本文整理汇总了PHP中AEUtilLogger类的典型用法代码示例。如果您正苦于以下问题:PHP AEUtilLogger类的具体用法?PHP AEUtilLogger怎么用?PHP AEUtilLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AEUtilLogger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _run
/**
* Implements the _run() abstract method
*/
function _run()
{
if ($this->getState() == 'postrun') {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, __CLASS__ . " :: Already finished");
$this->setStep('');
$this->setSubstep('');
} else {
$this->setState('running');
}
// Try to step the archiver
$archive = AEFactory::getArchiverEngine();
$ret = $archive->transformJPA($this->offset);
// Error propagation
$this->propagateFromObject($archive);
if ($ret !== false && $archive->getError() == '') {
$this->offset = $ret['offset'];
$this->setStep($ret['filename']);
}
// Check for completion
if ($ret['done']) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, __CLASS__ . ":: archive is initialized");
$this->setState('finished');
}
// Calculate percentage
$total_size = $ret['filesize'];
if ($total_size > 0) {
$this->progress = $this->offset / $total_size;
}
}
示例2: processPart
public function processPart($absolute_filename)
{
// Retrieve engine configuration data
$config = AEFactory::getConfiguration();
$address = trim($config->get('engine.postproc.email.address', ''));
$subject = $config->get('engine.postproc.email.subject', '0');
// Sanity checks
if (empty($address)) {
$this->setError('You have not set up a recipient\'s email address for the backup files');
return false;
}
// Send the file
$basename = basename($absolute_filename);
AEUtilLogger::WriteLog(_AE_LOG_INFO, "Preparing to email {$basename} to {$address}");
if (empty($subject)) {
$subject = JText::_('AKEEBA_DEFAULT_EMAIL_SUBJECT');
}
$body = "Emailing {$basename}";
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Subject: {$subject}");
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Body: {$body}");
$result = AEPlatform::getInstance()->send_email($address, $subject, $body, $absolute_filename);
// Return the result
if ($result !== true) {
// An error occured
$this->setError($result);
// Notify that we failed
return false;
} else {
// Return success
AEUtilLogger::WriteLog(_AE_LOG_INFO, "Email sent successfully");
return true;
}
}
示例3: _prepare
protected function _prepare()
{
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, __CLASS__ . " :: Processing parameters");
// Get the DB connection parameters
if (is_array($this->_parametersArray)) {
$driver = array_key_exists('driver', $this->_parametersArray) ? $this->_parametersArray['driver'] : 'mysql';
$host = array_key_exists('host', $this->_parametersArray) ? $this->_parametersArray['host'] : '';
$port = array_key_exists('port', $this->_parametersArray) ? $this->_parametersArray['port'] : '';
$username = array_key_exists('username', $this->_parametersArray) ? $this->_parametersArray['username'] : '';
$username = array_key_exists('user', $this->_parametersArray) ? $this->_parametersArray['user'] : $username;
$password = array_key_exists('password', $this->_parametersArray) ? $this->_parametersArray['password'] : '';
$database = array_key_exists('database', $this->_parametersArray) ? $this->_parametersArray['database'] : '';
$prefix = array_key_exists('prefix', $this->_parametersArray) ? $this->_parametersArray['prefix'] : '';
}
$options = array('driver' => $driver, 'host' => $host . ($port != '' ? ':' . $port : ''), 'user' => $username, 'password' => $password, 'database' => $database, 'prefix' => is_null($prefix) ? '' : $prefix);
$db = AEFactory::getDatabase($options);
$driverType = $db->getDriverType();
$className = 'AEDumpNative' . ucfirst($driverType);
// Check if we have a native dump driver
if (!class_exists($className, true)) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, __CLASS__ . " :: Native database dump engine {$className} not found; trying Reverse Engineering instead");
// Native driver nor found, I will try falling back to reverse engineering
$className = 'AEDumpReverse' . ucfirst($driverType);
}
if (!class_exists($className, true)) {
$this->setState('error', 'Akeeba Engine does not have a native dump engine for ' . $driverType . ' databases');
} else {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, __CLASS__ . " :: Instanciating new native database dump engine {$className}");
$this->_engine = new $className();
$this->_engine->setup($this->_parametersArray);
$this->_engine->callStage('_prepare');
$this->setState($this->_engine->getState(), $this->_engine->getError());
}
}
示例4: download
public function download()
{
AEPlatform::getInstance()->load_configuration(AEPlatform::getInstance()->get_active_profile());
$tag = JRequest::getCmd('tag', null);
$filename = AEUtilLogger::logName($tag);
@ob_end_clean();
// In case some braindead plugin spits its own HTML
header("Cache-Control: no-cache, must-revalidate");
// HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// Date in the past
header("Content-Description: File Transfer");
header('Content-Type: text/plain');
header('Content-Disposition: attachment; filename="Akeeba Backup Debug Log.txt"');
echo "WARNING: Do not copy and paste lines from this file!\r\n";
echo "You are supposed to ZIP and attach it in your support forum post.\r\n";
echo "If you fail to do so, your support request will receive minimal priority.\r\n";
echo "\r\n";
echo "--- START OF RAW LOG --\r\n";
@readfile($filename);
// The at sign is necessary to skip showing PHP errors if the file doesn't exist or isn't readable for some reason
echo "--- END OF RAW LOG ---\r\n";
flush();
JFactory::getApplication()->close();
}
示例5: updateMultipart
/**
* Updates the multipart status of the current backup attempt's statistics record
*
* @param int $multipart The new multipart status
*/
public function updateMultipart($multipart)
{
if ($this->multipart_lock) {
return;
}
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Updating multipart status to ' . $multipart);
// Cache this change and commit to db only after the backup is done, or failed
$registry = AEFactory::getConfiguration();
$registry->set('volatile.statistics.multipart', $multipart);
}
示例6: echoRawLog
public function echoRawLog()
{
$tag = $this->getState('tag', '');
echo "WARNING: Do not copy and paste lines from this file!\r\n";
echo "You are supposed to ZIP and attach it in your support forum post.\r\n";
echo "If you fail to do so, your support request will receive minimal priority.\r\n";
echo "\r\n";
echo "--- START OF RAW LOG --\r\n";
@readfile(AEUtilLogger::logName($tag));
// The at sign is necessary to skip showing PHP errors if the file doesn't exist or isn't readable for some reason
echo "--- END OF RAW LOG ---\r\n";
}
示例7: runAnalysis
public function runAnalysis()
{
$ret_array = array();
$ajaxTask = $this->getState('ajax');
$log = $this->getState('log');
switch ($ajaxTask) {
case 'start':
$tag = 'alice';
AliceUtilLogger::WriteLog(true);
AliceUtilLogger::WriteLog(_AE_LOG_INFO, 'Starting analysis');
AliceCoreKettenrad::reset(array('maxrun' => 0));
AliceUtilTempvars::reset($tag);
$kettenrad = AliceCoreKettenrad::load($tag);
$options = array('logToAnalyze' => AEUtilLogger::logName($log));
$kettenrad->setup($options);
$kettenrad->tick();
if ($kettenrad->getState() != 'running') {
$kettenrad->tick();
}
$ret_array = $kettenrad->getStatusArray();
$kettenrad->resetWarnings();
// So as not to have duplicate warnings reports
AliceCoreKettenrad::save($tag);
break;
case 'step':
$tag = 'alice';
$kettenrad = AliceCoreKettenrad::load($tag);
$kettenrad->tick();
$ret_array = $kettenrad->getStatusArray();
$kettenrad->resetWarnings();
// So as not to have duplicate warnings reports
AliceCoreKettenrad::save($tag);
if ($ret_array['HasRun'] == 1) {
// Let's get tests result
$config = AliceFactory::getConfiguration();
$feedback = $config->get('volatile.alice.feedback');
$ret_array['Results'] = json_encode($feedback);
// Clean up
AliceFactory::nuke();
AliceUtilTempvars::reset($tag);
}
break;
default:
break;
}
return $ret_array;
}
示例8: onKeyDown
}
document.oncontextmenu = mischandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;
// Disable CTRL-C, CTRL-V
function onKeyDown() {
return false;
}
document.onkeydown = onKeyDown;
</script>
<?php
// -- Get the log's file name
$tag = JRequest::getCmd('tag', 'null');
$logName = AEUtilLogger::logName($tag);
// Load JFile class
jimport('joomla.filesystem.file');
@ob_end_clean();
if (!JFile::exists($logName)) {
// Oops! The log doesn't exist!
echo '<p>' . JText::_('LOG_ERROR_LOGFILENOTEXISTS') . '</p>';
return;
} else {
// Allright, let's load and render it
$fp = fopen($logName, "rt");
if ($fp === FALSE) {
// Oops! The log isn't readable?!
echo '<p>' . JText::_('LOG_ERROR_UNREADABLE') . '</p>';
return;
}
示例9: AkeebaTimeoutTrap
function AkeebaTimeoutTrap()
{
if (connection_status() >= 2) {
AEUtilLogger::WriteLog(_AE_LOG_ERROR, 'Akeeba Engine has timed out');
}
}
示例10: enforce_min_exec_time
/**
* Enforce the minimum execution time
*
* @param bool $log Should I log what I'm doing? Default is true.
*/
public function enforce_min_exec_time($log = true)
{
// Try to get a sane value for PHP's maximum_execution_time INI parameter
if (@function_exists('ini_get')) {
$php_max_exec = @ini_get("maximum_execution_time");
} else {
$php_max_exec = 10;
}
if ($php_max_exec == "" || $php_max_exec == 0) {
$php_max_exec = 10;
}
// Decrease $php_max_exec time by 500 msec we need (approx.) to tear down
// the application, as well as another 500msec added for rounding
// error purposes. Also make sure this is never gonna be less than 0.
$php_max_exec = max($php_max_exec * 1000 - 1000, 0);
// Get the "minimum execution time per step" Akeeba Backup configuration variable
$configuration = AEFactory::getConfiguration();
$minexectime = $configuration->get('akeeba.tuning.min_exec_time', 0);
if (!is_numeric($minexectime)) {
$minexectime = 0;
}
// Make sure we are not over PHP's time limit!
if ($minexectime > $php_max_exec) {
$minexectime = $php_max_exec;
}
// Get current running time
$elapsed_time = $this->getRunningTime() * 1000;
// Only run a sleep delay if we haven't reached the minexectime execution time
if ($minexectime > $elapsed_time && $elapsed_time > 0) {
$sleep_msec = $minexectime - $elapsed_time;
if (function_exists('usleep')) {
if ($log) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Sleeping for {$sleep_msec} msec, using usleep()");
}
usleep(1000 * $sleep_msec);
} elseif (function_exists('time_nanosleep')) {
if ($log) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Sleeping for {$sleep_msec} msec, using time_nanosleep()");
}
$sleep_sec = floor($sleep_msec / 1000);
$sleep_nsec = 1000000 * ($sleep_msec - $sleep_sec * 1000);
time_nanosleep($sleep_sec, $sleep_nsec);
} elseif (function_exists('time_sleep_until')) {
if ($log) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Sleeping for {$sleep_msec} msec, using time_sleep_until()");
}
$until_timestamp = time() + $sleep_msec / 1000;
time_sleep_until($until_timestamp);
} elseif (function_exists('sleep')) {
$sleep_sec = ceil($sleep_msec / 1000);
if ($log) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Sleeping for {$sleep_sec} seconds, using sleep()");
}
sleep($sleep_sec);
}
} elseif ($elapsed_time > 0) {
// No sleep required, even if user configured us to be able to do so.
if ($log) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "No need to sleep; execution time: {$elapsed_time} msec; min. exec. time: {$minexectime} msec");
}
}
}
示例11: _createNewPart
/**
* Creates a new archive part
* @param bool $finalPart Set to true if it is the final part (therefore has the .jps extension)
*/
private function _createNewPart($finalPart = false)
{
// Push the previous part if we have to post-process it immediately
$configuration = AEFactory::getConfiguration();
if ($configuration->get('engine.postproc.common.after_part', 0)) {
$this->finishedPart[] = $this->_dataFileName;
}
$this->_totalFragments++;
$this->_currentFragment = $this->_totalFragments;
if ($finalPart) {
$this->_dataFileName = $this->_dataFileNameBase . '.jps';
} else {
$this->_dataFileName = $this->_dataFileNameBase . '.j' . sprintf('%02d', $this->_currentFragment);
}
AEUtilLogger::WriteLog(_AE_LOG_INFO, 'Creating new JPS part #' . $this->_currentFragment . ', file ' . $this->_dataFileName);
// Inform that we have chenged the multipart number
$statistics = AEFactory::getStatistics();
$statistics->updateMultipart($this->_totalFragments);
// Try to remove any existing file
@unlink($this->_dataFileName);
// Touch the new file
$result = @touch($this->_dataFileName);
if (function_exists('chmod')) {
chmod($this->_dataFileName, 0666);
}
return $result;
}
示例12: pack_files
/**
* Try to pack some files in the $file_list, restraining ourselves not to reach the max
* number of files or max fragment size while doing so. If this process is over and we are
* left without any more files, reset $done_scanning to false in order to instruct the class
* to scan for more files.
*
* @return bool True if there were files packed, false otherwise (empty filelist)
*/
private function pack_files()
{
// Get a reference to the archiver and the timer classes
$archiver = AEFactory::getArchiverEngine();
$timer = AEFactory::getTimer();
$configuration = AEFactory::getConfiguration();
// If post-processing after part creation is enabled, make sure we do post-process each part before moving on
if ($configuration->get('engine.postproc.common.after_part', 0)) {
if (!empty($archiver->finishedPart)) {
$filename = array_shift($archiver->finishedPart);
AEUtilLogger::WriteLog(_AE_LOG_INFO, 'Preparing to post process ' . basename($filename));
$post_proc = AEFactory::getPostprocEngine();
$result = $post_proc->processPart($filename);
$this->propagateFromObject($post_proc);
if ($result === false) {
$this->setWarning('Failed to process file ' . basename($filename));
} else {
AEUtilLogger::WriteLog(_AE_LOG_INFO, 'Successfully processed file ' . basename($filename));
}
// Should we delete the file afterwards?
if ($configuration->get('engine.postproc.common.delete_after', false) && $post_proc->allow_deletes && $result !== false) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Deleting already processed file ' . basename($filename));
AEPlatform::getInstance()->unlink($filename);
}
if ($post_proc->break_after && $result !== false) {
$configuration->set('volatile.breakflag', true);
return true;
}
// This is required to let the backup continue even after a post-proc failure
$this->resetErrors();
$this->setState('running');
}
}
// If the archiver has work to do, make sure it finished up before continuing
if ($configuration->get('volatile.engine.archiver.processingfile', false)) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Continuing file packing from previous step");
$result = $archiver->addFile('', '', '');
$this->propagateFromObject($archiver);
if ($this->getError()) {
return false;
}
// If that was the last step, mark a file done
if (!$configuration->get('volatile.engine.archiver.processingfile', false)) {
$this->progressMarkFileDone();
}
}
// Did it finish, or does it have more work to do?
if ($configuration->get('volatile.engine.archiver.processingfile', false)) {
// More work to do. Let's just tell our parent that we finished up successfully.
return true;
}
// Normal file backup loop; we keep on processing the file list, packing files as we go.
if (count($this->file_list) == 0) {
// No files left to pack -- This should never happen! We catch this condition at the end of this method!
$this->done_scanning = false;
$this->progressMarkFolderDone();
return false;
} else {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Packing files");
$packedSize = 0;
$numberOfFiles = 0;
list($usec, $sec) = explode(" ", microtime());
$opStartTime = (double) $usec + (double) $sec;
while (count($this->file_list) > 0) {
$file = @array_shift($this->file_list);
$size = 0;
if (file_exists($file)) {
$size = @filesize($file);
}
// Anticipatory file size algorithm
if ($numberOfFiles > 0 && $size > AELargeFileThreshold) {
if (!AEFactory::getConfiguration()->get('akeeba.tuning.nobreak.beforelargefile', 0)) {
// If the file is bigger than the big file threshold, break the step
// to avoid potential timeouts
$this->setBreakFlag();
AEUtilLogger::WriteLog(_AE_LOG_INFO, "Breaking step _before_ large file: " . $file . " - size: " . $size);
// Push the file back to the list.
array_unshift($this->file_list, $file);
// Mark that we are not done packing files
$this->done_scanning = true;
return true;
}
}
// Proactive potential timeout detection
// Rough estimation of packing speed in bytes per second
list($usec, $sec) = explode(" ", microtime());
$opEndTime = (double) $usec + (double) $sec;
if ($opEndTime - $opStartTime == 0) {
$_packSpeed = 0;
} else {
$_packSpeed = $packedSize / ($opEndTime - $opStartTime);
}
//.........这里部分代码省略.........
示例13: deleteTempFiles
/**
* Deletes all temporary files
*/
static function deleteTempFiles()
{
$configuration = AEFactory::getConfiguration();
$tempFiles = $configuration->get('volatile.tempfiles', false);
if ($tempFiles === false) {
$tempFiles = array();
} else {
$tempFiles = @unserialize($tempFiles);
}
$fileName = null;
if (!empty($tempFiles)) {
foreach ($tempFiles as $fileName) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "-- Removing temporary file {$fileName}");
$file = $configuration->get('akeeba.basic.output_directory') . '/' . $fileName;
$platform = strtoupper(PHP_OS);
if (substr($platform, 0, 6) == 'CYGWIN' || substr($platform, 0, 3) == 'WIN') {
// On Windows we have to chwon() the file first to make it owned by Nobody
@chown($file, 600);
}
$ret = @self::nullifyAndDelete($file);
}
}
$tempFiles = array();
$configuration->set('volatile.tempfiles', serialize($tempFiles));
}
示例14: _addFile
/**
* The most basic file transaction: add a single entry (file or directory) to
* the archive.
*
* @param bool $isVirtual If true, the next parameter contains file data instead of a file name
* @param string $sourceNameOrData Absolute file name to read data from or the file data itself is $isVirtual is true
* @param string $targetName The (relative) file name under which to store the file in the archive
* @return True on success, false otherwise
*/
protected function _addFile($isVirtual, &$sourceNameOrData, $targetName)
{
if (!is_object($this->zip)) {
return false;
}
if (!$isVirtual) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "AEArchiverZipnative :: Adding {$sourceNameOrData}");
if (is_dir($sourceNameOrData)) {
$result = $this->zip->addEmptyDir($targetName);
} else {
$this->runningSum += filesize($sourceNameOrData);
$result = $this->zip->addFile($sourceNameOrData, $targetName);
}
} else {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, ' Virtual add:' . $targetName . ' (' . strlen($sourceNameOrData) . ')');
$this->runningSum += strlen($sourceNameOrData);
if (empty($sourceNameOrData)) {
$result = $this->zip->addEmptyDir($targetName);
} else {
$result = $this->zip->addFromString($targetName, $sourceNameOrData);
}
}
$this->zip->close();
$this->__bootstrap_code();
return true;
}
示例15: transformJPA
/**
* Transforms a JPA archive (containing an installer) to the native archive format
* of the class. It actually extracts the source JPA in memory and instructs the
* class to include each extracted file.
*
* @param integer $index The index in the source JPA archive's list currently in use
* @param integer $offset The source JPA archive's offset to use
*
* @return boolean False if an error occurred, true otherwise
*/
public final function transformJPA($index, $offset)
{
static $totalSize = 0;
// Do we have to open the file?
if (!$this->_xform_fp) {
// Get the source path
$registry = AEFactory::getConfiguration();
$embedded_installer = $registry->get('akeeba.advanced.embedded_installer');
// Fetch the name of the installer image
$installerDescriptors = AEUtilInihelper::getInstallerList();
$xform_source = AEPlatform::getInstance()->get_installer_images_path() . DIRECTORY_SEPARATOR . 'foobar.jpa';
// We need this as a "safe fallback"
if (array_key_exists($embedded_installer, $installerDescriptors)) {
$packages = $installerDescriptors[$embedded_installer]['package'];
if (empty($packages)) {
// No installer package specified. Pretend we are done!
$retArray = array("filename" => '', "data" => '', "index" => 0, "offset" => 0, "skip" => false, "done" => true, "filesize" => 0);
return $retArray;
} else {
$packages = explode(',', $packages);
$totalSize = 0;
$pathPrefix = AEPlatform::getInstance()->get_installer_images_path() . DIRECTORY_SEPARATOR;
foreach ($packages as $package) {
$filePath = $pathPrefix . $package;
$totalSize += (int) @filesize($filePath);
}
if (count($packages) < $index) {
$this->setError(__CLASS__ . ":: Installer package index {$index} not found for embedded installer {$embedded_installer}");
return false;
}
$package = $packages[$index];
// A package is specified, use it!
$xform_source = $pathPrefix . $package;
}
}
// 2.3: Try to use sane default if the indicated installer doesn't exist
if (!file_exists($xform_source) && basename($xform_source) != 'angie.jpa') {
if ($index == 0) {
$this->setWarning(__CLASS__ . ":: Selected embedded installer not found, using ANGIE instead");
$xform_source = dirname($xform_source) . '/angie.jpa';
} else {
$this->setError(__CLASS__ . ":: Installer package {$xform_source} not found.");
return false;
}
}
// Try opening the file
if (file_exists($xform_source)) {
$this->_xform_fp = @fopen($xform_source, 'r');
if ($this->_xform_fp === false) {
$this->setError(__CLASS__ . ":: Can't seed archive with installer package " . $xform_source);
return false;
}
} else {
$this->setError(__CLASS__ . ":: Installer package " . $xform_source . " does not exist!");
return false;
}
}
$headerDataLength = 0;
if (!$offset) {
// First run detected!
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Initializing with JPA package ' . $xform_source);
$offset = 0;
// Skip over the header and check no problem exists
$offset = $this->_xformReadHeader();
if ($offset === false) {
$this->setError('JPA package file was not read');
return false;
// Oops! The package file doesn't exist or is corrupt
}
$headerDataLength = $offset;
}
$ret = $this->_xformExtract($offset);
$ret['index'] = $index;
if (is_array($ret)) {
$ret['chunkProcessed'] = $headerDataLength + $ret['offset'] - $offset;
$offset = $ret['offset'];
if (!$ret['skip'] && !$ret['done']) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, ' Adding ' . $ret['filename'] . '; Next offset:' . $offset);
$this->addVirtualFile($ret['filename'], '', $ret['data']);
if ($this->getError()) {
return false;
}
} elseif ($ret['done']) {
$registry = AEFactory::getConfiguration();
$embedded_installer = $registry->get('akeeba.advanced.embedded_installer');
$installerDescriptors = AEUtilInihelper::getInstallerList();
$packages = $installerDescriptors[$embedded_installer]['package'];
$packages = explode(',', $packages);
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, ' Done with package ' . $packages[$index]);
if (count($packages) > $index + 1) {
//.........这里部分代码省略.........