';
}
elseif ($_GET['a'] == 'quick_title_edit_save') {
$update=array();
if (isset($_POST['naslov']) && trim($_POST['naslov']) != '') {
$update[] = " naslov='".trim($_POST['naslov'])."'";
}
if (isset($_POST['akronim']) && trim($_POST['akronim']) != '') {
$update[] = " akronim='".trim($_POST['akronim'])."'";
}
if (isset($_POST['intro_opomba']) /*&& trim($_POST['intro_opomba']) != ''*/) {
$update[] = " intro_opomba='".trim($_POST['intro_opomba'])."'";
}
if (count($update) > 0 ) {
sisplet_query("UPDATE srv_anketa SET ".implode(',',$update)." WHERE id='".$this->anketa."'");
SurveyInfo :: getInstance()->resetSurveyData();
if (isset($_POST['quick_settings']) && $_POST['quick_settings'] == 'true') {
echo $site_url . 'admin/survey/index.php?anketa=' . $_POST['anketa'].'&a='.A_QUICK_SETTINGS;
return;
}
if (isset($_GET['ajaxa']) && trim($_GET['ajaxa']) != '') {
echo $site_url . 'admin/survey/index.php?anketa=' . $_POST['anketa'].'&a='.$_GET['ajaxa'];
return;
} else {
echo $site_url . 'admin/survey/index.php?anketa=' . $_POST['anketa'];
return;
}
}
if (isset($_POST['quick_settings']) && $_POST['quick_settings'] == 'true') {
echo $site_url . 'admin/survey/index.php?anketa=' . $_POST['anketa'].'&a='.A_QUICK_SETTINGS;
return;
}
echo $site_url . 'admin/survey/index.php?anketa=' . $_POST['anketa'];
return;
}
elseif ($_GET['a'] == 'editanketaintro') {
Common::updateEditStamp();
$show_intro = $_POST['show_intro'];
$show_concl = $_POST['show_concl'];
$concl_link = $_POST['concl_link'];
$intro_opomba = $_POST['intro_opomba'];
$concl_opomba = $_POST['concl_opomba'];
if ($_POST['concl_link'] == 1)
$concl_link = 0;
else
$concl_link = 1;
$sql = sisplet_query("UPDATE srv_anketa SET
introduction='$intro', conclusion='$concl', text='$text', url='$url' ,
show_intro = '$show_intro', show_concl='$show_concl', concl_link='$concl_link',
intro_opomba = '$intro_opomba', concl_opomba = '$concl_opomba'
WHERE id='$anketa'");
// vsilimo refresh podatkov
SurveyInfo :: getInstance()->resetSurveyData();
header('Location: index.php?anketa=' . $anketa . '');
}
elseif ($_GET['a'] == 'settings_anketa') {
$this->anketa = $anketa;
$this->grupa = $grupa;
$this->SurveyAdmin->anketa_nastavitve();
}
elseif ($_GET['a'] == 'editanketasettings') {
Common::updateEditStamp();
#sistemske nastavitve
if ($_GET['m'] == 'system') {
if (isset ($_POST['SurveyDostop'])) {
$val = $_POST['SurveyDostop'];
if ($val >= 0) {
$sql = sisplet_query("UPDATE misc SET value='$val' WHERE what = 'SurveyDostop'");
if (!$sql)
echo mysqli_error($GLOBALS['connect_db']);
}
}
if (isset ($_POST['SurveyCookie'])) {
$val = $_POST['SurveyCookie'];
$sql = sisplet_query("UPDATE misc SET value='$val' WHERE what = 'SurveyCookie'");
if (!$sql)
echo mysqli_error($GLOBALS['connect_db']);
}
if (isset ($_POST['SurveyExport'])) {
$val = $_POST['SurveyExport'];
$sql = sisplet_query("UPDATE misc SET value='$val' WHERE what = 'SurveyExport'");
if (!$sql)
echo mysqli_error($GLOBALS['connect_db']);
}
if (isset ($_POST['SurveyForum'])) {
$val = $_POST['SurveyForum'];
$sql = sisplet_query("UPDATE misc SET value='$val' WHERE what = 'SurveyForum'");
if (!$sql)
echo mysqli_error($GLOBALS['connect_db']);
}
}
elseif ($_GET['m'] == 'global_user_settings') {
if (isset ($_POST['language'])) {
$lang = $_POST['language'];
sisplet_query("UPDATE users SET lang = '$lang' WHERE id = '$global_user_id'");
}
$poslane_spremenljivke = [
'advancedMySurveys',
'oneclickCreateMySurveys',
'lockSurvey',
'autoActiveSurvey',
'activeComments',
'showIntro',
'showConcl',
'showSurveyTitle',
'showSAicon',
'showLanguageShortcut'
];
foreach($poslane_spremenljivke as $post_variable) {
if (isset ($_POST[$post_variable])) {
$val = $_POST[$post_variable];
UserSetting::getInstance()->setUserSetting($post_variable, $val);
UserSetting::getInstance()->saveUserSetting();
}
}
} elseif ($_GET['m'] == 'global_user_myProfile') {
// preveri prejsnje podatke
$sqlU = sisplet_query ("SELECT name, surname, email, pass FROM users WHERE id='".$global_user_id."'");
$rowU = mysqli_fetch_assoc($sqlU);
$name_before = $rowU['name'];
$surname_before = $rowU['surname'];
$email_before = $rowU['email'];
$password_before = $rowU['pass'];
// Spremenimo ime
if (isset($_POST['ime']) && $_POST['ime'] != '' && $_POST['ime'] != $name_before) {
$checkIme = sisplet_query ("SELECT * FROM users WHERE name='".$_POST['ime']."' AND surname='" .$_POST['priimek']."' AND id!='".$global_user_id."'");
if (mysqli_num_rows ($checkIme) == 0){
$ime = $_POST['ime'];
//$ime = strtolower($_POST['ime']);
$ime = CleanXSS($ime);
$result = sisplet_query ("UPDATE users SET name='$ime' WHERE id='".$global_user_id."'");
}
}
// Spremenimo priimek
if (isset($_POST['priimek']) && $_POST['priimek'] != '' && $_POST['priimek'] != $surname_before) {
$checkIme = sisplet_query ("SELECT * FROM users WHERE name='".$_POST['ime']."' AND surname='" .$_POST['priimek']."' AND id!='".$global_user_id."'");
if (mysqli_num_rows ($checkIme) == 0){
$priimek = $_POST['priimek'];
//$priimek = strtolower($_POST['priimek']);
$priimek = CleanXSS($priimek);
$result = sisplet_query ("UPDATE users SET surname='$priimek' WHERE id='".$global_user_id."'");
}
}
// Obveščanje posodobi
if(isset($_POST['gdpr_agree'])){
sisplet_query ("UPDATE users SET gdpr_agree='".$_POST['gdpr_agree']."' WHERE id='".$global_user_id."'");
}
if(!empty($_POST['google-2fa']) && !empty($_POST['google-2fa-secret'])){
User::getInstance($global_user_id)->setOption('google-2fa-secret', $_POST['google-2fa-secret']);
User::getInstance($global_user_id)->setOption('google-2fa-validation', 'NOT');
}elseif(!empty($_POST['google_2fa_koda_validate']) && empty($_POST['google-2fa-secret'])){
$google2fa = new \Sonata\GoogleAuthenticator\GoogleAuthenticator();
$secret = User::option($global_user_id, 'google-2fa-secret');
if ($google2fa->checkCode($secret, $_POST['google_2fa_koda_validate'])) {
sisplet_query ("UPDATE user_options SET option_value=NOW() WHERE option_name='google-2fa-validation'");
echo 'success';
return true;
}
}
if(empty($_POST['google-2fa']) && !empty($_POST['google_2fa_akcija']) && $_POST['google_2fa_akcija'] == 'deactivate' && !empty($_POST['google_2fa_deaktiviraj'])){
$user_2fa = User::option($global_user_id, 'google-2fa-secret');
$user_2fa_validate = User::option($global_user_id, 'google_2fa_koda_validate');
$google2fa = new \Sonata\GoogleAuthenticator\GoogleAuthenticator();
if($google2fa->checkCode($user_2fa, $_POST['google_2fa_deaktiviraj']) && $user_2fa_validate != 'NOT'){
sisplet_query("DELETE FROM user_options WHERE user_id='".$global_user_id."' AND option_name IN ('google-2fa-secret', 'google-2fa-validation')");
echo 'success';
return true;
}else{
echo 'error';
return true;
}
}
//Uporabnik si ni kode shranil
if(empty($_POST['google-2fa']) && !empty($_POST['google_2fa_akcija']) && $_POST['google_2fa_akcija'] == 'reset'){
if(User::option($global_user_id, 'google-2fa-validation') == 'NOT') {
sisplet_query("DELETE FROM user_options WHERE user_id='".$global_user_id."' AND option_name IN ('google-2fa-secret', 'google-2fa-validation')");
echo 'success';
return true;
}
}
// Spremenimo geslo
if (isset($_POST['geslo']) && $_POST['geslo'] != '' && $_POST['geslo'] != $password_before) {
global $pass_salt;
global $cookie_domain;
$geslo = $_POST['geslo'];
$geslo = CleanXSS ($geslo);
if (isset($_POST['geslo'])
&& $_POST['geslo'] != "PRIMERZELODOLGEGAGESLA"
&& $password_before != base64_encode((hash('SHA256', $geslo.$pass_salt)))
&& $_POST['geslo'] == $_POST['geslo2']){
$result = sisplet_query ("UPDATE users SET pass='".base64_encode((hash(SHA256, $geslo.$pass_salt)))."' WHERE id='".$global_user_id."'");
setcookie('uid', '', time() - 3600, '/', $cookie_domain);
setcookie('secret', '', time() - 3600, '/', $cookie_domain);
setcookie('unam', '', time() - 3600, '/', $cookie_domain);
global $site_frontend;
if($site_frontend == 'drupal') {
setcookie('spremembaGesla', '1', time() + 3600, '/',
$cookie_domain);
}
}
}
// Alternativni emaili
if (isset($_POST['alternative_email']) && validEmail($_POST['alternative_email'])) {
global $pass_salt;
$email = $_POST['alternative_email'];
// naredi link za aktivacijo
$code = base64_encode((hash('SHA256', time() .$pass_salt . $email. $rowU['name'])));
// Vstavimo novega userja v users_to_be kjer caka na aktivacijo
$insert_id = sisplet_query ("INSERT INTO users_to_be
(type, email, name, user_id, timecode, code, lang)
VALUES
('3', '".$email."', '".$rowU['name']."', '".$global_user_id."', '".time()."', '$code', '" .$lang['id']. "')", "id");
$poslji_email = [];
global $app_settings;
$PageName = $app_settings['app_name'];
// Pošljemo email na alternativni email in nato še na primarni email samo obvestilo o dodanem emailu
$poslji_email['novi'] = [
'email' => $email,
'naslov' => str_replace ("#PAGENAME#", $PageName, $lang['add_alternative_email_subject'])
];
$poslji_email['primarni'] = [
'email' => $email_before,
'naslov' => str_replace ("#PAGENAME#", $PageName, $lang['add_alternative_primary_email_subject'])
];
$uporabnik = sisplet_query("SELECT name, surname FROM users WHERE id='".$global_user_id."'", "obj");
// Sporočilo, ki ga posredujemo na nov email za aktivacijo
$alVsebina = str_replace ("#PRIMARNIEMAIL#", $email_before, $lang['add_alternative_email']);
$alVsebina = str_replace ("#ALTERNATIVNIEMAIL#", $email, $alVsebina);
$alVsebina = str_replace ("#NAME#", $uporabnik->name .' ' .$uporabnik->surname, $alVsebina);
$alVsebina = str_replace ("#PAGENAME#", $PageName, $alVsebina);
$alVsebina = str_replace ("#CODESTART#", '', $alVsebina);
$alVsebina = str_replace ("#CODEEND#", '', $alVsebina);
// Pošljemo še email na primarni email
$prVsebina= str_replace ("#ALTERNATIVNIEMAIL#", $email, $lang['add_alternative_primary_email']);
$prVsebina= str_replace ("#NAME#", $uporabnik->name .' ' .$uporabnik->surname, $prVsebina);
$prVsebina= str_replace ("#PAGENAME#", $PageName, $prVsebina);
// Podpis
$signature = Common::getEmailSignature();
$poslji_email['novi']['vsebina'] = $alVsebina . $signature;
$poslji_email['primarni']['vsebina'] = $prVsebina. $signature;
foreach($poslji_email as $poslji) {
try {
$MA = new MailAdapter();
$MA->addRecipients($poslji['email']);
$MA->sendMail(stripslashes($poslji['vsebina']), $poslji['naslov']);
} catch (Exception $e) {
error_log("Email pri dodajanju emaila ni bil poslan: $e");
}
}
echo 'success';
return true;
}
if (isset($_POST['active_email']) && $_POST['active_email'] != 'new') {
$emails = User::getInstance()->allEmails('without master');
foreach($emails as $email){
$active = 0;
if($email->id == $_POST['active_email'] )
$active = 1;
sisplet_query("UPDATE user_emails SET active='".$active."' WHERE id='".$email->id."'");
}
}
if (isset($_POST['izbrisiAlternativniEmail']) && $_POST['izbrisiAlternativniEmail'] == 1 && !empty($_POST['alternativniEmailId'])) {
sisplet_query("DELETE FROM user_emails WHERE user_id='".$global_user_id."' AND id='".$_POST['alternativniEmailId']."'");
}
// Izbriše račun - v bazi posatvimo na 0 in spremenimo email, da je bil odjavljen
if (isset($_POST['izbrisiRacun']) && $_POST['izbrisiRacun'] == 1) {
global $cookie_domain;
$result = sisplet_query ("UPDATE users SET status=0, email=CONCAT('UNSU8MD-', UNIX_TIMESTAMP(), email) WHERE id='".$global_user_id."'");
setcookie ('uid', '', time()-3600, '/', $cookie_domain);
setcookie ('secret', '', time()-3600, '/', $cookie_domain);
setcookie ('unam', '', time()-3600, '/', $cookie_domain);
echo 'izbrisan';
return null;
}
} elseif ($_GET['m'] == A_MAILING || $_GET['m'] == 'inv_server' || $_GET['m'] == 'email_server') { // smtp mailing
if ($_POST['submited'] == 1){
if ((int)$_POST['anketa'] > 0){
$this->anketa = $_POST['anketa'];
}
// Squalo vklopljen
if(isset($_POST['squalo_mode'])){
// Squalo vklopljen
if($_POST['squalo_mode'] == '1'){echo $_POST['squalo_mode'];
sisplet_query("UPDATE srv_anketa_module SET vrednost='2' WHERE ank_id='".$this->anketa."' AND modul='email'");
}
// Squalo izklopljen
else{
sisplet_query("UPDATE srv_anketa_module SET vrednost='1' WHERE ank_id='".$this->anketa."' AND modul='email'");
$MA = new MailAdapter($this->anketa, $type='alert');
$settings = $MA->getSettingsFromRequest($_REQUEST);
$mode = $_REQUEST['SMTPMailMode'];
$MA->setSettings($mode, $settings);
}
}
else{
$MA = new MailAdapter($this->anketa, $type='alert');
$settings = $MA->getSettingsFromRequest($_REQUEST);
$mode = $_REQUEST['SMTPMailMode'];
$MA->setSettings($mode, $settings);
}
}
} elseif ($_GET['m'] == 'predvidenicasi') { // predvideni casi
foreach($_POST AS $key => $val) {
if (substr($key, 0, 7) == 'timing_') {
GlobalMisc::setMisc($key, $val);
}
}
} else { // globalne nastavitve
if (isset ($_POST['phone']) || isset ($_POST['email'])) {
$phone = $_POST['phone'];
$email = $_POST['email'];
// nastavimo respondente iz baze, kreiramo novo sistemsko spremenljivko
if ($phone == 1 or $email == 1) {
$this->SurveyAdmin->createUserbaseSystemVariable($phone, $email);
$user_base = 1;
} else {
$this->SurveyAdmin->createUserbaseSystemVariable($phone, $email);
$user_base = 0;
$_POST['user_base'] = 0;
}
}
SurveySetting::getInstance()->Init($this->anketa);
if (isset($_POST['resp_change_lang'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('resp_change_lang', $_POST['resp_change_lang']);
}
if (isset($_POST['resp_change_lang_type'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('resp_change_lang_type', $_POST['resp_change_lang_type']);
}
if (isset($_POST['display_backlink'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('display_backlink', $_POST['display_backlink']);
}
if (isset($_POST['mobile_friendly'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('mobile_friendly', $_POST['mobile_friendly']);
}
if (isset($_POST['hide_mobile_img'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('hide_mobile_img', $_POST['hide_mobile_img']);
}
if (isset($_POST['mobile_tables'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('mobile_tables', $_POST['mobile_tables']);
}
if (isset($_POST['export_font_size'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_font_size', $_POST['export_font_size']);
}
if (isset($_POST['export_numbering'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_numbering', $_POST['export_numbering']);
}
if (isset($_POST['export_show_if'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_show_if', $_POST['export_show_if']);
}
if (isset($_POST['export_show_intro'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_show_intro', $_POST['export_show_intro']);
}
if (isset($_POST['export_data_type'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_data_type', $_POST['export_data_type']);
}
if (isset($_POST['export_data_font_size'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_data_font_size', $_POST['export_data_font_size']);
}
if (isset($_POST['export_data_numbering'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_data_numbering', $_POST['export_data_numbering']);
}
if (isset($_POST['export_data_show_if'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_data_show_if', $_POST['export_data_show_if']);
}
if (isset($_POST['export_data_show_recnum'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_data_show_recnum', $_POST['export_data_show_recnum']);
}
if (isset($_POST['export_data_PB'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_data_PB', $_POST['export_data_PB']);
}
if (isset($_POST['export_data_skip_empty'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_data_skip_empty', $_POST['export_data_skip_empty']);
}
if (isset($_POST['export_data_skip_empty_sub'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_data_skip_empty_sub', $_POST['export_data_skip_empty_sub']);
}
if (isset($_POST['export_data_landscape'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('export_data_landscape', $_POST['export_data_landscape']);
}
if (isset($_POST['privacy'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('survey_privacy', $_POST['privacy']);
}
if (isset($_POST['survey_hint'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('survey_hint', $_POST['survey_hint']);
}
if (isset($_POST['survey_hide_title'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('survey_hide_title', $_POST['survey_hide_title']);
}
if (isset($_POST['survey_track_reminders'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('survey_track_reminders', $_POST['survey_track_reminders']);
}
if (isset($_POST['enumerate'])) {
SurveySetting::getInstance()->setSurveyMiscSetting('enumerate', $_POST['enumerate']);
}
if (isset($_POST['anketa_folder'])) {
if($_POST['anketa_folder'] == '0'){
$sql = sisplet_query("DELETE FROM srv_mysurvey_anketa WHERE ank_id='".$anketa."' AND usr_id='".$global_user_id."'");
}
else{
// Razpremo folder v akterega uvrscamo anketo
$sql = sisplet_query("UPDATE srv_mysurvey_folder SET open='1' WHERE id='".$_POST['anketa_folder']."' AND usr_id='".$global_user_id."'");
// Vstavimo anketo
$sql = sisplet_query("INSERT INTO srv_mysurvey_anketa (ank_id, usr_id, folder) VALUES ('".$anketa."', '".$global_user_id."', '".$_POST['anketa_folder']."') ON DUPLICATE KEY UPDATE folder='".$_POST['anketa_folder']."'");
}
}
// shranjujemo dodatne prevode besedil...
if (isset($_POST['extra_translations'])) {
// Preverimo, če dobimo podatek za izbris vseh prevodov
$post = $_POST;
if(!empty($_POST['remove_lang'])){
$post = [];
parse_str($_POST['data'], $post);
}
foreach ($post AS $key => $val) {
if (substr($key, 0, 8) == 'srvlang_') {
if ($val != '' && empty($_POST['remove_lang'])) {
// očistimo HTML tage, če gre za gumbe
if (in_array(substr($key, 8), [
'srv_nextpage',
'srv_nextpage_uvod',
'srv_prevpage',
'srv_lastpage',
'srv_forma_send',
'srv_konec'
])) {
$val = strip_tags($val);
}
// Počistimo besedilo preden shranimo v bazo, saj je bila težava za tuje jezike
$purifier = New Purifier();
$val = $purifier->purify_DB($val);
SurveySetting::getInstance()->setSurveyMiscSetting($key, $val);
} else {
SurveySetting::removeSurveyMiscSetting($key);
}
// pri osnovnem jeziku vnesemo 2x - enkrat brez pripone ID jezika, enkrat s pripono (ker se nekje uporablja eno, nekje drugo...)
if (! is_numeric(substr($key, strrpos($key, '_') + 1))) {
if ($val != '') {
SurveySetting::getInstance()->setSurveyMiscSetting($key.'_'.SurveyInfo::getInstance()->getSurveyColumn('lang_resp'), $val);
} else {
SurveySetting::removeSurveyMiscSetting($key.'_'.SurveyInfo::getInstance()->getSurveyColumn('lang_resp'));
}
}
}
}
}
// Ce imamo vec jezikov popravimo vrednost v sistemskem vprasanju "language"
if(isset($_POST['lang_resp'])){
// Popravljamo samo ce imamo vec jezikov
$sqlL = sisplet_query("SELECT id FROM srv_language WHERE ank_id='$this->anketa'");
if (mysqli_num_rows($sqlL) > 0){
$new_resp_lang_id = $_POST['lang_resp'];
$old_resp_lang_id = SurveyInfo::getInstance()->getSurveyColumn('lang_resp');
// Dobimo id vprasanja
$sqlS = sisplet_query("SELECT s.id AS spr_id FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='$this->anketa' AND s.gru_id=g.id AND s.skupine='3'");
$spr_id = 0;
if(mysqli_num_rows($sqlS) > 0){
$rowS = mysqli_fetch_array($sqlS);
$spr_id = $rowS['spr_id'];
if($spr_id > 0){
$p = new Prevajanje($this->anketa);
$bck_lang_id = $lang['id'];
// Pobrisemo staro vrednost default jezika za respondente
$p->include_lang($old_resp_lang_id);
// Noce prjet zaradi čšž-jev tko da je to se najlazje:)
if (strcmp($lang['language'], 'Slovenščina') == 0)
$sqlV = sisplet_query("DELETE FROM srv_vrednost WHERE naslov='Slovenščina' AND spr_id='$spr_id'");
else
$sqlV = sisplet_query("DELETE FROM srv_vrednost WHERE naslov='".$lang['language']."' AND spr_id='$spr_id'");
// Dodamo novo vrednost v vprasanje "language"
$v = new Vprasanje($this->anketa);
$v->spremenljivka = $spr_id;
$p->include_lang($new_resp_lang_id);
$vre_id = $v->vrednost_new($lang['language']);
// Preklopimo nazaj na originalen jezik
$p->include_lang($bck_lang_id);
// Prestevilcimo in popravimo vrstni red
Common::repareVrednost($spr_id);
Common::prestevilci($spr_id);
}
}
}
}
// Zaradi zavihkov sproti preverjamo katere variable lahko shranimo če so bile podane preko $_POST
$allVariableToSave = array (
'cookie',
'cookie_return',
'return_finished',
'subsequent_answers',
'cookie_continue',
'user_from_cms',
'user_base',
'phone',
'email',
'social_network',
'quiz',
'uporabnost',
'usercode_skip',
'usercode_required',
'usercode_text',
'block_ip',
'starts',
'expire',
'dostop',
'odgovarja',
'vote_limit',
'vote_count',
'form_open',
'lang_admin',
'lang_resp',
'multilang',
'slideshow',
'mass_insert',
'show_email',
'show_concl',
'concl_link',
'url',
'conclusion',
'concl_end_button',
'concl_back_button',
'vprasanje_tracking',
'continue_later',
'js_tracking',
'defValidProfile',
'showItime',
'showLineNumber',
'parapodatki'
);
// ce mamo radio: user_from_cms potem mamo tudi checkbox user_from_cms_email
if(isset($_POST['user_from_cms'])) {
$allVariableToSave[] = 'user_from_cms_email';
if (!isset($_POST['user_from_cms_email']))
$_POST['user_from_cms_email'] = 0;
if ($_POST['user_from_cms']==2 && !isset($_POST['cookie']))
$_POST['cookie'] = -1;
}
$setString = "";
$prefix = "";
foreach ($allVariableToSave as $value) {
if (isset ($_POST[$value]) ) {
$setString .= $prefix . $value . " = '" . $_POST[$value] . "'"; // tale se ze zanasa na mysqli_real_escape_string($GLOBALS['connect_db'], _string() v function.php
$prefix = ", ";
}
}
# če je anketa označena kot trajna, jo hkrati aktiviramo če še ni
if (isset($_POST['trajna_anketa']) && $_POST['trajna_anketa'] == 'on') {
$setString .= $prefix . "active = '1'";
$prefix = ", ";
}
if ($setString != "") {
$sql = sisplet_query("UPDATE srv_anketa SET " . $setString . " WHERE id='$anketa'") or die(mysqli_error($GLOBALS['connect_db']));
// vsilimo refresh podatkov
SurveyInfo :: getInstance()->resetSurveyData();
}
if (isset($_POST['progressbar'])) {
$sql = sisplet_query("UPDATE srv_anketa SET progressbar='$_POST[progressbar]' WHERE id='$anketa'");
}
if ($_POST['quiz'] == 1) { // za kviz je anketa vedno v pogoji in bloki načinu
sisplet_query("UPDATE srv_anketa SET survey_type='3' WHERE id = '$anketa'");
ob_start();
$ba = new BranchingAjax($this->anketa);
$ba->ajax_dodaj_blok_interpretacije();
ob_get_clean();
}
// nastavitve za knjiznico
if (isset($_POST['javne_ankete'])) {
if ($_POST['javne_ankete'] == 1) {
$sqlk = sisplet_query("SELECT * FROM srv_library_anketa WHERE ank_id='$this->anketa' AND uid='0'");
if (mysqli_num_rows($sqlk) == 0) {
$sql1 = sisplet_query("SELECT id FROM srv_library_folder WHERE uid='0' AND tip='1' AND parent='0' AND lang='$lang[id]'");
$row1 = mysqli_fetch_array($sql1);
sisplet_query("INSERT INTO srv_library_anketa (ank_id, uid, folder) VALUES ('$this->anketa', '0', '$row1[id]')");
}
} else {
sisplet_query("DELETE FROM srv_library_anketa WHERE ank_id='$this->anketa' AND uid='0'");
}
}
if (isset($_REQUEST['moje_ankete'])) {
if ($_REQUEST['moje_ankete'] == 1) {
$sqlk = sisplet_query("SELECT * FROM srv_library_anketa WHERE ank_id='$this->anketa' AND uid='$global_user_id'");
if (mysqli_num_rows($sqlk) == 0) {
$sql1 = sisplet_query("SELECT id FROM srv_library_folder WHERE uid='$global_user_id' AND tip='1' AND parent='0'");
$row1 = mysqli_fetch_array($sql1);
sisplet_query("INSERT INTO srv_library_anketa (ank_id, uid, folder) VALUES ('$this->anketa', '$global_user_id', '$row1[id]')");
}
} else {
sisplet_query("DELETE FROM srv_library_anketa WHERE ank_id='$this->anketa' AND uid='$global_user_id'");
}
}
if ($_POST['multilang'] == 1) {
$this->SurveyAdmin->createUserbaseSystemVariable(0, 0, 1);
}
SurveySetting::getInstance()->Init($anketa);
$surveysetting = array(
'survey_comment',
'survey_comment_showalways',
'question_comment',
'survey_comment_viewadminonly',
'survey_comment_viewauthor',
'question_comment_viewadminonly',
'question_comment_viewauthor',
'question_resp_comment_viewadminonly',
'question_resp_comment_inicialke',
'question_resp_comment_inicialke_alert',
'question_resp_comment',
'survey_comment_resp',
'survey_comment_showalways_resp',
'survey_comment_viewadminonly_resp',
'survey_comment_viewauthor_resp',
'question_comment_text',
'question_note_write',
'question_note_view',
'question_resp_comment_show_open',
'sortpostorder',
'addfieldposition',
'commentmarks',
'commentmarks_who',
'comment_history',
'survey_ip',
'survey_show_ip',
'survey_browser',
'survey_js',
'survey_referal',
'survey_date',
'preview_disableif',
'preview_disablealert',
'preview_displayifs',
'preview_displayvariables',
'preview_hidecomment',
'preview_hide_survey_comment',
'preview_survey_comment_showalways',
'preview_disable_test_insert',
);
foreach ($surveysetting AS $key) {
if ( isset($_POST[$key]) )
SurveySetting::getInstance()->setSurveyMiscSetting($key, $_POST[$key]);
}
// shranjujemo skrivanje metapodatkov
if (isset($_POST['hide_metadata'])) {
foreach ($_POST AS $key => $val) {
if (substr($key, 0, 14) == 'hide_metadata_') {
if ($val == 1)
SurveySetting::getInstance()->setSurveyMiscSetting($key, '1');
else
SurveySetting::removeSurveyMiscSetting($key);
}
}
}
if ($dostop_edit == 1 && isset ($global_user_id) && $global_user_id > 0) {
global $admin_type;
$uid = $_POST['uid'];
// ne pustimo da ni izbran noben user, ker potem nihče več nima dostopa do ankete zato dodamo kontrolo na global_user_id
// prav tako ne smemo onemogočiti dostopa avtorju
$avtorSql = sisplet_query("SELECT insert_uid FROM srv_anketa WHERE id='" . $this->anketa . "'");
$avtorRow = mysqli_fetch_assoc($avtorSql);
// da ne more zbrisat avtorja
$avtorPogoj = (isset ($avtorRow['insert_uid']) && $avtorRow['insert_uid'] > 0) ? " AND (uid != ".$avtorRow['insert_uid']." )" : "";
// da ne more zbrisat sam sebe
$avtorID = " AND uid != '" . $global_user_id . "'";
if ($admin_type == 0) {
$avtorPogoj = '';
$avtorID = '';
}
$uid_canedits = " AND uid NOT IN (".implode(',', $uid).") ";
$sql = sisplet_query("DELETE FROM srv_dostop WHERE ank_id='$anketa' ". $avtorID . $avtorPogoj . $uid_canedits);
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
if (isset ($uid) && $uid != null && is_array($uid))
foreach ($uid AS $val) {
//if ($val != $global_user_id)
$sql = sisplet_query("INSERT INTO srv_dostop (ank_id, uid, aktiven) VALUES ('$anketa', '$val', '1')");
}
// pasivnih ni vec.....................
if (isset($_POST['uid_passive']) && $_POST['uid_passive'] != null && is_array($_POST['uid_passive']))
foreach ($_POST['uid_passive'] AS $val) {
//if ($val != $global_user_id)
$sql = sisplet_query("INSERT INTO srv_dostop (ank_id, uid, aktiven) VALUES ('$anketa', '$val', '0')");
}
if (isset($_POST['dostop_language'])) {
sisplet_query("DELETE FROM srv_dostop_language WHERE ank_id = '$anketa'");
foreach ($_POST['dostop_language'] AS $val) {
$val = explode('-', $val);
$uid = $val[0];
$lang_id = $val[1];
sisplet_query("INSERT INTO srv_dostop_language (ank_id, uid, lang_id) VALUES ('$anketa', '$uid', '$lang_id')");
}
}
}
if ($_POST['comment_send'] != '') {
// nastavitev, da se okno s komentarji prvic prikaze odprto
if ($_POST['srv_c_alert'] == '1')
$ocena = 5;
else $ocena = 0;
$ba = new BranchingAjax($this->anketa);
$ba->ajax_comment_manage(0, 0, $_POST['comment_send'], $ocena);
// posiljanje komentarjev na maile
if ($_POST['srv_c_to_mail'] == '1') {
$sr = SurveyInfo::getSurveyRow();
foreach ($_POST['mails'] AS $email) {
//$email = $rowa['email'];
$content = $_POST['comment_send'].'
'.$site_url.'admin/survey/index.php?anketa='.$this->anketa.'';
$subject = $lang['srv_admin_s_comments'].': '.$sr['naslov'];
try
{
$MA = new MailAdapter($this->anketa, $type='alert');
$MA->addRecipients($email);
$resultX = $MA->sendMail(stripslashes($content), $subject);
}
catch (Exception $e)
{
}
if ($resultX) {
$status = 1; // poslalo ok
} else {
$status = 2; // ni poslalo
}
}
}
}
// Dodajanje novih uproabnikov (emailov)
if (isset($_POST['addusers']) && $_POST['addusers'] != '') {
global $pass_salt, $global_user_id, $site_path, $admin_type;
$_POST['addusers'] = mysql_real_unescape_string($_POST['addusers']);
$users = explode(NEW_LINE, $_POST['addusers']);
$sqlu = sisplet_query("SELECT email, name FROM users WHERE id = '".$global_user_id."'");
$rowu = mysqli_fetch_array($sqlu);
$MailReply = $rowu['email'];
$nameAuthor = $rowu['name'];
$aktiven = $_POST['aktiven'];
// Loop cez vse vnesesne userje, ki jim dajemo dostop
foreach ($users AS $user) {
$user = explode(',', $user);
$email = trim($user[0]);
$name = trim($user[1])!='' ? trim($user[1]) : $email;
$surnname = trim($user[2])!='' ? trim($user[2]) : $email;
// Ce gre za veljaven email dodamo userja
if ($email != '' && validEmail($email)) {
$id = 0;
$sqlu = sisplet_query("SELECT id FROM users WHERE email='$email'");
// Ce user, ki ga dodajamo, se ne obstaja, ga ustvarimo - PO NOVEM SAMO CE SMO ADMIN ALI MANAGER
if (mysqli_num_rows($sqlu) == 0 && ($admin_type == 0 || $admin_type == 1)) {
$s = sisplet_query("INSERT INTO users (name, surname, email, pass, type, when_reg, came_from) VALUES ('$name', '$surnname', '$email', '" .base64_encode((hash(SHA256, '' .$pass_salt))) ."', '3', DATE_FORMAT(NOW(), '%Y-%m-%d'), '1')");
$id = mysqli_insert_id($GLOBALS['connect_db']);
}
// Drugace pridobimo podatke o userju iz baze
else {
$rowu = mysqli_fetch_array($sqlu);
$id = $rowu['id'];
}
// Ce je bil ustvarjen oz ga imamo ze v bazi, mu damo dostop in posljemo mail
if($id > 0){
$s = sisplet_query("INSERT INTO srv_dostop (ank_id, uid, aktiven) VALUES ('$anketa', '$id', '$aktiven')");
if ( !$s ) echo mysqli_error($GLOBALS['connect_db']);
// V kolikor gre za hierarhijo, potem še enkrat preverimo v bazi in dodelimo dostop tudi do hierarhije status 2 - naknadno dodan administrator
if(SurveyInfo::checkSurveyModule('hierarhija', $anketa))
sisplet_query("INSERT INTO srv_hierarhija_users (user_id, anketa_id, type) VALUES ('".$id."', '".$anketa."', 2)");
$naslov = SurveyInfo::getInstance()->getSurveyColumn('naslov');
$subject = $lang['srv_dostopmail_1'].' '.$naslov.'.';
$content = $lang['srv_dostopmail_2'].' '.$nameAuthor.' ('.$MailReply.') '.$lang['srv_dostopmail_3'].' '.$naslov.'.
'.$lang['srv_dostopmail_4'].' '.$site_url.' '.$lang['srv_dostopmail_5'].' ('.$email.').';
// Ce email se ni registriran, dodamo dodatno obvestilo
if(mysqli_num_rows($sqlu) == 0 && ($admin_type == 0 || $admin_type == 1)){
$content .= '
';
// Seznam uporabnikov na katere je bil poslan email
// Dobimo samo uporabnike na zadnjem nivoju in to obvestilo prikažemo samo prvič ko se aktivira anketa
if(SurveyInfo::getSurveyModules('hierarhija') == 1) {
$users_upravicen_do_evalvacije = (new \Hierarhija\Model\HierarhijaOnlyQuery())->queryStrukturaUsers($anketa, ' AND hs.level=(SELECT MAX(level) FROM srv_hierarhija_struktura WHERE anketa_id=' . $anketa . ') GROUP BY users.id');
echo '
';
}
// Prikaze uvoz iz besedila znotraj ankete (popup)
function ajax_show_import_from_text(){
global $lang, $site_url, $global_user_id;
// uvoz iz besedila
echo '
';
}
// Uvoz iz besedila znotraj ankete (popup)
function ajax_import_from_text(){
global $site_url;
// Ce ustvarjamo anketo preko uvoza iz besedila
if(isset($_POST['from_text'])){
$from_text = $_POST['from_text'];
$text_array = Common::anketaArrayFromText($from_text);
$spr_id = 0;
// Loop po vseh vprasanjih, ki jih uvazamo
foreach($text_array as $vprasanje){
$ba = new BranchingAjax($this->anketa);
// Imamo samo naslov vprasanja - text tip (21)
if(count($vprasanje) == 1){
$b = new Branching($this->anketa);
$spr_id = $ba->spremenljivka_new(0, 0, 1);
Vprasanje::change_tip($spr_id, $tip='21');
$sql = sisplet_query("UPDATE srv_spremenljivka SET naslov='".$vprasanje['title']."' WHERE id='".$spr_id."'");
}
// Imamo variable - radio tip (1)
else{
$b = new Branching($this->anketa);
$spr_id = $ba->spremenljivka_new(0, 0, 1);
Vprasanje::change_tip($spr_id, $tip='1');
$sql = sisplet_query("UPDATE srv_spremenljivka SET naslov='".$vprasanje['title']."' WHERE id='".$spr_id."'");
$sql = sisplet_query("DELETE FROM srv_vrednost WHERE spr_id='$spr_id'");
unset($vprasanje['title']);
// Loop po variablah
foreach($vprasanje as $key => $var_title){
$v = new Vprasanje();
$v->spremenljivka = $spr_id;
$vrednost = $v->vrednost_new($var_title);
Common::prestevilci($spr_id);
}
}
}
}
flush();
echo $site_url.'admin/survey/index.php?anketa='.$this->anketa;
}
// Display consulting popup
function ajax_consulting_popup_open () {
global $lang;
echo '