LICENSE: GPLv2 # # # changes: # 60620-1333 - Added variable filtering to eliminate SQL injection attack threat # - Added required user/pass to gain access to this page # require("dbconnect.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; $PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; $PHP_SELF=$_SERVER['PHP_SELF']; if (isset($_GET["group"])) {$group=$_GET["group"];} elseif (isset($_POST["group"])) {$group=$_POST["group"];} if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} if (isset($_GET["extension"])) {$extension=$_GET["extension"];} elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} if (isset($_GET["user"])) {$user=$_GET["user"];} elseif (isset($_POST["user"])) {$user=$_POST["user"];} if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} if (isset($_GET["submit"])) {$submit=$_GET["submit"];} elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} $PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); $PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); $STARTtime = date("U"); $TODAY = date("Y-m-d"); $admin_page = './admin.php'; if (!isset($begin_date)) {$begin_date = $TODAY;} if (!isset($end_date)) {$end_date = $TODAY;} $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $auth=$row[0]; $fp = fopen ("./project_auth_entries.txt", "a"); $date = date("r"); $ip = getenv("REMOTE_ADDR"); $browser = getenv("HTTP_USER_AGENT"); if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) { Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); Header("HTTP/1.0 401 Unauthorized"); echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; exit; } else { if($auth>0) { $office_no=strtoupper($PHP_AUTH_USER); $password=strtoupper($PHP_AUTH_PW); $stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $LOGfullname=$row[0]; fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); fclose($fp); ##### get server listing for dynamic pulldown $stmt="SELECT fullname from phones where server_ip='$server_ip' and extension='$extension'"; $rsltx=mysql_query($stmt, $link); $rowx=mysql_fetch_row($rsltx); $fullname = $row[0]; } else { fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); fclose($fp); } } ?> ASTERISK ADMIN: Telefon-Notfall
\n"; echo "
  STERNCHEN ADMIN: Leitung  
  VERZEICHNEN SIE ALLE TELEFONE | ADDIEREN Sie Ein NEUES TELEFON | SUCHE NACH Einem TELEFON | ADDIEREN Sie Einen BEDIENER | VERZEICHNEN SIE ALLE BEDIENER
  ZEIGEN SIE ALLE KONFERENZEN | ADDIEREN Sie Eine NEUE KONFERENZ
  \n"; echo "
\n"; echo "\n"; echo "\n"; echo " to \n"; echo "  \n"; echo "\n"; echo "           $user - $full_name\n"; echo "
\n"; $stmt="SELECT count(*),channel_group, sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' group by channel_group order by channel_group"; $rslt=mysql_query($stmt, $link); $statuses_to_print = mysql_num_rows($rslt); # echo "|$stmt|\n"; echo "
\n"; echo "ANRUF-ZEIT UND FÜHRUNGEN:\n"; echo "
\n"; echo "\n"; $total_calls=0; $o=0; while ($statuses_to_print > $o) { $row=mysql_fetch_row($rslt); if (eregi("1$|3$|5$|7$|9$", $o)) {$bgcolor='bgcolor="#B9CBFD"';} else {$bgcolor='bgcolor="#9BB9FB"';} $call_seconds = $row[2]; $call_hours = ($call_seconds / 3600); $call_hours = round($call_hours, 2); $call_hours_int = intval("$call_hours"); $call_minutes = ($call_hours - $call_hours_int); $call_minutes = ($call_minutes * 60); $call_minutes_int = round($call_minutes, 0); if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} echo ""; echo "\n"; echo "\n"; $total_calls = ($total_calls + $row[0]); $call_seconds=0; $o++; } $stmt="SELECT sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59'"; $rslt=mysql_query($stmt, $link); $counts_to_print = mysql_num_rows($rslt); $row=mysql_fetch_row($rslt); $call_seconds = $row[0]; $call_hours = ($call_seconds / 3600); $call_hours = round($call_hours, 2); $call_hours_int = intval("$call_hours"); $call_minutes = ($call_hours - $call_hours_int); $call_minutes = ($call_minutes * 60); $call_minutes_int = round($call_minutes, 0); if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} # echo "|$stmt|\n"; echo "\n"; echo "
KANALGRUPPE ZÄHLIMPULS HOURS:MINUTES
$row[1] $row[0] $call_hours_int:$call_minutes_int
GESAMTANRUFE $total_calls $call_hours_int:$call_minutes_int
\n"; echo "

\n"; echo "
\n"; echo "ANRUFE DES LETZT-1000 FÜR DATUM-STRECKE:\n"; echo "\n"; echo "\n"; $stmt="SELECT number_dialed,channel_group,start_time,length_in_min from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' LIMIT 1000"; $rslt=mysql_query($stmt, $link); $events_to_print = mysql_num_rows($rslt); # echo "|$stmt|\n"; $total_calls=0; $o=0; $event_start_seconds=''; $event_stop_seconds=''; while ($events_to_print > $o) { $row=mysql_fetch_row($rslt); if (eregi("1$|3$|5$|7$|9$", $o)) {$bgcolor='bgcolor="#B9CBFD"';} else {$bgcolor='bgcolor="#9BB9FB"';} echo ""; echo "\n"; echo "\n"; echo "\n"; $call_seconds=0; $o++; } echo "
ZAHL KANALGRUPPE DATUM LENGTH(MIN.)
$row[0] $row[1] $row[2] $row[3]
\n"; $ENDtime = date("U"); $RUNtime = ($ENDtime - $STARTtime); echo "\n\n\n


\n\n"; echo "\n\n\n


\nIndexlaufzeit: $RUNtime seconds
"; ?>