utility.mod.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. $data = table('uni_verifycode')->where(array(
  13. 'uniacid' => intval($uniacid),
  14. 'receiver' => $receiver,
  15. 'verifycode' => $code,
  16. 'createtime >' => (TIMESTAMP - 1800)
  17. ))->get();
  18. return !empty($data);
  19. }
  20. function utility_image_rename($image_source_url, $image_destination_url) {
  21. global $_W;
  22. load()->func('file');
  23. $image_source_url = str_replace(array("\0","%00","\r"),'',$image_source_url);
  24. if (empty($image_source_url) || !parse_path($image_source_url)) {
  25. return false;
  26. }
  27. if (!strexists($image_source_url, $_W['siteroot']) || $_W['setting']['remote']['type'] > 0) {
  28. $img_local_path = file_remote_attach_fetch($image_source_url);
  29. if (is_error($img_local_path)) {
  30. return false;
  31. }
  32. $img_source_path = ATTACHMENT_ROOT . $img_local_path;
  33. } else {
  34. $img_local_path = substr($image_source_url, strlen($_W['siteroot']));
  35. $img_path_params = explode('/', $img_local_path);
  36. if ($img_path_params[0] != 'attachment') {
  37. return false;
  38. }
  39. $img_source_path = IA_ROOT . '/' . $img_local_path;
  40. }
  41. if (!file_is_image($img_source_path)) {
  42. return false;
  43. }
  44. $result = copy($img_source_path, $image_destination_url);
  45. return $result;
  46. }
  47. function utility_smscode_verify($uniacid, $receiver, $verifycode = '') {
  48. $table = table('uni_verifycode');
  49. $verify_info = $table->getByReceiverVerifycode($uniacid, $receiver, $verifycode);
  50. if (empty($verify_info)) {
  51. $table->updateFailedCount($receiver);
  52. return error(-1, '短信验证码不正确');
  53. } else if ($verify_info['createtime'] + 120 < TIMESTAMP) {
  54. return error(-2, '短信验证码已过期,请重新获取');
  55. } else {
  56. return error(0, '短信验证码正确');
  57. }
  58. }