0byt3m1n1-V2
Path:
/
home
/
a
/
c
/
a
/
academiac
/
www
/
[
Home
]
File: controller.php.tar
home/academiac/www/components/com_media/controller.php 0000644 00000003377 15137154533 0017226 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_media * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Media Manager Component Controller * * @package Joomla.Site * @subpackage com_media * @version 1.5 */ class MediaController extends JControllerLegacy { /** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { JPluginHelper::importPlugin('content'); $vName = JRequest::getCmd('view', 'images'); switch ($vName) { case 'imagesList': $mName = 'list'; $vLayout = JRequest::getCmd('layout', 'default'); break; case 'images': default: $vLayout = JRequest::getCmd('layout', 'default'); $mName = 'manager'; $vName = 'images'; break; } $document = JFactory::getDocument(); $vType = $document->getType(); // Get/Create the view $view = $this->getView($vName, $vType); $view->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR.'/views/'.strtolower($vName).'/tmpl'); // Get/Create the model if ($model = $this->getModel($mName)) { // Push the model into the view (as default) $view->setModel($model, true); } // Set the layout $view->setLayout($vLayout); // Display the view $view->display(); return $this; } function ftpValidate() { // Set FTP credentials, if given JClientHelper::setCredentialsFromRequest('ftp'); } } home/academiac/www/administrator/components/com_templates/controller.php 0000644 00000003213 15137206754 0023015 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Templates manager master display controller. * * @package Joomla.Administrator * @subpackage com_templates * @since 1.6 */ class TemplatesController extends JControllerLegacy { /** * @var string The default view. * @since 1.6 */ protected $default_view = 'styles'; /** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { // Load the submenu. TemplatesHelper::addSubmenu(JRequest::getCmd('view', 'styles')); $view = JRequest::getCmd('view', 'styles'); $layout = JRequest::getCmd('layout', 'default'); $id = JRequest::getInt('id'); // Check for edit form. if ($view == 'style' && $layout == 'edit' && !$this->checkEditId('com_templates.edit.style', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_templates&view=styles', false)); return false; } parent::display(); } /** * Preview Template */ function preview() { JRequest::setVar('view', 'prevuuw'); parent::display(); } } home/academiac/www/administrator/components/com_contact/controller.php 0000644 00000003071 15137206762 0022453 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Component Controller * * @package Joomla.Administrator * @subpackage com_contact */ class ContactController extends JControllerLegacy { /** * @var string The default view. * @since 1.6 */ protected $default_view = 'contacts'; /** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT.'/helpers/contact.php'; // Load the submenu. ContactHelper::addSubmenu(JRequest::getCmd('view', 'contacts')); $view = JRequest::getCmd('view', 'contacts'); $layout = JRequest::getCmd('layout', 'default'); $id = JRequest::getInt('id'); // Check for edit form. if ($view == 'contact' && $layout == 'edit' && !$this->checkEditId('com_contact.edit.contact', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_contact&view=contacts', false)); return false; } parent::display(); return $this; } } home/academiac/www/administrator/components/com_content/controller.php 0000644 00000003004 15137206766 0022472 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Component Controller * * @package Joomla.Administrator * @subpackage com_content */ class ContentController extends JControllerLegacy { /** * @var string The default view. * @since 1.6 */ protected $default_view = 'articles'; /** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { // Load the submenu. ContentHelper::addSubmenu(JRequest::getCmd('view', 'articles')); $view = JRequest::getCmd('view', 'articles'); $layout = JRequest::getCmd('layout', 'articles'); $id = JRequest::getInt('id'); // Check for edit form. if ($view == 'article' && $layout == 'edit' && !$this->checkEditId('com_content.edit.article', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_content&view=articles', false)); return false; } parent::display(); return $this; } } home/academiac/www/administrator/components/com_newsfeeds/controller.php 0000644 00000002766 15137207531 0023010 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Newsfeeds master display controller. * * @package Joomla.Administrator * @subpackage com_newsfeeds * @since 1.6 */ class NewsfeedsController extends JControllerLegacy { /** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT.'/helpers/newsfeeds.php'; // Load the submenu. NewsfeedsHelper::addSubmenu(JRequest::getCmd('view', 'newsfeeds')); $view = JRequest::getCmd('view', 'newsfeeds'); $layout = JRequest::getCmd('layout', 'default'); $id = JRequest::getInt('id'); // Check for edit form. if ($view == 'newsfeed' && $layout == 'edit' && !$this->checkEditId('com_newsfeeds.edit.newsfeed', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_newsfeeds&view=newsfeeds', false)); return false; } parent::display(); } } home/academiac/www/administrator/components/com_installer/controller.php 0000644 00000003212 15137207606 0023010 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_installer * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License, see LICENSE.php */ defined('_JEXEC') or die; /** * Installer Controller * * @package Joomla.Administrator * @subpackage com_installer * @since 1.5 */ class InstallerController extends JControllerLegacy { /** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT.'/helpers/installer.php'; // Get the document object. $document = JFactory::getDocument(); // Set the default view name and format from the Request. $vName = JRequest::getCmd('view', 'install'); $vFormat = $document->getType(); $lName = JRequest::getCmd('layout', 'default'); // Get and render the view. if ($view = $this->getView($vName, $vFormat)) { $ftp = JClientHelper::setCredentialsFromRequest('ftp'); $view->assignRef('ftp', $ftp); // Get the model for the view. $model = $this->getModel($vName); // Push the model into the view (as default). $view->setModel($model, true); $view->setLayout($lName); // Push document object into the view. $view->assignRef('document', $document); // Load the submenu. InstallerHelper::addSubmenu($vName); $view->display(); } return $this; } } home/academiac/www/administrator/components/com_joomlaupdate/controller.php 0000644 00000003255 15137213060 0023475 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_joomlaupdate * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License, see LICENSE.php */ defined('_JEXEC') or die; /** * Joomla! Update Controller * * @package Joomla.Administrator * @subpackage com_joomlaupdate * @since 2.5.4 */ class JoomlaupdateController extends JControllerLegacy { /** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 2.5.4 */ public function display($cachable = false, $urlparams = false) { // Get the document object. $document = JFactory::getDocument(); // Set the default view name and format from the Request. $vName = JRequest::getCmd('view', 'default'); $vFormat = $document->getType(); $lName = JRequest::getCmd('layout', 'default'); // Get and render the view. if ($view = $this->getView($vName, $vFormat)) { $ftp = JClientHelper::setCredentialsFromRequest('ftp'); $view->assignRef('ftp', $ftp); // Get the model for the view. $model = $this->getModel($vName); // Perform update source preference check and refresh update information $model->applyUpdateSite(); $model->refreshUpdates(); // Push the model into the view (as default). $view->setModel($model, true); $view->setLayout($lName); // Push document object into the view. $view->assignRef('document', $document); $view->display(); } return $this; } } home/academiac/www/administrator/components/com_virtuemart_allinone/classes/controller.php 0000604 00000015434 15137224640 0026535 0 ustar 00 <?php /** * @package LiveUpdate * @copyright Copyright ©2011 Nicholas K. Dionysopoulos / AkeebaBackup.com * @license GNU LGPLv3 or later <http://www.gnu.org/copyleft/lesser.html> */ defined('_JEXEC') or die(); jimport('joomla.application.component.controller'); /** * The Live Update MVC controller */ class LiveUpdateController extends JController { private $jversion = '15'; /** * Object contructor * @param array $config * * @return LiveUpdateController */ public function __construct($config = array()) { parent::__construct(); // Do we have Joomla! 1.6? if( version_compare( JVERSION, '1.6.0', 'ge' ) ) { $this->jversion = '16'; } $basePath = dirname(__FILE__); if($this->jversion == '15') { $this->_basePath = $basePath; } else { $this->basePath = $basePath; } $this->registerDefaultTask('overview'); } /** * Runs the overview page task */ public function overview() { $this->display(); } /** * Starts the update procedure. If the FTP credentials are required, it asks for them. */ public function startupdate() { $ftp = $this->setCredentialsFromRequest('ftp'); if($ftp === true) { // The user needs to supply the FTP credentials $this->display(); } else { // No FTP credentials required; proceed with the download $this->setRedirect('index.php?option='.JRequest::getCmd('option','').'&view='.JRequest::getCmd('view','liveupdate').'&task=download'); $this->redirect(); } } /** * Download the update package */ public function download() { $ftp = $this->setCredentialsFromRequest('ftp'); $model = $this->getThisModel(); $result = $model->download(); if(!$result) { // Download failed $msg = JText::_('LIVEUPDATE_DOWNLOAD_FAILED'); $this->setRedirect('index.php?option='.JRequest::getCmd('option','').'&view='.JRequest::getCmd('view','liveupdate').'&task=overview', $msg, 'error'); } else { // Download successful. Let's extract the package. $url = 'index.php?option='.JRequest::getCmd('option','').'&view='.JRequest::getCmd('view','liveupdate').'&task=extract'; $user = JRequest::getString('username', null, 'GET', JREQUEST_ALLOWRAW); $pass = JRequest::getString('password', null, 'GET', JREQUEST_ALLOWRAW); if($user) { $url .= '&username='.urlencode($user).'&password='.urlencode($pass); } $this->setRedirect($url); } $this->redirect(); } public function extract() { $ftp = $this->setCredentialsFromRequest('ftp'); $model = $this->getThisModel(); $result = $model->extract(); if(!$result) { // Download failed $msg = JText::_('LIVEUPDATE_EXTRACT_FAILED'); $this->setRedirect('index.php?option='.JRequest::getCmd('option','').'&view='.JRequest::getCmd('view','liveupdate').'&task=overview', $msg, 'error'); } else { // Extract successful. Let's install the package. $url = 'index.php?option='.JRequest::getCmd('option','').'&view='.JRequest::getCmd('view','liveupdate').'&task=install'; $user = JRequest::getString('username', null, 'GET', JREQUEST_ALLOWRAW); $pass = JRequest::getString('password', null, 'GET', JREQUEST_ALLOWRAW); if($user) { $url .= '&username='.urlencode($user).'&password='.urlencode($pass); } // Do we have SRP installed yet? $app = JFactory::getApplication(); $jResponse = $app->triggerEvent('onSRPEnabled'); $status = false; if(!empty($jResponse)) { $status = false; foreach($jResponse as $response) { $status = $status || $response; } } // SRP enabled, use it if($status) { $return = $url; $url = $model->getSRPURL($return); if(!$url) { $url = $return; } } $this->setRedirect($url); } $this->redirect(); } public function install() { $ftp = $this->setCredentialsFromRequest('ftp'); $model = $this->getThisModel(); $result = $model->install(); if(!$result) { // Installation failed $model->cleanup(); $this->setRedirect('index.php?option='.JRequest::getCmd('option','').'&view='.JRequest::getCmd('view','liveupdate').'&task=overview'); $this->redirect(); } else { // Installation successful. Show the installation message. if(version_compare(JVERSION,'1.6.0','ge')) { $cache = JFactory::getCache('mod_menu'); $cache->clean(); } $this->display(); } } public function cleanup() { // Perform the cleanup $ftp = $this->setCredentialsFromRequest('ftp'); $model = $this->getThisModel(); $model->cleanup(); // Force reload update information $dummy = LiveUpdate::getUpdateInformation(true); die('OK'); } /** * Displays the current view * @param bool $cachable Ignored! */ public final function display($cachable = false) { $viewLayout = JRequest::getCmd( 'layout', 'default' ); $view = $this->getThisView(); // Get/Create the model $model = $this->getThisModel(); $view->setModel($model, true); // Assign the FTP credentials from the request, or return TRUE if they are required jimport('joomla.client.helper'); $ftp = $this->setCredentialsFromRequest('ftp'); $view->assignRef('ftp', $ftp); // Set the layout $view->setLayout($viewLayout); // Display the view $view->display(); } public final function getThisView() { static $view = null; if(is_null($view)) { $basePath = ($this->jversion == '15') ? $this->_basePath : $this->basePath; $tPath = dirname(__FILE__).'/tmpl'; require_once('view.php'); $view = new LiveUpdateView(array('base_path'=>$basePath, 'template_path'=>$tPath)); } return $view; } public final function getThisModel() { static $model = null; if(is_null($model)) { require_once('model.php'); $model = new LiveUpdateModel(); $task = ($this->jversion == '15') ? $this->_task : $this->task; $model->setState( 'task', $task ); $app = JFactory::getApplication(); $menu = $app->getMenu(); if (is_object( $menu )) { if ($item = $menu->getActive()) { $params =& $menu->getParams($item->id); // Set Default State Data $model->setState( 'parameters.menu', $params ); } } } return $model; } private function setCredentialsFromRequest($client) { // Determine wether FTP credentials have been passed along with the current request jimport('joomla.client.helper'); $user = JRequest::getString('username', null, 'GET', JREQUEST_ALLOWRAW); $pass = JRequest::getString('password', null, 'GET', JREQUEST_ALLOWRAW); if ($user != '' && $pass != '') { // Add credentials to the session if (JClientHelper::setCredentials($client, $user, $pass)) { $return = false; } else { $return =& JError::raiseWarning('SOME_ERROR_CODE', 'JClientHelper::setCredentialsFromRequest failed'); } } else { // Just determine if the FTP input fields need to be shown $return = !JClientHelper::hasCredentials('ftp'); } return $return; } } home/academiac/www/components/com_users/controller.php 0000644 00000006602 15137247157 0017307 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_users * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Base controller class for Users. * * @package Joomla.Site * @subpackage com_users * @since 1.5 */ class UsersController extends JControllerLegacy { /** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { // Get the document object. $document = JFactory::getDocument(); // Set the default view name and format from the Request. $vName = JRequest::getCmd('view', 'login'); $vFormat = $document->getType(); $lName = JRequest::getCmd('layout', 'default'); if ($view = $this->getView($vName, $vFormat)) { // Do any specific processing by view. switch ($vName) { case 'registration': // If the user is already logged in, redirect to the profile page. $user = JFactory::getUser(); if ($user->get('guest') != 1) { // Redirect to profile page. $this->setRedirect(JRoute::_('index.php?option=com_users&view=profile', false)); return; } // Check if user registration is enabled if(JComponentHelper::getParams('com_users')->get('allowUserRegistration') == 0) { // Registration is disabled - Redirect to login page. $this->setRedirect(JRoute::_('index.php?option=com_users&view=login', false)); return; } // The user is a guest, load the registration model and show the registration page. $model = $this->getModel('Registration'); break; // Handle view specific models. case 'profile': // If the user is a guest, redirect to the login page. $user = JFactory::getUser(); if ($user->get('guest') == 1) { // Redirect to login page. $this->setRedirect(JRoute::_('index.php?option=com_users&view=login', false)); return; } $model = $this->getModel($vName); break; // Handle the default views. case 'login': $model = $this->getModel($vName); break; case 'reset': // If the user is already logged in, redirect to the profile page. $user = JFactory::getUser(); if ($user->get('guest') != 1) { // Redirect to profile page. $this->setRedirect(JRoute::_('index.php?option=com_users&view=profile', false)); return; } $model = $this->getModel($vName); break; case 'remind': // If the user is already logged in, redirect to the profile page. $user = JFactory::getUser(); if ($user->get('guest') != 1) { // Redirect to profile page. $this->setRedirect(JRoute::_('index.php?option=com_users&view=profile', false)); return; } $model = $this->getModel($vName); break; default: $model = $this->getModel('Login'); break; } // Push the model into the view (as default). $view->setModel($model, true); $view->setLayout($lName); // Push document object into the view. $view->assignRef('document', $document); $view->display(); } } } home/academiac/www/libraries/joomla/application/component/controller.php 0000644 00000063744 15137261367 0022676 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Application * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; /** * Base class for a Joomla Controller * * Controller (Controllers are where you put all the actual code.) Provides basic * functionality, such as rendering views (aka displaying templates). * * @package Joomla.Platform * @subpackage Application * @since 11.1 */ class JController extends JObject { /** * ACO Section for the controller. * * @var string * @since 11.1 * @deprecated 12.1 */ protected $_acoSection; /** * Default ACO Section value for the controller. * * @var string * @since 11.1 * @deprecated 12.1 */ protected $_acoSectionValue; /** * The base path of the controller * * @var string * @since 11.1 * @note Replaces _basePath. */ protected $basePath; /** * The default view for the display method. * * @var string * @since 11.1 */ protected $default_view; /** * The mapped task that was performed. * * @var string * @since 11.1 * @note Replaces _doTask. */ protected $doTask; /** * Redirect message. * * @var string * @since 11.1 * @note Replaces _message. */ protected $message; /** * Redirect message type. * * @var string * @since 11.1 * @note Replaces _messageType. */ protected $messageType; /** * Array of class methods * * @var array * @since 11.1 * @note Replaces _methods. */ protected $methods; /** * The name of the controller * * @var array * @since 11.1 * @note Replaces _name. */ protected $name; /** * The prefix of the models * * @var string * @since 11.1 */ protected $model_prefix; /** * The set of search directories for resources (views). * * @var array * @since 11.1 * @note Replaces _path. */ protected $paths; /** * URL for redirection. * * @var string * @since 11.1 * @note Replaces _redirect. */ protected $redirect; /** * Current or most recently performed task. * * @var string * @since 11.1 * @note Replaces _task. */ protected $task; /** * Array of class methods to call for a given task. * * @var array * @since 11.1 * @note Replaces _taskMap. */ protected $taskMap; /** * @var JController JController instance container. * @since 11.3 */ protected static $instance; /** * Adds to the stack of model paths in LIFO order. * * @param mixed $path The directory (string), or list of directories (array) to add. * @param string $prefix A prefix for models * * @return void */ public static function addModelPath($path, $prefix = '') { jimport('joomla.application.component.model'); JModel::addIncludePath($path, $prefix); } /** * Create the filename for a resource. * * @param string $type The resource type to create the filename for. * @param array $parts An associative array of filename information. Optional. * * @return string The filename. * * @note Replaced _createFileName. * @since 11.1 */ protected static function createFileName($type, $parts = array()) { $filename = ''; switch ($type) { case 'controller': if (!empty($parts['format'])) { if ($parts['format'] == 'html') { $parts['format'] = ''; } else { $parts['format'] = '.' . $parts['format']; } } else { $parts['format'] = ''; } $filename = strtolower($parts['name']) . $parts['format'] . '.php'; break; case 'view': if (!empty($parts['type'])) { $parts['type'] = '.' . $parts['type']; } $filename = strtolower($parts['name']) . '/view' . $parts['type'] . '.php'; break; } return $filename; } /** * Method to get a singleton controller instance. * * @param string $prefix The prefix for the controller. * @param array $config An array of optional constructor options. * * @return JController * * @since 11.1 * @throws Exception if the controller cannot be loaded. */ public static function getInstance($prefix, $config = array()) { if (is_object(self::$instance)) { return self::$instance; } // Get the environment configuration. $basePath = array_key_exists('base_path', $config) ? $config['base_path'] : JPATH_COMPONENT; $format = JRequest::getWord('format'); $command = JRequest::getVar('task', 'display'); // Check for array format. $filter = JFilterInput::getInstance(); if (is_array($command)) { $command = $filter->clean(array_pop(array_keys($command)), 'cmd'); } else { $command = $filter->clean($command, 'cmd'); } // Check for a controller.task command. if (strpos($command, '.') !== false) { // Explode the controller.task command. list ($type, $task) = explode('.', $command); // Define the controller filename and path. $file = self::createFileName('controller', array('name' => $type, 'format' => $format)); $path = $basePath . '/controllers/' . $file; // Reset the task without the controller context. JRequest::setVar('task', $task); } else { // Base controller. $type = null; $task = $command; // Define the controller filename and path. $file = self::createFileName('controller', array('name' => 'controller', 'format' => $format)); $path = $basePath . '/' . $file; $backupfile = self::createFileName('controller', array('name' => 'controller')); $backuppath = $basePath . '/' . $backupfile; } // Get the controller class name. $class = ucfirst($prefix) . 'Controller' . ucfirst($type); // Include the class if not present. if (!class_exists($class)) { // If the controller file path exists, include it. if (file_exists($path)) { require_once $path; } elseif (isset($backuppath) && file_exists($backuppath)) { require_once $backuppath; } else { throw new InvalidArgumentException(JText::sprintf('JLIB_APPLICATION_ERROR_INVALID_CONTROLLER', $type, $format)); } } // Instantiate the class. if (class_exists($class)) { self::$instance = new $class($config); } else { throw new InvalidArgumentException(JText::sprintf('JLIB_APPLICATION_ERROR_INVALID_CONTROLLER_CLASS', $class)); } return self::$instance; } /** * Constructor. * * @param array $config An optional associative array of configuration settings. * Recognized key values include 'name', 'default_task', 'model_path', and * 'view_path' (this list is not meant to be comprehensive). * * @since 11.1 */ public function __construct($config = array()) { // Initialise variables. $this->methods = array(); $this->message = null; $this->messageType = 'message'; $this->paths = array(); $this->redirect = null; $this->taskMap = array(); if (defined('JDEBUG') && JDEBUG) { JLog::addLogger(array('text_file' => 'jcontroller.log.php'), JLog::ALL, array('controller')); } // Determine the methods to exclude from the base class. $xMethods = get_class_methods('JController'); // Get the public methods in this class using reflection. $r = new ReflectionClass($this); $rMethods = $r->getMethods(ReflectionMethod::IS_PUBLIC); foreach ($rMethods as $rMethod) { $mName = $rMethod->getName(); // Add default display method if not explicitly declared. if (!in_array($mName, $xMethods) || $mName == 'display') { $this->methods[] = strtolower($mName); // Auto register the methods as tasks. $this->taskMap[strtolower($mName)] = $mName; } } // Set the view name if (empty($this->name)) { if (array_key_exists('name', $config)) { $this->name = $config['name']; } else { $this->name = $this->getName(); } } // Set a base path for use by the controller if (array_key_exists('base_path', $config)) { $this->basePath = $config['base_path']; } else { $this->basePath = JPATH_COMPONENT; } // If the default task is set, register it as such if (array_key_exists('default_task', $config)) { $this->registerDefaultTask($config['default_task']); } else { $this->registerDefaultTask('display'); } // Set the models prefix if (empty($this->model_prefix)) { if (array_key_exists('model_prefix', $config)) { // User-defined prefix $this->model_prefix = $config['model_prefix']; } else { $this->model_prefix = $this->name . 'Model'; } } // Set the default model search path if (array_key_exists('model_path', $config)) { // User-defined dirs $this->addModelPath($config['model_path'], $this->model_prefix); } else { $this->addModelPath($this->basePath . '/models', $this->model_prefix); } // Set the default view search path if (array_key_exists('view_path', $config)) { // User-defined dirs $this->setPath('view', $config['view_path']); } else { $this->setPath('view', $this->basePath . '/views'); } // Set the default view. if (array_key_exists('default_view', $config)) { $this->default_view = $config['default_view']; } elseif (empty($this->default_view)) { $this->default_view = $this->getName(); } } /** * Adds to the search path for templates and resources. * * @param string $type The path type (e.g. 'model', 'view'). * @param mixed $path The directory string or stream array to search. * * @return JController A JController object to support chaining. * * @since 11.1 * @note Replaces _addPath. */ protected function addPath($type, $path) { // Just force path to array settype($path, 'array'); if (!isset($this->paths[$type])) { $this->paths[$type] = array(); } // Loop through the path directories foreach ($path as $dir) { // No surrounding spaces allowed! $dir = rtrim(JPath::check($dir, '/'), '/') . '/'; // Add to the top of the search dirs array_unshift($this->paths[$type], $dir); } return $this; } /** * Add one or more view paths to the controller's stack, in LIFO order. * * @param mixed $path The directory (string) or list of directories (array) to add. * * @return JController This object to support chaining. */ public function addViewPath($path) { $this->addPath('view', $path); return $this; } /** * Authorisation check * * @param string $task The ACO Section Value to check access on * * @return boolean True if authorised * * @since 11.1 * * @deprecated 12.1 Use JAuthorise */ public function authorize($task) { JLog::add('JController::authorize() is deprecated.', JLog::WARNING, 'deprecated'); $this->authorise($task); } /** * Authorisation check * * @param string $task The ACO Section Value to check access on. * * @return boolean True if authorised * * @since 11.1 * @deprecated 12.3 */ public function authorise($task) { // Only do access check if the aco section is set if ($this->_acoSection) { // If we have a section value set that trumps the passed task. if ($this->_acoSectionValue) { // We have one, so set it and lets do the check $task = $this->_acoSectionValue; } // Get the JUser object for the current user and return the authorization boolean $user = JFactory::getUser(); return $user->authorise($this->_acoSection, $task); } else { // Nothing set, nothing to check... so obviously it's ok :) return true; } } /** * Method to check whether an ID is in the edit list. * * @param string $context The context for the session storage. * @param integer $id The ID of the record to add to the edit list. * * @return boolean True if the ID is in the edit list. * * @since 11.1 */ protected function checkEditId($context, $id) { if ($id) { $app = JFactory::getApplication(); $values = (array) $app->getUserState($context . '.id'); $result = in_array((int) $id, $values); if (defined('JDEBUG') && JDEBUG) { JLog::add( sprintf( 'Checking edit ID %s.%s: %d %s', $context, $id, (int) $result, str_replace("\n", ' ', print_r($values, 1)) ), JLog::INFO, 'controller' ); } return $result; } else { // No id for a new item. return true; } } /** * Method to load and return a model object. * * @param string $name The name of the model. * @param string $prefix Optional model prefix. * @param array $config Configuration array for the model. Optional. * * @return mixed Model object on success; otherwise null failure. * * @since 11.1 * @note Replaces _createModel. */ protected function createModel($name, $prefix = '', $config = array()) { // Clean the model name $modelName = preg_replace('/[^A-Z0-9_]/i', '', $name); $classPrefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix); $result = JModel::getInstance($modelName, $classPrefix, $config); return $result; } /** * Method to load and return a view object. This method first looks in the * current template directory for a match and, failing that, uses a default * set path to load the view class file. * * Note the "name, prefix, type" order of parameters, which differs from the * "name, type, prefix" order used in related public methods. * * @param string $name The name of the view. * @param string $prefix Optional prefix for the view class name. * @param string $type The type of view. * @param array $config Configuration array for the view. Optional. * * @return mixed View object on success; null or error result on failure. * * @since 11.1 * @note Replaces _createView. */ protected function createView($name, $prefix = '', $type = '', $config = array()) { // Clean the view name $viewName = preg_replace('/[^A-Z0-9_]/i', '', $name); $classPrefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix); $viewType = preg_replace('/[^A-Z0-9_]/i', '', $type); // Build the view class name $viewClass = $classPrefix . $viewName; if (!class_exists($viewClass)) { jimport('joomla.filesystem.path'); $path = JPath::find($this->paths['view'], $this->createFileName('view', array('name' => $viewName, 'type' => $viewType))); if ($path) { require_once $path; if (!class_exists($viewClass)) { JError::raiseError(500, JText::sprintf('JLIB_APPLICATION_ERROR_VIEW_CLASS_NOT_FOUND', $viewClass, $path)); return null; } } else { return null; } } return new $viewClass($config); } /** * Typical view method for MVC based architecture * * This function is provide as a default implementation, in most cases * you will need to override it in your own controllers. * * @param boolean $cachable If true, the view output will be cached * @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController A JController object to support chaining. * * @since 11.1 */ public function display($cachable = false, $urlparams = false) { $document = JFactory::getDocument(); $viewType = $document->getType(); $viewName = JRequest::getCmd('view', $this->default_view); $viewLayout = JRequest::getString('layout', 'default'); $view = $this->getView($viewName, $viewType, '', array('base_path' => $this->basePath, 'layout' => $viewLayout)); // Get/Create the model if ($model = $this->getModel($viewName)) { // Push the model into the view (as default) $view->setModel($model, true); } $view->assignRef('document', $document); $conf = JFactory::getConfig(); // Display the view if ($cachable && $viewType != 'feed' && $conf->get('caching') >= 1) { $option = JRequest::getCmd('option'); $cache = JFactory::getCache($option, 'view'); if (is_array($urlparams)) { $app = JFactory::getApplication(); if (!empty($app->registeredurlparams)) { $registeredurlparams = $app->registeredurlparams; } else { $registeredurlparams = new stdClass; } foreach ($urlparams as $key => $value) { // Add your safe url parameters with variable type as value {@see JFilterInput::clean()}. $registeredurlparams->$key = $value; } $app->registeredurlparams = $registeredurlparams; } $cache->get($view, 'display'); } else { $view->display(); } return $this; } /** * Execute a task by triggering a method in the derived class. * * @param string $task The task to perform. If no matching task is found, the '__default' task is executed, if defined. * * @return mixed The value returned by the called method, false in error case. * * @since 11.1 */ public function execute($task) { $this->task = $task; $task = strtolower($task); if (isset($this->taskMap[$task])) { $doTask = $this->taskMap[$task]; } elseif (isset($this->taskMap['__default'])) { $doTask = $this->taskMap['__default']; } else { return JError::raiseError(404, JText::sprintf('JLIB_APPLICATION_ERROR_TASK_NOT_FOUND', $task)); } // Record the actual task being fired $this->doTask = $doTask; // Make sure we have access if ($this->authorise($doTask)) { $retval = $this->$doTask(); return $retval; } else { return JError::raiseError(403, JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN')); } } /** * Method to get a model object, loading it if required. * * @param string $name The model name. Optional. * @param string $prefix The class prefix. Optional. * @param array $config Configuration array for model. Optional. * * @return object The model. * * @since 11.1 */ public function getModel($name = '', $prefix = '', $config = array()) { if (empty($name)) { $name = $this->getName(); } if (empty($prefix)) { $prefix = $this->model_prefix; } if ($model = $this->createModel($name, $prefix, $config)) { // Task is a reserved state $model->setState('task', $this->task); // Let's get the application object and set menu information if it's available $app = JFactory::getApplication(); $menu = $app->getMenu(); if (is_object($menu)) { if ($item = $menu->getActive()) { $params = $menu->getParams($item->id); // Set default state data $model->setState('parameters.menu', $params); } } } return $model; } /** * Method to get the controller name * * The dispatcher name is set by default parsed using the classname, or it can be set * by passing a $config['name'] in the class constructor * * @return string The name of the dispatcher * * @since 11.1 */ public function getName() { if (empty($this->name)) { $r = null; if (!preg_match('/(.*)Controller/i', get_class($this), $r)) { JError::raiseError(500, JText::_('JLIB_APPLICATION_ERROR_CONTROLLER_GET_NAME')); } $this->name = strtolower($r[1]); } return $this->name; } /** * Get the last task that is being performed or was most recently performed. * * @return string The task that is being performed or was most recently performed. * * @since 11.1 */ public function getTask() { return $this->task; } /** * Gets the available tasks in the controller. * * @return array Array[i] of task names. * * @since 11.1 */ public function getTasks() { return $this->methods; } /** * Method to get a reference to the current view and load it if necessary. * * @param string $name The view name. Optional, defaults to the controller name. * @param string $type The view type. Optional. * @param string $prefix The class prefix. Optional. * @param array $config Configuration array for view. Optional. * * @return object Reference to the view or an error. * * @since 11.1 */ public function getView($name = '', $type = '', $prefix = '', $config = array()) { static $views; if (!isset($views)) { $views = array(); } if (empty($name)) { $name = $this->getName(); } if (empty($prefix)) { $prefix = $this->getName() . 'View'; } if (empty($views[$name])) { if ($view = $this->createView($name, $prefix, $type, $config)) { $views[$name] = & $view; } else { $result = JError::raiseError(500, JText::sprintf('JLIB_APPLICATION_ERROR_VIEW_NOT_FOUND', $name, $type, $prefix)); return $result; } } return $views[$name]; } /** * Method to add a record ID to the edit list. * * @param string $context The context for the session storage. * @param integer $id The ID of the record to add to the edit list. * * @return void * * @since 11.1 */ protected function holdEditId($context, $id) { // Initialise variables. $app = JFactory::getApplication(); $values = (array) $app->getUserState($context . '.id'); // Add the id to the list if non-zero. if (!empty($id)) { array_push($values, (int) $id); $values = array_unique($values); $app->setUserState($context . '.id', $values); if (defined('JDEBUG') && JDEBUG) { JLog::add( sprintf( 'Holding edit ID %s.%s %s', $context, $id, str_replace("\n", ' ', print_r($values, 1)) ), JLog::INFO, 'controller' ); } } } /** * Redirects the browser or returns false if no redirect is set. * * @return boolean False if no redirect exists. * * @since 11.1 */ public function redirect() { if ($this->redirect) { $app = JFactory::getApplication(); $app->redirect($this->redirect, $this->message, $this->messageType); } return false; } /** * Register the default task to perform if a mapping is not found. * * @param string $method The name of the method in the derived class to perform if a named task is not found. * * @return JController A JController object to support chaining. * * @since 11.1 */ public function registerDefaultTask($method) { $this->registerTask('__default', $method); return $this; } /** * Register (map) a task to a method in the class. * * @param string $task The task. * @param string $method The name of the method in the derived class to perform for this task. * * @return JController A JController object to support chaining. * * @since 11.1 */ public function registerTask($task, $method) { if (in_array(strtolower($method), $this->methods)) { $this->taskMap[strtolower($task)] = $method; } return $this; } /** * Unregister (unmap) a task in the class. * * @param string $task The task. * * @return JController This object to support chaining. * * @since 11.1 */ public function unregisterTask($task) { unset($this->taskMap[strtolower($task)]); return $this; } /** * Method to check whether an ID is in the edit list. * * @param string $context The context for the session storage. * @param integer $id The ID of the record to add to the edit list. * * @return void * * @since 11.1 */ protected function releaseEditId($context, $id) { $app = JFactory::getApplication(); $values = (array) $app->getUserState($context . '.id'); // Do a strict search of the edit list values. $index = array_search((int) $id, $values, true); if (is_int($index)) { unset($values[$index]); $app->setUserState($context . '.id', $values); if (defined('JDEBUG') && JDEBUG) { JLog::add( sprintf( 'Releasing edit ID %s.%s %s', $context, $id, str_replace("\n", ' ', print_r($values, 1)) ), JLog::INFO, 'controller' ); } } } /** * Sets the access control levels. * * @param string $section The ACO section (eg, the component). * @param string $value The ACO section value (if using a constant value). * * @return void * * @deprecated 12.1 Use JAccess * @see Jaccess * @since 11.1 */ public function setAccessControl($section, $value = null) { // Deprecation warning. JLog::add('JController::setAccessControl() is deprecated.', JLog::WARNING, 'deprecated'); $this->_acoSection = $section; $this->_acoSectionValue = $value; } /** * Sets the internal message that is passed with a redirect * * @param string $text Message to display on redirect. * @param string $type Message type (since 11.1). Optional, defaults to 'message'. * * @return string Previous message * * @since 11.1 */ public function setMessage($text, $type = 'message') { $previous = $this->message; $this->message = $text; $this->messageType = $type; return $previous; } /** * Sets an entire array of search paths for resources. * * @param string $type The type of path to set, typically 'view' or 'model'. * @param string $path The new set of search paths. If null or false, resets to the current directory only. * * @return void * * @note Replaces _setPath. * @since 11.1 */ protected function setPath($type, $path) { // Clear out the prior search dirs $this->paths[$type] = array(); // Actually add the user-specified directories $this->addPath($type, $path); } /** * Set a URL for browser redirection. * * @param string $url URL to redirect to. * @param string $msg Message to display on redirect. Optional, defaults to value set internally by controller, if any. * @param string $type Message type. Optional, defaults to 'message' or the type set by a previous call to setMessage. * * @return JController This object to support chaining. * * @since 11.1 */ public function setRedirect($url, $msg = null, $type = null) { $this->redirect = $url; if ($msg !== null) { // Controller may have set this directly $this->message = $msg; } // Ensure the type is not overwritten by a previous call to setMessage. if (empty($type)) { if (empty($this->messageType)) { $this->messageType = 'message'; } } // If the type is explicitly set, set it. else { $this->messageType = $type; } return $this; } } home/academiac/www/libraries/joomla/cache/controller.php 0000644 00000011502 15137274115 0017410 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Cache * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; /** * Public cache handler * * @package Joomla.Platform * @subpackage Cache * @since 11.1 */ class JCacheController { /** * @var JCache * @since 11.1 */ public $cache; /** * @var array Array of options * @since 11.1 */ public $options; /** * Constructor * * @param array $options Array of options * * @since 11.1 */ public function __construct($options) { $this->cache = new JCache($options); $this->options = & $this->cache->_options; // Overwrite default options with given options foreach ($options as $option => $value) { if (isset($options[$option])) { $this->options[$option] = $options[$option]; } } } /** * Magic method to proxy JCacheControllerMethods * * @param string $name Name of the function * @param array $arguments Array of arguments for the function * * @return mixed * * @since 11.1 */ public function __call($name, $arguments) { $nazaj = call_user_func_array(array($this->cache, $name), $arguments); return $nazaj; } /** * Returns a reference to a cache adapter object, always creating it * * @param string $type The cache object type to instantiate; default is output. * @param array $options Array of options * * @return JCache A JCache object * * @since 11.1 */ public static function getInstance($type = 'output', $options = array()) { JCacheController::addIncludePath(JPATH_PLATFORM . '/joomla/cache/controller'); $type = strtolower(preg_replace('/[^A-Z0-9_\.-]/i', '', $type)); $class = 'JCacheController' . ucfirst($type); if (!class_exists($class)) { // Search for the class file in the JCache include paths. jimport('joomla.filesystem.path'); if ($path = JPath::find(JCacheController::addIncludePath(), strtolower($type) . '.php')) { include_once $path; } else { JError::raiseError(500, 'Unable to load Cache Controller: ' . $type); } } return new $class($options); } /** * Set caching enabled state * * @param boolean $enabled True to enable caching * * @return void * * @since 11.1 */ public function setCaching($enabled) { $this->cache->setCaching($enabled); } /** * Set cache lifetime * * @param integer $lt Cache lifetime * * @return void * * @since 11.1 */ public function setLifeTime($lt) { $this->cache->setLifeTime($lt); } /** * Add a directory where JCache should search for controllers. You may * either pass a string or an array of directories. * * @param string $path A path to search. * * @return array An array with directory elements * * @since 11.1 */ public static function addIncludePath($path = '') { static $paths; if (!isset($paths)) { $paths = array(); } if (!empty($path) && !in_array($path, $paths)) { jimport('joomla.filesystem.path'); array_unshift($paths, JPath::clean($path)); } return $paths; } /** * Get stored cached data by id and group * * @param string $id The cache data id * @param string $group The cache data group * * @return mixed False on no result, cached object otherwise * * @since 11.1 */ public function get($id, $group = null) { $data = false; $data = $this->cache->get($id, $group); if ($data === false) { $locktest = new stdClass; $locktest->locked = null; $locktest->locklooped = null; $locktest = $this->cache->lock($id, $group); if ($locktest->locked == true && $locktest->locklooped == true) { $data = $this->cache->get($id, $group); } if ($locktest->locked == true) { $this->cache->unlock($id, $group); } } // Check again because we might get it from second attempt if ($data !== false) { $data = unserialize(trim($data)); // trim to fix unserialize errors } return $data; } /** * Store data to cache by id and group * * @param mixed $data The data to store * @param string $id The cache data id * @param string $group The cache data group * * @return boolean True if cache was stored * * @since 11.1 */ public function store($data, $id, $group = null) { $locktest = new stdClass; $locktest->locked = null; $locktest->locklooped = null; $locktest = $this->cache->lock($id, $group); if ($locktest->locked == false && $locktest->locklooped == true) { $locktest = $this->cache->lock($id, $group); } $sucess = $this->cache->store(serialize($data), $id, $group); if ($locktest->locked == true) { $this->cache->unlock($id, $group); } return $sucess; } } home/academiac/www/administrator/components/com_languages/controller.php 0000644 00000003202 15137316274 0022762 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Languages Controller * * @package Joomla.Administrator * @subpackage com_languages * @since 1.5 */ class LanguagesController extends JControllerLegacy { /** * @var string The default view. * @since 1.6 */ protected $default_view = 'installed'; /** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT.'/helpers/languages.php'; // Load the submenu. LanguagesHelper::addSubmenu(JRequest::getCmd('view', 'installed')); $view = JRequest::getCmd('view', 'languages'); $layout = JRequest::getCmd('layout', 'default'); $client = JRequest::getInt('client'); $id = JRequest::getInt('id'); // Check for edit form. if ($view == 'language' && $layout == 'edit' && !$this->checkEditId('com_languages.edit.language', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_languages&view=languages', false)); return false; } parent::display(); return $this; } } home/academiac/www/components/com_mailto/controller.php 0000644 00000007175 15137347064 0017437 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_mailto * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * @package Joomla.Site * @subpackage com_mailto */ class MailtoController extends JControllerLegacy { /** * Show the form so that the user can send the link to someone * * @access public * @since 1.5 */ function mailto() { $session = JFactory::getSession(); $session->set('com_mailto.formtime', time()); JRequest::setVar('view', 'mailto'); $this->display(); } /** * Send the message and display a notice * * @access public * @since 1.5 */ function send() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); $session = JFactory::getSession(); $db = JFactory::getDbo(); $timeout = $session->get('com_mailto.formtime', 0); if ($timeout == 0 || time() - $timeout < 20) { JError::raiseNotice(500, JText:: _ ('COM_MAILTO_EMAIL_NOT_SENT')); return $this->mailto(); } $SiteName = $app->getCfg('sitename'); $MailFrom = $app->getCfg('mailfrom'); $FromName = $app->getCfg('fromname'); $link = MailtoHelper::validateHash(JRequest::getCMD('link', '', 'post')); // Verify that this is a local link if (!$link || !JURI::isInternal($link)) { //Non-local url... JError::raiseNotice(500, JText:: _ ('COM_MAILTO_EMAIL_NOT_SENT')); return $this->mailto(); } // An array of email headers we do not want to allow as input $headers = array ( 'Content-Type:', 'MIME-Version:', 'Content-Transfer-Encoding:', 'bcc:', 'cc:'); // An array of the input fields to scan for injected headers $fields = array( 'mailto', 'sender', 'from', 'subject', ); /* * Here is the meat and potatoes of the header injection test. We * iterate over the array of form input and check for header strings. * If we find one, send an unauthorized header and die. */ foreach ($fields as $field) { foreach ($headers as $header) { if (strpos($_POST[$field], $header) !== false) { JError::raiseError(403, ''); } } } /* * Free up memory */ unset ($headers, $fields); $email = JRequest::getString('mailto', '', 'post'); $sender = JRequest::getString('sender', '', 'post'); $from = JRequest::getString('from', '', 'post'); $subject_default = JText::sprintf('COM_MAILTO_SENT_BY', $sender); $subject = JRequest::getString('subject', $subject_default, 'post'); // Check for a valid to address $error = false; if (! $email || ! JMailHelper::isEmailAddress($email)) { $error = JText::sprintf('COM_MAILTO_EMAIL_INVALID', $email); JError::raiseWarning(0, $error); } // Check for a valid from address if (! $from || ! JMailHelper::isEmailAddress($from)) { $error = JText::sprintf('COM_MAILTO_EMAIL_INVALID', $from); JError::raiseWarning(0, $error); } if ($error) { return $this->mailto(); } // Build the message to send $msg = JText :: _('COM_MAILTO_EMAIL_MSG'); $body = sprintf($msg, $SiteName, $sender, $from, $link); // Clean the email data $subject = JMailHelper::cleanSubject($subject); $body = JMailHelper::cleanBody($body); $sender = JMailHelper::cleanAddress($sender); // Send the email if (JFactory::getMailer()->sendMail($from, $sender, $email, $subject, $body) !== true) { JError::raiseNotice(500, JText:: _ ('COM_MAILTO_EMAIL_NOT_SENT')); return $this->mailto(); } JRequest::setVar('view', 'sent'); $this->display(); } } home/academiac/www/components/com_finder/controller.php 0000644 00000003110 15137347067 0017405 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_finder * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('_JEXEC') or die; JLoader::register('FinderHelperLanguage', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/language.php'); /** * Finder Component Controller. * * @package Joomla.Site * @subpackage com_finder * @since 2.5 */ class FinderController extends JControllerLegacy { /** * Method to display a view. * * @param boolean $cachable If true, the view output will be cached. [optional] * @param array $urlparams An array of safe url parameters and their variable types, * for valid values see {@link JFilterInput::clean()}. [optional] * * @return JController This object is to support chaining. * * @since 1.6 */ public function display($cachable = false, $urlparams = array()) { // Initialise variables. $input = JFactory::getApplication()->input; $cachable = true; // Load plug-in language files. FinderHelperLanguage::loadPluginLanguage(); // Set the default view name and format from the Request. $viewName = $input->get('view', 'search', 'word'); $input->set('view', $viewName); // Don't cache view for search queries if ($input->get('q') || $input->get('f') || $input->get('t')) { $cachable = false; } $safeurlparams = array( 'f' => 'INT', 'lang' => 'CMD' ); return parent::display($cachable, $safeurlparams); } } home/academiac/www/components/com_wrapper/controller.php 0000644 00000002006 15137355643 0017620 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_wrapper * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Content Component Controller * * @package Joomla.Site * @subpackage com_wrapper * @since 1.5 */ class WrapperController extends JControllerLegacy { /** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { $cachable = true; // Set the default view name and format from the Request. $vName = JRequest::getCmd('view', 'wrapper'); JRequest::setVar('view', $vName); return parent::display($cachable, array('Itemid'=>'INT')); } } home/academiac/www/administrator/components/com_sociallogin/controller.php 0000604 00000024503 15137374357 0023330 0 ustar 00 <?php /** * @package SocialLogin * @copyright Copyright 2012 http://www.oneall.com - All rights reserved. * @license GNU/GPL 2 or later * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. * * The "GNU General Public License" (GPL) is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * */ defined ('_JEXEC') or die ('Direct Access to this location is not allowed.'); jimport ('joomla.application.component.controller'); /** * General Controller of SocialLogin component */ class SocialLoginController extends JController { /** * Display task */ public function display ($cachable = false, $urlparams = false) { // Set default view if not set JRequest::setVar ('view', JRequest::getCmd ('view', 'SocialLogin')); // Call parent behavior parent::display ($cachable); } /** * Save settings */ public function apply () { $model = $this->getModel (); $model->saveSettings (); $this->setRedirect (JRoute::_ ('index.php?option=com_sociallogin&view=sociallogin&layout=default', false)); } /** * Autoderect API Connection Handler */ public function autodetect_api_connection_handler () { //CURL Works if ($this->is_curl_available () === true) { echo 'success_autodetect_api_curl'; die (); } //CURL does not work else { // FSOCKOPEN works if ($this->is_fsockopen_available () == true) { echo 'success_autodetect_api_fsockopen'; die (); } } //No working handler found echo 'error_autodetect_api_no_handler'; die (); } /** * Check API Settings */ public function check_api_settings () { $model = $this->getModel (); //Check if all fields have been filled out if (empty ($_POST ['api_subdomain']) OR empty ($_POST ['api_key']) OR empty ($_POST ['api_secret'])) { echo 'error_not_all_fields_filled_out'; $model->setSetting ('api_settings_verified', 0); die (); } //Check the handler $api_connection_handler = ((!empty ($_POST ['api_connection_handler']) AND $_POST ['api_connection_handler'] == 'fsockopen') ? 'fsockopen' : 'curl'); //FSOCKOPEN if ($api_connection_handler == 'fsockopen') { if ($this->is_fsockopen_available() !== true) { echo 'error_selected_handler_faulty'; $model->setSetting ('api_settings_verified', 0); die(); } } //CURL else { if ($this->is_curl_available() !== true) { echo 'error_selected_handler_faulty'; $model->setSetting ('api_settings_verified', 0); die(); } } //Parameters $api_subdomain = trim (strtolower ($_POST ['api_subdomain'])); $api_key = $_POST ['api_key']; $api_secret = $_POST ['api_secret']; //Full domain entered if (preg_match ("/([a-z0-9\-]+)\.api\.oneall\.com/i", $api_subdomain, $matches)) { $api_subdomain = $matches [1]; } //Check subdomain format if (!preg_match ("/^[a-z0-9\-]+$/i", $api_subdomain)) { echo 'error_subdomain_wrong_syntax'; $model->setSetting ('api_settings_verified', 0); die (); } //Domain $api_domain = $api_subdomain . '.api.oneall.com'; //Resource URI $api_resource_url = 'https://' . $api_domain . '/tools/ping.json'; //Get connection details $result = $this->make_api_request ($api_connection_handler, $api_resource_url, array ('api_key' => $api_key, 'api_secret' => $api_secret), 15); //Parse result if (is_object ($result) AND property_exists ($result, 'http_code') AND property_exists ($result, 'http_data')) { switch ($result->http_code) { //Success case 200: echo 'success'; $model->setSetting ('api_settings_verified', 1); die (); break; //Authentication Error case 401: echo 'error_authentication_credentials_wrong'; $model->setSetting ('api_settings_verified', 0); die (); break; //Wrong Subdomain case 404: echo 'error_subdomain_wrong'; $model->setSetting ('api_settings_verified', 0); die (); break; //Other error default: echo 'error_communication'; $model->setSetting ('api_settings_verified', 0); die (); break; } } else { echo 'error_communication'; $model->setSetting ('api_settings_verified', 0); die (); } die (); } /** * Send an API request by using the given handler */ function make_api_request ($handler, $url, $options = array (), $timeout = 15) { //FSOCKOPEN if ($handler == 'fsockopen') { return $this->make_fsockopen_request($url, $options, $timeout); } //CURL else { return $this->make_curl_request($url, $options, $timeout); } } ///////////////////////////////////////////////////////////////////////////// // CURL ///////////////////////////////////////////////////////////////////////////// /** * Check if CURL can be used */ public function is_curl_available () { if (in_array ('curl', get_loaded_extensions ()) AND function_exists('curl_exec')) { $result = $this->make_curl_request ('https://www.oneall.com/ping.html'); if (is_object ($result) AND property_exists ($result, 'http_code') AND $result->http_code == 200) { if (property_exists ($result, 'http_data')) { if (strtolower ($result->http_data) == 'ok') { return true; } } } } return false; } /** * Send a CURL request */ public function make_curl_request ($url, $options = array (), $timeout = 15) { //Store the result $result = new stdClass (); //Send request $curl = curl_init (); curl_setopt ($curl, CURLOPT_URL, $url); curl_setopt ($curl, CURLOPT_HEADER, 0); curl_setopt ($curl, CURLOPT_TIMEOUT, $timeout); curl_setopt ($curl, CURLOPT_VERBOSE, 0); curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 0); // BASIC AUTH? if (isset ($options ['api_key']) AND isset ($options ['api_secret'])) { curl_setopt ($curl, CURLOPT_USERPWD, $options ['api_key'] . ":" . $options ['api_secret']); } //Make request if (($http_data = curl_exec ($curl)) !== false) { $result->http_code = curl_getinfo ($curl, CURLINFO_HTTP_CODE); $result->http_data = $http_data; $result->http_error = null; } else { $result->http_code = -1; $result->http_data = null; $result->http_error = curl_error ($curl); } //Done return $result; } ///////////////////////////////////////////////////////////////////////////// // FSOCKOPEN ///////////////////////////////////////////////////////////////////////////// /** * Check if fsockopen can be used */ public function is_fsockopen_available () { $result = $this->make_fsockopen_request ('https://www.oneall.com/ping.html'); if (is_object ($result) AND property_exists ($result, 'http_code') AND $result->http_code == 200) { if (property_exists ($result, 'http_data')) { if (strtolower ($result->http_data) == 'ok') { return true; } } } return false; } /** * Send a FSOCKOPEN request */ public function make_fsockopen_request ($url, $options = array (), $timeout = 15) { //Store the result $result = new stdClass (); //Make that this is a valid URL if (($uri = parse_url ($url)) == false) { $result->http_code = -1; $result->http_data = null; $result->http_error = 'invalid_uri'; return $result; } //Make sure we can handle the schema switch ($uri ['scheme']) { case 'http': $port = (isset ($uri ['port']) ? $uri ['port'] : 80); $host = ($uri ['host'] . ($port != 80 ? ':' . $port : '')); $fp = @fsockopen ($uri ['host'], $port, $errno, $errstr, $timeout); break; case 'https': $port = (isset ($uri ['port']) ? $uri ['port'] : 443); $host = ($uri ['host'] . ($port != 443 ? ':' . $port : '')); $fp = @fsockopen ('ssl://' . $uri ['host'], $port, $errno, $errstr, $timeout); break; default: $result->http_code = -1; $result->http_data = null; $result->http_error = 'invalid_schema'; return $result; break; } //Make sure the socket opened properly if (!$fp) { $result->http_code = -$errno; $result->http_data = null; $result->http_error = trim ($errstr); return $result; } //Construct the path to act on $path = (isset ($uri ['path']) ? $uri ['path'] : '/'); if (isset ($uri ['query'])) { $path .= '?' . $uri ['query']; } //Create HTTP request $defaults = array ( 'Host' => "Host: $host", 'User-Agent' => 'User-Agent: OneAllSocialLogin (+http://www.oneall.com/)', ); // BASIC AUTH? if (isset ($options ['api_key']) AND isset ($options ['api_secret'])) { $defaults ['Authorization'] = 'Authorization: Basic ' . base64_encode ($options ['api_key'] . ":" . $options ['api_secret']); } //Build and send request $request = 'GET ' . $path . " HTTP/1.0\r\n"; $request .= implode ("\r\n", $defaults); $request .= "\r\n\r\n"; fwrite ($fp, $request); //Fetch response $response = ''; while (!feof ($fp)) { $response .= fread ($fp, 1024); } //Close connection fclose ($fp); //Parse response list($response_header, $response_body) = explode ("\r\n\r\n", $response, 2); //Parse header $response_header = preg_split ("/\r\n|\n|\r/", $response_header); list($header_protocol, $header_code, $header_status_message) = explode (' ', trim (array_shift ($response_header)), 3); //Build result $result->http_code = $header_code; $result->http_data = $response_body; //Done return $result; } } home/academiac/www/administrator/components/com_admirorgallery/controller.php 0000604 00000003636 15137374365 0024045 0 ustar 00 <?php /*------------------------------------------------------------------------ # com_admirorgallery - Admiror Gallery Component # ------------------------------------------------------------------------ # author Igor Kekeljevic & Nikola Vasiljevski # copyright Copyright (C) 2011 admiror-design-studio.com. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://www.admiror-design-studio.com/joomla-extensions # Technical Support: Forum - http://www.vasiljevski.com/forum/index.php # Version: 4.5.0 -------------------------------------------------------------------------*/ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die('Restricted access'); jimport('joomla.application.component.controller'); jimport('joomla.html.parameter'); class AdmirorgalleryController extends JController { function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT . '/helpers/admirorgallery.php'; if (!is_dir(JPATH_SITE . '/plugins/content/admirorgallery/')) { JError::raiseWarning('2', JText::_('COM_PLUGIN_NOT_INSTALLED')); } AdmirorGalleryHelper::addSubmenu(JRequest::getCmd('view', 'control_panel'),JRequest::getCmd('AG_resourceType', '')); JToolBarHelper :: custom('AG_apply', 'AG_apply', 'AG_apply', 'COM_ADMIRORGALLERY_APPLY_DESC', false, false); JToolBarHelper :: custom('AG_reset', 'AG_reset', 'AG_reset', 'COM_ADMIRORGALLERY_RESET_DESC', false, false); $doc = JFactory::getDocument(); $doc->addScriptDeclaration(' AG_jQuery(function(){ // SET SHORCUTS AG_jQuery(document).bind("keydown", "ctrl+return", function (){submitbutton("AG_apply");return false;}); AG_jQuery(document).bind("keydown", "ctrl+backspace", function (){submitbutton("AG_reset");return false;}); });//AG_jQuery(function() '); parent::display(); } } home/academiac/www/administrator/components/com_cache/controller.php 0000644 00000004663 15137374410 0022067 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_cache * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Cache Controller * * @package Joomla.Administrator * @subpackage com_cache * @since 1.6 */ class CacheController extends JControllerLegacy { /** * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT.'/helpers/cache.php'; // Get the document object. $document = JFactory::getDocument(); // Set the default view name and format from the Request. $vName = JRequest::getCmd('view', 'cache'); $vFormat = $document->getType(); $lName = JRequest::getCmd('layout', 'default'); // Get and render the view. if ($view = $this->getView($vName, $vFormat)) { switch ($vName) { case 'purge': break; case 'cache': default: $model = $this->getModel($vName); $view->setModel($model, true); break; } $view->setLayout($lName); // Push document object into the view. $view->assignRef('document', $document); // Load the submenu. CacheHelper::addSubmenu(JRequest::getCmd('view', 'cache')); $view->display(); } } public function delete() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JInvalid_Token')); $cid = JRequest::getVar('cid', array(), 'post', 'array'); $model = $this->getModel('cache'); if(empty($cid)) { JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED')); } else { $model->cleanlist($cid); } $this->setRedirect('index.php?option=com_cache&client='.$model->getClient()->id); } public function purge() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JInvalid_Token')); $model = $this->getModel('cache'); $ret = $model->purge(); $msg = JText::_('COM_CACHE_EXPIRED_ITEMS_HAVE_BEEN_PURGED'); $msgType = 'message'; if ($ret === false) { $msg = JText::_('Error purging expired items'); $msgType = 'error'; } $this->setRedirect('index.php?option=com_cache&view=purge', $msg, $msgType); } } home/academiac/www/administrator/components/com_media/controller.php 0000644 00000003635 15137374413 0022104 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Media Manager Component Controller * * @package Joomla.Administrator * @subpackage com_media * @version 1.5 */ class MediaController extends JControllerLegacy { /** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { JPluginHelper::importPlugin('content'); $vName = JRequest::getCmd('view', 'media'); switch ($vName) { case 'images': $vLayout = JRequest::getCmd('layout', 'default'); $mName = 'manager'; break; case 'imagesList': $mName = 'list'; $vLayout = JRequest::getCmd('layout', 'default'); break; case 'mediaList': $app = JFactory::getApplication(); $mName = 'list'; $vLayout = $app->getUserStateFromRequest('media.list.layout', 'layout', 'thumbs', 'word'); break; case 'media': default: $vName = 'media'; $vLayout = JRequest::getCmd('layout', 'default'); $mName = 'manager'; break; } $document = JFactory::getDocument(); $vType = $document->getType(); // Get/Create the view $view = $this->getView($vName, $vType); // Get/Create the model if ($model = $this->getModel($mName)) { // Push the model into the view (as default) $view->setModel($model, true); } // Set the layout $view->setLayout($vLayout); // Display the view $view->display(); return $this; } function ftpValidate() { // Set FTP credentials, if given JClientHelper::setCredentialsFromRequest('ftp'); } } home/academiac/www/administrator/components/com_categories/controller.php 0000644 00000005213 15137374441 0023145 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Categories view class for the Category package. * * @package Joomla.Administrator * @subpackage com_categories * @since 1.6 */ class CategoriesController extends JControllerLegacy { /** * @var string The extension for which the categories apply. * @since 1.6 */ protected $extension; /** * Constructor. * * @param array An optional associative array of configuration settings. * @see JController * @since 1.6 */ public function __construct($config = array()) { parent::__construct($config); // Guess the JText message prefix. Defaults to the option. if (empty($this->extension)) { $this->extension = JRequest::getCmd('extension', 'com_content'); } } /** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { // Get the document object. $document = JFactory::getDocument(); // Set the default view name and format from the Request. $vName = JRequest::getCmd('view', 'categories'); $vFormat = $document->getType(); $lName = JRequest::getCmd('layout', 'default'); $id = JRequest::getInt('id'); // Check for edit form. if ($vName == 'category' && $lName == 'edit' && !$this->checkEditId('com_categories.edit.category', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_categories&view=categories&extension='.$this->extension, false)); return false; } // Get and render the view. if ($view = $this->getView($vName, $vFormat)) { // Get the model for the view. $model = $this->getModel($vName, 'CategoriesModel', array('name' => $vName . '.' . substr($this->extension, 4))); // Push the model into the view (as default). $view->setModel($model, true); $view->setLayout($lName); // Push document object into the view. $view->assignRef('document', $document); // Load the submenu. require_once JPATH_COMPONENT.'/helpers/categories.php'; CategoriesHelper::addSubmenu($model->getState('filter.extension')); $view->display(); } return $this; } } home/academiac/www/components/com_xmap/controller.php 0000604 00000003623 15137411527 0017101 0 ustar 00 <?php /** * @version $Id$ * @copyright Copyright (C) 2005 - 2009 Joomla! Vargas. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author Guillermo Vargas (guille@vargas.co.cr) */ // No direct access defined( '_JEXEC' ) or die( 'Restricted access' ); jimport('joomla.application.component.controller'); /** * Xmap Component Controller * * @package Xmap * @subpackage com_xmap * @since 2.0 */ class XmapController extends JControllerLegacy { /** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { $cachable = true; $id = JRequest::getInt('id'); $viewName = JRequest::getCmd('view'); $viewLayout = JRequest::getCmd('layout', 'default'); $user = JFactory::getUser(); if ($user->get('id') || !in_array($viewName, array('html', 'xml')) || $viewLayout == 'xsl') { $cachable = false; } if ($viewName) { $document = JFactory::getDocument(); $viewType = $document->getType(); $view = $this->getView($viewName, $viewType, '', array('base_path' => $this->basePath, 'layout' => $viewLayout)); $sitemapmodel = $this->getModel('Sitemap'); $view->setModel($sitemapmodel, true); } $safeurlparams = array('id' => 'INT', 'itemid' => 'INT', 'uid' => 'CMD', 'action' => 'CMD', 'property' => 'CMD', 'value' => 'CMD'); parent::display($cachable, $safeurlparams); return $this; } } home/academiac/www/components/com_weblinks/controller.php 0000644 00000003541 15137412657 0017762 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_weblinks * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Weblinks Component Controller * * @package Joomla.Site * @subpackage com_weblinks * @since 1.5 */ class WeblinksController extends JControllerLegacy { /** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { // Initialise variables. $cachable = true; // Huh? Why not just put that in the constructor? $user = JFactory::getUser(); // Set the default view name and format from the Request. // Note we are using w_id to avoid collisions with the router and the return page. // Frontend is a bit messier than the backend. $id = JRequest::getInt('w_id'); $vName = JRequest::getCmd('view', 'categories'); JRequest::setVar('view', $vName); if ($user->get('id') ||($_SERVER['REQUEST_METHOD'] == 'POST' && $vName = 'categories')) { $cachable = false; } $safeurlparams = array( 'id' => 'INT', 'limit' => 'UINT', 'limitstart' => 'UINT', 'filter_order' => 'CMD', 'filter_order_Dir' => 'CMD', 'lang' => 'CMD' ); // Check for edit form. if ($vName == 'form' && !$this->checkEditId('com_weblinks.edit.weblink', $id)) { // Somehow the person just went to the form - we don't allow that. return JError::raiseError(403, JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); } return parent::display($cachable, $safeurlparams); } } home/academiac/www/administrator/components/com_plugins/controller.php 0000644 00000002750 15137413705 0022501 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Plugins master display controller. * * @package Joomla.Administrator * @subpackage com_plugins * @since 1.5 */ class PluginsController extends JControllerLegacy { /** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT.'/helpers/plugins.php'; // Load the submenu. PluginsHelper::addSubmenu(JRequest::getCmd('view', 'plugins')); $view = JRequest::getCmd('view', 'plugins'); $layout = JRequest::getCmd('layout', 'default'); $id = JRequest::getInt('extension_id'); // Check for edit form. if ($view == 'plugin' && $layout == 'edit' && !$this->checkEditId('com_plugins.edit.plugin', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_plugins&view=plugins', false)); return false; } parent::display(); } } home/academiac/www/administrator/components/com_admin/controller.php 0000644 00000000644 15137416665 0022120 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_admin * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Admin Controller * * @package Joomla.Administrator * @subpackage com_admin * @since 1.6 */ class AdminController extends JControllerLegacy { } home/academiac/www/administrator/components/com_weblinks/controller.php 0000644 00000003106 15137416747 0022643 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_weblinks * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Weblinks Weblink Controller * * @package Joomla.Administrator * @subpackage com_weblinks * @since 1.5 */ class WeblinksController extends JControllerLegacy { /** * Method to display a view. * * @param boolean $cachable If true, the view output will be cached * @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT.'/helpers/weblinks.php'; // Load the submenu. WeblinksHelper::addSubmenu(JRequest::getCmd('view', 'weblinks')); $view = JRequest::getCmd('view', 'weblinks'); $layout = JRequest::getCmd('layout', 'default'); $id = JRequest::getInt('id'); // Check for edit form. if ($view == 'weblink' && $layout == 'edit' && !$this->checkEditId('com_weblinks.edit.weblink', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_weblinks&view=weblinks', false)); return false; } parent::display(); return $this; } } home/academiac/www/components/com_admirorgallery/controller.php 0000604 00000001713 15137423504 0021145 0 ustar 00 <?php /*------------------------------------------------------------------------ # com_admirorgallery - Admiror Gallery Component # ------------------------------------------------------------------------ # author Igor Kekeljevic & Nikola Vasiljevski # copyright Copyright (C) 2011 admiror-design-studio.com. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://www.admiror-design-studio.com/joomla-extensions # Technical Support: Forum - http://www.vasiljevski.com/forum/index.php # Version: 4.5.0 -------------------------------------------------------------------------*/ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die( 'Restricted access' ); jimport( 'joomla.application.component.controller' ); jimport('joomla.html.parameter'); class AdmirorgalleryController extends JController { function display($cachable = false, $urlparams = false) { parent::display(); } } home/academiac/www/components/com_content/controller.php 0000644 00000005100 15137424265 0017605 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_content * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Content Component Controller * * @package Joomla.Site * @subpackage com_content * @since 1.5 */ class ContentController extends JControllerLegacy { function __construct($config = array()) { // Article frontpage Editor pagebreak proxying: if (JRequest::getCmd('view') === 'article' && JRequest::getCmd('layout') === 'pagebreak') { $config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR; } // Article frontpage Editor article proxying: elseif(JRequest::getCmd('view') === 'articles' && JRequest::getCmd('layout') === 'modal') { JHtml::_('stylesheet', 'system/adminlist.css', array(), true); $config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR; } parent::__construct($config); } /** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { $cachable = true; JHtml::_('behavior.caption'); // Set the default view name and format from the Request. // Note we are using a_id to avoid collisions with the router and the return page. // Frontend is a bit messier than the backend. $id = JRequest::getInt('a_id'); $vName = JRequest::getCmd('view', 'categories'); JRequest::setVar('view', $vName); $user = JFactory::getUser(); if ($user->get('id') || ($_SERVER['REQUEST_METHOD'] == 'POST' && (($vName == 'category' && JRequest::getCmd('layout') != 'blog') || $vName == 'archive' ))) { $cachable = false; } $safeurlparams = array('catid'=>'INT', 'id'=>'INT', 'cid'=>'ARRAY', 'year'=>'INT', 'month'=>'INT', 'limit'=>'UINT', 'limitstart'=>'UINT', 'showall'=>'INT', 'return'=>'BASE64', 'filter'=>'STRING', 'filter_order'=>'CMD', 'filter_order_Dir'=>'CMD', 'filter-search'=>'STRING', 'print'=>'BOOLEAN', 'lang'=>'CMD', 'Itemid'=>'INT'); // Check for edit form. if ($vName == 'form' && !$this->checkEditId('com_content.edit.article', $id)) { // Somehow the person just went to the form - we don't allow that. return JError::raiseError(403, JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); } parent::display($cachable, $safeurlparams); return $this; } } home/academiac/www/components/com_contact/controller.php 0000644 00000002655 15137440465 0017602 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_contact * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Contact Component Controller * * @package Joomla.Site * @subpackage com_contact * @since 1.5 */ class ContactController extends JControllerLegacy { /** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { $cachable = true; // Get the document object. $document = JFactory::getDocument(); // Set the default view name and format from the Request. $vName = JRequest::getCmd('view', 'categories'); JRequest::setVar('view', $vName); $user = JFactory::getUser(); $safeurlparams = array('catid'=>'INT', 'id'=>'INT', 'cid'=>'ARRAY', 'year'=>'INT', 'month'=>'INT', 'limit'=>'UINT', 'limitstart'=>'UINT', 'showall'=>'INT', 'return'=>'BASE64', 'filter'=>'STRING', 'filter_order'=>'CMD', 'filter_order_Dir'=>'CMD', 'filter-search'=>'STRING', 'print'=>'BOOLEAN', 'lang'=>'CMD'); parent::display($cachable, $safeurlparams); return $this; } } home/academiac/www/components/com_newsfeeds/controller.php 0000644 00000002456 15137443500 0020122 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_newsfeeds * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Newsfeeds Component Controller * * @package Joomla.Site * @subpackage com_newsfeeds * @since 1.5 */ class NewsfeedsController extends JControllerLegacy { /** * Method to show a newsfeeds view * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { $cachable = true; // Set the default view name and format from the Request. $vName = JRequest::getCmd('view', 'categories'); JRequest::setVar('view', $vName); $user = JFactory::getUser(); if ($user->get('id') || ($_SERVER['REQUEST_METHOD'] == 'POST' && $vName = 'category' )) { $cachable = false; } $safeurlparams = array('id'=>'INT', 'limit'=>'UINT', 'limitstart'=>'UINT', 'filter_order'=>'CMD', 'filter_order_Dir'=>'CMD', 'lang'=>'CMD'); parent::display($cachable, $safeurlparams); } } home/academiac/www/administrator/components/com_modules/controller.php 0000644 00000002746 15137444243 0022476 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Modules manager master display controller. * * @package Joomla.Administrator * @subpackage com_modules * @since 1.6 */ class ModulesController extends JControllerLegacy { /** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT.'/helpers/modules.php'; // Load the submenu. ModulesHelper::addSubmenu(JRequest::getCmd('view', 'modules')); $view = JRequest::getCmd('view', 'modules'); $layout = JRequest::getCmd('layout', 'default'); $id = JRequest::getInt('id'); // Check for edit form. if ($view == 'module' && $layout == 'edit' && !$this->checkEditId('com_modules.edit.module', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_modules&view=modules', false)); return false; } parent::display(); } } home/academiac/www/administrator/components/com_virtuemart/liveupdate/classes/controller.php 0000604 00000015434 15137447726 0027032 0 ustar 00 <?php /** * @package LiveUpdate * @copyright Copyright ©2011 Nicholas K. Dionysopoulos / AkeebaBackup.com * @license GNU LGPLv3 or later <http://www.gnu.org/copyleft/lesser.html> */ defined('_JEXEC') or die(); jimport('joomla.application.component.controller'); /** * The Live Update MVC controller */ class LiveUpdateController extends JController { private $jversion = '15'; /** * Object contructor * @param array $config * * @return LiveUpdateController */ public function __construct($config = array()) { parent::__construct(); // Do we have Joomla! 1.6? if( version_compare( JVERSION, '1.6.0', 'ge' ) ) { $this->jversion = '16'; } $basePath = dirname(__FILE__); if($this->jversion == '15') { $this->_basePath = $basePath; } else { $this->basePath = $basePath; } $this->registerDefaultTask('overview'); } /** * Runs the overview page task */ public function overview() { $this->display(); } /** * Starts the update procedure. If the FTP credentials are required, it asks for them. */ public function startupdate() { $ftp = $this->setCredentialsFromRequest('ftp'); if($ftp === true) { // The user needs to supply the FTP credentials $this->display(); } else { // No FTP credentials required; proceed with the download $this->setRedirect('index.php?option='.JRequest::getCmd('option','').'&view='.JRequest::getCmd('view','liveupdate').'&task=download'); $this->redirect(); } } /** * Download the update package */ public function download() { $ftp = $this->setCredentialsFromRequest('ftp'); $model = $this->getThisModel(); $result = $model->download(); if(!$result) { // Download failed $msg = JText::_('LIVEUPDATE_DOWNLOAD_FAILED'); $this->setRedirect('index.php?option='.JRequest::getCmd('option','').'&view='.JRequest::getCmd('view','liveupdate').'&task=overview', $msg, 'error'); } else { // Download successful. Let's extract the package. $url = 'index.php?option='.JRequest::getCmd('option','').'&view='.JRequest::getCmd('view','liveupdate').'&task=extract'; $user = JRequest::getString('username', null, 'GET', JREQUEST_ALLOWRAW); $pass = JRequest::getString('password', null, 'GET', JREQUEST_ALLOWRAW); if($user) { $url .= '&username='.urlencode($user).'&password='.urlencode($pass); } $this->setRedirect($url); } $this->redirect(); } public function extract() { $ftp = $this->setCredentialsFromRequest('ftp'); $model = $this->getThisModel(); $result = $model->extract(); if(!$result) { // Download failed $msg = JText::_('LIVEUPDATE_EXTRACT_FAILED'); $this->setRedirect('index.php?option='.JRequest::getCmd('option','').'&view='.JRequest::getCmd('view','liveupdate').'&task=overview', $msg, 'error'); } else { // Extract successful. Let's install the package. $url = 'index.php?option='.JRequest::getCmd('option','').'&view='.JRequest::getCmd('view','liveupdate').'&task=install'; $user = JRequest::getString('username', null, 'GET', JREQUEST_ALLOWRAW); $pass = JRequest::getString('password', null, 'GET', JREQUEST_ALLOWRAW); if($user) { $url .= '&username='.urlencode($user).'&password='.urlencode($pass); } // Do we have SRP installed yet? $app = JFactory::getApplication(); $jResponse = $app->triggerEvent('onSRPEnabled'); $status = false; if(!empty($jResponse)) { $status = false; foreach($jResponse as $response) { $status = $status || $response; } } // SRP enabled, use it if($status) { $return = $url; $url = $model->getSRPURL($return); if(!$url) { $url = $return; } } $this->setRedirect($url); } $this->redirect(); } public function install() { $ftp = $this->setCredentialsFromRequest('ftp'); $model = $this->getThisModel(); $result = $model->install(); if(!$result) { // Installation failed $model->cleanup(); $this->setRedirect('index.php?option='.JRequest::getCmd('option','').'&view='.JRequest::getCmd('view','liveupdate').'&task=overview'); $this->redirect(); } else { // Installation successful. Show the installation message. if(version_compare(JVERSION,'1.6.0','ge')) { $cache = JFactory::getCache('mod_menu'); $cache->clean(); } $this->display(); } } public function cleanup() { // Perform the cleanup $ftp = $this->setCredentialsFromRequest('ftp'); $model = $this->getThisModel(); $model->cleanup(); // Force reload update information $dummy = LiveUpdate::getUpdateInformation(true); die('OK'); } /** * Displays the current view * @param bool $cachable Ignored! */ public final function display($cachable = false) { $viewLayout = JRequest::getCmd( 'layout', 'default' ); $view = $this->getThisView(); // Get/Create the model $model = $this->getThisModel(); $view->setModel($model, true); // Assign the FTP credentials from the request, or return TRUE if they are required jimport('joomla.client.helper'); $ftp = $this->setCredentialsFromRequest('ftp'); $view->assignRef('ftp', $ftp); // Set the layout $view->setLayout($viewLayout); // Display the view $view->display(); } public final function getThisView() { static $view = null; if(is_null($view)) { $basePath = ($this->jversion == '15') ? $this->_basePath : $this->basePath; $tPath = dirname(__FILE__).'/tmpl'; require_once('view.php'); $view = new LiveUpdateView(array('base_path'=>$basePath, 'template_path'=>$tPath)); } return $view; } public final function getThisModel() { static $model = null; if(is_null($model)) { require_once('model.php'); $model = new LiveUpdateModel(); $task = ($this->jversion == '15') ? $this->_task : $this->task; $model->setState( 'task', $task ); $app = JFactory::getApplication(); $menu = $app->getMenu(); if (is_object( $menu )) { if ($item = $menu->getActive()) { $params =& $menu->getParams($item->id); // Set Default State Data $model->setState( 'parameters.menu', $params ); } } } return $model; } private function setCredentialsFromRequest($client) { // Determine wether FTP credentials have been passed along with the current request jimport('joomla.client.helper'); $user = JRequest::getString('username', null, 'GET', JREQUEST_ALLOWRAW); $pass = JRequest::getString('password', null, 'GET', JREQUEST_ALLOWRAW); if ($user != '' && $pass != '') { // Add credentials to the session if (JClientHelper::setCredentials($client, $user, $pass)) { $return = false; } else { $return =& JError::raiseWarning('SOME_ERROR_CODE', 'JClientHelper::setCredentialsFromRequest failed'); } } else { // Just determine if the FTP input fields need to be shown $return = !JClientHelper::hasCredentials('ftp'); } return $return; } } home/academiac/www/administrator/components/com_chronoforms/controller.php 0000604 00000125626 15137451463 0023366 0 ustar 00 <?php /** * CHRONOFORMS version 4.0 * Copyright (c) 2006 - 2011 Chrono_Man, ChronoEngine.com. All rights reserved. * Author: Chrono_Man (ChronoEngine.com) * @license GNU/GPL * Visit http://www.ChronoEngine.com for regular updates and information. **/ /* ensure that this file is not called from another file */ defined('_JEXEC') or die('Restricted access'); if(!class_exists('JParameter')){ class JParameter{ var $params = null; function __construct($string = ''){ if(is_array($string)){ $this->params = $string; }else{ $this->setParams($string); } } function get($k, $v = null){ if(array_key_exists($k, $this->params)){ return $this->params[$k]; }else{ return $v; } } function set($k, $v){ $this->params[$k] = $v; } function setParams($string = ''){ if(strlen(trim(($string))) > 0){ $data = json_decode($string, true); $this->params = $data; }else{ $this->params = array(); } } function toString(){ return json_encode($this->params); } function toArray(){ return $this->params; } function toObject(){ return json_decode(json_encode($this->params)); } } } class ChronoFormsAdmin extends JObject{ function __construct(){ } public static function admin_form(){ require_once(JPATH_SITE.DS.'components'.DS.'com_chronoforms'.DS.'libraries'.DS.'chronoform.php'); require_once(JPATH_SITE.DS.'components'.DS.'com_chronoforms'.DS.'chronoforms.html.php'); $formname = JRequest::getVar('chronoform', ''); $form_id = JRequest::getVar('form_id', ''); $event = JRequest::getVar('event'); if(empty($formname)){ if(empty($form_id)){ $mainframe->redirect("index.php?option=com_chronoforms", "Form doesn't exist!"); }else{ $row = JTable::getInstance('chronoforms', 'Table'); $row->load((int)$form_id); $formname = $row->name; //load some table data $database = JFactory::getDBO(); $table_name = $_POST['table_name']; $result = $database->getTableFields(array($table_name), false); $table_fields = $result[$table_name]; $primary = ''; foreach($table_fields as $table_field => $field_data){ if($field_data->Key == 'PRI'){ $primary = $table_field; } } if(empty($primary)){ JError::raiseWarning(100, "No table key found."); $mainframe->redirect("index.php?option=com_chronoforms"); } //get record data if(isset($_POST['cb']) && !empty($_POST['cb'])){ $_POST['cf_id'] = $_POST['cb'][0]; //load all selected records data $database->setQuery("SELECT * FROM ".$table_name." WHERE ".$primary." IN ('".implode("','", $_POST['cb'])."')"); $_POST['chronoform_data'] = $rows_data = $database->loadAssocList(); }else{ //JError::raiseWarning(100, "Invalid record."); //$mainframe->redirect("index.php?option=com_chronoforms"); } } } $form = CFChronoForm::getInstance($formname); $form->admin = true; //check if the event is the CSV export if($event == 'cf_csv_export'){ $csv_event = array( 'events' => array( 'cf_csv_export' => array( 'actions' => array( 'cfaction_csv_export_gh_9999' => array( 'events' => array( 'cfaction_csv_export_gh_9999_success' => array(), 'cfaction_csv_export_gh_9999_failed' => array() ) ) ) ) ) ); $form->form_details->events_actions_map = base64_encode(serialize($csv_event)); $csv_action_data = new stdClass(); $csv_action_data->type = 'csv_export_gh'; $csv_action_data->order = 9999; $csv_action_data->enabled = 1; $csv_action_params = new JParameter(''); $csv_action_params->set('download_export', 1); $csv_action_params->set('download_nosave', 1); $csv_action_data->params = $csv_action_params->toString(); $csv_action_data->content1 = ''; $form->form_actions[] = $csv_action_data; } $form->process($event); HTML_ChronoForms::processView($form); } public static function action_task(){ $mainframe = JFactory::getApplication(); $form_action = JRequest::getVar('action_name', ''); if(!empty($form_action)){ //load the action PHP file $action_file = JPATH_SITE.DS."administrator".DS."components".DS."com_chronoforms".DS.'form_actions'.DS.$form_action.DS.$form_action.'.php'; require_once($action_file); $actionclassname = preg_replace('/(?:^|_)(.?)/e', "strtoupper('$1')", 'cfaction_'.$form_action); if(class_exists($actionclassname)){ $actionclass = new $actionclassname; $fn = JRequest::getVar('fn', ''); if(!empty($fn)){ echo $actionclass->$fn(); } }else{ $action_params = array(); } }else{ echo ''; } $mainframe->close(); } public static function updates(){ if(JRequest::getVar('fn', '') != ''){ switch(JRequest::getVar('fn', '')){ case "db_updates": require_once(JPATH_SITE.DS."administrator".DS."components".DS."com_chronoforms".DS."versions".DS."db_updates.php"); ChronoFormsDbUpdates::updateDB(); break; default: break; } } HTML_Admin_ChronoForms::updates(); } public static function index(){ $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); //prepare the pagination $option = 'com_chronoforms'; $limit = $mainframe->getUserStateFromRequest($option.'.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); $limitstart = $mainframe->getUserStateFromRequest($option.'.limitstart', 'limitstart', 0, 'int'); //get apps $app = $mainframe->getUserStateFromRequest($option.'.app', 'select_app', '', 'string'); $apps = array('' => 'Default'); $database->setQuery("SELECT DISTINCT app FROM #__chronoforms"); $all = $database->loadObjectList(); foreach($all as $one){ if(!in_array($one->app, array_keys($apps))){ $apps[$one->app] = $one->app; } } // count entries $database->setQuery("SELECT count(*) FROM #__chronoforms WHERE `app` = '".$app."'"); //$database->setQuery("SELECT count(*) FROM #__chronoforms"); $total = $database->loadResult(); jimport('joomla.html.pagination'); $pageNav = new JPagination($total, $limitstart, $limit); //load forms data $val = ChronoFormsAdminVersion::__getValStatus(); $database->setQuery("SELECT * FROM #__chronoforms WHERE `app` = '".$app."' ORDER BY id LIMIT $pageNav->limitstart,$pageNav->limit"); //$database->setQuery("SELECT * FROM #__chronoforms ORDER BY id LIMIT $pageNav->limitstart,$pageNav->limit"); $forms = $database->loadObjectList(); if(!empty($forms)){ foreach($forms as $k => $form){ //load actions $query = "SELECT * FROM `#__chronoform_actions` WHERE `chronoform_id` = '".$form->id."' AND `enabled` = '1' ORDER BY `order`"; $database->setQuery($query); $forms[$k]->form_actions = $database->loadObjectList(); } } HTML_Admin_ChronoForms::index($forms, $pageNav, $apps, $val); } public static function publish($task = 'publish'){ if(isset($_POST['cb']) && !empty($_POST['cb'])){ $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); $published = ($task == 'publish') ? 1 : 0; $database->setQuery("UPDATE #__chronoforms SET published='".$published."' WHERE id='".$_POST['cb'][0]."'"); if(!$database->query()){ JError::raiseWarning(100, $database->getError()); $mainframe->redirect("index.php?option=com_chronoforms"); } $mainframe->redirect("index.php?option=com_chronoforms", "Updated successfully!"); } } public static function edit_form(){ $form = null; if(isset($_POST['cb']) && !empty($_POST['cb'])){ $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); $database->setQuery("SELECT * FROM #__chronoforms WHERE id='".$_POST['cb'][0]."'"); $form = $database->loadObject(); if(!empty($form)){ //load actions $query = "SELECT * FROM `#__chronoform_actions` WHERE `chronoform_id` = '".$form->id."' AND `enabled` = '1' ORDER BY `order`"; $database->setQuery($query); $form->form_actions = $database->loadObjectList(); } } HTML_Admin_ChronoForms::edit($form); } public static function save_form($task = 'save'){ $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); $row = JTable::getInstance('chronoforms', 'Table'); if(isset($_POST['params']) && !empty($_POST['params']) && is_array($_POST['params'])){ $params = new JParameter(''); foreach($_POST['params'] as $k => $v){ if(is_array($v)){ $v = implode(",", $v); } $params->set($k, $v); } $_POST['params'] = $params->toString(); } $post = JRequest::get('post', JREQUEST_ALLOWRAW); if(!$row->bind($post)){ JError::raiseWarning(100, $row->getError()); $mainframe->redirect("index.php?option=com_chronoforms"); } if(!$row->store()){ JError::raiseWarning(100, $row->getError()); $mainframe->redirect("index.php?option=com_chronoforms"); } if($task == 'apply'){ if(isset($row->id) && !empty($row->id)){ $database->setQuery("SELECT * FROM #__chronoforms WHERE id='".$row->id."'"); $form = $database->loadObject(); } $_POST['cb'] = array($row->id); ChronoFormsAdmin::edit_form(); //HTML_Admin_ChronoForms::edit($form); }else{ $mainframe->redirect("index.php?option=com_chronoforms", "Form '".$row->name."' has been saved successfully."); } } public static function delete_temp(){ $database = JFactory::getDBO(); $database->setQuery("SELECT `id` FROM #__chronoforms WHERE `app` = '__TMP__'"); $cbs = $database->loadResultArray(); if(is_array($cbs)){ //$this->delete_form($cbs); } } public static function delete_form($cbs = array()){ $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); //delete the form with all its actions if(empty($cbs)){ if(isset($_POST['cb']) && !empty($_POST['cb'])){ $cbs = $_POST['cb']; } } if(isset($cbs) && !empty($cbs)){ foreach($cbs as $form_id){ $database->setQuery("DELETE FROM #__chronoforms WHERE id='".$form_id."'"); if(!$database->query()){ JError::raiseWarning(100, $database->getErrorMsg()); $mainframe->redirect("index.php?option=com_chronoforms"); } $database->setQuery("DELETE FROM #__chronoform_actions WHERE chronoform_id='".$form_id."'"); if(!$database->query()){ JError::raiseWarning(100, $database->getErrorMsg()); $mainframe->redirect("index.php?option=com_chronoforms"); } } } $mainframe->redirect("index.php?option=com_chronoforms", "Deleted successfully."); } public static function copy_form(){ $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); $row = JTable::getInstance('chronoforms', 'Table'); if(isset($_POST['cb']) && !empty($_POST['cb'])){ $row->load($_POST['cb'][0]); $row->id = ''; $row->name = $row->name."-Copy"; if(!$row->store()){ JError::raiseWarning(100, $row->getError()); $mainframe->redirect("index.php?option=com_chronoforms"); } //copy actions as well $new_id = $row->id; unset($row); $query = "SELECT `id` FROM `#__chronoform_actions` WHERE `chronoform_id` = '".$_POST['cb'][0]."'"; $database->setQuery($query); $row_ids = $database->loadResultArray(); foreach($row_ids as $id){ $row = JTable::getInstance('chronoformActions', 'Table'); $row->load($id); $row->id = ''; $row->chronoform_id = $new_id; if(!$row->store()){ JError::raiseWarning(100, $row->getError()); $mainframe->redirect("index.php?option=com_chronoforms"); } } } $mainframe->redirect("index.php?option=com_chronoforms", "Form(s) successfully copied."); } public static function backup_forms(){ $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); if(isset($_POST['cb']) && !empty($_POST['cb'])){ $output = ''; foreach($_POST['cb'] as $form_id){ $database->setQuery("SELECT * FROM #__chronoforms WHERE id='".$form_id."'"); $form = $database->loadAssoc(); $database->setQuery("SELECT * FROM #__chronoform_actions WHERE chronoform_id='".$form_id."' ORDER BY `order` ASC"); $formactions = $database->loadAssocList(); $output .= "<__FORM_START__><__FORM_ROW_START__>".base64_encode(serialize($form))."<__FORM_ROW_END__><__FORM_ACTIONS_START__>".base64_encode(serialize($formactions))."<__FORM_ACTIONS_END__><__FORM_END__>"."\n"; } //get the domain name $uri = JFactory::getURI(); preg_match('/http(s)*:\/\/(.*?)\//i', $uri->root(), $matches); $domain = $matches[2]; //download the file if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT'])) { $UserBrowser = "Opera"; } elseif (ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT'])) { $UserBrowser = "IE"; } else { $UserBrowser = ''; } $mime_type = ($UserBrowser == 'IE' || $UserBrowser == 'Opera') ? 'application/octetstream' : 'application/octet-stream'; @ob_end_clean(); ob_start(); header('Content-Type: ' . $mime_type); header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); if ($UserBrowser == 'IE') { header('Content-Disposition: inline; filename="' . "CFV4_FormsBackup_ON_".$domain."_".date('d_M_Y_H:i:s').'.cf4bak"'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else { header('Content-Disposition: attachment; filename="' . "CFV4_FormsBackup_ON_".$domain."_".date('d_M_Y_H:i:s').'.cf4bak"'); header('Pragma: no-cache'); } print $output; exit(); } } public static function restore_forms(){ $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); jimport('joomla.utilities.error'); jimport('joomla.filesystem.file'); $files = $_FILES; if(is_array($files) && !empty($files)){ //the file has been uploaded $file = $files['file']; $filename = $file['name']; $exten = explode(".", $filename); if($exten[count($exten)-1] == 'cf4bak'){ $path = JPATH_BASE.DS.'cache'; $uploadedfile = JFile::upload($file['tmp_name'], $path.DS.$filename); if(!$uploadedfile){ JError::raiseWarning(100, "UPLAOD FAILED".": ".$file['error']); $mainframe->redirect("index.php?option=com_chronoforms"); }else{ ChronoFormsAdmin::restore_forms_from_file($path.DS.$filename); $mainframe->redirect("index.php?option=com_chronoforms", "Forms restored successfully."); } }else{ //wrong file extension JError::raiseWarning(100, "The file uploaded was not a Chronoforms V4 forms backup file."); $mainframe->redirect("index.php?option=com_chronoforms"); } }else{ //no file, render the upload page HTML_Admin_ChronoForms::restore_forms(); } } public static function restore_forms_from_file($bak_file_path, $replacers = array()){ $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); $data = file_get_contents($bak_file_path); //preg_match_all('/<__FORM_START__>(.*?)<__FORM_END__>/is', $data, $forms_data); $data = trim($data); $forms_data = explode("\n", $data); if(!empty($data) && !empty($forms_data)){ //loop through each form backup line foreach($forms_data as $form_data){ $form_data = str_replace(array('<__FORM_START__>', '<__FORM_END__>'), '', $form_data); //get form row data $form_row_data = explode('<__FORM_ROW_END__>', $form_data); //get actions data string with tags $form_actions_data = $form_row_data[1]; //get form pure row code $form_row_data = str_replace('<__FORM_ROW_START__>', '', $form_row_data[0]); //decrypt the code and save it $form_row_data = unserialize(base64_decode($form_row_data)); if(!empty($replacers)){ $form_row_data = str_replace(array_keys($replacers), array_values($replacers), var_export($form_row_data, true)); eval('?>'.'<?php $form_row_data = '.$form_row_data.'; ?>'); } unset($form_row_data['id']); //unpublish old items with the same name $database->setQuery("UPDATE #__chronoforms SET published='0' WHERE `name` = '".$form_row_data['name']."'"); if(!$database->query()){ JError::raiseWarning(100, "Couldn't unpublish old items with the same name."); } //insert new items $row = JTable::getInstance('chronoforms', 'Table'); if(!$row->bind($form_row_data)){ JError::raiseWarning(100, $row->getError()); } if(!$row->store()){ JError::raiseWarning(100, $row->getError()); } $chronoform_id = $row->id; //get form actions rows pure code $form_actions_data = str_replace(array('<__FORM_ACTIONS_START__>', '<__FORM_ACTIONS_END__>'), '', $form_actions_data); //decrypt the code and save it $form_actions_data = unserialize(base64_decode($form_actions_data)); if(!empty($replacers)){ $form_actions_data = str_replace(array_keys($replacers), array_values($replacers), var_export($form_actions_data, true)); eval('?>'.'<?php $form_actions_data = '.$form_actions_data.'; ?>'); } foreach($form_actions_data as $form_action){ unset($form_action['id']); $form_action['chronoform_id'] = $chronoform_id; $row = JTable::getInstance('chronoformactions', 'Table'); if(!$row->bind($form_action)){ JError::raiseWarning(100, $row->getError()); } if(!$row->store()){ JError::raiseWarning(100, $row->getError()); } } } } return true; } public static function install_action(){ $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); jimport('joomla.utilities.error'); jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.archive'); $files = $_FILES; if(is_array($files) && !empty($files)){ //the file has been uploaded $file = $files['file']; $filename = $file['name']; $exten = explode(".", $filename); if($exten[count($exten)-1] == 'zip'){ $path = JPATH_BASE.DS.'cache'; $uploadedfile = JFile::upload($file['tmp_name'], $path.DS.$filename); if(!$uploadedfile){ JError::raiseWarning(100, "UPLAOD FAILED".": ".$file['error']); $mainframe->redirect("index.php?option=com_chronoforms"); }else{ $zipper = JArchive::getAdapter('zip'); if($zipper->extract($path.DS.$filename, $path.DS.$exten[0])){ //we could extract the file, copy if(JFolder::copy($path.DS.$exten[0].DS, JPATH_SITE.DS."administrator".DS."components".DS."com_chronoforms".DS."form_actions".DS, '', true) === true){ $mainframe->redirect("index.php?option=com_chronoforms", "Action installed successfully."); }else{ JError::raiseWarning(100, "Couldn't copy to the destination folder."); $mainframe->redirect("index.php?option=com_chronoforms"); } }else{ //failed JError::raiseWarning(100, "Couldn't extract the file provided."); $mainframe->redirect("index.php?option=com_chronoforms"); } } }else{ //wrong file extension JError::raiseWarning(100, "The file uploaded was not a Chronoforms V4 action installer file."); $mainframe->redirect("index.php?option=com_chronoforms"); } }else{ //no file, render the upload page HTML_Admin_ChronoForms::install_action(); } } public static function form_wizard($task = 'form_wizard'){ $mainframe = JFactory::getApplication(); $form = null; $formactions = null; if($task == 'form_wizard'){ if(isset($_POST['form_id']) || isset($_GET['form_id'])){ $form_id = isset($_POST['form_id']) ? (int)$_POST['form_id'] : (int)$_GET['form_id']; if($form_id > 0){ //load existing form $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); $database->setQuery("SELECT * FROM #__chronoforms WHERE id='".$form_id."'"); $form = $database->loadObject(); $database->setQuery("SELECT * FROM #__chronoform_actions WHERE chronoform_id='".$form_id."' ORDER BY `order` ASC"); $formactions = $database->loadObjectList(); //print_r2(unserialize(base64_decode($form->events_actions_map))); } }else{ if(!empty($_POST)){ ChronoFormsAdmin::_save_form_wizard(); $mainframe->redirect("index.php?option=com_chronoforms", "Form '".$_POST['data']['Chronoform']['name']."' has been saved successfully."); } } }else{ //apply task if(!empty($_POST)){ $form_id = isset($_POST['data']['Chronoform']['id']) ? (int)$_POST['data']['Chronoform']['id'] : (int)$_GET['form_id']; $save_id = ChronoFormsAdmin::_save_form_wizard(); if(!$form_id){ $form_id = $save_id; } if(isset($_POST['save_mode']) && $_POST['save_mode'] == 'preview'){ //do nothing }else{ $mainframe->redirect("index.php?option=com_chronoforms&task=form_wizard&form_id=".$form_id, "Changes applied successfully."); } } } HTML_Admin_ChronoForms::form_wizard($form, $formactions); } public static function list_data(){ $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); if(isset($_POST['cb']) && !empty($_POST['cb'])){ $index = $_POST['cb'][0]; $_POST['table_name'] = $_POST['table_name'][$index]; $_POST['form_id'] = $index; } if((isset($_POST['table_name']) && !empty($_POST['table_name'])) || (isset($_GET['table_name']) && !empty($_GET['table_name']))){ $table_name = isset($_POST['table_name']) ? $_POST['table_name'] : $_GET['table_name']; //load some table data $result = $database->getTableFields(array($table_name), false); $table_fields = $result[$table_name]; $primary = ''; foreach($table_fields as $table_field => $field_data){ if($field_data->Key == 'PRI'){ $primary = $table_field; } } //prepare the pagination $option = 'com_chronoforms.'.$table_name; $limit = $mainframe->getUserStateFromRequest($option.'.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); $limitstart = $mainframe->getUserStateFromRequest($option.'.limitstart', 'limitstart', 0, 'int'); // count entries $database->setQuery("SELECT count(*) FROM `".$table_name."`"); $total = $database->loadResult(); jimport('joomla.html.pagination'); if($limitstart > $total)$limitstart = 0; $pageNav = new JPagination($total, $limitstart, $limit); //load the data $query = "SELECT * FROM `".$table_name."`"; if(!empty($primary)){ $query .= " ORDER BY ".$primary; } $query .= " LIMIT $pageNav->limitstart,$pageNav->limit"; $database->setQuery($query); $table_data = $database->loadObjectList(); HTML_Admin_ChronoForms::list_data($table_name, $table_fields, $table_data, $pageNav); }else{ JError::raiseWarning(100, "No tables were selected."); $mainframe->redirect("index.php?option=com_chronoforms"); } } public static function show_data(){ $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); if((isset($_POST['table_name']) && !empty($_POST['table_name'])) || (isset($_GET['table_name']) && !empty($_GET['table_name']))){ $table_name = isset($_POST['table_name']) ? $_POST['table_name'] : $_GET['table_name']; //load some table data $result = $database->getTableFields(array($table_name), false); $table_fields = $result[$table_name]; $primary = ''; foreach($table_fields as $table_field => $field_data){ if($field_data->Key == 'PRI'){ $primary = $table_field; } } if(empty($primary)){ JError::raiseWarning(100, "No table key found."); $mainframe->redirect("index.php?option=com_chronoforms"); } //show data if(isset($_POST['cb']) && !empty($_POST['cb'])){ $database->setQuery("SELECT * FROM ".$table_name." WHERE ".$primary."='".$_POST['cb'][0]."'"); $row_data = $database->loadObject(); HTML_Admin_ChronoForms::show_data($table_name, $table_fields, $row_data); }else{ JError::raiseWarning(100, "Invalid record."); $mainframe->redirect("index.php?option=com_chronoforms"); } }else{ JError::raiseWarning(100, "Table doesn't exist!"); $mainframe->redirect("index.php?option=com_chronoforms"); } } public static function delete_data(){ $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); if((isset($_POST['table_name']) && !empty($_POST['table_name'])) || (isset($_GET['table_name']) && !empty($_GET['table_name']))){ $table_name = isset($_POST['table_name']) ? $_POST['table_name'] : $_GET['table_name']; //load some table data $result = $database->getTableFields(array($table_name), false); $table_fields = $result[$table_name]; $primary = ''; foreach($table_fields as $table_field => $field_data){ if($field_data->Key == 'PRI'){ $primary = $table_field; } } if(empty($primary)){ JError::raiseWarning(100, "No table key found."); $mainframe->redirect("index.php?option=com_chronoforms"); } //delete the form with all its actions if(isset($_POST['cb']) && !empty($_POST['cb'])){ foreach($_POST['cb'] as $r_id){ $database->setQuery("DELETE FROM ".$table_name." WHERE `".$primary."` = '".$r_id."'"); if(!$database->query()){ JError::raiseWarning(100, $database->getErrorMsg()); $mainframe->redirect("index.php?option=com_chronoforms"); } } } }else{ JError::raiseWarning(100, "Table doesn't exist!"); $mainframe->redirect("index.php?option=com_chronoforms"); } unset($_POST['cb']); ChronoFormsAdmin::list_data(); //$mainframe->redirect("index.php?option=com_chronoforms&task=list_data&table_name=".$table_name, "Deleted successfully."); } public static function create_table($task = 'create_table'){ $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); //switch task if($task == 'save_table'){ if(isset($_POST['field_name']) && !empty($_POST['field_name']) && !empty($_POST['_cf_table_name'])){ $create = array("CREATE TABLE IF NOT EXISTS `".$_POST['_cf_table_name']."` ("); $primary_key = ""; foreach($_POST['field_name'] as $k => $name){ $name = trim($name); if(!empty($name) && isset($_POST['enabled'][$k]) && ((int)$_POST['enabled'][$k] == 1)){ $length = ""; if(!empty($_POST['field_length'][$k])){ $length = "(".$_POST['field_length'][$k].")"; } $default = ""; if(!isset($_POST['nulled'][$k])){ $default = " NOT NULL"; } if(!empty($_POST['field_default'][$k])){ $default .= " default '".$_POST['field_default'][$k]."'"; } $extra = ""; if(!empty($_POST['field_extra'][$k])){ $extra = " ".$_POST['field_extra'][$k]; } $create[] = "`".$name."` ".$_POST['field_type'][$k].$length.$default.$extra.","; if(isset($_POST['field_key'][$k]) && (int)$_POST['field_key'][$k] == 1){ $primary_key = "PRIMARY KEY (`".$name."`)"; } } } if(!empty($primary_key)){ $create[] = $primary_key; } $create[] = ");"; $create = implode("\n", $create); $database->setQuery($create); if(!$database->query()){ JError::raiseWarning(100, $database->getError()."<br /><br />Check table query below:<br /><br />".$create); $mainframe->redirect("index.php?option=com_chronoforms"); } $mainframe->redirect("index.php?option=com_chronoforms", "Table successfully created."); } }else{ $row = JTable::getInstance('chronoforms', 'Table'); if(isset($_POST['cb']) && !empty($_POST['cb'])){ $row->load($_POST['cb'][0]); $form_code = $row->content; $fields_names = ChronoFormsAdmin::_getFormFieldsNames($form_code); }else{ JError::raiseWarning(100, 'Invalid record!'); $mainframe->redirect("index.php?option=com_chronoforms"); } $defaults = array( 'cf_id' => array('type' => 'INT', 'length' => '11', 'default' => '', 'key' => 'PRI', 'extra' => 'auto_increment', 'enabled' => 1), 'cf_uid' => array('type' => 'VARCHAR', 'length' => '255', 'default' => '', 'key' => '', 'extra' => '', 'enabled' => 1), 'cf_created' => array('type' => 'DATETIME', 'length' => '', 'default' => '', 'key' => '', 'extra' => '', 'enabled' => 1), 'cf_modified' => array('type' => 'DATETIME', 'length' => '', 'default' => '', 'key' => '', 'extra' => '', 'enabled' => 1), 'cf_created_by' => array('type' => 'INT', 'length' => '11', 'default' => '', 'key' => '', 'extra' => '', 'enabled' => 1), 'cf_modified_by' => array('type' => 'INT', 'length' => '11', 'default' => '', 'key' => '', 'extra' => '', 'enabled' => 1), 'cf_ipaddress' => array('type' => 'VARCHAR', 'length' => '255', 'default' => '', 'key' => '', 'extra' => '', 'enabled' => 1), 'cf_user_id' => array('type' => 'INT', 'length' => '11', 'default' => '', 'key' => '', 'extra' => '', 'enabled' => 1) ); foreach($fields_names as $name){ if($name != 'cf_id'){ $defaults[$name] = array('type' => 'VARCHAR', 'length' => '255', 'default' => '', 'key' => '', 'extra' => '', 'enabled' => 1); } } } HTML_Admin_ChronoForms::create_table($row, $defaults); } function _getFormFieldsNames($form_code){ $fields_names = array(); $pattern_input = '/name=("|\')([^(>|"|\')]*?)("|\')/i'; preg_match_all($pattern_input, $form_code, $matches); foreach($matches[2] as $match){ if(strpos($match, '[]')){ $match = str_replace('[]', '', $match); } $fields_names[] = trim($match); } $fields_names = array_unique($fields_names); return $fields_names; } public static function wizard_preview(){ $formdata = array(); if(!empty($_POST['chronofield'])){ foreach($_POST['chronofield'] as $key => $fielddata){ $formdata['field_'.$key] = array(); foreach($fielddata as $fieldname => $fieldvalue){ $formdata['field_'.$key][$fieldname] = $fieldvalue; } } } $content = ChronoFormsAdmin::_processWizardCode($formdata); ob_start(); eval('?>'.$content); $content = ob_get_clean(); echo $content; $mainframe = JFactory::getApplication(); $mainframe->close(); } function _save_form_wizard(){ //generate XML code for the form $chronoform = array(); $formdata = array(); if(!empty($_POST['chronofield'])){ foreach($_POST['chronofield'] as $key => $fielddata){ $formdata['field_'.$key] = array(); foreach($fielddata as $fieldname => $fieldvalue){ $formdata['field_'.$key][$fieldname] = $fieldvalue; } } } //if easy mode, load the preset events actions if(isset($_POST['wizard_mode']) && $_POST['wizard_mode'] == 'easy'){ $_POST['chronoaction'][3] = array('type' => 'show_html'); $_POST['chronoaction'][5] = array('type' => 'event_loop'); $_POST['chronoaction'][7] = array('type' => 'event_loop'); $_POST['chronoaction'][16] = array('type' => 'handle_arrays'); } //prepare the actions details for the model $formactionsdata = array(); $action_count = 0; if(!empty($_POST['chronoaction'])){ foreach($_POST['chronoaction'] as $key => $actiondata){ $type = $_data['ChronoformAction'][$action_count]['type'] = $actiondata['type']; $_data['ChronoformAction'][$action_count]['order'] = $key; if(isset($actiondata['action_'.$actiondata['type'].'_'.$key.'_enabled'])){ $_data['ChronoformAction'][$action_count]['enabled'] = $actiondata['action_'.$actiondata['type'].'_'.$key.'_enabled']; unset($actiondata['action_'.$actiondata['type'].'_'.$key.'_enabled']); }else{ $_data['ChronoformAction'][$action_count]['enabled'] = 1; } //$_data['ChronoformAction'][$action_count]['event'] = $actiondata['action_'.$actiondata['type'].'_'.$key.'_event']; //unset($actiondata['action_'.$actiondata['type'].'_'.$key.'_event']); if(isset($actiondata['action_'.$actiondata['type'].'_'.$key.'_content1'])){ $_data['ChronoformAction'][$action_count]['content1'] = $actiondata['action_'.$actiondata['type'].'_'.$key.'_content1']; unset($actiondata['action_'.$actiondata['type'].'_'.$key.'_content1']); } unset($actiondata['type']); foreach($actiondata as $actionname => $actionvalue){ $actiondata[str_replace('action_'.$type.'_'.$key.'_', '', $actionname)] = $actionvalue; unset($actiondata[$actionname]); } $_data['ChronoformAction'][$action_count]['params'] = $actiondata; $action_count++; } } $chronoform['formcode'] = $formdata; /*print_r2($_data); die(); /*echo '<pre>'; print_r($formdata); print_r($_data); print_r($_POST['_form_actions_events_map']); echo '</pre>';*/ //save form $mainframe = JFactory::getApplication(); $database = JFactory::getDBO(); $row = JTable::getInstance('chronoforms', 'Table'); if(isset($_POST['data']['Chronoform']['id']) && !empty($_POST['data']['Chronoform']['id'])){ $_data['Chronoform']['id'] = $_POST['data']['Chronoform']['id']; if(isset($_POST['wizard_mode'])){// && $_POST['wizard_mode'] == 'easy'){ //load the form $database = JFactory::getDBO(); $database->setQuery("SELECT * FROM #__chronoforms WHERE id='".$_data['Chronoform']['id']."'"); $form = $database->loadObject(); //$_data['Chronoform']['params'] = 'form_mode='.$_POST['wizard_mode'].''."\n".trim($form->params)."\n".'form_mode='.$_POST['wizard_mode']; $form_params = new JParameter($form->params); $form_params->set('form_mode', $_POST['wizard_mode']); $form_params->set('tight_layout', $_POST['params']['tight_layout']); $_data['Chronoform']['params'] = $form_params->toString(); } }else{ $_data['Chronoform']['form_type'] = 1; //this is a new form, set it as WIZARD form if(isset($_POST['wizard_mode'])){// && $_POST['wizard_mode'] == 'easy'){ //$_data['Chronoform']['params'] = 'form_mode='.$_POST['wizard_mode']; $form_params = new JParameter(''); $form_params->set('form_mode', $_POST['wizard_mode']); $form_params->set('tight_layout', $_POST['params']['tight_layout']); $_data['Chronoform']['params'] = $form_params->toString(); } } $_POST['data']['Chronoform']['name'] = $_data['Chronoform']['name'] = $_POST['chronoform_name']; $_data['Chronoform']['published'] = $_POST['chronoform_published']; $_data['Chronoform']['app'] = $_POST['data']['Chronoform']['app']; if(isset($_POST['form_type']) && (int)$_POST['form_type'] != 0){ $_data['Chronoform']['content'] = ChronoFormsAdmin::_processWizardCode($formdata); $_data['Chronoform']['wizardcode'] = var_export($formdata, true); /*if(strpos($form->form_details->content, 'validate[') !== false){ }*/ } //get the actions events map $_data['Chronoform']['events_actions_map'] = base64_encode(serialize($_POST['_form_actions_events_map']['myform'])); //if easy mode, load the preset events map if(isset($_POST['wizard_mode']) && $_POST['wizard_mode'] == 'easy'){ $_data['Chronoform']['events_actions_map'] = "YToxOntzOjY6ImV2ZW50cyI7YToyOntzOjQ6ImxvYWQiO2E6MTp7czo3OiJhY3Rpb25zIjthOjQ6e3M6MTg6ImNmYWN0aW9uX2xvYWRfanNfMCI7czowOiIiO3M6MTk6ImNmYWN0aW9uX2xvYWRfY3NzXzEiO3M6MDoiIjtzOjIzOiJjZmFjdGlvbl9sb2FkX2NhcHRjaGFfMiI7czowOiIiO3M6MjA6ImNmYWN0aW9uX3Nob3dfaHRtbF8zIjtzOjA6IiI7fX1zOjY6InN1Ym1pdCI7YToxOntzOjc6ImFjdGlvbnMiO2E6MTI6e3M6MjQ6ImNmYWN0aW9uX2NoZWNrX2NhcHRjaGFfNCI7YToxOntzOjY6ImV2ZW50cyI7YToyOntzOjM3OiJjZmFjdGlvbmV2ZW50X2NoZWNrX2NhcHRjaGFfNF9zdWNjZXNzIjtzOjA6IiI7czozNDoiY2ZhY3Rpb25ldmVudF9jaGVja19jYXB0Y2hhXzRfZmFpbCI7YToxOntzOjc6ImFjdGlvbnMiO2E6MTp7czoyMToiY2ZhY3Rpb25fZXZlbnRfbG9vcF81IjtzOjA6IiI7fX19fXM6MjM6ImNmYWN0aW9uX3VwbG9hZF9maWxlc182IjthOjE6e3M6NjoiZXZlbnRzIjthOjI6e3M6MzY6ImNmYWN0aW9uZXZlbnRfdXBsb2FkX2ZpbGVzXzZfc3VjY2VzcyI7czowOiIiO3M6MzM6ImNmYWN0aW9uZXZlbnRfdXBsb2FkX2ZpbGVzXzZfZmFpbCI7YToxOntzOjc6ImFjdGlvbnMiO2E6MTp7czoyMToiY2ZhY3Rpb25fZXZlbnRfbG9vcF83IjtzOjA6IiI7fX19fXM6MjI6ImNmYWN0aW9uX2N1c3RvbV9jb2RlXzgiO3M6MDoiIjtzOjI1OiJjZmFjdGlvbl9oYW5kbGVfYXJyYXlzXzE2IjtzOjA6IiI7czoxODoiY2ZhY3Rpb25fZGJfc2F2ZV85IjtzOjA6IiI7czoxNzoiY2ZhY3Rpb25fZW1haWxfMTAiO3M6MDoiIjtzOjE3OiJjZmFjdGlvbl9lbWFpbF8xMSI7czowOiIiO3M6MTc6ImNmYWN0aW9uX2VtYWlsXzEyIjtzOjA6IiI7czoyMzoiY2ZhY3Rpb25fY3VzdG9tX2NvZGVfMTMiO3M6MDoiIjtzOjMxOiJjZmFjdGlvbl9zaG93X3RoYW5rc19tZXNzYWdlXzE0IjtzOjA6IiI7czoyNToiY2ZhY3Rpb25fcmVkaXJlY3RfdXNlcl8yMCI7czowOiIiO3M6MjA6ImNmYWN0aW9uX2RlYnVnZ2VyXzE4IjtzOjA6IiI7fX19fQ=="; } if(!$row->bind($_data['Chronoform'])){ JError::raiseWarning(100, $row->getError()); $mainframe->redirect("index.php?option=com_chronoforms"); } if(!$row->store()){ JError::raiseWarning(100, $row->getError()); $mainframe->redirect("index.php?option=com_chronoforms"); } $chronoform_id = $row->id; //save actions if(isset($_data['ChronoformAction']) && !empty($_data['ChronoformAction'])){ //delete previous actions to save new ones if(isset($_POST['data']['Chronoform']['id']) && !empty($_POST['data']['Chronoform']['id'])){ $database->setQuery("DELETE FROM #__chronoform_actions WHERE chronoform_id='".$_POST['data']['Chronoform']['id']."'"); if(!$database->query()){ JError::raiseWarning(100, $row->getError()); $mainframe->redirect("index.php?option=com_chronoforms"); } } //save all new actions foreach($_data['ChronoformAction'] as $action){ $row = JTable::getInstance('chronoformactions', 'Table'); $action['chronoform_id'] = $chronoform_id; $params = new JParameter(''); if(isset($action['params']) && is_array($action['params'])){ foreach($action['params'] as $k => $param){ $params->set($k, $param); } $action['params'] = $params->toString(); } if(!$row->bind($action)){ JError::raiseWarning(100, $row->getError()); $mainframe->redirect("index.php?option=com_chronoforms"); } if(!$row->store()) { JError::raiseWarning(100, $row->getError()); $mainframe->redirect("index.php?option=com_chronoforms"); } } } return $chronoform_id; } function _processWizardCode($formdata){ $content = ''; require_once(JPATH_SITE.DS."administrator".DS."components".DS."com_chronoforms".DS."helpers".DS."html_helper.php"); $HtmlHelper = new HtmlHelper(); foreach($formdata as $formdata_key => $formdata_element){ $field_header = $formdata_element['tag'].'_'.$formdata_element['type'].'_'.str_replace('field_', '', $formdata_key); $formcontent_item_array = array(); $field_name = ''; if(isset($formdata_element[$field_header.'_input_name'])){ $field_name = $formdata_element[$field_header.'_input_name']; } //disable label if empty if(isset($formdata_element[$field_header.'_label_text']) && strlen($formdata_element[$field_header.'_label_text'])){ $formcontent_item_array['label'] = $formdata_element[$field_header.'_label_text']; }else{ $formcontent_item_array['label'] = false; } switch($formdata_element['type']){ default: $process = true; $file_name = 'input_'.$formdata_element['type']; if(file_exists(JPATH_SITE.DS."administrator".DS."components".DS."com_chronoforms".DS.'form_elements'.DS.$file_name.'.php')){ require_once(JPATH_SITE.DS."administrator".DS."components".DS."com_chronoforms".DS.'form_elements'.DS.$file_name.'.php'); $elementclassname = preg_replace('/(?:^|_)(.?)/e', "strtoupper('$1')", 'chrono_forms_'.$file_name); if(class_exists($elementclassname)){ $elementclass = new $elementclassname; $methods = get_class_methods($elementclass); if(in_array('save', $methods)){ $formcontent_item_array = $elementclass->save($formdata_element, $field_header, $formcontent_item_array); $process = false; } } } if($process){ if(isset($formdata_element[$field_header.'_input_id'])){ $formcontent_item_array['id'] = $formdata_element[$field_header.'_input_id']; unset($formdata_element[$field_header.'_input_id']); } if(isset($formdata_element[$field_header.'_input_value'])){ $formcontent_item_array['default'] = $formdata_element[$field_header.'_input_value']; unset($formdata_element[$field_header.'_input_value']); } if(isset($formdata_element[$field_header.'_input_maxlength'])){ $formcontent_item_array['maxlength'] = $formdata_element[$field_header.'_input_maxlength']; unset($formdata_element[$field_header.'_input_maxlength']); } if(isset($formdata_element[$field_header.'_input_size'])){ $formcontent_item_array['size'] = $formdata_element[$field_header.'_input_size']; unset($formdata_element[$field_header.'_input_size']); } if(isset($formdata_element[$field_header.'_input_class'])){ $formcontent_item_array['class'] = $formdata_element[$field_header.'_input_class']; unset($formdata_element[$field_header.'_input_class']); } if(isset($formdata_element[$field_header.'_input_title'])){ $formcontent_item_array['title'] = $formdata_element[$field_header.'_input_title']; unset($formdata_element[$field_header.'_input_title']); } if(isset($formdata_element[$field_header.'_label_over'])){ $formcontent_item_array['label_over'] = $formdata_element[$field_header.'_label_over']; unset($formdata_element[$field_header.'_label_over']); } if(isset($formdata_element[$field_header.'_hide_label'])){ $formcontent_item_array['hide_label'] = $formdata_element[$field_header.'_hide_label']; unset($formdata_element[$field_header.'_hide_label']); } if(isset($formdata_element[$field_header.'_validations'])){ $formcontent_item_array['validations'] = $formdata_element[$field_header.'_validations']; unset($formdata_element[$field_header.'_validations']); } if(isset($formdata_element[$field_header.'_instructions'])){ $formcontent_item_array['smalldesc'] = $formdata_element[$field_header.'_instructions']; unset($formdata_element[$field_header.'_instructions']); } if(isset($formdata_element[$field_header.'_tooltip'])){ $formcontent_item_array['tooltip'] = $formdata_element[$field_header.'_tooltip']; unset($formdata_element[$field_header.'_tooltip']); } if(isset($formdata_element['real_type'])){ $formcontent_item_array['type'] = $formdata_element['real_type']; unset($formdata_element['real_type']); unset($formdata_element['type']); unset($formdata_element['tag']); } //unset the name and the label unset($formdata_element[$field_header.'_input_name']); unset($formdata_element[$field_header.'_label_text']); //load the field params array foreach($formdata_element as $k => $v){ $formcontent_item_array[str_replace($field_header.'_', '', $k)] = $formdata_element[$k]; } $formcontent_item_array['wf_key'] = str_replace('field_', '', $formdata_key); } $formcontent_item_array['container_id'] = $formdata_element['container_id']; break; } $content .= $HtmlHelper->input($field_name, $formcontent_item_array, true); } $content .= $HtmlHelper->input('empty', array('type' => 'empty', 'container_id' => 9999999), true); return $content; } public static function validationconnect($type, $host, $port='80', $path='/', $data=array()) { $mainframe = JFactory::getApplication(); $_err = 'lib sockets::'.__FUNCTION__.'(): '; $str = ''; $d = array(); //switch($type) { case 'http': $type = ''; case 'ssl': continue; default: die($_err.'bad $type'); } if(!empty($data)){ foreach($data as $k => $v){ $strarr[] = urlencode($k).'='.urlencode($v); } } $str = implode('&', $strarr); $result = ''; //echo $str; $fp = fsockopen($host, $port, $errno, $errstr, 30); if(!$fp){ //$mainframe->redirect( "index.php?option=com_chronoforms", $_err.$errstr.$errno); $result = 'error'; //die($_err.$errstr.$errno); }else{ fputs($fp, "POST $path HTTP/1.1\r\n"); fputs($fp, "Host: $host\r\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: ".strlen($str)."\r\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $str."\r\n\r\n"); while(!feof($fp)){ $d[] = fgets($fp,4096); } fclose($fp); $result = $d[count($d) - 1]; } return $result; } } ?>