setup.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. if(isset( $_POST["pass"] ) && $pass !== "none"){ $error = "Wrong Password!";}
  33. $parts = explode('$', $hash_pass);
  34. $test_hash = crypt($pass, sprintf('$%s$%s$%s$', $parts[1], $parts[2], $parts[3]));
  35. if(($hash_pass == $test_hash)){
  36. setcookie("logged", $hash_pass, time() + (86400 * 7), "/");
  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($_COOKIE["logged"]))){
  45. echo "<center><B>Please Login to Contiune<br/><br/>";
  46. echo $error . "<br/>";
  47. 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; }
  48. .css-input:focus { outline:none; } </style>";
  49. echo "<form method='POST'>";
  50. echo "<b>Password: </b><input class='css-input' type='password' name='pass'></input> ";
  51. echo "<input class='css-input' type='submit' name='submit' value='Go'></input>";
  52. echo "</form></center>";
  53. }else{
  54. echo "<!DOCTYPE html>";
  55. echo "<head>";
  56. echo "<title>Form submitted</title>";
  57. echo "<script type='text/javascript'>window.location.replace('settings.php');</script>";
  58. echo "</head>";
  59. echo "<body></body></html>";
  60. }
  61. ?>