Removed string generation functions from this file, and instead included the file that contains them

php
Aadhavan Srinivasan 1 year ago
parent 3bce00440e
commit 1ecf347694

@ -1,33 +1,7 @@
<?php <?php
session_start(); session_start();
require_once 'db.inc.php'; require_once 'db.inc.php';
require_once 'rand_string.inc.php';
function gen_base62_rand_shortlink($len) {
$rand_bytes = random_bytes(intval(($len * 2) / 3));
$rand_string = base64_encode($rand_bytes);
$rand_string = str_replace("+","",$rand_string);
$rand_string = str_replace("/","",$rand_string);
$rand_string = str_replace("=","",$rand_string);
if (mb_strlen($rand_string) < $len) {
$curlen = mb_strlen($rand_string);
$rand_string = $rand_string . gen_rand_shortlink($len - $curlen);
}
return $rand_string;
}
function gen_rand_shortlink($len) {
$to_return = '';
$possible_chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
while (mb_strlen($to_return) < $len) {
$to_return = $to_return . $possible_chars[rand(0, mb_strlen($possible_chars)-1)];
}
return $to_return;
}
ini_set('display_errors', 1); ini_set('display_errors', 1);

Loading…
Cancel
Save