validpost.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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/libs/lib.validator.php';
  25. $auth->check(1);
  26. include dirname(__FILE__).'/inc/connexion.php';
  27. openPopup(__('Entry validation'));
  28. $post_id = (!empty($_GET['post_id'])) ? $_GET['post_id'] : '';
  29. $co_id = (!empty($_GET['co_id'])) ? $_GET['co_id'] : '';
  30. $is_post = $is_comment = false;
  31. if ($post_id != '')
  32. {
  33. $post = $blog->getPostByID($post_id);
  34. $is_post = true;
  35. echo '<h2>'.__('Entry validation').'</h2>';
  36. }
  37. elseif ($co_id != '')
  38. {
  39. $comment = $blog->getComment($co_id);
  40. $is_comment = true;
  41. echo '<h2>'.__('Comment validation').'</h2>';
  42. }
  43. if ((empty($post) || $post->isEmpty()) && (empty($comment) || $comment->isEmpty()))
  44. {
  45. echo
  46. '<div class="erreur"><p><strong>'.__('Error(s)').' :</strong></p>'.
  47. '<p>'.($is_post ? __('No entry') : __('No comment')).'</p></div>';
  48. }
  49. else
  50. {
  51. flush();
  52. if ($post_id != '') {
  53. $content = $post->f('post_chapo')."\n".$post->f('post_content');
  54. } else {
  55. $content = $comment->f('comment_content');
  56. }
  57. if (($valid = validator::xhtml($content)) === false)
  58. {
  59. echo '<p>'.__('Cannot connect to server.').'</p>';
  60. }
  61. elseif ($valid['valid'] == true)
  62. {
  63. echo '<h3>'.($is_post ? __('Valid entry') : __('Valid comment')).'</h3>';
  64. }
  65. elseif ($valid['valid'] == false)
  66. {
  67. echo '<h3>'.($is_post ? __('Invalid entry') : __('Invalid comment')).'</h3>';
  68. if ($valid['errors'] != '')
  69. {
  70. echo '<p>'.__('Errors list').'&nbsp;:</p>';
  71. echo $valid['errors'];
  72. }
  73. }
  74. echo '<p class="small">'.sprintf(__('Validation done with %s'),'WDG HTML Validator').'<br />'.
  75. 'http://www.htmlhelp.com/tools/validator/</p>';
  76. echo '<p><img src="images/wdglogo-small.gif" alt="" /></p>';
  77. }
  78. closePopup();
  79. ?>