phpスライドショー
自宅サーバの画像ファイルをスライドショーで閲覧可能なようにした。
また、画像には属性(「家族画像」、「エロ系画像」…)などを
confファイル(imgattr.conf)で定義できるようにして、
属性で絞り込まれた画像のみをスライドできるようにした。
<html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta http-equiv="content-script-type" content="text/javascript"> <title>image viewer</title> </head><body> <!-- St-HP-H --> <!-- En-HP-H --> <center> <table style="width:700;border-collapse:collapse;"> <tr> <td style="height:400;background-color:#ffffff;"> <center> <div style="width:700;font-size:16px;text-align:left;"> <script language="JavaScript"> <!-- var hayasa=500; photo=new Array();var pn=0; <?php // 属性定義 $conf = './imgattr.conf'; $watchdone = './WATCHDONE'; $attr = $_REQUEST["attr"]; $skip = $_REQUEST["skip"]; $excludewatchdone = $_REQUEST["excludewatchdone"]; $imgs = array(); $urldir = '/ero_images/data'; $dir = '/home/dukkiedukkie/Documents' . $urldir; if ( $attr ) { if ( $attr == "undef" ) { $done=array(); $fp = fopen( "$conf", "r" ); while(!feof($fp)){ $line = fgets($fp); $line = preg_replace("/\n/", "", $line ); $strs = preg_split("/\t/", $line); if ( $strs[0] ) { $done[$strs[0]]=1; } } if ( $excludewatchdone == "1") { $fp = fopen( "$watchdone", "r" ); while(!feof($fp)){ $done_file = fgets($fp); $done_file = preg_replace("/\n/", "", $done_file ); $done[$done_file]=1; } } if ($dh = opendir($dir)) { $cnt = 0; while($file = readdir($dh)) { $ffile="$dir/$file"; if ( is_file("$ffile") ) { if (($done["$urldir/$file"] == "" ) && ($cnt > $skip)) { array_push($imgs, "$urldir/$file"); } } $cnt++; } } closedir($dh); } else { // 定義済み属性をまず取得 $fp = fopen( "$conf", "r" ); while(!feof($fp)){ $line = fgets($fp); $line = preg_replace("/\n/", "", $line ); $strs = preg_split("/\t/", $line); if ( $strs[0] ) { if ( $strs[1] == $attr ) { array_push($imgs, $strs[0]); } } } } fclose($fp); } else { if ($dh = opendir($dir)) { $cnt = 0; while($file = readdir($dh)) { if ( ( is_file("$dir/$file") ) && ($cnt > $skip)) { array_push($imgs, "$urldir/$file"); } $cnt++; } } closedir($dh); } //$imgs = array_reverse($imgs); foreach ( $imgs as $file ) { echo "photo[pn++]=\"$file\";\n"; } ?> var n=photo.length; document.write('<table style="width:700;border-collapse:collapse;border:1px solid #000000;"><tr>'); document.write('<td style="background-color:#000000;">'); document.write('<center>'); document.write('<input type="button" onclick="kaisi();" value="start">'); document.write('<input type="button" onclick="mae();" value="before">'); document.write('<input type="button" onclick="tugi();" value="next">'); document.write('<input type="button" onclick="teisi();" value="stop">'); document.write('</center>'); document.write('</td></tr><tr>'); document.write('<td style="background-color:#eeeeee;height:450;">'); document.write('<center>'); document.write('<img id="myimg" galleryimg=no style="height:450;border:1px solid #000000;cursor:pointer;margin-bottom:5;" onclick="mado();" title="define attribute">'); document.write('</center>'); document.write('</td></tr><tr>'); document.write('<td style="background-color:#000000;">'); document.write('<center>'); document.write('<span id="text" style="font-size:12px;color:#ffffff;">dummy</span>'); document.write('</center>'); document.write('</td></tr></table>'); var tid,joutai="stopping", i=0; hyouji(); function kaisi(){ clearInterval(tid); joutai="moving"; tugi(); tid=setInterval("tugi();",hayasa); } function mae(){ if(i>0){ i--; hyouji(); }else{ i=n-1; hyouji(); } } function tugi(){ if(i<n-1){ i++; hyouji(); }else{ i=0; hyouji(); } } function teisi(){clearInterval(tid);joutai="stopping";hyouji();} function henkou(sel_no){i=sel_no;hyouji();} function hyouji(){ document.getElementById("myimg").src=photo[i]; var j="show is "+joutai+" : all "+n+" files : "+(i+1)+" th file."; document.getElementById("text").firstChild.nodeValue=j; } function attrlink(){ } function mado(){ var myurl="./defattr.php?img="+photo[i]; //var myurl=photo[i]; window.open(myurl,i); } //-- > //--> </script> </div> <br> <br> <br> </div> </center> </td> </tr> <tr> <td style="height:30;color:#ffffff;text-align:center;font-size:12px;"> All Rights Reserved. dukaduka </td> </tr> </table> </center> <br> <!-- St-HP-F --> <!-- En-HP-F --> </body></html>