本文整理汇总了PHP中addComment函数的典型用法代码示例。如果您正苦于以下问题:PHP addComment函数的具体用法?PHP addComment怎么用?PHP addComment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了addComment函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addNewComment
public function addNewComment()
{
$response['signed'] = false;
$response['valid'] = false;
$response['succeeded'] = false;
$response['comment'] = array();
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$comment = ['post_id' => $comment_id = $request->post_id, 'caption' => $caption = $request->caption];
$v = new Validator();
$v->required('post_id')->digits();
$v->required('caption')->lengthBetween(1, 1000);
$result = $v->validate($comment);
$response['valid'] = $result->isValid();
if (isset($_SESSION["user_id"]) && strlen(trim($_SESSION["user_id"])) > 0) {
$response['signed'] = true;
if ($response['valid']) {
$response['comment'] = addComment($_SESSION['user_id'], $comment);
$response['succeeded'] = true;
} else {
print_r($result->getFailures());
}
}
echo json_encode($response);
}
示例2: add_comment
function add_comment($moderator_email)
{
$caller = strtolower($_POST["url"]);
//$_SERVER['HTTP_REFERER'];
$filename = md5($caller);
$abs_comment_file = realpath('.') . '/' . $filename . '.xml';
$date_value = time();
$comment_id = $date_value . '-' . rand(1, 100000000);
$author_value = processText($_POST["name"]);
$subject_value = trim(processText($_POST["subject"]));
$msg_value = processText($_POST["message"]);
$email = processText($_POST["email"]);
$site = processText($_POST["site"]);
$title = processText($_POST["title"]);
$parent_id = processText($_POST["id"]);
$dom_id = processText($_POST["domid"]);
$moderate = processText($_POST["moderate"]);
// 0 No moderate, 1: waiting for moderate 2: trash 3: spamn 4: approved
$max_reply = intval(processText($_POST["max"]));
$secured = empty($_SERVER["HTTPS"]) ? '' : $_SERVER["HTTPS"] == "on" ? "s" : "";
$protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/") . $secured;
$ec_path = $protocol . '://' . $_SERVER['HTTP_HOST'] . processText($_POST["path"]);
if (empty($parent_id)) {
$parent_id = null;
}
$ip = $_SERVER["REMOTE_ADDR"];
$ret = addComment($abs_comment_file, $caller, $title, $dom_id, $comment_id, $date_value, $author_value, $subject_value, $email, $site, $msg_value, $ip, $moderate, $parent_id, $max_reply);
$msg_value = str_replace(array("\r", "\n"), "<br />", $msg_value);
echo json_encode(array("id" => $comment_id, "comment" => '<li class="ec-comment" id="' . $comment_id . '">' . ' <div class="avatar"></div>' . ' <span class="user-name author">' . $author_value . '</span> <br/>' . ' <span class="comment-html">' . (empty($subject_value) ? '' : ' <strong>' . $subject_value . '</strong><br /><br />') . $msg_value . ' </span><br/>' . ' <span class="comment-time">' . ago(time() - $date_value * 1) . '</span><br/>' . ($ret ? ' <button name="reply" id="reply_' . $comment_id . '">Reply</button>' : "") . '</li>'));
// send email to moderator
if ($moderate == "1") {
$body = 'A new comment is waiting for your approval:<br /><br />' . 'Author:' . $author_value . '(IP: ' . $ip . ')<br/>' . 'Email:' . $email . '<br/>' . 'URL:' . $site . '<br/>' . 'Subject:' . $subject_value . '<br/>' . 'Whois:<a href="http://whois.arin.net/rest/ip/' . $ip . '" target="_blank">http://whois.arin.net/rest/ip/' . $ip . '</a><br/>' . 'Comment:<br/>' . '<blockquote>' . $msg_value . '</blockquote><br/>' . 'To moderate this message, click <a href="' . $ec_path . 'ec-dashboard.html">' . $ec_path . 'ec-dashboard.html</a><br/>' . '<br/>' . 'Thanks for choosing EastComment<br/><br/>' . '<a href="http://www.jswidget.com/lab/easy-comment.html" target="_blank">http://www.jswidget.com/lab/easy-comment.html</a>';
sendEmail($moderator_email, $body);
}
}
示例3: htmlspecialchars
<?php
include 'functions.php';
$commentBody = htmlspecialchars($_POST['commentBody']);
$postId = htmlspecialchars($_POST['postId']);
$userId = htmlspecialchars($_SESSION['userId']);
if (!commentIsOkay($commentBody)) {
$_SESSION['errors'] = ['error' => 'Comment cannot be empty!'];
return header('Location: ' . 'viewPost.php?postId=' . $postId);
}
addComment($commentBody, $postId, $userId);
header('Location: ' . 'viewPost.php?postId=' . $postId);
示例4: session_start
echo "</form>";
}
session_start();
$storyCreator = showStory();
showLink();
echo "<br><br><br><br>";
showComment();
if (isset($_SESSION['user_name'])) {
if (isset($_POST["replyCommentButton"])) {
$replyTo = htmlspecialchars($_POST["replyCommentTo"]);
} elseif (isset($_POST["replyStoryButton"])) {
$replyTo = htmlspecialchars($_POST["replyStory"]);
} else {
$replyTo = $storyCreator;
}
addComment($storyCreator, $replyTo);
} else {
echo "<br>log in to reply<br><br>";
}
?>
<form action="storyBoard.php" >
<?php
session_start();
echo "<input type=\"hidden\" name=\"token\" value=" . htmlspecialchars($_SESSION['token']) . ">";
?>
<input type="submit" name="returnStoryBoard" value="Back">
</form>
</div>
</body>
示例5: addView
}
if ($count == 0) {
addView($mid);
}
addIPAddress($mid);
$r = mysql_query("SELECT uid,cvid,mid,comment FROM `Comments` WHERE mid='{$mid}'") or die(mysql_error());
$q = mysql_query("SELECT * FROM `Media` WHERE mid='{$mid}'") or die(mysql_error());
$row = mysql_fetch_assoc($q);
$path = $row["MediaPath"];
$name = $row['Title'];
$text = $row['Description'];
$type = $row['Type'];
if (isset($_POST['comment'])) {
if ($_SESSION["username"]) {
if (strlen($_POST['text']) > 0) {
addComment($id, $mid, $_POST['text']);
}
} else {
$url = $_SERVER['REQUEST_URI'];
echo "<meta http-equiv=\"refresh\" content=\"0;url=Login.php?url={$url}\">";
}
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<head>
<title>
PLAYER
示例6:
$xmlRoot->appendChild(userInfo($dbconn, $xmlDoc, $_REQUEST['id']));
break;
case "editUsername":
$xmlRoot->appendChild(editUsername($dbconn, $xmlDoc, $_REQUEST['id'], $_REQUEST['username']));
break;
case "castVote":
$xmlRoot->appendChild(castVote($dbconn, $xmlDoc, $_REQUEST['user_id'], $_REQUEST['post_id'], $_REQUEST['vote']));
break;
case "tallyVotes":
$xmlRoot->appendChild(tallyVotes($dbconn, $xmlDoc, $_REQUEST['post_id']));
break;
case "checkForUserVote":
$xmlRoot->appendChild(checkForUserVote($dbconn, $xmlDoc, $_REQUEST['post_id'], $_REQUEST['user_id']));
break;
case "addComment":
$xmlRoot->appendChild(addComment($dbconn, $xmlDoc, $_REQUEST['user_id'], $_REQUEST['post_id'], $_REQUEST['comment']));
break;
case "getComments":
$xmlRoot->appendChild(getComments($dbconn, $xmlDoc, $_REQUEST['post_id']));
break;
case "addNewUser":
$xmlRoot->appendChild(addNewUser($dbconn, $xmlDoc, $_REQUEST['username'], $_REQUEST['password'], $_REQUEST['email']));
break;
case "signIn":
$xmlRoot->appendChild(signIn($dbconn, $xmlDoc, $_REQUEST['username'], $_REQUEST['password']));
break;
case "getConnections":
$xmlRoot->appendChild(getConnections($dbconn, $xmlDoc, $_REQUEST['user_id'], $_REQUEST['module_type']));
break;
case "logs":
$xmlRoot->appendChild(getLogs($dbconn, $xmlDoc, $_REQUEST['user_id']));
示例7: addComment
require 'header.php';
require 'config.php';
// Empty pour n'envoyer des commentaires à la bdd que si $errors est vide !
if (!empty($_POST['submitcomm'])) {
$id_post = $_POST['id_post'];
$auteur = $_POST['auteur'];
$message = $_POST['commentaire'];
$errors = [];
if (empty($message)) {
$errors = "Message requis !";
}
if (empty($auteur)) {
$errors = "Auteur requis !";
}
if (empty($errors)) {
addComment($bdd, $id_post, $auteur, $message);
}
}
// Empty pour n'envoyer des posts à la bdd que si $errors est vide !
if (!empty($_POST['submitpost'])) {
$titre = $_POST['titre'];
$contenu = $_POST['contenu'];
$errors = [];
if (empty($contenu)) {
$errors = "Message requis !";
}
if (empty($titre)) {
$errors = "Titre requis !";
}
if (empty($errors)) {
addPost($bdd, $titre, $contenu);
示例8: deleteGoal
break;
case "DELETE":
$data["goalID"] = $path[1];
$results = deleteGoal($data);
break;
default:
$results["meta"] = methodNotAllowed($method, $path);
}
break;
case "comments":
switch ($method) {
case "GET":
$results = getComments($data);
break;
case "POST":
$results = addComment($data);
break;
case "PATCH":
$data["commentID"] = $path[1];
$results = editComment($data);
break;
case "DELETE":
$data["commentID"] = $path[1];
$results = deleteComment($data);
break;
default:
$results["meta"] = methodNotAllowed($method, $path);
}
break;
case "follows":
switch ($method) {
示例9: getData
print getData($sql);
break;
case 'getAlbum':
$albumUserID = intval($_POST['albumUserID']);
if ($albumUserID <= 0) {
$sql = "SELECT * FROM AlbumTable WHERE AlbumName!='Face' and AlbumName!='Default'";
} else {
$sql = "SELECT * FROM AlbumTable WHERE UserID={$albumUserID}";
}
print getData($sql);
break;
case 'sendComment':
if ($ifLogin == 1) {
$cmt = $_POST['cmt'];
$picID = $_POST['picID'];
addComment($userID, $picID, $cmt, time());
} else {
}
break;
case 'addLike':
if ($ifLogin == 1) {
$picID = $_POST['picID'];
addLike($userID, $picID, time());
} else {
}
break;
case 'uploadPic':
if ($ifLogin == 1) {
$picAlbumID = $_POST['upAlbumID'];
$picAlbumName = $_POST['upAlbumName'];
$sql = "SELECT * FROM AlbumTable WHERE AlbumID={$picAlbumID} AND UserID={$userID}";
示例10: db_value
case 'sharePhotos':
$sCaption = db_value("SELECT `Caption` FROM `ProfileCompose` WHERE `Func` = 'SharePhotos'");
echo PageCompSharePhotosContent($sCaption, $profileID);
break;
case 'shareVideos':
$sCaption = db_value("SELECT `Caption` FROM `ProfileCompose` WHERE `Func` = 'ShareVideos'");
echo PageCompShareVideosContent($sCaption, $profileID);
break;
}
exit;
}
$_page['header'] = process_line_output($p_arr['NickName']) . ": " . htmlspecialchars_adv($p_arr['Headline']);
//$_page['header_text'] = process_line_output( $p_arr['Headline'] );
//post comment
if ($_POST['commentsubmit']) {
$ret .= addComment($profileID);
}
//delete comment
if ($_GET['action'] == 'commentdelete') {
$ret .= deleteComment((int) $_GET['commentID']);
}
// track profile views
if ($track_profile_view && $memberID && !$oProfile->owner) {
db_res("DELETE FROM `ProfilesTrack` WHERE `Member` = {$memberID} AND `Profile` = {$profileID}", 0);
db_res("INSERT INTO `ProfilesTrack` SET `Arrived` = NOW(), `Member` = {$memberID}, `Profile` = {$profileID}", 0);
}
$_ni = $_page['name_index'];
$_page_cont[$_ni]['page_main_code'] = $oProfile->genColumns();
PageCode();
function addComment($profileID)
{
示例11: session_start
<?php
session_start();
include "config.php";
include "db.php";
dbconnect() or send_err_mail("Cannot connect to server" . mysql_error(), $PHP_SELF);
$user_id = $_SESSION[vis_user_id];
$organiser_id = $_SESSION[vis_organiser_id];
$track_discussion = addslashes($track_discussion);
$result = addComment($discus_track_id, $discus_event_id, $track_discussion);
?>
<table border='0' width='100%' cellspacing="0" cellpadding="0" style="padding:100px;" >
<?php
$Discus_track_sql = "SELECT {$tbltrackDiscussion}.contact_id,{$tbltrackDiscussion}.track_discussion,{$tblcontact}.contact_prof_pic,{$tblcontact}.contact_name,{$tblcontact}.salutation,{$tblcontact}.first_name,{$tblcontact}.last_name FROM {$tbltrackDiscussion},{$tblcontact} WHERE {$tbltrackDiscussion}.status IN ('active') AND {$tbltrackDiscussion}.track_id='{$discus_track_id}' AND {$tbltrackDiscussion}.event_id='{$discus_event_id}' AND {$tbltrackDiscussion}.contact_id={$tblcontact}.contact_id ORDER BY {$tbltrackDiscussion}.added_on";
$Discus_track_res = mysql_query($Discus_track_sql) or send_err_mail($Discus_track_sql . mysql_error(), $PHP_SELF);
$Discus_track_total = mysql_num_rows($Discus_track_res);
if ($Discus_track_total > 0) {
while ($Discus_track_row = mysql_fetch_array($Discus_track_res)) {
$discuss_contact_id = $Discus_track_row['contact_id'];
$registarnt_type_id = get_registarnt_type_of_this_event($event_id, $discuss_contact_id);
if ($registarnt_type_id == "1") {
$discuss_profile_page = "buyer_profile.php";
}
if ($registarnt_type_id == "2") {
$discuss_profile_page = "seller_profile.php";
}
if ($registarnt_type_id == "3") {
$discuss_profile_page = "speaker_profile.php";
}
if ($registarnt_type_id == "4") {
示例12: round
$arg = round($arg);
} else {
$arg = 0;
}
return $arg;
}
require_once 'gshare.php';
// work
// outputs
if ($_GET['ss']) {
if (file_exists("styles/{$_GET['ss']}")) {
setcookie('style', $_GET['ss'], time() + 3600 * 24 * 30);
redir("/");
}
} elseif (int_esc($_GET['ac']) && isset($_POST['name']) && isset($_POST['text'])) {
addComment($_GET['ac'], strip_tags($_POST['name']), $_POST['text']);
redir("/?e={$_GET['ac']}");
} elseif ($_GET['a'] == 'new-uri') {
if (preg_match('|^gnunet://ecrs/chk/[A-Z0-9]+\\.[A-Z0-9]+\\.\\d+$|', $_POST['uri'], $matches) && isset($_POST['title']) && isset($_POST['desc'])) {
$_POST['title'] = strip_tags($_POST['title']);
if ($num = postNewEntry($_POST['uri'], $_POST['title'], $_POST['desc'])) {
redir("/?e={$num}");
}
} else {
$page = "Something's not right";
}
} elseif (int_esc($_GET['p'])) {
$page = getPage($_GET['p']);
if (getPagesCount() > $_GET['p']) {
$nextpage = "| <a href='{$r}/?p='" . ($_GET['p'] + 1) . "'>25 older entries »</a>";
}
示例13: header
$bool = $cod->setUsed($code32);
$bool = $cod->setUsed($code33);
$msg = "Votation Done.";
header("Location: ../views/popularVote.php?msg={$msg}");
}
} else {
if (isset($_GET["idpincho"])) {
//Código para leer comentarios
$idpincho = $_GET["idpincho"];
viewComments($idpincho);
} else {
if (isset($_POST["message"])) {
//Código para añadir comentario
$message = $_POST["message"];
$idpincho = $_POST["idpincho"];
addComment($message, $idpincho);
} else {
echo "No recibe";
}
}
}
}
}
}
}
}
function viewComments($idpincho)
{
$c = new Comments();
$array = $c->getComments($idpincho);
if ($array == false) {
示例14: story_addcomment
function story_addcomment()
{
if (!empty($_POST['content'])) {
$id = $_GET['id'];
addComment(2, $id);
}
header("location:" . $_SERVER['HTTP_REFERER']);
}
示例15: reportForumPost
function reportForumPost($itemId)
{
if (!is_numeric($itemId)) {
return false;
}
$item = getForumItem($itemId);
if (!$item) {
return false;
}
if (isset($_POST['motivation'])) {
$queueId = addToModerationQueue(MODERATION_FORUM, $itemId);
addComment(COMMENT_MODERATION, $queueId, $_POST['motivation']);
goLoc('forum.php?id=' . $item['parentId']);
die;
}
echo showForumPost($item, '', false) . '<br/>';
echo xhtmlForm('abuse', $_SERVER['PHP_SELF'] . '?id=' . $itemId);
echo t('Write a motivation') . ':<br/>';
echo xhtmlTextarea('motivation', '', 50, 5) . '<br/><br/>';
echo xhtmlSubmit('Report');
echo xhtmlFormClose() . '<br/><br/>';
}