當前位置: 首頁>>代碼示例>>PHP>>正文


PHP service函數代碼示例

本文整理匯總了PHP中service函數的典型用法代碼示例。如果您正苦於以下問題:PHP service函數的具體用法?PHP service怎麽用?PHP service使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了service函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: logout

 public function logout()
 {
     if (service("Passport")->logoutLocalAdmin()) {
         $this->assign("jumpUrl", U("Admin/Public/login"));
         $this->success('登出成功!');
     }
 }
開發者ID:BGCX262,項目名稱:ztoa-svn-to-git,代碼行數:7,代碼來源:PublicAction.class.php

示例2: init

 public function init()
 {
     if (!$this->logger) {
         $this->logger = service('log');
     }
     $this->register();
 }
開發者ID:hanfengyang,項目名稱:framework,代碼行數:7,代碼來源:ErrorHandler.php

示例3: delArticle

 public function delArticle()
 {
     service('user')->superUserAuth();
     $Model = new \system\model\Article();
     $Model->where('id', q('get.id'))->delete();
     message('文章刪除成功', 'back', 'success');
 }
開發者ID:houdunwang,項目名稱:hdcms,代碼行數:7,代碼來源:Article.php

示例4: action_token

 public function action_token()
 {
     $server = service('oauth.server.auth');
     try {
         $response = $server->issueAccessToken(json_decode($this->request->body(), TRUE));
         if (!empty($response['refresh_token'])) {
             $response['refresh_token_expires_in'] = $server->getGrantType('refresh_token')->getRefreshTokenTTL();
         }
     } catch (OAuthClientException $e) {
         // Throw an exception because there was a problem with the client's request
         $response = array('error' => $server::getExceptionType($e->getCode()), 'error_description' => $e->getMessage());
         // Auth server returns an indexed array of headers, along with the server
         // status as a header, which must be converted to use with Kohana.
         $headers = $server::getExceptionHttpHeaders($server::getExceptionType($e->getCode()));
         foreach ($headers as $header) {
             if (preg_match('#^HTTP/1.1 (\\d{3})#', $header, $matches)) {
                 $this->response->status($matches[1]);
             } else {
                 list($name, $value) = explode(': ', $header);
                 $this->response->header($name, $value);
             }
         }
     } catch (Exception $e) {
         // Throw an error when a non-library specific exception has been thrown
         $response = array('error' => 'undefined_error', 'error_description' => $e->getMessage());
         $this->response->status(400);
     }
     $this->response->headers('Content-Type', 'application/json');
     $this->response->body(json_encode($response));
 }
開發者ID:nolanglee,項目名稱:platform,代碼行數:30,代碼來源:OAuth.php

示例5: apply

 public function apply()
 {
     $this->check(1);
     $get = I('get.');
     $get['userid'] = $this->userid;
     $get['giftid'] = $get['infoid'];
     unset($get['infoid']);
     $gifts = M('Gifts')->field('needjf,title')->where(array('id' => $get['giftid']))->find();
     $needjf = $gifts['needjf'];
     if ($this->userinfo['upoint'] < $needjf) {
         $this->error('<span>您的積分不足,無法兌換該禮品!</span>');
     }
     $count = M('GiftsApply')->where(array('userid' => $get['userid'], 'giftid' => $get['giftid']))->count();
     if ($count) {
         $this->error('<span>請已經兌換過該禮品了,請不要重複兌換!</span>');
     }
     $get['status'] = false;
     $get['create_time'] = time();
     $result = M('GiftsApply')->add($get);
     if ($result) {
         $data['requestnum'] = array('exp', 'requestnum+1');
         $msg = "你在積分換禮中,申請了<a class=\"yf-list-type\" href=\"/jifen/detail/{$get['giftid']}.html\">" . $gifts['title'] . "</a>,扣除" . $needjf . "積分";
         //yf-0928
         service('Passport')->userDynamic($this->userid, $needjf, $msg, 2, 'gift', $get['giftid']);
         //yf-0925
         M('Gifts')->where(array('id' => $get['giftid']))->save($data);
         $this->success('<span>您已成功兌換該禮品,請耐心等待我們聯係!</span>');
     } else {
         $this->error('<span>兌換出錯,請稍候再試!</span>');
     }
 }
開發者ID:gzwyufei,項目名稱:hp,代碼行數:31,代碼來源:JifenController.class.php

示例6: delete

 /**
  * 刪除附件 get單個刪除 post批量刪除 
  */
 public function delete()
 {
     $Attachment = service("Attachment");
     if (IS_POST) {
         $aid = $_POST['aid'];
         foreach ($aid as $k => $v) {
             $Attachment->del($v);
             //刪除附件關係
             M("AttachmentIndex")->where(array("aid" => $v))->delete();
         }
         $status = true;
     } else {
         $aid = $this->_get('aid');
         if (empty($aid)) {
             $this->error("缺少參數!");
         }
         $status = $Attachment->del($aid);
         M("AttachmentIndex")->where(array("aid" => $aid))->delete();
     }
     if (IS_AJAX) {
         if ($status) {
             $this->ajaxReturn("", "刪除附件成功!", true);
         } else {
             $this->ajaxReturn("", "刪除附件失敗!", false);
         }
     } else {
         if ($status) {
             $this->success("刪除附件成功!");
         } else {
             $this->error("刪除附件失敗!");
         }
     }
 }
開發者ID:BGCX262,項目名稱:ztoa-svn-to-git,代碼行數:36,代碼來源:AtadminAction.class.php

示例7: checkEmail

 public function checkEmail($email)
 {
     if (service("Passport")->user_checkemail($email) == 1) {
         return true;
     }
     return false;
 }
開發者ID:BGCX262,項目名稱:ztoa-svn-to-git,代碼行數:7,代碼來源:MemberModel.class.php

示例8: run

 public function run(&$params)
 {
     $ccmService = service('CouponCodeMall');
     $ccmService->clearCache($params['id']);
     $params = null;
     B('CouponCodeMallRecs', $params);
 }
開發者ID:yunsite,項目名稱:tp-coupon,代碼行數:7,代碼來源:CouponCodeMallBehavior.class.php

示例9: delete

 /**
  * 刪除附件 get單個刪除 post批量刪除 
  */
 public function delete()
 {
     $Attachment = service("Attachment");
     if (IS_POST) {
         $aid = $_POST['aid'];
         foreach ($aid as $k => $v) {
             if ($Attachment->delFile((int) $v)) {
                 //刪除附件關係
                 M("AttachmentIndex")->where(array("aid" => $v))->delete();
             }
         }
         $status = true;
     } else {
         $aid = I('get.aid', 0, 'intval');
         if (empty($aid)) {
             $this->error("缺少參數!");
         }
         if ($Attachment->delFile((int) $aid)) {
             M("AttachmentIndex")->where(array("aid" => $aid))->delete();
             $status = true;
         } else {
             $status = false;
         }
     }
     if ($status) {
         $this->success("刪除附件成功!");
     } else {
         $this->error("刪除附件失敗!");
     }
 }
開發者ID:sandom123,項目名稱:king400,代碼行數:33,代碼來源:AtadminController.class.php

示例10: package

 public function package()
 {
     //分配菜單
     service('menu')->assign();
     //分配菜單
     return view();
 }
開發者ID:houdunwang,項目名稱:hdcms,代碼行數:7,代碼來源:Entry.php

示例11: imageUp

 /**
 * 編輯器圖片上傳
 * array (
  'pictitle' => '6.jpg',
  'Filename' => '6.jpg',
  'catid' => '73',
  'Upload' => 'Submit Query',
  )
 */
 public function imageUp()
 {
     if (IS_POST) {
         //如果是非後台用戶,進行權限判斷
         if (!$this->isadmin) {
             $Member_group = F("Member_group");
             if ((int) $Member_group[$this->groupid]['allowattachment'] < 1) {
                 echo "{'url':'圖片地址','state':'沒有上傳權限!','title':'標題'}";
                 exit;
             }
         }
         $upload = new UploadFile();
         $this->catid = $this->_post("catid") ? $this->_post("catid") : 0;
         $this->Attachment = service("Attachment", array("module" => $this->module, "catid" => $this->catid, "isadmin" => $this->isadmin ? 1 : 0));
         $this->module = strtolower("contents");
         //上傳目錄
         $this->filepath = $this->Attachment->FilePath();
         //設置上傳類型,強製為圖片類型
         $upload->allowExts = $this->allowExts = array("jpg", "png", "gif", "jpeg");
         //設置上傳目錄
         $upload->savePath = $this->filepath;
         $Callback = false;
         //是否添加水印
         if ((int) $this->_post('watermark_enable')) {
             $Callback = array(array("AttachmentsAction", "water"), array());
         }
         //開始上傳
         if ($upload->upload($Callback)) {
             //上傳成功
             $info = $upload->getUploadFileInfo();
             //保存目錄路徑 例如 /home/wwwroot/ecms.85zu.com/e/home/d/album/1970/01
             $savepath = $info[0]['savepath'];
             //保存文件名
             $savename = $info[0]['savename'];
             //文件路徑
             $upfilepath = $savepath . $savename;
             //附件表信息寫入
             $status = $this->Attachment->FileData($info[0]);
             $in = array("url" => "", "state" => "", "title" => "");
             if ($status) {
                 // 設置附件cookie
                 $this->Attachment->upload_json($status, $this->Attachment->filehttp, str_replace(array("\\", "/"), "", $info[0]['name']));
                 $in['url'] = $this->Attachment->filehttp;
                 $in['title'] = str_replace(array("\\", "/"), "", $info[0]['name']);
                 $in['state'] = "SUCCESS";
                 //                    array2file($in, SITE_PATH . "/post.txt");
                 echo json_encode($in);
                 exit;
             } else {
                 //刪除已經上傳的圖片,這裏邏輯還要優化
                 @unlink($upfilepath);
                 echo "{'url':'圖片地址','state':'上傳失敗!','title':'標題'}";
                 exit;
             }
         }
     }
     echo "{'url':'圖片地址','state':'上傳失敗!','title':'標題'}";
     exit;
 }
開發者ID:BGCX262,項目名稱:ztoa-svn-to-git,代碼行數:68,代碼來源:UeditorAction.class.php

示例12: __construct

 public function __construct()
 {
     $this->user = new User();
     service('user')->superUserAuth();
     $user = Db::table('cloud')->find(1);
     $this->url = c('api.cloud') . "?uid={$user['uid']}&AppSecret={$user['AppSecret']}&t=web&siteid=1&m=store";
     $this->db = new \system\model\Cloud();
 }
開發者ID:houdunwang,項目名稱:hdcms,代碼行數:8,代碼來源:Cloud.php

示例13: action_put_me

 /**
  * Update current user
  *
  * PUT /api/users/me
  *
  * @return void
  */
 public function action_put_me()
 {
     $this->action_put_index();
     if ($id = service('session.user')->getId()) {
         // Replace the "me" id with the actual id
         $this->_usecase->setIdentifiers(['id' => $id]);
     }
 }
開發者ID:gjorgiev,項目名稱:platform,代碼行數:15,代碼來源:Users.php

示例14: del

 /**
  * 刪除文章
  *
  * @param $aid 文章編號
  *
  * @return bool
  */
 public function del($aid)
 {
     $rid = Db::table('reply_cover')->where('module', 'article:aid:' . $aid)->pluck('rid');
     service('WeChat')->removeRule($rid);
     Db::table('web_article')->where('aid', $aid)->delete();
     Db::table('reply_cover')->where('module', 'article:aid:' . $aid)->delete();
     return TRUE;
 }
開發者ID:houdunwang,項目名稱:hdcms,代碼行數:15,代碼來源:WebArticle.php

示例15: logout

 public function logout()
 {
     if (service("PassportAdmin")->logoutLocalAdmin()) {
         //手動登出時,清空forward
         cookie("forward", NULL);
         $this->success('登出成功!', U("Admin/Public/login"));
     }
 }
開發者ID:NeilFee,項目名稱:vipxinbaigo,代碼行數:8,代碼來源:PublicAction.class.php


注:本文中的service函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。