1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2010 Olivier Meunier & Association Dotclear |
---|
7 | # Licensed under the GPL version 2.0 license. |
---|
8 | # See LICENSE file or |
---|
9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
10 | # |
---|
11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
12 | |
---|
13 | require dirname(__FILE__).'/../inc/admin/prepend.php'; |
---|
14 | |
---|
15 | dcPage::check('usage,contentadmin'); |
---|
16 | |
---|
17 | # Check if post exists and is online |
---|
18 | $id = !empty($_REQUEST['id']) ? (integer) $_REQUEST['id'] : null; |
---|
19 | |
---|
20 | $post = null; |
---|
21 | $tb_excerpt = $tb_urls = ''; |
---|
22 | $auto_link = ''; |
---|
23 | $can_view_page = true; |
---|
24 | |
---|
25 | # Check if post exists |
---|
26 | if ($id !== null) |
---|
27 | { |
---|
28 | $params['post_id'] = $id; |
---|
29 | $params['post_status'] = 1; |
---|
30 | $post = $core->blog->getPosts($params); |
---|
31 | |
---|
32 | if ($post->isEmpty()) { |
---|
33 | $core->error->add(__('This entry does not exist or is not published')); |
---|
34 | $can_view_page = false; |
---|
35 | } else { |
---|
36 | $TB = new dcTrackback($core); |
---|
37 | $tb_excerpt = $post->post_excerpt_xhtml.' '.$post->post_content_xhtml; |
---|
38 | $post_title = $post->post_title; |
---|
39 | $post_url = $post->getURL(); |
---|
40 | } |
---|
41 | } |
---|
42 | else |
---|
43 | { |
---|
44 | $core->error->add(__('This entry does not exist.')); |
---|
45 | $can_view_page = false; |
---|
46 | } |
---|
47 | |
---|
48 | # Change excerpt |
---|
49 | if (!empty($_POST['tb_excerpt'])) { |
---|
50 | $tb_excerpt = $_POST['tb_excerpt']; |
---|
51 | } |
---|
52 | |
---|
53 | # Sanitize excerpt |
---|
54 | $tb_excerpt = html::clean($tb_excerpt); |
---|
55 | $tb_excerpt = html::decodeEntities($tb_excerpt); |
---|
56 | $tb_excerpt = text::cutString(html::escapeHTML($tb_excerpt),255); |
---|
57 | $tb_excerpt = preg_replace('/\s+/ms',' ',$tb_excerpt); |
---|
58 | |
---|
59 | # Send pings |
---|
60 | if ($post && !$post->isEmpty() && !empty($_POST['tb_urls'])) |
---|
61 | { |
---|
62 | $tb_urls = $_POST['tb_urls']; |
---|
63 | $tb_urls = str_replace("\r",'',$tb_urls); |
---|
64 | |
---|
65 | $post_title = html::escapeHTML(trim(html::clean($post_title))); |
---|
66 | |
---|
67 | foreach (explode("\n",$tb_urls) as $tb_url) |
---|
68 | { |
---|
69 | try { |
---|
70 | $TB->ping($tb_url,$id,$post_title,$tb_excerpt,$post_url); |
---|
71 | } catch (Exception $e) { |
---|
72 | $core->error->add($e->getMessage()); |
---|
73 | } |
---|
74 | } |
---|
75 | |
---|
76 | if (!$core->error->flag()) { |
---|
77 | http::redirect('trackbacks.php?id='.$id.'&sent=1'); |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | $page_title = __('Ping blogs'); |
---|
82 | |
---|
83 | /* DISPLAY |
---|
84 | -------------------------------------------------------- */ |
---|
85 | dcPage::open($page_title,dcPage::jsLoad('js/_trackbacks.js')); |
---|
86 | |
---|
87 | # Exit if we cannot view page |
---|
88 | if (!$can_view_page) { |
---|
89 | dcPage::close(); |
---|
90 | exit; |
---|
91 | } |
---|
92 | |
---|
93 | if (!empty($_GET['sent'])) { |
---|
94 | echo '<p class="message">'.__('All pings sent.').'</p>'; |
---|
95 | } |
---|
96 | |
---|
97 | echo '<h2>'.html::escapeHTML($core->blog->name).' › '.$page_title.'</h2>'; |
---|
98 | |
---|
99 | echo '<p><a href="'.$core->getPostAdminURL($post->post_type,$id).'">« '. |
---|
100 | sprintf(__('Back to "%s"'),html::escapeHTML($post->post_title)).'</a></p>'; |
---|
101 | |
---|
102 | echo |
---|
103 | '<h3 id="entry-preview-title">'. |
---|
104 | html::escapeHTML($post->post_title).'</h3>'. |
---|
105 | '<div class="frame-shrink" id="entry-preview">'. |
---|
106 | ($post->post_excerpt_xhtml ? $post->post_excerpt_xhtml.'<hr />' : ''). |
---|
107 | $post->post_content_xhtml. |
---|
108 | '</div>'; |
---|
109 | |
---|
110 | if (!empty($_GET['auto'])) { |
---|
111 | flush(); |
---|
112 | $tb_urls = implode("\n",$TB->discover($post->post_excerpt_xhtml.' '.$post->post_content_xhtml)); |
---|
113 | } else { |
---|
114 | $auto_link = '<strong><a href="trackbacks.php?id='.$id.'&auto=1">'. |
---|
115 | __('Auto discover ping URLs').'</a></strong>'; |
---|
116 | } |
---|
117 | |
---|
118 | echo |
---|
119 | '<h3>'.__('Ping blogs').'</h3>'. |
---|
120 | '<form action="trackbacks.php" id="trackback-form" method="post">'. |
---|
121 | '<p><label for="tb_urls" class="area">'.__('URLs to ping:'). |
---|
122 | form::textarea('tb_urls',60,5,$tb_urls). |
---|
123 | '</label></p>'. |
---|
124 | |
---|
125 | '<p><label for="tb_excerpt" class="area">'.__('Send excerpt:'). |
---|
126 | form::textarea('tb_excerpt',60,3,$tb_excerpt).'</label></p>'. |
---|
127 | |
---|
128 | '<p>'.form::hidden('id',$id). |
---|
129 | $core->formNonce(). |
---|
130 | '<input type="submit" value="'.__('Ping blogs').'" /> '. |
---|
131 | $auto_link.'</p>'. |
---|
132 | '</form>'; |
---|
133 | |
---|
134 | $pings = $TB->getPostPings($id); |
---|
135 | |
---|
136 | if (!$pings->isEmpty()) |
---|
137 | { |
---|
138 | echo '<h3>'.__('Previously sent pings').'</h3>'; |
---|
139 | |
---|
140 | echo '<ul class="nice">'; |
---|
141 | while ($pings->fetch()) { |
---|
142 | echo |
---|
143 | '<li>'.dt::dt2str(__('%Y-%m-%d %H:%M'),$pings->ping_dt).' - '. |
---|
144 | $pings->ping_url.'</li>'; |
---|
145 | } |
---|
146 | echo '</ul>'; |
---|
147 | } |
---|
148 | |
---|
149 | dcPage::close(); |
---|
150 | ?> |
---|