/inc/start.php

https://gitlab.com/Etern4l/BitcoinDice · PHP · 60 lines · 43 code · 11 blank · 6 comment · 14 complexity · e7beb84c02ffb70440a8fbc178d36c13 MD5 · raw file

  1. <?php
  2. /*
  3. * © BitcoinDice
  4. */
  5. if (!isset($init)) exit();
  6. session_start();
  7. $included=true;
  8. $conf_c=false;
  9. include './inc/db-conf.php';
  10. if ($conf_c==false) {
  11. header('Location: ./install/');
  12. exit();
  13. }
  14. include './inc/wallet_driver.php';
  15. $wallet=new jsonRPCClient($driver_login);
  16. include './inc/functions.php';
  17. if (empty($_GET['unique'])) {
  18. if (!empty($_COOKIE['unique_D_']) && mysql_num_rows(mysql_query("SELECT `id` FROM `players` WHERE `hash`='".prot($_COOKIE['unique_D_'])."' LIMIT 1"))!=0) {
  19. header('Location: ./?unique='.$_COOKIE['unique_D_'].'# Do Not Share This URL!');
  20. exit();
  21. }
  22. newPlayer($wallet);
  23. }
  24. else { // !empty($_GET['unique'])
  25. if (mysql_num_rows(mysql_query("SELECT `id` FROM `players` WHERE `hash`='".prot($_GET['unique'])."' LIMIT 1"))!=0) {
  26. $player=mysql_fetch_array(mysql_query("SELECT * FROM `players` WHERE `hash`='".prot($_GET['unique'])."' LIMIT 1"));
  27. $unique=prot($_GET['unique']);
  28. setcookie('unique_D_',prot($_GET['unique']),(time()+60*60*24*365*5),'/');
  29. }
  30. else {
  31. setcookie('unique_D_',false,(time()-10000),'/');
  32. header('Location: ./');
  33. exit();
  34. }
  35. }
  36. if ($player['password']!='' && (empty($_COOKIE['protected_D_']) || $_COOKIE['protected_D_']!=$player['password'])) {
  37. if (isset($_GET['bad_'])) echo '<script type="text/javascript">alert(\'Wrong password!\')</script>';
  38. echo '<script type="text/javascript">window.location.href=\'./content/requestAccess.php?_unique='.$unique.'&pass=\'+prompt(\'This URL is password protected. Please, enter password:\');</script>';
  39. exit();
  40. }
  41. $settings=mysql_fetch_array(mysql_query("SELECT * FROM `system` WHERE `id`=1 LIMIT 1"));
  42. if (!file_exists('./themes/'.$settings['activeTheme'].'/main.css') || !file_exists('./themes/'.$settings['activeTheme'].'/frontpage.php')) {
  43. echo '<b>Error!</b> Can\'t load active theme.';
  44. exit();
  45. }
  46. ?>