Wednesday, January 16, 2008

mod_rewrite 特定のURLを対象外

<Directory "/***">
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !\.(cgi|css|gif|jpe?g|png)$


RewriteRule ^(.+)/bookmark/movie/list/([0-9]+)/?$ hoge2.php?page=$1&id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.+)/movie/list/([0-9]+)/?$ hoge.php?page=$1&page2=$2&%{QUERY_STRING} [L]



</Directory>

Tuesday, January 15, 2008

直リンクの禁止 バーチャルドメインの場合

<VirtualHost 192.168.*.*>
ServerName example.com
DocumentRoot /home/example/htdocs
ServerAdmin webmaster@www.hoge.co.jp
ErrorLog logs/error_log
TransferLog logs/access_log

#<Files *.gif>

<Files ~ "\.(tbz|tgz|bz2|gz|tar|lzh|zip|mag|png|jpeg|jpg|gif)$">

SetEnvIf referer "^http://example\.com" RefOk
Order Deny,Allow
Deny from all
Allow from env=RefOk
</Files>

</VirtualHost>

Monday, January 07, 2008

年齢 MYSQL PHP

select (YEAR(CURDATE())-YEAR(birth))- (RIGHT(CURDATE(),5) <RIGHT(birth,5)) AS age from hoge

----

PHPの場合

<?php
$birthday = '1990-01-12';
$lapse = getdate(mktime()-mktime(0,0,0,substr($birthday,5,2),
substr($birthday,8,2),substr($birthday,0,4)));
$age = $lapse['year']-1990;
echo $age;
?>
~

Thursday, January 03, 2008

javascript 日付チェック

if(!chkDate(document.form.year.value,document.form.month.value,document.form.day.value)) {
alert("日付を正しく入力してください。");
return false;
}


function chkDate(y,m,d){
var date1 = new Date(y,m-1,d);
if(date1.getFullYear() == y && date1.getMonth() == m-1 && date1.getDate() == d){
return true;
}
return false;
}