smilies upload tool for 2indi
you need to add an extra field into the ibwf_smilies table called filename for this script to work right or delete the bit of coding that links to the filename field. Hope this helps. 😊
<?php
include("config.php");
include("core.php");
connectdb();
$sid = $_GET["sid"];
$page = $_GET["page"];
$who = $_GET["who"];
$uid = getuid_sid($sid);
$desc = $_POST['desc'];
$upload = $_POST['upload'];
$superdat = $_FILES['superdat']['tmp_name'];
$superdat_name=$_FILES['superdat']['name'];
echo("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML Mobile 1.0//EN\"". " \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
?>
<head>
<title>Uploader</title>
<meta forua="true" http-equiv="Cache-Control" content="no-cache"/>
<meta forua="true" http-equiv="Cache-Control" content="must-revalidate"/>
<?php
echo gettheme($sid);
?>
</head>
<body>
<?php
////////this is my can use upload tools replace with your isadmin
//////////////////////
if(!uploadtool(getuid_sid($sid)))
{
echo "<p align=\"center\">";
echo "You are not an admin<br/>";
echo "<br/>";
echo "<a href=\"index.php$sid\">Home</a>";
echo "</p></div></div></font></body>";
echo "</html>";
exit();
}
//////////////////////////
if((islogged($sid)==false)||($uid==0))
{
boxstart("Error!");
echo "<center><img src=\"images/notok.gif\" alt=\"\"/><small>You are not logged in<br/>";
echo "or your session has expired.<br/><br/>";
echo "
<form action=\"login.php\" method=\"get\">
<img src=\"images/user.gif\" alt=\"\"/>Enter username:<br/>
<input id=\"inputText\" name=\"loguid\" maxlength=\"30\"/><br/>
<img src=\"images/pass.gif\" alt=\"\"/>Enter password:<br/>
<input id=\"inputText\" type=\"password\" format=\"*x\" name=\"logpwd\" maxlength=\"30\"/><br/>
<input id=\"inputButton\" type=\"submit\" value=\"Login\"/><br/>
</form>
<br/><br/><img src=\"images/register.gif\" alt=\"\"/><a href=\"register.php\">Register</a>
<br/><img src=\"images/home.gif\" alt=\"\"/><a href=\"index.php\">Home</a>
</small></center></div></div></body></html>";
exit();
}
if(isbanned($uid))
{
boxstart("Error!");
echo "<small><p align=\"center\"><img src=\"images/notok.gif\" alt=\"\"/>
You have been <b>BANNED!</b><br/>";
$banto = mysql_fetch_array(mysql_query("SELECT timeto FROM ibwf_penalties WHERE uid='".$uid."' AND penalty='1'"));
$banres = mysql_fetch_array(mysql_query("SELECT lastpnreas FROM ibwf_users WHERE id='".$uid."'"));
$remain = $banto[0] - time();
$rmsg = gettimemsg($remain);
echo "Ban Reason: ".$banres[0]." <br/>You can login again after ".$rmsg."
</p></small></div></div>
</body>
</html>";
exit();
}
boxstart("Upload Smilie");
echo "<small><p>";
addonline(getuid_sid($sid),"Tools","");
if ($upload="upload"&&$superdat_name)
{
if (!eregi("\.(gif|bmp|jpeg|jpg|png)$",$superdat_name))
{
print "<b>Unsupported File Extention! Supported types are gif, bmp, jpeg, jpg, png</b>";
}else
{
$superdat_name = preg_replace(
'/[^a-zA-Z0-9\.\$\%\'\`\-\@\{\}\~\!\#\(\)\&\_\^]/'
,'',str_replace(array(' ','%20',"'"),array('_','_', ""),$superdat_name));
if(strlen($superdat_name)>53){ print "<b>File Name Is Too Long!</b>";
}
else
{
if (empty($superdat))
{
print "<b>No input file specified!!!</b>";
}
if (empty($desc))
{
print "<b>No smilie code specified!!!</b>";
}
else
{
$exi1 = mysql_query("SELECT COUNT FROM ibwf_smilies WHERE scode='$desc'");
if($exi1[0]>0){
print "<b>Smilie code already exists!!!</b>";
exit();
}
else
{
$exi2 = mysql_fetch_array(mysql_query("SELECT COUNT(id), MAX(id) FROM ibwf_smilies WHERE filename='".$superdat_name."' "));
if($exi2[0]>0)
{
$superdat_name="1".$superdat_name;
$flag1="<br/>Filename already existed but code didnt match so it was renamed and prefixed witha 1";
}
}
echo mysql_error();
$ext = explode(".", strrev($superdat_name));
switch(strtolower($ext[0]))
{
case "fig":
$type="image";
break;
case "gnp":
$type="image";
break;
case "gpj":
$type="image";
break;
case "gepj":
$type="image";
break;
case "pmb":
$type="image";
break;
case "pmbw":
$type="image";
break;
}
$uploads_dir = './smilies';/
////////////// replace this with your smilies folder
$ims = "http://domain.co.uk/smilies/$superdat_name";
///////////////////
move_uploaded_file("$superdat", "$uploads_dir/$superdat_name") or
die("Couldn't copy file.");
$result=mysql_query("INSERT INTO `web102-users-1`.`ibwf_smilies` (`id`, `scode`, `imgsrc`, `hidden`, `filename`) VALUES (NULL, '$desc', '$ims', '0', '$superdat_name')");
echo "<b>$superdat_name</b> has successfully been uploaded to the smilies place with the code $desc";
}
}
}
}
?>
<?php
echo "<form align=\"center\" action=\"adminsmilies.php?sid=$sid\" method=\"post\" enctype=\"multipart/form-data\">";
?>
»Upload file size limit is 1MB<br/>
<b>Enter Smilie BB Code(Maximum 25 chars):</b><br/>
<input id="inputText" align="center" type="text" name="desc" maxlength="255"/><br/>
<b>Select File To Be Uploaded :</b><br/>
<input id="inputText" align="center" type="file" name="superdat"/><br/>
<input id="inputText" align="center" type="hidden" name="upload" value="upload"/>
<input id="inputButton" align="center" type="submit" name="submit" value="Upload File!"/><br/><br/> <b><u>You can upload smilies with folowing extentions:</u></b><br/>
Image: gif, bmp, jpeg, jpg, png<br/>
<hr/>
<?php
//////////Replace this with your admin tools link
echo "<br/><a href=\"tools.php?action=tools&sid=$sid\">Tools</a>";
//////////////////////////////////////////////////
?>
</form>
</p></small>
<?php
boxend();
echo getfooter($sid);
?>
</body></html>
Almost forgot there is a few things you need to change but I have showed them in the coding and save the file as adminsmilies.php