wcddl_reports.php Run the SQL install in code on db.
Code:
<?php
/*BEGIN_INFO
Show the reported sites.
END_INFO*/
if(!defined("WCDDL_GUTS"))
exit;
// SQL Install
/*
CREATE TABLE IF NOT EXISTS `wcddl_reports` (
`id` int(11) NOT NULL auto_increment,
`download` int(11) NOT NULL,
`reason` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
*/
// Config
$modEnabled = true; //Change to false if don't use
if($modEnabled) {
$add = array('reportMod' => "Reported Downloads",);
$core->admin_links = array_merge($core->admin_links, $add);
function reportDownload($id,$reason) {
$id = intval($id);
if($id < 1)
return false;
if(empty($reason))
return false;
mysql_query("INSERT INTO wcddl_reports (download,reason) VALUES ('".$id."','".mysql_real_escape_string($reason)."')");
return true;
}
function reportAdmin() {
switch($_GET['go']) {
case "reportMod":
$get = mysql_query("SELECT id,download,reason FROM wcddl_reports");
echo '<table width="100%" border="0">';
while($row = mysql_fetch_assoc($get)) {
echo '<tr>
//<td>Download #'.$row['download'].'</td>
<td>'.htmlspecialchars($row['reason']).'</td>
<td>Clean</td>
<td>Delete</td>
</tr>';
}
echo '<td>Clean Remove only the Report, Delete Remove the Report & Download.</td></table>';
break;
case "reportModDelete":
if(!isset($_GET['id']))
$msg = 'No ID set!';
else {
$id = intval($_GET['id']);
if($id < 1)
$msg = 'Invalid report ID given!';
else {
$exists = mysql_query("SELECT id, download, reason FROM wcddl_reports WHERE id = ".$id);
$row = mysql_fetch_assoc($exists);
if($row['id'] != $id)
$msg = 'Report does not exist!';
else {
mysql_query("DELETE FROM wcddl_reports WHERE download = ".$row['download']);
mysql_query("DELETE FROM wcddl_downloads WHERE id = ".$row['download']);
$msg = 'Report and Download deleted.';
}
}
}
echo ''.$msg.'';
break;
case "reportModClean":
if(!isset($_GET['id']))
$msg = 'No ID set!';
else {
$id = intval($_GET['id']);
if($id < 1)
$msg = 'Invalid report ID given!';
else {
$exists = mysql_query("SELECT COUNT(0) FROM wcddl_reports WHERE id = ".$id);
$exists = mysql_result($exists,0);
if($exists < 1)
$msg = 'Report does not exist!';
else {
mysql_query("DELETE FROM wcddl_reports WHERE id = ".$id);
$msg = 'Report deleted.';
}
}
}
echo ''.$msg.'';
break;
default:
return true;
break;
}
}
$core->attachHook("adminFunctions","reportAdmin");
}
?>
reportdownload.php
Code:
<?php
include "funcs.php";
if(!isset($_GET['id']))
exit;
$id = intval($_GET['id']);
if($id < 1)
exit;
if(isset($_POST['reason'])) {
$reason = $_POST['reason'];
// Make use of the processURL func to strip crappy chars
$reason = $core->processURL($reason,' ');
if(empty($reason))
$str = 'Empty reason given.';
else {
$exists = mysql_query("SELECT COUNT(0) FROM wcddl_downloads WHERE id = ".$id);
$exists = mysql_result($exists,0);
if($exists < 1)
$str = 'Download does not exist.';
else {
if(reportDownload($id,$reason)) {
$str = 'Reported.';
} else {
$str = 'Report failed for an unknown reason.';
}
}
}
} else
$str = '
Report this Download:
Reason: <input type="text" name="reason" />
<input type="submit" value="Report" />';
?>
<html>
<head>
<title>Report a Download</title>
</head>
<body style='background:#FFF'>
<div style='width:400px; margin:auto; background:#EFEFEF; text-align:center; border:1px solid #777;'>
<form action="reportdownload.php?id=<?=$id?>" method="post">
<?=$str?>
Go Back
</form>
</div>
</body>
</html>
<?php
$core->modules(ob_get_contents());
?>
This has the delete option to remove the report and the link.
Also the clean option which removes only the report.
I believe this is the latest code jomasaco originally posted elsewhere.
Feel free to reply with further details or corrections and even questions.