aozhiwei 62232d51f8 1
2021-12-15 11:13:46 +08:00

113 lines
2.4 KiB
PHP

<?php
ini_set('date.timezone','Asia/Shanghai');
require 'phpcommon/common.php';
require_once('phpcommon/sqlhelper.php');
require_once('models/BaseModel.php');
require_once('services/BaseService.php');
define('TEAMID_KEY', 'team_uuid:');
define('V_ITEM_GOLD', 10001); //金币
define('V_ITEM_DIAMOND', 10002); //钻石
define('V_ITEM_EXP', 10003); //经验
define('V_ITEM_ACTIVE', 10004); //活跃度
define('TN_BEGIN', 8001);
define('TN_ACTIVE', 8002);
define('TN_SHOP', 8003);
define('TN_RECHARGE_UPGRADE_TIMES', 8004);
define('TN_SHARE_GAMES', 8005);
define('TN_END', 8005);
define('TN_DAILY_BEGIN', 9001);
define('TN_DAILY_LOGINS', 9001);
define('TN_DAILY_ACTIVE', 9002);
define('TN_DAILY_SHOP', 9003);
define('TN_DAILY_RECHARGE_UPGRADE_TIMES', 9004);
define('TN_DAILY_SHARE_GAMES', 9005);
define('TN_DAILY_END', 9005);
define('TN_WEEKLY_BEGIN', 10001);
define('TN_WEEKLY_ACTIVE', 10002);
define('TN_WEEKLY_SHOP', 10003);
define('TN_WEEKLY_RECHARGE_UPGRADE_TIMES', 10004);
define('TN_WEEKLY_SHARE_GAMES', 10005);
define('TN_WEEKLY_END', 10005);
function getConfigBaseDir()
{
return '../res/';
}
function getResBaseDir()
{
return '../res/';
}
function getXVal($arr, $name, $defVal = null)
{
if (is_null($arr)) {
error_log('callstack:' . json_encode(debug_backtrace(), JSON_PRETTY_PRINT));
}
$val = array_key_exists($name, $arr) ? $arr[$name] : $defVal;
return $val;
}
function getReqVal($name, $defVal)
{
return getXVal($_REQUEST, $name, $defVal);
}
function emptyReplace($val, $defVal)
{
return !empty($val) ? $val :$defVal;
}
function isValidSex($sex)
{
return in_array($sex, array(0, 1, 2));
}
$_myself = null;
function myself()
{
global $_myself;
return $_myself;
}
function array_find($arr, $cb)
{
foreach ($arr as $val) {
if ($cb($val)) {
return $val;
}
}
return null;
}
require 'config_loader.php';
function new_sendError($errcode, $errmsg_tid, $errmsg)
{
$filename = getResBaseDir() . 'text@text.php';
if (file_exists($filename)) {
$g_text_table = require($filename);
foreach ($g_text_table as $conf) {
if ($conf['textid'] == $errmsg_tid) {
$errmsg = $conf['text'];
break;
}
}
}
if (empty($errmsg)) {
$errmsg = $errmsg_tid;
}
echo json_encode(array(
'errcode' => $errcode,
'errmsg' => $errmsg,
'errmsg_tid' => $errmsg_tid
));
}