PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, ]; try { $pdo = new PDO($dsn, $mysql_username, $mysql_password, $options); $pdo->exec("use " . $mysql_db); } catch (PDOException $e) { die($e->getMessage() . " " . (int) $e->getCode()); } while (true) { $id = random_str($char_per_id); $deleteId = random_str($char_per_deleteId); while ( $id == "index" || $id == "shorten" || $id == "delete" || $id == "report" || $id == "reported" ) { $id = random_str($char_per_id); $deleteId = random_str($char_per_deleteId); } $req = $pdo->prepare( "select * from " . $mysql_table . " where id = ?" ); $req->execute([$id]); $getId = $req->fetch(); $req = $pdo->prepare( "select * from " . $mysql_table . " where deleteId = ?" ); $req->execute([$deleteId]); $getdeleteId = $req->fetch(); if ( !isset($getId["original"]) || !isset($getdeleteId["original"]) ) { break; } } $req = $pdo->prepare( "insert into " . $mysql_table . " (id, original, deleteId, time) values (?, ?, ?, ?)" ); $req->execute([$id, $link, $deleteId, time()]); $req = $pdo->prepare("select * from " . $mysql_table . " where id = ?"); $req->execute([$id]); $row = $req->fetch(); if (!isset($row["original"])) { $pagename = "An unknown error has occurred"; include_once $_SERVER["DOCUMENT_ROOT"] . "/assets/includes/header.php"; ?>

__("Oh no..."); ?>

__("An unknown error has occurred."); ?>

__("Return to the homepage"); ?>

__("Your link has been successfully shortened"); ?>

__("Thank you for your trust."); ?>

__("Shortened link"); ?>
" readonly>
__("Deletion link"); ?>
" data-toggle="popover" data-placement="bottom" data-content="__("Keep this deletion link in case you want to delete your shortened link in the future.") ?>" data-trigger="hover" readonly>
__("Return to the homepage"); ?>

__("Oh no..."); ?>

__( "The link you want to shorten is invalid." ); ?>

__("Return to the homepage"); ?>