/** * 媒体文章详情 * @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'); }
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主站 }
function pageRender($module = '', $action = '') { if (!file_exists("modules/" . $module . "_processor.php")) { print "modules/" . $module . ".php"; return page404($module); } require_once "modules/" . $module . "_processor.php"; $module_object = new $module(); if (!method_exists($module_object, $action)) { return page404($module); } return $module_object->{$action}(); }
/** * 找回密码输入邀请码页面 * @param HttpRequest $request */ public function reset(HttpRequest $request) { $username = $request->getParameter('username', 'trim'); $type = $request->getParameter('type'); //获取用户信息 $userService = Beans::get('user.user.service'); $user = $userService->getItem(array('username' => $username)); if (!$user) { page404(); } $this->assign('user', $user); $this->assign('type', $type); $this->setView('password_reset'); }
/** * 关于我们模块统一处理页面,属于单文章模型,默认将显示第一篇 * @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'); }
/** * 标签详情页 * @param HttpRequest $request */ public function detail(HttpRequest $request) { $id = $request->getParameter('id', 'intval'); $page = $request->getParameter('page', 'intval'); if ($id <= 0) { page404(); } $this->setPage($page); $condi = array('tagid' => $id); $articleViewService = Beans::get('article.view.service'); $tagsService = Beans::get('article.tags.service'); $userService = Beans::get('user.user.service'); $items = $articleViewService->getItems($condi, 'id,title,thumb,add_time,chanel_id, tags,media_id,bcontent', 'add_time DESC', $this->getPage(), $this->getPagesize()); $cacheInfo = array('baseKey' => 'tags', 'ftype' => 'article', 'factor' => $id . '-' . $this->getPage(), 'expr' => 300); $aricles =& $this->loadArticleInfo($items, ART_INFO_DEFAULT, $cacheInfo); $this->assign('items', $aricles); //获取分页 $count = $articleViewService->count($condi); $this->getPageData($count); //获取标签 $tag = $tagsService->getItem($id); $tagsService->increase('hits', 1, $id); //获取热门标签 $hotTags = $tagsService->getHotTags(12); $this->assign('hotTags', $hotTags); //判断用户是否订阅此标签 $loginUser = $userService->getLoginUser(); $ordered = 0; if ($loginUser) { $tagsOrderService = Beans::get('article.tags.order'); $orderCondi = array('userid' => $loginUser['id'], 'tagid' => $id); if ($tagsOrderService->getItem($orderCondi)) { $ordered = 1; } } $this->assign('ordered', $ordered); $this->assign('tag', $tag); //注册页面seo信息 $this->assign('seoTitle', '驼牛词条-' . $tag['name']); $this->assign('seoKwords', $tag['name'] . '驼牛网,牛媒体'); $this->assign('seoDesc', $tag['intro'] == '' ? $tag['name'] : $tag['intro']); $this->setView('tag_detail'); }
/** * Метод вызываемый для работы модуля */ function Output() { //Дополнительные функции, аякс $path = explode('/', $_SERVER['REQUEST_URI']); $path = array_filter($path); $action = end($path); switch ($action) { case 'ajaxTypes': $id = abs((int) $_POST['id']); $size = $_POST['size']; echo $this->GetColorsBySizeProduct($id, $size); exit; break; default: break; } $this->holder = end($GLOBALS['path']); if ($this->currentPath = $this->getCurrentTopicPath()) { $this->currentTopic = end($this->currentPath); } $this->pageType = $this->definePageType(); switch ($this->pageType) { case 'main': $title = $this->holder['name']; $content = $this->holder['text'] . $this->ProductsList(); break; case 'list': $title = $this->currentTopic['name']; $content = $this->currentTopic['text'] . $this->ProductsList(); break; case 'product': if ($content = $this->Product()) { $title = $this->currentProduct['name']; } else { page404(); } break; case '404': page404(); break; } return tpl('modules/' . __CLASS__ . '/page', array('title' => $title, 'text' => $content, 'backPath' => $this->BackPath())); }
/** * 获取推荐位文章 * @param string $position 文章推荐位key */ public function getArticlePosition($position = null) { if (!$position) { page404(); } $articlePositionService = Beans::get('article.rec.service'); $conditions['position'] = $position; $articlePosition = $articlePositionService->getItem($conditions); $articleService = Beans::get('article.article.service'); if (!empty($articlePosition['aids'])) { $articleConditions = array('id' => "#IN {$articlePosition['aids']}"); $indexPosition = $articleService->getItems($articleConditions, 'id,title,thumb', 'id desc', 1, 1); $indexPosition = $indexPosition[0]; $indexPosition['url'] = url("/mobile_index_detail/?id={$indexPosition['id']}"); $indexPosition['thumb'] = getImageThumb($indexPosition['thumb'], '653x366'); $this->assign('indexPosition', $indexPosition); } }
/** * 修改文章界面 * @param HttpRequest $request */ public function edit(HttpRequest $request) { //获取媒体频道列表 $service = Beans::get("media.chanel.service"); $navList = $service->getItems("media_id=" . $this->loginMedia["id"], "id,name"); $this->assign("navList", $navList); $articleService = Beans::get($this->getServiceBean()); $id = $request->getParameter('id', 'intval'); $item = $articleService->getItem($id); if ($item['media_id'] != $this->loginMedia['id']) { page404(); } //初始化文章标签 $tagsId = explode(',', $item['tags']); $tagService = Beans::get('article.tags.service'); $tags = $tagService->getItems($tagsId, 'id, name'); $tags = ArrayUtils::changeArrayKey($tags, 'id'); $__tags = array(); foreach ($tagsId as $value) { $__tags[] = $tags[$value]['name']; } $item['tags'] = implode(',', $__tags); $this->assign('item', $item); $this->assign("seoTitle", "媒体中心后台管理 - 编辑文章"); $this->assign("seoDesc", "媒体中心后台管理 文章列表 - 编辑文章"); $this->assign("seoKwords", "媒体中心后台管理 文章列表 编辑文章"); $this->setView('article/article_form'); }
function UploadFiles() { global $ioptions, $filesendname; $our_folder = $this->folder; if ($_GET['uri'] != '') { $this->folder = $_GET['uri']; if (!file_exists(DIR . $this->folder)) { mkdir(DIR . $this->folder); } $realpath1 = realpath(DIR . $our_folder); $realpath2 = realpath(DIR . $_GET['uri']); $strlen1 = strlen($realpath1); $strlen2 = strlen($realpath2); if ($strlen1 > $strlen2) { page404(); exit; } for ($i = 0; $i < $strlen1; $i++) { if ($realpath1[$i] != $realpath2[$i]) { page404(); exit; } } } else { if ($_GET['folder'] != '') { $this->folder = '/storage/' . $_GET['folder']; if (!file_exists(DIR . $this->folder)) { mkdir(DIR . $this->folder); } } } $result = array(); if (isset($_FILES['Filedata'])) { $file = $_FILES['Filedata']['tmp_name']; $error = false; $size = false; /*if (!is_uploaded_file($file) ) { } else {*/ if (!is_uploaded_file($file)) { print "error1"; exit; } else { if (!($size = @getimagesize($file)) && strtolower(substr($_FILES['Filedata']['name'], strrpos($_FILES['Filedata']['name'], '.') + 1)) != 'svg') { print "error2"; exit; } else { if (!$error && !in_array($size[2], array(1, 2, 3, 7, 8)) && strtolower(substr($_FILES['Filedata']['name'], strrpos($_FILES['Filedata']['name'], '.') + 1)) != 'svg') { print "error3"; exit; } else { $ext = strtolower(substr($_FILES['Filedata']['name'], strrpos($_FILES['Filedata']['name'], '.') + 1)); $name = findname($_FILES['Filedata']['tmp_name'], DIR . $this->folder, $_FILES['Filedata']['name'], $_FILES['Filedata']['name'] == 'blob.png'); if (!file_exists(DIR . $this->folder . '/.thumbs')) { mkdir(DIR . $this->folder . '/.thumbs'); } if ($ioptions["water"] != '') { $name = $name . "_water"; } $source = DIR . $this->folder . '/' . $name . '.' . $ext; if (!@copy($_FILES['Filedata']['tmp_name'], $source)) { //print "error4"; } if (true) { if (!file_exists(DIR . $this->folder . '/.thumbs')) { mkdir(DIR . $this->folder . '/.thumbs'); } if ($ioptions["water"] != '') { $thumb = DIR . $this->folder . '/.thumbs/preview1_' . $name . '.' . "png"; } else { $thumb = DIR . $this->folder . '/.thumbs/preview1_' . $name . '.' . $ext; } //$thumb2 = DIR.$this->folder.'/.thumbs/preview_2_'.$name.'.'.$ext; //$image = new files('tinyimages'); //$this->Resize($source,$thumb,200,200,'back-ffffff'); /****************************************************************** ***************************************************************** ************************************************************** *******************************************************************/ /*>>>>>>>>>>>>>>*/ $this->Resize($source, $thumb, $ioptions["w"], $ioptions["h"], 'thumb', $ioptions["water"]); //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< /*>>>>>>>>>>>>>>*/ $i = 2; $fl = 0; while ($fl == 0) { if (isset($ioptions["w" . $i]) && isset($ioptions["h" . $i])) { $thumb = DIR . $this->folder . '/.thumbs/preview' . $i . '_' . $name . '.' . $ext; if (strtolower($ext) != 'svg') { $this->Resize($source, $thumb, $ioptions["w" . $i], $ioptions["h" . $i], 'thumb'); } else { copy($source, $thumb); } $i++; } else { $fl = 1; } } $result['result'] = 'success'; $newadress = $this->folder; $newfilename = $name . '.' . $ext; if (isset($_GET['uri'])) { $newadress = $_GET['uri']; } if ($newadress == "") { $newadress = "/storage"; } print $newadress . "/" . $newfilename; } else { $result['result'] = 'success'; $newadress = "/storage"; $newfilename = $name . '.' . $ext; if (isset($_GET['uri'])) { $newadress = $_GET['uri']; } if ($newadress == "") { $newadress = "/storage"; } print $newadress . "/" . $newfilename; } } } } } else { print 'error5'; } /*foreach ($result as $key=>$val) { $return[$key] = iconv("windows-1251", "utf-8", $val); }*/ exit; }
/** * 推荐位详情 * @param HttpRequest $request */ public function detail(HttpRequest $request) { $id = $request->getParameter('id', 'intval'); if ($id <= 0) { page404(); } $condi = array('position' => $id, 'media_id' => $this->loginMedia['id']); $service = Beans::get($this->getServiceBean()); $item = $service->getItem($condi); if (!$item) { page404(); } //获取推荐位的文章 if ($item['aids']) { $articleService = Beans::get('article.article.service'); $aids = explode(',', $item['aids']); $items = $articleService->getItems($aids, 'id, title, add_time'); //重新按照推荐位ID排序 $items = ArrayUtils::changeArrayKey($items, 'id'); $newItems = array(); foreach ($aids as $value) { $newItems[] = $items[$value]; } $this->assign('items', $newItems); } $this->assign('item', $item); $this->setView('article/recommend_detail'); }
/** * 爆料详情 * @param HttpRequest $request */ public function detail(HttpRequest $request) { if ($request->getParameter('id', 'intval')) { $id = $request->getParameter('id', 'intval'); $conditions = array('userid' => $this->loginUser['id'], 'id' => $id); $items = $this->tipoffService->getItem($conditions); $this->assign('items', $items); $this->setView('tipoff/detail'); } else { page404(); } }
/** * 登出操作 * @param HttpRequest $request */ public function logout(HttpRequest $request) { $op = $request->getParameter('op', 'trim'); if ($op == 'logout') { $userService = Beans::get('user.user.service'); $userService->logout(); $this->location(url('/user_login_index')); } else { page404(); } }
function searchpage($d) { $request = $d["request"]; $proxyadd = ""; $proxyform = ""; if (isset($request["enableproxy"]) && $request["enableproxy"] == "true") { $proxyadd = "&enableproxy=" . $request["enableproxy"]; $proxyform = "<input type=hidden name=enableproxy value=" . $request["enableproxy"] . ">"; } /* if (loggedin()) { $subs=""; foreach ($_SESSION["subscribed"] as $sub) { $subs.='<a href="index.php?q='.$sub["url"].'" class="subitem"><span>'.$sub["name"].'</span></a>'; } $header=' <div id="navbarlinks"> <a target=_blank href="http://www.reddit.com/u/'.$_SESSION["username"].'">+'.$_SESSION["username"].'</a> <div id="subtoggle" href="#"> <div id="subscribed"> '.$subs.' </div> subscribed </div> </div> <div id="navbarmenu"> <div id="navbarmenuicon"></div> <div id="navbarmenunotification"></div> <div id="navbarmenuadd"></div> <div id="navbarmenuprofile" tabindex="1"> <a href="index.php?action=logout" id="navbarlogout"> Logout </a> </div> </div>'; } else { $header='<div id="navbarmenu"> <div id="navbarmenuicon"></div> <label for="logincheckbox" id="navbarmenubutton">Sign In</label> <input type="checkbox" id="logincheckbox" value="1" style="display:none;"> <div id="navbarlogin"> <form method="post"> <input type="hidden" name="q" value="'.$d["query"].'"> <input type="hidden" name="action" value="login"> <input type="text" name="username" placeholder="User"> <input type="password" name="password" placeholder="Password"> <button id="loginbutton" type="submit">Sign In</button> </form> </div> </div>'; }*/ $header = '<div id="navbarmenu"> <div id="navbarmenuicon"></div> <div id="navbarmenubutton">Sign In</div> </div>'; $active = array("", "", "", "", "", "", "", ""); switch ($d["sub"]) { case "/new": $active[1] = "active"; $sublink = "&action=new"; break; case "/rising": $active[2] = "active"; $sublink = "&action=rising"; break; case "/controversial": $active[3] = "active"; $sublink = "&action=controversial"; break; case "/top": $active[4] = "active"; $sublink = "&action=top"; break; case "/gilded": $active[5] = "active"; $sublink = "&action=gilded"; break; case "/promoted": $active[6] = "active"; $sublink = "&action=promoted"; break; case "/wiki": $active[7] = "active"; $sublink = "&action=wiki"; break; default: $active[0] = "active"; $sublink = "&action=hot"; break; } $sublink .= $proxyadd; echo ' <!DOCTYPE HTML> <head> <meta charset="utf-8"> <title>' . $d["query"] . ' - Cluffle Search</title> <link rel="shortcut icon" href="gfx/faviconsmall.png" /> <style>'; require "css/searchpage.css"; echo '</style> <script>'; require "js/jquery-2.1.1.min.js"; echo '</script> <script>'; require "js/script.js"; echo '</script> <style> body { background-color:white; padding:0; margin:0; padding-top:172px; min-width:980px; } </style> </head> <body> <div id="navbar"> <a href="index.php"> <img id="logo" src="gfx/logo.png"></img> </a> <form> <input type="text" id="searchbox" name="q" value="' . $d["query"] . '" autocomplete=off> ' . $proxyform . ' <label for=searchsubmitbutton id="searchbutton"> <input id="searchsubmitbutton" type="submit" style="display:none;"> </label> </form> ' . $header . ' </div> <div id="navbar2"> <a href="index.php?q=' . $d["query"] . $proxyadd . '"> <div class="navbar2sub ' . $active[0] . '"> Hot </div> </a> <a href="index.php?action=new&q=' . $d["query"] . $proxyadd . '"> <div class="navbar2sub ' . $active[1] . '"> New </div> </a> <a href="index.php?action=rising&q=' . $d["query"] . $proxyadd . '"> <div class="navbar2sub ' . $active[2] . '"> Rising </div> </a> <a href="index.php?action=controversial&q=' . $d["query"] . $proxyadd . '"> <div class="navbar2sub ' . $active[3] . '"> Controversial </div> </a> <a href="index.php?action=top&q=' . $d["query"] . $proxyadd . '"> <div class="navbar2sub ' . $active[4] . '"> Top </div> </a> <a href="index.php?action=gilded&q=' . $d["query"] . $proxyadd . '"> <div class="navbar2sub ' . $active[5] . '"> Gilded </div> </a> <a href="index.php?action=promoted&q=' . $d["query"] . $proxyadd . '"> <div class="navbar2sub ' . $active[6] . '"> Promoted </div> </a> <a href="index.php?action=wiki&q=' . $d["query"] . $proxyadd . '"> <div class="navbar2sub ' . $active[7] . '"> Wiki </div> </a> <img id="cog" src="gfx/cog.png"> </div> <div id="navbar3"> <div id="resultstats"> ' . $d["resultstats"] . ' </div> </div> <div id="results"> '; if (empty($d["results"])) { $d["results"] = page404(); } foreach ($d["results"] as $r) { if (isset($r["strOverwrite"])) { $commentgreen = ' <a href="' . htmlentities($r["strLink"]) . '">' . $r["strTitel"] . '</a><br> <a class="resultlink" href="#">' . $r["strOverwrite"] . '</a> '; } else { if (isset($r["nsfw"]) && $r["nsfw"]) { $nsfw = "[NSFW] "; } else { $nsfw = ""; } $commentlink = 'index.php?action=groups&comment=' . $r["strComment"]; $commentstring = $nsfw . $r["numComments"] . ' comments'; $commentgreen = ' <a target="_blank" href="' . htmlentities($r["strLink"]) . '">' . $r["strTitel"] . '</a><br> <a class="resultlink" target=_blank href="' . $commentlink . '">' . $commentstring . '</a> <span class="resultlink">-</span> <a class="resultlink" target=_blank href="index.php?q=' . $r["strDomain"] . '">' . htmlentities($r["strDomain"]) . '</a> '; } echo ' <div class="resultdiv"> ' . $commentgreen . ' <br> <span class="resulttext"> ' . $r["strCreated"] . str_replace("<a", "<a target='_blank'", closetags($r["strBeschreibung"])) . ' </span> </div> '; } if ($d["showNav"]) { if (!$d["back"]) { //Kein Zurück $back = ' <td> <span id="Cl1"></span> </td> '; } else { $back = ' <td> <a href="' . $d["backlink"] . $sublink . '"> <span id="Cl2"></span><span id="back">Previous</span> </a> </td> '; //Zurück } $toggle = 0; $pagenumbers = ""; foreach ($d["pagelinks"] as $page) { if ($toggle == 0 && $page["current"] == 1) { $pagenumbers .= '<td id="cur"> <span class="u"></span><span class="bottomnavtext">' . $page["number"] . '</span> </td>'; $toggle = 1; } else { if ($toggle == 0) { $pagenumbers .= '<td> <a href="' . $page["link"] . $sublink . '"><span class="u"></span><span class="bottomnavtext">' . $page["number"] . '</span></a> </td>'; } else { $pagenumbers .= '<td> <a href="' . $page["link"] . $sublink . '"><span class="u"></span><span class="bottomnavtext">' . $page["number"] . '</span></a> </td>'; } } } if ($d["forward"]) { $next = '<td> <a href="' . $d["forwardlink"] . $sublink . '"><span id="ffle"></span><span id="weiter" style="font-weight:700;">Next</span></a> </td> '; } else { $next = '<td> <span id="ffle" style="cursor:default; width:62px;"></span> </td> '; } echo ' <div id="bottomnavwrapper"> <table id="bottomnav"> <tbody> <tr valign=top> ' . $back . $pagenumbers . ' ' . $next . ' </tr> </tbody> </table> </div>'; } else { echo ' <div id="bottomnavwrapper"> </div>'; } echo ' </div> <div id="footer"> <a div="opensource" style="margin-left:135px;">Help</a> <a div="opensource">Open Source</a> <a div="about">About</a> <a target=_blank href="http://www.reddit.com/user/Lutan">Contact</a> ' . $d["proxyquery"] . ' </div> <div id="help" class="popup" style="display:none;"> <h2>Help</h2> <div class="closebutton">Close</div> <p> </p> </div> <div id="opensource" class="popup" style="display:none;"> <h2>Open Source</h2> <div class="closebutton">Close</div> <p> The whole project is completely open source and available at <a href="http://www.github.com/Lutron/Cluffle">Github</a>.<br> If you want to help improving the messy project (it\'s based on PHP), feel free to make a pull request. I\'ll also list everyone helping here. </p> </div> <div id="about" class="popup" style="display:none;"> <h2>About</h2> <div class="closebutton">Close</div> <p>Want to use Reddit without people knowing you are using it? This page provides you with the known Google interface for your Reddit needs.<br><br> Browse a subreddit by entering it into the box ("/r/internetisbeautiful" or "/r/web_design").<br> Search for a term as you would on reddit.<br> Press the "I\'m feeling lucky" - button to browse a random subreddit.<br><br> Cluffle is your stealth mode to avoid things like suspicious coworkers and classmates.<br> Reddit is blocked at work? Cluffle also works as a proxy.<br> You want the usual Reddit interface while using the proxy? Just go to <a href="http://proxy.cluffle.com" target=_blank>proxy.cluffle.com</a>. </p> </div> </body> '; }
/** * 文章详情页面 * @param HttpRequest $request */ public function detail(HttpRequest $request) { $id = $request->getParameter('id', 'intval'); if ($id <= 0) { page404(); } //获取文章信息 $condi = getArticleBasicConditions(); $condi['id'] = $id; $articleService = Beans::get('article.article.service'); $item = $articleService->getItem($condi, "id,title, chanel_id, media_id, bcontent,tags, zan_times, kwords, add_time"); if (!$item) { page404(); } //更新点击率 $articleService->increase('hits', 1, $id); //获取频道,标签和媒体宿主 $chanelService = Beans::get('admin.chanel.service'); $tagService = Beans::get('article.tags.service'); $mediaService = Beans::get('media.media.service'); $userService = Beans::get('user.user.service'); if ($item['tags'] != '') { $item['tags'] = $tagService->getItems("id in({$item['tags']}) AND name != ''", 'id,name'); } if ($item['media_id'] > 0) { $media = $mediaService->getItem($item['media_id'], 'name'); $item['media'] = $media['name']; } else { $item['media'] = '驼牛网'; } if ($item['chanel_id'] > 0) { $chanel = $chanelService->getItem($item['chanel_id'], 'id, name'); $item['chanel'] = $chanel['name']; } //获取热点排行文章 $hotRanks = $articleService->getHotRank(10, 'id,title'); $this->assign('hotRanks', $hotRanks); //获取周排行 $weekRanks = $articleService->getWeekRank(10, 'id,title'); $this->assign('weekRanks', $weekRanks); //获取编辑推荐的文章 $editorRec = $articleService->getEditorRecommend(10); $this->assign('editorRec', $editorRec); //获取推荐媒体信息 $niulanMedia = $mediaService->getRecommendMedia(4, 'niulan'); $this->assign('niulanMedia', $niulanMedia); //获取热门标签 $hotTags = $tagService->getHotTags(12); $this->assign('hotTags', $hotTags); //获取相关文章 $alikeArticles = $articleService->getAlikeArticles($item['id'], 4); $this->assign('alikeArticles', $alikeArticles); //--获取文章评论 $commentService = Beans::get('article.service.comment'); $commentList = $commentService->getComment($id); //以id为键 $pidList = array(); foreach ($commentList as $val) { array_push($pidList, $val['pid']); } //获取各个评论的上一级 $preComment = array(); if ($pidList) { $preComment = $commentService->getCommentsById($pidList); } $commentList = array_merge($commentList, $preComment); $temp = array(); foreach ($commentList as $val) { $temp[$val['id']] = $val; } $this->assign('commentList', $temp); $this->assign('aid', $id); //获取评论的用户 $userlist = array(); if ($commentList) { foreach ($commentList as $key => $val) { array_push($userlist, $val['uid']); } } $userlist = array_unique($userlist); //获取评论的用户信息 $userlist = $userService->getUsers($userlist); //变成以用户id为键的 数组 $users = array(); foreach ($userlist as $val) { $users[$val['id']] = $val; } $this->assign('users', $users); //获取媒体信息 $imageClass = 'logo'; $circleClass = ''; if ($item['media_id'] > 0) { $mediaInfo = $mediaService->getItem($item['media_id'], "id, name, media_type,nickname, logo, intro"); $condi = getArticleBasicConditions(); $condi['media_id'] = $item['media_id']; $mediaArticles = $articleService->getItems($condi, "id, title", 'id DESC', 1, 4); $this->assign('mediaArticles', $mediaArticles); //判断媒体类型 $mediaTypeService = Beans::get('media.type.service'); $type = $mediaTypeService->getItem($mediaInfo['media_type'], 'tkey'); if ($type['tkey'] != 'qunmei') { $imageClass = 'face'; $circleClass = 'aside_publish_user'; } } $this->assign('imageClass', $imageClass); $this->assign('circleClass', $circleClass); $loginUser = $userService->getLoginUser(); //判断是否已收藏 if ($loginUser) { $collectService = Beans::get('user.collect.service'); $collectCondi = array('userid' => $this->loginUser['id'], 'aid' => $item['id']); if ($collectService->count($collectCondi) > 0) { $item['collection'] = 1; } else { $item['collection'] = 0; } } //判断是否已被点赞 if ($loginUser) { $CACHER = CacheFactory::create('file'); $key = md5($loginUser['id'] . $id); $item['zan'] = $CACHER->get($key); } else { $item['zan'] = 0; } $this->assign('item', $item); $this->assign('mediaInfo', $mediaInfo); $this->setView('article_detail'); //注册页面seo信息 $this->assign('seoTitle', $item['title'] . ' - 驼牛网'); //如果没有关键字,则使用标签 if (!$item['kwords']) { foreach ($item['tags'] as $value) { $item['kwords'] .= $value['name'] . ','; } } $this->assign('seoKwords', $item['kwords']); $this->assign('seoDesc', $item['bcontent']); }
public function Output() { $this->holder = end($GLOBALS['path']); $path = explode('?', $_SERVER['REQUEST_URI']); $path = $path[0]; $path = explode('/', $path); $path = array_filter($path); $action = end($path); switch ($action) { case 'add': if (isset($_REQUEST['id'])) { $id = abs((int) $_REQUEST['id']); } else { page404(); } if (isset($_REQUEST['count'])) { $count = abs((int) $_REQUEST['count']); } else { $count = 1; } $this->addToBasket($id, $count); break; case 'edit': if (isset($_REQUEST['id'])) { $id = abs((int) $_REQUEST['id']); } else { page404(); } if (isset($_REQUEST['count'])) { $count = abs((int) $_REQUEST['count']); } else { page404(); } $this->editCount($id, $count); if ($_SERVER['REQUEST_METHOD'] == 'POST') { echo $this->getBasketTotalsJSON(); exit; } break; case 'del': if (isset($_REQUEST['id'])) { $id = abs((int) $_REQUEST['id']); } else { page404(); } $this->delFromBasket($id); if ($_SERVER['REQUEST_METHOD'] == 'POST') { echo $this->getBasketTotalsJSON(); exit; } break; case 'clean': $this->cleanBasket(); break; default: return tpl('modules/' . __CLASS__ . '/page', array('title' => $this->holder['name'], 'text' => $this->Page())); break; } //Если мы еще здесь ) //Если запрос был выполнен гетом, то просто вернем на предыдущую страницу //Если запрос сделан постом, то вероятнее что это аякс, отдадим блок корзины и просто закончим работу if ($_SERVER['REQUEST_METHOD'] == 'GET') { if (isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])) { header('Location: ' . $_SERVER['HTTP_REFERER']); } exit; } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { echo $this->Block(); exit; } }
exporter(); break; case 'imprimer': imprimer(); break; case 'rechercher_session': rechercher(); break; case 'visualiser_session': visualiser_session(); break; case 'session_rapide': session_rapide(); break; default: page404(); } /*page introuvable*/ function page404() { global $page; global $administration; $page['gabarit'] = "administration"; $page['vue'] = "page404.vue.php"; } /*page d'acceuil session*/ function base() { global $page; global $session; $page['gabarit'] = "administration";
/** * 媒体所包含的文章列表 * @param HttpRequest $request */ public function detail(HttpRequest $request) { $id = $request->getParameter('id', 'intval'); $page = $request->getParameter('page', 'intval'); if ($id <= 0) { page404(); } $this->setPage($page); //获取文章 $userService = Beans::get('user.user.service'); $articleService = Beans::get('article.article.service'); $mediaService = Beans::get('media.media.service'); $tagService = Beans::get('article.tags.service'); $baseCondi = getArticleBasicConditions(); $condi['media_id'] = $id; $condi = array_merge($condi, $baseCondi); $items = $articleService->getItems($condi, 'id,title,thumb,add_time,chanel_id, tags,media_id,bcontent', 'add_time DESC', $this->getPage(), $this->getPagesize()); $cacheInfo = array('baseKey' => 'article', 'ftype' => 'mediadetail', 'factor' => $id . '-' . $page, 'expr' => 300); $aricles =& $this->loadArticleInfo($items, ART_INFO_DEFAULT, $cacheInfo); $this->assign('items', $aricles); //获取分页 $count = $articleService->count($condi); $this->getPageData($count); //获取媒体信息 $mediaInfo = $mediaService->getItem($id, 'id,name,intro,logo'); $this->assign('mediaInfo', $mediaInfo); //获取媒体信息 $imageClass = 'logo'; $mediaInfo = $mediaService->getItem($id, "id, name, media_type, nickname, domain, logo, intro"); $mediaInfo['domain'] = trim($mediaInfo['domain']); if ($mediaInfo['domain'] != '') { $mediaInfo['domain'] = 'http://www.' . $mediaInfo['domain']; } else { $mediaInfo['domain'] = url('/site_index_index/?media_id=' . $id); } $mediaInfo['configs'] = cn_json_decode($mediaInfo['configs']); $this->assign('mediaInfo', $mediaInfo); //判断媒体类型 $mediaTypeService = Beans::get('media.type.service'); $type = $mediaTypeService->getItem($mediaInfo['media_type'], 'tkey'); if ($type['tkey'] != 'qunmei') { $imageClass = 'aside_publish_user'; } $this->assign('imageClass', $imageClass); //判断用户是否订阅此媒体 $loginUser = $userService->getLoginUser(); $mediaOrdered = 0; if ($loginUser) { $mediaOrderService = Beans::get('media.order.service'); $orderCondi = array('userid' => $loginUser['id'], 'media_id' => $id); if ($mediaOrderService->getItem($orderCondi)) { $mediaOrdered = 1; } } $this->assign('mediaOrdered', $mediaOrdered); //获取热点排行文章 $hotRanks = $articleService->getHotRank(10, 'id,title'); $this->assign('hotRanks', $hotRanks); //获取周排行 $weekRanks = $articleService->getWeekRank(10, 'id,title'); $this->assign('weekRanks', $weekRanks); //获取编辑推荐的文章 $editorRec = $articleService->getEditorRecommend(10); $this->assign('editorRec', $editorRec); //获取推荐媒体信息 $niulanMedia = $mediaService->getRecommendMedia(4, 'niulan'); $this->assign('niulanMedia', $niulanMedia); //获取热门标签 $hotTags = $tagService->getHotTags(12); $this->assign('hotTags', $hotTags); //注册页面seo信息 $this->assign('seoTitle', $mediaInfo['configs']['sitetitle'] . ' - 驼牛网牛媒体'); $this->assign('seoKwords', $mediaInfo['configs']['siteseo'] . '驼牛网,牛媒体'); $this->assign('seoDesc', $mediaInfo['configs']['sitedescription']); $this->setView('media_detail'); }
function callMe() { global $url; // get the values from the global variable $url index.php $urlArray = array(); $paramArray = array(); $controller = ""; $action = ""; $model = ""; $controllerName = ""; if ($url !== '/') { $urlArray = explode("/", $url); array_shift($urlArray); if (count($urlArray)) { if (count($urlArray) < 2) { if (strstr($urlArray[0], '?')) { $urlArray = explode("?", $urlArray[0]); $controller = urlForHypen($urlArray[0]); // get the first element from the array } else { $controller = urlForHypen($urlArray[0]); } $action = 'actionIndex'; $actionName = 'Index'; } else { $controller = urlForHypen($urlArray[0]); // get the first element from the array array_shift($urlArray); // remove the first element from the array if (strstr($urlArray[0], '?')) { $urlArray = explode("?", $urlArray[0]); $action = urlForHypen($urlArray[0]); // get the first element from the array } else { $action = urlForHypen($urlArray[0]); // get the new first element from the array array_shift($urlArray); // remove the first element from the array } $actionName = $action; $action = 'action' . $action; } $paramArray = $urlArray; $model = strtolower($controller); $controller .= 'Controller'; $controllerName = $controller; if ((int) method_exists($controller, $action)) { //check if the action name method was existed $dispatch = new $controller($model, $controllerName, $action); if ((int) method_exists($controller, 'behaviors')) { $rules = $dispatch->behaviors(); if (count($rules['access']['rules'])) { $is_allowed = false; $allow_guest_actions = array(); $allow_logged_actions = array(); $allow_admin = array(); $not_allow_actions = array(); foreach ($rules['access']['rules'] as $val) { if ($val['allow']) { if (in_array('?', $val['roles'])) { foreach ($val['actions'] as $list_action) { $allow_guest_actions[] = $list_action; } } else { if (in_array('@', $val['roles'])) { foreach ($val['actions'] as $list_action) { $allow_logged_actions[] = $list_action; } } else { if (in_array('admin', $val['roles'])) { foreach ($val['actions'] as $list_action) { $allow_admin[] = $list_action; } } } } } else { foreach ($val['actions'] as $list_action) { $not_allow_actions[] = $list_action; } } } } $guest = new User(); if (in_array(strtolower($actionName), $allow_logged_actions) && !$guest->loggedin()) { $_SESSION['cur_url'] = $_SERVER['REQUEST_URI']; $dispatch->redirect('/user/login'); } if (in_array(strtolower($actionName), $allow_admin) && (!$guest->loggedin() || $guest->loggedin()) && $guest->loggedin_permission() != 1) { page403(); } if (in_array(strtolower($actionName), $not_allow_actions)) { page404(); } } call_user_func_array(array($dispatch, $action), $paramArray); } else { page404(); } } else { $model = 'site'; $controllerName = ''; $action = ''; $cntroler = new SiteController($model, $controllerName, $action); $cntroler->render('home'); } } else { $model = 'site'; $controllerName = ''; $action = ''; $cntroler = new SiteController($model, $controllerName, $action); $cntroler->render('home'); } }
/** * 媒体申请详情页 * @param HttpRequest $request */ public function mediaApplyDetail(HttpRequest $request) { if ($request->getParameter('id', 'intval')) { $id = $request->getParameter('id', 'intval'); $mediaService = Beans::get('media.media.service'); $item = $mediaService->getItem($id); if ($item[ischeck] == 0) { $item[ischeck] = '未审核'; } elseif ($item[ischeck] == 1) { $item[ischeck] = '审核通过'; } else { $item[ischeck] = '审核失败'; } if ($item[media_type] == 1) { $item[mediaType] = '群媒'; } elseif ($item[media_type] == 2) { $item[mediaType] = '自媒体'; } else { $item[mediaType] = '企业'; } $this->assign('item', $item); $this->setView('ucenter/mediaApplyDetail'); } else { page404(); } }
public function m2Chanel(HttpRequest $request) { $id = $request->getParameter('id', 'intval'); if ($id < 0) { page404(); } $chanelService = Beans::get('media.chanel.service'); $chanel = $chanelService->getItem($id, 'id,name'); $this->assign('title', $chanel); $conditions = array('media_chanel' => $id, 'media_id' => $this->mediaId); $items = $this->getArticles($conditions, 'id,thumb,title,media_id,add_time,bcontent,chanel_id'); $this->assign('items', $items); $this->assign('id', $id); $this->setView('site/m2Chanel'); }
/** * 修改文章界面 * @param HttpRequest $request */ public function edit(HttpRequest $request) { if ($request->getParameter('id', 'intval')) { $id = $request->getParameter('id', 'intval'); $item = $this->articleService->getItem($id); if ($item['userid'] != $this->loginUser['id']) { page404(); } //初始化文章标签 $tagsId = explode(',', $item['tags']); $tagService = Beans::get('article.tags.service'); $tags = $tagService->getItems($tagsId, 'id, name'); $tags = ArrayUtils::changeArrayKey($tags, 'id'); $__tags = array(); foreach ($tagsId as $value) { $__tags[] = $tags[$value]['name']; } $item['tags'] = implode(',', $__tags); $this->assign('item', $item); $this->setView('article/edit'); } else { page404(); } }
function UploadFiles() { global $ioptions, $filesendname; $our_folder = $this->folder; if ($_GET['uri'] != '') { $this->folder = $_GET['uri']; if (!file_exists(DIR . $this->folder)) { mkdir(DIR . $this->folder); } $realpath1 = realpath(DIR . $our_folder); $realpath2 = realpath(DIR . $_GET['uri']); $strlen1 = strlen($realpath1); $strlen2 = strlen($realpath2); if ($strlen1 > $strlen2) { page404(); exit; } for ($i = 0; $i < $strlen1; $i++) { if ($realpath1[$i] != $realpath2[$i]) { page404(); exit; } } } $result = array(); if (isset($_FILES['Filedata'])) { $file = $_FILES['Filedata']['tmp_name']; $error = false; $size = false; /*if (!is_uploaded_file($file) ) { } else {*/ if (!is_uploaded_file($file)) { print "error1"; exit; } else { if (false) { print "error2"; exit; } else { if (!preg_match('/\\.(mp3|zip|txt|flv|doc|rtf|swf|docx|xlsx|xml|ies|pdf|zip|rar|xls|jpg|gif|png|jpeg|pptx?)$/i', $_FILES['Filedata']['name'])) { print "ERROR_Invalid_filetype"; exit; } else { $newadress = "/storage"; $newfilename = $name . '.' . $ext; if (isset($_GET['uri'])) { $newadress = $_GET['uri']; } $ext = substr($_FILES['Filedata']['name'], strrpos($_FILES['Filedata']['name'], '.') + 1); $name = findname($_FILES['Filedata']['tmp_name'], DIR . $this->folder, $_FILES['Filedata']['name'], false); $source = DIR . $this->folder . '/' . $name . '.' . $ext; if (!copy($_FILES['Filedata']['tmp_name'], $source)) { print "error4"; } else { $result['result'] = 'success'; $newadress = "/storage"; $newfilename = $name . '.' . $ext; if (isset($_GET['uri'])) { $newadress = $_GET['uri']; } if ($newadress == "") { $newadress = "/storage"; } print $newadress . "/" . $newfilename; } } } } } else { print 'error5'; } /*foreach ($result as $key=>$val) { $return[$key] = iconv("windows-1251", "utf-8", $val); }*/ exit; }