Bonjour,
Je suis en train de créer un fichier d'installation pour mon script
Le fichier /install/ se compose de ceci
/install/
/install/index.php/
/install/sql.sql/
Voici le contenu du fichier index.php
Mais le problème c'est que je ne sais pas comment inclure le fichier sql.sql dans le fichier index.php
Voir ligne 17
Code PHP :
<?php
if(isset($_POST['settings'])) {
if(empty($_POST['sitename']) || empty($_POST['siteurl']) || empty($_POST['slogan']) || empty($_POST['pagination']) || empty($_POST['password'])) {
echo 'Sorry, one or more fields was left empty.';
} else {
if(!ctype_digit($_POST['pagination'])) {
echo 'Sorry, pagination MUST be a number';
} else {
if(!is_writable('../thumbnails/') || !is_writable('../files/')) {
echo 'Sorry, thumbnail folder and files folder must be chmodded to 777.';
} else {
include('../inc/config.php');
// Create settings table
$query = mysql_query;include ('sql.sql');
echo 'Ads table created!<br /><br />';
}
}
}
} elseif(isset($_GET['settings'])) {
echo '<form name="settings" method="post" action="index.php">
Nom du site:<br />
<input type="text" name="sitename" /><br />
Site URL:<br />
<input type="text" name="siteurl" /><br />
Site Slogan:<br />
<input type="text" name="slogan" /><br />
Non d\'utilisateur:<br/>
<input type="text" name="username" /><br/>
Mot de passe admin:<br />
<input type="password" name="password" /><br />
Adresse E-mail:
<input type="text" name="mail" /><br />
Votre Copyright:
<input type="text" name="copyright" /><br/><br/>
<input type="submit" name="settings" value="Valider" />
</form>';
} elseif(isset($_POST['database'])) {
if(empty($_POST['host']) || empty($_POST['dbuser']) || empty($_POST['dbname']) || empty($_POST['dbpassword'])) {
echo 'Sorry, one or more fields was left empty.';
} else {
$config = "../inc/config.php";
if(!is_writable($config)) {
die("Error: Config file not CHMODDED");
} else {
$connect = @mysql_connect($_POST['host'], $_POST['dbuser'], $_POST['dbpassword']);
$database = @mysql_select_db($_POST['dbname']);
if($connect === false || $database === false) {
echo 'Could not connect to the database';
} else {
$fh = fopen($config, 'w') or die("can't open file");
$stringData = '<?php
$host = "' . $_POST['host'] . '";
$database = "' . $_POST['dbname'] . '";
$username = "' . $_POST['dbuser'] . '";
$password = "' . $_POST['dbpassword'] . '";
mysql_connect($host, $username, $password);
mysql_select_db($database) or die("Cannot connect to the database");
?>';
fwrite($fh, $stringData);
fclose($fh);
echo 'Config created successfully.<br /><a href="?settings=true">Click here to proceed!</a>
';
}
}
}
} else {
echo '
<h2>Bienvenue sur CMS-Rencontre!</h2>
<p>Please ensure that you have chmodded the /inc/config.php file and the files and thumbnails folder to 777, otherwise the script will not install.</p>
<form name="database" method="post" action="index.php">
Host:<br />
<input type="text" name="host" /><br />
DB Name:<br />
<input type="text" name="dbname" /><br />
DB Username:<br />
<input type="text" name="dbuser" /><br />
DB Passowrd:<br />
<input type="text" name="dbpassword" /><br /><br />
<input type="submit" name="database" value="Go" />
</form>';
} ?>
Merci d'avance pour votre aide