/** * Execute the controller. * * @return void * * @since 3.1 */ public function execute() { // Get the application /* @var InstallationApplicationWeb $app */ $app = $this->getApplication(); // Check for request forgeries. JSession::checkToken() or $app->sendJsonResponse(new Exception(JText::_('JINVALID_TOKEN'), 403)); // Get the setup model. $model = new InstallationModelSetup(); // Check the form $vars = $model->checkForm('database'); // Determine if the configuration file path is writable. $path = JPATH_CONFIGURATION . '/configuration.php'; $useftp = file_exists($path) ? !is_writable($path) : !is_writable(JPATH_CONFIGURATION . '/'); $r = new stdClass(); $r->view = $useftp ? 'ftp' : 'summary'; // Get the database model. $db = new InstallationModelDatabase(); // Attempt to initialise the database. $return = $db->createDatabase($vars); // Check if the database was initialised if (!$return) { $r->view = 'database'; } $app->sendJsonResponse($r); }
/** * Execute the controller. * * @return void * * @since 3.1 */ public function execute() { // Get the application /* @var InstallationApplicationWeb $app */ $app = $this->getApplication(); // Check for request forgeries. JSession::checkToken() or $app->sendJsonResponse(new Exception(JText::_('JINVALID_TOKEN'), 403)); // Get the setup model. $model = new InstallationModelSetup(); // Get the data $data = $app->input->post->get('jform', array(), 'array'); // Store the options in the session. $vars = $model->storeOptions($data); // Get the database model. $ftp = new InstallationModelFtp(); // Attempt to detect the Joomla root from the ftp account. $return = $ftp->verifyFtpSettings($vars); // Build the response object $r = new stdClass(); $r->view = 'ftp'; // If we got a FTP root, add it to the response object if ($return) { $r->valid = $return; } $app->sendJsonResponse($r); }
/** * Method to get the field options. * * @return array The field option objects. * * @since 1.6 */ protected function getOptions() { $app = JFactory::getApplication(); // Detect the native language. $native = JLanguageHelper::detectLanguage(); if (empty($native)) { $native = 'en-GB'; } // Get a forced language if it exists. $forced = $app->getLocalise(); if (!empty($forced['language'])) { $native = $forced['language']; } // If a language is already set in the session, use this instead $model = new InstallationModelSetup(); $options = $model->getOptions(); if (isset($options['language'])) { $native = $options['language']; } // Get the list of available languages. $options = JLanguageHelper::createLanguageList($native); if (!$options || $options instanceof Exception) { $options = array(); } else { usort($options, array($this, '_sortLanguages')); } // Set the default value from the native language. $this->value = $native; // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
/** * Method to render the view. * * @return string The rendered view. * * @since 3.1 */ public function render() { $this->options = $this->model->getOptions(); // Get the config string from the session. $this->config = JFactory::getSession()->get('setup.config', null); return parent::render(); }
/** * Execute the controller. * * @return void * * @since 3.1 */ public function execute() { // Get the application /* @var InstallationApplicationWeb $app */ $app = $this->getApplication(); // Check for request forgeries. JSession::checkToken() or $app->sendJsonResponse(new Exception(JText::_('JINVALID_TOKEN'), 403)); // Get the setup model. $model = new InstallationModelSetup(); // Check the form $model->checkForm('site'); // Redirect to the page. $r = new stdClass(); $r->view = 'database'; $app->sendJsonResponse($r); }
/** * Method to render the view. * * @return string The rendered view. * * @since 3.1 */ public function render() { $this->options = $this->model->getOptions(); /* * Prepare the tasks array * Note: The first character of the task *MUST* be capitalised or the application will not find the task */ $this->tasks[] = $this->options['db_old'] == 'remove' ? 'Database_remove' : 'Database_backup'; $this->tasks[] = 'Database'; if ($this->options['sample_file']) { $this->tasks[] = 'Sample'; } $this->tasks[] = 'Config'; if ($this->options['summary_email']) { $this->tasks[] = 'Email'; } return parent::render(); }
/** * Execute the controller. * * @return void * * @since 3.1 */ public function execute() { // Get the application /* @var InstallationApplicationWeb $app */ $app = $this->getApplication(); // Check for request forgeries. JSession::checkToken() or $app->sendJsonResponse(new Exception(JText::_('JINVALID_TOKEN'), 403)); // Very crude workaround to give an error message when JSON is disabled if (!function_exists('json_encode') || !function_exists('json_decode')) { $app->setHeader('status', 500); $app->setHeader('Content-Type', 'application/json; charset=utf-8'); $app->sendHeaders(); echo '{"token":"' . JSession::getFormToken(true) . '","lang":"' . JFactory::getLanguage()->getTag() . '","error":true,"header":"' . JText::_('INSTL_HEADER_ERROR') . '","message":"' . JText::_('INSTL_WARNJSON') . '"}'; $app->close(); } // Check for potentially unwritable session $session = JFactory::getSession(); if ($session->isNew()) { $this->sendResponse(new Exception(JText::_('INSTL_COOKIES_NOT_ENABLED'), 500)); } // Get the setup model. $model = new InstallationModelSetup(); // Get the posted values from the request and validate them. $data = $this->input->post->get('jform', array(), 'array'); $return = $model->validate($data, 'preinstall'); $r = new stdClass(); // Check for validation errors. if ($return === false) { /* * The validate method enqueued all messages for us, so we just need to * redirect back to the site setup screen. */ $r->view = $this->input->getWord('view', 'site'); $app->sendJsonResponse($r); } // Store the options in the session. $model->storeOptions($return); // Setup language $language = JFactory::getLanguage(); $language->setLanguage($return['language']); // Redirect to the page. $r->view = $this->input->getWord('view', 'site'); $app->sendJsonResponse($r); }
/** * Execute the controller. * * @return void * * @since 3.1 */ public function execute() { // Get the application /* @var InstallationApplicationWeb $app */ $app = $this->getApplication(); // Check for request forgeries. JSession::checkToken() or $app->sendJsonResponse(new Exception(JText::_('JINVALID_TOKEN'), 403)); // Get the setup model. $model = new InstallationModelSetup(); // Get the options from the session $options = $model->getOptions(); // Get the database model. $db = new InstallationModelDatabase(); // Attempt to create the database tables. $return = $db->createTables($options); $r = new stdClass(); $r->view = 'install'; // Check if the database was initialised if (!$return) { $r->view = 'database'; } $app->sendJsonResponse($r); }
/** * Method to render the view. * * @return string The rendered view. * * @since 3.1 */ public function render() { $this->form = $this->model->getForm(); return parent::render(); }
/** * Execute the controller. * * @return void * * @since 3.1 */ public function execute() { // Get the application /* @var InstallationApplicationWeb $app */ $app = $this->getApplication(); // Check for request forgeries. JSession::checkToken() or $app->sendJsonResponse(new Exception(JText::_('JINVALID_TOKEN'), 403)); // Get the setup model. $model = new InstallationModelSetup(); // Get the options from the session $options = $model->getOptions(); $name = $options['admin_user']; $email = $options['admin_email']; $subject = JText::sprintf(JText::_('INSTL_EMAIL_SUBJECT'), $options['site_name']); // Prepare email body $body = array(); $body[] = JText::sprintf(JText::_('INSTL_EMAIL_HEADING'), $options['site_name']); $body[] = ''; $body[] = array(JText::_('INSTL_SITE_NAME_LABEL'), $options['site_name']); $body[] = $this->emailTitle(JText::_('INSTL_COMPLETE_ADMINISTRATION_LOGIN_DETAILS')); $body[] = array(JText::_('JEMAIL'), $options['admin_email']); $body[] = array(JText::_('JUSERNAME'), $options['admin_user']); if ($options['summary_email_passwords']) { $body[] = array(JText::_('INSTL_ADMIN_PASSWORD_LABEL'), $options['admin_password']); } $body[] = $this->emailTitle(JText::_('INSTL_DATABASE')); $body[] = array(JText::_('INSTL_DATABASE_TYPE_LABEL'), $options['db_type']); $body[] = array(JText::_('INSTL_DATABASE_HOST_LABEL'), $options['db_host']); $body[] = array(JText::_('INSTL_DATABASE_USER_LABEL'), $options['db_user']); if ($options['summary_email_passwords']) { $body[] = array(JText::_('INSTL_DATABASE_PASSWORD_LABEL'), $options['db_pass']); } $body[] = array(JText::_('INSTL_DATABASE_NAME_LABEL'), $options['db_name']); $body[] = array(JText::_('INSTL_DATABASE_PREFIX_LABEL'), $options['db_prefix']); if (isset($options['ftp_enable']) && $options['ftp_enable']) { $body[] = $this->emailTitle(JText::_('INSTL_FTP')); $body[] = array(JText::_('INSTL_FTP_USER_LABEL'), $options['ftp_user']); if ($options['summary_email_passwords']) { $body[] = array(JText::_('INSTL_FTP_PASSWORD_LABEL'), $options['ftp_pass']); } $body[] = array(JText::_('INSTL_FTP_HOST_LABEL'), $options['ftp_host']); $body[] = array(JText::_('INSTL_FTP_PORT_LABEL'), $options['ftp_port']); } $max = 0; foreach ($body as $line) { if (is_array($line)) { $max = max(array($max, strlen($line['0']))); } } foreach ($body as $i => $line) { if (is_array($line)) { $label = $line['0']; $label .= ': ' . str_repeat(' ', $max - strlen($label)); $body[$i] = $label . $line['1']; } } $body = implode("\r\n", $body); $mail = JFactory::getMailer(); $mail->addRecipient($email); $mail->addReplyTo($email, $name); $mail->setSender(array($email, $name)); $mail->setSubject($subject); $mail->setBody($body); $r = new stdClass(); $r->view = 'install'; try { $mail->Send(); } catch (Exception $e) { $app->enqueueMessage(JText::_('INSTL_EMAIL_NOT_SENT'), 'notice'); $r->view = 'complete'; } $app->sendJsonResponse($r); }
/** * Execute the controller. * * @return string The rendered view. * * @since 3.1 */ public function execute() { // Get the application /* @var InstallationApplicationWeb $app */ $app = $this->getApplication(); // Get the document object. $document = $app->getDocument(); // Set the default view name and format from the request. if (file_exists(JPATH_CONFIGURATION . '/configuration.php') && filesize(JPATH_CONFIGURATION . '/configuration.php') > 10 && file_exists(JPATH_INSTALLATION . '/index.php')) { $default_view = 'remove'; } else { $default_view = 'site'; } $vName = $this->input->getWord('view', $default_view); $vFormat = $document->getType(); $lName = $this->input->getWord('layout', 'default'); if (strcmp($vName, $default_view) == 0) { $this->input->set('view', $default_view); } switch ($vName) { case 'preinstall': $model = new InstallationModelSetup(); $sufficient = $model->getPhpOptionsSufficient(); $checkOptions = false; $options = $model->getOptions(); if ($sufficient) { $app->redirect('index.php'); } break; case 'languages': case 'defaultlanguage': $model = new InstallationModelLanguages(); $checkOptions = false; $options = array(); break; default: $model = new InstallationModelSetup(); $sufficient = $model->getPhpOptionsSufficient(); $checkOptions = true; $options = $model->getOptions(); if (!$sufficient) { $app->redirect('index.php?view=preinstall'); } break; } if ($vName != $default_view && ($checkOptions && empty($options))) { $this->setRedirect('index.php'); } // Include the component HTML helpers. JHtml::addIncludePath(JPATH_COMPONENT . '/helper/html'); // Register the layout paths for the view $paths = new SplPriorityQueue(); $paths->insert(JPATH_INSTALLATION . '/view/' . $vName . '/tmpl', 'normal'); $vClass = 'InstallationView' . ucfirst($vName) . ucfirst($vFormat); if (!class_exists($vClass)) { $vClass = 'InstallationViewDefault'; } /* @var JViewHtml $view */ $view = new $vClass($model, $paths); $view->setLayout($lName); // Render our view and return it to the application. return $view->render(); }