Skip to content

Instantly share code, notes, and snippets.

@lukegb
Forked from anonymous/gist:513113
Created August 7, 2010 19:44
Show Gist options
  • Save lukegb/513114 to your computer and use it in GitHub Desktop.
Save lukegb/513114 to your computer and use it in GitHub Desktop.
<?php
require './conf/dbconf.php';
require './conf/opendb.php';
//echo "<pre>".print_r($_REQUEST,true)."</pre>";
session_start();
if (!isset($_SESSION['leo']) || $_SESSION['leo'] != true) {
header('Location: login.php');
exit;
}
$ulvl = $_SESSION['usrlvl'];
$uname = $_SESSION['usrname'];
$uuid = $_SESSION['uuid'];
$deletecount = 0;
$mtr = $_POST['name'];
$N = count($mtr);
echo "
<html>
<head>
<title>
MemoServ Brought to you by Xray-Hope
</title>
</head>
<body bgcolor=\"000000\" text=\"FFFFFF\">
<br>
<br>
<center>
<a href=\"index.php\">Home</a> <a href=\"alt.php\">Request Alt</a> <a href=\"logout.php\">Logout</a>
</center>
<br>
<br>
";
for($i=0; $i < $N; $i++){
echo "
<center>
<form action=\"viewmemos.php?mtri={$i}\" method=\"POST\">
<table width=\"1200px\" border=\"1px\">
<tr>
<td>
<b>
<center>
";
echo $mtr[$i];
echo "
</center>
</b>
</td>
</tr>
</table>
<table width=\"1200px\" border=\"1px\">
<tr height=\"10px\">
<td width=\"20px\">
&nbsp;
</td>
<td width=\"40px\">
<center>
<b>
Chan
</b>
</center>
</td>
<td width=\"150px\">
<center>
<b>
From
</b>
</center>
</td>
<td width=\"150px\">
<center>
<b>
To
</b>
</center>
</td>
<td width=\"60px\">
<center>
<b>
Date
</b>
</center>
</td>
<td width=\"60px\">
<center>
<b>
Time
</b>
</center>
</td>
<td>
<center>
<b>
Message
</b>
</center>
</td>
<td>
&nbsp;
</td>
</tr>
";
$result = '';
$result = mysql_query("SELECT * FROM memos WHERE nickto='".mysql_real_escape_string($mtr[$i])."'");
//if (!$result) echo mysql_error();
$n = 1;
while ($row = mysql_fetch_array($result)) {
if (isset($_GET['mtri']) && isset($_POST['selmemos']) && $_GET['mtri'] == $i && array_search($row['id'], $_POST['selmemos'])) {
mysql_query("DELETE FROM memos WHERE nickto='".mysql_real_escape_string($mtr[$i])."' AND id='".(int)$row['id']."' LIMIT 1");
$deletecount++;
continue;
}
echo "
<tr >
<td width=\"20px\">
";
// echo $row['id']; // Hmm... no. What you actually want is an incrementing number, which makes more sense in this context.
echo $n++;
echo "
</td>
<td width=\"40px\">
";
echo $row['chan'];
echo "
</td>
<td width=\"150px\">
";
echo $row['nickfrom'];
echo "
</td>
<td width=\"150px\">
";
echo $row['nickto'];
echo "
</td>
<td width=\"60px\">
";
echo $row['date'];
echo "
</td>
<td width=\"60px\">
";
echo $row['time'];
echo "
</td>
<td>
";
echo $row['message'];
echo "
</td>
<td width=\"20px\">
<input type=\"checkbox\" name=\"selmemos[]\" value=\"{$row['id']}\" />
</td>
</tr>
";
}
echo "
</table>
<div style=\"float:right;\"><input type=\"submit\" name=\"deletesel\" value=\"Delete Selected Memos\" /></div>
</form>
</center>
<br>
<br>
<br>
<br>
";
}
echo "
</body>
</html>
";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment