-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAction.php
executable file
·69 lines (57 loc) · 2.31 KB
/
Action.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
<?php ! defined('__TYPECHO_ROOT_DIR__') and exit();
class B3logForHacPai_Action extends Typecho_Widget
{
/**
* 构造函数
*
* @param mixed $request
* @param mixed $response
* @param null $params
*/
public function __construct($request, $response, $params = NULL)
{
parent::__construct($request, $response, $params);
}
/**
* Article receiver (from B3log Symphony).
*
*/
public function articleReceiver(){
//print_r($_POST);
}
/**
* Comment receiver (from B3log Symphony).
*
*/
public function commentReceiver(){
if (!isset($GLOBALS['HTTP_RAW_POST_DATA'])) {
$GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input");
}
if (isset($GLOBALS['HTTP_RAW_POST_DATA'])) {
$GLOBALS['HTTP_RAW_POST_DATA'] = trim($GLOBALS['HTTP_RAW_POST_DATA']);
}
$result = json_decode($GLOBALS['HTTP_RAW_POST_DATA']);
if($result->client->key == Typecho_Widget::widget('Widget_Options')->plugin('B3logForHacPai')->b3logKey) {
$post = Typecho_Db::get()->fetchRow(Typecho_Db::get()->select('authorId')->from('table.contents')->where('cid = ?', $result->comment->articleId));
if ($post) {
$comment = array(
'cid' => $result->comment->articleId,
'created' => $result->comment->time,
'text' => $result->comment->content,
'author' => $result->comment->authorName,
'mail' => $result->comment->authorEmail,
'url' => $result->comment->authorURL,
'agent' => $result->comment->ua,//$this->request->getAgent(),
'ip' => $result->comment->ip,//$this->request->getIp(),
'ownerId' => $post['authorId'],
'type' => 'comment',
'status' => 'approved',
'authorId' => $result->comment->isArticleAuthor?1:0,
);
//print_r($result->comment->articleid);
//$article = Typecho_Widget::widget('Widget_Users_Author@' . $this->cid, array('cid' => $result->comment->articleId));
Typecho_Widget::widget('Widget_Feedback')->insert($comment);
}
}
}
}