phMapDB is a script mainly used for gaming resource sites. If the game allows players to make maps, this is a good way to display maps on your site. No more adding maps the old fashion way, the one of a kind script is here :). I has lots of features for a script that’s just starting out, including map uploading, multiple administrators with permissions, unlimited games and game types. It also features my work in progress template system, so if you want to change the look and don’t know some PHP it’s easy to edit the layout with some simple html knowledge.
/*
//================================================================================
* phphq.Net Custom PHP Scripts *
//================================================================================
:- Script Name: phMapDB
:- Version: 1.0b (Beta)
:- Release Date: Oct. 23 2004.
:- Author: Scott L. aka. Panther <scott@phphq.net> http://www.phphq.net
:- Copyright (c) 2004 All Rights Reserved
:-
:- This script is freeware. Permission is granted to copy and distribute this
:- program so long as it is not modified in any way and no fees are exchanged.
:- All copyright text must remain visible and unmodified.
//================================================================================
*/
require_once("./conf.php");
If($glbl[set_allow_rate]) {
If($_POST['dorate']) {
$mapid=intval($_POST['mid']);
$score=intval($_POST['rate']);
If(($mapid) AND ($score) AND ($score<=5)) {
If(!$ph->getrows("SELECT * FROM phmapdb_maps WHERE mid='$mapid' AND mlstrip='".$_SERVER['REMOTE_ADDR']."' LIMIT 1") AND (!$_COOKIE['r$mapid'])) {
$ph->query("UPDATE phmapdb_maps SET mlstrip='".$_SERVER['REMOTE_ADDR']."', mrates=mrates+$score, mvotes=mvotes+1 WHERE mid='$mapid' LIMIT 1");
setcookie("r$mapid",True,time()+87925445);
}
}
header("Location: ".self(true,true));
exit;
}
}
eval("output(\"".get_template("header.html")."\");");
eval("output(\"".get_template("main_table_start.html")."\");");
$self=self(true);
eval("output(\"".get_template("main_header.html")."\");");
//######################################VIEW/SEARCH MAPS#############################
If(($glbl[view]=="maps") OR ($glbl[view]=="search")) {
$max=intval($_GET['max']);
$order=$_GET['order'];
$acdc=$_GET['acdc'];
$game=intval($_GET['game']);
$type=intval($_GET['type']);
$search=$_GET['search'];
$pages="";
If(empty($game)) {
disp_msg("No game selected, please go back and select a game!",true);
}
$query=$ph->query("SELECT tid,tname FROM phmapdb_types WHERE tgames LIKE '%|$game%|'");
while($result=$ph->fetch($query)) {
$type_temp[$result[tid]]=$result[tname];
}
$ph->free($query);
$query=$ph->query("SELECT id,gname FROM phmapdb_games");
while($result=$ph->fetch($query)) {
$game_temp[$result[id]]=$result[gname];
}
$ph->free($query);
If(empty($type)) {
$type="0";
}
If(empty($max)) {
$max=10;
} Elseif($max<5) {
$limit=5;
} Elseif($max > 20) {
$limit=20;
} Else {
$max=$max;
}
$valid=array("mauthor","mhits","mrating","mid");
If((!in_array($order,$valid)) OR empty($order)) {
$order="mid";
}
$valid=array("ASC","DESC");
If((!in_array($acdc,$valid)) OR (empty($acdc))) {
$acdc="ASC";
}
If($glbl[view]=="search") {
$string=$_GET['string'];
$extra_query=" AND mtypes LIKE '|%$type%|' ";
If($search=="auth") { //Searching the author
$total_maps=$ph->getrows("SELECT mid FROM phmapdb_maps WHERE mapprove='1' AND mgame='$game' AND mauthor LIKE '%$string%' $extra_query");
$pages=split_pages(self(true,true),$total_maps,$max);
$query=$ph->query("SELECT * FROM phmapdb_maps WHERE mapprove='1' AND mgame='$game' AND mauthor LIKE '%$string%' $extra_query ORDER BY $order $acdc LIMIT $glbl[start],$max");
} Elseif($search=="des") { //Searching the description
$total_maps=$ph->getrows("SELECT mid FROM phmapdb_maps WHERE mapprove='1' AND mgame='$game' AND mdesc LIKE '%$string%' $extra_query");
$pages=split_pages(self(true,true),$total_maps,$max);
$query=$ph->query("SELECT * FROM phmapdb_maps WHERE mapprove='1' AND mgame='$game' AND mdesc LIKE '%$string%' $extra_query ORDER BY $order $acdc LIMIT $glbl[start],$max");
} Elseif($search=="name") { //Searching the map name
$total_maps=$ph->getrows("SELECT mid FROM phmapdb_maps WHERE mapprove='1' AND mgame='$game' AND mname LIKE '%$string%' $extra_query");
$pages=split_pages(self(true,true),$total_maps,$max);
$query=$ph->query("SELECT * FROM phmapdb_maps WHERE mapprove='1' AND mgame='$game' AND mname LIKE '%$string%' $extra_query ORDER BY $order $acdc LIMIT $glbl[start],$max");
} Else { //Not in anything specific
$total_maps=$ph->getrows("SELECT mid FROM phmapdb_maps WHERE mapprove='1' AND mgame='$game' AND (mauthor LIKE '%$string%' OR mname LIKE '%$string%' OR mdesc LIKE '%$string%') $extra_query");
$pages=split_pages(self(true,true),$total_maps,$max);
$query=$ph->query("SELECT * FROM phmapdb_maps WHERE mapprove='1' AND mgame='$game' AND (mauthor LIKE '%$string%' OR mname LIKE '%$string%' OR mdesc LIKE '%$string%') $extra_query ORDER BY $order $acdc LIMIT $glbl[start],$max");
}
} Else {
$total_maps=$ph->getrows("SELECT mid FROM phmapdb_maps WHERE mapprove='1' AND mgame='$game' AND mtypes LIKE '%|$type|%'");
$pages=split_pages(self(true,true),$total_maps,$max);
$query=$ph->query("SELECT * FROM phmapdb_maps WHERE mapprove='1' AND mgame='$game' AND mtypes LIKE '%|$type|%' ORDER BY $order $acdc LIMIT $glbl[start],$max");
}
$query_search=$ph->query("SELECT * FROM phmapdb_types WHERE tgames LIKE '%|$game|%'");
$types="<option value=\"0\">All Maps</option>";
while($result=$ph->fetch($query_search)) {
$types.="<option value=\"".intval($result[tid])."\"";
If($type==$result[tid]) {
$types.=" selected";
}
$types.=">".html($result[tname])."</option>";
}
$ph->free($query_search);
$search_form="<option value=\"\"";If($search==""){$search_form.=" selected";}$search_form.=">Anything</option>";
$search_form.="<option value=\"auth\"";If($search=="auth"){$search_form.=" selected";}$search_form.=">Author</option>";
$search_form.="<option value=\"des\"";If($search=="des"){$search_form.=" selected";}$search_form.=">Description</option>";
$search_form.="<option value=\"name\"";If($search=="name"){$search_form.=" selected";}$search_form.=">Map Name</option>";
eval("output(\"".get_template("search_form.html")."\");");
$order_form_search="<option value=\"mauthor\"";If($order=="mauthor"){$order_form_search.=" selected";}$order_form_search.=">Author</option>";
$order_form_search.="<option value=\"mhits\"";If($order=="mhits"){$order_form_search.=" selected";}$order_form_search.=">Hits</option>";
$order_form_search.="<option value=\"mrating\"";If($order=="mrating"){$order_form_search.=" selected";}$order_form_search.=">Rating</option>";
$order_form_search.="<option value=\"mid\"";If($order=="mid"){$order_form_search.=" selected";}$order_form_search.=">Date</option>";
$order_form_acdc="<option value=\"ASC\"";If($acdc=="ASC"){$order_form_acdc.=" selected";}$order_form_acdc.=">Ascending</option>";
$order_form_acdc.="<option value=\"DESC\"";If($acdc=="DESC"){$order_form_acdc.=" selected";}$order_form_acdc.=">Descending</option>";
eval("output(\"".get_template("maps_order_form.html")."\");");
$extra="";
If($glbl[view]=="search") {
If(empty($total_maps)) {
$extra="Please try again!";
}
If(trim($string)=="") {
$string="Nothing";
}
eval("output(\"".get_template("search_num_results.html")."\");");
} Else {
If(empty($total_maps)) {
$extra="Please try another type!";
}
eval("output(\"".get_template("maps_num_results.html")."\");");
}
If(!empty($total_maps)) {
If($pages) {
eval("output(\"".get_template("maps_pages.html")."\");");
}
while($result=$ph->fetch($query)) {
display_maps($result,"maps_bit");
}
$ph->free($query);
}
//######################################SELECT GAME TYPE#############################
} Else {
eval("output(\"".get_template("games_select_start.html")."\");");
$query=$ph->query("SELECT * FROM phmapdb_games");
while($result=$ph->fetch($query)) {
$gamename=html($result[gname]);
eval("output(\"".get_template("games_bit_start.html")."\");");
$query2=$ph->query("SELECT * FROM phmapdb_types WHERE tgames LIKE '|%".intval($result[id])."%|'");
while($result2=$ph->fetch($query2)) {
@extract($result2);
$url=self(true);
$id=intval($result[id]);
$tid=intval($tid);
$typename=html($tname);
eval("output(\"".get_template("types_bit.html")."\");");
}
$ph->free($query2);
eval("output(\"".get_template("games_bit_end.html")."\");");
}
$ph->free($query);
eval("output(\"".get_template("games_select_end.html")."\");");
}
eval("output(\"".get_template("main_table_end.html")."\");");
eval("output(\"".get_template("footer.html")."\");");
$ph->disconnect();
?>