summaryrefslogtreecommitdiffstats
path: root/index.php
diff options
context:
space:
mode:
authorAnton Luka Šijanec <sijanecantonluka@gmail.com>2020-10-03 18:17:16 +0200
committerGitHub <noreply@github.com>2020-10-03 18:17:16 +0200
commit43806e2bdda2a6c2f73a294cda2661c903724ac6 (patch)
treec52afab49c855db1721ceb33f439ae5fb74d7fcb /index.php
parentɔopyleft (diff)
downloadbalkan-shortlink-43806e2bdda2a6c2f73a294cda2661c903724ac6.tar
balkan-shortlink-43806e2bdda2a6c2f73a294cda2661c903724ac6.tar.gz
balkan-shortlink-43806e2bdda2a6c2f73a294cda2661c903724ac6.tar.bz2
balkan-shortlink-43806e2bdda2a6c2f73a294cda2661c903724ac6.tar.lz
balkan-shortlink-43806e2bdda2a6c2f73a294cda2661c903724ac6.tar.xz
balkan-shortlink-43806e2bdda2a6c2f73a294cda2661c903724ac6.tar.zst
balkan-shortlink-43806e2bdda2a6c2f73a294cda2661c903724ac6.zip
Diffstat (limited to '')
-rw-r--r--index.php14
1 files changed, 7 insertions, 7 deletions
diff --git a/index.php b/index.php
index 7a65a96..9ed2e2e 100644
--- a/index.php
+++ b/index.php
@@ -27,7 +27,7 @@ $username = "shortlink"; // uporabniško ime za dostop do strežnika SQL
$password = "antoniolukas"; // geslo za dostop do strežnika SQL
$baza = "shortlink"; // podatkovna baza SQL v katero naj pišem - naredi jo pred zagonom programa
$tabela = "links"; // tabela, ki naj jo naredim v podatkovni bazi SQL oziroma tabela v podatkovni bazi SQL, ki naj jo uporabljam
-$maxlength = 9;
+$maxlength = 9; $longurlmaxlen = 4096;
$rxshort = "/^[0-9a-z]{1,".$maxlength."}$/"; // angleško regular expression, ki naj ga uporabim za kratek niz - nujno popravi še besedilne opise. Pusti ga takega, kot je!
$domena = $_SERVER['HTTP_HOST']; // tvoja domena
$delidomene = explode(".", $domena);
@@ -81,10 +81,10 @@ if(in_array(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2), ['sl', 'hr', 'sr', '
<span class=closebtn onclick=this.parentElement.style.display='none';>&times;</span>
<b>Napaka vnosa!</b> Dolg URL se ne ujema z standardi. Poskusite ponovno. Posebni znaki v URL-ju (kot na primer š) morajo biti URL kodirani.
</div><br>";
- $longurl_too_long = "Dolg URL je predolg. Mora biti krajši od 767 bajtov, drugače lahko pride do napak v podatkovni bazi.\n";
+ $longurl_too_long = "Dolg URL je predolg. Mora biti krajši od ".$longurlmaxlen." bajtov, drugače lahko pride do napak v podatkovni bazi.\n";
$longurl_too_long_ui = "<div class=alert>
<span class=closebtn onclick=this.parentElement.style.display='none';>&times;</span>
-<b>Napaka vnosa!</b> URL je predolg. Mora biti krajši od 767 bajtov.
+<b>Napaka vnosa!</b> URL je predolg. Mora biti krajši od ".$longurlmaxlen." bajtov.
</div><br>";
$longurl_not_too_long = "Dolg URL ni predolg. To je v redu.\n";
$shortlink_free_error_ui = "<div class=alert>
@@ -163,10 +163,10 @@ contain lowercase letters and numbers.
<span class=closebtn onclick=this.parentElement.style.display='none';>&times;</span>
<b>Input error!</b> Long URL does not compile with the rules. Try again. Special characters (such as š) have to be URL encoded.
</div><br>";
- $longurl_too_long = "Long URL is too long. It has to be shorter than 767 bytes, otherwise it can come to database errors.\n";
+ $longurl_too_long = "Long URL is too long. It has to be shorter than ".$longurlmaxlen." bytes, otherwise it can come to database errors.\n";
$longurl_too_long_ui = "<div class=alert>
<span class=closebtn onclick=this.parentElement.style.display='none';>&times;</span>
-<b>Input error!</b> URL is too long. It has to be shorter than 767 bytes.
+<b>Input error!</b> URL is too long. It has to be shorter than ".$longurlmaxlen." bytes.
</div><br>";
$longurl_not_too_long = "Dolg URL ni predolg. To je v redu.\n";
$shortlink_free_error_ui = "<div class=alert>
@@ -271,7 +271,7 @@ if($alitabelaobstaja !== FALSE) {
$log .= $tablenotexists;
$sql = 'CREATE TABLE IF NOT EXISTS `'.$tabela.'` ( `short` varchar('.$maxlength.
') COLLATE utf8_unicode_ci NOT NULL,
- `long` text(767) COLLATE utf8_unicode_ci NOT NULL,
+ `long` text('.$longurlmaxlen.') COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`short`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
if (mysqli_query($conn, $sql)) {
@@ -343,7 +343,7 @@ if(filter_var($_REQUEST['long'], FILTER_VALIDATE_URL)) {
// preprecevanje sql prekoračitve
-if(strlen($_REQUEST['long']) > 767) { //strlen pove bajte, mb_strlen pove dolžino niza
+if(strlen($_REQUEST['long']) > $longurlmaxlen) { //strlen pove bajte, mb_strlen pove dolžino niza
$log .= $longurl_too_long;
$nadaljuj = "ne";
$alert .= $longurl_too_long_ui; //drugače lahko pride do napak v SQL bazi podatkov