folder = $site_path . EXPORT_FOLDER.'/'; // če je podan anketa ID if ((int)$anketa > 0) { $this->anketa = $anketa; } else { die("Napaka!"); } if ( SurveyInfo::getInstance()->SurveyInit($this->anketa)) { $this->uid = $global_user_id; SurveyUserSetting::getInstance()->Init($this->anketa, $this->uid); } } function displayEdit(){ global $global_user_id; global $lang; global $site_url; // Ce je vklopljen evoli team meter se ne sme tukaj urejat skupin (ker se belezijo v dodatno bazo srv_evoli_teammeter z dodatnimi parametri) if(SurveyInfo::getInstance()->checkSurveyModule('evoli_teammeter') || SurveyInfo::getInstance()->checkSurveyModule('evoli_quality_climate') || SurveyInfo::getInstance()->checkSurveyModule('evoli_teamship_meter') || SurveyInfo::getInstance()->checkSurveyModule('evoli_organizational_employeeship_meter') ){ echo '
'; return; } $userAccess = UserAccess::getInstance($global_user_id); $spr_id = $this->hasSkupine(); echo ''; echo ''; } /* * Vrne id spremenljivke ce obstaja skupina * param $skupine -> 1 navadne skupine, 2 -> password skupine */ function hasSkupine($skupine=1){ global $global_user_id; $sql = sisplet_query("SELECT s.id AS id FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='$this->anketa' AND s.skupine='$skupine'"); if(mysqli_num_rows($sql) > 0){ $row = mysqli_fetch_array($sql); return $row['id']; } else return 0; } function getVrednosti($spr_id){ global $global_user_id; global $site_url; $link = SurveyInfo::getSurveyLink(); $vrednosti = array(); $sqlS = sisplet_query("SELECT variable FROM srv_spremenljivka WHERE id='$spr_id'"); $rowS = mysqli_fetch_array($sqlS); $variable = $rowS['variable']; // Preverimo ce imamo lep url $sql2 = sisplet_query("SELECT id FROM srv_nice_links WHERE ank_id='$this->anketa'"); $sql = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$spr_id'"); if(mysqli_num_rows($sql) > 0){ $cnt = 0; while($row = mysqli_fetch_array($sql)){ $vrednosti[$cnt] = $row; $vrednosti[$cnt]['url'] = $link.'?'.$variable.'='.$row['id']; // Ce imamo nice url za skupine ga tudi shranimo if(mysqli_num_rows($sql2) > 0){ $sql3 = sisplet_query("SELECT link fROM srv_nice_links_skupine WHERE ank_id='$this->anketa' AND vre_id='$row[id]'"); if(mysqli_num_rows($sql3) > 0){ $row3 = mysqli_fetch_array($sql3); $vrednosti[$cnt]['nice_url'] = $site_url.$row3['link']; } } $cnt++; } return $vrednosti; } else return 0; } // Prestejemo stevilo odgovorov za doloceno skupino private function countSkupinaAnswers($vre_id){ $answer_count = 0; $sql = sisplet_query("SELECT count(u.id) AS answer_count FROM srv_user u, srv_data_vrednost_active v WHERE v.vre_id='".$vre_id."' AND u.id=v.usr_id AND u.deleted='0' "); $row = mysqli_fetch_array($sql); $answer_count = $row['answer_count']; return $answer_count; } // Vrnemo url za doloceno skupino function getUrl($spr_id, $vre_id){ global $global_user_id; global $site_url; $link = SurveyInfo::getSurveyLink(); $sqlS = sisplet_query("SELECT variable FROM srv_spremenljivka WHERE id='$spr_id'"); $rowS = mysqli_fetch_array($sqlS); $variable = $rowS['variable']; $sql = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id='$spr_id' AND id='$vre_id'"); if(mysqli_num_rows($sql) > 0){ $row = mysqli_fetch_array($sql); $url = $link.'?'.$variable.'='.$row['id']; // Ce imamo nice url za skupine ga tudi shranimo $sql2 = sisplet_query("SELECT id FROM srv_nice_links WHERE ank_id='$this->anketa'"); if(mysqli_num_rows($sql2) > 0){ $sql3 = sisplet_query("SELECT link fROM srv_nice_links_skupine WHERE ank_id='$this->anketa' AND vre_id='$row[id]'"); if(mysqli_num_rows($sql3) > 0){ $row3 = mysqli_fetch_array($sql3); $url = $site_url.$row3['link']; } } return $url; } else return ''; } /** Funkcije ki skrbijo za ajax del * */ public function ajax() { global $global_user_id; global $lang; global $site_path; if (isset ($_POST['anketa'])) { $anketa = $_POST['anketa']; $this->anketa = $_POST['anketa']; } $spr_id = (isset($_POST['spr_id'])) ? $_POST['spr_id'] : 0; if ($_GET['a'] == 'add_skupina') { $skupine = (isset($_POST['skupine'])) ? $_POST['skupine'] : 1; $variable = ($skupine == 2) ? 'password' : strtolower($lang['srv_skupina']); $naslov = ($skupine == 2) ? 'Password' : $lang['srv_skupina']; $naslov_vrednost = (isset($_POST['text'])) ? $_POST['text'] : ''; if($naslov_vrednost != ''){ // Dodatno preverimo ce sigurno nimamo skupine if($spr_id == 0){ $spr_id = $this->hasSkupine($skupine); } // Na zacetku moramo ustvarit najprej vprasanje if($spr_id == 0){ $sqlG = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='$this->anketa' AND vrstni_red='1'"); $rowG = mysqli_fetch_array($sqlG); $gru_id = $rowG['id']; $b = new Branching($this->anketa); $spr_id = $b->nova_spremenljivka($grupa=$gru_id, $grupa_vrstni_red=1, $vrstni_red=0); $sql = sisplet_query("UPDATE srv_spremenljivka SET naslov='$naslov', variable='$variable', variable_custom='1', skupine='$skupine', sistem='1', visible='0', size='0' WHERE id='$spr_id'"); Vprasanje::change_tip($spr_id, 1); } $v = new Vprasanje($this->anketa); $v->spremenljivka = $spr_id; $vre_id = $v->vrednost_new($naslov_vrednost); // Ce gre za password ga dodamo if($skupine == 2){ $s = sisplet_query("REPLACE INTO srv_password (ank_id, password) VALUES ('$this->anketa', '$naslov_vrednost')"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); } // Preverimo ce imamo nice URL -> dodamo dodatnega za skupine $sql = sisplet_query("SELECT id, link FROM srv_nice_links WHERE ank_id='$this->anketa'"); if($skupine == 1 && mysqli_num_rows($sql) > 0){ Common::updateEditStamp(); $row = mysqli_fetch_array($sql); $add = false; $anketa = $this->anketa; $nice_url = $row['link']; $skupina_string = strtolower($lang['srv_skupina']); $sql2 = sisplet_query("SELECT vrstni_red FROM srv_vrednost WHERE id='$vre_id'"); $row2 = mysqli_fetch_array($sql2); $nice_url .= '_'.$row2['vrstni_red']; $f = @fopen($site_path.'.htaccess', 'rb'); if ($f !== false) { $add = true; while (!feof($f)) { $r = fgets($f); if (strpos($r, "^".$nice_url.'\b') !== false) { // preverimo, da ni tak redirect ze dodan $add = false; } } fclose($f); } if (strlen($nice_url) < 3) $add = false; if (SurveyInfo::getInstance()->checkSurveyModule('uporabnost')) $link = 'main/survey/uporabnost.php?anketa='.SurveyInfo::getInstance()->getSurveyHash().'&'.$skupina_string.'='.$vre_id; else $link = 'main/survey/index.php?anketa='.SurveyInfo::getInstance()->getSurveyHash().'&'.$skupina_string.'='.$vre_id; if ($add) { $f = @fopen($site_path.'.htaccess', 'a'); if ($f !== false) { fwrite($f, "\nRewriteRule ^".$nice_url.'\b(?!-)(.*) '.$link."&foo=\$1&%{QUERY_STRING}"); fclose($f); $sqlI = sisplet_query("INSERT INTO srv_nice_links_skupine (id,ank_id,nice_link_id,vre_id,link) VALUES ('','$this->anketa','$row[id]','$vre_id','$nice_url')"); } } } // Vstavljanje v html tabelo echo '' . $lang['srv_password_add_mass_instructions'] . '
'; echo ''; echo ' '; } // Masovno dodajanje gesel if ($_GET['a'] == 'add_password_mass') { $skupine = 2; $variable = 'password'; $naslov = 'Password'; $passwords = (isset($_POST['passwords'])) ? $_POST['passwords'] : ''; if($passwords != ''){ // Dodatno preverimo ce sigurno nimamo skupine if($spr_id == 0){ $spr_id = $this->hasSkupine($skupine); } // Na zacetku moramo ustvarit najprej vprasanje if($spr_id == 0){ $sqlG = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='$this->anketa' AND vrstni_red='1'"); $rowG = mysqli_fetch_array($sqlG); $gru_id = $rowG['id']; $b = new Branching($this->anketa); $spr_id = $b->nova_spremenljivka($grupa=$gru_id, $grupa_vrstni_red=1, $vrstni_red=0); $sql = sisplet_query("UPDATE srv_spremenljivka SET naslov='$naslov', variable='$variable', variable_custom='1', skupine='$skupine', sistem='1', visible='0', size='0' WHERE id='$spr_id'"); Vprasanje::change_tip($spr_id, 1); } $v = new Vprasanje($this->anketa); $v->spremenljivka = $spr_id; // Loop cez vsa gesla po vrsticah in jih dodamo $passwords_array = explode("\\n", $passwords); foreach($passwords_array as $password){ // Pocistimo vec presledkov in line breakov $password = trim($password); $password = preg_replace('/\s+/', ' ', $password); if($password != ''){ $vre_id = $v->vrednost_new($password); $s = sisplet_query("REPLACE INTO srv_password (ank_id, password) VALUES ('$this->anketa', '$password')"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); } } } } } } ?>