本文整理汇总了PHP中AEFactory类的典型用法代码示例。如果您正苦于以下问题:PHP AEFactory类的具体用法?PHP AEFactory怎么用?PHP AEFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AEFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
// This is a directory inclusion filter.
$this->object = 'db';
$this->subtype = 'inclusion';
$this->method = 'direct';
$this->filter_name = 'PlatformSitedb';
// Add a new record for the core Joomla! database
// Get core database options
$options = AEPlatform::getInstance()->get_platform_database_options();
$host = $options['host'];
$port = NULL;
$socket = NULL;
$targetSlot = substr(strstr($host, ":"), 1);
if (!empty($targetSlot)) {
// Get the port number or socket name
if (is_numeric($targetSlot)) {
$port = $targetSlot;
} else {
$socket = $targetSlot;
}
// Extract the host name only
$host = substr($host, 0, strlen($host) - (strlen($targetSlot) + 1));
// This will take care of the following notation: ":3306"
if ($host == '') {
$host = 'localhost';
}
}
// This is the format of the database inclusion filters
$entry = array('host' => $host, 'port' => is_null($socket) ? is_null($port) ? '' : $port : $socket, 'username' => $options['user'], 'password' => $options['password'], 'database' => $options['database'], 'prefix' => $options['prefix'], 'dumpFile' => 'joomla.sql', 'driver' => AEPlatform::getInstance()->get_default_database_driver(true));
// We take advantage of the filter class magic to inject our custom filters
$configuration =& AEFactory::getConfiguration();
$this->filter_data['[SITEDB]'] = $entry;
parent::__construct();
}
示例2: display
function display()
{
$registry =& AEFactory::getConfiguration();
// Set the toolbar title
JToolBarHelper::title(JText::_('AKEEBA').':: <small>'.JText::_('SITETRANSFERWIZARD').'</small>','akeeba');
JToolBarHelper::back('AKEEBA_CONTROLPANEL', 'index.php?option='.JRequest::getCmd('option'));
// Add references to CSS and JS files
AkeebaHelperIncludes::includeMedia(false);
// Add live help
AkeebaHelperIncludes::addHelp();
$model = $this->getModel();
$task = JRequest::getCmd('task','default');
switch($task) {
case 'step1':
case 'default':
default:
$cpanelmodel = JModel::getInstance('Cpanel','AkeebaModel');
$this->assign('profilelist', $cpanelmodel->getProfilesList());
$this->assign('stw_profile_id', $model->getSTWProfileID());
break;
case 'step2':
$this->assignRef('opts', $model->getTransferSettings());
break;
case 'step3':
break;
}
parent::display();
}
示例3: check
public function check()
{
$db = AEFactory::getDatabase();
// Can I execute SHOW statements?
try {
$result = $db->setQuery('SHOW TABLES')->query();
} catch (Exception $e) {
AliceUtilLogger::WriteLog(_AE_LOG_INFO, $this->checkName . " Test failed, can't execute SHOW TABLES statement");
$this->setResult(-1);
throw new Exception(JText::_('ALICE_ANALYZE_REQUIREMENTS_DBPERMISSIONS_ERROR'));
}
if (!$result) {
AliceUtilLogger::WriteLog(_AE_LOG_INFO, $this->checkName . " Test failed, can't execute SHOW TABLES statement");
$this->setResult(-1);
throw new Exception(JText::_('ALICE_ANALYZE_REQUIREMENTS_DBPERMISSIONS_ERROR'));
}
try {
$result = $db->setQuery('SHOW CREATE TABLE ' . $db->nameQuote('#__ak_profiles'))->query();
} catch (Exception $e) {
AliceUtilLogger::WriteLog(_AE_LOG_INFO, $this->checkName . " Test failed, can't execute SHOW CREATE TABLE statement");
$this->setResult(-1);
throw new Exception(JText::_('ALICE_ANALYZE_REQUIREMENTS_DBPERMISSIONS_ERROR'));
}
if (!$result) {
AliceUtilLogger::WriteLog(_AE_LOG_INFO, $this->checkName . " Test failed, can't execute SHOW CREATE TABLE statement");
$this->setResult(-1);
throw new Exception(JText::_('ALICE_ANALYZE_REQUIREMENTS_DBPERMISSIONS_ERROR'));
}
return true;
}
示例4: initialize
/**
* Initialises the archiver class, seeding the remote installation
* from an existent installer's JPA archive.
*
* @param string $sourceJPAPath Absolute path to an installer's JPA archive
* @param string $targetArchivePath Absolute path to the generated archive (ignored in this class)
* @param array $options A named key array of options (optional)
* @access public
*/
public function initialize($targetArchivePath, $options = array())
{
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, __CLASS__ . " :: new instance");
$registry = AEFactory::getConfiguration();
$this->_host = $registry->get('engine.archiver.directsftp.host', '');
$this->_port = $registry->get('engine.archiver.directsftp.port', '22');
$this->_user = $registry->get('engine.archiver.directsftp.user', '');
$this->_pass = $registry->get('engine.archiver.directsftp.pass', '');
$this->_privkey = $registry->get('engine.archiver.directsftp.privkey', '');
$this->_pubkey = $registry->get('engine.archiver.directsftp.pubkey', '');
$this->_initdir = $registry->get('engine.archiver.directsftp.initial_directory', '');
if (isset($options['host'])) {
$this->_host = $options['host'];
}
if (isset($options['port'])) {
$this->_port = $options['port'];
}
if (isset($options['user'])) {
$this->_user = $options['user'];
}
if (isset($options['pass'])) {
$this->_pass = $options['pass'];
}
if (isset($options['privkey'])) {
$this->_privkey = $options['privkey'];
}
if (isset($options['pubkey'])) {
$this->_pubkey = $options['pubkey'];
}
if (isset($options['initdir'])) {
$this->_initdir = $options['initdir'];
}
$this->connect_ok = $this->_connectSFTP();
AEUtilLogger::WriteLog(_AE_LOG_DEBUG, __CLASS__ . " :: SFTP connection status: " . ($this->connect_ok ? 'success' : 'FAIL'));
}
示例5: 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;
}
}
示例6: _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());
}
}
示例7: apply
/**
* Handle the apply task which saves settings and shows the editor again
*
*/
public function apply()
{
// CSRF prevention
if (!JRequest::getVar(JUtility::getToken(), false, 'POST')) {
JError::raiseError('403', JText::_(version_compare(JVERSION, '1.6.0', 'ge') ? 'JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN' : 'Request Forbidden'));
}
// Get the var array from the request
$var = JRequest::getVar('var', array(), 'default', 'array');
// Make it into Akeeba Engine array format
$data = array();
foreach ($var as $key => $value) {
$data[$key] = $value;
}
// Forbid stupidly selecting the site's root as the output or temporary directory
if (array_key_exists('akeeba.basic.output_directory', $data)) {
$folder = $data['akeeba.basic.output_directory'];
$folder = AEUtilFilesystem::translateStockDirs($folder, true, true);
$check = AEUtilFilesystem::translateStockDirs('[SITEROOT]', true, true);
if ($check == $folder) {
JError::raiseWarning(503, JText::_('CONFIG_OUTDIR_ROOT'));
$data['akeeba.basic.output_directory'] = '[DEFAULT_OUTPUT]';
}
}
// Merge it
$config = AEFactory::getConfiguration();
$config->mergeArray($data, false, false);
// Save configuration
AEPlatform::getInstance()->save_configuration();
$this->setRedirect(JURI::base() . 'index.php?option=' . JRequest::getCmd('option') . '&view=config', JText::_('CONFIG_SAVE_OK'));
}
示例8: is_excluded_by_api
protected function is_excluded_by_api($test, $root)
{
static $from_datetime;
$config =& AEFactory::getConfiguration();
if (is_null($from_datetime) && $filter_switch) {
$user_setting = $config->get('core.filters.dateconditional.start');
$from_datetime = strtotime($user_setting);
}
// Get the filesystem path for $root
$fsroot = $config->get('volatile.filesystem.current_root', '');
$ds = $fsroot == '' || $fsroot == '/' ? '' : DIRECTORY_SEPARATOR;
$filename = $fsroot . $ds . $test;
// Get the timestamp of the file
$timestamp = @filemtime($filename);
// If we could not get this information, include the file in the archive
if ($timestamp === false) {
return false;
}
// Compare it with the user-defined minimum timestamp and exclude if it's older than that
if ($timestamp <= $from_datetime) {
return true;
}
// No match? Just include the file!
return false;
}
示例9: step
public function step()
{
// Check permissions
$this->_checkPermissions();
// Set the profile
$this->_setProfile();
$kettenrad =& AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN);
$array = $kettenrad->tick();
AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN);
if ($array['Error'] != '') {
@ob_end_clean();
echo '500 ERROR -- ' . $array['Error'];
flush();
JFactory::getApplication()->close();
} elseif ($array['HasRun'] == false) {
// All done
AEFactory::nuke();
AEUtilTempvars::reset();
@ob_end_clean();
echo '200 OK';
flush();
JFactory::getApplication()->close();
} else {
$noredirect = JRequest::getInt('noredirect', 0);
if ($noredirect != 0) {
@ob_end_clean();
echo "301 More work required";
flush();
JFactory::getApplication()->close();
} else {
$this->setRedirect(JURI::base() . 'index.php?option=com_akeeba&view=backup&task=step&key=' . JRequest::getVar('key') . '&profile=' . JRequest::getInt('profile', 1));
}
}
}
示例10: loadConfig
private static function loadConfig()
{
if (defined('JVERSION')) {
$j16 = version_compare(JVERSION, '1.6.0', 'ge');
} else {
$j16 = false;
}
$db =& AEFactory::getDatabase();
if (!$j16) {
$sql = "SELECT " . $db->nameQuote('params') . " FROM " . $db->nameQuote('#__components') . " WHERE (" . $db->nameQuote('link') . " = " . $db->Quote('option=com_akeeba') . ") AND (" . $db->nameQuote('parent') . " = " . $db->Quote('0') . ")";
$db->setQuery($sql);
$config_ini = $db->loadResult();
} else {
$config_ini = null;
}
if ($db->getErrorNum() || is_null($config_ini)) {
// Maybe it's Joomla! 1.6?
$sql = "SELECT " . $db->nameQuote('params') . " FROM " . $db->nameQuote('#__extensions') . " WHERE (" . $db->nameQuote('type') . ' = ' . $db->Quote('component') . ') AND (' . $db->nameQuote('element') . " = " . $db->Quote('com_akeeba') . ")";
$db->setQuery($sql);
$config_ini = $db->loadResult();
// OK, Joomla! 1.6 stores values JSON-encoded so, what do I do? Right!
$config_ini = json_decode($config_ini, true);
return $config_ini;
}
return AEUtilINI::parse_ini_file($config_ini, false, true);
}
示例11: display
public function display($tpl = null)
{
$task = JRequest::getCmd('task','default');
switch($task)
{
case 'step':
$kettenrad =& AEFactory::getKettenrad();
$array = $kettenrad->getStatusArray();
$this->assign('array', $array);
break;
case 'error':
$this->assign('errormessage', JRequest::getVar('error',''));
break;
case 'done':
break;
case 'default':
default:
$model =& $this->getModel();
$this->assignRef('profilelist', $model->getProfiles());
break;
}
parent::display(JRequest::getCmd('tpl',null));
}
示例12: foreach
public function &getExtraSQL($root)
{
$empty = '';
if ($root != '[SITEDB]') {
return $empty;
}
$sql = '';
$db = AEFactory::getDatabase();
$this->getFilters(null);
// Forcibly reload the filter data
// Loop all components and add SQL statements
if (!empty($this->filter_data)) {
foreach ($this->filter_data as $type => $items) {
if (!empty($items)) {
// Make sure that DB only backups get the correct prefix
$configuration = AEFactory::getConfiguration();
$abstract = AEUtilScripting::getScriptingParameter('db.abstractnames', 1);
if ($abstract) {
$prefix = '#__';
} else {
$prefix = $db->getPrefix();
}
foreach ($items as $item) {
$client = $type == 'frontend' ? 0 : 1;
$sql .= 'DELETE FROM ' . $db->quoteName($prefix . 'modules_menu') . ' WHERE ' . $db->quoteName('moduleid') . ' IN (' . 'SELECT ' . $db->quoteName('id') . ' FROM ' . $db->quoteName($prefix . 'modules') . ' WHERE ' . '(' . $db->quoteName('module') . ' = ' . $db->Quote($item) . ')' . ' AND (' . $db->quoteName('client_id') . ' = ' . $db->Quote($client) . ')' . ");\n";
$sql .= 'DELETE FROM ' . $db->quoteName($prefix . 'modules') . ' WHERE ' . '(' . $db->quoteName('module') . ' = ' . $db->Quote($item) . ')' . ' AND (' . $db->quoteName('client_id') . ' = ' . $db->Quote($client) . ')' . ";\n";
$sql .= 'DELETE FROM ' . $db->quoteName($prefix . 'extensions') . ' WHERE ' . $db->quoteName('element') . ' = ' . $db->Quote($item) . " AND " . $db->quoteName('type') . ' = ' . $db->Quote('module') . ";\n";
}
}
}
}
return $sql;
}
示例13: init
protected function init()
{
// Fetch the configuration
$config = AEFactory::getConfiguration();
$this->params = (object) array('type' => $config->get('core.filters.srp.type', 'component'), 'group' => $config->get('core.filters.srp.group', 'group'), 'name' => $config->get('core.filters.srp.name', 'name'), 'customdirs' => $config->get('core.filters.srp.customdirs', array()), 'customfiles' => $config->get('core.filters.srp.customfiles', array()), 'langfiles' => $config->get('core.filters.srp.langfiles', array()));
$this->alloweddirs = array();
// Process custom directories
if (is_array($this->params->customdirs)) {
foreach ($this->params->customdirs as $dir) {
$dir = $this->treatDirectory($dir);
$this->alloweddirs[] = $dir;
}
}
// Process custom files
if (is_array($this->params->customfiles)) {
foreach ($this->params->customfiles as $file) {
$dir = dirname($file);
$dir = $this->treatDirectory($dir);
if (!in_array($dir, $this->strictalloweddirs)) {
$this->strictalloweddirs[] = $dir;
}
if (!in_array($dir, $this->alloweddirs)) {
$this->alloweddirs[] = $dir;
}
}
}
$this->alloweddirs[] = 'language';
$this->alloweddirs[] = 'administrator/language';
// Process core directorires
switch ($this->params->type) {
case 'component':
$this->alloweddirs[] = 'components/com_' . $this->params->name;
$this->alloweddirs[] = 'administrator/components/com_' . $this->params->name;
$this->alloweddirs[] = 'media/com_' . $this->params->name;
$this->alloweddirs[] = 'media/' . $this->params->name;
break;
case 'plugin':
// This is required for Joomla! 1.5 compatibility
$this->alloweddirs[] = 'plugins/' . $this->params->group;
// This is required for Joomla! 1.6 compatibility
$this->alloweddirs[] = 'plugins/' . $this->params->group . '/' . $this->params->name;
break;
case 'module':
if ($this->params->group == 'admin') {
$this->alloweddirs[] = 'administrator/modules/mod_' . $this->params->name;
} else {
$this->alloweddirs[] = 'modules/mod_' . $this->params->name;
}
break;
case 'template':
if ($this->params->group == 'admin') {
$this->alloweddirs[] = 'administrator/templates/' . $this->params->name;
} else {
$this->alloweddirs[] = 'templates/' . $this->params->name;
}
break;
default:
$this->alloweddirs = array();
}
}
示例14: foreach
public function &getExtraSQL($root)
{
$empty = '';
if ($root != '[SITEDB]') {
return $empty;
}
$sql = '';
$db = AEFactory::getDatabase();
$this->getFilters(null);
// Forcibly reload the filter data
// Loop all components and add SQL statements
if (!empty($this->filter_data)) {
foreach ($this->filter_data as $type => $items) {
if (!empty($items)) {
// Make sure that DB only backups get the correct prefix
$configuration = AEFactory::getConfiguration();
$abstract = AEUtilScripting::getScriptingParameter('db.abstractnames', 1);
if ($abstract) {
$prefix = '#__';
} else {
$prefix = $db->getPrefix();
}
foreach ($items as $item) {
if (!$this->joomla16) {
$sql .= 'DELETE FROM ' . $db->quoteName($prefix . 'components') . ' WHERE ' . $db->quoteName('option') . ' = ' . $db->Quote($item) . ";\n";
} else {
$sql .= 'DELETE FROM ' . $db->quoteName($prefix . 'extensions') . ' WHERE ' . $db->quoteName('element') . ' = ' . $db->Quote($item) . " AND " . $db->quoteName('type') . ' = ' . $db->Quote('component') . ";\n";
}
$sql .= 'DELETE FROM ' . $db->quoteName($prefix . 'menu') . ' WHERE ' . $db->quoteName('type') . ' = ' . $db->Quote('component') . ' AND ' . $db->quoteName('link') . ' LIKE ' . $db->Quote('%option=' . $item . '%') . ";\n";
}
}
}
}
return $sql;
}
示例15: scanFolder
protected function scanFolder($folder, &$position, $forFolders = true, $threshold_key = 'dir', $threshold_default = 50)
{
$registry = AEFactory::getConfiguration();
// Initialize variables
$arr = array();
$false = false;
if (!is_dir($folder) && !is_dir($folder . '/')) {
return $false;
}
try {
$di = new DirectoryIterator($folder);
} catch (Exception $e) {
$this->setWarning('Unreadable directory ' . $folder);
return $false;
}
if (!$di->valid()) {
$this->setWarning('Unreadable directory ' . $folder);
return $false;
}
if (!empty($position)) {
$di->seek($position);
if ($di->key() != $position) {
$position = null;
return $arr;
}
}
$counter = 0;
$maxCounter = $registry->get("engine.scan.large.{$threshold_key}_threshold", $threshold_default);
while ($di->valid()) {
if ($di->isDot()) {
$di->next();
continue;
}
if ($di->isDir() != $forFolders) {
$di->next();
continue;
}
$ds = $folder == '' || $folder == '/' || @substr($folder, -1) == '/' || @substr($folder, -1) == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR;
$dir = $folder . $ds . $di->getFilename();
$data = _AKEEBA_IS_WINDOWS ? AEUtilFilesystem::TranslateWinPath($dir) : $dir;
if ($data) {
$counter++;
$arr[] = $data;
}
if ($counter == $maxCounter) {
break;
} else {
$di->next();
}
}
// Determine the new value for the position
$di->next();
if ($di->valid()) {
$position = $di->key() - 1;
} else {
$position = null;
}
return $arr;
}