MISAuth.class.inc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /*
  3. * DON'T REMOVE THE FOLLOWING LICENSE
  4. * INFORMATION!
  5. * ----------------------------------
  6. * Copyright by
  7. * Global Cube Business Solutions
  8. * Author: Dennis Ritz
  9. * info@global-cube.de
  10. * 2007-2008
  11. * ----------------------------------
  12. */
  13. class MISAuth extends App {
  14. public function __construct() {
  15. parent::__construct(__file__);
  16. }
  17. /*
  18. * init
  19. * ----
  20. * This function sets the main workaround for this class.
  21. */
  22. public function __init() {
  23. return $this->__AUTH();
  24. }
  25. public function login($p_username = null, $p_password = null) {
  26. //$confirmLogin = $this->confirmLogin($p_username,$p_password);
  27. //if(!$confirmLogin) {
  28. $status = parent::login($p_username,$p_password);
  29. //}
  30. if($status == AUTH_LOGGED_IN) {
  31. return array("CMgr.getMODEL().setUser('".utf8_to_latin1($this->getUsername())." ".$this->_getI18N("logout")."');CMgr.getMODEL().__construct();");
  32. } elseif($status == AUTH_CONFIRM_LOGIN){
  33. return array("Browser.getElementById('inp_password').value='';CMgr.getAUTH().setInfoMsg('".$this->_getI18N("authConfirmLoginMsg")."');");
  34. } else {
  35. return array("CMgr.getAUTH().setInfoMsg('".$this->_getI18N("authFailedMsg")."');");
  36. }
  37. }
  38. public function logout() {
  39. $MISConfig = new MISConfig();
  40. $status = parent::logout();
  41. $MISConfig->setConfigFile($MISConfig->getDefaultConfigFile());
  42. $projectDOM = new DOMDocument('1.0', 'utf-8');
  43. $projectDOM->load($MISConfig->getConfigFile());
  44. $projectXpath = new DOMXpath($projectDOM);
  45. $configNode = $projectXpath->query("/Configuration")->item(0);
  46. $configName = ($configNode instanceof DOMElement) ? $configNode->getAttribute("Name") : '';
  47. return array('CMgr.getMODEL().__construct();CMgr.getMODEL().setConfig("'.$configName.'");CMgr.getMODEL().setUser("'.$this->_getI18N("login").'");');
  48. }
  49. public function getMain() {
  50. $eval = "Browser.getElementById('inp_username').focus();CMgr.getMODEL().setLocationName('');CMgr.getMODEL().setLeftToolbar('');CMgr.getMODEL().setLeftFootbar('');CMgr.getMODEL().setMainToolbar('');CMgr.getMODEL().setMainFootbar('');CMgr.getMODEL().setMainHead('');CMgr.getMODEL().setUser('".$this->_getI18N("login")."');";
  51. switch($this->getAuthStatus()) {
  52. case AUTH_FAILED: $logonInfoMsg = $this->_getI18N("authFailedMsg");
  53. break;
  54. case AUTH_LOGGED_IN: $logonInfoMsg = $this->_getI18N("authLoggedInMsg");
  55. break;
  56. case AUTH_NOT_LOGGED: $logonInfoMsg = $this->_getI18N("authNotLoggedMsg");
  57. break;
  58. case AUTH_LOGGED_OUT: $logonInfoMsg = $this->_getI18N("authLoggedOutMsg");
  59. break;
  60. case AUTH_TIMEOUT: $logonInfoMsg = $this->_getI18N("authTimeoutMsg");
  61. break;
  62. case AUTH_EXPIRED: $logonInfoMsg = $this->_getI18N("authExpiredMsg");
  63. break;
  64. case AUTH_ERROR: $logonInfoMsg = $this->_getI18N("authErrorMsg");
  65. break;
  66. case AUTH_SECURITY: $logonInfoMsg = $this->_getI18N("authSecurityMsg");
  67. break;
  68. case AUTH_CONFIRM_LOGIN:$logonInfoMsg = $this->_getI18N("authConfirmLoginMsg");
  69. break;
  70. }
  71. if($this->getAuthStatus() != AUTH_LOGGED_IN && $this->getAuthStatus() != AUTH_TIMEOUT) {
  72. $eval .= "Cookie.eraseAll();Browser.getElementById('inp_username').focus();";
  73. }
  74. return array('<div id="logon" style="margin:auto;"><img style="position:relative;left:200px;top:0px;" src="img/MISView/company.png">
  75. <div class="title">'.$this->_getI18N("welcome").'</div>
  76. <div class="content"><div id="logonInfoMsg">'.$logonInfoMsg.'</div>
  77. <form name="loginForm" encoding="utf-8" action="" target="_self" method="post" class="" onsubmit="return Form.submit(this,\'MISAuth\',\'login\',\'username\',\'password\');">
  78. <fieldset>
  79. <legend>'.$this->_getI18N("auth").'</legend>
  80. <table>
  81. <tr>
  82. <td><label for="inp_username">'.$this->_getI18N("username").'</label>:</td>
  83. <td><input type="text" id="inp_username" name="username"></td>
  84. </tr>
  85. <tr>
  86. <td><label for="inp_password">'.$this->_getI18N("password").'</label>:</td>
  87. <td><input type="password" id="inp_password" name="password"></td>
  88. </tr>
  89. <tr>
  90. <td>&nbsp;</td>
  91. <td><input type="submit" value="'.$this->_getI18N("loginBtn").'"></td>
  92. </tr>
  93. </table>
  94. </fieldset>
  95. </form>
  96. </div>
  97. </div>',
  98. $eval);
  99. }
  100. }
  101. ?>