Subversion-Projekte lars-tiefland.content-management

Revision

Revision 1 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
2 lars 1
<?php
2
    $path = "module/content-management/";
3
    if ( !defined( "IS_WEBAN" ) )
4
    {
5
        if ( $_SERVER["REMOTE_ADDR"] == "89.245.130.99" || $_SERVER["PHP_AUTH_USER"] ==
6
            "admin" || preg_match( "/192\.168\.0/", $_SERVER["REMOTE_ADDR"] ) )
1 lars 7
        {
2 lars 8
            define( "IS_WEBAN", true );
1 lars 9
        }
2 lars 10
        else
11
        {
12
            define( "IS_WEBAN", false );
13
        }
14
    }
15
    function microtime_float()
16
    {
17
        list( $usec, $sec ) = explode( " ", microtime() );
18
        return ( ( float )$usec + ( float )$sec );
19
    }
1 lars 20
 
2 lars 21
    define( "DEBUG", true );
1 lars 22
 
2 lars 23
    $self = basename( $_SERVER["PHP_SELF"] );
24
    $MySQL_Host = "localhost";
25
    $database_name = "content_management";
26
 
27
    if ( $_SERVER["SERVER_NAME"] != "server2" )
28
    {
29
        $MySQL_User = "content_managem";
30
        $MySQL_Passwd = "k-dp-u";
31
    }
1 lars 32
    else
2 lars 33
    {
34
        $MySQL_User = "root";
35
        $MySQL_Passwd = "";
36
        $PHP_AUTH_USER = "admin";
37
    }
1 lars 38
 
2 lars 39
    // Verbindung zum Server herstellen^
40
    if ( !$localhost_dbh = mysql_connect( $MySQL_Host, $MySQL_User, $MySQL_Passwd ) )
41
    {
42
        echo "Die Verbindung zum Datenbanksever konnte nicht hergestellt werden<br>";
43
        die( mysql_errno() . ": " . mysql_error() );
44
    }
1 lars 45
 
2 lars 46
    // Datenbank CMS anw.hlen
47
    if ( !$db = mysql_select_db( $database_name ) )
48
    {
49
        echo "Die Verbindung zur Datenbank <font color=\"#FF0000\">$database_name</font> konnte nicht hergestellt werden<br>";
50
        die( mysql_errno() . ": " . mysql_error() );
51
    }
1 lars 52
 
2 lars 53
    // Datenbank des Kunden auslesen
54
    require_once $path . "whoami.php";
55
    require_once $path . "webs.php";
1 lars 56
 
2 lars 57
    // user & web_rechte einlesen
58
    require_once $path . "get_rechte.php";
1 lars 59
 
2 lars 60
    // Falls ein remoteServer eingetragen ist Verbindung zu diesem Server herstellen
61
    if ( $webs["db_server"] )
62
    {
63
        if ( !$remoteServer_dbh = mysql_connect( $webs["db_server"], $webs["db_username"],
64
            $webs["db_password"] ) )
65
        {
66
            echo "Die Verbindung zum Datenbanksever konnte nicht hergestellt werden<br>";
67
            die( mysql_errno() . ": " . mysql_error() );
68
        }
69
    }
1 lars 70
 
2 lars 71
    // Shop-Datenbank anwählen
72
    //$webs[datenbank] = "kuehlerundklima_de";
73
    if ( !$db = mysql_select_db( $webs["datenbank"] ) )
74
    {
75
        echo "Die Verbindung zur Datenbank <font color=\"#FF0000\">" . $webs["datenbank"] .
76
            "</font> konnte nicht hergestellt werden<br>";
77
        die( mysql_errno() . ": " . mysql_error() );
78
    }
1 lars 79
 
2 lars 80
    if ( !$webs["bgcolor_seite"] )
81
    {
82
        $webs["bgcolor_seite"] = "FFFFFF";
83
    }
84
    if ( !$webs["bgcolor_links"] )
85
    {
86
        $webs["bgcolor_links"] = "FFFFFF";
87
    }
88
    if ( !$webs["bgcolor_rechts"] )
89
    {
90
        $webs["bgcolor_rechts"] = "FFFFFF";
91
    }
1 lars 92
 
2 lars 93
    if ( !$webs["font_color_seite"] )
94
    {
95
        $webs["font_color_seite"] = "000000";
96
    }
97
    if ( !$webs["font_color_links"] )
98
    {
99
        $webs["font_color_links"] = "000000";
100
    }
101
    if ( !$webs["font_color_rechts"] )
102
    {
103
        $webs["font_color_rechts"] = "000000";
104
    }
1 lars 105
 
2 lars 106
    // Variablen freigeben
107
    unset( $query );
108
    unset( $result );
1 lars 109
 
2 lars 110
    function timestamp2human( $date )
111
    {
112
        $Jahr = substr( $date, 0, 4 );
113
        $Monat = substr( $date, 4, 2 );
114
        $Tag = substr( $date, 6, 2 );
1 lars 115
 
2 lars 116
        $Stunde = substr( $date, 8, 2 );
117
        $Minute = substr( $date, 10, 2 );
118
        $Sekunde = substr( $date, 12, 2 );
1 lars 119
 
2 lars 120
        return array( "Datum" => "$Tag.$Monat.$Jahr", "Zeit" => "$Stunde:$Minute:$Sekunde" );
121
    }
1 lars 122
 
2 lars 123
    function datetime2human( $date )
124
    {
125
        $date = preg_split( "/ /", $date );
126
        return array( "Datum" => join( ".", array_reverse( preg_split( "/-/", $date[0] ) ) ),
127
                "Zeit" => $date[1] );
128
    }
1 lars 129
 
2 lars 130
    function date2human( $date )
131
    {
132
        return join( ".", array_reverse( preg_split( "/-/", $date ) ) );
133
    }
1 lars 134
 
2 lars 135
    function human2date( $date )
136
    {
137
        return join( "-", array_reverse( preg_split( "/\./", $date ) ) );
138
    }
1 lars 139
 
2 lars 140
    function display( $ar )
141
    {
142
        return pre( $ar, true );
143
    }
144
 
145
    function pre( $elem, $r = false, $dump = false )
146
    {
147
        if ( $dump == true )
148
        {
149
            $output = "<pre>" . htmlentities( var_export( $elem, true ) ) .
150
                "</pre>";
151
        }
152
        else
153
        {
154
            $output = "<pre>" . htmlentities( print_r( $elem, true ) ) .
155
                "</pre>";
156
        }
157
 
158
        if ( $r == true )
159
        {
160
            return $output;
161
        }
162
        else
163
        {
164
            echo $output;
165
        }
166
    }
167
 
1 lars 168
    function getUserName()
169
    {
170
        global $localhost_dbh;
2 lars 171
        $sql = "
1 lars 172
            SELECT
173
                name
174
            FROm
175
                content_management.Access
176
            WHERE
2 lars 177
                user='" . $_SERVER["PHP_AUTH_USER"] . "'
178
        ";
179
        $res = mysql_query( $sql, $localhost_dbh );
180
        if ( $res )
1 lars 181
        {
2 lars 182
            $row = mysql_fetch_assoc( $res );
183
            if ( !empty( $row["name"] ) )
1 lars 184
            {
2 lars 185
                $ret = $row["name"];
1 lars 186
            }
187
            else
188
            {
2 lars 189
                $ret = $_SERVER["PHP_AUTH_USER"];
1 lars 190
            }
191
        }
192
        else
193
        {
2 lars 194
            $ret = $_SERVER["PHP_AUTH_USER"];
1 lars 195
        }
196
        return $ret;
197
    }
2 lars 198
    $_SESSION["USERNAME"] = getUserName();
199
    //require_once "/web/apache/content-management/loginTest.php";
200
 
201
?>