<?php
/*
+--------------------------------------------------------+
| O-BLOG - PHP Blog System                               |
| Copyright (c) 2004 phpBlog.CN                          |
| Support : http://www.phpBlog.cn                        |
| Author : ShiShiRui (shishirui@163.com)                 |
|--------------------------------------------------------+
*/
//error_reporting(7);

require('config.php');

$do = checkPost(trim($_GET['do']));
if (!$do) $do=checkPost(trim($_POST['do']));

if($do == "add") {
	$blogid = intval($_GET['id']);
	if($blogid == 0) {
		exit;
	}
	if(!isset($_COOKIE['ob_has_view_'.$blogid]) || trim($_COOKIE['ob_has_view_'.$blogid]) != 'ob_has_view') {
		if($DB->query("UPDATE {$mysql_prefix}blog SET viewcount=viewcount+1 WHERE id='{$blogid}'")) {
			setcookie("ob_has_view_".$blogid, "ob_has_view",time()+3600);
		}
	}
}

if($do == "get")
{
	$ids = trim($_GET['ids']);
	if (!$ids) die;
	$arr = explode("|",$ids);
	$s = "";
	foreach($arr as $id)
	{
		$id = intval($id);
		if (!$id) continue;
		$s.= $id.")";
		$i = $DB->fetch_one("SELECT viewcount FROM {$mysql_prefix}blog WHERE id='{$id}'");
		if (!$i) $i = 0;
		$s.= $i."|";
	}
	echo $s;
}

?>