public function logout() { if (service("Passport")->logoutLocalAdmin()) { $this->assign("jumpUrl", U("Admin/Public/login")); $this->success('登出成功!'); } }
public function init() { if (!$this->logger) { $this->logger = service('log'); } $this->register(); }
public function delArticle() { service('user')->superUserAuth(); $Model = new \system\model\Article(); $Model->where('id', q('get.id'))->delete(); message('文章删除成功', 'back', 'success'); }
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)); }
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>'); } }
/** * 删除附件 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("删除附件失败!"); } } }
public function checkEmail($email) { if (service("Passport")->user_checkemail($email) == 1) { return true; } return false; }
public function run(&$params) { $ccmService = service('CouponCodeMall'); $ccmService->clearCache($params['id']); $params = null; B('CouponCodeMallRecs', $params); }
/** * 删除附件 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("删除附件失败!"); } }
public function package() { //分配菜单 service('menu')->assign(); //分配菜单 return view(); }
/** * 编辑器图片上传 * 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; }
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(); }
/** * 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]); } }
/** * 删除文章 * * @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; }
public function logout() { if (service("PassportAdmin")->logoutLocalAdmin()) { //手动登出时,清空forward cookie("forward", NULL); $this->success('登出成功!', U("Admin/Public/login")); } }
public function __construct() { //加载站点缓存 service('site')->loadSite(); //与微信官网通信绑定验证 \Weixin::valid(); $this->instance = \Weixin::instance('message'); }
public function notificationCount() { if (empty($this->user_id) && isset($this->mid)) { return service('Notify')->getCount($this->mid); } else { return service('Notify')->getCount($this->user_id); } }
/** * 解析已有的模块 * @param unknown_type $content * @param unknown_type $cacheOpen * @return mixed */ public function parseId($content, $cacheOpen = true) { $preg = "/\\[widget:(\\w+)\\]/siU"; preg_match_all($preg, $content, $pluginIds); $pluginIds = array_merge(array_filter($pluginIds)); $pluginIds = array_combine($pluginIds[0], $pluginIds[1]); $data = model('DiyWidget')->getTagInofs($pluginIds); foreach ($pluginIds as $key => $value) { $widgetKey = $value; $tagInfo = $data[$value]; if (isset($tagInfo['attr']['cache_timeout'])) { $cacheTime = $tagInfo['attr']['cache_timeout']; } else { $cacheTime = $cacheOpen; } if ($cacheOpen && $cacheTime != 0 && C('MEMCACHED_ON')) { $cache = service('Cache', array("type" => "memcache")); if (!($value = $cache->getWidget($widgetKey))) { $attrSet = $tagInfo['attr']; $tagName = $tagInfo['tagName']; $value = $tagInfo['content']; $path = self::$tags[strtolower($tagName)]; list($dir, $file) = explode(':', $tagName); $file = ucfirst($file); require_once $path; $fileObjct = new $file(); if ($fileObjct->getTagStatus() || !empty($value)) { $value = $fileObjct->replaceTag($attrSet, $value, $tagInfo); } else { $value = $fileObjct->replaceTag($attrSet, '', $tagInfo); } $cache->setWidget($widgetKey, $value, $cacheTime); } } else { $attrSet = $tagInfo['attr']; $tagName = $tagInfo['tagName']; $value = $tagInfo['content']; if (strpos($tagInfo['attr']['style'], 'custom') != 0 && empty($value)) { continue; } $path = self::$tags[strtolower($tagName)]; list($dir, $file) = explode(':', $tagName); $file = ucfirst($file); if (!is_file($path)) { continue; } require_once $path; $fileObjct = new $file(); if ($fileObjct->getTagStatus() || !empty($value)) { $value = $fileObjct->replaceTag($attrSet, $value, $tagInfo); } else { $value = $fileObjct->replaceTag($attrSet, '', $tagInfo); } } $content = str_replace($key, $value, $content); } return $content; }
public function doWEbOpenidLogin() { //微信自动登录 if (service('member')->weixinLogin()) { $url = q('get.backurl', web_url('entry/home', ['siteid' => SITEID])); go($url); } message('微信登录失败,请检查微信公众号是否验证', 'back', 'error'); }
public function run(&$params) { $ccmService = service('TaoShop'); $ccmService->clearCache($params['id']); if (isset($params['seller_id'])) { $ccmService->clearItemsCache($params['seller_id']); } $params = null; B('TaoShopRecs', $params); }
function feature($name) { $config = service('repository.config'); try { $conf = $config->get('features'); } catch (\Exception $e) { return false; } return !empty($conf->{$name}); }
public function __construct() { $this->dir = IS_MOBILE ? 'mobile' : 'web'; $this->webid = isset($_GET['webid']) ? intval($_GET['webid']) : Session::get('webid'); if (!$this->webid) { $web = service('web')->getDefaultWeb(); $this->webid = $web['id']; } Session::set('webid', $this->webid); }
public function __construct() { $this->siteid = SITEID; $this->template = (v('module.is_system') ? "module/" : "addons/") . v('module.name') . '/template'; $this->ucenter_template = 'ucenter/' . (IS_MOBILE ? "mobile" : "web"); $this->config = service('module')->getModuleConfig(); defined('__TEMPLATE_PATH__') or define('__TEMPLATE_PATH__', $this->template); defined('__TEMPLATE__') or define('__TEMPLATE__', __ROOT__ . '/' . $this->template); defined('__UCENTER_TEMPLATE__') or define('__UCENTER_TEMPLATE__', __ROOT__ . '/' . $this->ucenter_template); }
public function action_get_index_collection() { $db = service('db.config'); $phinx_config = ['configuration' => realpath(APPPATH . '../application/phinx.php'), 'parser' => 'php']; $phinx_app = new Phinx\Console\PhinxApplication(); $phinx_wrapper = new Phinx\Wrapper\TextWrapper($phinx_app, $phinx_config); $migration_results = call_user_func([$phinx_wrapper, 'getMigrate'], 'ushahidi', null); $error = $phinx_wrapper->getExitCode() > 0; $this->_response_payload = ['results' => explode("\n", $migration_results, -1)]; }
public function action_get_index_collection() { // Get usecase with default formatter $this->_usecase = service('factory.usecase')->get($this->_resource(), 'export')->setFilters($this->_filters()); // ...or use a different one if requested $format = strtolower($this->request->query('format')); if ($format) { $this->_usecase->setFormatter(service("formatter.entity.post.{$format}")); } }
/** * 删除模块 * * @param string $module 模块名称 * @param int $removeData 删除模块数据 * * @return bool */ public function remove($module, $removeData = 0) { //删除封面关键词数据 if ($removeData) { //本地安装的模块删除处理 $xmlFile = 'addons/' . $module . '/manifest.xml'; if (is_file($xmlFile)) { $manifest = Xml::toArray(file_get_contents($xmlFile)); //卸载数据 $installSql = trim($manifest['manifest']['uninstall']['@cdata']); if (!empty($installSql)) { if (preg_match('/.php$/', $installSql)) { $file = 'addons/' . $module . '/' . $installSql; if (!is_file($file)) { $this->error = '卸载文件:' . $file . '不存在'; return; } require $file; } else { \Schema::sql($installSql); } } } //删除模块回复规则列表 $rids = Db::table('rule')->where('module', $module)->lists('rid') ?: []; foreach ($rids as $rid) { service('WeChat')->removeRule($rid); } //删除站点模块 Db::table('site_modules')->where('module', $module)->delete(); //模块设置 Db::table('module_setting')->where('module', $module)->delete(); //代金券使用的模块 Db::table('ticket_module')->where('module', $module)->delete(); } //删除模块数据 $this->where('name', $module)->delete(); //删除模块动作数据 Db::table('modules_bindings')->where('module', $module)->delete(); //更新套餐数据 $package = Db::table('package')->get(); if ($package) { foreach ($package as $p) { $p['modules'] = unserialize($p['modules']) ?: []; if ($k = array_search($_GET['module'], $p['modules'])) { unset($p['modules'][$k]); } $p['modules'] = serialize($p['modules']); Db::table('package')->where('id', $p['id'])->update($p); } } //更新所有站点缓存 service('site')->updateAllCache(); return TRUE; }
public function run(&$params) { if (isset($params['ad_id'])) { $advS = service('Adv'); $advS->clearCache($params['ad_id']); } if (isset($params['pos_id'])) { $advS = service('Adv'); $advS->clearPosCache($params['pos_id']); } }
/** * Formats a log entry. * * Fixes PHP 5.4 compatibility issues * * @param array $message * @param string $format * @return string */ public function format_message(array $message, $format = "time site --- level: body in file:line") { try { $dbconfig = service('db.config'); // hacky - use db name as fallback $message['site'] = service('site') ?: $dbconfig['connection']['database']; } catch (Exception $e) { // Ignore errors, they're probably why we're here to start with $message['site'] = ''; } return parent::format_message(array_filter($message, 'is_scalar'), $format); }
public function doSitePost() { if (IS_POST) { Validate::make([['welcome', 'required', '欢迎信息关键字 不能为空'], ['default', 'required', '默认信息关键字 不能为空']]); $data['welcome'] = Request::post('welcome'); $data['default_message'] = Request::post('default'); Db::table('site_setting')->where('siteid', SITEID)->update($data); service('site')->updateCache(); message('系统回复消息设置成功', '', 'success'); } return view($this->template . '/post.html'); }
/** * 友情链接 * */ public function links() { //友情链接 $friendlinks = array(); $flService = service('FriendLinks'); $res = $flService->getAll(); $friendlinks = $res['all']; $this->assign('friendlinks', $friendlinks); $this->assign('page_title', '友情链接 - '); $this->assign('page_keywords', $this->_CFG['site_keywords']); $this->assign('page_description', $this->_CFG['site_description']); $this->display(); }