install.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <!doctype html>
  2. <html class="no-js" lang="">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  6. <title></title>
  7. <meta name="description" content="">
  8. <meta name="viewport" content="width=device-width, initial-scale=1">
  9. <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,800,700,400italic,600italic,700italic,800italic,300italic" rel="stylesheet" type="text/css">
  10. <link rel="stylesheet" href="css/bootflat.min.css">
  11. <link rel="stylesheet" href="css/font-awesome.min.css">
  12. <link rel="stylesheet" href="css/main.css">
  13. </head>
  14. <body>
  15. <!-- menu -->
  16. <nav role="navigation" class="navbar navbar-inverse">
  17. <div class="container-fluid">
  18. <!-- Brand and toggle get grouped for better mobile display -->
  19. <div class="navbar-header">
  20. <button data-target="#bs-example-navbar-collapse-5" data-toggle="collapse" class="navbar-toggle" type="button">
  21. <span class="sr-only">Toggle navigation</span>
  22. <span class="icon-bar"></span>
  23. <span class="icon-bar"></span>
  24. <span class="icon-bar"></span>
  25. </button>
  26. <a href="index.php" class="navbar-brand">Hackpoint</a>
  27. </div>
  28. <!-- Collect the nav links, forms, and other content for toggling -->
  29. </div><!-- /.container-fluid -->
  30. </nav>
  31. <!-- menu -->
  32. <!-- body -->
  33. <div class="container-fluid">
  34. <?php
  35. try{
  36. mb_internal_encoding('UTF-8');
  37. require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'constant.php');
  38. require_once(__ROOT__.'function.php');
  39. date_default_timezone_set(TIME_ZONE);
  40. set_error_handler('errorToException');
  41. spl_autoload_register('app_autoloader');
  42. $_ = array_map('htmlentities',array_merge($_POST,$_GET));
  43. if(isset($_SESSION['currentUser']))
  44. $myUser =unserialize($_SESSION['currentUser']);
  45. if(file_exists(__ROOT__.DATABASE_PATH) && filesize(__ROOT__.DATABASE_PATH)>0) throw new Exception('Base déjà installée, pour réinstaller la base, supprimez le fichier '.DATABASE_PATH.', puis rechargez cette page.');
  46. //Class entities
  47. Entity::install(__ROOT__.'class');
  48. $admin = new User();
  49. $admin->login = 'admin';
  50. $admin->password = User::password_encrypt('admin');
  51. $admin->rank = 'ADMIN';
  52. $admin->save();
  53. ?>
  54. <div class="alert alert-success alert-dismissable">
  55. <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
  56. <strong>Succès!</strong> La base est bien installée, l'utilisateur par défaut est <code>admin:admin</code>, pensez à changer le mot de passe rapidemment.
  57. </div>
  58. <?php
  59. }catch(Exception $e){
  60. ?>
  61. <div class="alert alert-danger">
  62. <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
  63. <strong>Oops!</strong> <?php echo $e->getMessage(); ?>
  64. </div>
  65. <?php } ?>
  66. <a class="btn btn-primary" href="index.php">Revenir à l'index</a>
  67. </div>
  68. <!-- body -->
  69. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
  70. <script>window.jQuery || document.write('<script src="js/vendor/jquery-1.11.2.min.js"><\/script>')</script>
  71. <script src="js/vendor/bootflat.min.js"></script>
  72. <script src="js/vendor/mustache.min.js"></script>
  73. <script src="js/plugins.js"></script>
  74. <script src="js/main.js"></script>
  75. </body>
  76. </html>