function plugin_isbn_cache_fetch($target, $dir, $check = true) { $this->config['AMAZON_ASE_ID'] = $this->get_associate_tag($this->config['AMAZON_ASE_ID']); $filename = $dir . $target . '_' . $this->config['AMAZON_ASE_ID'] . '.isbn'; $error = ''; if (!empty($this->root->rtf['use_cache_always'])) { $check = false; } if (!is_file($filename) || $check && $this->config['ISBN_AMAZON_EXPIRE_TIT'] * 3600 * 24 < $this->cont['UTC'] - filemtime($filename)) { // データを取りに行く include_once XOOPS_TRUST_PATH . '/class/hyp_common/hsamazon/hyp_simple_amazon.php'; $ama = new HypSimpleAmazon($this->config['AMAZON_ASE_ID']); if ($this->root->amazon_AccessKeyId) { $ama->AccessKeyId = $this->root->amazon_AccessKeyId; } if ($this->root->amazon_SecretAccessKey) { $ama->SecretAccessKey = $this->root->amazon_SecretAccessKey; } $ama->encoding = $this->cont['SOURCE_ENCODING'] === 'EUC-JP' ? 'EUCJP-win' : $this->cont['SOURCE_ENCODING']; $ama->itemLookup($target); $tmpary = $ama->getCompactArray(); $error = $ama->error; $ama = NULL; $title = ''; if (!empty($tmpary['Items'])) { $tmpary = $tmpary['Items'][0]; $title = trim($tmpary['TITLE']); $category = @$tmpary['BINDING']; $price = @$tmpary['PRICE']; $author = @$tmpary['PRESENTER']; $artist = ''; $releasedate = @$tmpary['RELEASEDATE']; $manufacturer = @$tmpary['MANUFACTURER']; $availability = @$tmpary['AVAILABILITY']; $listprice = @$tmpary['LISTPRICE']; $usedprice = @$tmpary['USEDPRICE']; $simg = $tmpary['SIMG']; //[10] $mimg = $tmpary['MIMG']; //[11] $limg = $tmpary['LIMG']; //[12] } if (!$error) { // タイトルがあれば、できるだけキャッシュに保存 $title = "{$title}<>{$category}<>{$price}<>{$author}<>{$artist}<>{$releasedate}<>{$manufacturer}<>{$availability}<>{$listprice}<>{$usedprice}<>{$simg}<>{$mimg}<>{$limg}"; $this->plugin_isbn_cache_save($title, $filename); } // Update plainDB $this->func->need_update_plaindb(); } else { $title = file_get_contents($filename); } if (!$error) { return explode("<>", $title); } else { return array("\t" . $error); } }
function plugin_aws_get($f, $m, $k, $b, $s) { $ret = ''; if (!$f) { $f = 'default'; } if (!empty($this->config['template_map'])) { if (array_key_exists($f, $this->config['template_map'])) { $f = $this->config['template_map'][$f]; } } $this->options['amazon_t'] = $this->config['amazon_t']; if (!empty($this->root->vars['page'])) { if ($this->root->amazon_UseUserPref) { $user_pref = $this->func->get_user_pref($this->func->get_pg_auther($this->root->vars['page'])); if (!empty($user_pref['amazon_associate_tag'])) { $this->options['amazon_t'] = preg_replace('/[^a-zA-Z0-9-]/', '', $user_pref['amazon_associate_tag']); } } if ($this->options['timestamp']) { $this->options['page'] = $this->root->vars['page']; } } $cache_file = $this->cont['CACHE_DIR'] . 'plugin/' . md5($f . $m . $k . $b . $s . serialize($this->options)) . ".aws"; if (!empty($this->root->rtf['preview'])) { @unlink($cache_file); } if (is_readable($cache_file) && (!empty($this->root->rtf['use_cache_always']) || filemtime($cache_file) + $this->config['cache_time'] * 60 > $this->cont['UTC'])) { $ret = file_get_contents($cache_file); } else { include_once $this->cont['TRUST_PATH'] . 'class/hyp_common/hsamazon/hyp_simple_amazon.php'; $ama = new HypSimpleAmazon($this->options['amazon_t']); if ($this->config['AccessKeyId']) { $ama->AccessKeyId = $this->config['AccessKeyId']; } if ($this->config['SecretAccessKey']) { $ama->SecretAccessKey = $this->config['SecretAccessKey']; } $ama->encoding = $this->cont['SOURCE_ENCODING'] === 'EUC-JP' ? 'EUCJP-win' : $this->cont['SOURCE_ENCODING']; $ama->getPages = $this->options['pages']; $options = array(); if ($s && preg_match("/\\+?([a-z,-]+)/", $s, $s_val)) { $options['Sort'] = $s_val[1]; } if ($k) { $ama->setSearchIndex($m, $this->options['search']); if ($b) { $options['BrowseNode'] = $b; } $ama->itemSearch($k, $options); } else { if ($b) { $ama->setSearchIndex($m); $ama->browseNodeSearch($b, $options); } } $html = $ama->getHTML($f); //if (! empty($this->root->rtf['preview'])) {$html .= $ama->url;} $header = $k && !is_null($ama->compactArray['totalresults']) ? $ama->makeSearchLink($k, sprintf($this->msg['more_search'], $this->func->htmlspecialchars($k)), TRUE) : ''; $ret = $header . "" . $html; // remove wrong characters $ret = mb_convert_encoding($ret, $this->cont['SOURCE_ENCODING'], $this->cont['SOURCE_ENCODING']); if (!is_null($ama->compactArray['totalresults']) && empty($this->root->rtf['preview']) && ($fp = @fopen($cache_file, "wb"))) { fputs($fp, $ret); fclose($fp); } else { //$ret .= $ama->url; } if ($this->options['timestamp'] && empty($this->root->rtf['preview']) && $ama->getReleaseTime($k) && !empty($this->root->vars['page'])) { $this->func->touch_page($this->root->vars['page'], $ama->getReleaseTime($k)); } if (!$ama->error && empty($this->root->rtf['preview']) && $this->options['makepage'] && !empty($this->root->vars['page']) && substr_count($this->root->vars['page'], '/') + 1 < $this->options['maxdepth']) { $wait = 0; $checkUTIME = $this->cont['UTC'] - 86400 * 7; // 1週間前まで foreach ($ama->compactArray['Items'] as $item) { if ($checkUTIME <= $item['RELEASEUTIME'] && $this->func->basename($this->root->vars['page']) !== $item['TITLE']) { $newpage = $this->root->vars['page'] . '/' . $this->func->pagename_normalize(str_replace('/', '|', htmlspecialchars_decode($item['TITLE'], ENT_QUOTES))); if (!$this->func->is_page($newpage) && !$this->func->is_alias($newpage)) { $data = array('action' => 'plugin_func', 'plugin' => 'makepage', 'func' => 'auto_make', 'args' => array('new_page' => $newpage, 'twitter' => 'Release Date: ' . $item['RELEASEDATE'] . ' (' . $item['PRICE_FORMATTED'] . ')')); $this->func->regist_jobstack($data, 864000, $wait); $wait = $wait + 10; } } } } $ama = NULL; if (empty($this->root->rtf['preview'])) { // Update plainDB $this->func->need_update_plaindb(); // After a day $this->func->need_update_plaindb($this->root->vars['page'], 'update', TRUE, TRUE, $this->config['cache_time'] * 60); } } return explode("", $ret, 2); }
function is_asin() { include_once XOOPS_TRUST_PATH . '/class/hyp_common/hsamazon/hyp_simple_amazon.php'; $ama = new HypSimpleAmazon(); $this->asin = $ama->ISBN2ASIN($this->asin_all); $ama = NULL; if (!preg_match('/[a-z0-9]{10}/i', $this->asin)) { $this->asin = ''; return FALSE; } return TRUE; }