';
$path_base = dirname( __FILE__ );
$today = date( 'Ymd' );
$ranking = $path_base . '/result/ranking.' . $today . '.html';
if ( isset( $_GET['mode'] ) && $_GET['mode'] == 'reload' ) {
} else if ( file_exists( $ranking ) ) {
$result = file_get_contents( $ranking );
if ( strlen( $linkshareId ) == 11 && strpos( $result, $linkshareId ) === false ) {
} else {
echo $result;
exit;
}
}
$fp = fopen( $ranking, 'wt' );
$requestBeforeUri = "http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/toppaidapplications/sf=";
$requestAfterUri = "/limit=100/xml";
//$countryID = 143462;
$countryID = intval( $appreview_countryid );
$request = $requestBeforeUri . $countryID . $requestAfterUri;
$rss = fetch_rss($request);
$title = $rss->channel['title'];
$output = '
';
echo $output;
fputs( $fp, $output . "\n" );
$nameMaxLength = 18;
$count = 0;
foreach ($rss->items as $item ) {
$appUrl = $item[ 'id' ];
$dryRead = file_get_contents( $appUrl );
preg_match("/(.*?)<\/h1>/i", $dryRead, $match);
$name = $match[1];
preg_match('/
- (.*?)<\/li>/i', $dryRead, $match);
$genre = strip_tags( $match[1] );
preg_match('/
- (.*?)<\/li>/i', $dryRead, $match);
$release = strip_tags( $match[1] );
$url = $item[ 'link' ];
$url .= "&partnerId=30";
$iconArray = split( "http:", $item[ 'im' ][ 'image' ] );
$icon = "http:" . $iconArray[ 1 ];
$price = mb_convert_encoding( $item[ 'im' ][ 'price' ], 'UTF8', 'AUTO' );
$link_enclosure = $item['link_enclosure'];
if ( $linkshareId != "" ) {
$link = $linkshareBase . urlencode( urlencode( $url ) );
} else {
$link = $url;
}
$count++;
if ( mb_strlen( $name, 'UTF8' ) > $nameMaxLength ) {
$trim = ' ...';
} else {
$trim = '';
}
$output = '
- ' . $count . '';
$output .= '';
$output .= '
';
$output .= '';
$output .= '' . mb_substr( $name, 0, $nameMaxLength, 'UTF8' ) . $trim . '
';
$output .= $genre . '
';
$output .= '' . __("Price:") . $price . '
';
$output .= $release;
$output .= '' . __("Review now") . ' ';
echo $output;
fputs( $fp, $output . "\n" );
}
$output = '
';
fputs( $fp, $output . "\n" );
fclose( $fp );
?>