Guest User

Untitled

a guest
Apr 11th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. <?
  2.  
  3. //require_once('header.php');
  4.  
  5. $userinfo = $SDK->get_info();
  6.  
  7. if ($SDK->is_loggedin()=="1")
  8. {
  9. $loggedin = true;
  10.  
  11. $username = $userinfo['name'];
  12.  
  13. }
  14.  
  15. $xajax->register(XAJAX_FUNCTION, processLogin);
  16. $xajax->register(XAJAX_FUNCTION, processForm);
  17. $xajax->register(XAJAX_FUNCTION, updateText);
  18. $xajax->register(XAJAX_FUNCTION, logout);
  19.  
  20.  
  21.  
  22. function processLogin($aFormValues)
  23. {
  24. global $SDK;
  25. $objResponse = new xajaxResponse();
  26. // The form was submitted. Lets authenticate!
  27. if (trim($aFormValues['username']) == "" && trim($aFormValues['password']) == "")
  28. {
  29. $smarty->assign('loginMsg', "Please fill in all of the form fields to login");
  30. $bError = true;
  31. }
  32.  
  33. else {
  34.  
  35. if (trim($aFormValues['username']) == "")
  36. {
  37.  
  38. $smarty->assign('loginMsg', "Please enter your username");
  39. $bError = true;
  40.  
  41. }
  42. if (trim($aFormValues['password']) == "")
  43. {
  44.  
  45. $smarty->assign('loginMsg', "Please enter your password");
  46. $bError = true;
  47.  
  48. }
  49.  
  50. }
  51. if(!$bError)
  52. {
  53. $username = trim($aFormValues['username']);
  54. $password = trim($aFormValues['password']);
  55. if ($SDK->login($username, $password))
  56. {
  57.  
  58. // The login worked.
  59. $loginhtml = "You are currently posting as <b>" . $username . "</b>. <br> <form id=\"logout\" action=\"javascript:void(null);\" onsubmit=\"submitLogout();\">
  60. <input value=\"Logout\" name=\"logout\" id=\"logoutButton\" type=\"submit\">
  61. </form>";
  62. $objResponse->Assign("login","innerHTML",$loginhtml);
  63. $smarty->assign('loginMsg', "You have been logged in...");
  64. $objResponse->Script("document.getElementById('loginMsg').style.display='inline';
  65. setTimeout(\"document.getElementById('loginMsg').style.display='none'\",3000); ");
  66.  
  67. }
  68. else
  69. {
  70.  
  71. $smarty->assign('loginMsg', "Please fill in all of the form fields to login");
  72. $objResponse->Assign("loginButton","value","Login");
  73. $objResponse->Assign("loginButton","disabled",false);
  74. $objResponse->Script("document.getElementById('loginMsg').style.display='inline';
  75. setTimeout(\"document.getElementById('loginMsg').style.display='none'\",3000); ");
  76.  
  77. }
  78. }
  79. else
  80. {
  81.  
  82. $objResponse->Assign("loginButton","value","Login");
  83. $objResponse->Assign("loginButton","disabled",false);
  84.  
  85. }
  86.  
  87. return $objResponse;
  88.  
  89. }
  90.  
  91. function logout()
  92. {
  93. global $SDK;
  94. $objResponse = new xajaxResponse();
  95.  
  96.  
  97. $SDK->logout();
  98.  
  99.  
  100. $loginhtml = "You are currently posting as <b>Guest</b>. Login Below: <form id=\"loginbox\" action=\"javascript:void(null);\" onsubmit=\"submitLogin();\">
  101. Username:<input type=\"text\" id=\"username\" name=\"username\"><br>
  102. Password:<input type=\"password\" id=\"password\" name=\"password\"><br>
  103. <input value=\"Login\" name=\"submit\" id=\"loginButton\" type=\"submit\">
  104. </form>";
  105. $objResponse->Assign("login","innerHTML",$loginhtml);
  106. $smarty->assign('loginMsg', "You have been logged out...");
  107. $objResponse->Script("document.getElementById('logoutMsg').style.display='inline';
  108. setTimeout(\"document.getElementById('logoutMsg').style.display='none'\",3000); ");
  109.  
  110.  
  111.  
  112. return $objResponse;
  113.  
  114. }
  115.  
  116.  
  117. ?>
Add Comment
Please, Sign In to add comment