From db2b3d4b29de9df82b720bcd55e8c3e9470253d9 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 18 Apr 2019 14:27:32 +0800 Subject: [PATCH] add voice --- webapp/controller/VoiceController.class.php | 52 +++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 webapp/controller/VoiceController.class.php diff --git a/webapp/controller/VoiceController.class.php b/webapp/controller/VoiceController.class.php new file mode 100644 index 0000000..1f0f1ca --- /dev/null +++ b/webapp/controller/VoiceController.class.php @@ -0,0 +1,52 @@ + $mysql_conf['host'], + 'port' => $mysql_conf['port'], + 'user' => $mysql_conf['user'], + 'passwd' => $mysql_conf['passwd'], + 'dbname' => 'gamedb2001_' . $mysql_conf['instance_id'] + )); + return $conn; + } + + 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; + } + + public function upload() + { + $raw_data = file_get_contents('php://input'); + $data = base64_encode($raw_data); + $md5 = md5($data); + $r = $this->getRedis($md5); + $r->set('game2001:voice:' . $md5, $data); + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'download_url' => "https://game2001api-test.kingsome.cn/webapp/index.php?c=Voice&a=download&res_id=" . $md5 + )); + } + + public function download() + { + $r = $this->getRedis($_REQUEST['res_id']); + $data = $r->get('game2001:voice:' . $_REQUEST['res_id']); + echo base64_decode($data); + } + +} + +