From 9a63d1abed608ecce689fa4e7409c498c8d827ff Mon Sep 17 00:00:00 2001 From: Horus3 Date: Wed, 12 Mar 2014 17:21:06 +0100 Subject: regex for detecting hyperlinks --- www/upload.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'www/upload.php') diff --git a/www/upload.php b/www/upload.php index ed25d85..5c3f758 100644 --- a/www/upload.php +++ b/www/upload.php @@ -110,4 +110,12 @@ function upload($db){ } } +function web_upload($db){ + $url = ; + if(preg_match("/^((https?|ftp)?://|www\.|ftp\.)?([-a-z0-9+&@#/%?=~_|!:,.;]+\.)+[a-z]{2}[a-z]*/i", $url)){ + echo "hyperlink detected"; + } else { + echo "no hyperlink"; + } +} upload($db); -- cgit v1.2.3 From 11f7f219b72c909cdbf74426e5095d9ee3ef8ec8 Mon Sep 17 00:00:00 2001 From: Horus3 Date: Wed, 12 Mar 2014 19:32:07 +0100 Subject: fixed PHP's bug with empty() --- www/upload.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'www/upload.php') diff --git a/www/upload.php b/www/upload.php index 5c3f758..2858e72 100644 --- a/www/upload.php +++ b/www/upload.php @@ -67,7 +67,8 @@ function upload($db){ $filehash = hash_file("md5", $_FILES['userfile']['tmp_name']); $hashtest_db = $db->query("SELECT hash FROM files WHERE hash='" . $filehash ."';"); - if(empty($hashtest_db)){ + $hashtest_ar = $hashtest_ar->fetchArray(SQLITE3_NUM); + if(empty($hashtest_ar)){ if(move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $_FILES['userfile']['name'])){ @@ -110,7 +111,7 @@ function upload($db){ } } -function web_upload($db){ +function web_upload($db){ // no use atm $url = ; if(preg_match("/^((https?|ftp)?://|www\.|ftp\.)?([-a-z0-9+&@#/%?=~_|!:,.;]+\.)+[a-z]{2}[a-z]*/i", $url)){ echo "hyperlink detected"; -- cgit v1.2.3