Subversion-Projekte lars-tiefland.content-management

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
    /**
4
     * @package   Content-management
5
     * @author    Lars Tiefland <tiefland@weban.de>
6
     * @copyright 2010 Webagentur Niewerth
7
     * @license   propietary http://www.weban.de
8
     * @version   $Rev: 3879 $
9
     * @filesource
10
     *
11
     */
12
 
13
    /**
14
     *
15
     * @package   Content-management
16
     * @author    Lars Tiefland <tiefland@weban.de>
17
     * @copyright 2010 Webagentur Niewerth
18
     */
19
 
20
    // SVN: $Id: admin_web_rechte.php 3879 2011-09-06 13:12:02Z tiefland $
21
 
22
    $self = basename( $PHP_SELF );
23
    $Tab = "Access";
24
    require_once "connect.php";
25
    // -------------------------
26
    // Sonderrechte abchecken
27
    if ( ( $site == "weban.de" ) or ( $_SERVER["SERVER_NAME"] == "server" ) )
28
    {
29
    }
30
    else
31
    {
32
        exit;
33
    }
34
    // -------------------------
35
    require_once "Weban_Smarty.class.php";
36
    $GLOBALS["ui"] = new Weban_Smarty();
37
    $GLOBALS["ui"]->compile_dir = $_SERVER["DOCUMENT_ROOT"] .
38
        "/templates_c/";
39
    $GLOBALS["ui"]->use_sub_dirs = true;
40
 
41
    if ( $action == "update" )
42
    {
43
        /*$query="delete from webs_properties where webs = $ID";
44
        $result = mysql_query ($query) or die (mysql_errno().": ".mysql_error()."<hr>$query<hr>");*/
45
 
46
        if ( isset( $modules ) )
47
        {
48
            foreach ( $modules as $m_id => $tools )
49
            {
50
                $m_name = getModuleName( $m_id );
51
                foreach ( $tools as $t_id => $properties )
52
                {
53
                    foreach ( $properties as $elem => $val )
54
                    {
55
                        $p_name = getPropertyName( $elem );
56
                        $query = "
57
                            SELECT
58
                                *
59
                            FROM
60
                                webs_properties
61
                            WHERE
62
                                webs=$ID
63
                            AND
64
                                properties=$elem
65
                        ";
66
                        $result = mysql_query( $query );
67
                        $anz = mysql_num_rows( $result );
68
                        $row = mysql_fetch_assoc( $result );
69
                        if ( $anz && !$val )
70
                        {
71
                            $query = "
72
                                DELETE FROM
73
                                    webs_properties
74
                                WHERE
75
                                    webs = $ID
76
                                AND
77
                                    properties=$elem
78
                            ";
79
                        } elseif ( $val && !$anz )
80
                        {
81
                            $query = "
82
                                INSERT INTO
83
                                    webs_properties
84
                                        (webs,properties,Bezeichnung)
85
                                    VALUES
86
                                        ($ID,$elem,'$Bezeichnung[$elem]')
87
                            ";
88
                            /*
89
                            $f_name = $m_name . "/" . $p_name . ".sql";
90
                            if ( file_exists( $f_name ) )
91
                            {
92
                            echo "Lese $f_name<br>";
93
                            $cont = file_get_contents( $f_name );
94
                            $cont = explode( ";", $cont );
95
                            foreach ( $cont as $sql )
96
                            {
97
                            if ( $sql && $sql[0] != "-" )
98
                            {
99
                            $res = mysql_query( $sql );
100
                            }
101
                            }
102
                            }
103
                            */
104
                        } elseif ( $Bezeichnung[$elem] != $row["Bezeichnung"] )
105
                        {
106
                            $query = "
107
                                UPDATE
108
                                    webs_properties
109
                                SET
110
                                    Bezeichnung='$Bezeichnung[$elem]'
111
                                WHERE
112
                                    webs=$ID
113
                                AND
114
                                    properties=$elem
115
                            ";
116
                        }
117
                        $result = mysql_query( $query ) or die( mysql_errno
118
                            () . ": " . mysql_error() . "<hr>$query<hr>" );
119
                    }
120
                }
121
            }
122
        }
123
        unset( $modules );
124
    }
125
 
126
    $query_site = "
127
        SELECT
128
            *
129
        FROM
130
            webs
131
        WHERE
132
            ID = $ID
133
    ";
134
    $result_site = mysql_query( $query_site ) or die( mysql_errno() . ": " .
135
        mysql_error() . "<hr>$query_site<hr>" );
136
    $web = mysql_fetch_assoc( $result_site );
137
    $query = "
138
        SELECT
139
            webs_properties.*
140
        FROM
141
            webs_properties,
142
            webs
143
        WHERE
144
            webs.ID = $ID
145
        AND
146
            webs_properties.webs = webs.ID
147
    ";
148
    $result = mysql_query( $query ) or die( mysql_errno() . ": " .
149
        mysql_error() . "<hr>$query<hr>" );
150
    while ( $zeile = mysql_fetch_assoc( $result ) )
151
    {
152
        $web["webs_properties"][$zeile["properties"]] = $zeile["Bezeichnung"];
153
    }
154
    $query = "
155
        SELECT
156
            *
157
        FROM
158
            modules
159
        ORDER BY
160
            rang
161
    ";
162
    $result_modules = mysql_query( $query ) or die( mysql_errno() . ": " .
163
        mysql_error() );
164
    while ( $module = mysql_fetch_assoc( $result_modules ) )
165
    {
166
        $query = "
167
            SELECT
168
                tools.*
169
            FROM
170
                tools
171
            WHERE
172
                tools.modules = $module[ID]
173
            ORDER BY
174
                tools.rang
175
        ";
176
        $result_tools = mysql_query( $query ) or die( mysql_errno() . ": " .
177
            mysql_error() );
178
        while ( $tool = mysql_fetch_assoc( $result_tools ) )
179
        {
180
            $query = "
181
                SELECT
182
                    properties.*
183
                FROM
184
                    properties
185
                WHERE
186
                    properties.tools = $tool[ID]
187
                ORDER BY
188
                    properties.rang
189
            ";
190
            $result_properties = mysql_query( $query ) or die( mysql_errno() .
191
                ": " . mysql_error() );
192
            while ( $property = mysql_fetch_assoc( $result_properties ) )
193
            {
194
                $property["beschreibung"] = htmlspecialchars( str_replace( "'",
195
                    '"', $property["beschreibung"] ), ENT_QUOTES );
196
                $property["beschreibung"] = preg_replace( "/[\r\n]/", "<br>",
197
                    $property["beschreibung"] );
198
                $property["beschreibung"] = str_replace( "<br><br>", "<br>",
199
                    $property["beschreibung"] );
200
                $tool["properties"][] = $property;
201
            }
202
            $module["tools"][] = $tool;
203
        }
204
        $modules[] = $module;
205
    }
206
    $algos = array( "", "crypt", "md5", "sha1" );
207
    if ( function_exists( "hash" ) )
208
    {
209
        $algos[] = "sha256";
210
        $algos[] = "sha512";
211
    }
212
    $GLOBALS["ui"]->assign( "algos", $algos );
213
    $GLOBALS["ui"]->assign( "modules", $modules );
214
    $GLOBALS["ui"]->assign( "web", $web );
215
    $GLOBALS["ui"]->display( "admin_web_rechte.tpl" );
216
 
217
    function getModuleName( $m_id )
218
    {
219
        $sql = "SELECT
220
                interner_name
221
            FROM
222
                content_management.modules
223
            WHERE
224
                id=$m_id
225
        ";
226
        $res = mysql_query( $sql );
227
        $row = mysql_fetch_assoc( $res );
228
        return $row["interner_name"];
229
    }
230
    function getPropertyName( $p_id )
231
    {
232
        $sql = "SELECT
233
                interner_name
234
            FROM
235
                content_management.properties
236
            WHERE
237
                id=$p_id
238
        ";
239
        $res = mysql_query( $sql );
240
        $row = mysql_fetch_assoc( $res );
241
        return $row["interner_name"];
242
    }
243
?>