Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 37.05 KB | None | 0 0
  1. <?php
  2.  
  3. require_once(ROOT."module/model.class.php");
  4. class account_obj{
  5. public $info;
  6. public $_utable;
  7. public $link;
  8. public $db_server;
  9. public function __construct(){
  10. global $db_table;
  11. global $db_server;
  12. global $error_info;
  13. $this->error_info = $error_info;
  14. $this->db_server = $db_server;
  15. $this->link["main"] = new model($db_server["main"],"main");
  16. $this->_utable = $db_table["users"];
  17. $this->_ufieldstable = $db_table["userfields"];
  18. $this->_corptable = $db_table["corporation"];
  19. }
  20. function register_user_info($data){
  21. global $global_role_info;
  22. $email  = $data["email"];
  23. $corp_code  = $data["corp_code"];
  24. $original_passwd = $data["passwd"];
  25. $passwd =   md5($original_passwd);
  26. $info = array();
  27. $error_no = "";
  28. $match = check_mail($email);
  29. if ($email == ""){
  30. $error_no = "8";
  31. }else{
  32. if (!$match){
  33. $error_no = "8";
  34. }else if ($this->is_email_exists($email)){
  35. $error_no = "9";
  36. }
  37. }
  38. if ($error_no == "") {
  39. if ($this->is_corp_exists($corp_code)){
  40. $error_no = "10";
  41. }
  42. }
  43. if ($error_no == ""){
  44. $info["email"] = $email;
  45. $info["passwd"] = $passwd;
  46. $time = my_time();
  47. $info["created"] = $time;
  48. $info["original_passwd"] = $original_passwd;
  49. $info["username"] = $data["username"];
  50. $info["firstname"] = $data["firstname"];
  51. $info["lastname"] = $data["lastname"];
  52. $info["userpass"] = $passwd;
  53. $info["corp_code"] = $data["corp_code"];
  54. $info["corp_name"] = $data["corp_name"];
  55. $role = $global_role_info["administrator"];
  56. $info["role_id"] = $role;
  57. $info["blocked"] = "0";
  58. $info['is_emailverified'] = "pass";
  59. $info['zone_val'] = $data['zone_val'];
  60. $info_arr = $this->add_user_info($info,$role);
  61. $info["request"] = $info_arr;
  62. }
  63. if ($error_no==""&&!$info_arr){
  64. $error_no = "11";
  65. }
  66. $log_type = $error_no ?$error_no : 0;
  67. $reason = $log_type."|".$role."|".$info["blocked"]."|".$info['is_emailverified'];
  68. $log_data = array(
  69. 'email'=>$email,
  70. 'operation'=>'register',
  71. 'reason'=>$reason,
  72. 'created'=>$time,
  73. );
  74. $sys_obj = new sys_obj();
  75. $sys_obj->add_log($log_data);
  76. if ($error_no!=""){
  77. $info = array();
  78. }
  79. $return_arr = array(
  80. "info"=>$info,
  81. "error_no"=>$error_no
  82. );
  83. return $return_arr;
  84. }
  85. function add_user_info($data,$role='administrator'){
  86. $err = false;
  87. $ip = get_ip();
  88. $expire_time = mktime(date(H),date(i),date(s),date(m)+1,date(d),date(Y));
  89. $this->link["main"]->query_data("START TRANSACTION");
  90. $fields = array("email","username","password","role_id","blocked","is_emailverified","created","upgrade_date","expire_date");
  91. $value = array($data["email"],$data["username"],$data["passwd"],$role,$data["blocked"],$data['is_emailverified'],$data["created"],$data["created"],$expire_time);
  92. $lastid = $this->link["main"]->insert_data($this->_utable,$fields,$value,"","",$debug=false,$lock=false);
  93. if ($lastid>0){
  94. $fields_1 = array("user_id","email","username","first_name","last_name","ip");
  95. $value_1 = array($lastid,$data['email'],$data['username'],$data['firstname'],$data['lastname'],$ip);
  96. $ufield_id = $this->link["main"]->insert_data($this->_ufieldstable,$fields_1,$value_1,"","",$debug=false,$lock=false);
  97. if ($ufield_id>0){
  98. $fields_2 = array("user_id","corporation_code","corporation_name","is_registerd","zone_val","set_code","created","allow_portal");
  99. $value_2 = array($lastid,$data['corp_code'],$data['corp_name'],1,$data['zone_val'],1,$data['created'],1);
  100. $corp_id = $this->link["main"]->insert_data($this->_corptable,$fields_2,$value_2,"","",$debug=false,$lock=false);
  101. if ($corp_id>0){
  102. $fields_3 = array("corporation_id","modified");
  103. $value_3 = array($corp_id,$data['created']);
  104. $where = "id=".$lastid;
  105. $us = $this->link["main"]->update_data($this->_utable,$fields_3,$value_3,$where,"","",$debug=false);
  106. $err = $us ?false : true;
  107. }else {
  108. $err = true;
  109. }
  110. }else {
  111. $err = true;
  112. }
  113. }else {
  114. $err = true;
  115. }
  116. if($err) {
  117. $this->link["main"]->query_data("ROLLBACK");
  118. $user_info = array();
  119. }else {
  120. $this->link["main"]->query_data("COMMIT");
  121. $user_info = array(
  122. 'userid'=>$lastid,
  123. 'corp_id'=>$corp_id,
  124. );
  125. }
  126. return $user_info;
  127. }
  128. function is_email_exists($email,$where=""){
  129. $where = empty($where) ?"email='$email'": "email='$email' and ".$where;
  130. $rs = $this->link["main"]->select_data($this->_utable,"count(1) as nums",$where,"-1","-1","","",false);
  131. return (intval($rs[0]["nums"])>0) ?true : false;
  132. }
  133. function is_trial_exists($email,$where=""){
  134. $where = empty($where) ?"email='$email'": "email='$email' and ".$where;
  135. $rs = $this->link["main"]->select_data($this->_utable,"id,password",$where,"0","1","","",false);
  136. return is_array($rs) ?$rs : "";
  137. }
  138. function is_corp_exists($corp_code,$where=""){
  139. $where = empty($where) ?"corporation_code='$corp_code'": "corporation_code='$corp_code' and ".$where;
  140. $rs = $this->link["main"]->select_data($this->_corptable,"count(1) as nums",$where,"-1","-1","","",false);
  141. return (intval($rs[0]["nums"])>0) ?true : false;
  142. }
  143. function check_corp_exists($corp_id,$where=""){
  144. $where = empty($where) ?"id='$corp_id'": "id='$corp_id' and ".$where;
  145. $rs = $this->link["main"]->select_data($this->_corptable,"count(1) as nums",$where,"-1","-1","","",false);
  146. return (intval($rs[0]["nums"])>0) ?true : false;
  147. }
  148. function register_full_user($data){
  149. global $global_role_info;
  150. $email  = $data["email"];
  151. $regkey = $data["regcode"];
  152. $corp_code = $data['corp_code'];
  153. $original_passwd = $data["passwd"];
  154. $passwd = md5($original_passwd);
  155. $info = array();
  156. $error_no = "";
  157. $up_flag = false;
  158. $match = check_mail($email);
  159. if ($email==""){
  160. $error_no = "8";
  161. }else{
  162. if (!$match){
  163. $error_no = "8";
  164. }else if($chereg = $this->is_trial_exists($email)){
  165. if (is_array($chereg) &&$chereg !=""){
  166. if ($passwd === $chereg["password"]){
  167. $up_flag = true;
  168. }else{
  169. $error_no = "15";
  170. }
  171. }
  172. }
  173. }
  174. if ($error_no == ""){
  175. $where = $up_flag ?" user_id<>".$chereg['id'] : "";
  176. if ($corp_code == ""){
  177. $error_no = 16;
  178. }else {
  179. if ($this->is_corp_exists($corp_code,$where)){
  180. $error_no = "10";
  181. }
  182. }
  183. }
  184. if ($regkey == ""){
  185. $error_no = "17";
  186. }else{
  187. $purchased = 1;
  188. }
  189. if ($error_no == ""){
  190. $info["email"] = $email;
  191. $info["username"] = $data["username"];
  192. $info["firstname"] = $data["firstname"];
  193. $info["lastname"] = $data["lastname"];
  194. $info["passwd"] = $passwd;
  195. $time = my_time();
  196. $info["created"] = $time;
  197. $info["regkey"] = $regkey;
  198. $info["corp_code"] = $corp_code;
  199. $info["corp_name"] = $data["corp_name"];
  200. $info["up_flag"] = $up_flag;
  201. $role = $global_role_info["administrator"];
  202. $info["blocked"] = "1";
  203. $info['is_emailverified'] = "pass";
  204. $info['purchased'] = $purchased;
  205. $info_arr = $this->add_full_user($info,$role);
  206. $info["request"] = $info_arr;
  207. }
  208. if ($error_no==""&&!$info_arr){
  209. $error_no = "11";
  210. }
  211. $log_type = $error_no ?$error_no : 0;
  212. $reason = $log_type."|".$role."|".$info["blocked"]."|".$info['is_emailverified']."|".$regkey;
  213. $log_data = array(
  214. 'email'=>$email,
  215. 'operation'=>'register',
  216. 'reason'=>$reason,
  217. 'created'=>$time,
  218. );
  219. $sys_obj = new sys_obj();
  220. $sys_obj->add_log($log_data);
  221. if ($error_no!=""){
  222. $info = array();
  223. }
  224. $return_arr = array(
  225. "info"=>$info,
  226. "error_no"=>$error_no
  227. );
  228. return $return_arr;
  229. }
  230. function add_full_user($data,$role='administrator'){
  231. $err = false;
  232. $this->link["main"]->query_data("START TRANSACTION");
  233. $expire_time = mktime(date(H),date(i),date(s),date(m)+6,date(d),date(Y));
  234. if ($data["up_flag"]){
  235. $where = "email='$data[email]'";
  236. $user_info = $this->link["main"]->select_data($this->_utable,"id,corporation_id",$where,"0","1","","",false);
  237. if ($user_info){
  238. $fields = array("username","role_id","blocked","purchased","registration_code","is_emailverified","modified","license_type","upgrade_date","expire_date");
  239. $value = array($data["username"],$role,$data['blocked'],$data['purchased'],$data['regkey'],$data['is_emailverified'],$data['created'],"unlimited",$data['created'],$expire_time);
  240. $where = "id=".$user_info["id"];
  241. $us = $this->link["main"]->update_data($this->_utable,$fields,$value,$where,"","",$debug=false);
  242. if ($us){
  243. $fields_1 = array("username","first_name","last_name");
  244. $value_1 = array($data["username"],$data['firstname'],$data['lastname']);
  245. $where_1 = "user_id=".$user_info["id"];
  246. $fields_us = $this->link["main"]->update_data($this->_ufieldstable,$fields_1,$value_1,$where_1,"","",$debug=false);
  247. if ($fields_us){
  248. $fields_2 = array("corporation_code","corporation_name","modified");
  249. $value_2 = array($data["corp_code"],$data["corp_name"],$data["created"]);
  250. $corp_us = $this->link["main"]->update_data($this->_corptable,$fields_2,$value_2,$where_1,"","",$debug=false);
  251. $err = $corp_us ?false : true;
  252. }else {
  253. $err = true;
  254. }
  255. }else {
  256. $err = true;
  257. }
  258. }else {
  259. $err = true;
  260. }
  261. }else {
  262. $fields = array("email","username","password","role_id","blocked","is_emailverified","purchased","registration_code","created","license_type","upgrade_date","expire_date");
  263. $value = array($data["email"],$data["username"],$data["passwd"],$role,$data['blocked'],$data['is_emailverified'],$data["purchased"],$data['regkey'],$data["created"],"unlimited",$data['created'],$expire_time);
  264. $lastid = $this->link["main"]->insert_data($this->_utable,$fields,$value,"","",$debug=false,$lock=false);
  265. if ($lastid>0){
  266. $ip = get_ip();
  267. $fields_1 = array("user_id","email","username","first_name","last_name","ip");
  268. $value_1 = array($lastid,$data['email'],$data['username'],$data['firstname'],$data['lastname'],$ip);
  269. $ufields_id = $this->link["main"]->insert_data($this->_ufieldstable,$fields_1,$value_1,"","",$debug=false,$lock=false);
  270. if ($ufields_id){
  271. $fields_2 = array("user_id","corporation_code","corporation_name","is_registerd","created");
  272. $value_2 = array($lastid,$data['corp_code'],$data['corp_name'],1,$data['created']);
  273. $corp_id = $this->link["main"]->insert_data($this->_corptable,$fields_2,$value_2,"","",$debug=false,$lock=false);
  274. if ($corp_id>0){
  275. $fields_3 = array("corporation_id","modified");
  276. $value_3 = array($corp_id,$data['created']);
  277. $where = "id=".$lastid;
  278. $us = $this->link["main"]->update_data($this->_utable,$fields_3,$value_3,$where,"","",false);
  279. $err = $us ?false : true;
  280. $user_info = array(
  281. 'id'=>$lastid,
  282. 'corporation_id'=>$corp_id,
  283. );
  284. }else {
  285. $err = true;
  286. }
  287. }else {
  288. $err = true;
  289. }
  290. }else {
  291. $err = true;
  292. }
  293. }
  294. if($err) {
  295. $this->link["main"]->query_data("ROLLBACK");
  296. $user_info = array();
  297. }else {
  298. $this->link["main"]->query_data("COMMIT");
  299. }
  300. return $user_info;
  301. }
  302. function reg_part_user($data){
  303. global $global_role_info,$config;
  304. $email  = $data["email"];
  305. $corp_id = $data['corp_id'];
  306. $original_passwd = $data["passwd"];
  307. $passwd =   md5($original_passwd);
  308. $info = array();
  309. $error_no = "";
  310. $match = check_mail($email);
  311. if ($email==""){
  312. $error_no = "8";
  313. }else{
  314. if (!$match){
  315. $error_no = "8";
  316. }else if ($this->is_email_exists($email)){
  317. $error_no = "9";
  318. }
  319. }
  320. if ($error_no == ""){
  321. $auth = $this->check_reg_auth($email,$corp_id);
  322. $error_no = isset($auth['error_no']) ?$auth['error_no'] : "";
  323. $reg_verified = isset($auth['reg_verified']) ?$auth['reg_verified'] : "";
  324. }
  325. $user_obj = new user_obj();
  326. $where = "id=".$corp_id;
  327. $corp_info = $user_obj->get_corpinfo_bycondition($result_fields="user_id,corporation_code",$where,$start="0",$limit="1",$order="",$debug=false);
  328. if ($corp_info){
  329. $info['corp_code'] = $corp_info['corporation_code'];
  330. }else {
  331. $error_no = 11;
  332. }
  333. $time = my_time();
  334. if (!$reg_verified &&$error_no ==''){
  335. if (INSTALLTYPE == STANDALONE){
  336. $limit_participant = sys_authcode(LICENSELIMIT,'DECODE','W');
  337. }else {
  338. $where = "id='$corp_info[user_id]'";
  339. $rs = $user_obj->get_userinfo_bycondition('license_type,expire_date',$where,0,1,'',false);
  340. $license_type = $rs['license_type'] ?$rs['license_type'] : $config['trial_license'];
  341. $where = "license_level='$license_type' AND (status=1 || status=2)";
  342. $rs2 = $user_obj->get_licenseinfo_bycondition('limit_participant',$where,0,1,'','',false);
  343. $limit_participant = $rs2['limit_participant'];
  344. }
  345. $where = "corporation_id='$corp_id' and role_id='participant' and blocked =1 AND is_emailverified='pass'";
  346. $user_rs = $user_obj->get_userinfo_bycondition("count(1) as nums",$where);
  347. $participant_nums = $user_rs[0]["nums"] >0 ?$user_rs[0]["nums"] : 0;
  348. $error_no = ($participant_nums >= $limit_participant) &&$limit_participant !='Unlimited'?18 : '';
  349. if ($error_no ==''&&INSTALLTYPE != STANDALONE){
  350. $error_no = $rs['expire_date'] <$time ?19 : '';
  351. }
  352. }
  353. $info["email"] = $email;
  354. $info["passwd"] = $passwd;
  355. $info["username"] = $data["username"];
  356. $info["firstname"] = $data["firstname"];
  357. $info["lastname"] = $data["lastname"];
  358. $info["created"] = $time;
  359. $info["corp_id"] = $corp_id;
  360. $info["reg_verified"] = $reg_verified;
  361. $info["is_emailverified"] = "pass";
  362. $info["blocked"] = $reg_verified ?2 : 1 ;
  363. $role = $global_role_info["participant"];
  364. if ($error_no == ""){
  365. $info_arr = $this->add_part_user($info,$role);
  366. $info["request"] = $info_arr;
  367. }
  368. if ($error_no==""&&!$info_arr){
  369. $error_no = "11";
  370. }else {
  371. }
  372. $log_type = $error_no ?$error_no : 0;
  373. $reason = $log_type."|".$role."|".$info["blocked"]."|".$info["is_emailverified"];
  374. $log_data = array(
  375. 'email'=>$email,
  376. 'operation'=>'register',
  377. 'reason'=>$reason,
  378. 'created'=>$time,
  379. );
  380. $sys_obj = new sys_obj();
  381. $sys_obj->add_log($log_data);
  382. if ($error_no !=""){
  383. $info = array();
  384. }
  385. $return_arr = array(
  386. "info"=>$info,
  387. "error_no"=>$error_no
  388. );
  389. return $return_arr;
  390. }
  391. function check_reg_auth($email,$corp_id){
  392. $email_limit = true;
  393. $error_no = "";
  394. $where = empty($where) ?"id='$corp_id'": "id='$corp_id' and ".$where;
  395. $rs = $this->link["main"]->select_data($this->_corptable,"*",$where,"0","1","","",false);
  396. if ($rs) {
  397. if ($rs['is_registerd'] == '0') {
  398. $error_no = "13";
  399. }else {
  400. if ($rs['limit_register'] != ''){
  401. $email_limit_arr = explode(",",$rs['limit_register']);
  402. foreach ($email_limit_arr as $item) {
  403. $pattern = str_replace("*","(.*)",$item);
  404. $match = preg_match("/$pattern/is",$email,$reg);
  405. if($match &&$reg[0] == $email){
  406. $email_limit = false;
  407. break;
  408. }
  409. }
  410. }else {
  411. $email_limit = false;
  412. }
  413. $error_no = $email_limit ?"14": "";
  414. }
  415. }else {
  416. $error_no = "12";
  417. }
  418. $is_register_verified = isset($rs['is_register_verified']) ?$rs['is_register_verified'] : "";
  419. $return_arr = array(
  420. 'error_no'=>$error_no,
  421. 'reg_verified'=>$is_register_verified  
  422. );
  423. return $return_arr;
  424. }
  425. function add_part_user($data,$role='participant'){
  426. $err = false;
  427. $this->link["main"]->query_data("START TRANSACTION");
  428. $fields = array("email","username","password","role_id","corporation_id","blocked","is_emailverified","setup_code","created");
  429. $value = array($data["email"],$data["username"],$data["passwd"],$role,$data['corp_id'],$data["blocked"],$data['is_emailverified'],$data['setup_code'],$data["created"]);
  430. $lastid = $this->link["main"]->insert_data($this->_utable,$fields,$value,"","",$debug=false,$lock=false);
  431. if ($lastid>0){
  432. $ip = get_ip();
  433. $fields = array("user_id","username","email","first_name","last_name","ip");
  434. $value = array($lastid,$data["username"],$data["email"],$data['firstname'],$data['lastname'],$ip);
  435. $rs = $this->link["main"]->insert_data($this->_ufieldstable,$fields,$value,"","",$debug=false,$lock=false);
  436. $err = $rs ?false : true;
  437. }else {
  438. $err = true;
  439. }
  440. if($err) {
  441. $this->link["main"]->query_data("ROLLBACK");
  442. $user_info = array();
  443. }else {
  444. $this->link["main"]->query_data("COMMIT");
  445. $user_info = array(
  446. 'id'=>$lastid
  447. );
  448. }
  449. return $user_info;
  450. }
  451. function register_role_info($data){
  452. global $global_role_info,$config;
  453. $checkreg_email = $data["reg_email"];
  454. $checkreg_firstname = $data["reg_firstname"];
  455. $checkreg_lastname = $data["reg_lastname"];
  456. $checkreg_passwd    = $data["reg_passwd"];
  457. $corp_id = $data['corp_id'];
  458. $user_id = $data['user_id'];
  459. $import_group_id = $data['import_group_id'];
  460. $addition_import_group_id = $data['addition_import_group_id'];
  461. $is_purchased = $data['is_purchased'];
  462. $issend_mail = $data['send_email'];
  463. $return_arr = array();
  464. $register_group = array();
  465. $error_no = "";
  466. $info = array();
  467. $valid_email = array();
  468. $exists_email = array();
  469. $error_email = array();
  470. $reg_email = array();
  471. $user_obj = new user_obj();
  472. $isRegPublisher = $data["role"] == $global_role_info['publisher'] ?true : false;
  473. $isRegParticipant = $data["role"] == $global_role_info['participant'] ?true : false;
  474. if ($_FILES['reg_file']['error'] == 0 &&$_FILES['reg_file']['size'] >0){
  475. $return_arr = $this->parse_register_file($_FILES,$data["set_passwd"]);
  476. if ($return_arr['error_no']){
  477. $error_no = $return_arr['error_no'];
  478. }else {
  479. $email_arr = $return_arr['reg_info'];
  480. $register_group = $return_arr['group_info'];
  481. }
  482. }elseif ($data['reg_type'] !='file') {
  483. $tmp_email = array();
  484. if ($checkreg_email &&is_array($checkreg_email)){
  485. foreach ($checkreg_email as $key =>$row){
  486. if ($row ==''&&$checkreg_firstname[$key] ==''&&$checkreg_lastname[$key] ==''&&$checkreg_passwd[$key]=='') continue;
  487. $email_arr[$key]['email'] = trim($row);
  488. $email_arr[$key]['firstname'] = trim($checkreg_firstname[$key]);
  489. $email_arr[$key]['lastname'] = trim($checkreg_lastname[$key]);
  490. $cur_pwd = trim($checkreg_passwd[$key]);
  491. $email_arr[$key]['group_id'] = $import_group_id;
  492. if($email_arr[$key]['email'] == ''){
  493. $error_no = 3;
  494. break;
  495. }
  496. if($email_arr[$key]['firstname']==''||$email_arr[$key]['lastname'] ==''){
  497. $error_no = 15;
  498. break;
  499. }
  500. if ($data['set_passwd'] ==2){
  501. if (strlen($cur_pwd) >5 &&strlen($cur_pwd) <33){
  502. $email_arr[$key]['passwd'] = $cur_pwd;
  503. }else {
  504. $error_no = 1;
  505. break;
  506. }
  507. }
  508. }
  509. }
  510. }
  511. if($error_no ==""&&(!is_array($email_arr) ||count($email_arr)<=0)){
  512. $error_no = 3;
  513. }
  514. if ($error_no == ""){
  515. foreach ($email_arr as $key =>$row){
  516. $email = is_array($row) ?$row['email'] : $row;
  517. if (in_array($email,$tmp_email)){
  518. continue;
  519. }else {
  520. $tmp_email[] = $email;
  521. }
  522. $firstname = is_array($row) ?str_replace("'","&#039;",$row['firstname']) : "";
  523. $lastname = is_array($row) ?str_replace("'","&#039;",$row['lastname']) : "";
  524. $username = $firstname ||$lastname ?$firstname." ".$lastname : substr($email,0,strpos($email,'@'));
  525. $match = check_mail($email);
  526. if ($match){
  527. if ($this->is_email_exists($email)){
  528. $exists_email[] = $email;
  529. }else {
  530. $valid_email[$key]['email'] = $email;
  531. $valid_email[$key]['username'] = $username;
  532. $valid_email[$key]['firstname'] = $firstname;
  533. $valid_email[$key]['lastname'] = $lastname;
  534. $valid_email[$key]['passwd'] = isset($row['passwd']) ?$row['passwd'] : '';
  535. $valid_email[$key]['group'] = $row['group']>0 ?$row['group'] : 0;
  536. $valid_email[$key]['group_id'] = $row['group_id']>0 ?$row['group_id'] : 0;
  537. }
  538. }else {
  539. if ($email){
  540. $error_email[] = $email;
  541. }
  542. }
  543. }
  544. if ($error_email){
  545. $error_no = 9;
  546. $error_info = implode(',',$error_email);
  547. }elseif ($exists_email){
  548. $error_no = 10;
  549. $error_info = implode(',',$exists_email);
  550. }
  551. }
  552. if ($valid_email &&$error_no ==''){
  553. $where = "id=".$corp_id;
  554. $result_fields = "corporation_code,user_id,corporation_name";
  555. $corp_info = $user_obj->get_corpinfo_byconditon($result_fields,$where,$start="0",$limit="1",$order="",$debug=false);
  556. if (!$is_purchased &&$isRegPublisher &&INSTALLTYPE != STANDALONE){
  557. $result_fields = "COUNT(*) AS nums";
  558. $where = "(role_id='$global_role_info[administrator]' or role_id='$global_role_info[publisher]') AND corporation_id='$corp_id' AND blocked<>-1";
  559. $qid = $user_obj->get_userinfo_bycondition($result_fields,$where);
  560. if ($qid[0]['nums'] >$config['reg_limit_publisher']){
  561. $error_no = "11";
  562. }
  563. }
  564. if ($error_no == ''){
  565. if ($register_group){
  566. $group_info = array();
  567. $group_type = $isRegPublisher ?1 : 0;
  568. foreach ($register_group as $key =>$item){
  569. $where = "corporation_id='$corp_id' AND group_name='$item' and type='$group_type' ";
  570. $rs = $user_obj->get_groupinfo_bycondition($result_fields="count(1) as nums,id",$where,-1,-1,"","",$debug=false);
  571. if($rs&&$rs[0]["nums"]>0){
  572. $group_info[$item] = $rs[0]['id'];
  573. unset($register_group[$key]);
  574. }
  575. }
  576. if($error_no == ""){
  577. foreach ($register_group as $item){
  578. $g_data = array(
  579. 'corp_id'=>$corp_id,
  580. 'group_name'=>$item,
  581. 'type'=>$group_type,
  582. 'user_id'=>$user_id,
  583. 'description'=>'',
  584. 'group_parent_id'=>0,
  585. 'is_checked'=>1
  586. );
  587. $g_rs = $user_obj->add_group($g_data);
  588. $group_info[$item] = $g_rs['group_id'] >0 ?$g_rs['group_id'] : 0;
  589. }
  590. }
  591. }
  592. if($error_no == ""){
  593. foreach ($valid_email as $key =>$row){
  594. $tmp_group = array();
  595. $reg_email[$key]['email'] = $row['email'];
  596. $reg_email[$key]['username'] = $row['username'];
  597. $reg_email[$key]['firstname'] = $row['firstname'];
  598. $reg_email[$key]['lastname'] = $row['lastname'];
  599. $reg_email[$key]['group_id'] = $row['group_id'];
  600. if ($data["set_passwd"] == 1){
  601. $reg_email[$key]['passwd'] = $data["passwd"];
  602. $reg_email[$key]['auth_passwd'] = md5($data["passwd"]);
  603. }elseif ($data["set_passwd"] == 2){
  604. $reg_email[$key]['passwd'] = $row["passwd"];
  605. $reg_email[$key]['auth_passwd'] = md5($row["passwd"]);
  606. }else {
  607. $auto_passwd = set_rand_password();
  608. $reg_email[$key]['passwd'] = $auto_passwd;
  609. $reg_email[$key]['auth_passwd'] = md5($auto_passwd);
  610. }
  611. if ($row['group']){
  612. foreach ($row['group'] as $val){
  613. if ($group_info[$val] >0){
  614. $tmp_group[] = $group_info[$val];
  615. }
  616. }
  617. }
  618. if ($import_group_id >0 &&!in_array($import_group_id,$tmp_group)){
  619. $tmp_group[] = $import_group_id;
  620. }
  621. if ($addition_import_group_id >0 &&!in_array($addition_import_group_id,$tmp_group)){
  622. $tmp_group[] = $addition_import_group_id;
  623. }
  624. if(count($tmp_group) >0){
  625. $reg_email[$key]['group_id'] = @implode(',',$tmp_group);
  626. }else{
  627. $reg_email[$key]['group_id'] = 0;
  628. }
  629. }
  630. }
  631. }
  632. }elseif ($error_no == "") {
  633. $error_no = 4;
  634. }
  635. $info['reg_email'] = $reg_email;
  636. $info['exists_email'] = $exists_email;
  637. $info['error_email'] = $error_email;
  638. $time = my_time();
  639. $info["created"] = $time;
  640. $info["corp_id"] = $corp_id;
  641. $info["role"] = $data["role"];
  642. $info["blocked"] = "1";
  643. $info["is_emailverified"] = "pass";
  644. $info['corp_code'] = $corp_info['corporation_code'];
  645. $account_data['reg_nums'] = count($info['reg_email']);
  646. $account_data['corp_id'] = $corp_id;
  647. if($data["admin_type"] == "publisher") {
  648. $account_data["user_id"] = $corp_info["user_id"];
  649. }else {
  650. $account_data['user_id'] = $user_id;
  651. }
  652. $reg_status = $user_obj->check_account_rule($account_data);
  653. $error_no = $error_no ?$error_no : $reg_status;
  654. if ($error_no == ""&&$reg_email){
  655. $info_arr = $this->add_role_info($info);
  656. }
  657. if ($error_no==""&&!$info_arr){
  658. $error_no = "5";
  659. }
  660. unset($_FILES);
  661. $log_type = $error_no ?$error_no : 0;
  662. $reason = $log_type."|".$info["role"]."|".$info["blocked"]."|".$info["is_emailverified"];
  663. $log_data = array(
  664. 'email'=>$reg_email,
  665. 'operation'=>'register',
  666. 'reason'=>$reason,
  667. 'created'=>$time,
  668. );
  669. $sys_obj = new sys_obj();
  670. $sys_obj->add_log($log_data);
  671. $section = 'register_role_action';
  672. if ($error_no){
  673. $log_type = ($error_no ==5 ||$error_no == 6 ||$error_no == 8) ?'error': 'warn';
  674. }else {
  675. $log_type = 'notice';
  676. }
  677. if ($exists_email){
  678. $exists_str = implode(',',$exists_email);
  679. }
  680. if ($error_email){
  681. $error_str = implode(',',$error_email);
  682. }
  683. $reg_mailstr = array2sqlstr($reg_email,'email');
  684. $log_str = 'regemail:'.$reg_mailstr.';extemail:'.$exists_str.';erremail:'.$error_str.";operuid:".$user_id.";errno:".$error_no;
  685. sys_insert_log($log_str,$section,$log_type);
  686. if ($error_no !=""){
  687. $info = array();
  688. }elseif ($info_arr &&$reg_email &&$issend_mail){
  689. $sys_obj = new sys_obj();
  690. $tpl_id = "register_notify";
  691. $sitedomain = INSTALLTYPE == STANDALONE ?DOMAIN_MAIN : get_corp_url($info["corp_code"]);
  692. $cur_userinfo = $user_obj->get_userinfo_byuserid($user_id,'email,username','',false);
  693. foreach ($reg_email as $item){
  694. $tpl_vars = array(
  695. "corp_id"=>$corp_id,
  696. "email_from"=>$cur_userinfo['email'],
  697. "email_fromname"=>$cur_userinfo['username'],
  698. "email_to"=>$item['email'],
  699. "passwd"=>$item['passwd'],
  700. "username"=>$item['username'],
  701. "sitedomain"=>$sitedomain
  702. );
  703. $recipient = array('0'=>$item['email']);
  704. $sys_obj->add_mail_queue($tpl_id,$tpl_vars,$time_to_send="",$ip="",$sender="",$recipient,$try_sent=0,$delete_after_send=1,$ishtml=1);
  705. }
  706. if (INSTALLTYPE == STANDALONE){
  707. include_once(ROOT."shell/mailer/mailer_behavior.class.php");
  708. $mail_behavior = new mailer_behavior();
  709. $mail_behavior->send_mail_queue();
  710. }
  711. }
  712. $return_arr = array(
  713. "info"=>$info,
  714. "error_no"=>$error_no,
  715. "error_info"=>$error_info
  716. );
  717. return $return_arr;
  718. }
  719. function parse_register_file($_FILES,$set_passwd){
  720. global $parse_file_type;
  721. $error_no = "";
  722. $reg_info = array();
  723. $group_arr = array();
  724. if ($_FILES["reg_file"]["error"] == UPLOAD_ERR_OK &&$_FILES["reg_file"]["size"] >0) {
  725. $tmp_name = $_FILES["reg_file"]["tmp_name"];
  726. $name = $_FILES["reg_file"]["name"];
  727. $file_match = array();
  728. preg_match("/(.+)\.([^.]+)$/i",$name,$file_match);
  729. $file_type = strtolower($file_match[2]);
  730. $file_name = strtolower($file_match[0]);
  731. if(in_array($file_type,$parse_file_type)){
  732. if(!$fh = fopen($tmp_name,'r')) {
  733. $error_no = 8;
  734. }else {
  735. $cont2arr = array();
  736. $index = 0;
  737. while(!feof($fh)){
  738. $index++;
  739. $line = fgets($fh,255);
  740. if (!$line ||$index == 1) {
  741. continue;
  742. }
  743. $cont2arr = split(',',$line);
  744. $reg_info[$index]['email'] = escape_ctrl_char(trim($cont2arr[0]));
  745. $reg_info[$index]['passwd'] = trim($cont2arr[1]);
  746. $reg_info[$index]['firstname'] = escape_ctrl_char(trim($cont2arr[2]));
  747. $reg_info[$index]['lastname'] = escape_ctrl_char(trim($cont2arr[3]));
  748. $reg_info[$index]['username'] = $reg_info[$index]['firstname']." ".$reg_info[$index]['lastname'];
  749. $reg_info[$index]['email'] = escape_ctrl_char(trim($cont2arr[0]));
  750. if ($set_passwd == 2){
  751. if ($reg_info[$index]['passwd'] !=''&&strlen($reg_info[$index]['passwd']) >5){
  752. }else {
  753. $error_no = 14;
  754. }
  755. }else {
  756. $reg_info[$index]['passwd'] = '';
  757. }
  758. $cur_group = array();
  759. $tmp_group1 = escape_ctrl_char(trim($cont2arr[4]));
  760. $tmp_group2 = escape_ctrl_char(trim($cont2arr[5]));
  761. $tmp_group3 = escape_ctrl_char(trim($cont2arr[6]));
  762. if ($tmp_group1){
  763. $cur_group[] = $tmp_group1;
  764. $group_arr[] = $tmp_group1;
  765. }
  766. if ($tmp_group2){
  767. $cur_group[] = $tmp_group2;
  768. $group_arr[] = $tmp_group2;
  769. }
  770. if ($tmp_group3){
  771. $cur_group[] = $tmp_group3;
  772. $group_arr[] = $tmp_group3;
  773. }
  774. $reg_info[$index]['group'] = array_unique($cur_group);
  775. $group_arr = array_unique($group_arr);
  776. }
  777. }
  778. }else {
  779. $error_no = 7;
  780. }
  781. }else {
  782. $error_no = 6;
  783. }
  784. if ($error_no){
  785. $reg_info = array();
  786. }
  787. $return_arr = array(
  788. "error_no"=>$error_no,
  789. "reg_info"=>$reg_info,
  790. "group_info"=>$group_arr
  791. );
  792. return $return_arr;
  793. }
  794. function add_role_info($data){
  795. $err = false;
  796. $field_info = array();
  797. $reg_email = $data['reg_email'];
  798. $index = 1;
  799. $value_str = "";
  800. $fields_str = "email, username, password, role_id, corporation_id, blocked, is_emailverified, group_id, created";
  801. $int_total = count($reg_email);
  802. foreach ($reg_email as $item){
  803. $field_info[$item['email']]['firstname'] = $item['firstname'];
  804. $field_info[$item['email']]['lastname'] = $item['lastname'];
  805. $field_info[$item['email']]['phone'] = $item['phone'];
  806. $field_info[$item['email']]['fax'] = $item['fax'];
  807. $field_info[$item['email']]['address'] = $item['address'];
  808. $field_info[$item['email']]['desc'] = $item['desc'];
  809. if ($int_total == $index){
  810. $value_str .= "('$item[email]','$item[username]','$item[auth_passwd]','$data[role]','$data[corp_id]','$data[blocked]','$data[is_emailverified]','$item[group_id]','$data[created]')";
  811. }else {
  812. $value_str .= "('$item[email]','$item[username]','$item[auth_passwd]','$data[role]','$data[corp_id]','$data[blocked]','$data[is_emailverified]','$item[group_id]','$data[created]'),";
  813. }
  814. $index++;
  815. }
  816. $this->link["main"]->query_data("START TRANSACTION");
  817. $sql = "INSERT INTO ".$this->_utable."(".$fields_str.") VALUES ".$value_str;
  818. $rs = $this->link["main"]->query_data($sql,false);
  819. if ($rs) {
  820. $email_str = array2sqlstr($reg_email,"email");
  821. $where = "email IN ({$email_str})";
  822. $user_rs = $this->link["main"]->select_data($this->_utable,"id,email,username",$where,"-1","-1","","",false);
  823. if ($user_rs){
  824. $ip = get_ip();
  825. $fields_str = "user_id,email,username,first_name,last_name,phone,fax,address,description,ip";
  826. $total = count($user_rs);
  827. $index = 1;
  828. $value_str = "";
  829. foreach ($user_rs as $row){
  830. $first_name = $field_info[$row['email']]['firstname'];
  831. $last_name = $field_info[$row['email']]['lastname'];
  832. $phone = $field_info[$row['email']]['phone'];
  833. $fax = $field_info[$row['email']]['fax'];
  834. $address = $field_info[$row['email']]['address'];
  835. $desc = $field_info[$row['email']]['desc'];
  836. if ($total == $index){
  837. $value_str .= "('$row[id]','$row[email]','$row[username]','$first_name','$last_name','$phone','$fax','$address','$desc','$ip')";
  838. }else {
  839. $value_str .= "('$row[id]','$row[email]','$row[username]','$first_name','$last_name','$phone','$fax','$address','$desc','$ip'),";
  840. }
  841. $index++;
  842. }
  843. $ufields_sql = "INSERT INTO ".$this->_ufieldstable."(".$fields_str.") VALUES ".$value_str;
  844. $ufields_rs = $this->link["main"]->query_data($ufields_sql,false);
  845. $err = $ufields_rs ?false : true;
  846. }else {
  847. $err = true;
  848. }
  849. }else {
  850. $err = true;
  851. }
  852. if($err) {
  853. $this->link["main"]->query_data("ROLLBACK");
  854. $return = false;
  855. }else {
  856. $this->link["main"]->query_data("COMMIT");
  857. $return = true;
  858. }
  859. return $return;
  860. }
  861. function auto_reg_guest($data){
  862. global $lang;
  863. $Tcookie = get_qms_cookie("Tcookie");
  864. $is_allow_cookie = false;
  865. if($Tcookie!=""){
  866. $is_allow_cookie = true;
  867. }else{
  868. $is_allow_cookie = false;
  869. }
  870. if(isset($_SESSION["Tcookie"])){
  871. $retry_nums = $_SESSION["Tcookie"];
  872. }else{
  873. $retry_nums = 0;
  874. }
  875. if($retry_nums >3){
  876. $msg = $lang['cookie_forbiden'];
  877. $msg = urlencode($msg);
  878. report_error($msg);
  879. die();
  880. }
  881. if(!$is_allow_cookie){
  882. $cookies = array("Tcookie"=>"qms");
  883. set_qms_cookie($cookies,-2);
  884. $Tcookie = get_qms_cookie("Tcookie");
  885. session_register("Tcookie");
  886. $retry_nums = intval($retry_nums) +1;
  887. $_SESSION["Tcookie"] = $retry_nums;
  888. $this_url = "index.php?module=account&submod=account&method=sys_experience";
  889. redirect($this_url);
  890. die();
  891. }
  892. $guid_code = "";
  893. if($_SERVER["HTTP_USER_AGENT"] !=""&&$_SERVER["HTTP_ACCEPT"] !=""&&$_SERVER["HTTP_CONNECTION"]){
  894. $qms_registerid = get_qms_cookie("qms_registerid");
  895. if($qms_registerid!=""){
  896. $up_auth_id = $qms_registerid;
  897. $id_arr = explode("|",base64_decode(sys_authcode($up_auth_id,'DECODE')));
  898. $cur_userid = $id_arr[0];
  899. $guid_code = $id_arr[1];
  900. }else{
  901. require_once(ROOT."phplibs/php_guid.class.php");
  902. $guid = new Guid();
  903. $guid_code = $guid->toString();
  904. $guid_code = "{".$guid_code."}";
  905. $cur_userid = "-1";
  906. $up_auth_id = sys_authcode(base64_encode($cur_userid."|".$guid_code),"ENCODE");
  907. $qms_registerid = $up_auth_id;
  908. $cookies = array("qms_registerid"=>$up_auth_id);
  909. set_qms_cookie($cookies,-2);
  910. }
  911. }
  912. preg_match("/\{([0-9a-fA-F]{8})-([0-9a-fA-F]{4})-([0-9a-fA-F]{4})-([0-9a-fA-F]{4})-([0-9a-fA-F]{12})\}/i",$guid_code,$match);
  913. if($cur_userid == "-1"&&$match[1]!=""&&$match[2]!=""){
  914. $is_register = false;
  915. if($_SERVER["HTTP_USER_AGENT"] !=""&&$_SERVER["HTTP_ACCEPT"] !=""&&$_SERVER["HTTP_CONNECTION"]){
  916. $is_register = true;
  917. }
  918. if($is_register){
  919. $register_data = array("register_id"=>$up_auth_id);
  920. $return_arr = $this->auto_register($register_data);
  921. if(!isset($return_arr["error_no"]) ||$return_arr["error_no"] == ""){
  922. $register_info = $return_arr["info"];
  923. $login_data = array(
  924. "email"=>$register_info["email"],
  925. "userpass"=>md5($register_info["original_passwd"]),
  926. "mode"=>"autologin",
  927. );
  928. $user_obj = new user_obj();
  929. $login_rs = $user_obj->user_login($login_data);
  930. $user_info = $login_rs;
  931. if(!isset($login_rs["error_no"]) ||$login_rs["error_no"] == ""){
  932. $up_auth_id = $login_rs["auth_id"];
  933. $cookies = array(
  934. "qms_cur_userid"=>$login_rs["userid"],
  935. "qms_cur_email"=>$login_rs["email"],
  936. "qms_username"=>$login_rs["username"],
  937. "qms_pass"=>sys_authcode($login_data["userpass"],'ENCODE'),
  938. "qms_is_try"=>$login_rs["is_try"],
  939. "qms_auth_id"=>$login_rs['auth_id'],
  940. );
  941. $arr = array("qms_dcur_userid"=>"qms_test");
  942. set_qms_cookie($cookies,-2);
  943. }
  944. return $user_info;
  945. }
  946. }
  947. }
  948. return false;
  949. }
  950. function auto_reg_anonymous($data){
  951. global $lang;
  952. $guid_code = "";
  953. $corp_id = $data['corporation_id'];
  954. require_once(ROOT."phplibs/php_guid.class.php");
  955. $guid = new Guid();
  956. $guid_code = $guid->toString();
  957. $guid_code = "{".$guid_code."}";
  958. $cur_userid = "-1";
  959. $up_auth_id = sys_authcode(base64_encode($cur_userid."|".$guid_code."|".$corp_id),"ENCODE");
  960. $qms_registerid = $up_auth_id;
  961. preg_match("/\{([0-9a-fA-F]{8})-([0-9a-fA-F]{4})-([0-9a-fA-F]{4})-([0-9a-fA-F]{4})-([0-9a-fA-F]{12})\}/i",$guid_code,$match);
  962. if($cur_userid == "-1"&&$match[1]!=""&&$match[2]!=""){
  963. $is_register = true;
  964. }else {
  965. $error_no = 2;
  966. }
  967. $register_data = array(
  968. "register_id"=>$up_auth_id,
  969. "error_no"=>$error_no
  970. );
  971. return $register_data;
  972. }
  973. function auto_register($data){
  974. global $global_guest_user_info,$global_role_info;
  975. $register_data = array();
  976. $register_data = array();
  977. $error_no = "";
  978. $individ_email = $data['email'];
  979. $id_arr = explode("|",base64_decode(sys_authcode($data["register_id"],"DECODE")));
  980. $cur_userid = $id_arr[0];
  981. $setup_code = $id_arr[1];
  982. preg_match("/\{([0-9a-fA-F]{8})-([0-9a-fA-F]{4})-([0-9a-fA-F]{4})-([0-9a-fA-F]{4})-([0-9a-fA-F]{12})\}/i",$setup_code,$match);
  983. $email_hex = $match[1].$match[2].$match[3].$match[4].$match[5];
  984. if($match[1]!=""&&$match[2]!=""&&$match[3]!=""&&$match[4]!=""&&$match[5]!=""){
  985. $email = $email_hex.$global_guest_user_info["email"];
  986. $nick = $individ_email ?$individ_email : $global_guest_user_info["nick"].time();
  987. $original_passwd = set_rand_password();
  988. $passwd =   md5($original_passwd);
  989. $role_id = $global_guest_user_info["role_id"];
  990. $register_data["email"] =   escape_ctrl_char(trim($email));
  991. $register_data["username"]      =   escape_ctrl_char(trim($nick));
  992. $register_data["passwd"]    =   escape_ctrl_char(trim($passwd));
  993. $register_data["role_id"] = (isset($role_id) &&$role_id !='') ?$role_id : "guest_participant";
  994. $register_data["corp_id"] = $data['corporation_id'] ?$data['corporation_id'] : '';
  995. $register_data["blocked"] = 0;
  996. $register_data["is_emailverified"] = "pass";
  997. $register_data["created"] = my_time();
  998. $register_data["original_passwd"] = $original_passwd;
  999. $auth_passwd_rs = auth_passwd($register_data["original_passwd"],"ENCODE",$setup_code);
  1000. $register_data["setup_code"] = $auth_passwd_rs["passwd"];
  1001. $user_obj = new user_obj();
  1002. $where = "email='".$register_data["email"]."'";
  1003. $result_fields = "id,username,email,password,setup_code";
  1004. $user_rs = $user_obj->get_userinfo_bycondition($result_fields,$where,0,1,"id desc","",false);
  1005. if(is_array($user_rs) &&count($user_rs) >0 &&$user_rs["id"] >0){
  1006. $setup_code = $user_rs["setup_code"];
  1007. $passwd_rs = auth_passwd($setup_code,"DECODE");
  1008. $original_passwd = $passwd_rs["passwd"];
  1009. $user_rs["original_passwd"] = $original_passwd;
  1010. $return_arr = array(
  1011. "error_no"=>"",
  1012. "info"=>$user_rs
  1013. );
  1014. }else{
  1015. $reg_info = $this->add_part_user($register_data,$role=$register_data["role_id"]);
  1016. if (count($reg_info) >0 &&$reg_info['id']>0){
  1017. $register_data['id'] = $reg_info['id'];
  1018. $return_arr = array(
  1019. "error_no"=>"",
  1020. "info"=>$register_data,
  1021. );
  1022. }
  1023. }
  1024. }else{
  1025. $return_arr = array(
  1026. "error_no"=>"2",
  1027. "info"=>$register_data,
  1028. );
  1029. }
  1030. return $return_arr;
  1031. }
  1032. function user_activation($data){
  1033. global $lang;
  1034. $get = my_get();
  1035. $email = isset($data["email"]) ?strtolower(escape_ctrl_char(trim($data["email"]))) : "";
  1036. $retake_validate = isset($data["s"]) ?trim($data["s"]) : "";
  1037. $error_no = "";
  1038. $user_info = array();
  1039. $result_fields = "*";
  1040. $where = "email='$email'";
  1041. $user_obj = new user_obj();
  1042. $user_info = $user_obj->get_userinfo_bycondition($result_fields,$where,0,1);
  1043. if (is_array($user_info) &&count($user_info)>0){
  1044. if($user_info['is_emailverified'] == 'pend'){
  1045. if($retake_validate == retake_get_validate($user_info["email"],$user_info["created"])){
  1046. $auth_id = encode_user_auth($user_info['id'],$user_info['email'],$user_info['corporation_id'],$auth_pass=0,$user_suffix=0);
  1047. $time = date("Y-m-d H:i:s");
  1048. $fields = array("is_emailverified","modified");
  1049. $value = array("pass",$time);
  1050. $where = "email='$email' and is_emailverified='pend'";
  1051. $modified_rs = $user_obj->modify_user_info($fields,$value,$where,$other_fields,$other_value);
  1052. if($modified_rs){
  1053. }else{
  1054. $error_no = 4;
  1055. }
  1056. }else{
  1057. $error_no = 3;
  1058. }
  1059. }else {
  1060. $error_no = 2;
  1061. }
  1062. }else {
  1063. $error_no = 1;
  1064. }
  1065. $error_message = $this->error_info["user_activation"][$error_no] ?$this->error_info["user_activation"][$error_no] : $lang["activation_success"];
  1066. $result_array = array(
  1067. "error_no"=>$error_no,
  1068. "result"=>$error_message,
  1069. "email"=>$email,
  1070. );
  1071. return $result_array;
  1072. }
  1073. function update_activation($data){
  1074. global $lang,$global_role_info;
  1075. $get = my_get();
  1076. $type = "update";
  1077. $email = isset($data["email"]) ?strtolower(escape_ctrl_char($data["email"])) : "";
  1078. $update_validate = isset($data["s"]) ?trim($data["s"]) : "";
  1079. $auth_str = base64_decode(sys_authcode($update_validate,"DECODE"));
  1080. $auth_arr = explode("|",$auth_str);
  1081. $regcode = $auth_arr[0];
  1082. $sign = $auth_arr[1];
  1083. $expire_time = mktime(date(H),date(i),date(s),date(m)+6,date(d),date(Y));
  1084. $error_no = "";
  1085. $user_info = array();
  1086. $result_fields = "id,role_id,purchased";
  1087. $where = "email='$email'";
  1088. $user_obj = new user_obj();
  1089. $user_info = $user_obj->get_userinfo_bycondition($result_fields,$where,0,1);
  1090. if (is_array($user_info) &&count($user_info)>0){
  1091. if($user_info['role_id'] == $global_role_info['administrator']){
  1092. if($is_register = check_full_register($email,$regcode,strtolower($sign))){
  1093. $time = my_time();
  1094. $fields = array("blocked","purchased","registration_code","is_emailverified","modified","license_type","upgrade_date","expire_date");
  1095. $value = array('1','1',$regcode,'pass',$time,"unlimited",$time,$expire_time);
  1096. $where = "id=".$user_info["id"];
  1097. $update_rs = $this->link["main"]->update_data($this->_utable,$fields,$value,$where,"","",$debug=false);
  1098. $error_no = $update_rs ?'': 4;
  1099. }else{
  1100. $error_no = 3;
  1101. }
  1102. }else {
  1103. $error_no = 2;
  1104. }
  1105. }else {
  1106. $error_no = 1;
  1107. }
  1108. $error_message = $this->error_info["update_activation"][$error_no] ?$this->error_info["update_activation"][$error_no] : $lang["update_success"];
  1109. $result_array = array(
  1110. "error_no"=>$error_no,
  1111. "result"=>$error_message,
  1112. "email"=>$email,
  1113. );
  1114. return $result_array;
  1115. }
  1116. }
  1117.  
  1118. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement