First off, I want to thank everyone on the forum, I've learned so much here! I've never posted because I'm just learning PHP and haven't had a question yet that I couldn't figure out by reading other's questions and your AMAZINGLY HELPFUL answers. So, thank you!
Now, for my problem. I'm helping a friend with a script he bought, and he needs a delete function for his user submissions. Currently there is only an accept or deny function, but that's creating a mess for moderation since there are a ton of denied submissions.
This is the code from the admin/index.php file, which is all I can find to need to modify. I tried to do it myself, but failed miserably, so this is the original code.
<?php
$admin = "../";
if($page_var == 'meta'){
if($_POST['title']){
$editingMetaData = true;
}
}
function getTimestamp($date) {
//23/06/2009 16:07
$pattern = "^([0-9]{2})/([0-9]{2})/([0-9]{4}) ([0-9]{2}):([0-9]{2})[:]*([0-9]*)$";
eregi($pattern,$date,$result);
$result = mktime($result[4],$result[5],$result[6],$result[1],$result[2],$result[3]);
return $result;
}
include('header.php');
if(!isset($_SESSION['user']) || $_SESSION['user']['level'] < 3) {
// the user is not connected or has not the necessary level.
// Display the login form.
$page = get_page('login');
$layout = str_replace('[[main-content]]', $page, $layout);
$page = str_replace("[[sitename]]", $copyright, $page);
echo $page;
} else {
$page_var = $_SERVER['QUERY_STRING'];//_SERVER['argv'][0];
// get the first parameter
$page_var = explode('&', $page_var);
$page_var = $page_var[0];
if(trim($page_var) == "") {
$page_var = 'index';
}
//if(count($_SERVER['argv']) < 1) $page = get_page('index');
//else $page = get_page($page_var);
$page = get_page($page_var);
if($page_var == 'main'){
if($_POST['SAVE']){
mysql_query("UPDATE `fmyclone_settings` SET `data2` = '". $_POST['sharelinksD2'] ."', `data1` = '". $_POST['sharelinksD1'] ."' WHERE `id` = 'sharelinks'");
mysql_query("UPDATE `fmyclone_settings` SET `data2` = '". clean($_POST['votes1D2']) ."' WHERE `id` = 'votes1'");
mysql_query("UPDATE `fmyclone_settings` SET `data2` = '". clean($_POST['votes2D2']) ."' WHERE `id` = 'votes2'");
mysql_query("UPDATE `fmyclone_settings` SET `data1` = '". $_POST['submitpop'] ."' WHERE `id` = 'submit'");
$result = "<strong>Settings updated!</strong>";
}
$page = str_replace('%result%', $result, $page);
$page = str_replace('%votes1%', $phrase1, $page);
$page = str_replace('%votes2%', $phrase2, $page);
$page = str_replace('%sharelinkscode%', $sharelinkscode, $page);
$page = str_replace('%sharelinkschecked%', $sharelinkschecked, $page);
$page = str_replace('%submitchecked%', $submitpopchecked, $page);
$page = str_replace('%so%', $submitpopno, $page);
}
if($page_var == 'moderate'){
// See if there is a submission to save
$editForm = "";
if(isset($_REQUEST['action']) && ($_REQUEST['action'] == "editCompliment")) {
if(isset($_REQUEST['message'])) {
// save the comment.
$query = "update comps set message='" . addslashes($_REQUEST['message']) . "' where id='". $_REQUEST['compId'] ."'";
$result = mysql_query($query);
if($result) {
$editForm = "Submission saved!";
} else {
$editForm = "Errors occured while saving the submission: " . mysql_error();
}
$page = str_replace('%editDisplay%', "none", $page);
} else {
// display the editing form.
$editForm = "";
// read the comment text
$query = "select id,message from comps where id='". $_REQUEST['compId'] ."'";
$result = mysql_query($query);
if(mysql_num_rows($result) == 1) {
$comment = mysql_fetch_array($result);
$page = str_replace('%submissionMessage%', $comment['message'], $page);
$page = str_replace('%compId%', $comment['id'], $page);
$page = str_replace('%editDisplay%', "block", $page);
// $editForm .="<div class=\"result\" style=\"width:320px;\">
// <form name=\"editComment\" action=\"\" method=\"post\" style=\"padding:6px;font-size:11px;\">
// <textarea id=\"commentbox\" cols=\"40\" rows=\"3\" name=\"message\">" . $comment['message'] . "</textarea>
// <br/>
// <input type=\"hidden\" value=\"" . $_REQUEST['commentId'] . "\" name=\"commentId\"/>
// <input type=\"hidden\" value=\"edit\" name=\"action\"/>
// <input class=\"button_login2\" type=\"submit\" style=\"font-size:10px;\" value=\"Save Comment\" name=\"save_comment\"/>
// </form>
// </div>";
} else {
// display somme error message here.
echo "No submission was found.";
}
}
} else {
$page = str_replace('%editDisplay%', "none", $page);
}
if(isset($_REQUEST['cleanfilter'])) {
// clean the filter
$_SESSION['filtre'] = null;
}
$filter = array("filtreSubmittedBy"=>"",
"acceptedStatus"=>"",
"deniedStatus"=>"",
"ddebut"=>"",
"dfin"=>"");
$useFilter = false;
// proccess the filter here
//print_r($_REQUEST);
if(isset($_REQUEST['filterSubmit'])) {
$filter = $_REQUEST['filtre'];
$_SESSION['filtre'] = $filter;
$useFilter = true;
} else if(isset($_SESSION['filtre'])) {
// see if the filter is somewhere in the session
$filter = $_SESSION['filtre'];
$useFilter = true;
}