From 19985dbb8c0aa66dc4bf7905abc1148de909097d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Tue, 11 Jan 2022 12:35:47 +0100 Subject: prvi-commit --- frontend/install/classes/class.Display.php | 231 +++++++++++ frontend/install/classes/class.DisplayCheck.php | 392 ++++++++++++++++++ frontend/install/classes/class.DisplayDatabase.php | 112 ++++++ frontend/install/classes/class.DisplaySettings.php | 448 +++++++++++++++++++++ frontend/install/classes/class.ImportDB.php | 256 ++++++++++++ 5 files changed, 1439 insertions(+) create mode 100644 frontend/install/classes/class.Display.php create mode 100644 frontend/install/classes/class.DisplayCheck.php create mode 100644 frontend/install/classes/class.DisplayDatabase.php create mode 100644 frontend/install/classes/class.DisplaySettings.php create mode 100644 frontend/install/classes/class.ImportDB.php (limited to 'frontend/install/classes') diff --git a/frontend/install/classes/class.Display.php b/frontend/install/classes/class.Display.php new file mode 100644 index 0000000..3a04fe3 --- /dev/null +++ b/frontend/install/classes/class.Display.php @@ -0,0 +1,231 @@ +stran = $_GET['step']; + + + // Nastavimo jezik + if(isset($_GET['lang_id'])) + $this->lang_id = $_GET['lang_id']; + elseif(isset($_SESSION['lang_id'])) + $this->lang_id = $_SESSION['lang_id']; + + $_SESSION['lang_id'] = $this->lang_id; + + $file = '../../lang/'.$this->lang_id.'.php'; + include($file); + } + + + public function displayHead(){ + global $lang; + global $site_url; + + echo ' '; + echo ' '; + + echo ' '; + + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + + echo ' '.$lang['install_title'].''; + + echo ' '; + echo ' '; + echo ' '; + + echo ' '; + echo ' '; + echo ' '; + echo ' '; + + echo ' '; + echo ' '; + + echo ' '; + echo ' '; + } + + + // Izris zgornje vrstice z logotipom in menijem + public function displayHeader(){ + global $lang; + + // Logo v glavi + echo ''; + + + // Navigacija + echo ''; + } + + // Izris vsebine + public function displayMain(){ + global $lang; + + echo '
'; + + //echo '

'.$lang['install_title'].'

'; + + switch($this->stran){ + + case 'welcome': + $this->displayWelcomePage(); + break; + + case 'check': + $dc = new DisplayCheck(); + $dc->displayCheckPage(); + break; + + case 'settings': + $ds = new DisplaySettings(); + $ds->displaySettingsPage(); + break; + + case 'database': + $dd = new DisplayDatabase(); + $dd->displayDatabasePage(); + break; + + case 'finish': + $this->displayFinishPage(); + break; + + default: + $this->displayWelcomePage(); + break; + } + + echo '
'; + } + + // Izris footerja + public function displayFooter(){ + global $lang; + global $site_url; + + // Stolpec 1 + echo '
'; + echo '

'.$lang['simple_footer_about'].'

'; + echo ' '.$lang['simple_footer_about_1ka'].''; + echo ' '.$lang['simple_footer_about_general'].''; + echo ' '.$lang['simple_footer_about_privacy'].''; + echo ' '.$lang['simple_footer_about_cookies'].''; + echo ' '.$lang['simple_footer_about_antispam'].''; + echo ' '; + echo '
'; + + // Stolpec 2 - logotipi + echo '
'; + + // Logotipa FDV in CDI + echo '
'; + echo ' '; + echo ' '; + echo '
'; + + echo '
'; + + // Stolpec 3 + echo '
'; + + echo '
'; + } + + + // Izris prve welcome + private function displayWelcomePage(){ + global $lang; + + echo '

'.$lang['install_welcome_title'].'

'; + + echo '

'.$lang['install_welcome_text'].'

'; + + // Next button + echo '
'; + echo ' '; + echo '
'; + } + + // Izris strani za preverjanje konfiguracije streznika, baze + private function displayFinishPage(){ + global $lang; + + echo '

'.$lang['install_finish_title'].'

'; + + echo '

'.$lang['install_finish_text'].'

'; + + // Redirect na naslovnico + echo '
'; + echo ' '; + echo ' '; + echo '
'; + } +} \ No newline at end of file diff --git a/frontend/install/classes/class.DisplayCheck.php b/frontend/install/classes/class.DisplayCheck.php new file mode 100644 index 0000000..81d7fc7 --- /dev/null +++ b/frontend/install/classes/class.DisplayCheck.php @@ -0,0 +1,392 @@ +'.$lang['install_check_title'].''; + + echo '

'.$lang['install_check_text'].'


'; + + + $red_error = false; + + // APACHE + echo '
'; + echo '

'.$lang['install_check_apache'].'

'; + + $apache_check = $this->apacheCheck(); + foreach($apache_check as $apache_item){ + + if($apache_item['error'] == 1){ + $color_class = 'orange'; + } + elseif($apache_item['error'] == 2){ + $color_class = 'red'; + $red_error = true; + } + else{ + $color_class = 'green'; + } + + echo '
'; + echo '
'.$lang['install_check_'.$apache_item['what']].':
'; + echo '
'.$apache_item['value'].'
'; + echo '
'; + } + echo '
'; + + + // PHP + echo '
'; + echo '

'.$lang['install_check_php'].'

'; + + $php_check = $this->phpCheck(); + foreach($php_check as $php_item){ + + if($php_item['error'] == 1){ + $color_class = 'orange'; + } + elseif($php_item['error'] == 2){ + $color_class = 'red'; + $red_error = true; + } + else{ + $color_class = 'green'; + } + + echo '
'; + echo '
'.$lang['install_check_'.$php_item['what']].':
'; + echo '
'.$php_item['value'].'
'; + echo '
'; + } + echo '
'; + + + // SQL + echo '
'; + echo '

'.$lang['install_check_sql'].'

'; + + $sql_check = $this->sqlCheck(); + foreach($sql_check as $sql_item){ + + if($sql_item['error'] == 1){ + $color_class = 'orange'; + } + elseif($sql_item['error'] == 2){ + $color_class = 'red'; + $red_error = true; + } + else{ + $color_class = 'green'; + } + + echo '
'; + echo '
'.$lang['install_check_'.$sql_item['what']].':
'; + echo '
'.$sql_item['value'].'
'; + echo '
'; + } + echo '
'; + + + // OTHER + echo '
'; + echo '

'.$lang['install_check_other'].'

'; + + $other_check = $this->otherCheck(); + foreach($other_check as $other_item){ + + if($other_item['error'] == 1){ + $color_class = 'orange'; + } + elseif($other_item['error'] == 2){ + $color_class = 'red'; + $red_error = true; + } + else{ + $color_class = 'green'; + } + + echo '
'; + echo '
'.$lang['install_check_'.$other_item['what']].':
'; + echo '
'.$other_item['value'].'
'; + echo '
'; + } + echo '
'; + + + // Next button - if no red errors + echo '
'; + echo ' '; + if(!$red_error) + echo ' '; + else + echo ' '; + echo '
'; + } + + + // Preverimo apache + private function apacheCheck(){ + global $lang; + + $result = array(); + + $apache_modules = apache_get_modules(); + + // Mod rewrite + $result['mod_rewrite']['what'] = 'mod_rewrite'; + + if(in_array('mod_rewrite', $apache_modules)){ + $result['mod_rewrite']['value'] = $lang['install_check_ok']; + } + else{ + $result['mod_rewrite']['value'] = $lang['install_check_not_ok']; + $result['mod_rewrite']['error'] = 2; + } + + return $result; + } + + // Preverimo php verzijo + private function phpCheck(){ + global $lang; + + $result = array(); + + + // Php verzija + $php_version = phpversion(); + + $result['version']['what'] = 'php_version'; + $result['version']['value'] = $php_version; + + // Zahtevan je php 7 ali 8.0 + if(substr($php_version, 0, 1) != '7' && substr($php_version, 0, 3) != '8.0'){ + $result['version']['error'] = 2; + } + + + // Php nastavitve + // Open tag + $result['opentag']['what'] = 'short_open_tag'; + if(ini_get('short_open_tag') == '1'){ + $result['opentag']['value'] = $lang['install_check_ok']; + } + else{ + $result['opentag']['value'] = 'Not enabled'; + $result['opentag']['error'] = 2; + } + + // upload_max_filesize - 500M + $result['upload_max_filesize']['what'] = 'upload_max_filesize'; + if((int)str_replace('M', '', ini_get('upload_max_filesize')) >= '500'){ + $result['upload_max_filesize']['value'] = ini_get('upload_max_filesize'); + } + else{ + $result['upload_max_filesize']['value'] = ini_get('upload_max_filesize').' - '.$lang['install_check_upload_max_filesize_error']; + $result['upload_max_filesize']['error'] = 1; + } + + // max_execution_time - 120 + $result['max_execution_time']['what'] = 'max_execution_time'; + if((int)ini_get('max_execution_time') >= 120){ + $result['max_execution_time']['value'] = ini_get('max_execution_time'); + } + else{ + $result['max_execution_time']['value'] = ini_get('max_execution_time').' - '.$lang['install_check_max_execution_time_error']; + $result['max_execution_time']['error'] = 1; + } + + // max_input_time - 120 + $result['max_input_time']['what'] = 'max_input_time'; + if((int)ini_get('max_input_time') >= 120){ + $result['max_input_time']['value'] = ini_get('max_input_time'); + } + else{ + $result['max_input_time']['value'] = ini_get('max_input_time').' - '.$lang['install_check_max_input_time_error']; + $result['max_input_time']['error'] = 1; + } + + // max_input_vars - 8000 + /*$result['max_input_vars']['what'] = 'max_input_vars'; + if((int)ini_get('max_input_vars') >= 8000){ + $result['max_input_vars']['value'] = ini_get('max_input_vars'); + } + else{ + $result['max_input_vars']['value'] = 'Recommended value is 8000'; + $result['max_input_vars']['error'] = true; + }*/ + + // memory_limit - 512M + $result['memory_limit']['what'] = 'memory_limit'; + if((int)str_replace('M', '', ini_get('memory_limit')) >= 512){ + $result['memory_limit']['value'] = ini_get('memory_limit'); + } + else{ + $result['memory_limit']['value'] = ini_get('memory_limit').' - '.$lang['install_check_memory_limit_error']; + $result['memory_limit']['error'] = 1; + } + + // post_max_size - 500M + $result['post_max_size']['what'] = 'post_max_size'; + if((int)str_replace('M', '', ini_get('post_max_size')) >= 500){ + $result['post_max_size']['value'] = ini_get('post_max_size'); + } + else{ + $result['post_max_size']['value'] = ini_get('post_max_size').' - '.$lang['install_check_post_max_size_error']; + $result['post_max_size']['error'] = 1; + } + + + // Php moduli + // Mbstring + $result['mbstring']['what'] = 'mbstring'; + if(extension_loaded('mbstring')){ + $result['mbstring']['value'] = $lang['install_check_ok']; + } + else{ + $result['mbstring']['value'] = $lang['install_check_not_ok']; + $result['mbstring']['error'] = 2; + } + + // Openssl + $result['openssl']['what'] = 'openssl'; + if(extension_loaded('openssl')){ + $result['openssl']['value'] = $lang['install_check_ok']; + } + else{ + $result['openssl']['value'] = $lang['install_check_not_ok']; + $result['openssl']['error'] = 2; + } + + // GD + $result['gd']['what'] = 'gd'; + if(extension_loaded('gd')){ + $result['gd']['value'] = $lang['install_check_ok']; + } + else{ + $result['gd']['value'] = $lang['install_check_not_ok']; + $result['gd']['error'] = 2; + } + + // bcmath + $result['bcmath']['what'] = 'bcmath'; + if(extension_loaded('bcmath')){ + $result['bcmath']['value'] = $lang['install_check_ok']; + } + else{ + $result['bcmath']['value'] = $lang['install_check_not_ok']; + $result['bcmath']['error'] = 2; + } + + // zip + $result['zip']['what'] = 'zip'; + if(extension_loaded('zip')){ + $result['zip']['value'] = $lang['install_check_ok']; + } + else{ + $result['zip']['value'] = $lang['install_check_not_ok']; + $result['zip']['error'] = 2; + } + + + return $result; + } + + // Preverimo sql + private function sqlCheck(){ + global $lang; + + $result = array(); + + // Sql version + $sql_version = mysqli_get_server_info($GLOBALS['connect_db']); + + $result['version']['what'] = 'sql_version'; + $result['version']['value'] = $sql_version; + + if(false){ + $result['version']['error'] = 2; + } + + + // Strict + $sql_mode = sisplet_query("SHOW VARIABLES LIKE 'sql_mode'"); + $row_mode = mysqli_fetch_array($sql_mode); + + $result['strict']['what'] = 'sql_strict'; + + if (strpos($row_mode[0], 'STRICT_TRANS_TABLES') === false) { + $result['strict']['value'] = $lang['install_check_ok']; + } + else{ + $result['strict']['value'] = $lang['install_check_sql_strict_error']; + $result['strict']['error'] = 2; + } + + + return $result; + } + + // Preverimo ostalo + private function otherCheck(){ + global $lang; + + $result = array(); + + + // SED + $output = array(); + exec("sed 2>&1", $output1); + $result['sed']['what'] = 'sed'; + + if(strpos($output1[0], 'not found') === false){ + $result['sed']['value'] = $lang['install_check_ok']; + } + else{ + $result['sed']['value'] = $lang['install_check_sed_error']; + $result['sed']['error'] = 2; + } + + + // AWK + $output = array(); + exec("awk 2>&1", $output); + $result['awk']['what'] = 'awk'; + + if(strpos($output[0], 'not found') === false){ + $result['awk']['value'] = $lang['install_check_ok']; + } + else{ + $result['awk']['value'] = $lang['install_check_awk_error']; + $result['awk']['error'] = 2; + } + + + // Rscript + $output = array(); + exec("Rscript 2>&1", $output); + $result['rscript']['what'] = 'r'; + + if(strpos($output[0], 'not found') === false){ + $result['rscript']['value'] = $lang['install_check_ok']; + } + else{ + $result['rscript']['value'] = $lang['install_check_r_error']; + $result['rscript']['error'] = 1; + } + + + return $result; + } +} \ No newline at end of file diff --git a/frontend/install/classes/class.DisplayDatabase.php b/frontend/install/classes/class.DisplayDatabase.php new file mode 100644 index 0000000..0703ac6 --- /dev/null +++ b/frontend/install/classes/class.DisplayDatabase.php @@ -0,0 +1,112 @@ +'.$lang['install_database_title'].''; + + $import = new ImportDB(); + + // Baza je prazna + if($import->checkDBEmpty()){ + $this->displayInsert(); + } + // Baza ni updatana + elseif($import->checkDBUpdated()){ + $update = $import->getDBUpdateLines(); + $this->displayUpdate($update); + } + // Ok - zadnja verzija baze + else{ + $this->displayOK(); + } + } + + + // Prikazemo ce je vse ok + private function displayOK(){ + global $lang; + + echo '

'.$lang['install_database_ok'].'

'; + + // Next button + echo '
'; + echo ' '; + echo ' '; + echo '
'; + } + + // Prikazemo uvoz celotne baze + private function displayInsert(){ + global $site_url; + global $lang; + + echo '

'.$lang['install_database_import'].'

'; + + echo '

'.$lang['install_database_import_progress'].'

'; + + + // Div kamor izpisemo response po uvazanju + echo '
'; + + + // Next button + echo '
'; + echo ' '; + echo ' '; + echo '
'; + + + // Se popup okna + echo '
'; + echo ''; + } + + // Prikazemo update baze + public function displayUpdate($update){ + global $site_url; + global $lang; + global $debug; + global $admin_type; + + echo '

'.$lang['install_database_update'].'

'; + + echo '

'.$lang['install_database_version'].': '.$update['current_version'].'

'; + + echo '

'.$lang['install_database_version_update'].': '.$update['new_version'].'

'; + + // Ce smo admin ali v debugu izpisemo tudi vrstice za update + if($admin_type == '0' || $debug == '1'){ + + foreach ($update['update_lines'] as $key => $update_line) { + echo $update_line.'

'; + } + } + + + // Div kamor izpisemo response po uvazanju + echo '
'; + + + // Next button + echo '
'; + echo ' '; + echo ' '; + echo '
'; + + + // Se popup okna + echo '
'; + echo ''; + } +} \ No newline at end of file diff --git a/frontend/install/classes/class.DisplaySettings.php b/frontend/install/classes/class.DisplaySettings.php new file mode 100644 index 0000000..f3ea45b --- /dev/null +++ b/frontend/install/classes/class.DisplaySettings.php @@ -0,0 +1,448 @@ +'.$lang['install_settings_title'].''; + + echo '

'.$lang['install_settings_text'].'


'; + + + echo '
'; + + // SEGMENT 1 - app_settings + echo '
'; + $this->displaySettingsApp(); + echo '
'; + + // SEGMENT 2 - email + echo ''; + + // SEGMENT 3 - google + echo '
'; + $this->displaySettingsGoogle(); + echo '
'; + + // SEGMENT 3 - subscribe + echo ''; + + // Submit + echo '
'; + echo ' '; + echo ' '; + echo '
'; + + echo '
'; + + + // Skrijemo nepotrebna text polja + echo ''; + } + + private function displaySettingsApp(){ + global $lang; + global $app_settings; + global $confirm_registration; + + echo '

'.$lang['install_settings_app_title'].'

'; + + // Ime aplikacije + echo '
'; + echo '
'.$lang['install_settings_app_name'].':
'; + echo '
'; + echo '
'; + + // Admin email + echo '
'; + echo '
'.$lang['install_settings_admin_email'].':
'; + echo '
'; + echo '
'; + + // Owner + echo '
'; + echo '
'.$lang['install_settings_owner'].':
'; + echo '
'; + echo '
'; + + // Owner website + echo '
'; + echo '
'.$lang['install_settings_owner_website'].':
'; + echo '
'; + echo '
'; + + + // Custom head title + echo '
'; + echo '
'.$lang['install_settings_head_title_custom'].':
'; + echo '
'; + echo ' '; + echo ' '; + echo '
'; + echo '
'; + + // Custom head title text + echo '
'; + echo '
'.$lang['install_settings_head_title_text'].':
'; + echo '
'; + echo '
'; + + + // Custom foooter + echo ''; + + // Custom footer text + echo ''; + + + // Custom survey foooter + echo ''; + + // Custom footer survey text + echo ''; + + + // Custom email sig + echo '
'; + echo '
'.$lang['install_settings_email_signature_custom'].':
'; + echo '
'; + echo ' '; + echo ' '; + echo '
'; + echo '
'; + + // Custom email sig text + echo '
'; + echo '
'.$lang['install_settings_email_signature_text'].':
'; + echo '
'; + echo '
'; + + + // Survey finish url + echo '
'; + echo '
'.$lang['install_settings_survey_finish_url'].':
'; + echo '
'; + echo '
'; + + + // Export type + echo '
'; + echo '
'.$lang['install_settings_export_type'].':
'; + echo '
'; + echo ' '; + echo ' '; + echo '
'; + echo '
'; + + + // confirm_registration + echo '
'; + echo '
'.$lang['install_settings_confirm_registration'].':
'; + echo '
'; + echo ' '; + echo ' '; + echo '
'; + echo '
'; + } + + private function displaySettingsEmail(){ + global $lang; + global $email_server_settings; + + echo '

'.$lang['install_settings_email_title'].'

'; + + // Email SMTPFrom + echo '
'; + echo '
'.$lang['install_settings_SMTPFrom'].':
'; + echo '
'; + echo '
'; + + // Email SMTPFromNice + echo '
'; + echo '
'.$lang['install_settings_SMTPFromNice'].':
'; + echo '
'; + echo '
'; + + // Email SMTPReplyTo + echo '
'; + echo '
'.$lang['install_settings_SMTPReplyTo'].':
'; + echo '
'; + echo '
'; + + // Email SMTPHost + echo '
'; + echo '
'.$lang['install_settings_SMTPHost'].':
'; + echo '
'; + echo '
'; + + // Email SMTPPort + echo '
'; + echo '
'.$lang['install_settings_SMTPPort'].':
'; + echo '
'; + echo '
'; + + + // Email SMTPAuth + echo '
'; + echo '
'.$lang['install_settings_SMTPAuth'].':
'; + echo '
'; + echo ' '; + echo ' '; + echo '
'; + echo '
'; + + // Email SMTPSecure + echo '
'; + echo '
'.$lang['install_settings_SMTPSecure'].':
'; + echo '
'; + echo ' '; + echo ' '; + echo ' '; + echo '
'; + echo '
'; + + + // Email SMTPUsername + echo '
'; + echo '
'.$lang['install_settings_SMTPUsername'].':
'; + echo '
'; + echo '
'; + + // Email SMTPPassword + echo '
'; + echo '
'.$lang['install_settings_SMTPPassword'].':
'; + echo '
'; + echo '
'; + } + + private function displaySettingsGoogle(){ + global $lang; + global $recaptcha_sitekey; + global $secret_captcha; + global $google_maps_API_key; + + echo '

'.$lang['install_settings_google_title'].'

'; + + // Google recaptcha_sitekey + echo '
'; + echo '
'.$lang['install_settings_recaptcha_sitekey'].':
'; + echo '
'; + echo '
'; + + // Google secret_captcha + echo '
'; + echo '
'.$lang['install_settings_secret_captcha'].':
'; + echo '
'; + echo '
'; + + // Google google_maps_API_key + echo '
'; + echo '
'.$lang['install_settings_google_maps_API_key'].':
'; + echo '
'; + echo '
'; + } + + private function displaySettingsSubscribe(){ + global $lang; + + echo '

'.$lang['install_settings_subscribe_title'].'

'; + + echo '

'.$lang['install_settings_subscribe_text'].'

'; + + echo '
'; + echo '
'.$lang['install_settings_subscribe_radio'].':
'; + echo '
'; + echo ' '; + echo ' '; + echo '
'; + echo '
'; + } + + + // Shranimo nastavitve v settings_optional.php in redirectamo + public function ajaxSubmitSettings(){ + + $new_content = ' \''.$app_name.'\','.PHP_EOL; + + $admin_email = isset($_POST['admin_email']) ? $_POST['admin_email'] : ''; + $new_content .= ' \'admin_email\' => \''.$admin_email.'\','.PHP_EOL; + + $owner = isset($_POST['owner']) ? $_POST['owner'] : ''; + $new_content .= ' \'owner\' => \''.$owner.'\','.PHP_EOL; + + $owner_website = isset($_POST['owner_website']) ? $_POST['owner_website'] : ''; + $new_content .= ' \'owner_website\' => \''.$owner_website.'\','.PHP_EOL; + + $head_title_custom = isset($_POST['head_title_custom']) ? $_POST['head_title_custom'] : ''; + $new_content .= ' \'head_title_custom\' => \''.$head_title_custom.'\','.PHP_EOL; + + $head_title_text = isset($_POST['head_title_text']) ? $_POST['head_title_text'] : ''; + $new_content .= ' \'head_title_text\' => \''.$head_title_text.'\','.PHP_EOL; + + $footer_custom = isset($_POST['footer_custom']) ? $_POST['footer_custom'] : ''; + $new_content .= ' \'footer_custom\' => \''.$footer_custom.'\','.PHP_EOL; + + $footer_text = isset($_POST['footer_text']) ? $_POST['footer_text'] : ''; + $new_content .= ' \'footer_text\' => \''.$footer_text.'\','.PHP_EOL; + + $footer_survey_custom = isset($_POST['footer_survey_custom']) ? $_POST['footer_survey_custom'] : ''; + $new_content .= ' \'footer_survey_custom\' => \''.$footer_survey_custom.'\','.PHP_EOL; + + $footer_survey_text = isset($_POST['footer_survey_text']) ? $_POST['footer_survey_text'] : ''; + $new_content .= ' \'footer_survey_text\' => \''.$footer_survey_text.'\','.PHP_EOL; + + $email_signature_custom = isset($_POST['email_signature_custom']) ? $_POST['email_signature_custom'] : ''; + $new_content .= ' \'email_signature_custom\' => \''.$email_signature_custom.'\','.PHP_EOL; + + $email_signature_text = isset($_POST['email_signature_text']) ? $_POST['email_signature_text'] : ''; + $new_content .= ' \'email_signature_text\' => \''.$email_signature_text.'\','.PHP_EOL; + + $survey_finish_url = isset($_POST['survey_finish_url']) ? $_POST['survey_finish_url'] : ''; + $new_content .= ' \'survey_finish_url\' => \''.$survey_finish_url.'\','.PHP_EOL; + + $export_type = isset($_POST['export_type']) ? $_POST['export_type'] : ''; + $new_content .= ' \'export_type\' => \''.$export_type.'\','.PHP_EOL; + + $new_content .= ');'.PHP_EOL.PHP_EOL; + + + // $email_server_settings + $new_content .= '$email_server_settings = array('.PHP_EOL; + + $SMTPFrom = isset($_POST['SMTPFrom']) ? $_POST['SMTPFrom'] : ''; + $new_content .= ' \'SMTPFrom\' => \''.$SMTPFrom.'\','.PHP_EOL; + + $SMTPFromNice = isset($_POST['SMTPFromNice']) ? $_POST['SMTPFromNice'] : ''; + $new_content .= ' \'SMTPFromNice\' => \''.$SMTPFromNice.'\','.PHP_EOL; + + $SMTPReplyTo = isset($_POST['SMTPReplyTo']) ? $_POST['SMTPReplyTo'] : ''; + $new_content .= ' \'SMTPReplyTo\' => \''.$SMTPReplyTo.'\','.PHP_EOL; + + $SMTPHost = isset($_POST['SMTPHost']) ? $_POST['SMTPHost'] : ''; + $new_content .= ' \'SMTPHost\' => \''.$SMTPHost.'\','.PHP_EOL; + + $SMTPPort = isset($_POST['SMTPPort']) ? $_POST['SMTPPort'] : ''; + $new_content .= ' \'SMTPPort\' => \''.$SMTPPort.'\','.PHP_EOL; + + $SMTPSecure = isset($_POST['SMTPSecure']) ? $_POST['SMTPSecure'] : ''; + $new_content .= ' \'SMTPSecure\' => \''.$SMTPSecure.'\','.PHP_EOL; + + $SMTPAuth = isset($_POST['SMTPAuth']) ? $_POST['SMTPAuth'] : ''; + $new_content .= ' \'SMTPAuth\' => \''.$SMTPAuth.'\','.PHP_EOL; + + $SMTPUsername = isset($_POST['SMTPUsername']) ? $_POST['SMTPUsername'] : ''; + $new_content .= ' \'SMTPUsername\' => \''.$SMTPUsername.'\','.PHP_EOL; + + $SMTPPassword = isset($_POST['SMTPPassword']) ? $_POST['SMTPPassword'] : ''; + $new_content .= ' \'SMTPPassword\' => \''.$SMTPPassword.'\','.PHP_EOL; + + $new_content .= ');'.PHP_EOL.PHP_EOL; + + + // Confirm registration, gdpr + $confirm_registration = isset($_POST['confirm_registration']) ? $_POST['confirm_registration'] : ''; + $new_content .= '$confirm_registration = \''.$confirm_registration.'\';'.PHP_EOL; + + $confirm_registration_admin = $admin_email; + $new_content .= '$confirm_registration_admin = \''.$confirm_registration_admin.'\';'.PHP_EOL; + + $gdpr_admin_email = $admin_email; + $new_content .= '$gdpr_admin_email = \''.$gdpr_admin_email.'\';'.PHP_EOL.PHP_EOL; + + + // Google + $recaptcha_sitekey = isset($_POST['recaptcha_sitekey']) ? $_POST['recaptcha_sitekey'] : ''; + $new_content .= '$recaptcha_sitekey = \''.$recaptcha_sitekey.'\';'.PHP_EOL; + + $secret_captcha = isset($_POST['secret_captcha']) ? $_POST['secret_captcha'] : ''; + $new_content .= '$secret_captcha = \''.$secret_captcha.'\';'.PHP_EOL; + + $google_maps_API_key = isset($_POST['google_maps_API_key']) ? $_POST['google_maps_API_key'] : ''; + $new_content .= '$google_maps_API_key = \''.$google_maps_API_key.'\';'.PHP_EOL.PHP_EOL; + + + // Zapisemo nov content v settings_optional.php + $this->writeSettings($new_content); + + + // Preverimo prijavo na prejemanje obvestil - potem pošljemo obvestilo na www.1ka.si + $subscribe = isset($_POST['subscribe']) ? $_POST['subscribe'] : '0'; + if($subscribe == '1') + $this->sendNotification($app_name, $admin_email); + } + + // Zapisemo nov content v settings_optional.php + private function writeSettings($new_content){ + + $file_handle = fopen("../../settings_optional.php", "w"); + fwrite($file_handle, $new_content); + fclose($file_handle); + } + + // Pošljemo obvestilo o prijava na obvestila za novo instalacijo + private function sendNotification($app_name, $admin_email){ + global $site_domain; + global $site_url; + + $parameters = 'site_domain='.urlencode($site_domain); + $parameters .= '&site_url='.urlencode($site_url); + $parameters .= '&app_name='.urlencode($app_name); + $parameters .= '&admin_email='.urlencode($admin_email); + + //$url = 'http://localhost/utils/1kaUtils/custom_install_notify.php?'.$parameters; + $url = 'https://www.1ka.si/utils/1kaUtils/custom_install_notify.php?'.$parameters; + + // Pripravimo klic + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + // Izvedemo klic + $result = curl_exec($ch); + } + +} \ No newline at end of file diff --git a/frontend/install/classes/class.ImportDB.php b/frontend/install/classes/class.ImportDB.php new file mode 100644 index 0000000..5ba632f --- /dev/null +++ b/frontend/install/classes/class.ImportDB.php @@ -0,0 +1,256 @@ + 0){ + $row = mysqli_fetch_array($sql); + $this->version = $row['value']; + } + } + + + // Pogledamo ce je baza uvozena + public function checkDBEmpty(){ + + return ($this->version == '') ? true : false; + } + + // Pogledamo ce je baza posodobljena na najnovejso verzijo + public function checkDBUpdated(){ + + $update = $this->prepareUpdateArray(); + + return (count($update['update_lines']) != 0) ? true : false; + } + + // Vrnemo vrstice in verzijo za updatanje + public function getDBUpdateLines(){ + + $update = $this->prepareUpdateArray(); + + $update['current_version'] = $this->version; + + return $update; + } + + + // Izvajamo uvoz celotne baze + public function executeImport(){ + global $site_url; + global $lang; + + // Pripravimo vrstice za uvoz + $import = $this->prepareImportArray(); + + // Uvozimo novo bazo + $this->importCleanDB($import); + + // Ce je bilo vse ok potem izvedemo se posodobitev + $sql = sisplet_query("SELECT * FROM misc WHERE what='version'"); + if($sql !== FALSE && mysqli_num_rows($sql) > 0){ + + $row = mysqli_fetch_array($sql); + $this->version = $row['value']; + + // Pripravimo vrstice za posodobitev + $update = $this->prepareUpdateArray(); + + // Izvedemo posodobitev + $this->updateDB($update['new_version'], $update['update_lines']); + + echo $lang['install_database_import_complete']; + } + // Uvoz error + else{ + echo $lang['install_database_import_error']; + } + } + + // Pripravimo vrstice za uvoz + private function prepareImportArray(){ + global $lang; + + $import_lines = array(); + $query = ''; + + $handle = fopen($this->clean_db_file, "r"); + if ($handle) { + while (($line = fgets($handle)) !== false){ + + // Trimamo odvecne presledke + $line = trim($line); + + // Shranimo vrstico za update + if($line != '' && substr($line, 0, 1) != '#' && substr($line, 0, 2) != '--' && substr($line, 0, 2) != '//' && substr($line, 0, 2) != '/*'){ + + // Ce je vrstica zakljucena s ; dodamo query v array + if(substr($line, -1) == ';' || substr($line, 0, 22) == 'INSERT INTO `srv_help`'){ + + $query .= $line; + + $import_lines[] = $query; + $query = ''; + } + // Ukaz je v vecih vrsticah - samo pripnemo string + else{ + $query .= $line; + } + } + } + + fclose($handle); + + // Se dodatno dodamo recnum funkcijo + $import_lines[] = "CREATE FUNCTION MAX_RECNUM (aid INT(11)) RETURNS INT(11) DETERMINISTIC BEGIN DECLARE max INT(11); SELECT MAX(recnum) INTO max FROM srv_user WHERE ank_id = aid AND preview='0'; IF max IS NULL THEN SET max = '0'; END IF; RETURN max+1; END;"; + } + else { + echo $lang['install_database_sql_import_missing']; + } + + return $import_lines; + } + + // Uvoz nove prazne baze po vrsticah + private function importCleanDB($import_lines){ + global $lang; + + // Izvedemo uvoz po posameznih ukazih + if(count($import_lines) > 0){ + foreach ($import_lines as $key => $import_line) { + + $sql = sisplet_query($import_line); + + if (!$sql){ + echo $lang['install_database_import_line'].':
'.$import_line.'
'; + echo $lang['install_database_import_line_error'].': '.mysqli_error($GLOBALS['connect_db']); + + echo '

'; + } + /*else{ + echo 'Uvoz vrstice:
'.$import_line.'
'; + echo 'OK'; + + echo '

'; + }*/ + + flush(); + } + } + } + + + // Izvajamo update celotne baze + public function executeUpdate(){ + global $lang; + + // Pipravimo vrstice za posodobitev + $update = $this->prepareUpdateArray(); + + // Izvedemo update + $this->updateDB($update['new_version'], $update['update_lines']); + + echo $lang['install_database_update_complete']; + } + + // Pripravimo vrstice za posodabljanje + private function prepareUpdateArray(){ + global $lang; + + $new_version = ''; + $update_lines = array(); + $update = false; + $query = ''; + + $handle = fopen($this->update_db_file, "r"); + if ($handle) { + while (($line = fgets($handle)) !== false){ + + // Trimamo odvecne presledke + $line = trim($line); + + // Shranimo vrstico za update + if($update && $line != '' && substr($line, 0, 1) != '#'){ + + // Ce je vrstica zakljucena s ; dodamo query v array + if(substr($line, -1) == ';'){ + + $query .= $line; + + // Pogledamo ce gre za vrstico verzije in jo shranimo + if(strpos($query, ' WHERE what="version"') !== false){ + if (preg_match("/^update misc set value='(.*)' where what=/i", $query, $matches)) { + $new_version = $matches[1]; + } + } + + $update_lines[] = $query; + $query = ''; + } + // Ukaz je v vecih vrsticah - samo pripnemo string + else{ + $query .= $line; + } + } + + // Ko pridemo do vrstice za trenutno verzijo shranimo vse nadaljne vrstice za update + if(strpos($line, $this->version) !== false) + $update = true; + } + + fclose($handle); + } + else { + echo $lang['install_database_sql_update_missing']; + } + + return array('new_version'=>$new_version, 'update_lines'=>$update_lines); + } + + // Izvedba popravkov od trenutne verzije naprej po vrsticah + private function updateDB($new_version, $update_lines){ + global $lang; + + // Izvedemo posodobitve + if($new_version != '' && count($update_lines) > 0){ + + foreach ($update_lines as $key => $update_line) { + + $sql = sisplet_query($update_line); + + if (!$sql){ + echo $lang['install_database_update_line'].':
'.$update_line.'
'; + echo $lang['install_database_update_error'].': '.mysqli_error($GLOBALS['connect_db']); + + echo '

'; + } + /*else{ + echo 'Posodabljanje vrstice:
'.$update_line.'
'; + echo 'OK'; + + echo '

'; + }*/ + + flush(); + } + } + } +} + +?> \ No newline at end of file -- cgit v1.2.3