44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
require 'classes/Quest.php';
|
|
require 'classes/AddReward.php';
|
|
|
|
class TempController{
|
|
|
|
protected function getRedMysql()
|
|
{
|
|
$mysql_conf = getMysqlConfig(crc32(''));
|
|
$conn = new phpcommon\Mysql(array(
|
|
'host' => $mysql_conf['host'],
|
|
'port' => $mysql_conf['port'],
|
|
'user' => $mysql_conf['user'],
|
|
'passwd' => $mysql_conf['passwd'],
|
|
'dbname' => DBNAME_PREFIX . 1
|
|
));
|
|
return $conn;
|
|
}
|
|
|
|
public function getRedSum()
|
|
{
|
|
$type = $_REQUEST['type'];
|
|
$red_conn = $this->getRedMysql();
|
|
$rows = $red_conn->execQueryOne('SELECT * FROM redpack ' .
|
|
' WHERE red_type=:red_type AND red_date=:red_date;',
|
|
array(
|
|
':red_type' => $type,
|
|
':red_date' => phpcommon\getdayseconds(time())
|
|
));
|
|
error_log(json_encode($rows));
|
|
if ($rows['red_sum'] + 0.3 > 100) {
|
|
phpcommon\sendError(ERR_USER_BASE + 3, '今日红包已领完');
|
|
return;
|
|
}
|
|
echo json_encode(array(
|
|
'errcode' => 0,
|
|
'errmsg' => '',
|
|
'sum' => $rows['red_sum']
|
|
));
|
|
}
|
|
}
|
|
?>
|