3d skin support
parent
8db9b6deeb
commit
0dac98ff23
20
change.php
20
change.php
|
@ -7,29 +7,33 @@ $user=$forum_user['username'];
|
|||
|
||||
$set="";
|
||||
|
||||
$type=$_GET['t'];
|
||||
|
||||
if (!$type || is_numeric($type)==false)
|
||||
SQLerror("Type required","you have not specifed a skin type");
|
||||
|
||||
|
||||
$set="cha_type=$type";
|
||||
|
||||
$front=$_GET['f'];
|
||||
|
||||
if ($front){
|
||||
$front= mysql_real_escape_string ($front);
|
||||
$set="cha_front='".$front."'";
|
||||
$set.=", cha_front='".$front."'";
|
||||
}
|
||||
|
||||
$back=$_GET['b'];
|
||||
|
||||
if ($back){
|
||||
if ($back && $type==2){
|
||||
$back = mysql_real_escape_string ($back);
|
||||
|
||||
if ($set!="")
|
||||
$set.=", ";
|
||||
|
||||
$set.="cha_back='$back'";
|
||||
$set.=", cha_back='$back'";
|
||||
}
|
||||
|
||||
echo "UPDATE punbb_users SET $set WHERE username='$user'";
|
||||
|
||||
if ($set!=""){
|
||||
|
||||
$res = $forum_db->query("UPDATE punbb_users SET $set WHERE username='$user'") or SQLerror("MySQL Query Error","Error on setting punbb_users.cha_front and cha_back");
|
||||
$res = $forum_db->query("UPDATE users SET $set WHERE username='$user'") or SQLerror("MySQL Query Error","Error on setting punbb_users.cha_front and cha_back");
|
||||
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 466 B |
Binary file not shown.
After Width: | Height: | Size: 412 B |
|
@ -13,10 +13,10 @@ $type = $_GET['type'];
|
|||
|
||||
if (!$type)
|
||||
if (!$query && !$mode){
|
||||
echo "<a href=\"gallery.php?type=2d\">2d Character (Sprite)</a><br /><br /><!--<a href=\"gallery.php?type=3d\">-->3d Character <i>currently unavailable</i></a>";
|
||||
echo "<a href=\"gallery.php?type=2\">2d Character (Sprite)</a><br /><br /><a href=\"gallery.php?type=3\">3d Character</a>";
|
||||
include "scripts/pagefooter.php";
|
||||
}else
|
||||
$type="2d";
|
||||
$type=0;
|
||||
|
||||
|
||||
if (!$mode)
|
||||
|
|
24
index.php
24
index.php
|
@ -15,22 +15,34 @@ if ($forum_user['username']=="Guest"){
|
|||
|
||||
echo "<h1>Hello, ".$forum_user['username']."</h1>\n";
|
||||
|
||||
include "scripts/skin_view.php";
|
||||
|
||||
//
|
||||
// View Skin
|
||||
//
|
||||
|
||||
$def=false;
|
||||
|
||||
if ($forum_user['cha_type']!=3){
|
||||
if ($forum_user['cha_back']!=""){
|
||||
echo "<img src=\"".$forum_user['cha_front'].".png\" width=64 height=128 alt=\"left\" /> ";
|
||||
skin_view(2,$forum_user['cha_front'],$forum_user['cha_back']);
|
||||
}else{
|
||||
echo "<img src=\"files/default_texture.png\" width=64 height=128 /> ";
|
||||
skin_view(2,"files/default_texture.png","files/default_texture.png");
|
||||
$def=true;
|
||||
}
|
||||
if ($forum_user['cha_back']!=""){
|
||||
echo "<img src=\"".$forum_user['cha_back'].".png\" width=64 height=128 alt=\"right\" />";
|
||||
|
||||
}else{
|
||||
echo "<img src=\"files/default_texture_back.png\" width=64 height=128 />";
|
||||
$def=true;
|
||||
skin_view(3,$forum_user['cha_front'],"");
|
||||
}
|
||||
|
||||
if ($def==true)
|
||||
echo "<br /><font size=2>No avatar selected.<br />\nDefault avatar from the server's texture pack will be used.</font>";
|
||||
|
||||
//
|
||||
// End of Skin Viewer
|
||||
//
|
||||
|
||||
|
||||
?>
|
||||
<p>
|
||||
<a href="gallery.php">Avatar from Gallery</a><br /><br />
|
||||
|
|
|
@ -3,6 +3,11 @@ echo "<table width=\"100%\">";
|
|||
$query= mysql_real_escape_string ($query);
|
||||
|
||||
if ($mode=="tags"){
|
||||
if ($type==2)
|
||||
$qu_str="SELECT * FROM cha WHERE type=2 AND tags LIKE '%$query%'";
|
||||
else if ($type==3)
|
||||
$qu_str="SELECT * FROM cha WHERE type=3 AND tags LIKE '%$query%'";
|
||||
else
|
||||
$qu_str="SELECT * FROM cha WHERE tags LIKE '%$query%'";
|
||||
}else if ($mode=="user"){
|
||||
$qu_str="SELECT * FROM cha WHERE owner='$query'";
|
||||
|
@ -38,7 +43,7 @@ while ($hash = mysql_fetch_assoc($res)){
|
|||
echo "\n</tr><tr>\n";
|
||||
}
|
||||
|
||||
echo "<td width=70><a href=\"viewcha.php?id={$hash['id']}\" title=\"{$hash['name']} by {$hash['owner']}\"><img width=32 height=64 src=\"files/{$hash['file']}.png\"><img width=32 height=64 src=\"files/{$hash['file']}_back.png\"></a></td>";
|
||||
echo "<td width=32><a href=\"viewcha.php?id={$hash['id']}\" title=\"{$hash['name']} by {$hash['owner']}\"><img width=32 height=64 src=\"files/{$hash['file']}.png\"></a></td><td width=32><a href=\"viewcha.php?id={$hash['id']}\" title=\"{$hash['name']} by {$hash['owner']}\"><img width=32 height=64 src=\"files/{$hash['file']}_back.png\"></a>";
|
||||
}
|
||||
|
||||
while($alternate<11){
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
function upload_skin($name,$filen,$public,$side){
|
||||
global $forum_user;
|
||||
global $_FILES;
|
||||
$dest="";
|
||||
|
||||
if ($public==true){
|
||||
$dest=$name;
|
||||
}else{
|
||||
$dest="player_".$forum_user['username'];
|
||||
}
|
||||
|
||||
$dest.=$side;
|
||||
|
||||
if ($_FILES[$filen]["error"] > 0){
|
||||
return "Error: " . $_FILES[$filen]["error"];
|
||||
}else{
|
||||
if (file_exists("files/".$dest.".png") && $public==true){
|
||||
return "<!--Error:-->An avatar already exists with that name";
|
||||
}else{
|
||||
move_uploaded_file($_FILES[$filen]["tmp_name"],"files/".$dest.".png");
|
||||
}
|
||||
}
|
||||
|
||||
return $dest;
|
||||
}
|
||||
?>
|
|
@ -13,7 +13,7 @@
|
|||
<link rel="stylesheet" href="http://minetest.net/style_v2.css" type="text/css" />
|
||||
<link rel="shortcut icon" href="/favicon.ico" />
|
||||
<link rel="bookmark icon" href="/favicon.ico" />
|
||||
<title><?php echo $page_title;?> - Minetest Mods</title>
|
||||
<title><?php echo $page_title;?> - Minetest Skins</title>
|
||||
|
||||
<style>
|
||||
.inbar_login {
|
||||
|
@ -53,13 +53,9 @@
|
|||
</span>
|
||||
<span class="inbar_other">
|
||||
<ul>
|
||||
<!--<li class="navlink_special"><a href="http://c55.me/blog">Blog</a></li>
|
||||
<li class="navlink_special"><a href="http://wiki.minetest.com/wiki/">Wiki</a></li>
|
||||
<li class="navlink_special"><a href="http://minetest.net/forum/">Forum</a></li>
|
||||
<li class="navlink_special"><a href="https://github.com/celeron55/minetest">Github</a></li>
|
||||
<li class="navlink_special"><a href="http://api.minetest.net/">API</a></li>-->
|
||||
<li class="navlink_normal"><a href="<?php echo $serverpath;?>/index.php">Home</a></li>
|
||||
<li class="navlink_normal"><a href="<?php echo FORUM_ROOT;?>">Forum</a></li>
|
||||
<li class="navlink_normal"><a href="<?php echo $serverpath;?>/zipball.php">Zipball</a></li>
|
||||
</ul>
|
||||
</span>
|
||||
<span class="inbar_login">
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
function skin_view($type,$front,$back){
|
||||
if ($type==2){
|
||||
echo "<img src=\"$front\" width=64 height=128 alt=\"left\" /> ";
|
||||
echo "<img src=\"$back\" width=64 height=128 alt=\"right\" />";
|
||||
}else{
|
||||
echo "<img src=\"$front\" width=128 height=64 alt=\"3d flat skin\" />";
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,80 +1,82 @@
|
|||
<?php
|
||||
// Load scripts
|
||||
require_once "image_upload.php";
|
||||
|
||||
// Temporary Message
|
||||
$message="The uploaded is being edited to support 3d. All uploads will not work at the moment";
|
||||
|
||||
// Load posted information
|
||||
$public=$_POST['public'];
|
||||
$public=($public=="on");
|
||||
$name=$_POST['name'];
|
||||
$desc=$_POST['desc'];
|
||||
$tags=$_POST['tags'];
|
||||
$sub=$_POST['submitted'];
|
||||
$type=3-($_POST['s2d']=="on");
|
||||
|
||||
if ($sub=="")
|
||||
return;
|
||||
|
||||
if ($_FILES["front"]["type"]=="" && $_FILES["back"]["type"]==""){
|
||||
$message="You need to upload two textures for the Avatar";
|
||||
if (is_numeric($type)==false){
|
||||
$message="Something went wrong. Variable \$type non-numeric error.";
|
||||
return;
|
||||
}
|
||||
|
||||
$public=$_POST['public'];
|
||||
$public=($public=="on");
|
||||
// Check all required textures are given
|
||||
$insf=false; //insufficient textures to make skin
|
||||
|
||||
$name=$_POST['name'];
|
||||
$desc=$_POST['desc'];
|
||||
$tags=$_POST['tags'];
|
||||
if ($_FILES["front"]["type"]=="")
|
||||
$insf=true;
|
||||
|
||||
if ($_FILES["back"]["type"]=="" && $type==2)
|
||||
$insf=true;
|
||||
|
||||
if ($insf==true){
|
||||
$message="You need to upload textures for the Skin";
|
||||
return;
|
||||
}
|
||||
|
||||
// Check public information
|
||||
|
||||
if ($public==true && $name==""){
|
||||
$message="You need to give your Avatar Textures a name!";
|
||||
return;
|
||||
}
|
||||
|
||||
if (($_FILES["front"]["type"] == "image/png") && ($_FILES["back"]["type"] == "image/png")){
|
||||
$front_dest="";
|
||||
$back_dest="";
|
||||
|
||||
if ($public==true){
|
||||
$front_dest=$name;
|
||||
$back_dest=$name."_back";
|
||||
}else{
|
||||
$front_dest="player_".$forum_user['username'];
|
||||
$back_dest="player_".$forum_user['username']."_back";
|
||||
}
|
||||
|
||||
|
||||
if ($_FILES["front"]["error"] > 0){
|
||||
$message= "Error: " . $_FILES["front"]["error"];
|
||||
return;
|
||||
}else{
|
||||
if (file_exists("files/".$front_dest.".png") && $public==true){
|
||||
$message="An avatar already exists with that name";
|
||||
return;
|
||||
}else{
|
||||
move_uploaded_file($_FILES["front"]["tmp_name"],"files/".$front_dest.".png");
|
||||
}
|
||||
// Check all is good with extensions
|
||||
if (($_FILES["front"]["type"] != "image/png")){
|
||||
$message="'".$_FILES["front"]["type"]."' is a invalid format. Only PNG files are allowed. ";
|
||||
return;
|
||||
}
|
||||
|
||||
if ($_FILES["back"]["error"] > 0){
|
||||
$message= "Error: " . $_FILES["back"]["error"];
|
||||
return;
|
||||
}else{
|
||||
if (file_exists("files/".$back_dest.".png") && $public==true){
|
||||
$message="An avatar already exists with that name";
|
||||
return;
|
||||
}else{
|
||||
move_uploaded_file($_FILES["back"]["tmp_name"],"files/".$back_dest.".png");
|
||||
}
|
||||
if ($type==2 && ($_FILES["back"]["type"] != "image/png")){
|
||||
$message="'".$_FILES["back"]["type"]."' is a invalid format. Only PNG files are allowed. ";
|
||||
return;
|
||||
}
|
||||
|
||||
//$message="Uploaded";
|
||||
// Upload the textures
|
||||
|
||||
if ($public==false){
|
||||
header("location: change.php?f=$front_dest&b=$back_dest");
|
||||
$front_dest=upload_skin($name,"front",$public,"");
|
||||
$back_dest="";
|
||||
if ($type==2)
|
||||
$back_dest=upload_skin($name,"back",$public,"_back");
|
||||
|
||||
if (strstr($front_dest,"Error")){
|
||||
$message=$front_dest;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($public==false){
|
||||
header("location: change.php?t=$type&f=files/$front_dest&b=files/$back_dest");
|
||||
}else{
|
||||
$name= mysql_real_escape_string ($name);
|
||||
$desc= mysql_real_escape_string ($desc);
|
||||
$front_dest= mysql_real_escape_string ($front_dest);
|
||||
$tags= mysql_real_escape_string ($tags);
|
||||
$owner= mysql_real_escape_string ($forum_user['username']);
|
||||
mysql_query("INSERT INTO cha (name, description, file, owner, tags) VALUES ('$name', '$desc', '$front_dest', '$owner', '$tags')",$handle);
|
||||
mysql_query("INSERT INTO cha (name, description, file, owner, tags, type) VALUES ('$name', '$desc', '$front_dest', '$owner', '$tags', $type)",$handle);
|
||||
$the_id=mysql_insert_id($handle);
|
||||
header("location: viewcha.php?id=$the_id");
|
||||
}
|
||||
}else{
|
||||
$message="'".$_FILES["front"]["type"]."' is a invalid format. Only PNG files are allowed. ";
|
||||
}
|
||||
|
||||
?>
|
77
upload.php
77
upload.php
|
@ -13,7 +13,48 @@ include "scripts/pageheader.php";
|
|||
|
||||
|
||||
?>
|
||||
<font color="#0000FF"><i><?php echo $message;?></i></font>
|
||||
<font color="#FF0000"><i><?php echo $message;?></i></font>
|
||||
|
||||
<h1>Texture Upload</h1>
|
||||
<form action="upload.php" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="submitted" value="yes">
|
||||
|
||||
<p>
|
||||
<input type="checkbox" name="s2d" id="s2d" onClick="javascript:toggle2dInfo()">Is a 2d skin
|
||||
</p>
|
||||
|
||||
<fieldset>
|
||||
<legend>Character Textures</legend>
|
||||
|
||||
|
||||
<i>Texture files must be 16x32 or to scale.</i>
|
||||
|
||||
<p>Front: <input type="file" name="front" id="front"><br />
|
||||
<div id="back_pnl">Back: <input type="file" name="back" id="back"></div>
|
||||
</fieldset>
|
||||
|
||||
<p>
|
||||
<input type="checkbox" name="public" id="public" onClick="javascript:togglePrivInfo()">Add to the Public Gallery
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<fieldset id="gallery_data" style="display: block;">
|
||||
<legend>Public Gallery Settings</legend>
|
||||
Name of Character pack: <input type="text" name="name" /><br />
|
||||
Tags: <input type="text" name="tags" /><br /><br />
|
||||
Description: <a href="help_markup.php" target="_blank">Supports a Markup format</a><br />
|
||||
<textarea name="desc" cols=100 rows=7>
|
||||
</textarea>
|
||||
|
||||
<p>
|
||||
<font color="#FF0000"><b>Warning</b></font><br>
|
||||
If you do not specify a license, then your skin will be treated as one with a <a href="http://sam.zoy.org/wtfpl/">WTFPL license</a>.
|
||||
</p>
|
||||
</fieldset>
|
||||
</p>
|
||||
|
||||
<input type="submit" value="Upload">
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
function prepareForm() {
|
||||
|
@ -25,43 +66,19 @@ function prepareForm() {
|
|||
function togglePrivInfo() {
|
||||
toggle('gallery_data');
|
||||
}
|
||||
function toggle2dInfo() {
|
||||
toggle('back_pnl');
|
||||
}
|
||||
function toggle(id) {
|
||||
var element = document.getElementById(id);
|
||||
var display = (element.style.display === 'none') ? '' : 'none';
|
||||
element.style.display = display;
|
||||
}
|
||||
prepareForm();
|
||||
togglePrivInfo();
|
||||
toggle2dInfo();
|
||||
</script>
|
||||
|
||||
|
||||
<h1>Texture Upload</h1>
|
||||
<form action="upload.php" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="submitted" value="yes">
|
||||
<fieldset>
|
||||
<legend>Character Textures</legend>
|
||||
<i>Texture files must be 16x32 or to scale.</i><br />
|
||||
Front: <input type="file" name="front" id="front"><br />
|
||||
Back: <input type="file" name="back" id="back">
|
||||
</fieldset>
|
||||
|
||||
<p>
|
||||
<input type="checkbox" name="public" id="public" onClick="javascript:togglePrivInfo()">Add to the Public Gallery
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<fieldset id="gallery_data" style="display: none;">
|
||||
<legend>Public Gallery Settings</legend>
|
||||
Name of Character pack: <input type="text" name="name" /><br />
|
||||
Tags: <input type="text" name="tags" /><br /><br />
|
||||
Description: <a href="help_markup.php" target="_blank">Supports a Markup format</a><br />
|
||||
<textarea name="desc" cols=100 rows=7>
|
||||
</textarea>
|
||||
</fieldset>
|
||||
</p>
|
||||
|
||||
<input type="submit" value="Upload">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
include "scripts/pagefooter.php";
|
||||
?>
|
||||
|
|
24
viewcha.php
24
viewcha.php
|
@ -1,7 +1,9 @@
|
|||
<?php
|
||||
include "scripts/setup.php";
|
||||
require_once "scripts/setup.php";
|
||||
|
||||
include "scripts/formatcode.php";
|
||||
require_once "scripts/formatcode.php";
|
||||
|
||||
require_once "scripts/skin_view.php";
|
||||
|
||||
$id=$_GET['id'];
|
||||
|
||||
|
@ -10,20 +12,24 @@ if (is_numeric($id)==false){
|
|||
}
|
||||
|
||||
$res = mysql_query("SELECT * FROM cha WHERE id=$id",$handle) or SQLerror("MySQL Query Error","Error on searching database.cha.id for '$id'");
|
||||
$row = mysql_fetch_row($res) or SQLerror("Row Error","No results where found for a mod with the id $id");
|
||||
$row = mysql_fetch_array($res) or SQLerror("Row Error","No results where found for a mod with the id $id");
|
||||
$page_title="View Character - {$row[1]}";
|
||||
|
||||
$owner = $row[4];
|
||||
|
||||
include "scripts/pageheader.php";
|
||||
include_once "scripts/pageheader.php";
|
||||
|
||||
$links="";
|
||||
|
||||
echo "<table width=\"900\"><tr><td>\n";
|
||||
echo "<table width=\"900\" bgcolor=\"#FFFFBD\"><tr><td width=\"100\">";
|
||||
|
||||
if ($forum_user['username']!="Guest")
|
||||
echo "<a href=\"change.php?f=http://multa.bugs3.com/minetest/characters/files/{$row[3]}&b=http://multa.bugs3.com/minetest/characters/files/{$row[3]}_back\">Use This</a>";
|
||||
if ($forum_user['username']!="Guest"){
|
||||
if ($row['type']==2)
|
||||
echo "<a href=\"change.php?t=2&f=$serverpath/files/{$row[3]}.png&b=$serverpath/files/{$row[3]}_back.png\">Use This</a>";
|
||||
else
|
||||
echo "<a href=\"change.php?t=3&f=$serverpath/files/{$row[3]}.png\">Use This</a>";
|
||||
}
|
||||
|
||||
echo "</td>\n";
|
||||
|
||||
|
@ -34,7 +40,11 @@ echo "</tr></table></td></tr>\n"; // Version
|
|||
|
||||
echo "<tr><td><table width=\"900\"><tr><td><div style=\"width:870px;text-wrap: suppress;\"><p>\n";
|
||||
|
||||
echo "<center><img width=64 height=128 src=\"files/{$row[3]}.png\">\n<img width=64 height=128 src=\"files/{$row[3]}_back.png\"></center>\n";
|
||||
echo "<center>";
|
||||
|
||||
skin_view($row['type'],"files/{$row['file']}.png","files/{$row['file']}_back.png");
|
||||
|
||||
echo "</center>\n";
|
||||
|
||||
echo "</p><p>\n";
|
||||
|
||||
|
|
BIN
zipball.zip
BIN
zipball.zip
Binary file not shown.
Loading…
Reference in New Issue