function.php 769 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. * 微商城公共方法
  4. *
  5. * 公共方法
  6. *
  7. */
  8. defined('InShopNC') or exit('Access Invalid!');
  9. function getMicroshopImageSize($image_url, $max_width = 238) {
  10. $local_file_path = str_replace(UPLOAD_SITE_URL, BASE_ROOT_PATH.DS.DIR_UPLOAD, $image_url);
  11. if(file_exists($local_file_path)) {
  12. list($width, $height) = getimagesize($local_file_path);
  13. } else {
  14. list($width, $height) = getimagesize($image_url);
  15. }
  16. if($width > $max_width) {
  17. $height = $height * $max_width/ $width;
  18. $width=$max_width;
  19. }
  20. return array(
  21. 'width' => $width,
  22. 'height' => $height
  23. );
  24. }
  25. function getRefUrl() {
  26. return urlencode('http://'.$_SERVER['HTTP_HOST'].request_uri());
  27. }