Skip to content

Commit

Permalink
Importing changes towards PHPrbl version 0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
sgaduuw committed Sep 3, 2010
1 parent 408aa93 commit 05d6fa6
Show file tree
Hide file tree
Showing 6 changed files with 278 additions and 0 deletions.
50 changes: 50 additions & 0 deletions install-0.4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
--
-- Table structure for table `blocked`
--

CREATE TABLE `blocked` (
`id` int(8) NOT NULL auto_increment,
`ip` varchar(15) NOT NULL default '',
`visits` int(8) NOT NULL default '0',
`lastseen` varchar(11) NOT NULL default '',
`service` varchar(255) NOT NULL default '',
`referer` varchar(255) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ip` (`ip`)
) TYPE=MyISAM;

--
-- Dumping data for table `blocked`
--


-- --------------------------------------------------------

--
-- Table structure for table `keywords`
--

CREATE TABLE `keywords` (
`id` int(8) NOT NULL auto_increment,
`keyword` varchar(255) NOT NULL default '',
`occurances` int(8) NOT NULL default '0',
`added` varchar(11) NOT NULL default '',
KEY `id` (`id`,`keyword`)
) TYPE=MyISAM;

--
-- Dumping data for table `keywords`
--

INSERT INTO `keywords` VALUES (1, 'viagra', 0, '1130320374');
INSERT INTO `keywords` VALUES (2, 'phentermine', 0, '1130320371');
INSERT INTO `keywords` VALUES (3, 'cialis', 0, '1130320381');
INSERT INTO `keywords` VALUES (4, 'adipex', 0, '1130320387');
INSERT INTO `keywords` VALUES (5, 'hydrocodone', 0, '1130320395');
INSERT INTO `keywords` VALUES (6, 'xanax', 0, '1130320400');
INSERT INTO `keywords` VALUES (7, 'vicodin', 0, '1130320405');
INSERT INTO `keywords` VALUES (8, 'fioricet', 0, '1130320412');
INSERT INTO `keywords` VALUES (9, 'valium', 0, '1130320418');
INSERT INTO `keywords` VALUES (10, 'poker', 0, '1130320424');
INSERT INTO `keywords` VALUES (11, 'holdem', 0, '1130320440');

17 changes: 17 additions & 0 deletions phprbladmin/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

# remove the following line
exit("Hehe, you haven't read the README :P");

# Set $enable_admin_area to 1 to enable the PHPrbl Admin Area
# MySQL is required for this feature
$enable_admin_area = 0;
$admin_user = "PHPRBLADMINUSER"; # username for admin area
$admin_pass = "PHPRBLADMINPASS"; # password for admin area

$mysql_host = "MYSQLHOST"; # mysql host (usually localhost)
$mysql_user = "MYSQLUSER"; # mysql username
$mysql_pass = "MYSQLPASS"; # mysql password
$mysql_data = "MYSQLDATA"; # mysql database

?>
45 changes: 45 additions & 0 deletions phprbladmin/delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

#
# PHPrbl: PHP realtime black listing
# Released under GNU GPL License version 2, see LICENSE for more info
#
# (c) Eelco Wesemann ([email protected])
# http://phprbl.init1.nl || http://eol.init1.nl
# (Version 0.4, Oct 26 2005)


require("config.php");

while (!isset($_SERVER["PHP_AUTH_USER"])) {
header("WWW-Authenticate: Basic realm=\"PHPrbl Admin Area\"");
header("HTTP/1.0 401 Unauthorized");
echo "<h1>401 Unauthorized</h1><br />";
echo "Try a little harder";
exit();
}
if ($_SERVER["PHP_AUTH_USER"] == $admin_user && $_SERVER["PHP_AUTH_PW"] == $admin_pass && $enable_admin_area == 1) {
if ($_POST) {
$keyword_id = $_POST['keyword_id'];
} elseif ($_GET) {
$keyword_id = $_GET['keyword_id'];
} else {
echo "Whatchoo doing?\n";
exit("<div align=\"center\"><a href=\"index.php\">back to index</a></div>");
}

$mysql_link = mysql_connect("$mysql_host", "$mysql_user", "$mysql_pass") or die("Unable to connect to database");
mysql_select_db($mysql_data, $mysql_link) or die ("Unable to select database");

$mysql_query = mysql_query("SELECT id,keyword FROM keywords WHERE id='$keyword_id' LIMIT 1");
while ($row = mysql_fetch_object($mysql_query)) {
echo "Deleting keyword: <b>". $row->keyword ."</b>\n";
mysql_query("DELETE FROM keywords WHERE id='$keyword_id'");
echo "<div align=\"center\"><a href=\"index.php\">back to index</a></div>\n";
}


} else {
exit("Bad credentials, or Admin Area not enabled.");
}
?>
69 changes: 69 additions & 0 deletions phprbladmin/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php
#
# PHPrbl: PHP realtime black listing
# Released under GNU GPL License version 2, see LICENSE for more info
#
# (c) Eelco Wesemann ([email protected])
# http://phprbl.init1.nl || http://eol.init1.nl
# (Version 0.4, Oct 26 2005)


require("config.php");

if ($admin_user == "PHPRBLADMINUSER" || $admin_pass == "PHPRBLADMINPASS") {
exit("Please, please don't use the default username and password.");
}

while (!isset($_SERVER["PHP_AUTH_USER"])) {
header("WWW-Authenticate: Basic realm=\"PHPrbl Admin Area\"");
header("HTTP/1.0 401 Unauthorized");
echo "<h1>401 Unauthorized</h1><br />";
echo "Try a little harder";
exit();
}
if ($_SERVER["PHP_AUTH_USER"] == $admin_user && $_SERVER["PHP_AUTH_PW"] == $admin_pass && $enable_admin_area == 1) {

$mysql_link = mysql_connect("$mysql_host", "$mysql_user", "$mysql_pass") or die("Unable to connect to database");
mysql_select_db($mysql_data, $mysql_link) or die ("Unable to select database");

?>
<html>
<head>
<title>PHPrbl Admin Area</title>
</head>
<body>
<h3>Welcome to PHPrbl's Admin Area</h3><br />
Bad keywords:
<table border="1" width="700">
<tr>
<td align="center" width="50">hits</td>
<td align="center">keyword</td>
<td align="center" width="50">del</td>
</tr>
<?php
$mysql_query = mysql_query("SELECT id,keyword,occurances FROM keywords ORDER BY occurances DESC");
while ($row = mysql_fetch_object($mysql_query)) {
echo " <tr>\n";
echo " <td align=\"center\">". $row->occurances ."</td>\n";
echo " <td align=\"left\">". $row->keyword ."</td>\n";
echo " <td align=\"center\"><a href=\"delete.php?keyword_id=". $row->id ."\">del</a></td>\n";
echo " </tr>\n";
}

?>
</table>
<form name="blockkeyword" action="setkeyword.php" method="post">
Block keyword: <input type="text" name="keyword"> <input type="submit" value="Block!">
</form>
</body>
</html>
<?php

mysql_close($mysql_link);

} else {
exit("Bad credentials, or Admin Area not enabled.");
}
?>


63 changes: 63 additions & 0 deletions phprbladmin/setkeyword.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

#
# PHPrbl: PHP realtime black listing
# Released under GNU GPL License version 2, see LICENSE for more info
#
# (c) Eelco Wesemann ([email protected])
# http://phprbl.init1.nl || http://eol.init1.nl
# (Version 0.4, Oct 26 2005)



require("config.php");

while (!isset($_SERVER["PHP_AUTH_USER"])) {
header("WWW-Authenticate: Basic realm=\"PHPrbl Admin Area\"");
header("HTTP/1.0 401 Unauthorized");
echo "<h1>401 Unauthorized</h1><br />";
echo "Try a little harder";
exit();
}
if ($_SERVER["PHP_AUTH_USER"] == $admin_user && $_SERVER["PHP_AUTH_PW"] == $admin_pass && $enable_admin_area == 1) {
if ($_POST) {
$keyword = $_POST['keyword'];
} elseif ($_GET) {
$keyword = $_GET['keyword'];
} else {
echo "Whatchoo doing?\n";
exit("<div align=\"center\"><a href=\"index.php\">back to index</a></div>");
}

$errors = 0;
if (strlen($keyword) == 0) {
echo "Please enter a keyword<br />\n";
$errors++;
}

if ($errors > 0) {
echo "You did something wrong!<br />\n";
exit("<div align=\"center\"><a href=\"index.php\">back to index</a></div>");
}

$datestring = time();

$mysql_link = mysql_connect("$mysql_host", "$mysql_user", "$mysql_pass") or die("Unable to connect to database");
mysql_select_db($mysql_data, $mysql_link) or die ("Unable to select database");

$query_keyword = mysql_query("SELECT count(keyword) AS countname FROM keywords WHERE keyword='$keyword'", $mysql_link);
while($row = mysql_fetch_object($query_keyword))
{
$countname = $row->countname;
}
if ($countname > 0) {
echo "We already have the word \"<b>$keyword</b>\" listed!<br />\n";
exit("<div align=\"center\"><a href=\"index.php\">back to index</a></div>");
} else {
header("Location: index.php");
mysql_query("INSERT INTO keywords (keyword,added) VALUES ('$keyword', '$datestring')");
}
} else {
exit("Bad credentials, or Admin Area not enabled.");
}
?>
34 changes: 34 additions & 0 deletions upgrade-0.3.1_to0.4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--
-- fixes table structure to not use reserved table names
--
ALTER TABLE `blocked` CHANGE `count` `visits` INT( 8 ) NOT NULL DEFAULT '0';


--
-- Table structure for table `keywords`
--

CREATE TABLE `keywords` (
`id` int(8) NOT NULL auto_increment,
`keyword` varchar(255) NOT NULL default '',
`occurances` int(8) NOT NULL default '0',
`added` varchar(11) NOT NULL default '',
KEY `id` (`id`,`keyword`)
) TYPE=MyISAM;

--
-- Dumping data for table `keywords`
--

INSERT INTO `keywords` VALUES (1, 'viagra', 0, '1130320374');
INSERT INTO `keywords` VALUES (2, 'phentermine', 0, '1130320371');
INSERT INTO `keywords` VALUES (3, 'cialis', 0, '1130320381');
INSERT INTO `keywords` VALUES (4, 'adipex', 0, '1130320387');
INSERT INTO `keywords` VALUES (5, 'hydrocodone', 0, '1130320395');
INSERT INTO `keywords` VALUES (6, 'xanax', 0, '1130320400');
INSERT INTO `keywords` VALUES (7, 'vicodin', 0, '1130320405');
INSERT INTO `keywords` VALUES (8, 'fioricet', 0, '1130320412');
INSERT INTO `keywords` VALUES (9, 'valium', 0, '1130320418');
INSERT INTO `keywords` VALUES (10, 'poker', 0, '1130320424');
INSERT INTO `keywords` VALUES (11, 'holdem', 0, '1130320440');

0 comments on commit 05d6fa6

Please sign in to comment.