api.userstatsinit.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. $ContentContainer = '';
  3. $statsconfig = zbs_LoadConfig();
  4. // set default lang
  5. $lang = $statsconfig['lang'];
  6. // if language change is allowed
  7. if ($statsconfig['allowclang']) {
  8. if (isset($_GET['changelang'])) {
  9. $lang = $_GET['changelang'];
  10. } else {
  11. if (isset($_COOKIE['zbs_lang'])) {
  12. $lang = $_COOKIE['zbs_lang'];
  13. }
  14. }
  15. if (is_string($lang)) {
  16. $lang = vf($lang);
  17. } else {
  18. $lang = $statsconfig['lang'];
  19. }
  20. }
  21. setcookie("zbs_lang", $lang, time() + 2592000);
  22. $langglobal = zbs_LoadLang($lang);
  23. //if enabled login based auth
  24. if ($statsconfig['auth'] == 'login' or $statsconfig['auth'] == 'both') {
  25. if ((isset($_POST['ulogin'])) and isset($_POST['upassword'])) {
  26. if (is_string($_POST['ulogin']) and is_string($_POST['upassword'])) {
  27. //setting auth cookies subroutine
  28. $ulogin = trim(vf($_POST['ulogin']));
  29. $upassword = trim(vf($_POST['upassword']));
  30. $upassword = md5($upassword);
  31. setcookie("ulogin", $ulogin, time() + 2592000);
  32. setcookie("upassword", $upassword, time() + 2592000);
  33. rcms_redirect("index.php");
  34. }
  35. }
  36. if (isset($_POST['ulogout'])) {
  37. setcookie("upassword", 'nopassword', time() + 2592000);
  38. rcms_redirect("index.php");
  39. }
  40. }