summaryrefslogtreecommitdiffstats
path: root/php
diff options
context:
space:
mode:
Diffstat (limited to 'php')
-rw-r--r--php/pgets-intro.html43
-rw-r--r--php/pgets.php119
-rw-r--r--php/style.css39
3 files changed, 201 insertions, 0 deletions
diff --git a/php/pgets-intro.html b/php/pgets-intro.html
new file mode 100644
index 0000000..98a66c2
--- /dev/null
+++ b/php/pgets-intro.html
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="iso-8895-15"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head>
+<title>pgETS</title>
+<link rel="stylesheet" type="text/css" href="style.css" />
+</head>
+
+<body>
+<h1>ETS Call Accounting - Make Your Selection</h1>
+
+<form action="pgets.php" method="get">
+
+<h3>Direction</h3>
+<div class="radiobox">
+<div><input type="radio" checked name="direction" value="0"/>Outgoing + Incoming</div>
+<div><input type="radio" name="direction" value="1"/>Outgoing</div>
+<div><input type="radio" name="direction" value="2"/>Incoming</div>
+</div>
+
+<h3>Sort Order</h3>
+<div class="radiobox">
+<div><input type="radio" checked name=order value="0"/>Ascending</div>
+<div><input type="radio" name="order" value="1"/>Descending</div>
+</div>
+
+<h3>Time Range</h3>
+<p>Format is YYYY-MM-DD, leave empty for complete list.</p>
+<p>Between <input type=input name="sdate" value=""/> and <input type=input name="edate" value=""/></p>
+<div><input type="submit" value="Submit Query"/></div>
+
+</form>
+
+<hr/>
+<p>
+<b>Shortcuts:</b> <a href="pgets.php">Complete List</a> | <a href="pgets.php?special=1&amp;direction=1">Outgoing This Month</a>
+</p>
+
+<hr/>
+<div class="grey"><!-- hhmts start -->Last modified: Mon Mar 1 00:03:59 CET 2004 <!-- hhmts end --></div>
+</body>
+</html>
diff --git a/php/pgets.php b/php/pgets.php
new file mode 100644
index 0000000..d1e8036
--- /dev/null
+++ b/php/pgets.php
@@ -0,0 +1,119 @@
+<?php echo '<?xml version="1.0" encoding="iso-8895-15"?>' ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head>
+<title>pgETS</title>
+<link rel="stylesheet" type="text/css" href="style.css" />
+</head>
+
+<body>
+<h1>ETS Call Accounting - Query Results</h1>
+<?php
+
+$local_prefix = "040";
+$dbspec = "dbname=pgets user=pgets_web password=gandhi";
+
+$n_order = (int) $HTTP_GET_VARS['order'];
+$n_direction = (int) $HTTP_GET_VARS['direction'];
+$order = $n_order ? "DESC" : "ASC";
+
+if (isset($HTTP_GET_VARS['sdate'])) {
+ $sdate = addslashes($HTTP_GET_VARS['sdate']);
+} else if (isset($HTTP_GET_VARS['sday'])) {
+ $sday = (int) $HTTP_GET_VARS['sday'];
+ $smon = (int) $HTTP_GET_VARS['smon'];
+ $syear = (int) $HTTP_GET_VARS['syear'];
+
+ $sdate = sprintf("%04s-%02s-%02s", $syear, $smon, $sday);
+} else {
+ $sdate = "";
+}
+
+if (isset($HTTP_GET_VARS['edate'])) {
+ $edate = addslashes($HTTP_GET_VARS['edate']);
+} else if (isset($HTTP_GET_VARS['eday'])) {
+ $eday = (int) $HTTP_GET_VARS['eday'];
+ $emon = (int) $HTTP_GET_VARS['emon'];
+ $eyear = (int) $HTTP_GET_VARS['eyear'];
+ $edate = sprintf("%04s-%02s-%02s", $eyear, $emon, $eday);
+} else {
+ $edate = "";
+}
+
+if (isset($HTTP_GET_VARS['special'])) {
+ if ($HTTP_GET_VARS['special'] == 1)
+ $sdate = date("Y-m-01");
+}
+
+
+if ($edate != "" || $sdate != "") {
+ echo "<p><i>";
+
+ if ($edate != "" && $sdate != "") {
+ echo "Showing entries between $sdate (incl) and $edate (excl).";
+ } else if ($edate != "") {
+ echo "Showing entries before $edate (excl).";
+ } else if ($sdate != "") {
+ echo "Showing entries after $sdate (incl).";
+ }
+
+ echo "</p></i>";
+}
+
+$db = pg_pconnect($dbspec);
+
+$where = "WHERE 1=1";
+if ($n_direction == 1) $where = $where." AND incoming='f'";
+if ($n_direction == 2) $where = $where." AND incoming='t'";
+if ($sdate != "") $where = $where." AND _timestamp >= '$sdate'";
+if ($edate != "") $where = $where." AND _timestamp < '$edate'";
+
+$q = pg_query($db, "SELECT CASE WHEN SUBSTRING(remote_msn FROM 1 FOR 3)='".$local_prefix."' THEN SUBSTRING(TRIM(remote_msn) FROM 4) ELSE TRIM(remote_msn) END, CASE WHEN incoming='t' THEN 'Incoming' ELSE 'Outgoing' END, participant, TO_CHAR(_timestamp, 'DD.MM.YYYY HH24:MI'), CASE WHEN duration > 60 THEN duration/60||'m '||duration%60||'s' ELSE duration||'s' END FROM pgets_accounting ".$where." ORDER BY _timestamp ".$order);
+
+$num = pg_numrows($q);
+
+if ($num == 0) {
+ echo "<p><b>No entries found.</b></p>\n";
+} else {
+ echo "<table summary=\"Phone calls\" cellspacing=\"0\" cellpadding=\"2\">\n<tr class=\"theader\"><th>Remote MSN</th><th><a href=\"pgets.php?sdate=$sdate&amp;edate=$edate&amp;order=$n_order&amp;direction=".(($n_direction+1)%3)."\">Direction</a></th><th>P.</th><th><a href=\"pgets.php?sdate=$sdate&amp;edate=$edate&amp;order=".(1-$n_order)."&amp;direction=$n_direction\">Start time</a></th><th>Duration</th></tr>\n";
+
+ $c = 0;
+
+ for ($i = 0; $i < $num; $i++) {
+ $r = pg_fetch_row($q, $i);
+
+
+ $c = 1-$c;
+
+ echo "<tr class=\"line$c\">";
+
+ for ($j=0; $j < count($r); $j++) {
+ echo "<td>&nbsp;$r[$j]&nbsp;</td>";
+ }
+
+ echo "</tr>\n";
+ }
+
+ echo "</table>\n";
+
+ $q = pg_query($db, "SELECT COUNT(*),SUM(duration) FROM pgets_accounting $where");
+ $r = pg_fetch_row($q, 0);
+
+ if ($r[1] > 3600) {
+ $sum = (int) ($r[1]/3600)."h ".(int)($r[1] % 3600 / 60)."m ".(int)($r[1] % 60)."s";
+ } else if ($r[1] > 60) {
+ $sum = (int)($r[1]/60)."m ".(int)($r[1] % 60)."s";
+ } else {
+ $sum = $r[1]."s";
+ }
+
+ echo "<p><b>$r[0] items, $sum total duration.</b></p>";
+}
+
+?>
+
+<hr/>
+<div class="grey">Generated: <?php echo date("r") ?></div>
+</body>
+</html> \ No newline at end of file
diff --git a/php/style.css b/php/style.css
new file mode 100644
index 0000000..ae6132c
--- /dev/null
+++ b/php/style.css
@@ -0,0 +1,39 @@
+/* $Id$ */
+
+/***
+ * This file is part of pgets.
+ *
+ * pgets is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * pgets is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with pgets; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ ***/
+
+body { color: black; background-color: white; margin: 0.5cm; }
+a:link, a:visited { color: #900000; }
+p { margin-left: 0.5cm; margin-right: 0.5cm; }
+div.news-date { margin-left: 0.5cm; font-size: 80%; color: #4f0000; }
+p.news-text { margin-left: 1cm; }
+h1 { color: #00009F; }
+h2 { color: #00009F; }
+h3 { color: #00004F; margin-left: 0.5cm; }
+ul { margin-left: .5cm; }
+ol { margin-left: .5cm; }
+pre { margin-left: .5cm; background-color: #f0f0f0; padding: 0.4cm;}
+.grey { color: #afafaf; }
+
+.radiobox { margin-left: .5cm; background-color:#f0f0f0; padding: 0.4cm; }
+.line0 { background-color:#f0f0f0; }
+.line1 { background-color:#ffffff; }
+.theader { background-color:#d0d0d0; }
+
+table { border:1px solid black; }