· 9 years ago · Oct 01, 2016, 02:14 PM
1<?php
2@session_start();
3header('Content-type: text/html; charset=utf-8');
4 //ini_set("display_errors",0);
5 //error_reporting(0);
6
7 //---------------------------------------------------------
8 // Requires fichiers database
9 //---------------------------------------------------------
10 require_once('../config/configuration.php');
11
12 $titre = 'Installation de SamantCMS';
13 require_once ("../inc/head.php");
14?>
15 <body>
16
17 <div class="container">
18
19 <center><img src="../install/logo.png">
20
21 <div class="box-shadow well news-body">
22
23 <h2><b>Etape 2 :</b> Configuration de la base de donnée</h2></center>
24 <?php if (isset($_SESSION['utilisateur'])) { ?>
25<?php
26 if(isset($_POST['etape1']))
27 {
28 if(empty($_POST['hote_mysql']) || empty($_POST['login_mysql']) || empty($_POST['nom_mysql']))
29 {
30 echo '<div class="alert alert-danger">Vous devez rentrer vos informations MySQL.</div>';
31 }
32 else
33 {
34
35 $bdd_addr_serveur=$_POST['hote_mysql'];
36 $bdd_login=$_POST['login_mysql'];
37 $bdd_mot_de_passe=$_POST['mdp_mysql'];
38 $bdd_nom_base=$_POST['nom_mysql'];
39
40 try
41 {
42 $bdd = new PDO('mysql:host='.$bdd_addr_serveur.';dbname='.$bdd_nom_base.'', ''.$bdd_login.'', ''.$bdd_mot_de_passe.'');
43 $bdd->exec('SET NAMES utf8');
44
45 $data = '
46 <?php
47 try
48 {
49 $bdd = new PDO("mysql:host='.$bdd_addr_serveur.';dbname='.$bdd_nom_base.'", "'.$bdd_login.'", "'.$bdd_mot_de_passe.'");
50 $bdd->exec("SET NAMES utf8");
51 }
52 catch (Exception $e)
53 {
54 die($e->getMessage());
55 }
56
57 ?>
58 ';
59
60 $fp = fopen("../configuration/baseDonnees.php","w+");
61 fwrite($fp, $data);
62 fclose($fp);
63
64
65 echo '<div class="clear"></div><a href=""><h4>Terminé !</h4></a> <br>';
66
67
68
69 $admin = $bdd->exec("
70 CREATE TABLE IF NOT EXISTS `admin` (
71 `id` int(11) NOT NULL AUTO_INCREMENT,
72 `pseudo` varchar(50) DEFAULT NULL,
73 `email` varchar(50) DEFAULT NULL,
74 `mdp` varchar(50) DEFAULT NULL,
75 `actif` int(5) DEFAULT '0',
76 `aleatoireChiffres` varchar(30) DEFAULT NULL,
77 `dateConnexion` varchar(30) DEFAULT NULL,
78 `ipConnexion` varchar(40) DEFAULT NULL,
79 PRIMARY KEY (`id`)
80 ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;");
81
82 $boutique = $bdd->exec("
83 CREATE TABLE IF NOT EXISTS `boutique` (
84 `id` int(11) NOT NULL AUTO_INCREMENT,
85 `categories_id` varchar(255) NOT NULL,
86 `image` varchar(255) NOT NULL,
87 `prix` text NOT NULL,
88 `commande` text NOT NULL,
89 PRIMARY KEY (`id`)
90 ) ENGINE=MyISAM AUTO_INCREMENT=167 DEFAULT CHARSET=utf8;");
91
92 $boutique_onglets = $bdd->exec("
93 CREATE TABLE IF NOT EXISTS `categories` (
94 `id` int(11) NOT NULL AUTO_INCREMENT,
95 `active` varchar(50) DEFAULT NULL,
96 `nom` varchar(50) DEFAULT NULL,
97 PRIMARY KEY (`id`)
98 ) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1;");
99
100 $historique = $bdd->exec("
101 CREATE TABLE IF NOT EXISTS `forum_main` (
102 `id` int(11) NOT NULL AUTO_INCREMENT,
103 `name` varchar(50) NOT NULL,
104 `description` text NOT NULL,
105 `lastpost` varchar(255) NOT NULL,
106 PRIMARY KEY (`id`)
107 ) ENGINE=MyISAM AUTO_INCREMENT=50 DEFAULT CHARSET=utf8;");
108
109
110 $joueurs = $bdd->exec("
111 CREATE TABLE IF NOT EXISTS `joueurs` (
112 `id` int(11) NOT NULL AUTO_INCREMENT,
113 `pseudo` varchar(32) NOT NULL,
114 `mdp` varchar(40) NOT NULL,
115 `mail` varchar(100) NOT NULL,
116 `user_points` int(255) NOT NULL DEFAULT '0',
117 `user_inscription` int(255) NOT NULL,
118 `vote` int(255) NOT NULL,
119 `date_vote` text NOT NULL,
120 `point_boutique` text NOT NULL,
121 `reponse` varchar(100),
122 PRIMARY KEY (`id`)
123 ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;");
124
125 $news = $bdd->exec("
126 CREATE TABLE IF NOT EXISTS `news` (
127 `id` int(11) NOT NULL AUTO_INCREMENT,
128 `titre` varchar(35) DEFAULT NULL,
129 `date` varchar(50) DEFAULT NULL,
130 `afficher` int(11) NOT NULL,
131 `texte` text,
132 `auteur` varchar(50) DEFAULT NULL,
133 `img` text,
134 PRIMARY KEY (`id`)
135 ) ENGINE=InnoDB AUTO_INCREMENT=46 DEFAULT CHARSET=latin1;");
136
137 $pages = $bdd->exec("
138 CREATE TABLE IF NOT EXISTS `pages` (
139 `id` int(11) NOT NULL AUTO_INCREMENT,
140 `titre` varchar(50) NOT NULL,
141 `page` text NOT NULL,
142 `date` varchar(25) NOT NULL,
143 PRIMARY KEY (`id`)
144 ) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;");
145
146 $probabilites = $bdd->exec("
147 CREATE TABLE IF NOT EXISTS `replies` (
148 `id` int(11) NOT NULL AUTO_INCREMENT,
149 `topicid` varchar(50) DEFAULT NULL,
150 `username` varchar(255) DEFAULT NULL,
151 `message` text DEFAULT NULL,
152 `forum` varchar(25) DEFAULT NULL,
153 `created` varchar(255) DEFAULT NULL,
154 PRIMARY KEY (`id`)
155 ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;");
156
157 $requetesall = $bdd->exec("
158 CREATE TABLE IF NOT EXISTS `shop_vote` (
159 `id` int(11) NOT NULL AUTO_INCREMENT,
160 `image` varchar(255) DEFAULT NULL,
161 `command` varchar(255) DEFAULT NULL,
162 `prix` varchar(255) DEFAULT NULL,
163 PRIMARY KEY (`id`)
164 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
165
166 $staff = $bdd->exec("
167 CREATE TABLE IF NOT EXISTS `staff` (
168 `id` int(5) NOT NULL AUTO_INCREMENT,
169 `nom` varchar(50) NOT NULL,
170 `role` varchar(255) NOT NULL,
171 PRIMARY KEY (`id`)
172 ) ENGINE=MyISAM AUTO_INCREMENT=16 DEFAULT CHARSET=latin1;");
173
174 $vote_ip = $bdd->exec("
175 CREATE TABLE IF NOT EXISTS `vote_sites` (
176 `id` int(7) NOT NULL AUTO_INCREMENT,
177 `nom` varchar(255) DEFAULT NULL,
178 `url` text,
179 `temps` int(10) DEFAULT NULL,
180 `image` text,
181 PRIMARY KEY (`id`)
182 ) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
183
184 ");
185
186 $stats = $bdd->exec("
187 CREATE TABLE IF NOT EXISTS `topics` (
188 `id` int(7) NOT NULL AUTO_INCREMENT,
189 `title` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
190 `starter` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
191 `lastpost` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
192 `forum` int(11) NOT NULL,
193 `message` text CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
194 `created` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
195 `sticky` int(11) NOT NULL DEFAULT '0',
196 PRIMARY KEY (`id`)
197 ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
198 ");
199
200
201 if(count($admin) == 1 && count($boutique) == 1 && count($boutique_onglets) == 1 && count($historique) == 1
202 && count($joueurs) == 1 && count($news) == 1 && count($pages) == 1
203 && count($probabilites) == 1 && count($requetesall) == 1 && count($staff) == 1 && count($vote_ip) == 1
204 && count($stats) == 1 ){
205 echo '<div class="alert alert-success">Les TABLES ont été crées.</div>';
206 echo '<div class="alert alert-success">Etape validée redirection vers la suivante dans 3 secondes</div>';
207 header ("Refresh: 3;URL=../install/compteadmin.php");
208
209 echo '<a href="../install/compteadmin.php" class="btn btn-primary">Etape suivante</a>';
210
211 }
212 }
213 catch (Exception $e)
214 {
215 echo '<div class="alert alert-danger">Erreur : ' . $e->getMessage().'</div>';
216 }
217
218 }
219
220 }?>
221 <br><h4><u>Progression de l'installation</u></h4>
222 <div class="progress progress-striped active">
223 <div class="bar" style="width: 12%;"></div>
224 </div><br>
225
226 <div class="alert alert-info">Assurez vous que le fichier configuration/baseDonnees.php soit en mode CHMOD 777 lors de l'installation</div>
227
228 <form action="" method="post">
229
230 <div class="span6">
231 <div class="form-group">
232 <label for="">Hôte MySQL</label>
233 <input type="text" class="form-control" name="hote_mysql">
234 </div>
235
236 <div class="form-group">
237 <label for="">Login MySQL</label>
238 <input type="text" class="form-control" name="login_mysql">
239 </div>
240
241 <div class="form-group">
242 <label for="">Mot de passe MySQL</label>
243 <input type="password" class="form-control" name="mdp_mysql">
244 </div>
245
246 <div class="form-group">
247 <label for="">Nom de la base MySQL</label>
248 <input type="text" class="form-control" name="nom_mysql">
249 </div>
250
251 <input type="submit" name="etape1" class="btn btn-info" value="Valider">
252
253 </div>
254 </form>
255
256 <div class="clear"></div>
257 </div>
258<?php
259 }else{
260 echo "<div class='alert alert-danger'<font color='white'>Vous navez pas mit de cle d'authentifiction.Vous en avez pas allez sur notre <a href='http://craftacms.com'>forum</a> pour en générer une.</font></div>";
261 }
262 ?>
263 <?php require_once("../install/footer.php");?>
264
265 </div>
266
267 </body>
268</html>