本文整理汇总了PHP中AEUtilLogger::WriteLog方法的典型用法代码示例。如果您正苦于以下问题:PHP AEUtilLogger::WriteLog方法的具体用法?PHP AEUtilLogger::WriteLog怎么用?PHP AEUtilLogger::WriteLog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AEUtilLogger
的用法示例。
在下文中一共展示了AEUtilLogger::WriteLog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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());
}
}
示例2: _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;
}
}
示例3: 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;
}
}
示例4: 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);
}
示例5: reset
/**
* Resets the Kettenrad state, wipping out any pending backups and/or stale
* temporary data.
*
* @param array $config Configuration parameters for the reset operation
*/
public static function reset($config = array())
{
$default_config = array('global' => true, 'log' => false, 'maxrun' => 0);
$config = (object) array_merge($default_config, $config);
// Pause logging if so desired
if (!$config->log) {
AEUtilLogger::WriteLog(false, '');
}
$tag = null;
if (!$config->global) {
// If we're not resetting globally, get a list of running backups per tag
$tag = AEPlatform::getInstance()->get_backup_origin();
}
// Cache the factory before proceeding
$factory = AEFactory::serialize();
$runningList = AEPlatform::getInstance()->get_running_backups($tag);
// Origins we have to clean
$origins = array(AEPlatform::getInstance()->get_backup_origin());
// 1. Detect failed backups
if (is_array($runningList) && !empty($runningList)) {
// The current timestamp
$now = time();
// Mark running backups as failed
foreach ($runningList as $running) {
if (empty($tag)) {
// Check the timestamp of the log file to decide if it's stuck,
// but only if a tag is not set
$tstamp = @filemtime(AEUtilLogger::logName($running['origin']));
if ($tstamp !== false) {
// We can only check the timestamp if it's returned. If not, we assume the backup is stale
$difference = abs($now - $tstamp);
// Backups less than 3 minutes old are not considered stale
if ($difference < $config->maxrun) {
continue;
}
}
}
$filenames = AEUtilStatistics::get_all_filenames($running, false);
// Process if there are files to delete...
if (!is_null($filenames)) {
// Delete the failed backup's archive, if exists
foreach ($filenames as $failedArchive) {
AEPlatform::getInstance()->unlink($failedArchive);
}
}
// Mark the backup failed
$running['status'] = 'fail';
$running['multipart'] = 0;
$dummy = null;
AEPlatform::getInstance()->set_or_update_statistics($running['id'], $running, $dummy);
$origins[] = $running['origin'];
}
}
if (!empty($origins)) {
$origins = array_unique($origins);
foreach ($origins as $tag) {
AECoreKettenrad::load($tag);
// Remove temporary files
AEUtilTempfiles::deleteTempFiles();
// Delete any stale temporary data
AEUtilTempvars::reset($tag);
}
}
// Reload the factory
AEFactory::unserialize($factory);
unset($factory);
// Unpause logging if it was previously paused
if (!$config->log) {
AEUtilLogger::WriteLog(true, '');
}
}
示例6: tick
/**
* The public interface to an engine part. This method takes care for
* calling the correct method in order to perform the initialisation -
* run - finalisation cycle of operation and return a proper reponse array.
* @return array A Reponse Array
*/
public final function tick($nesting = 0)
{
$configuration = AEFactory::getConfiguration();
$timer = AEFactory::getTimer();
// Call the right action method, depending on engine part state
switch ($this->getState()) {
case "init":
$this->_prepare();
$breakFlag = $configuration->set('volatile.breakflag', false);
break;
case "prepared":
$this->_run();
break;
case "running":
$this->_run();
break;
case "postrun":
$this->_finalize();
$breakFlag = $configuration->set('volatile.breakflag', false);
break;
}
// If there is still time, we are not finished and there is no break flag set, re-run the tick()
// method.
$breakFlag = $configuration->get('volatile.breakflag', false);
if (!in_array($this->getState(), array('finished', 'error')) && $timer->getTimeLeft() > 0 && !$breakFlag && $nesting < 20 && $this->nest_logging) {
// Nesting is only applied if $this->nest_logging == true (currently only Kettenrad has this)
$nesting++;
if ($this->nest_logging) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "*** Batching successive steps (nesting level {$nesting})");
}
$out = $this->tick($nesting);
} else {
// Return the output array
$out = $this->_makeReturnTable();
// Things to do for nest-logged parts (currently, only Kettenrad is)
if ($this->nest_logging) {
if ($breakFlag) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "*** Engine steps batching: Break flag detected.");
}
// Reset the break flag
$configuration->set('volatile.breakflag', false);
// Log that we're breaking the step
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "*** Batching of engine steps finished. I will now return control to the caller.");
// Enforce minimum execution time
$timer = AEFactory::getTimer();
$timer->enforce_min_exec_time(true);
}
}
// Send a Return Table back to the caller
return $out;
}
示例7: AkeebaTimeoutTrap
function AkeebaTimeoutTrap()
{
if (connection_status() >= 2) {
AEUtilLogger::WriteLog(_AE_LOG_ERROR, 'Akeeba Engine has timed out');
}
}
示例8: processPart
public function processPart($absolute_filename)
{
// Retrieve engine configuration data
$config = AEFactory::getConfiguration();
$accesskey = trim($config->get('engine.postproc.s3.accesskey', ''));
$secret = trim($config->get('engine.postproc.s3.secretkey', ''));
$usessl = $config->get('engine.postproc.s3.usessl', 0) == 0 ? false : true;
$bucket = $config->get('engine.postproc.s3.bucket', '');
$legacy = $config->get('engine.postproc.s3.legacy', 0);
$directory = $config->get('volatile.postproc.directory', null);
$lowercase = $config->get('engine.postproc.s3.lowercase', 1);
$rrs = $config->get('engine.postproc.s3.rrs', 1);
$endpoint = $config->get('engine.postproc.s3.customendpoint', '');
if (empty($directory)) {
$directory = $config->get('engine.postproc.s3.directory', 0);
}
if (!empty($directory)) {
$directory = str_replace('\\', '/', $directory);
$directory = rtrim($directory, '/');
}
$endpoint = trim($endpoint);
if (!empty($endpoint)) {
$protoPos = strpos($endpoint, ':\\');
if ($protoPos !== false) {
$endpoint = substr($endpoint, $protoPos + 3);
}
$slashPos = strpos($endpoint, '/');
if ($slashPos !== false) {
$endpoint = substr($endpoint, $slashPos + 1);
}
}
// Sanity checks
if (empty($accesskey)) {
$this->setError('You have not set up your Amazon S3 Access Key');
return false;
}
if (empty($secret)) {
$this->setError('You have not set up your Amazon S3 Secret Key');
return false;
}
if (empty($bucket)) {
$this->setError('You have not set up your Amazon S3 Bucket');
return false;
} else {
// Remove any slashes from the bucket
$bucket = str_replace('/', '', $bucket);
if ($lowercase) {
$bucket = strtolower($bucket);
}
}
// Create an S3 instance with the required credentials
$s3 = AEUtilAmazons3::getInstance($accesskey, $secret, $usessl);
if (!empty($endpoint)) {
$s3->defaultHost = $endpoint;
}
// Do not use multipart uploads when in an immediate post-processing step,
// i.e. we are uploading a part right after its creation
$immediateEnabled = $config->get('engine.postproc.common.after_part', 0);
if ($immediateEnabled) {
$noMultipart = true;
} else {
$noMultipart = false;
}
// Disable multipart uploads if the user requested it
if ($legacy) {
$noMultipart = true;
}
// Are we already processing a multipart upload?
if (!empty($this->cache)) {
// Continue processing an existing file and return
$filename = $this->cache->filename;
$absolute_filename = $this->cache->absolute_filename;
$partNumber = $this->cache->partnumber;
$uploadID = $this->cache->uploadid;
$etags = $this->cache->etags;
$partNumber++;
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "S3 -- Uploading part {$partNumber} of {$uploadID}");
// DEBUG
/**
$flatetags = implode(', ',$etags);
AEUtilLogger::WriteLog(_AE_LOG_DEBUG,"S3 -- Absolute/relative filenames: $absolute_filename ### $filename");
AEUtilLogger::WriteLog(_AE_LOG_DEBUG,"S3 -- Etags: ".$flatetags);
AEUtilLogger::WriteLog(_AE_LOG_DEBUG,"S3 -- Serialized cache: ".serialize($this->cache));
/**/
$fileInfo = AEUtilAmazons3::inputFile($absolute_filename, false);
$fileInfo['UploadID'] = $uploadID;
$fileInfo['etags'] = $etags;
$fileInfo['PartNumber'] = $partNumber;
$input = $fileInfo;
// So that it doesn't get overwritten
$etag = AEUtilAmazons3::uploadMultipart($input, $bucket, $filename);
if ($etag === 0) {
// Done uploading, finalize
$this->cache = null;
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "S3 -- Finalizing multipart upload of " . basename($absolute_filename) . " (part #{$partNumber})");
$result = AEUtilAmazonS3::finalizeMultipart($fileInfo, $bucket, $filename);
$this->propagateFromObject($s3);
if ($result === false) {
// Finalization failed
return false;
//.........这里部分代码省略.........
示例9: crc32_file_php512
/**
* Very efficient CRC32 calculation for PHP 5.1.2 and greater, requiring
* the 'hash' PECL extension
*
* @param string $filename Absolute filepath
*
* @return integer The CRC32
*/
private function crc32_file_php512($filename)
{
// Detection of buggy PHP hosts
static $mustInvert = null;
if (is_null($mustInvert)) {
$test_crc = @hash('crc32b', 'test', false);
$mustInvert = strtolower($test_crc) == '0c7e7fd8';
// Normally, it's D87F7E0C :)
if ($mustInvert) {
AEUtilLogger::WriteLog(_AE_LOG_WARNING, 'Your server has a buggy PHP version which produces inverted CRC32 values. Attempting a workaround. ZIP files may appear as corrupt.');
}
}
$res = @hash_file('crc32b', $filename, false);
if ($mustInvert) {
// Workaround for buggy PHP versions (I think before 5.1.8) which produce inverted CRC32 sums
$res2 = substr($res, 6, 2) . substr($res, 4, 2) . substr($res, 2, 2) . substr($res, 0, 2);
$res = $res2;
}
$res = hexdec($res);
return $res;
}
示例10: apply_srp_quotas
public function apply_srp_quotas($parent) {
$parent->relayStep('Applying quotas');
$parent->relaySubstep('');
// If no quota settings are enabled, quit
$registry =& AEFactory::getConfiguration();
$srpQuotas = $registry->get('akeeba.quota.srp_size_quota');
if($srpQuotas <= 0)
{
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "No restore point quotas were defined; old restore point files will be kept intact" );
return true; // No quota limits were requested
}
// Get valid-looking backup ID's
$validIDs =& AEPlatform::get_valid_backup_records(true, array('restorepoint'));
$statistics =& AEFactory::getStatistics();
$latestBackupId = $statistics->getId();
// Create a list of valid files
$allFiles = array();
if(count($validIDs))
{
foreach($validIDs as $id)
{
$stat = AEPlatform::get_statistics($id);
// Multipart processing
$filenames = AEUtilStatistics::get_all_filenames($stat, true);
if(!is_null($filenames))
{
// Only process existing files
$filesize = 0;
foreach($filenames as $filename)
{
$filesize += @filesize($filename);
}
$allFiles[] = array('id' => $id, 'filenames' => $filenames, 'size' => $filesize);
}
}
}
unset($validIDs);
// If there are no files, exit early
if(count($allFiles) == 0)
{
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "There were no old restore points to apply quotas on" );
return true;
}
// Init arrays
$killids = array();
$ret = array();
$leftover = array();
// Do we need to apply size quotas?
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Processing restore point size quotas" );
// OK, let's start counting bytes!
$runningSize = 0;
while(count($allFiles) > 0)
{
// Each time, remove the last element of the backup array and calculate
// running size. If it's over the limit, add the archive to the return array.
$def = array_pop($allFiles);
$runningSize += $def['size'];
if($runningSize >= $srpQuotas)
{
if($latestBackupId == $def['id'])
{
$runningSize -= $def['size'];
}
else
{
$ret[] = $def['filenames'];
$killids[] = $def['filenames'];
}
}
}
// Convert the $ret 2-dimensional array to single dimensional
$quotaFiles = array();
foreach($ret as $temp)
{
foreach($temp as $filename)
{
$quotaFiles[] = $filename;
}
}
// Update the statistics record with the removed remote files
if(!empty($killids)) foreach($killids as $id) {
$data = array('filesexist' => '0');
AEPlatform::set_or_update_statistics($id, $data, $parent);
}
// Apply quotas
if(count($quotaFiles) > 0)
{
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Applying quotas" );
jimport('joomla.filesystem.file');
//.........这里部分代码省略.........
示例11: 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");
}
}
}
示例12: __construct
/**
* Public constructor, loads filter data and filter classes
*/
public final function __construct()
{
static $initializing = false;
parent::__construct();
// Call parent's constructor
// Load filter data from platform's database
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Fetching filter data from database');
$this->filter_registry =& AEPlatform::getInstance()->load_filters();
// Load platform, plugin and core filters
$this->filters = array();
$locations = array(AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'platform' . DIRECTORY_SEPARATOR . AKEEBAPLATFORM . DIRECTORY_SEPARATOR . 'filters', AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'filters', AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'filters');
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Loading filters');
foreach ($locations as $folder) {
$is_platform = $folder == AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'platform' . DIRECTORY_SEPARATOR . AKEEBAPLATFORM . DIRECTORY_SEPARATOR . 'filters';
$files = AEUtilScanner::getFiles($folder);
if ($files === false) {
continue;
}
// Skip inexistent folders
if (empty($files)) {
continue;
}
// Skip no-match folders
// Loop all files
foreach ($files as $file) {
if (substr($file, -4) != '.php') {
continue;
}
// Skip non-PHP files
if (in_array(substr($file, 0, 1), array('.', '_'))) {
continue;
}
// Skip filter files starting with dot or dash
$filter_name = ($is_platform ? 'Platform' : '') . ucfirst(basename($file, '.php'));
// Extract filter base name
if (array_key_exists($filter_name, $this->filters)) {
continue;
}
// Skip already loaded filters
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, '-- Loading filter ' . $filter_name);
$this->filters[$filter_name] =& AEFactory::getFilterObject($filter_name);
// Add the filter
}
}
// Load platform, plugin and core stacked filters
$locations = array(AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'platform' . DIRECTORY_SEPARATOR . AKEEBAPLATFORM . DIRECTORY_SEPARATOR . 'filters' . DIRECTORY_SEPARATOR . 'stack', AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'filters' . DIRECTORY_SEPARATOR . 'stack', AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'filters' . DIRECTORY_SEPARATOR . 'stack');
$config =& AEFactory::getConfiguration();
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Loading optional filters');
foreach ($locations as $folder) {
$is_platform = $folder == AEFactory::getAkeebaRoot() . DIRECTORY_SEPARATOR . 'platform' . DIRECTORY_SEPARATOR . AKEEBAPLATFORM . DIRECTORY_SEPARATOR . 'filters' . DIRECTORY_SEPARATOR . 'stack';
$files = AEUtilScanner::getFiles($folder);
if ($files === false) {
continue;
}
// Skip inexistent folders
if (empty($files)) {
continue;
}
// Skip no-match folders
// Loop all files
foreach ($files as $file) {
if (substr($file, -4) != '.php') {
continue;
}
// Skip non-PHP files
$bare_name = strtolower(basename($file, '.php'));
$filter_name = 'Stack' . ($is_platform ? 'Platform' : '') . ucfirst(basename($file, '.php'));
// Extract filter base name
if (array_key_exists($filter_name, $this->filters)) {
continue;
}
// Skip already loaded filters
if (!file_exists(substr($file, 0, -4) . '.ini')) {
continue;
}
// Make sure the INI file also exists
$key = "core.filters.{$bare_name}.enabled";
if ($config->get($key, 0)) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, '-- Loading optional filter ' . $filter_name);
$this->filters[$filter_name] =& AEFactory::getFilterObject($filter_name);
// Add the filter
}
}
}
}
示例13: process_dependencies
/**
* Process all table dependencies
*
* @return null
*/
protected function process_dependencies()
{
if (count($this->table_name_map) > 0) {
foreach ($this->table_name_map as $table_name => $table_abstract) {
$this->push_table($table_name);
}
}
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, __CLASS__ . " :: Processed dependencies");
}
示例14: 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) {
//.........这里部分代码省略.........
示例15: _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;
}