function q_header($database, &$array) { $dk = 1; $search = 0; $orderby = 'ORDER BY post_on DESC'; $limit = ' LIMIT 0, 10 '; if (!empty($_GET['post_permalink'])) { $value = addslashes($_GET['post_permalink']); $dk = array('post_permalink' => $value); } if (!empty($_GET['cat_permalink'])) { $value = addslashes($_GET['cat_permalink']); $dk = array('cat_permalink' => $value); } if (!empty($_GET['author'])) { $value = addslashes($_GET['author']); $dk = array('user_name' => $value); } if (!empty($_GET['search'])) { $search = 1; $value = addslashes($_GET['search']); $dk = array('post_name' => $value); } $post = new post($database); $post->have_posts($dk, $search, $orderby, $limit); if (isset($post->r)) { if (mysqli_num_rows($post->r) > 0) { while ($m = mysqli_fetch_array($post->r, MYSQLI_ASSOC)) { $array[] = $m; } } } // print_r($array); }
public function adminNotify() { if ($this->cookie->check("id_user") and $this->cookie->id_user == 1) { //no notificamos a administrador de su propio comentario. return; } $id = $this->registry->lastCommentID; $Comment = new comment(); $comment = $Comment->find($id); $comment['content'] = utils::nl2br($comment['content']); if (!defined('GESHI_VERSION')) { $comment['content'] = $this->comment_source_code_beautifier($comment['content'], 'addTagPRE'); } else { $comment['content'] = $this->comment_source_code_beautifier($comment['content']); } $User = new user(); $user = $User->find(1); $Post = new post(); $post = $Post->find($comment['ID_post']); $commentsWaiting = $Comment->countCommentsByPost(null, 'waiting'); $mailStr = "\n\t\t\t<table width=\"100%\">\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<small>\n\t\t\t\t\t\t<strong>From IP</strong>: {$comment['IP']}<br />\n\t\t\t\t\t\t<strong>URL</strong>: <a href=\"{$comment['url']}\">{$comment['url']}</a><br />\n\t\t\t\t\t\t<strong>Email</strong>: <a href=\"mailto:{$comment['email']}\">{$comment['email']}</a><br />\n\t\t\t\t\t\t<strong>DateTime</strong>: {$comment['created']}<br />\n\t\t\t\t\t</small>\n\t\t\t\t\t<hr>\n\t\t\t\t\t<strong>Author</strong>: {$comment['author']}<br />\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t\n\t\t\t<tr><td><strong>Content</strong></td></tr>\n\t\t\t<tr><td bgcolor=\"#f7f7f7\">\n\t\t\t\t{$comment['content']}\n\t\t\t\t<hr />\n\t\t\t</td></tr>\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<p>\n\t\t\t\t\t\tModerate comment: <a href=\"{$this->registry->path}comments/edit/{$comment['ID']}\">{$this->registry->path}comments/edit/{$comment['ID']}</a><br />\n\t\t\t\t\t\tView entry: <a href=\"{$this->registry->path}{$post['urlfriendly']}\">{$this->registry->path}{$post['urlfriendly']}</a>\n\t\t\t\t\t</p>\n\t\t\n\t\t\t\t\t<p>\n\t\t\t\t\t\tThere are {$commentsWaiting} comments waiting for approbal. <br />\n\t\t\t\t\t\tPlease moderate comments: <a href=\"{$this->registry->path}comments/waiting\">{$this->registry->path}comments</a>\n\t\t\t\t\t</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t\n\t\t\t</table>\n\t\t"; $conf = $this->registry->conf; $subject = "[{$conf['blog_name']}] Nuevo Comentario en: {$post['title']}"; $this->enviaMail($user['email'], $subject, $mailStr, $user['email']); }
public function getPosts($status = null, $limitQuery = null) { $P = new post(); $posts = array(); if (is_null($status) === true) { $posts = $P->findAll("ID,id_user,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", 'ID DESC', $limitQuery, null); } else { if (is_array($status) === false) { $posts = $P->findAll("ID,id_user,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", 'ID DESC', $limitQuery, "WHERE status='{$status}'"); } else { $status_sql = ""; foreach ($status as $st) { $status_sql .= "status ='{$st}' OR "; } $status_sql = substr($status_sql, 0, -3); $posts = $P->findAll("ID,id_user,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", 'ID DESC', $limitQuery, "WHERE ({$status_sql})"); } } $C = new comment(); foreach ($posts as $k => $p) { $posts[$k]['title'] = htmlspecialchars($posts[$k]['title']); $posts[$k]['tags'] = $this->getTags($posts[$k]['ID']); $posts[$k]['comments_count'] = $C->countCommentsByPost($posts[$k]['ID'], "publish"); $U = new user(); if ($posts[$k]['id_user'] < 2) { $posts[$k]['autor'] = $U->find(1); } else { $posts[$k]['autor'] = $U->find($posts[$k]['id_user']); } } return $posts; }
/** * Create a post */ public static function createPost() { if (!Flight::has('currentUser')) { Flight::redirect('/'); } $post = new post(['user' => Flight::get('currentUser')->id, 'title' => Flight::request()->data->title, 'content' => Flight::request()->data->content]); $post->store(); }
function getPosts($dbh) { $stmt = $dbh->prepare("select * from " . post::$table_name . " ORDER BY id DESC;"); $stmt->execute(); $result = array(); while ($row = $stmt->fetch()) { $p = new post(); $p->copyFromRow($row); $result[] = $p; } return $result; }
public function posts_of_user($orderby = 'ORDER BY post_on DESC', $limit = 0) { if ($this->is_admin()) { $post = new post($this->db); $post->posts_of_user(array('user_id' => $this->user_id), 0, $orderby, $limit); if (mysqli_num_rows($post->r) > 0) { $this->post = $post->r; return true; } else { return false; } } else { return false; } }
public function rss($id = NULL) { $this->plugin->call('feed_header'); $post = new post(); $this->view->conf = $this->conf; $this->view->setLayout("feed"); $posts = $post->findAll("ID,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", "ID DESC", $this->conf['blog_posts_per_page'], "WHERE status = 'publish'"); $temp = array(); foreach ($posts as $a_post) { $temp[$a_post['ID']] = $a_post; $temp[$a_post['ID']]['tags'] = $post->getTags($a_post['ID'], 'string'); } $this->view->posts = $temp; $this->render("rss"); }
function __construct() { $this->session = session::getInstance(); $this->post = post::getInstance(); $this->get = get::getInstance(); $this->http = http::getInstance(); $this->file = new file(); $this->cookie = new cookie(config('cookie')); }
function __construct() { $this->session = session::getInstance(); $this->post = post::getInstance(); $this->get = get::getInstance(); $this->http = http::getInstance(); $this->file = file::getInstance(); $this->cookie = cookie::getInstance(); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(PostEditFormRequest $request, $id) { //Actualiza un post $post = post::whereId($id)->firstOrFail(); $post->title = $request->get('title'); $post->content = $request->get('content'); $post->slug = Str::slug($request->get('title'), '-'); $post->save(); $post->categories()->sync($request->get('categories')); return redirect(action('Admin\\PostsController@edit', $post->id))->with('status', 'The post has been updated!'); }
public function submit() { $post = $_POST; $file = $_FILES['file_upload']; $request = new post($post, $file); $submission = $request->getPost(); $database = new database(); $query = $database->query(); $image = new image($query, $submission); // upload image try { $upload = $image->upload(); } catch (Exception $e) { echo 'Message: ' . $e->getMessage(); } // insert image if (isset($upload) && $upload == 'success') { $images = new image($query, $submission); $image->insert(); } }
public function edit($id = NULL) { $id = (int) $id; if (!$id) { $this->redirect('comments'); } $this->view->conf = $this->conf; $Comment = new comment(); $comment = $Comment->find($id); $comment['content'] = utils::convert2HTML($comment['content']); $Post = new post(); $post = $Post->findBy('ID', $comment['ID_post']); $comment['post'] = array('urlfriendly' => $post['urlfriendly'], 'title' => $post['title']); $this->view->comment = $comment; $this->view->id = $id; $statuses = array("publish", "waiting"); $this->view->statuses = $statuses; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (isset($_POST['cancelar'])) { $this->redirect("comments"); } else { ########### # Las siguientes dos lineas no deberian estar pero algo anda mal con el ActiveRecord que no deja las variables # de las consultas que se realizan directamente desde dentro de algun metodo en el model con $this->db->query e interfiere # con el actualizar por que podria haber campos que no se requieren en la actualizacion. ########### $comment = new comment(); ####### $comment->find($id); ####### $comment->prepareFromArray($_POST); $comment->save(); $this->redirect("comments/edit/{$id}"); } } else { $this->view->setLayout("admin"); $this->title_for_layout($this->l10n->__("Editar comentario - Codice CMS")); $this->render(); } }
/** * Load post from database. Returns false, if the post doesn't exist * @param int $post_id * @return boolean|Gn36\OoPostingApi\post */ static function get($post_id) { global $db; $sql = "SELECT * FROM " . POSTS_TABLE . " WHERE post_id=" . intval($post_id); $result = $db->sql_query($sql); $post_data = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$post_data) { //post does not exist, return false return false; } return post::from_array($post_data); }
public function index($id = NULL, $page = 1) { if (is_null($id) or is_numeric($id)) { $this->redirect($this->conf['blog_siteurl']); } $tag = $id; $post = new post(); $link = new link(); $comment = new comment(); $this->html->useTheme($this->conf['blog_current_theme']); $info = array(); $info["isAdmin"] = false; if ($this->cookie->check("logged") and $this->cookie->id_user == 1) { $info["isAdmin"] = true; } $this->themes->info = $info; $includes['charset'] = $this->html->charsetTag("UTF-8"); $includes['rssFeed'] = $this->html->includeRSS(); if ($page > 1) { $includes['canonical'] = "<link rel=\"canonical\" href=\"{$this->conf['blog_siteurl']}/tag/" . rawurlencode($post->sql_escape($id)) . "/{$page}\" />"; } else { $includes['canonical'] = "<link rel=\"canonical\" href=\"{$this->conf['blog_siteurl']}/tag/" . rawurlencode($post->sql_escape($id)) . "\" />"; } $this->registry->includes = $includes; $this->plugin->call('index_includes'); $includes = null; foreach ($this->registry->includes as $include) { $includes .= $include; } $this->themes->includes = $includes; $this->themes->links = $link->findAll(); $this->themes->single = false; $total_rows = $post->countPosts(array('status' => 'publish', 'tag' => $tag)); $page = (int) is_null($page) ? 1 : $page; $limit = $this->conf['blog_posts_per_page']; $offset = ($page - 1) * $limit; $limitQuery = $offset . "," . $limit; $targetpage = $this->path . "tag/{$tag}/"; $this->themes->pagination = $this->pagination->init($total_rows, $page, $limit, $targetpage); $posts = $post->getPostsByTag($tag, $limitQuery); foreach ($posts as $k => $p) { $posts[$k]['title'] = htmlspecialchars($p['title']); $posts[$k]['tags'] = $post->getTags($p['ID']); $posts[$k]['comments_count'] = $comment->countCommentsByPost($posts[$k]['ID']); $user = new user(); if ($posts[$k]['id_user'] < 2) { $posts[$k]['autor'] = $user->find(1); } else { $posts[$k]['autor'] = $user->find($posts[$k]['id_user']); } } $this->registry->posts = $posts; $this->plugin->call("index_post_content"); $this->themes->posts = $this->registry->posts; $this->themes->title_for_layout = "{$this->conf['blog_name']} - {$tag}"; $this->render(); }
<?php //number of comments/page $limit = 10; //number of pages to display. number - 1. ex: for 5 value should be 4 $page_limit = 6; //Load required class files. post.class and cache.class $post = new post(); $cache = new cache(); header("Cache-Control: store, cache"); header("Pragma: cache"); $domain = $cache->select_domain(); $id = $db->real_escape_string($_GET['id']); if (!is_numeric($id)) { $id = str_replace("#", "", $id); } $id = (int) $id; $date = date("Ymd"); //Load post_table data and the previous next values in array. 0 previous, 1 next. $post_data = $post->show($id); //Check if data exists in array, if so, kinda ignore it. if ($post_data == "" || is_null($post_data)) { header('Location: index.php?page=post&s=list'); exit; } $prev_next = $post->prev_next($id); if (!is_dir("{$main_cache_dir}" . "" . "\\cache/{$id}")) { $cache->create_page_cache("cache/{$id}"); } $data = $cache->load("cache/" . $id . "/post.cache"); if ($data !== false) {
ini_set('error_log', NULL); ini_set('max_execution_time', 0); ini_set('log_errors', 0); require_once "./config.php"; require_once "./geshi/geshi.php"; require_once "./class/utilities_class.php"; require_once "./class/phpfiglet_class.php"; require_once "./class/mybb_class.php"; require_once "./class/html_class.php"; require_once "./class/cookie_class.php"; require_once "./class/admin_class.php"; require_once "./class/post_class.php"; /* * Create instance of all available Class object */ $post_inst = new post(); $phpFiglet = new phpFiglet(); $inst_post = new mybb_style(); $htmlinst = new html(); $admin = new adminclass(); $util = new utilities(); $cook = new cookie(); /* * Check if sqlite database file is not existed * If yes, then redirect to create.php */ if (sqlite_file == '' || !file_exists(sqlite_file)) { $htmlinst->change_location("./create.php"); } $_SERVER['REMOTE_ADDR'] = $util->get_client_ip($_SERVER); $phpFiglet->loadFont("./figlet/spliff.flf");
<h5>' . $note['postTitle']; if ($note['imp'] == 1) { $content .= '<span class="imp">Imp</span>'; } $content .= ' </h5> <span>' . $note['class'] . ' | ' . $note['facultyName'] . ' | ' . $note['subjectName'] . '</span> </div> <div class="cleaner"></div> </div> </a>'; } } } } else { $questions = post::all(1, $postTypId); if (!$questions) { die($e); } else { if ($questions == 'empty') { $title = 'No Question posted'; $titleBar = 'Questions'; $content = '<center><img src="' . $website . 'assets/img/smile_face.png" /><br /><p style="color:#AAA;font-size:1.5em;">No Questions to Show</p></center>'; } else { $title = 'Questions'; $titleBar = $title; $content = ''; foreach ($questions as $note) { $dateArray = getdate(strtotime($note['postDate'])); $content .= ' <a href="' . generate_link($note['postTitle'], $note['postId']) . '" class="pl-anchor">
$this->db1->query("UPDATE users SET active=" . $status . " WHERE iduser="******" LIMIT 1"); $txtreturn = $this->lang('admin_txt_msgok'); echo '1: ' . $txtreturn; return; } if ($action == 2) { $this->db1->query("UPDATE users SET leveladmin=" . $levelnivel . ", is_network_admin=" . $level . " WHERE iduser="******" LIMIT 1"); $txtreturn = $this->lang('admin_txt_msgok'); echo '1: ' . $txtreturn; return; } if ($action == 3) { // look for the ids of albums $allposts = $this->network->getPostsUser($uid); foreach ($allposts as $onepost) { $onepost = new post($onepost->code); $onepost->deletePost(); unset($onepost); } $this->db1->query("DELETE FROM activities WHERE iduser="******"DELETE FROM chat WHERE id_from=" . $uid . " OR id_to=" . $uid); /*****************/ $r = $this->db2->fetch_all('SELECT idpost FROM comments WHERE iduser='******'SELECT idpost FROM likes WHERE iduser=' . $uid); foreach ($r as $oneitem) { $this->db1->query("UPDATE posts SET numlikes=numlikes-1 WHERE idpost=" . $oneitem->idpost);
} $theactivity = $this->db2->fetch("SELECT idpost, posts.iduser, posts.whendate, username, firstname, lastname, avatar, users.code as ucode FROM posts, users WHERE posts.code='" . $D->codpost . "' AND users.iduser=posts.iduser LIMIT 1"); if (!$theactivity) { $this->redirect($C->SITE_URL . $D->u->username); } $D->nameUser = empty($D->u->firstname) || empty($D->u->lastname) ? $D->u->username : $D->u->firstname . ' ' . $D->u->lastname; $D->htmlResult = ''; $D->userName = $theactivity->username; $D->nameUser = empty($theactivity->firstname) || empty($theactivity->lastname) ? $theactivity->username : $theactivity->firstname . ' ' . $theactivity->lastname; $D->userAvatar = $theactivity->avatar; $D->isThisUserVerified0 = $this->network->isUserVerified($theactivity->iduser); $D->a_date = $theactivity->whendate; $D->codeUser = $theactivity->ucode; $D->idpost = $theactivity->idpost; $D->codepost = $D->codpost; $onePost = new post($D->codepost); $D->idUser = $onePost->iduser; $D->typepost = $onePost->typepost; $D->numlikes = $onePost->numlikes; $D->numcommentstotal = $onePost->numcomments; $D->post = stripslashes($onePost->post); $D->typepost = $onePost->typepost; $D->valueattach = $onePost->valueattach; $D->idpostShared = $D->idpost; $D->isShare = 0; if ($D->typepost == 'share') { $infop = explode(':', $D->valueattach); $D->idpostShared = $infop[0]; $D->isShare = 1; } // see if the favorite is for the observer
if ($note['imp'] == 1) { $content .= '<span class="imp">Imp</span>'; } $content .= ' </h5> <span>' . $note['class'] . ' | ' . $note['facultyName'] . ' | ' . $note['subjectName'] . '</span> </div> <div class="cleaner"></div> </div> </a>'; } } } } else { //$notes = getPostList($postTypId); $notes = post::all(1, $postTypId); if (!$notes) { die($e); } else { if ($notes == 'empty') { $title = 'No Note posted'; $titleBar = 'Notes'; $content = '<center><img src="' . $website . 'assets/img/smile_face.png" /><br /><p style="color:#AAA;font-size:1.5em;">No Notes to Show</p></center>'; } else { $title = 'Notes'; $titleBar = $title; $content = ''; foreach ($notes as $note) { $dateArray = getdate(strtotime($note['postDate'])); $content .= ' <a href="' . generate_link($note['postTitle'], $note['postId']) . '" class="pl-anchor">
<?php date_default_timezone_set("Asia/Manila"); $date = date('Y-m-d H:i:s'); if (isset($_POST['btnpost'])) { include_once "post.php"; $param = array("postTitle" => $_POST["title"], "postDesc" => $_POST["desc"], "userID" => $_SESSION['id'], "topicID" => $_GET['topicid'], "datePosted" => $date, "postStatus" => 1, "postLevel" => $_SESSION['level']); $query = new post(); $query->create("tblpost", $param); } if (isset($_POST['btntopic'])) { include_once "topic.php"; $param = array("topicTitle" => $_POST["title"], "topicDesc" => $_POST["content"], "dateCreated" => $date, "forumCatID" => $_POST["cbocategory"], "topicStatus" => 1); $query = new topic(); $query->create("tbltopic", $param); } if (isset($_POST['btnreply'])) { include_once "post.php"; $param = array("replyContent" => $_POST["message"], "postID" => $_GET["postid"], "userID" => $_SESSION["id"], "datePosted" => $date, "replyLevel" => $_SESSION["level"], "replyStatus" => 1); $query = new post(); $query->add("tblreply", $param); }
<?php require '../../includes/config.php'; require '../../structure/database.php'; require '../../structure/forum.php'; require '../../structure/forum.post.php'; require '../../structure/base.php'; require '../../structure/user.php'; $database = new database($db_host, $db_name, $db_user, $db_password); $post = new post($database); $base = new base($database); $user = new user($database); $user->updateLastActive(); $username = $user->getUsername($_COOKIE['user'], 2); $rank = $user->getRank($username); //take action then log it if ($rank > 2) { $post->hidePost($_GET['pid'], $rank); } $base->appendToFile('../logs.txt', array($username . ' hid the post ' . $_GET['pid'])); $base->redirect('../viewthread.php?forum=' . $_GET['forum'] . '&id=' . $_GET['id'] . '&goto=' . $_GET['pid']);
echo '</feed>' . "\n"; return; } } $rss_title = $this->lang('rss_grpposts', array('#GROUP#' => htmlspecialchars($g->title))); $rss_altlink = $C->SITE_URL . $g->groupname; $q = 'SELECT *, "public" AS `type` FROM posts WHERE group_id="' . $g->id . '" AND (api_id=2 OR user_id<>0) ORDER BY id DESC LIMIT ' . $q_limit; } else { echo '</feed>' . "\n"; return; } $rss_dtupd = 0; $posts = array(); $r = $this->db2->query($q); while ($obj = $this->db2->fetch_object($r)) { $p = new post($obj->type, FALSE, $obj); if ($p->error) { continue; } $posts[] = $p; $rss_dtupd = max($rss_dtupd, $p->post_date); } echo "\t<title>" . $rss_title . " - " . $C->SITE_TITLE . "</title>\n"; echo "\t<subtitle>" . $rss_title . " - " . $C->SITE_TITLE . "</subtitle>\n"; echo "\t" . '<link href="' . $_SERVER['REQUEST_URI'] . '" rel="self" />' . "\n"; echo "\t" . '<link href="' . $rss_altlink . '" rel="alternate" type="text/html" />' . "\n"; echo "\t<id>tag:" . $C->DOMAIN . ',' . md5($_SERVER['REQUEST_URI']) . "</id>\n"; echo "\t<updated>" . date('c', $rss_dtupd) . "</updated>\n"; foreach ($posts as &$p) { if ($p->post_user->id == 0 && $p->post_group) { $title = $p->post_group->title;
echo htmlspecialchars($c->comment_user->fullname); ?> "><?php echo $c->comment_user->username; ?> </a></div> <p class="message"><?php echo nl2br($c->parse_text()); ?> </p> <div class="meta" style="padding-left:3px;"> <?php echo post::parse_date($c->comment_date); ?> <?php echo post::parse_api($c->comment_api_id); ?> </div> </div> <hr /> <?php } ?> <?php if ($D->cnum_pages > 1 && $D->cpg > 1 && $D->cpg < $D->cnum_pages) { ?> <div id="backnext"> <a href="<?php echo $D->post->permalink; ?> /cpg:<?php
<?php require "../includes/conf.inc.php"; require "../includes/functions.inc.php"; $sq = $_POST['search']; $sqn = sanitize_text($sq); $searchResult = post::searchPosts($sqn, ''); if ($searchResult == false) { echo $e; } else { if ($searchResult == 'empty') { echo '<span class="search-wait">No Results Found</span>'; } else { $srOutput = ''; foreach ($searchResult as $sr) { $srOutput .= '<a href="' . generate_link($sr['postTitle'], $sr['postId']) . '">' . $sr['postTitle'] . '</a>'; } echo $srOutput; } }
<!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <?php trait Shareable { public function share() { return "The name of the trait is: " . __TRAIT__; } } class post { use Shareable; } $post = new post(); echo $post->share(); ?> </body> </html>
<?php require 'components/get_listview_referrer.php'; require 'subclasses/post.php'; $dbh_post = new post(); $dbh_post->set_where("id='" . quote_smart($id) . "'"); if ($result = $dbh_post->make_query()->result) { $data = $result->fetch_assoc(); extract($data); $data = explode('-', $date); if (count($data) == 3) { $date_year = $data[0]; $date_month = $data[1]; $date_day = $data[2]; } }
public function remove($id) { $P = new post(); $P->find($id); $P->delete(); $this->redirect("admin/"); }
<?php $post = new post(); $cache = new cache(); header("Cache-Control: store, cache"); header("Pragma: cache"); $domain = $cache->select_domain(); if (isset($_GET['t']) && $_GET['t'] == 'json') { $api_type = 'json'; } else { $api_type = 'xml'; } if ($api_type == 'json') { header('Content-type: application/json'); } else { header('Content-type: text/xml'); } if (isset($_GET['id'])) { $id = $db->real_escape_string($_GET['id']); if (!is_numeric($id)) { $id = str_replace("#", "", $id); } $id = (int) $id; } else { if ($api_type == 'json') { print '{"offset":"0","count":"0",posts":[]}'; } else { print '<?xml version="1.0" encoding="UTF-8"?><posts offset="0" count="0"></posts>'; } exit; }
<?php require "../../includes/conf.inc.php"; require "../../includes/functions.inc.php"; if (isset($_POST['postTitle'])) { $adminId = $_SESSION['adminId']; $postTitle = $_POST['postTitle']; $postTypId = $_POST['postTypId']; $subjectId = $_POST['subjectId']; $imp = $_POST['imp']; $postText = $_POST['postText']; $postTitle = ucfirst(sanitize_text($postTitle)); $postText = trim(mysql_real_escape_string(stripslashes($postText))); if ($postTitle == '' || $postText == '') { //when any entry is empty $response = array('success' => 0, 'error' => 1, 'errorMsg' => 'Either Post Title Or Post Body is empty!'); } else { $newPost = array('postTitle' => $postTitle, 'postText' => $postText, 'subjectId' => $subjectId, 'postTypId' => $postTypId, 'adminId' => $adminId, 'statusId' => 2, 'imp' => $imp); if (!post::create($newPost)) { $response = array('success' => 0, 'error' => 2, 'errorMsg' => 'Opps! Something Went Wrong!'); } else { $response = array('success' => 1, 'error' => 0); } } /*$_SESSION['response'] = $response; header("location: add.php");*/ echo json_encode($response); }