$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { echo $e->getMessage(); } if (isset($_POST['favorite'])) { switch ($_POST['favorite']) { case 'Favorite': favorite(); break; case 'Unfavorite': unfavorite(); break; } } if (isset($_POST['comment'])) { postComment($_POST['comment']); } $title = new Title(); function favorite() { session_start(); global $con; try { $sql = "UPDATE `users` SET `favorites` = CONCAT(`favorites`, :title) WHERE `users`.`username` = :name"; $sql = $con->prepare($sql); $title = $_SESSION['title'] . ","; $sql->bindParam(':title', $title); $sql->bindParam(':name', $_SESSION['username']); $sql->execute(); array_push($_SESSION['favorites'], $_SESSION['title']); } catch (PDOException $e) {
<?php foreach ($post as $post) { postComment($post['post_id']); /*MENTIONED IN A COMMENT*/ if ($post['reply'] > 0) { $comments = getComment($post['reply']); if (!empty($comments)) { print '<div class="post">'; print '<div class="postit"><ul>'; foreach ($comments as $comments) { if ($comments['post'] == $post['post']) { /*THE @_COMMENT*/ print '<li class="postit atcomment">'; /*WHO AND WHEN MENTIONED*/ print '<p><i>' . printTime($comments['time_stamp']) . ', ' . atLink($comments['username']) . ' mentioned you in a comment:</i></p><br>'; /*DELETE_BUTTON*/ if ($sess['user_id'] == $comments['user_id']) { print '<div class="del_post">'; print '<form method="POST"> <input type="hidden" name="post_id" value="' . $comments['post_id'] . '"> <button type="submit" name="del_comment"><img src="img/trashicon.png"></button> </form>'; print '</div>'; } /*END DELETE_BUTTON*/ print '<div class="profile_img">' . getProfilePic($post['user_id'], '50px') . '</div>'; print '<h3>' . atLink($comments['username']) . ':</h3>'; print '<p> "' . atLink($post['post']) . '"</p><br><br>'; /*REPLY_FORM*/ print '<div class="reply at">
/** @test */ public function it_can_delete_comment() { $comment = postComment($this); // Delete comment $delete = $this->call('DELETE', '/api/comment/' . $comment->id . '?token=' . $this->token); $delete = $delete->getOriginalContent(); $this->assertResponseOk(); $this->seeInDatabase('comments', ['deleted_at' => $delete->deleted_at]); }
<?php session_start(); require_once 'connection.php'; if ($_POST['action'] == 'message') { postMessage($connection, $_POST); } else { if ($_POST['action'] == 'comment') { postComment($connection, $_POST); } else { session_destroy(); header('Location: login.php'); } } function postMessage($connection, $post) { $_SESSION['message_errors'] = array(); if (empty($post['message'])) { header('Location: success.php'); } else { $message = mysqli_real_escape_string($connection, $post['message']); $query = "INSERT INTO messages (message, user_id, created_at, updated_at) VALUES ('{$message}', '{$_SESSION['user_id']}', NOW(), NOW())"; mysqli_query($connection, $query); header('Location: success.php'); } } function postComment($connection, $post) { $_SESSION['comment_errors'] = array(); if (empty($post['comment'])) { header('Location: success.php');
<?php if ($_SERVER["REQUEST_METHOD"] == "POST") { print '<div class="post_it"><h3>'; if (isset($_POST['litter'])) { print createPost(); } if (isset($_POST['postComment'])) { print postComment(); } if (isset($_POST['reply'])) { print replyComment(); } if (isset($_POST['profile_pic'])) { print changeProfilePic(); } if (isset($_POST['changeInfo'])) { print changeInfo(); } if (isset($_POST['del_user'])) { deleteUser(); } if (isset($_POST['del_post'])) { print deletePost(); } if (isset($_POST['del_comment'])) { print deleteComment(); } if (isset($_POST['recycle'])) { print recycle(); }
<?php /** * Created by PhpStorm. * User: Radmation * Date: 5/14/15 * Time: 9:11 PM */ require_once '../podio/PodioAPI.php'; require_once '../config/config.php'; require_once '../functions/functions.php'; echo 'start'; authorize(); if (isset($_POST['comment']) && isset($_POST['comment_id'])) { //echo $_POST['comment']; postComment($_POST['comment_id'], $_POST['comment']); header('Location: http://kb-demos.com/podio2'); } else { echo "Not Set"; echo $_POST['comment']; echo $_POST['comment_id']; }
/** * Prints the code to auto receive and add tracksbacks from external clients * for the root trackback.php file * */ function printTrackbackReceiver() { global $_zp_gallery; // Set page header to XML header('Content-Type: text/xml'); // MUST be the 1st line // Get trackback information $tb_id = $this->id; // The id of the item being trackbacked $tb_type = $this->type; // The type of the item being trackbacked $tb_url = $this->url; // The URL from which we got the trackback. $tb_title = $this->title; // Subject/title send by trackback $tb_blogname = $this->blog_name; // Name of the blog/site that sends the trackback; // Following trackback spec only $tb_url is mandatory, so throw error if missing. Also if comments are not allowed at all if (empty($tb_url) || empty($tb_id) || empty($tb_type)) { echo $this->receive(false, "Trackbacks are not allowed"); exit; } if (empty($tb_blogname)) { $tb_blogname = "[Trackback] " . $tb_url; // if there is no name sent, use the url as name. } else { $tb_blogname = "[Trackback] " . $tb_blogname; } $tb_excerpt = truncate_string($this->excerpt, 255, "[...]"); // Short text send by trackback if too long $tb_excerpt = "<strong>" . $tb_title . "</strong><br />" . $tb_excerpt; // add trackback title to trackback content to show them togehter // getting the item "name" so that we can setup an receiver object for postComment() $gallery = new Gallery(); //$_zp_gallery; $query = ""; switch ($tb_type) { case "albums": $query = query_single_row('SELECT `folder` FROM ' . prefix('albums') . ' WHERE `id`="' . zp_escape_string($tb_id) . '"', true); $object = new Album($gallery, $query['folder']); $allowed = commentsAllowed('comment_form_albums'); break; case "images": $query = query_single_row('SELECT `filename`,`albumid` FROM ' . prefix('images') . ' WHERE `id`="' . zp_escape_string($tb_id) . '"', true); $albumid = $query['albumid']; $query2 = query_single_row('SELECT `folder` FROM ' . prefix('albums') . ' WHERE `id`="' . zp_escape_string($albumid) . '"', true); $albobject = new Album($gallery, $query2['folder']); $object = newImage($albobject, $query['filename']); $allowed = commentsAllowed('comment_form_images'); break; case "pages": $query = query_single_row('SELECT `titlelink` FROM ' . prefix('zenpage_pages') . ' WHERE `id`="' . zp_escape_string($tb_id) . '"', true); $object = new ZenpagePage($query['titlelink']); $allowed = commentsAllowed('comment_form_pages'); break; case "news": $query = query_single_row('SELECT `titlelink` FROM ' . prefix('zenpage_news') . ' WHERE `id`="' . zp_escape_string($tb_id) . '"', true); $object = new ZenpageNews($query['titlelink']); $allowed = commentsAllowed('comment_form_articles'); break; } // Check if the url being sent really includes a link to us. $our_url = $this->getPermalinkURL($object); if (!$this->validateTrackbackSender($tb_url, $our_url)) { echo $this->receive(false, "Not a valid trackback!"); exit; } // I realized that we should only send one final receive(true) at the end // and only receive(false) inbetween if it fails a precheck. if (!(getOption('zp_plugin_comment_form') && $allowed && $object->getCommentsAllowed())) { echo $this->receive(false, gettext("Sorry, comments are closed for this item.")); exit; } $sql = 'SELECT `id` FROM ' . prefix('comments') . ' WHERE `ownerid`=' . $tb_id . ' AND `comment`="' . zp_escape_string($tb_excerpt) . '" AND `website`="' . zp_escape_string($tb_url) . '" AND `type`="' . zp_escape_string($tb_type) . '" AND `name`="' . zp_escape_string($tb_blogname) . '"'; $dbcheck = query_single_row($sql); if ($dbcheck) { echo $this->receive(false, gettext("This trackback already exists!")); exit; } else { $commentobj = postComment($tb_blogname, "", $tb_url, $tb_excerpt, "", "", $object, "", "", "", COMMENT_WEB_REQUIRED | COMMENT_SEND_EMAIL); if ($commentobj->getInModeration() >= 0) { echo $this->receive(true); } else { echo $this->receive(false); } } }
/** * Adds comments to the album * assumes data is coming straight from GET or POST * * Returns a comment object * * @param string $name Comment author name * @param string $email Comment author email * @param string $website Comment author website * @param string $comment body of the comment * @param string $code CAPTCHA code entered * @param string $code_ok CAPTCHA hash expected * @param string $ip the IP address of the comment poster * @param bool $private set to true if the comment is for the admin only * @param bool $anon set to true if the poster wishes to remain anonymous * @return object */ function addComment($name, $email, $website, $comment, $code, $code_ok, $ip, $private, $anon) { $goodMessage = postComment($name, $email, $website, $comment, $code, $code_ok, $this, $ip, $private, $anon); return $goodMessage; }
</div> <!-- /.comment-avatar --> <div class="comment-meta"> <p> <?php echo "The Sample Comment"; ?> </p> </div> </div> </li> <li> <?php $img_url = "{$baseUrl}" . "/static/imgs/rajnish.jpg"; postComment($img_url, 'project/activity/comment', 'comment_to_project_activity', 'comment_project_avtivity'); ?> </li> </ol> </div> </div> <!-- /.Activities-block ends--> </div> <div class="col-md-3 col-sm-4"> <hr> <div class="post-title"> <h4>
cat = kategori, a untuk answer, q untuk question id = id answer/question val = nilai vote (1 atau -1) */ $uag = $_SERVER['HTTP_USER_AGENT']; $ip = $_SERVER['REMOTE_ADDR']; if ($ip = "::1") { $ip = "0:0:0:0:0:0:0:1"; } if (isset($_SESSION['token'])) { //post answer $token = $_SESSION['token']; if (isset($_POST['content']) && isset($_GET['id'])) { $q_id = $_GET['id']; $content = $_POST['content']; postComment($q_id, $token, $uag, $ip, $content); } //vote if (isset($_GET['id']) && isset($_GET['cat']) && isset($_GET['val'])) { $id = $_GET['id']; $category = $_GET['cat']; $value = $_GET['val']; if ($category == 'a') { voteAnswer($id, $token, $uag, $ip, $value); } else { if ($category == 'q') { voteQuestion($id, $token, $uag, $ip, $value); } } } } else {
<?php require_once "config.php"; require_once "github.php"; require_once "gifs.php"; $config = null; foreach ($REPOS as $repo => $repo_config) { if ($repo === $_GET['repo']) { $config = $repo_config; break; } } $body = file_get_contents("php://input"); if (!$config || "sha1=" . hash_hmac("sha1", $body, $config["secret"]) !== $_SERVER['HTTP_X_HUB_SIGNATURE']) { die("404?"); } $body = json_decode($body, true); if ($body["pull_request"]["base"]["ref"] === "master") { if ($body['action'] === "opened") { postComment($body['pull_request']['url'], "**Notice**: This will go live on the website as soon as the pull request is closed.\n\nPlease ensure this has been tested properly on `master`.\n\nYou sho uld not accept this PR by yourself. Someone else should accept it, preferably after reading it."); if ($config["lint_cmd"]) { updateCommitStatus($body['pull_request'], 'pending'); $output = shell_exec($config["cmd"]); } } if ($body["action"] === "closed" && $body["pull_request"]["merged"] === true) { shell_exec($config["cmd"]); postComment($body['pull_request']['url'], "Deployed successfully. Please check your changes on " . $config['url'] . "\n<img src=\"" . $GIFS[array_rand($GIFS)] . "\">"); } }
global $dbi; $now = date( "M, d Y @ h:i a" ); sql_query( "insert into jones_blog_comment values( null, '$blog_entry_id', '$name', '$email', '$subject', '$body', '$now' )", $dbi ); Header( "Location: blog.php?cmd=readAll&id=$blog_entry_id" ); } set_error_handler("myErrorHandler"); if( isSet( $_GET['cmd'] ) ) $cmd = $_GET['cmd']; else if( isSet( $_POST['cmd'] ) ) $cmd = $_POST['cmd']; else $cmd = ""; switch( $cmd ) { case "viewCategory": viewCategory( $_GET['id'] ); break; case "readAll": readAll( $_GET['id'] ); break; case "postComment": postComment( $_POST['blog_entry_id'], $_POST['name'], $_POST['email'], $_POST['subject'], $_POST['body'] ); break; default: main( ); break; } ?>