summaryrefslogtreecommitdiff
path: root/www/functions/func_rewrite.php
diff options
context:
space:
mode:
authorHorus32014-03-12 02:50:30 +0100
committerHorus32014-03-12 02:50:30 +0100
commit8970954933ecf4b5c842027faa7c52f85cc25fe2 (patch)
treee502119b624197871550d72d55c2e9a9f2a4f05b /www/functions/func_rewrite.php
parent0148c370ea13ee0469bd67260cf8c9fe9c97677d (diff)
downloadfiles.iamfabulous.de-8970954933ecf4b5c842027faa7c52f85cc25fe2.tar.gz
Structure in functions. Stronger hash algorith for password safety, also pepper.
Diffstat (limited to 'www/functions/func_rewrite.php')
-rw-r--r--www/functions/func_rewrite.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/www/functions/func_rewrite.php b/www/functions/func_rewrite.php
new file mode 100644
index 0000000..5ca2171
--- /dev/null
+++ b/www/functions/func_rewrite.php
@@ -0,0 +1,31 @@
+<?
+function rewrite($db){
+
+ /* test if first argument a username or folder */
+
+ $name = SQLite3::escapeString("$_GET[name]");
+
+ $name_id_db = $db->query("SELECT id FROM user WHERE name='" . $name . "';");
+ $name_id_ar = $name_id_db->fetchArray(SQLITE3_NUM);
+
+ if(empty($name_id_ar)){
+
+ /* if first argument wasn't valid, rewrite the URL to include the username */
+
+ if($_SESSION["login"]){
+ header("Refresh: 0; /" . $_SESSION[username] . "/" . $_GET["name"] . "/" . $_GET["folder"] . "");
+ exit;
+ } else {
+
+ $wrong_folder = $_GET["name"];
+ $working_path = $_GET["name"];
+
+ get_404($working_path, $wrong_folder);
+ return false;
+ }
+ return false;
+ }
+
+ return true;
+}
+