Blame | Letzte Änderung | Log anzeigen | RSS feed
<?php/*** @package Content-management* @author Lars Tiefland <tiefland@weban.de>* @copyright 2009 Webagentur Niewerth* @license propietary http://www.weban.de* @version $Rev: 3931 $* @filesource**//**** @package Content-management* @author Lars Tiefland <tiefland@weban.de>* @copyright 2009 Webagentur Niewerth*/// SVN: $Id: edit_config.php 3931 2011-09-16 08:17:57Z tiefland $require_once "Config.php";require_once "File/Find.php";require_once "common.php";$path = "/etc/shop_configs/";$path .= ( $site != "weban.de" ) ? $site : "";$files = File_Find::search( "/config\..*\.ini\.php$/", $path, "perl" );$files = array_merge( $files, File_Find::search( "/template\.ini\.php$/",$path, "perl" ) );$files = array_merge( $files, File_Find::search( "/template_.*\.ini\.php$/",$path, "perl" ) );sort( $files );foreach ( $files as $id => $file ){$info = split( "/", $file );$i_site = $info[count( $info ) - 3];$i_shop = $info[count( $info ) - 2];$files_new["$i_site - $i_shop"][$file] = $file;}$GLOBALS["ui"]->assign( "files", $files_new );$new_conf = array();if ( isset( $user_rechte["admin"]["toolbox"]["edit_config"] ) && $_SERVER["SERVER_ADDR"] =="192.168.0.151" ){$GLOBALS["ui"]->assign( "meld","ACHTUNG! ACHTUNG! ACHTUNG!<br>Veränderungen an diesen Parametern können den Shop zerstören!" );$GLOBALS["ui"]->assign( "error", true );$GLOBALS["ui"]->assign( "file", "common/edit_config.tpl" );if ( $_POST["file"] && in_array( $_POST["file"], $files ) ){$cfg = new Config();$cfg_file = $_POST["file"];$GLOBALS["ui"]->assign( "cfg_file", $cfg_file );$conf = $cfg->parseConfig( $cfg_file, "IniCommented" );if ( PEAR::isError( $conf ) ){$GLOBALS["ui"]->assign( "error", true );$GLOBALS["ui"]->assign( "meld", $conf->getMessage() );$GLOBALS["ui"]->assign( "file", "common/meld.tpl" );$GLOBALS["ui"]->display( "common/page.tpl" );exit;}$conf = $conf->toArray();//sort($conf["root"]);$none_cnt = 0;foreach ( $conf["root"] as $key => $val ){if ( !is_array( $val ) ){$none_cnt++;$new_conf[$key] = $val;unset( $conf["root"][$key] );}}ksort( $new_conf );ksort( $conf["root"] );foreach ( $conf["root"] as $key => $val ){ksort( $conf["root"][$key] );}$conf["root"] = array_merge( $new_conf, $conf["root"] );$GLOBALS["ui"]->assign( "none_cnt", $none_cnt );$GLOBALS["ui"]->assign( "config", $conf["root"] );if ( $_POST["mode"] == "save" ){$out_cfg = new Config();$ini = $_POST["ini"];foreach ( $ini as $key => $val ){if ( !is_array( $val ) ){$none_cnt++;$new_conf[$key] = $val;unset( $ini[$key] );}}ksort( $new_conf );ksort( $ini );foreach ( $ini as $key => $val ){ksort( $ini[$key] );}$ini = array_merge( $new_conf, $ini );$out_cfg->parseConfig( $ini, "phparray", array( "name" =>"root" ) );$out_cfg->writeConfig( $cfg_file, "IniCommented" );$file2 = dirname( $cfg_file ) . "/" . basename( $cfg_file,".ini.php" ) . ".xml";$out_cfg->writeConfig( $file2, "XML", array( "name" =>"config" ) );$add = false;$add2 = false;$cmd = "svn status $cfg_file";exec( $cmd, $out, $ret );$status = substr( $out[0], 0, 1 );unset( $out );if ( $status == "?" ){$cmd = "svn add $cfg_file";exec( $cmd, $out, $ret );$add = true;} elseif ( $status == "A" ){$add = true;}unset( $out );$cmd = "svn status $file2";exec( $cmd, $out, $ret );$status2 = substr( $out[0], 0, 1 );unset( $out );if ( $status2 == "?" ){$cmd = "svn add $file2";exec( $cmd, $out, $ret );$add2 = true;} elseif ( $status2 == "A" ){$add2 = true;}$status = ( $add ) ? "hinzugefuegt" : "geaendert";$status2 = ( $add2 ) ? "hinzugefuegt" : "geaendert";unset( $out );$msg = "\"Sachbearbeiter: " . $_SERVER["PHP_AUTH_USER"] . "\n";$msg .= "Server: " . $_SERVER["SERVER_NAME"] . "\n";$msg .= "Remote: " . $_SERVER["REMOTE_HOST"] . " (" . $_SERVER["REMOTE_ADDR"] .")\n";$msg .= "Konfiguration $cfg_file $status\nKonfiguration $file2 $status2\"";$cmd = "svn ci $cfg_file $file2 -m $msg --username www-data --password NcC2010";exec( $cmd, $out, $ret );$GLOBALS["ui"]->assign( "error", false );$GLOBALS["ui"]->assign( "meld", "Datei $cfg_file erfolgreich aktualisiert!" );$GLOBALS["ui"]->assign( "file", "common/meld.tpl" );}}}else{$GLOBALS["ui"]->assign( "error", true );$GLOBALS["ui"]->assign( "meld","Sie haben nicht das Recht dieses Tool zu benutzen!" );$GLOBALS["ui"]->assign( "file", "common/meld.tpl" );}$GLOBALS["ui"]->display( "common/page.tpl" );?>