Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function create_config($path,$server,$db_name)
- {
- global $user, $user_pass;
- $string_config = <<<EOD
- <?php
- $CFG = array(
- 'host'=> '$server',
- 'database' => '$db_name',
- 'user' => '$user',
- 'password' => '$user_pass'
- );
- ORM::configure(array(
- 'connection_string' => 'mysql:host='.$CFG['host'].';dbname='.$CFG['database'],
- 'username' => $CFG['user'],
- 'password' => $CFG['password'],
- 'driver_options' => array(PDO::MYSQL_ATTR_INIT_COMMAND=>'set NAMES utf8')));
- EOD;
- try
- {
- touch("../../$path"); //Creo la ruta en la raiz del fichero mkdir
- $fh = fopen("../../$path","w+") or die("Error al crear el fichero de configuracion"); //Abro el fichero en mode de escritura
- fwrite($fh,$string_config); //escribo en el fichero
- fclose($fh); //cierro el fichero
- chmod("../../".$path,'0777');#Cambiando permisos
- $create_file = true;
- } catch (PDOException $e)
- {
- die('error al crear el archivo'.$path."".$e->getMessage());
- }
- return $create_file;
- }
- if(isset($_POST['instalar']))
- {
- $server = test_input($_POST['servidor']); //Nombre del servidor
- $db_name = test_input($_POST['dbname']);
- $user = test_input($_POST['user']);
- $user_pass = test_input($_POST['password0']);
- #Crear el archivo config.php si no existe en caso de que no exista
- if(!file_exists("../../".$path))
- {
- $create_file = create_config($path,$server,$db_name);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement