Merge pull request #2 from Phitherek/master

3m compatibility + DB relativity changes.
master
Rubenwardy 2012-09-15 07:40:21 -07:00
commit 429eed5cb7
10 changed files with 213 additions and 61 deletions

24
3mrelinc.php Normal file
View File

@ -0,0 +1,24 @@
<?php
// 3m Release increasing (by Phitherek_)
include "scripts/setup.php";
$page_title="3m Release Increasing (by Phitherek_)";
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";
$mmmres = mysql_query("SELECT rel FROM 3m_specific WHERE id=".$id, $handle) or SQLerror("SQL Error", "Could not find the entry!");
$mmmarr = mysql_fetch_array($mmmres);
$mmmrel = $mmmarr['rel'];
$mmmrel = $mmmrel + 1;
$q = mysql_query("UPDATE 3m_specific SET rel=".$mmmrel." WHERE id=".$id, $handle) or SQLerror("SQL Error", "Could not increase 3m release value!");
echo("3m Release increased!<br />");
header("location: viewmod.php?id=$id");
// End of Phitherek_' s code
?>

114
README.md
View File

@ -1,15 +1,14 @@
Rubenwardy's Mod Forum
======================
A php and mysgl forum for mods.
A php and mysql forum for mods.
Also a mod database for Jeijas Ingame Mod Manager
and Sfan's Python Mod Manager
Also a mod database for Jeija' s Ingame Mod Manager, Sfan's Python Mod Manager and Phitherek_' s 3m Minetest Mod Manager
License
=======
Copyright (c) 2012, Andrew "Rubenwardy" Ward
Copyright (c) 2012, Andrew "Rubenwardy" Ward and Piotr "Phitherek_" Żurek
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -53,44 +52,77 @@ Database
========
The database structure.
USERS:
mysql> show tables;
+-----------------------------+
| Tables_in_minetest_forum_db |
+-----------------------------+
| 3m_specific |
| mods |
| posts |
| users |
+-----------------------------+
4 rows in set (0.00 sec)
* id (int)
* name
* email
* password
* level (int)
* stars
* avatar
* location
* sig
mysql> describe users;
+----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(100) | YES | | NULL | |
| email | varchar(300) | YES | | NULL | |
| password | varchar(500) | YES | | NULL | |
| level | int(11) | YES | | NULL | |
| stars | int(11) | YES | | NULL | |
| avatar | int(11) | YES | | NULL | |
| location | varchar(50) | YES | | NULL | |
| sig | varchar(500) | YES | | NULL | |
+----------+--------------+------+-----+---------+----------------+
9 rows in set (0.00 sec)
MOD:
mysql> describe mods;
+-------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+--------------+------+-----+---------+----------------+
| mod_id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(100) | YES | | NULL | |
| version | varchar(20) | YES | | NULL | |
| owner | int(11) | YES | | NULL | |
| description | varchar(500) | YES | | NULL | |
| likes | int(11) | YES | | NULL | |
| dislikes | int(11) | YES | | NULL | |
| tags | varchar(100) | YES | | NULL | |
| license | varchar(10) | YES | | NULL | |
| file | varchar(500) | YES | | NULL | |
| depend | varchar(500) | YES | | NULL | |
| basename | varchar(100) | YES | | NULL | |
| date_released | date | YES | | NULL | |
| quality_total | int(11) | YES | | NULL | |
| quality_voters | int(11) | YES | | NULL | |
| usefullness_total | int(11) | YES | | NULL | |
| cpu_total | int(11) | YES | | NULL | |
| cpu_voters | int(11) | YES | | NULL | |
+-------------------+--------------+------+-----+---------+----------------+
18 rows in set (0.01 sec)
* 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)
mysql> describe posts;
+----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+----------------+
| post_id | int(11) | NO | PRI | NULL | auto_increment |
| owner | int(11) | YES | | NULL | |
| post | varchar(500) | YES | | NULL | |
| topic | int(11) | YES | | NULL | |
| likes | int(11) | YES | | NULL | |
| dislikes | int(11) | YES | | NULL | |
+----------+--------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)
POSTS:
* post_id (int)
* Owner
* Post
* Topic (int)
* Like (int)
* Dislike (int)
mysql> describe 3m_specific;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
| rel | int(11) | YES | | NULL | |
| repotype | varchar(20) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
3 rows in set (0.01 sec)

View File

@ -24,7 +24,10 @@ if (is_member_moderator($_SESSION['user'])==true){
<!--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>
<!-- 3m release (by Phitherek_) -->
<td width="20%">Version:* <input type="text" size="30" name="mod_version" value="<?php echo $version;?>"></td>
<td width="20%">3m Release:* <input type="text" size="30" name="mmmrel" value="<?php echo $mmmrel;?>"></td>
<!-- End of Phitherek_' s change -->
</tr>
<!--Description-->
@ -64,6 +67,12 @@ Delete these notes before adding the entry-->
<!--License and File-->
<tr>
<!--3m Repotype (by Phitherek_)-->
<td>3m Repotype: <select name="mmmrt" size="1">
<option value="archive" selected>Archive</option>
<option value="git">Git</option>
</select></td>
<!--End of Phitherek_' s code-->
<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>

View File

@ -3,23 +3,36 @@ 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'");
$res = mysql_query("SELECT * FROM mods WHERE basename='$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");
$row = mysql_fetch_array($res) or die("Name:\nDepends:\nFile:\nVersion:\n");
$mmmres = mysql_query("SELECT * FROM 3m_specific WHERE id=".$row['id']);
$mmmarr = mysql_fetch_array($mmmres);
echo "{{$row[1]}}\n";
echo "{{$row['basename']}}\n";
echo "[description]\n";
echo "{$row[3]}\n";
echo "{$row['desc']}\n";
echo "[release]\n";
echo "{$row[2]}\n";
echo "{$mmmres['rel']}\n";
echo "[deps]\n";
$deps = $row['depend'];
$parseddeps = "";
for($i=0; $i < strlen($deps); $i++) {
if($deps[$i] == ",") {
$parseddeps .= "\n";
} else if($deps == " ") {
} else {
$parseddeps .= $deps[$i];
}
}
echo "{$parseddeps}\n";
echo "[depsend]\n";
echo "[repotype]\n";
echo "archive\n";
echo "{$mmmres['repotype']}\n";
echo "[repoaddr]\n";
echo "{$row[9]}\n";
echo "{$row['file']}\n";
echo "{end}\n";

View File

@ -10,11 +10,11 @@ header("Content-type: text/plain");
// Get projects loop
while ($hash = mysql_fetch_assoc($res)){
echo "{{$hash['name']}}\n";
echo "{{$hash['basename']}}\n";
echo "[server]\n";
echo "multa.bugs3.com\n";
echo "[modinfo]\n";
echo "minetest/forum/api/3m/getmodbyname?id={$hash['name']}\n";
echo "minetest/forum/api/3m/getmodbyname?id={$hash['basename']}\n";
echo "{end}\n\n";
}

View File

@ -33,6 +33,9 @@ if ($name==""){
if ($do==true){
$name=mysql_real_escape_string($name);
mysql_query("DELETE FROM mods WHERE name='$name'",$handle) or SQLerror("MySQL Query Error","Error finding entry $name");
// 3m specific removal (by Phitherek_)
mysql_query("DELETE FROM 3m_specific WHERE id=".$id, $handle);
// End of Phitherek_' s code
header("location: index.php");
}
?>

View File

@ -13,7 +13,12 @@ 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");
// Owner name instead of id, 3m_specific (by Phitherek_)
$owr = mysql_query("SELECT name FROM users WHERE id=".$row[3], $handle);
$owar = mysql_fetch_array($owr);
$mmmres = mysql_query("SELECT * FROM 3m_specific WHERE id=".$id, $handle);
$mmmarr = mysql_fetch_array($mmmres);
// End of Phitherek_' s code
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");
@ -34,7 +39,16 @@ $version=$_POST['mod_version'];
if ($version=="")
$version=$row[2];
$owner=$row[3];
//3m release (by Phitherek_)
$mmmrel=$_POST['mmmrel'];
if($mmmrel=="") {
$mmmrel=$mmmarr['rel'];
}
//End of Phitherek_' s code
// Owner name instead of id (by Phitherek_)
$owner=$owar['name'];
// End of Phitherek_' s change
$desc=$_POST['mod_desc'];
if ($desc=="")
@ -48,6 +62,13 @@ $license=$_POST['mod_lic'];
if ($license=="")
$license=$row[8];
// 3m repotype (by Phitherek_)
$mmmrt=$_POST['mmmrt'];
if($mmmrt =="") {
$mmmrt = $mmmarr['repotype'];
}
// End of Phitherek_' s code
$file=$_POST['mod_file'];
if ($file=="")
$file=$row[9];
@ -62,6 +83,9 @@ if ($basename=="")
if ($do==true){
include "scripts/entry_adders_sql_safe.php"; mysql_query("UPDATE mods SET version='$version' WHERE name='$name'",$handle);
// 3m release (by Phitherek_)
mysql_query("UPDATE 3m_specific SET rel='$mmmrel' WHERE id='$id'",$handle) or SQLerror("Error on 3m_specific:rel","");
// End of Phitherek_' s code
/*echo "$name<br />";
echo "$desc<br />";
echo "$tags<br />";
@ -72,6 +96,9 @@ if ($do==true){
mysql_query("UPDATE mods SET description='$desc' WHERE name='$name'",$handle) or SQLerror("Error on desc","");
mysql_query("UPDATE mods SET tags='$tags' WHERE name='$name'",$handle)or SQLerror("Error on tags","");
mysql_query("UPDATE mods SET license='$license' WHERE name='$name'",$handle)or SQLerror("Error on license","");
// 3m repotype (by Phitherek_)
mysql_query("UPDATE 3m_specific SET repotype='$mmmrt' WHERE id='$id'",$handle) or SQLerror("Error on 3m_specific:repotype","");
// End of Phitherek_' s code
mysql_query("UPDATE mods SET file='$file' WHERE name='$name'",$handle)or SQLerror("Error on file","");
mysql_query("UPDATE mods SET depend='$depend' WHERE name='$name'",$handle)or SQLerror("Error on depend","");
mysql_query("UPDATE mods SET basename='$basename' WHERE name='$name'",$handle)or SQLerror("Error on basename","");
@ -96,7 +123,10 @@ Help: <a href="help/markup.php" target="_blank">Description Markup</a> - <a href
<!--Mod Name and Version-->
<tr>
<td width="60%">Mod Name: <input type="text" size="50" name="mod_name" readonly="true" style="background-color:#EEEEEE;" value="<?php echo $name;?>"></td>
<td width="40%">Version: <input type="text" size="30" name="mod_version" value="<?php echo $version;?>"></td>
<!-- 3m release (by Phitherek_) -->
<td width="20%">Version: <input type="text" size="30" name="mod_version" value="<?php echo $version;?>"></td>
<td width="20%">3m Release: <input type="text" size="30" name="mmmrel" value="<?php echo $mmmrel;?>"></td>
<!-- End of Phitherek_' s change -->
</tr>
<!--Description-->
@ -110,6 +140,12 @@ Help: <a href="help/markup.php" target="_blank">Description Markup</a> - <a href
<!--License and File-->
<tr>
<!--3m Repotype (by Phitherek_)-->
<td>3m Repotype: <select name="mmmrt" size="1">
<option value="archive" <?php if($mmmrt=="archive") echo "selected"; ?>>Archive</option>
<option value="git" <?php if($mmmrt=="git") echo "selected"; ?>>Git</option>
</select></td>
<!--End of Phitherek_' s code-->
<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>

View File

@ -9,6 +9,12 @@ $version=$_POST['mod_version'];
if ($version=="")
return 0;
//3m release (by Phitherek_)
$mmmrel=$_POST['mmmrel'];
if ($mmrel=="")
return 0;
//End of Phitherek_' s code
$desc=$_POST['mod_desc'];
if ($desc=="")
return 0;
@ -23,6 +29,11 @@ if ($tags_msc=="")
return 0;
$license=$_POST['mod_lic'];
//3m repotype
$mmmrt=$_POST['mmmrt'];
if($mmmrt=="")
return 0;
//End of Phitherek_' s code
$file=$_POST['mod_file'];
if ($file=="")
@ -37,17 +48,27 @@ $owner=$_POST['user'];
if ($owner=="")
$owner=$_SESSION['user'];
//Extract ownerid from database (by Phitherek_)
$q = mysql_query("SELECT id FROM users WHERE name='".$owner."'");
$qr = mysql_fetch_array($q);
$ownerid = $qr['id'];
//End of Phitherek_' s code
//Load on_submit values
$date = date('Y-m-d H:i:s');
$tags = "$tags_type,$tags_msc,";
if (entry_exists($name,$handle))
return 1;
//Substitute owner with ownerid (by Phitherek_)
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')");
VALUES ('$name','$version',$ownerid,'$desc','$tags',0,0,'$license','$file','$depend','$basename','$date')");
//End of Phitherek_' s change
$the_id=mysql_insert_id($handle);
//3m specific adding (by Phitherek_)
mysql_query("INSERT INTO 3m_specific VALUES($the_id,$mmmrel,'$mmmrt')");
//End of Phitherek_' s code
header("location: viewmod.php?id=$the_id");
?>

View File

@ -12,8 +12,15 @@ while ($hash = mysql_fetch_assoc($res)){
}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>";
// Owner name from id (by Phitherek_)
$q = mysql_query("SELECT name FROM users WHERE id=".$hash['owner']);
$qr = mysql_fetch_array($q);
// End of Phitherek_' s code
// Owner name instead of id (by Phitherek_)
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 {$qr['name']}</td>";
// End of Phitherek_' s change
echo "<td>{$hash['likes']}</td>";
echo "<td>{$hash['tags']}</td>";
echo "<td>{$hash['license']}</td></tr>\n";

View File

@ -17,19 +17,26 @@ $res = mysql_query("SELECT * FROM mods WHERE mod_id=$id",$handle) or SQLerror("M
$row = mysql_fetch_row($res) or die("row error");
$page_title="View mod - {$row[1]}";
// Substitute owner ID with owner name (by Phitherek_):
$r = mysql_query("SELECT name FROM users WHERE id=".$row[3],$handle) or SQLerror("MySQL Query Error","Error on getting owner name from users");
$ra = mysql_fetch_array($r);
$owner = $ra['name'];
// End of Phitherek_' s code
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> <a href=\"deleteentry.php?id=$id\">Delete</a>";
//3m Release Increasing (by Phitherek_)
$links="<a href=\"editentry.php?id=$id\">Edit</a> <a href=\"3mrelinc.php?id=$id\">Increase 3m Release</a> <a href=\"deleteentry.php?id=$id\">Delete</a>";
//End of Phitherek_' s change
}else{
$links="";
}
echo "<table width=\"100%\"><tr bgcolor=\"#FFFFBD\"><td><a href=\"{$row[9]}\">Download</a></td><td>"; // Download Link
echo "<h1 align=center>{$row[1]} - by <a href=\"user.php?name={$row[3]}\">{$row[3]}</a></h1></td>"; // Title and User Link
echo "<h1 align=center>{$row[1]} - by <a href=\"user.php?name={$owner}\">{$owner}</a></h1></td>"; // Title and User Link
echo "<td width=150>{$row[2]}</td></tr>"; // Version
echo "<tr><td colspan=2><div style=\"width:900px;text-wrap: suppress;\"><p>".formatbb($row[4])."</p></div></td>"; // Description
echo "<td><a href=\"viewmod.php?id=$id&action=like\">+</a></td></tr>"; // Likes