connect.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. //-- Global Config Variables --\\
  3. //**URL & FOLDERS**\\
  4. define('URL', 'colorstrike.jancokock.me'); //Base url of site
  5. define('ROOT', '/colorstrike/'); //Root folder of project (if URL -> /)
  6. define('PHP', '/colorstrike/php/'); //PHP folder
  7. //**SYSTEM INFO**\\
  8. define('DEV', true); //Development mode or not
  9. //**DATABASE**\\
  10. define('DATABASE_NAME', 'colorstrike'); //Database name
  11. define('DATABASE_USER', 'csadmin'); //Database user
  12. define('DATABASE_PASS', 'aardbei123'); //Database password
  13. //-- Global Config Variables --\\
  14. if(DEV)
  15. {
  16. ini_set("display_errors", "1");
  17. error_reporting(E_ALL);
  18. }
  19. //Create message
  20. function error($page, $msg)
  21. {
  22. $link = ROOT . $page . "?error=" . $msg;
  23. die(header("Location: $link"));
  24. }
  25. function warning($page, $msg)
  26. {
  27. $link = ROOT . $page . "?warning=" . $msg;
  28. die(header("Location: $link"));
  29. }
  30. function success($page, $msg)
  31. {
  32. $link = ROOT . $page . "?success=" . $msg;
  33. die(header("Location: $link"));
  34. }
  35. function info($page, $msg)
  36. {
  37. $link = ROOT . $page . "?info=" . $msg;
  38. die(header("Location: $link"));
  39. }
  40. function url($url)
  41. {
  42. echo(ROOT . $url);
  43. }
  44. function php($url)
  45. {
  46. echo(PHP . $url);
  47. }
  48. function returnurl($url)
  49. {
  50. return (ROOT . $url);
  51. }
  52. function returnphp($url)
  53. {
  54. return (PHP . $url);
  55. }
  56. function format($input)
  57. {
  58. $usec = $input % 1000;
  59. $str_usec = sprintf("%03d", $usec);
  60. $input = floor($input / 1000);
  61. $seconds = $input % 60;
  62. $str_seconds = sprintf("%02d", $seconds);
  63. $input = floor($input / 60);
  64. $minutes = $input % 60;
  65. $str_minutes = sprintf("%02d", $minutes);
  66. $input = floor($input / 60);
  67. $str = $str_minutes . ":" . $str_seconds . ":" . $str_usec;
  68. $array = array(
  69. 'string' => $str,
  70. 'minutes' => $str_minutes,
  71. 'seconds' => $str_seconds,
  72. 'usec' => $str_usec,
  73. 'tminutes' => $minutes,
  74. 'tseconds' => ($minutes*60 + $seconds),
  75. 'tusec' => ($minutes*60 + $seconds*60 + $usec)
  76. );
  77. return $array;
  78. }
  79. $connection = mysqli_connect("localhost", DATABASE_USER, DATABASE_PASS, DATABASE_NAME) or die("Connection Failed: " . mysqli_connect_error());
  80. ?>