utility.mod.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. function code_verify($uniacid, $receiver, $code) {
  8. $receiver = safe_gpc_string($receiver);
  9. if (empty($receiver) || !is_numeric($code)) {
  10. return false;
  11. }
  12. $params = array('uniacid' => intval($uniacid), 'receiver' => $receiver, 'verifycode' => $code, 'createtime >' => (TIMESTAMP - 1800));
  13. $data = table('account')->getUniVerifycode($params);
  14. if(empty($data)) {
  15. return false;
  16. }
  17. return true;
  18. }
  19. function utility_image_rename($image_source_url, $image_destination_url) {
  20. global $_W;
  21. load()->func('file');
  22. $image_source_url = str_replace(array("\0","%00","\r"),'',$image_source_url);
  23. if (empty($image_source_url) || !parse_path($image_source_url)) {
  24. return false;
  25. }
  26. if (!strexists($image_source_url, $_W['siteroot'])) {
  27. $img_local_path = file_remote_attach_fetch($image_source_url);
  28. if (is_error($img_local_path)) {
  29. return false;
  30. }
  31. $img_source_path = ATTACHMENT_ROOT . $img_local_path;
  32. } else {
  33. $img_local_path = substr($image_source_url, strlen($_W['siteroot']));
  34. $img_path_params = explode('/', $img_local_path);
  35. if ($img_path_params[0] != 'attachment') {
  36. return false;
  37. }
  38. $img_source_path = IA_ROOT . '/' . $img_local_path;
  39. }
  40. if (!file_is_image($img_source_path)) {
  41. return false;
  42. }
  43. $result = copy($img_source_path, $image_destination_url);
  44. return $result;
  45. }
  46. function utility_smscode_verify($uniacid, $receiver, $verifycode = '') {
  47. $table = table('uni_verifycode');
  48. $verify_info = $table->getByReceiverVerifycode($uniacid, $receiver, $verifycode);
  49. if (empty($verify_info)) {
  50. $table->updateFailedCount($receiver);
  51. return error(-1, '短信验证码不正确');
  52. } else if ($verify_info['createtime'] + 120 < TIMESTAMP) {
  53. return error(-2, '短信验证码已过期,请重新获取');
  54. } else {
  55. return error(0, '短信验证码正确');
  56. }
  57. }