コード例 #1
0
ファイル: requests.php プロジェクト: johngrange/wookeyholeweb
 /**
  * Public constructor of the Controller class
  *
  * @param   array  $config  Optional configuration parameters
  */
 public function __construct($config = array())
 {
     // No JInputJSON in J2.5
     $raw = file_get_contents('php://input');
     $data = json_decode($raw, true);
     if ($data && array_key_exists('ajax', $data) && $data['ajax'] === 1) {
         $input = new F0FInput();
         $param = array_merge($input->getData(), $data);
         $config['input'] = $param;
     }
     parent::__construct($config);
 }
コード例 #2
0
 /**
  * Save fields for many-to-many relations in their pivot tables.
  *
  * @param F0FTable $table Current item table.
  *
  * @return bool True if the object can be saved successfully, false elsewhere.
  * @throws Exception The error message get trying to save fields into the pivot tables.
  */
 public function onAfterStore(&$table)
 {
     // Retrieve the relations configured for this table
     $input = new F0FInput();
     $key = $table->getConfigProviderKey() . '.relations';
     $relations = $table->getConfigProvider()->get($key, array());
     // Abandon the process if not a save task
     if (!in_array($input->getWord('task'), array('apply', 'save', 'savenew'))) {
         return true;
     }
     // For each relation check relative field
     foreach ($relations as $relation) {
         // Only if it is a multiple relation, sure!
         if ($relation['type'] == 'multiple') {
             // Retrive the fully qualified relation data from F0FTableRelations object
             $relation = array_merge(array('itemName' => $relation['itemName']), $table->getRelations()->getRelation($relation['itemName'], $relation['type']));
             // Deduce the name of the field used in the form
             $field_name = F0FInflector::pluralize($relation['itemName']);
             // If field exists we catch its values!
             $field_values = $input->get($field_name, array(), 'array');
             // If the field exists, build the correct pivot couple objects
             $new_couples = array();
             foreach ($field_values as $value) {
                 $new_couples[] = array($relation['ourPivotKey'] => $table->getId(), $relation['theirPivotKey'] => $value);
             }
             // Find existent relations in the pivot table
             $query = $table->getDbo()->getQuery(true)->select($relation['ourPivotKey'] . ', ' . $relation['theirPivotKey'])->from($relation['pivotTable'])->where($relation['ourPivotKey'] . ' = ' . $table->getId());
             $existent_couples = $table->getDbo()->setQuery($query)->loadAssocList();
             // Find new couples and create its
             foreach ($new_couples as $couple) {
                 if (!in_array($couple, $existent_couples)) {
                     $query = $table->getDbo()->getQuery(true)->insert($relation['pivotTable'])->columns($relation['ourPivotKey'] . ', ' . $relation['theirPivotKey'])->values($couple[$relation['ourPivotKey']] . ', ' . $couple[$relation['theirPivotKey']]);
                     // Use database to create the new record
                     if (!$table->getDbo()->setQuery($query)->execute()) {
                         throw new Exception('Can\'t create the relation for the ' . $relation['pivotTable'] . ' table');
                     }
                 }
             }
             // Now find the couples no more present, that will be deleted
             foreach ($existent_couples as $couple) {
                 if (!in_array($couple, $new_couples)) {
                     $query = $table->getDbo()->getQuery(true)->delete($relation['pivotTable'])->where($relation['ourPivotKey'] . ' = ' . $couple[$relation['ourPivotKey']])->where($relation['theirPivotKey'] . ' = ' . $couple[$relation['theirPivotKey']]);
                     // Use database to create the new record
                     if (!$table->getDbo()->setQuery($query)->execute()) {
                         throw new Exception('Can\'t delete the relation for the ' . $relation['pivotTable'] . ' table');
                     }
                 }
             }
         }
     }
     return true;
 }
コード例 #3
0
ファイル: joomla3.php プロジェクト: ppantilla/bbninja
 /**
  * Echoes any HTML to show after the view template
  *
  * @param   string    $view    The current view
  * @param   string    $task    The current task
  * @param   F0FInput  $input   The input array (request parameters)
  * @param   array     $config  The view configuration array
  *
  * @return  void
  */
 public function postRender($view, $task, $input, $config = array())
 {
     $format = $input->getCmd('format', 'html');
     if (empty($format)) {
         $format = 'html';
     }
     if ($format != 'html') {
         return;
     }
     // Closing tag only if we're not in CLI
     if (F0FPlatform::getInstance()->isCli()) {
         return;
     }
     echo "</div>\n";
     // Closes akeeba-renderjoomla div
 }
コード例 #4
0
ファイル: toolbar.php プロジェクト: ppantilla/bbninja
 /**
  * Gets an instance of a component's toolbar
  *
  * @param   string  $option  The name of the component
  * @param   array   $config  The configuration array for the component
  *
  * @return  F0FToolbar  The toolbar instance for the component
  */
 public static function &getAnInstance($option = null, $config = array())
 {
     static $instances = array();
     // Make sure $config is an array
     if (is_object($config)) {
         $config = (array) $config;
     } elseif (!is_array($config)) {
         $config = array();
     }
     $hash = $option;
     if (!array_key_exists($hash, $instances)) {
         if (array_key_exists('input', $config)) {
             if ($config['input'] instanceof F0FInput) {
                 $input = $config['input'];
             } else {
                 $input = new F0FInput($config['input']);
             }
         } else {
             $input = new F0FInput();
         }
         $config['option'] = !is_null($option) ? $option : $input->getCmd('option', 'com_foobar');
         $input->set('option', $config['option']);
         $config['input'] = $input;
         $className = ucfirst(str_replace('com_', '', $config['option'])) . 'Toolbar';
         if (!class_exists($className)) {
             $componentPaths = F0FPlatform::getInstance()->getComponentBaseDirs($config['option']);
             $searchPaths = array($componentPaths['main'], $componentPaths['main'] . '/toolbars', $componentPaths['alt'], $componentPaths['alt'] . '/toolbars');
             if (array_key_exists('searchpath', $config)) {
                 array_unshift($searchPaths, $config['searchpath']);
             }
             $filesystem = F0FPlatform::getInstance()->getIntegrationObject('filesystem');
             $path = $filesystem->pathFind($searchPaths, 'toolbar.php');
             if ($path) {
                 require_once $path;
             }
         }
         if (!class_exists($className)) {
             $className = 'F0FToolbar';
         }
         $instance = new $className($config);
         $instances[$hash] = $instance;
     }
     return $instances[$hash];
 }
コード例 #5
0
 protected function getOptions()
 {
     $options = array();
     $this->value = array();
     // The selected values
     // Deduce table name from conventional names
     $input = new F0FInput();
     $component_prefix = ucfirst(str_replace('com_', '', $input->getString('option')));
     $view_prefix = ucfirst($input->getString('view'));
     // Deduce name of the relation
     $relation_name = @F0FInflector::pluralize($this->element['name']);
     // todo remove silence operator
     // Create a relation's model instance
     $relation_model = F0FModel::getTmpInstance(ucfirst($relation_name), $component_prefix . 'Model');
     // Get the name of key and title field
     $table = $relation_model->getTable();
     $key_field = $table->getKeyName();
     $value_field = $table->getColumnAlias('title');
     // List all items from the referred table
     foreach ($relation_model->getItemList(true) as $value) {
         $options[] = JHtmlSelect::option($value->{$key_field}, $value->{$value_field});
     }
     // Don't load selected values if item is new
     if ($id = $input->getInt('id')) {
         // Create an instance of the correct table and load this item
         $table = F0FTable::getInstance($view_prefix, $component_prefix . 'Table');
         // Load the instance of this item, based on ID query parameter
         $table->load($id);
         // Get the relation
         $relation = $table->getRelations()->getMultiple($relation_name);
         // Add existent relation as default selected values on list
         foreach ($relation as $item) {
             $this->value[] = $item->getId();
         }
     }
     return $options;
 }
コード例 #6
0
 /**
  * Modify the query to filter list objects by n:n relation.
  *
  * @param F0FModel       $model The model on which operate.
  * @param JDatabaseQuery $query The query to alter.
  */
 public function onAfterBuildQuery(&$model, &$query)
 {
     $input = new F0FInput();
     $db = $model->getDbo();
     // Retrieve the relations configuration for this table
     $table = $model->getTable();
     $key = $table->getConfigProviderKey() . '.relations';
     $relations = $table->getConfigProvider()->get($key, array());
     // For each multiple type relation add the filter query
     foreach ($relations as $relation) {
         if ($relation['type'] == 'multiple') {
             // Get complete relation fields
             $relation = array_merge(array('itemName' => $relation['itemName']), $table->getRelations()->getRelation($relation['itemName'], $relation['type']));
             // Model only save $table->getKnownFields as state, so we look into the input
             $filter_name = $relation['itemName'];
             $model_filter_value = $input->getInt($filter_name);
             // Build the conditions based on relation configuration
             if (!empty($model_filter_value)) {
                 $query->innerJoin(sprintf('%1$s ON %1$s.%2$s = %3$s.%4$s', $db->qn($relation['pivotTable']), $db->qn($relation['ourPivotKey']), $db->qn($table->getTableName()), $db->qn($relation['localKey'])));
                 $query->where(sprintf('%s.%s = %s', $db->qn($relation['pivotTable']), $db->qn($relation['theirPivotKey']), $model_filter_value));
             }
         }
     }
 }
コード例 #7
0
 /**
  * Imports an exported profile .json file
  */
 public function import()
 {
     $this->_csrfProtection();
     $user = JFactory::getUser();
     if (!$user->authorise('akeeba.configure', 'com_akeeba')) {
         return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     // Get the user
     $user = JFactory::getUser();
     // Get some data from the request
     $file = F0FInput::getVar('importfile', '', $_FILES, 'array');
     if (isset($file['name'])) {
         // Load the file data
         $data = JFile::read($file['tmp_name']);
         @unlink($file['tmp_name']);
         // JSON decode
         $data = json_decode($data, true);
         // Check for data validity
         $isValid = is_array($data) && !empty($data);
         if ($isValid) {
             $isValid = $isValid && array_key_exists('description', $data);
         }
         if ($isValid) {
             $isValid = $isValid && array_key_exists('configuration', $data);
         }
         if ($isValid) {
             $isValid = $isValid && array_key_exists('filters', $data);
         }
         if (!$isValid) {
             $this->setRedirect('index.php?option=com_akeeba&view=profiles', JText::_('COM_AKEEBA_PROFILES_ERR_IMPORT_INVALID'), 'error');
             return false;
         }
         // Unset the id, if it exists
         if (array_key_exists('id', $data)) {
             unset($data['id']);
         }
         // Try saving the profile
         $result = $this->getThisModel()->getTable()->save($data);
         if ($result) {
             $this->setRedirect('index.php?option=com_akeeba&view=profiles', JText::_('COM_AKEEBA_PROFILES_MSG_IMPORT_COMPLETE'));
         } else {
             $this->setRedirect('index.php?option=com_akeeba&view=profiles', JText::_('COM_AKEEBA_PROFILES_ERR_IMPORT_FAILED'), 'error');
         }
     } else {
         $this->setRedirect('index.php?option=com_akeeba&view=profiles', JText::_('MSG_UPLOAD_INVALID_REQUEST'), 'error');
         return false;
     }
 }
コード例 #8
0
ファイル: model.php プロジェクト: 01J/topm
 /**
  * Guesses the best candidate for the path to use for a particular form.
  *
  * @param   string  $source  The name of the form file to load, without the .xml extension.
  * @param   array   $paths   The paths to look into. You can declare this to override the default F0F paths.
  *
  * @return  mixed  A string if the path and filename of the form to load is found, false otherwise.
  *
  * @since   2.0
  */
 public function findFormFilename($source, $paths = array())
 {
     // TODO Should we read from internal variables instead of the input? With a temp instance we have no input
     $option = $this->input->getCmd('option', 'com_foobar');
     $view = $this->name;
     $componentPaths = F0FPlatform::getInstance()->getComponentBaseDirs($option);
     $file_root = $componentPaths['main'];
     $alt_file_root = $componentPaths['alt'];
     $template_root = F0FPlatform::getInstance()->getTemplateOverridePath($option);
     if (empty($paths)) {
         // Set up the paths to look into
         // PLEASE NOTE: If you ever change this, please update Model Unit tests, too, since we have to
         // copy these default folders (we have to add the protocol for the virtual filesystem)
         $paths = array($template_root . '/' . $view, $template_root . '/' . F0FInflector::singularize($view), $template_root . '/' . F0FInflector::pluralize($view), $file_root . '/views/' . $view . '/tmpl', $file_root . '/views/' . F0FInflector::singularize($view) . '/tmpl', $file_root . '/views/' . F0FInflector::pluralize($view) . '/tmpl', $alt_file_root . '/views/' . $view . '/tmpl', $alt_file_root . '/views/' . F0FInflector::singularize($view) . '/tmpl', $alt_file_root . '/views/' . F0FInflector::pluralize($view) . '/tmpl', $file_root . '/models/forms', $alt_file_root . '/models/forms');
     }
     $paths = array_unique($paths);
     // Set up the suffixes to look into
     $suffixes = array();
     $temp_suffixes = F0FPlatform::getInstance()->getTemplateSuffixes();
     if (!empty($temp_suffixes)) {
         foreach ($temp_suffixes as $suffix) {
             $suffixes[] = $suffix . '.xml';
         }
     }
     $suffixes[] = '.xml';
     // Look for all suffixes in all paths
     $result = false;
     $filesystem = F0FPlatform::getInstance()->getIntegrationObject('filesystem');
     foreach ($paths as $path) {
         foreach ($suffixes as $suffix) {
             $filename = $path . '/' . $source . $suffix;
             if ($filesystem->fileExists($filename)) {
                 $result = $filename;
                 break;
             }
         }
         if ($result) {
             break;
         }
     }
     return $result;
 }
コード例 #9
0
ファイル: scanner.php プロジェクト: knigherrant/decopatio
 public function saveConfiguration()
 {
     $rawInput = $this->getState('rawinput', array());
     $newFileExtension = trim(F0FInput::getVar('fileextensions', '', $rawInput));
     $newExcludeFolders = trim(F0FInput::getVar('exludefolders', '', $rawInput));
     $newExcludeFiles = trim(F0FInput::getVar('exludefiles', '', $rawInput));
     $newMinExecTime = trim(F0FInput::getInt('mintime', '', $rawInput));
     $newMaxExecTime = trim(F0FInput::getInt('maxtime', '', $rawInput));
     $newRuntimeBias = trim(F0FInput::getInt('runtimebias', '', $rawInput));
     $protectedKeys = $this->aeconfig->getProtectedKeys();
     $this->aeconfig->resetProtectedKeys();
     $this->aeconfig->set('akeeba.basic.file_extensions', join('|', $this->getTextInputAsArray($newFileExtension)));
     $this->aeconfig->set('akeeba.basic.exclude_folders', join('|', $this->getTextInputAsArray($newExcludeFolders, '/')));
     $this->aeconfig->set('akeeba.basic.exclude_files', join('|', $this->getTextInputAsArray($newExcludeFiles, '/')));
     $this->aeconfig->set('akeeba.tuning.min_exec_time', $newMinExecTime);
     $this->aeconfig->set('akeeba.tuning.max_exec_time', $newMaxExecTime);
     $this->aeconfig->set('akeeba.tuning.run_time_bias', $newRuntimeBias);
     \Akeeba\Engine\Platform::getInstance()->save_configuration();
     $this->aeconfig->setProtectedKeys($protectedKeys);
 }
コード例 #10
0
ファイル: platform.php プロジェクト: 01J/topm
 /**
  * This method will try retrieving a variable from the request (input) data.
  *
  * @param   string    $key           The user state key for the variable
  * @param   string    $request       The request variable name for the variable
  * @param   F0FInput  $input         The F0FInput object with the request (input) data
  * @param   mixed     $default       The default value. Default: null
  * @param   string    $type          The filter type for the variable data. Default: none (no filtering)
  * @param   boolean   $setUserState  Should I set the user state with the fetched value?
  *
  * @see F0FPlatformInterface::getUserStateFromRequest()
  *
  * @return  mixed  The value of the variable
  */
 public function getUserStateFromRequest($key, $request, $input, $default = null, $type = 'none', $setUserState = true)
 {
     return $input->get($request, $default, $type);
 }
コード例 #11
0
ファイル: eselect.php プロジェクト: johngrange/wookeyholeweb
 /**
  * published.
  *
  * @param   string  $selected  The key that is selected
  * @param   string  $name      The name for the field
  * @param   array   $attribs   Additional HTML attributes for the <select> tag
  * @param   string  $yes       Param
  * @param   string  $no        Param
  * @param   string  $idTag     Additional HTML attributes for the <select> tag
  *
  * @return  string  HTML
  */
 public static function published($selected = null, $name = 'enabled', $attribs = array(), $yes = 'JPUBLISHED', $no = 'JUNPUBLISHED', $idTag = null)
 {
     $platform = F0FPlatform::getInstance();
     $input = new F0FInput();
     $editstate = $platform->authorise('core.edit.state', $input->getCmd('option', 'com_foobar'));
     if ($editstate) {
         if ($selected === null) {
             $selected = 1;
         }
         return self::booleanList($selected, $name, $attribs, $yes, $no, $idTag);
     } else {
         if ($selected) {
             $value = 1;
             $tag = JText::_($yes);
         } else {
             $value = 0;
             $tag = JText::_($no);
         }
         $control = EHtml::readonlyText($tag, $name . '-readonly');
         $control .= '<input type="hidden" value="' . $value . '" name="' . $name . '" id="' . $idTag . '">';
         return $control;
     }
 }
コード例 #12
0
ファイル: platform.php プロジェクト: 01J/topm
 /**
  * This method will try retrieving a variable from the request (input) data.
  *
  * @param   string    $key           The user state key for the variable
  * @param   string    $request       The request variable name for the variable
  * @param   F0FInput  $input         The F0FInput object with the request (input) data
  * @param   mixed     $default       The default value. Default: null
  * @param   string    $type          The filter type for the variable data. Default: none (no filtering)
  * @param   boolean   $setUserState  Should I set the user state with the fetched value?
  *
  * @see F0FPlatformInterface::getUserStateFromRequest()
  *
  * @return  mixed  The value of the variable
  */
 public function getUserStateFromRequest($key, $request, $input, $default = null, $type = 'none', $setUserState = true)
 {
     list($isCLI, $isAdmin) = $this->isCliAdmin();
     if ($isCLI) {
         return $input->get($request, $default, $type);
     }
     $app = JFactory::getApplication();
     if (method_exists($app, 'getUserState')) {
         $old_state = $app->getUserState($key, $default);
     } else {
         $old_state = null;
     }
     $cur_state = !is_null($old_state) ? $old_state : $default;
     $new_state = $input->get($request, null, $type);
     // Save the new value only if it was set in this request
     if ($setUserState) {
         if ($new_state !== null) {
             $app->setUserState($key, $new_state);
         } else {
             $new_state = $cur_state;
         }
     } elseif (is_null($new_state)) {
         $new_state = $cur_state;
     }
     return $new_state;
 }
コード例 #13
0
ファイル: requests.php プロジェクト: johngrange/wookeyholeweb
 /**
  * buildQuery
  *
  * @param   bool  $overrideLimits  Param
  *
  * @return	F0FQuery
  */
 public function buildQuery($overrideLimits = false)
 {
     $db = $this->getDbo();
     $query = F0FQueryAbstract::getNew($db)->select('*')->from($db->quoteName('#__autotweet_requests'));
     $fltPublishup = $this->getState('publish_up', null, 'date');
     if ($fltPublishup) {
         $fltPublishup = $fltPublishup . '%';
         $query->where($db->qn('publish_up') . ' LIKE ' . $db->q($fltPublishup));
     }
     $fltUntilDate = $this->getState('until_date', null, 'date');
     if ($fltUntilDate) {
         $query->where($db->qn('publish_up') . ' <= ' . $db->q($fltUntilDate));
     }
     $input = new F0FInput();
     $start = $input->get('xtstart');
     if ($start) {
         $date = new JDate($start);
         $query->where($db->qn('publish_up') . ' >= ' . $db->q($date->toSql()));
     }
     $end = $input->get('xtend');
     if ($end) {
         $date = new JDate($end);
         $query->where($db->qn('publish_up') . ' <= ' . $db->q($date->toSql()));
     }
     $fltPlugin = $this->getState('plugin', null, 'string');
     if ($fltPlugin) {
         $query->where($db->qn('plugin') . ' = ' . $db->q($fltPlugin));
     }
     $fltRefId = $this->getState('ref_id', null, 'string');
     if ($fltRefId) {
         $query->where($db->qn('ref_id') . ' = ' . $db->q($fltRefId));
     }
     $fltRids = $this->getState('rids', null);
     if ($fltRids != '') {
         if (is_string($fltRids)) {
             $fltRids = TextUtil::listToArray($fltRids);
         }
         $list = array();
         foreach ($fltRids as $p) {
             $list[] = $db->q($p);
         }
         $fltRids = implode(',', $list);
         $query->where($db->qn('id') . ' IN (' . $fltRids . ')');
     }
     $fltTypeinfo = $this->getState('typeinfo', null, 'string');
     if ($fltTypeinfo) {
         $query->where($db->qn('typeinfo') . ' = ' . $db->q($fltTypeinfo));
     }
     $fltPublished = $this->getState('published', 0, 'int');
     $query->where($db->qn('published') . ' = ' . $db->q($fltPublished));
     $search = $this->getState('search', null);
     if ($search) {
         $search = '%' . $search . '%';
         $query->where('(' . $db->qn('id') . ' LIKE ' . $db->quote($search) . ' OR ' . $db->qn('ref_id') . ' LIKE ' . $db->quote($search) . ' OR ' . $db->qn('description') . ' LIKE ' . $db->quote($search) . ' OR ' . $db->qn('url') . ' LIKE ' . $db->quote($search) . ')');
     }
     AclPermsHelper::whereOwnership($query);
     $order = $this->getState('filter_order', 'publish_up', 'cmd');
     if (!in_array($order, array_keys($this->getTable()->getData()))) {
         $order = 'publish_up';
     }
     $dir = $this->getState('filter_order_Dir', 'ASC', 'cmd');
     $query->order($order . ' ' . $dir);
     return $query;
 }
コード例 #14
0
 /**
  * sampleJoocialIntegration
  *
  * @param   int  $productId  Param
  *
  * Example of how to save Joocial Advanced attributes
  * Copy-paste into your extension, and customize freely
  *
  * @return	void
  */
 private static function sampleJoocialIntegration($productId)
 {
     if (!defined('AUTOTWEET_API')) {
         include_once JPATH_ADMINISTRATOR . '/components/com_autotweet/api/autotweetapi.php';
     }
     // Joocial - Saving Advanced Attrs
     $input = new F0FInput();
     $autotweet_advanced = $input->get('autotweet_advanced_attrs', null, 'string');
     if ($autotweet_advanced) {
         $advanced_attrs = AdvancedattrsHelper::retrieveAdvancedAttrs($autotweet_advanced);
         if ($advanced_attrs) {
             AdvancedattrsHelper::saveAdvancedAttrs($advanced_attrs, $productId);
         }
     }
 }
コード例 #15
0
 /**
  * Gets a temporary instance of a Dispatcher
  *
  * @param   string  $option  The component name
  * @param   string  $view    The View name
  * @param   array   $config  Configuration data
  *
  * @return F0FDispatcher
  */
 public static function &getTmpInstance($option = null, $view = null, $config = array())
 {
     if (array_key_exists('input', $config)) {
         if ($config['input'] instanceof F0FInput) {
             $input = $config['input'];
         } else {
             if (!is_array($config['input'])) {
                 $config['input'] = (array) $config['input'];
             }
             $config['input'] = array_merge($_REQUEST, $config['input']);
             $input = new F0FInput($config['input']);
         }
     } else {
         $input = new F0FInput();
     }
     $config['option'] = !is_null($option) ? $option : $input->getCmd('option', 'com_foobar');
     $config['view'] = !is_null($view) ? $view : $input->getCmd('view', '');
     $input->set('option', $config['option']);
     $input->set('view', $config['view']);
     $config['input'] = $input;
     $className = ucfirst(str_replace('com_', '', $config['option'])) . 'Dispatcher';
     if (!class_exists($className)) {
         $componentPaths = F0FPlatform::getInstance()->getComponentBaseDirs($config['option']);
         $searchPaths = array($componentPaths['main'], $componentPaths['main'] . '/dispatchers', $componentPaths['admin'], $componentPaths['admin'] . '/dispatchers');
         if (array_key_exists('searchpath', $config)) {
             array_unshift($searchPaths, $config['searchpath']);
         }
         $filesystem = F0FPlatform::getInstance()->getIntegrationObject('filesystem');
         $path = $filesystem->pathFind($searchPaths, 'dispatcher.php');
         if ($path) {
             require_once $path;
         }
     }
     if (!class_exists($className)) {
         $className = 'F0FDispatcher';
     }
     $instance = new $className($config);
     return $instance;
 }
コード例 #16
0
// Old PHP version detected. EJECT! EJECT! EJECT!
if (!version_compare($version, '5.3.0', '>=')) {
    return JError::raise(E_ERROR, 500, 'PHP versions 4.x, 5.0, 5.1 and 5.2 are no longer supported by AutoTweetNG.', 'The version of PHP used on your site is obsolete and contains known security vulenrabilities.
			Moreover, it is missing features required by AutoTweetNG to work properly or at all.
			Please ask your host to upgrade your server to the latest PHP 5.3/5.4 stable release. Thank you!');
}
if (!defined('AUTOTWEET_API')) {
    include_once JPATH_ADMINISTRATOR . '/components/com_autotweet/api/autotweetapi.php';
}
$config = array();
$view = null;
// If we are processing Gplus, redirect to controller
$session = JFactory::getSession();
$channelId = $session->get('channelId');
if (!empty($channelId)) {
    $input = new F0FInput();
    $code = $input->getString('code');
    if (!empty($code)) {
        $view = 'gpluschannels';
        $config['input'] = array('task' => 'callback');
    }
}
// If we are processing Frontend Twitter Channel Auth, redirect to controller
$authstate = $session->get('twitter-authstate');
if ($authstate) {
    $session->set('twitter-authstate', 0);
    $view = 'userchannels';
    $config['input'] = array('task' => 'twCallback');
}
// If we are processing Frontend LinkedIn Channel Auth, redirect to controller
$authstate = $session->get('linkedin-authstate');
コード例 #17
0
ファイル: relation.php プロジェクト: esorone/efcpw
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  */
 protected function getOptions()
 {
     $options = array();
     $this->value = array();
     $value_field = $this->element['value_field'] ? (string) $this->element['value_field'] : 'title';
     $input = new F0FInput();
     $component = ucfirst(str_replace('com_', '', $input->getString('option')));
     $view = ucfirst($input->getString('view'));
     $relation = F0FInflector::pluralize((string) $this->element['name']);
     $model = F0FModel::getTmpInstance(ucfirst($relation), $component . 'Model');
     $table = $model->getTable();
     $key = $table->getKeyName();
     $value = $table->getColumnAlias($value_field);
     foreach ($model->getItemList(true) as $option) {
         $options[] = JHtml::_('select.option', $option->{$key}, $option->{$value});
     }
     if ($id = F0FModel::getAnInstance($view)->getId()) {
         $table = F0FTable::getInstance($view, $component . 'Table');
         $table->load($id);
         $relations = $table->getRelations()->getMultiple($relation);
         foreach ($relations as $item) {
             $this->value[] = $item->getId();
         }
     }
     return $options;
 }
コード例 #18
0
ファイル: render.php プロジェクト: johngrange/wookeyholeweb
 /**
  * Renders the toolbar buttons
  *
  * @param   string    $view    The active view name
  * @param   string    $task    The current task
  * @param   F0FInput  $input   The input object
  * @param   array     $config  Extra configuration variables for the toolbar
  *
  * @return  void
  */
 protected function renderButtons($view, $task, $input, $config = array())
 {
     if (F0FPlatform::getInstance()->isCli()) {
         return;
     }
     // Do not render buttons unless we are in the the frontend area and we are asked to do so
     $toolbar = F0FToolbar::getAnInstance($input->getCmd('option', 'com_foobar'), $config);
     $renderFrontendButtons = $toolbar->getRenderFrontendButtons();
     // Load main backend language, in order to display toolbar strings
     // (JTOOLBAR_BACK, JTOOLBAR_PUBLISH etc etc)
     F0FPlatform::getInstance()->loadTranslations('joomla');
     if (F0FPlatform::getInstance()->isBackend() || !$renderFrontendButtons) {
         return;
     }
     $bar = JToolBar::getInstance('toolbar');
     $items = $bar->getItems();
     $substitutions = array('icon-32-new' => 'xticon xticon-plus', 'icon-32-publish' => 'xticon xticon-check-sign', 'icon-32-unpublish' => 'xticon xticon-times-circle', 'icon-32-delete' => 'xticon xticon-times', 'icon-32-edit' => 'xticon xticon-edit', 'icon-32-copy' => 'xticon xticon-copy', 'icon-32-cancel' => 'xticon xticon-times-circle', 'icon-32-back' => 'xticon xticon-times-circle', 'icon-32-apply' => 'xticon xticon-save', 'icon-32-save' => 'xticon xticon-edit', 'icon-32-save-new' => 'xticon xticon-plus', 'icon-32-process' => 'xticon xticon-cog');
     $html = array();
     $actions = array();
     $html[] = '<div class="extly"><div id="F0FHeaderHolder" class="row-fluid"><div class="span12">';
     $html[] = '<div class="buttonsHolder btn-toolbar pull-right">';
     foreach ($items as $node) {
         $type = $node[0];
         $button = $bar->loadButtonType($type);
         if ($button !== false) {
             if (method_exists($button, 'fetchId')) {
                 $id = call_user_func_array(array(&$button, 'fetchId'), $node);
             } else {
                 $id = null;
             }
             $action = call_user_func_array(array(&$button, 'fetchButton'), $node);
             $action = str_replace('class="toolbar"', 'class="toolbar btn"', $action);
             $action = str_replace('<span ', '<i ', $action);
             $action = str_replace('</span>', '</i>', $action);
             $action = str_replace(array_keys($substitutions), array_values($substitutions), $action);
             $actions[] = $action;
         }
     }
     $html = array_merge($html, $actions);
     $html[] = '</div>';
     $html[] = '</div></div></div>';
     echo implode("\n", $html);
 }
コード例 #19
0
ファイル: joomla.php プロジェクト: kidaa30/lojinha
 /**
  * Renders the toolbar buttons
  *
  * @param   string    $view    The active view name
  * @param   string    $task    The current task
  * @param   F0FInput  $input   The input object
  * @param   array     $config  Extra configuration variables for the toolbar
  *
  * @return  void
  */
 protected function renderButtons($view, $task, $input, $config = array())
 {
     // On command line don't do anything
     if (F0FPlatform::getInstance()->isCli()) {
         return;
     }
     // Do not render buttons unless we are in the the frontend area and we are asked to do so
     $toolbar = F0FToolbar::getAnInstance($input->getCmd('option', 'com_foobar'), $config);
     $renderFrontendButtons = $toolbar->getRenderFrontendButtons();
     if (F0FPlatform::getInstance()->isBackend() || !$renderFrontendButtons) {
         return;
     }
     // Load main backend language, in order to display toolbar strings
     // (JTOOLBAR_BACK, JTOOLBAR_PUBLISH etc etc)
     F0FPlatform::getInstance()->loadTranslations('joomla');
     $title = JFactory::getApplication()->get('JComponentTitle');
     $bar = JToolBar::getInstance('toolbar');
     // Delete faux links, since if SEF is on, Joomla will follow the link instead of submitting the form
     $bar_content = str_replace('href="#"', '', $bar->render());
     echo '<div id="F0FHeaderHolder">', $bar_content, $title, '<div style="clear:both"></div>', '</div>';
 }
コード例 #20
0
 public function importData()
 {
     $db = $this->getDbo();
     $input = new F0FInput('files');
     $file = $input->get('importfile', null, 'file', 2);
     // Sanity checks
     if (!$file) {
         $this->setError(JText::_('COM_ADMINTOOLS_IMPORTEXPORT_NOFILE'));
         return false;
     }
     $data = file_get_contents($file['tmp_name']);
     if ($data === false) {
         $this->setError(JText::_('COM_ADMINTOOLS_IMPORTEXPORT_ERR_READING_FILE'));
         return false;
     }
     $data = json_decode($data, true);
     if (!$data) {
         $this->setError(JText::_('COM_ADMINTOOLS_IMPORTEXPORT_ERR_READING_FILE'));
         return false;
     }
     // Everything seems ok, let's start importing data
     $result = true;
     if (isset($data['wafconfig'])) {
         /** @var AdmintoolsModelWafconfig $config */
         $config = F0FModel::getTmpInstance('Wafconfig', 'AdmintoolsModel');
         $config->saveConfig($data['wafconfig']);
     }
     if (isset($data['ipblacklist'])) {
         try {
             $db->truncateTable('#__admintools_ipblock');
             $insert = $db->getQuery(true)->insert($db->qn('#__admintools_ipblock'))->columns(array($db->qn('ip'), $db->qn('description')));
             // I could have several records, let's create a single big query
             foreach ($data['ipblacklist'] as $row) {
                 $insert->values($db->q($row['ip']) . ', ' . $db->q($row['description']));
             }
             $db->setQuery($insert)->execute();
         } catch (Exception $e) {
             $this->setError(JText::_('COM_ADMINTOOLS_IMPORTEXPORT_ERR_BLACKLIST'));
             $result = false;
         }
     }
     if (isset($data['ipwhitelist'])) {
         try {
             $db->truncateTable('#__admintools_adminiplist');
             // I could have several records, let's create a single big query
             $insert = $db->getQuery(true)->insert($db->qn('#__admintools_adminiplist'))->columns(array($db->qn('ip'), $db->qn('description')));
             foreach ($data['ipwhitelist'] as $row) {
                 $insert->values($db->q($row['ip']) . ', ' . $db->q($row['description']));
             }
             $db->setQuery($insert)->execute();
         } catch (Exception $e) {
             $this->setError(JText::_('COM_ADMINTOOLS_IMPORTEXPORT_ERR_WHITELIST'));
             $result = false;
         }
     }
     if (isset($data['badwords'])) {
         try {
             $db->truncateTable('#__admintools_badwords');
             // I could have several records, let's create a single big query
             $insert = $db->getQuery(true)->insert($db->qn('#__admintools_badwords'))->columns(array($db->qn('word')));
             foreach ($data['badwords'] as $row) {
                 $insert->values($db->q($row['word']));
             }
             $db->setQuery($insert)->execute();
         } catch (Exception $e) {
             $this->setError(JText::_('COM_ADMINTOOLS_IMPORTEXPORT_ERR_BADWORDS'));
             $result = false;
         }
     }
     if (isset($data['emailtemplates'])) {
         try {
             $db->truncateTable('#__admintools_waftemplates');
         } catch (Exception $e) {
             $this->setError(JText::_('COM_ADMINTOOLS_IMPORTEXPORT_ERR_EMAILTEMPLATES'));
             $result = false;
         }
         $table = F0FModel::getTmpInstance('Waftemplate', 'AdmintoolsModel')->getTable();
         // Most likely I will only have 10-12 templates max, so I can use the table instead of directly writing inside the db
         foreach ($data['emailtemplates'] as $row) {
             $table->reset();
             $table->admintools_waftemplate_id = null;
             // Let's leave primary key handling to the database
             unset($row['admintools_waftemplate_id']);
             unset($row['created_by']);
             unset($row['created_on']);
             unset($row['modified_by']);
             unset($row['modified_on']);
             // Calling the save method will trigger all the checks
             if (!$table->save($row)) {
                 // There was an error, better stop here
                 $this->setError(JText::_('COM_ADMINTOOLS_IMPORTEXPORT_ERR_EMAILTEMPLATES'));
                 $result = false;
                 break;
             }
         }
     }
     return $result;
 }
コード例 #21
0
ファイル: ehtml.php プロジェクト: johngrange/wookeyholeweb
 /**
  * renderRouting
  *
  * @return  string  HTML
  */
 public static function renderRoutingTags()
 {
     $formToken = JFactory::getSession()->getFormToken();
     $input = new F0FInput();
     $Itemid = $input->getInt('Itemid', 0);
     $lang = EParameter::getLanguageSef();
     $output = array();
     if ($formToken) {
         $output[] = '<input type="hidden" id="XTtoken" name="' . $formToken . '" value="1" />';
     }
     if ($Itemid) {
         $output[] = '<input type="hidden" id="XTItemid" name="Itemid" value="' . $Itemid . '" />';
     }
     if ($lang) {
         $output[] = '<input type="hidden" id="XTlang" name="lang" value="' . $lang . '" />';
     }
     return implode("\n", $output);
 }
コード例 #22
0
ファイル: view.php プロジェクト: brenot/forumdesenvolvimento
 /**
  * Sets an entire array of search paths for templates or resources.
  *
  * @param   string  $type  The type of path to set, typically 'template'.
  * @param   mixed   $path  The new search path, or an array of search paths.  If null or false, resets to the current directory only.
  *
  * @return  void
  */
 protected function _setPath($type, $path)
 {
     // Clear out the prior search dirs
     $this->_path[$type] = array();
     // Actually add the user-specified directories
     $this->_addPath($type, $path);
     // Always add the fallback directories as last resort
     switch (strtolower($type)) {
         case 'template':
             // Set the alternative template search dir
             if (!F0FPlatform::getInstance()->isCli()) {
                 $fallback = F0FPlatform::getInstance()->getTemplateOverridePath($this->input->getCmd('option', '')) . '/' . $this->getName();
                 $this->_addPath('template', $fallback);
             }
             break;
     }
 }
コード例 #23
0
ファイル: twapp.php プロジェクト: johngrange/wookeyholeweb
 /**
  * Obtain a request token from Twitter
  *
  * @return string
  */
 public function getAccessToken()
 {
     $session = JFactory::getSession();
     // Set the request token and secret we have stored
     $user_token = $session->get('authtoken');
     $user_secret = $session->get('authsecret');
     $this->access_token = $user_token;
     $this->token_secret = $user_secret;
     $this->login();
     $input = new F0FInput();
     $oauth_verifier = $input->get('oauth_verifier');
     // Send request for an access token
     $this->_twitter->request('POST', $this->_twitter->url('oauth/access_token', ''), array('oauth_verifier' => $oauth_verifier));
     if ($this->_twitter->response['code'] == 200) {
         // Get the access token and store it in a cookie
         $response = $this->_twitter->extract_params($this->_twitter->response['response']);
         $access_token = $response['oauth_token'];
         $access_token_secret = $response['oauth_token_secret'];
         return array('access_token' => $access_token, 'access_token_secret' => $access_token_secret);
     }
     return false;
 }
コード例 #24
0
ファイル: table.php プロジェクト: lyrasoft/lyrasoft.github.io
 /**
  * Get the content type for ucm
  *
  * @return string The content type alias
  */
 public function getContentType()
 {
     if ($this->contentType) {
         return $this->contentType;
     }
     /**
      * When tags was first introduced contentType variable didn't exist - so we guess one
      * This will fail if content history behvaiour is enabled. This code is deprecated
      * and will be removed in F0F 3.0 in favour of the content type class variable
      */
     $component = $this->input->get('option');
     $view = F0FInflector::singularize($this->input->get('view'));
     $alias = $component . '.' . $view;
     return $alias;
 }
コード例 #25
0
ファイル: select.php プロジェクト: johngrange/wookeyholeweb
 /**
  * Method to create a clickable icon to change the state of an item
  *
  * @param   mixed    $value     Either the scalar value or an object (for backward compatibility, deprecated)
  * @param   integer  $i         The index
  * @param   bool     $withLink  Param
  *
  * @return  string
  */
 public static function processedWithIcons($value, $i, $withLink = null)
 {
     if (is_object($value)) {
         $value = $value->published;
     }
     $img = $value ? self::REQ_ICON_YES : self::REQ_ICON_NO;
     if ($withLink === null) {
         $platform = F0FPlatform::getInstance();
         $input = new F0FInput();
         $withLink = $platform->authorise('core.edit.state', $input->getCmd('option', 'com_foobar'));
     }
     if (!$withLink) {
         return $img;
     }
     $task = $value ? 'unpublish' : 'publish';
     $alt = $value ? JText::_('JPUBLISHED') : JText::_('JUNPUBLISHED');
     $action = $value ? JText::_('JLIB_HTML_UNPUBLISH_ITEM') : JText::_('JLIB_HTML_PUBLISH_ITEM');
     $href = '<a href="#" onclick="return listItemTask(\'cb' . $i . '\',\'' . $task . '\')" title="' . $action . '">' . $img . '</a>';
     return $href;
 }
コード例 #26
0
ファイル: input.php プロジェクト: brenot/forumdesenvolvimento
 /**
  * Old static methods are now deprecated. This magic method makes sure there
  * is a continuity in our approach. The downside is that it's only compatible
  * with PHP 5.3.0. Sorry!
  *
  * @param   string  $name       Name of the method we're calling
  * @param   array   $arguments  The arguments passed to the method
  *
  * @return  mixed
  */
 public static function __callStatic($name, $arguments)
 {
     F0FPlatform::getInstance()->logDeprecated('F0FInput: static getXXX() methods are deprecated. Use the input object\'s methods instead.');
     if (substr($name, 0, 3) == 'get') {
         // Initialise arguments
         $key = array_shift($arguments);
         $default = array_shift($arguments);
         $input = array_shift($arguments);
         $type = 'none';
         $mask = 0;
         $type = strtolower(substr($name, 3));
         if ($type == 'var') {
             $type = array_shift($arguments);
             $mask = array_shift($arguments);
         }
         if (is_null($type)) {
             $type = 'none';
         }
         if (is_null($mask)) {
             $mask = 0;
         }
         if (!$input instanceof F0FInput && !$input instanceof JInput) {
             $input = new F0FInput($input);
         }
         return $input->get($key, $default, $type, $mask);
     }
     return false;
 }
コード例 #27
0
ファイル: strapper.php プロジェクト: chaudhary4k4/modernstore
 /**
  * Renders a raw fieldset of a F0FForm and returns the corresponding HTML
  *
  * @param   stdClass  &$fieldset   The fieldset to render
  * @param   F0FForm   &$form       The form to render
  * @param   F0FModel  $model       The model providing our data
  * @param   F0FInput  $input       The input object
  * @param   string    $formType    The form type e.g. 'edit' or 'read'
  * @param   boolean   $showHeader  Should I render the fieldset's header?
  *
  * @return  string    The HTML rendering of the fieldset
  */
 protected function renderFieldset(stdClass &$fieldset, F0FForm &$form, F0FModel $model, F0FInput $input, $formType, $showHeader = true)
 {
     $html = '';
     $fields = $form->getFieldset($fieldset->name);
     if (isset($fieldset->class)) {
         $class = 'class="' . $fieldset->class . '"';
     } else {
         $class = '';
     }
     $html .= "\t" . '<div id="' . $fieldset->name . '" ' . $class . '>' . PHP_EOL;
     $isTabbedFieldset = $this->isTabFieldset($fieldset);
     if (isset($fieldset->label) && !empty($fieldset->label) && !$isTabbedFieldset) {
         $html .= "\t\t" . '<h3>' . JText::_($fieldset->label) . '</h3>' . PHP_EOL;
     }
     foreach ($fields as $field) {
         $groupClass = $form->getFieldAttribute($field->fieldname, 'groupclass', '', $field->group);
         // Auto-generate label and description if needed
         // Field label
         $title = $form->getFieldAttribute($field->fieldname, 'label', '', $field->group);
         $emptylabel = $form->getFieldAttribute($field->fieldname, 'emptylabel', false, $field->group);
         if (empty($title) && !$emptylabel) {
             $model->getName();
             $title = strtoupper($input->get('option') . '_' . $model->getName() . '_' . $field->id . '_LABEL');
         }
         // Field description
         $description = $form->getFieldAttribute($field->fieldname, 'description', '', $field->group);
         /**
          * The following code is backwards incompatible. Most forms don't require a description in their form
          * fields. Having to use emptydescription="1" on each one of them is an overkill. Removed.
          */
         /*
         $emptydescription   = $form->getFieldAttribute($field->fieldname, 'emptydescription', false, $field->group);
         if (empty($description) && !$emptydescription)
         {
         	$description = strtoupper($input->get('option') . '_' . $model->getName() . '_' . $field->id . '_DESC');
         }
         */
         if ($formType == 'read') {
             $inputField = $field->static;
         } elseif ($formType == 'edit') {
             $inputField = $field->input;
         }
         if (empty($title)) {
             $html .= "\t\t\t" . $inputField . PHP_EOL;
             if (!empty($description) && $formType == 'edit') {
                 $html .= "\t\t\t\t" . '<span class="help-block">';
                 $html .= JText::_($description) . '</span>' . PHP_EOL;
             }
         } else {
             $html .= "\t\t\t" . '<div class="control-group ' . $groupClass . '">' . PHP_EOL;
             $html .= $this->renderFieldsetLabel($field, $form, $title);
             $html .= "\t\t\t\t" . '<div class="controls">' . PHP_EOL;
             $html .= "\t\t\t\t\t" . $inputField . PHP_EOL;
             if (!empty($description)) {
                 $html .= "\t\t\t\t" . '<span class="help-block">';
                 $html .= JText::_($description) . '</span>' . PHP_EOL;
             }
             $html .= "\t\t\t\t" . '</div>' . PHP_EOL;
             $html .= "\t\t\t" . '</div>' . PHP_EOL;
         }
     }
     $html .= "\t" . '</div>' . PHP_EOL;
     return $html;
 }
コード例 #28
0
 /**
  * Autoload Views
  *
  * @param   string  $class_name  The name of the class to load
  *
  * @return  void
  */
 public function autoload_fof_view($class_name)
 {
     F0FPlatform::getInstance()->logDebug(__METHOD__ . "() autoloading {$class_name}");
     static $isCli = null, $isAdmin = null;
     if (is_null($isCli) && is_null($isAdmin)) {
         list($isCli, $isAdmin) = F0FDispatcher::isCliAdmin();
     }
     if (strpos($class_name, 'View') === false) {
         return;
     }
     // Change from camel cased into a lowercase array
     $class_modified = preg_replace('/(\\s)+/', '_', $class_name);
     $class_modified = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $class_modified));
     $parts = explode('_', $class_modified);
     // We need at least three parts in the name
     if (count($parts) < 3) {
         return;
     }
     // We need the second part to be "view"
     if ($parts[1] != 'view') {
         return;
     }
     // Get the information about this class
     $component_raw = $parts[0];
     $component = 'com_' . $parts[0];
     $view = $parts[2];
     if (count($parts) > 3) {
         $format = $parts[3];
     } else {
         $input = new F0FInput();
         $format = $input->getCmd('format', 'html', 'cmd');
     }
     // Is this an F0F 2.1 or later component?
     if (!$this->isF0FComponent($component)) {
         return;
     }
     // Get the alternate view and class name (opposite singular/plural name)
     $alt_view = F0FInflector::isSingular($view) ? F0FInflector::pluralize($view) : F0FInflector::singularize($view);
     $alt_class = F0FInflector::camelize($component_raw . '_view_' . $alt_view);
     // Get the proper and alternate paths and file names
     $componentPaths = F0FPlatform::getInstance()->getComponentBaseDirs($component);
     $protoFile = "/models/{$view}";
     $protoAltFile = "/models/{$alt_view}";
     $path = $componentPaths['main'];
     $altPath = $componentPaths['alt'];
     $formats = array($format);
     if ($format != 'html') {
         $formats[] = 'raw';
     }
     foreach ($formats as $currentFormat) {
         $file = $protoFile . '.' . $currentFormat . '.php';
         $altFile = $protoAltFile . '.' . $currentFormat . '.php';
         // Try to find the proper class in the proper path
         if (!class_exists($class_name) && file_exists($path . $file)) {
             @(include_once $path . $file);
         }
         // Try to find the proper class in the alternate path
         if (!class_exists($class_name) && file_exists($altPath . $file)) {
             @(include_once $altPath . $file);
         }
         // Try to find the alternate class in the proper path
         if (!class_exists($alt_class) && file_exists($path . $altFile)) {
             @(include_once $path . $altFile);
         }
         // Try to find the alternate class in the alternate path
         if (!class_exists($alt_class) && file_exists($altPath . $altFile)) {
             @(include_once $altPath . $altFile);
         }
     }
     // If the alternate class exists just map the class to the alternate
     if (!class_exists($class_name) && class_exists($alt_class)) {
         $this->class_alias($alt_class, $class_name);
     } elseif (!class_exists($class_name)) {
         if ($view != 'default') {
             $defaultClass = F0FInflector::camelize($component_raw . '_view_default');
             $this->class_alias($defaultClass, $class_name);
         } else {
             if (!file_exists(self::$fofPath . '/view/' . $format . '.php')) {
                 $default_class = 'F0FView';
             } else {
                 $default_class = 'F0FView' . ucfirst($format);
             }
             $this->class_alias($default_class, $class_name, true);
         }
     }
 }
コード例 #29
0
 /**
  * Applies CSRF protection by means of a standard Joomla! token (nonce) check.
  * Raises a 403 Access Forbidden error through the platform if the check fails.
  *
  * TODO Move this check inside the platform
  *
  * @return  boolean  True if the CSRF check is successful
  *
  * @throws Exception
  */
 protected function _csrfProtection()
 {
     static $isCli = null, $isAdmin = null;
     if (is_null($isCli)) {
         $isCli = F0FPlatform::getInstance()->isCli();
         $isAdmin = F0FPlatform::getInstance()->isBackend();
     }
     switch ($this->csrfProtection) {
         // Never
         case 0:
             return true;
             break;
             // Always
         // Always
         case 1:
             break;
             // Only back-end and HTML format
         // Only back-end and HTML format
         case 2:
             if ($isCli) {
                 return true;
             } elseif (!$isAdmin && $this->input->get('format', 'html', 'cmd') != 'html') {
                 return true;
             }
             break;
             // Only back-end
         // Only back-end
         case 3:
             if (!$isAdmin) {
                 return true;
             }
             break;
     }
     $hasToken = false;
     $session = JFactory::getSession();
     // Joomla! 1.5/1.6/1.7/2.5 (classic Joomla! API) method
     if (method_exists('JUtility', 'getToken')) {
         $token = JUtility::getToken();
         $hasToken = $this->input->get($token, false, 'none') == 1;
         if (!$hasToken) {
             $hasToken = $this->input->get('_token', null, 'none') == $token;
         }
     }
     // Joomla! 2.5+ (Platform 12.1+) method
     if (!$hasToken) {
         if (method_exists($session, 'getToken')) {
             $token = $session->getToken();
             $hasToken = $this->input->get($token, false, 'none') == 1;
             if (!$hasToken) {
                 $hasToken = $this->input->get('_token', null, 'none') == $token;
             }
         }
     }
     // Joomla! 2.5+ formToken method
     if (!$hasToken) {
         if (method_exists($session, 'getFormToken')) {
             $token = $session->getFormToken();
             $hasToken = $this->input->get($token, false, 'none') == 1;
             if (!$hasToken) {
                 $hasToken = $this->input->get('_token', null, 'none') == $token;
             }
         }
     }
     if (!$hasToken) {
         F0FPlatform::getInstance()->raiseError(403, JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
         return false;
     }
 }
コード例 #30
0
 /**
  * isEnabledAttrComps
  *
  * @return bool
  */
 public static function isEnabledAttrComps()
 {
     $input = new F0FInput();
     $option = $input->get('option');
     $controller = $input->get('controller', '-');
     $view = $input->get('view', '-');
     $layout = $input->get('layout', '-');
     $task = $input->get('task', '-');
     if (array_key_exists($option, self::$enabledAttrComps) && array_key_exists($controller, self::$enabledAttrComps[$option]) && array_key_exists($view, self::$enabledAttrComps[$option][$controller]) && array_key_exists($layout, self::$enabledAttrComps[$option][$controller][$view]) && array_key_exists($task, self::$enabledAttrComps[$option][$controller][$view][$layout])) {
         return self::$enabledAttrComps[$option][$controller][$view][$layout][$task];
     }
     return false;
 }