From c46c138146831ca85a3194439de149094ad53dd5 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Thu, 26 Jul 2007 05:25:17 +0000 Subject: added config migrator and the code to detect a bad config --- bin/migrate_config.inc | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 bin/migrate_config.inc (limited to 'bin') diff --git a/bin/migrate_config.inc b/bin/migrate_config.inc new file mode 100644 index 00000000..fe5e907d --- /dev/null +++ b/bin/migrate_config.inc @@ -0,0 +1,84 @@ +'mysql', + 'tag_order'=>'id3v2,id3v1,vorbiscomment,quicktime,ape,asf', + 'album_art_order'=>'db,id3,folder,lastfm,amazon', + 'amazon_base_urls'=>'http://webservices.amazon.com'); + +$translate = array('local_host'=>'database_hostname', + 'local_db'=>'database_name', + 'local_username'=>'database_username', + 'local_pass'=>'database_password', + 'local_length'=>'session_length', + 'sess_name'=>'session_name', + 'sess_cookielife'=>'session_cookielife', + 'sess_cookiesecure'=>'session_cookiesecure'); + +$old_config = file_get_contents('../config/ampache.cfg.php'); + +$data = explode("\n",$old_config); + +echo "Parsing old config file...\n"; + +foreach ($data as $line) { + + // Replace a # with ; + if ($line['0'] == '#') { + $line = substr_replace($line,";",0,1); + } + + foreach ($unmigratable as $option=>$default) { + if (strstr($line,$option) AND !$migrated[$option]) { + $line = $option . " = \"$default\""; + $migrated[$option] = true; + } + elseif (strstr($line,$option)) { + $line = ';' . $line; + } + } + + foreach ($translate as $old=>$new) { + if (strstr($line,$old)) { + $line = str_replace($old,$new,$line); + } + } + + $new_config .= $line . "\n"; + +} // end foreach lines + + +echo "Parse complete, writing\n"; + +$handle = fopen('../config/ampache.cfg.php','w'); + +$worked = fwrite($handle,$new_config); + +if ($worked) { + echo "Write success, config migrated\n"; +} +else { + echo "Access Denied, config migration failed\n"; +} + +?> -- cgit