utility.mod.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. $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));
  9. if(empty($data)) {
  10. return false;
  11. }
  12. return true;
  13. }
  14. function utility_image_rename($image_source_url, $image_destination_url) {
  15. global $_W;
  16. load()->func('file');
  17. $image_source_url = str_replace(array("\0","%00","\r"),'',$image_source_url);
  18. if (empty($image_source_url) || !parse_path($image_source_url) || !file_is_image($image_source_url)) {
  19. return false;
  20. }
  21. if (!strexists($image_source_url, $_W['siteroot'])) {
  22. $img_local_path = file_remote_attach_fetch($image_source_url);
  23. if (is_error($img_local_path)) {
  24. return false;
  25. }
  26. $img_source_path = ATTACHMENT_ROOT . $img_local_path;
  27. } else {
  28. $img_local_path = substr($image_source_url, strlen($_W['siteroot']));
  29. $img_path_params = explode('/', $img_local_path);
  30. if ($img_path_params[0] != 'attachment') {
  31. return false;
  32. }
  33. $img_source_path = IA_ROOT . '/' . $img_local_path;
  34. }
  35. $result = copy($img_source_path, $image_destination_url);
  36. return $result;
  37. }