Cheetah
Forum.php
Go to the documentation of this file.
1 <?php
2 
8 // forum operations
9 
10 class Forum extends ThingPage
11 {
12  // mandatory methods
13  var $getUserInfo; // $stringUser
14  var $getUserPerm; // $stringUser, $stringType (public, provate, own), $stringAction (read, post, edit, del, search, sticky), $intForumId
15  var $getLoginUser; // no parameters
16 
17  // optional methods
18  var $onPostReply; // $arrayTopic, $stringPostText, $stringUser
19  var $onPostEdit; // $arrayTopic, $intPostId, $stringPostText, $stringUser
20  var $onPostDelete; // $arrayTopic, $intPostId, $stringUser
21  var $onNewTopic; // $intForumId, $stringTopicSubject, $stringTopicText, $isTopicSticky, $stringUser, $stringTopicUri
22  var $onVote; // $intPostId, $stringUser, $intVote (1 or -1)
23  var $onReport; // $intPostId, $stringUser
24  var $onFlag; // $intTopicId, $stringUser
25  var $onUnflag; // $intTopicId, $stringUser
26 
30  function __construct ()
31  {
32  $this->fdb = new DbForum ();
33  }
34 
44  function getSearchResultsXML ($text, $type, $forum, $u, $disp, $start = 0, $isWholePage = false)
45  {
46  global $gConf;
47 
48  if (!$this->_checkUserPerm ('', '', 'search')) {
49  return $this->_no_access();
50  }
51 
52  $num = 0;
53  switch ($type) {
54  case 'msgs':
55  case 'tlts':
56  $a = $this->fdb->searchMessages (filter_to_db($text), filter_to_db($u), $forum, $type, ('posts' == $disp ? 1 : 0), $start, $num);
57  break;
58  default:
59  return '<error>[L[Wrong search type]]</error>';
60  }
61 
62  $ws = preg_split("/\s+/", $text);
63 
64  $ui = array();
65  $s = '';
66  switch ($type) {
67  case 'tlts':
68  foreach ($a as $r) {
69 
70  if (!$this->_checkUserPerm ('', $r['forum_type'], 'read', $r['forum_id']))
71  continue;
72 
73  encode_post_text($r['cat_name']);
74  encode_post_text($r['forum_title']);
75  encode_post_text($r['topic_title'], true);
76 
77  // search hightlight
78  if ($text) {
79  foreach ($ws as $w) {
80  if ($w) {
81  $wreg = preg_quote($w, '/');
82  $r['topic_title'] = preg_replace ("/($wreg)/i", "<span style=\"background-color:yellow\">$w</span>", $r['topic_title']);
83  }
84  }
85  }
86 
87  // acquire user info
88  if (!isset($ui[$r['user']]) && ($aa = $this->_getUserInfoReadyArray ($r['user'])))
89  $ui[$r['user']] = $aa;
90 
91  $r['date'] = ch_html_attribute(orca_format_date($r['date']));
92 
93  $s .= <<<EOF
94  <sr date="{$r['date']}">
95  <c id="{$r['cat_id']}" uri="{$r['cat_uri']}">{$r['cat_name']}</c>
96  <f id="{$r['forum_id']}" uri="{$r['forum_uri']}">{$r['forum_title']}</f>
97  <t id="{$r['topic_id']}" uri="{$r['topic_uri']}">{$r['topic_title']}</t>
98  <u>
99  <avatar>{$ui[$r['user']]['avatar']}</avatar>
100  <avatar_medium>{$ui[$r['user']]['avatar64']}</avatar_medium>
101  <profile>{$ui[$r['user']]['url']}</profile>
102  <profile_title>{$ui[$r['user']]['title']}</profile_title>
103  <onclick>{$ui[$r['user']]['onclick']}</onclick>
104  <role>{$ui[$r['user']]['role']}</role>
105  </u>
106  </sr>
107 EOF;
108  }
109  break;
110  case 'msgs':
111  foreach ($a as $r) {
112 
113  if (!$this->_checkUserPerm ('', $r['forum_type'], 'read', $r['forum_id']))
114  continue;
115 
116  // search hightlight
117  if ($text) {
118  foreach ($ws as $w) {
119  if ($w) {
120  $wreg = preg_quote($w, '/');
121  $ind = preg_match( "/([^>]*<)/i", $r['post_text'], $ind ); // html tags?
122  if ($ind)
123  $r['post_text'] = preg_replace("/($wreg)(?=[^>]*<)/i", "<span style=\"background-color:yellow\">$w</span>", "<div>{$r['post_text']}</div>");
124  else
125  $r['post_text'] = preg_replace("/($wreg)/i", "<span style=\"background-color:yellow\">$w</span>", $r['post_text']);
126  }
127  }
128  }
129 
130  encode_post_text ($r['post_text']);
131  encode_post_text($r['cat_name']);
132  encode_post_text($r['forum_title']);
133  encode_post_text($r['topic_title'], true);
134 
135  if ($text) {
136  foreach ($ws as $w) {
137  $wreg = preg_quote($w, '/');
138  $r['topic_title'] = preg_replace ("/($wreg)/i", "<span style=\"background-color:yellow\">$w</span>", $r['topic_title']);
139  }
140  }
141 
142  // acquire user info
143  if (!isset($ui[$r['user']]) && ($aa = $this->_getUserInfoReadyArray ($r['user'])))
144  $ui[$r['user']] = $aa;
145 
146  $r['date'] = ch_html_attribute(orca_format_date($r['date']));
147 
148  $s .= <<<EOF
149  <sr date="{$r['date']}">
150  <c id="{$r['cat_id']}" uri="{$r['cat_uri']}">{$r['cat_name']}</c>
151  <f id="{$r['forum_id']}" uri="{$r['forum_uri']}">{$r['forum_title']}</f>
152  <t id="{$r['topic_id']}" uri="{$r['topic_uri']}">{$r['topic_title']}</t>
153  <p id="{$r['post_id']}">{$r['post_text']}</p>
154  <u name="{$r['user']}">
155  <avatar>{$ui[$r['user']]['avatar']}</avatar>
156  <avatar_medium>{$ui[$r['user']]['avatar64']}</avatar_medium>
157  <profile>{$ui[$r['user']]['url']}</profile>
158  <profile_title>{$ui[$r['user']]['title']}</profile_title>
159  <onclick>{$ui[$r['user']]['onclick']}</onclick>
160  <role>{$ui[$r['user']]['role']}</role>
161  </u>
162  </sr>
163 EOF;
164  }
165  break;
166  }
167 
168  $p = $this->_getPages ($start, $num, $gConf['topics_per_page']);
169 
170  $textEncoded = ch_js_string($text, CH_ESCAPE_STR_APOS);
171  $userEncoded = ch_js_string($u, CH_ESCAPE_STR_APOS);
172 
173  $sp = <<<EOS
174 <search_text><![CDATA[$text]]></search_text>
175 <search_params>
176  <text><![CDATA[$textEncoded]]></text>
177  <type>$type</type>
178  <forum>$forum</forum>
179  <user><![CDATA[$userEncoded]]></user>
180  <disp>$disp</disp>
181 </search_params>
182 EOS;
183  $cu = $this->getUrlsXml ();
184  encode_post_text($text);
185 
186  if ($isWholePage) {
187  $this->setTitle ('<![CDATA[[L[Search Results For:]]' . $text . ']]>');
188  $li = $this->_getLoginInfo ($u);
189  return $this->addHeaderFooter ($li, "<search>{$sp}<pages num=\"$num\" per_page=\"{$gConf['topics_per_page']}\">$p</pages>$s</search>");
190  } else {
191  return "<root>$cu<search>{$sp}<pages num=\"$num\" per_page=\"{$gConf['topics_per_page']}\">$p</pages>$s</search></root>";
192  }
193  }
194 
198  function getSearchXML ($wp = false)
199  {
200  if (!$this->_checkUserPerm ('', '', 'search')) {
201  return $this->_no_access($wp);
202  }
203 
204  $s = $this->getCategsShortXML('read');
205 
206  $cu = $this->getUrlsXml ();
207 
208  if ($wp) {
209  $this->setTitle ('<![CDATA[[L[Search The Forum]]]]>');
210  $li = $this->_getLoginInfo ($u);
211  return $this->addHeaderFooter ($li, "<search>$s</search>");
212  } else {
213  return "<root>$cu<search>$s</search></root>";
214  }
215  }
216 
220  function getNewTopicXML ($forum_uri, $isWholePage = false)
221  {
222  $f = $this->fdb->getForumByUri (filter_to_db($forum_uri));
223  $forum_id = isset($f['forum_id']) ? $f['forum_id'] : 0;
224 
225  if (!$this->_checkUserPerm ('', isset($f['forum_type']) ? $f['forum_type'] : 'public', 'post', $forum_id)) {
226  return $this->_no_access();
227  }
228 
229  $sticky = 0;
230  if ($this->_checkUserPerm ('', '', 'sticky', $forum_id)) {
231  $sticky = 1;
232  }
233 
234  encode_post_text ($f['forum_title']);
235  encode_post_text ($f['forum_desc']);
236 
237  $x1 = <<<EOF
238 <forum>
239  <id>{$f['forum_id']}</id>
240  <uri>{$f['forum_uri']}</uri>
241  <title>{$f['forum_title']}</title>
242  <desc>{$f['forum_desc']}</desc>
243  <type>{$f['forum_type']}</type>
244 </forum>
245 EOF;
246 
247  $cat = $this->fdb->getCat ($f['cat_id']);
248  encode_post_text ($cat['cat_name']);
249  $x2 = <<<EOF
250 <cat>
251  <id>{$f['cat_id']}</id>
252  <uri>{$cat['cat_uri']}</uri>
253  <title>{$cat['cat_name']}</title>
254 </cat>
255 EOF;
256 
257  $x3 = $this->getCategsShortXML('post');
258 
259  $cu = $this->getUrlsXml ();
260 
261  $u = $this->_getLoginUser();
262  $signature = $this->fdb->getSignature ($u);
263  encode_post_text ($signature);
264 
265  if ($isWholePage) {
266  $this->setTitle ('<![CDATA[[L[New Topic]]]]>');
267  $li = $this->_getLoginInfo ($u);
268  return $this->addHeaderFooter ($li, "<new_topic sticky=\"$sticky\">{$x2}{$x1}{$x3}<signature>{$signature}</signature></new_topic>");
269  } else {
270  return "<root>$cu<new_topic sticky=\"$sticky\">{$x2}{$x1}{$x3}<signature>{$signature}</signature></new_topic></root>";
271  }
272  }
273 
277  function getPostReplyXML ($forum_id, $topic_id)
278  {
279  $f = $this->fdb->getForum ($forum_id);
280 
281  $t = $this->fdb->getTopic ((int)$topic_id);
282 
283  if (!$this->_checkUserPerm ('', $f['forum_type'], 'post', (int)$forum_id) || $t['topic_locked']) {
284  return $this->_no_access();
285  }
286 
287  encode_post_text ($f['forum_title']);
288  encode_post_text ($f['forum_desc']);
289 
290  $x1 = <<<EOF
291 <forum>
292  <id>{$f['forum_id']}</id>
293  <uri>{$f['forum_uri']}</uri>
294  <title>{$f['forum_title']}</title>
295  <desc>{$f['forum_desc']}</desc>
296  <type>{$f['forum_type']}</type>
297 </forum>
298 EOF;
299 
300  $u = $this->_getLoginUser();
301  $signature = $this->fdb->getSignature ($u);
302  encode_post_text ($signature);
303 
304  $cu = $this->getUrlsXml ();
305  return "<root>$cu<new_topic>$x1<topic><id>$topic_id</id></topic><signature>{$signature}</signature></new_topic></root>";
306  }
307 
313  function getHiddenPostXML ($post_id, $force_show)
314  {
315  global $gConf;
316 
317  $post_id = (int)$post_id;
318  if (!$post_id) return false;
319 
320  $ui = array ();
321 
322  $t = $this->fdb->getTopicByPostId ($post_id);
323  $topic_id = $t['topic_id'];
324 
325  $f = $this->fdb->getForum ($t['forum_id']);
326  $forum_id = $f['forum_id'];
327 
328  // check user permission to read this topic posts
329 
330  $forum_type = $f['forum_type'];
331 
332  if (!$this->_checkUserPerm ('', $forum_type, 'read', $forum_id)) {
333  return $this->_no_access();
334  }
335 
336  // check user permissions to delete or edit posts
337  $gl_allow_edit = 0;
338  $gl_allow_del = 0;
339  $gl_allow_hide_posts = 0;
340  $gl_allow_unhide_posts = 0;
341  $gl_allow_download = 0;
342 
343  if ($this->_checkUserPerm ('', $forum_type, 'edit', $forum_id))
344  $gl_allow_edit = 1;
345 
346  if ($this->_checkUserPerm ('', $forum_type, 'del', $forum_id))
347  $gl_allow_del = 1;
348 
349  if ($this->_checkUserPerm ('', '', 'hide_posts', $forum_id))
350  $gl_allow_hide_posts = 1;
351 
352  if ($this->_checkUserPerm ('', '', 'unhide_posts', $forum_id))
353  $gl_allow_unhide_posts = 1;
354 
355  if ($this->_checkUserPerm ('', '', 'download', $forum_id));
356  $gl_allow_download = 1;
357 
358  $u = $this->_getLoginUser();
359 
360  $r = $this->fdb->getPost($post_id, $u);
361 
362  // acquire user info
363  if (!isset($ui[$r['user']]) && ($aa = $this->_getUserInfoReadyArray ($r['user']))) {
364  $ui[$r['user']] = $aa;
365  $ui[$r['user']]['posts'] = (int)$this->fdb->getUserPosts($r['user']);
366  }
367 
368  $allow_edit = $gl_allow_edit;
369  $allow_del = $gl_allow_del;
370 
371  if (!$allow_edit && $r['user'] == $this->_getLoginUserName()) {
372  if ($this->_checkUserPerm ($r['user'], 'own', 'edit', $forum_id) && !$this->_isEditTimeout($r['post_id']) && !$t['topic_locked'])
373  $allow_edit = 1;
374  }
375 
376  if (!$allow_del && $r['user'] == $this->_getLoginUserName()) {
377  if ($this->_checkUserPerm ($r['user'], 'own', 'del', $forum_id) && !$this->_isEditTimeout($r['post_id']) && !$t['topic_locked'])
378  $allow_del = 1;
379  }
380 
381  $cu = $this->getUrlsXml ();
382  $li = "<logininfo>" . array2xml($this->_getLoginInfo ($u)) . "</logininfo>";
383 
384  $files = $this->_getAttachmentsXML ($r['post_id']);
385 
386  encode_post_text ($r['post_text'], false, true);
387 
388  $r['when'] = orca_format_date($r['when']);
389 
390  return <<<EOF
391 <root>
392 $cu
393 $li
394 <forum>
395  <id>{$f['forum_id']}</id>
396  <uri>{$f['forum_uri']}</uri>
397 </forum>
398 <topic>
399  <id>$topic_id</id>
400  <uri>{$t['topic_uri']}</uri>
401 </topic>
402 <post id="{$r['post_id']}" force_show="$force_show">
403  <text>{$r['post_text']}</text>
404  <when>{$r['when']}</when>
405  <allow_edit>$allow_edit</allow_edit>
406  <allow_del>$allow_del</allow_del>
407  <allow_hide_posts>$gl_allow_hide_posts</allow_hide_posts>
408  <allow_unhide_posts>$gl_allow_unhide_posts</allow_unhide_posts>
409  <allow_download>$gl_allow_download</allow_download>
410  <points>{$r['votes']}</points>
411  <hidden>{$r['hidden']}</hidden>
412  <vote_user_point>{$r['vote_user_point']}</vote_user_point>
413  <user posts="{$ui[$r['user']]['posts']}" name="{$r['user']}">
414  <avatar>{$ui[$r['user']]['avatar']}</avatar>
415  <avatar_medium>{$ui[$r['user']]['avatar64']}</avatar_medium>
416  <url>{$ui[$r['user']]['url']}</url>
417  <title>{$ui[$r['user']]['title']}</title>
418  <onclick>{$ui[$r['user']]['onclick']}</onclick>
419  <role>{$ui[$r['user']]['role']}</role>
420  </user>
421  <attachments>$files</attachments>
422  <min_point>{$gConf['min_point']}</min_point>
423 </post>
424 </root>
425 EOF;
426  }
427 
433  function getPostsXML ($topic_uri, $wp)
434  {
435  global $gConf;
436 
437  $ui = array ();
438 
439  $u = $this->_getLoginUser();
440  $a = $this->fdb->getPostsByUri(filter_to_db($topic_uri), $u);
441  $topic_id = $a[0]['topic_id'];
442 
443  // check user permission to read this topic posts
444  $f = $this->fdb->getForum ($a[0]['forum_id']);
445  $forum_id = $f['forum_id'];
446  $forum_type = $f['forum_type'];
447 
448  if (!$this->_checkUserPerm ($u, $forum_type, 'read', $forum_id)) {
449  return $this->_no_access($wp);
450  }
451 
452  $t = $this->fdb->getTopic ($topic_id);
453 
454  $gl_allow_hide_topics = 0;
455  $gl_allow_unhide_topics = 0;
456  $gl_allow_lock_topics = 0;
457  $gl_allow_stick_topics = 0;
458 
459  if ($this->_checkUserPerm ($u, '', 'hide_topics', $forum_id))
460  $gl_allow_hide_topics = 1;
461 
462  if ($this->_checkUserPerm ($u, '', 'unhide_topics', $forum_id))
463  $gl_allow_unhide_topics = 1;
464 
465  if (!$gl_allow_unhide_topics && !$gl_allow_hide_topics && $t['topic_hidden'])
466  return $this->_no_access($wp);
467 
468  if ($this->_checkUserPerm ($u, '', 'lock', $forum_id))
469  $gl_allow_lock_topics = 1;
470 
471  if ($this->_checkUserPerm ($u, '', 'sticky', $forum_id))
472  $gl_allow_stick_topics = 1;
473 
474  $this->setTrackTopic ($topic_id);
475 
476  // check user permissions to delete or edit posts
477  $gl_allow_edit = 0;
478  $gl_allow_del = 0;
479  $gl_allow_hide_posts = 0;
480  $gl_allow_unhide_posts = 0;
481 
482  $gl_allow_move_topics = 0;
483  $gl_allow_del_topics = 0;
484  $gl_allow_download = 0;
485 
486  if ($this->_checkUserPerm ($u, $forum_type, 'edit', $forum_id))
487  $gl_allow_edit = 1;
488 
489  if ($this->_checkUserPerm ($u, $forum_type, 'del', $forum_id))
490  $gl_allow_del = 1;
491 
492  if ($this->_checkUserPerm ($u, '', 'hide_posts', $forum_id))
493  $gl_allow_hide_posts = 1;
494 
495  if ($this->_checkUserPerm ('', '', 'unhide_posts', $forum_id))
496  $gl_allow_unhide_posts = 1;
497 
498  if ($this->_checkUserPerm ($u, '', 'move_topics', $forum_id))
499  $gl_allow_move_topics = 1;
500 
501  if ($this->_checkUserPerm ($u, '', 'del_topics', $forum_id))
502  $gl_allow_del_topics = 1;
503 
504  if ($this->_checkUserPerm ('', '', 'download', $forum_id));
505  $gl_allow_download = 1;
506 
507  $p = '';
508  foreach ($a as $r) {
509 
510  // acquire user info
511  if (!$ui[$r['user']] && ($aa = $this->_getUserInfoReadyArray ($r['user']))) {
512  $signature = $this->fdb->getSignature ($r['user']);
513  encode_post_text ($signature);
514  $ui[$r['user']] = $aa;
515  $ui[$r['user']]['signature'] = $signature;
516  $ui[$r['user']]['posts'] = (int)$this->fdb->getUserPosts($r['user']);
517  }
518 
519  $allow_edit = $gl_allow_edit;
520  $allow_del = $gl_allow_del;
521 
522  if (!$allow_edit && $r['user'] == $u) {
523  if ($this->_checkUserPerm ($r['user'], 'own', 'edit', $forum_id) && !$this->_isEditTimeout($r['post_id']) && !$t['topic_locked'])
524  $allow_edit = 1;
525  }
526 
527  if (!$allow_del && $r['user'] == $u) {
528  if ($this->_checkUserPerm ($r['user'], 'own', 'del', $forum_id) && !$this->_isEditTimeout($r['post_id']) && !$t['topic_locked'])
529  $allow_del = 1;
530  }
531 
532  $files = $this->_getAttachmentsXML ($r['post_id']);
533 
534  encode_post_text ($r['post_text'], false, true);
535 
536  $r['when'] = orca_format_date($r['when']);
537 
538  $p .= <<<EOF
539 <post id="{$r['post_id']}" force_show="0">
540  <text>{$r['post_text']}</text>
541  <when>{$r['when']}</when>
542  <allow_edit>$allow_edit</allow_edit>
543  <allow_del>$allow_del</allow_del>
544  <allow_hide_posts>$gl_allow_hide_posts</allow_hide_posts>
545  <allow_unhide_posts>$gl_allow_unhide_posts</allow_unhide_posts>
546  <allow_download>$gl_allow_download</allow_download>
547  <points>{$r['votes']}</points>
548  <hidden>{$r['hidden']}</hidden>
549  <vote_user_point>{$r['vote_user_point']}</vote_user_point>
550  <user posts="{$ui[$r['user']]['posts']}" name="{$r['user']}">
551  <avatar>{$ui[$r['user']]['avatar']}</avatar>
552  <avatar_medium>{$ui[$r['user']]['avatar64']}</avatar_medium>
553  <url>{$ui[$r['user']]['url']}</url>
554  <title>{$ui[$r['user']]['title']}</title>
555  <onclick>{$ui[$r['user']]['onclick']}</onclick>
556  <role>{$ui[$r['user']]['role']}</role>
557  <signature>{$ui[$r['user']]['signature']}</signature>
558  </user>
559  <attachments>$files</attachments>
560  <min_point>{$gConf['min_point']}</min_point>
561 </post>
562 EOF;
563  $rr = $r;
564  }
565 
566  $cat = $this->fdb->getCat ($f['cat_id']);
567  encode_post_text ($cat['cat_name']);
568  $x0 = <<<EOF
569 <cat>
570  <id>{$cat['cat_id']}</id>
571  <uri>{$cat['cat_uri']}</uri>
572  <title>{$cat['cat_name']}</title>
573 </cat>
574 EOF;
575 
576  encode_post_text ($t['forum_title']);
577  encode_post_text ($t['forum_desc']);
578  $x1 = <<<EOF
579 <forum>
580  <id>{$f['forum_id']}</id>
581  <uri>{$f['forum_uri']}</uri>
582  <title>{$t['forum_title']}</title>
583  <desc>{$t['forum_desc']}</desc>
584  <type>{$f['forum_type']}</type>
585 </forum>
586 EOF;
587  encode_post_text ($t['topic_title'], true);
588  $topic_flagged = $this->fdb->isFlagged ($rr['topic_id'], $u) ? 1 : 0;
589  $x2 = <<<EOF
590 <topic>
591  <id>{$t['topic_id']}</id>
592  <uri>{$t['topic_uri']}</uri>
593  <title>{$t['topic_title']}</title>
594  <locked>{$t['topic_locked']}</locked>
595  <sticky>{$t['topic_sticky']}</sticky>
596  <hidden>{$t['topic_hidden']}</hidden>
597  <flagged>{$topic_flagged}</flagged>
598  <allow_hide_topics>$gl_allow_hide_topics</allow_hide_topics>
599  <allow_unhide_topics>$gl_allow_unhide_topics</allow_unhide_topics>
600  <allow_move_topics>$gl_allow_move_topics</allow_move_topics>
601  <allow_del_topics>$gl_allow_del_topics</allow_del_topics>
602  <allow_lock_topics>$gl_allow_lock_topics</allow_lock_topics>
603  <allow_stick_topics>$gl_allow_stick_topics</allow_stick_topics>
604 </topic>
605 EOF;
606 
607  if ($wp) {
608  $this->setTitle($t['topic_title']);
609  $li = $this->_getLoginInfo ($u);
610  return $this->addHeaderFooter ($li, "<posts>{$x0}{$x1}{$x2}{$p}</posts>");
611  } else {
612  $cu = $this->getUrlsXml ();
613  $li = $this->_getLoginInfo ($u);
614  encode_post_text ($li['profile_title']);
615  return "<root><logininfo>" . array2xml($li) . "</logininfo>$cu<posts>{$x0}{$x1}{$x2}{$p}</posts></root>";
616  }
617  }
618 
619 
624  function getXxxTopicsXML ($wp, $sTitle, $sDesc, $sFunc, $start = 0)
625  {
626  global $gConf;
627 
628  $user = $this->getLoginUser();
629 
630  if (!$user) {
631  return $this->_no_access($wp);
632  }
633 
634  $x1 = <<<EOF
635 <forum>
636  <title><![CDATA[$sTitle]]></title>
637  <desc><![CDATA[$sDesc]]></desc>
638 </forum>
639 EOF;
640 
641  $x2 = '';
642 
643  $user_last_act = (int)$this->fdb->getUserLastActivity ($user);
644 
645  $num = 0;
646  $a = $this->fdb->$sFunc($user, $start, $num);
647  $t = '';
648  foreach ($a as $r) {
649  $lp = $this->fdb->getTopicPost($r['topic_id'], 'last');
650  $fp = $this->fdb->getTopicPost($r['topic_id'], 'first');
651 
652  // acquire user info
653  if (!isset($ui[$fp['user']]) && ($aa = $this->_getUserInfoReadyArray ($fp['user'])))
654  $ui[$fp['user']] = $aa;
655  if (!isset($ui[$lp['user']]) && ($aa = $this->_getUserInfoReadyArray ($lp['user'])))
656  $ui[$lp['user']] = $aa;
657 
658  $td = $this->fdb->getTopicDesc ($r['topic_id']);
659  $td = orca_mb_substr($td, 0, $gConf['topics_desc_len']);
660  if (orca_mb_len($td) == $gConf['topics_desc_len'])
661  $td .= '...';
662  $this->_buld_topic_desc ($td);
663 
664  if (!$user)
665  $new_topic = 0;
666  else
667  $new_topic = $this->isNewTopic ($r['topic_id'], $r['last_post_when'], $user_last_act) ? 1 : 0;
668 
669  encode_post_text ($r['topic_title'], true);
670 
671  $lp['when'] = orca_format_date($lp['when']);
672  $fp['when'] = orca_format_date($fp['when']);
673 
674  $t .= <<<EOF
675 <topic id="{$r['topic_id']}" new="$new_topic" lpt="{$r['last_post_when']}" lut="{$user_last_act}">
676  <uri>{$r['topic_uri']}</uri>
677  <title>{$r['topic_title']}</title>
678  <desc>{$td}</desc>
679  <count>{$r['count_posts']}</count>
680  <last_u>
681  <avatar>{$ui[$lp['user']]['avatar']}</avatar>
682  <avatar_medium>{$ui[$lp['user']]['avatar64']}</avatar_medium>
683  <profile>{$ui[$lp['user']]['url']}</profile>
684  <profile_title>{$ui[$lp['user']]['title']}</profile_title>
685  <profile_link>{$ui[$lp['user']]['link']}</profile_link>
686  <onclick>{$ui[$lp['user']]['onclick']}</onclick>
687  <role>{$ui[$lp['user']]['role']}</role>
688  </last_u>
689  <last_d>{$lp['when']}</last_d>
690  <first_u>
691  <avatar>{$ui[$fp['user']]['avatar']}</avatar>
692  <avatar_medium>{$ui[$fp['user']]['avatar64']}</avatar_medium>
693  <profile>{$ui[$fp['user']]['url']}</profile>
694  <profile_title>{$ui[$fp['user']]['title']}</profile_title>
695  <profile_link>{$ui[$fp['user']]['link']}</profile_link>
696  <onclick>{$ui[$fp['user']]['onclick']}</onclick>
697  <role>{$ui[$fp['user']]['role']}</role>
698  </first_u>
699  <first_d>{$fp['when']}</first_d>
700 </topic>
701 EOF;
702  }
703 
704  $p = $this->_getPages ($start, $num, $gConf['topics_per_page']);
705 
706  if ($wp) {
707  $this->setTitle($sTitle);
708  $li = $this->_getLoginInfo ();
709  return $this->addHeaderFooter ($li, "<topics><pages num=\"$num\" per_page=\"{$gConf['topics_per_page']}\">$p</pages>{$x2}{$x1}{$t}</topics>");
710  } else {
711  $cu = $this->getUrlsXml ();
712  return "<root>$cu<topics><pages num=\"$num\" per_page=\"{$gConf['topics_per_page']}\">$p</pages>{$x2}{$x1}{$t}</topics></root>";
713  }
714  }
715 
720  function getHiddenTopicsXML ($wp, $start = 0)
721  {
722  return $this->getXxxTopicsXML ($wp, '[L[Hidden Topics]]', '[L[Hidden topics]]', 'getHiddenTopics', $start);
723  }
724 
729  function getMyThreadsXML ($wp, $start = 0)
730  {
731  return $this->getXxxTopicsXML ($wp, '[L[My Topics]]', '[L[Topics you participate in]]', 'getMyThreadsTopics', $start);
732  }
733 
738  function getMyFlagsXML ($wp, $start = 0)
739  {
740  return $this->getXxxTopicsXML ($wp, '[L[Flagged topics]]', '[L[Topics you have flagged]]', 'getMyFlaggedTopics', $start);
741  }
742 
749  function getTopicsXML ($forum_uri, $wp, $start = 0)
750  {
751  global $gConf;
752 
753  $f = $this->fdb->getForumByUri (filter_to_db($forum_uri));
754  $forum_id = $f['forum_id'];
755 
756  $user = $this->getLoginUser();
757 
758  if (!$this->_checkUserPerm ($user, $f['forum_type'], 'read', $forum_id)) {
759  return $this->_no_access($wp);
760  }
761 
762  encode_post_text ($f['forum_title']);
763  encode_post_text ($f['forum_desc']);
764 
765  $x1 = <<<EOF
766 <forum>
767  <id>{$f['forum_id']}</id>
768  <uri>{$f['forum_uri']}</uri>
769  <title>{$f['forum_title']}</title>
770  <desc>{$f['forum_desc']}</desc>
771  <type>{$f['forum_type']}</type>
772 </forum>
773 EOF;
774 
775  $cat = $this->fdb->getCat ($f['cat_id']);
776  encode_post_text ($cat['cat_name']);
777  $x2 = <<<EOF
778 <cat>
779  <id>{$cat['cat_id']}</id>
780  <uri>{$cat['cat_uri']}</uri>
781  <title>{$cat['cat_name']}</title>
782 </cat>
783 EOF;
784 
785  $user_last_act = (int)$this->fdb->getUserLastActivity ($user);
786 
787  $a = $this->fdb->getTopics($forum_id, $start);
788  $ui = array();
789  $t = '';
790  foreach ($a as $r) {
791  // acquire user info
792  if (!isset($ui[$r['first_post_user']]) && ($aa = $this->_getUserInfoReadyArray ($r['first_post_user'])))
793  $ui[$r['first_post_user']] = $aa;
794  if (!isset($ui[$r['last_post_user']]) && ($aa = $this->_getUserInfoReadyArray ($r['last_post_user'])))
795  $ui[$r['last_post_user']] = $aa;
796 
797  $td = $this->fdb->getTopicDesc ($r['topic_id']);
798  $td = orca_mb_substr($td, 0, $gConf['topics_desc_len']);
799  if (orca_mb_len($td) == $gConf['topics_desc_len'])
800  $td .= '...';
801  $this->_buld_topic_desc ($td);
802 
803  if (!$user)
804  $new_topic = 0;
805  else
806  $new_topic = $this->isNewTopic ($r['topic_id'], $r['last_post_when'], $user_last_act) ? 1 : 0;
807 
808  encode_post_text ($r['topic_title'], true);
809  $r['last_when'] = orca_format_date($r['last_when']);
810  $r['first_when'] = orca_format_date($r['first_when']);
811 
812  $t .= <<<EOF
813 <topic id="{$r['topic_id']}" new="$new_topic" lpt="{$r['last_post_when']}" lut="{$user_last_act}" sticky="{$r['topic_sticky']}" locked="{$r['topic_locked']}">
814  <uri>{$r['topic_uri']}</uri>
815  <title>{$r['topic_title']}</title>
816  <desc>{$td}</desc>
817  <count>{$r['count_posts']}</count>
818  <last_u>
819  <avatar>{$ui[$r['last_post_user']]['avatar']}</avatar>
820  <avatar_medium>{$ui[$r['last_post_user']]['avatar64']}</avatar_medium>
821  <profile>{$ui[$r['last_post_user']]['url']}</profile>
822  <profile_title>{$ui[$r['last_post_user']]['title']}</profile_title>
823  <profile_link>{$ui[$r['last_post_user']]['link']}</profile_link>
824  <onclick>{$ui[$r['last_post_user']]['onclick']}</onclick>
825  <role>{$ui[$r['last_post_user']]['role']}</role>
826  </last_u>
827  <last_d>{$r['last_when']}</last_d>
828  <first_u>
829  <avatar>{$ui[$r['first_post_user']]['avatar']}</avatar>
830  <avatar_medium>{$ui[$r['first_post_user']]['avatar64']}</avatar_medium>
831  <profile>{$ui[$r['first_post_user']]['url']}</profile>
832  <profile_title>{$ui[$r['first_post_user']]['title']}</profile_title>
833  <profile_link>{$ui[$r['first_post_user']]['link']}</profile_link>
834  <onclick>{$ui[$r['first_post_user']]['onclick']}</onclick>
835  <role>{$ui[$r['first_post_user']]['role']}</role>
836  </first_u>
837  <first_d>{$r['first_when']}</first_d>
838 </topic>
839 EOF;
840  }
841 
842  $num = $this->fdb->getTopicsNum($forum_id);
843  $p = $this->_getPages ($start, $num, $gConf['topics_per_page']);
844 
845  if ($wp) {
846  $this->setTitle($f['forum_title']);
847  $li = $this->_getLoginInfo ($user);
848  return $this->addHeaderFooter ($li, "<topics><pages num=\"$num\" per_page=\"{$gConf['topics_per_page']}\">$p</pages>{$x2}{$x1}{$t}</topics>");
849  } else {
850  $cu = $this->getUrlsXml ();
851  return "<root>$cu<topics><pages num=\"$num\" per_page=\"{$gConf['topics_per_page']}\">$p</pages>{$x2}{$x1}{$t}</topics></root>";
852  }
853  }
854 
861  function getRecentTopicsXML ($wp, $start = 0)
862  {
863  global $gConf;
864 
865  $user = $this->getLoginUser();
866 
867  $user_last_act = (int)$this->fdb->getUserLastActivity ($user);
868 
869  $a = $this->fdb->getRecentTopics($start);
870  $ui = array();
871  $t = '';
872  foreach ($a as $r) {
873  if (!$this->_checkUserPerm ('', $r['forum_type'], 'read', $r['forum_id']))
874  continue;
875 
876  // acquire user info
877  if (!isset($ui[$r['first_post_user']]) && ($aa = $this->_getUserInfoReadyArray ($r['first_post_user'])))
878  $ui[$r['first_post_user']] = $aa;
879  if (!isset($ui[$r['last_post_user']]) && ($aa = $this->_getUserInfoReadyArray ($r['last_post_user'])))
880  $ui[$r['last_post_user']] = $aa;
881 
882  if (!$user)
883  $new_topic = 0;
884  else
885  $new_topic = $this->isNewTopic ($r['topic_id'], $r['last_post_when'], $user_last_act) ? 1 : 0;
886 
887  encode_post_text ($r['topic_title'], true);
888  encode_post_text ($r['forum_title']);
889  encode_post_text ($r['cat_name']);
890 
891  $r['last_when'] = orca_format_date($r['last_when']);
892  $r['first_when'] = orca_format_date($r['first_when']);
893 
894  $t .= <<<EOF
895 <topic id="{$r['topic_id']}" new="$new_topic" lpt="{$r['last_post_when']}" lut="{$user_last_act}" sticky="{$r['topic_sticky']}" locked="{$r['topic_locked']}">
896  <uri>{$r['topic_uri']}</uri>
897  <title>{$r['topic_title']}</title>
898  <desc />
899  <count>{$r['count_posts']}</count>
900  <last_u>
901  <avatar>{$ui[$r['last_post_user']]['avatar']}</avatar>
902  <avatar_medium>{$ui[$r['last_post_user']]['avatar64']}</avatar_medium>
903  <profile>{$ui[$r['last_post_user']]['url']}</profile>
904  <profile_title>{$ui[$r['last_post_user']]['title']}</profile_title>
905  <profile_link>{$ui[$r['last_post_user']]['link']}</profile_link>
906  <onclick>{$ui[$r['last_post_user']]['onclick']}</onclick>
907  <role>{$ui[$r['last_post_user']]['role']}</role>
908  </last_u>
909  <last_d>{$r['last_when']}</last_d>
910  <first_u>
911  <avatar>{$ui[$r['first_post_user']]['avatar']}</avatar>
912  <avatar_medium>{$ui[$r['first_post_user']]['avatar64']}</avatar_medium>
913  <profile>{$ui[$r['first_post_user']]['url']}</profile>
914  <profile_title>{$ui[$r['first_post_user']]['title']}</profile_title>
915  <profile_link>{$ui[$r['first_post_user']]['link']}</profile_link>
916  <onclick>{$ui[$r['first_post_user']]['onclick']}</onclick>
917  <role>{$ui[$r['first_post_user']]['role']}</role>
918  </first_u>
919  <first_d>{$r['first_when']}</first_d>
920  <forum id="{$r['forum_id']}" uri="{$r['forum_uri']}">{$r['forum_title']}</forum>
921  <cat id="{$r['cat_id']}" uri="{$r['cat_uri']}">{$r['cat_name']}</cat>
922 </topic>
923 EOF;
924  }
925 
926  $num = $this->fdb->getRecentTopicsNum();
927  $p = $this->_getPages ($start, $num, $gConf['topics_per_page']);
928 
929  $aParams = array();
930  $sCategories = '';//$this->getCategoriesXML ($wp, $aParams);
931 
932  if ($wp) {
933  $this->setTitle('[L[Recent Topics]]');
934  $li = $this->_getLoginInfo ($user);
935  return $this->addHeaderFooter ($li, "<topics><pages num=\"$num\" per_page=\"{$gConf['topics_per_page']}\">$p</pages>{$t}</topics>$sCategories");
936  } else {
937  $cu = $this->getUrlsXml ();
938  return "<root>$cu<topics><pages num=\"$num\" per_page=\"{$gConf['topics_per_page']}\">$p</pages>{$t}</topics>$sCategories</root>";
939  }
940  }
941 
945  function getTrackTopics ()
946  {
947  $a = unserialize($_COOKIE['track_topics']);
948  if (!is_array($a)) return array ();
949  return $a;
950  }
951 
955  function setTrackTopic ($topic_id)
956  {
957  $a = unserialize($_COOKIE['track_topics']);
958  if (!is_array($a)) $a = array ();
959  $a[$topic_id] = time();
960  setcookie ('track_topics', serialize($a));
961  }
962 
967  function isNewTopic ($topic_id, $topic_last_time, $user_last_time)
968  {
969  $a = $this->getTrackTopics ();
970 
971  if ($a[$topic_id] && $topic_last_time > $a[$topic_id])
972  return 1;
973  else if ($a[$topic_id])
974  return 0;
975 
976  if (!$user_last_time) return 1;
977 
978  if ($topic_last_time > $user_last_time) return 1;
979 
980  return 0;
981  }
982 
986  function getCategsShortXML ($sCheckPermission = false)
987  {
988  $a = $this->fdb->getCategs();
989  $c = '';
990  foreach ($a as $r) {
991  $c .= "<categ id=\"{$r['cat_id']}\" uri=\"{$r['cat_uri']}\">";
992  encode_post_text($r['cat_name']);
993  $c .= "<title>{$r['cat_name']}</title>";
994  $c .= '<forums>' . $this->getForumsShortXML ($r['cat_id'], 0, $sCheckPermission) . '</forums>';
995  $c .= "</categ>";
996  }
997 
998  return "<categs>$c</categs>";
999  }
1000 
1004  function getForumsShortXML ($cat, $root, $sCheckPermission = false)
1005  {
1006  $c = $root ? '<forums>' : '';
1007  $aa = $this->fdb->getForums ($cat);
1008  foreach ($aa as $rr) {
1009  if ($sCheckPermission && !$this->_checkUserPerm ('', $rr['forum_type'], $sCheckPermission, $rr['forum_id']))
1010  continue;
1011 
1012  encode_post_text($rr['forum_title']);
1013 
1014  $c .= <<<EOF
1015 <forum id="{$rr['forum_id']}">
1016  <uri>{$rr['forum_uri']}</uri>
1017  <title>{$rr['forum_title']}</title>
1018  <type>{$rr['forum_type']}</type>
1019 </forum>
1020 
1021 EOF;
1022  }
1023  return $root ? ($c . "</forums>\n") : $c;
1024  }
1025 
1029  function getForumsXML ($cat, $root)
1030  {
1031  if ($root)
1032  $c = '<forums>';
1033  else
1034  $c = '';
1035  $aa = $this->fdb->getForumsByCatUri (filter_to_db($cat));
1036 
1037  foreach ($aa as $rr) {
1038  if (!$this->_checkUserPerm ('', $rr['forum_type'], 'read', $rr['forum_id']))
1039  continue;
1040 
1041  encode_post_text ($rr['forum_title']);
1042  encode_post_text ($rr['forum_desc']);
1043 
1044  if (!$rr['forum_last_ts'])
1045  $rr['forum_last'] = '';
1046  else
1047  $rr['forum_last'] = orca_format_date($rr['forum_last']);
1048 
1049  $c .= <<<EOF
1050 <forum id="{$rr['forum_id']}" new="0" cat="$cat">
1051  <uri>{$rr['forum_uri']}</uri>
1052  <title>{$rr['forum_title']}</title>
1053  <desc>{$rr['forum_desc']}</desc>
1054  <type>{$rr['forum_type']}</type>
1055  <posts>{$rr['forum_posts']}</posts>
1056  <topics>{$rr['forum_topics']}</topics>
1057  <last>{$rr['forum_last']}</last>
1058 </forum>
1059 
1060 EOF;
1061  }
1062 
1063  if ($root) {
1064  $cu = $this->getUrlsXml ();
1065  return '<root>' . $cu . $c . "</forums></root>\n";
1066  } else {
1067  return $c;
1068  }
1069  }
1070 
1071 
1072 
1076  function getPageXML ($first_load = 1, &$p)
1077  {
1078  global $gConf;
1079 
1080  if (isset($p['manage_forum']) && $p['manage_forum'] && !$this->isAdmin()) {
1081  return $this->_no_access($first_load);
1082  }
1083 
1084  $s = $this->getCategoriesXML ($first_load, $p);
1085 
1086  // live tracker
1087  $lt = '';//"<live_tracker>" . $this->getLivePostsXML() . "</live_tracker>";
1088 
1089  $li = $this->_getLoginInfo ();
1090 
1091  if ($first_load) {
1092  return $this->addHeaderFooter ($li, $s.$lt);
1093  } else {
1094  $cu = $this->getUrlsXml ();
1095  return "<root>$cu<logininfo>".array2xml($li)."</logininfo><page>{$s}{$lt}</page></root>";
1096  }
1097  }
1098 
1102  function getCategoriesXML ($first_load = 1, &$p)
1103  {
1104  global $gConf;
1105 
1106  $a = $this->fdb->getCategs();
1107  $c = '';
1108  foreach ($a as $r) {
1109  $icon_url = $r['cat_icon'] ? $gConf['url']['icon'] . $r['cat_icon'] : '';
1110  $c .= "<categ id=\"{$r['cat_id']}\" uri=\"{$r['cat_uri']}\" icon=\"$icon_url\" count_posts=\"{$r['count_posts']}\" count_topics=\"{$r['count_topics']}\" count_forums=\"{$r['count_forums']}\">";
1111  encode_post_text ($r['cat_name']);
1112  $c .= "<title>{$r['cat_name']}</title>";
1113 
1114  if ((isset($p['cat']) && $p['cat'] == $r['cat_uri']) || ($r['cat_expanded'] && !isset($p['cat']))) {
1115  $this->setTitle ($r['cat_name']);
1116  $c .= '<forums>'.$this->getForumsXML ($r['cat_uri'], 0) . '</forums>';
1117  }
1118  $c .= "</categ>";
1119  }
1120 
1121  $s = "<categs>$c</categs>";
1122 
1123  if ($first_load && isset($p['action']) && 'goto' == $p['action'] && isset($p['forum_id']))
1124  $s .= "<onload>f.selectForum('" . $p['forum_id'] . "', 0)</onload>";
1125 
1126  if ($first_load && isset($p['action']) && 'goto' == $p['action'] && isset($p['topic_id']))
1127  $s .= "<onload>f.selectTopic('" . $p['topic_id'] . "')</onload>";
1128 
1129  return $s;
1130  }
1131 
1132  function liveTracker ()
1133  {
1134  $lt = "<live_tracker>" . $this->getLivePostsXML() . "</live_tracker>";
1135  return $this->addHeaderFooter ($li, $lt);
1136  }
1137 
1138  function getLivePostsXML ($count = 10, $ts = 0)
1139  {
1140  global $gConf;
1141 
1142  $ret = '';
1143 
1144  if ($ts < (time() - 172800))
1145  $ts = 0;
1146 
1147  $a = $this->fdb->getLivePosts ($count, $ts);
1148  $ui = array ();
1149  foreach ($a as $r) {
1150  // acquire user info
1151  if (!isset($ui[$r['user']]) && ($aa = $this->_getUserInfoReadyArray ($r['user'])))
1152  $ui[$r['user']] = $aa;
1153 
1154  $this->_buld_topic_desc ($r['post_text']);
1155 
1156  encode_post_text($r['topic_title'], true);
1157  encode_post_text($r['forum_title']);
1158  encode_post_text($r['cat_name']);
1159 
1160  $r['when'] = $this->_format_when ($r['sec']);
1161 
1162  $ret .= <<<EOF
1163 <post id="{$r['post_id']}" ts="{$r['ts']}">
1164  <text>{$r['post_text']}</text>
1165  <user>{$r['user']}</user>
1166  <date>{$r['when']}</date>
1167 
1168  <avatar>{$ui[$r['user']]['avatar']}</avatar>
1169  <avatar_medium>{$ui[$r['user']]['avatar64']}</avatar_medium>
1170  <profile>{$ui[$r['user']]['url']}</profile>
1171  <profile_title>{$ui[$r['user']]['title']}</profile_title>
1172  <onclick>{$ui[$r['user']]['onclick']}</onclick>
1173  <role>{$ui[$r['user']]['role']}</role>
1174 
1175  <topic id="{$r['topic_id']}" uri="{$r['topic_uri']}">{$r['topic_title']}</topic>
1176  <forum id="{$r['forum_id']}" uri="{$r['forum_uri']}">{$r['forum_title']}</forum>
1177  <cat id="{$r['cat_id']}" uri="{$r['cat_uri']}">{$r['cat_name']}</cat>
1178  <base>{$gConf['url']['base']}</base>
1179 </post>
1180 EOF;
1181  }
1182 
1183  return $ret;
1184  }
1185 
1190  function isNewPost ($ts)
1191  {
1192  return '<ret>' . (int)$this->fdb->getNewPostTs ($ts) . '</ret>';
1193  }
1194 
1195 
1200  function postReplyXML (&$p)
1201  {
1202  global $gConf;
1203 
1204  $f = $this->fdb->getForum ((int)$p['forum_id']);
1205 
1206  $t = $this->fdb->getTopic ((int)$p['topic_id']);
1207 
1208  if (!$this->_checkUserPerm ('', $f['forum_type'], 'post', (int)$p['forum_id']) || $t['topic_locked'] || ch_is_spam($p['topic_text'])) {
1209  return <<<EOF
1210 <html>
1211 <body>
1212 <script language="javascript" type="text/javascript">
1213  window.parent.document.f.accessDenied();
1214 </script>
1215 </body>
1216 </html>
1217 EOF;
1218  }
1219 
1220 
1221  // post mesage here
1222 
1223  $p['forum_id'] = (int)$p['forum_id'];
1224  $p['topic_id'] = (int)$p['topic_id'];
1225 
1226  $user = $this->_getLoginUserName ();
1227 
1228  prepare_to_db($p['topic_text'], 1);
1229 
1230  // check if max number of posts per topic is reached
1231  if ($t['topic_posts'] >= $gConf['max_posts']) {
1232  $t = $this->topicAutoContinue($t);
1233  }
1234 
1235  $iReplyId = $this->fdb->postReply ($p['forum_id'], $t['topic_id'], $p['topic_text'], $user);
1236  $aReply = $this->fdb->getPost($iReplyId, '');
1237 
1238  $this->_handleSignature ($_POST, $user);
1239 
1240  $isUploadSuccess = $this->_handleUpload ($p, $iReplyId);
1241 
1242  $t = $this->fdb->getTopic($t['topic_id']);
1243 
1244  if (is_callable($this->onPostReply))
1245  call_user_func_array ($this->onPostReply, array($t, $aReply['post_text'], $user));
1246 
1247  return <<<EOF
1248 <html>
1249 <body>
1250 <script language="javascript" type="text/javascript">
1251  if (!$isUploadSuccess)
1252  window.parent.alert ('[L[Some or all files upload failed]]');
1253  window.parent.document.f.replySuccess('{$f['forum_uri']}', '{$t['topic_uri']}');
1254 </script>
1255 </body>
1256 </html>
1257 EOF;
1258 
1259 
1260  }
1261 
1267  function topicAutoContinue ($t)
1268  {
1269  global $gConf;
1270 
1271  // extract index of last topic to continue from
1272  $iTopicIndex = 1;
1273  $sTopicUri = $t['topic_uri'];
1274  $iPos = mb_strpos($t['topic_uri'], '.');
1275  if (false !== $iPos) {
1276  $iTopicIndexOld = mb_substr($t['topic_uri'], $iPos + 1);
1277  if ((int)$iTopicIndexOld) {
1278  $iTopicIndex = (int)$iTopicIndexOld;
1279  $sTopicUri = mb_substr($t['topic_uri'], 0, $iPos);
1280  }
1281  }
1282 
1283  // generate new topic uri
1284  $iLimit = 1000;
1285  do {
1286  $sNewTopicUri = $sTopicUri . '.' . (++$iTopicIndex);
1287  } while (--$iLimit && $this->uriCheckUniq($sTopicUri, TF_FORUM_TOPIC, 'topic_uri'));
1288 
1289  // create new topic with service post
1290  $aTopicFirst = $this->fdb->getTopicByUri($sTopicUri);
1291  $sNewTopicSubj = ($aTopicFirst ? $aTopicFirst['topic_title'] : $t['topic_title']) . sprintf('[L[continue_topic_suffix - %d]]', $iTopicIndex);
1292  $sOldTopicUrl = $gConf['url']['base'] . sprintf($gConf['rewrite']['topic'], $t['topic_uri']);
1293  $sNewTopicText = sprintf('[L[continue_topic_first %s]]', '<a href="' . $sOldTopicUrl . '">' . $t['topic_title'] . '</a>');
1294  prepare_to_db($sNewTopicSubj, -1);
1295  prepare_to_db($sNewTopicText, 1);
1296  $iNewTopicReply = $this->fdb->newTopic ((int)$t['forum_id'], $sNewTopicSubj, $sNewTopicText, false, $gConf['robot'], $sNewTopicUri);
1297  $aNewTopicReply = $this->fdb->getPost($iNewTopicReply, '');
1298  $aNewTopic = $this->fdb->getTopic($aNewTopicReply['topic_id']);
1299 
1300  // add service reply in old topic
1301  $sNewTopicUrl = $gConf['url']['base'] . sprintf($gConf['rewrite']['topic'], $sNewTopicUri);
1302  $sOldTopicText = sprintf('[L[continue_topic_last %s]]', '<a href="' . $sNewTopicUrl . '">' . $aNewTopic['topic_title'] . '</a>');
1303  prepare_to_db($sOldTopicText, 1);
1304  $iReplyId = $this->fdb->postReply ((int)$t['forum_id'], $t['topic_id'], $sOldTopicText, $gConf['robot']);
1305 
1306  // lock old topic
1307  if (!$this->fdb->isLocked($t['topic_id']))
1308  $this->fdb->lock($t['topic_id'], $gConf['robot']);
1309 
1310  // trasfer subscribers to new topic
1311  $a = $this->fdb->getSubscribersToTopic ($t['topic_id']);
1312  foreach ($a as $r)
1313  $this->fdb->flag($aNewTopic['topic_id'], $r['user']);
1314 
1315  return $aNewTopic;
1316  }
1317 
1323  function editPostXml ($post_id, $topic_id)
1324  {
1325  $cu = $this->getUrlsXml ();
1326  if ($post_id) {
1327  $a = $this->fdb->getTopicByPostId ($post_id);
1328  $t = $this->fdb->getTopic ($a['topic_id']);
1329  $topic_id = $t['topic_uri'];
1330 
1331  $timeout = 'disabled';
1332  $access = 'deny';
1333  if ($this->_checkUserPerm ('', $t['forum_type'], 'edit', $t['forum_id']) )
1334  $access = 'allow';
1335  if ('deny' == $access
1336  &&
1337  ($user = $this->fdb->getPostUser((int)$post_id)) == $this->_getLoginUserName()
1338  &&
1339  $this->_checkUserPerm ('', 'own', 'edit', $t['forum_id']) ) {
1340 
1341  $when = $this->fdb->getPostWhen ((int)$post_id);
1342  $timeout = $GLOBALS['gConf']['edit_timeout'] - (time() - $when);
1343  $access = $timeout > 10 && !$t['topic_locked'] ? 'allow' : 'deny';
1344  }
1345  }
1346 
1347  $files = '';
1348  $signature = '';
1349  if ('allow' == $access) {
1350  $files = $this->_getAttachmentsXML ((int)$post_id);
1351  $signature = $this->fdb->getSignature ($this->fdb->getPostUser((int)$post_id));
1352  encode_post_text ($signature);
1353  }
1354 
1355  return <<<EOS
1356 <root>
1357  $cu
1358  <edit_post>
1359  <post_id>$post_id</post_id>
1360  <topic_id>$topic_id</topic_id>
1361  <timeout>$timeout</timeout>
1362  <access>$access</access>
1363  <attachments>$files</attachments>
1364  <signature>$signature</signature>
1365  </edit_post>
1366 </root>
1367 EOS;
1368  }
1369 
1376  function editPost ($post_id, $topic_id, $text)
1377  {
1378  $no_access = true;
1379 
1380  $t = $this->fdb->getTopicByUri (filter_to_db($topic_id));
1381  $user = $this->fdb->getPostUser((int)$post_id);
1382 
1383  if ($this->_checkUserPerm ('', $t['forum_type'], 'edit', $t['forum_id']))
1384  $no_access = false;
1385  if ($no_access && $user == $this->_getLoginUserName())
1386  if ($this->_checkUserPerm ('', 'own', 'edit', $t['forum_id']) && !$this->_isEditTimeout((int)$post_id) && !$t['topic_locked'])
1387  $no_access = false;
1388 
1389  if ($no_access) {
1390  return <<<EOF
1391 <html>
1392 <body>
1393 <script language="javascript" type="text/javascript">
1394  window.parent.document.f.accessDenied();
1395 </script>
1396 </body>
1397 </html>
1398 EOF;
1399  }
1400 
1401  // edit post here
1402  prepare_to_db($text, 1);
1403 
1404  $this->fdb->editPost ($post_id, $text, $user);
1405 
1406  $this->_handleSignature ($_POST, $user);
1407 
1408  $isUploadSuccess = $this->_handleUpload ($_POST, $post_id);
1409 
1410  if (is_callable($this->onPostEdit))
1411  call_user_func_array ($this->onPostEdit, array($t, $post_id, $text, $user));
1412 
1413  return <<<EOF
1414 <html>
1415 <body>
1416 <script language="javascript" type="text/javascript">
1417  if (!$isUploadSuccess)
1418  window.parent.alert ('[L[Some or all files upload failed]]');
1419  window.parent.document.f.editSuccess('{$t['topic_uri']}');
1420 </script>
1421 </body>
1422 </html>
1423 EOF;
1424 
1425  }
1426 
1433  function deletePostXML ($post_id, $topic_id, $forum_id)
1434  {
1435  $no_access = true;
1436 
1437  $f = $this->fdb->getForumByPostId ($post_id);
1438  $aTopic = $this->fdb->getTopic ($topic_id);
1439  $sPostUser = $this->fdb->getPostUser((int)$post_id);
1440  $sUser = $this->_getLoginUserName();
1441 
1442  if ($this->_checkUserPerm ('', $f['forum_type'], 'del', $f['forum_id']))
1443  $no_access = false;
1444  if ($no_access && $sPostUser == $sUser)
1445  if ($this->_checkUserPerm ('', 'own', 'del', $f['forum_id']) && !$this->_isEditTimeout((int)$post_id) && !$aTopic['topic_locked'])
1446  $no_access = false;
1447 
1448  if ($no_access || 0 !== strcasecmp($_SERVER['REQUEST_METHOD'], 'POST')) {
1449  return <<<EOF
1450 <html>
1451 <body>
1452 <script language="javascript" type="text/javascript">
1453  window.parent.document.f.accessDenied();
1454 </script>
1455 </body>
1456 </html>
1457 EOF;
1458  }
1459 
1460  // delete post here
1461 
1462  $this->fdb->deletePost ($post_id, $sPostUser == $sUser ? '' : $sUser);
1463 
1464  $exists = $this->fdb->getTopic ($topic_id) ? 1 : 0;
1465 
1466  if (is_callable($this->onPostDelete))
1467  call_user_func_array ($this->onPostDelete, array($aTopic, $post_id, $user));
1468 
1469  return <<<EOF
1470 <html>
1471 <body>
1472 <script language="javascript" type="text/javascript">
1473  window.parent.document.f.deleteSuccess('{$f['forum_uri']}', '{$aTopic['topic_uri']}', {$exists});
1474 </script>
1475 </body>
1476 </html>
1477 EOF;
1478 
1479  }
1480 
1487  function hidePost ($is_hide, $post_id)
1488  {
1489  $f = $this->fdb->getForumByPostId((int)$post_id);
1490  $user = $this->_getLoginUserName();
1491  if (0 !== strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') || !$this->_checkUserPerm ($user, '', 'hide_posts', $f ? $f['forum_id'] : 0))
1492  return '<ret>0</ret>';
1493 
1494  if (!$this->fdb->hidePost ((int)$is_hide, (int)$post_id, $user))
1495  return '<ret>0</ret>';
1496 
1497  if (is_callable($this->onPostHideUnhide))
1498  call_user_func_array ($this->onPostHideUnhide, array($is_hide, $post_id, $user));
1499 
1500  return '<ret>1</ret>';
1501  }
1502 
1507  function moveTopicForm ($topic_id)
1508  {
1509  $cu = $this->getUrlsXml ();
1510 
1511  $t = $this->fdb->getTopic ($topic_id);
1512 
1513  $s = '<forums>';
1514  $ac = $this->fdb->getCategs();
1515  foreach ($ac as $c) {
1516  $s .= '<cat name="'. htmlspecialchars($c['cat_name']) .'">';
1517 
1518  $af = $this->fdb->getForumsByCatUri (filter_to_db($c['cat_uri']));
1519 
1520  foreach ($af as $f) {
1521  encode_post_text ($f['forum_title']);
1522  $s .= '<forum id="' . $f['forum_id'] . '" uri="' . $f['forum_uri'] . '" selected="' . ($t['forum_id'] == $f['forum_id'] ? 1 : 0) . '">' . $f['forum_title'] . '</forum>';
1523  }
1524 
1525  $s .= '</cat>';
1526  }
1527  $s .= '</forums>';
1528 
1529  return <<<EOS
1530 <root>
1531 $cu
1532 <form>
1533  <topic>
1534  <id>{$t['topic_id']}</id>
1535  <title><![CDATA[{$t['topic_title']}]]></title>
1536  <uri>{$t['topic_uri']}</uri>
1537  <forum_id>{$t['forum_id']}</forum_id>
1538  </topic>
1539  $s
1540 </form>
1541 </root>
1542 EOS;
1543  }
1544 
1545  function moveTopicSubmit ($topic_id, $forum_id, $old_forum_id, $goto_new_location)
1546  {
1547  $user = $this->_getLoginUserName();
1548  if (0 !== strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') || !$this->_checkUserPerm ($user, '', 'move_topics', (int)$forum_id) || !$topic_id || !$forum_id || !$old_forum_id)
1549  return '<ret>0</ret>';
1550 
1551  if (!$this->fdb->moveTopic ((int)$topic_id, (int)$forum_id, (int)$old_forum_id))
1552  return '<ret>0</ret>';
1553 
1554  if (is_callable($this->onTopicMove))
1555  call_user_func_array ($this->onTopicMove, array($topic_id, $forum_id, $user));
1556 
1557  $f = $this->fdb->getForum($goto_new_location ? $forum_id : $old_forum_id);
1558  return "<ret>{$f['forum_uri']}</ret>";
1559  }
1560 
1565  function delTopic ($topic_id)
1566  {
1567  $f = $this->fdb->getForumByTopicId ((int)$topic_id);
1568  $user = $this->_getLoginUserName();
1569  if (0 !== strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') || !$this->_checkUserPerm ($user, '', 'del_topics', $f ? $f['forum_id'] : 0))
1570  return '<ret>0</ret>';
1571 
1572  if (!$this->fdb->delTopic ((int)$topic_id, $user))
1573  return '<ret>0</ret>';
1574 
1575  if (is_callable($this->onTopicDelete))
1576  call_user_func_array ($this->onTopicDelete, array($topic_id, $user));
1577 
1578  return '<ret>1</ret>';
1579  }
1580 
1586  function hideTopic ($is_hide, $topic_id)
1587  {
1588  $f = $this->fdb->getForumByTopicId ((int)$topic_id);
1589  $user = $this->_getLoginUserName();
1590  if (0 !== strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') || !$this->_checkUserPerm ($user, '', $is_hide ? 'hide_topics' : 'unhide_topics', $f ? $f['forum_id'] : 0))
1591  return '<ret>0</ret>';
1592 
1593  if (!$this->fdb->hideTopic ((int)$is_hide, (int)$topic_id, $user))
1594  return '<ret>0</ret>';
1595 
1596  if (is_callable($this->onTopicHideUnhide))
1597  call_user_func_array ($this->onTopicHideUnhide, array($is_hide, $topic_id, $user));
1598 
1599  return '<ret>1</ret>';
1600  }
1601 
1606  function stick ($topic_id)
1607  {
1608  $f = $this->fdb->getForumByTopicId ((int)$topic_id);
1609  $user = $this->_getLoginUserName();
1610  if (0 !== strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') || !$this->_checkUserPerm ($user, '', 'sticky', $f ? $f['forum_id'] : 0))
1611  return '<ret>0</ret>';
1612 
1613  if (!$this->fdb->stick ((int)$topic_id, $user))
1614  return '<ret>0</ret>';
1615 
1616  $t = $this->fdb->getTopic($topic_id);
1617  return $t['topic_sticky'] ? '<ret>1</ret>' : '<ret>-1</ret>';
1618  }
1619 
1624  function lock ($topic_id)
1625  {
1626  $f = $this->fdb->getForumByTopicId ((int)$topic_id);
1627  $user = $this->_getLoginUserName();
1628  if (0 !== strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') || !$this->_checkUserPerm ($user, '', 'lock', $f ? $f['forum_id'] : 0))
1629  return '<ret>0</ret>';
1630 
1631  if (!$this->fdb->lock ((int)$topic_id, $user))
1632  return '<ret>0</ret>';
1633 
1634  return $this->fdb->isLocked ((int)$topic_id) ? '<ret>1</ret>' : '<ret>-1</ret>';
1635  }
1636 
1641  function postNewTopicXML ($p)
1642  {
1643  $sAccessDeniedCode = <<<EOF
1644 <html>
1645 <body>
1646 <script language="javascript" type="text/javascript">
1647 
1648  if (window.parent.document.getElementById('tinyEditor'))
1649  window.parent.tinyMCE.execCommand('mceRemoveEditor', false, 'tinyEditor');
1650 
1651  window.parent.document.f.accessDenied();
1652 
1653 </script>
1654 </body>
1655 </html>
1656 EOF;
1657 
1658  $f = $this->fdb->getForum ((int)$p['forum']);
1659 
1660  if (!$this->_checkUserPerm ('', $f['forum_type'], 'post', (int)$p['forum']) || ch_is_spam($p['topic_text']))
1661  return $sAccessDeniedCode;
1662 
1663  if ($p['topic_sticky'] == 'on' && !$this->_checkUserPerm ('', '', 'sticky', (int)$p['forum']))
1664  return $sAccessDeniedCode;
1665 
1666 
1667  // post mesage here
1668 
1669  $user = $this->_getLoginUserName ();
1670 
1671  prepare_to_db($p['topic_subject'], -1);
1672  prepare_to_db($p['topic_text'], 1);
1673 
1674  $topic_uri = $this->uriGenerate ($p['topic_subject'], TF_FORUM_TOPIC, 'topic_uri');
1675  $post_id = $this->fdb->newTopic ((int)$p['forum'], $this->fdb->unescape($p['topic_subject']), $p['topic_text'], ($p['topic_sticky'] == 'on'), $user, $topic_uri);
1676 
1677  $this->_handleSignature ($_POST, $user);
1678 
1679  $isUploadSuccess = $this->_handleUpload ($p, $post_id);
1680 
1681  if (is_callable($this->onNewTopic))
1682  call_user_func_array ($this->onNewTopic, array((int)$p['forum'], $p['topic_subject'], $p['topic_text'], ($p['topic_sticky'] == 'on'), $user, $topic_uri, $post_id));
1683 
1684  return <<<EOF
1685 <html>
1686 <body>
1687 <script language="javascript" type="text/javascript">
1688 
1689  if (!$isUploadSuccess)
1690  window.parent.alert ('[L[Some or all files upload failed]]');
1691 
1692  if (window.parent.document.getElementById('tinyEditor'))
1693  window.parent.tinyMCE.execCommand('mceRemoveEditor', false, 'tinyEditor');
1694 
1695  window.parent.document.f.selectTopic('{$topic_uri}');
1696 
1697 </script>
1698 </body>
1699 </html>
1700 EOF;
1701 
1702  }
1703 
1704  function isAdmin ()
1705  {
1706  $a = $this->_getUserInfo ($this->getLoginUser());
1707  return $a['admin'];
1708  }
1709 
1713  function getLoginUser ()
1714  {
1715  return $this->_getLoginUser();
1716  }
1717 
1722  {
1723  $u = $this->getLoginUser ();
1724  if (!$u) return;
1725 
1726  $this->fdb->updateUserActivity ($u);
1727  }
1728 
1729  function logout ()
1730  {
1731  $u = $this->getLoginUser ();
1732  if (!$u) return '<ret>0</ret>';
1733 
1734  setcookie('orca_pwd', 'orca_pwd', time() - 86400);
1735  setcookie('orca_user', 'orca_user', time() - 86400);
1736  setcookie('track_topics', 'track_topics', time() - 86400);
1737 
1738  $this->fdb->updateUserLastActivity ($u);
1739 
1740  return '<ret>1</ret>';
1741  }
1742 
1748  function votePost ($post_id, $vote)
1749  {
1750  $u = $this->getLoginUser ();
1751  if (!$u || 0 !== strcasecmp($_SERVER['REQUEST_METHOD'], 'POST'))
1752  return '<ret>0</ret>';
1753 
1754  if (!$this->fdb->insertVote ((int)$post_id, $u, $vote))
1755  return '<ret>0</ret>';
1756 
1757  if (is_callable($this->onVote))
1758  call_user_func_array ($this->onVote, array((int)$post_id, $u, $vote));
1759 
1760  return '<ret>1</ret>';
1761  }
1762 
1767  function report ($post_id)
1768  {
1769  if (!$post_id || 0 !== strcasecmp($_SERVER['REQUEST_METHOD'], 'POST'))
1770  return '<ret>0</ret>';
1771 
1772  $u = $this->getLoginUser ();
1773  if (!$u)
1774  return '<ret>0</ret>';
1775 
1776  if (!$this->fdb->report ((int)$post_id, $u))
1777  return '<ret>0</ret>';
1778 
1779  if (is_callable($this->onReport))
1780  call_user_func_array ($this->onReport, array((int)$post_id, $u));
1781 
1782  return '<ret>1</ret>';
1783  }
1784 
1789  function flag ($topic_id)
1790  {
1791  if (!$topic_id || 0 !== strcasecmp($_SERVER['REQUEST_METHOD'], 'POST'))
1792  return '<ret>0</ret>';
1793 
1794  $u = $this->getLoginUser ();
1795  if (!$u)
1796  return '<ret>0</ret>';
1797 
1798  if ($this->fdb->isFlagged ((int)$topic_id, $u)) {
1799  if (!$this->fdb->unflag ((int)$topic_id, $u))
1800  return '<ret>0</ret>';
1801  if (is_callable($this->onUnflag))
1802  call_user_func_array ($this->onUnflag, array((int)$topic_id, $u));
1803  return '<ret>-1</ret>';
1804  }
1805 
1806  if (!$this->fdb->flag ((int)$topic_id, $u))
1807  return '<ret>0</ret>';
1808 
1809  if (is_callable($this->onFlag))
1810  call_user_func_array ($this->onFlag, array((int)$topic_id, $u));
1811 
1812  return '<ret>1</ret>';
1813  }
1814 
1819  function getRssForum ($forum_uri)
1820  {
1821  global $gConf;
1822 
1823  $this->_rssPrepareConf ();
1824 
1825  $f = $this->fdb->getForumByUri (filter_to_db($forum_uri));
1826  $forum_id = $f['forum_id'];
1827 
1828  if (!$f) exit;
1829 
1830  $a = $this->fdb->getTopics ($forum_id, 0);
1831 
1832  $items = '';
1833  $lastBuildDate = '';
1834  foreach ($a as $r) {
1835  $lp = $this->fdb->getTopicPost($r['topic_id'], 'last');
1836 
1837  $td = $this->fdb->getTopicDesc ($r['topic_id']);
1838  $td = orca_mb_substr($td, 0, $gConf['topics_desc_len']);
1839  if (orca_mb_len($td) == $gConf['topics_desc_len'])
1840  $td .= '...';
1841 
1842  if (!$lastBuildDate)
1843  $lastBuildDate = $lp['when'];
1844 
1845  $items .= $this->_rssItem ($r['topic_title'], sprintf($gConf['rewrite']['topic'], $r['topic_uri']), $td, $lp['when']);
1846  }
1847 
1848  return $this->_rssFeed ($f['forum_title'], sprintf($gConf['rewrite']['forum'], $f['forum_uri'], 0), $f['forum_title'], $lastBuildDate, $items);
1849  }
1850 
1851 
1857  {
1858  global $gConf;
1859 
1860  $this->_rssPrepareConf ();
1861 
1862  $a = $this->fdb->getRecentTopics (0);
1863 
1864  $items = '';
1865  $lastBuildDate = '';
1866  $ui = array();
1867  foreach ($a as $r) {
1868  // acquire user info
1869  if (!isset($ui[$r['last_post_user']]) && ($aa = $this->_getUserInfoReadyArray ($r['last_post_user'], false)))
1870  $ui[$r['last_post_user']] = $aa;
1871 
1872  $td = orca_mb_replace('/#/', $r['count_posts'], '[L[# posts]]') . ' &#183; ' . orca_mb_replace('/#/', $ui[$r['last_post_user']]['title'], '[L[last reply by #]]') . ' &#183; ' . $r['cat_name'] . ' &#187; ' . $r['forum_title'];
1873 
1874  if (!$lastBuildDate)
1875  $lastBuildDate = $r['last_when'];
1876 
1877  $items .= $this->_rssItem ($r['topic_title'], sprintf($gConf['rewrite']['topic'], $r['topic_uri']), $td, $r['last_when']);
1878  }
1879 
1880  return $this->_rssFeed ('[L[Updated Topics]]', '', '[L[Updated Topics]]', $lastBuildDate, $items);
1881  }
1882 
1883 
1888  function getRssTopic ($topic_uri)
1889  {
1890  global $gConf;
1891 
1892  $this->_rssPrepareConf ();
1893 
1894  $t = $this->fdb->getTopicByUri(filter_to_db($topic_uri));
1895  $topic_id = (int)$t['topic_id'];
1896 
1897  if (!$t) {
1898  header("HTTP/1.1 404 Not Found");
1899  echo '404 Not Found';
1900  exit;
1901  }
1902 
1903  $a = $this->fdb->getPosts ($topic_id, 0, 'DESC', 10);
1904 
1905  $items = '';
1906  $lastBuildDate = '';
1907  foreach ($a as $r) {
1908  $td = orca_mb_substr($r['post_text'], 0, 255);
1909  if (orca_mb_len($td) == 255) $td .= '[...]';
1910  $td = strip_tags($td);
1911 
1912  $tt = orca_mb_substr($td, 0, 32);
1913 
1914  if (!$lastBuildDate) $lastBuildDate = $a['when'];
1915 
1916  $items .= $this->_rssItem ($tt, sprintf($gConf['rewrite']['topic'], $t['topic_uri']), $td, $r['when']);
1917  }
1918 
1919  return $this->_rssFeed ($t['topic_title'], sprintf($gConf['rewrite']['topic'], $t['topic_uri']), $t['topic_title'], $lastBuildDate, $items);
1920  }
1921 
1927  function getRssUser ($user, $sort)
1928  {
1929  global $gConf;
1930 
1931  $this->_rssPrepareConf ();
1932 
1933  $a = $this->fdb->getUserPostsList(filter_to_db($user), $sort, $gConf['topics_per_page']);
1934 
1935  $items = '';
1936  $lastBuildDate = '';
1937  foreach ($a as $r) {
1938  if (!$lastBuildDate)
1939  $lastBuildDate = $r['when'];
1940 
1941  $td = strip_tags($r['post_text']);
1942  if (strlen($td) == 256) $td .= '[...]';
1943 
1944  $items .= $this->_rssItem ($r['topic_title'], sprintf($gConf['rewrite']['topic'], $r['topic_uri']), $td, $r['when']);
1945  }
1946 
1947  if ($sort == 'rnd' || $sort == 'top') $lastBuildDate = '';
1948 
1949  $aUser = $this->_getUserInfoReadyArray ($user, false);
1950 
1951  $sTitle = sprintf("[L[%s's forum posts]]", $aUser['title']);
1952 
1953  return $this->_rssFeed ($sTitle, '?action=goto&amp;search_result=1&amp;text=&amp;type=msgs&amp;forum=0&amp;u=' . $user . '&amp;disp=posts&amp;start=0', $sTitle, $lastBuildDate, $items);
1954  }
1955 
1961  function getRssAll ($sort)
1962  {
1963  global $gConf;
1964 
1965  $this->_rssPrepareConf ();
1966 
1967  $a = $this->fdb->getAllPostsList($sort, $gConf['topics_per_page']);
1968 
1969  $ui = array();
1970  $items = '';
1971  $lastBuildDate = '';
1972  foreach ($a as $r) {
1973  if (!$lastBuildDate)
1974  $lastBuildDate = $r['when'];
1975 
1976  if (!isset($ui[$r['user']]) && ($aa = $this->_getUserInfo ($r['user'])))
1977  $ui[$r['user']] = $aa;
1978 
1979  $td = $r['post_text'];
1980  if (orca_mb_len($td) == 255) $td .= '[...]';
1981  $td = strip_tags($td);
1982 
1983 
1984  $items .= $this->_rssItem ($r['topic_title'], sprintf($gConf['rewrite']['topic'], $r['topic_uri']), $ui[$r['user']]['profile_title'] . ': ' . $td, $r['when']);
1985  }
1986 
1987  if ($sort == 'rnd' || $sort == 'top') $lastBuildDate = '';
1988 
1989  return $this->_rssFeed ('[L[Forum Posts]]', '', '[L[Forum Posts]]', $lastBuildDate, $items);
1990  }
1991 
1992  function _rssPrepareConf ()
1993  {
1994  global $gConf;
1995  $gConf['topics_per_page'] = 10;
1996  }
1997 
1998  function _rssItem ($sTitle, $sLink, $sDesc, $iTimestamp)
1999  {
2000  global $gConf;
2001  if ($iTimestamp)
2002  $sDate = date(DATE_RSS, $iTimestamp);
2003  else
2004  $sDate = '';
2005  return "
2006  <item>
2007  <title><![CDATA[{$sTitle}]]></title>
2008  <link>" . $gConf['url']['base'] . $sLink . "</link>
2009  <description><![CDATA[{$sDesc}]]></description>
2010  <pubDate>{$sDate}</pubDate>
2011  <guid>" . $gConf['url']['base'] . $sLink . "</guid>
2012  </item>";
2013  }
2014 
2015  function _rssFeed ($sTitle, $sLink, $sDesc, $iLastDateTimestamp, $sItems)
2016  {
2017  global $gConf;
2018  if ($iLastDateTimestamp)
2019  $sLastDate = date(DATE_RSS, $iLastDateTimestamp);
2020  else
2021  $sLastDate = '';
2022  return <<<EOF
2023 <rss version="2.0">
2024  <channel>
2025  <title><![CDATA[{$sTitle}]]></title>
2026  <link>{$gConf['url']['base']}{$sLink}</link>
2027  <description><![CDATA[{$sDesc}]]></description>
2028  <lastBuildDate>{$sLastDate}</lastBuildDate>
2029  $sItems
2030  </channel>
2031 </rss>
2032 EOF;
2033  }
2034 
2040  function showProfile ($u, $wp)
2041  {
2042  $a = $this->_getUserInfo ($u);
2043  $as = $this->fdb->getUserStat (filter_to_db($u));
2044 
2045  $a['username'] = $u;
2046  $a['posts'] = (int)$as['posts'];
2047  $a['user_last_post'] = orca_format_date($as['user_last_post']);
2048  $a['last_online'] = orca_format_date($this->fdb->getUserLastOnlineTime (filter_to_db($u)));
2049 
2050  encode_post_text ($as['role']);
2051  $a['role'] = $as['role'];
2052 
2053  $p = array2xml ($a);
2054 
2055  if ($wp) {
2056  if ($a)
2057  $this->setTitle ("<![CDATA[$u]]>");
2058  $li = $this->_getLoginInfo ();
2059  return $this->addHeaderFooter ($li, "<profile>$p</profile>");
2060  } else {
2061  $cu = $this->getUrlsXml ();
2062  return "<root>$cu<profile>$p</profile></root>";
2063  }
2064  }
2065 
2066  // private functions
2067 
2068  function _getLoginInfo ($user = '')
2069  {
2070  if (!strlen($user)) $user = $this->_getLoginUserName ();
2071  $a = $this->_getUserInfo ($user);
2072  $a['username'] = $user;
2073  return $a;
2074  }
2075 
2076  function _getUserInfoReadyArray ($user, $bWrapWithCdata = true)
2077  {
2078  $aa = $this->_getUserInfo ($user);
2079  if (!$aa)
2080  return array();
2081 
2082  if ($bWrapWithCdata ) {
2083  encode_post_text ($aa['role']);
2084  encode_post_text ($aa['profile_title']);
2085  }
2086 
2087  $aa['profile_link'] = ($aa['profile_url'] ? '<a href="' . $aa['profile_url'] . '">' . $aa['profile_title'] . '</a>' : $aa['profile_title']);
2088 
2089  return array ('avatar' => $aa['avatar'], 'avatar64' => $aa['avatar64'], 'url' => $aa['profile_url'], 'link' => $aa['profile_link'], 'title' => $aa['profile_title'], 'onclick' => $aa['profile_onclick'], 'role' => $aa['role']);
2090  }
2091 
2092  function _getUserInfo ($user)
2093  {
2094  if (is_callable($this->getUserInfo))
2095  return call_user_func_array ($this->getUserInfo, array($user));
2096  return array ();
2097  }
2098 
2105  function _checkUserPerm ($user, $f_type, $a_type, $forum_id = 0)
2106  {
2107  if (is_callable($this->getUserPerm)) {
2108  $a = call_user_func_array ($this->getUserPerm, array($user, $f_type, $a_type, $forum_id));
2109  return $a["{$a_type}_{$f_type}"];
2110  }
2111  return false;
2112  }
2113 
2118  function _isEditTimeout ($post_id)
2119  {
2120  if ((time() - $this->fdb->getPostWhen($post_id) - 10) > $GLOBALS['gConf']['edit_timeout'])
2121  return true;
2122  return false;
2123  }
2124 
2128  function _getLoginUserName ()
2129  {
2130  return $this->_getLoginUser();
2131  }
2132 
2136  function _getLoginUser ()
2137  {
2138  if (is_callable($this->getLoginUser))
2139  return call_user_func ($this->getLoginUser);
2140  return '';
2141  }
2142 
2143  function _format_when ($iSec)
2144  {
2145  $s = '';
2146  if ($iSec < 3600) {
2147  $i = round($iSec/60);
2148  if (0 == $i || 1 == $i) $s .= '1[L[Minute Ago]]';
2149  else $s .= $i . '[L[Minutes Ago]]';
2150  } else if ($iSec < 86400) {
2151  $i = round($iSec/60/60);
2152  if (0 == $i || 1 == $i) $s .= '1[L[Hour Ago]]';
2153  else $s .= $i . '[L[Hours Ago]]';
2154  } else {
2155  $i = round($iSec/60/60/24);
2156  if (0 == $i || 1 == $i) $s .= '1[L[Day Ago]]';
2157  else $s .= $i . '[L[Days Ago]]';
2158  }
2159  return $s;
2160  }
2161 
2162  function _no_access ($wp = 0)
2163  {
2164  $xml = '<forum_access>no</forum_access>';
2165  if (!$wp) return $xml;
2166  $li = $this->_getLoginInfo ();
2167  return $this->addHeaderFooter ($li, $xml);
2168  }
2169 
2170  function _buld_topic_desc (&$s)
2171  {
2172  $s = strip_tags ($s);
2173  validate_unicode ($s);
2174  if ($s == '') $s = ' ';
2175  $s = '<![CDATA[' . $s . ']]>';
2176  }
2177 
2178  function uriGenerate ($s, $sTable, $sField, $iMaxLen = 255)
2179  {
2180  if ($GLOBALS['oTemplConfig']->bAllowUnicodeInPreg)
2181  $s = orca_mb_replace ('/[^\pL^\pN]+/u', '-', $s); // unicode characters
2182  else
2183  $s = orca_mb_replace ('/([^\d^\w]+)/u', '-', $s); // latin characters
2184 
2185  $s = orca_mb_replace ('/([-^]+)/', '-', $s);
2186  if (!$s) $s = '-';
2187 
2188  if ($this->uriCheckUniq($s, $sTable, $sField)) return $s;
2189 
2190  // try to add date
2191 
2192  if (orca_mb_len($s) > 240)
2193  $s = orca_mb_substr ($s, 0, 240);
2194 
2195  $s .= '-' . date('Y-m-d');
2196 
2197  if ($this->uriCheckUniq($s, $sTable, $sField)) return $s;
2198 
2199  // try to add number
2200 
2201  for ($i = 0 ; $i < 999 ; ++$i) {
2202  if ($this->uriCheckUniq($s . '-' . $i, $sTable, $sField)) {
2203  return ($s . '-' . $i);
2204  }
2205  }
2206 
2207  return rand(0, 999999999);
2208  }
2209 
2210  function uriCheckUniq ($s, $sTable, $sField)
2211  {
2212  return !$this->fdb->getOne("SELECT 1 FROM $sTable WHERE $sField = ? LIMIT 1", [$s]);
2213  }
2214 
2215  function setTitle ($s)
2216  {
2217  $s = str_replace(array('<![CDATA[', ']]>'), '', $s);
2218  $GLOBALS['gConf']['title'] = '<![CDATA[' . $s . '[L[add this to title]]' . ']]>';
2219  }
2220 
2221  function _handleSignature (&$p, $user)
2222  {
2223  if (isset($p['signature']))
2224  $p['signature'] = trim ($p['signature']);
2225 
2226  if (!isset($p['signature']) || $p['signature'] == $this->fdb->getSignature ($user))
2227  return true;
2228 
2229  prepare_to_db ($p['signature'], 1);
2230 
2231  return $this->fdb->updateSignature ($p['signature'], $user);
2232  }
2233 
2234  function _handleUpload (&$p, $post_id)
2235  {
2236  global $gConf;
2237 
2238  // handle existing uploads
2239 
2240  $attachments = $this->fdb->getAttachments ($post_id);
2241  foreach ($attachments as $file) {
2242  $mixedIndex = array_search ($file['att_hash'], $p['existing_file']);
2243  if (false !== $mixedIndex && null !== $mixedIndex)
2244  continue;
2245  $this->fdb->removeAttachment($file['att_hash']);
2246  }
2247 
2248  // handle new uploads
2249 
2250  $failed_uploads = 0;
2251 
2252  foreach ($_FILES['attachments']['error'] as $i => $error) {
2253 
2254  if (UPLOAD_ERR_NO_FILE == $error)
2255  continue;
2256 
2257  if ($error != UPLOAD_ERR_OK || !$_FILES['attachments']['size'][$i]) {
2258  ++$failed_uploads;
2259  continue;
2260  }
2261 
2262  $tmp_name = $_FILES["attachments"]["tmp_name"][$i];
2263  $name = $_FILES["attachments"]["name"][$i];
2264  $type = $_FILES["attachments"]["type"][$i];
2265  $size = (int)$_FILES["attachments"]["size"][$i];
2266  $hash = $this->fdb->genFileHash();
2267  $path = $gConf['dir']['attachments'] . orca_build_path ($hash);
2268 
2269  orca_mkdir_r ($path);
2270 
2271  if (!move_uploaded_file($tmp_name, $path . $hash)) {
2272  ++$failed_uploads;
2273  continue;
2274  }
2275 
2276  prepare_to_db ($name, 0);
2277  prepare_to_db ($type, 0);
2278 
2279  if (!$this->fdb->insertAttachment ($post_id, $hash, $name, $type, $size)) {
2280  ++$failed_uploads;
2281  continue;
2282  }
2283 
2284  }
2285 
2286  return $failed_uploads > 0 ? 0 : 1;
2287  }
2288 
2289  function download($hash)
2290  {
2291  global $gConf;
2292 
2293  prepare_to_db ($hash, 0);
2294  $a = $this->fdb->getAttachment($hash);
2295  if (!$a) {
2296  header("HTTP/1.1 404 Not Found");
2297  echo '404 Not Found';
2298  exit;
2299  }
2300 
2301  if (!$this->_checkUserPerm ('', '', 'download', (int)$a['forum_id'])) {
2302  transCheck ($this->_no_access(1), $gConf['dir']['xsl'] . 'search_form_main.xsl', $_GET['debug'] ? 0 : 1);
2303  exit;
2304  }
2305 
2306  $this->fdb->updateAttachmentDownloads ($hash);
2307 
2308  header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
2309  header ("Content-type: {$a['att_type']}");
2310  header ("Content-Length: " . $a['att_size']);
2311  if (0 !== strncmp('image/', $a['att_type'], 6))
2312  header ("Content-Disposition: attachment; filename=\"{$a['att_name']}\"");
2313 
2314  readfile ($gConf['dir']['attachments'] . orca_build_path ($hash) . $hash);
2315 
2316  exit;
2317  }
2318 
2319  function _getAttachmentsXML ($post_id)
2320  {
2321  $attachments = $this->fdb->getAttachments ($post_id);
2322  $files = '';
2323  foreach ($attachments as $file) {
2324  encode_post_text ($file['att_name']);
2325  $isImage = 0 === strncmp('image/', $file['att_type'], 6) ? 1 : 0;
2326  $files .= '<file image="' . $isImage . '" hash="' . $file['att_hash'] . '" size="' . orca_format_bytes($file['att_size']) . '" downloads="' . $file['att_downloads'] . '">' . $file['att_name'] . '</file>';
2327  }
2328 
2329  return $files;
2330  }
2331 
2332  function _getPages ($iStart, $iNum, $iPerPage)
2333  {
2334  $p = '';
2335  for ($i = 0 ; $i < $iNum ; $i += $iPerPage)
2336  if (0 >= $i || ($iNum - $iPerPage) <= $i || ($i >= ($iStart - 2*$iPerPage) && $i <= ($iStart + 2*$iPerPage)))
2337  $p .= '<p c="' . (($iStart >= $i && $iStart < ($i + $iPerPage)) ? 1 : 0 ). '" start="' . $i . '">' . ($i/$iPerPage + 1) . '</p>';
2338  return $p;
2339  }
2340 
2341 }
Forum\$onReport
$onReport
Definition: Forum.php:23
header
</code > Be careful enabling this directive if you have a redirector script that does not use the< code > Location</code > HTTP header
Definition: URI.MungeResources.txt:10
Forum\$onPostReply
$onPostReply
Definition: Forum.php:18
orca_mb_len
orca_mb_len($s)
Definition: util.inc.php:288
Forum\download
download($hash)
Definition: Forum.php:2289
Forum\hideTopic
hideTopic($is_hide, $topic_id)
Definition: Forum.php:1586
Forum\getPostsXML
getPostsXML($topic_uri, $wp)
Definition: Forum.php:433
orca_mb_replace
orca_mb_replace($sPattern, $sReplace, $s)
Definition: util.inc.php:283
Forum\_getAttachmentsXML
_getAttachmentsXML($post_id)
Definition: Forum.php:2319
Forum\getRssUpdatedTopics
getRssUpdatedTopics()
Definition: Forum.php:1856
Forum\postNewTopicXML
postNewTopicXML($p)
Definition: Forum.php:1641
onNewTopic
$f onNewTopic
Definition: callback.php:24
Forum\__construct
__construct()
Definition: Forum.php:30
Forum\getRssAll
getRssAll($sort)
Definition: Forum.php:1961
$f
global $f
Definition: callback.php:13
Forum\_buld_topic_desc
_buld_topic_desc(&$s)
Definition: Forum.php:2170
Forum\_no_access
_no_access($wp=0)
Definition: Forum.php:2162
orca_format_date
orca_format_date($iTimestamp)
Definition: util.inc.php:273
ch_js_string
ch_js_string($mixedInput, $iQuoteType=CH_ESCAPE_STR_AUTO)
Definition: utils.inc.php:1294
name
Core AllowHostnameUnderscore underscores are not permitted in host most browsers do the right thing when faced with an underscore in the host name
Definition: Core.AllowHostnameUnderscore.txt:11
Forum\logout
logout()
Definition: Forum.php:1729
Forum\stick
stick($topic_id)
Definition: Forum.php:1606
orca_mb_substr
orca_mb_substr($s, $iStart, $iLen)
Definition: util.inc.php:296
Forum\getLivePostsXML
getLivePostsXML($count=10, $ts=0)
Definition: Forum.php:1138
Forum\topicAutoContinue
topicAutoContinue($t)
Definition: Forum.php:1267
post
post($sTable, $sId, $sAuthor, $sParent, $sMood, $sFileId)
Definition: customFunctions.inc.php:8
encode_post_text
encode_post_text(&$s, $bEncodeSpecialChars=false, $bAutohyperlink=false)
Definition: util.inc.php:146
Forum\getTrackTopics
getTrackTopics()
Definition: Forum.php:945
$ret
$ret
Definition: index.php:39
Forum\showProfile
showProfile($u, $wp)
Definition: Forum.php:2040
Forum\_getUserInfo
_getUserInfo($user)
Definition: Forum.php:2092
transCheck
transCheck($xml, $xsl, $trans, $browser_transform=0)
Definition: util.inc.php:16
Forum\getMyFlagsXML
getMyFlagsXML($wp, $start=0)
Definition: Forum.php:738
Forum\votePost
votePost($post_id, $vote)
Definition: Forum.php:1748
orca_build_path
orca_build_path($s)
Definition: util.inc.php:278
array2xml
array2xml($arr, $tag=false)
Definition: util.inc.php:60
Forum\delTopic
delTopic($topic_id)
Definition: Forum.php:1565
Forum\_format_when
_format_when($iSec)
Definition: Forum.php:2143
Forum\deletePostXML
deletePostXML($post_id, $topic_id, $forum_id)
Definition: Forum.php:1433
Forum\_getLoginUser
_getLoginUser()
Definition: Forum.php:2136
Forum\$onPostEdit
$onPostEdit
Definition: Forum.php:19
$hash
$hash
Definition: Filter.ExtractStyleBlocks.txt:46
Forum\_getPages
_getPages($iStart, $iNum, $iPerPage)
Definition: Forum.php:2332
php
Forum\_rssPrepareConf
_rssPrepareConf()
Definition: Forum.php:1992
Forum\getHiddenPostXML
getHiddenPostXML($post_id, $force_show)
Definition: Forum.php:313
DbForum
Definition: DbForum.php:35
Forum\uriCheckUniq
uriCheckUniq($s, $sTable, $sField)
Definition: Forum.php:2210
$iPos
$iPos
Definition: design.php:157
Forum\_handleUpload
_handleUpload(&$p, $post_id)
Definition: Forum.php:2234
Forum\postReplyXML
postReplyXML(&$p)
Definition: Forum.php:1200
Forum\liveTracker
liveTracker()
Definition: Forum.php:1132
Forum\_handleSignature
_handleSignature(&$p, $user)
Definition: Forum.php:2221
onVote
$f onVote
Definition: callback.php:25
Forum\setTrackTopic
setTrackTopic($topic_id)
Definition: Forum.php:955
Forum\$getUserInfo
$getUserInfo
Definition: Forum.php:13
onFlag
$f onFlag
Definition: callback.php:27
onUnflag
$f onUnflag
Definition: callback.php:28
$iPerPage
else $iPerPage
Definition: browse.php:61
Forum\getNewTopicXML
getNewTopicXML($forum_uri, $isWholePage=false)
Definition: Forum.php:220
Forum\_getLoginInfo
_getLoginInfo($user='')
Definition: Forum.php:2068
Forum\_rssItem
_rssItem($sTitle, $sLink, $sDesc, $iTimestamp)
Definition: Forum.php:1998
orca_mkdir_r
orca_mkdir_r($dirName, $rights=0755)
Definition: util.inc.php:258
Forum\getRssTopic
getRssTopic($topic_uri)
Definition: Forum.php:1888
onPostEdit
$f onPostEdit
Definition: callback.php:22
Forum\getTopicsXML
getTopicsXML($forum_uri, $wp, $start=0)
Definition: Forum.php:749
Forum\$onNewTopic
$onNewTopic
Definition: Forum.php:21
ch_html_attribute
ch_html_attribute($mixedInput)
Definition: utils.inc.php:1324
filter_to_db
filter_to_db($s, $iAllowHTML=0)
Definition: util.inc.php:123
Forum\setTitle
setTitle($s)
Definition: Forum.php:2215
Forum\hidePost
hidePost($is_hide, $post_id)
Definition: Forum.php:1487
Forum\editPost
editPost($post_id, $topic_id, $text)
Definition: Forum.php:1376
Forum\getXxxTopicsXML
getXxxTopicsXML($wp, $sTitle, $sDesc, $sFunc, $start=0)
Definition: Forum.php:624
Forum\_isEditTimeout
_isEditTimeout($post_id)
Definition: Forum.php:2118
Forum\moveTopicSubmit
moveTopicSubmit($topic_id, $forum_id, $old_forum_id, $goto_new_location)
Definition: Forum.php:1545
exit
exit
Definition: cart.php:21
$_GET
$_GET['debug']
Definition: index.php:67
$sTitle
$sTitle
Definition: actions.inc.php:13
orca_format_bytes
orca_format_bytes($i)
Definition: util.inc.php:263
Forum\getPostReplyXML
getPostReplyXML($forum_id, $topic_id)
Definition: Forum.php:277
ThingPage\getUrlsXml
getUrlsXml()
Definition: ThingPage.php:43
Forum\uriGenerate
uriGenerate($s, $sTable, $sField, $iMaxLen=255)
Definition: Forum.php:2178
Forum\getCategsShortXML
getCategsShortXML($sCheckPermission=false)
Definition: Forum.php:986
Forum\flag
flag($topic_id)
Definition: Forum.php:1789
type
if(!defined("USER_STATUS_TYPE")) define("USER_STATUS_TYPE" type
Definition: constants.inc.php:13
Forum\isNewPost
isNewPost($ts)
Definition: Forum.php:1190
Forum\getSearchXML
getSearchXML($wp=false)
Definition: Forum.php:198
$path
$path
Definition: header.inc.php:12
Forum\getSearchResultsXML
getSearchResultsXML($text, $type, $forum, $u, $disp, $start=0, $isWholePage=false)
Definition: Forum.php:44
Forum
Definition: Forum.php:11
Forum\$onPostDelete
$onPostDelete
Definition: Forum.php:20
Forum\getMyThreadsXML
getMyThreadsXML($wp, $start=0)
Definition: Forum.php:729
Forum\isAdmin
isAdmin()
Definition: Forum.php:1704
onPostDelete
$f onPostDelete
Definition: callback.php:23
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
Forum\moveTopicForm
moveTopicForm($topic_id)
Definition: Forum.php:1507
Forum\$onVote
$onVote
Definition: Forum.php:22
time
that in the case of a Adaptation or at a minimum such credit will if a credit for all contributing authors of the Adaptation or Collection then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors For the avoidance of You may only use the credit required by this Section for the purpose of attribution in the manner set out above by exercising Your rights under this You may not implicitly or explicitly assert or imply any connection sponsorship or endorsement by the Original Licensor and or Attribution as of You or Your use of the without the express prior written permission of the Original Licensor and or Attribution Parties Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable if You Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or You must not modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author s honor or reputation Licensor agrees that in those in which any exercise of the right granted in modification or other derogatory action prejudicial to the Original Author s honor and the Licensor will waive or not as this to the fullest extent permitted by the applicable national to enable You to reasonably exercise Your right under Warranties and Disclaimer UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN LICENSOR OFFERS THE WORK AS IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE STATUTORY OR WITHOUT WARRANTIES OF FITNESS FOR A PARTICULAR OR THE ABSENCE OF LATENT OR OTHER OR THE PRESENCE OF ABSENCE OF WHETHER OR NOT DISCOVERABLE SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED SO SUCH EXCLUSION MAY NOT APPLY TO YOU Limitation on Liability EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES Termination This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License Individuals or entities who have received Adaptations or Collections from You under this will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses and will survive any termination of this License Subject to the above terms and the license granted here is Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time
Definition: license.txt:56
validate_unicode
validate_unicode(&$s)
Definition: util.inc.php:195
getUserPerm
$f getUserPerm
Definition: callback.php:19
Forum\$getLoginUser
$getLoginUser
Definition: Forum.php:15
Forum\editPostXml
editPostXml($post_id, $topic_id)
Definition: Forum.php:1323
Forum\_checkUserPerm
_checkUserPerm($user, $f_type, $a_type, $forum_id=0)
Definition: Forum.php:2105
$s
$s
Definition: embed.php:13
CH_ESCAPE_STR_APOS
const CH_ESCAPE_STR_APOS
escape apostrophes only, for js strings enclosed in apostrophes, for use in
Definition: utils.inc.php:33
$aUser
$aUser
Definition: profiles.inc.php:74
Forum\getCategoriesXML
getCategoriesXML($first_load=1, &$p)
Definition: Forum.php:1102
onReport
$f onReport
Definition: callback.php:26
Forum\getRssUser
getRssUser($user, $sort)
Definition: Forum.php:1927
Forum\_getUserInfoReadyArray
_getUserInfoReadyArray($user, $bWrapWithCdata=true)
Definition: Forum.php:2076
Forum\$getUserPerm
$getUserPerm
Definition: Forum.php:14
Forum\_rssFeed
_rssFeed($sTitle, $sLink, $sDesc, $iLastDateTimestamp, $sItems)
Definition: Forum.php:2015
ThingPage
Definition: ThingPage.php:11
Forum\updateCurrentUserActivity
updateCurrentUserActivity()
Definition: Forum.php:1721
getUserInfo
$f getUserInfo
Definition: callback.php:18
$gConf
global $gConf
Definition: header.inc.php:8
Forum\getLoginUser
getLoginUser()
Definition: Forum.php:1713
TF_FORUM_TOPIC
const TF_FORUM_TOPIC
Definition: DbForum.php:11
Forum\lock
lock($topic_id)
Definition: Forum.php:1624
version
and that you are informed that you can do these things To protect your we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it For if you distribute copies of the whether gratis or for a you must give the recipients all the rights that we gave you You must make sure that receive or can get the source code If you link other code with the you must provide complete object files to the so that they can relink them with the library after making changes to the library and recompiling it And you must show them these terms so they know their rights We protect your rights with a two step which gives you legal permission to distribute and or modify the library To protect each we want to make it very clear that there is no warranty for the free library if the library is modified by someone else and passed the recipients should know that what they have is not the original version
Definition: license.txt:55
Forum\getForumsShortXML
getForumsShortXML($cat, $root, $sCheckPermission=false)
Definition: Forum.php:1004
Forum\getForumsXML
getForumsXML($cat, $root)
Definition: Forum.php:1029
Forum\getHiddenTopicsXML
getHiddenTopicsXML($wp, $start=0)
Definition: Forum.php:720
$sDesc
$sDesc
Definition: actions.inc.php:21
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
prepare_to_db
prepare_to_db(&$s, $iAllowHTML=1)
Definition: util.inc.php:110
Forum\getRecentTopicsXML
getRecentTopicsXML($wp, $start=0)
Definition: Forum.php:861
ThingPage\addHeaderFooter
addHeaderFooter(&$li, $content)
Definition: ThingPage.php:63
Forum\_getLoginUserName
_getLoginUserName()
Definition: Forum.php:2128
Forum\$onUnflag
$onUnflag
Definition: Forum.php:25
form
iii in the case of the organization that transmits the broadcast Work means the literary and or artistic work offered under the terms of this License including without limitation any production in the scientific and artistic whatever may be the mode or form of its expression including digital form
Definition: license.txt:19
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10
ch_is_spam
ch_is_spam($val)
Definition: utils.inc.php:1080
Forum\getPageXML
getPageXML($first_load=1, &$p)
Definition: Forum.php:1076
Forum\report
report($post_id)
Definition: Forum.php:1767
Forum\isNewTopic
isNewTopic($topic_id, $topic_last_time, $user_last_time)
Definition: Forum.php:967
Forum\getRssForum
getRssForum($forum_uri)
Definition: Forum.php:1819
Forum\$onFlag
$onFlag
Definition: Forum.php:24
$sUser
$sUser
Definition: r.php:13
onPostReply
$f onPostReply
Definition: callback.php:21