Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- multiple shorten url's issue
- $url_to_shorten = $_POST[links];
- $ownshuff = $_POST[shuff];
- $theurls = explode("n",$url_to_shorten);
- foreach($theurls as $urlmulti){
- shortcreate($urlmulti,$shuffss,$ownshuff);
- }
- http://www.123.com
- http://www.1234.com
- http://www.1235.com
- http://www.mysite.com/IUo
- http://www.mysite.com/kOl-Hello_Man
- http://www.mysite.com/Rww-Hello_Man
- function shortcreate($url_long, $Suffix, $ownshuf){
- global $db;
- $chars = $Suffix;
- while (!shortisUnique($chars)) {
- if ($ownshuf != "") {
- $chars = shortgenerate_chars() . "-" . $ownshuf;
- }
- else {
- $chars = shortgenerate_chars();
- }
- }
- $url = $url_long;
- $url = trim($url);
- $url = mysql_real_escape_string($url);
- if (!shortisThere($url)) {
- $q = "INSERT INTO `shorturls` (url, unique_chars) VALUES ('" . $url . "', '" . $chars . "')";
- //echo $q;
- $r = $db->query($q);
- if (mysql_affected_rows()):
- $q = "SELECT * FROM `shorturls` WHERE `url`='" . $url . "'";
- $r = $db->query($q);
- $row = $db->fetch($r);
- $the_url = SITE_URL . "" . $row[2];
- echo "$the_urln";
- else:
- $the_url = NULL;
- return false;
- endif;
- }
- else {
- $q = "SELECT * FROM `shorturls` WHERE `url` = '" . $url . "'";
- $r = mysql_query($q);
- $row = mysql_fetch_row($r);
- $the_url = SITE_URL . "" . $row[2];
- echo "$the_urln";
- }
- }
- $chars = $Suffix;
- while (!shortisUnique($chars)) {
- if ($ownshuf != "") {
- $chars = shortgenerate_chars() . "-" . $ownshuf;
- }
- else {
- $chars = shortgenerate_chars();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment