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)
<?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.
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
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 ? :-?
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:
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,