Subversion-Projekte lars-tiefland.content-management

Revision

Zur aktuellen Revision | Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 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"] ) )
7
        {
8
            define( "IS_WEBAN", true );
9
        }
10
        else
11
        {
12
            define( "IS_WEBAN", false );
13
        }
14
    }
15
    require_once "Log.php";
16
    function microtime_float()
17
    {
18
        list( $usec, $sec ) = explode( " ", microtime() );
19
        return ( ( float )$usec + ( float )$sec );
20
    }
21
 
22
    define( "DEBUG", true );
23
 
24
    session_start();
25
 
26
    $database_name = "content_management";
27
 
28
    $MySQL_Host = "localhost";
29
 
30
    if ( $_SERVER["SERVER_NAME"] != "server3" && !stristr($_SERVER["SERVER_NAME"],".local"))
31
    {
32
        $self = basename( $_SERVER["PHP_SELF"] );
33
        $MySQL_User = "Shop_Daemon";
34
        $MySQL_Passwd = "S-Jp-g";
35
        $MySQL_Host_write = "213.203.217.142";
36
    }
37
    else
38
    {
39
        $MySQL_User = "root";
40
        $MySQL_Passwd = "";
41
        $_SERVER["PHP_AUTH_USER"] = "admin";
42
        $root = -1;
43
    }
44
 
45
    // Verbindung zum Server herstellen
46
    if ( !$localhost_dbh = mysql_connect( "$MySQL_Host", "$MySQL_User", "$MySQL_Passwd" ) )
47
    {
48
        echo
49
            "Die Verbindung zum Datenbanksever konnte nicht hergestellt werden<br>";
50
        die( mysql_errno() . ": " . mysql_error() );
51
    }
52
 
53
    // Datenbank CMS anwählen
54
    if ( !$db = mysql_select_db( "$database_name" ) )
55
    {
56
        echo "Die Verbindung zur Datenbank <font color=\"#FF0000\">$database_name</font> konnte nicht hergestellt werden<br>";
57
        die( mysql_errno() . ": " . mysql_error() );
58
    }
59
 
60
    // Datenbank des Kunden auslesen
61
    require_once $path . "whoami.php";
62
    require_once $path . "webs.php";
63
 
64
    // user & web_rechte einlesen
65
    require_once $path . "get_rechte.php";
66
 
67
    // Falls ein remoteServer eingetragen ist Verbindung zu diesem Server herstellen
68
    if ( $webs["db_server"] )
69
    {
70
        if ( !$remoteServer_dbh = mysql_connect( $webs["db_server"], $webs["db_username"],
71
            $webs["db_password"] ) )
72
        {
73
            echo
74
                "Die Verbindung zum Datenbanksever konnte nicht hergestellt werden<br>";
75
            die( mysql_errno() . ": " . mysql_error() );
76
        }
77
    }
78
 
79
    // Shop-Datenbank anwählen
80
    //$webs[datenbank] = "kuehlerundklima_de";
81
    if ( !$db = mysql_select_db( $webs["datenbank"] ) )
82
    {
83
        var_dump( $webs );
84
        echo "Die Verbindung zur Datenbank <font color=\"#FF0000\">$webs[datenbank]</font> konnte nicht hergestellt werden<br>";
85
        die( mysql_errno() . ": " . mysql_error() );
86
    }
87
 
88
    if ( !$webs["bgcolor_seite"] )
89
    {
90
        $webs["bgcolor_seite"] = "FFFFFF";
91
    }
92
    if ( !$webs["bgcolor_links"] )
93
    {
94
        $webs["bgcolor_links"] = "FFFFFF";
95
    }
96
    if ( !$webs["bgcolor_rechts"] )
97
    {
98
        $webs["bgcolor_rechts"] = "FFFFFF";
99
    }
100
 
101
    if ( !$webs["font_color_seite"] )
102
    {
103
        $webs["font_color_seite"] = "000000";
104
    }
105
    if ( !$webs["font_color_links"] )
106
    {
107
        $webs["font_color_links"] = "000000";
108
    }
109
    if ( !$webs["font_color_rechts"] )
110
    {
111
        $webs["font_color_rechts"] = "000000";
112
    }
113
 
114
    // Variablen freigeben
115
    unset( $query );
116
    unset( $result );
117
 
118
    function timestamp2human( $date )
119
    {
120
        $Jahr = substr( $date, 0, 4 );
121
        $Monat = substr( $date, 4, 2 );
122
        $Tag = substr( $date, 6, 2 );
123
 
124
        $Stunde = substr( $date, 8, 2 );
125
        $Minute = substr( $date, 10, 2 );
126
        $Sekunde = substr( $date, 12, 2 );
127
 
128
        return array( "Datum" => "$Tag.$Monat.$Jahr", "Zeit" => "$Stunde:$Minute:$Sekunde" );
129
    }
130
 
131
    function datetime2human( $date )
132
    {
133
        $date = preg_split( "/ /", $date );
134
        return array( "Datum" => join( ".", array_reverse( preg_split( "/-/",
135
            $date[0] ) ) ), "Zeit" => $date[1] );
136
    }
137
 
138
    function date2human( $date )
139
    {
140
        return join( ".", array_reverse( preg_split( "/-/", $date ) ) );
141
    }
142
 
143
    function human2date( $date )
144
    {
145
        return join( "-", array_reverse( preg_split( "/\./", $date ) ) );
146
    }
147
 
148
    function display( $ar )
149
    {
150
        return pre( $ar, true );
151
    }
152
 
153
    function pre( $elem, $r = false, $dump = false )
154
    {
155
        if ( $dump == true )
156
        {
157
            $output = "<pre>" . htmlentities( var_export( $elem, true ) ) .
158
                "</pre>";
159
        }
160
        else
161
        {
162
            $output = "<pre>" . htmlentities( print_r( $elem, true ) ) .
163
                "</pre>";
164
        }
165
 
166
        if ( $r == true )
167
        {
168
            return $output;
169
        }
170
        else
171
        {
172
            echo $output;
173
        }
174
    }
175
 
176
    function build_log( $id, $type, $filename = "" )
177
    {
178
        $old_content = "";
179
        switch ( $type )
180
        {
181
            case "xml_export":
182
                $content = date( "d.m.Y H:i:s", time() ) .
183
                    " -xml- Die Datei " . $filename . " wurde erstellt.\n";
184
 
185
                break;
186
            case "ftp_upload":
187
                $content = date( "d.m.Y H:i:s", time() ) .
188
                    " -ftp- Die Datei " . $filename . " wurde hochgeladen.\n";
189
                break;
190
            case "img_upload":
191
                $content = date( "d.m.Y H:i:s", time() ) .
192
                    " -img- Die Datei " . $filename . " wurde hochgeladen.\n";
193
                break;
194
            default:
195
                break;
196
        }
197
 
198
        $sql = "select ID,content from log where data_id = " . $id . "";
199
 
200
        $old_content = "";
201
        if ( $q = mysql_query( $sql ) )
202
        {
203
            $r = mysql_fetch_assoc( $q );
204
            $old_content = $r['content'];
205
        }
206
        $sql = "replace into log (data_id,content)
207
					values (" . $id . ",concat('" . $old_content . "','" . $content . "'))";
208
        if ( $q = mysql_query( $sql ) )
209
        {
210
        }
211
 
212
    }
213
 
214
 
215
    function getUserInfo()
216
    {
217
        global $localhost_dbh;
218
        $sql = "
219
            SELECT
220
                *
221
            FROM
222
                content_management.Access
223
            WHERE
224
                user='" . $_SERVER["PHP_AUTH_USER"] . "'
225
        ";
226
        $res = mysql_query( $sql, $localhost_dbh );
227
        if ( $res )
228
        {
229
            $row = mysql_fetch_assoc( $res );
230
            $ret = $row;
231
        }
232
        if ( empty( $ret["name"] ) )
233
        {
234
            $ret["name"] = $_SERVER["PHP_AUTH_USER"];
235
        }
236
        return $ret;
237
    }
238
 
239
    function hilfeOverlib( $modul )
240
    {
241
        global $localhost_dbh;
242
        if ( empty( $modul ) )
243
        {
244
            die( 'Fehler! Es wurde $modul nicht übergeben!' );
245
        }
246
 
247
        $sql = '
248
            SELECT
249
                hilfetext,
250
                name
251
            FROM
252
               content_management.properties
253
            WHERE
254
                interner_name = "' . $modul . '"
255
       ;';
256
        $result = mysql_query( $sql, $localhost_dbh ) or die( mysql_errno() .
257
            ': ' . mysql_error() . '<hr />' . $sql );
258
        $row = mysql_fetch_assoc( $result );
259
 
260
        $name = $row['name'];
261
        $hilfetext = $row['hilfetext'];
262
 
263
        $hilfetext = strip_tags( $hilfetext );
264
        $hilfetext = str_replace( "\"", "", $hilfetext );
265
        $hilfetext = str_replace( "\r\n", "<br>", $hilfetext );
266
 
267
        $hilfeReturn = "<a href='http://" . $_SERVER['SERVER_NAME'] .
268
            "/html/batterieverordnung.htm'
269
				onmouseover='return overlib(\"" . $hilfetext . "\", CAPTION, \"$name\", HAUTO, VAUTO, WIDTH, 500);' onmouseout='return nd();'
270
				>[?]</a>";
271
 
272
        return $hilfeReturn;
273
    }
274
 
275
    $erg = getUserInfo();
276
    $_SESSION["USERNAME"] = $erg["name"];
277
    $_SESSION["U_ID"] = $erg["ID"];
278
    $_SESSION["U_EMAIL"] = $erg["email"];
279
    $_SESSION["U_TELEFON"] = $erg["telefon"];
280
    $_SESSION["U_FAX"] = $erg["fax"];
281
    require_once $path . "loginTest.php";
282
 
283
    if ( isset( $web_rechte["admin"]["toolbox"]["logbuch"] ) )
284
    {
285
        require_once "MDB2.php";
286
        $conf["dsn"] = "mysqli://" . $webs["db_username"] . ":" . $webs["db_password"] .
287
            "@" . $webs["db_server"] . "/" . $webs["datenbank"];
288
        $conf["u_id"] = $_SESSION["U_ID"];
289
        $GLOBALS["Log"]["best"] = Log::factory( "weban_sql", "logbuch", "1",
290
            $conf );
291
        if ( PEAR::isError( $GLOBALS["Log"]["best"] ) )
292
        {
293
            die( $GLOBALS["Log"]["best"]->getMessage() );
294
        }
295
        $GLOBALS["Log"]["art"] = &Log::singleton( "weban_sql", "logbuch",
296
            "2", $conf );
297
        if ( PEAR::isError( $GLOBALS["Log"]["art"] ) )
298
        {
299
            die( $GLOBALS["Log"]["art"]->getMessage() );
300
        }
301
        $GLOBALS["Log"]["dir"] = &Log::singleton( "weban_sql", "logbuch",
302
            "3", $conf );
303
        if ( PEAR::isError( $GLOBALS["Log"]["dir"] ) )
304
        {
305
            die( $GLOBALS["Log"]["dir"]->getMessage() );
306
        }
307
    }
308
    if ( isset( $web_rechte["online_shop"]["language"]["standardsprache"] ) )
309
    {
310
        require_once "language_pack.php";
311
        foreach ( $language_pack as $l )
312
        {
313
            //if($)
314
            $val_langs[$l[0]] = 1;
315
        }
316
        $lang = $web_rechte["online_shop"]["language"]["standardsprache"];
317
        if ( !$lang || !array_key_exists( $lang, $val_langs ) )
318
        {
319
            $lang = "DE";
320
        }
321
    }
322
    else
323
    {
324
        $lang = "DE";
325
    }
326
    define( "DEFAULT_LANG", $lang );
327
    function weban_debug( $msg, $dump = false )
328
    {
329
        if ( IS_WEBAN )
330
        {
331
            return pre( $msg, true, $dump );
332
        }
333
    }
334
?>