93 lines
1.8 KiB
PHP
93 lines
1.8 KiB
PHP
<?php
|
|
|
|
require 'phpcommon/sqlhelper.php';
|
|
|
|
class BaseController {
|
|
|
|
private $nowtime = 0;
|
|
|
|
function __construct()
|
|
{
|
|
$this->nowtime = phpcommon\getNowTime();
|
|
}
|
|
|
|
public function handlePre()
|
|
{
|
|
}
|
|
|
|
public function handlePost()
|
|
{
|
|
}
|
|
|
|
protected function getNowTime()
|
|
{
|
|
return $this->nowtime;
|
|
}
|
|
|
|
protected function getNowDaySeconds()
|
|
{
|
|
return phpcommon\getDaySeconds($this->nowtime);
|
|
}
|
|
|
|
protected function getTodayRemainSeconds()
|
|
{
|
|
return max(0, $this->getNowDaySeconds() + 3600 * 24 - $this->getNowTime());
|
|
}
|
|
|
|
protected function rspErr($errcode, $errmsg)
|
|
{
|
|
echo json_encode(array(
|
|
'errcode' => $errcode,
|
|
'errmsg' => $errmsg,
|
|
));
|
|
}
|
|
|
|
protected function rspOk()
|
|
{
|
|
echo json_encode(array(
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
));
|
|
}
|
|
|
|
protected function rspDataOld($data)
|
|
{
|
|
echo json_encode(array(
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
'data' => $data
|
|
));
|
|
}
|
|
|
|
protected function rspData($data)
|
|
{
|
|
$rawData = array(
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
);
|
|
foreach ($data as $key => $val) {
|
|
$rawData[$key] = $val;
|
|
}
|
|
echo json_encode($rawData);
|
|
}
|
|
|
|
protected function rspRawData($rawData)
|
|
{
|
|
echo json_encode($rawData);
|
|
}
|
|
|
|
protected function getExplode($string)
|
|
{
|
|
$delim = "|";
|
|
$drop_multiply = explode($delim, $string);
|
|
$delim1 = ":";
|
|
$arr = array();
|
|
for ($i = 0; $i < count($drop_multiply); $i++) {
|
|
$mul = explode($delim1, $drop_multiply[$i]);
|
|
array_push($arr, $mul);
|
|
}
|
|
return $arr;
|
|
}
|
|
|
|
}
|