-
Notifications
You must be signed in to change notification settings - Fork 5
/
post.php
76 lines (59 loc) · 1.88 KB
/
post.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/**
* Shows a single post to a user, with its comments
*
* @author Brian Moon <[email protected]>
* @copyright 1997-Present Brian Moon
* @package Wordcraft
* @license http://wordcraft.googlecode.com/files/license.txt
* @link http://wordcraft.googlecode.com/
*
*/
include_once "./include/common.php";
include_once "./include/database.php";
include_once "./include/output.php";
include_once "./include/format.php";
include_once "./include/url.php";
include_once "./include/captcha/CaptchaJavascript.php";
include_once "./include/captcha/lib/iscramble.php";
$post_id = (isset($_GET["post_id"])) ? (int)$_GET["post_id"] : 0;
$post_uri = (isset($_GET["uri"])) ? $_GET["uri"] : "";
if(empty($post_id) && empty($post_uri)){
wc_output("notfound");
return;
}
if($post_id){
$WCDATA["post"] = wc_db_get_post($post_id);
} else {
$WCDATA["post"] = wc_db_get_post($post_uri);
}
if(empty($WCDATA["post"])){
wc_output("notfound");
return;
}
wc_format_post($WCDATA["post"]);
if(empty($post_id)){
$post_id = $WCDATA["post"]["post_id"];
}
list($WCDATA["comments"], $comment_total) = wc_db_get_comments($post_id, "APPROVED");
foreach($WCDATA["comments"] as &$comment){
wc_format_comment($comment);
}
unset($comment);
$WCDATA["title"] = strip_tags($WCDATA["post"]["subject"]);
$WCDATA["description"] = preg_replace('!\s+!', " ", substr(strip_tags($WCDATA["post"]["body"]), 0, 300));
$WCDATA["comment_url"] = wc_get_url("comment");
if($WC["use_captcha"]){
$captcha = new CaptchaJavascript();
$data = $captcha->generate_captcha();
$WCDATA["captcha"] = iScramble_javascript();
$WCDATA["captcha"].= $data["html_form"];
$WCDATA["captcha"].= $data["html_after_form"];
session_start();
$_SESSION["captcha"] = $data;
}
if($WCDATA["post"]["allow_comments"]){
header("X-Pingback: ".wc_get_url("pingback"));
}
wc_output("post", $WCDATA);
?>