Ejemplo n.º 1
0
 /**
  * 更新插件里的所有钩子对应的插件
  * @param $plug_name
  * @return bool
  */
 public function updateHooks($plug_name)
 {
     $plug_class = getPlugClass($plug_name);
     //获取插件名
     if (!class_exists($plug_class)) {
         JsonObject(array('status' => false, 'msg' => "未实现" . $plug_name . "插件的入口文件"));
     }
     $methods = get_class_methods($plug_class);
     $_hooks = db()->table("hook")->getAll(array('status' => \Admin\Hoke\Type\Status::STATUS_ENABLE))->fields('name')->done();
     $hooks = array();
     foreach ($_hooks as $v) {
         $hooks[] = $v['name'];
     }
     $common = array_intersect($hooks, $methods);
     if (!empty($common)) {
         foreach ($common as $hook) {
             $flag = $this->updateplugs($hook, array($plug_name));
             if (false === $flag) {
                 $this->removeHooks($plug_name);
                 return false;
             }
         }
     }
     return true;
 }
Ejemplo n.º 2
0
 public function avatarUploadAction()
 {
     $data = post("data", "txt");
     $token = post("avatarToken", "txt");
     if ($token !== session('avatarToken')) {
         exit(JsonObject(array('success' => false, 'msg' => '未知的上传来源,上传失败!')));
     }
     $targetFolder = 'Data/upload/image/avatar';
     // Relative to the root
     $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
     $member = $this->getMember();
     //检验目录
     $targetDir = rtrim($targetPath, '/') . '/' . $member['id'];
     if (!file_exists($targetDir)) {
         mkdir($targetDir, 0777, true);
     }
     //move_uploaded_file
     $code = time() . rand(0, 9999);
     $targetFile = $targetDir . '/yt_' . md5($member['id'] . $code) . ".jpg";
     $img = str_replace('data:image/png;base64,', '', $data);
     $img = str_replace(' ', '+', $img);
     $data = base64_decode($img);
     $file = UPLOAD_DIR . uniqid() . '.png';
     $success = file_put_contents($targetFile, $data);
     if (!$success) {
         exit(JsonObject(array('success' => false, 'msg' => '保存失败!')));
     }
     $webFile = 'http://' . str_replace($_SERVER['DOCUMENT_ROOT'], $_SERVER['HTTP_HOST'] . "/", $targetFile);
     $res = db()->table('member_info')->upDate(array('avatar' => $webFile), array('id' => $member['id']))->done();
     exit(JsonObject(array('success' => true, 'msg' => '保存成功!')));
 }
Ejemplo n.º 3
0
 public function sortAction()
 {
     $data = post("data", "txt");
     $id = post("id", "int");
     $plugs = arr2str($data, ",");
     $res = db()->table('hook')->upDate(array('plugs' => $plugs), array('id' => $id))->done();
     if ($res) {
         return JsonObject(array("msg" => "保存成功"));
     }
 }
Ejemplo n.º 4
0
 public function delAction()
 {
     $re = new \System\Library\Request();
     $id = post("id", "int");
     $res = db()->table("twitter")->delete(array('id' => $id))->done();
     if ($res) {
         return JsonObject(array("status" => true));
     } else {
         return JsonObject(array("status" => false));
     }
 }
Ejemplo n.º 5
0
 public function editAction()
 {
     $id = post("id", "int");
     $k = post("type", "txt");
     $v = post("v", "txt");
     $r = db()->table('article_category')->upDate(array($k => $v), array('id' => $id))->done();
     if ($r) {
         return JsonObject(array("status" => true, "msg" => "更新成功"));
     } else {
         return JsonObject(array("status" => false, "msg" => "更新失败"));
     }
 }
Ejemplo n.º 6
0
 /**
  * 初始数据
  */
 public function showAction()
 {
     $member = $this->getMember();
     if (!$member) {
         echo '加载失败!';
     }
     $data = db()->table("calendar")->getAll(array('member_id' => $member['id']))->done();
     foreach ($data as $k => $v) {
         $allday = $v['allday'];
         $is_allday = $allday == 1 ? true : false;
         $data[] = array('id' => $v['id'], 'title' => $v['title'], 'start' => date('Y-m-d H:i', $v['starttime']), 'end' => date('Y-m-d H:i', $v['endtime']), 'allDay' => $is_allday, 'color' => $v['color']);
     }
     return JsonObject($data);
 }
Ejemplo n.º 7
0
 /**
  * 开启插件
  */
 public function enableAction()
 {
     $id = post("val", "int");
     $row = db()->table("plugs")->getRow(array('id' => $id))->done();
     if (!$row) {
         JsonObject(array('status' => false, 'msg' => "开启失败,插件不存在"));
     }
     if ($row['status'] == \Admin\Plug\Type\Status::STATUS_ENABLE) {
         JsonObject(array('status' => true, 'msg' => "已开启"));
     }
     $r = db()->table("plugs")->upDate(array('status' => \Admin\Plug\Type\Status::STATUS_ENABLE), array('id' => $id))->done();
     $hookModel = new \Admin\Model\hookModel();
     JsonObject(array('status' => true, 'msg' => "已开启"));
 }
Ejemplo n.º 8
0
 /**
  *  删除模板
  */
 public function delTplAction()
 {
     $name = post("name", "string");
     $templateModel = new templateModel();
     $r = $templateModel->delTpl($name);
     if ($r) {
         return JsonObject(array("status" => true));
     } else {
         return JsonObject(array("status" => false));
     }
 }
Ejemplo n.º 9
0
 public function showSqlAction()
 {
     $seller_id = post("sellerid", "int");
     $date = array();
     if ($seller_id) {
         $date[0] = db("jutuan")->Table('td_seller_info_copy')->getRow(array('seller_id' => $seller_id))->done();
         //getRow
     } else {
         $date = db("jutuan")->Table('td_seller_info_copy')->getAll()->done();
         //getRow
     }
     $msg = "<textarea style='width: 100%;height: 100%'>";
     foreach ($date as $row) {
         $msg .= "UPDATE `a0923142448`.`td_seller_info` SET `SELLER_ID`='" . $row['SELLER_ID'] . "', `SELLER_NAME`='" . $row['SELLER_NAME'] . "', `AGENT_ID`='" . $row['AGENT_ID'] . "', `PROVINCE_ID`='" . $row['PROVINCE_ID'] . "', `CITY_ID`='" . $row['CITY_ID'] . "', `COUNTY_ID`='" . $row['COUNTY_ID'] . "', `DISTRICT_ID`='" . $row['DISTRICT_ID'] . "', `ADDR_DETAIL`='" . $row['ADDR_DETAIL'] . "', `TELEPHONE`='" . $row['TELEPHONE'] . "', `LINK_MAN`='" . $row['LINK_MAN'] . "', `LONGITUDE`='" . $row['LONGITUDE'] . "', `LATITUDE`='" . $row['LATITUDE'] . "', `INSERT_TIME`='" . $row['INSERT_TIME'] . "', `REMARK1`=" . $row['REMARK1'] . ", `REMARK2`=" . $row['REMARK2'] . ", `REMARK3`=" . $row['REMARK3'] . " WHERE (`SELLER_ID`='" . $row['SELLER_ID'] . "');\n";
     }
     $msg .= "</textarea>";
     return JsonObject(array("msg" => $msg));
 }
Ejemplo n.º 10
0
 public function delAction()
 {
     $id = get("id", 'int');
     $r = db()->table('sidebar')->delete(array('id' => $id))->done();
     if ($r) {
         return JsonObject(array("msg" => "删除成功"));
     } else {
         return JsonObject(array("msg" => "删除失败"));
     }
 }