' . "\n"); ?> Invalid session ' . "\n"); ?> -1 ', $message); } return $message; } function time_layout($unixtime) { global $minutes_label; global $hours_label; $minutes = (int)($unixtime / 60); if ($minutes > 60) { $hours = (int)(($unixtime / 60) / 60); $minutes = (int)(($unixtime / 60) - ($hours * 60)); if ($minutes < 10) { $minutes = '0' . (int)(($unixtime / 60) - ($hours * 60)); } $seconds = ($unixtime % 60); if ($seconds < 10) { $seconds = '0' . ($unixtime % 60); } return $hours . ':' . $minutes . ':' . $seconds . ' ' . $hours_label; } else { if ($minutes < 10) { $minutes = '0' . (int)($unixtime / 60); } $seconds = ($unixtime % 60); if ($seconds < 10) { $seconds = '0' . ($unixtime % 60); } return $minutes . ':' . $seconds . ' ' . $minutes_label; } } function pendingUsersPopup($timeout) { global $table_prefix; global $departments; global $current_department; global $SQL; // PENDING USERS QUERY displays pending users not logged in on users users table depending on department settings if ($departments == true) { $departments_sql = departmentsSQL($current_department); $query = "SELECT DISTINCT (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`datetime`)) AS `display` FROM " . $table_prefix . "sessions WHERE (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`refresh`)) < '$timeout' AND active = '0' AND $departments_sql"; } else { $query = "SELECT DISTINCT (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`datetime`)) AS `display` FROM " . $table_prefix . "sessions WHERE (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`refresh`)) < '$timeout' AND active = '0'"; } $rows = $SQL->selectall($query); // Initalise user status to false $user_status = 'false'; if (is_array($rows)) { foreach ($rows as $key => $row) { if (is_array($row)) { $display_flag = $row['display']; if ($display_flag < $timeout) { $user_status = 'true'; } } } } return $user_status; } function browsingUsersPopup($timeout) { global $table_prefix; global $SQL; // BROWSING USERS QUERY displays browsing users $query = "SELECT DISTINCT (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`request`)) AS `display` FROM " . $table_prefix . "requests WHERE (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`request`)) < '$timeout' AND status = '0'"; $rows = $SQL->selectall($query); // Initalise user status to false $user_status = 'false'; $count = 0; if (is_array($rows)) { foreach ($rows as $key => $row) { if (is_array($row)) { $display_flag = $row['display']; if ($display_flag < $timeout) { $user_status = 'true'; } } } } return $user_status; } function transferredUsersPopup($timeout) { global $table_prefix; global $operator_login_id; global $SQL; //error_log("3. operator_login_id :". $operator_login_id."\n", 3, "func.log"); // TRANSFERRED USERS QUERY displays transferred users not loged in on users users table $query = "SELECT DISTINCT (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`datetime`)) AS display FROM " . $table_prefix . "sessions WHERE (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`refresh`)) < '$timeout' AND active = '-2' AND `transfer` = '$operator_login_id'"; $rows = $SQL->selectall($query); // Initalise user status to false $user_status = 'false'; if (is_array($rows)) { foreach ($rows as $key => $row) { if (is_array($row)) { $display_flag = $row['display']; if ($display_flag < $timeout) { $user_status = 'true'; } } } } return $user_status; } function totalPendingUsers() { global $table_prefix; global $connection_timeout; global $SQL; // PENDING USERS QUERY displays pending site visitors $query = "SELECT count(`id`) FROM " . $table_prefix . "sessions WHERE (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`refresh`)) < '$connection_timeout' AND `active` = '0'"; $row = $SQL->selectquery($query); // Initalise user status to false $total_users = '0'; if (is_array($row)) { $total_users = $row['count(login_id)']; } return $total_users; } function totalBrowsingUsers() { global $table_prefix; global $connection_timeout; global $SQL; // BROWSING USERS QUERY displays browsing users $query = "SELECT count(`id`) FROM " . $table_prefix . "requests WHERE (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`refresh`)) < '$connection_timeout'"; $row = $SQL->selectquery($query); // Initalise user status to false $total_users = '0'; if (is_array($row)) { $total_users = $row['count(`id`)']; } return $total_users; } function departmentsSQL($department) { $multi_departments = preg_split('/\[\;\]/', $department); $sql = ''; if (is_array($multi_departments)) { $i = 0; $length = count($multi_departments); if ($length > 1) { while ($i < $length) : $department = trim(addslashes($multi_departments[$i])); if ($i == 0) { $sql = "( `department` = '$department'"; } elseif ($i > 0 && $i < $length - 1) { $sql .= " OR `department` = '$department'"; } elseif ($i == $length - 1) { $sql .= " OR `department` = '$department' OR `department` = '' )"; } $i++; endwhile; } else { $sql = "( `department` = '$department' OR `department` = '' )"; } } else { $sql = "( `department` = '$department' OR `department` = '' )"; } return $sql; } function xmlinvalidchars($string) { $string = str_replace(array('>', '<', '"', '&'), array('>', '<', '"', '&'), $string); return $string; } function unixtimestamp($datetime) { $datetime = explode(" ", $datetime); $date = explode("-", $datetime[0]); $time = explode(":", $datetime[1]); unset($datetime); list($year, $month, $day) = $date; list($hour, $minute, $second) = $time; return mktime(intval($hour), intval($minute), intval($second), intval($month), intval($day), intval($year)); } function writeToLog($msg) { $f = fopen("debug.txt", "a"); fwrite($f, $msg . "\n"); fclose($f); } function doTemplateReplace($q1, $q2) { $pieces = explode("") > 0) { $pieces[$i] = substr($pieces[$i], 0, strpos($pieces[$i], "-//>")); } else { $pieces[$i] = ""; } } for($i = 0; $i < count($pieces); $i++) { if($pieces[$i] != "") { $q1 = str_replace("", $q2[$pieces[$i]], $q1); } } return $q1; } ?>