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 2009 Webagentur Niewerth
7
     * @license   propietary http://www.weban.de
8
     * @version   $Rev: 3931 $
9
     * @filesource
10
     *
11
     */
12
 
13
    /**
14
     *
15
     * @package   Content-management
16
     * @author    Lars Tiefland <tiefland@weban.de>
17
     * @copyright 2009 Webagentur Niewerth
18
     */
19
 
20
    // SVN: $Id: edit_config.php 3931 2011-09-16 08:17:57Z tiefland $
21
 
22
    require_once  "Config.php";
23
    require_once  "File/Find.php";
24
    require_once  "common.php";
25
 
26
    $path = "/etc/shop_configs/";
27
    $path .= ( $site != "weban.de" ) ? $site : "";
28
    $files = File_Find::search( "/config\..*\.ini\.php$/", $path, "perl" );
29
    $files = array_merge( $files, File_Find::search( "/template\.ini\.php$/",
30
        $path, "perl" ) );
31
    $files = array_merge( $files, File_Find::search( "/template_.*\.ini\.php$/",
32
        $path, "perl" ) );
33
    sort( $files );
34
    foreach ( $files as $id => $file )
35
    {
36
        $info = split( "/", $file );
37
        $i_site = $info[count( $info ) - 3];
38
        $i_shop = $info[count( $info ) - 2];
39
        $files_new["$i_site - $i_shop"][$file] = $file;
40
    }
41
    $GLOBALS["ui"]->assign( "files", $files_new );
42
 
43
    $new_conf = array();
44
    if ( isset( $user_rechte["admin"]["toolbox"]["edit_config"] ) && $_SERVER["SERVER_ADDR"] ==
45
        "192.168.0.151" )
46
    {
47
        $GLOBALS["ui"]->assign( "meld",
48
            "ACHTUNG! ACHTUNG! ACHTUNG!<br>Veränderungen an diesen Parametern können den Shop zerstören!" );
49
        $GLOBALS["ui"]->assign( "error", true );
50
        $GLOBALS["ui"]->assign( "file", "common/edit_config.tpl" );
51
        if ( $_POST["file"] && in_array( $_POST["file"], $files ) )
52
        {
53
            $cfg = new Config();
54
            $cfg_file = $_POST["file"];
55
            $GLOBALS["ui"]->assign( "cfg_file", $cfg_file );
56
            $conf = $cfg->parseConfig( $cfg_file, "IniCommented" );
57
            if ( PEAR::isError( $conf ) )
58
            {
59
                $GLOBALS["ui"]->assign( "error", true );
60
                $GLOBALS["ui"]->assign( "meld", $conf->getMessage() );
61
                $GLOBALS["ui"]->assign( "file", "common/meld.tpl" );
62
                $GLOBALS["ui"]->display( "common/page.tpl" );
63
                exit;
64
            }
65
            $conf = $conf->toArray();
66
            //sort($conf["root"]);
67
            $none_cnt = 0;
68
            foreach ( $conf["root"] as $key => $val )
69
            {
70
                if ( !is_array( $val ) )
71
                {
72
                    $none_cnt++;
73
                    $new_conf[$key] = $val;
74
                    unset( $conf["root"][$key] );
75
                }
76
            }
77
            ksort( $new_conf );
78
            ksort( $conf["root"] );
79
            foreach ( $conf["root"] as $key => $val )
80
            {
81
                ksort( $conf["root"][$key] );
82
            }
83
            $conf["root"] = array_merge( $new_conf, $conf["root"] );
84
            $GLOBALS["ui"]->assign( "none_cnt", $none_cnt );
85
            $GLOBALS["ui"]->assign( "config", $conf["root"] );
86
            if ( $_POST["mode"] == "save" )
87
            {
88
                $out_cfg = new Config();
89
                $ini = $_POST["ini"];
90
                foreach ( $ini as $key => $val )
91
                {
92
                    if ( !is_array( $val ) )
93
                    {
94
                        $none_cnt++;
95
                        $new_conf[$key] = $val;
96
                        unset( $ini[$key] );
97
                    }
98
                }
99
                ksort( $new_conf );
100
                ksort( $ini );
101
                foreach ( $ini as $key => $val )
102
                {
103
                    ksort( $ini[$key] );
104
                }
105
                $ini = array_merge( $new_conf, $ini );
106
                $out_cfg->parseConfig( $ini, "phparray", array( "name" =>
107
                    "root" ) );
108
                $out_cfg->writeConfig( $cfg_file, "IniCommented" );
109
                $file2 = dirname( $cfg_file ) . "/" . basename( $cfg_file,
110
                    ".ini.php" ) . ".xml";
111
                $out_cfg->writeConfig( $file2, "XML", array( "name" =>
112
                    "config" ) );
113
                $add = false;
114
                $add2 = false;
115
                $cmd = "svn status $cfg_file";
116
                exec( $cmd, $out, $ret );
117
                $status = substr( $out[0], 0, 1 );
118
                unset( $out );
119
                if ( $status == "?" )
120
                {
121
                    $cmd = "svn add $cfg_file";
122
                    exec( $cmd, $out, $ret );
123
                    $add = true;
124
                } elseif ( $status == "A" )
125
                {
126
                    $add = true;
127
                }
128
                unset( $out );
129
                $cmd = "svn status $file2";
130
                exec( $cmd, $out, $ret );
131
                $status2 = substr( $out[0], 0, 1 );
132
                unset( $out );
133
                if ( $status2 == "?" )
134
                {
135
                    $cmd = "svn add $file2";
136
                    exec( $cmd, $out, $ret );
137
                    $add2 = true;
138
                } elseif ( $status2 == "A" )
139
                {
140
                    $add2 = true;
141
                }
142
                $status = ( $add ) ? "hinzugefuegt" : "geaendert";
143
                $status2 = ( $add2 ) ? "hinzugefuegt" : "geaendert";
144
                unset( $out );
145
                $msg = "\"Sachbearbeiter: " . $_SERVER["PHP_AUTH_USER"] . "\n";
146
                $msg .= "Server: " . $_SERVER["SERVER_NAME"] . "\n";
147
                $msg .= "Remote: " . $_SERVER["REMOTE_HOST"] . " (" . $_SERVER["REMOTE_ADDR"] .
148
                    ")\n";
149
                $msg .= "Konfiguration $cfg_file $status\nKonfiguration $file2 $status2\"";
150
                $cmd = "svn ci $cfg_file $file2 -m $msg --username www-data --password NcC2010";
151
                exec( $cmd, $out, $ret );
152
                $GLOBALS["ui"]->assign( "error", false );
153
                $GLOBALS["ui"]->assign( "meld", "Datei $cfg_file erfolgreich aktualisiert!" );
154
 
155
                $GLOBALS["ui"]->assign( "file", "common/meld.tpl" );
156
            }
157
        }
158
    }
159
    else
160
    {
161
        $GLOBALS["ui"]->assign( "error", true );
162
        $GLOBALS["ui"]->assign( "meld",
163
            "Sie haben nicht das Recht dieses Tool zu benutzen!" );
164
 
165
        $GLOBALS["ui"]->assign( "file", "common/meld.tpl" );
166
    }
167
    $GLOBALS["ui"]->display( "common/page.tpl" );
168
?>