コード例 #1
0
ファイル: storage.php プロジェクト: Arturogcalleja/herbolario
 public final function set($key, $value)
 {
     if ($key == 'updatedata') {
         if (function_exists('json_encode') && function_exists('json_decode')) {
             $value = json_encode($value);
         } elseif (function_exists('base64_encode') && function_exists('base64_decode')) {
             $value = base64_encode(serialize($value));
         } else {
             $value = serialize($value);
         }
     }
     self::$registry->setValue("update.{$key}", $value);
 }
コード例 #2
0
ファイル: storage.php プロジェクト: laiello/senluonirvana
 public final function set($key, $value)
 {
     if ($key == 'updatedata') {
         if (function_exists('json_encode') && function_exists('json_decode')) {
             $value = json_encode($value);
         } elseif (function_exists('base64_encode') && function_exists('base64_decode')) {
             $value = base64_encode(serialize($value));
         } else {
             $value = serialize($value);
         }
     }
     if (version_compare(JVERSION, '3.0.0', 'ge')) {
         self::$registry->set("update.{$key}", $value);
     } else {
         self::$registry->setValue("update.{$key}", $value);
     }
 }
コード例 #3
0
ファイル: session.php プロジェクト: gradha/Joomla1.5.999
 /**
  * Unset data from the session store
  *
  * @access public
  * @param  string 	$name 		Name of variable
  * @param  string 	$namespace 	Namespace to use, default to 'default'
  * @return mixed $value the value from session or NULL if not set
  */
 function clear($name, $namespace = 'default')
 {
     $namespace = '__' . $namespace;
     //add prefix to namespace to avoid collisions
     if ($this->_state !== 'active') {
         // @TODO :: generated error here
         return null;
     }
     return $this->data->setValue($namespace . '.' . $name, null);
 }
コード例 #4
0
ファイル: k2usergroup.php プロジェクト: vuchannguyen/dayhoc
 function bind($array, $ignore = '')
 {
     if (key_exists('params', $array) && is_array($array['params'])) {
         $registry = new JRegistry();
         $registry->loadArray($array['params']);
         if (JRequest::getVar('categories') == 'all' || JRequest::getVar('categories') == 'none') {
             $registry->setValue('categories', JRequest::getVar('categories'));
         }
         $array['permissions'] = $registry->toString();
     }
     return parent::bind($array, $ignore);
 }
コード例 #5
0
ファイル: ajax.json.php プロジェクト: 01J/topm
 public function editElement()
 {
     JSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
     jimport('joomla.utilities.date');
     jimport('joomla.user.helper');
     $user = JFactory::getUser();
     $groups = array_keys(JUserHelper::getUserGroups($user->get('id')));
     $result = new JRegistry('_default');
     $sitemapId = JREquest::getInt('id');
     if (!$user->authorise('core.edit', 'com_xmap.sitemap.' . $sitemapId)) {
         $result->setValue('result', 'KO');
         $result->setValue('message', 'You are not authorized to perform this action!');
     } else {
         $model = $this->getModel('sitemap');
         if ($model->getItem()) {
             $action = JRequest::getCmd('action', '');
             $uid = JRequest::getCmd('uid', '');
             $itemid = JRequest::getInt('itemid', '');
             switch ($action) {
                 case 'toggleElement':
                     if ($uid && $itemid) {
                         $state = $model->toggleItem($uid, $itemid);
                     }
                     break;
                 case 'changeProperty':
                     $uid = JRequest::getCmd('uid', '');
                     $property = JRequest::getCmd('property', '');
                     $value = JRequest::getCmd('value', '');
                     if ($uid && $itemid && $uid && $property) {
                         $state = $model->chageItemPropery($uid, $itemid, 'xml', $property, $value);
                     }
                     break;
             }
         }
         $result->set('result', 'OK');
         $result->set('state', $state);
         $result->set('message', '');
     }
     echo $result->toString();
 }
コード例 #6
0
ファイル: component.php プロジェクト: bizanto/Hooked
 public function save()
 {
     $data = self::$registry->toString('INI');
     $db =& JFactory::getDBO();
     // An interesting discovery: if your component is manually updating its
     // component parameters before Live Update is called, then calling Live
     // Update will reset the modified component parameters because
     // JComponentHelper::getComponent() returns the old, cached version of
     // them. So, we have to forget the following code and shoot ourselves in
     // the feet. Dammit!!!
     /*
     jimport('joomla.html.parameter');
     jimport('joomla.application.component.helper');
     $component =& JComponentHelper::getComponent(self::$component);
     $params = new JParameter($component->params);
     $params->setValue(self::$key, $data);
     */
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $sql = $db->getQuery(true)->select($db->nq('params'))->from($db->nq('#__extensions'))->where($db->nq('type') . ' = ' . $db->q('component'))->where($db->nq('element') . ' = ' . $db->q(self::$component));
     } else {
         $sql = 'SELECT ' . $db->nameQuote('params') . ' FROM ' . $db->nameQuote('#__components') . ' WHERE ' . $db->nameQuote('option') . ' = ' . $db->Quote(self::$component) . " AND `parent` = 0 AND `menuid` = 0";
     }
     $db->setQuery($sql);
     $rawparams = $db->loadResult();
     $params = new JRegistry();
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $params->loadJSON($rawparams);
     } else {
         $params->loadINI($rawparams);
     }
     $params->setValue(self::$key, $data);
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         // Joomla! 1.6
         $data = $params->toString('JSON');
         $sql = $db->getQuery(true)->update($db->nq('#__extensions'))->set($db->nq('params') . ' = ' . $db->q($data))->where($db->nq('type') . ' = ' . $db->q('component'))->where($db->nq('element') . ' = ' . $db->q(self::$component));
     } else {
         // Joomla! 1.5
         $data = $params->toString('INI');
         $sql = 'UPDATE `#__components` SET `params` = ' . $db->Quote($data) . ' WHERE ' . "`option` = " . $db->Quote(self::$component) . " AND `parent` = 0 AND `menuid` = 0";
     }
     $db->setQuery($sql);
     $db->query();
 }
コード例 #7
0
ファイル: application.php プロジェクト: kaantunc/MYK-BOR
 /**
  * Save the configuration
  */
 function save()
 {
     global $mainframe;
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     $ftp = JClientHelper::getCredentials('ftp');
     //Save user and media manager settings
     $table =& JTable::getInstance('component');
     $userpost['params'] = JRequest::getVar('userparams', array(), 'post', 'array');
     $userpost['option'] = 'com_users';
     $table->loadByOption('com_users');
     $table->bind($userpost);
     // pre-save checks
     if (!$table->check()) {
         JError::raiseWarning(500, $table->getError());
         return false;
     }
     // save the changes
     if (!$table->store()) {
         JError::raiseWarning(500, $table->getError());
         return false;
     }
     $mediapost['params'] = JRequest::getVar('mediaparams', array(), 'post', 'array');
     $mediapost['option'] = 'com_media';
     //Sanitize $file_path and $image_path
     $file_path = $mediapost['params']['file_path'];
     $image_path = $mediapost['params']['image_path'];
     if (strpos($file_path, '/') === 0 || strpos($file_path, '\\') === 0) {
         //Leading slash.  Kill it and default to /media
         $file_path = 'images';
     }
     if (strpos($image_path, '/') === 0 || strpos($image_path, '\\') === 0) {
         //Leading slash.  Kill it and default to /media
         $image_path = 'images/stories';
     }
     if (strpos($file_path, '..') !== false) {
         //downward directories.  Kill it and default to images/
         $file_path = 'images';
     }
     if (strpos($image_path, '..') !== false) {
         //downward directories  Kill it and default to images/stories
         $image_path = 'images/stories';
     }
     $mediapost['params']['file_path'] = $file_path;
     $mediapost['params']['image_path'] = $image_path;
     $table->loadByOption('com_media');
     $table->bind($mediapost);
     // pre-save checks
     if (!$table->check()) {
         JError::raiseWarning(500, $table->getError());
         return false;
     }
     // save the changes
     if (!$table->store()) {
         JError::raiseWarning(500, $table->getError());
         return false;
     }
     $config = new JRegistry('config');
     $config_array = array();
     // SITE SETTINGS
     $config_array['offline'] = JRequest::getVar('offline', 0, 'post', 'int');
     $config_array['editor'] = JRequest::getVar('editor', 'tinymce', 'post', 'cmd');
     $config_array['list_limit'] = JRequest::getVar('list_limit', 20, 'post', 'int');
     $config_array['helpurl'] = JRequest::getVar('helpurl', 'http://help.joomla.org', 'post', 'string');
     // DEBUG
     $config_array['debug'] = JRequest::getVar('debug', 0, 'post', 'int');
     $config_array['debug_lang'] = JRequest::getVar('debug_lang', 0, 'post', 'int');
     // SEO SETTINGS
     $config_array['sef'] = JRequest::getVar('sef', 0, 'post', 'int');
     $config_array['sef_rewrite'] = JRequest::getVar('sef_rewrite', 0, 'post', 'int');
     $config_array['sef_suffix'] = JRequest::getVar('sef_suffix', 0, 'post', 'int');
     // FEED SETTINGS
     $config_array['feed_limit'] = JRequest::getVar('feed_limit', 10, 'post', 'int');
     $config_array['feed_email'] = JRequest::getVar('feed_email', 'author', 'post', 'word');
     // SERVER SETTINGS
     $config_array['secret'] = JRequest::getVar('secret', 0, 'post', 'string');
     $config_array['gzip'] = JRequest::getVar('gzip', 0, 'post', 'int');
     $config_array['error_reporting'] = JRequest::getVar('error_reporting', -1, 'post', 'int');
     $config_array['xmlrpc_server'] = JRequest::getVar('xmlrpc_server', 0, 'post', 'int');
     $config_array['log_path'] = JRequest::getVar('log_path', JPATH_ROOT . DS . 'logs', 'post', 'string');
     $config_array['tmp_path'] = JRequest::getVar('tmp_path', JPATH_ROOT . DS . 'tmp', 'post', 'string');
     $config_array['live_site'] = rtrim(JRequest::getVar('live_site', '', 'post', 'string'), '/\\');
     $config_array['force_ssl'] = JRequest::getVar('force_ssl', 0, 'post', 'int');
     // LOCALE SETTINGS
     $config_array['offset'] = JRequest::getVar('offset', 0, 'post', 'float');
     // CACHE SETTINGS
     $config_array['caching'] = JRequest::getVar('caching', 0, 'post', 'int');
     $config_array['cachetime'] = JRequest::getVar('cachetime', 900, 'post', 'int');
     $config_array['cache_handler'] = JRequest::getVar('cache_handler', 'file', 'post', 'word');
     $config_array['memcache_settings'] = JRequest::getVar('memcache_settings', array(), 'post');
     // FTP SETTINGS
     $config_array['ftp_enable'] = JRequest::getVar('ftp_enable', 0, 'post', 'int');
     $config_array['ftp_host'] = JRequest::getVar('ftp_host', '', 'post', 'string');
     $config_array['ftp_port'] = JRequest::getVar('ftp_port', '', 'post', 'int');
     $config_array['ftp_user'] = JRequest::getVar('ftp_user', '', 'post', 'string');
     $config_array['ftp_pass'] = JRequest::getVar('ftp_pass', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $config_array['ftp_root'] = JRequest::getVar('ftp_root', '', 'post', 'string');
     // DATABASE SETTINGS
     $config_array['dbtype'] = JRequest::getVar('dbtype', 'mysql', 'post', 'word');
     $config_array['host'] = JRequest::getVar('host', 'localhost', 'post', 'string');
     $config_array['user'] = JRequest::getVar('user', '', 'post', 'string');
     $config_array['db'] = JRequest::getVar('db', '', 'post', 'string');
     $config_array['dbprefix'] = JRequest::getVar('dbprefix', 'jos_', 'post', 'string');
     // MAIL SETTINGS
     $config_array['mailer'] = JRequest::getVar('mailer', 'mail', 'post', 'word');
     $config_array['mailfrom'] = JRequest::getVar('mailfrom', '', 'post', 'string');
     $config_array['fromname'] = JRequest::getVar('fromname', 'Joomla 1.5', 'post', 'string');
     $config_array['sendmail'] = JRequest::getVar('sendmail', '/usr/sbin/sendmail', 'post', 'string');
     $config_array['smtpauth'] = JRequest::getVar('smtpauth', 0, 'post', 'int');
     $config_array['smtpsecure'] = JRequest::getVar('smtpsecure', 'none', 'post', 'word');
     $smtpport = JRequest::getVar('smtpport', '', 'post', 'int');
     $config_array['smtpport'] = $smtpport ? $smtpport : '25';
     $config_array['smtpuser'] = JRequest::getVar('smtpuser', '', 'post', 'string');
     $config_array['smtppass'] = JRequest::getVar('smtppass', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $config_array['smtphost'] = JRequest::getVar('smtphost', '', 'post', 'string');
     // META SETTINGS
     $config_array['MetaAuthor'] = JRequest::getVar('MetaAuthor', 1, 'post', 'int');
     $config_array['MetaTitle'] = JRequest::getVar('MetaTitle', 1, 'post', 'int');
     // SESSION SETTINGS
     $config_array['lifetime'] = JRequest::getVar('lifetime', 0, 'post', 'int');
     $config_array['session_handler'] = JRequest::getVar('session_handler', 'none', 'post', 'word');
     //LANGUAGE SETTINGS
     //$config_array['lang']				= JRequest::getVar('lang', 'none', 'english', 'cmd');
     //$config_array['language']			= JRequest::getVar('language', 'en-GB', 'post', 'cmd');
     $config->loadArray($config_array);
     //override any possible database password change
     $config->setValue('config.password', $mainframe->getCfg('password'));
     // handling of special characters
     $sitename = htmlspecialchars(JRequest::getVar('sitename', '', 'post', 'string'), ENT_COMPAT, 'UTF-8');
     $config->setValue('config.sitename', $sitename);
     $MetaDesc = htmlspecialchars(JRequest::getVar('MetaDesc', '', 'post', 'string'), ENT_COMPAT, 'UTF-8');
     $config->setValue('config.MetaDesc', $MetaDesc);
     $MetaKeys = htmlspecialchars(JRequest::getVar('MetaKeys', '', 'post', 'string'), ENT_COMPAT, 'UTF-8');
     $config->setValue('config.MetaKeys', $MetaKeys);
     // handling of quotes (double and single) and amp characters
     // htmlspecialchars not used to preserve ability to insert other html characters
     $offline_message = JRequest::getVar('offline_message', '', 'post', 'string');
     $offline_message = JFilterOutput::ampReplace($offline_message);
     $offline_message = str_replace('"', '"', $offline_message);
     $offline_message = str_replace("'", ''', $offline_message);
     $config->setValue('config.offline_message', $offline_message);
     //purge the database session table (only if we are changing to a db session store)
     if ($mainframe->getCfg('session_handler') != 'database' && $config->getValue('session_handler') == 'database') {
         $table =& JTable::getInstance('session');
         $table->purge(-1);
     }
     // Get the path of the configuration file
     $fname = JPATH_CONFIGURATION . DS . 'configuration.php';
     // Update the credentials with the new settings
     $oldconfig =& JFactory::getConfig();
     $oldconfig->setValue('config.ftp_enable', $config_array['ftp_enable']);
     $oldconfig->setValue('config.ftp_host', $config_array['ftp_host']);
     $oldconfig->setValue('config.ftp_port', $config_array['ftp_port']);
     $oldconfig->setValue('config.ftp_user', $config_array['ftp_user']);
     $oldconfig->setValue('config.ftp_pass', $config_array['ftp_pass']);
     $oldconfig->setValue('config.ftp_root', $config_array['ftp_root']);
     JClientHelper::getCredentials('ftp', true);
     if (!$config->get('caching') && $oldconfig->get('caching')) {
         $cache = JFactory::getCache();
         $cache->clean();
     }
     // Try to make configuration.php writeable
     jimport('joomla.filesystem.path');
     if (!$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0644')) {
         JError::raiseNotice('SOME_ERROR_CODE', 'Could not make configuration.php writable');
     }
     // Get the config registry in PHP class format and write it to configuation.php
     jimport('joomla.filesystem.file');
     if (JFile::write($fname, $config->toString('PHP', 'config', array('class' => 'JConfig')))) {
         $msg = JText::_('The Configuration Details have been updated');
     } else {
         $msg = JText::_('ERRORCONFIGFILE');
     }
     // Redirect appropriately
     $task = $this->getTask();
     switch ($task) {
         case 'apply':
             $this->setRedirect('index.php?option=com_config', $msg);
             break;
         case 'save':
         default:
             $this->setRedirect('index.php', $msg);
             break;
     }
     // Try to make configuration.php unwriteable
     //if (!$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0444')) {
     if ($config_array['ftp_enable'] == 0 && !$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0444')) {
         JError::raiseNotice('SOME_ERROR_CODE', 'Could not make configuration.php unwritable');
     }
 }
コード例 #8
0
ファイル: postsetup.php プロジェクト: ppantilla/bbninja
 public function save()
 {
     $enableSRP = $this->input->get('srp', 0, 'bool');
     $enableAutoupdate = $this->input->get('autoupdate', 0, 'bool');
     $enableBackuponupdate = $this->input->get('backuponupdate', 0, 'bool');
     $runConfwiz = $this->input->get('confwiz', 0, 'bool');
     $acceptlicense = $this->input->get('acceptlicense', 0, 'bool');
     $acceptsupport = $this->input->get('acceptsupport', 0, 'bool');
     $acceptbackuptest = $this->input->get('acceptbackuptest', 0, 'bool');
     // SRP is only supported on MySQL databases
     if (!$this->isMySQL()) {
         $enableSRP = false;
     }
     $db = JFactory::getDBO();
     if ($enableSRP) {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where($db->qn('element') . ' = ' . $db->q('srp'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     } else {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('0'))->where($db->qn('element') . ' = ' . $db->q('srp'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     }
     if ($enableBackuponupdate) {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where($db->qn('element') . ' = ' . $db->q('backuponupdate'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     } else {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('0'))->where($db->qn('element') . ' = ' . $db->q('backuponupdate'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     }
     $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('0'))->where($db->qn('element') . ' = ' . $db->q('akeebaupdatecheck'))->where($db->qn('folder') . ' = ' . $db->q('system'));
     $db->setQuery($query);
     $db->execute();
     // Update last version check and minstability. DO NOT USE JCOMPONENTHELPER!
     $sql = $db->getQuery(true)->select($db->qn('params'))->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q('component'))->where($db->qn('element') . ' = ' . $db->q('com_akeeba'));
     $db->setQuery($sql);
     $rawparams = $db->loadResult();
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $params = new JRegistry();
         if (version_compare(JVERSION, '3.0', 'ge')) {
             $params->loadString($rawparams);
         } else {
             $params->loadJSON($rawparams);
         }
     } else {
         $params = new JRegistry($rawparams);
     }
     if ($acceptlicense && $acceptsupport) {
         $version = AKEEBA_VERSION;
     } else {
         $version = '0.0.0';
     }
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $params->set('lastversion', $version);
         $params->set('acceptlicense', $acceptlicense);
         $params->set('acceptsupport', $acceptsupport);
         $params->set('acceptbackuptest', $acceptbackuptest);
     } else {
         $params->setValue('lastversion', $version);
         $params->setValue('acceptlicense', $acceptlicense);
         $params->setValue('acceptsupport', $acceptsupport);
         $params->setValue('acceptbackuptest', $acceptbackuptest);
     }
     $data = $params->toString('JSON');
     $sql = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('params') . ' = ' . $db->q($data))->where($db->qn('element') . ' = ' . $db->q('com_akeeba'))->where($db->qn('type') . ' = ' . $db->q('component'));
     $db->setQuery($sql);
     $db->execute();
     // Even better, create the "akeeba.lastversion.php" file with this information
     $fileData = "<" . "?php\ndefined('_JEXEC') or die();\ndefine('AKEEBA_LASTVERSIONCHECK','" . $version . "');";
     JLoader::import('joomla.filesystem.file');
     $fileName = JPATH_COMPONENT_ADMINISTRATOR . '/akeeba.lastversion.php';
     JFile::write($fileName, $fileData);
     // Reset the plugins and modules cache
     F0FUtilsCacheCleaner::clearPluginsCache();
     // Run the configuration wizard if requested
     $message = '';
     if ($runConfwiz) {
         $url = 'index.php?option=com_akeeba&view=confwiz';
     } else {
         $url = 'index.php?option=com_akeeba&view=cpanel';
     }
     if (!$acceptlicense) {
         JFactory::getApplication()->enqueueMessage(JText::_('AKEEBA_POSTSETUP_ERR_ACCEPTLICENSE'), 'error');
         $url = 'index.php?option=com_akeeba&view=postsetup';
     }
     if (!$acceptsupport) {
         JFactory::getApplication()->enqueueMessage(JText::_('AKEEBA_POSTSETUP_ERR_ACCEPTSUPPORT'), 'error');
         $url = 'index.php?option=com_akeeba&view=postsetup';
     }
     if (!$acceptbackuptest) {
         JFactory::getApplication()->enqueueMessage(JText::_('AKEEBA_POSTSETUP_ERR_ACCEPTBACKUPTEST'), 'error');
         $url = 'index.php?option=com_akeeba&view=postsetup';
     }
     JFactory::getApplication()->redirect($url);
 }
コード例 #9
0
 public function save()
 {
     // CSRF prevention
     $this->_csrfProtection();
     $enableAutoupdate = $this->input->getBool('autoupdate', 0);
     $enableAutojupdate = $this->input->getBool('autojupdate', 0);
     $acceptlicense = $this->input->getBool('acceptlicense', 0);
     $acceptsupport = $this->input->getBool('acceptsupport', 0);
     $db = JFactory::getDBO();
     if ($enableAutoupdate || $enableAutojupdate) {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where($db->qn('element') . ' = ' . $db->q('oneclickaction'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     } else {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('0'))->where($db->qn('element') . ' = ' . $db->q('oneclickaction'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     }
     $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('0'))->where($db->qn('element') . ' = ' . $db->q('atoolsupdatecheck'))->where($db->qn('folder') . ' = ' . $db->q('system'));
     $db->setQuery($query);
     $db->execute();
     if ($enableAutojupdate) {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where($db->qn('element') . ' = ' . $db->q('atoolsjupdatecheck'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     } else {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('0'))->where($db->qn('element') . ' = ' . $db->q('atoolsjupdatecheck'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     }
     // Load the component parameters. DO NOT USE JCOMPONENTHELPER!
     $query = $db->getQuery(true)->select(array($db->qn('params')))->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q('component'))->where($db->qn('element') . ' = ' . $db->q('com_admintools'));
     $db->setQuery($query);
     $rawparams = $db->loadResult();
     $params = new JRegistry();
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $params->loadString($rawparams, 'JSON');
     } else {
         $params->loadJSON($rawparams);
     }
     // Apply htmaker folders fix.
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $has240Fix = $params->get('htmaker_folders_fix_at240', '0');
     } else {
         $has240Fix = $params->getValue('htmaker_folders_fix_at240', '0');
     }
     if (!$has240Fix) {
         $htmaker = $this->getModel('htmaker');
         $config = $htmaker->loadConfiguration();
         $isConfigChanged = false;
         $jUpdateRestore = 'administrator/components/com_joomlaupdate/restore.php';
         if (!in_array($jUpdateRestore, $config->exceptionfiles)) {
             array_push($config->exceptionfiles, $jUpdateRestore);
             $isConfigChanged = true;
         }
         $fontDir = 'media/jui/fonts';
         if (!in_array($fontDir, $config->fepexdirs)) {
             array_push($config->fepexdirs, $fontDir);
             $isConfigChanged = true;
         }
         if ($isConfigChanged) {
             $htmaker->saveConfiguration($config, true);
         }
         if (version_compare(JVERSION, '3.0', 'ge')) {
             $params->set('htmaker_folders_fix_at240', '1');
         } else {
             $params->setValue('htmaker_folders_fix_at240', '1');
         }
     }
     // Update last version check.
     if ($acceptlicense && $acceptsupport) {
         $version = ADMINTOOLS_VERSION;
     } else {
         $version = '0.0.0';
     }
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $params->set('lastversion', $version);
         $params->set('acceptlicense', $acceptlicense);
         $params->set('acceptsupport', $acceptsupport);
     } else {
         $params->setValue('lastversion', $version);
         $params->setValue('acceptlicense', $acceptlicense);
         $params->setValue('acceptsupport', $acceptsupport);
     }
     // Joomla! 1.6
     $data = $params->toString('JSON');
     $sql = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('params') . ' = ' . $db->q($data))->where($db->qn('element') . ' = ' . $db->q('com_admintools'))->where($db->qn('type') . ' = ' . $db->q('component'));
     $db->setQuery($sql);
     $db->execute();
     // Even better, create the "admintools.lastversion.php" file with this information
     $fileData = "<" . "?php\ndefined('_JEXEC') or die;\ndefine('ADMINTOOLS_LASTVERSIONCHECK','" . $version . "');";
     JLoader::import('joomla.filesystem.file');
     $fileName = JPATH_COMPONENT_ADMINISTRATOR . '/admintools.lastversion.php';
     JFile::write($fileName, $fileData);
     $url = 'index.php?option=com_admintools&view=cpanel';
     // Reset the Joomla! plugins cache
     F0FUtilsCacheCleaner::clearPluginsCache();
     if (!$acceptlicense) {
         JFactory::getApplication()->enqueueMessage(JText::_('COM_ADMINTOOLS_POSTSETUP_ERR_ACCEPTLICENSE'), 'error');
         $url = 'index.php?option=com_admintools&view=postsetup';
     }
     if (!$acceptsupport) {
         JFactory::getApplication()->enqueueMessage(JText::_('COM_ADMINTOOLS_POSTSETUP_ERR_ACCEPTSUPPORT'), 'error');
         $url = 'index.php?option=com_admintools&view=postsetup';
     }
     JFactory::getApplication()->redirect($url);
 }
コード例 #10
0
ファイル: cpanel.php プロジェクト: neoandrew1000/crao_journal
 /**
  * Automatically migrates settings from the component's parameters storage
  * to our version 2.1+ dedicated storage table.
  */
 public function autoMigrate()
 {
     // First, load the component parameters
     // FIX 2.1.13: Load the component parameters WITHOUT using JComponentHelper
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select($db->qn('params'))->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->quote('component'))->where($db->qn('element') . ' = ' . $db->quote('com_admintools'));
     $db->setQuery($query);
     $rawparams = $db->loadResult();
     $cparams = new JRegistry();
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $cparams->loadString($rawparams, 'JSON');
     } else {
         $cparams->loadJSON($rawparams);
     }
     // Migrate parameters
     $allParams = $cparams->toArray();
     $safeList = array('downloadid', 'lastversion', 'minstability', 'scandiffs', 'scanemail', 'htmaker_folders_fix_at240', 'acceptlicense', 'acceptsupport', 'sitename', 'showstats', 'longconfigpage', 'autoupdateCli', 'notificationFreq', 'notificationTime', 'notificationEmail', 'usage');
     if (interface_exists('JModel')) {
         $params = JModelLegacy::getInstance('Storage', 'AdmintoolsModel');
     } else {
         $params = JModel::getInstance('Storage', 'AdmintoolsModel');
     }
     $modified = 0;
     foreach ($allParams as $k => $v) {
         if (in_array($k, $safeList)) {
             continue;
         }
         if ($v == '') {
             continue;
         }
         $modified++;
         if (version_compare(JVERSION, '3.0', 'ge')) {
             $cparams->set($k, null);
         } else {
             $cparams->setValue($k, null);
         }
         $params->setValue($k, $v);
     }
     if ($modified == 0) {
         return;
     }
     // Save new parameters
     $params->save();
     // Save component parameters
     $db = JFactory::getDBO();
     $data = $cparams->toString();
     $sql = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('params') . ' = ' . $db->q($data))->where($db->qn('element') . ' = ' . $db->q('com_admintools'))->where($db->qn('type') . ' = ' . $db->q('component'));
     $db->setQuery($sql);
     $db->execute();
 }
コード例 #11
0
ファイル: configuration.php プロジェクト: joebushi/joomla
 function _createConfiguration($options)
 {
     jimport('joomla.registry.registry');
     // Create a new registry to build the configuration options.
     $registry = new JRegistry();
     /* Site Settings */
     $registry->setValue('offline', 0);
     $registry->setValue('offline_message', JText::_('STDOFFLINEMSG'));
     $registry->setValue('sitename', $options->site_name);
     $registry->setValue('editor', 'tinymce');
     $registry->setValue('list_limit', 20);
     $registry->setValue('access', 1);
     /* Debug Settings */
     $registry->setValue('debug', 0);
     $registry->setValue('debug_lang', 0);
     $registry->setValue('debug_modules', 1);
     /* Database Settings */
     $registry->setValue('dbtype', $options->db_type);
     $registry->setValue('host', $options->db_host);
     $registry->setValue('user', $options->db_user);
     $registry->setValue('password', $options->db_pass);
     $registry->setValue('db', $options->db_name);
     $registry->setValue('dbprefix', $options->db_prefix);
     /* Server Settings */
     $registry->setValue('live_site', '');
     $registry->setValue('secret', JUserHelper::genRandomPassword(16));
     $registry->setValue('gzip', 0);
     $registry->setValue('error_reporting', -1);
     $registry->setValue('helpurl', 'http://help.joomla.org');
     $registry->setValue('xmlrpc_server', 0);
     $registry->setValue('ftp_host', $options->ftp_host);
     $registry->setValue('ftp_port', $options->ftp_port);
     $registry->setValue('ftp_user', $options->ftp_save ? $options->ftp_user : '');
     $registry->setValue('ftp_pass', $options->ftp_save ? $options->ftp_pass : '');
     $registry->setValue('ftp_root', $options->ftp_save ? $options->ftp_root : '');
     $registry->setValue('ftp_enable', $options->ftp_enable);
     /* Locale Settings */
     $registry->setValue('offset', 0);
     $registry->setValue('offset_user', 0);
     /* Mail Settings */
     $registry->setValue('mailer', 'mail');
     $registry->setValue('mailfrom', $options->admin_email);
     $registry->setValue('fromname', $options->site_name);
     $registry->setValue('sendmail', '/usr/sbin/sendmail');
     $registry->setValue('smtpauth', 0);
     $registry->setValue('smtpuser', '');
     $registry->setValue('smtppass', '');
     $registry->setValue('smtphost', 'localhost');
     $registry->setValue('smtpsecure', 'none');
     $registry->setValue('smtpport', '25');
     /* Cache Settings */
     $registry->setValue('caching', 0);
     $registry->setValue('cachetime', 15);
     $registry->setValue('cache_handler', 'file');
     /* Meta Settings */
     $registry->setValue('MetaDesc', JText::_('STDMETADESC'));
     $registry->setValue('MetaKeys', JText::_('STDMETAKEYS'));
     $registry->setValue('MetaTitle', 1);
     $registry->setValue('MetaAuthor', 1);
     /* SEO Settings */
     $registry->setValue('sef', 1);
     $registry->setValue('sef_rewrite', 0);
     $registry->setValue('sef_suffix', 1);
     $registry->setValue('unicodeslugs', 0);
     /* Feed Settings */
     $registry->setValue('feed_limit', 10);
     $registry->setValue('log_path', JPATH_ROOT . DS . 'logs');
     $registry->setValue('tmp_path', JPATH_ROOT . DS . 'tmp');
     /* Session Setting */
     $registry->setValue('lifetime', 15);
     $registry->setValue('session_handler', 'database');
     // Generate the configuration class string buffer.
     $buffer = $registry->toString('PHP', null, array('class' => 'JConfig'));
     // Build the configuration file path.
     $path = JPATH_CONFIGURATION . DS . 'configuration.php';
     // Determine if the configuration file path is writable.
     if (file_exists($path)) {
         $canWrite = is_writable($path);
     } else {
         $canWrite = is_writable(JPATH_CONFIGURATION . DS);
     }
     /*
      * If the file exists but isn't writable OR if the file doesn't exist and the parent directory
      * is not writable we need to use FTP
      */
     $useFTP = false;
     if (file_exists($path) && !is_writable($path) || !file_exists($path) && !is_writable(dirname($path) . '/')) {
         $useFTP = true;
     }
     // Check for safe mode
     if (ini_get('safe_mode')) {
         $useFTP = true;
     }
     // Enable/Disable override
     if (!isset($options->ftpEnable) || $options->ftpEnable != 1) {
         $useFTP = false;
     }
     if ($useFTP == true) {
         // Connect the FTP client
         jimport('joomla.client.ftp');
         jimport('joomla.filesystem.path');
         $ftp =& JFTP::getInstance($options->ftp_host, $options->ftp_port);
         $ftp->login($options->ftp_user, $options->ftp_pass);
         // Translate path for the FTP account
         $file = JPath::clean(str_replace(JPATH_CONFIGURATION, $options->ftp_root, $path), '/');
         // Use FTP write buffer to file
         if (!$ftp->write($file, $buffer)) {
             // Set the config string to the session.
             $session =& JFactory::getSession();
             $session->set('setup.config', $buffer);
         }
         $ftp->quit();
     } else {
         if ($canWrite) {
             file_put_contents($path, $buffer);
             $session =& JFactory::getSession();
             $session->set('setup.config', null);
         } else {
             // Set the config string to the session.
             $session =& JFactory::getSession();
             $session->set('setup.config', $buffer);
         }
     }
     return true;
 }
コード例 #12
0
 /**
  * Stores a Workflow to database
  *
  * @access	public
  * @param object $data Workflow Data to be saved 
  * @return int	ID of the newly saved workflow on success , 0 on failure
  */
 function save($data)
 {
     $user =& JFactory::getUser();
     $db =& JFactory::getDBO();
     $row =& JTable::getInstance('Workflow', 'Table');
     $nullDate = $db->getNullDate();
     if (!$row->bind($data)) {
         JError::raiseError(500, $db->stderr());
         return 0;
     }
     $row->id = intval($row->id);
     JArrayHelper::toInteger($data['category']);
     $row->category = implode(',', $data['category']);
     $newEntry = $row->id ? false : true;
     //Copied directly from com_content saveContent()
     // Are we saving from an item edit?
     if (!$newEntry) {
         $datenow =& JFactory::getDate();
         $row->modified = $datenow->toMySQL();
         $row->modified_by = $user->get('id');
     }
     $row->created_by = $row->created_by ? $row->created_by : $user->get('id');
     if ($row->created && strlen(trim($row->created)) <= 10) {
         $row->created .= ' 00:00:00';
     }
     $config =& JFactory::getConfig();
     $tzoffset = $config->getValue('config.offset');
     $date =& JFactory::getDate($row->created, $tzoffset);
     $row->created = $date->toMySQL();
     if (strlen(trim($row->publish_up)) == 0) {
         $date =& JFactory::getDate(1, $tzoffset);
     } else {
         $row->publish_up .= ' 00:00:00';
         $date =& JFactory::getDate($row->publish_up, $tzoffset);
     }
     $row->publish_up = $date->toMySQL();
     // Handle never unpublish date
     if (trim($row->publish_down) == JText::_('Never') || trim($row->publish_down) == '') {
         $row->publish_down = $nullDate;
     } else {
         if (strlen(trim($row->publish_down)) <= 10) {
             $row->publish_down .= ' 00:00:00';
         }
         $date =& JFactory::getDate($row->publish_down, $tzoffset);
         $row->publish_down = $date->toMySQL();
     }
     // Make sure the data is valid
     if (!$row->check()) {
         JError::raiseError(500, $db->stderr());
     }
     // Store the content to the database
     if (!$row->store()) {
         JError::raiseError(500, $db->stderr());
     }
     // Check the form
     $row->checkin();
     //End of faithful copy
     if ($newEntry) {
         $row->id = lastInsertId();
     }
     if (!$newEntry) {
         //Delete stations of this workflow
         $db->setQuery('DELETE FROM #__jwf_stations WHERE wid=' . $row->id);
         if (!$db->query()) {
             JError::raiseError(500, $db->getErrorMsg());
         }
     }
     $queriesNewId = array();
     $queriesOldId = array();
     foreach ($data['stations'] as $station) {
         $wid = intval($row->id);
         $title = $db->getEscaped($station->title, true);
         $task = $db->getEscaped($station->task, true);
         $allocatedTime = intval($station->allocatedTime);
         $group = intval($station->acl->id);
         $fields = $db->getEscaped($station->fields, true);
         $hooks = $station->activeHooks;
         $validations = $db->getEscaped($station->activeValidations, true);
         $order = intval($station->order);
         if ($station->id == null) {
             $queriesNewId[] = "({$wid}, '{$title}', '{$task}', {$allocatedTime}, {$group}, '{$fields}' , '{$hooks}', '{$validations}', {$order})";
         } else {
             $queriesOldId[] = "({$station->id}, {$wid}, '{$title}', '{$task}', {$allocatedTime}, {$group}, '{$fields}', '{$hooks}', '{$validations}', {$order})";
         }
     }
     if (count($queriesNewId)) {
         $sqlNewIds = implode(',', $queriesNewId);
         $sqlNewIds = 'INSERT INTO `#__jwf_stations` (`wid`,`title`,`task`,`allocatedTime`,`group`,`fields`, `activeHooks`, `activeValidations`,  `order`) VALUES ' . $sqlNewIds;
         $db->setQuery($sqlNewIds);
         if (!$db->query()) {
             JError::raiseError(500, $db->getErrorMsg());
         }
     }
     if (count($queriesOldId)) {
         $sqlOldIds = implode(',', $queriesOldId);
         $sqlOldIds = 'INSERT INTO `#__jwf_stations` (`id`,`wid`,`title`,`task`,`allocatedTime`,`group`,`fields`,`activeHooks`, `activeValidations`, `order`) VALUES ' . $sqlOldIds;
         $db->setQuery($sqlOldIds);
         if (!$db->query()) {
             JError::raiseError(500, $db->getErrorMsg());
         }
     }
     //Update trigger cache
     $pManager =& getPluginManager();
     $pManager->loadPlugins('component');
     $plugins = $pManager->settings['component'];
     $trigger = $plugins[$row->component]->trigger;
     $category = $row->category;
     $component = $row->component;
     $triggerDataPath = JWF_FS_PATH . DS . 'triggerCache.ini';
     $triggerCacheData = new JRegistry();
     $triggerCacheData->loadINI(file_get_contents($triggerDataPath));
     $triggerCacheData->setValue($row->id, $trigger . '-' . $component . '-' . $category);
     file_put_contents($triggerDataPath, $triggerCacheData->toString('INI'));
     return $row->id;
 }