base
This commit is contained in:
commit
5aacc2e840
10
.gitigonre
Normal file
10
.gitigonre
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
*.*\~
|
||||||
|
*.*~
|
||||||
|
*.*\#
|
||||||
|
*.*#
|
||||||
|
~*.*
|
||||||
|
\#*.*
|
||||||
|
*.tar
|
||||||
|
*.tar.gz
|
||||||
|
config
|
||||||
|
.idea
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "third_party/phpcommon"]
|
||||||
|
path = third_party/phpcommon
|
||||||
|
url = git@git.kingsome.cn:server_common/phpcommon.git
|
1
third_party/phpcommon
vendored
Submodule
1
third_party/phpcommon
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 4fa9d00842f4fd2fb2c0b3c82bfdaa4f7ac6a602
|
54
webapp/bootstrap/config_loader.php
Normal file
54
webapp/bootstrap/config_loader.php
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$g_conf_mysql_cluster = require('../config/pay.mysql.cluster.php');
|
||||||
|
$g_conf_redis_cluster = require('../config/pay.redis.cluster.php');
|
||||||
|
|
||||||
|
function checkMysqlConfig()
|
||||||
|
{
|
||||||
|
$instance_id = 1;
|
||||||
|
global $g_conf_mysql_cluster;
|
||||||
|
foreach ($g_conf_mysql_cluster as $instance) {
|
||||||
|
if ($instance_id != $instance['instance_id']) {
|
||||||
|
error_log('pay.mysql.cluster.php config error');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
$instance_id++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function checkRedisConfig()
|
||||||
|
{
|
||||||
|
$instance_id = 1;
|
||||||
|
global $g_conf_redis_cluster;
|
||||||
|
foreach ($g_conf_redis_cluster as $instance) {
|
||||||
|
if ($instance_id != $instance['instance_id']) {
|
||||||
|
error_log('pay.redis.cluster.php config error');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
$instance_id++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMysqlConfig($hash_value)
|
||||||
|
{
|
||||||
|
if ($hash_value < 0) {
|
||||||
|
die('hash_value < 0 ' . $hash_value);
|
||||||
|
}
|
||||||
|
global $g_conf_mysql_cluster;
|
||||||
|
$idx = $hash_value % count($g_conf_mysql_cluster);
|
||||||
|
return $g_conf_mysql_cluster[$idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRedisConfig($hash_value)
|
||||||
|
{
|
||||||
|
if ($hash_value < 0) {
|
||||||
|
die('hash_value < 0 ' . $hash_value);
|
||||||
|
}
|
||||||
|
global $g_conf_redis_cluster;
|
||||||
|
$idx = $hash_value % count($g_conf_redis_cluster);
|
||||||
|
return $g_conf_redis_cluster[$idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
checkMysqlConfig();
|
||||||
|
checkRedisConfig();
|
6
webapp/bootstrap/init.php
Normal file
6
webapp/bootstrap/init.php
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
ini_set('date.timezone','Asia/Shanghai');
|
||||||
|
require 'phpcommon/common.php';
|
||||||
|
|
||||||
|
require 'config_loader.php';
|
1
webapp/controller/OpsController.class.php
Symbolic link
1
webapp/controller/OpsController.class.php
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../phpcommon/Controller/OpsController.class.php
|
39
webapp/controller/PayController.class.php
Normal file
39
webapp/controller/PayController.class.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class PayController {
|
||||||
|
|
||||||
|
protected function getRedis($accountid)
|
||||||
|
{
|
||||||
|
$redis_conf = getRedisConfig(crc32($accountid));
|
||||||
|
$r = new phpcommon\Redis(array(
|
||||||
|
'host' => $redis_conf['host'],
|
||||||
|
'port' => $redis_conf['port'],
|
||||||
|
'passwd' => $redis_conf['passwd']
|
||||||
|
));
|
||||||
|
return $r;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getMysql($accountid)
|
||||||
|
{
|
||||||
|
$mysql_conf = getMysqlConfig(crc32($accountid));
|
||||||
|
$conn = new phpcommon\Mysql(array(
|
||||||
|
'host' => $mysql_conf['host'],
|
||||||
|
'port' => $mysql_conf['port'],
|
||||||
|
'user' => $mysql_conf['user'],
|
||||||
|
'passwd' => $mysql_conf['passwd'],
|
||||||
|
'dbname' => 'kefudb' . $mysql_conf['instance_id']
|
||||||
|
));
|
||||||
|
return $conn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOrderId()
|
||||||
|
{
|
||||||
|
echo 'sss';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function notifyAllUser()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
24
webapp/index.php
Normal file
24
webapp/index.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require 'bootstrap/init.php';
|
||||||
|
|
||||||
|
if (empty($_REQUEST['c']) || empty($_REQUEST['a'])) {
|
||||||
|
die();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
function autoload_controller__($classname)
|
||||||
|
{
|
||||||
|
require_once "controller/$classname.class.php";
|
||||||
|
spl_autoload_unregister('autoload_controller__');
|
||||||
|
}
|
||||||
|
spl_autoload_register('autoload_controller__');
|
||||||
|
|
||||||
|
try{
|
||||||
|
$c = $_REQUEST['c'];
|
||||||
|
$a = $_REQUEST['a'];
|
||||||
|
$classname = $c .'Controller';
|
||||||
|
$obj = eval('return (new $classname())->$a();');
|
||||||
|
} catch (Exception $e){
|
||||||
|
echo($e);
|
||||||
|
}
|
1
webapp/phpcommon
Symbolic link
1
webapp/phpcommon
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../third_party/phpcommon/
|
Loading…
x
Reference in New Issue
Block a user