[enh] Modifies bootstrap mysql config
This commit is contained in:
		
							parent
							
								
									ee767f5fce
								
							
						
					
					
						commit
						d3910de8e2
					
				|  | @ -70,41 +70,33 @@ $root                                   = ALTERNC_PANEL."/"; | ||||||
| 
 | 
 | ||||||
| // Database variables setup
 | // Database variables setup
 | ||||||
| // ***********************
 | // ***********************
 | ||||||
|  | // Default values
 | ||||||
|  | $database                               = "alternc_test"; | ||||||
|  | $user                                   = "root"; | ||||||
|  | $password                               = ""; | ||||||
|  | // Local override
 | ||||||
| if ( is_readable("my.cnf") ) { | if ( is_readable("my.cnf") ) { | ||||||
|   $mysqlConfigFile                      = file_get_contents("my.cnf"); |     $mysqlConfigFile                      = file("my.cnf"); | ||||||
| } else if ( is_readable("/etc/alternc/dbusers.cnf") ) { |     foreach ($mysqlConfigFile as $line) { | ||||||
|   $mysqlConfigFile                      = file_get_contents("/etc/alternc/dbusers.cnf"); |       if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $matches)) { | ||||||
| } else if ( is_readable("/etc/alternc/my.cnf") ) { |           switch ($matches[1]) { | ||||||
|   $mysqlConfigFile                      = file_get_contents("/etc/alternc/my.cnf"); |           case "user": | ||||||
| } else { |             $user                           = $matches[2]; | ||||||
|     throw new Exception("You must provide a mysql configuration file", 1 ); |           break; | ||||||
| } |           case "password": | ||||||
| $mysqlConfigFile                        = explode("\n",$mysqlConfigFile); |             $password                       = $matches[2]; | ||||||
| foreach ($mysqlConfigFile as $line) { |           break; | ||||||
|   if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $matches)) { |           case "database": | ||||||
|       switch ($matches[1]) { |             $database                       = $matches[2]; | ||||||
|       case "user": |           break; | ||||||
|         $user                           = $matches[2]; |         } | ||||||
|       break; |       } | ||||||
|       case "password": |       if (preg_match('/^#alternc_var ([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $matches)) { | ||||||
|         $password                       = $matches[2]; |         $$matches[1]                        = $matches[2]; | ||||||
|       break; |       } | ||||||
|       case "database": |  | ||||||
|         $database                       = $matches[2]; |  | ||||||
|       break; |  | ||||||
|     } |     } | ||||||
|   } |  | ||||||
|   if (preg_match('/^#alternc_var ([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $matches)) { |  | ||||||
|     $$matches[1] =     $matches[2]; |  | ||||||
|   } |  | ||||||
| }  | }  | ||||||
| 
 | 
 | ||||||
| // Database default 
 |  | ||||||
| // ********************************************
 |  | ||||||
| 
 |  | ||||||
| if( ! $database ){ |  | ||||||
| 	$database 							= "alternc_phpunit"; |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
| * Class for MySQL management in the bureau  | * Class for MySQL management in the bureau  | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 alban
						alban