syntaxhighlighterなるものを導入してみた。。。
<?php
$count = 0;
for($i = 0; $i < 10; $i++){
$count++;
}
echo "Hello PHP";
?>
CakePHPでアクセスカウンタをつくってみた。
よくわからないけど,とにかく簡単につくってみた。
■機能
■DB
テーブル:counts
フィールド:
■コード
// アクセスカウンタの更新処理
$count = 0;
$query = array(
'order'=>'Count.count DESC',
);
$cnt =$this->Count->find('first', $query);
if($cnt){
$count = $cnt['Count']['count'];
}
if($this->Cookie->read('count') != 'checked''){
$this->Cookie->write('count', 'cheched');
$count = $count + 1;
// キリ番判定
if((ereg("00$", $count))
||(ereg('^1{2,}$', $count))
||(ereg('^2{2,}$', $count))
||(ereg('^3{2,}$', $count))
||(ereg('^4{2,}$', $count))
||(ereg('^5{2,}$', $count))
||(ereg('^6{2,}$', $count))
||(ereg('^7{2,}$', $count))
||(ereg('^8{2,}$', $count))
||(ereg('^9{2,}$', $count))
){ // 100単位 or ぞろ目
$this->redirect('キリ番登録先');
}
$this->data['Count']['count'] = $count;
$this->Count->save($this->data);
}
$this->set('count', $count); // viewにカウント数をセット