<?php
include(dirname(__FILE__)."/require.php");
if($ppurview[41]!=1)
  jump("jump.php?id=25&jump=main.php");
$phpcolor->table="integral_log";
if(isset($_GET['action']) and $_GET['action'] == "adddo")
{
  submitfilter($_POST['integral']);
  $phpcolor->table="user";
  $phpcolor->field="*";
  $phpcolor->where="username = '".$_POST['username']."'";
  if(!$phpcolor->exist(2))
    jump("jump.php?id=1&jump=integral.php?action=add");
  $phpcolor->table="integral_log";
  $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
  $phpcolor->upintegral($_POST['username'],$_POST['objects'],$_POST['integral'],$_POST['type'],$time);
  jump("jump.php?id=24&jump=integral.php");
}
if(isset($_GET['action']) and $_GET['action'] == "add")
  $tpl -> display("integral_add.htm");
else
{
  if(!isset($_GET['page']))
    $_GET['page']=0;
  $phpcolor->field="*";
  if(isset($_GET['username']))
  {
    $phpcolor->where="username like '%".$_GET['username']."%'";
    $count=$phpcolor->exist(2);
    $phpcolor->where="username like '%".$_GET['username']."%' order by operatetime desc limit ".($_GET['page']*20).",20";
	$page=pages($count,20,$_GET['page'],'integral','&username='.$_GET['username'].'','0');
  }
  else
  {
	$phpcolor->where="1=1";
    $count=$phpcolor->exist(2);
    $phpcolor->where="1=1 order by operatetime desc limit ".($_GET['page']*20).",20"; 
    $page=pages($count,20,$_GET['page'],'integral','','','0');
  }
  $log=$phpcolor->assignment();
  for ($count=0;$count<count($log);$count++)
  {
    $logs[$count]=$phpcolor->integralso($log[$count]['type'],$log[$count]['integral'],$log[$count]['objects']);
	$log[$count]['type']=$logs[$count]['type'];
	$log[$count]['integral']=$logs[$count]['integral'];
  }
  $tpl -> assign("log", $log);
  $tpl -> assign("page", $page);
  $tpl -> display("integral.htm");
}
?>