|
1 | 1 | <?php |
2 | 2 |
|
3 | 3 | /* |
4 | | - Copyright (c) 2007, Till Brehm, projektfarm Gmbh |
| 4 | + Copyright (c) 2007-2011, Till Brehm, projektfarm Gmbh |
5 | 5 | All rights reserved. |
6 | 6 |
|
7 | 7 | Redistribution and use in source and binary forms, with or without modification, |
|
54 | 54 | * Try to Load the server configuration from the master-db |
55 | 55 | */ |
56 | 56 | if ($app->dbmaster->connect()) { |
57 | | - // get the dalaog_id of the last performed record |
58 | 57 | $server_db_record = $app->dbmaster->queryOneRecord("SELECT * FROM server WHERE server_id = " . $conf['server_id']); |
| 58 | + |
59 | 59 | $conf['last_datalog_id'] = (int) $server_db_record['updated']; |
60 | 60 | $conf['mirror_server_id'] = (int) $server_db_record['mirror_server_id']; |
| 61 | + |
61 | 62 | // Load the ini_parser |
62 | 63 | $app->uses('ini_parser'); |
| 64 | + |
63 | 65 | // Get server configuration |
64 | 66 | $conf['serverconfig'] = $app->ini_parser->parse_ini_string(stripslashes($server_db_record['config'])); |
| 67 | + |
65 | 68 | // Set the loglevel |
66 | 69 | $conf['log_priority'] = intval($conf['serverconfig']['server']['loglevel']); |
67 | 70 |
|
| 71 | + // we do not need this variable anymore |
68 | 72 | unset($server_db_record); |
| 73 | + |
| 74 | + /* |
| 75 | + * Save the rescue-config, maybe we need it (because the database is down) |
| 76 | + */ |
| 77 | + $tmp['serverconfig']['server']['loglevel'] = $conf['log_priority']; |
| 78 | + $tmp['serverconfig']['rescue'] = $conf['serverconfig']['rescue']; |
| 79 | + file_put_contents(dirname(__FILE__) . "/temp/rescue_module_serverconfig.ser.txt", serialize($tmp)); |
| 80 | + unset($tmp); |
| 81 | + |
| 82 | + // protect the file |
| 83 | + chmod(dirname(__FILE__) . "/temp/rescue_module_serverconfig.ser.txt", 0600); |
| 84 | + |
69 | 85 | } else { |
70 | 86 | /* |
71 | 87 | * The master-db is not available. |
72 | 88 | * Problem: because we need to start the rescue-module (to rescue the DB if this IS the |
73 | 89 | * server, the master-db is running at) we have to initialize some config... |
74 | 90 | */ |
75 | | - $conf['last_datalog_id'] = intval('9223372036854775807'); // maxint at 32 and 64 bit systems |
76 | | - $conf['mirror_server_id'] = 0; // no mirror |
77 | | - // Set the loglevel to warning |
78 | | - $conf['log_priority'] = LOGLEVEL_WARN; |
| 91 | + |
| 92 | + /* |
| 93 | + * If there is a temp-file with the data we could get from the database, then we use it |
| 94 | + */ |
| 95 | + $tmp = array(); |
| 96 | + if (file_exists(dirname(__FILE__) . "/temp/rescue_module_serverconfig.ser.txt")){ |
| 97 | + $tmp = unserialize(file_get_contents(dirname(__FILE__) . "/temp/rescue_module_serverconfig.ser.txt")); |
| 98 | + } |
| 99 | + |
| 100 | + // maxint at 32 and 64 bit systems |
| 101 | + $conf['last_datalog_id'] = intval('9223372036854775807'); |
| 102 | + |
| 103 | + // no mirror |
| 104 | + $conf['mirror_server_id'] = 0; |
| 105 | + |
| 106 | + // Set the loglevel |
| 107 | + $conf['log_priority'] = (isset($tmp['serverconfig']['server']['loglevel']))? $tmp['serverconfig']['server']['loglevel'] : LOGLEVEL_ERROR; |
79 | 108 | /* |
80 | 109 | * Set the configuration to rescue the database |
81 | 110 | */ |
82 | | - $conf['serverconfig']['rescue']['try_rescue'] = 'y'; |
83 | | - $conf['serverconfig']['rescue']['do_not_try_rescue_mysql'] = 'n'; |
| 111 | + if (isset($tmp['serverconfig']['rescue'])){ |
| 112 | + $conf['serverconfig']['rescue'] = $tmp['serverconfig']['rescue']; |
| 113 | + } |
| 114 | + else{ |
| 115 | + $conf['serverconfig']['rescue']['try_rescue'] = 'n'; |
| 116 | + } |
| 117 | + // we do not need this variable anymore |
| 118 | + unset($tmp); |
84 | 119 | } |
85 | 120 |
|
86 | 121 |
|
|
0 commit comments