Skip to content

Instantly share code, notes, and snippets.

@bzz0217
Created November 9, 2015 15:59
Show Gist options
  • Save bzz0217/48ef253ef3acb224591b to your computer and use it in GitHub Desktop.
Save bzz0217/48ef253ef3acb224591b to your computer and use it in GitHub Desktop.
画像一覧
<?php
function imglist($path){
$img = array();
$imglist = array();
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if (preg_match("{\d+_.*?\.jpg}", $file)){
$imglist[] = $file;
}
}
}
//日付降順ソート
rsort($imglist, SORT_STRING);
for ($i=0; $i<count($imglist); $i++){
preg_match("{(\d+)_.*?\.jpg}", $imglist[$i], $res);
$imginfo = array();
$imginfo['date'] = $res[1];
$imginfo['name'] = $imglist[$i];
$img[$imginfo['date']][] = $imginfo['name'];
}
return $img;
}
$path = "/var/www/html/m/";
$img = imglist($path);
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>みんくちゃんねる 画像一覧</title>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<style>
@import url(//fonts.googleapis.com/css?family=Open+Sans:400,400italic,600,600italic,700,700italic);
body{
font-family:Avenir , "Open Sans" , "Helvetica Neue" , Helvetica , Arial , Verdana , Roboto , "游ゴシック" , "Yu Gothic" , "游ゴシック体" , "YuGothic" , "ヒラギノ角ゴ Pro W3" , "Hiragino Kaku Gothic Pro" , "Meiryo UI" , "メイリオ" , Meiryo , "MS Pゴシック" , "MS PGothic" , sans-serif;
}
h1{
font-size:20px;
color:#16a085;
font-weight:800;
}
h2{
font-size:16px;
color:#354b60;
}
</style>
<!--&#91;if lt IE 9&#93;>
<script src="//cdn.jsdelivr.net/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<!&#91;endif&#93;-->
<link rel="shortcut icon" href="">
</head>
<body>
<h1>みんくちゃんねる 画像一覧</h1>
<?php
foreach($img as $date => $val){
echo "<h2><i class=\"fa fa-calendar\"></i> " . $date . "</h2>";
echo "<div class=\"imglist\">";
for ($i=0; $i<count($val); $i++){
echo "<a href=\"" . $val[$i] . "\" target=\"_blank\">";
echo "<img src=\"" . $val[$i] . "\" width=\"100px\">";
echo "</a>";
}
echo "</div>";
}
?>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.js"></script>
<script type="text/javascript" src="jquery.stalactite.min.js"></script>
<script type="text/javascript">
$(function () {
$(".imglist").stalactite({
duration: 5, //表示速度
easing: 'swing', //表示の動き
fluid: true //ウィンドウサイズの変更でも適用するか
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment