private function add_navigation(Template $view)
 {
     $form = new HTMLForm('preambleForm', UpdateUrlBuilder::server_configuration()->rel(), false);
     $action_fieldset = new FormFieldsetSubmit('actions');
     $next = new FormButtonSubmitCssImg($this->lang['step.next'], 'fa fa-arrow-right', 'introduction');
     $action_fieldset->add_element($next);
     $form->add_fieldset($action_fieldset);
     $view->put_all(array('C_PUT_UNDER_MAINTENANCE' => !MaintenanceConfig::load()->is_under_maintenance(), 'SERVER_FORM' => $form->display()));
 }
 public function execute(HTTPRequestCustom $request)
 {
     $this->create_view();
     $this->fill_view();
     $maintenance_config = MaintenanceConfig::load();
     if ($maintenance_config->is_under_maintenance() && !$maintenance_config->is_authorized_in_maintenance()) {
         return new SiteNodisplayResponse($this->view);
     } else {
         $response = new $this->response_classname($this->view);
         $graphical_env = $response->get_graphical_environment();
         if (!$graphical_env instanceof AbstractDisplayGraphicalEnvironment) {
             throw new Exception($this->response_classname . ' does not contains a graphical environement ' . 'that is an instance of AbstractDisplayGraphicalEnvironment');
         }
         $graphical_env->set_page_title($this->title);
         return $response;
     }
 }
 protected function process_site_maintenance()
 {
     $maintenance_config = MaintenanceConfig::load();
     if ($maintenance_config->is_under_maintenance()) {
         if (!$maintenance_config->is_authorized_in_maintenance()) {
             // Redirect if user not authorized the site for maintenance
             if (AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) {
                 $session = AppContext::get_session();
                 Session::delete($session);
                 AppContext::get_response()->redirect(UserUrlBuilder::connect());
             }
             $maintain_url = UserUrlBuilder::maintain();
             if (!Url::is_current_url($maintain_url->relative())) {
                 AppContext::get_response()->redirect($maintain_url);
             }
         }
     }
 }
 protected function display_site_maintenance()
 {
     //Users not authorized cannot come here
     parent::process_site_maintenance();
     $template = new FileTemplate('maintain.tpl');
     $maintenance_config = MaintenanceConfig::load();
     if ($maintenance_config->is_under_maintenance() && $maintenance_config->get_display_duration_for_admin()) {
         $date_lang = LangLoader::get('date-common');
         //Durée de la maintenance.
         $array_time = array(-1, 60, 300, 600, 900, 1800, 3600, 7200, 10800, 14400, 18000, 21600, 25200, 28800, 57600, 86400, 172800, 604800);
         $array_delay = array(LangLoader::get_message('unspecified', 'main'), '1 ' . $date_lang['minute'], '5 ' . $date_lang['minutes'], '10 ' . $date_lang['minutes'], '15 ' . $date_lang['minutes'], '30 ' . $date_lang['minutes'], '1 ' . $date_lang['hour'], '2 ' . $date_lang['hours'], '3 ' . $date_lang['hours'], '4 ' . $date_lang['hours'], '5 ' . $date_lang['hours'], '6 ' . $date_lang['hours'], '7 ' . $date_lang['hours'], '8 ' . $date_lang['hours'], '16 ' . $date_lang['hours'], '1 ' . $date_lang['day'], '2 ' . $date_lang['hours'], '1 ' . $date_lang['week']);
         //Retourne le délai de maintenance le plus proche.
         if (!$maintenance_config->is_unlimited_maintenance()) {
             $key_delay = 0;
             $current_time = time();
             $array_size = count($array_time) - 1;
             $end_timestamp = $maintenance_config->get_end_date()->get_timestamp();
             for ($i = $array_size; $i >= 1; $i--) {
                 if ($end_timestamp - $current_time - $array_time[$i] < 0 && $end_timestamp - $current_time - $array_time[$i - 1] > 0) {
                     $key_delay = $i - 1;
                     break;
                 }
             }
             //Calcul du format de la date
             $array_release = array(Date::to_format($end_timestamp, 'Y', Timezone::SITE_TIMEZONE), Date::to_format($end_timestamp, 'n', Timezone::SITE_TIMEZONE) - 1, Date::to_format($end_timestamp, 'j', Timezone::SITE_TIMEZONE), Date::to_format($end_timestamp, 'G', Timezone::SITE_TIMEZONE), Date::to_format($end_timestamp, 'i', Timezone::SITE_TIMEZONE), Date::to_format($end_timestamp, 's', Timezone::SITE_TIMEZONE));
             $array_now = array(Date::to_format(time(), 'Y', Timezone::SITE_TIMEZONE), Date::to_format(time(), 'n', Timezone::SITE_TIMEZONE) - 1, Date::to_format(time(), 'j', Timezone::SITE_TIMEZONE), Date::to_format(time(), 'G', Timezone::SITE_TIMEZONE), Date::to_format(time(), 'i', Timezone::SITE_TIMEZONE), Date::to_format(time(), 's', Timezone::SITE_TIMEZONE));
         } else {
             $key_delay = 0;
             $array_release = array('0', '0', '0', '0', '0', '0');
             $array_now = array('0', '0', '0', '0', '0', '0');
         }
         $template->put_all(array('C_ALERT_MAINTAIN' => true, 'C_MAINTAIN_DELAY' => true, 'UNSPECIFIED' => $maintenance_config->is_unlimited_maintenance() ? 0 : 1, 'DELAY' => isset($array_delay[$key_delay]) ? $array_delay[$key_delay] : '0', 'MAINTAIN_RELEASE_FORMAT' => implode(',', $array_release), 'MAINTAIN_NOW_FORMAT' => implode(',', $array_now), 'L_MAINTAIN_DELAY' => self::$main_lang['maintain_delay'], 'L_LOADING' => self::$main_lang['loading'], 'L_DAYS' => $date_lang['days'], 'L_HOURS' => $date_lang['hours'], 'L_MIN' => $date_lang['minutes'], 'L_SEC' => $date_lang['seconds']));
     }
     return $template;
 }
 private function save()
 {
     $this->maintain_type = $this->form->get_value('maintain_type')->get_raw_value();
     switch ($this->maintain_type) {
         case 'during':
             $maintain_during = $this->form->get_value('maintain_during')->get_raw_value();
             $this->maintenance_config->enable_maintenance();
             $this->maintenance_config->set_unlimited_maintenance(false);
             $this->maintenance_config->set_end_date(new Date(time() + 5 + $maintain_during, Timezone::SERVER_TIMEZONE));
             break;
         case 'until':
             $this->maintenance_config->enable_maintenance();
             $this->maintenance_config->set_unlimited_maintenance(false);
             $this->maintenance_config->set_end_date($this->form->get_value('maintain_until'));
             break;
         case 'unlimited':
             $this->maintenance_config->enable_maintenance();
             $this->maintenance_config->set_unlimited_maintenance(true);
             break;
         default:
             $this->maintenance_config->disable_maintenance();
             $this->maintenance_config->set_end_date(new Date());
     }
     if ($this->form->get_value('display_duration')) {
         $this->maintenance_config->set_display_duration(true);
         $this->maintenance_config->set_display_duration_for_admin($this->form->get_value('display_duration_for_admin'));
     } else {
         $this->maintenance_config->set_display_duration(false);
     }
     $this->maintenance_config->set_message($this->form->get_value('message'));
     $this->maintenance_config->set_auth($this->form->get_value('authorizations')->build_auth_array());
     MaintenanceConfig::save();
 }
 private function init(HTTPRequestCustom $request)
 {
     $this->request = $request;
     $this->view = new FileTemplate('user/UserLoginController.tpl');
     $this->lang = LangLoader::get('user-common');
     $this->view->add_lang($this->lang);
     $this->maintain_config = MaintenanceConfig::load();
 }
 public static function get_advises(HTMLForm $html_form)
 {
     $lang = LangLoader::get('admin-server-common');
     $server_configuration = new ServerConfiguration();
     $maintenance_config = MaintenanceConfig::load();
     $general_config = GeneralConfig::load();
     $server_environment_config = ServerEnvironmentConfig::load();
     $security_config = SecurityConfig::load();
     $url_rewriting_available = false;
     try {
         $url_rewriting_available = $server_configuration->has_url_rewriting();
     } catch (UnsupportedOperationException $ex) {
     }
     $fieldset = new FormFieldsetHTML('advises', $lang['advises']);
     $fieldset->add_field(new FormFieldFree('modules_management', '', MessageHelper::display($lang['advises.modules_management'], MessageHelper::SUCCESS)->render()));
     if ($maintenance_config->is_under_maintenance()) {
         $fieldset->add_field(new FormFieldFree('check_modules_authorizations', '', MessageHelper::display($lang['advises.check_modules_authorizations'], MessageHelper::SUCCESS)->render()));
     }
     if (!strstr($general_config->get_site_url(), 'localhost') && !strstr($general_config->get_site_url(), '127.0.0.1') && !$maintenance_config->is_under_maintenance() && Debug::is_debug_mode_enabled()) {
         $fieldset->add_field(new FormFieldFree('disable_debug_mode', '', MessageHelper::display($lang['advises.disable_debug_mode'], MessageHelper::WARNING)->render()));
     }
     if ($url_rewriting_available && !$server_environment_config->is_url_rewriting_enabled()) {
         $fieldset->add_field(new FormFieldFree('enable_url_rewriting', '', MessageHelper::display($lang['advises.enable_url_rewriting'], MessageHelper::NOTICE)->render()));
     }
     if (function_exists('ob_gzhandler') && @extension_loaded('zlib') && !$server_environment_config->is_output_gziping_enabled()) {
         $fieldset->add_field(new FormFieldFree('enable_output_gz', '', MessageHelper::display($lang['advises.enable_output_gz'], MessageHelper::NOTICE)->render()));
     }
     if (DataStoreFactory::is_apc_available() && !DataStoreFactory::is_apc_enabled()) {
         $fieldset->add_field(new FormFieldFree('enable_apcu_cache', '', MessageHelper::display($lang['advises.enable_apcu_cache'], MessageHelper::NOTICE)->render()));
     }
     $fieldset->add_field(new FormFieldFree('save_database', '', MessageHelper::display($lang['advises.save_database'], MessageHelper::SUCCESS)->render()));
     if (!DatabaseConfig::load()->is_database_tables_optimization_enabled()) {
         $fieldset->add_field(new FormFieldFree('optimize_database_tables', '', MessageHelper::display($lang['advises.optimize_database_tables'], MessageHelper::SUCCESS)->render()));
     }
     if ($security_config->get_internal_password_min_length() == 6 && $security_config->get_internal_password_strength() == SecurityConfig::PASSWORD_STRENGTH_WEAK && !$security_config->are_login_and_email_forbidden_in_password()) {
         $fieldset->add_field(new FormFieldFree('password_security', '', MessageHelper::display($lang['advises.password_security'], MessageHelper::NOTICE)->render()));
     }
     if (ServerConfiguration::get_phpversion() < '5.6') {
         $fieldset->add_field(new FormFieldFree('upgrade_php_version', '', MessageHelper::display($lang['advises.upgrade_php_version'], MessageHelper::NOTICE)->render()));
     }
     if (count($fieldset->get_fields())) {
         $html_form->add_fieldset($fieldset);
     }
 }
Exemplo n.º 8
0
 public function put_site_under_maintenance()
 {
     $maintenance_config = MaintenanceConfig::load();
     if (!$maintenance_config->is_under_maintenance()) {
         $maintenance_config->enable_maintenance();
         $maintenance_config->set_unlimited_maintenance(true);
         MaintenanceConfig::save();
     }
 }