gaku-ura/hide_php/index.php

51 行
1.8 KiB
PHP

<?php
//直接アクセスしちゃだめ
require $d_root.'/hide_php/conf/c.php';
$access_count_file = $d_root.'/sqlike/access/log/access_count.txt';
$c = ['水銀燈', '金糸雀', '翠星石', '蒼星石', '真紅', '雛苺', '雪華綺晶', '薔薇水晶'];
$say = ['よ', 'かしら', 'です', 'だよ', 'なのだわ', 'なの', '。', '.'];
//アクセスカウンター
if (file_exists($access_count_file)){
$access_count = file_get_contents($access_count_file);
} else {
$access_count = 0;
file_put_contents($access_count_file, '0', LOCK_EX);
}
if (!isset($_COOKIE['accessed']) || empty($_COOKIE['accessed'])){
setcookie('accessed', 'yet', time() + 3600 * 24, '/');
unlink_by_date($d_root.'/sqlike/access/log/keep', 3600 * 24);
$ug = (isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:'unset');
$ip = (isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:'unset');
$keep_file = $d_root.'/sqlike/access/log/keep/.'.substr(pass($ug.$ip), -10);
if (!file_exists($keep_file)){
$access_count = $access_count +1;
file_put_contents($keep_file, '');
file_put_contents($access_count_file, $access_count, LOCK_EX);
}
}
##################html開始
html_head('','自由で、まったりしていて、優しくてゆるいサイトです。', $d_root.'/sqlike/css/home/index.css', true);
//htmlの分離
$f = $d_root.'/sqlike/html/home/index.html';
if (!file_exists($f)){
exit;
}
$html = explode('{ACCESS_COUNTER}', file_get_contents($f));
echo $html[0];
//アクセスカウンター
$akey = $access_count%7;
echo '<p><span style="background-image:url(/img/'.$c[$akey].'.png);background-repeat:no-repeat;width:24px;height:24px;display:block;float:left;background-size:contain;" title="'.$c[$akey].'"></span>「あなたは'.$access_count.'人目の訪問者'.$say[$akey].'」</p>';
//残り
echo $html[1];
html_foot('', '');