function make_thumbnail($url, $prms) { static $count = 0; if (!preg_match('#^https?://#', $url)) { $url = 'http://' . $url; } $target = $this->func->htmlspecialchars($prms['target']); $nolink = $prms['nolink']; $thumburl = $this->fetch_url . $url; $sha1 = sha1($thumburl); $prm_size = strtolower($prms['size']); if (!preg_match('/[sml]/', $prm_size)) { $prm_size = 's'; } $thumb_size = $this->thumb_size[$prm_size]; $size = $thumb_size['width'] . 'x' . $thumb_size['height']; $thumb_file = $this->cont['CACHE_DIR'] . 'ASIN_SITEIMAGE_' . $sha1 . '_' . $prm_size . '.jpg'; $cache = $this->cont['CACHE_DIR'] . 'plugin/' . $sha1 . '.siteimage'; $is_new = !is_file($cache); if ($is_new || $count < $this->get_max_once && filemtime($cache) + $this->cache_day * 86400 < $this->cont['UTC']) { $count++; $ht = new Hyp_HTTP_Request(); $ht->init(); $ht->ua = 'Mozilla/5.0'; $ht->url = $thumburl; $ht->get(); $image = ''; if ($ht->rc === 200) { $image = $ht->data; } $ht = NULL; if ($image && ($fp = fopen($cache, 'wb'))) { fwrite($fp, $image); fclose($fp); foreach (array('s', 'm', 'l') as $_size) { @unlink($this->cont['CACHE_DIR'] . 'ASIN_SITEIMAGE_' . $sha1 . '_' . $_size . '.jpg'); } if ($is_new) { $this->func->pkwk_touch_file($cache, $this->cont['UTC'] - $this->cache_day * 86400 + $this->cache1st_min * 60); } } } if (!is_file($thumb_file)) { copy($cache, $thumb_file); HypCommonFunc::ImageResize($thumb_file, $size); HypCommonFunc::ImageMagickRoundCorner($thumb_file, '', 5, 2); } $cache_url = str_replace($this->cont['DATA_HOME'], $this->cont['HOME_URL'], $thumb_file); $url = $this->func->htmlspecialchars($url); $title = preg_replace('#^https?://#i', '', $url); $ret = "<img src=\"" . $cache_url . "\" width=\"{$thumb_size['width']}\" height=\"{$thumb_size['height']}\" alt=\"{$title}\">"; if (!$nolink) { $ret = "<a class=\"siteimage\" href=\"{$url}\" target=\"{$target}\" title=\"{$title}\">" . $ret . "</a>"; } return $ret; }