<?php
// 保存ファイルは以下２種類あればいいはず
// 毎月（直近１００件をrirekiで表示）	$accese_history_file = "./tmp/accese_history_" . date( "Ym" )   . ".log" ;   $accese_history_201709.log ;
// 毎日（日付していの場合に表示）	        $accese_history_file = "./tmp/accese_history_" . date( "Ymd" ) . ".log" ;   $accese_history_20170901.log ;
//$accese_history_file = $accese_history_ .  "_" .   date( "Ym" ) . ".log" ;
//$accese_history_file = $accese_history_ .  "_" .   date( "Ymd" ) . ".log" ;



require_once( './util.php' );
define("ACCESE_HISTORY_DISPLAY_ROW_COUNT", "50");
//$log_file            = "./log/log_file_" . date( "Ym" ) . ".log" ;
//$output_file_name2 = DIR_ROOT . "tmp/colorhenkan_log.txt" ;
// 入力
//$input_a_box  = $_GET["input_a_box"]  ; 
$date = "";
$date = $_GET['date']; // 日指定の場合
if ($date != '') {
    $accese_history_file = "./tmp/accese_history_" . $date . ".log";
    $date_wamei = substr($date, 0, 4) . "年" . substr($date, 4, 2) . "月" . substr($date, 6, 2) . "日";
} else {
//	$accese_history_file = "./tmp/accese_history_" . date( "Ymd" ) . ".log" ;
    $accese_history_file = "./tmp/accese_history_" . date("Ym") . ".log";
}

//if ( file_exists( $log_file ) == false ) {
//	touch( $log_file );
//	chmod( $log_file , 0666 );
//} 
if (file_exists($accese_history_file) == false) {
    touch($accese_history_file);
    chmod($accese_history_file, 0666);
}

// 過去のりれぎ ファイル表示
// 表示するのにソート
$f = file($accese_history_file);
//krsort($f) ;
$i = 0;
//echo "count[" . count($f)  . "]<br>" ;
//var_dump($f);
$accese_history_contents = "";
foreach ($f as $key => $value) {
//for ( $i = 0 ; $i < count($f) ; $i++ ) {
//echo "ZZZ key[" . $i . "]value[" . $f[$i] . "]<br>" ;
//	$i++;
    $accese_history_contents .= $f[$i] . "<br>";
    if ($i >= ACCESE_HISTORY_DISPLAY_ROW_COUNT) {
        break;
    }
}

//echo "9999999999[" .  $accese_history_contents . "]99999" ;
//$accese_history_contents = "222222222222222";

if (file_exists("/var/www/html/colorhenkan/PRODUCTION.txt")) {
    define("DOMAIN_URL", "colorhenkan.pw");
    define("DIR_ROOT", "/var/www/html/colorhenkan/");
} else {
    define("DOMAIN_URL", "localhost/colorhenkan");
    define("DIR_ROOT", "D:/xampp/htdocs/colorhenkan/"); // php5 
}


define("LOG_RECORD_CNT", 300); // logから読んでくるレコード数
define("TITLE", "色を表示する！カラーコード変換するツールの履歴"); // logから読んでくるレコード数
?>








<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    <html lang="en" class="no-js">
        <head>
            <meta charset="utf-8">
            <meta http-equiv="X-UA-Compatible" content="IE=edge">
            <meta name="viewport" content="width=device-width, initial-scale=1">


            <?php
            if ($date != "") {
//	echo '<TITLE>' . $html2 . ' ' . TITLE . '</TITLE>' ;
//	echo '<META name="description" content="' . TITLE . ' ' . $html2 . '">' ;
                echo '<TITLE>' . $date_wamei . 'の色変換 ' . TITLE . '</TITLE>';
                echo '<META name="description" content="' . $date_wamei . 'の色変換 ' . TITLE . '">';
            } else {
                echo '<TITLE>' . TITLE . '</TITLE>';
                echo '<META name="description" content="' . TITLE . '">';
            }
            ?>


            <META name="keywords" content="colorcode,カラーコード,color,16進数">
            <link rel="shortcut icon" href="./favicon.ico">
            <!-- Bootstrap -->
            <script src="js_boxify/modernizr.custom.js"></script>
            <link href="css_boxify/bootstrap.min.css" rel="stylesheet">
            <link href="css_boxify/jquery.fancybox.css" rel="stylesheet">
            <link href="css_boxify/flickity.css" rel="stylesheet" >
            <link href="css_boxify/animate.css" rel="stylesheet">
            <link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css_boxify/font-awesome.min.css" rel="stylesheet">
            <link href='http://fonts.googleapis.com/css?family=Nunito:400,300,700' rel='stylesheet' type='text/css'>
            <link href="css_boxify/styles.css" rel="stylesheet">
            <link href="css_boxify/queries.css" rel="stylesheet">
            <!-- Facebook and Twitter integration -->
            <meta property="og:title" content=""/>
            <meta property="og:image" content=""/>
            <meta property="og:url" content=""/>
            <meta property="og:site_name" content=""/>
            <meta property="og:description" content=""/>
            <meta name="twitter:title" content="" />
            <meta name="twitter:image" content="" />
            <meta name="twitter:url" content="" />
            <meta name="twitter:card" content="" />
            <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
            <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
            <!--[if lt IE 9]>
            <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
            <script src="https://oss.maxcdn.com/libs/respond.js_boxify/1.4.2/respond.min.js"></script>
            <![endif]-->

            <style type='text/css'>
                <!--
                .rireki_box {
                    font-size:14px; 
                    margin:10px; 
                    background-color: #FFFFFF; 
                    padding:10px; 
                }
                .rireki_box a {
                    color:#3388FF;
                }
                -->
            </style>

        </head>
        <body>
            <!--[if lt IE 7]>
            <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
            <![endif]-->
            <!-- open/close -->

            <?php
// if ( $err_msg_html != ""){
// 	echo "<div style='margin-left:20px; margin-right:20px;  margin-top:20px; margin-bottom:20px; border-bottom:3px solid #777777; border-top:3px solid #777777; background-color:#EEEEEE; padding:10px; '><div style='margin-top:0px; margin-left:20px; color:#333333; padding-right:10px; word-break:break-all; font-size:24px;'>" ;
// 	echo $err_msg_html ;
// 	echo "</div></div>" ;
// //	echo "ぱらあり" ;
// } else {
// //	echo "ぱらなし" ;
// }
            ?>
            <header>
                <div class="texture-overlay"></div>
                <div class="container">
                    <a href="http://<?php echo DOMAIN_URL; ?>" style="color:#FFBBBB;">colorhenkan.pw</a>
                </div>
            </header>

            <div class="row hero-content" style="background-color:#EEFFCC;">
                <center>
                    <div class="col-md-12">
                        <h1 class="animated fadeInDown" style="background-color:#FFFFFF;  padding:10px 0px 10px 0px; color:#FFFFFF; font-size:46px;"><a href="http://<?php echo DOMAIN_URL; ?>" style="color:#222222;">
                                <img src="./img/colors.png" style="width:42px;">
                                <span style="color:#222222;">カ</span>
                                <span style="color:#22FF22;">ラ</span>
                                <span style="color:#2222FF;">ー</span>
                                <span style="color:#FF2222;">コ</span>
                                <span style="color:#FFFF22;">ー</span>
                                <span style="color:#22FFFF;">ド</span>
                                <span style="color:#FF22FF;">変</span>
                                <span style="color:#AA2222;">換</span>
                                <span style="color:#22AA22;">ツ</span>
                                <span style="color:#2222AA;">ー</span>
                                <span style="color:#AAAA22;">ル</span>
                            </a></h1>
                    </div>
                </center>











                <center>
                    <div class="col-md-12" style="margin-top:20px;">
                        <div class="sub_title"><img src="./img/icon_tag2.png" style="width:30px; margin-right:7px;">直近のカラーコード変換履歴</div>
                        <div class="rireki_box">
                            <?php
// logファイルが存在している時のみ
//if  ( file_exists( $output_file_name2 ) == TRUE ) {
                            if (file_exists($accese_history_file) == TRUE) {
//echo "iii[" . $output_file_name2 . "]" ;
//	$f =file(  $log_file );
//	krsort($f) ;
                                $i = 1;
                                foreach ($f as $key => $value) {
//	 echo "key[" . $key ."]" ;
//	 echo "value[" . $value ."]" ;
//		$v = split(",",$value);
//		print($v[0]);
                                    print($value);
                                    if ($i > LOG_RECORD_CNT) {
                                        break;
                                    }
                                    $i++;
                                }
                            }
                            ?>
                        </div>
                    </div>

		    <div style="clear:both;"></div>
                    <!-- ads -->
                    <div style="text-align:center; margin-top:0px; margin-bottom:0px;">

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- colorhenkan.pw auto reponsive -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-8933330050465971"
     data-ad-slot="9349181841"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

                        <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                        <!-- colorhenkan.pw responsible -->
                        <ins class="adsbygoogle"
                             style="display:block"
                             data-ad-client="ca-pub-8933330050465971"
                             data-ad-slot="2673667642"
                             data-ad-format="auto"></ins>
                        <script>
                            (adsbygoogle = window.adsbygoogle || []).push({});
                        </script>
                    </div>
                    <!-- /ads -->



                    <?php
//echo "rrrrrr" ;
//                    echo $accese_history_contents;
//echo "rrrrrr" ;
                    ?>


                    <!-- json link calendar -->
                    <style type='text/css'>
                        <!--
                        .calendar    { font-size:18px; width:80%; }
                        .calendar td { text-align:right; padding:3px; }
                        .youbi    { width:100px; text-align:right; }
                        .sat      { width:100px; text-align:right; }
                        .sun      { width:100px; text-align:right; }
                        -->
                    </style>
                    <br>
                    <!-- /json link calendar -->
                    <br>
                    <?php
//---------------------------------
// カレンダー表示設定
//---------------------------------
                    $calendar_thismonth = calendar(date('Y'), date('n'));    // 通常（現在の日付）
                    $calendar_beforemonth = calendar(date('Y'), date('n') - 1); // 特定年月のカレンダーを表示する場合

                    echo $calendar_thismonth;
                    echo "<br>";
                    echo $calendar_beforemonth;
                    ?>









                    <footer>
                        <div style="width:90%; font-size:12px; color:#888888; line-height:180%; ">指定したカラーコードを表示するサービス、ツールです。</div>
                        <div align="center"><font size=-1 style="color:#888888;">&copy;<?php echo date('Y') ?> <?php echo DOMAIN_URL; ?></font></div>

                    </footer>

                </center>

            </div>


            <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
            <script src="js_boxify/min/toucheffects-min.js"></script>
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
            <script src="js_boxify/flickity.pkgd.min.js"></script>
            <script src="js_boxify/jquery.fancybox.pack.js"></script>
            <!-- Include all compiled plugins (below), or include individual files as needed -->
            <script src="js_boxify/retina.js"></script>
            <script src="js_boxify/waypoints.min.js"></script>
            <script src="js_boxify/bootstrap.min.js"></script>
            <script src="js_boxify/min/scripts-min.js"></script>
            <!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
        </body>
    </html>
