acp.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace WY\app\controller\derpay;
  3. use WY\app\libs\Controller;
  4. if (!defined('WY_ROOT')) {
  5. exit;
  6. }
  7. class acp extends CheckAdmin
  8. {
  9. public function index()
  10. {
  11. $data = array('title' => '接入商信息');
  12. $lists = $this->model()->select()->from('acp')->fetchAll();
  13. $data += array('lists' => $lists);
  14. $this->put('acp.php', $data);
  15. }
  16. public function save()
  17. {
  18. $name = $this->req->post('name');
  19. $code = $this->req->post('code');
  20. $email = $this->req->post('email');
  21. $userid = $this->req->post('userid');
  22. $userkey = $this->req->post('userkey');
  23. if ($name == '' || $code == '' || $userid == '' || $userkey == '') {
  24. echo json_encode(array('status' => 0, 'msg' => '选项填写不完整'));
  25. exit;
  26. }
  27. $data = array('name' => $name, 'code' => $code, 'email' => $email, 'userid' => $userid, 'userkey' => $userkey);
  28. if ($this->model()->from('acp')->insertData($data)->insert()) {
  29. echo json_encode(array('status' => 1, 'msg' => '设置保存成功', 'url' => $this->dir . 'acp'));
  30. exit;
  31. }
  32. echo json_encode(array('status' => 0, 'msg' => '设置保存失败'));
  33. exit;
  34. }
  35. public function editsave()
  36. {
  37. $id = isset($this->action[3]) ? intval($this->action[3]) : 0;
  38. $data = isset($_POST) ? $_POST : false;
  39. if ($data) {
  40. foreach ($data as $key => $val) {
  41. $data[$key] = $this->req->post($key);
  42. }
  43. if ($this->model()->from('acp')->updateSet($data)->where(array('fields' => 'id=?', 'values' => array($id)))->update()) {
  44. echo json_encode(array('status' => 1, 'msg' => '设置保存成功'));
  45. exit;
  46. }
  47. }
  48. echo json_encode(array('status' => 0, 'msg' => '设置保存失败'));
  49. exit;
  50. }
  51. public function del()
  52. {
  53. $id = $this->req->get('id');
  54. if ($id) {
  55. if ($this->model()->from('acp')->where(array('fields' => 'id=?', 'values' => array($id)))->delete()) {
  56. echo json_encode(array('status' => 1));
  57. exit;
  58. }
  59. }
  60. echo json_encode(array('status' => 0));
  61. exit;
  62. }
  63. }