public function store(Request $request)
 {
     $rules = array('front-image' => 'image|mimes:jpeg,jpg,png,bmp,gif,svg', 'front-title' => '', 'front-subtitle' => '', 'calendar-important' => '');
     $validator = \Validator::make(\Input::all(), $rules);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator);
     }
     if ($request->hasFile('front-image')) {
         $destinationPath = public_path('assets/img/banner.png');
         $uploadSuccess = \Image::make($request->file('front-image')->getRealPath())->save($destinationPath);
     }
     if ($request->has('front-title')) {
         set_content('front.title', $request->input('front-title'));
     }
     if ($request->has('front-subtitle')) {
         set_content('front.subtitle', $request->input('front-subtitle'));
     }
     if ($request->has('calendar-important')) {
         set_content('calendar.important', $request->input('calendar-important'));
     }
     return redirect()->back();
 }
示例#2
0
// 获取评论
if ($t_obj['comments']) {
    if ($page == 0) {
        $page = 1;
    }
    $query_sql = "SELECT c.id,c.uid,c.addtime,c.content,u.avatar as avatar,u.name as author\n        FROM yunbbs_comments c \n        LEFT JOIN yunbbs_users u ON c.uid=u.id\n        WHERE c.articleid='{$tid}' ORDER BY c.id ASC LIMIT " . ($page - 1) * $options['commentlist_num'] . "," . $options['commentlist_num'];
    $query = $DBS->query($query_sql);
    $commentdb = array();
    while ($comment = $DBS->fetch_array($query)) {
        // 格式化内容
        $comment['addtime'] = showtime($comment['addtime']);
        if ($is_spider || $tpl) {
            // 手机浏览和搜索引擎访问不用 jquery.lazyload
            $comment['content'] = set_content($comment['content'], 1);
        } else {
            $comment['content'] = set_content($comment['content']);
        }
        $commentdb[] = $comment;
    }
    unset($comment);
    $DBS->free_result($query);
}
// 增加浏览数
$DBS->unbuffered_query("UPDATE yunbbs_articles SET views=views+1 WHERE id='{$tid}'");
// 如果id在提醒里则清除
if ($cur_user && $cur_user['notic'] && strpos(' ' . $cur_user['notic'], $tid . ',')) {
    $db_user = $DBS->fetch_one_array("SELECT * FROM yunbbs_users WHERE id='" . $cur_uid . "'");
    $n_arr = explode(',', $db_user['notic']);
    foreach ($n_arr as $k => $v) {
        if ($v == $tid) {
            unset($n_arr[$k]);
示例#3
0
/**
 * Application entry point
 */
function start()
{
    load_config();
    load_libraries();
    validate_uri($_SERVER['REQUEST_URI']);
    $url = parse_url($_SERVER['REQUEST_URI']);
    if (isset($url['path'])) {
        $uri = $url['path'];
    } else {
        $uri = $_SERVER['REQUEST_URI'];
        $pos = strpos($uri, '?');
        $uri = $pos !== FALSE ? substr($uri, 0, $pos) : $uri;
    }
    $qry = isset($url['query']) ? $url['query'] : '';
    $svc = $_SERVER['SCRIPT_NAME'];
    if (isset($svc[0])) {
        $dir = str_replace('\\', '/', dirname($svc));
        if ($dir != '/') {
            if (strpos($uri, $svc) === 0) {
                $uri = (string) substr($uri, strlen($svc));
            } else {
                if (strpos($uri, $dir) === 0) {
                    $uri = (string) substr($uri, strlen($dir));
                }
            }
        }
    }
    if (trim($uri, '/') === '' && strncmp($qry, '/', 1) === 0) {
        $tmp = explode('?', $qry, 2);
        $uri = $tmp[0];
        $_SERVER['QUERY_STRING'] = isset($tmp[1]) ? $tmp[1] : '';
    } else {
        $_SERVER['QUERY_STRING'] = $qry;
    }
    parse_str($_SERVER['QUERY_STRING'], $_GET);
    if ($uri == '') {
        $uri = '/';
    }
    set_var('uri', $uri);
    set_var('qry', $qry);
    $segments = uri_segments();
    $segments = array_pad($segments, 1, '');
    $module = $segments[0];
    if ($uri == '/') {
        $segments = explode('/', get_config('default'));
        $segments = array_pad($segments, 1, '');
        $module = $segments[0];
    }
    $layout = 'main.php';
    if ($module != '') {
        $module = init_module($module);
        if ($module) {
            $layout = $module->layout . '.php';
            $page = array_shift($segments);
            while (count($segments) > 0) {
                $path = implode('/', $segments);
                if (file_exists($module->path . $path . '.php')) {
                    $page = $path;
                    break;
                }
                array_pop($segments);
            }
            if (empty($page) || !file_exists($module->path . $page . '.php')) {
                $page = $module->name;
            }
            $page = $module->path . $page . '.php';
            set_content('file', $page);
        }
    }
    if (!is_ajax()) {
        include BASEPATH . 'layouts/' . $layout;
    } else {
        echo get_content();
    }
}