Advertisement
Guest User

Here is the index.php that contains the database connection

a guest
Jan 17th, 2017
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. session_start();
  4. error_reporting(0);
  5. if(file_exists("./install.php")) {
  6. header("Location: ./install.php");
  7. }
  8. include("includes/config.php");
  9. $db = new mysqli($CONF['host'], $CONF['user'], $CONF['pass'], $CONF['name']);
  10. if ($db->connect_errno) {
  11. echo "Failed to connect to MySQL: (" . $db->connect_errno . ") " . $db->connect_error;
  12. }
  13. $db->set_charset("utf8");
  14. $settingsQuery = $db->query("SELECT * FROM settings ORDER BY id DESC LIMIT 1");
  15. $settings = $settingsQuery->fetch_assoc();
  16. include("includes/functions.php");
  17. include(getLanguage($settings['url'],null,null));
  18. if(checkSession()) {
  19. $time = time();
  20. $update = $db->query("UPDATE users SET acttime='$time' WHERE id='$_SESSION[suid]'");
  21. if(idinfo($_SESSION['suid'],"status") == "2") {
  22. unset($_SESSION['suid']);
  23. unset($_SESSION['susername']);
  24. session_unset();
  25. session_destroy();
  26. header("Location: $settings[url]");
  27. }
  28. } else {
  29. if($_COOKIE['mexchange_user_id']) {
  30. $_SESSION['suid'] = $_COOKIE['mexchange_user_id'];
  31. $_SESSION['susername'] = $_COOKIE['mexchange_username'];
  32. header("Location: $settings[url]");
  33. }
  34. }
  35.  
  36. check_unpayed();
  37.  
  38. if(isset($_GET['refid'])) {
  39. $_SESSION['refid'] = protect($_GET['refid']);
  40. header("Location: $settings[url]");
  41. }
  42.  
  43. include("sources/header.php");
  44. $a = protect($_GET['a']);
  45. switch($a) {
  46. case "login": include("sources/login.php"); break;
  47. case "register": include("sources/register.php"); break;
  48. case "forgot-password": include("sources/forgot-password.php"); break;
  49. case "password-recovery": include("sources/password-recovery.php"); break;
  50. case "check_payment": include("sources/check_payment.php"); break;
  51. case "account": include("sources/account.php"); break;
  52. case "page": include("sources/page.php"); break;
  53. case "testimonials": include("sources/testimonials.php"); break;
  54. case "submit-testimonial": include("sources/submit-testimonial.php"); break;
  55. case "logout":
  56. unset($_SESSION['suid']);
  57. unset($_SESSION['susername']);
  58. unset($_COOKIE['mexchange_user_id']);
  59. unset($_COOKIE['mexchange_username']);
  60. setcookie("mexchange_user_id", "", time() - (86400 * 30), '/'); // 86400 = 1 day
  61. setcookie("mexchange_username", "", time() - (86400 * 30), '/'); // 86400 = 1 day
  62. session_unset();
  63. session_destroy();
  64. header("Location: $settings[url]");
  65. break;
  66. default: include("sources/homepage.php");
  67. }
  68. include("sources/footer.php");
  69. mysqli_close($db);
  70. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement