Vidali /install/install.php

Language PHP Lines 89
MD5 Hash df4c164c8594bfc0f0302807fdc5d4ee
Repository https://github.com/ivansoriasolis/Vidali.git View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php 
/*	Vidali, Social Network Open Source.
This file is part of Vidali.

Vidali is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Vidali is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Foobar.  If not, see <http://www.gnu.org/licenses/>.*/

//Comprobar la integridad de los datos
$error= false;
$aux = 0;
$empty = "";
foreach ($_POST as $id => $data){
	if(empty($_POST[$id])){
		$aux++;
		$empty = $empty . "&emp$aux=$id";
		$error = true;
	}
}
	if($error == true){
		//header('Location:' . getenv('HTTP_REFERER') . "?empty=$aux"."$empty");
		//TODO: Si no es un lio, devolver esto en JSON
		echo $empty;
	}else{
		//crear el db.ini
		$con = new mysqli($_POST["DB_DIR"], $_POST["DB_USER"], $_POST["DB_PASS"],$_POST["DB_NAME"]);
		if (mysqli_connect_errno()) {
			printf("Connect failed: %s\n", mysqli_connect_error());
		exit();
		}
		else{
			include "../vdl-include/vdl-core/core_db.class.php";
			define ("DBDIR","NULL");
			$core= new CORE_DB();
			$config = $core->set($_POST["DB_DIR"], $_POST["DB_USER"], $_POST["DB_PASS"],$_POST["DB_NAME"]);
			$nombre_archivo = 'vidali.sql';
			$sql = explode(";",file_get_contents($nombre_archivo)); 
			$con->autocommit(FALSE);
			foreach($sql as $query){
//				echo " Linea de la BD: $query<br>";
				if (!empty($query)){
					if(!$con->query($query))
						printf("Error: %s<br>", mysqli_error($con));
				}
			}
			$con->autocommit(TRUE);
		}
		if(!$con->query("INSERT INTO `vdl_config` (`config_id`, `config_name`, `config_value`) VALUES (4, 'ADMIN', '1')"))
			printf("Error: %s<br>", mysqli_error($con));
		if(!$con->query("INSERT INTO `vdl_config` (`config_id`, `config_name`, `config_value`) VALUES (5, 'REGISTER', '".$_POST["optionsRadios"]."')"))
			printf("Error: %s<br>", mysqli_error($con));
		if(!$con->query("INSERT INTO `vdl_config` (`config_id`, `config_name`, `config_value`) VALUES (6, 'PRIVACY', '".$_POST["optionsRadios2"]."')"))
			printf("Error: %s<br>", mysqli_error($con));
		 /* TODO: Si index_bots o central_sync no estan marcados, no se envia el valor "yes" por POST  y por lo tanto deja $_POST["index_bots"] sin definir. Codigo comentado hasta que se solucione el bug para que el resto funcione.
		if(!$con->query("INSERT INTO `vdl_config` (`config_id`, `config_name`, `config_value`) VALUES (7, 'INDEX', '".$_POST["index_bots"]."')"))
			printf("Error: %s<br>", mysqli_error($con));
		if(!$con->query("INSERT INTO `vdl_config` (`config_id`, `config_name`, `config_value`) VALUES (8, 'SYNC', '".$_POST["central_sync"]."')"))
			printf("Error: %s<br>", mysqli_error($con));
		*/
		if(!$con->query("INSERT INTO `vdl_config` (`config_id`, `config_name`, `config_value`) VALUES (9, 'STORAGE', 'SERVER')"))
			printf("Error: %s<br>", mysqli_error($con));
		if(!$con->query("INSERT INTO `vdl_config` (`config_id`, `config_name`, `config_value`) VALUES (10, 'BASEDIR', '/Vidali')"))
			printf("Error: %s<br>", mysqli_error($con));
		//Crear usuario
/*		$admin = $_POST["nickname"];
		$password = mysql_real_escape_string(sha1(md5(trim($_POST["password"]))));
		date_default_timezone_set("Europe/London");
		$date = date($_POST["birthdate"]);
		$query = ("INSERT INTO vdl_users (user_id,passwd,nickname,name,location,genre,bday,email,bio,img_prof,prof_nets) VALUES
							 ('$admin','$password','".$_POST["nickname"]."','".$_POST["name"]."','".$_POST["location"]."','".$_POST["sex"]."','$date','".$_POST["email"]."','".$_POST["bio"]."','prof_def',1)");
		$result = mysql_query($query,$connection);
		
		$result = mysql_query("INSERT INTO `vdl_config` (`config_id`, `config_name`, `config_value`) VALUES (4, 'ADMIN', '$admin')",$connection);
		*/
		//header("Location:../index.php?action=register");
		echo "1";
	}
	mysqli_close($con);
?>
Back to Top