| 1 |  |  | <?php | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * @title            InstallController Class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @author           Pierre-Henry Soria <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @copyright        (c) 2012-2017, Pierre-Henry Soria. All Rights Reserved. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @license          GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @package          PH7 / Install / Controller | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | namespace PH7; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | defined('PH7') or exit('Restricted access'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | // Reset the time limit | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | @set_time_limit(0); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | class InstallController extends Controller | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      * Enable/Disable Modules according to the chosen niche | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     const SOCIAL_MODS = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         'connect' => '0', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         'affiliate' => '0', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         'game' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         'chat' => '0', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         'chatroulette' => '0', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         'picture' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         'video' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         'hotornot' => '0', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         'forum' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         'note' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         'blog' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         'newsletter' => '0', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         'invite' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         'webcam' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         'love-calculator' => '0', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         'mail' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         'im' => '0', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         'user-dashboard' => '0', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         'related-profile' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         'friend' => '1' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     const DATING_MODS = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         'connect' => '0', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         'affiliate' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         'game' => '0', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         'chat' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         'chatroulette' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         'picture' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         'video' => '0', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         'hotornot' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         'forum' => '0', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         'note' => '0', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         'blog' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         'newsletter' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         'invite' => '0', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         'webcam' => '0', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         'love-calculator' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         'mail' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         'im' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         'user-dashboard' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         'related-profile' => '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         'friend' => '0' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      * Enable/Disable Site Settings according to the chosen niche | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     const SOCIAL_SETTINGS = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         'social_media_widgets' => '1' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     const DATING_SETTINGS = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         'social_media_widgets' => '0' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     /********************* STEP 1 *********************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     public function index() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         $aLangs = get_dir_list(PH7_ROOT_INSTALL . 'langs/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         $aLangsList = include PH7_ROOT_INSTALL . 'inc/lang_list.inc.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         $sLangSelect = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         foreach ($aLangs as $sLang) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |             $sSel = (empty($_REQUEST['l']) ? $sLang == $this->sCurrentLang ? '" selected="selected' : '' : ($sLang == $_REQUEST['l']) ? '" selected="selected' : ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |             $sLangSelect .= '<option value="?l=' . $sLang . $sSel . '">' . $aLangsList[$sLang] . '</option>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         $this->oView->assign('lang_select', $sLangSelect); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         $this->oView->assign('sept_number', 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |         $this->oView->display('index.tpl'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     /********************* STEP 2 *********************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     public function config_path() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         global $LANG; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         if (empty($_SESSION['val']['path_protected'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |             $_SESSION['val']['path_protected'] = PH7_ROOT_PUBLIC . '_protected' . PH7_DS; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['path_protected'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |             $_SESSION['val']['path_protected'] = check_ext_start(check_ext_end(trim($_POST['path_protected']))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |             if (is_dir($_SESSION['val']['path_protected'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |                 if (is_readable($_SESSION['val']['path_protected'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |                     $sConstantContent = file_get_contents(PH7_ROOT_INSTALL . 'data/configs/constants.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |                     $sConstantContent = str_replace('%path_protected%', addslashes($_SESSION['val']['path_protected']), $sConstantContent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |                     if (!@file_put_contents(PH7_ROOT_PUBLIC . '_constants.php', $sConstantContent)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |                         $aErrors[] = $LANG['no_public_writable']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |                     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |                         $_SESSION['step2'] = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |                         unset($_SESSION['val']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |                         redirect(PH7_URL_SLUG_INSTALL . 'config_system'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |                     $aErrors[] = $LANG['no_protected_readable']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |                 $aErrors[] = $LANG['no_protected_exist']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         $this->oView->assign('sept_number', 2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |         $this->oView->assign('errors', @$aErrors); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |         unset($aErrors); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |         $this->oView->display('config_path.tpl'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     /********************* STEP 3 *********************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |     public function config_system() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |         global $LANG; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |         if (!empty($_SESSION['step2']) && is_file(PH7_ROOT_PUBLIC . '_constants.php')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |             session_regenerate_id(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |             if (empty($_SESSION['val'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |                 $_SESSION['db']['type_name'] = 'MySQL'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |                 $_SESSION['db']['type'] = 'mysql'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |                 $_SESSION['db']['hostname'] = 'localhost'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |                 $_SESSION['db']['username'] = 'root'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |                 $_SESSION['db']['name'] = 'ph7cms'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |                 $_SESSION['db']['prefix'] = 'PH7_'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |                 $_SESSION['db']['port'] = '3306'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |                 $_SESSION['db']['charset'] = 'UTF8'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |                 $_SESSION['val']['bug_report_email'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |                 $_SESSION['val']['ffmpeg_path'] = ffmpeg_path(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |             if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['config_system_submit'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |                 if (filled_out($_POST)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |                     foreach ($_POST as $sKey => $sVal) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |                         $_SESSION['db'][str_replace('db_', '', $sKey)] = trim($sVal); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |                     $_SESSION['val']['bug_report_email'] = trim($_POST['bug_report_email']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |                     $_SESSION['val']['ffmpeg_path'] = trim($_POST['ffmpeg_path']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |                     if (validate_email($_SESSION['val']['bug_report_email'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |                         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |                             require_once PH7_ROOT_INSTALL . 'inc/_db_connect.inc.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |                             @require_once PH7_ROOT_PUBLIC . '_constants.php'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |                             @require_once PH7_PATH_APP . 'configs/constants.php'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |                             // Config File | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |                             @chmod(PH7_PATH_APP_CONFIG, 0777); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |                             $sConfigContent = file_get_contents(PH7_ROOT_INSTALL . 'data/configs/config.ini'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |                             $sConfigContent = str_replace('%bug_report_email%', $_SESSION['val']['bug_report_email'], $sConfigContent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |                             $sConfigContent = str_replace('%ffmpeg_path%', clean_string($_SESSION['val']['ffmpeg_path']), $sConfigContent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |                             $sConfigContent = str_replace('%db_type_name%', $_SESSION['db']['type_name'], $sConfigContent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |                             $sConfigContent = str_replace('%db_type%', $_SESSION['db']['type'], $sConfigContent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |                             $sConfigContent = str_replace('%db_hostname%', $_SESSION['db']['hostname'], $sConfigContent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |                             $sConfigContent = str_replace('%db_username%', clean_string($_SESSION['db']['username']), $sConfigContent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |                             $sConfigContent = str_replace('%db_password%', clean_string($_SESSION['db']['password']), $sConfigContent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |                             $sConfigContent = str_replace('%db_name%', clean_string($_SESSION['db']['name']), $sConfigContent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |                             $sConfigContent = str_replace('%db_prefix%', clean_string($_SESSION['db']['prefix']), $sConfigContent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |                             $sConfigContent = str_replace('%db_charset%', $_SESSION['db']['charset'], $sConfigContent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |                             $sConfigContent = str_replace('%db_port%', $_SESSION['db']['port'], $sConfigContent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |                             $sConfigContent = str_replace('%private_key%', generate_hash(40), $sConfigContent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |                             $sConfigContent = str_replace('%rand_id%', generate_hash(5), $sConfigContent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |                             if (!@file_put_contents(PH7_PATH_APP_CONFIG . 'config.ini', $sConfigContent)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |                                 $aErrors[] = $LANG['no_app_config_writable']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |                             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |                                 if ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |                                     !($DB->getAttribute(\PDO::ATTR_DRIVER_NAME) == 'mysql' && | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |                                     version_compare($DB->getAttribute(\PDO::ATTR_SERVER_VERSION), PH7_REQUIRE_SQL_VERSION, '>=')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |                                 ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |                                     $aErrors[] = $LANG['require_mysql_version']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |                                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |                                     $aDumps = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |                                         /*** Game ***/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |                                         // We need to install the Game before the Core SQL for "foreign keys" that work are correct. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |                                         'pH7_SchemaGame', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |                                         'pH7_DataGame', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |                                         /*** Core ***/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |                                         'pH7_Core', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |                                         // --- GeoIp (exec_query_file() function executes these files only if they existens otherwise it does nothing) --- // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |                                         'pH7_GeoCountry', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |                                         'pH7_GeoCity', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |                                         'pH7_GeoCity2', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |                                         'pH7_GeoCity3', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |                                         'pH7_GeoCity4', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |                                         'pH7_GeoCity5', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |                                         'pH7_GeoCity6', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |                                         'pH7_GeoCity7', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |                                         'pH7_GeoCity8', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |                                         'pH7_GeoState', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |                                         // --- Execute this file if there is something --- // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |                                         'pH7_SampleData' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |                                     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |                                     for ($i = 0, $iCount = count($aDumps); $i < $iCount; $i++) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |                                         exec_query_file($DB, PH7_ROOT_INSTALL . 'data/sql/' . $_SESSION['db']['type_name'] . '/' . $aDumps[$i] . '.sql'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |                                     unset($DB); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |                                     $_SESSION['step3'] = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |                                     unset($_SESSION['val']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |                                     redirect(PH7_URL_SLUG_INSTALL . 'config_site'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |                                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |                             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |                         } catch (\PDOException $oE) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |                             $aErrors[] = $LANG['database_error'] . escape($oE->getMessage()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |                     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |                         $aErrors[] = $LANG['bad_email']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |                     $aErrors[] = $LANG['all_fields_mandatory']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |             redirect(PH7_URL_SLUG_INSTALL . 'config_path'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |         $this->oView->assign('sept_number', 3); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |         $this->oView->assign('errors', @$aErrors); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |         unset($aErrors); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |         $this->oView->display('config_system.tpl'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |     /********************* STEP 4 *********************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |     public function config_site() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |         global $LANG; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |         if (empty($_SESSION['step4'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |             if (!empty($_SESSION['step3']) && is_file(PH7_ROOT_PUBLIC . '_constants.php')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |                 session_regenerate_id(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |                 if (empty($_SESSION['val'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |                     $_SESSION['val']['site_name'] = Controller::DEFAULT_SITE_NAME; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |                     $_SESSION['val']['admin_login_email'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |                     $_SESSION['val']['admin_email'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |                     $_SESSION['val']['admin_feedback_email'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |                     $_SESSION['val']['admin_return_email'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |                     $_SESSION['val']['admin_username'] = 'administrator'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |                     $_SESSION['val']['admin_first_name'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |                     $_SESSION['val']['admin_last_name'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |                 if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['config_site_submit'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |                     if (filled_out($_POST)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |                         foreach ($_POST as $sKey => $sVal) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |                             $_SESSION['val'][$sKey] = trim($sVal); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |                         if (validate_email($_SESSION['val']['admin_login_email']) && validate_email($_SESSION['val']['admin_email']) && validate_email($_SESSION['val']['admin_feedback_email']) && validate_email($_SESSION['val']['admin_return_email'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |                             if (validate_username($_SESSION['val']['admin_username']) == 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |                                 if (validate_password($_SESSION['val']['admin_password']) == 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |                                     if (validate_identical($_SESSION['val']['admin_password'], $_SESSION['val']['admin_passwords'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |                                         if (!find($_SESSION['val']['admin_password'], $_SESSION['val']['admin_username']) && !find($_SESSION['val']['admin_password'], $_SESSION['val']['admin_first_name']) && !find($_SESSION['val']['admin_password'], $_SESSION['val']['admin_last_name'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |                                             if (validate_name($_SESSION['val']['admin_first_name'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |                                                 if (validate_name($_SESSION['val']['admin_last_name'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |                                                     @require_once PH7_ROOT_PUBLIC . '_constants.php'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |                                                     @require_once PH7_PATH_APP . 'configs/constants.php'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |                                                     require PH7_PATH_APP . 'includes/helpers/misc.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |                                                     require PH7_PATH_FRAMEWORK . 'Loader/Autoloader.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |                                                     // To load "\PH7\Framework\Security\Security" class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |                                                     Framework\Loader\Autoloader::getInstance()->init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |                                                     try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |                                                         require_once PH7_ROOT_INSTALL . 'inc/_db_connect.inc.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |                                                         // SQL EXECUTE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |                                                         $rStmt = $DB->prepare('INSERT INTO ' . $_SESSION['db']['prefix'] . 'Admins | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |                                                         (profileId , username, password, email, firstName, lastName, joinDate, lastActivity, ip) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |                                                         VALUES (1, :username, :password, :email, :firstName, :lastName, :joinDate, :lastActivity, :ip)'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |                                                         $sCurrentDate = date('Y-m-d H:i:s'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |                                                         $rStmt->execute([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |                                                             'username' => $_SESSION['val']['admin_username'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |                                                             'password' => Framework\Security\Security::hashPwd($_SESSION['val']['admin_password']), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |                                                             'email' => $_SESSION['val']['admin_login_email'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |                                                             'firstName' => $_SESSION['val']['admin_first_name'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |                                                             'lastName' => $_SESSION['val']['admin_last_name'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |                                                             'joinDate' => $sCurrentDate, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |                                                             'lastActivity' => $sCurrentDate, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |                                                             'ip' => client_ip() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |                                                         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |                                                         $rStmt = $DB->prepare('UPDATE ' . $_SESSION['db']['prefix'] . 'Settings SET value = :siteName WHERE name = \'siteName\' LIMIT 1'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |                                                         $rStmt->execute(['siteName' => $_SESSION['val']['site_name']]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |                                                         $rStmt = $DB->prepare('UPDATE ' . $_SESSION['db']['prefix'] . 'Settings SET value = :adminEmail WHERE name = \'adminEmail\'  LIMIT 1'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |                                                         $rStmt->execute(['adminEmail' => $_SESSION['val']['admin_email']]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |                                                         $rStmt = $DB->prepare('UPDATE ' . $_SESSION['db']['prefix'] . 'Settings SET value = :feedbackEmail WHERE name = \'feedbackEmail\'  LIMIT 1'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |                                                         $rStmt->execute(['feedbackEmail' => $_SESSION['val']['admin_feedback_email']]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |                                                         $rStmt = $DB->prepare('UPDATE ' . $_SESSION['db']['prefix'] . 'Settings SET value = :returnEmail WHERE name = \'returnEmail\'  LIMIT 1'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |                                                         $rStmt->execute(['returnEmail' => $_SESSION['val']['admin_return_email']]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |                                                         // We finalise by putting the correct permission to the config files | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |                                                         $this->chmodConfigFiles(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |                                                         $_SESSION['step4'] = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |                                                         redirect(PH7_URL_SLUG_INSTALL . 'niche'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |                                                     } catch (\PDOException $oE) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |                                                         $aErrors[] = $LANG['database_error'] . escape($oE->getMessage()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |                                                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |                                                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |                                                     $aErrors[] = $LANG['bad_last_name']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |                                                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |                                             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |                                                 $aErrors[] = $LANG['bad_first_name']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |                                             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |                                         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |                                             $aErrors[] = $LANG['insecure_password']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |                                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |                                     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |                                         $aErrors[] = $LANG['passwords_different']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |                                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |                                 } elseif (validate_password($_SESSION['val']['admin_password']) == 1) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |                                     $aErrors[] = $LANG['password_too_short']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |                                 } elseif (validate_password($_SESSION['val']['admin_password']) == 2) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |                                     $aErrors[] = $LANG['password_too_long']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |                                 } elseif (validate_password($_SESSION['val']['admin_password']) == 3) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |                                     $aErrors[] = $LANG['password_no_number']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |                                 } elseif (validate_password($_SESSION['val']['admin_password']) == 4) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |                                     $aErrors[] = $LANG['password_no_upper']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |                                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |                             } elseif (validate_username($_SESSION['val']['admin_username']) == 1) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |                                 $aErrors[] = $LANG['username_too_short']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |                             } elseif (validate_username($_SESSION['val']['admin_username']) == 2) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |                                 $aErrors[] = $LANG['username_too_long']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |                             } elseif (validate_username($_SESSION['val']['admin_username']) == 3) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |                                 $aErrors[] = $LANG['bad_username']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |                             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |                         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |                             $aErrors[] = $LANG['bad_email']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |                     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |                         $aErrors[] = $LANG['all_fields_mandatory']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |                 redirect(PH7_URL_SLUG_INSTALL . 'config_system'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |             redirect(PH7_URL_SLUG_INSTALL . 'niche'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |         $this->oView->assign('def_site_name', Controller::DEFAULT_SITE_NAME); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |         $this->oView->assign('sept_number', 4); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |         $this->oView->assign('errors', @$aErrors); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |         unset($aErrors); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |         $this->oView->display('config_site.tpl'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |     /********************* STEP 5 *********************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |     public function niche() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |         global $LANG; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |         if (empty($_SESSION['step5'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |             if (!empty($_SESSION['step4']) && is_file(PH7_ROOT_PUBLIC . '_constants.php')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |                 session_regenerate_id(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |                 if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['niche_submit'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |                     $bUpdateNeeded = false; // Value by default. Don't need to update the DB for the Social-Dating Niche | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |                     switch ($_POST['niche_submit']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |                         case 'zendate': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |                             $bUpdateNeeded = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |                             $sTheme = 'zendate'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |                             $aModUpdate = self::SOCIAL_MODS; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |                             $aSettingUpdate = self::SOCIAL_SETTINGS; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |                             break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |                         case 'datelove': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |                             $bUpdateNeeded = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |                             $sTheme = 'datelove'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |                             $aModUpdate = self::DATING_MODS; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |                             $aSettingUpdate = self::DATING_SETTINGS; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |                             break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |                         // Or for 'base', don't do anything. Just use the default settings already setup in the database | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |                     if ($bUpdateNeeded) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |                         @require_once PH7_ROOT_PUBLIC . '_constants.php'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |                         @require_once PH7_PATH_APP . 'configs/constants.php'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |                         require PH7_PATH_APP . 'includes/helpers/misc.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |                         require PH7_PATH_FRAMEWORK . 'Loader/Autoloader.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |                         // To load "PH7\Framework\Mvc\Model\DbConfig" class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |                         Framework\Loader\Autoloader::getInstance()->init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |                         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |                             require_once PH7_ROOT_INSTALL . 'inc/_db_connect.inc.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |                             // Enable/Disable the modules according to the chosen niche | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |                             foreach ($aModUpdate as $sModName => $sStatus) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |                                 $this->updateMods($DB, $sModName, $sStatus); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |                             $this->updateSettings($aSettingUpdate); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |                             // Set the theme for the chosen niche | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |                             $sSql = 'UPDATE ' . $_SESSION['db']['prefix'] . 'Settings SET value = :theme WHERE name = \'defaultTemplate\' LIMIT 1'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |                             $rStmt = $DB->prepare($sSql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |                             $rStmt->execute(['theme' => $sTheme]); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |                         } catch (\PDOException $oE) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |                             $aErrors[] = $LANG['database_error'] . escape($oE->getMessage()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |                     $_SESSION['step5'] = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |                     redirect(PH7_URL_SLUG_INSTALL . 'service'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |                 redirect(PH7_URL_SLUG_INSTALL . 'config_site'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |             redirect(PH7_URL_SLUG_INSTALL . 'service'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |         $this->oView->assign('sept_number', 5); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |         $this->oView->assign('errors', @$aErrors); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |         unset($aErrors); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |         $this->oView->display('niche.tpl'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |     /********************* STEP 6 *********************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |     public function service() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |         $this->oView->assign('sept_number', 6); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |         $this->oView->display('service.tpl'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |     /********************* STEP 7 *********************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |     public function license() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |         global $LANG; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |         if (!empty($_SESSION['step5']) && is_file(PH7_ROOT_PUBLIC . '_constants.php')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |             if (empty($_SESSION['val']['license'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |                 $_SESSION['val']['license'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |             if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['license'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |                 $sKey = trim($_POST['license']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |                 if (check_license($sKey)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |                     @require_once PH7_ROOT_PUBLIC . '_constants.php'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |                     @require_once PH7_PATH_APP . 'configs/constants.php'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |                     try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |                         require_once PH7_ROOT_INSTALL . 'inc/_db_connect.inc.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |                         $rStmt = $DB->prepare('UPDATE ' . $_SESSION['db']['prefix'] . 'License SET licenseKey = :key WHERE licenseId = 1'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |                         $rStmt->execute(['key' => $sKey]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |                         redirect(PH7_URL_SLUG_INSTALL . 'finish'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |                     } catch (\PDOException $oE) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |                         $aErrors[] = $LANG['database_error'] . escape($oE->getMessage()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |                     $aErrors[] = $LANG['failure_license']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |             redirect(PH7_URL_SLUG_INSTALL . 'niche'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |         $this->oView->assign('sept_number', 7); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |         $this->oView->assign('errors', @$aErrors); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |         unset($aErrors); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |         $this->oView->display('license.tpl'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |     /********************* STEP 8 *********************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |     public function finish() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |         @require_once PH7_ROOT_PUBLIC . '_constants.php'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |         if ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |             !empty($_SESSION['val']['admin_login_email']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |             && !empty($_SESSION['val']['admin_username']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |         ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |             $this->sendWelcomeEmail(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |             $this->oView->assign('admin_login_email', $_SESSION['val']['admin_login_email']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |             $this->oView->assign('admin_username', $_SESSION['val']['admin_username']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |         $this->removeSessions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |         $this->removeCookies(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |         if ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |             $_SERVER['REQUEST_METHOD'] == 'POST' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |             && !empty($_POST['confirm_remove_install']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |         ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |             remove_install_dir(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |             clearstatcache(); // We remove the files status cache as the "_install" folder doesn't exist anymore by now. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |             exit(header('Location: ' . PH7_URL_ROOT)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |         $this->oView->assign('sept_number', 8); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |         $this->oView->display('finish.tpl'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  |      * Send an email to say the installation is now done, and give some information... | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |     private function sendWelcomeEmail() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  |         global $LANG; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  |         $aParams = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |             'to' => $_SESSION['val']['admin_login_email'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |             'subject' => $LANG['title_email_finish_install'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  |             'body' => $LANG['content_email_finish_install'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  |         send_mail($aParams); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  |     private function removeSessions() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  |         $_SESSION = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  |         session_unset(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  |         session_destroy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  |     private function removeCookies() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |         $sCookieName = Controller::SOFTWARE_PREFIX_COOKIE_NAME . '_install_lang'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  |         // We are asking the browser to delete the cookie. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  |         setcookie($sCookieName, 0, 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  |         // and then, we delete the cookie value locally to avoid using it by mistake in following our script. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  |         unset($_COOKIE[$sCookieName]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  |      * Update module status (enabled/disabled). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |      * @param Db $oDb | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  |      * @param string $sModName Module Name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  |      * @param string $sStatus '1' = Enabled | '0' = Disabled (need to be string because in DB it is an "enum"). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  |      * @return integer|boolean Returns the number of rows on success or FALSE on failure. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  |     private function updateMods(Db $oDb, $sModName, $sStatus) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  |         $sSql = 'UPDATE ' . $_SESSION['db']['prefix'] . 'SysModsEnabled SET enabled = :status WHERE folderName = :modName LIMIT 1'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |         $rStmt = $oDb->prepare($sSql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  |         return $rStmt->execute(['modName' => $sModName, 'status' => $sStatus]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  |      * @param array $aParams | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  |      * @return void | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 589 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 590 |  |  |     private function updateSettings(array $aParams) | 
            
                                                                        
                            
            
                                    
            
            
                | 591 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 592 |  |  |         // Initialize the site's database to get "\PH7\Framework\Mvc\Model\Engine\Db" class working (as it uses that DB and not the installer one) | 
            
                                                                        
                            
            
                                    
            
            
                | 593 |  |  |         Framework\Mvc\Router\FrontController::getInstance()->_databaseInitialize(); | 
            
                                                                        
                            
            
                                    
            
            
                | 594 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 595 |  |  |         // Enable/Disable Social Media Widgets according to the chosen niche | 
            
                                                                        
                            
            
                                    
            
            
                | 596 |  |  |         Framework\Mvc\Model\DbConfig::setSocialWidgets($aParams['social_media_widgets']); | 
            
                                                                        
                            
            
                                    
            
            
                | 597 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |     /***** Set the correct permission to the config files *****/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  |     private function chmodConfigFiles() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |         @chmod(PH7_PATH_APP_CONFIG . 'config.ini', 0644); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  |         @chmod(PH7_ROOT_PUBLIC . '_constants.php', 0644); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  |     /***** Get the loading image *****/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  |     private function loadImg() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  |         global $LANG; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  |         return '<div style="text-align:center"><p>' . $LANG['wait_importing_database'] . '</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  |         <p><img src="data:image/gif;base64,R0lGODlhHwAfAPUAAP///wAAAOjo6NLS0ry8vK6urqKiotzc3Li4uJqamuTk5NjY2KqqqqCgoLCwsMzMzPb29qioqNTU1Obm5jY2NiYmJlBQUMTExHBwcJKSklZWVvr6+mhoaEZGRsbGxvj4+EhISDIyMgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAHwAfAAAG/0CAcEgUDAgFA4BiwSQexKh0eEAkrldAZbvlOD5TqYKALWu5XIwnPFwwymY0GsRgAxrwuJwbCi8aAHlYZ3sVdwtRCm8JgVgODwoQAAIXGRpojQwKRGSDCRESYRsGHYZlBFR5AJt2a3kHQlZlERN2QxMRcAiTeaG2QxJ5RnAOv1EOcEdwUMZDD3BIcKzNq3BJcJLUABBwStrNBtjf3GUGBdLfCtadWMzUz6cDxN/IZQMCvdTBcAIAsli0jOHSJeSAqmlhNr0awo7RJ19TJORqdAXVEEVZyjyKtE3Bg3oZE2iK8oeiKkFZGiCaggelSTiA2LhxiZLBSjZjBL2siNBOFQ84LxHA+mYEiRJzBO7ZCQIAIfkECQoAAAAsAAAAAB8AHwAABv9AgHBIFAwIBQPAUCAMBMSodHhAJK5XAPaKOEynCsIWqx0nCIrvcMEwZ90JxkINaMATZXfju9jf82YAIQxRCm14Ww4PChAAEAoPDlsAFRUgHkRiZAkREmoSEXiVlRgfQgeBaXRpo6MOQlZbERN0Qx4drRUcAAJmnrVDBrkVDwNjr8BDGxq5Z2MPyUQZuRgFY6rRABe5FgZjjdm8uRTh2d5b4NkQY0zX5QpjTc/lD2NOx+WSW0++2RJmUGJhmZVsQqgtCE6lqpXGjBchmt50+hQKEAEiht5gUcTIESR9GhlgE9IH0BiTkxrMmWIHDkose9SwcQlHDsOIk9ygiVbl5JgMLuV4HUmypMkTOkEAACH5BAkKAAAALAAAAAAfAB8AAAb/QIBwSBQMCAUDwFAgDATEqHR4QCSuVwD2ijhMpwrCFqsdJwiK73DBMGfdCcZCDWjAE2V347vY3/NmdXNECm14Ww4PChAAEAoPDltlDGlDYmQJERJqEhGHWARUgZVqaWZeAFZbERN0QxOeWwgAAmabrkMSZkZjDrhRkVtHYw+/RA9jSGOkxgpjSWOMxkIQY0rT0wbR2LQV3t4UBcvcF9/eFpdYxdgZ5hUYA73YGxruCbVjt78G7hXFqlhY/fLQwR0HIQdGuUrTz5eQdIc0cfIEwByGD0MKvcGSaFGjR8GyeAPhIUofQGNQSgrB4IsdOCqx7FHDBiYcOQshYjKDxliVDpRjunCjdSTJkiZP6AQBACH5BAkKAAAALAAAAAAfAB8AAAb/QIBwSBQMCAUDwFAgDATEqHR4QCSuVwD2ijhMpwrCFqsdJwiK73DBMGfdCcZCDWjAE2V347vY3/NmdXNECm14Ww4PChAAEAoPDltlDGlDYmQJERJqEhGHWARUgZVqaWZeAFZbERN0QxOeWwgAAmabrkMSZkZjDrhRkVtHYw+/RA9jSGOkxgpjSWOMxkIQY0rT0wbR2I3WBcvczltNxNzIW0693MFYT7bTumNQqlisv7BjswAHo64egFdQAbj0RtOXDQY6VAAUakihN1gSLaJ1IYOGChgXXqEUpQ9ASRlDYhT0xQ4cACJDhqDD5mRKjCAYuArjBmVKDP9+VRljMyMHDwcfuBlBooSCBQwJiqkJAgAh+QQJCgAAACwAAAAAHwAfAAAG/0CAcEgUDAgFA8BQIAwExKh0eEAkrlcA9oo4TKcKwharHScIiu9wwTBn3QnGQg1owBNld+O72N/zZnVzRApteFsODwoQABAKDw5bZQxpQ2JkCRESahIRh1gEVIGVamlmXgBWWxETdEMTnlsIAAJmm65DEmZGYw64UZFbR2MPv0QPY0hjpMYKY0ljjMZCEGNK09MG0diN1gXL3M5bTcTcyFtOvdzBWE+207pjUKpYrL+wY7MAB4EerqZjUAG4lKVCBwMbvnT6dCXUkEIFK0jUkOECFEeQJF2hFKUPAIkgQwIaI+hLiJAoR27Zo4YBCJQgVW4cpMYDBpgVZKL59cEBhw+U+QROQ4bBAoUlTZ7QCQIAIfkECQoAAAAsAAAAAB8AHwAABv9AgHBIFAwIBQPAUCAMBMSodHhAJK5XAPaKOEynCsIWqx0nCIrvcMEwZ90JxkINaMATZXfju9jf82Z1c0QKbXhbDg8KEAAQCg8OW2UMaUNiZAkREmoSEYdYBFSBlWppZl4AVlsRE3RDE55bCAACZpuuQxJmRmMOuFGRW0djD79ED2NIY6TGCmNJY4zGQhBjStPTFBXb21DY1VsGFtzbF9gAzlsFGOQVGefIW2LtGhvYwVgDD+0V17+6Y6BwaNfBwy9YY2YBcMAPnStTY1B9YMdNiyZOngCFGuIBxDZAiRY1eoTvE6UoDEIAGrNSUoNBUuzAaYlljxo2M+HIeXiJpRsRNMaq+JSFCpsRJEqYOPH2JQgAIfkECQoAAAAsAAAAAB8AHwAABv9AgHBIFAwIBQPAUCAMBMSodHhAJK5XAPaKOEynCsIWqx0nCIrvcMEwZ90JxkINaMATZXfjywjlzX9jdXNEHiAVFX8ODwoQABAKDw5bZQxpQh8YiIhaERJqEhF4WwRDDpubAJdqaWZeAByoFR0edEMTolsIAA+yFUq2QxJmAgmyGhvBRJNbA5qoGcpED2MEFrIX0kMKYwUUslDaj2PA4soGY47iEOQFY6vS3FtNYw/m1KQDYw7mzFhPZj5JGzYGipUtESYowzVmF4ADgOCBCZTgFQAxZBJ4AiXqT6ltbUZhWdToUSR/Ii1FWbDnDkUyDQhJsQPn5ZU9atjUhCPHVhgTNy/RSKsiqKFFbUaQKGHiJNyXIAAh+QQJCgAAACwAAAAAHwAfAAAG/0CAcEh8JDAWCsBQIAwExKhU+HFwKlgsIMHlIg7TqQeTLW+7XYIiPGSAymY0mrFgA0LwuLzbCC/6eVlnewkADXVECgxcAGUaGRdQEAoPDmhnDGtDBJcVHQYbYRIRhWgEQwd7AB52AGt7YAAIchETrUITpGgIAAJ7ErdDEnsCA3IOwUSWaAOcaA/JQ0amBXKa0QpyBQZyENFCEHIG39HcaN7f4WhM1uTZaE1y0N/TacZoyN/LXU+/0cNyoMxCUytYLjm8AKSS46rVKzmxADhjlCACMFGkBiU4NUQRxS4OHijwNqnSJS6ZovzRyJAQo0NhGrgs5bIPmwWLCLHsQsfhxBWTe9QkOzCwC8sv5Ho127akyRM7QQAAOwAAAAAAAAAAAA==" alt="' . $LANG['loading'] . '" /></p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  |         </div>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 615 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 616 |  |  |  | 
            
                        
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.