Smilies uploader

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Smilies uploader

    Hey guys i have this code
    Code:
    /////////////////////////////smilies/////////////////////////////
    
    else if($action=="smilies")
    {
    addonline(getuid_sid($sid),"Viewing Smilies","");
    if($script=="wml"){
    echo "<card id=\"main\" title=\"Gallery Pics\">";
    echo "<p align=\"center\">";
    }else{
    echo "<head>";
    echo "<title>Smilies</title>";
    echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
    echo "</head>";
    echo "<body>";
    echo "<center>";
    }
    $items_per_page = "10";
    if (!isset($page)) {$page = 0;}
    $total = 0;
    if(!($dp = opendir("./"))) die ("Cannot open ./");
    $file_array = array();
     
    while ($file = readdir ($dp))
    {
    if(substr($file,0,1) != '.' and $file != "index.php")
    {
    $file_array[] =  $file;
    }
    }
    $file_count = count ($file_array);
    sort ($file_array);
    echo "<u><i><b>Smilies</b></i></u><br/>";	
    if ($file_count > 0)
    {
    $first_record = $page * $items_per_page;
    $last_record = $first_record + $items_per_page;
    while (list($fileIndexValue, $file_name) = each ($file_array))
    {
    if (($fileIndexValue >= $first_record) AND ($fileIndexValue < $last_record))
    {
    
    if((isowner(getuid_sid($sid)))||(isheadadmin(getuid_sid($sid))))
    {
    $delpic="<br/><a href=\"index.php?action=smilies&amp;page=$page&amp;sid=$sid&amp;script=$script&amp;delete=$file_name\"><img src=\"../images/notok.gif\" alt=\"[x]\"/></a><br/>";
    }
    echo "<a href=\"$file_name\">$file_name</a> ". round(filesize($file_name)/1024,1) . "kb$delpic<br/>";
    $delete = $_GET["delete"];
    if($delete=="$file_name"){
    if((isowner(getuid_sid($sid)))||(isheadadmin(getuid_sid($sid))))
    {
    unlink("./$file_name");
    echo "<br/>$file_name deleted successfully<br/>";
    if($script=="wml"){
    echo "<card id=\"refresh\" title=\"refresh\" ontimer=\"index.php?action=smilies&amp;page=$page&amp;sid=$sid&amp;script=$script\">";
    echo "<timer value=\"1\"/>pls wait while browser redirects</card></p></card></wml>";
    exit();
    }else{
    echo "<meta http-equiv=Refresh content=1;url=index.php?action=smilies&amp;page=$page&amp;sid=$sid&amp;script=$script>";
    echo "</p></body></html>";
    exit();
    }
    }
    }
    $total = $total + filesize($file_name);
    }
    }
    echo "<br/>";
    $pages =(int) ceil($file_count / $items_per_page);
    $pages = ($pages -1);
    
    if (($file_count > 0) AND ($page != 0))
    {
    $prev_page = $page -1;
    echo "<a href=\"".$_SERVER["PHP_SELF"]."?action=smilies&amp;page=$prev_page&amp;sid=$sid&amp;script=$script\"><img src=\"../images/prev.gif\" alt=\"Prev\"/></a> |";
    }
    if (($file_count > 0) AND ($last_record < $file_count))
    {
    $next_page = $page + 1;
    echo " <a href=\"".$_SERVER["PHP_SELF"]."?action=smilies&amp;page=$next_page&amp;sid=$sid&amp;script=$script\"><img src=\"../images/next.gif\" alt=\"Next\"/></a>";
    }
    if ($file_count > 10)
    {
    if($script=="wml"){
    $rets = "<br/>Jump (0-$pages/$page)<br/><input name=\"pg\" format=\"*N\" size=\"2\"/>";
    $rets .= "<anchor>goto page";
    $rets .= "<go href=\"index.php\" method=\"get\">";
    $rets .= "<postfield name=\"action\" value=\"$action\"/>";
    $rets .= "<postfield name=\"sid\" value=\"$sid\"/>";
    $rets .= "<postfield name=\"script\" value=\"$script\"/>";
    $rets .= "<postfield name=\"page\" value=\"$(pg)\"/>";
    $rets .= "</go></anchor><br/>";
    echo $rets;
    }else{
    $rets = "<form action=\"index.php\" method=\"get\">";
    $rets .= "Jump (0-$pages/$page)<br/><input name=\"page\" style=\"-wap-input-format: '*N'\" size=\"2\"/>";
    $rets .= "<input type=\"hidden\" name=\"action\" value=\"$action\">";
    $rets .= "<input type=\"hidden\" name=\"sid\" value=\"$sid\">";
    $rets .= "<input type=\"hidden\" name=\"script\" value=\"$script\">";
    $rets .= "<input type=\"Submit\" name=\"Submit\" Value=\"goto page\"></form>";
    echo $rets;
    }
    echo "<br/>";
    }
    echo "<br/>Directory: $file_count ";
    if ($file_count == 1)
    {echo "file";}
    else
    {echo "files";}
    }
    
    echo "<br/>";
    if((strpos(strtoupper($HTTP_ACCEPT),"VND.WAP.XHTML+XML") > 0)||(
    strpos(strtoupper($HTTP_ACCEPT),"XHTML+XML") > 0)||($ubr=="Mozilla"))
    {
    echo "<a href=\"index.php?action=upload&amp;sid=$sid&amp;script=xhtml&amp;prevscript=$script\">Upload</a><br/>";
    }
    if(isowner(getuid_sid($sid)))
    {
    if($script=="wml")
    {
    
    echo "<a href=\"../ownercp.php?action=addsml2&amp;sid=$sid\">Link Smilies into site</a><br/>";
    }else{
    echo "<a href=\"../ownercp.php?action=addsml2&amp;sid=$sid\">Link Smilies into site</a><br/>";
    }
    echo "<a href=\"index.php?action=upload&amp;sid=$sid\">Upload smilies</a><br/>";
    }
    closedir($dp);
    if($script=="wml"){
    echo "<a href=\"../index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    echo "</p>";
    echo "</card>";
    }else{
    echo "<b>0 </b><a accesskey=\"0\" href=\"../index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    echo "</center>";
    echo "</body>";
    }
    }
    /////////////////////////////upload//////////////////////////////
    
    else if($action=="upload")
    {
    if((isowner(getuid_sid($sid)))||(isheadadmin(getuid_sid($sid))))
    {
    $script2 = $_GET["prevscript"];
    addonline(getuid_sid($sid),"Uploading Smilies","");
    if($script=="wml"){
    echo "<card id=\"main\" title=\"Gallery Pics\">";
    }else{
    echo "<head>";
    echo "<title>Upload Smilie</title>";
    echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
    echo "</head>";
    echo "<body>";
    }
    echo "<p align=\"center\">";
    echo "<u><i><b>Upload</b></i></u><br/>";
    echo "Image Files<br/>";
    $size_bytes = 2048000;
    $kb = $size_bytes / 1024;
    $mb = $kb / 1024;
    echo "Max <b>$mb</b> Mb<br/>";
    if($script=="wml"){
    echo "<img src=\"../images/point.gif\" alt=\"!\"/>Browser not compatible wif xhtml uploader";
    }else{
    echo "<form method=\"post\" enctype=\"multipart/form-data\" action=\"index.php?action=upload&amp;sid=$sid&amp;upload=add&amp;script=$script&amp;prevscript=$script2\">";
    echo "<input type=\"file\" name=\"filetoupload\"><br>";
    echo "<input type=\"Submit\" name=\"uploadform\" value=\"Upload\">";
    echo "</form>";
    }
    $upload_dir = "./";
    $filename = $_FILES['filetoupload']['name'];
    $size = $_FILES['filetoupload']['size'];
    $extlimit = "yes";
    $limitedext = array(".jpeg",".jpg",".JPEG",".JPG",".gif",".GIF",".png",".PNG");
    $ext = strrchr($_FILES['filetoupload'][name],'.');
    
    if($upload=="add"){
    if (!is_uploaded_file($_FILES['filetoupload']['tmp_name']))
    {
    echo "<img src=\"../images/notok.gif\" alt=\"(error)\"/>No file selected!<br/>";
    echo "<br/>";
    echo "<a href=\"index.php?action=smilies&amp;sid=$sid&amp;script=$script2\">Back</a><br/>";
    if($script2=="wml"){
    echo "<a href=\"../index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }else{
    echo "<b>0 </b><a accesskey=\"0\" href=\"../web/index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }
    echo "</p>";
    if($script=="wml"){
    echo "</card>";
    }else{
    echo "</body>";
    }
    exit();
    }
    
    if (($extlimit == "yes") && (!in_array($ext,$limitedext)))
    {
    echo("<img src=\"../images/notok.gif\" alt=\"(error)\"/>Invalid file type!<br/>");
    echo "<br/>";
    echo "<a href=\"index.php?action=smilies&amp;sid=$sid&amp;script=$script2\">Back</a><br/>";
    if($script2=="wml"){
    echo "<a href=\"../index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }else{
    echo "<b>0 </b><a accesskey=\"0\" href=\"../web/index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }
    echo "</p>";
    if($script=="wml"){
    echo "</card>";
    }else{
    echo "</body>";
    }
    exit();
    }
    
    if ($size > $size_bytes)
    {
    echo "<img src=\"../images/notok.gif\" alt=\"(error)\"/>Exceeded File size limit! Maximum <b>$kb</b> Kb.<br/>";
    echo "<br/>";
    echo "<a href=\"index.php?action=smilies&amp;sid=$sid&amp;script=$script2\">Back</a><br/>";
    if($script2=="wml"){
    echo "<a href=\"../wap/index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }else{
    echo "<b>0 </b><a accesskey=\"0\" href=\"../web/index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }
    echo "</p>";
    if($script=="wml"){
    echo "</card>";
    }else{
    echo "</body>";
    }
    exit();
    }
    
    if (file_exists("$upload_dir/$filename")) 
    {
    echo("<img src=\"../images/notok.gif\" alt=\"(error)\"/>Filename already exists!<br/>");
    echo "<br/>";
    echo "<a href=\"index.php?action=smilies&amp;sid=$sid&amp;script=$script2\">Back</a><br/>";
    if($script2=="wml"){
    echo "<a href=\"../wap/index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }else{
    echo "<b>0 </b><a accesskey=\"0\" href=\"../web/index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }
    echo "</p>";
    if($script=="wml"){
    echo "</card>";
    }else{
    echo "</body>";
    }
    exit();
    }
    if(move_uploaded_file ($_FILES['filetoupload']['tmp_name'], "../smilies/$filename")){;
    
    echo "<img src=\"../images/ok.gif\" alt=\":o)\"/>$filename sucessfully uploaded!<br/>";
    echo "<br/>";
    if(isowner(getuid_sid($sid)))
    {
    if($script2=="wml")
    {
    echo "<a href=\"../ownercp.php?action=addsml&amp;sid=$sid\">Add Smilies into site</a><br/>";
    }else{
    echo "<a href=\"../ownercp.php?action=addsml&amp;sid=$sid\">Add Smilies into site</a><br/>";
    }
    }
    echo "<a href=\"index.php?action=smilies&amp;sid=$sid&amp;script=$script2\">Back</a><br/>";
    if($script2=="wml"){
    echo "<a href=\"../index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }else{
    echo "<b>0 </b><a accesskey=\"0\" href=\"../index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }
    echo "</p>";
    if($script=="wml"){
    echo "</card>";
    }else{
    echo "</body>";
    }
    exit();
    }
    else
    {
    echo "<img src=\"../images/notok.gif\" alt=\"(error)\"/>Unknown error! Pls try again...<br/>";
    echo "<br/>";
    echo "<a href=\"index.php?action=smilies&amp;sid=$sid&amp;script=$script2\">Back</a><br/>";
    if($script2=="wml"){
    echo "<a href=\"../index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }else{
    echo "<b>0 </b><a accesskey=\"0\" href=\"../web/index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }
    echo "</p>";
    if($script=="wml"){
    echo "</card>";
    }else{
    echo "</body>";
    }
    exit();
    }
    }
    echo "<br/>";
    echo "<a href=\"index.php?action=smilies&amp;sid=$sid&amp;script=$script2\">Back</a><br/>";
    if($script2=="wml"){
    echo "<a href=\"../index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }else{
    echo "<b>0 </b><a accesskey=\"0\" href=\"../index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }
    echo "</p>";
    if($script=="wml"){
    echo "</card>";
    }else{
    echo "</body>";
    }
    }else{
    $script2 = $_GET["prevscript"];
    addonline(getuid_sid($sid),"Uploading Smilie","");
    if($script=="wml"){
    echo "<card id=\"main\" title=\"Gallery Pics\">";
    }else{
    echo "<head>";
    echo "<title>Upload Smilie</title>";
    echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
    echo "</head>";
    echo "<body>";
    }
    echo "i dont no how u got in here  but there nothing to show...<br/><br/>";
    echo "<a href=\"index.php?action=smilies&amp;sid=$sid&amp;script=$script2\">Back</a><br/>";
    if($script2=="wml"){
    echo "<a href=\"../index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }else{
    echo "<b>0 </b><a accesskey=\"0\" href=\"../index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }
    if($script=="wml"){
    echo "</card>";
    }else{
    echo "</body>";
    }
    }
    }
    how can i make the smilies to show its image and name and in the upload when uploading image u will have option to add the smilie code in there also while uploading it -smile-
    Last edited by riderz; 23.07.09, 11:47.

    #2
    who can get the rest of this code fixed up please it can upload say file uploaded but when look at the smilie it dnt show
    Code:
    else if($action=="addsml")
    {$pstyle = gettheme($sid);
        echo xhtmlhead("$stitle",$pstyle);
        boxstart("Smilies");
        echo "<p align=\"center\">";
        echo "<b>Add Smilies</b><br/><br/>";
        echo "<form action=\"admproc.php?action=addsml&amp;sid=$sid\" method=\"post\">";
        echo "Code:<input name=\"smlcde\" maxlength=\"30\"/><br/>";
        //echo "Image Source:<input name=\"smlsrc\" maxlength=\"200\"/><br/>";
    echo "<form method=\"post\" enctype=\"multipart/form-data\">";
    echo "<input type=\"file\" name=\"filetoupload\"><br>";
    echo "<input type=\"Submit\" name=\"uploadform\" value=\"Upload\">";
    echo "</form>";
    
    //echo "<a href=\"smilies/index.php?action=upload&amp;sid=$sid&amp;script=xhtml&amp;prevscript=$script\">Upload</a><br/>";
        echo "<br/><br/><a href=\"index.php?action=admincp&amp;sid=$sid\"><img src=\"images/admn.gif\" alt=\"*\"/>";
      echo "Admin CP</a><br/>";
      echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>";
      echo "Home</a>";
      echo "</p>";
        echo "</body>";
        }
    i dnt know where to add this code
    Code:
    $upload_dir = "./";
    $filename = $_FILES['filetoupload']['name'];
    $size = $_FILES['filetoupload']['size'];
    $extlimit = "yes";
    $limitedext = array(".jpeg",".jpg",".JPEG",".JPG",".gif",".GIF",".png",".PNG");
    $ext = strrchr($_FILES['filetoupload'][name],'.');
    
    if($upload=="add"){
    if (!is_uploaded_file($_FILES['filetoupload']['tmp_name']))
    {
    echo "<img src=\"../images/notok.gif\" alt=\"(error)\"/>No file selected!<br/>";
    echo "<br/>";
    echo "<a href=\"index.php?action=smilies&amp;sid=$sid&amp;script=$script2\">Back</a><br/>";
    if($script2=="wml"){
    echo "<a href=\"../index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }else{

    Comment

    Working...
    X