Forgot Password / Register
Site Statistics
Total Members: 509
Total Tutorials: 242
Newsest User: Lestop
Todays Unique Hits: 92
0 Users 2 Guests Online

Report & Warn Script

First off you will want to run the following in phpMyAdmin

Code

CREATE TABLE `reps` (
`id` INT( 11 ) NOT NULL auto_increment,
`username` VARCHAR( 255 ) NOT NULL,
`reason` TEXT NOT NULL,
`date` VARCHAR( 255 ) NOT NULL,
`reported_by` VARCHAR( 255 ) NOT NULL,
PRIMARY KEY(`id`)
);

CREATE TABLE warnings (
`id` INT( 11 ) NOT NULL auto_increment,
`user` VARCHAR( 255 ) NOT NULL,
`reason` TEXT NOT NULL,
`from` VARCHAR( 255 ) NOT NULL,
`date` VARCHAR( 255 ) NOT NULL,
PRIMARY KEY(`id`)
);


Next, call this file report.php
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
if(!$logged['username']){//check for logged username
    
print "<h2>Error</h2>
    <p>
    You Are Not Logged In
    </p>"
//they aren't so give err
}else{ //or
    
if(!$_POST['report']){ //form wasn't submitted
        
print "<h2>Report User</h2>
        <form method=\"post\" action=\"
$_SERVER[PHP_SELF]\">
        <p>
        <label>Username</label>
        <input type=\"text\" name=\"user\" size=\"30\" />
        <label>Reason</label>
        <textarea cols=\"25\" rows=\"5\" name=\"reason\"></textarea>
        <input type=\"submit\" name=\"report\" value=\"Report User\" />
        </p>
        </form>"
//give the form to report someone :)
    
}else{ //or...
        
$user protect($_POST['user']); //protect the username being reported
        
$reason protect($_POST['reason']); //protect the text input again
        
$date date("d-m-y h:i A"); //today's date
        
$from $logged['username']; //logged user :)
        
if(empty($user) || empty($reason)){ //something was empty!!!!
            
print "<h2>Error</h2>
            <p>
            You Must Fill Out The Form Completely
            </p>"
//haha you fail!
        
}else{ //or not?
            
$insert mysql_query("INSERT INTO `reps` (`username`,`reason`,`date`,`reported_by`) VALUES ( '$user','$reason','$date','$from');"); //insert the data
            
if(mysql_error()){ //poo theres an error
                
print "<h2>Error</h2>
                <p>" 
mysql_error() . "</p>"//echo the error
            
}else{ //or...
                
print "<h2>Success</h2>
                <p>
                Report Sent!
                </p>"
//no error
            
//end error check
        
//end empty check
    
}//end form check
//end logged in check
?>


Thats that read the comments and such :P
this next file is called repcp.php and its accessible by mods and admins.

PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
if(!$logged['username']){ //check logged user
    
print "<h2>Error</h2>
    <p>
    You Are Not Logged In!
    </p>"
//nope
}elseif($logged['username'] && $logged['userlevel'] < '4'){ //not an admin or mod
    
print "<h2>Error</h2>
    <p>
    You Do Not Have Access to this Function.
    </p>"
//give error >:|
}else{ //or they are :D
    
switch($_GET['x']){ //make multiple pages
        
default: //default
            
$get_reps mysql_query("SELECT * FROM `reps` ORDER BY `id` DESC"); //get all reports
            
if(mysql_num_rows($get_reps) == 0){ //none >:(
                
print "<h2>No Reports</h2>
                <p>
                There are No Reports in the Database.
                </p>"
//woohoo error!!
            
}else{ //or not >)
                
print "<table width=\"500\">
                <tr>
                <td align=\"left\" valign=\"middle\">
                <b>User</b>
                </td>
                <td align=\"left\" valign=\"middle\">
                <b>Reported By</b>
                </td>
                <td align=\"left\" valign=\"middle\">
                <b>Reason</b>
                </td>
                <td align=\"left\" valign=\"middle\">
                <b>Date Sent</b>
                </td>
                <td align=\"center\" valign=\"middle\">
                <b>Options</b>
                </td>
                </tr>"
//table headers
                
while($reps mysql_fetch_array($get_reps)){ //make a loop for the reports to be shown
                    
print "<tr>
                    <td align=\"left\" valign=\"middle\">
                    
$reps[username]
                    </td>
                    <td align=\"left\" valign=\"middle\">
                    
$reps[reported_by]
                    </td>
                    <td align=\"left\" valign=\"middle\">
                    
$reps[reason]
                    </td>
                    <td align=\"left\" valign=\"middle\">
                    
$reps[date]
                    </td>
                    <td align=\"center\" valign=\"middle\">
                    <a href=\"repcp.php?x=warn&id=
$reps[id]\">Warn $reps[username]</a>&nbsp;||&nbsp;
                    <a href=\"repcp.php?x=delete&id=
$reps[id]\">Delete Report</a>
                    </td>
                    </tr>"
//yay for data to be shown :)
                
//end the loop :(
            
//end the reports check
            
break; //end the default page
        
case 'warn'//haha i get to warn the dude >:)
            
$id = (int) addslashes($_GET['id']); //make the ID Safe
            
if(!$id){ //no id sucker!
                
print "<h2>Error</h2>
                <p>
                No ID Selected
                </p>"
//haha you got an error
            
}else{ //or not :(
                
$check mysql_query("SELECT * FROM `reps` WHERE `id` = '$id';"); //check to make sure
                
if(mysql_num_rows($check) == 0){ //lol you still got an error >:)
                    
print "<h2>Error</h2>
                    <p>
                    Invalid ID Selected.
                    </p>"
//give him/her what they came for!
                
}else{ //or not...
                    
$array mysql_fetch_array($check); //array the data
                    
if(!$_POST['warn']){ //warn form wasn't submitted
                        
print "<h2>Warn $array[username]</h2>
                        <form method=\"post\" action=\"
$_SERVER[PHP_SELF]?x=warn&id=$id\">
                        <p>
                        <label>Reason</label>
                        <textarea rows=\"5\" cols=\"25\" name=\"reason\"></textarea>
                        <input type=\"submit\" name=\"warn\" value=\"Warn 
$array[username]\">
                        </p>
                        </form>"
//give the reasoning form :)
                    
}else{ //chyea the form was submitted
                        
$reason protect($_POST['reason'])); //make the reason safe
                        
$date date("m-d-y h:i A"); //the date
                        
$from $logged['username']; //who warned
                        
if(empty($reason)){ //reason was empty
                            
print "<h2>Error</h2>
                            <p>
                            You Must Give A Reason
                            </p>"
//lol you got an error
                        
}else{ //darn. your not.
                            
$insert mysql_query("INSERT INTO `warns` (`user`,`reason`,`from`,`date`) VALUES ('$array[username]','$reason','$from','$date');"); //warn the user
                            
$delete mysql_query("DELETE FROM `warns` WHERE `id` = '$id';"); //delete the report
                            
if(!mysql_error()){ //no mySQL Error
                                
print "<h2>Success</h2>
                                <p>
                                
$array[user] Has Been Warned!
                                </p>"
//yay they were warned!
                            
}else{ //or not
                                
print "<h2>Error</h2>
                                <p>
                                "
.mysql_error()."
                                </p>"
//HAHA YOU GOT AN ERROR
                            
//end error check
                        
//end empty form check
                    
//end the form submit check
                
//end the verification check
            
//end the final check if id is there or not xD
            
break;
        case 
'delete'//the delete report page >:)
            
$id = (int) addslashes($_GET['id']); //make the ID safe
            
if(!$id){ //no id HAHA
                
print "<h2>Error</h2>
                <p>
                No ID Selected
                </p>"
//lol you got an error
            
}else{ //there was an id D:
                
$check mysql_query("SELECT * FROM `reps` WHERE `id` = '$id';"); //check DB for ID
                
if(mysql_num_rows($check) == 0){ //haha not found
                    
print "<h2>Error</h2>
                    <p>
                    Invalid ID Selected
                    </p>"
//invalid ID
                
}else{ //its found :) :(
                    
$delete mysql_query("DELETE FROM `reps` WHERE `id` = '$id';"); //delete it 
                    
if(!mysql_error()){ //no error
                        
print "<h2>Success</h2>
                        <p>
                        Report Deleted
                        </p>"
//yay!!
                    
}else{ //or not....
                        
print "<h2>Error</h2>
                        <p>
                        "
.mysql_error()."
                        </p>"
//you got an error
                    
//end error check
                
//end verification check
            
//end first id check
            
break; //end the page
    
}//end the switch function
//end logged username check
?>


WOOHOO okay we got all that but you cant view your warns :(

call this file: my_warns.php and type something like the following.

PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
if(!$logged['username']){ //not logged in
    
print "<h2>Error</h2>
    <p>
    You Are not Logged In
    </p>"
//lol error
}else{ //or they are
    
print "<h2>Your Warnings</h2>
    <table width=\"400\">
    <tr>
    <td align=\"left\" valign=\"middle\">
    <b>Warned By</b>
    </td>
    <td align=\"left\" valign=\"middle\">
    <b>Reason</b>
    </td>
    <td align=\"left\" valign=\"middle\">
    <b>Date Warned</b>
    </td>
    </tr>"
//table headers
    
$get_warns mysql_query("SELECT * FROM `warns` WHERE `user` = '$logged[username]';"); //get the users warns
    
while($warns mysql_fetch_array($get_warns)){ //loop them
        
print "<tr>
        <td align=\"left\" valign=\"middle\">
        
$warns[from]
        </td>
        <td align=\"left\" valign=\"middle\">
        
$warns[reason]
        </td>
        <td align=\"left\" valign=\"middle\">
        
$warns[date]
        </td>
        </tr>"
//display their warns
    
//end loop
    
print "    </table>"//end table
}
?>


Thats that!

Next part will have the user jail( by darklight ) and the user banning.
ShadowMage
Author:
Views:
2442
Rating:
Posted on Saturday 12th September 2015 at 05:24 PM
deathwish
deathwish
ops sorry for double post. the post didn't show up so i thought my net was giving issues
Posted on Saturday 12th September 2015 at 05:23 PM
deathwish
deathwish
Code

$delete = mysqli_query($db,"DELETE FROM `warns` WHERE `id` = '$id';"); //delete the report

should actually be:
Code

$delete = mysqli_query($db,"DELETE FROM `repcps` WHERE `id` = '$id';"); //delete the report
Posted on Saturday 12th September 2015 at 05:23 PM
deathwish
deathwish
Code

$delete = mysqli_query($db,"DELETE FROM `warns` WHERE `id` = '$id';"); //delete the report

should actually be:
Code

$delete = mysqli_query($db,"DELETE FROM `repcps` WHERE `id` = '$id';"); //delete the report
Posted on Friday 1st August 2008 at 09:34 AM
jambomb
jambomb
hmm
Posted on Tuesday 15th July 2008 at 07:05 PM
UrbanTwitch
UrbanTwitch
Error

You Are Not Logged In!

I am logged in actually...
Posted on Tuesday 15th July 2008 at 07:04 PM
UrbanTwitch
UrbanTwitch
Parse error: syntax error, unexpected ')' in /home/jsfdan/public_html/repcp.php on line 88

:
Posted on Thursday 26th June 2008 at 02:16 AM
ShadowMage
ShadowMage
nevermind. I can't access the ACP. :P
Posted on Thursday 26th June 2008 at 02:15 AM
ShadowMage
ShadowMage
erm... i messed up. i'll update my code.
Posted on Wednesday 25th June 2008 at 09:04 PM
dtnet
dtnet
My doesn't add reported by. It's adding all of the other fields, but not that one.
Posted on Wednesday 16th April 2008 at 02:47 PM
Nathan
Nathan
doesnt send the reports