ホームページにカウンタを付けられますか?
by
質問さん
(62537c0d)
投稿数:0回
(ベストアンサー:0回)
(ベストアンサー:0回)
2015/02/27 15:35
無料レンタルサーバーのトップページに、来訪者数のカウンタを付けたいのですが、出来ますでしょうか?
できるようなら、コードを教えてください。
よろしくお願いします。
できるようなら、コードを教えてください。
よろしくお願いします。
by
su56さん
(c9624cf9)
投稿数:17回
(ベストアンサー:3回)
(ベストアンサー:3回)
2015/03/03 19:10
FC2とか忍者とかのカウンター利用で登録に抵抗があるのなら
http://www.rays-counter.com/
でタグ作成してそっくり貼り付ければできます。
http://www.rays-counter.com/
でタグ作成してそっくり貼り付ければできます。
by
RabbitKさん
(7801929b)
投稿数:3回
(ベストアンサー:1回)
(ベストアンサー:1回)
2015/03/11 15:04
IP ADDRESSでカウントされるタイプの雑な手作りでよければどうぞ!
<?php
function counter(){
echo'
<form name="counter">
<label>VISITER:</label>
';
session_start();
if (!empty($_SERVER["HTTP_CLIENT_IP"])){
$IP = $_SERVER["HTTP_CLIENT_IP"];
}elseif (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])){
$IP = $_SERVER["HTTP_X_FORWARDED_FOR"];
}else{
$IP = $_SERVER["REMOTE_ADDR"];
}
if(!empty($IP)){
if(!file_exists("accessip.txt")){
if($file = touch("accessip.txt")){
$open = fopen("accessip.txt","w+");
$write = fwrite($open,"$IP\n");
$close = fclose($open);
if($_SESSION['access'] = 1){
if(!file_exists("accessnum.txt")){
if($file = touch("accessnum.txt")){
$open2 = fopen("accessnum.txt","w+");
$write2 = fwrite($open2,$_SESSION['access']);
$close2 = fclose($open2);
}}//
$i = $_SESSION['access'];
}//
}//
}else{
$file = "accessip.txt";
if($get = file_get_contents($file)){
if(strstr($get,$IP) !== false){
$getnum = file_get_contents("accessnum.txt");
$i = $getnum;
}else{
$file = "accessip.txt";
$open = file_get_contents($file);
$open .= "$IP\n";
$write = file_put_contents($file,$open);
$getnum = file_get_contents("accessnum.txt");
$i = $getnum;
$i++;
$numopen = fopen("accessnum.txt","w+");
$numwrite = fwrite($numopen,$i);
$numclose = fclose($numopen);
$_SESSION['access'] = $i;
}//
}//
}//
}
$split = str_split($i);
$loop = count($split);
for($i=0;$i<=$loop-1;$i++){
echo'
<input type="text" name="count'.$i.'" value="'.$split[$i].'" maxlength="1" placeholder=" 0" style="width:1em;">
';
}
echo'
<label>ACCESS IP:</label>
<input type="text" name="visiterip" value="';
echo$IP;
echo'" maxlength="13" size="10">
</form>
';
}
?>
<?php
counter();
?>
<?php
function counter(){
echo'
<form name="counter">
<label>VISITER:</label>
';
session_start();
if (!empty($_SERVER["HTTP_CLIENT_IP"])){
$IP = $_SERVER["HTTP_CLIENT_IP"];
}elseif (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])){
$IP = $_SERVER["HTTP_X_FORWARDED_FOR"];
}else{
$IP = $_SERVER["REMOTE_ADDR"];
}
if(!empty($IP)){
if(!file_exists("accessip.txt")){
if($file = touch("accessip.txt")){
$open = fopen("accessip.txt","w+");
$write = fwrite($open,"$IP\n");
$close = fclose($open);
if($_SESSION['access'] = 1){
if(!file_exists("accessnum.txt")){
if($file = touch("accessnum.txt")){
$open2 = fopen("accessnum.txt","w+");
$write2 = fwrite($open2,$_SESSION['access']);
$close2 = fclose($open2);
}}//
$i = $_SESSION['access'];
}//
}//
}else{
$file = "accessip.txt";
if($get = file_get_contents($file)){
if(strstr($get,$IP) !== false){
$getnum = file_get_contents("accessnum.txt");
$i = $getnum;
}else{
$file = "accessip.txt";
$open = file_get_contents($file);
$open .= "$IP\n";
$write = file_put_contents($file,$open);
$getnum = file_get_contents("accessnum.txt");
$i = $getnum;
$i++;
$numopen = fopen("accessnum.txt","w+");
$numwrite = fwrite($numopen,$i);
$numclose = fclose($numopen);
$_SESSION['access'] = $i;
}//
}//
}//
}
$split = str_split($i);
$loop = count($split);
for($i=0;$i<=$loop-1;$i++){
echo'
<input type="text" name="count'.$i.'" value="'.$split[$i].'" maxlength="1" placeholder=" 0" style="width:1em;">
';
}
echo'
<label>ACCESS IP:</label>
<input type="text" name="visiterip" value="';
echo$IP;
echo'" maxlength="13" size="10">
</form>
';
}
?>
<?php
counter();
?>