[align=center]Bug Report [v2][/align]
[align=left]This Modification is somewhat helpful for game owners that aren't always available to be searching for bugs. Although you can't depend on users to actually not abuse it and just report it, it gives a 50 crystal reward upon staff confirmation ( not automatic, you have to click a confirm button ). I believe its secure, if any problems just either tell me or fix it and post it on here :). [/align]
-------------------------------
SQL
[mysql]
-- phpMyAdmin SQL Dump
-- version 3.2.4
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 03, 2010 at 07:00 PM
-- Server version: 5.0.90
-- PHP Version: 5.2.6
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `devcommu_corruptw`
--
-- --------------------------------------------------------
--
-- Table structure for table `bugs`
--
CREATE TABLE IF NOT EXISTS `bugs` (
`bugID` int(11) NOT NULL auto_increment,
`bugPROBLEM` text NOT NULL,
`bugUSER` int(11) NOT NULL,
`bugACTIVE` int(11) NOT NULL default '1',
PRIMARY KEY (`bugID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- Dumping data for table `bugs`
--
[/mysql]
bugs.php ( All in One )
<?php
/*
Modification By Solid Snake for McCodes.
Free-to-use and distribute as long as you keep this tag on :).
Q&C: [email]
[email protected][/email]
*/
require_once(DIRNAME(__FILE__) . '/globals.php');
$_GET['cmd'] = isset($_GET['cmd']) && is_string($_GET['cmd']) && ctype_alpha($_GET['cmd']) ? strtolower(trim($_GET['cmd'])) : FALSE;
switch($_GET['cmd']){
case 'new': new_bug(); break;
case 'del': del_bug(); break;
case 'truncate': truncate_bug(); break;
case 'confirm': confirm_bug(); break;
case 'rules': rules_bug(); break;
default: index(); break;
}
function strip_my_slashes($text){
global $db;
return str_replace(array("/","\\"), array("",""), $text);
}
function index(){
global $db,$ir,$h;
echo '<h3>[img=icons/bug.png] <span style="color:orange;">Bug Reports</span></h3>
[url="bugs.php?cmd=rules"][img=icons/information.png] Reporting Rules[/url]
[url="bugs.php?cmd=new"][img=icons/bug_add.png] New Bug Report[/url]
';
if($ir['user_level'] == 2) { echo '[url="bugs.php?cmd=truncate"][img=icons/bug_delete.png] Delete All Bug Reports[/url]
'; }
echo '
';
$bq = $db->query("SELECT bug.`bugID`,bug.`bugPROBLEM`,bug.`bugUSER`,bug.`bugACTIVE`,u.`userid`,u.`username`,u.`gender` ".
"FROM bugs bug ".
"LEFT JOIN users u ".
"ON bug.`bugUSER`=u.`userid` ".
"ORDER BY bug.`bugID` DESC");
if(!$db->num_rows($bq)){
echo 'There are no active bug reports!';
$h->endpage();
exit;
} else {
echo 'There are '.$db->num_rows($bq).' Bug Reports.';
$actions = ($ir['user_level'] == 2) ? '<th width="10%" style="color:black;">Staff Actions</th>' : '';
echo '<table width="80%" cellspacing="0" class="table" style="text-align:center; table-layout:fixed;">
<tr>
<th width="20%">Reported By</th>
<th width="35%">Problem</th>
<th width="10%">Status</th>
'.$actions.'
</tr>';
while($bug = $db->fetch_row($bq)){
$action_data = ($ir['user_level'] == 2) ? '<td>[url="bugs.php?cmd=confirm&bugid='.$bug['bugID'].'"][img=icons/accept.png][/url] [url="bugs.php?cmd=del&bugid='.$bug['bugID'].'"][img=icons/cross.png][/url]</td>' : '';
$user_img = ($bug['gender'] == 'Male') ? '[img=icons/user.png]' : '[img=icons/user_female.png]';
$status = ($bug['bugACTIVE']) ? '[img=icons/accept.png]' : '[img=icons/delete.png]';
$prob = $bug['bugPROBLEM'];
echo '
<tr class="back">
<td width="20%" style="word-wrap:break-word;">'.$user_img.' '.strip_tags($bug['username']).'['.$bug['userid'].']</td>
<td width="35%" style="word-wrap:break-word;">'.strip_tags(htmlentities(strip_my_slashes($prob))).'</td>
<td width="15%">'.$status.'</td>
'.$action_data.'
</tr>
';
}
echo '</table>';
}
}
function new_bug(){
global $db,$ir,$h;
echo '<h3>[img=icons/bug.png] <span style="color:orange;">File a Bug Report</span></h3>
';
if(!$_POST['SubmitBug']){
echo 'Note: If the Bug Reported is found fake, you will not recieve 50 points for the report.
If you file 3 or more fake Bug Reports, you will be banned from the game.
';
echo '<form action="bugs.php?cmd=new" method="POST">
<table width="40%" cellspacing="1" class="table" style=" text-align:center;">
<tr>
<th style="color:black;">Report:</th><td><textarea name="bugREPORT" style="width:98%; height:100px; " maxlength="255">No HTML Allowed, 255 Character Limit, No BBCode
</textarea></td>
</tr>
<tr>
<td></td><td><input type="submit" name="SubmitBug" value="File Bug Report!" style="background-color:#A68064; border:2px solid #A68064;"></td>
</tr>
</table>
</form>';
} else {
if(preg_match("/<[^<]+?>/is",$_POST['bugREPORT'])){
echo 'Report cannot be submitted for the following reason(s): [b]HTML found[/b]!';
$h->endpage();
exit;
}
if(preg_match("/\[[^\[]+?\]/is",$_POST['bugREPORT'])){
echo 'Report cannot be submitted for the following reason(s): [b]BBCode found[/b]!';
$h->endpage();
exit;
}
if(strlen($_POST['bugREPORT']) > 255){
echo 'Report cannot be submitted for the following reason(s): [b]Length exceeds 255 Characters[/b]!';
$h->endpage();
exit;
}
$db->query("INSERT INTO `bugs` VALUES('$i','".$db->escape(strip_tags(htmlentities($_POST['bugREPORT'])))."','".$ir['userid']."',0)");
event_add(1,"{$ir['username']} has posted a new Bug Report.",$c);
echo 'Your Bug Report has been successfully filed!
Redirecting...
<meta http-equiv="refresh" content="3; bugs.php">';
}
}
function del_bug(){
global $db,$ir,$h;
$_GET['bugid'] = abs((int) $_GET['bugid']);
echo '<h3>Delete Bug Report</h3>
';
if($ir['user_level'] != 2){
echo 'You don\'t have permission to do this action!';
$h->endpage();
exit;
}
if(!$_GET['bugid']){
echo 'Report does not exist!';
$h->endpage();
exit;
}
$rq = $db->query("SELECT `bugID` FROM `bugs` WHERE `bugID`=".$_GET['bugid']);
if(!$db->num_rows($rq)){
echo 'Report does not exist!';
$h->endpage();
exit;
} else {
$db->query("DELETE FROM `bugs` WHERE `bugID`=".$_GET['bugid']);
stafflog_add("Deleted Bug ID#".$_GET['bugid']);
echo 'You have successfully deleted Bug ID #'.$_GET['bugid'].'!
Redirecting...
<meta http-equiv="refresh" content="3; bugs.php">';
}
}
function truncate_bug(){
global $db,$ir,$h;
echo '<h3>Delete All Bug Reports</h3>
';
if($ir['user_level'] != 2){
echo 'You don\'t have permission to do this action!';
$h->endpage();
exit;
} else {
echo 'You have successfully deleted all Bug Reports!
Redirecting...
<meta http-equiv="refresh" content="3; bugs.php">';
$db->query("TRUNCATE TABLE `bugs`");
}
}
function rules_bug(){
echo '<h3>[img=icons/information.png] Reporting Rules</h3>
';
echo '[list=1]
[*]Any reports not relating to bugs are considered spam, and will be handled at a staff member\'s discretion
[*]Any attempt to get around our filters is considered permanent ban.
[*]Please give a good description of the bug if you want to recieve your points.
If we can\'t understand it, we\'ll have to deny it.
[*]Spam is considered an automatic ban. If you are caught spamming, you will be banned, no matter what.
[*]These rules apply to everyone, including donators. If you are caught spamming or cheating the reports, you will be banned.
[*]Ignorance of these rules is no excuse.
[/list]
*Rules are subject to change.';
}
function confirm_bug(){
global $db,$h,$c;
$_GET['bugid']+=0;
if(!$_GET['bugid']){
echo 'Bug entry doesn\'t exist!';
$h->endpage();
exit;
}
$bq = $db->query("SELECT `bugID`,`bugUSER`,`bugACTIVE` FROM `bugs` WHERE `bugID` = ".$_GET['bugid']);
$br = $db->fetch_row($bq);
if(!$db->num_rows($bq)){
echo 'Bug entry doesn\'t exist!';
$h->endpage();
exit;
}
if($br['bugACTIVE']){
echo 'This bug is already confirmed.';
$h->endpage();
exit;
}
$db->query("UPDATE `users` SET `crystals`=`crystals`+50 WHERE `userid`=".$br['bugUSER']);
event_add($br['bugUSER'],"You have been rewarded 50 points from the administration for filing a valid bug report.
Thank you, - Staff",$c);
echo '50 Points were rewarded to ID #'.$br['bugUSER'].'!
Redirecting...<meta http-equiv="refresh" content="3; bugs.php">';
$db->query("UPDATE `bugs` SET `bugACTIVE`=1 WHERE `bugID`=".$_GET['bugid']);
}
echo '
© Extension by [url="http://makewebgames.io/user/15858/solidsnake/"]Solid Snake[/url] 2010.';
$h->endpage();
?>
Lite
<?php
/*
Modification By Solid Snake for McCodes.
Free-to-use and distribute as long as you keep this tag on :).
Q&C: [email]
[email protected][/email]
*/
session_start();
require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$cm=money_formatter($ir['crystals'],'');
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm,$cm);
$h->menuarea();
$_GET['cmd'] = isset($_GET['cmd']) && is_string($_GET['cmd']) && ctype_alpha($_GET['cmd']) ? strtolower(trim($_GET['cmd'])) : FALSE;
switch($_GET['cmd']){
case 'new': new_bug(); break;
case 'del': del_bug(); break;
case 'truncate': truncate_bug(); break;
case 'confirm': confirm_bug(); break;
case 'rules': rules_bug(); break;
default: index(); break;
}
function strip_my_slashes($text){
return str_replace(array("/","\\"), array("",""), $text);
}
function index(){
global $ir,$c,$h;
echo '<h3>[img=icons/bug.png]<span style="color:orange;">Bug Reports</span></h3>
[url="bugs.php?cmd=rules"][img=icons/information.png]Reporting Rules[/url]
[url="bugs.php?cmd=new"][img=icons/bug_add.png]New Bug Report[/url]
';
if($ir['user_level'] == 2) { echo '[url="bugs.php?cmd=truncate"][img=icons/bug_delete.png]Delete All Bug Reports[/url]
'; }
echo '
';
$bq = mysql_query("SELECT bug.`bugID`,bug.`bugPROBLEM`,bug.`bugUSER`,bug.`bugACTIVE`,u.`userid`,u.`username`,u.`gender` ".
"FROM bugs bug ".
"LEFT JOIN users u ".
"ON bug.`bugUSER`=u.`userid` ".
"ORDER BY bug.`bugID` DESC",$c);
if(!mysql_num_rows($bq)){
echo 'There are no active bug reports!';
exit;
} else {
echo 'There are '.mysql_num_rows($bq).' Bug Reports.';
$actions = ($ir['user_level'] == 2) ? '<th width="10%" style="color:black;">Staff Actions</th>' : '';
echo '<table width="80%" cellspacing="0" class="table" style="text-align:center; table-layout:fixed;">
<tr>
<th width="20%">Reported By</th>
<th width="35%">Problem</th>
<th width="10%">Status</th>
'.$actions.'
</tr>';
while($bug = mysql_fetch_array($bq)){
$action_data = ($ir['user_level'] == 2) ? '<td>[url="bugs.php?cmd=confirm&bugid='.$bug['bugID'].'"][img=icons/accept.png][/url] [url="bugs.php?cmd=del&bugid='.$bug['bugID'].'"][img=icons/cross.png][/url]</td>' : '';
$user_img = ($bug['gender'] == 'Male') ? '[img=/icons/user.png]' : '[img=/icons/user_female.png]';
$status = ($bug['bugACTIVE']) ? '[img=icons/accept.png]' : '[img=icons/delete.png]';
$prob = $bug['bugPROBLEM'];
echo '
<tr class="back">
<td width="20%" style="word-wrap:break-word;">'.$user_img.''.strip_tags($bug['username']).'['.$bug['userid'].']</td>
<td width="35%" style="word-wrap:break-word;">'.strip_tags(htmlentities(strip_my_slashes($prob))).'</td>
<td width="15%">'.$status.'</td>
'.$action_data.'
</tr>
';
}
echo '</table>';
}
}
function new_bug(){
global $ir,$c,$h;
echo '<h3>[img=icons/bug.png]<span style="color:orange;">File a Bug Report</span></h3>
';
if(!$_POST['SubmitBug']){
echo 'Note: If the Bug Reported is found fake, you will not recieve 50 points for the report.
If you file 3 or more fake Bug Reports, you will be banned from the game.
';
echo '<form action="bugs.php?cmd=new" method="POST">
<table width="40%" cellspacing="1" class="table" style=" text-align:center;">
<tr>
<th style="color:black;">Report:</th><td><textarea name="bugREPORT" style="width:98%; height:100px; " maxlength="255">No HTML Allowed, 255 Character Limit, No BBCode
</textarea></td>
</tr>
<tr>
<td></td><td><input type="submit" name="SubmitBug" value="File Bug Report!" style="background-color:#A68064; border:2px solid #A68064;"></td>
</tr>
</table>
</form>';
} else {
if(preg_match("/<[^<]+?>/is",$_POST['bugREPORT'])){
echo 'Report cannot be submitted for the following reason(s): [b]HTML found[/b]!';
$h->endpage();
exit;
}
if(preg_match("/\[[^\[]+?\]/is",$_POST['bugREPORT'])){
echo 'Report cannot be submitted for the following reason(s): [b]BBCode found[/b]!';
$h->endpage();
exit;
}
if(strlen($_POST['bugREPORT']) > 255){
echo 'Report cannot be submitted for the following reason(s): [b]Length exceeds 255 Characters[/b]!';
$h->endpage();
exit;
}
mysql_query("INSERT INTO `bugs` VALUES('$i','".mysql_escape(strip_tags(htmlentities($_POST['bugREPORT'])))."','".$ir['userid']."',0)",$c);
event_add(1,"{$ir['username']} has posted a new Bug Report.",$c);
echo 'Your Bug Report has been successfully filed!
Redirecting...
<meta http-equiv="refresh" content="3; bugs.php">';
}
}
function del_bug(){
global $ir,$c,$h;
$_GET['bugid']+=0;
echo '<h3>Delete Bug Report</h3>
';
if($ir['user_level'] != 2){
echo 'You don\'t have permission to do this action!';
exit;
}
if(!$_GET['bugid']){
echo 'Report does not exist!';
exit;
}
$rq = mysql_query("SELECT `bugID` FROM `bugs` WHERE `bugID`=".$_GET['bugid'],$c);
if(!mysql_num_rows($rq)){
echo 'Report does not exist!';
exit;
} else {
mysql_query("DELETE FROM `bugs` WHERE `bugID`=".$_GET['bugid'],$c);
echo 'You have successfully deleted Bug ID #'.$_GET['bugid'].'!
Redirecting...
<meta http-equiv="refresh" content="3; bugs.php">';
}
}
function truncate_bug(){
global $ir,$c,$h;
echo '<h3>Delete All Bug Reports</h3>
';
if($ir['user_level'] != 2){
echo 'You don\'t have permission to do this action!';
exit;
} else {
echo 'You have successfully deleted all Bug Reports!
Redirecting...
<meta http-equiv="refresh" content="3; bugs.php">';
mysql_query("TRUNCATE TABLE `bugs`",$c);
}
}
function rules_bug(){
echo '<h3>[img=icons/information.png]Reporting Rules</h3>
';
echo '[list=1]
[*]Any reports not relating to bugs are considered spam, and will be handled at a staff member\'s discretion
[*]Any attempt to get around our filters is considered permanent ban.
[*]Please give a good description of the bug if you want to recieve your points.
If we can\'t understand it, we\'ll have to deny it.
[*]Spam is considered an automatic ban. If you are caught spamming, you will be banned, no matter what.
[*]These rules apply to everyone, including donators. If you are caught spamming or cheating the reports, you will be banned.
[*]Ignorance of these rules is no excuse.
[/list]
*Rules are subject to change.';
}
function confirm_bug(){
global $ir,$c,$h;
$_GET['bugid']+=0;
if($ir['user_level'] != 2){
echo 'Your not supposed to be here.';
exit;
}
if(!$_GET['bugid']){
echo 'Bug entry doesn\'t exist!';
$h->endpage();
exit;
}
$bq = mysql_query("SELECT `bugID`,`bugUSER`,`bugACTIVE` FROM `bugs` WHERE `bugID` = ".$_GET['bugid'],$c);
$br = mysql_fetch_array($bq);
if(!mysql_num_rows($bq)){
echo 'Bug entry doesn\'t exist!';
exit;
}
if($br['bugACTIVE']){
echo 'This bug is already confirmed.';
exit;
}
mysql_query("UPDATE `users` SET `crystals`=`crystals`+50 WHERE `userid`=".$br['bugUSER']);
event_add($br['bugUSER'],"You have been rewarded 50 points from the administration for filing a valid bug report.
Thank you, - Staff",$c);
echo '50 Points were rewarded to ID #'.$br['bugUSER'].'!
Redirecting...<meta http-equiv="refresh" content="3; bugs.php">';
mysql_query("UPDATE `bugs` SET `bugACTIVE`=1 WHERE `bugID`=".$_GET['bugid'],$c);
}
echo '
© Extension by [url="http://makewebgames.io/user/15858/solidsnake/"]Solid Snake[/url] 2010.';
$h->endpage();
?>
If you have any questions regarding this modification, dont hesitate to PM me :).