Did 3m, like/dislike, and more
This commit is contained in:
parent
36b36ef962
commit
a14e2ca9ef
27
api/3m/getmodbyname.php
Normal file
27
api/3m/getmodbyname.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?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 "{{$row[1]}}\n";
|
||||
echo "[description]\n";
|
||||
echo "{$row[3]}\n";
|
||||
echo "[release]\n";
|
||||
echo "{$row[2]}\n";
|
||||
echo "[deps]\n";
|
||||
echo "[depsend]\n";
|
||||
echo "[repotype]\n";
|
||||
echo "archive\n";
|
||||
echo "[repoaddr]\n";
|
||||
echo "{$row[9]}\n";
|
||||
echo "{end}\n";
|
||||
|
||||
|
||||
die("");
|
||||
?>
|
22
api/3m/getmods.php
Normal file
22
api/3m/getmods.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
include "../../scripts/setup.php";
|
||||
$id=$_GET['id'];
|
||||
if ($id==""){
|
||||
$id="mod";
|
||||
}
|
||||
$res = mysql_query("SELECT * FROM mods WHERE tags LIKE '%$id%' ORDER BY mod_id",$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";
|
||||
echo "[server]\n";
|
||||
echo "multa.bugs3.com\n";
|
||||
echo "[modinfo]\n";
|
||||
echo "minetest/forum/api/3m/getmodbyname?id={$hash['name']}\n";
|
||||
echo "{end}\n\n";
|
||||
}
|
||||
|
||||
die("");
|
||||
?>
|
@ -1,7 +1,9 @@
|
||||
<?php
|
||||
include "../../scripts/setup.php";
|
||||
|
||||
$id="mod";
|
||||
$id=$_GET['id'];
|
||||
if ($id==""){
|
||||
$id="mod";
|
||||
}
|
||||
$res = mysql_query("SELECT * FROM mods WHERE tags LIKE '%$id%' ORDER BY mod_id",$handle) or SQLerror("MySQL Query Error","Error on searching database.mods.tags for '$query'");
|
||||
|
||||
header("Content-type: text/plain");
|
||||
|
@ -8,7 +8,7 @@
|
||||
}
|
||||
|
||||
function seperator($cols){
|
||||
echo "<tr bgcolor=#00000 height=2><td colspan=$cols></td></tr>";
|
||||
echo "<tr style=\"background-color:#000000;\" height=2><td colspan=$cols></td></tr>";
|
||||
}
|
||||
|
||||
$page_title="Home";
|
||||
@ -30,11 +30,13 @@
|
||||
|
||||
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("tech","Technical Mods","Technical Mods (eg: Mesecons, Technic)",$handle);
|
||||
listSearch("fun","Experimental Mods","Experimental mods for the game (eg: Chess, Mesecons, Carts)",$handle);
|
||||
listSearch("server","Server Interaction Mods","Mods ideal for servers (low lag, tools)(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("util","Utility Mods","Mods that add new feature and actons to the game (eg: bones,falling_items,throwing)",$handle);
|
||||
listSearch("3d","3D Object Mods","Mods that use NodeBoxes",$handle);
|
||||
|
||||
seperator(4);
|
||||
|
@ -35,6 +35,9 @@ $result=str_replace("[/*]","</li>",$result);
|
||||
$result=str_replace("[code]","<p><code>",$result);
|
||||
$result=str_replace("[/code]","</code></p>",$result);
|
||||
|
||||
$result=str_replace("[color=red]","<font color=\"#FF0000\">",$result);
|
||||
$result=str_replace("[/color]","</font>",$result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
?>
|
79
scripts/voters.php
Normal file
79
scripts/voters.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
function likeMod($id,$user,$handle){
|
||||
echo "\n\n\n<!-- function likeMod($id,$user,$handle) is executing:\n";
|
||||
if (is_numeric($id)==false){
|
||||
echo "[Error]: is not numeric\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
$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");
|
||||
$user_d = getUser($user,$handle);
|
||||
|
||||
if (!$user_d){
|
||||
echo "[Error]: user is null\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
echo "[Notice]: calculating\n";
|
||||
if (strstr($user_d[5],$row[1].",")){
|
||||
echo "-decreasing likes\n";
|
||||
changeLikes($id,$user,-1,$handle);
|
||||
}else{
|
||||
echo "-increasing likes\n";
|
||||
changeLikes($id,$user,1,$handle);
|
||||
}
|
||||
echo "\n\nend of execution-->\n\n\n";
|
||||
}
|
||||
|
||||
|
||||
function changeLikes($id,$user,$amount,$handle){
|
||||
echo "\n\n\n function changeLikes($id,$user,$amount,$handle) is executing\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("row error");
|
||||
$user_d = getUser($user,$handle);
|
||||
|
||||
if (!$user_d){
|
||||
echo "[Error]: user is null\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($amount==1){
|
||||
$tmp=$user_d[5].$row[1].",";
|
||||
mysql_query("UPDATE users SET liked='$tmp' WHERE name='$user'",$handle) or die("Error on searching database.users.name for '$user'");
|
||||
$tmp=$row[5]+1;
|
||||
mysql_query("UPDATE mods SET likes=$tmp WHERE mod_id=$id",$handle) or die("Error on searching database.mods.mod_id for '$id'");
|
||||
}else{
|
||||
$tmp=str_replace($row[1].",","",$user_d[5]);
|
||||
mysql_query("UPDATE users SET liked='$tmp' WHERE name='$user'",$handle) or die("Error on searching database.users.name for '$user'");
|
||||
$tmp=$row[5]-1;
|
||||
mysql_query("UPDATE mods SET likes=$tmp WHERE mod_id=$id",$handle) or die("Error on searching database.mods.mod_id for '$id'");
|
||||
}
|
||||
}
|
||||
|
||||
function changeDislikes($id,$user,$amount,$handle){
|
||||
echo "\n\n\n function changeDislikes($id,$user,$amount,$handle) is executing\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("row error");
|
||||
$user_d = getUser($user,$handle);
|
||||
|
||||
if (!$user_d){
|
||||
echo "[Error]: user is null\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($amount==1){
|
||||
$tmp=$user_d[9].$row[1].",";
|
||||
mysql_query("UPDATE users SET dislikes='$tmp' WHERE name='$user'",$handle) or die("Error on searching database.users.name for '$user'");
|
||||
$tmp=$row[6]+1;
|
||||
mysql_query("UPDATE mods SET dislikes=$tmp WHERE mod_id=$id",$handle) or die("Error on searching database.mods.mod_id for '$id'");
|
||||
}else{
|
||||
$tmp=str_replace($row[1].",","",$user_d[9]);
|
||||
mysql_query("UPDATE users SET dislikes='$tmp' WHERE name='$user'",$handle) or die("Error on searching database.users.name for '$user'");
|
||||
$tmp=$row[6]-1;
|
||||
mysql_query("UPDATE mods SET dislikes=$tmp WHERE mod_id=$id",$handle) or die("Error on searching database.mods.mod_id for '$id'");
|
||||
}
|
||||
}
|
||||
?>
|
17
viewmod.php
17
viewmod.php
@ -1,7 +1,13 @@
|
||||
<?php
|
||||
include "scripts/setup.php";
|
||||
include "scripts/voters.php";
|
||||
|
||||
$id=$_GET['id'];
|
||||
$act=$_GET['action'];
|
||||
|
||||
if ($act=="like"){
|
||||
likeMod($id,$_SESSION['user'],$handle);
|
||||
}
|
||||
|
||||
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>");
|
||||
@ -14,16 +20,19 @@ $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> <a href=\"deleteentry.php?id=$id\">Delete</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 "<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 "<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
|
||||
echo "<tr height=30 bgcolor=\"#FFFFBD\"><td colspan=3 style=\"text-align:right;\">$links    </td></tr>";
|
||||
|
||||
include "scripts/loadposts.php";
|
||||
|
Loading…
x
Reference in New Issue
Block a user