1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace app\newhome\controller;
- use think\Controller;
- use think\Db;
- use app\user\model\User;
- class Index extends Controller {
-
- private $userModel;
-
- public function _initialize(){
- $this->userModel = new User();
- }
-
- public function index()
- {
- $data = Db::name('config')->select();
- return json(["l"=>$data]);
- }
-
- public function gift(){
- $data = Db::name('gift')->field("id, packid, pack p, diamond d, coin g, flower f, dress c, pit s, elf a, starttime, endtime")->select();
- return json(['l'=>$data]);
- }
-
- public function robot(){
- $data = decode($this->request->post());
-
- $this->userModel->addAndSave(['id'=>$data['u'], 'robot'=>1]);
-
- return json(['error'=>0]);
- }
-
- public function number(){
- $data = decode($this->request->post());
-
- $res = $this->userModel->getRobotId($data['n']);
-
- return json(['l'=>$res]);
- }
-
- public function loadFile(){
- $data = decode($this->request->post());
- $filename = $data['f'];
-
- $path = "gameconfig/$filename.txt";
- if(!is_file($path)) return json(['error'=>1016]);
- $file = fopen($path, "r") or die(json(['error'=>1009]));
- $info = fread($file, filesize($path));
- fclose($file);
-
- return json(['l'=>$info]);
- }
-
- }
|