From 43933b5939b329a4ab333b093a370dabe995e0ad Mon Sep 17 00:00:00 2001 From: root Date: Wed, 26 Mar 2014 23:51:57 +0100 Subject: Small changes. --- blob/nginx_rewrite_rules | 23 +++++++++++++---------- www/functions/func_rewrite.php | 2 ++ www/functions/func_upload.php | 7 ++----- www/index.php | 16 ++++++---------- 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/blob/nginx_rewrite_rules b/blob/nginx_rewrite_rules index 34a4f20..eb6b0a2 100755 --- a/blob/nginx_rewrite_rules +++ b/blob/nginx_rewrite_rules @@ -8,35 +8,38 @@ location /static {} #location ~* ^/.+[^/].+\.css {} location ~* ^/?login/?([a-z0-9]+=[a-z0-9]+(&[a-z0-9]+=[a-z0-9]+)?)?$ { - rewrite ^/?login([?/]?.*) /index.php?task=login&arguments=$1 last; + rewrite ^/?login([?/]?.*) /index.php?task=login&arguments=$1 last; } location ~* ^/?logout/?(\?[0-9a-zA-Z]+(=[0-9a-zA-Z]*)?)?$ { - rewrite ^/?logout([?/]?.*) /index.php?task=logout&arguments=$1 last; + rewrite ^/?logout([?/]?.*) /index.php?task=logout&arguments=$1 last; } location ~* ^/?register/?(\?[0-9a-zA-Z]+(=[0-9a-zA-Z]*)?)?$ { - rewrite ^/?register(\?[0-9a-zA-Z]*(=[0-9a-zA-Z]*)?)? /index.php?task=register&arguments=$1 last; + rewrite ^/?register(\?[0-9a-zA-Z]*(=[0-9a-zA-Z]*)?)? /index.php?task=register&arguments=$1 last; } location ~* ^/?invite/?(\?[0-9a-zA-Z]+(=[0-9a-zA-Z]*)?)?$ { - rewrite ^/?invite(\?[0-9a-zA-Z]*(=[0-9a-zA-Z]*)?)? /index.php?task=invite&arguments=$1 last; + rewrite ^/?invite(\?[0-9a-zA-Z]*(=[0-9a-zA-Z]*)?)? /index.php?task=invite&arguments=$1 last; } location ~* ^/?user/?(\?[0-9a-zA-Z]+(=[0-9a-zA-Z]*)?)?$ { - rewrite ^/?user(\?[0-9a-zA-Z]*(=[0-9a-zA-Z]*)?)? /index.php?task=user&arguments=$1 last; + rewrite ^/?user(\?[0-9a-zA-Z]*(=[0-9a-zA-Z]*)?)? /index.php?task=user&arguments=$1 last; } location ~* ^/?download/?(\?[0-9a-zA-Z]+(=[0-9a-zA-Z]*)?)?$ { - rewrite ^/?download(\?[0-9a-zA-Z]*(=[0-9a-zA-Z]*)?)? /index.php?task=download&arguments=$1 last; + rewrite ^/?download(\?[0-9a-zA-Z]*(=[0-9a-zA-Z]*)?)? /index.php?task=download&arguments=$1 last; } -#location ~* \.php(\?[0-9a-zA-Z]+(=[0-9a-zA-Z]*)?)?$ {} #empty block to catch all +location ~* ^/password_recover/?(\?[0-9a-zA-Z]+(=[0-9a-zA-Z]*)?)?$ { + rewrite ^/?password_recover(\?[0-9a-zA-Z]*(=[0-9a-zA-Z]*)?)? /index.php?task=password_recover&arguments=$1 last; +} +#location ~* \.php(\?[0-9a-zA-Z]+(=[0-9a-zA-Z]*)?)?$ {} #empty block to catch all location / { - rewrite ^/([0-9a-zA-Z-_]+)/(.*) /index.php?name=$1&folder=$2 last; - rewrite ^/([0-9a-zA-Z-_]+)$ /index.php?name=$1&folder= last; - rewrite ^/$ /index.php last; + rewrite ^/([0-9a-zA-Z-_]+)/(.*) /index.php?name=$1&folder=$2 last; + rewrite ^/([0-9a-zA-Z-_]+)$ /index.php?name=$1&folder= last; + rewrite ^/$ /index.php last; break; } diff --git a/www/functions/func_rewrite.php b/www/functions/func_rewrite.php index d9f694d..0a123d6 100755 --- a/www/functions/func_rewrite.php +++ b/www/functions/func_rewrite.php @@ -16,7 +16,9 @@ function rewrite($db){ } if($_SESSION["login"]){ + $scheme = $GLOBALS["scheme"]; header("Refresh: 0; ".$scheme.$_SERVER["HTTP_HOST"]."/" . $_SESSION['username'] . "/" . $_GET["name"] . "/" . $folder . ""); + exit; } return false; diff --git a/www/functions/func_upload.php b/www/functions/func_upload.php index 8059191..dd113fc 100755 --- a/www/functions/func_upload.php +++ b/www/functions/func_upload.php @@ -50,10 +50,7 @@ function upload($db){ return UPLOAD_FOLDER_NOT_OWNER; } - $ownername = SQLite3::escapeString($_SESSION['username']); - $owner_db = $db->query("SELECT id FROM user WHERE name='" . $ownername . "';"); - $owner_ar = $owner_db->fetchArray(SQLITE3_NUM); - $owner = $owner_ar[0]; + $owner = $_SESSION["userid"]; $overall_size_db = $db->query("SELECT size FROM files WHERE owner=" . $owner . " AND size > 0;"); $overall_size = 0; @@ -62,7 +59,7 @@ function upload($db){ $overall_size = $overall_size + $row[$count]; $count++; } - + if($overall_size > 2147483648){ // == 2GB return UPLOAD_QUOTA; } diff --git a/www/index.php b/www/index.php index 5866411..de33f64 100755 --- a/www/index.php +++ b/www/index.php @@ -23,11 +23,12 @@ if(empty($_GET)){ if(empty($_GET["name"])){ switch($_GET["task"]){ case("login"): + if($_SESSION["login"]){ + header("Refresh: 0; ".$scheme.$_SERVER["HTTP_HOST"]."/".$_SESSION["username"]); + exit; + } + if($_SERVER['REQUEST_METHOD'] == 'POST'){ - if($_SESSION["login"]){ - header("Refresh: 0; ".$scheme.$_SERVER["HTTP_HOST"]."/".$_SESSION["username"]); - exit; - } $var = login($db); if($var == LOGIN_SUCCESSFULL){ header("Refresh: 0; ".$scheme.$_SERVER["HTTP_HOST"]."/".$_SESSION["username"]); @@ -36,12 +37,7 @@ if(empty($_GET)){ print_login($var); } } else { - if(!$_SESSION["login"]){ - print_login(constant("EMPTY")); - } else { - header("Refresh: 0; ".$scheme.$_SERVER["HTTP_HOST"]."/" . $_SESSION["username"]); - exit; - } + print_login(constant("EMPTY")); } break; -- cgit v1.2.3