0) || (isset ($anketa) && $anketa > 0)) { $this->anketa = (isset ($_REQUEST['anketa']) && $_REQUEST['anketa'] > 0) ? $_REQUEST['anketa'] : $anketa; } else { return 'Anketa ID ne obstaja'; } # poiščemo aktivno anketo SurveyInfo :: getInstance()->SurveyInit($this->anketa); if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1) $this->db_table = '_active'; if ($_GET['m'] == 'tracking_data') $this->sub = 'data'; elseif ($_GET['appendMerge'] == '1') $this->sub = 'append'; else $this->sub = 'survey'; // Filter po statusu if (isset($_GET['status']) && in_array($_GET['status'], array('0', '1', '2', '3', '4', '5', '6'))) $this->status = " AND status = '{$_GET[status]}' "; return $this; } private static $_instance; /** * V kolikor razred kličemo statično * * @return instance */ public static function init() { if (!static::$_instance) static::$_instance = new TrackingClass(); return static::$_instance; } /** * Filter po statusih * Filter omogoča, da se prvi parameter ne upošteva statusa, v koliko ni filtra upošteva vse statuse. * Drugi parameter naredi inverzno operacijo - išče samo po tem statusu * 0 => urejanje * 1 => uvoz podatkov * 2 => analiza * 3 => reporti * 4 => podatki * 5 => objava - vabila * 6 => hierarhija * 20 => hierarhija - splošno * 21 => hierarhija - gradnja strukture * 22 => hierarhija - uporabniki * * @param (int or array) $exclude_status * @param (boolean) $invert_status * @return $this */ public function filter($exclude_status = null, $invert_status = false) { $opcija = '!'; if ($invert_status) $opcija = ''; if (!is_null($exclude_status) && is_int($exclude_status)) { $this->status = " AND status " . $opcija . "= '" . $exclude_status . "' "; } elseif (!is_null($exclude_status) && is_array($exclude_status)) { if (!empty($opcija)) { $this->status = " AND status NOT IN (" . implode(',', $exclude_status) . ")"; } else { $this->status = " AND status IN (" . implode(',', $exclude_status) . ")"; } } return $this; } /** * @desc prikaze tracking sprememb * status: * -1 => unknown * 0 => urejanje * 1 => uvoz podatkov * 2 => analiza * 3 => reporti * 4 => podatki * 5 => objava - vabila * 20 => hierarhija - splošno * 21 => hierarhija - gradnja strukture * 22 => hierarhija - uporabniki */ public function trackingDisplay() { global $lang; echo '
'; } public function csvExport() { define('delimiter', ';'); $podatki = 'datetime' . delimiter; $podatki .= 'uid' . delimiter; $podatki .= 'ip' . delimiter; $podatki .= 'status' . delimiter; $podatki .= 'parameter' . delimiter; $podatki .= 'value' . delimiter; $podatki .= 'parameter' . delimiter; $podatki .= 'value' . delimiter; $podatki .= "\n"; $sql = sisplet_query("SELECT * FROM srv_tracking".$this->db_table." WHERE ank_id = '" . $this->anketa . "' " . $this->status . " ORDER BY datetime DESC"); while ($row = mysqli_fetch_array($sql)) { $sqlu = sisplet_query("SELECT name, surname, id FROM users WHERE id = '$row[user]'"); $rowu = mysqli_fetch_array($sqlu); $podatki .= '' . datetime($row['datetime']) . delimiter; $podatki .= '' . $rowu['id'] . delimiter; $podatki .= '' . $row['ip'] . delimiter; $podatki .= '' . $row['status'] . delimiter; foreach (explode(',', $row['get']) AS $value) { $value = explode(':', $value); $podatki .= trim($value[0]) . delimiter; $podatki .= trim($value[1]) . delimiter; } $podatki .= "\n"; } $ime = str_replace('-', '_', $_GET['a']); return Export::init()->csv('Spremembe_' . $ime, $podatki); } /** * Update srv_tracking table * @desc vnese spremembo v srv_tracking za sledenje sprememb * * @param (int) $anketa * @param (int) $status */ private static $time_start; static function update($anketa, $status = 0) { global $global_user_id; # poiščemo aktivno anketo SurveyInfo :: getInstance()->SurveyInit($anketa); $db_table = (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1) ? '_active' : ''; $get = ''; foreach ($_GET AS $key => $val) { if ($get != '') $get .= ', '; $get .= $key . ': "' . $val . '"'; } $post = ''; foreach ($_POST AS $key => $val) { if ($post != '') $post .= ', '; // if (is_array($val)) // $val = implode(',', $val); if (is_array($val)) $val = self::arrayToString($val); $post .= $key . ': "' . $val . '"'; } // izracunamo trajanje skripte v sekundah if (self::$time_start != null) $time_seconds = microtime(true) - self::$time_start; else $time_seconds = 0; // IP uporabnika $ip = GetIP(); $s = sisplet_query("INSERT INTO srv_tracking".$db_table." (ank_id, datetime, ip, user, `get`, post, status, time_seconds) VALUES ('$anketa', NOW(), '".$ip."', '$global_user_id', '$get', '$post','$status', '$time_seconds')"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); } static function update_user($status = 0) { global $global_user_id; $get = ''; foreach ($_GET AS $key => $val) { if ($get != '') $get .= ', '; $get .= $key . ': "' . $val . '"'; } $post = ''; foreach ($_POST AS $key => $val) { if ($post != '') $post .= ', '; // if (is_array($val)) // $val = implode(',', $val); if (is_array($val)) $val = self::arrayToString($val); $post .= $key . ': "' . $val . '"'; } // izracunamo trajanje skripte v sekundah if (self::$time_start != null) $time_seconds = microtime(true) - self::$time_start; else $time_seconds = 0; // IP uporabnika $ip = GetIP(); $s = sisplet_query("INSERT INTO user_tracking (datetime, ip, user, `get`, post, status, time_seconds) VALUES (NOW(), '".$ip."', '$global_user_id', '$get', '$post','$status', '$time_seconds')"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); } private static function arrayToString($array) { $string = ""; if (is_array($array)) { foreach ($array as $key => $value) { if (is_array($value)) { $string .= ', '.$key .': [' . self::arrayToString($value) . '] '; } else { if ($key == 0) $string .= $key . ': ' . $value . ' '; } } } return $string; } }