6) { $slen = split(":",$slen); $time = (int) $slen[0]*60*60 + (int) $slen[1]*60 + (int) $slen[2]; } else { $slen = split(":",$slen); $time = (int) $slen[0]*60 + (int) $slen[1]; } $view = (int) date("U"); $play = (int) date("U", filemtime(__FILE__)) + $time; $currentsong = "%%CURRENTSONG%%"; $title = "%%CURRENTSONGTITLE%%"; $artist = "%%CURRENTARTIST%%"; $album = "%%CURRENTALBUM%%"; $comment = "%%CURRENTCOMMENT%%"; $currentsong = mb_convert_encoding($currentsong, $encode, "auto"); $title = mb_convert_encoding($title, $encode, "auto"); $artist = mb_convert_encoding($artist, $encode, "auto"); $album = mb_convert_encoding($album, $encode, "auto"); $comment = mb_convert_encoding($comment, $encode, "auto"); $notplay = mb_convert_encoding($notplay, $encode, "auto"); $unknown = mb_convert_encoding($unknown, $encode, "auto"); $result = ""; $items = ""; $image = ""; if (!strncmp($comment,'IMG=',4)) { $altimage = substr($comment,4); } if (strlen($album) <= 1) { $album = $title; } if (strlen($title) <= 1 && strlen($artist) <= 1) { $currentsong = split('[-(]', $currentsong); $artist = trim($currentsong[0]); $title = trim($currentsong[1]); if (strlen($album) <= 1) { $album = $title; } $play += 10*60; } $words = "$artist $album"; $params = array('keyword' => $words, 'page' => '1', 'mode' => 'music-jp', 'tag' => $asoid, 'devtag' => $devid, 'type' => 'lite', 'locale' => 'jp'); if ($view < $play) { if (!(strlen($album) > 1)) { echo "
\n"; echo "\n"; echo "
\n"; } //検索前に if (file_exists("$temp")) { $filetime = (int) date("U", filemtime("$temp")) + $time; } if (strlen($album) > 1) { if ($view < $filetime && !($filetime < $play)) { printfile($temp); return; } } if (!search_amazon($params, $words, 'jp', 'music-jp')) if (!search_amazon($params, $words, 'us', 'music')) if (!search_amazon($params, $words, 'jp', 'classical-jp')) if (!search_amazon($params, $words, 'us', 'classical')) if ($altimage != "") { $image = "\"now"; } else { $image = "\"no"; } if (strlen($album) > 1) { if ($fp = fopen("$temp", 'w+')) { fwrite($fp, "
\n\n
\n"); } fclose($fp); echo "
\n\n
\n"; return; } } else { echo "
\n"; echo "\n"; echo "
\n"; printfile($temp); return; } function search_amazon($params, $keyword, $locale, $mode) { global $altimage; global $imagedir; global $result; global $items; global $image; global $amazon_wsdl; global $soapclient; $params['keyword'] = $keyword; $params['locale'] = $locale; $params['mode'] = $mode; $soapclient = new soapclient($amazon_wsdl, true); $proxy = $soapclient->getProxy(); $result = $proxy->KeywordSearchRequest($params); $items = $result['Details'][0]; if ($altimage) $items[ImageUrlMedium] = "$imagedir/$altimage"; if (!$result['faultstring']) { $image = return_imagetag($items[Url], $items[ImageUrlMedium]); return true; } else { return false; } } function return_imagetag($url, $img) { global $album; global $artist; global $noimage; $alt = htmlspecialchars("$album - $artist", ENT_QUOTES); list($imgwidth, $imgheight, $type, $attr) = getimagesize("$img"); if ($type == 1) { $img = str_replace(".09.", ".01.", $img); list($imgwidth, $imgheight, $type, $attr) = getimagesize("$img"); } while ($imgwidth <= 1){ if (substr_count($img, ".09.") > 0) { $img = str_replace(".09.", ".01.", $img); list($imgwidth, $imgheight, $type, $attr) = getimagesize("$img"); } else if (substr_count($img, ".01.") > 0) { $img = $noimage; list($imgwidth, $imgheight, $type, $attr) = getimagesize("$img"); } else { break; } } return "\"$album"; } function printfile($filename) { if ($fp = fopen("$filename", 'r')) { $contents = fread($fp, filesize("$filename")); echo "$contents"; fclose($fp); } else { echo "can't open file\n"; } } ?>