root/tags/1.0.0/log.php

Revision 1553, 10.7 KB (checked in by jeena, 3 years ago)

bugfixes

  • Property svn:executable set to *
Line 
1<?php
2 require('.'.DIRECTORY_SEPARATOR.'personal'.DIRECTORY_SEPARATOR.'settings.inc.php');
3 require(JLOG_BASEPATH.'lang'.DIRECTORY_SEPARATOR.'lang-admin.inc.php');
4
5 $get = strip($_GET);
6 $c['form_content'] = "";
7 $date = date(JLOG_DATE);
8
9 $sql_get = escape_for_mysql($get);
10
11        if(!empty($sql_get['y']) AND !empty($sql_get['m']) AND !empty($sql_get['url'])) {
12                $sql = "SELECT
13                                                *,
14                                                UNIX_TIMESTAMP(date) AS date,
15                                 DATE_FORMAT(date, '%Y-%m-%dT%T".substr(date("O"), 0, 3) . ":" . substr(date("O"), 3)."') AS metadate
16                                  FROM ".JLOG_DB_CONTENT."
17                                  WHERE
18                                                YEAR(date)      = ".$sql_get['y']." AND
19                                                MONTH(date)     = ".$sql_get['m']." AND
20                                                url                     = '".$sql_get['url']."' AND
21                                                section         = 'weblog'
22                                  LIMIT 1";
23
24        $blog = new Query($sql);
25        if($blog->error()) {
26                echo "<pre>\n";
27                echo $blog->getError();
28                echo "</pre>\n";
29                die();
30        }
31
32                if($blog->numRows() == 0) {
33                        header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
34                        include_once(JLOG_BASEPATH."error404.php");
35                        exit;
36                }
37        }
38        else {
39                header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
40                include_once(JLOG_BASEPATH."error404.php");
41                exit;
42        }
43
44 $blogentry = $blog->fetch();
45
46// get comments from Database
47
48        $sql_comments = "SELECT
49                                                                *,
50                                                                UNIX_TIMESTAMP(date) AS date
51                                                        FROM ".JLOG_DB_COMMENTS."
52                                                        WHERE reference = '".$blogentry['id']."'
53                                                        ORDER BY date;";
54
55 $c['meta']['date']        = $blogentry['metadate'];
56 $c['meta']['description'] = strip_tags($bbcode->parse($blogentry['teaser']));
57 $c['meta']['keywords']    = $blogentry['keywords'];
58 $c['meta']['title']       = $blogentry['topic'];
59 $c['meta']['pingback']    = true;
60
61 $c['main'] = do_entry($blogentry);
62
63// Form entry
64
65 $com_form = strip($_POST);
66 $error = com_check_errors($com_form);
67
68// Preview
69 if(isset($com_form['form_submitted']) AND $com_form['form_submitted'] === $l['comments_preview']) {
70
71    $comments = new Query($sql_comments);
72     if($comments->error()) {
73        echo "<pre>\n";
74        echo $comments->getError();
75        echo "</pre>\n";
76        die();
77     }
78
79    $commentsArray = array();
80    $countComments = 0;
81    while($commentsArray[] = $comments->fetch());
82    foreach($commentsArray as $tmp_comment) if($tmp_comment['type'] != 'pingback') ++$countComments;
83
84  $preview = "";
85  if(isset($error)) $preview .= error_output($error);
86  $clear_form = com_clean_data($com_form);
87  $clear_form['id'] = "";
88
89  $preview .= "
90   <ul class='comments' id='preview'>
91    ".do_comment($clear_form, $countComments)."
92   </ul>";
93
94  $c['form_content'] .= $preview;
95  $c['form_content'] .= com_form_output($com_form).com_javascript_variables();
96 }
97
98
99// Send data to DB
100 elseif(isset($com_form['form_submitted']) AND $com_form['form_submitted'] == $l['comments_send'] AND $blogentry['comments'] == 1) {
101  if(isset($error)) {
102
103   $c['form_content'] .= error_output($error);
104   $c['form_content'] .= com_form_output($com_form).com_javascript_variables();
105  }
106  else {
107 // Send comment
108
109   $com_form = com_clean_data($com_form);
110
111   ### Plugin Hook
112   $com_form = $plugins->callHook('newComment', $com_form);
113
114   $com = escape_for_mysql($com_form);
115   if(!isset($com['mail_by_comment'])) $com['mail_by_comment'] = "";
116   
117   $sql = "INSERT INTO ".JLOG_DB_COMMENTS." (
118                        sid,
119                        name,
120                        city,
121                        email,
122                        homepage,
123                        content,
124                        reference,
125                        mail_by_comment,
126                        date
127                  )
128           VALUES (
129            '".$com['sid']."',
130            '".$com['name']."',
131            '".$com['city']."',
132            '".$com['email']."',
133            '".$com['homepage']."',
134            '".$com['content']."',
135            '".$blogentry['id']."',
136            '".$com['mail_by_comment']."',
137            NOW()
138           )"; 
139
140   $newcomment = new Query($sql);
141   $cid = mysql_insert_id();
142   if($newcomment->error()) {
143    if($newcomment->getErrno() == 1062) {
144          $errors[] = $l['comments_duplicate'];
145     $c['form_content'] .= error_output($errors, 'entryform').com_javascript_variables();
146    }
147    else {
148     echo "<pre>\n";
149     echo $newcomment->getError();
150     echo "</pre>\n";
151     die();
152    }
153   }
154   else {
155    if(isset($com_form['cookie']) AND $com_form['cookie'] == 1) set_cookie($com_form);
156    else trash_cookie();
157   
158    include_once(JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'update.php');
159   
160     $sql = "SELECT DISTINCT email
161                            FROM ".JLOG_DB_COMMENTS." WHERE reference = '".$blogentry['id']."' AND mail_by_comment = 1";
162          $comment_mail = new Query($sql);
163   
164     if($comment_mail->error()) {
165      echo "<pre>\n";
166      echo $comment_mail->getError();
167      echo "</pre>\n";
168      die();
169     }
170     else {
171
172      if(JLOG_INFO_BY_COMMENT === true) {
173                 $mail['headers'] = "From: ";
174                 if(isset($com_form['name'])) $mail['headers'] .= $com_form['name'];
175                 else $mail['headers'] .= $l['admin']['comments_anonym'];
176                 if(isset($com_form['email'])) $mail['headers'] .= " <".$com_form['email'].">";
177                 $mail['headers'] .= "\r\nX-Mailer: PHP/".phpversion();
178
179
180       $mail['text'] = $l['admin']['comments_mail_txt']." »".$blogentry['topic'].\n- -\n";
181       if(isset($com_form['name'])) $mail['text'] .= $com_form['name'];
182       else $mail['text'] .= $l['admin']['comments_anonym'];
183       if(isset($com_form['city'])) $mail['text'] .= " ".$l['comments_from']." ".$com_form['city'];
184       $mail['text'] .= " ".$l['admin']['comments_posted']." ".$date.":\n\n";
185       $mail['text'] .= html_entity_decode(strip_tags($bbcomments->parse($com_form['content'])));
186       $mail['text'] .= "\n\n".str_replace ( '&amp;', '&', blog($blogentry['date'], $blogentry['url']))."#c".$cid;
187       $mail['text'] .= "\n\n".$l['admin']['kill_c_email']."\n".JLOG_PATH."/admin/comments.php?action=trash&id=".$cid;
188
189       @mail(JLOG_EMAIL, $l['admin']['comments_mailsubject']." - ".$blogentry['topic'], $mail['text'], $mail['headers']);
190      }
191
192                $mail['headers'] = "From: ".JLOG_WEBSITE." <".JLOG_EMAIL.">\r\n"
193                                   ."X-Mailer: PHP/".phpversion();
194
195                $mail['text'] = $l['comments_mail_txt']." »".$blogentry['topic'].\n- -\n";
196      if(isset($com_form['name'])) $mail['text'] .= $com_form['name'];
197      else $mail['text'] .= $l['comments_anonym'];
198      if(isset($com_form['city'])) $mail['text'] .= " ".$l['comments_from']." ".$com_form['city'];
199      $mail['text'] .= " ".$l['comments_posted']." ".$date.":\n\n";
200      $mail['text'] .= html_entity_decode(strip_tags($bbcomments->parse($com_form['content'])));
201      $mail['text'] .= "\n\n".str_replace ( '&amp;', '&', blog($blogentry['date'], $blogentry['url']))."#c".$cid."";
202      $mail['text'] .= "\n-- \n".$l['comments_stop_receiving']."\n";
203      $mail['text'] .= JLOG_PATH."/stop.php?id=".$blogentry['id']."&email=";
204
205      while ($data = $comment_mail->fetch()) {
206       if($data['email'] != $com['email']) {
207           @mail($data['email'], $l['comments_mailsubject']." - ".$blogentry['topic'], $mail['text'].$data['email'], $mail['headers']);
208       }
209      }
210     }
211    $c['form_content'] .= "<p id='entryform'>".$l['comments_thx']."</p>".com_javascript_variables();
212   }
213  }
214 }
215
216// If nothing happens
217 elseif($blogentry['comments'] == 1) {
218  $com_form['name']             = $l['comments_name'];
219  $com_form['city']             = $l['comments_city'];
220  $com_form['email']            = $l['comments_email'];
221  $com_form['homepage']         = $l['comments_homepage'];
222  $com_form['sid']              = new_sid();
223  if(isset($_COOKIE["jlog_userdata"])) {
224        $cookie = unserialize(urldecode($_COOKIE["jlog_userdata"]));
225         if($cookie != "")       $com_form['cookie']    = 1;
226         if($cookie[0] != "") $com_form['name']                 = $cookie[0];
227         if($cookie[1] != "") $com_form['city']                 = $cookie[1];
228         if($cookie[2] != "") $com_form['email']                = $cookie[2];
229         if($cookie[3] != "") $com_form['homepage']     = $cookie[3];
230  }
231  $c['form_content'] .= com_form_output($com_form).com_javascript_variables();
232 }
233 else $c['form_content'] .= "  <p id='entryform'>".$l['comments_closed']."</p>\n".com_javascript_variables();
234
235// get comments and pingbacks
236
237    $comments = new Query($sql_comments);
238     if($comments->error()) {
239        echo "<pre>\n";
240        echo $comments->getError();
241        echo "</pre>\n";
242        die();
243     }
244    $countPingbacks = 0;
245    $countComments = 0;
246    $commentsArray = array();
247    $no_comments = "";
248
249    while($tmp_commentsArray = $comments->fetch()) $commentsArray[] = $tmp_commentsArray;
250    foreach($commentsArray as $tmp_comment) {
251        if($tmp_comment['type'] == 'pingback') ++$countPingbacks;
252        else ++$countComments;
253    }
254
255    if($countPingbacks > 0)  {
256        if($countComments < 1) $no_comments = " class='entryform'";
257        $c['main'] .= "\n <h3 id='pingbacks'".$no_comments.">".$l['pingback_topic']."</h3>\n  <ol id='pingbackslist'>";
258        foreach($commentsArray as $pingback) {
259            if($pingback['type'] == 'pingback') $c['main'] .= "\n   <li><a href='".$pingback['homepage']."'>".$pingback['name']."</a></li>";
260        }
261        $c['main'] .= "\n  </ol>\n";
262    }
263
264 if($countComments < 1) $no_comments = " class='entryform'";
265 $c['main'] .= "\n <h3 id='comments'".$no_comments.">".$l['comments_comment_topic']."</h3>\n";
266
267 if($countComments > 0) {
268    $c['main'] .= "  <ul class='comments' id='commentslist'>";
269
270    $i = 0;
271    foreach($commentsArray as $data) {
272        if($data['type'] !== 'pingback') {
273            ++$i;
274            $data = com_clean_data($data);
275            $c['main'] .= do_comment($data, $i);
276        }
277    }
278
279    $c['main'] .= "\n  </ul>\n";
280  }
281
282 $c['main'] .= $c['form_content'];
283
284require(JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'do_template.php');
285echo $body;
286?>
Note: See TracBrowser for help on using the browser.