diff options
Diffstat (limited to 'frontend/install/classes')
-rw-r--r-- | frontend/install/classes/class.Display.php | 231 | ||||
-rw-r--r-- | frontend/install/classes/class.DisplayCheck.php | 392 | ||||
-rw-r--r-- | frontend/install/classes/class.DisplayDatabase.php | 112 | ||||
-rw-r--r-- | frontend/install/classes/class.DisplaySettings.php | 448 | ||||
-rw-r--r-- | frontend/install/classes/class.ImportDB.php | 256 |
5 files changed, 1439 insertions, 0 deletions
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 @@ +<?php
+
+
+ini_set('display_errors', 1);
+ini_set('display_startup_errors', 1);
+error_reporting(E_ALL);
+
+
+include_once '../../function.php';
+
+include_once 'classes/class.DisplayCheck.php';
+include_once 'classes/class.DisplaySettings.php';
+include_once 'classes/class.ImportDB.php';
+include_once 'classes/class.DisplayDatabase.php';
+
+
+class Display{
+
+ var $stran; // stran na kateri se nahajamo
+
+ var $lang_id = 1; // izbran jezik
+
+
+ function __construct(){
+ global $admin_type;
+ global $site_url;
+ global $lang;
+ global $global_user_id;
+
+
+ if(isset($_GET['step']))
+ $this->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 ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
+ echo ' <meta charset="utf-8">';
+
+ echo ' <meta name = "viewport" content = "user-scalable=no, initial-scale=1.0, maximum-scale=1.0, width=device-width">';
+
+ echo ' <meta name="keywords" content="web survey software, internet survey, online survey, web questionaires">';
+ echo ' <meta name="keywords" content="spletne ankete, spletna anketa, spletno anketiranje, internetne ankete, slovenščina, slovenski jezik, software, softver, programska oprema, orodje za spletne ankete, internetno anketiranje, online vprašalniki, ankete po internetu, internet, internetne ankete, anketa" lang="si">';
+ echo ' <meta name="description" content="1KA je orodje za spletne ankete, hkrati pa je tudi on-line platforma (gostitelj), na kateri se lahko spletna anketa brezplačno izdela.">';
+ echo ' <meta name="abstract" content="1KA je orodje za spletne ankete">';
+ echo ' <meta name="author" content="CDI, FDV">';
+ echo ' <meta name="publisher" content="">';
+ echo ' <meta name="copyright" content="CDI, FDV">';
+ echo ' <meta name="audience" content="splošna populacija">';
+ echo ' <meta name="page-topic" content="spletne aplikacije">';
+ echo ' <meta name="revisit-after" content="7">';
+
+ echo ' <title>'.$lang['install_title'].'</title>';
+
+ echo ' <!-- CSS -->';
+ echo ' <link type="text/css" href="css/style.css" rel="stylesheet" />';
+ echo ' <link type="text/css" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css" rel="stylesheet" /">';
+
+ echo ' <!-- JAVASCRIPT -->';
+ echo ' <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>';
+ echo ' <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>';
+ echo ' <script type="text/javascript" src="https://www.google.com/recaptcha/api.js"></script>';
+
+ echo ' <script type="text/javascript" src="script/init.js"></script>';
+ echo ' <script type="text/javascript" src="script/script.js"></script>';
+
+ echo ' <!-- FAVICON -->';
+ echo ' <link rel="shortcut icon" type="image/ico" href="../../favicon.ico" />';
+ }
+
+
+ // Izris zgornje vrstice z logotipom in menijem
+ public function displayHeader(){
+ global $lang;
+
+ // Logo v glavi
+ echo '<div class="logo ">';
+
+ echo ' <a href="index.php">';
+ echo ' <img src="../../public/img/logo/1ka_'.($this->lang_id != 1 ? 'eng' : 'slo').'.svg">';
+ echo ' </a>';
+
+ echo '</div>';
+
+
+ // Navigacija
+ echo '<nav>';
+
+ // Hidden polje z lang_id-jem
+ echo ' <input type="hidden" name="lang_id" value="'.$this->lang_id.'" />';
+
+ // Preklop jezika
+ echo '<span class="menu_item lang_switch">';
+ $params = '?' . (isset($_GET['step']) ? 'step='.$_GET['step'] : '');
+ if($this->lang_id == 1){
+ echo ' <a href="index.php'.$params.'&lang_id=2">';
+ echo ' <div class="flag eng"></div> <span>English</span>';
+ echo ' </a>';
+ }
+ else{
+ echo ' <a href="index.php'.$params.'&lang_id=1">';
+ echo ' <div class="flag slo"></div> <span>Slovenščina</span>';
+ echo '</a>';
+ }
+ echo '</span>';
+
+ echo '</nav>';
+ }
+
+ // Izris vsebine
+ public function displayMain(){
+ global $lang;
+
+ echo '<div class="main_content '.$this->stran.'">';
+
+ //echo '<h1>'.$lang['install_title'].'</h1>';
+
+ 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 '</div>';
+ }
+
+ // Izris footerja
+ public function displayFooter(){
+ global $lang;
+ global $site_url;
+
+ // Stolpec 1
+ echo '<div class="col">';
+ echo ' <h2>'.$lang['simple_footer_about'].'</h2>';
+ echo ' <span>'.$lang['simple_footer_about_1ka'].'</span>';
+ echo ' <span>'.$lang['simple_footer_about_general'].'</span>';
+ echo ' <span>'.$lang['simple_footer_about_privacy'].'</span>';
+ echo ' <span>'.$lang['simple_footer_about_cookies'].'</span>';
+ echo ' <span>'.$lang['simple_footer_about_antispam'].'</span>';
+ echo ' <div class="follow">'.$lang['simple_footer_about_follow'].': ';
+ echo ' <a href="https://twitter.com/enklikanketa" target="_blank"><span class="icon twitter"></span></a>';
+ echo ' <a href="https://www.facebook.com/1KA-123545614388521/" target="_blank"><span class="icon fb"></span></a>';
+ echo ' </div>';
+ echo '</div>';
+
+ // Stolpec 2 - logotipi
+ echo '<div class="col">';
+
+ // Logotipa FDV in CDI
+ echo '<div class="logo_holder">';
+ echo ' <img src="'.$site_url.'/public/img/logo/fdv.png">';
+ echo ' <img src="'.$site_url.'/public/img/logo/cdi_'.($this->lang_id != 1 ? 'eng' : 'slo').'.png">';
+ echo '</div>';
+
+ echo '</div>';
+
+ // Stolpec 3
+ echo '<div class="col">';
+
+ echo '</div>';
+ }
+
+
+ // Izris prve welcome
+ private function displayWelcomePage(){
+ global $lang;
+
+ echo '<h2>'.$lang['install_welcome_title'].'</h2>';
+
+ echo '<p>'.$lang['install_welcome_text'].'</p>';
+
+ // Next button
+ echo '<div class="bottom_buttons">';
+ echo ' <a href="index.php?step=check"><input type="button" value="'.$lang['next1'].'"></a>';
+ echo '</div>';
+ }
+
+ // Izris strani za preverjanje konfiguracije streznika, baze
+ private function displayFinishPage(){
+ global $lang;
+
+ echo '<h2>'.$lang['install_finish_title'].'</h2>';
+
+ echo '<p>'.$lang['install_finish_text'].'</p>';
+
+ // Redirect na naslovnico
+ echo '<div class="bottom_buttons">';
+ echo ' <a href="index.php?step=database"><input name="back" value="'.$lang['back'].'" type="button"></a>';
+ echo ' <a href="/index.php"><input type="button" value="'.$lang['install_finish_redirect'].'"></a>';
+ echo '</div>';
+ }
+}
\ 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 @@ +<?php
+
+
+class DisplayCheck{
+
+
+ function __construct(){
+
+ }
+
+
+ // Izris strani za preverjanje konfiguracije streznika, baze
+ public function displayCheckPage(){
+ global $lang;
+
+ echo '<h2>'.$lang['install_check_title'].'</h2>';
+
+ echo '<p>'.$lang['install_check_text'].'</p><br/>';
+
+
+ $red_error = false;
+
+ // APACHE
+ echo '<div class="check_segment apache">';
+ echo '<h3>'.$lang['install_check_apache'].'</h3>';
+
+ $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 '<div class="check_item">';
+ echo ' <div class="what">'.$lang['install_check_'.$apache_item['what']].':</div>';
+ echo ' <div class="value '.$color_class.'">'.$apache_item['value'].'</div>';
+ echo '</div>';
+ }
+ echo '</div>';
+
+
+ // PHP
+ echo '<div class="check_segment php">';
+ echo '<h3>'.$lang['install_check_php'].'</h3>';
+
+ $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 '<div class="check_item">';
+ echo ' <div class="what">'.$lang['install_check_'.$php_item['what']].':</div>';
+ echo ' <div class="value '.$color_class.'">'.$php_item['value'].'</div>';
+ echo '</div>';
+ }
+ echo '</div>';
+
+
+ // SQL
+ echo '<div class="check_segment sql">';
+ echo '<h3>'.$lang['install_check_sql'].'</h3>';
+
+ $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 '<div class="check_item">';
+ echo ' <div class="what">'.$lang['install_check_'.$sql_item['what']].':</div>';
+ echo ' <div class="value '.$color_class.'">'.$sql_item['value'].'</div>';
+ echo '</div>';
+ }
+ echo '</div>';
+
+
+ // OTHER
+ echo '<div class="check_segment other">';
+ echo '<h3>'.$lang['install_check_other'].'</h3>';
+
+ $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 '<div class="check_item">';
+ echo ' <div class="what">'.$lang['install_check_'.$other_item['what']].':</div>';
+ echo ' <div class="value '.$color_class.'">'.$other_item['value'].'</div>';
+ echo '</div>';
+ }
+ echo '</div>';
+
+
+ // Next button - if no red errors
+ echo '<div class="bottom_buttons">';
+ echo ' <a href="index.php?step=welcome"><input name="back" value="'.$lang['back'].'" type="button"></a>';
+ if(!$red_error)
+ echo ' <a href="index.php?step=settings"><input type="button" value="'.$lang['next1'].'"></a>';
+ else
+ echo ' <a href="index.php?step=check"><input type="button" value="Ponovno preveri"></a>';
+ echo '</div>';
+ }
+
+
+ // 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 @@ +<?php
+
+
+class DisplayDatabase{
+
+
+ function __construct(){
+
+ }
+
+
+ // Izris strani za preverjanje konfiguracije streznika, baze
+ public function displayDatabasePage(){
+ global $lang;
+
+ echo '<h2>'.$lang['install_database_title'].'</h2>';
+
+ $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 '<p>'.$lang['install_database_ok'].'</p>';
+
+ // Next button
+ echo '<div class="bottom_buttons">';
+ echo ' <a href="index.php?step=settings"><input name="back" value="'.$lang['back'].'" type="button"></a>';
+ echo ' <a href="index.php?step=finish"><input type="button" value="'.$lang['next1'].'"></a>';
+ echo '</div>';
+ }
+
+ // Prikazemo uvoz celotne baze
+ private function displayInsert(){
+ global $site_url;
+ global $lang;
+
+ echo '<p>'.$lang['install_database_import'].'</p>';
+
+ echo '<p>'.$lang['install_database_import_progress'].'</p>';
+
+
+ // Div kamor izpisemo response po uvazanju
+ echo '<div id="db_response"></div>';
+
+
+ // Next button
+ echo '<div class="bottom_buttons">';
+ echo ' <a href="index.php?step=settings"><input name="back" value="'.$lang['back'].'" type="button"></a>';
+ echo ' <a href="#" onClick="databaseImport();"><input type="button" value="'.$lang['install_database_button_import'].'"></a>';
+ echo '</div>';
+
+
+ // Se popup okna
+ echo '<div id="fade"></div>';
+ echo '<div id="popup"> '.$lang['install_database_import_progress'].'</div>';
+ }
+
+ // Prikazemo update baze
+ public function displayUpdate($update){
+ global $site_url;
+ global $lang;
+ global $debug;
+ global $admin_type;
+
+ echo '<p>'.$lang['install_database_update'].'</p>';
+
+ echo '<p>'.$lang['install_database_version'].': <b>'.$update['current_version'].'</b></p>';
+
+ echo '<p>'.$lang['install_database_version_update'].': <b>'.$update['new_version'].'</b></p>';
+
+ // 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.'<br /><br />';
+ }
+ }
+
+
+ // Div kamor izpisemo response po uvazanju
+ echo '<div id="db_response"></div>';
+
+
+ // Next button
+ echo '<div class="bottom_buttons">';
+ echo ' <a href="index.php?step=settings"><input name="back" value="'.$lang['back'].'" type="button"></a>';
+ echo ' <a href="#" onClick="databaseUpdate();"><input type="button" value="'.$lang['install_database_button_update'].'"></a>';
+ echo '</div>';
+
+
+ // Se popup okna
+ echo '<div id="fade"></div>';
+ echo '<div id="popup"> '.$lang['install_database_update_progress'].'</div>';
+ }
+}
\ 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 @@ +<?php
+
+
+class DisplaySettings{
+
+
+ function __construct(){
+
+ }
+
+
+ // Izris strani za preverjanje konfiguracije streznika, baze
+ public function displaySettingsPage(){
+ global $lang;
+
+ echo '<h2>'.$lang['install_settings_title'].'</h2>';
+
+ echo '<p>'.$lang['install_settings_text'].'</p><br/>';
+
+
+ echo '<form name="settings_form" id="settings_form" action="index.php?step=settings" method="post">';
+
+ // SEGMENT 1 - app_settings
+ echo '<div class="settings_segment app">';
+ $this->displaySettingsApp();
+ echo '</div>';
+
+ // SEGMENT 2 - email
+ echo '<div class="settings_segment email">';
+ $this->displaySettingsEmail();
+ echo '</div>';
+
+ // SEGMENT 3 - google
+ echo '<div class="settings_segment google">';
+ $this->displaySettingsGoogle();
+ echo '</div>';
+
+ // SEGMENT 3 - subscribe
+ echo '<div class="settings_segment subscribe">';
+ $this->displaySettingsSubscribe();
+ echo '</div>';
+
+ // Submit
+ echo '<div class="bottom_buttons">';
+ echo ' <a href="index.php?step=check"><input name="back" value="'.$lang['back'].'" type="button"></a>';
+ echo ' <a href="#" onClick="settingsSubmit();"><input name="submit" value="'.$lang['next1'].'" type="button"></a>';
+ echo '</div>';
+
+ echo '</form>';
+
+
+ // Skrijemo nepotrebna text polja
+ echo '<script>settingsToggle();</script>';
+ }
+
+ private function displaySettingsApp(){
+ global $lang;
+ global $app_settings;
+ global $confirm_registration;
+
+ echo '<h3>'.$lang['install_settings_app_title'].'</h3>';
+
+ // Ime aplikacije
+ echo '<div class="settings_item text">';
+ echo ' <div class="what">'.$lang['install_settings_app_name'].':</div>';
+ echo ' <div class="value"><input type="text" name="app_name" value="'.$app_settings['app_name'].'"></div>';
+ echo '</div>';
+
+ // Admin email
+ echo '<div class="settings_item text">';
+ echo ' <div class="what">'.$lang['install_settings_admin_email'].':</div>';
+ echo ' <div class="value"><input type="text" name="admin_email" value="'.$app_settings['admin_email'].'"></div>';
+ echo '</div>';
+
+ // Owner
+ echo '<div class="settings_item text">';
+ echo ' <div class="what">'.$lang['install_settings_owner'].':</div>';
+ echo ' <div class="value"><input type="text" name="owner" value="'.$app_settings['owner'].'"></div>';
+ echo '</div>';
+
+ // Owner website
+ echo '<div class="settings_item text">';
+ echo ' <div class="what">'.$lang['install_settings_owner_website'].':</div>';
+ echo ' <div class="value"><input type="text" name="owner_website" value="'.$app_settings['owner_website'].'"></div>';
+ echo '</div>';
+
+
+ // Custom head title
+ echo '<div class="settings_item radio head_title_custom">';
+ echo ' <div class="what">'.$lang['install_settings_head_title_custom'].':</div>';
+ echo ' <div class="value">';
+ echo ' <input type="radio" name="head_title_custom" id="head_title_custom_0" value="0" '.($app_settings['head_title_custom'] != '1' ? 'checked="checked"' : '').' onClick="settingsToggle();"><label for="head_title_custom_0">'.$lang['no'].'</label>';
+ echo ' <input type="radio" name="head_title_custom" id="head_title_custom_1" value="1" '.($app_settings['head_title_custom'] == '1' ? 'checked="checked"' : '').' onClick="settingsToggle();"><label for="head_title_custom_1">'.$lang['yes'].'</label>';
+ echo ' </div>';
+ echo '</div>';
+
+ // Custom head title text
+ echo '<div class="settings_item text head_title_text">';
+ echo ' <div class="what">'.$lang['install_settings_head_title_text'].':</div>';
+ echo ' <div class="value"><input type="text" name="head_title_text" value="'.$app_settings['head_title_text'].'"></div>';
+ echo '</div>';
+
+
+ // Custom foooter
+ echo '<div class="settings_item radio footer_custom">';
+ echo ' <div class="what">'.$lang['install_settings_footer_custom'].':</div>';
+ echo ' <div class="value">';
+ echo ' <input type="radio" name="footer_custom" id="footer_custom_0" value="0" '.($app_settings['footer_custom'] != '1' ? 'checked="checked"' : '').' onClick="settingsToggle();"><label for="footer_custom_0">'.$lang['no'].'</label>';
+ echo ' <input type="radio" name="footer_custom" id="footer_custom_1" value="1" '.($app_settings['footer_custom'] == '1' ? 'checked="checked"' : '').' onClick="settingsToggle();"><label for="footer_custom_1">'.$lang['yes'].'</label>';
+ echo ' </div>';
+ echo '</div>';
+
+ // Custom footer text
+ echo '<div class="settings_item text footer_text">';
+ echo ' <div class="what">'.$lang['install_settings_footer_text'].':</div>';
+ echo ' <div class="value"><input type="text" name="footer_text" value="'.$app_settings['footer_text'].'"></div>';
+ echo '</div>';
+
+
+ // Custom survey foooter
+ echo '<div class="settings_item radio footer_survey_custom">';
+ echo ' <div class="what">'.$lang['install_settings_footer_survey_custom'].':</div>';
+ echo ' <div class="value">';
+ echo ' <input type="radio" name="footer_survey_custom" id="footer_survey_custom_0" value="0" '.($app_settings['footer_survey_custom'] != '1' ? 'checked="checked"' : '').' onClick="settingsToggle();"><label for="footer_survey_custom_0">'.$lang['no'].'</label>';
+ echo ' <input type="radio" name="footer_survey_custom" id="footer_survey_custom_1" value="1" '.($app_settings['footer_survey_custom'] == '1' ? 'checked="checked"' : '').' onClick="settingsToggle();"><label for="footer_survey_custom_1">'.$lang['yes'].'</label>';
+ echo ' </div>';
+ echo '</div>';
+
+ // Custom footer survey text
+ echo '<div class="settings_item text footer_survey_text">';
+ echo ' <div class="what">'.$lang['install_settings_footer_survey_text'].':</div>';
+ echo ' <div class="value"><input type="text" name="footer_survey_text" value="'.$app_settings['footer_survey_text'].'"></div>';
+ echo '</div>';
+
+
+ // Custom email sig
+ echo '<div class="settings_item radio email_signature_custom">';
+ echo ' <div class="what">'.$lang['install_settings_email_signature_custom'].':</div>';
+ echo ' <div class="value">';
+ echo ' <input type="radio" name="email_signature_custom" id="email_signature_custom_0" value="0" '.($app_settings['email_signature_custom'] != '1' ? 'checked="checked"' : '').' onClick="settingsToggle();"><label for="email_signature_custom_0">'.$lang['no'].'</label>';
+ echo ' <input type="radio" name="email_signature_custom" id="email_signature_custom_1" value="1" '.($app_settings['email_signature_custom'] == '1' ? 'checked="checked"' : '').' onClick="settingsToggle();"><label for="email_signature_custom_1">'.$lang['yes'].'</label>';
+ echo ' </div>';
+ echo '</div>';
+
+ // Custom email sig text
+ echo '<div class="settings_item text email_signature_text">';
+ echo ' <div class="what">'.$lang['install_settings_email_signature_text'].':</div>';
+ echo ' <div class="value"><input type="text" name="email_signature_text" value="'.$app_settings['email_signature_text'].'"></div>';
+ echo '</div>';
+
+
+ // Survey finish url
+ echo '<div class="settings_item text">';
+ echo ' <div class="what">'.$lang['install_settings_survey_finish_url'].':</div>';
+ echo ' <div class="value"><input type="text" name="survey_finish_url" value="'.$app_settings['survey_finish_url'].'"></div>';
+ echo '</div>';
+
+
+ // Export type
+ echo '<div class="settings_item radio">';
+ echo ' <div class="what">'.$lang['install_settings_export_type'].':</div>';
+ echo ' <div class="value">';
+ echo ' <input type="radio" name="export_type" id="export_type_0" value="old" '.($app_settings['export_type'] != 'new' ? 'checked="checked"' : '').'><label for="export_type_0">'.$lang['install_settings_export_type_0'].'</label>';
+ echo ' <input type="radio" name="export_type" id="export_type_1" value="new" '.($app_settings['export_type'] == 'new' ? 'checked="checked"' : '').'><label for="export_type_1">'.$lang['install_settings_export_type_1'].'</label>';
+ echo ' </div>';
+ echo '</div>';
+
+
+ // confirm_registration
+ echo '<div class="settings_item radio">';
+ echo ' <div class="what">'.$lang['install_settings_confirm_registration'].':</div>';
+ echo ' <div class="value">';
+ echo ' <input type="radio" name="confirm_registration" id="confirm_registration_0" value="0" '.($confirm_registration != '1' ? 'checked="checked"' : '').'><label for="confirm_registration_0">'.$lang['no'].'</label>';
+ echo ' <input type="radio" name="confirm_registration" id="confirm_registration_1" value="1" '.($confirm_registration == '1' ? 'checked="checked"' : '').'><label for="confirm_registration_1">'.$lang['yes'].'</label>';
+ echo ' </div>';
+ echo '</div>';
+ }
+
+ private function displaySettingsEmail(){
+ global $lang;
+ global $email_server_settings;
+
+ echo '<h3>'.$lang['install_settings_email_title'].'</h3>';
+
+ // Email SMTPFrom
+ echo '<div class="settings_item text">';
+ echo ' <div class="what">'.$lang['install_settings_SMTPFrom'].':</div>';
+ echo ' <div class="value"><input type="text" name="SMTPFrom" value="'.$email_server_settings['SMTPFrom'].'"></div>';
+ echo '</div>';
+
+ // Email SMTPFromNice
+ echo '<div class="settings_item text">';
+ echo ' <div class="what">'.$lang['install_settings_SMTPFromNice'].':</div>';
+ echo ' <div class="value"><input type="text" name="SMTPFrom" value="'.$email_server_settings['SMTPFromNice'].'"></div>';
+ echo '</div>';
+
+ // Email SMTPReplyTo
+ echo '<div class="settings_item text">';
+ echo ' <div class="what">'.$lang['install_settings_SMTPReplyTo'].':</div>';
+ echo ' <div class="value"><input type="text" name="SMTPReplyTo" value="'.$email_server_settings['SMTPReplyTo'].'"></div>';
+ echo '</div>';
+
+ // Email SMTPHost
+ echo '<div class="settings_item text">';
+ echo ' <div class="what">'.$lang['install_settings_SMTPHost'].':</div>';
+ echo ' <div class="value"><input type="text" name="SMTPHost" value="'.$email_server_settings['SMTPHost'].'"></div>';
+ echo '</div>';
+
+ // Email SMTPPort
+ echo '<div class="settings_item text">';
+ echo ' <div class="what">'.$lang['install_settings_SMTPPort'].':</div>';
+ echo ' <div class="value"><input type="text" name="SMTPPort" value="'.$email_server_settings['SMTPPort'].'"></div>';
+ echo '</div>';
+
+
+ // Email SMTPAuth
+ echo '<div class="settings_item radio">';
+ echo ' <div class="what">'.$lang['install_settings_SMTPAuth'].':</div>';
+ echo ' <div class="value">';
+ echo ' <input type="radio" name="SMTPAuth" id="SMTPAuth_0" value="0" '.($email_server_settings['SMTPAuth'] != '1' ? 'checked="checked"' : '').'><label for="SMTPAuth_0">'.$lang['no'].'</label>';
+ echo ' <input type="radio" name="SMTPAuth" id="SMTPAuth_1" value="1" '.($email_server_settings['SMTPAuth'] == '1' ? 'checked="checked"' : '').'><label for="SMTPAuth_1">'.$lang['yes'].'</label>';
+ echo ' </div>';
+ echo '</div>';
+
+ // Email SMTPSecure
+ echo '<div class="settings_item radio">';
+ echo ' <div class="what">'.$lang['install_settings_SMTPSecure'].':</div>';
+ echo ' <div class="value">';
+ echo ' <input type="radio" name="SMTPSecure" id="SMTPSecure_0" value="0" '.($email_server_settings['SMTPSecure'] != 'ssl' && $email_server_settings['SMTPSecure'] != 'tls' ? 'checked="checked"' : '').'><label for="SMTPSecure_0">'.$lang['no'].'</label>';
+ echo ' <input type="radio" name="SMTPSecure" id="SMTPSecure_1" value="ssl" '.($email_server_settings['SMTPSecure'] == 'ssl' ? 'checked="checked"' : '').'><label for="SMTPSecure_1">SSL</label>';
+ echo ' <input type="radio" name="SMTPSecure" id="SMTPSecure_2" value="tls" '.($email_server_settings['SMTPSecure'] == 'tls' ? 'checked="checked"' : '').'><label for="SMTPSecure_2">TLS</label>';
+ echo ' </div>';
+ echo '</div>';
+
+
+ // Email SMTPUsername
+ echo '<div class="settings_item text">';
+ echo ' <div class="what">'.$lang['install_settings_SMTPUsername'].':</div>';
+ echo ' <div class="value"><input type="text" name="SMTPUsername" value="'.$email_server_settings['SMTPUsername'].'"></div>';
+ echo '</div>';
+
+ // Email SMTPPassword
+ echo '<div class="settings_item text">';
+ echo ' <div class="what">'.$lang['install_settings_SMTPPassword'].':</div>';
+ echo ' <div class="value"><input type="text" name="SMTPPassword" value="'.$email_server_settings['SMTPPassword'].'"></div>';
+ echo '</div>';
+ }
+
+ private function displaySettingsGoogle(){
+ global $lang;
+ global $recaptcha_sitekey;
+ global $secret_captcha;
+ global $google_maps_API_key;
+
+ echo '<h3>'.$lang['install_settings_google_title'].'</h3>';
+
+ // Google recaptcha_sitekey
+ echo '<div class="settings_item text">';
+ echo ' <div class="what">'.$lang['install_settings_recaptcha_sitekey'].':</div>';
+ echo ' <div class="value"><input type="text" name="recaptcha_sitekey" value="'.$recaptcha_sitekey.'"></div>';
+ echo '</div>';
+
+ // Google secret_captcha
+ echo '<div class="settings_item text">';
+ echo ' <div class="what">'.$lang['install_settings_secret_captcha'].':</div>';
+ echo ' <div class="value"><input type="text" name="secret_captcha" value="'.$secret_captcha.'"></div>';
+ echo '</div>';
+
+ // Google google_maps_API_key
+ echo '<div class="settings_item text">';
+ echo ' <div class="what">'.$lang['install_settings_google_maps_API_key'].':</div>';
+ echo ' <div class="value"><input type="text" name="google_maps_API_key" value="'.$google_maps_API_key.'"></div>';
+ echo '</div>';
+ }
+
+ private function displaySettingsSubscribe(){
+ global $lang;
+
+ echo '<h3>'.$lang['install_settings_subscribe_title'].'</h3>';
+
+ echo '<p>'.$lang['install_settings_subscribe_text'].'</p>';
+
+ echo '<div class="settings_item radio">';
+ echo ' <div class="what">'.$lang['install_settings_subscribe_radio'].':</div>';
+ echo ' <div class="value">';
+ echo ' <input type="radio" name="subscribe" id="subscribe_1" value="1" checked="checked"><label for="subscribe_1">'.$lang['yes'].'</label>';
+ echo ' <input type="radio" name="subscribe" id="subscribe_0" value="0"><label for="subscribe_0">'.$lang['no'].'</label>';
+ echo ' </div>';
+ echo '</div>';
+ }
+
+
+ // Shranimo nastavitve v settings_optional.php in redirectamo
+ public function ajaxSubmitSettings(){
+
+ $new_content = '<?php'.PHP_EOL.PHP_EOL;
+
+
+ // Prednastavljena polja
+ $new_content .= '$debug = \'0\';'.PHP_EOL;
+ $new_content .= '$lastna_instalacija = \'1\';'.PHP_EOL;
+ $new_content .= '$email_server_fromSurvey = \'1\';'.PHP_EOL.PHP_EOL;
+
+
+ // $app_settings
+ $new_content .= '$app_settings = array('.PHP_EOL;
+
+ $app_name = isset($_POST['app_name']) ? $_POST['app_name'] : '';
+ $new_content .= ' \'app_name\' => \''.$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 @@ +<?php
+/**
+*
+* Class, ki skrbi za posodabljanje in uvažanje 1ka baze
+*
+*/
+
+class ImportDB{
+
+ var $clean_db_file = '../../sql/1ka_clean_27-7-2020.sql'; // Datoteka prazne baze za uvoz
+ var $update_db_file = '../../sql/update2.sql'; // Datoteka prazne baze za uvoz
+
+ var $version = ''; // Trenutna verzija 1ke
+
+
+ function __construct () {
+
+ // Pogledamo ce je baza ze uvozena
+ $sql = sisplet_query("SELECT * FROM misc WHERE what='version'");
+
+ // Baza je ze uvozena - pogledamo verzijo
+ if($sql !== FALSE && mysqli_num_rows($sql) > 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'].':<br />'.$import_line.'<br />';
+ echo $lang['install_database_import_line_error'].': '.mysqli_error($GLOBALS['connect_db']);
+
+ echo '<br /><br />';
+ }
+ /*else{
+ echo 'Uvoz vrstice:<br />'.$import_line.'<br />';
+ echo 'OK';
+
+ echo '<br /><br />';
+ }*/
+
+ 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'].':<br />'.$update_line.'<br />';
+ echo $lang['install_database_update_error'].': '.mysqli_error($GLOBALS['connect_db']);
+
+ echo '<br /><br />';
+ }
+ /*else{
+ echo 'Posodabljanje vrstice:<br />'.$update_line.'<br />';
+ echo 'OK';
+
+ echo '<br /><br />';
+ }*/
+
+ flush();
+ }
+ }
+ }
+}
+
+?>
\ No newline at end of file |