[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[1179] | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
[0] | 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 | -------------------------------------------------------- */ |
---|
[1358] | 85 | if ($can_view_page) { |
---|
| 86 | $breadcrumb = dcPage::breadcrumb( |
---|
| 87 | array( |
---|
| 88 | html::escapeHTML($core->blog->name) => '', |
---|
| 89 | html::escapeHTML($post->post_title) => $core->getPostAdminURL($post->post_type,$id), |
---|
| 90 | '<span class="page-title">'.$page_title.'</span>' => '' |
---|
| 91 | )); |
---|
| 92 | } else { |
---|
| 93 | $breadcrumb = ''; |
---|
| 94 | } |
---|
| 95 | dcPage::open($page_title,dcPage::jsLoad('js/_trackbacks.js'),$breadcrumb); |
---|
[0] | 96 | |
---|
| 97 | # Exit if we cannot view page |
---|
| 98 | if (!$can_view_page) { |
---|
| 99 | dcPage::close(); |
---|
| 100 | exit; |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | if (!empty($_GET['sent'])) { |
---|
[907] | 104 | dcPage::message(__('All pings sent.')); |
---|
[0] | 105 | } |
---|
| 106 | |
---|
[196] | 107 | echo '<p><a class="back" href="'.$core->getPostAdminURL($post->post_type,$id).'">'. |
---|
[0] | 108 | sprintf(__('Back to "%s"'),html::escapeHTML($post->post_title)).'</a></p>'; |
---|
| 109 | |
---|
| 110 | echo |
---|
| 111 | '<h3 id="entry-preview-title">'. |
---|
| 112 | html::escapeHTML($post->post_title).'</h3>'. |
---|
| 113 | '<div class="frame-shrink" id="entry-preview">'. |
---|
| 114 | ($post->post_excerpt_xhtml ? $post->post_excerpt_xhtml.'<hr />' : ''). |
---|
| 115 | $post->post_content_xhtml. |
---|
| 116 | '</div>'; |
---|
| 117 | |
---|
| 118 | if (!empty($_GET['auto'])) { |
---|
| 119 | flush(); |
---|
| 120 | $tb_urls = implode("\n",$TB->discover($post->post_excerpt_xhtml.' '.$post->post_content_xhtml)); |
---|
| 121 | } else { |
---|
[196] | 122 | $auto_link = '<strong><a class="button" href="trackbacks.php?id='.$id.'&auto=1">'. |
---|
[0] | 123 | __('Auto discover ping URLs').'</a></strong>'; |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | echo |
---|
| 127 | '<h3>'.__('Ping blogs').'</h3>'. |
---|
| 128 | '<form action="trackbacks.php" id="trackback-form" method="post">'. |
---|
[1399] | 129 | '<p><label for="tb_urls" class="area">'.__('URLs to ping:').'</label>'. |
---|
[0] | 130 | form::textarea('tb_urls',60,5,$tb_urls). |
---|
[1399] | 131 | '</p>'. |
---|
[0] | 132 | |
---|
[1399] | 133 | '<p><label for="tb_excerpt" class="area">'.__('Send excerpt:').'</label>'. |
---|
| 134 | form::textarea('tb_excerpt',60,3,$tb_excerpt).'</p>'. |
---|
[0] | 135 | |
---|
| 136 | '<p>'.form::hidden('id',$id). |
---|
| 137 | $core->formNonce(). |
---|
| 138 | '<input type="submit" value="'.__('Ping blogs').'" /> '. |
---|
| 139 | $auto_link.'</p>'. |
---|
| 140 | '</form>'; |
---|
| 141 | |
---|
| 142 | $pings = $TB->getPostPings($id); |
---|
| 143 | |
---|
| 144 | if (!$pings->isEmpty()) |
---|
| 145 | { |
---|
| 146 | echo '<h3>'.__('Previously sent pings').'</h3>'; |
---|
| 147 | |
---|
| 148 | echo '<ul class="nice">'; |
---|
| 149 | while ($pings->fetch()) { |
---|
| 150 | echo |
---|
| 151 | '<li>'.dt::dt2str(__('%Y-%m-%d %H:%M'),$pings->ping_dt).' - '. |
---|
| 152 | $pings->ping_url.'</li>'; |
---|
| 153 | } |
---|
| 154 | echo '</ul>'; |
---|
| 155 | } |
---|
| 156 | |
---|
[1459] | 157 | dcPage::helpBlock('core_trackbacks'); |
---|
[0] | 158 | dcPage::close(); |
---|
| 159 | ?> |
---|