本文整理汇总了PHP中AEFactory::getPostprocEngine方法的典型用法代码示例。如果您正苦于以下问题:PHP AEFactory::getPostprocEngine方法的具体用法?PHP AEFactory::getPostprocEngine怎么用?PHP AEFactory::getPostprocEngine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AEFactory
的用法示例。
在下文中一共展示了AEFactory::getPostprocEngine方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dpeCustomAPICall
/**
* Runs a custom API call for the selected post-processing engine
*
* @return boolean
*/
public function dpeCustomAPICall()
{
$engine = $this->getState('engine');
$method = $this->getState('method');
$params = $this->getState('params', array());
$engine = AEFactory::getPostprocEngine($engine);
if ($engine === false) {
return false;
}
return $engine->customApiCall($method, $params);
}
示例2: dlfromremote
/**
* Downloads a file from the remote storage to the user's browsers
*/
public function dlfromremote()
{
$id = $this->getAndCheckId();
$part = $this->input->get('part', 0, 'int');
if ($id === false) {
$url = 'index.php?option=com_akeeba&view=remotefiles&tmpl=component&task=listactions&id=' . $id;
$this->setRedirect($url, JText::_('REMOTEFILES_ERR_INVALIDID'), 'error');
return true;
}
$stat = AEPlatform::getInstance()->get_statistics($id);
$remoteFilename = $stat['remote_filename'];
$rfparts = explode('://', $remoteFilename);
$engine = AEFactory::getPostprocEngine($rfparts[0]);
$remote_filename = $rfparts[1];
$basename = basename($remote_filename);
$extension = strtolower(str_replace(".", "", strrchr($basename, ".")));
if ($part > 0) {
$new_extension = substr($extension, 0, 1) . sprintf('%02u', $part);
} else {
$new_extension = $extension;
}
$filename = $basename . '.' . $new_extension;
$remote_filename = substr($remote_filename, 0, -strlen($extension)) . $new_extension;
if ($engine->downloads_to_browser_inline) {
@ob_end_clean();
@clearstatcache();
// Send MIME headers
header('MIME-Version: 1.0');
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
switch ($extension) {
case 'zip':
// ZIP MIME type
header('Content-Type: application/zip');
break;
default:
// Generic binary data MIME type
header('Content-Type: application/octet-stream');
break;
}
// Disable caching
header('Expires: Mon, 20 Dec 1998 01:00:00 GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
}
AEPlatform::getInstance()->load_configuration($stat['profile_id']);
$result = $engine->downloadToBrowser($remote_filename);
if (is_string($result) && $result !== true && $result !== false) {
// We have to redirect
$result = str_replace('://%2F', '://', $result);
@ob_end_clean();
header('Location: ' . $result);
flush();
JFactory::getApplication()->close();
} elseif ($result === false) {
// Failed to download
$url = 'index.php?option=com_akeeba&view=remotefiles&tmpl=component&task=listactions&id=' . $id;
$this->setRedirect($url, $engine->getWarning(), 'error');
}
return true;
}
示例3: deleteRemoteFiles
public function deleteRemoteFiles()
{
$id = $this->getState('id', -1);
$part = $this->getState('part', -1);
$ret = array('error' => false, 'finished' => false, 'id' => $id, 'part' => $part);
// Gather the necessary information to perform the delete
$stat = AEPlatform::getInstance()->get_statistics($id);
$remoteFilename = $stat['remote_filename'];
$rfparts = explode('://', $remoteFilename);
$engine = AEFactory::getPostprocEngine($rfparts[0]);
$remote_filename = $rfparts[1];
// Load the correct backup profile
AEPlatform::getInstance()->load_configuration($stat['profile_id']);
$config = AEFactory::getConfiguration();
// Start timing ourselves
$timer = AEFactory::getTimer();
// The core timer object
$start = $timer->getRunningTime();
// Mark the start of this download
$break = false;
// Don't break the step
while ($timer->getTimeLeft() && !$break && $part < $stat['multipart']) {
// Get the remote filename
$basename = basename($remote_filename);
$extension = strtolower(str_replace(".", "", strrchr($basename, ".")));
if ($part > 0) {
$new_extension = substr($extension, 0, 1) . sprintf('%02u', $part);
} else {
$new_extension = $extension;
}
$filename = $basename . '.' . $new_extension;
$remote_filename = substr($remote_filename, 0, -strlen($extension)) . $new_extension;
// Do we have to initialize the process?
if ($part == -1) {
// Init
$part = 0;
}
// Try to delete the part
$required_time = 1.0;
$result = $engine->delete($remote_filename);
if (!$result) {
$ret['error'] = JText::_('REMOTEFILES_ERR_CANTDELETE') . $engine->getWarning();
return $ret;
return;
} else {
// Successful delete
$end = $timer->getRunningTime();
$part++;
}
// Do we predict that we have enough time?
$required_time = max(1.1 * ($end - $start), $required_time);
if ($timer->getTimeLeft() < $required_time) {
$break = true;
}
$start = $end;
}
if ($part >= $stat['multipart']) {
// Just finished!
$stat['remote_filename'] = '';
AEPlatform::getInstance()->set_or_update_statistics($id, $stat, $engine);
$ret['finished'] = true;
return $ret;
} else {
// More work to do...
$ret['id'] = $id;
$ret['part'] = $part;
return $ret;
}
}
示例4: 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);
}
//.........这里部分代码省略.........
示例5: _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::getInstance()->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;
}
}
}
$this->stepDatabaseDump();
$null = null;
$this->writeline($null);
}
示例6: apply_remote_quotas
private function apply_remote_quotas()
{
$this->setStep('Applying remote storage quotas');
$this->setSubstep('');
// Make sure we are enabled
$config = AEFactory::getConfiguration();
$enableRemote = $config->get('akeeba.quota.remote', 0);
if (!$enableRemote) {
return true;
}
// Get the list of files to kill
if (empty($this->remote_files_killlist)) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'Applying remote file quotas');
$this->remote_files_killlist = $this->get_remote_quotas();
if (empty($this->remote_files_killlist)) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, 'No remote files to apply quotas to were found');
return true;
}
}
// Remove the files
$timer = AEFactory::getTimer();
while ($timer->getRunningTime() && count($this->remote_files_killlist)) {
$filename = array_shift($this->remote_files_killlist);
list($engineName, $path) = explode('://', $filename);
$engine = AEFactory::getPostprocEngine($engineName);
if (!$engine->can_delete) {
continue;
}
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Removing {$filename}");
$result = $engine->delete($path);
if (!$result) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Removal failed: " . $engine->getWarning());
}
}
// Return false if we have more work to do or true if we're done
if (count($this->remote_files_killlist)) {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Remote file removal will continue in the next step");
return false;
} else {
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Remote file quotas applied successfully");
return true;
}
}
示例7: upload
public function upload()
{
$id = $this->getState('id', -1);
$part = $this->getState('part', -1);
$frag = $this->getState('frag', -1);
// Calculate the filenames
$stat = AEPlatform::getInstance()->get_statistics($id);
$local_filename = $stat['absolute_path'];
$basename = basename($local_filename);
$extension = strtolower(str_replace(".", "", strrchr($basename, ".")));
if ($part > 0) {
$new_extension = substr($extension, 0, 1) . sprintf('%02u', $part);
} else {
$new_extension = $extension;
}
$filename = $basename . '.' . $new_extension;
$local_filename = substr($local_filename, 0, -strlen($extension)) . $new_extension;
// Load the post-processing engine
AEPlatform::getInstance()->load_configuration($stat['profile_id']);
$config = AEFactory::getConfiguration();
$session = JFactory::getSession();
$engine = null;
if (!empty($savedEngine) && $frag != -1) {
// If it's not the first fragment, try to revive the saved engine
$savedEngine = $session->get('postproc_engine', null, 'akeeba');
$engine = unserialize($savedEngine);
}
if (empty($engine)) {
$engine_name = $config->get('akeeba.advanced.proc_engine');
$engine = AEFactory::getPostprocEngine($engine_name);
}
// Start uploading
$result = $engine->processPart($local_filename);
switch ($result) {
case true:
$part++;
break;
case 1:
$frag++;
$savedEngine = serialize($engine);
$session->set('postproc_engine', null, 'akeeba');
break;
case false:
$part = -1;
return;
break;
}
$remote_filename = $config->get('akeeba.advanced.proc_engine', '') . '://';
$remote_filename .= $engine->remote_path;
if ($part >= 0) {
if ($part >= $stat['multipart']) {
// Update stats with remote filename
$data = array('remote_filename' => $remote_filename);
AEPlatform::getInstance()->set_or_update_statistics($id, $data, $engine);
}
}
$this->setState('id', $id);
$this->setState('part', $part);
$this->setState('frag', $frag);
$this->setState('stat', $stat);
$this->setState('remotename', $remote_filename);
return $result;
}
示例8: _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
//.........这里部分代码省略.........
示例9: postProcessDonePartFile
/**
* @param $archiver
* @param $configuration
*
* @return bool
*/
private function postProcessDonePartFile($archiver, $configuration)
{
$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');
return false;
}
示例10: upload
public function upload()
{
// Get the parameters
$id = $this->getAndCheckId();
$part = JRequest::getInt('part', 0);
$frag = JRequest::getInt('frag', 0);
// Check the backup stat ID
if($id === false) {
$url = 'index.php?option=com_akeeba&view=upload&tmpl=component&task=cancelled&id='.$id;
$this->setRedirect($url, JText::_('AKEEBA_TRANSFER_ERR_INVALIDID'), 'error');
return;
}
// Calculate the filenames
$stat = AEPlatform::get_statistics($id);
$local_filename = $stat['absolute_path'];
$basename = basename($local_filename);
$extension = strtolower(str_replace(".", "", strrchr($basename, ".")));
if($part > 0) {
$new_extension = substr($extension,0,1) . sprintf('%02u', $part);
} else {
$new_extension = $extension;
}
$filename = $basename.'.'.$new_extension;
$local_filename = substr($local_filename, 0, -strlen($extension)).$new_extension;
// Load the post-processing engine
AEPlatform::load_configuration($stat['profile_id']);
$config = AEFactory::getConfiguration();
$session = JFactory::getSession();
$engine = null;
if(!empty($savedEngine) && ($frag != -1)) {
// If it's not the first fragment, try to revive the saved engine
$savedEngine = $session->get('postproc_engine', null, 'akeeba');
$engine = unserialize($savedEngine);
}
if(empty($engine)) {
$engine_name = $config->get('akeeba.advanced.proc_engine');
$engine = AEFactory::getPostprocEngine($engine_name);
}
// Start uploading
$result = $engine->processPart($local_filename);
switch($result) {
case true:
$part++;
break;
case 1:
$frag++;
$savedEngine = serialize($engine);
$session->set('postproc_engine', null, 'akeeba');
break;
case false;
$part = -1;
return;
break;
}
if(version_compare(JVERSION, '1.6.0', 'ge')) {
$view = & $this->getView( 'upload', 'html', '', array('base_path' => $this->basePath));
} else {
$view = & $this->getView( 'upload', 'html', '', array( 'base_path'=>$this->_basePath));
}
if($part >= 0) {
if($part < $stat['multipart']) {
$view->setLayout('uploading');
$view->assign('parts',$stat['multipart']);
$view->assign('part', $part);
$view->assign('frag', $frag);
$view->assign('id', $id);
} else {
// Update stats with remote filename
$remote_filename = $config->get('akeeba.advanced.proc_engine','').'://';
$remote_filename .= $engine->remote_path;
$data = array(
'remote_filename' => $remote_filename
);
AEPlatform::set_or_update_statistics($id, $data, $engine);
$view->setLayout('done');
}
} else {
$view->setLayout('error');
}
$view->display();
}