Guest User

Untitled

a guest
Jul 3rd, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. <?php
  2.  
  3. //@ validate inclusion
  4. if(!defined('VALID_ACL_')) exit('direct access is not allowed.');
  5.  
  6. class Registration{
  7. public function check_user_exist(){
  8.  
  9. }
  10. public function form(){
  11. global $ACL_LANG;
  12. $htmlForm = '<form id="frmregister">'.
  13. '<label>';
  14. switch(LOGIN_METHOD) {
  15. case 'both':
  16. $htmlForm .= $ACL_LANG['USERNAME'].'/'.$ACL_LANG['EMAIL'];
  17. break;
  18. case 'email':
  19. $htmlForm .= $ACL_LANG['EMAIL'];
  20. break;
  21. default:
  22. $htmlForm .= $ACL_LANG['USERNAME'];
  23. break;
  24. }
  25. $htmlForm .= ':</label>'.
  26. '<input type="text" name="u" id="u" class="textfield" />'.
  27. '<label>'.$ACL_LANG['PASSWORD'].'</label>'.
  28. '<input type="password" name="p" id="p" class="textfield" />'.
  29. '<input type="password" name="cp" id="cp" class="textfield" />'.
  30. '<input type="submit" name="btn" id="btn" class="buttonfield" value="'.$ACL_LANG['LOGIN'].'" />'.
  31. '</form>';
  32. return $htmlForm;
  33. }
  34.  
  35. public function register($u,$p){
  36. global $db_config,$user_config;
  37.  
  38. if (USEDB){
  39. if($u&&$p){
  40. $this->db = @mysql_connect($db_config['server'],$db_config['user'],$db_config['pass']);
  41. if(!$this->db) return false;
  42.  
  43. $opendb = @mysql_select_db($db_config['name'], $this->db);
  44. if(!$opendb) return false;
  45.  
  46. $sql = "INSERT INTO".$db_config['tbl_user']." WHERE ";
  47. switch(LOGIN_METHOD){
  48. case 'both':
  49. $sql .= "(username='".mysql_real_escape_string($u)."' OR useremail='".mysql_real_escape_string($u)."')";
  50. break;
  51. case 'email':
  52. $sql .= "useremail='".mysql_real_escape_string($u)."'";
  53. break;
  54. default:
  55. $sql .= "username='".mysql_real_escape_string($u)."'";
  56. break;
  57. }
  58. $sql .= " AND userpassword = '".md5($p)."'";
  59.  
  60. $rs = @mysql_query($sql,$this->db);
  61.  
  62. if(!$rs) return false;
  63.  
  64. if(mysql_num_rows($rs)) {
  65. $this->set_session(array_merge(mysql_fetch_assoc($rs),array('expires'=>time()+(45*60))));
  66. $return = true;
  67. }
  68. mysql_free_result($rs);
  69. mysql_close($this->db);
  70. unset($rs,$sql);
  71. }
  72. }else{
  73. for($i=0;$i<count($user_config);$i++){
  74. switch(LOGIN_METHOD) {
  75. case 'both':
  76. if(($user_config[$i]['username']==$u||$user_config[$i]['useremail']==$u) &&
  77. $user_config[$i]['userpassword']==md5($p)) { $return = true;}
  78. break;
  79. case 'email':
  80. if($user_config[$i]['useremail']==$u &&
  81. $user_config[$i]['userpassword']==md5($p)) { $return = true;}
  82. break;
  83. default:
  84. if($user_config[$i]['username']==$u &&
  85. $user_config[$i]['userpassword']==md5($p)) { $return = true;}
  86. break;
  87. }
  88.  
  89. if($return===true){
  90. $this->set_session(array_merge($user_config[$i],array('expires'=>time()+(45*60))));
  91. }
  92. }
  93. }
  94.  
  95. return $return;
  96.  
  97. }
  98. private function notify_user(){
  99.  
  100. }
  101.  
  102.  
  103. }
  104. ?>
Add Comment
Please, Sign In to add comment