分類 | イベントハンドラ | 発生状況 |
---|---|---|
onload | リソースのロードが完了したとき | |
onunload | アンロードされたとき (ロードする前) | |
readystatechange | documentのreadyState属性が変化したとき | |
フォーカス | onfocus | 要素が入力フォーカスを得たとき |
onblur | 要素が入力フォーカスを失ったとき | |
onchange | ユーザーが要素の値を変更し、要素が入力フォーカスを失ったとき (プログラムから変更した場合には、イベントは発生しない) | |
onselect | テキストが選択されたとき | |
oncontextmenu | マウスで右クリック、またはアプリケーションキーが押されるなどして、コンテキストメニューが表示されるとき | |
マウス | onclick | マウスでクリックされたとき |
ondblclick | マウスでダブルクリックされたとき | |
onmousedown | マウスボタンが押されたとき | |
onmouseup | マウスボタンが離されたとき | |
onmouseover | マウスが要素に乗ったとき | |
onmouseout | マウスが要素から離れたとき | |
onmousemove | マウスが要素の上を移動したとき | |
キー | onkeydown | ユーザーがキーを押したとき |
onkeypress | ユーザーがキーを押して離したとき | |
onkeyup | ユーザーがキーを離したとき | |
フォーム | onsubmit | フォームの送信が要求されたとき |
onreset | フォームのリセットが要求されたとき | |
onresize | ウィンドウのサイズが変更されたとき (Windowオブジェクトのみ) | |
onscroll | 要素のコンテンツがスクロールされたとき | |
onabort | 画像のロードが中断されたとき | |
onerror | 画像のロード中にエラーが発生したとき |
2016年1月23日土曜日
addEventListener 一覧
ラベル:
addEventListener,
Javascript
2016年1月20日水曜日
テキストボックスのオートコンプリートを無効
テキストボックスのオートコンプリートを無効
autocomplete="off"
<input type="text" name="input" autocomplete="off" />
autocomplete="off"
<input type="text" name="input" autocomplete="off" />
2016年1月18日月曜日
フォームの送信(onsubmit)を中断する
submitの送信を中断する、addEventListener エベントの戻り値。
送信する値は””であれば、送信しませんん。
<php
echo "<form action =\"{$action_url}\" id =\"f\" method = \"get\">";
echo "<input id = \"searchform_q\" name = \"search_query\" value = \"{$value}\">";
echo '<button id = "searchform_button">send</button>';
echo '</from>';
?>
<script type = "text/javascript">
addevt();
function addevt(){
var f = document.getElementById('f');
f.addEventListener("submit",button_chk,false);
}
function button_chk(){
var input_text = document.getElementById('searchform_q');
if(input_text.value == ""){
event.returnValue=false; <<event.returnValue
}else{
event.returnValue=true;
}
}
</script>
送信する値は””であれば、送信しませんん。
<php
echo "<form action =\"{$action_url}\" id =\"f\" method = \"get\">";
echo "<input id = \"searchform_q\" name = \"search_query\" value = \"{$value}\">";
echo '<button id = "searchform_button">send</button>';
echo '</from>';
?>
<script type = "text/javascript">
addevt();
function addevt(){
var f = document.getElementById('f');
f.addEventListener("submit",button_chk,false);
}
function button_chk(){
var input_text = document.getElementById('searchform_q');
if(input_text.value == ""){
event.returnValue=false; <<event.returnValue
}else{
event.returnValue=true;
}
}
</script>
2016年1月5日火曜日
SQLITE3利用したログ記録 その3
<?php
//logo
set_time_limit(120);
session_name('aixin');
session_start();
//error_reporting(E_ALL);
date_default_timezone_set('Asia/Tokyo');
//include_once('acclog.php');
$hi = new acclog();
if(count(get_included_files()) == 1){
if(array_key_exists('xx',$_GET)){
//$hi->viewlog();
$hi->viewlog2();
}else{
$name = basename(__FILE__);
echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">';
echo '<html><head>';
echo '<title>404 Not Found</title>';
echo '</head><body>';
echo '<h1>Not Found</h1>';
echo "<p>The requested URL /{$name} was not found on this server.</p>";
echo '</body></html>';
exit();
}
}
class acclog{
public $db_name = "acclog.db";
// select datetime(request_time,"localtime") from log;
public function acclog(){
if(!file_exists($this->db_name)){
$this->create_acclog_db();
}
if(filesize($this->db_name) > 6438912){
$this->diet();
}
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("insert into log ('remote_addr','http_user_agent','request_uri','http_accept_language') values (:a,:b,:c,:d)");
$temp->bindValue(':a',$_SERVER['REMOTE_ADDR'],SQLITE3_TEXT);
$temp->bindValue(':b',$this->user_agent($_SERVER['HTTP_USER_AGENT']),SQLITE3_TEXT);
$temp->bindValue(':c',$_SERVER['REQUEST_URI'],SQLITE3_TEXT);
$temp->bindValue(':d',$_SERVER['HTTP_ACCEPT_LANGUAGE'],SQLITE3_TEXT);
$temp->execute();
$db->close();
$this->page_count($_SERVER['SCRIPT_FILENAME']);
}
private function user_agent($agent){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$sql_select = sprintf("select rowid from user_agent where http_user_agent = \"%s\"",$agent);
$sql_insert = sprintf("insert into user_agent (http_user_agent) values (\"%s\")",$agent);
$temp = $db->querySingle($sql_select);
if(is_null($temp)){
$db->exec($sql_insert);
$temp = $db->querySingle($sql_select);
$db->close();
return $temp;
}else{
$db->close();
return $temp;
}
$db->close();
}
public function viewlog2(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(1000);
$temp1 = $db->querySingle("select count(*) from log");
$temp2 = $db->querySingle("select count(*) from user_agent");
$temp3 = $db->querySingle("select count(*) from page_count");
$file_size = round((filesize($this->db_name)/1024/1024),2);
echo "<div>log_count:: {$temp1}</div>";
echo "<div>user_agent_count:: {$temp2}</div>";
echo "<div>page_count:: {$temp3}</div>";
echo "<div>file_size:: {$file_size} MB</div>";
echo '<br>';
$vt = $db->prepare("select * from page_count");
$vx = $vt->execute();
echo '<table border=1>';
while($vxx = $vx->fetchArray(SQLITE3_ASSOC)){
echo "<tr><td>{$vxx['script_filename']}</td><td>{$vxx['count']}</td></tr>";
}
echo '</table>';
$db->close();
}
public function viewlog(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("select rowid,http_user_agent from user_agent order by http_user_agent asc");
$temp2 = $temp->execute();
while($temp3 = $temp2->fetchArray(SQLITE3_ASSOC)){
$temp4 = $this->user_agent_count($temp3['rowid']);
if($temp4 != 0){
echo "<div>{$temp3['rowid']}::{$temp3['http_user_agent']}</div>";
echo "<div>{$temp4}</div>";
echo "<div><br></div>";
}
}
$vt = $db->prepare("select * from page_count");
$vx = $vt->execute();
while($vxx = $vx->fetchArray(SQLITE3_ASSOC)){
echo "<div>[script_filename] => {$vxx['script_filename']}</div>";
echo "<div>[count] => {$vxx['count']}</div>";
}
$db->close();
}
private function user_agent_count($rowid){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("select count(*) as count from log where http_user_agent = :a");
$temp->bindValue(':a',$rowid);
$temp2 = $temp->execute();
while($temp3 = $temp2->fetchArray(SQLITE3_ASSOC)){
$db->close();
return $temp3['count'];
}
$db->close();
}
private function page_count($script_filename){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
//script_filename
$sql_1 = sprintf("select script_filename from page_count where script_filename = \"%s\"",$script_filename);
$sql_2 = sprintf("insert into page_count (script_filename,count) values (\"%s\",0)",$script_filename);
$sql_3 = sprintf ("update page_count set count = count + 1 where script_filename = \"%s\"",$script_filename);
$temp = $db->querySingle($sql_1);
if($temp == null){
$db->exec($sql_2);
$db->exec($sql_3);
}else{
$db->exec($sql_3);
}
$db->close();
}
private function diet(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
//$temp = $db->prepare("delete from log where request_time < datetime('now','-2 days')");
//$temp->execute();
$sql = sprintf("delete from log where request_time < datetime('now','-1 days')");
$db->exec($sql);
$db->exec('VACUUM');
$db->close();
}
public function create_acclog_db(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$create_db =
"create table log(
request_time text default current_timestamp,
remote_addr text,
http_user_agent text,
request_uri text,
http_accept_language text
)";
$db->exec($create_db);
$create_db =
"create table user_agent(
http_user_agent text
)";
$db->exec($create_db);
$create_db =
"create table page_count(
script_filename text unique,
count integer
)";
$db->exec($create_db);
$db->close();
}
}
//old
function old_mf_log($log=null){
error_reporting(0);
date_default_timezone_set('Asia/Tokyo');
$file=basename(__FILE__);
$log_server[$file]=date('c');
$log_server['ip']=$_SERVER['REMOTE_ADDR'];
$log_server['uag']=$_SERVER['HTTP_USER_AGENT'];
$log_server['lg']=$_SERVER['HTTP_ACCEPT_LANGUAGE'];
$log_server['url']=$log;
$log_str='<?php //';
foreach ($log_server as $key=>$val){
$log_str=$log_str.$key.'>'.$val.', ';
unset($val);
unset($key);
}
$log_str=$log_str.'// ?>'."\r\n";
file_put_contents('log_itunes.php', $log_str, FILE_APPEND | LOCK_EX);
}
?>
//logo
set_time_limit(120);
session_name('aixin');
session_start();
//error_reporting(E_ALL);
date_default_timezone_set('Asia/Tokyo');
//include_once('acclog.php');
$hi = new acclog();
if(count(get_included_files()) == 1){
if(array_key_exists('xx',$_GET)){
//$hi->viewlog();
$hi->viewlog2();
}else{
$name = basename(__FILE__);
echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">';
echo '<html><head>';
echo '<title>404 Not Found</title>';
echo '</head><body>';
echo '<h1>Not Found</h1>';
echo "<p>The requested URL /{$name} was not found on this server.</p>";
echo '</body></html>';
exit();
}
}
class acclog{
public $db_name = "acclog.db";
// select datetime(request_time,"localtime") from log;
public function acclog(){
if(!file_exists($this->db_name)){
$this->create_acclog_db();
}
if(filesize($this->db_name) > 6438912){
$this->diet();
}
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("insert into log ('remote_addr','http_user_agent','request_uri','http_accept_language') values (:a,:b,:c,:d)");
$temp->bindValue(':a',$_SERVER['REMOTE_ADDR'],SQLITE3_TEXT);
$temp->bindValue(':b',$this->user_agent($_SERVER['HTTP_USER_AGENT']),SQLITE3_TEXT);
$temp->bindValue(':c',$_SERVER['REQUEST_URI'],SQLITE3_TEXT);
$temp->bindValue(':d',$_SERVER['HTTP_ACCEPT_LANGUAGE'],SQLITE3_TEXT);
$temp->execute();
$db->close();
$this->page_count($_SERVER['SCRIPT_FILENAME']);
}
private function user_agent($agent){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$sql_select = sprintf("select rowid from user_agent where http_user_agent = \"%s\"",$agent);
$sql_insert = sprintf("insert into user_agent (http_user_agent) values (\"%s\")",$agent);
$temp = $db->querySingle($sql_select);
if(is_null($temp)){
$db->exec($sql_insert);
$temp = $db->querySingle($sql_select);
$db->close();
return $temp;
}else{
$db->close();
return $temp;
}
$db->close();
}
public function viewlog2(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(1000);
$temp1 = $db->querySingle("select count(*) from log");
$temp2 = $db->querySingle("select count(*) from user_agent");
$temp3 = $db->querySingle("select count(*) from page_count");
$file_size = round((filesize($this->db_name)/1024/1024),2);
echo "<div>log_count:: {$temp1}</div>";
echo "<div>user_agent_count:: {$temp2}</div>";
echo "<div>page_count:: {$temp3}</div>";
echo "<div>file_size:: {$file_size} MB</div>";
echo '<br>';
$vt = $db->prepare("select * from page_count");
$vx = $vt->execute();
echo '<table border=1>';
while($vxx = $vx->fetchArray(SQLITE3_ASSOC)){
echo "<tr><td>{$vxx['script_filename']}</td><td>{$vxx['count']}</td></tr>";
}
echo '</table>';
$db->close();
}
public function viewlog(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("select rowid,http_user_agent from user_agent order by http_user_agent asc");
$temp2 = $temp->execute();
while($temp3 = $temp2->fetchArray(SQLITE3_ASSOC)){
$temp4 = $this->user_agent_count($temp3['rowid']);
if($temp4 != 0){
echo "<div>{$temp3['rowid']}::{$temp3['http_user_agent']}</div>";
echo "<div>{$temp4}</div>";
echo "<div><br></div>";
}
}
$vt = $db->prepare("select * from page_count");
$vx = $vt->execute();
while($vxx = $vx->fetchArray(SQLITE3_ASSOC)){
echo "<div>[script_filename] => {$vxx['script_filename']}</div>";
echo "<div>[count] => {$vxx['count']}</div>";
}
$db->close();
}
private function user_agent_count($rowid){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("select count(*) as count from log where http_user_agent = :a");
$temp->bindValue(':a',$rowid);
$temp2 = $temp->execute();
while($temp3 = $temp2->fetchArray(SQLITE3_ASSOC)){
$db->close();
return $temp3['count'];
}
$db->close();
}
private function page_count($script_filename){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
//script_filename
$sql_1 = sprintf("select script_filename from page_count where script_filename = \"%s\"",$script_filename);
$sql_2 = sprintf("insert into page_count (script_filename,count) values (\"%s\",0)",$script_filename);
$sql_3 = sprintf ("update page_count set count = count + 1 where script_filename = \"%s\"",$script_filename);
$temp = $db->querySingle($sql_1);
if($temp == null){
$db->exec($sql_2);
$db->exec($sql_3);
}else{
$db->exec($sql_3);
}
$db->close();
}
private function diet(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
//$temp = $db->prepare("delete from log where request_time < datetime('now','-2 days')");
//$temp->execute();
$sql = sprintf("delete from log where request_time < datetime('now','-1 days')");
$db->exec($sql);
$db->exec('VACUUM');
$db->close();
}
public function create_acclog_db(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$create_db =
"create table log(
request_time text default current_timestamp,
remote_addr text,
http_user_agent text,
request_uri text,
http_accept_language text
)";
$db->exec($create_db);
$create_db =
"create table user_agent(
http_user_agent text
)";
$db->exec($create_db);
$create_db =
"create table page_count(
script_filename text unique,
count integer
)";
$db->exec($create_db);
$db->close();
}
}
//old
function old_mf_log($log=null){
error_reporting(0);
date_default_timezone_set('Asia/Tokyo');
$file=basename(__FILE__);
$log_server[$file]=date('c');
$log_server['ip']=$_SERVER['REMOTE_ADDR'];
$log_server['uag']=$_SERVER['HTTP_USER_AGENT'];
$log_server['lg']=$_SERVER['HTTP_ACCEPT_LANGUAGE'];
$log_server['url']=$log;
$log_str='<?php //';
foreach ($log_server as $key=>$val){
$log_str=$log_str.$key.'>'.$val.', ';
unset($val);
unset($key);
}
$log_str=$log_str.'// ?>'."\r\n";
file_put_contents('log_itunes.php', $log_str, FILE_APPEND | LOCK_EX);
}
?>
2015年12月29日火曜日
SQLITE3利用したログ記録 その2
SQLITE3利用したログ記録 その2
private function page_count () を追加しました。
script_filename アクセス数をカウントします。
<?php
//logo
session_name('aixin');
session_start();
//error_reporting(E_ALL);
date_default_timezone_set('Asia/Tokyo');
//include_once('acclog.php');
$hi = new acclog();
if(count(get_included_files()) == 1){
if(array_key_exists('xx',$_GET)){
$hi->viewlog();
}else{
$name = basename(__FILE__);
echo '<html><head>';
echo '<title>404 Not Found</title>';
echo '</head><body>';
echo '<h1>Not Found</h1>';
echo "<p>The requested URL /{$name} was not found on this server.</p>";
echo '</body></html>';
exit();
}
}
class acclog{
public $db_name = "acclog.db";
// select datetime(request_time,"localtime") from log;
public function acclog(){
if(!file_exists($this->db_name)){
$this->create_acclog_db();
}
if(filesize($this->db_name) > 6438912){
$this->diet();
}
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("insert into log ('remote_addr','http_user_agent','request_uri','http_accept_language') values (:a,:b,:c,:d)");
$temp->bindValue(':a',$_SERVER['REMOTE_ADDR'],SQLITE3_TEXT);
$temp->bindValue(':b',$this->user_agent($_SERVER['HTTP_USER_AGENT']),SQLITE3_TEXT);
$temp->bindValue(':c',$_SERVER['REQUEST_URI'],SQLITE3_TEXT);
$temp->bindValue(':d',$_SERVER['HTTP_ACCEPT_LANGUAGE'],SQLITE3_TEXT);
$temp->execute();
$db->close();
$this->page_count($_SERVER['SCRIPT_FILENAME']);
}
private function user_agent($agent){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$sql_select = sprintf("select rowid from user_agent where http_user_agent = \"%s\"",$agent);
$sql_insert = sprintf("insert into user_agent (http_user_agent) values (\"%s\")",$agent);
$temp = $db->querySingle($sql_select);
if(is_null($temp)){
$db->exec($sql_insert);
$temp = $db->querySingle($sql_select);
$db->close();
return $temp;
}else{
$db->close();
return $temp;
}
$db->close();
}
public function viewlog(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("select rowid,http_user_agent from user_agent order by http_user_agent asc");
$temp2 = $temp->execute();
while($temp3 = $temp2->fetchArray(SQLITE3_ASSOC)){
$temp4 = $this->user_agent_count($temp3['rowid']);
if($temp4 != 0){
echo "<div>{$temp3['rowid']}::{$temp3['http_user_agent']}</div>";
echo "<div>{$temp4}</div>";
echo "<div><br></div>";
}
}
$vt = $db->prepare("select * from page_count");
$vx = $vt->execute();
while($vxx = $vx->fetchArray(SQLITE3_ASSOC)){
echo "<div>[script_filename] => {$vxx['script_filename']}</div>";
echo "<div>[count] => {$vxx['count']}</div>";
}
$db->close();
}
private function user_agent_count($rowid){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("select count(*) as count from log where http_user_agent = :a");
$temp->bindValue(':a',$rowid);
$temp2 = $temp->execute();
while($temp3 = $temp2->fetchArray(SQLITE3_ASSOC)){
$db->close();
return $temp3['count'];
}
$db->close();
}
private function page_count($script_filename){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
//script_filename
$sql_1 = sprintf("select script_filename from page_count where script_filename = \"%s\"",$script_filename);
$sql_2 = sprintf("insert into page_count (script_filename,count) values (\"%s\",0)",$script_filename);
$sql_3 = sprintf ("update page_count set count = count + 1 where script_filename = \"%s\"",$script_filename);
$temp = $db->querySingle($sql_1);
if($temp == null){
$db->exec($sql_2);
$db->exec($sql_3);
}else{
$db->exec($sql_3);
}
$db->close();
}
private function diet(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("delete from log where request_time < datetime('now','-7 days')");
$temp->execute();
$db->exec('VACUUM');
$db->close();
}
public function create_acclog_db(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$create_db =
"create table log(
request_time text default current_timestamp,
remote_addr text,
http_user_agent text,
request_uri text,
http_accept_language text
)";
$db->exec($create_db);
$create_db =
"create table user_agent(
http_user_agent text
)";
$db->exec($create_db);
$create_db =
"create table page_count(
script_filename text unique,
count integer
)";
$db->exec($create_db);
$db->close();
}
}
//old
function old_mf_log($log=null){
error_reporting(0);
date_default_timezone_set('Asia/Tokyo');
$file=basename(__FILE__);
$log_server[$file]=date('c');
$log_server['ip']=$_SERVER['REMOTE_ADDR'];
$log_server['uag']=$_SERVER['HTTP_USER_AGENT'];
$log_server['lg']=$_SERVER['HTTP_ACCEPT_LANGUAGE'];
$log_server['url']=$log;
$log_str='<?php //';
foreach ($log_server as $key=>$val){
$log_str=$log_str.$key.'>'.$val.', ';
unset($val);
unset($key);
}
$log_str=$log_str.'// ?>'."\r\n";
file_put_contents('log_itunes.php', $log_str, FILE_APPEND | LOCK_EX);
}
?>
private function page_count () を追加しました。
script_filename アクセス数をカウントします。
<?php
//logo
session_name('aixin');
session_start();
//error_reporting(E_ALL);
date_default_timezone_set('Asia/Tokyo');
//include_once('acclog.php');
$hi = new acclog();
if(count(get_included_files()) == 1){
if(array_key_exists('xx',$_GET)){
$hi->viewlog();
}else{
$name = basename(__FILE__);
echo '<html><head>';
echo '<title>404 Not Found</title>';
echo '</head><body>';
echo '<h1>Not Found</h1>';
echo "<p>The requested URL /{$name} was not found on this server.</p>";
echo '</body></html>';
exit();
}
}
class acclog{
public $db_name = "acclog.db";
// select datetime(request_time,"localtime") from log;
public function acclog(){
if(!file_exists($this->db_name)){
$this->create_acclog_db();
}
if(filesize($this->db_name) > 6438912){
$this->diet();
}
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("insert into log ('remote_addr','http_user_agent','request_uri','http_accept_language') values (:a,:b,:c,:d)");
$temp->bindValue(':a',$_SERVER['REMOTE_ADDR'],SQLITE3_TEXT);
$temp->bindValue(':b',$this->user_agent($_SERVER['HTTP_USER_AGENT']),SQLITE3_TEXT);
$temp->bindValue(':c',$_SERVER['REQUEST_URI'],SQLITE3_TEXT);
$temp->bindValue(':d',$_SERVER['HTTP_ACCEPT_LANGUAGE'],SQLITE3_TEXT);
$temp->execute();
$db->close();
$this->page_count($_SERVER['SCRIPT_FILENAME']);
}
private function user_agent($agent){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$sql_select = sprintf("select rowid from user_agent where http_user_agent = \"%s\"",$agent);
$sql_insert = sprintf("insert into user_agent (http_user_agent) values (\"%s\")",$agent);
$temp = $db->querySingle($sql_select);
if(is_null($temp)){
$db->exec($sql_insert);
$temp = $db->querySingle($sql_select);
$db->close();
return $temp;
}else{
$db->close();
return $temp;
}
$db->close();
}
public function viewlog(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("select rowid,http_user_agent from user_agent order by http_user_agent asc");
$temp2 = $temp->execute();
while($temp3 = $temp2->fetchArray(SQLITE3_ASSOC)){
$temp4 = $this->user_agent_count($temp3['rowid']);
if($temp4 != 0){
echo "<div>{$temp3['rowid']}::{$temp3['http_user_agent']}</div>";
echo "<div>{$temp4}</div>";
echo "<div><br></div>";
}
}
$vt = $db->prepare("select * from page_count");
$vx = $vt->execute();
while($vxx = $vx->fetchArray(SQLITE3_ASSOC)){
echo "<div>[script_filename] => {$vxx['script_filename']}</div>";
echo "<div>[count] => {$vxx['count']}</div>";
}
$db->close();
}
private function user_agent_count($rowid){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("select count(*) as count from log where http_user_agent = :a");
$temp->bindValue(':a',$rowid);
$temp2 = $temp->execute();
while($temp3 = $temp2->fetchArray(SQLITE3_ASSOC)){
$db->close();
return $temp3['count'];
}
$db->close();
}
private function page_count($script_filename){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
//script_filename
$sql_1 = sprintf("select script_filename from page_count where script_filename = \"%s\"",$script_filename);
$sql_2 = sprintf("insert into page_count (script_filename,count) values (\"%s\",0)",$script_filename);
$sql_3 = sprintf ("update page_count set count = count + 1 where script_filename = \"%s\"",$script_filename);
$temp = $db->querySingle($sql_1);
if($temp == null){
$db->exec($sql_2);
$db->exec($sql_3);
}else{
$db->exec($sql_3);
}
$db->close();
}
private function diet(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("delete from log where request_time < datetime('now','-7 days')");
$temp->execute();
$db->exec('VACUUM');
$db->close();
}
public function create_acclog_db(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$create_db =
"create table log(
request_time text default current_timestamp,
remote_addr text,
http_user_agent text,
request_uri text,
http_accept_language text
)";
$db->exec($create_db);
$create_db =
"create table user_agent(
http_user_agent text
)";
$db->exec($create_db);
$create_db =
"create table page_count(
script_filename text unique,
count integer
)";
$db->exec($create_db);
$db->close();
}
}
//old
function old_mf_log($log=null){
error_reporting(0);
date_default_timezone_set('Asia/Tokyo');
$file=basename(__FILE__);
$log_server[$file]=date('c');
$log_server['ip']=$_SERVER['REMOTE_ADDR'];
$log_server['uag']=$_SERVER['HTTP_USER_AGENT'];
$log_server['lg']=$_SERVER['HTTP_ACCEPT_LANGUAGE'];
$log_server['url']=$log;
$log_str='<?php //';
foreach ($log_server as $key=>$val){
$log_str=$log_str.$key.'>'.$val.', ';
unset($val);
unset($key);
}
$log_str=$log_str.'// ?>'."\r\n";
file_put_contents('log_itunes.php', $log_str, FILE_APPEND | LOCK_EX);
}
?>
2015年12月28日月曜日
SQLITE3利用したログ記録
ログ記録
SQLITE3利用したログ記録
<?php
//logo
session_name('log');
session_start();
error_reporting(E_ALL);
date_default_timezone_set('Asia/Tokyo');
//include_once('acclog.php');
$hi = new acclog();
if(count(get_included_files()) == 1){
$hi->viewlog();
}
class acclog{
public $db_name = "acclog.db";
// select datetime(request_time,"localtime") from log;
public function acclog(){
if(!file_exists($this->db_name)){
$this->create_acclog_db();
}
if(filesize($this->db_name) > 6438912){
$this->diet();
}
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("insert into log ('remote_addr','http_user_agent','request_uri','http_accept_language') values (:a,:b,:c,:d)");
$temp->bindValue(':a',$_SERVER['REMOTE_ADDR'],SQLITE3_TEXT);
$temp->bindValue(':b',$this->user_agent($_SERVER['HTTP_USER_AGENT']),SQLITE3_TEXT);
$temp->bindValue(':c',$_SERVER['REQUEST_URI'],SQLITE3_TEXT);
$temp->bindValue(':d',$_SERVER['HTTP_ACCEPT_LANGUAGE'],SQLITE3_TEXT);
$temp->execute();
$db->close();
}
private function user_agent($agent){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$sql_select = sprintf("select rowid from user_agent where http_user_agent = \"%s\"",$agent);
$sql_insert = sprintf("insert into user_agent (http_user_agent) values (\"%s\")",$agent);
$temp = $db->querySingle($sql_select);
if(is_null($temp)){
$db->exec($sql_insert);
$temp = $db->querySingle($sql_select);
$db->close();
return $temp;
}else{
$db->close();
return $temp;
}
$db->close();
}
public function viewlog(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("select rowid,http_user_agent from user_agent order by http_user_agent asc");
$temp2 = $temp->execute();
while($temp3 = $temp2->fetchArray(SQLITE3_ASSOC)){
$temp4 = $this->user_agent_count($temp3['rowid']);
if($temp4 != 0){
echo "<div>{$temp3['rowid']}::{$temp3['http_user_agent']}</div>";
echo "<div>{$temp4}</div>";
echo "<div><br></div>";
}
}
$db->close();
}
private function user_agent_count($rowid){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("select count(*) as count from log where http_user_agent = :a");
$temp->bindValue(':a',$rowid);
$temp2 = $temp->execute();
while($temp3 = $temp2->fetchArray(SQLITE3_ASSOC)){
$db->close();
return $temp3['count'];
}
$db->close();
}
private function diet(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("delete from log where request_time < datetime('now','-7 days')");
$temp->execute();
$db->exec('VACUUM');
$db->close();
}
public function create_acclog_db(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$create_db =
"create table log(
request_time text default current_timestamp,
remote_addr text,
http_user_agent text,
request_uri text,
http_accept_language text
)";
$db->exec($create_db);
$create_db =
"create table user_agent(
http_user_agent text
)";
$db->exec($create_db);
$db->close();
}
}
//old
function mf_log($log=null){
error_reporting(0);
date_default_timezone_set('Asia/Tokyo');
$file=basename(__FILE__);
$log_server[$file]=date('c');
$log_server['ip']=$_SERVER['REMOTE_ADDR'];
$log_server['uag']=$_SERVER['HTTP_USER_AGENT'];
$log_server['lg']=$_SERVER['HTTP_ACCEPT_LANGUAGE'];
$log_server['url']=$log;
$log_str='<?php //';
foreach ($log_server as $key=>$val){
$log_str=$log_str.$key.'>'.$val.', ';
unset($val);
unset($key);
}
$log_str=$log_str.'// ?>'."\r\n";
file_put_contents('log_itunes.php', $log_str, FILE_APPEND | LOCK_EX);
}
?>
SQLITE3利用したログ記録
<?php
//logo
session_name('log');
session_start();
error_reporting(E_ALL);
date_default_timezone_set('Asia/Tokyo');
//include_once('acclog.php');
$hi = new acclog();
if(count(get_included_files()) == 1){
$hi->viewlog();
}
class acclog{
public $db_name = "acclog.db";
// select datetime(request_time,"localtime") from log;
public function acclog(){
if(!file_exists($this->db_name)){
$this->create_acclog_db();
}
if(filesize($this->db_name) > 6438912){
$this->diet();
}
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("insert into log ('remote_addr','http_user_agent','request_uri','http_accept_language') values (:a,:b,:c,:d)");
$temp->bindValue(':a',$_SERVER['REMOTE_ADDR'],SQLITE3_TEXT);
$temp->bindValue(':b',$this->user_agent($_SERVER['HTTP_USER_AGENT']),SQLITE3_TEXT);
$temp->bindValue(':c',$_SERVER['REQUEST_URI'],SQLITE3_TEXT);
$temp->bindValue(':d',$_SERVER['HTTP_ACCEPT_LANGUAGE'],SQLITE3_TEXT);
$temp->execute();
$db->close();
}
private function user_agent($agent){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$sql_select = sprintf("select rowid from user_agent where http_user_agent = \"%s\"",$agent);
$sql_insert = sprintf("insert into user_agent (http_user_agent) values (\"%s\")",$agent);
$temp = $db->querySingle($sql_select);
if(is_null($temp)){
$db->exec($sql_insert);
$temp = $db->querySingle($sql_select);
$db->close();
return $temp;
}else{
$db->close();
return $temp;
}
$db->close();
}
public function viewlog(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("select rowid,http_user_agent from user_agent order by http_user_agent asc");
$temp2 = $temp->execute();
while($temp3 = $temp2->fetchArray(SQLITE3_ASSOC)){
$temp4 = $this->user_agent_count($temp3['rowid']);
if($temp4 != 0){
echo "<div>{$temp3['rowid']}::{$temp3['http_user_agent']}</div>";
echo "<div>{$temp4}</div>";
echo "<div><br></div>";
}
}
$db->close();
}
private function user_agent_count($rowid){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("select count(*) as count from log where http_user_agent = :a");
$temp->bindValue(':a',$rowid);
$temp2 = $temp->execute();
while($temp3 = $temp2->fetchArray(SQLITE3_ASSOC)){
$db->close();
return $temp3['count'];
}
$db->close();
}
private function diet(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$temp = $db->prepare("delete from log where request_time < datetime('now','-7 days')");
$temp->execute();
$db->exec('VACUUM');
$db->close();
}
public function create_acclog_db(){
$db = new sqlite3($this->db_name);
$db->busyTimeout(10000);
$create_db =
"create table log(
request_time text default current_timestamp,
remote_addr text,
http_user_agent text,
request_uri text,
http_accept_language text
)";
$db->exec($create_db);
$create_db =
"create table user_agent(
http_user_agent text
)";
$db->exec($create_db);
$db->close();
}
}
//old
function mf_log($log=null){
error_reporting(0);
date_default_timezone_set('Asia/Tokyo');
$file=basename(__FILE__);
$log_server[$file]=date('c');
$log_server['ip']=$_SERVER['REMOTE_ADDR'];
$log_server['uag']=$_SERVER['HTTP_USER_AGENT'];
$log_server['lg']=$_SERVER['HTTP_ACCEPT_LANGUAGE'];
$log_server['url']=$log;
$log_str='<?php //';
foreach ($log_server as $key=>$val){
$log_str=$log_str.$key.'>'.$val.', ';
unset($val);
unset($key);
}
$log_str=$log_str.'// ?>'."\r\n";
file_put_contents('log_itunes.php', $log_str, FILE_APPEND | LOCK_EX);
}
?>
2015年12月26日土曜日
Google 可以识别的元标记
Google 可以识别的元标记
noindex:防止网页被编入索引
<meta name="robots" content="noindex" />
这些元标记可以控制搜索引擎的抓取和索引编制行为。robots 元标记适用于所有搜索引擎,而“googlebot”元标记专用于 Google。默认值是“index, follow”(相当于“all”),不需要进行指定。我们可以识别以下值(指定多个值时,请使用英文逗号进行分隔):
noindex:防止网页被编入索引
nofollow:防止 Googlebot 跟踪此页面中的链接
nosnippet:防止代码段显示在搜索结果中
noodp:防止使用 ODP/DMOZ 中的替代说明
noarchive:防止 Google 显示网页的缓存链接。
unavailable_after:[date]:可让您指定要停止抓取此网页及将其编入索引的确切时间和日期
noimageindex:可让您指定您不希望自己的网页显示为 Google 搜索结果中所显示图片的引荐来源网页。
none:相当于 noindex, nofollow。
现在,您还可以使用“X-Robots-Tag”HTTP 标头指令在网页的标头中指定此信息。如果您要限制将非 HTML 文件(如图形或其他类型的文档)编入索引,这种方法尤其实用。详细了解漫游器元标记
noindex:防止网页被编入索引
<meta name="robots" content="noindex" />
这些元标记可以控制搜索引擎的抓取和索引编制行为。robots 元标记适用于所有搜索引擎,而“googlebot”元标记专用于 Google。默认值是“index, follow”(相当于“all”),不需要进行指定。我们可以识别以下值(指定多个值时,请使用英文逗号进行分隔):
noindex:防止网页被编入索引
nofollow:防止 Googlebot 跟踪此页面中的链接
nosnippet:防止代码段显示在搜索结果中
noodp:防止使用 ODP/DMOZ 中的替代说明
noarchive:防止 Google 显示网页的缓存链接。
unavailable_after:[date]:可让您指定要停止抓取此网页及将其编入索引的确切时间和日期
noimageindex:可让您指定您不希望自己的网页显示为 Google 搜索结果中所显示图片的引荐来源网页。
none:相当于 noindex, nofollow。
现在,您还可以使用“X-Robots-Tag”HTTP 标头指令在网页的标头中指定此信息。如果您要限制将非 HTML 文件(如图形或其他类型的文档)编入索引,这种方法尤其实用。详细了解漫游器元标记
登録:
投稿 (Atom)