C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\movieDB\web\inc\common.php


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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?
function greatescape($text)
{
    if (!
ini_get("magic_quotes_gpc")) {
        return (
addslashes($text));
    } else {
        return 
$text;
    }
}

function 
ungreatescape($text)
{
    if (
ini_get("magic_quotes_gpc")) {
        return (
stripslashes($text));
    } else {
        return 
$text;
    }
}

function 
saneempty($value)
{
    if (
strlen($value)==0)
        return 
TRUE;
    else
        return 
FALSE;
}

function 
addpar($url$par)
{
    if (
strpos($url,"?")===FALSE$chr="?"; else $chr="&";
    return 
$url.$chr.$par;
}

function 
getconfig($user="")
{
    
$config=array();
    
$result=doquery("select * from config");

    while (
$row=mysql_fetch_assoc($result)) {
        
$config[$row["item"]]=$row["value"];
    }

    
// Only certain values can be user defined
    
$validconfs=array("showimdb""defregion""defmedia""theme""movcolumns","movienav");

    if (!
saneempty($user)) {
        
$result=doquery("select item, value from userprefs where userid=".$user);
        while (
$row=mysql_fetch_assoc($result)) {
            if (
in_array($row["item"],$validconfs)) $config[$row["item"]]=$row["value"];
        }
    } else if (isset(
$_COOKIE["userid"])) {
        
$result=doquery("select item, value from userprefs where userid=".intval($_COOKIE["userid"]));
        while (
$row=mysql_fetch_assoc($result)) {
            if (
in_array($row["item"],$validconfs)) $config[$row["item"]]=$row["value"];
        }
    }

    return 
$config;
}

function 
dopage($content)
{
    global 
$config;

    require(
"themes/".$config["theme"]."/header.php");
    echo 
$content["body"];
    require(
"themes/".$config["theme"]."/footer.php");
}
function 
ckbit($bit,$value)
{
    if ((
$value&$bit)==$bit) return TRUE; else return FALSE;
}
function 
redirect($location)
{
    if (
strpos($_SERVER["SERVER_SOFTWARE"], "IIS")!==FALSE) {
        
// Do a meta refresh. Resolves refresh problem when setting cookies
        // with Microsoft IIS servers 5.0 and lower.
        
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=".$location."\">";
    } else {
        
header ("Location: ".$location);
    }
}
?>