<?php
/******************************************************************************
************** Simple SMS Site Software *********************************
************** SSSSv1.0*****************************************************
************** by (aq) limited http://aql.com *******************************
************** All Rights Reserved ******************************************
************** Please read COPYRIGHT file prior to modification********
********************************************************************************/
session_start();
$only_mine = $_GET['o'];
$user = $_SESSION['user'];
$pass = $_SESSION['pass'];
$empty = 'yes';
include("inc/header.inc.php");
if ($access == "forbidden") {
include("inc/restricted.inc.php");
}
elseif ($access == "locked") {
include("inc/restricted.inc.php");
}
else {
include("inc/dbinfo.inc.php");
?>
<h1>Delivery Report Viewer</h1>
<?
if ($access == 'admin') {
if ($only_mine == '1') {
?>
<a href="do_show_delreps.php?o=2">Show all</a>
<?
}
else {
?>
<a href="do_show_delreps.php?o=1">Show mine</a>
<?
}
}
// query db, make array of reference numbers
$query = "SELECT reference FROM delrep ORDER BY id";
$result = mysql_query($query);
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
$row_count = mysql_num_rows($result); // count number of results (i.e no of reports)
for($i = 0; $i < $row_count; $i++)
{
$row = mysql_fetch_row($result); // add each report reference to an array
foreach ($row as $x) {
$repArray[] = $x;
}
}
// query db, make array of report codes
$query = "SELECT reportcode FROM delrep ORDER BY id";
$result = mysql_query($query);
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
$row_count = mysql_num_rows($result); // count number of results (i.e no of reports)
for($i = 0; $i < $row_count; $i++)
{
$row = mysql_fetch_row($result); // add each report reference to an array
foreach ($row as $x) {
$codeArray[] = $x;
}
}
?>
<table class=outline>
<tr BGCOLOR="#66AACC">
<td><p align="center">Index</p></td>
<td><p align="center">Status</p></td>
<td><p align="center">User</p></td>
<td><p align="center">Time</p></td>
</tr>
<?
$row_count = count($repArray);
for($i = 0; $i < $row_count; $i++) // cycle through list, show all references
{
if ($oddRow == 1) {
$colour = "#99CCFF";
$oddRow = 0;
}
else {
$colour = "#FFFFFF";
$oddRow = 1;
}
if ($access == 'admin') { // select all rows if user is an admin
if ($only_mine == '1') {
$query = "SELECT * FROM sent_messages WHERE id='$repArray[$i]' AND username='$user'";
}
else {
$query = "SELECT * FROM sent_messages WHERE id='$repArray[$i]'";
}
}
else { // select current users rows only
$query = "SELECT * FROM sent_messages WHERE id='$repArray[$i]' AND username='$user'";
}
$result = mysql_query($query);
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
$row = mysql_fetch_row($result);
if ($row[0]){ // empty if current row does not belong to current user (unless they have admin privileges)
$empty = 'no';
// the bit that fills the table
?>
<tr BGCOLOR=<?echo "$colour";?>>
<td><p align="center"><?echo "$i";?></p></td>
<td><p align="center"><?
if ($codeArray[$i] == 1) {
echo "Delivered";
}
elseif ($codeArray[$i] == 2) {
echo "Failed";
}
elseif ($codeArray[$i] == 4) {
echo "Buffered";
}
elseif ($codeArray[$i] == 8) {
echo "Accepted by SMSC";
}
elseif ($codeArray[$i] == 16) {
echo "Rejected by SMSC";
}
else {
echo "Failed";
}
?></p></td>
<td><p align="center"><?echo "$row[1]";?></p></td>
<td><p align="center"><?echo "$row[7]";?></p></td>
<td><input type="button" value="details" onClick="javascript:nw=window.open('do_more_delreps.php?id=<?echo "$repArray[$i]";?>&repuser=<?echo $row[1]?>','<?echo "$repArray[$i]";?>','height=340,width=400,location=no,scrollbars=no,menubars=no,toolbars=no,resizable=yes');nw.opener=self;return false;"></td>
</tr><?
}
}
if ($empty == 'yes') {
?>
<tr BGCOLOR=<?echo "$colour";?>>
<td><p align="center">No Reports</p></td>
<td><p align="center">-</p></td>
<td><p align="center">-</p></td>
<td><p align="center">-</p></td>
<td><p align="center">-</p></td>
</tr><?
}
?>
</table>
</form>
<?
}
include("inc/footer.inc.php");
?>