setup.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. /*$salt = substr(str_replace('+','.',base64_encode(md5(mt_rand(), true))),0,16);
  32. $rounds = 10000;
  33. $given_hash = crypt($realpass, sprintf('$5$rounds=%d$%s$', $rounds, $salt));
  34. */
  35. $pass = isset( $_POST["pass"] ) ? $_POST["pass"] : "none" ;
  36. if(isset( $_POST["pass"] ) && $pass !== "none"){ $error = "Wrong Password!";}
  37. $parts = explode('$', $hash_pass);
  38. $test_hash = crypt($pass, sprintf('$%s$%s$%s$', $parts[1], $parts[2], $parts[3]));
  39. if(($hash_pass == $test_hash)){
  40. setcookie("logged", "Dashboard", time() + (86400 * 7), "/");
  41. //echo "<meta http-equiv='refresh' content='0'>";
  42. echo "<!DOCTYPE html>";
  43. echo "<head>";
  44. echo "<title>Form submitted</title>";
  45. echo "<script type='text/javascript'>window.parent.location.reload()</script>";
  46. echo "</head>";
  47. echo "<body></body></html>";
  48. }
  49. if((!isset($_COOKIE["logged"]))){
  50. echo "<center><B>Please Login to Contiune<br/><br/>";
  51. echo $error . "<br/>";
  52. 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; }
  53. .css-input:focus { outline:none; } </style>";
  54. echo "<form method='POST'>";
  55. echo "<b>Password: </b><input class='css-input' type='password' name='pass'></input> ";
  56. echo "<input class='css-input' type='submit' name='submit' value='Go'></input>";
  57. echo "</form></center>";
  58. }else{
  59. echo "<!DOCTYPE html>";
  60. echo "<head>";
  61. echo "<title>Form submitted</title>";
  62. echo "<script type='text/javascript'>window.location.replace('settings.php');</script>";
  63. echo "</head>";
  64. echo "<body></body></html>";
  65. }
  66. ?>