trackback.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. # ***** BEGIN LICENSE BLOCK *****
  3. # This file is part of DotClear.
  4. # Copyright (c) 2004 Olivier Meunier and contributors. All rights
  5. # reserved.
  6. #
  7. # DotClear is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # DotClear is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with DotClear; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. #
  21. # ***** END LICENSE BLOCK *****
  22. require dirname(__FILE__).'/inc/prepend.php';
  23. require dirname(__FILE__).'/../inc/incutio/class.httpClient.php';
  24. require dirname(__FILE__).'/../inc/classes/class.dc.autodiscovery.php';
  25. $auth->check(1);
  26. include dirname(__FILE__).'/inc/connexion.php';
  27. $list_url = (!empty($_POST['list_url'])) ? $_POST['list_url'] : '';
  28. $tb_content = (!empty($_POST['tb_content'])) ? util::cutString($_POST['tb_content'],255) : '';
  29. $is_editable = false;
  30. $ping_res = array();
  31. $post_id = (!empty($_REQUEST['post_id'])) ? $_REQUEST['post_id'] : '';
  32. # Vérifications d'usage
  33. if ($post_id != '') {
  34. $post = $blog->getPostByID($post_id);
  35. if (!$post->isEmpty())
  36. {
  37. # Post éditable que par un admin ou son créateur
  38. if ($post->f('user_id') == $_SESSION['sess_user_id'] || $_SESSION['sess_user_level'] >= 9) {
  39. $is_editable = true;
  40. }
  41. }
  42. }
  43. # Création des trackback
  44. if ($is_editable && $list_url != '')
  45. {
  46. $list_url = str_replace("\r",'',$list_url);
  47. $turi = array_unique(explode("\n",$list_url));
  48. foreach ($turi as $uri)
  49. {
  50. if ($blog->postTbPingURL($post_id,$uri,dc_blog_name,$tb_content) !== false) {
  51. $ping_res[$uri]['status'] = true;
  52. } else {
  53. $ping_error = $blog->error();
  54. $ping_res[$uri]['status'] = false;
  55. $ping_res[$uri]['error'] = $ping_error[0][1];
  56. $blog->resetError();
  57. }
  58. }
  59. }
  60. # Sous menu
  61. $mySubMenu->addItem(
  62. __('Back to entry'),'poster.php?post_id='.$post_id,
  63. 'images/ico_retour.png',false);
  64. openPage(__('Pings'));
  65. ?>
  66. <h2><?php echo __('Pings'); ?></h2>
  67. <?php
  68. if (!$is_editable)
  69. {
  70. echo '<div class="erreur"><p><strong>'.__('Error(s)').' :</strong></p>'.
  71. '<p>'.__('No entry').'</p></div>';
  72. }
  73. else
  74. {
  75. $chapo = $post->f('post_chapo');
  76. $content = $post->f('post_content');
  77. if ($tb_content == '') {
  78. $tb_content = util::cutString(strip_tags($post->f('post_content')),252).'...';
  79. }
  80. echo '<div class="cadre preview clear">'.
  81. '<h3>'.$post->f('post_titre').'</h3>'.
  82. (($chapo != '') ? $chapo.'<hr class="thin" />' : '').
  83. $content.'</div>';
  84. if (!empty($_GET['auto']) && $_GET['auto'] == 1)
  85. {
  86. $autodisc = new autodiscover();
  87. $list_url = implode("\n",$autodisc->autoDiscovery($chapo."\n".$content));
  88. }
  89. if (empty($_GET['auto'])) {
  90. echo '<p><a href="trackback.php?post_id='.$post_id.'&auto=1">'.
  91. __('Auto discovery of ping URLs').'</a></p>';
  92. }
  93. echo '<form action="trackback.php" method="post">'.
  94. '<p><label for="list_url">'.__('Insert here URLs to ping').' :</label>'.
  95. form::textArea('list_url',30,5,
  96. htmlspecialchars($list_url),'','class="max"').
  97. '</p>'.
  98. '<p><label for="tb_content">'.__('Summary to send').'&nbsp;:</label>'.
  99. form::textArea('tb_content',30,3,
  100. $tb_content,'','class="max" '.
  101. 'onkeypress="limitArea(this,255);" onkeyup="limitArea(this,255);"').
  102. '</p>'.
  103. '<p><input type="submit" class="submit" value="'.__('Ping URLs').'" /> '.
  104. form::hidden('post_id',$post_id).
  105. '</p>'.
  106. '</form>';
  107. if (!empty($_POST['list_url']))
  108. {
  109. echo '<h3>'.__('Result').'</h3>';
  110. foreach ($ping_res as $k => $v)
  111. {
  112. if ($v['status']) {
  113. $img = '<img src="images/check_on.png" alt="OK" />';
  114. } else {
  115. $img = '<img src="images/check_off.png" alt="ERROR" />';
  116. }
  117. echo '<p>'.$img.' '.$k.'<br />'.
  118. '<strong>'.((!$v['status']) ? $v['error'] : 'Ping OK').'</strong>';
  119. '</p>';
  120. }
  121. }
  122. echo '<h3>'.__('Previous pings sent').'</h3>';
  123. $rs = $blog->postGetPings($post_id);
  124. if ($rs->isEmpty()) {
  125. echo '<p>'.__('No ping yet').'</p>';
  126. } else {
  127. echo '<ul>';
  128. while (!$rs->EOF())
  129. {
  130. echo '<li>'.
  131. '['.date('d/m/Y @ H:i:s',strtotime($rs->f('ping_dt'))).'] '.
  132. '<strong>'.$rs->f('ping_url').'</strong>'.
  133. '</li>';
  134. $rs->moveNext();
  135. }
  136. echo '</ul>';
  137. }
  138. }
  139. closePage();
  140. ?>