アートな美女写真サイト4Uをウィジェット化してみた。::レビログ
とりあえず、日替わり美女プラグインが欲しかったので。作った。
でもなぜか、はてな にはscriptもiframeも張れない。ぇー、ショボー
http://revilog.com/2008/04/011265.html
ほいよ。スパゲティ一丁おまちっ
美女スパゲティのレシピだぜ。スパゲティなのは気にするな!
綺麗にしようかと思ったが、それは次回作の時にすることにした(w
このプログラムは仕様書が必要な例ですなwww我ながら。
ところで、はてな、にはwikiとかによくある、ソースコードを児童で色分けしてくれる機能無いのかしら?
色分けされることを期待して書いているので、物カラーだとさらに醜いorz
なんか4UのRSSのフォーマットが変わっていたので、対応した
http://d.hatena.ne.jp/kokorohamoe/20080417/1208419448
<? <? if(!isset($_GET["javascript"])){ ?> <html> <head> <title>4U Widget by revilog</title> <style> body{ margin:0 0 0 0; padding:0 0 0 0; border:0 0 0 0; font-size:10px; } img{ border:0 0 0 0; margin:0 0 0 0; padding:0 0 0 0; } <? if(isset($_GET["center"])){ ?> #Widget4U{ text-align:center; width:100%; } <? } if(isset($_GET["bgcolor"]) && preg_match ("/^[0-9a-f]+$/",$_GET["bgcolor"])){ ?> body{ background-color:#<?=$_GET["bgcolor"];?>; } <? }else if(isset($_GET["bgcolor"]) && preg_match ("/^[a-zA-Z]+$/",$_GET["bgcolor"])){ ?> body{ background-color:<?=$_GET["bgcolor"];?>; } <? } ?> <? if(isset($_GET["width"]) && preg_match ("/[0-9]+/",$_GET["width"])){ ?> body{ width:#<?=$_GET["width"];?>; } <? } ?> </style> </head> <body> <? } ?> <? $filename = "/tmp/4u.cache"; $lock = "/tmp/4u.lock"; $file_time = filemtime ($filename); $now_time = time(); $restore = true; $checktime = 10; if($file_time===FALSE || ($file_time < ($now_time-$checktime*60) )){ $fp = fopen($lock,"r+"); flock($fp,LOCK_EX); $file_time = filemtime ($filename); $now_time = time(); if($file_time===FALSE || ($file_time < ($now_time-$checktime*60) )){ $article = simplexml_load_file('http://4u.straightline.jp/rss'); $cnt = count( $article->channel->item); for($i=0;$i<$cnt;$i++){ $key = $article->channel->item[$i]; $img = (string)$key->description; $s = strpos($img,"<a"); $e = strpos($img,"</a>"); $img = trim(substr($img,$s,$e+4-$s)); $title = $key->title; $img = str_replace("<a ","<a target=\"_top\"",$img); $images[$i] = str_replace("<img ","<img alt=\"$title\" ",$img); } file_put_contents($filename,serialize($images)); $file_time = filemtime ($filename); $restore = false; } flock($fp,LOCK_UN); fclose($fp); } if($restore){ $images = unserialize(file_get_contents($filename)); $cnt = count($images); } if(isset($_GET["br"])){ $BR = "<br />\r\n"; }else{ $BR = ""; } if(isset($_GET["count"])){ if($cnt > $_GET["count"]){ $cnt = $_GET["count"]; } } if(isset($_GET["start"])){ $start = $_GET["start"]; }else{ $start = 0; } if(isset($_GET["javascript"])){ print("document.open();"); print "document.write('<div id=\\\"Widget4U\\\">');"; for($i=$start;$i<$cnt;$i++){ print("document.write('".addslashes($images[$start+$i]).$BR."');"); } print "document.write('</div>');"; print("document.close();"); }else{ ?> <a target="_top" href="http://4u.straightline.jp/">4U</a> <a target="_top" href="http://revilog.com/2008/04/011265.html">Revilog</a> <? print "<div id=\"Widget4U\">"; for($i=0;$i<$cnt;$i++){ print($images[$start+$i].$BR); } print "</div>"; } ?> <? if(!isset($_GET["javascript"])){ ?> </body> </html> <? } ?>
ご意見ご要望はメールとか、コメントとか。メールはプロフィール。