/**
  * 媒体文章详情
  * @param HttpRequest $request
  */
 public function detail(HttpRequest $request)
 {
     $id = $request->getParameter('id', 'intval');
     if ($id <= 0) {
         page404();
     }
     $articleService = Beans::get("article.article.service");
     $tagService = Beans::get('article.tags.service');
     $condi = getMediaArticleConds();
     $conditions = array('id' => $id, 'media_id' => $this->loginMedia['id']);
     $condi = array_merge($conditions, $condi);
     $item = $articleService->getItem($condi, 'id,title,media_chanel,bcontent,tags,kwords,author, add_time, update_time');
     if (!$item) {
         page404();
     }
     //更新文章点击率
     $articleService->increase('hits', 1, $id);
     if ($item['tags'] != '') {
         $tagids = explode(',', $item['tags']);
         $item['tags'] = $tagService->getItems($tagids, 'id,name');
     }
     $this->assign('item', $item);
     //注册页面seo信息
     $this->assign('seoTitle', $item['title'] . '-' . $this->mediaConfigs['sitename']);
     $this->assign('seoKwords', $item['kwords']);
     $this->assign('seoDesc', $item['bcontent']);
     $this->assign("chanelId", $item["media_chanel"]);
     $this->setView('article_detail');
 }
 /**
  * 用户删除操作监听
  * @param int $userid 用户ID
  * @param boolean $status 操作的结果,默认操作是成功的
  * @return boolean
  */
 public function delete($userid, $status = true)
 {
     if ($status && $userid > 0) {
         $conditions = array('userid' => $userid);
         //1.删除用户添加的媒体
         $mediaService = Beans::get('media.media.service');
         $opt_1 = $mediaService->deletes($conditions);
         //2.删除用户的爆料
         $tipoffService = Beans::get('tipoff.tipoff.service');
         $opt_2 = $tipoffService->deletes($conditions);
         //3.删除用户图片
         $imageService = Beans::get('image.image.service');
         $opt_3 = $imageService->deletes($conditions);
         //4.删除用户所有的短消息
         $messageService = Beans::get('user.message.service');
         $opt_4 = $messageService->deletes(array('receiver' => $userid));
         //5.删除所有的用户收藏文章
         $collectService = Beans::get('user.collect.service');
         $opt_5 = $collectService->deletes($conditions);
         //4. 删除当前媒体所有的管理员管用户
         $managerService = Beans::get('media.manager.service');
         $opt_6 = $managerService->deletes($conditions);
         //所头操作成功后才算成功
         return $opt_1 && $opt_2 && $opt_3 && $opt_4 && $opt_5 && $opt_6;
     } else {
         return false;
     }
 }
 /**
  * 媒体删除操作监听
  * @param int $mediaId 媒体ID
  * @param bool $status 操作的结果,默认操作是成功的
  * @return bool
  */
 public function delete($mediaId, $status = true)
 {
     if ($status && $mediaId > 0) {
         $conditions = array('media_id' => $mediaId);
         //1. 删除当前媒体的所有频道
         $mediaChanelService = Beans::get('media.chanel.service');
         $opt_1 = $mediaChanelService->deletes($conditions);
         //2. 删除当前媒体的所有的友情链接
         $friendLinkService = Beans::get('media.friendlink.service');
         $opt_2 = $friendLinkService->deletes($conditions);
         //3. 删除当前媒体用户所有的管理员角色
         $managerRoleService = Beans::get('media.managerRole.service');
         $opt_3 = $managerRoleService->deletes($conditions);
         //4. 删除当前媒体所有的管理员管用户
         $managerService = Beans::get('media.manager.service');
         $opt_4 = $managerService->deletes($conditions);
         //5. 删除媒体模板安装记录
         $templateService = Beans::get('media.template.service');
         $opt_5 = $templateService->deletes($conditions);
         //6. 删除媒体订阅
         $orderService = Beans::get('media.order.service');
         $orderService->deletes($conditions);
         //所有的操作都成功了则返回成功
         return $opt_1 && $opt_2 && $opt_3 && $opt_4 && $opt_5;
     } else {
         return false;
     }
 }
 /**
  * @see ISmsService::sendTemplateMessage()
  */
 public function sendTemplateMessage($mobiles, $tempKey, $sendTime = '')
 {
     //获取模板内容
     $templateService = Beans::get('admin.messageTemplate.service');
     $template = $templateService->getItem("type='message' AND tkey='{$tempKey}'");
     if (!$template) {
         return false;
     }
     //获取当前登录用户
     $userService = Beans::get('user.user.service');
     $loginUser = $userService->getLoginUser();
     //替换标签
     $replacements = array('{username}' => $loginUser['username'], '{mobile}' => $loginUser['mobile'], '{email}' => $loginUser['email'], '{nickname}' => $loginUser['nickname']);
     $content = str_replace(array_keys($replacements), $replacements, $template['content']);
     //去除html标签
     $content = strip_tags($content);
     //发送校验码
     if (strpos($content, '{authcode}') !== false) {
         $authCode = mt_rand(100000, 999999);
         //缓存校验码
         $factor = $mobiles;
         if (!is_numeric($mobiles)) {
             $factor = getHashCode($mobiles);
         }
         $CACHER = CacheFactory::create('file');
         $CACHER->baseKey('authcode')->ftype('mobile')->factor($factor);
         $CACHER->set(null, $authCode);
         $content = str_replace('{authcode}', $authCode, $content);
     }
     return $this->sendMessage($mobiles, strip_tags($content), $sendTime);
 }
Exemplo n.º 5
0
 /**
  * @see \admin\service\interfaces\IMenuService::getMenuByUser
  */
 public function getMenuByUser($user)
 {
     $menus = $this->getMenuCache();
     //如果是超级管理员,则直接返回所有菜单
     $adminService = Beans::get('admin.admin.service');
     if ($adminService->isSuperManager($user)) {
         return $menus;
     }
     $permissions = $adminService->getPermissions();
     $data = array();
     foreach ($menus as $key => $value) {
         $data[$key] = array();
         $i = 0;
         foreach ($value as $_value) {
             if ($this->hasSubMenu($_value['sub'], $permissions)) {
                 $data[$key][$i] = $_value;
                 $data[$key][$i]['sub'] = array();
                 foreach ($_value['sub'] as $val) {
                     $__key = $this->url2PermissionKey($val['url']);
                     if ($permissions[$__key] == 1) {
                         $data[$key][$i]['sub'][] = $val;
                     }
                 }
             }
             $i++;
         }
     }
     return $data;
 }
 /**
  * 重置密码验证
  * 包括邮件重置密码和短信重置密码都在这里统一验证
  * @param HttpRequest $request
  */
 public function password(HttpRequest $request)
 {
     $email = $request->getParameter('email', 'trim');
     $authcode = $request->getParameter('authcode', 'trim');
     $mobile = $request->getParameter('mobile', 'trim');
     $password = $request->getParameter('password', 'trim');
     $repass = $request->getParameter('repass', 'trim');
     $userid = $request->getParameter('userid', 'intval');
     if ($email != '') {
         $__authcode = getEmailCode($email, 7200);
     } else {
         if ($mobile != '') {
             $__authcode = getMobileCode($mobile, 600);
         }
     }
     if ($__authcode != $authcode) {
         AjaxResult::ajaxResult('error', '授权码错误');
     }
     if ($password != $repass) {
         AjaxResult::ajaxResult('error', '两次输入密码不一致');
     }
     $userService = Beans::get('user.user.service');
     if ($userService->set('password', md5(md5($password)), $userid)) {
         AjaxResult::ajaxSuccessResult();
     } else {
         AjaxResult::ajaxFailtureResult();
     }
 }
Exemplo n.º 7
0
 /**
  * 首页方法
  * @param HttpRequest $request
  */
 public function index(HttpRequest $request)
 {
     echo "<h1>Bean 模块测试,使用bean来管理服务。Beans::get('test.user.service')</h1>";
     $userService = Beans::get('test.user.service');
     $userService->register();
     $userService->login();
     die;
 }
Exemplo n.º 8
0
 public function user()
 {
     $service = Beans::get('test.user.service');
     $query = MysqlEntity::getInstance()->field('*')->addOptWhere('id', '>=', 20)->addLikeWhere('username', '123');
     $result = $service->getItems($query);
     __print($result);
     die;
 }
 public function C_start()
 {
     parent::C_start();
     $webApp = WebApplication::getInstance();
     $request = $webApp->getHttpRequest();
     $currentOpt = $request->getAction() . '@' . $request->getMethod();
     $this->assign("currentOpt", $currentOpt);
     $this->messageService = Beans::get('user.message.service');
 }
Exemplo n.º 10
0
 /**
  * 首页方法
  * @param HttpRequest $request
  */
 public function index(HttpRequest $request)
 {
     __print($request->getParameters());
     __print("Bean 模块测试,使用bean来管理服务。");
     $userService = Beans::get('test.user.service');
     $userService->register();
     $userService->login();
     die;
 }
 /**
  * 友情链接列表
  * @param HttpRequest $request
  */
 public function index(HttpRequest $request)
 {
     $service = Beans::get($this->getServiceBean());
     $items = $service->getItems("media_id=" . $this->loginMedia["id"], "id,ishow,add_time,name");
     $this->assign("items", $items);
     $this->assign("seoTitle", "媒体中心后台管理-友情链接列表");
     $this->assign("seoDesc", "友情链接");
     $this->assign("seoKwords", "媒体中心后台管理 友情链接");
     $this->setView('system/friendLink_list');
 }
Exemplo n.º 12
0
 /**
  * 文章详情
  * @param HttpRequest $request
  */
 public function detail(HttpRequest $request)
 {
     $id = $request->getParameter('id', 'intval');
     if ($id <= 0) {
         $id = 4779;
     }
     $articleService = Beans::get('test.article.service');
     $item = $articleService->getItem($id);
     $this->assign('item', $item);
 }
Exemplo n.º 13
0
 /**
  * @param HttpRequest $request
  */
 public function index(HttpRequest $request)
 {
     $emailService = Beans::get('common.email.service');
     //$email = new Smtp('smtp.163.com', 25, '*****@*****.**', 'tuoniu123WANG', $_auth = true, $time_out = 30);
     //$result = $email->Send_Mail('*****@*****.**', '*****@*****.**', '测试邮件', '<h1 style="color: #ff0000">HTML测试邮件。F**k it</h1>', 'html');
     //$result = $emailService->sendEmail('*****@*****.**', '测试邮件', '<h1 style="color: #ff0000">来自驼牛的测试邮件。F**k it</h1>', 'html');
     $result = $emailService->sendTemplateEmail('*****@*****.**', 'email_reset_password');
     var_dump($result);
     die;
 }
 /**
  * 批量标签
  * @see \article\service\interfaces\IArticleTagService::delete()
  */
 public function delete($id)
 {
     if ($this->getModelDao()->delete($id)) {
         //删除标签订阅
         $tagOrderSerivce = Beans::get('article.tags.order');
         $tagOrderSerivce->deletes("tagid={$id}");
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 15
0
 /**
  * 登出操作
  * @param HttpRequest $request
  */
 public function logout(HttpRequest $request)
 {
     $op = $request->getParameter('op', 'trim');
     if ($op == 'logout') {
         $adminService = Beans::get('admin.admin.service');
         $adminService->logout();
         $this->location(url('/admin_login_index'));
     } else {
         die('您要进行的操作不存在!');
     }
 }
 /**
  * 媒体频道删除操作监听
  * @param int $chanelId 媒体频道ID
  * @param boolean $status 操作的结果,默认操作是成功的
  * @return boolean
  */
 public function delete($chanelId, $status = true)
 {
     if ($status && $chanelId > 0) {
         $conditions = array('media_chanel' => $chanelId);
         //1. 删除当前媒体频道的所有文章
         $articleService = Beans::get('article.article.service');
         return $articleService->deletes($conditions);
     } else {
         return false;
     }
 }
Exemplo n.º 17
0
 /**
  * 获取爆料详情
  * @param HttpRequest $request
  */
 public function detail(HttpRequest $request)
 {
     $id = $request->getParameter('id', 'intval');
     $service = Beans::get($this->getServiceBean());
     $item = $service->getItem($id);
     if ($item) {
         AjaxResult::ajaxResult('ok', $item['content']);
     } else {
         AjaxResult::ajaxFailtureResult();
     }
 }
 /**
  * 初始化方法
  */
 public function C_start()
 {
     parent::C_start();
     $this->setServiceBean('article.article.service');
     //获取所有的子频道
     $chanelService = Beans::get('admin.chanel.service');
     $subChanels = $chanelService->getItems('pid > 0', 'id,pid,name,seo_title', 'sort_num ASC');
     $chanels = $chanelService->getItems(null, 'id,pid,name,seo_title', 'sort_num ASC');
     $this->assign('subChanels', $subChanels);
     $this->assign('chanels', ArrayUtils::changeArrayKey($chanels, 'id'));
 }
 /**
  * @see \article\service\interfaces\IArticleViewService::getItems
  */
 public function getItem($conditions, $fields, $order, $group, $having)
 {
     $item = $this->getModelDao()->getItem($conditions, $fields, $order, $group, $having);
     //将标签ID转为标签名称
     $tagSerive = Beans::get('article.tags.service');
     $tags = $tagSerive->getItems(explode(',', $item['tags']), 'name');
     $item['tags_name'] = array();
     foreach ($tags as $_val) {
         $item['tags_name'][] = $_val['name'];
     }
     return $item;
 }
 /**
  * 初始化方法
  */
 public function C_start()
 {
     parent::C_start();
     //获取友情链接
     $friendLinkService = Beans::get('admin.friendlink.service');
     $friendLinks = $friendLinkService->getFootLinks(40);
     $this->assign('friendLinks', $friendLinks);
     //获取底部导航
     $artoneService = Beans::get('artone.artone.service');
     $footNavis = $artoneService->getFootNavis(6, 'site_bottom', 'sort_num ASC');
     $this->assign('footNavis', $footNavis);
 }
Exemplo n.º 21
0
 /**
  * 编辑媒体管理员角色界面
  * @param HttpRequest $request
  */
 public function edit(HttpRequest $request)
 {
     //获取管理员角色
     $service = Beans::get("media.managerRole.service");
     $roles = $service->getItems("media_id=" . $this->loginMedia["id"], "id,name");
     $this->assign("roles", $roles);
     parent::edit($request);
     $this->assign("seoTitle", "媒体中心后台管理-媒体管理员");
     $this->assign("seoDesc", "媒体管理员 - 编辑媒体管理员");
     $this->assign("seoKwords", "媒体中心后台管理 编辑媒体管理员");
     $this->setView('manager/edit');
 }
Exemplo n.º 22
0
 public function index(HttpRequest $request)
 {
     $id = $request->getParameter("id", "intval");
     if ($id <= 0) {
         page404();
     }
     $artoneService = Beans::get("artone.artone.service");
     $condi = array('id' => $id, 'media_id' => $this->loginMedia['id']);
     $item = $artoneService->getItem($condi);
     $this->assign('item', $item);
     $this->setView("service");
 }
 /**
  * 请求拦截
  */
 public function beforeRequestInit()
 {
     $host = $_SERVER['HTTP_HOST'];
     $host = str_replace('www.', '', $host);
     $domain = getConfig('domain');
     //移动端访问
     if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'iPad') !== false) {
         //绑定了独立域名,直接跳转到手机媒体站
         if ($host != $domain) {
             $mediaService = Beans::get('media.media.service');
             $conditions = array('domain' => $host);
             $item = $mediaService->getItem($conditions, 'id');
             if (!$item) {
                 page404();
             }
             //访问驼牛网手机媒体站
             $urlMap = array('/^\\/$/iU' => '/mobile_site_index/?mediaId=' . $item['id'], '/^\\/site_index_index\\/media_id-(\\d+)\\.shtml$/iU' => '/mobile_index_media/?id=${1}', '/^\\/site_article_detail\\/id-(\\d+)-media_id-(\\d+)\\.shtml$/iU' => '/mobile_index_detail/?id=${1}');
             $url = preg_replace(array_keys($urlMap), $urlMap, $_SERVER['REQUEST_URI']);
             $_SERVER['REQUEST_URI'] = url($url);
             //除了媒体站的页面,不能通过媒体站的独立域名访问驼牛的其他页面
             if (strpos($_SERVER['REQUEST_URI'], '/mobile_') === false && $_SERVER['REQUEST_URI'] != '/') {
                 page404();
             }
         } else {
             //访问驼牛网手机主站
             if (strpos($_SERVER['REQUEST_URI'], '/mobile_') === false) {
                 header("Location:http://{$domain}/mobile_index_index");
                 die;
             }
         }
     } else {
         //pc端访问
         //绑定了独立域名,直接跳转到PC官网
         if ($host != $domain) {
             $mediaService = Beans::get('media.media.service');
             $conditions = array('domain' => $host);
             $item = $mediaService->getItem($conditions, 'id');
             if (!$item) {
                 page404();
             }
             //除了媒体站的页面,不能通过媒体站的独立域名访问驼牛的其他页面
             if (strpos($_SERVER['REQUEST_URI'], '/site_') === false && $_SERVER['REQUEST_URI'] != '/') {
                 page404();
             }
             //访问驼牛网PC媒体站首页
             if ($_SERVER['REQUEST_URI'] == '/') {
                 $_SERVER['REQUEST_URI'] = '/site_index_index/?media_id=' . $item['id'];
             }
         }
     }
     //代码执行到这里,则默认访问驼牛的PC主站
 }
Exemplo n.º 24
0
 /**
  * @param HttpRequest $request
  */
 public function index(HttpRequest $request)
 {
     $service = Beans::get('common.mobileMessage.service');
     //发送普通短信
     //$result = $service->sendMessage('18575670125', '驼牛网测试短信');
     //发送模板短信
     $result = $service->sendTemplateMessage('18575670125', 'mobile_reset_password');
     if ($result) {
         __print('短信发送成功');
     } else {
         __print($service->getMessage());
     }
     die;
 }
Exemplo n.º 25
0
 /**
  * @param HttpRequest $request
  */
 public function updateDomain(HttpRequest $request)
 {
     $domain = $request->getParameter('domain', 'trim');
     $domain = str_replace('www.', '', $domain);
     $mediaService = Beans::get($this->getServiceBean());
     $result = $mediaService->set('domain', $domain, $this->loginMedia['id']);
     //更新媒体信息
     if ($result) {
         $this->updateLoginMedia(array('domain' => $domain));
         AjaxResult::ajaxSuccessResult();
     } else {
         AjaxResult::ajaxFailtureResult();
     }
 }
Exemplo n.º 26
0
 /**
  * 关于我们模块统一处理页面,属于单文章模型,默认将显示第一篇
  * @param HttpRequest $request
  */
 public function service(HttpRequest $request)
 {
     $id = $request->getParameter('id', 'intval');
     if ($id <= 0) {
         page404();
     }
     $service = Beans::get('artone.artone.service');
     $service->increase('hits', 1, $id);
     $item = $service->getItem($id);
     if (!$item) {
         page404();
     }
     $this->assign('item', $item);
     $this->setView('artone_detail');
 }
Exemplo n.º 27
0
 /**
  * 加载编辑器
  * @param HttpRequest $request
  */
 public function index(HttpRequest $request)
 {
     $service = Beans::get('test.test.service');
     $data = array('name' => 'zhangsan', 'mobile' => '18575670125', 'email' => '*****@*****.**');
     $service->beginTransaction();
     $service->beginTransaction();
     $service->beginTransaction();
     $result = $service->add($data);
     $service->commit();
     $service->rollback();
     $service->commit();
     //Debug::printMessage();
     var_dump($result);
     die;
 }
Exemplo n.º 28
0
 /**
  * 上传文件,返回上传文件的地址
  * @param HttpRequest $request
  */
 public function index(HttpRequest $request)
 {
     $userid = $request->getParameter('userid', 'intval');
     $mediaId = $request->getParameter('media_id', 'intval');
     $type = $request->getParameter('type', 'trim');
     //图片的最大尺寸,大于这个尺寸就等比例裁剪
     $width = $request->getParameter('width', 'intval');
     if ($width <= 0) {
         $width = 800;
     }
     if (!$type) {
         $type = 'image';
     }
     $__uploadDir = $type . '/' . date('Y') . '/' . date('m') . '/' . date('d');
     $uploadDir = getConfig('upload_dir') . $__uploadDir;
     //上传图片
     $config = array("upload_dir" => $uploadDir, 'max_size' => 2048000);
     $upload = new FileUpload($config);
     $result = $upload->upload('Filedata');
     if ($result && $result['is_image'] == 1) {
         //缩放图片
         if ($width < $result['image_width']) {
             $src = $result['file_path'];
             $thumb = ImageThumb::getInstance();
             $thumb->setFlag(2);
             //规定宽度,等比缩放
             $filename = $thumb->makeThumb(array($width, 0), $src, null, true);
             //重新获取图片的尺寸和大小
             $info = getimagesize($filename);
             $result['image_width'] = $info[0];
             $result['image_height'] = $info[1];
             $result['file_size'] = filesize($filename);
         }
         //添加图片图片信息到数据库
         $service = Beans::get('image.image.service');
         $url = '/res/upload/' . $__uploadDir . '/' . $result['file_name'];
         $data = array('userid' => $userid, 'media_id' => $mediaId, 'url' => $url, 'filename' => $result['local_name'], 'type' => $type, 'filesize' => formatFileSize($result['file_size']), 'width' => intval($result['image_width']), 'height' => intval($result['image_height']), 'add_time' => time(), 'grabed' => 1);
         //保存到数据库失败
         if (!$service->add($data)) {
             //删除图片
             @unlink($result['file_path']);
         }
         AjaxResult::ajaxResult(1, $url);
     } else {
         @unlink($result['file_path']);
         AjaxResult::ajaxResult(0, '图片上传失败,' . $upload->getUploadMessage());
     }
 }
Exemplo n.º 29
0
 /**
  * 系统配置列表
  * @param HttpRequest $request
  */
 public function index(HttpRequest $request)
 {
     $configService = Beans::get('admin.config.service');
     $items = $configService->getItems();
     //获取app配置文档
     $wepApp = WebApplication::getInstance();
     $groups = $wepApp->getConfig('system.config.group');
     //将数据分组
     $newItems = array();
     foreach ($groups as $key => $value) {
         $newItems[$key] = ArrayUtils::filterArrayByKey('groupkey', $key, $items);
     }
     $this->assign('items', $newItems);
     $this->assign('groups', $groups);
     $this->setView('system/config_index');
 }
Exemplo n.º 30
0
 /**
  * 首页
  * @param HttpRequest $request
  */
 public function index(HttpRequest $request)
 {
     $page = $request->getParameter('page', 'intval');
     //获取轮播图
     $mediaService = Beans::get("media.media.service");
     $casoulItems = $mediaService->getMediaCarousel(5, $this->loginMedia['id']);
     $this->assign("casoulItems", $casoulItems);
     $condi = getMediaArticleConds();
     $condi['media_id'] = $this->loginMedia['id'];
     $this->loadMediaArticles($condi, $page, 'sort_num DESC, id DESC');
     //注册页面seo信息
     $this->assign('seoTitle', $this->mediaConfigs['sitetitle']);
     $this->assign('seoKwords', $this->mediaConfigs['siteseo']);
     $this->assign('seoDesc', $this->mediaConfigs['sitedescription']);
     $this->setView('index');
 }