人人商城

utility.mod.php 2.0KB

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