*/ if (!empty($_SESSION[WW_SESS]['guest']) && $_SESSION[WW_SESS]['level'] == 'contributor') { $_GET['author_id'] = $_SESSION[WW_SESS]['user_id']; } $articles = get_articles_admin(); $total_articles = !empty($articles) ? $articles[0]['total_found'] : 0; $total_pages = !empty($articles) ? $articles[0]['total_pages'] : 0; // per page - same definition as list_admin_articles() $per_page = !isset($_GET['per_page']) || empty($_GET['per_page']) ? 15 : (int) $_GET['per_page']; // sub header text $title_text = array(); $status = ''; // category if (isset($_GET['category_id'])) { $title_text[] = " filed under " . get_category_title($_GET['category_id']); $sub_header_text[] = get_category_title($_GET['category_id']); } // author if (isset($_GET['author_id'])) { $title_text[] = " by " . get_author_name($_GET['author_id']); $sub_header_text[] = 'author: ' . get_author_name($_GET['author_id']); } // tag if (isset($_GET['tag_id'])) { $title_text[] = " tagged " . get_tag_title($_GET['tag_id']); $sub_header_text[] = 'tag: ' . get_tag_title($_GET['tag_id']); } // postdated if (isset($_GET['postdated'])) { $status = ' postdated'; }
?> ">查看全文</a></span> <span class="pull-right"> <span class="author"><?php echo get_username($article["uid"]); ?> </span> <span>于 <?php echo date('Y-m-d H:i', $article["create_time"]); ?> </span> 发表在 <span> <a href="<?php echo U('Article/lists?category=' . get_category_name($article['category_id'])); ?> "><?php echo get_category_title($article["category_id"]); ?> </a></span> ( 阅读:<?php echo $article["view"]; ?> ) </span> </div> <hr/><?php } } } else { echo ""; } ?>
?> ">查看全文</a></span> <span class="pull-right"> <span class="author"><?php echo get_username($list["uid"]); ?> </span> <span>于 <?php echo date('Y-m-d H:i', $list["create_time"]); ?> </span> 发表在 <span> <a href="<?php echo U('Article/lists?category=' . get_category_name($list['category_id'])); ?> "><?php echo get_category_title($list["category_id"]); ?> </a></span> <span>阅读(<?php echo $list["view"]; ?> )</span> </span> </div> <hr/><?php } } } else { echo ""; } ?>
if ($row['visibility'] == 'public') { $html_content .= '<a href="view_snippet.php?id=' . $row['id'] . '" class="list-group-item"><span class="snippet-title">' . $row['name'] . '</span><span class="by-creator"> by <strong>' . get_username($row['user_id']) . '</strong></span> · <span class="created-date">' . get_timeago($row['updated_time']) . '</span></a>'; } } } $html_content .= '</div>'; } else { $html_content = '<div class="alert alert-warning" role="alert"><span class="label label-warning">OOPS..</span> No available snippet found under this category.</div>'; } } } else { // ID not numeric header('Location: 404.php?error=invalid_category'); exit; } $category_title = get_category_title($snippet_cat); $category_color = get_category_color($snippet_cat); ?> <!DOCTYPE html> <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title><?php
$html_content = '<div class="list-group snippet-list">'; foreach ($results as $row) { $html_content .= '<a href="view_snippet.php?id=' . $row['id'] . '" class="list-group-item"><span class="snippet-title">' . $row['name'] . '</span> <span class="label ' . get_category_color($row['category_tag']) . '">' . get_category_title($row['category_tag']) . '</span> · <span class="created-date">updated ' . get_timeago($row['updated_time']) . '</span></a>'; } $html_content .= '</div>'; } else { // empty cat $html_content = 'Oops.. you don\'t have any snippet saved here yet. Why not <a href="add_snippet.php">submit one</a>?'; } $query2 = "SELECT * FROM " . DBTABLE_SNIPPETS . " WHERE user_id='" . $user_loggedin_id . "' AND visibility='private'"; $total_found2 = $db->num_rows($query2); if ($total_found2 > 0) { $results2 = $db->get_results($query2); $html_content2 = '<div class="list-group snippet-list">'; foreach ($results2 as $row2) { $html_content2 .= '<a href="view_snippet.php?id=' . $row2['id'] . '" class="list-group-item"><span class="snippet-title">' . $row2['name'] . '</span> <span class="label ' . get_category_color($row2['category_tag']) . '">' . get_category_title($row2['category_tag']) . '</span> · <span class="created-date">updated ' . get_timeago($row2['updated_time']) . '</span></a>'; } $html_content2 .= '</div>'; } else { // empty cat $html_content2 = 'Oops.. you don\'t have any snippet saved here yet. Why not <a href="add_snippet.php">submit one</a>?'; } $query3 = "SELECT * FROM " . DBTABLE_SNIPPETS . " WHERE user_id='" . $user_loggedin_id . "'"; $total_found3 = $db->num_rows($query3); $html_content3 = '<div class="alert alert-info" role="alert"><span class="label label-info">INFO</span> You have <strong>' . $total_found3 . '</strong> snippets in total; <em>' . $total_found . ' public snippets</em> and <em>' . $total_found2 . ' private snippets</em>.</div>'; ?> <!DOCTYPE html> <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
$user_loggedin_id = get_userid($loggedInUser); $authenticated = true; } if (isset($_GET['id']) && !empty($_GET['id']) && is_numeric($_GET['id'])) { $db = DB::getInstance(); $snippet_id = $db->filter($_GET['id']); $query = "SELECT user_id, category_tag, name, visibility, description, snippet, created_time, updated_time, view_count FROM " . DBTABLE_SNIPPETS . " WHERE id='" . $snippet_id . "'"; if ($db->num_rows($query) > 0) { list($user_id, $category_tag, $name, $visibility, $description, $snippet, $created_time, $updated_time, $view_count) = $db->get_row($query); if ($visibility == 'private' && $user_id != $user_loggedin_id) { // Visibility is private AND logged in user is not the owner of the snippet header('Location: 404.php?error=user_not_owner'); } else { $snippet_user_id = $user_id; $snippet_name = $name; $snippet_cat = get_category_title($category_tag); $snippet_cat_color = get_category_color($category_tag); $snippet_desc = $description; if ($snippet_cat == 'plain-text') { $snippet_output = '<div id="plainOutput"><pre class="plain"><code>' . $snippet . '</code></pre></div>'; } else { $snippet_output = '<div id="codeOutput"><pre class="highlighted"><code>' . $snippet . '</code></pre></div>'; } $snippet_created_time = get_timeago($created_time); $snippet_updated_time = get_timeago($updated_time); $snippet_creator = get_username($user_id); $snippet_view_count = $view_count + 1; snippet_view_increment($snippet_id, $snippet_view_count); } } else { // ID not found
} else { $html_content = '<div class="alert alert-warning" role="alert"><span class="label label-warning">OOPS..</span> No available snippet found.</div>'; } } else { // authenticated == true $query = "SELECT * FROM " . DBTABLE_SNIPPETS . " ORDER BY view_count DESC LIMIT 20"; $total_found = $db->num_rows($query); if ($total_found > 0) { $results = $db->get_results($query); $html_content = '<div class="list-group snippet-list">'; foreach ($results as $row) { if ($row['visibility'] == 'private' && $row['user_id'] == $user_loggedin_id) { $html_content .= '<a href="view_snippet.php?id=' . $row['id'] . '" class="list-group-item"><span class="snippet-title">' . $row['name'] . '</span> <span class="label ' . get_category_color($row['category_tag']) . '">' . get_category_title($row['category_tag']) . '</span> · <span class="by-creator"> by <strong>' . get_username($row['user_id']) . '</strong></span> · <span class="created-date">updated ' . get_timeago($row['updated_time']) . '</span> · <span class="view-counter">' . $row['view_count'] . ' views</span><br><span class="private-snippet"><i class="fa fa-info-circle"></i> This is your private snippet. Only you can see this!</span></a>'; } else { if ($row['visibility'] == 'public') { $html_content .= '<a href="view_snippet.php?id=' . $row['id'] . '" class="list-group-item"><span class="snippet-title">' . $row['name'] . '</span> <span class="label ' . get_category_color($row['category_tag']) . '">' . get_category_title($row['category_tag']) . '</span> · <span class="by-creator"> by <strong>' . get_username($row['user_id']) . '</strong></span> · <span class="created-date">updated ' . get_timeago($row['updated_time']) . '</span> · <span class="view-counter">' . $row['view_count'] . ' views</span></a>'; } } } $html_content .= '</div>'; } else { $html_content = '<div class="alert alert-warning" role="alert"><span class="label label-warning">OOPS..</span> No available snippet found.</div>'; } } ?> <!DOCTYPE html> <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> <!--[if gt IE 8]><!-->
include_once WW_ROOT . '/ww_config/model_functions.php'; include_once WW_ROOT . '/ww_config/combined_functions.php'; include_once WW_ROOT . '/ww_config/controller_functions.php'; include_once WW_ROOT . '/ww_config/view_functions.php'; // get article data // debug_array($_POST); $article = stripslashes_deep($_POST); $article['id'] = isset($_POST['article_id']) ? $_POST['article_id'] : 0; $article['url'] = isset($_POST['url']) ? $_POST['url'] : 'temp_url_title'; $article['date_uploaded'] = isset($_POST['date_uploaded']) ? $_POST['date_uploaded'] : date('Y-m-d H:i:s'); $article['date_ts'] = strtotime($article['date_uploaded']); // get author name $article['author_name'] = get_author_name($article['author_id']); $article['author_url'] = 'temp'; // get category name $article['category_title'] = get_category_title($article['category_id']); $article['category_url'] = 'temp'; // comments and other fields $article['comments_hide'] = 1; $article['comments_disable'] = 1; $article['total_pages'] = 1; $article['pages'] = 1; $article['tags'] = ''; $article['attachments'] = ''; $article['comments'] = ''; // page name $_GET['page_name'] = 'article'; // get content partial - checking for theme versions as well $theme_content_folder = WW_ROOT . '/ww_view/themes' . $config['site']['theme'] . '/_content'; $content_partial = file_exists($theme_content_folder . '/_article.php') ? $theme_content_folder . '/_article.php' : WW_ROOT . '/ww_view/_content/_article.php'; if (file_exists($theme_content_folder . '/_header.php')) {
"><?php echo $data["title"]; ?> </a></h3> </div> <div> <span class="author"><?php echo get_username($data["uid"]); ?> </span> <span>于 <?php echo date('Y-m-d H:i', $data["create_time"]); ?> </span> 发表在 <span><a href=""><?php echo get_category_title($data["category_id"]); ?> </a></span> <span>阅读(<?php echo $data["view"]; ?> )</span> </div> <hr/><?php } } } else { echo ""; } ?>
<?php // generate text for meta tags, page title and headers /* this is a cut down version of the default code in ww_view/_content/_listing.php */ $title_text = array(); $sub_header_text = array(); if (!empty($_GET['search'])) { $config['site']['meta_title'] = 'Search results for "' . $_GET['search'] . '" - ' . $config['site']['title']; $config['site']['meta']['description'] = 'Search results for ' . $_GET['search'] . ' on ' . $config['site']['meta_title']; $config['site']['meta']['keywords'] = $_GET['search']; $title_text[] = 'containing the term "' . $_GET['search'] . '"'; } else { // what are we looking for? // category if (isset($_GET['category_id']) && isset($_GET['category_url'])) { $title_text[] = "category: " . get_category_title($_GET['category_id']); } // author if (isset($_GET['author_id']) && isset($_GET['author_url'])) { $title_text[] = "author: " . get_author_name($_GET['author_id']); } // tag if (isset($_GET['tag_id']) && isset($_GET['tag_url'])) { $title_text[] = "tagged " . get_tag_title($_GET['tag_id']); } // date if (isset($_GET['year'])) { if (isset($_GET['day'])) { $query_ts = strtotime($_GET['year'] . '-' . $_GET['month'] . '-' . $_GET['day']); $title_text[] = "date: " . date('d M Y', $query_ts); } elseif (isset($_GET['month'])) {