install.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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('secure_user_vars', array_merge($_POST, $_GET));
  43. if (isset($_SESSION['currentUser'])) {
  44. $myUser =unserialize($_SESSION['currentUser']);
  45. }
  46. if(!is_writable (__ROOT__.UPLOAD_PATH)) throw new Exception('Le dossier '.__ROOT__.UPLOAD_PATH.' doit être accessible en ecriture, merci de taper la commande linux <code>sudo chown -R www-data:www-data '.__ROOT__.UPLOAD_PATH.'</code> ou de régler le dossier en écriture via votre client ftp');
  47. if(!is_writable (dirname(__ROOT__.DATABASE_PATH))) throw new Exception('Le dossier '.dirname(__ROOT__.DATABASE_PATH).' doit être accessible en ecriture, merci de taper la commande linux <code>sudo chown -R www-data:www-data '.dirname(__ROOT__.DATABASE_PATH).'</code> ou de régler le dossier en écriture via votre client ftp');
  48. if(!file_exists(__ROOT__.SKETCH_PATH)) mkdir(__ROOT__.SKETCH_PATH);
  49. 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.');
  50. if(!extension_loaded('gd') || !function_exists('gd_info')) throw new Exception('L\'extension php GD2 est requise, veuillez installer GD2 (sous linux : <code>sudo apt-get install php5-gd && service apache2 restart</code>)');
  51. if(!in_array('sqlite',PDO::getAvailableDrivers())) throw new Exception('Le driver SQLITE est requis, veuillez installer sqlite3 (sous linux : <code>sudo apt-get install php5-sqlite && service apache2 restart</code>)');
  52. if (!file_exists(__ROOT__.PART_PATH)) mkdir(__ROOT__.PART_PATH,0755,true);
  53. //Class entities
  54. Entity::install(__ROOT__.'class');
  55. $admin = new User();
  56. $admin->login = 'admin';
  57. $admin->password = User::password_encrypt('admin');
  58. $admin->rank = 'ADMIN';
  59. $admin->save();
  60. ?>
  61. <div class="alert alert-success alert-dismissable">
  62. <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
  63. <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.
  64. </div>
  65. <?php
  66. } catch (Exception $e) {
  67. ?>
  68. <div class="alert alert-danger">
  69. <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
  70. <strong>Oops!</strong> <?php echo $e->getMessage();
  71. ?>
  72. </div>
  73. <?php
  74. } ?>
  75. <a class="btn btn-primary" href="index.php">Revenir à l'index</a>
  76. </div>
  77. <!-- body -->
  78. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
  79. <script>window.jQuery || document.write('<script src="js/vendor/jquery-1.11.2.min.js"><\/script>')</script>
  80. <script src="js/vendor/bootflat.min.js"></script>
  81. <script src="js/vendor/mustache.min.js"></script>
  82. <script src="js/plugins.js"></script>
  83. <script src="js/main.js"></script>
  84. </body>
  85. </html>