| [ Index ] |
|
Code source de Serendipity 1.2 |
1 <?php # $Id: comment.php 1055 2006-04-06 09:14:11Z garvinhicking $ 2 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team) 3 # All rights reserved. See LICENSE file for licensing details 4 5 include ('serendipity_config.inc.php'); 6 include S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php'; 7 8 header('Content-Type: text/html; charset=' . LANG_CHARSET); 9 10 if (isset($serendipity['GET']['delete'], $serendipity['GET']['entry'], $serendipity['GET']['type'])) { 11 serendipity_deleteComment($serendipity['GET']['delete'], $serendipity['GET']['entry'], $serendipity['GET']['type']); 12 if (serendipity_isResponseClean($_SERVER['HTTP_REFERER'])) { 13 header('Location: '. $_SERVER['HTTP_REFERER']); 14 } 15 } 16 17 if (isset($serendipity['GET']['switch'], $serendipity['GET']['entry'])) { 18 serendipity_allowCommentsToggle($serendipity['GET']['entry'], $serendipity['GET']['switch']); 19 } 20 21 serendipity_rememberComment(); 22 23 if (!($type = @$_REQUEST['type'])) { 24 $type = 'normal'; 25 } 26 27 $tb_logging = false; // for developers: can be switched to true! 28 29 if ($type == 'trackback') { 30 if ($tb_logging) { 31 # PHP 4.2.2 way of doing things 32 ob_start(); 33 print_r($_REQUEST); 34 $tmp = ob_get_contents(); 35 ob_end_clean(); 36 37 $fp = fopen('trackback2.log', 'a'); 38 fwrite($fp, '[' . date('d.m.Y H:i') . '] RECEIVED TRACKBACK' . "\n"); 39 fwrite($fp, '[' . date('d.m.Y H:i') . '] ' . $tmp . "\n"); 40 } 41 42 $uri = $_SERVER['REQUEST_URI']; 43 if (isset($_REQUEST['entry_id'])) { 44 $id = (int)$_REQUEST['entry_id']; 45 } else if ($_REQUEST['amp;entry_id']) { 46 // For possible buggy variable transmission caused by an intermediate CVS-release of s9y 47 $id = (int)$_REQUEST['amp;entry_id']; 48 } else if (preg_match('@/(\d+)_[^/]*$@', $uri, $matches)) { 49 $id = (int)$matches[1]; 50 } 51 52 if ($tb_logging) { 53 fwrite($fp, '[' . date('d.m.Y H:i') . '] Match on ' . $uri . "\n"); 54 fwrite($fp, '[' . date('d.m.Y H:i') . '] ID: ' . $id . "\n"); 55 fclose($fp); 56 } 57 58 if (add_trackback($id, $_REQUEST['title'], $_REQUEST['url'], $_REQUEST['blog_name'], $_REQUEST['excerpt'])) { 59 if ($tb_logging) { 60 $fp = fopen('trackback2.log', 'a'); 61 fwrite($fp, '[' . date('d.m.Y H:i') . '] TRACKBACK SUCCESS' . "\n"); 62 } 63 report_trackback_success(); 64 } else { 65 if ($tb_logging) { 66 $fp = fopen('trackback2.log', 'a'); 67 fwrite($fp, '[' . date('d.m.Y H:i') . '] TRACKBACK FAILURE' . "\n"); 68 } 69 report_trackback_failure(); 70 } 71 72 if ($tb_logging) { 73 fclose($fp); 74 } 75 } else if ($type == 'pingback') { 76 if (add_pingback($_REQUEST['entry_id'], $HTTP_RAW_POST_DATA)) { 77 report_pingback_success(); 78 } else { 79 report_pingback_failure(); 80 } 81 } else { 82 $id = (int)(!empty($serendipity['POST']['entry_id']) ? $serendipity['POST']['entry_id'] : $serendipity['GET']['entry_id']); 83 $serendipity['head_subtitle'] = COMMENTS; 84 $serendipity['smarty_file'] = 'commentpopup.tpl'; 85 serendipity_smarty_init(); 86 87 if ($id == 0) { 88 return false; 89 } else { 90 $serendipity['smarty']->assign('entry_id', $id); 91 } 92 93 if (isset($_GET['success']) && $_GET['success'] == 'true') { 94 $serendipity['smarty']->assign( 95 array( 96 'is_comment_added' => true, 97 'comment_url' => htmlspecialchars($_GET['url']) . '&serendipity[entry_id]=' . $id, 98 'comment_string' => explode('%s', COMMENT_ADDED_CLICK) 99 ) 100 ); 101 } else if (!isset($serendipity['POST']['submit'])) { 102 if ($serendipity['GET']['type'] == 'trackbacks') { 103 $query = "SELECT title, timestamp FROM {$serendipity['dbPrefix']}entries WHERE id = '". $id ."'"; 104 $entry = serendipity_db_query($query); 105 $entry = serendipity_archiveURL($id, $entry[0]['title'], 'baseURL', true, array('timestamp' => $entry[0]['timestamp'])); 106 107 $serendipity['smarty']->assign( 108 array( 109 'is_showtrackbacks' => true, 110 'comment_url' => $serendipity['baseURL'] . 'comment.php?type=trackback&entry_id=' . $id, 111 'comment_entryurl' => $entry 112 ) 113 ); 114 } else { 115 $query = "SELECT id, last_modified, timestamp, allow_comments, moderate_comments FROM {$serendipity['dbPrefix']}entries WHERE id = '" . $id . "'"; 116 $ca = serendipity_db_query($query, true); 117 $comment_allowed = serendipity_db_bool($ca['allow_comments']) || !is_array($ca) ? true : false; 118 $serendipity['smarty']->assign( 119 array( 120 'is_showcomments' => true, 121 'is_comment_allowed' => $comment_allowed 122 ) 123 ); 124 125 if ($comment_allowed) { 126 serendipity_displayCommentForm($id, '?', NULL, $serendipity['POST'], true, serendipity_db_bool($ca['moderate_comments']), $ca); 127 } 128 } 129 } else { 130 $comment['url'] = $serendipity['POST']['url']; 131 $comment['comment'] = trim($serendipity['POST']['comment']); 132 $comment['name'] = $serendipity['POST']['name']; 133 $comment['email'] = $serendipity['POST']['email']; 134 $comment['subscribe'] = $serendipity['POST']['subscribe']; 135 $comment['parent_id'] = $serendipity['POST']['replyTo']; 136 if (!empty($comment['comment'])) { 137 if (serendipity_saveComment($id, $comment, 'NORMAL')) { 138 $sc_url = $serendipity['baseURL'] . 'comment.php?serendipity[entry_id]=' . $id . '&success=true&url=' . urlencode($_SERVER['HTTP_REFERER']); 139 if (serendipity_isResponseClean($sc_url)) { 140 header('Location: ' . $sc_url); 141 } 142 exit; 143 } else { 144 $serendipity['smarty']->assign( 145 array( 146 'is_comment_notadded' => true, 147 'comment_url' => htmlspecialchars($_SERVER['HTTP_REFERER']), 148 'comment_string' => explode('%s', COMMENT_NOT_ADDED_CLICK) 149 ) 150 ); 151 } 152 } else { 153 $serendipity['smarty']->assign( 154 array( 155 'is_comment_empty' => true, 156 'comment_url' => htmlspecialchars($_SERVER['HTTP_REFERER']), 157 'comment_string' => explode('%s', EMPTY_COMMENT) 158 ) 159 ); 160 } 161 } 162 163 $serendipity['smarty']->display(serendipity_getTemplateFile($serendipity['smarty_file'], 'serendipityPath')); 164 } 165 /* vim: set sts=4 ts=4 expandtab : */ 166 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sat Nov 24 09:00:37 2007 | par Balluche grâce à PHPXref 0.7 |
|