Code:
<?php
// Buzz inet PHPLS03 - Check User Session is set
session_start();
if(!isset($HTTP_SESSION_VARS['usersession'])){
header("Location: ../login.php");
session_destroy();
$message="";
}
?><?php require_once('../Connections/conn_fra.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_Recordset1 = 30;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_conn_fra, $conn_fra);
$query_Recordset1 = " SELECT `user`.username, `user`.postcode, `form`.userID, `form`.added_by, `form`.email, `form`.phone, `form`.mobile, `form`.address, `form`.suburb, `form`.postcode, `form`.`state`, `form`.`datetime` FROM `user` inner join `form` on `user`.postcode = `form`.postcode WHERE `user`.username = '".$HTTP_SESSION_VARS['usersession']."'ORDER BY userID DESC";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $conn_fra) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
mysql_select_db($database_conn_fra, $conn_fra);
$query_Recordset2 = "SELECT * FROM news";
$Recordset2 = mysql_query($query_Recordset2, $conn_fra) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function BRB_PHP_DelWithCon(deletepage_url,field_name,field_value,messagetext) { //v1.0 - Deletes a record with confirmation
if (confirm(messagetext)==1){
location.href = eval('\"'+deletepage_url+'?'+field_name+'='+field_value+'\"');
}
}
//-->
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/admin.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Administration</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<link href="../css.css" rel="stylesheet" type="text/css" /><!-- InstanceEndEditable -->
<link href="../css.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
background-color: #CCCCCC;
}
-->
</style></head>
<body>
<table width="20" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td><table width="872" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="91"><img src="images/logo.gif" width="600" height="127" /></td>
<td width="22"> </td>
</tr>
<tr>
<td colspan="2"><table width="861" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="5"><div align="right" class="BlueWhiteHeader">ADMINISTRATION </div></td>
</tr>
<tr>
<td colspan="2"> </td>
<td width="598" class="text">Hello <strong><? echo $_SESSION['usersession']; ?>! </strong>You are now Logged in. </td>
<td colspan="2" class="text"><div align="right"><a href="../default.php" class="textLink">Logout</a></div></td>
</tr>
<tr>
<td width="118" valign="top"><p><a href="default.php" class="textLink">Home</a></p>
<p>Archieves</p>
<p><a href="contact_us.php" class="textLink">Contact Us</a></p></td>
<td width="4"> </td>
<td colspan="3"><!-- InstanceBeginEditable name="body" -->
<table width="730" border="0" align="center" class="text">
<tr>
<td colspan="6" valign="top"><p><br />
Welcome to the your administration area.</p>
<p>View the list of leads below. Select there name to view details. </p>
<p>
<?php if ($totalRows_Recordset2 > 0) { // Show if recordset not empty ?>
<strong>Important News: </strong><br />
<?php echo nl2br($row_Recordset2['news']); ?>
<?php } // Show if recordset not empty ?>
</p>
<p> </p></td>
<td valign="top"> </td>
</tr>
<tr>
<td colspan="6" valign="top"><em><strong>List of New Leads </strong></em></td>
<td valign="top"> </td>
</tr>
<tr>
<td colspan="7">Records <?php echo ($startRow_Recordset1 + 1) ?> to <?php echo min($startRow_Recordset1 + $maxRows_Recordset1, $totalRows_Recordset1) ?> of <?php echo $totalRows_Recordset1 ?> </td>
</tr>
<tr bgcolor="#FF9900">
<td width="40"><strong>Lead ID</strong></td>
<td width="138"><strong>Name</strong></td>
<td width="132"><strong>Submitted</strong></td>
<td width="121"><strong>Suburb</strong></td>
<td width="60"><strong>Post Code</strong> </td>
<td width="49"> </td>
<td width="42"><div align="center"><strong>Delete</strong></div></td>
</tr>
<?php do { ?>
<?php if ($totalRows_Recordset1 > 0) { // Show if recordset not empty ?>
<tr valign="middle" bgcolor="#FFFFCC">
<td width="40"><div align="center">#<?php echo $row_Recordset1['userID']; ?></div></td>
<td><a href="detail.php?userID=<?php echo $row_Recordset1['userID']; ?>"> <span class="textLink"><?php echo ucwords($row_Recordset1['added_by']); ?></span></a></td>
<td><?php echo $row_Recordset1['datetime']; ?></td>
<td width="121"><?php echo ucwords($row_Recordset1['suburb']); ?></td>
<td width="60"><?php
#$postcode = $row_Recordset1['postcode'];
$postcode_in = $row_Recordset1['postcode'];
$postcode = explode(",", $postcode_in);
foreach ($postcode as $postcode_out) {
echo $postcode_out .'<br />';
}
print_r($postcode);
?></td>
<td><div align="center" class="textLink"><a href="reply.php?userID=<?php echo $row_Recordset1['userID']; ?>">Respond</a></div></td>
<td><div align="center"><a href="javascript:BRB_PHP_DelWithCon('delete.php','userID',<?php echo $row_Recordset1['userID']; ?>,'Are you sure you want to delete this record?');"><img src="../images/cancel_f2.png" width="24" height="24" border="0" /></a></div></td>
</tr>
<?php } // Show if recordset not empty ?>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<br>
<table border="0" width="50%" align="center">
<tr>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, 0, $queryString_Recordset1); ?>" class="textLink">First</a>
<?php } // Show if not first page ?> </td>
<td width="31%" align="center"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>" class="textLink">Previous</a>
<?php } // Show if not first page ?> </td>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>" class="textLink">Next</a>
<?php } // Show if not last page ?> </td>
<td width="23%" align="center"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, $totalPages_Recordset1, $queryString_Recordset1); ?>" class="textLink">Last</a>
<?php } // Show if not last page ?> </td>
</tr>
</table>
<!-- InstanceEndEditable --></td>
</tr>
<tr>
<td colspan="2"> </td>
<td colspan="2"> </td>
<td width="103"> </td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2" bgcolor="#EEEEEE"><div align="center" class="text">© Free Realestate Appraisals 2007 </div></td>
</tr>
</table></td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($Recordset1);
mysql_free_result($Recordset2);
?>
Bookmarks