Help me -URGENT !!!!

Discussion in 'PHP' started by hormoz, Apr 20, 2008.

  1. #1
    hi guys

    i want to have a text field to enter some links (each link in one line) like this :

    http://rs107.rapidshare.com/files/107819707/dl/Ashampoo_Photo_Commander_abu137_.rar
    Code (markup):
    then when i click submit button i want to get it converted to :

    http://mysite.com/rs107/107819707/dl/Ashampoo_Photo_Commander_abu137_.rar
    Code (markup):

    anyone helps me to write my script will get a method to upload from RS to RS (pm me to help me in other parts of script and get it)
     
    hormoz, Apr 20, 2008 IP
  2. Student Gamers

    Student Gamers Banned

    Messages:
    47
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <?php
    $url = 'http://rs107.rapidshare.com/files/107819707/dl/Ashampoo_Photo_Commander_abu137_.rar';
    
    $firstSplit = explode("/", $url);
    
    $secondSplit = explode(".", $firstSplit[2]);
    
    $newUrl = 'http://mysite.com/'.$secondSplit[0].'/'.$firstSplit[4].'/dl/'.$firstSplit[6];
    
    echo $newUrl;
    ?>
    PHP:
    That *should* work unless I got some counting wrong in the arrays. As for the text field to post it if you haven't written that let me know and I will try and whip something up for that. If you have just change this:

    <?php
    $url = $_POST['url'];
    ?>
    PHP:
    Ok, this way may be a tad messy but I am not too great with PREG_REPLACE terms, when someone posts a new version it will probably be faster. But this is a quick temp. fix.
     
    Student Gamers, Apr 20, 2008 IP
  3. hormoz

    hormoz Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks for your help

    and i didn't write the text field

    and i dont know how to set it to one link per line ;)
     
    hormoz, Apr 20, 2008 IP
  4. hormoz

    hormoz Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ok i wrote my text field ,

    this is the index.php :

    <label>
    <form id="url" name="url" method="post" action="save.php"  $_POST['url']>
      <label>
      <textarea name="url" cols="100" rows="20"  ></textarea>
      </label>
      <p>
        <label>
        <input type="submit" name="Submit" value="Submit" />
        </label>
      </p>
    </form>
    
    Code (markup):
    and posts link to save.php :

    <?php
    $url = $_POST['url'];
    
    $firstSplit = explode("/", $url);
    
    $secondSplit = explode(".", $firstSplit[2]);
    
    $newUrl = 'http://mysite.com/'.$secondSplit[0].'/'.$firstSplit[4].'/dl/'.$firstSplit[6];
    
    echo $newUrl;
    ?>
    Code (markup):
    but the problem is : how to make it support MULTIPLE LINK converts ? :-?
     
    hormoz, Apr 20, 2008 IP
  5. hormoz

    hormoz Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    anyone ? :(
     
    hormoz, Apr 20, 2008 IP
  6. hormoz

    hormoz Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    please help me :((
     
    hormoz, Apr 21, 2008 IP
  7. xrvel

    xrvel Notable Member

    Messages:
    918
    Likes Received:
    30
    Best Answers:
    2
    Trophy Points:
    225
    #7
    My question is does the previous code work correctly for single-line input ? (i haven't tested it)

    If it does, here's your code :)
    and posts link to save.php :

    
    <?php
    $url = $_POST['url'];
    
    if ($url != '') {
    
        $lines = array();
    
        if (preg_match("/\n/", $url)) {// if multi lines
            $lines = explode("\n", $url);// separate each line
        } else {
            $lines[] = $url;
        }
    
        // Let's loop between line
        foreach ($lines as $line) {
            $line = trim($line);
            if ($line != '') {
                $firstSplit = explode("/", $line);
                $secondSplit = explode(".", $firstSplit[2]);
                $newUrl = 'http://mysite.com/'.$secondSplit[0].'/'.$firstSplit[4].'/dl/'.$firstSplit[6];
                echo $newUrl . '<br />';
            }
        }
    }
    ?>
    
    PHP:
     
    xrvel, Apr 21, 2008 IP
  8. hormoz

    hormoz Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    thanks to all friends

    i wrote my script successfully

    @ Student Gamers & xrvel : if you want to know how to remote upload from rs to rs pm me , i'll give you instructions,
     
    hormoz, Apr 21, 2008 IP