$privacy = $_POST['privacy']; if (!is_numeric($id) || $privacy != "pub" && $privacy != "fri" && $privacy != "meo") { $OP->ser(); } if ($post == "") { $OP->ser("Post is Blank", "The post content was left blank. It is not allowed.", "json"); } $sql = $OP->dbh->prepare("UPDATE `posts` SET `post` = ?, `privacy` = ?, `time` = NOW() WHERE `id` = ? AND `uid` = ?"); $sql->execute(array($post, $privacy, $id, curUser)); if ($sql->rowCount() == 0) { $OP->ser("No changes was made", "Either you didn't make any changes or you're no the owner of this post"); } else { $sql = $OP->dbh->prepare("SELECT * FROM `posts` WHERE `id` = ?"); $sql->execute(array($id)); $postsArr = $sql->fetchAll(PDO::FETCH_ASSOC); $html = Render::post($postsArr); echo $html; } } elseif (isset($_POST['id'])) { $sql = $OP->dbh->prepare("SELECT `post`, `privacy` FROM `posts` WHERE `id` = ? AND `uid` = ?"); $sql->execute(array($_POST['id'], curUser)); if ($sql->rowCount() == 0) { $OP->ser(); } $data = $sql->fetch(PDO::FETCH_ASSOC); $post = $data['post']; $pvc = $data['privacy']; $arr = array(); $arr['textarea'] = "<textarea style='width: 100%;height:100px;'>" . $OP->format($post) . "</textarea>"; $arr['privacy'] = '<select name="privacy"> <option value="pub"' . ($pvc == "pub" ? "selected='selected'" : "") . '>Public</option>
if ($path[0] == "/search") { preg_match("/\\/search\\/(.*?)/", $matches); $q = urldecode($matches[0]); $sql = $OP->dbh->prepare("SELECT * FROM `posts` WHERE `id` > :lid AND `post` LIKE :q AND (\n `uid`=:who OR `uid` IN (\n SELECT `fid` FROM `conn` WHERE `uid`=:who\n ) AND (\n `privacy`='pub' OR (\n `privacy`='fri' AND `uid` IN (\n SELECT `fid` FROM `conn` WHERE `uid`=:who AND `fid` IN (\n SELECT `uid` FROM `conn` WHERE `fid`=:who\n )\n )\n )\n )\n ) ORDER BY `id` DESC LIMIT 10"); $sql->execute(array(":q" => "%{$q}%", ":who" => $who, ":lid" => $id)); } elseif ($_POST['pt'] == "profile") { $pU = $path[1]; $sql = $OP->dbh->prepare("SELECT * FROM `posts` WHERE `id` > :lid AND `uid`=:fid ORDER BY `id` DESC LIMIT 10"); $sql->execute(array(":fid" => $pU, ":lid" => $id)); } else { $sql = $OP->dbh->prepare("SELECT * FROM posts WHERE `id` > :lid AND (\n `uid`=:who OR `uid` IN (\n SELECT `fid` FROM `conn` WHERE `uid`=:who\n ) AND (\n `privacy`='pub' OR (\n `privacy`='fri' AND `uid` IN (\n SELECT `fid` FROM `conn` WHERE `uid`=:who AND `fid` IN (\n SELECT `uid` FROM `conn` WHERE `fid`=:who\n )\n )\n )\n )\n ) ORDER BY `id` DESC LIMIT 10"); $sql->execute(array(":who" => $who, ":lid" => $id)); } if ($sql->rowCount() != 0) { $postArr = $sql->fetchAll(PDO::FETCH_ASSOC); $html = $OP->rendFilt(Render::post($postArr)); /* Give a fadein effect on new posts */ $effect = ""; foreach ($postArr as $id => $v) { $effect .= "\$('#" . $id . ".post').hide().fadeIn(2000);"; } $k = array_keys($postArr); ?> if($(".post:first").attr("id") != "<?php echo $k[0]; ?> "){ p="<?php echo $html; ?> ";$(".post:first").before(p);
<?php require_once "render.php"; if (isset($_POST['user']) && $_POST['user'] != '') { $sql = $OP->dbh->prepare("SELECT * FROM posts WHERE uid=:id AND (\n \t\tprivacy='pub' OR (\n \t\t\tprivacy='fri' AND uid IN (\n \t\t\t\tSELECT fid FROM conn WHERE uid=:who AND fid IN (\n \t\t\t\t\tSELECT uid FROM conn WHERE fid=:who\n \t\t\t\t)\n \t\t\t)\n \t\t)\n \t) ORDER BY id DESC LIMIT 5"); $sql->execute(array(":id" => $_POST['user'], ":who" => $who)); } elseif (isset($_GET['q']) && $_GET['q'] != "" && $_SERVER['REDIRECT_PAGE'] == "/search") { $_GET['q'] = urldecode($_GET['q']); $sql = $OP->dbh->prepare("SELECT * FROM posts WHERE post LIKE :q AND (\n \t\tprivacy='pub' OR (\n \t\t\tprivacy='fri' AND uid IN (\n \t\t\t\tSELECT fid FROM conn WHERE uid=:who AND fid IN (\n \t\t\t\t\tSELECT uid FROM conn WHERE fid=:who\n \t\t\t\t)\n \t\t\t)\n \t\t)\n \t) ORDER BY id DESC LIMIT 10"); $sql->execute(array(":q" => "%" . $_GET['q'] . "%", ":who" => $who)); } elseif (isset($_GET['q']) && $_GET['q'] == "" && $_SERVER['REDIRECT_PAGE'] == "/search") { $sql = $OP->dbh->prepare("SELECT * FROM posts WHERE privacy='pub' OR (\n \t\tprivacy='fri' AND uid IN (\n \t\t\tSELECT fid FROM conn WHERE uid=:who AND fid IN (\n \t\t\t\tSELECT uid FROM conn WHERE fid=:who\n \t\t\t)\n \t\t)\n \t) ORDER BY id DESC LIMIT 10"); $sql->execute(array(":who" => $who)); } elseif (isset($_GET['id']) && $_GET['id'] != "" && $_SERVER['REDIRECT_PAGE'] == "/view") { $sql = $OP->dbh->prepare("SELECT * FROM posts WHERE id=:id AND (\n \t\tprivacy='pub' OR (\n \t\t\tprivacy='fri' AND uid IN (\n \t\t\t\tSELECT fid FROM conn WHERE uid=:who AND fid IN (\n \t\t\t\t\tSELECT uid FROM conn WHERE fid=:who\n \t\t\t\t)\n \t\t\t)\n \t\t)\n \t) ORDER BY id DESC LIMIT 1"); $sql->execute(array(":who" => $who, ":id" => $_GET['id'])); } else { $sql = $OP->dbh->prepare("SELECT * FROM posts WHERE uid=:who OR uid IN (\n \t\tSELECT fid FROM conn WHERE uid=:who\n \t) AND (\n \t\tprivacy='pub' OR (\n \t\t\tprivacy='fri' AND uid IN (\n \t\t\t\tSELECT fid FROM conn WHERE uid=:who AND fid IN (\n \t\t\t\t\tSELECT uid FROM conn WHERE fid=:who\n \t\t\t\t)\n \t\t\t)\n \t\t)\n \t) ORDER BY id DESC LIMIT 10"); $sql->execute(array(":who" => $who)); } $postArr = $sql->fetchAll(PDO::FETCH_ASSOC); echo Render::post($postArr); if ($_SERVER['REDIRECT_PAGE'] != "/view") { echo "<div class='load_more_posts'><div class='normal'>Load More Posts</div><div class='loader' hide><img src='" . HOST . "/cdn/img/load.gif' height='32' width='32'/><span>Loading More Posts</span></div></div>"; }