function shortcode_ldjam($atts) { ld_get_vars(); // Populate the $ldvar global // global $ldvar; // Verify URL // if (isset($_GET['u'])) { $url = to_slug($_GET['u']); if ($url !== $_GET['u']) { $_GET['u'] = $url; $link = "//{$_SERVER['HTTP_HOST']}{$_SERVER['REDIRECT_URL']}"; $link = htmlspecialchars($link, ENT_QUOTES, 'UTF-8'); $link .= "?" . http_build_query($_GET); $link = str_replace('%2F', '/', $link); // Replace % code for / with an actual slash // ld_redirect($link); } } $id = null; // Verify ID // if (isset($_GET['i'])) { $id = base_decode(base_fix($_GET['i'])); } // ld_redirect // print_r($_GET); // echo( to_slug($_GET['u']) ); $shimmy = apcu_fetch('shimmy'); echo $_GET['u']; echo " | " . $id; echo " | " . base_encode($id); //print_r($_SERVER); return "<br />I am very important"; }
/** * * @param string $flag */ public function encrypt($flag = false) { $data = $flag ? $this->privateEncrypt() : $this->publicEncrypt(); return base_encode($data); }
<?php require 'main.php'; session_start(); include "con-db.php"; $long_url = mysqli_real_escape_string($con, $_POST['long']); // echo $long_url; $sql = "INSERT into data(long_url) VALUES ('{$long_url}')"; //$result = mysqli_query($con,"SELECT max(id) as max from data"); //$row = mysqli_fetch_array($result,MYSQL_ASSOC); //echo $row['max'] . '\n'; if (mysqli_query($con, $sql)) { // echo "yo"; } else { echo mysqli_error(); } // printf("new id %d.\n",mysqli_insert_id($con)); $inserted_id = mysqli_insert_id($con); // printf("Last inserted record has id %d\n", mysql_insert_id()); $con->close(); $shorten_id = base_encode($inserted_id, $alphabet); echo 'Your shorted url for ' . $long_url . ' is ' . 'http://po.lo/' . $shorten_id; // $decoded_id = base_decode($shorten_id, $alphabet); // echo "<br/>"; // echo $decoded_id; ?>