UPLOAD problem LAVALAIR pls help me.

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

    UPLOAD problem LAVALAIR pls help me.

    i have a script of a modified lavalair script.. but my problem is about uploading files on my host server.. my host is only freehosting. // on my localhost(PC)>> XAMMP.. it is working.. the files go to the directory when i upload the file.. but on my host.. the script running successfully.. but the file did not copy or place on the directory.. i think because i have a problem with the FTP on my script.. im going to give you the script of mine..




    <?php
    include("../web/core.php");
    include("../web/config.php");
    connectdb();
    $uip = getip();
    $action = $_GET["action"];
    $sid = $_GET["sid"];
    $page = $_GET["page"];
    $who = $_GET["who"];
    $uid = getuid_sid($sid);
    $sid = $_GET["sid"];
    $site = $_GET["site"];
    $theme = mysql_fetch_array(mysql_query("SELECT theme FROM ibwf_users WHERE id='".$uid."'"));
    $sitename = mysql_fetch_array(mysql_query("SELECT value FROM ibwf_settings WHERE name='sitename'"));
    $sitename = $sitename[0];

    echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html"/>
    <meta http-equiv="Cache-Control" content="no-cache" forua="true"/>';
    echo "<title>$sitename Upload Files</title>";
    echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
    echo "</head>";
    echo "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#0000FF\" vlink=\"#800080\">";

    if ($upload="upload"&&$superdat_name){

    if (!eregi("\.(mid|zip|bmp|mid|midi|3gp|mp3|wav|jar|j ad|nth|rar|sis|mmf|amr|sisx|txt)$",$superdat_name) ){
    print "<b>Unsupported File Extention!</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>";
    }else{
    copy($connection,$superdat,"files/$superdat_name",FTP_BINARY) or
    die("Couldn't copy file.");
    $date=(date("D, j F Y"));
    $fsize=round($superdat_size/1024,1);
    $text = "&&$superdat_name&&$fsize KB&&$date&&$REMOTE_ADDR&&";
    $fz = "$fsize KB";
    if("$text"!="$check[1]"){
    $mysql=mysql_query("INSERT INTO ibwf_uploads SET id='', uid='".$uid."', filename='".$superdat_name."', filesize='".$fsize." KB', date='".$date."', uip='".$REMOTE_ADDR."'");
    echo mysql_error();
    }
    echo "<b>$superdat_name</b> Has Been Successfully Uploaded";
    }
    }
    }
    }
    ?>
    <?php
    echo "<FORM align=\"center\" ACTION=\"upload.php?sid=$sid&amp;site=$site\" METHOD=\"POST\" ENCTYPE=\"multipart/form-data\">";
    ?>
    <b>Select File :</b><br/>
    <input align="center" type="file" name="superdat"><br/>
    <input align="center" type="hidden" name="upload" value="upload"/>
    <INPUT align="center" TYPE=SUBMIT NAME="submit" VALUE="Upload File!"><br/><br/></small><br/> <b><u>Allowed Extensions:</u></b><br/>
    .sisx, .nth, .mid, .midi, .mpg, .mmf, .amr, .mp3, .wav, .wmv , .avi, .3gp, .sis, .jar, .jad, .zip, .rar, .txt<br/>
    ----------
    <?php echo "<br/><small><a href=\"index.php?sid=$sid&amp;site=$site\">Filesha ring Menu</a></small>"; ?>
    </FORM>
    <?php

    if($site=="wap"){
    echo "<br/><br/><a href=\"../wap/index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }else{
    echo "<br/><br/><a href=\"../web/index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    }
    ?>
    </body>
    </html>













    this is the FTP script on core..


    function FtpUpload($dest_file, $src_file){

    // set up basic connection



    $server= "server"; // ftp server

    $connection = ftp_connect($server); // connection



    // login to ftp server

    $user = "user";

    $pass = "pass";

    $result = ftp_login($connection, $user, $pass);

    // check connection

    if ((!$connection) || (!$result)) {

    echo "FTP connection has failed!";

    echo "Attempted to connect to $ftp_server for user $ftp_user_name";

    exit;

    }

    // upload the file

    $upload = ftp_put($connection, $dest_file, $src_file, FTP_BINARY);



    // check upload status

    if (!$upload) {

    echo "FTP upload has failed!";

    }


    // close the FTP stream

    ftp_close($connection);

    }





    i tried to set the server user and password..depend on my FTP server.. but nothings happen..
    look at the script of the UPLOAD.php there is no FTP script where you can see @ core.php

    plss help me. what is the problem.. huhuh

    #2
    i hope you have chmod 777 to upload folder
    Follow me @ksg91 | My Blog: http://ksg91.com | Nokia Blog: http://NokiaTips.in

    Comment


      #3
      Not Only Upload problem, you ll get sql injection problem soon. your codes are full of Bugs. Fix them.. ;)

      Comment


        #4
        i know that my script is not yet sanitize.. but im focusing on my problem.. on how to upload files.. somebody help me plss

        Comment


          #5
          globals are turned off so you will need to collect your data:
          PHP Code:
          $superdat $_FILES['superdat']['tmp_name'];
          $superdat_name=$_FILES['superdat']['name'];
          $superdat_size=$_FILES['superdat']['size']; 
          MAKE SURE YOU SECURE YOUR UPLOADER!!!!


          also advice:

          this can be shortened lots:
          PHP Code:
          <?php echo "<br/><small><a href=\"index.php?sid=$sid&amp;site=$site\">Filesha ring Menu</a></small>"?>
          </FORM>
          <?php

          if($site=="wap"){
          echo 
          "<br/><br/><a href=\"../wap/index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
          }else{
          echo 
          "<br/><br/><a href=\"../web/index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
          }
          ?>
          to something like:
          PHP Code:
          <br/><small><a href="index.php?sid=<?=$sid?>&amp;site=<?=$site?>">Filesha ring Menu</a></small>
          </FORM>
          <br/><br/><a href="http://coding-talk.com/<?=$site?>/index.php?action=main&amp;sid=<?=$sid?>"><img src="http://coding-talk.com/images/home.gif" alt=""/>Home</a>

          Comment

          Working...
          X