本文整理汇总了PHP中AEPlatform::unlink方法的典型用法代码示例。如果您正苦于以下问题:PHP AEPlatform::unlink方法的具体用法?PHP AEPlatform::unlink怎么用?PHP AEPlatform::unlink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AEPlatform
的用法示例。
在下文中一共展示了AEPlatform::unlink方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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, // Reset all origins when true
'log' => false, // Log our actions
);
$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::get_backup_origin();
}
// Cache the factory before proceeding
$factory = AEFactory::serialize();
$runningList = AEPlatform::get_running_backups($tag);
// Origins we have to clean
$origins = array(
AEPlatform::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 < 180) continue;
}
}
$filenames = AEUtilStatistics::get_all_filenames($running);
// Process if there are files to delete...
if(!is_null($filenames))
{
// Delete the failed backup's archive, if exists
foreach($filenames as $failedArchive)
{
AEPlatform::unlink($failedArchive);
}
}
// Mark the backup failed
$running['status'] = 'fail';
$running['multipart'] = 0;
$dummy = null;
AEPlatform::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,'');
}
示例2: 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::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 = ((float)$usec + (float)$sec);
while( (count($this->file_list) > 0) )
//.........这里部分代码省略.........
示例3: _run
/**
* Implements the _run() abstract method
*/
protected function _run()
{
// Check if we are already done
if ($this->getState() == 'postrun') {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, __CLASS__." :: Already finished");
$this->setStep("");
$this->setSubstep("");
return;
}
// Mark ourselves as still running (we will test if we actually do towards the end ;) )
$this->setState('running');
// Check if we are still adding a database dump part to the archive, or if
// we have to post-process a part
if( AEUtilScripting::getScriptingParameter('db.saveasname','normal') != 'output' )
{
$archiver =& AEFactory::getArchiverEngine();
$configuration =& AEFactory::getConfiguration();
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::unlink($filename);
}
if($post_proc->break_after) {
$configuration->set('volatile.breakflag', true);
return;
}
}
}
if($configuration->get('volatile.engine.archiver.processingfile',false))
{
// We had already started archiving the db file, but it needs more time
$finished = true;
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Continuing adding the SQL dump part to the archive");
$archiver->addFile(null,null,null);
$this->propagateFromObject($archiver);
if($this->getError()) return;
$finished = !$configuration->get('volatile.engine.archiver.processingfile',false);
if($finished)
{
$this->getNextDumpPart();
}
else
{
return;
}
}
}
// Initialize local variables
$db =& $this->getDB();
if($this->getError()) return;
if( !is_object($db) || ($db === false) )
{
$this->setError(__CLASS__.'::_run() Could not connect to database?!');
return;
}
$outData = ''; // Used for outputting INSERT INTO commands
$this->enforceSQLCompatibility(); // Apply MySQL compatibility option
if($this->getError()) return;
// Touch SQL dump file
$nada = "";
$this->writeline($nada);
// Get this table's information
//.........这里部分代码省略.........
示例4: apply_srp_quotas
//.........这里部分代码省略.........
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');
foreach($quotaFiles as $file)
{
if(!@AEPlatform::unlink($file))
{
$parent->setWarning("Failed to remove old system restore point file ".$file );
}
}
}
return true;
}
示例5: apply_quotas
//.........这里部分代码省略.........
{
// Are there more files than the quota limit?
if( !(count($allFiles) > $countQuota) )
{
// No, effectively skip the quota checking
$leftover =& $allFiles;
}
else
{
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Processing count quotas" );
// Yes, aply the quota setting. Add to $ret all entries minus the last
// $countQuota ones.
$totalRecords = count($allFiles);
$checkLimit = $totalRecords - $countQuota;
// Only process if at least one file (current backup!) is to be left
for($count = 0; $count < $totalRecords; $count++)
{
$def = array_pop($allFiles);
if(count($ret) < $checkLimit)
{
if($latestBackupId != $def['id']) {
$ret[] = $def['filenames'];
$killids[] = $def['id'];
}
}
else
{
$leftover[] = $def;
}
}
unset($allFiles);
}
}
else
{
// No count quotas are applied
$leftover =& $allFiles;
}
// Do we need to apply size quotas?
if( $useSizeQuotas && is_numeric($sizeQuota) && !($sizeQuota <= 0) && (count($leftover) > 0) && !$useDayQuotas )
{
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Processing size quotas" );
// OK, let's start counting bytes!
$runningSize = 0;
while(count($leftover) > 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($leftover);
$runningSize += $def['size'];
if($runningSize >= $sizeQuota)
{
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, $this);
}
// Apply quotas
if(count($quotaFiles) > 0)
{
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Applying quotas" );
jimport('joomla.filesystem.file');
foreach($quotaFiles as $file)
{
if(!@AEPlatform::unlink($file))
{
$this->setWarning("Failed to remove old backup file ".$file );
}
}
}
$this->apply_obsolete_quotas();
return true;
}