95 lines
1.8 KiB
PHP
95 lines
1.8 KiB
PHP
<?php
|
|
|
|
use phpcommon\SqlHelper;
|
|
|
|
class BaseController {
|
|
|
|
private $nowtime = 0;
|
|
|
|
function __construct()
|
|
{
|
|
global $_myself;
|
|
$_myself = $this;
|
|
$this->nowtime = phpcommon\getNowTime();
|
|
}
|
|
|
|
public function _handlePre()
|
|
{
|
|
}
|
|
|
|
public function _handlePost()
|
|
{
|
|
}
|
|
|
|
public function _getNowTime()
|
|
{
|
|
return $this->nowtime;
|
|
}
|
|
|
|
public function _getNowDaySeconds()
|
|
{
|
|
return phpcommon\getDaySeconds($this->nowtime);
|
|
}
|
|
|
|
public function _getTodayRemainSeconds()
|
|
{
|
|
return max(0, $this->getNowDaySeconds() + 3600 * 24 - $this->_getNowTime());
|
|
}
|
|
|
|
public function _rspErr($errcode, $errmsg)
|
|
{
|
|
echo json_encode(array(
|
|
'errcode' => $errcode,
|
|
'errmsg' => $errmsg,
|
|
));
|
|
}
|
|
|
|
public function _rspOk()
|
|
{
|
|
echo json_encode(array(
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
));
|
|
}
|
|
|
|
public function _rspDataOld($data)
|
|
{
|
|
echo json_encode(array(
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
'data' => $data
|
|
));
|
|
}
|
|
|
|
public function _rspData($data)
|
|
{
|
|
$rawData = array(
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
);
|
|
foreach ($data as $key => $val) {
|
|
$rawData[$key] = $val;
|
|
}
|
|
echo json_encode($rawData);
|
|
}
|
|
|
|
public function _rspRawData($rawData)
|
|
{
|
|
echo json_encode($rawData);
|
|
}
|
|
|
|
public 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;
|
|
}
|
|
|
|
}
|