Subversion-Projekte lars-tiefland.content-management

Revision

Revision 1 | Details | Vergleich mit vorheriger | 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 );
2 lars 84
        echo "Die Verbindung zur Datenbank <font color=\"#FF0000\">" . $webs["datenbank"] .
85
            "</font> konnte nicht hergestellt werden<br>";
1 lars 86
        die( mysql_errno() . ": " . mysql_error() );
87
    }
88
 
89
    if ( !$webs["bgcolor_seite"] )
90
    {
91
        $webs["bgcolor_seite"] = "FFFFFF";
92
    }
93
    if ( !$webs["bgcolor_links"] )
94
    {
95
        $webs["bgcolor_links"] = "FFFFFF";
96
    }
97
    if ( !$webs["bgcolor_rechts"] )
98
    {
99
        $webs["bgcolor_rechts"] = "FFFFFF";
100
    }
101
 
102
    if ( !$webs["font_color_seite"] )
103
    {
104
        $webs["font_color_seite"] = "000000";
105
    }
106
    if ( !$webs["font_color_links"] )
107
    {
108
        $webs["font_color_links"] = "000000";
109
    }
110
    if ( !$webs["font_color_rechts"] )
111
    {
112
        $webs["font_color_rechts"] = "000000";
113
    }
114
 
115
    // Variablen freigeben
116
    unset( $query );
117
    unset( $result );
118
 
119
    function timestamp2human( $date )
120
    {
121
        $Jahr = substr( $date, 0, 4 );
122
        $Monat = substr( $date, 4, 2 );
123
        $Tag = substr( $date, 6, 2 );
124
 
125
        $Stunde = substr( $date, 8, 2 );
126
        $Minute = substr( $date, 10, 2 );
127
        $Sekunde = substr( $date, 12, 2 );
128
 
129
        return array( "Datum" => "$Tag.$Monat.$Jahr", "Zeit" => "$Stunde:$Minute:$Sekunde" );
130
    }
131
 
132
    function datetime2human( $date )
133
    {
134
        $date = preg_split( "/ /", $date );
135
        return array( "Datum" => join( ".", array_reverse( preg_split( "/-/",
136
            $date[0] ) ) ), "Zeit" => $date[1] );
137
    }
138
 
139
    function date2human( $date )
140
    {
141
        return join( ".", array_reverse( preg_split( "/-/", $date ) ) );
142
    }
143
 
144
    function human2date( $date )
145
    {
146
        return join( "-", array_reverse( preg_split( "/\./", $date ) ) );
147
    }
148
 
149
    function display( $ar )
150
    {
151
        return pre( $ar, true );
152
    }
153
 
154
    function pre( $elem, $r = false, $dump = false )
155
    {
156
        if ( $dump == true )
157
        {
158
            $output = "<pre>" . htmlentities( var_export( $elem, true ) ) .
159
                "</pre>";
160
        }
161
        else
162
        {
163
            $output = "<pre>" . htmlentities( print_r( $elem, true ) ) .
164
                "</pre>";
165
        }
166
 
167
        if ( $r == true )
168
        {
169
            return $output;
170
        }
171
        else
172
        {
173
            echo $output;
174
        }
175
    }
176
 
177
    function build_log( $id, $type, $filename = "" )
178
    {
179
        $old_content = "";
180
        switch ( $type )
181
        {
182
            case "xml_export":
183
                $content = date( "d.m.Y H:i:s", time() ) .
184
                    " -xml- Die Datei " . $filename . " wurde erstellt.\n";
185
 
186
                break;
187
            case "ftp_upload":
188
                $content = date( "d.m.Y H:i:s", time() ) .
189
                    " -ftp- Die Datei " . $filename . " wurde hochgeladen.\n";
190
                break;
191
            case "img_upload":
192
                $content = date( "d.m.Y H:i:s", time() ) .
193
                    " -img- Die Datei " . $filename . " wurde hochgeladen.\n";
194
                break;
195
            default:
196
                break;
197
        }
198
 
199
        $sql = "select ID,content from log where data_id = " . $id . "";
200
 
201
        $old_content = "";
202
        if ( $q = mysql_query( $sql ) )
203
        {
204
            $r = mysql_fetch_assoc( $q );
205
            $old_content = $r['content'];
206
        }
207
        $sql = "replace into log (data_id,content)
208
					values (" . $id . ",concat('" . $old_content . "','" . $content . "'))";
209
        if ( $q = mysql_query( $sql ) )
210
        {
211
        }
212
 
213
    }
214
 
215
 
216
    function getUserInfo()
217
    {
218
        global $localhost_dbh;
219
        $sql = "
220
            SELECT
221
                *
222
            FROM
223
                content_management.Access
224
            WHERE
225
                user='" . $_SERVER["PHP_AUTH_USER"] . "'
226
        ";
227
        $res = mysql_query( $sql, $localhost_dbh );
228
        if ( $res )
229
        {
230
            $row = mysql_fetch_assoc( $res );
231
            $ret = $row;
232
        }
233
        if ( empty( $ret["name"] ) )
234
        {
235
            $ret["name"] = $_SERVER["PHP_AUTH_USER"];
236
        }
237
        return $ret;
238
    }
239
 
240
    function hilfeOverlib( $modul )
241
    {
242
        global $localhost_dbh;
243
        if ( empty( $modul ) )
244
        {
245
            die( 'Fehler! Es wurde $modul nicht übergeben!' );
246
        }
247
 
248
        $sql = '
249
            SELECT
250
                hilfetext,
251
                name
252
            FROM
253
               content_management.properties
254
            WHERE
255
                interner_name = "' . $modul . '"
256
       ;';
257
        $result = mysql_query( $sql, $localhost_dbh ) or die( mysql_errno() .
258
            ': ' . mysql_error() . '<hr />' . $sql );
259
        $row = mysql_fetch_assoc( $result );
260
 
261
        $name = $row['name'];
262
        $hilfetext = $row['hilfetext'];
263
 
264
        $hilfetext = strip_tags( $hilfetext );
265
        $hilfetext = str_replace( "\"", "", $hilfetext );
266
        $hilfetext = str_replace( "\r\n", "<br>", $hilfetext );
267
 
268
        $hilfeReturn = "<a href='http://" . $_SERVER['SERVER_NAME'] .
269
            "/html/batterieverordnung.htm'
270
				onmouseover='return overlib(\"" . $hilfetext . "\", CAPTION, \"$name\", HAUTO, VAUTO, WIDTH, 500);' onmouseout='return nd();'
271
				>[?]</a>";
272
 
273
        return $hilfeReturn;
274
    }
275
 
276
    $erg = getUserInfo();
277
    $_SESSION["USERNAME"] = $erg["name"];
278
    $_SESSION["U_ID"] = $erg["ID"];
279
    $_SESSION["U_EMAIL"] = $erg["email"];
280
    $_SESSION["U_TELEFON"] = $erg["telefon"];
281
    $_SESSION["U_FAX"] = $erg["fax"];
282
    require_once $path . "loginTest.php";
283
 
284
    if ( isset( $web_rechte["admin"]["toolbox"]["logbuch"] ) )
285
    {
286
        require_once "MDB2.php";
287
        $conf["dsn"] = "mysqli://" . $webs["db_username"] . ":" . $webs["db_password"] .
288
            "@" . $webs["db_server"] . "/" . $webs["datenbank"];
289
        $conf["u_id"] = $_SESSION["U_ID"];
290
        $GLOBALS["Log"]["best"] = Log::factory( "weban_sql", "logbuch", "1",
291
            $conf );
292
        if ( PEAR::isError( $GLOBALS["Log"]["best"] ) )
293
        {
294
            die( $GLOBALS["Log"]["best"]->getMessage() );
295
        }
296
        $GLOBALS["Log"]["art"] = &Log::singleton( "weban_sql", "logbuch",
297
            "2", $conf );
298
        if ( PEAR::isError( $GLOBALS["Log"]["art"] ) )
299
        {
300
            die( $GLOBALS["Log"]["art"]->getMessage() );
301
        }
302
        $GLOBALS["Log"]["dir"] = &Log::singleton( "weban_sql", "logbuch",
303
            "3", $conf );
304
        if ( PEAR::isError( $GLOBALS["Log"]["dir"] ) )
305
        {
306
            die( $GLOBALS["Log"]["dir"]->getMessage() );
307
        }
308
    }
309
    if ( isset( $web_rechte["online_shop"]["language"]["standardsprache"] ) )
310
    {
311
        require_once "language_pack.php";
312
        foreach ( $language_pack as $l )
313
        {
314
            //if($)
315
            $val_langs[$l[0]] = 1;
316
        }
317
        $lang = $web_rechte["online_shop"]["language"]["standardsprache"];
318
        if ( !$lang || !array_key_exists( $lang, $val_langs ) )
319
        {
320
            $lang = "DE";
321
        }
322
    }
323
    else
324
    {
325
        $lang = "DE";
326
    }
327
    define( "DEFAULT_LANG", $lang );
328
    function weban_debug( $msg, $dump = false )
329
    {
330
        if ( IS_WEBAN )
331
        {
332
            return pre( $msg, true, $dump );
333
        }
334
    }
2 lars 335
    function getWebSettings( $settings, $shop = 1, $bestell_art = 1 )
336
    {
337
        $sql = "SHOW COLUMNS FROM web_settings";
338
        $res = mysql_query( $sql );
339
        $where_sql="";
340
        while ( $row = mysql_fetch_assoc( $res ) )
341
        {
342
            if($row["Field"]=="bestellart_id")
343
            {
344
                $where_sql = " AND bestellart_id = $bestell_art";
345
            }
346
        }
347
        $sql = "SELECT
348
                *
349
            FROM
350
                web_settings
351
            WHERE
352
                shops_id = $shop
353
            $where_sql
354
            AND
355
                ID IN (".implode(",",$settings).")
356
        ";
357
        $res = mysql_query($sql);
358
        while($row = mysql_fetch_assoc($res))
359
        {
360
            $ret[$row["ID"]] = $row["Inhalt"];
361
        }
362
        return $ret;
363
    }
1 lars 364
?>