setup.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. //ini_set('display_errors',1); error_reporting(E_ALL);
  3. $configfile = 'settings.ini.php';
  4. $examplefile = 'example.ini.php';
  5. if(!file_exists($filename) && !file_exists($examplefile)){
  6. die('You are missing the ini configuration file, please download and refresh this page');
  7. }
  8. if(!file_exists($configfile)){
  9. echo "The file $configfile does not exist, we will make a copy now...<br/><br/>";
  10. if (!is_writable(dirname($examplefile)))
  11. die('We don\'t have access to write to the current directory, please change the permissions to this directory.');
  12. else {
  13. copy($examplefile, $configfile);
  14. sleep(2);
  15. echo "<!DOCTYPE html>";
  16. echo "<head>";
  17. echo "<title>Form submitted</title>";
  18. echo "<script type='text/javascript'>window.parent.location.reload()</script>";
  19. echo "</head>";
  20. echo "<body></body></html>";
  21. }
  22. }
  23. try {
  24. $config = parse_ini_file('settings.ini.php', true);
  25. } catch(Exception $e) {
  26. die('<b>Unable to read config.ini.php. Did you rename it from settings.ini.php-example?</b><br><br>Error message: ' .$e->getMessage());
  27. }
  28. foreach ($config as $keyname => $section) {
  29. if(($keyname == "general")) { $hash_pass = $section["password"]; }
  30. }
  31. $pass = isset( $_POST["pass"] ) ? $_POST["pass"] : "none" ;
  32. $parts = explode('$', $hash_pass);
  33. $test_hash = crypt($pass, sprintf('$%s$%s$%s$', $parts[1], $parts[2], $parts[3]));
  34. if(($hash_pass == $test_hash)){
  35. setcookie("logged", $hash_pass, time() + (86400 * 7), "/");
  36. $error = "You got it dude!";
  37. echo "<!DOCTYPE html>";
  38. echo "<head>";
  39. echo "<title>Form submitted</title>";
  40. echo "<script type='text/javascript'>window.parent.location.reload()</script>";
  41. echo "</head>";
  42. echo "<body></body></html>";
  43. }
  44. if(isset( $_POST["pass"] ) && ($hash_pass !== $test_hash)){
  45. $error = "Wrong Password!";
  46. }
  47. if((!isset($_COOKIE["logged"]))){
  48. echo "<center><B>Please Login to Contiune<br/><br/>";
  49. echo $error . "<br/>";
  50. echo "<style> .css-input { padding:8px; border-radius:47px; border-width:3px; border-style:double; font-size:17px; border-color:#0a090a; box-shadow: 2px 6px 8px 0px rgba(42,42,42,.75); font-weight:bold; }
  51. .css-input:focus { outline:none; } </style>";
  52. echo "<form method='POST'>";
  53. echo "<b>Password: </b><input class='css-input' type='password' name='pass'></input> ";
  54. echo "<input class='css-input' type='submit' name='submit' value='Go'></input>";
  55. echo "</form></center>";
  56. }else{
  57. echo "<!DOCTYPE html>";
  58. echo "<head>";
  59. echo "<title>Form submitted</title>";
  60. echo "<script type='text/javascript'>window.location.replace('settings.php');</script>";
  61. echo "</head>";
  62. echo "<body></body></html>";
  63. }
  64. ?>