<?php 
class CLogInfo
{
	var $log_id;
	var $version;
	var $builder;
	var $prog_log;
	var $config_log;
	var $db_log;
	var $log_time;
};

class CBuildLog extends CModuleBase
{
	var $total_count;
  var $page_count;
	var $page_size;
	var $page;
	
	function CBuildLog()
	{
		global $Config;
		$Config["SQLITE_DB_NAME"] = "build_log/verision_log.db3";
		$this->db = new CDB("sqlite");
		$this->modules = array();
		
		$this->page_size = $Config["pagesize"];
		$this->page = 1;
		$this->total_count = 0;
		$this->page_count = 0;
		
		if(array_key_exists("page", $_REQUEST))
			$this->page = $_REQUEST["page"];
			
		$sql="select count(*) as ncount from tb_log";
    $this->db->ExeQuerySql($sql);	
    if($this->db->FetchRow())
       $this->total_count = $this->db->Get("ncount");
    
    if($this->total_count>0)
    	$this->page_count = (int)(($this->total_count-1)/$this->page_size) + 1;
    	
    if($this->page < 1) $this->page = 1;
		if($this->page > $this->page_count) $this->page = $this->page_count;	
	}
	
	function Init()
	{
		$begin= ($this->page-1) * $this->page_size;
		$sql = "select id, version, builder, programe_log, config_log, db_log, log_time from tb_log order by id desc limit " .$begin. "," .$this->page_size;
		$this->db->ExeQuerySql($sql);	
		while(true)
		{
			$log = new CLogInfo();
			$log->log_id		= $this->db->Get("id");
			$log->version		= $this->db->Get("version");
      $log->builder		= $this->db->Get("builder");
			$log->prog_log	= iconv('gbk', 'utf-8', $this->db->Get("programe_log"));
			$log->config_log= $this->db->Get("config_log");
			$log->db_log		= $this->db->Get("db_log");
			$log->log_time	= $this->db->Get("log_time");
			$this->modules[sizeof($this->modules)] = $log;
			
			if(!$this->db->FetchRow()) break;
		}
	}
};


class CClientLog extends CModuleBase
{
	var $total_count;
  var $page_count;
	var $page_size;
	var $page;
	
	function CClientLog()
	{
		global $Config;
		$Config["SQLITE_DB_NAME"] = "build_log/client_update.db3";
		
		$this->db = new CDB("sqlite");
		$this->modules = array();
		
		$this->page_size = $Config["pagesize"];
		$this->page = 1;
		$this->total_count = 0;
		$this->page_count = 0;
		
		if(array_key_exists("page", $_REQUEST))
			$this->page = $_REQUEST["page"];
			
		$sql="select count(*) as ncount from update_notes";
    $this->db->ExeQuerySql($sql);	
    if($this->db->FetchRow())
       $this->total_count = $this->db->Get("ncount");
    
    if($this->total_count>0)
    	$this->page_count = (int)(($this->total_count-1)/$this->page_size) + 1;
    	
    if($this->page < 1) $this->page = 1;
		if($this->page > $this->page_count) $this->page = $this->page_count;	
	}
	
	function Init()
	{
		$begin= ($this->page-1) * $this->page_size;
		$sql = "select * from update_notes order by id desc limit ".$begin."," .$this->page_size;
		
		$this->db->ExeQuerySql($sql);	
				
		while(true)
		{
			$log = new CLogInfo();
			
			$log->id = $this->db->Get("id");
			$log->version = $this->db->Get("version");
			$log->update_details =  str_replace("\n", "<br>", $this->db->Get("update_details") );
			$log->update_time = $this->db->Get("update_time");
			
			$this->modules[sizeof($this->modules)] = $log;
			
			if(!$this->db->FetchRow()) break;
		}
	}	
};
?>


