<?php include_once dirname(__FILE__) . "/../configs.php"; $success = false; $message = ""; $logged_in = ManagerActions::isLoggedIn(); if ($logged_in && isset($_POST["json"])) { $json = json_decode($_POST['json'], true); $id = trim(strip_tags($json["id"])); $post_data = $json["post_data"]; if (count($post_data > 0)) { try { $db = MongoConnection(); $db_getter = new MongoGetter($db); $db_getter->updateSinglePostDataById($id, $post_data); $success = true; $message = "Post Edited"; } catch (MongoCursorException $e) { $message = "error message: " . $e->getMessage() . "\n"; } } } echo returnMessage($success, $message, null);
<?php include_once dirname(__FILE__) . "/../configs.php"; if (isset($_GET["id"]) && isset($_GET["cat"])) { $id = $_GET["id"]; $cat = $_GET["cat"]; try { $db = MongoConnection(); $db_getter = new MongoGetter($db); $post_data = $db_getter->getSingleRowById($id); if ($post_data !== NULL) { //post is found $post_cat = in_array($cat, $post_data["category"]) ? $cat : $post_data["category"][0]; //it is possible the post is no longer part of the given cat so check if it is and if it is not give the post a cat it belongs to $post_data["show_id"] = true; //make id visable $parse_down = new Parsedown(); $post_views = new PostViews($parse_down); $post_template = file_get_contents($GLOBALS['template_dir'] . "/blog_post.txt"); echo $post_views->makePostHtmlFromData($post_data, $post_cat, $post_template); } } catch (MongoCursorException $e) { //echo "error message: ".$e->getMessage()."\n"; } }
<?php include_once dirname(__FILE__) . "/../../configs.php"; $holder = array(); if (isset($_POST['json'])) { $db = MongoConnection(); $db_getter = new MongoGetter($db); $json = json_decode($_POST['json'], true); $url = $json['url']; //$start_date = new DateTime( $json['start_date'] ); //$end_date = new DateTime( $json['end_date'] ); //$start = $start_date->format( DateTime::ISO8601 ); //$end = $end_date->format( DateTime::ISO8601 ); $start = strtotime($json['start_date']); $end = strtotime($json['end_date']); $data = $db_getter->getPageCountsByUrlAndDateRange($url, $start, $end); foreach ($data as $row) { $tmp = array(); $sec = $row["date"]->sec; $dt = new DateTime("@{$sec}"); $tmp['date'] = $dt->format('m/d/Y'); $tmp['views'] = $row['views']; $tmp['unique'] = count($row["ips"]); array_push($holder, $tmp); } } echo json_encode($holder);
<?php include_once dirname(__FILE__) . "/../configs.php"; $json = json_decode($_POST['json'], true); $id = $json["id"]; $db = MongoConnection(); $db_getter = new MongoGetter($db); $data = $db_getter->getSinglePostDataById($id); $ret = json_encode($data["post_data"]); echo $ret;
<?php include_once dirname(__FILE__) . "/../configs.php"; if (isset($_GET["cat"]) && isset($_GET["ts"])) { $time = floatval($_GET["ts"]); $time_stamp = $time / 1000; //js use milliseconds mongo uses seconds convert milliseconds to seconds $cat = $_GET['cat']; try { $db = MongoConnection(); $db_getter = new MongoGetter($db); $post_data = $db_getter->getPreviousPostsFromTimestamp($cat, $time_stamp); $post_template = file_get_contents($GLOBALS['template_dir'] . "/next_post_button.txt"); foreach ($post_data as $posting) { $post_view = new PostViews(new Parsedown()); echo $post_view->getNextPostButton($posting, $cat, $post_template); } } catch (MongoCursorException $e) { echo "error message: " . $e->getMessage() . "\n"; } }
<?php include_once dirname(__FILE__) . "/../configs.php"; $page_num = $_GET["p"]; $cat = $_GET["cat"]; if (true) { try { $db = MongoConnection(); $db_getter = new MongoGetter($db); if (strlen($cat) === 0 && isset($_GET["search"])) { $search = $_GET["search"]; $cursor = $db_getter->getPostsFromDbBySearch($page_num, $search); } else { $cursor = $db_getter->getBlogManagePosts($page_num, $cat); } $posts = iterator_to_array($cursor); if (count($posts) > $GLOBALS['amount_on_manger_tab']) { array_pop($posts); $next = true; } else { $next = false; } $parsedown = new Parsedown(); $post_views = new PostViews($parsedown); $modified_array = array(); $post_template = file_get_contents($GLOBALS['template_dir'] . "/blog_post.txt"); foreach ($posts as $row) { $post_cat = strlen($cat) > 0 ? $cat : $row["category"][0]; //when viewing all posts/search cat will be empty string so use base cat $modified_row = $post_views->generateModifedListingForPostInfo($row, $post_cat); $row["show_id"] = true;
*/ $server = dirname(__FILE__) . "/../"; include_once $server . "/configs.php"; if (count($GLOBALS['url_parts']) === 6) { $base = $GLOBALS['base_url']; $cat = $GLOBALS['url_parts'][1]; $year = $GLOBALS['url_parts'][2]; $month = $GLOBALS['url_parts'][3]; $date = $GLOBALS['url_parts'][4]; $title = $GLOBALS['url_parts'][5]; $initial_date = "{$year}-{$month}-{$date}"; $start = strtotime($initial_date); $end = strtotime("{$initial_date}+23 hours 59 minutes 59 seconds"); try { $db = MongoConnection(); $db_getter = new MongoGetter($db); $post_views = new PostViews(new Parsedown()); $non_hyphenated_title = $post_views->convertPostTitleHyphensToSpaces($title); $single_post_data = $db_getter->getSingleRowFromDate($non_hyphenated_title, $start, $end); //NULL if not found $page_template = file_get_contents($GLOBALS['template_dir'] . "/base_page.txt"); $post_template = file_get_contents($GLOBALS['template_dir'] . "/blog_post.txt"); if ($single_post_data !== NULL) { $tmplt_data = array(); $tmplt_data["title"] = $single_post_data["title"] . " - " . $_SERVER['HTTP_HOST']; $tmplt_data["description"] = $single_post_data["description"]; $tmplt_data["styles"] = ""; $tmplt_data["scripts"] = "<script src='/scripts/page_actions/post_actions.js' ></script>"; $tmplt_data["base"] = $base; $tmplt_data["header"] = $post_views->getCatHeaderList($cat); $tmplt_data["category"] = $cat;
<?php include_once dirname(__FILE__) . "/../configs.php"; $result = false; $message = "Not Logged In"; $logged_in = ManagerActions::isLoggedIn(); if ($logged_in) { $json = json_decode($_POST['json'], true); $id = $json["id"]; try { $db = MongoConnection(); $db_getter = new MongoGetter($db); $deleted = $db_getter->removeSingleRowById($id); $result = true; $message = 'Deleted'; } catch (MongoCursorException $e) { $message = "error message: " . $e->getMessage() . "\n"; } } echo returnMessage($result, $message, null);
<?php include_once dirname(__FILE__) . "/../configs.php"; $success = false; $message = ""; $logged_in = ManagerActions::isLoggedIn(); if ($logged_in && isset($_POST["json"])) { $json = json_decode($_POST['json'], true); $id = trim(strip_tags($json["id"])); try { $db = MongoConnection(); $db_getter = new MongoGetter($db); $result = $db_getter->renewPostDate($id); $success = $result['nModified'] === 1 ? true : false; $message = $success ? "Post Moved To Top" : "Could not update post with id " . $id; } catch (MongoCursorException $e) { $message = "error message: " . $e->getMessage() . "\n"; } } echo returnMessage($success, $message, null);
<?php include_once dirname(__FILE__) . "/../../configs.php"; $success = false; $message = ""; if (true) { $db = MongoConnection(); $db_getter = new MongoGetter($db); $data = $db_getter->getUniqueAnalyticUrlPage(); $list = ""; foreach ($data as $url) { $list .= "<li data-url=" . $url . " onclick='urlClickAction(this)' >" . $url . "</li>"; } } echo $list;