Reverted to PHP

master
Rubenwardy 2012-09-07 18:20:39 +01:00
parent 42d6bed3e8
commit 580bf807d4
32 changed files with 846 additions and 118 deletions

101
README.md
View File

@ -1,101 +0,0 @@
Rubenwardy's Mod Forum
======================
A ruby on rails and mysgl forum for mods.
Was previously php, but that moved to branches/php-version as ruby on rails is so much easier to use
Also a mod database for Jeijas Ingame Mod Manager
and Sfan's Python Mod Manager
License
=======
Copyright (c) 2012, Andrew "Rubenwardy" Ward
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions that are hosted on the website must retain the above copyright notice, this
list of conditions and the following disclaimer, and also the notice at the bottom of each page.
3. This source code/software modified/unmodified must not be used for commercial use .
4. The copyright owner has the right to change these conditions at anytime with/without notice.
5. The copyright owner can issue an exception to these conditions by giving specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
To Do
=====
(Changes suggested by VannesaE - http://multa.bugs3.com/minetest/chat_with_VenessaE.txt)
* (done) list of mods, show license
* (done) More mods in demo
* (done)BBCode
* (work in progress) Keep up-to-date
* (done) user creation
* Search mod names and descriptions
* wrap desc text
* (almost done) edit posts
Database
========
The database structure.
USERS:
* id (int)
* name
* email
* password
* level (int)
* stars
* avatar
* location
* sig
MOD:
* mod_id (int)
* name
* version
* owner
* description
* likes (int)
* dislikes (int)
* tags
* license
* file
* depend
* basename (the mod name, eg: "moreblocks")
* date_released (date)
* quality_total (int)
* quality_voters (int)
* usefullness_total (int)
* cpu_total (int)
* cpu_voters (int)
POSTS:
* post_id (int)
* Owner
* Post
* Topic (int)
* Like (int)
* Dislike (int)

78
addentry.php Normal file
View File

@ -0,0 +1,78 @@
<?php
include "scripts/setup.php";
$page_title="Add a Mod";
include "scripts/pageheader.php";
require_login();
if ((include('scripts/addentry.php'))==1){
echo "Entry already exists.<br /><br />";
}
?>
Help: <a href="help/markup.php" target="_blank">Description Markup</a> - <a href="help/tags.php" target="_blank">Tags</a>. Not creating? Make sure you fill in all *ed sections.
<hr />
<form method="post" action="<?php echo curPageURL();?>">
<?php
if (is_member_moderator($_SESSION['user'])==true){
echo "<p>Owner is: <input type=\"text\" name=\"user\" value=\"{$_SESSION['user']}\"></p>";
}
?>
<table width="100%">
<!--Tags, License, File, Depend, Basename-->
<!--Mod Name and Version-->
<tr>
<td width="60%">Mod Name:* <input type="text" size="50" name="mod_name" value="<?php echo $name;?>"></td>
<td width="40%">Version:* <input type="text" size="30" name="mod_version" value="<?php echo $version;?>"></td>
</tr>
<!--Description-->
<tr>
<td colspan="2">
<p>*<Br /><textarea name="mod_desc" cols="105" rows="15">
<?php echo $desc;?>
</textarea></p>
</td>
</tr>
<!--License and File-->
<tr>
<td>File URL*: <input type="text" size="50" name="mod_file" value="<?php echo $file;?>"></td>
<td>License: <input type="text" size="30" name="mod_lic" value="<?php echo $license;?>"></td>
</tr>
<!--Depends and Basename-->
<tr>
<td>Depends (seperated by "," - no space): <input type="text" size="30" name="mod_dep" value="<?php echo $depend;?>"></td>
<td>Mod Namespace: <input type="text" size="30" name="mod_base" value="<?php echo $basename;?>"></td>
</tr>
<!--Tags-->
<tr><td colspan="2"><br /><br /><center><b>Tags</b> Users use tags to search and find mods</center></td></tr>
<tr>
<td>*
<input type="radio" name="mod_tag_type" value="mod"> Mod
<input type="radio" name="mod_tag_type" value="mdpack"> Mod Pack
<input type="radio" name="mod_tag_type" value="texture"> Texture Pack
</td>
<td>
Other Tags: <input type="text" size=30 name="mod_tag_msc" value="<?php echo $tags_msc;?>">
</td>
</tr>
<tr>
<td colspan=2>
<br /><br /><center>
<input type="submit" value="Add Mod" />
</center>
</td>
</tr>
</table>
</form>
<?php
include "scripts/pagefooter.php";
?>

25
api/python/getmodbyid.php Normal file
View File

@ -0,0 +1,25 @@
<?php
include "../../scripts/setup.php";
$id=$_GET['id'];
header("Content-type: text/plain");
if (is_numeric($id)==false){
//SQLerror("error: Non Numeric Value","?id=$id is not allowed");
die("Name:\nDepends:\nFile:\nVersion:\n");
}
$res = mysql_query("SELECT * FROM mods WHERE mod_id=$id",$handle) or SQLerror("MySQL Query Error","Error on searching database.mods.mod_id for '$id'");
$row = mysql_fetch_row($res) or die("Name:\nDepends:\nFile:\nVersion:\n");
echo "Name:{$row[1]}\n";
echo "Depends:{$row[10]}\n";
echo "File:{$row[9]}\n";
echo "Version:{$row[2]}\n";
die("");
?>

View File

@ -0,0 +1,18 @@
<?php
include "../../scripts/setup.php";
$id=$_GET['id'];
$id= mysql_real_escape_string ($id);
$res = mysql_query("SELECT * FROM mods WHERE name='$id'",$handle) or SQLerror("MySQL Query Error","Error on searching database.mods.mod_id for '$id'");
header("Content-type: text/plain");
$row = mysql_fetch_row($res) or die("Name:\nDepends:\nFile:\nVersion:\n");
echo "Name:{$row[1]}\n";
echo "Depends:{$row[10]}\n";
echo "File:{$row[9]}\n";
echo "Version:{$row[2]}\n";
die("");
?>

15
api/python/getmods.php Normal file
View File

@ -0,0 +1,15 @@
<?php
include "../../scripts/setup.php";
$id="mod";
$res = mysql_query("SELECT * FROM mods WHERE tags LIKE '%$id%' ORDER BY likes",$handle) or SQLerror("MySQL Query Error","Error on searching database.mods.tags for '$query'");
header("Content-type: text/plain");
// Get projects loop
while ($hash = mysql_fetch_assoc($res)){
echo "{$hash['name']}\n";
}
die("");
?>

137
editentry.php Normal file
View File

@ -0,0 +1,137 @@
<?php
include "scripts/setup.php";
$page_title="Edit a Mod";
require_login();
$id=$_GET['id'];
if (is_numeric($id)==false){
SQLerror("Non Integer","Non integers are not allowed in the id field. <br /> <a href=\"index.php\">Back to home</a>");
}
include "scripts/pageheader.php";
$res = mysql_query("SELECT * FROM mods WHERE mod_id=$id",$handle) or SQLerror("MySQL Query Error","Error on searching database.mods.mod_id for '$id'");
$row = mysql_fetch_row($res) or die("row error");
if (is_member_moderator($_SESSION['user']) || $_SESSION['user']==$row[3]){
}else{
SQLerror("Editing Denied","You do not own that entry, and you are not a moderator");
}
// --------------------------
// Load Variables
// --------------------------
$do=true;
$name=$_POST['mod_name'];
if ($name==""){
$do=false;
$name=$row[1];
}
$version=$_POST['mod_version'];
if ($version=="")
$version=$row[2];
$owner=$row[3];
$desc=$_POST['mod_desc'];
if ($desc=="")
$desc=$row[4];
$tags=$_POST['mod_tag'];
if ($tags=="")
$tags = $row[7];
$license=$_POST['mod_lic'];
if ($license=="")
$license=$row[8];
$file=$_POST['mod_file'];
if ($file=="")
$file=$row[9];
$depend=$_POST['mod_dep'];
if ($depend=="")
$depend=$row[10];
$basename=$_POST['mod_base'];
if ($basename=="")
$basename=$row[11];
if ($do==true){
include "scripts/entry_adders_sql_safe.php"; mysql_query("UPDATE mods SET version='$version' WHERE name='$name'",$handle);
mysql_query("UPDATE mods SET description='$desc' WHERE name='$name'",$handle);
mysql_query("UPDATE mods SET tags='$tags' WHERE name='$name'",$handle);
mysql_query("UPDATE mods SET license='$license' WHERE name='$name'",$handle);
mysql_query("UPDATE mods SET file='$file' WHERE name='$name'",$handle);
mysql_query("UPDATE mods SET depend='$depend' WHERE name='$name'",$handle);
mysql_query("UPDATE mods SET basename='$basename' WHERE name='$name'",$handle);
header("location: viewmod.php?id=$id");
}
// --------------------------
// End of loading variable
// --------------------------
?>
Help: <a href="help/markup.php" target="_blank">Description Markup</a> - <a href="help/tags.php" target="_blank">Tags</a>
<hr />
<form method="post" action="<?php echo curPageURL();?>">
<table width="100%">
<!--Tags, License, File, Depend, Basename-->
<!--Mod Name and Version-->
<tr>
<td width="60%">Mod Name: <input type="text" size="50" name="mod_name" value="<?php echo $name;?>"></td>
<td width="40%">Version: <input type="text" size="30" name="mod_version" value="<?php echo $version;?>"></td>
</tr>
<!--Description-->
<tr>
<td colspan="2">
<p><textarea name="mod_desc" cols="105" rows="15">
<?php echo $desc;?>
</textarea></p>
</td>
</tr>
<!--License and File-->
<tr>
<td>File URL: <input type="text" size="50" name="mod_file" value="<?php echo $file;?>"></td>
<td>License: <input type="text" size="30" name="mod_lic" value="<?php echo $license;?>"></td>
</tr>
<!--Depends and Basename-->
<tr>
<td>Depends (seperated by "," - no space): <input type="text" size="30" name="mod_dep" value="<?php echo $depend;?>"></td>
<td>Mod Namespace: <input type="text" size="30" name="mod_base" value="<?php echo $basename;?>"></td>
</tr>
<!--Tags-->
<tr><td colspan="2"><br /><br /><center><b>Tags</b> Users use tags to search and find mods</center></td></tr>
<tr>
<td colspan="2" width="100">
Tags: <input type="text" size=100 name="mod_tags" value="<?php echo $tags;?>">
</td>
</tr>
<tr>
<td colspan=2>
<br /><br /><center>
<input type="submit" value="Save Mod" />
</center>
</td>
</tr>
</table>
</form>
<?php
include "scripts/pagefooter.php";
?>

23
help/markup.php Normal file
View File

@ -0,0 +1,23 @@
<?php
include "../scripts/setup.php";
$page_title="Mark Up - Help";
include "../scripts/pageheader.php";
?>
<p><table>
<tr><th width=30%>Code</th><th>Description</th><th>Example</th></tr>
<tr bgcolor="#FFFFBD"><td>[b]bold[/b]</td><td>Bold</td><td><b>bold</b></td></tr>
<tr><td>[i]italic[/i]</td><td>Italic</td><td><i>italic</i></td></tr>
<tr bgcolor="#FFFFBD"><td>[u]underline[/u]</td><td>Under Lined</td><td><u>underline</u></td></tr>
<tr><td>[h]header[/h]</td><td>Header (title)</td><td><h1>header</h1></td></tr>
<tr bgcolor="#FFFFBD"><td>[tag]</td><td>Header (title)</td><td><h1>header</h1></td></tr>
<tr><td>[code]The code[/code]</td><td>Adds a code box</td><td><code>The code</code></td></tr>
<tr bgcolor="#FFFFBD"><td>[img]url_for_img[/img]</td><td>Adds an image, If the width is smaller or equal to 900, use this one</td><td><img height="20" src="../images/header.png"></td></tr>
<tr><td>[img]url_for_img[/img-enforce]</td><td>Adds an image. If the width is bigger than 900, use this one</td><td><img height="20" src="../images/header.png"></td></tr>
<tr bgcolor="#FFFFBD"><td>[url=the_links_url=url]The Link Text[/url]</td><td>Adds an hyperlink</td><td><a href="the_links_url">The Links Text</a></td></tr>
<tr><td>[list]<br />[*]An Item[/*]<br />[*]Another Item[/*]<br />[/list]</td><td>A list</td><td><ul><li>An Item</li><li>Another Item</li></ul></td></tr>
</table>
<?php
include "../scripts/pagefooter.php";
?>

40
help/tags.php Normal file
View File

@ -0,0 +1,40 @@
<?php
include "../scripts/setup.php";
$page_title="Tags - Help";
include "../scripts/pageheader.php";
?>
<p><table>
<tr><th width=30%>Tag</th><th>Description</th></tr>
<tr bgcolor="#FFFFBD"><td>mod</td><td>A Mod (use "type" radio buttons</td></tr>
<tr><td>mpack</td><td>A Mod Pack (use "type" radio button)</td></tr>
<tr bgcolor="#FFFFBD"><td>texture</td><td>A Texture Pack (use "type" radio button)</td></tr>
<tr><td>sound</td><td>Adds Sounds to the game</td></tr>
<tr bgcolor="#FFFFBD"><td>deco</td><td>Adds basic decorating blocks to the game</td></tr>
<tr><td>fun</td><td>fun mods for the game (mesecons, chess, carts)</td></tr>
<tr bgcolor="#FFFFBD"><td>server</td><td>Mods ideal for servers</td></tr>
<tr><td>food</td><td>Mods that add Food</td></tr>
<tr bgcolor="#FFFFBD"><td>growing</td><td>Mods that add Plants and Growing</td></tr>
<tr><td>mobs</td><td>Mods that add Mobs</td></tr>
<tr bgcolor="#FFFFBD"><td>3d</td><td>Mods that use nodeboxes</td></tr>
<tr><td>envir</td><td>Changes the MapGen</td></tr>
<tr bgcolor="#FFFFBD"><td>biome</td><td>Adds a new biome to the game</td></tr>
<tr><td>comic-txt</td><td>Comic/Cartoon style textures</td></tr>
<tr bgcolor="#FFFFBD"><td>real-txt</td><td>Realistic style textures</td></tr>
<tr><td>hd-txt</td><td>d</td></tr>
<tr bgcolor="#FFFFBD"><td>0.4.2</td><td>for 0.4.2-rc1 *</td></tr>
<tr><td>0.4.1</td><td>for 0.4.1 *</td></tr>
<tr bgcolor="#FFFFBD"><td>0.4</td><td>for 0.4 *</td></tr>
</table></p>
And make up your own for search box searching.
<br />
* Which versions your mod/texture pack works on. You may add more than one of these tags
<?php
include "scripts/pagefooter.php";
?>

BIN
images/header.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
images/topicicon_read.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

View File

60
index.php Normal file
View File

@ -0,0 +1,60 @@
<?php
include "scripts/setup.php";
function listSearch($query,$title,$description,$handle){
echo "<tr><td width=16><img width=16 height=16 src=\"images/topicicon_read.jpg\" /></td><td><a href=\"search.php?id=$query\">$title</a></td><td>$description</td>";
$num=getNoTopics($query,$handle);
echo "<td>$num<td></tr>";
}
function seperator($cols){
echo "<tr bgcolor=#00000 height=2><td colspan=$cols></td></tr>";
}
$page_title="Home";
include "scripts/pageheader.php";
if (is_logged_in())
echo "<a href=\"addentry.php\">Add a Mod</a><br /><br />";
echo "<table width=\"100%\"><tr><th colspan=2>Category</th><th>Description</th><th>Mods</th></tr>";
//List Categories
listSearch("","All","All Items",$handle);
listSearch("mod","All Mods","All Mods",$handle);
listSearch("mpack","All Mod Packs","All Mod Packs",$handle);
listSearch("texture","All Texture Packs","All Texture Packs",$handle);
listSearch("sound","All Sound Packs","All Sound Packs and Sound Mods",$handle);
seperator(4);
listSearch("deco","Block Adder Mods","Adds basic decorating blocks to the game (eg: moreblocks, homedecor)",$handle);
listSearch("fun","Fun Mods","Fun mods for the game (eg: Chess, Mesecons)",$handle);
listSearch("server","Server Interaction Mods","Mods ideal for servers (eg: antigrief, money)",$handle);
listSearch("food","Food Mods","Mods that add food",$handle);
listSearch("growing","Growing Mods","Mods that add Plants",$handle);
listSearch("mobs","Mob Mods","Mods that add Mobs",$handle);
listSearch("3d","3D Object Mods","Mods that use NodeBoxes",$handle);
seperator(4);
listSearch("envir","Enviroment Mods","Changes the map generator",$handle);
listSearch("biome","Biome Mods","Adds a new biome to the game",$handle);
seperator(4);
listSearch("comic-txt","Comic Style Textures","Cartoon Style Texture Packs",$handle);
listSearch("real-txt","Realistic Textures","Realistic Styled Texture Packs",$handle);
listSearch("hd-txt","HD Textures","HD Texture packs",$handle);
seperator(4);
listSearch("0.4.2","0.4.2","for 0.4.2-rc1",$handle);
listSearch("0.4.1","0.4.1","for 0.4 Stable",$handle);
listSearch("0.4","0.4","for 0.4",$handle);
echo "</table>";
//listSearch("0.3","0.3","for 0.3",0);
//listSearch("old_minetest","Older","for older versions of minetest",0);
include "scripts/pagefooter.php";
?>

38
login.php Normal file
View File

@ -0,0 +1,38 @@
<?php
include "scripts/setup.php";
$user=$_POST['user'];
$pass=$_POST['pass'];
$redir=$_GET['redir'];
$message="";
if (authcheck($user,$pass,$handle)==true){
login($user);
if ($redir==""){
header("location: index.php");
}else{
header("location: $redir");
}
}else{
$message="Incorrect username/password";
}
if ($user=="" || $pass==""){
$message="Enter your login details or <a href=\"signup.php\">Sign Up</a>";
}
$page_title="Log In - Minetest Mods";
include "scripts/pageheader.php";
echo "<p>$message</p>";
?>
<form action="<?php echo curPageURL();?>" method="post">
Username: <input type="text" name="user"><br />
Password: <input type="password" name="pass"><br />
<input type="submit" value="Log In">
</form>
<?php
include "scripts/pagefooter.php";
?>

7
logout.php Normal file
View File

@ -0,0 +1,7 @@
<?php
session_start();
session_destroy();
header("location: index.php");
?>

1
mm/getmodbyid.php Normal file
View File

@ -0,0 +1 @@
This has moved to <a href="../api/python/getmodbyid.php">here</a>

1
mm/getmodbyname.php Normal file
View File

@ -0,0 +1 @@
This has moved to <a href="../api/python/getmodbyname.php">here</a>

1
mm/getmods.php Normal file
View File

@ -0,0 +1 @@
This has moved to <a href="../api/python/getmods.php">here</a>

53
scripts/addentry.php Normal file
View File

@ -0,0 +1,53 @@
<?php
// Load Posted Values
$name=$_POST['mod_name'];
if ($name=="")
return 0;
$version=$_POST['mod_version'];
if ($version=="")
return 0;
$desc=$_POST['mod_desc'];
if ($desc=="")
return 0;
//Tag
$tags_type=$_POST['mod_tag_type'];
if ($tags_type=="")
return 0;
$tags_msc=$_POST['mod_tag_msc'];
if ($tags_msc=="")
return 0;
$license=$_POST['mod_lic'];
$file=$_POST['mod_file'];
if ($file=="")
return 0;
$depend=$_POST['mod_dep'];
$basename=$_POST['mod_base'];
$owner=$_POST['user'];
if ($owner=="")
$owner=$_SESSION['user'];
//Load on_submit values
$date = date("F j, Y, g:i a");
$tags = "$tags_type,$tags_msc,";
if (entry_exists($name,$handle))
return 1;
mysql_query("INSERT INTO mods (name,version,owner,description,tags,likes,dislikes,license,file,depend,basename,date_released)
VALUES ('$name','$version','$owner','$desc','$tags',0,0,'$license','$file','$depend','$basename','$date')");
$the_id=mysql_insert_id($handle);
header("location: viewmod.php?id=$the_id");
?>

View File

@ -1,7 +0,0 @@
class Mod < ActiveRecord::Base
belongs_to :user
end
class User < ActiveRecord::Base
has_many :mods
end

View File

@ -0,0 +1,11 @@
<?php
$name=mysql_real_escape_string($name);
$version=mysql_real_escape_string($version);
$owner=mysql_real_escape_string($owner);
$desc=mysql_real_escape_string($desc);
$tags=mysql_real_escape_string($tags);
$license=mysql_real_escape_string($license);
$file=mysql_real_escape_string($file);
$depend=mysql_real_escape_string($depend);
$basename=mysql_real_escape_string($basename);
?>

40
scripts/formatcode.php Normal file
View File

@ -0,0 +1,40 @@
<?php
function formatbb($input){
$result=$input;
$result=str_replace("[img]","<img src=\"",$result);
$result=str_replace("[/img]","\" />",$result);
$result=str_replace("[/img-enforce]","\" width=\"900\"/>",$result);
$result=str_replace("[url=","<a href=\"",$result);
$result=str_replace("=url]","\">",$result);
$result=str_replace("[/url]","</a>",$result);
$result=str_replace("\n","<br />",$result);
$result=str_replace("\t","&#9;",$result);
$result=str_replace("[tab]","&#9;",$result);
$result=str_replace("[h]","<h1>",$result);
$result=str_replace("[/h]","</h1>",$result);
$result=str_replace("[b]","<b>",$result);
$result=str_replace("[/b]","</b>",$result);
$result=str_replace("[u]","<u>",$result);
$result=str_replace("[/u]","</u>",$result);
$result=str_replace("[i]","<i>",$result);
$result=str_replace("[/i]","</i>",$result);
$result=str_replace("[list]","<ul>",$result);
$result=str_replace("[/list]","</ul>",$result);
$result=str_replace("[*]","<li>",$result);
$result=str_replace("[/*]","</li>",$result);
$result=str_replace("[code]","<p><code>",$result);
$result=str_replace("[/code]","</code></p>",$result);
return $result;
}
?>

24
scripts/loadmods.php Normal file
View File

@ -0,0 +1,24 @@
<?php
echo "<table width=\"100%\"><tr><th colspan=2>Mod Name</th><th>Populatity</th><th>Tags</th><th>License</th></tr>\n";
$query= mysql_real_escape_string ($query);
$res = mysql_query("SELECT * FROM mods WHERE tags LIKE '%$query%' ORDER BY likes DESC",$handle) or SQLerror("MySQL Query Error","Error on searching database.mods.tags for '$query'");
$alternate=1;
// Get projects loop
while ($hash = mysql_fetch_assoc($res)){
if ($alternate==0){
$bgcolor="#FFFFFF";
}else{
$bgcolor="#FFFFBD";
}
echo "<tr bgcolor=\"$bgcolor\"><td width=16><img width=16 height=16 src=\"images/topicicon_read.jpg\" /></td><td><a href=\"viewmod.php?id={$hash['mod_id']}\">{$hash['name']}</a><br />by {$hash['owner']}</td>";
echo "<td>{$hash['likes']}</td>";
echo "<td>{$hash['tags']}</td>";
echo "<td>{$hash['license']}</td></tr>\n";
$alternate=1-$alternate;
}
echo "</table>";
?>

17
scripts/loadposts.php Normal file
View File

@ -0,0 +1,17 @@
<?php
echo "<table width=100%><tr><th width=100></th><th></th><th width=100></th></tr>";
if (is_numeric($id)==false){
SQLerror("Non Integer","Non integers are not allowed in the id field. <br /> <a href=\"index.php\">Back to home</a>");
}
$res = mysql_query("SELECT * FROM posts WHERE Topic=$id",$handle) or SQLerror("MySQL Query Error","Error on searching database.posts for '$id'");
// Get posts loop
while ($hash = mysql_fetch_assoc($res)){
echo "<tr><td>User: {$hash[1]}</td>";
echo "<td>{$hash[2]}</td><td></td></tr>";
}
echo "</table>";
?>

5
scripts/pagefooter.php Normal file
View File

@ -0,0 +1,5 @@
<p>
<img src="<?php echo $serverpath;?>/images/header.png" width="900" height="50" border="0" alt="" style="left:0px;">
</div>
</body>
</html>

View File

@ -4,13 +4,13 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<meta name="Generator" content="Serif WebPlus X5 (13.0.3.029)">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8">
<title>The Title - Minetest Mods</title>
<title><?php echo $page_title ?> - Minetest Mods</title>
<meta name="keywords" content="">
<meta name="author" content="Andrew Ward">
<meta name="copyright" content="Copyright &#xA9; to Andrew Ward">
<meta http-equiv="Content-Language" content="en-gb">
<meta name="robots" content="index,follow">
<link rel="stylesheet" type="text/css" href="style/mainstyle.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $serverpath;?>/mainstyle.css" />
<!--<link rel="icon" href="favicon.ico" type="image/x-icon">-->
</head>
@ -19,18 +19,24 @@
<div style="background-color:transparent;text-align:left;margin-left:auto;margin-right:auto;position:relative;width:900px;">
<!--The Header-->
<img src="style/header.png" width="900" height="100" border="0" alt="" style="position:absolute;left:0px;top:0px;">
<img src="<?php echo $serverpath;?>/images/header.png" width="900" height="100" border="0" alt="" style="position:absolute;left:0px;top:0px;">
<div id="userbar" style="text-align:right;position:relative;left:710px;top:70px;width:180px;height=30px;">
Login Box
</div>
<div id="userbar" style="text-align:right;position:relative;left:710px;top:70px;width:180px;height=30px;"><?php
if (is_logged_in()){
echo $_SESSION['user']." - <a href=\"$serverpath/logout.php\"><font color=\"#FFFFFF\"><u>Log Out</u></font></a>";
}else{
echo "<a href=\"$serverpath/login.php\"><font color=\"#FFFFFF\"><u>Login</u></font></a> - ";
echo "<a href=\"$serverpath/signup.php\"><font color=\"#FFFFFF\"><u>Sign Up</u></font></a>";
}
?></div>
<div id="userbar" style="text-align:left;position:relative;left:10px;top:55px;width:180px;height=30px;">
<a href="index.html"><font color="#FFFFFF">Home</font></a>
</div>
<div id="userbar" style="text-align:left;position:relative;left:10px;top:55px;width:180px;height=30px;"><?php
echo "<a href=\"$serverpath/index.php\"><font color=\"#FFFFFF\"><u>Home</u></font></a> - ";
echo "<a href=\"$serverpath/user.php\"><font color=\"#FFFFFF\"><u>User List</u></font></a>";
?></div>
<div style="position:relative;left:670px;top:70px;width:400px;">
<form method="get" action="search.php">
<form method="get" action="<?php echo $serverpath;?>/search.php">
<input type="text" name="id"> <input type="submit" value="Search">
</form>
</div>

125
scripts/setup.php Normal file
View File

@ -0,0 +1,125 @@
<?php
//configuration
$serverpath="http://multa.bugs3.com/minetest/forum";
function is_member_moderator($user){
if ($user=="rubenwardy"){
return true;
}else{
return false;
}
}
function SQLerror($title,$msg){
echo "<h1>$title</h1>";
die("$msg");
}
session_start();
$handle = mysql_pconnect("mysql.serversfree.com","u372522788_admin","password");
if (!$handle)
die("MySQL - Error connecting to the MySQL database");
mysql_select_db("u372522788_minetest",$handle) or die("Error Switching DB");
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
function authcheck($user,$pass,$handle){
$pasw = sha1($pass);
$row=getUser($user,$handle);
if ($row==0){
return false;
}
//echo "'{$row[3]}' vs '$passw'";
if ($row[3]==$pasw){
return true;
}else{
return false;
}
}
function login($user){
$_SESSION['auth']="somerandomkey";
$_SESSION['user']=$user;
}
function is_logged_in(){
if ($_SESSION['auth']=="somerandomkey"){
return true;
}
return false;
}
function getUser($user,$handle){
$us= mysql_real_escape_string ($user);
$res = mysql_query("SELECT * FROM users WHERE name='$us'",$handle) or die("query error");
if(mysql_num_rows($res)==0){
return 0;
}
$row = mysql_fetch_row($res) or die("");
return $row;
}
function require_login(){
if (is_logged_in()==false){
header("location: login.php?redir=".curPageURL());
}
}
function getNoTopics($tag,$handle){
$qu = mysql_real_escape_string ($tag);
$res = mysql_query("SELECT * FROM mods WHERE tags LIKE '%$qu%' ORDER BY likes DESC",$handle);
return mysql_num_rows($res);
}
function addUser($user,$pass,$passcon,$email,$handle){
if ($user=="" || $pass=="" || $passcon=="" || $email==""){
return 0;
}
if ($pass==$passcon){
if (user_exists($user,$handle))
return 4;
$pasw=sha1($pass);
if ($pasw=="")
return 3;
$res=mysql_query("INSERT INTO users (name,email,password) VALUES ('$user','$email','$pasw')");
if ($res==1){
return 1;
}else{
return 3;
}
}else{
return 2;
}
}
function user_exists($user,$handle){
$qu = mysql_real_escape_string ($user);
$res = mysql_query("SELECT * FROM users WHERE name='$qu'",$handle);
return mysql_num_rows($res);
}
function entry_exists($name,$handle){
$qu = mysql_real_escape_string ($name);
$res = mysql_query("SELECT * FROM mods WHERE name='$qu'",$handle);
return mysql_num_rows($res);
}
?>

10
search.php Normal file
View File

@ -0,0 +1,10 @@
<?php
include "scripts/setup.php";
$query=$_GET['id'];
$page_title="Search for $query";
include "scripts/pageheader.php";
include "scripts/loadmods.php";
include "scripts/pagefooter.php";
?>

51
signup.php Normal file
View File

@ -0,0 +1,51 @@
<?php
include "scripts/setup.php";
$user=$_POST['user'];
$pass=$_POST['pass'];
$passcon=$_POST['passcon'];
$email=$_POST['email'];
$page_title="Sign Up";
include "scripts/pageheader.php";
$message="Enter your details below.";
$res=addUser($user,$pass,$passcon,$email,$handle);
if ($res==1)
header("location: login.php");
if ($res==2)
$message="Passwords do not match";
if ($res==3)
$message="Account Creation Failed";
if ($res==4)
$message="User already exists";
?>
<table><tr><td width="50%">
<?php
echo "<p>$message</p>";
?>
<form method="post" action="signup.php">
<b>Email:</b> <input type="email" name="email"><br /><br />
<b>Username:</b> <input type="text" name="user"><br /><br />
<b>Password:</b> <input type="password" name="pass"><br /><br />
<b>Confirm:</b> <input type="password" name="passcon"><br /><br />
<input type="submit" value="Create">
</form>
<td><td width="50%">
<h2>Sign Up for a Minetest Mod Forum account</h2>
<h3>Vote</h3>
Vote on which mod, mod pack, texture pack or sound pack is the best
<h3>Add a Mod</h3>
Add a mod, mod pack, texture pack or sound pack to this database
<h3>Secure</h3>
Your password is safe with SHA-1 encrypton.
</td></tr>
</table>
<?php
include "scripts/pagefooter.php";
?>

View File

18
user.php Normal file
View File

@ -0,0 +1,18 @@
<?php
include "scripts/setup.php";
$page_title="Users";
include "scripts/pageheader.php";
?>
<p>
<p>
<p>
<p>
Nothing here yet...
</p>
</p>
</p>
</p>
<?php
include "scripts/pagefooter.php";
?>

32
viewmod.php Normal file
View File

@ -0,0 +1,32 @@
<?php
include "scripts/setup.php";
$id=$_GET['id'];
if (is_numeric($id)==false){
SQLerror("Non Integer","Non integers are not allowed in the id field. <br /> <a href=\"index.php\">Back to home</a>");
}
$res = mysql_query("SELECT * FROM mods WHERE mod_id=$id",$handle) or SQLerror("MySQL Query Error","Error on searching database.mods.mod_id for '$id'");
$row = mysql_fetch_row($res) or die("row error");
$page_title="View mod - {$row[1]}";
include "scripts/pageheader.php";
include "scripts/formatcode.php";
if (is_member_moderator($_SESSION['user']) || $_SESSION['user']==$row[3]){
$links="<a href=\"editentry.php?id=$id\">Edit</a>";
}else{
$links="";
}
echo "<table width=\"100%\"><tr bgcolor=\"#FFFFBD\"><td><a href=\"{$row[9]}\">Download</a></td><td>";
echo "<h1 align=center>{$row[1]} - by <a href=\"user.php?name={$row[3]}\">{$row[3]}</a></h1></td>";
echo "<td width=100>{$row[2]}</td></tr>";
echo "<tr><td colspan=3><div style=\"width:900px;text-wrap: suppress;\"><p>".formatbb($row[4])."</p></div></td><tr>";
echo "<tr height=30 bgcolor=\"#FFFFBD\"><td colspan=3 style=\"text-align:right;\">$links&#32;&#32;&#32;&#32;</td></tr>";
include "scripts/loadposts.php";
include "scripts/pagefooter.php";
?>