summaryrefslogtreecommitdiff
path: root/www/functions/func_rewrite.php
blob: 48131f824ed0c2811e62110e77dda27a60c4b03d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
function rewrite($db){

        /* test if first argument a username or folder */

	$name = user_id($db, $_GET["name"]);

        if($name == ""){
	
                /* if first argument wasn't valid, rewrite the URL to include the username */

		$folder = $_GET["folder"];

		if(preg_match("/\/$/", $_GET["folder"])){
			$folder = substr($_GET["folder"], 0, -1);
		}

                if($_SESSION["login"]){
                        header("Refresh: 0; /" . $_SESSION['username'] . "/" . $_GET["name"] . "/" . $folder . "");
                        return false;
                } else {

                        $wrong_folder = $_GET["name"];
                        $working_path = $_GET["name"];

                        get_404($working_path, $wrong_folder);
			return false;
                }
	} else {
		return true;
	}
}