diff options
author | Chaoyi Zha <summermontreal@gmail.com> | 2015-09-19 04:59:00 +0300 |
---|---|---|
committer | Chaoyi Zha <summermontreal@gmail.com> | 2015-09-19 04:59:00 +0300 |
commit | 64714b8b64653cfc372ba45eedd0cf48fd070725 (patch) | |
tree | 2d292b7c1f6db79143a506dfed9f12bc39a975e6 | |
parent | b914c763783375ce22a2748a1c1a06637ccc3808 (diff) |
Prettify
-rw-r--r-- | createurl.php | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/createurl.php b/createurl.php index f21eb37..b42b73d 100644 --- a/createurl.php +++ b/createurl.php @@ -19,7 +19,7 @@ if ($li_shorten_only == true) { function bve($bv) { global $mysqli; - $query1 = "SELECT `rid` FROM `redirinfo` WHERE baseval='{$bv}'"; // Check if exists natura + $query1 = "SELECT `rid` FROM `redirinfo` WHERE baseval='{$bv}'"; // check if URL exists $result = $mysqli->query($query1); $row = mysqli_fetch_assoc($result); $existing = $row['rid']; @@ -31,26 +31,26 @@ function bve($bv) { } } -if(!strstr($_POST['urlr'], $protocol)) { +if (!strstr($_POST['urlr'], $protocol)) { $urlr = "http".$protocol.trim($_POST['urlr']); //add http:// if :// not there } else { $urlr = trim($_POST['urlr']); } -if(!filterurl($urlr)) { +if (!filterurl($urlr)) { echo "You entered an invalid url<br>"; echo "<a href='index.php'>Back</a>"; die(); } -if($hpi !== $hp) { +if ($hpi !== $hp) { echo "We have detected that you may be using automated methods to shorten links. <br>We offer a free API, please do not use our shorten page as an API.<br>If you are getting this message, but you are not a bot, please email support@polr.cf <br> Thanks."; die(); } function rStr($length = 4) { return substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length); } -if($ps == "s") { +if ($ps == "s") { // if secret url $rstr = rStr(4); } @@ -65,7 +65,6 @@ else { } $urlr = $mysqli->real_escape_string($urlr); -//Other URL Shorteners List Array $isshort = array('polr.me', 'polr.cf','bit.ly','is.gd','tiny.cc','adf.ly','ur1.ca','goo.gl','ow.ly','j.mp','t.co'); @@ -75,7 +74,7 @@ foreach ($isshort as $url_shorteners) { echo "<a href='index.php'>Back</a>"; die(); } -}$query1 = "SELECT `rid`,`lkey` FROM `redirinfo` WHERE `rurl`='{$urlr}' AND iscustom='no';"; // Check if exists naturally +}$query1 = "SELECT `rid`,`lkey` FROM `redirinfo` WHERE `rurl`='{$urlr}' AND iscustom='no';"; // check if URL exists $result = $mysqli->query($query1); $row = mysqli_fetch_assoc($result); $existing = $row['rid']; @@ -86,24 +85,25 @@ $customurl = $mysqli->real_escape_string($_POST['custom']); if($customurl == "") { $iscustom = "no"; } -//check custom url -if($customurl!="") { - if(!ctype_alnum($customurl)) { + +// check if the custom URL ending is allowed +if ($customurl!="") { + if (!ctype_alnum($customurl)) { echo "<b>Symbols or spaces are not allowed in a customized URL - alphanumeric only. <a href='index.php'>Try again</a></b>"; die(); } - if(strlen($customurl)>20) { + if (strlen($customurl)>20) { echo "<b>The maximum length for a custom url is 20 letters. <a href='index.php'>Try again</a></b>"; die(); } } if(!$existing || $customurl!="" || $ps=="s" || $lkey_ex) { - // If does not exist or creating custom URL. If requesting a secret link, recreate as well. + // if URL does not exist, creating custom URL, or requesting a secret link, recreate the URL. $query1 = "SELECT MAX(rid) AS `rid` FROM `redirinfo` WHERE `iscustom`='no';"; $result = $mysqli->query($query1); $row = mysqli_fetch_assoc($result); $ridr = $row['rid']; - // Check if next URL in base32 has been occupied by a custom url + // check if next baseval in base32 has been occupied by a custom url $q_checkbv = "SELECT `baseval` FROM `redirinfo` WHERE `rid`='{$ridr}';"; $perform_cbv = $mysqli->query($q_checkbv); $cbvr = mysqli_fetch_assoc($perform_cbv); @@ -117,28 +117,28 @@ if(!$existing || $customurl!="" || $ps=="s" || $lkey_ex) { } - if($customurl!="") { - // creating custom URL? + if ($customurl!="") { + // if user is creating a custom URL $baseval = $customurl; $iscustom = "yes"; - $query = "SELECT `rid` FROM `redirinfo` WHERE `baseval`='{$customurl}';"; //check if baseval used already + $query = "SELECT `rid` FROM `redirinfo` WHERE `baseval`='{$customurl}';"; // check if baseval is occupied $result = $mysqli->query($query); $row = mysqli_fetch_assoc($result); $custom_existing = $row['rid']; - if($custom_existing) { + if ($custom_existing) { echo "The custom shorturl ending you specified is already in use. <a href='index.php'>Try again</a>"; die(); } } - if($ps == "p" || !$ps) { + if ($ps == "p" || !$ps) { $query2 = "INSERT INTO `redirinfo` (baseval,rurl,ip,user,iscustom,country) VALUES ('{$baseval}','{$urlr}','{$ip}','{$userinfo['username']}','{$iscustom}','{$country_code}');"; } - else if($ps=="s") { + else if ($ps=="s") { $query2 = "INSERT INTO `redirinfo` (baseval,rurl,ip,user,iscustom,lkey,country) VALUES ('{$baseval}','{$urlr}','{$ip}','{$userinfo['username']}','{$iscustom}','{$rstr}','{$country_code}');"; $baseval .= "?".$rstr; } - $result2r = $mysqli->query($query2);// or showerror(); + $result2r = $mysqli->query($query2); $basewsa = base64_encode($wsa); $basebv =base64_encode($baseval); echo "<input type='hidden' value='$basebv' id='j' /><input type='hidden' value='$basewsa' id='k' />"; @@ -146,7 +146,7 @@ if(!$existing || $customurl!="" || $ps=="s" || $lkey_ex) { echo "<div style='text-align:center;padding-left:11%;padding-right:11%;'><h3>URL:</h3> <input type='text' id='i' onselect=\"select_text();\" onclick=\"select_text();\" readonly=\"readonly\" class='form-control' value=\"Please enable Javascript\" />"; } else { - // Already exists. Fetch from DB and send over. + //if already exists, send the previously shortened URL baseval back to the client $query1 = "SELECT `baseval` FROM `redirinfo` WHERE `rurl`='{$urlr}' AND iscustom='no'"; $result = $mysqli->query($query1); $row = mysqli_fetch_assoc($result); @@ -156,7 +156,7 @@ else { echo "<input type='hidden' value='$basebv' id='j' /><input type='hidden' value='$basewsa' id='k' />"; echo $decodescript; echo "<div style='text-align:center;padding-left:11%;padding-right:11%;'><h3>URL:</h3> <input type='text' id='i' onselect=\"select_text();\" onclick=\"select_text();\" readonly=\"readonly\" class='form-control' value=\"Please enable JavaScript\" />"; - } +} echo '<br><a href="index.php" class="btn btn-primary btn-large">Shorten Another Link</a></div><script>function select_text(){var a=document.getElementById("i");a&&(a.focus(),a.select())}window.onload=select_text;</script>'; require_once('layout-footerlg.php'); |