Closed Thread
Results 1 to 6 of 6

Thread: PHP Help (loop) 10 Points

  1. #1
    Josh is offline Uber No0b Josh is an unknown quantity at this point
    Join Date
    Jan 2005
    Posts
    197

    PHP Help (loop) 10 Points

    Alright, I have this php script that helps me copy files to my server and I need help modding it so I can input a number of times to grab the file from another server (ex 15 times). If this can't be done, just make an infinite loop. This is to make many copies of the same file on the server. I believe this has something to do with php loops, although I have no PHP experience so this is just a guess. I realize there are other ways to do this, but I would like it this way.


    edit: offering 20 points instead.

    15 points to the person who can do this.

    This is the PHP code:

    PHP Code:
    <?

    C
    :\htdocs\FOLDER (Windows)
    $defaultDest "/ho/";
    $password "";

    // Operating System your SERVER Uses
    //1 for Linux. 2 for Windows.
    //I'm not sure but I think most Operating Systems other then Windows will use 1.
    $os "1";

    //////////////////////////////////////////////
    //Do Not Change Below Here////////////////////
    //////////////////////////////////////////////

    echo "<form method=\"POST\" action=\"$PHP_SELF\">";
    echo 
    "<fieldset>\n<legend>Image Upload</legend>\n";
    echo 
    "<label for=\"file\">Full path to file to copy</label><br>";
    echo 
    "Example: http://www.google.ca/intl/en_ca/images/logo.gif<br>";
    echo 
    "<input type=\"text\" name=\"file\" id=\"file\" size=\"35\" tabindex=\"1\" value=\"\"><br>";
    echo 
    "<label for=\"new\">New file name</label><br>";
    echo 
    "Example: google.gif<br>";
    echo 
    "<input type=\"text\" name=\"new\" id=\"new\" size=\"35\" tabindex=\"2\" value=\"\"><br>";
    if (
    $password) {
        echo 
    "<label for=\"password\">Password</label><br>";
        echo 
    "<input type=\"password\" name=\"password\" id=\"password\" size=\"35\" tabindex=\"3\" value=\"\"><br>";
    }
    echo 
    "<p><input name=\"submit\" type=\"submit\" id=\"submit\" value=\"submit\"></p>";
    echo 
    "</fieldset>\n</form>";

    $submit $_POST['submit'];
    if(
    $submit) {
    if(
    $password) {
        if (
    $_POST['password']!=$password) {
            echo 
    "Password incorrect!";
            } else {
            
    $access "09023578353";
            }
            } else {
    $access "09023578353";
    }


    if(
    $access=="09023578353") {

    if(
    $os==2) {
        
    $slash="\\";
    } else {
        
    $slash="/";
    }

    $file $_POST['file'];
    $newfilename $_POST['new'];

    if(
    $_POST['otherdest']) {
        
    $dest $_GET['otherdest'];
    } else {
        
    $dest $defaultDest;
    }

    $ds = array($dest$slash$newfilename);
    $ds implode(""$ds);

    if (
    file_exists($ds)) {
        echo 
    "File already exists! <br>\n Adding random digits to beginning of filename. <br>\n";
        
    $ds = array($dest$slashrand(0,9999), $newfilename);
        
    $ds implode(""$ds);
    }

    echo 
    "New destination $ds <br>\n";
    if (!
    copy($file$ds)) {
        echo 
    "Was unable to copy $file <br>\n See if your path and destination are correct. \n";
    } else {
        echo 
    "<strong>Copy successful!</strong> \n";
    }
    }
    }

    ?>
    Last edited by Josh; 04-28-2006 at 07:37 PM.

  2. #2
    Josh is offline Uber No0b Josh is an unknown quantity at this point
    Join Date
    Jan 2005
    Posts
    197

    Re: PHP Help (loop) 10 Points

    Anyone? 25 Points?

  3. #3
    Chris Z's Avatar
    Chris Z is offline x10 Spammer Chris Z is an unknown quantity at this point
    Join Date
    Sep 2005
    Location
    Alabama, USA
    Posts
    2,802

    Re: PHP Help (loop) 10 Points

    i believe you will get maybe like 1/4 of a script with 25 points, that's not even close to reasonable for this sort of job

  4. #4
    Josh is offline Uber No0b Josh is an unknown quantity at this point
    Join Date
    Jan 2005
    Posts
    197

    Re: PHP Help (loop) 10 Points

    Ok 180 points then, Its been a while since I was on the forums, a lot has changed since. 25 points used to be good amount of points.
    Last edited by Josh; 04-30-2006 at 09:37 PM.

  5. #5
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

    Re: PHP Help (loop) 10 Points

    I have no idea if this works

    PHP Code:
    <?

    C
    :htdocsFOLDER (Windows)
    $defaultDest "/ho/";
    $password "";

    // Operating System your SERVER Uses
    //1 for Linux. 2 for Windows.
    //I'm not sure but I think most Operating Systems other then Windows will use 1.
    $os "1";

    //////////////////////////////////////////////
    //Do Not Change Below Here////////////////////
    //////////////////////////////////////////////

    echo "<form method=\"POST\" action=\"$PHP_SELF\">";
    echo 
    "<fieldset>\n<legend>Image Upload</legend>\n";
    echo 
    "<label for=\"file\">Full path to file to copy</label><br>";
    echo 
    "Example: http://www.google.ca/intl/en_ca/images/logo.gif<br>";
    echo 
    "<input type=\"text\" name=\"file\" id=\"file\" size=\"35\" tabindex=\"1\" value=\"\"><br>";
    echo 
    "<label for=\"new\">New file name</label><br>";
    echo 
    "Example: google.gif<br>";
    echo 
    "<input type=\"text\" name=\"new\" id=\"new\" size=\"35\" tabindex=\"2\" value=\"\"><br>";
    echo 
    "Upload Files x number of times.<input type=\"text\" name=\"times\" id=\"times\" size=\"3\" tabindex=\"2\" value=\"\"><br>";
    if (
    $password) {
        echo 
    "<label for=\"password\">Password</label><br>";
        echo 
    "<input type=\"password\" name=\"password\" id=\"password\" size=\"35\" tabindex=\"3\" value=\"\"><br>";
    }
    echo 
    "<p><input name=\"submit\" type=\"submit\" id=\"submit\" value=\"submit\"></p>";
    echo 
    "</fieldset>\n</form>";

    $submit $_POST['submit'];
    if(
    $submit) {
    if(
    $password) {
        if (
    $_POST['password']!=$password) {
            echo 
    "Password incorrect!";
            } else {
            
    $access "09023578353";
            }
            } else {
    $access "09023578353";
    }


    if(
    $access=="09023578353") {

    if(
    $os==2) {
        
    $slash="\\";
    } else {
        
    $slash="/";
    }

    $number $_PST['times'];
    $file $_POST['file'];
    $newfilename $_POST['new'];

    $num '0';

    if ((
    $num) != $number){
    if(
    $_POST['otherdest']) {
        
    $dest $_GET['otherdest'];
    } else {
        
    $dest $defaultDest;
    }

    $ds = array($dest$slash$newfilename);
    $ds implode(""$ds);

    if (
    file_exists($ds)) {
        echo 
    "File already exists! <br>\n Adding random digits to beginning of filename. <br>\n";
        
    $ds = array($dest$slashrand(0,9999), $newfilename);
        
    $ds implode(""$ds);
    }

    echo 
    "New destination $ds <br>\n";
    if (!
    copy($file$ds)) {
        echo 
    "Was unable to copy $file <br>\n See if your path and destination are correct. \n";
    } else {
        echo 
    "<strong>Copy successful!</strong> \n";
    $num ++;
    }
    }
    }
    }

    ?>
    it should, but I am at school where there is no server to test it on

    if it errors on line 80 or so find this

    PHP Code:
    $num ++; 
    and replace with
    PHP Code:
    $num++; 

    I would love to change the world, but they won't give me the source code

  6. #6
    Josh is offline Uber No0b Josh is an unknown quantity at this point
    Join Date
    Jan 2005
    Posts
    197

    Re: PHP Help (loop) 10 Points

    there aren't any errors, but the loop isn't working. It only grabs the file once, no matter how many numbers I put in.

Closed Thread

Similar Threads

  1. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  2. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  3. PHP Coding For Points
    By [TX]-Ghost in forum The Marketplace
    Replies: 3
    Last Post: 11-26-2007, 09:22 AM
  4. [req] Points System On Php Nuke Bhpbb
    By Mani5 in forum The Marketplace
    Replies: 0
    Last Post: 12-21-2005, 11:57 PM
  5. [REQ] phpnuke/postnuke module or php script 100+ points
    By 03moscropl in forum The Marketplace
    Replies: 5
    Last Post: 09-30-2005, 10:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers