21. File Comparison Report

Produced on Wed Jun 18 08:01:30 2008 UTC. This report uses XHTML and CSS2, and is best viewed with a reasonably standards compliant browser such as the latest version of Firefox or Internet Explorer. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

21.1 Files compared

# Location File Last Modified
1 Dolphin-v.6.1.1\groups\orca\classes Forum.php Sun May 11 13:17:02 2008 UTC
2 Dolphin-v.6.1.2\groups\orca\classes Forum.php Thu Jun 12 09:57:43 2008 UTC

21.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 6 3832
Changed 4 12
Inserted 1 1
Removed 0 0

21.3 Comparison options

Whitespace All differences in whitespace within lines are ignored
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

21.4 Active regular expressions

No regular expressions were active.

21.5 Comparison detail

1   <?php   1   <?php
2   /********* ********** ********** ********** ********** ********** ********** ******   2   /********* ********** ********** ********** ********** ********** ********** ******
3   *                              O rca Intera ctive Foru m Script   3   *                              O rca Intera ctive Foru m Script
4   *                                 --------- --------   4   *                                 --------- --------
5   *     begi n                 : F r Nov 10 2 006   5   *     begi n                 : F r Nov 10 2 006
6   *     copy right             : ( C) 2006 Bo onEx Group   6   *     copy right             : ( C) 2006 Bo onEx Group
7   *     webs ite               : h ttp://www. boonex.com /   7   *     webs ite               : h ttp://www. boonex.com /
8   * This fil e is part  of Orca -  Interactiv e Forum Sc ript   8   * This fil e is part  of Orca -  Interactiv e Forum Sc ript
9   *   9   *
10   * Orca is  free softw are. This  work is li censed und er a Creat ive Common s Attribut ion 3.0 Li cense.    10   * Orca is  free softw are. This  work is li censed und er a Creat ive Common s Attribut ion 3.0 Li cense. 
11   * http://c reativecom mons.org/l icenses/by /3.0/   11   * http://c reativecom mons.org/l icenses/by /3.0/
12   *   12   *
13   * Orca is  distribute d in the h ope that i t will be  useful, bu t WITHOUT  ANY WARRAN TY;   13   * Orca is  distribute d in the h ope that i t will be  useful, bu t WITHOUT  ANY WARRAN TY;
14   * without  even the i mplied war ranty of   MERCHANTAB ILITY or F ITNESS FOR  A PARTICU LAR PURPOS E.   14   * without  even the i mplied war ranty of   MERCHANTAB ILITY or F ITNESS FOR  A PARTICU LAR PURPOS E.
15   * See the  Creative C ommons Att ribution 3 .0 License  for more  details.    15   * See the  Creative C ommons Att ribution 3 .0 License  for more  details. 
16   * You shou ld have re ceived a c opy of the  Creative  Commons At tribution  3.0 Licens e along wi th Orca,    16   * You shou ld have re ceived a c opy of the  Creative  Commons At tribution  3.0 Licens e along wi th Orca, 
17   * see lice nse.txt fi le; if not , write to  marketing @boonex.co m   17   * see lice nse.txt fi le; if not , write to  marketing @boonex.co m
18   ********** ********** ********** ********** ********** ********** ********** *****/   18   ********** ********** ********** ********** ********** ********** ********** *****/
19     19  
20     20  
21   // forum o perations   21   // forum o perations
22     22  
23   class Foru m extends  ThingPage   23   class Foru m extends  ThingPage
24   {      24   {   
25     25  
26       /**   26       /**
27        * con structor   27        * con structor
28        */   28        */
29       functi on Forum ( )   29       functi on Forum ( )
30       {   30       {
31     31  
32       }   32       }
33     33  
34       /**   34       /**
35        * ret urns searc h results  XML   35        * ret urns searc h results  XML
36        * @pa ram $text      search  string   36        * @pa ram $text      search  string
37        * @pa ram $type      search  type: msg s - messag es | tlts  - titles   37        * @pa ram $type      search  type: msg s - messag es | tlts  - titles
38        * @pa ram $forum     forum  id to sear ch within   38        * @pa ram $forum     forum  id to sear ch within
39        * @pa ram $u         search  posts of  this user  only   39        * @pa ram $u         search  posts of  this user  only
40        * @pa ram $disp      displa y: topics  | posts   40        * @pa ram $disp      displa y: topics  | posts
41        * @pa ram $max_r es  max nu mber of re sults   41        * @pa ram $max_r es  max nu mber of re sults
42        */   42        */
43       functi on getSear chResultsX ML ($text,  $type, $f orum, $u,  $disp, $ma x_res = 50 )   43       functi on getSear chResultsX ML ($text,  $type, $f orum, $u,  $disp, $ma x_res = 50 )
44       {           44       {        
45           $f db = new D bForum ();   45           $f db = new D bForum ();
46           if  (!$this-> _checkUser Perm ('',  '', 'searc h'))   46           if  (!$this-> _checkUser Perm ('',  '', 'searc h'))
47           {   47           {
48                return $ this->_no_ access();   48                return $ this->_no_ access();
49           }   49           }
50     50  
51           sw itch ($typ e)   51           sw itch ($typ e)
52           {   52           {
53                case 'ms gs':   53                case 'ms gs':
54                case 'tl ts':   54                case 'tl ts':
55                    $a =  $fdb->sea rchMessage s ($text,  $u, $forum , $type, ( 'posts' ==  $disp ? 1  : 0), $ma x_res);   55                    $a =  $fdb->sea rchMessage s ($text,  $u, $forum , $type, ( 'posts' ==  $disp ? 1  : 0), $ma x_res);
56                    brea k;   56                    brea k;
57                default:   57                default:
58                    retu rn '<error >[L[Wrong  search typ e]]</error >';   58                    retu rn '<error >[L[Wrong  search typ e]]</error >';
59           }   59           }
60     60  
61           $w s = preg_s plit("/\s+ /", $text) ;      61           $w s = preg_s plit("/\s+ /", $text) ;   
62     62  
63           re set ($a);   63           re set ($a);
64           $s  = '';            64           $s  = '';         
65           sw itch ($typ e)   65           sw itch ($typ e)
66           {   66           {
67                case 'tl ts':   67                case 'tl ts':
68                    whil e ( list ( ,$r) = eac h ($a) )   68                    whil e ( list ( ,$r) = eac h ($a) )
69                    {   69                    {
70                         // search  hightlight   70                         // search  hightlight
71                           71                        
72                           72                        
73                         reset($ws) ;                     73                         reset($ws) ;                  
74                         while (lis t (,$w) =  each ($ws) )   74                         while (lis t (,$w) =  each ($ws) )
75                             if ($w )   75                             if ($w )
76                                 $r ['topic_ti tle'] = pr eg_replace  ("/($w)/i ", "<span  style=\"ba ckground-c olor:yello w\">$w</sp an>", $r[' topic_titl e']);   76                                 $r ['topic_ti tle'] = pr eg_replace  ("/($w)/i ", "<span  style=\"ba ckground-c olor:yello w\">$w</sp an>", $r[' topic_titl e']);
77                           77                        
78     78  
79                         encode_pos t_text($r[ 'cat_name' ]);   79                         encode_pos t_text($r[ 'cat_name' ]);
80                         encode_pos t_text($r[ 'forum_tit le']);   80                         encode_pos t_text($r[ 'forum_tit le']);
81                         encode_pos t_text($r[ 'topic_tit le'], 0, 1 );                      81                         encode_pos t_text($r[ 'topic_tit le'], 0, 1 );                   
82                           82                        
83                         $s .= <<<E OF   83                         $s .= <<<E OF
84                         <sr date=" {$r['date' ]}" user=" {$r['user' ]}">   84                         <sr date=" {$r['date' ]}" user=" {$r['user' ]}">
85                             <c id= "{$r['cat_ id']}" uri ="{$r['cat _uri']}">{ $r['cat_na me']}</c>   85                             <c id= "{$r['cat_ id']}" uri ="{$r['cat _uri']}">{ $r['cat_na me']}</c>
86                             <f id= "{$r['foru m_id']}" u ri="{$r['f orum_uri'] }">{$r['fo rum_title' ]}</f>   86                             <f id= "{$r['foru m_id']}" u ri="{$r['f orum_uri'] }">{$r['fo rum_title' ]}</f>
87                             <t id= "{$r['topi c_id']}" u ri="{$r['t opic_uri'] }">{$r['to pic_title' ]}</t>   87                             <t id= "{$r['topi c_id']}" u ri="{$r['t opic_uri'] }">{$r['to pic_title' ]}</t>
88                         </sr>   88                         </sr>
89   EOF;   89   EOF;
90                    }   90                    }
91                    brea k;   91                    brea k;
92                case 'ms gs':   92                case 'ms gs':
93                    whil e ( list ( ,$r) = eac h ($a) )   93                    whil e ( list ( ,$r) = eac h ($a) )
94                    {   94                    {
95                           95                        
96                         // search  hightlight                                               96                         // search  hightlight                                            
97                         reset($ws) ;   97                         reset($ws) ;
98                         while (lis t (,$w) =  each ($ws) )   98                         while (lis t (,$w) =  each ($ws) )
99                         {   99                         {
100                             if ($w )   100                             if ($w )
101                             {                                  101                             {                               
102                                 $i nd = eregi ( "([^>]*< )", $r['po st_text'],  $ind ); / / html tag s?   102                                 $i nd = eregi ( "([^>]*< )", $r['po st_text'],  $ind ); / / html tag s?
103                                 if  ($ind)   103                                 if  ($ind)
104                                      $r['post _text'] =  preg_repla ce("/($w)( ?=[^>]*<)/ i", "<span  style=\"b ackground- color:yell ow\">$w</s pan>", "<d iv>{$r['po st_text']} </div>");   104                                      $r['post _text'] =  preg_repla ce("/($w)( ?=[^>]*<)/ i", "<span  style=\"b ackground- color:yell ow\">$w</s pan>", "<d iv>{$r['po st_text']} </div>");
105                                 el se   105                                 el se
106                                      $r['post _text'] =  preg_repla ce ("/($w) /i", "<spa n style=\" background -color:yel low\">$w</ span>", $r ['post_tex t']);   106                                      $r['post _text'] =  preg_repla ce ("/($w) /i", "<spa n style=\" background -color:yel low\">$w</ span>", $r ['post_tex t']);
107                             }   107                             }
108     108  
109                         }   109                         }
110                           110                        
111                         encode_pos t_text ($r ['post_tex t']);   111                         encode_pos t_text ($r ['post_tex t']);
112                           112                        
113                         reset($ws) ;   113                         reset($ws) ;
114                         while (lis t (,$w) =  each ($ws) )   114                         while (lis t (,$w) =  each ($ws) )
115                             $r['to pic_title' ] = preg_r eplace ("/ ($w)/i", " <span styl e=\"backgr ound-color :yellow\"> $w</span>" , $r['topi c_title']) ;   115                             $r['to pic_title' ] = preg_r eplace ("/ ($w)/i", " <span styl e=\"backgr ound-color :yellow\"> $w</span>" , $r['topi c_title']) ;
116                           116                        
117     117  
118                         encode_pos t_text($r[ 'cat_name' ]);   118                         encode_pos t_text($r[ 'cat_name' ]);
119                         encode_pos t_text($r[ 'forum_tit le']);   119                         encode_pos t_text($r[ 'forum_tit le']);
120                         encode_pos t_text($r[ 'topic_tit le'], 0, 1 );                      120                         encode_pos t_text($r[ 'topic_tit le'], 0, 1 );                   
121                           121                        
122                         $s .= <<<E OF   122                         $s .= <<<E OF
123                         <sr date=" {$r['date' ]}" user=" {$r['user' ]}">   123                         <sr date=" {$r['date' ]}" user=" {$r['user' ]}">
124                             <c id= "{$r['cat_ id']}" uri ="{$r['cat _uri']}">{ $r['cat_na me']}</c>   124                             <c id= "{$r['cat_ id']}" uri ="{$r['cat _uri']}">{ $r['cat_na me']}</c>
125                             <f id= "{$r['foru m_id']}" u ri="{$r['f orum_uri'] }">{$r['fo rum_title' ]}</f>   125                             <f id= "{$r['foru m_id']}" u ri="{$r['f orum_uri'] }">{$r['fo rum_title' ]}</f>
126                             <t id= "{$r['topi c_id']}" u ri="{$r['t opic_uri'] }">{$r['to pic_title' ]}</t>   126                             <t id= "{$r['topi c_id']}" u ri="{$r['t opic_uri'] }">{$r['to pic_title' ]}</t>
127                             <p id= "{$r['post _id']}">{$ r['post_te xt']}</p>   127                             <p id= "{$r['post _id']}">{$ r['post_te xt']}</p>
128                         </sr>   128                         </sr>
129   EOF;   129   EOF;
130                    }   130                    }
131                    brea k;   131                    brea k;
132           }   132           }
133     133  
134           $c u = $this- >getUrlsXm l ();   134           $c u = $this- >getUrlsXm l ();
135           en code_post_ text($text , 0, 1);          135           en code_post_ text($text , 0, 1);       
136           re turn "<roo t>$cu<sear ch><search _text>$tex t</search_ text>$s</s earch></ro ot>";   136           re turn "<roo t>$cu<sear ch><search _text>$tex t</search_ text>$s</s earch></ro ot>";
137       }   137       }
138     138  
139       /**   139       /**
140        * ret urns searc h  page XM L   140        * ret urns searc h  page XM L
141        */   141        */
142       functi on getSear chXML ()   142       functi on getSear chXML ()
143       {   143       {
144           if  (!$this-> _checkUser Perm ('',  '', 'searc h'))   144           if  (!$this-> _checkUser Perm ('',  '', 'searc h'))
145           {   145           {
146                return $ this->_no_ access();   146                return $ this->_no_ access();
147           }   147           }
148     148  
149           $f db = new D bForum ();   149           $f db = new D bForum ();
150     150  
151           $a  = $fdb->g etCategs() ;   151           $a  = $fdb->g etCategs() ;
152           re set ($a);   152           re set ($a);
153           $c  = '';   153           $c  = '';
154           wh ile ( list  (,$r) = e ach ($a) )   154           wh ile ( list  (,$r) = e ach ($a) )
155           {               155           {            
156                $c .= "< categ id=\ "{$r['cat_ id']}\" ur i=\"{$r['c at_uri']}\ ">";   156                $c .= "< categ id=\ "{$r['cat_ id']}\" ur i=\"{$r['c at_uri']}\ ">";
157                encode_p ost_text($ r['cat_nam e'], 0);   157                encode_p ost_text($ r['cat_nam e'], 0);
158                $c .= "< title>{$r[ 'cat_name' ]}</title> ";   158                $c .= "< title>{$r[ 'cat_name' ]}</title> ";
159                $c .= '< forums>' .  $this->ge tForumsSho rtXML ($r[ 'cat_id'],  0) . '</f orums>';   159                $c .= '< forums>' .  $this->ge tForumsSho rtXML ($r[ 'cat_id'],  0) . '</f orums>';
160                $c .= "< /categ>";   160                $c .= "< /categ>";
161           }   161           }
162              162           
163           $s  = "<categ s>$c</cate gs>";   163           $s  = "<categ s>$c</cate gs>";
164     164  
165           $c u = $this- >getUrlsXm l ();   165           $c u = $this- >getUrlsXm l ();
166           re turn "<roo t>$cu<sear ch>$s</sea rch></root >";   166           re turn "<roo t>$cu<sear ch>$s</sea rch></root >";
167       }   167       }
168     168  
169       /**   169       /**
170        * ret urns new t opic page  XML   170        * ret urns new t opic page  XML
171        */   171        */
172       functi on getNewT opicXML ($ forum_uri)   172       functi on getNewT opicXML ($ forum_uri)
173       {   173       {
174           $f db = new D bForum ();   174           $f db = new D bForum ();
175     175  
176           $f  = $fdb->g etForumByU ri ($forum _uri);            176           $f  = $fdb->g etForumByU ri ($forum _uri);         
177           $f orum_id =  $f['forum_ id'];            177           $f orum_id =  $f['forum_ id'];         
178     178  
179           if  (!$this-> _checkUser Perm ('',  $f['forum_ type'], 'p ost', $for um_id))   179           if  (!$this-> _checkUser Perm ('',  $f['forum_ type'], 'p ost', $for um_id))
180           {   180           {
181                return $ this->_no_ access();   181                return $ this->_no_ access();
182           }            182           }         
183     183  
184           $s ticky = 0;   184           $s ticky = 0;
185           if  ($this->_ checkUserP erm ('', ' ', 'sticky ', $forum_ id))   185           if  ($this->_ checkUserP erm ('', ' ', 'sticky ', $forum_ id))
186           {   186           {
187                $sticky  = 1;   187                $sticky  = 1;
188           }            188           }         
189     189  
190           en code_post_ text ($f[' forum_titl e'], 0);   190           en code_post_ text ($f[' forum_titl e'], 0);
191           en code_post_ text ($f[' forum_desc '], 0);   191           en code_post_ text ($f[' forum_desc '], 0);
192              192           
193           $x 1 = <<<EOF   193           $x 1 = <<<EOF
194   <forum>   194   <forum>
195       <id>{$ f['forum_i d']}</id>   195       <id>{$ f['forum_i d']}</id>
196       <uri>{ $f['forum_ uri']}</ur i>   196       <uri>{ $f['forum_ uri']}</ur i>
197       <title >{$f['foru m_title']} </title>   197       <title >{$f['foru m_title']} </title>
198       <desc> {$f['forum _desc']}</ desc>   198       <desc> {$f['forum _desc']}</ desc>
199       <type> {$f['forum _type']}</ type>   199       <type> {$f['forum _type']}</ type>
200   </forum>   200   </forum>
201   EOF;   201   EOF;
202     202  
203           $c at = $fdb- >getCat ($ f['cat_id' ]);   203           $c at = $fdb- >getCat ($ f['cat_id' ]);
204           en code_post_ text ($cat ['cat_name '], 0);   204           en code_post_ text ($cat ['cat_name '], 0);
205           $x 2 = <<<EOF   205           $x 2 = <<<EOF
206   <cat>   206   <cat>
207       <id>{$ f['cat_id' ]}</id>   207       <id>{$ f['cat_id' ]}</id>
208       <uri>{ $cat['cat_ uri']}</ur i>   208       <uri>{ $cat['cat_ uri']}</ur i>
209       <title >{$cat['ca t_name']}< /title>   209       <title >{$cat['ca t_name']}< /title>
210   </cat>   210   </cat>
211   EOF;   211   EOF;
212     212  
213           $c u = $this- >getUrlsXm l ();   213           $c u = $this- >getUrlsXm l ();
214     214  
215           re turn "<roo t>$cu<new_ topic stic ky=\"$stic ky\">{$x2} {$x1}</new _topic></r oot>";   215           re turn "<roo t>$cu<new_ topic stic ky=\"$stic ky\">{$x2} {$x1}</new _topic></r oot>";
216       }   216       }
217     217  
218       /**   218       /**
219        * ret urns post  reply page  XML   219        * ret urns post  reply page  XML
220        */   220        */
221       functi on getPost ReplyXML ( $forum_id,  $topic_id )   221       functi on getPost ReplyXML ( $forum_id,  $topic_id )
222       {   222       {
223           $f db = new D bForum ();   223           $f db = new D bForum ();
224     224  
225           $f  = $fdb->g etForum ($ forum_id);   225           $f  = $fdb->g etForum ($ forum_id);
226     226  
227           $t  = $fdb->g etTopic (( int)$topic _id);   227           $t  = $fdb->g etTopic (( int)$topic _id);
228     228  
229           if  (!$this-> _checkUser Perm ('',  $f['forum_ type'], 'p ost', (int )$forum_id ) || $t['t opic_locke d'])   229           if  (!$this-> _checkUser Perm ('',  $f['forum_ type'], 'p ost', (int )$forum_id ) || $t['t opic_locke d'])
230           {   230           {
231                return $ this->_no_ access();   231                return $ this->_no_ access();
232           }   232           }
233     233  
234           en code_post_ text ($f[' forum_titl e'], 0);   234           en code_post_ text ($f[' forum_titl e'], 0);
235           en code_post_ text ($f[' forum_desc '], 0);   235           en code_post_ text ($f[' forum_desc '], 0);
236              236           
237           $x 1 = <<<EOF   237           $x 1 = <<<EOF
238   <forum>   238   <forum>
239       <id>{$ f['forum_i d']}</id>   239       <id>{$ f['forum_i d']}</id>
240       <uri>{ $f['forum_ uri']}</ur i>   240       <uri>{ $f['forum_ uri']}</ur i>
241       <title >{$f['foru m_title']} </title>   241       <title >{$f['foru m_title']} </title>
242       <desc> {$f['forum _desc']}</ desc>   242       <desc> {$f['forum _desc']}</ desc>
243       <type> {$f['forum _type']}</ type>   243       <type> {$f['forum _type']}</ type>
244   </forum>   244   </forum>
245   EOF;   245   EOF;
246           $c u = $this- >getUrlsXm l ();   246           $c u = $this- >getUrlsXm l ();
247           re turn "<roo t>$cu<new_ topic>$x1< topic><id> $topic_id< /id></topi c></new_to pic></root >";   247           re turn "<roo t>$cu<new_ topic>$x1< topic><id> $topic_id< /id></topi c></new_to pic></root >";
248       }   248       }
249     249  
250       /**   250       /**
251        * ret urns singl e post XML   251        * ret urns singl e post XML
252        * @pa ram $post_ id      po st id   252        * @pa ram $post_ id      po st id
253        * @pa ram $force _show   fo rce show h idden post   253        * @pa ram $force _show   fo rce show h idden post
254        */    254        */ 
255       functi on getHidd enPostXML  ($post_id,  $force_sh ow)   255       functi on getHidd enPostXML  ($post_id,  $force_sh ow)
256       {   256       {
257           gl obal $gCon f;   257           gl obal $gCon f;
258              258           
259           $p ost_id = ( int)$post_ id;   259           $p ost_id = ( int)$post_ id;
260           if  (!$post_i d) return  false;   260           if  (!$post_i d) return  false;
261              261           
262           $u i = array  ();   262           $u i = array  ();
263     263  
264           $f db = new D bForum ();   264           $f db = new D bForum ();
265     265  
266           $t  = $fdb->g etTopicByP ostId ($po st_id);   266           $t  = $fdb->g etTopicByP ostId ($po st_id);
267           $t opic_id =  $t['topic_ id'];   267           $t opic_id =  $t['topic_ id'];
268     268  
269           $f  = $fdb->g etForum ($ t['forum_i d']);            269           $f  = $fdb->g etForum ($ t['forum_i d']);         
270           $f orum_id =  $f['forum_ id'];   270           $f orum_id =  $f['forum_ id'];
271              271           
272           //  check use r permissi on to read  this topi c posts   272           //  check use r permissi on to read  this topi c posts
273     273  
274           $f orum_type  = $f['foru m_type'];   274           $f orum_type  = $f['foru m_type'];
275     275  
276           if  (!$this-> _checkUser Perm ('',  $forum_typ e, 'read',  $forum_id ))   276           if  (!$this-> _checkUser Perm ('',  $forum_typ e, 'read',  $forum_id ))
277           {   277           {
278                return $ this->_no_ access();   278                return $ this->_no_ access();
279           }   279           }
280     280  
281           //  check use r permissi ons to del ete or edi t posts   281           //  check use r permissi ons to del ete or edi t posts
282           $g l_allow_ed it = 0;   282           $g l_allow_ed it = 0;
283           $g l_allow_de l = 0;   283           $g l_allow_de l = 0;
284              284           
285           if  ($this->_ checkUserP erm ('', $ forum_type , 'edit',  $forum_id) )   285           if  ($this->_ checkUserP erm ('', $ forum_type , 'edit',  $forum_id) )
286                $gl_allo w_edit = 1 ;   286                $gl_allo w_edit = 1 ;
287     287  
288           if  ($this->_ checkUserP erm ('', $ forum_type , 'del', $ forum_id))   288           if  ($this->_ checkUserP erm ('', $ forum_type , 'del', $ forum_id))
289                $gl_allo w_del = 1;   289                $gl_allo w_del = 1;
290     290  
291           $u  = $this-> _getLoginU ser();   291           $u  = $this-> _getLoginU ser();
292              292           
293           $r  = $fdb->g etPost($po st_id, $u) ;   293           $r  = $fdb->g etPost($po st_id, $u) ;
294              294           
295           //  acquire u ser info   295           //  acquire u ser info
296           if  (!$ui[$r[ 'user']])   296           if  (!$ui[$r[ 'user']])
297           {                    297           {                 
298                $aa = $t his->_getU serInfo ($ r['user']) ;   298                $aa = $t his->_getU serInfo ($ r['user']) ;
299                $ui[$r[' user']] =  array ('po sts' => (i nt)$fdb->g etUserPost s($r['user ']), 'avat ar' => $aa ['avatar'] , 'url' =>  $aa['prof ile_url'],  'onclick'  => $aa['p rofile_onc lick']);   299                $ui[$r[' user']] =  array ('po sts' => (i nt)$fdb->g etUserPost s($r['user ']), 'avat ar' => $aa ['avatar'] , 'url' =>  $aa['prof ile_url'],  'onclick'  => $aa['p rofile_onc lick']);
300           }   300           }
301     301  
302           $a llow_edit  = $gl_allo w_edit;   302           $a llow_edit  = $gl_allo w_edit;
303           $a llow_del =  $gl_allow _del;   303           $a llow_del =  $gl_allow _del;
304     304  
305           if  (!$allow_ edit && $r ['user'] = = $this->_ getLoginUs erName())   305           if  (!$allow_ edit && $r ['user'] = = $this->_ getLoginUs erName())
306           {   306           {
307                if ($thi s->_checkU serPerm ($ r['user'],  'own', 'e dit', $for um_id))   307                if ($thi s->_checkU serPerm ($ r['user'],  'own', 'e dit', $for um_id))
308                    $all ow_edit =  1;   308                    $all ow_edit =  1;
309           }               309           }            
310     310  
311           if  (!$allow_ del && $r[ 'user'] ==  $this->_g etLoginUse rName())   311           if  (!$allow_ del && $r[ 'user'] ==  $this->_g etLoginUse rName())
312           {   312           {
313                if ($thi s->_checkU serPerm ($ r['user'],  'own', 'd el', $foru m_id))   313                if ($thi s->_checkU serPerm ($ r['user'],  'own', 'd el', $foru m_id))
314                    $all ow_del = 1 ;   314                    $all ow_del = 1 ;
315           }               315           }            
316     316  
317           $c u = $this- >getUrlsXm l ();   317           $c u = $this- >getUrlsXm l ();
318     318  
319           en code_post_ text ($r[' post_text' ]);   319           en code_post_ text ($r[' post_text' ]);
320     320  
321           re turn <<<EO F   321           re turn <<<EO F
322   <root>   322   <root>
323   $cu   323   $cu
324   <forum>   324   <forum>
325       <id>{$ f['forum_i d']}</id>   325       <id>{$ f['forum_i d']}</id>
326       <uri>{ $f['forum_ uri']}</ur i>   326       <uri>{ $f['forum_ uri']}</ur i>
327   </forum>   327   </forum>
328   <topic>   328   <topic>
329       <id>$t opic_id</i d>   329       <id>$t opic_id</i d>
330       <uri>{ $t['topic_ uri']}</ur i>   330       <uri>{ $t['topic_ uri']}</ur i>
331   </topic>   331   </topic>
332   <post id=" {$r['post_ id']}" for ce_show="$ force_show ">   332   <post id=" {$r['post_ id']}" for ce_show="$ force_show ">
333       <text> {$r['post_ text']}</t ext>   333       <text> {$r['post_ text']}</t ext>
334       <when> {$r['when' ]}</when>   334       <when> {$r['when' ]}</when>
335       <allow _edit>$all ow_edit</a llow_edit>   335       <allow _edit>$all ow_edit</a llow_edit>
336       <allow _del>$allo w_del</all ow_del>   336       <allow _del>$allo w_del</all ow_del>
337       <point s>{$r['vot es']}</poi nts>   337       <point s>{$r['vot es']}</poi nts>
338       <vote_ user_point >{$r['vote _user_poin t']}</vote _user_poin t>     338       <vote_ user_point >{$r['vote _user_poin t']}</vote _user_poin t>  
339       <user  posts="{$u i[$r['user ']]['posts ']}" name= "{$r['user ']}">   339       <user  posts="{$u i[$r['user ']]['posts ']}" name= "{$r['user ']}">
340           <a vatar>{$ui [$r['user' ]]['avatar ']}</avata r>   340           <a vatar>{$ui [$r['user' ]]['avatar ']}</avata r>
341           <u rl>{$ui[$r ['user']][ 'url']}</u rl>   341           <u rl>{$ui[$r ['user']][ 'url']}</u rl>
342           <o nclick>{$u i[$r['user ']]['oncli ck']}</onc lick>   342           <o nclick>{$u i[$r['user ']]['oncli ck']}</onc lick>
343       </user >   343       </user >
344       <min_p oint>{$gCo nf['min_po int']}</mi n_point>   344       <min_p oint>{$gCo nf['min_po int']}</mi n_point>
345   </post>   345   </post>
346   </root>   346   </root>
347   EOF;   347   EOF;
348       }   348       }
349          349       
350       /**   350       /**
351        * ret urns topic  posts XML   351        * ret urns topic  posts XML
352        * @pa ram $topic _id   352        * @pa ram $topic _id
353        * @pa ram $wp            re turn whole  page XML   353        * @pa ram $wp            re turn whole  page XML
354        */   354        */
355       functi on getPost sXML ($top ic_uri, $w p)   355       functi on getPost sXML ($top ic_uri, $w p)
356       {   356       {
357           gl obal $gCon f;   357           gl obal $gCon f;
358              358           
359           $u i = array  ();   359           $u i = array  ();
360     360  
361           $f db = new D bForum ();   361           $f db = new D bForum ();
362     362  
363           $u  = $this-> _getLoginU ser();   363           $u  = $this-> _getLoginU ser();
364           $a  = $fdb->g etPostsByU ri($topic_ uri, $u);   364           $a  = $fdb->g etPostsByU ri($topic_ uri, $u);
365           $t opic_id =  $a[0]['top ic_id'];   365           $t opic_id =  $a[0]['top ic_id'];
366     366  
367           //  check use r permissi on to read  this topi c posts   367           //  check use r permissi on to read  this topi c posts
368           $f  = $fdb->g etForum ($ a[0]['foru m_id']);   368           $f  = $fdb->g etForum ($ a[0]['foru m_id']);
369           $f orum_id =  $f['forum_ id'];   369           $f orum_id =  $f['forum_ id'];
370           $f orum_type  = $f['foru m_type'];   370           $f orum_type  = $f['foru m_type'];
371     371  
372           if  (!$this-> _checkUser Perm ($u,  $forum_typ e, 'read',  $forum_id ))   372           if  (!$this-> _checkUser Perm ($u,  $forum_typ e, 'read',  $forum_id ))
373           {   373           {
374                return $ this->_no_ access($wp );   374                return $ this->_no_ access($wp );
375           }   375           }
376     376  
377           $c anPost = ( string)(in t)$this->_ checkUserP erm ($u, $ forum_type , 'post',  $forum_id) ;   377           $c anPost = ( string)(in t)$this->_ checkUserP erm ($u, $ forum_type , 'post',  $forum_id) ;
378           $p erm = "<pe rm><can_po st>$canPos t</can_pos t></perm>" ;   378           $p erm = "<pe rm><can_po st>$canPos t</can_pos t></perm>" ;
379     379  
380           $t his->setTr ackTopic ( $topic_id) ;   380           $t his->setTr ackTopic ( $topic_id) ;
381     381  
382           //  check use r permissi ons to del ete or edi t posts   382           //  check use r permissi ons to del ete or edi t posts
383           $g l_allow_ed it = 0;   383           $g l_allow_ed it = 0;
384           $g l_allow_de l = 0;   384           $g l_allow_de l = 0;
385              385           
386           if  ($this->_ checkUserP erm ($u, $ forum_type , 'edit',  $forum_id) )   386           if  ($this->_ checkUserP erm ($u, $ forum_type , 'edit',  $forum_id) )
387                $gl_allo w_edit = 1 ;   387                $gl_allo w_edit = 1 ;
388     388  
389           if  ($this->_ checkUserP erm ($u, $ forum_type , 'del', $ forum_id))   389           if  ($this->_ checkUserP erm ($u, $ forum_type , 'del', $ forum_id))
390                $gl_allo w_del = 1;   390                $gl_allo w_del = 1;
391     391  
392                       392                    
393           re set ($a);   393           re set ($a);
394           $p  = '';   394           $p  = '';
395           wh ile ( list  (,$r) = e ach ($a) )   395           wh ile ( list  (,$r) = e ach ($a) )
396           {   396           {
397                   397                
398                // acqui re user in fo   398                // acqui re user in fo
399                if (!$ui [$r['user' ]])   399                if (!$ui [$r['user' ]])
400                {                   400                {                
401                    $aa  = $this->_ getUserInf o ($r['use r']);   401                    $aa  = $this->_ getUserInf o ($r['use r']);
402                    $ui[ $r['user'] ] = array  ('posts' = > $fdb->ge tUserPosts ($r['user' ]), 'avata r' => $aa[ 'avatar'],  'url' =>  $aa['profi le_url'],  'onclick'  => $aa['pr ofile_oncl ick']);   402                    $ui[ $r['user'] ] = array  ('posts' = > $fdb->ge tUserPosts ($r['user' ]), 'avata r' => $aa[ 'avatar'],  'url' =>  $aa['profi le_url'],  'onclick'  => $aa['pr ofile_oncl ick']);
403                }   403                }
404     404  
405                $allow_e dit = $gl_ allow_edit ;   405                $allow_e dit = $gl_ allow_edit ;
406                $allow_d el = $gl_a llow_del;   406                $allow_d el = $gl_a llow_del;
407     407  
408                if (!$al low_edit & & $r['user '] == $u)   408                if (!$al low_edit & & $r['user '] == $u)
409                {   409                {
410                    if ( $this->_ch eckUserPer m ($r['use r'], 'own' , 'edit',  $forum_id) )   410                    if ( $this->_ch eckUserPer m ($r['use r'], 'own' , 'edit',  $forum_id) )
411                         $allow_edi t = 1;   411                         $allow_edi t = 1;
412                }               412                }            
413     413  
414                if (!$al low_del &&  $r['user' ] == $u)   414                if (!$al low_del &&  $r['user' ] == $u)
415                {   415                {
416                    if ( $this->_ch eckUserPer m ($r['use r'], 'own' , 'del', $ forum_id))   416                    if ( $this->_ch eckUserPer m ($r['use r'], 'own' , 'del', $ forum_id))
417                         $allow_del  = 1;   417                         $allow_del  = 1;
418                }               418                }            
419              419           
420                encode_p ost_text ( $r['post_t ext'], $wp , 1);             420                encode_p ost_text ( $r['post_t ext'], $wp , 1);          
421                   421                
422                $p .= << <EOF   422                $p .= << <EOF
423   <post id=" {$r['post_ id']}"  fo rce_show=" 0">   423   <post id=" {$r['post_ id']}"  fo rce_show=" 0">
424       <text> {$r['post_ text']}</t ext>   424       <text> {$r['post_ text']}</t ext>
425       <when> {$r['when' ]}</when>   425       <when> {$r['when' ]}</when>
426       <allow _edit>$all ow_edit</a llow_edit>   426       <allow _edit>$all ow_edit</a llow_edit>
427       <allow _del>$allo w_del</all ow_del>   427       <allow _del>$allo w_del</all ow_del>
428       <point s>{$r['vot es']}</poi nts>   428       <point s>{$r['vot es']}</poi nts>
429       <vote_ user_point >{$r['vote _user_poin t']}</vote _user_poin t>     429       <vote_ user_point >{$r['vote _user_poin t']}</vote _user_poin t>  
430       <user  posts="{$u i[$r['user ']]['posts ']}" name= "{$r['user ']}">   430       <user  posts="{$u i[$r['user ']]['posts ']}" name= "{$r['user ']}">
431           <a vatar>{$ui [$r['user' ]]['avatar ']}</avata r>   431           <a vatar>{$ui [$r['user' ]]['avatar ']}</avata r>
432           <u rl>{$ui[$r ['user']][ 'url']}</u rl>   432           <u rl>{$ui[$r ['user']][ 'url']}</u rl>
433           <o nclick>{$u i[$r['user ']]['oncli ck']}</onc lick>   433           <o nclick>{$u i[$r['user ']]['oncli ck']}</onc lick>
434       </user >   434       </user >
435       <min_p oint>{$gCo nf['min_po int']}</mi n_point>   435       <min_p oint>{$gCo nf['min_po int']}</mi n_point>
436   </post>   436   </post>
437   EOF;   437   EOF;
438                $rr = $r ;   438                $rr = $r ;
439           }   439           }
440     440  
441           $t  = $fdb->g etTopic ($ rr['topic_ id']);   441           $t  = $fdb->g etTopic ($ rr['topic_ id']);
442     442  
443     443  
444           $c at = $fdb- >getCat ($ f['cat_id' ]);   444           $c at = $fdb- >getCat ($ f['cat_id' ]);
445           en code_post_ text ($cat ['cat_name '], $wp);   445           en code_post_ text ($cat ['cat_name '], $wp);
446           $x 0 = <<<EOF   446           $x 0 = <<<EOF
447   <cat>   447   <cat>
448       <id>{$ cat['cat_i d']}</id>   448       <id>{$ cat['cat_i d']}</id>
449       <uri>{ $cat['cat_ uri']}</ur i>   449       <uri>{ $cat['cat_ uri']}</ur i>
450       <title >{$cat['ca t_name']}< /title>   450       <title >{$cat['ca t_name']}< /title>
451   </cat>   451   </cat>
452   EOF;   452   EOF;
453     453  
454           en code_post_ text ($t[' forum_titl e'], $wp);   454           en code_post_ text ($t[' forum_titl e'], $wp);
455           en code_post_ text ($t[' forum_desc '], $wp);   455           en code_post_ text ($t[' forum_desc '], $wp);
456           $x 1 = <<<EOF   456           $x 1 = <<<EOF
457   <forum>   457   <forum>
458       <id>{$ f['forum_i d']}</id>   458       <id>{$ f['forum_i d']}</id>
459       <uri>{ $f['forum_ uri']}</ur i>   459       <uri>{ $f['forum_ uri']}</ur i>
460       <title >{$t['foru m_title']} </title>   460       <title >{$t['foru m_title']} </title>
461       <desc> {$t['forum _desc']}</ desc>   461       <desc> {$t['forum _desc']}</ desc>
462       <type> {$f['forum _type']}</ type>   462       <type> {$f['forum _type']}</ type>
463   </forum>   463   </forum>
464   EOF;   464   EOF;
465           en code_post_ text ($t[' topic_titl e'], $wp,  1);   465           en code_post_ text ($t[' topic_titl e'], $wp,  1);
466           $x 2 = <<<EOF   466           $x 2 = <<<EOF
467   <topic>   467   <topic>
468       <id>{$ t['topic_i d']}</id>   468       <id>{$ t['topic_i d']}</id>
469       <uri>{ $t['topic_ uri']}</ur i>   469       <uri>{ $t['topic_ uri']}</ur i>
470       <title >{$t['topi c_title']} </title>   470       <title >{$t['topi c_title']} </title>
471       <locke d>{$t['top ic_locked' ]}</locked >   471       <locke d>{$t['top ic_locked' ]}</locked >
472   </topic>   472   </topic>
473   EOF;   473   EOF;
474     474  
475           if  ($wp)   475           if  ($wp)
476           {   476           {
477                $li = $t his->_getL oginInfo ( $u);   477                $li = $t his->_getL oginInfo ( $u);
478                return $ this->addH eaderFoote r ($li, "< posts>{$pe rm}{$x0}{$ x1}{$x2}{$ p}</posts> ");   478                return $ this->addH eaderFoote r ($li, "< posts>{$pe rm}{$x0}{$ x1}{$x2}{$ p}</posts> ");
479           }   479           }
480           el se   480           el se
481           {   481           {
482                $cu = $t his->getUr lsXml ();   482                $cu = $t his->getUr lsXml ();
483                $li = $t his->_getL oginInfo ( $u);   483                $li = $t his->_getL oginInfo ( $u);
484                return " <root><log ininfo>" .  array2xml ($li) . "< /logininfo >$cu<posts >{$perm}{$ x0}{$x1}{$ x2}{$p}</p osts></roo t>";   484                return " <root><log ininfo>" .  array2xml ($li) . "< /logininfo >$cu<posts >{$perm}{$ x0}{$x1}{$ x2}{$p}</p osts></roo t>";
485           }   485           }
486       }   486       }
487     487  
488     488  
489       /**   489       /**
490        * ret urns my th reads topi cs XML   490        * ret urns my th reads topi cs XML
491        * @pa ram $wp            re turn whole  page XML   491        * @pa ram $wp            re turn whole  page XML
492        */   492        */
493       functi on getMyTh readsXML ( $wp)   493       functi on getMyTh readsXML ( $wp)
494       {   494       {
495           gl obal $gCon f;   495           gl obal $gCon f;
496     496  
497           $u ser = $thi s->getLogi nUser();   497           $u ser = $thi s->getLogi nUser();
498     498  
499           $f db = new D bForum ();   499           $f db = new D bForum ();
500     500  
501           $f  = $fdb->g etForum ($ forum_id);   501           $f  = $fdb->g etForum ($ forum_id);
502     502  
503           if  (!$user)   503           if  (!$user)
504           {   504           {
505                return $ this->_no_ access($wp );   505                return $ this->_no_ access($wp );
506           }   506           }
507     507  
508           $x 1 = <<<EOF   508           $x 1 = <<<EOF
509   <forum>   509   <forum>
510       <title ><![CDATA[ [L[My Topi cs]]]]></t itle>   510       <title ><![CDATA[ [L[My Topi cs]]]]></t itle>
511       <desc> <![CDATA[[ L[Topics y ou partici pate in]]] ]></desc>   511       <desc> <![CDATA[[ L[Topics y ou partici pate in]]] ]></desc>
512   </forum>   512   </forum>
513   EOF;   513   EOF;
514     514  
515           $x 2 = '';   515           $x 2 = '';
516              516           
517           $u ser_last_a ct = (int) $fdb->getU serLastAct ivity ($us er);   517           $u ser_last_a ct = (int) $fdb->getU serLastAct ivity ($us er);
518     518  
519           $a  = $fdb->g etMyThread sTopics($u ser);   519           $a  = $fdb->g etMyThread sTopics($u ser);
520           re set ($a);   520           re set ($a);
521           $t  = '';   521           $t  = '';
522           wh ile ( list  (,$r) = e ach ($a) )   522           wh ile ( list  (,$r) = e ach ($a) )
523           {   523           {
524                    $lp  = $fdb->ge tTopicPost ($r['topic _id'], 'la st');   524                    $lp  = $fdb->ge tTopicPost ($r['topic _id'], 'la st');
525                    $fp  = $fdb->ge tTopicPost ($r['topic _id'], 'fi rst');   525                    $fp  = $fdb->ge tTopicPost ($r['topic _id'], 'fi rst');
526                       526                    
527                    $td  = $fdb->ge tTopicDesc  ($r['topi c_id']);   527                    $td  = $fdb->ge tTopicDesc  ($r['topi c_id']);
528                    $thi s->_buld_t opic_desc  ($td);   528                    $thi s->_buld_t opic_desc  ($td);
529     529  
530                    if ( !$user)   530                    if ( !$user)
531                         $new_topic  = 0;   531                         $new_topic  = 0;
532                    else   532                    else
533                         $new_topic  = $this-> isNewTopic  ($r['topi c_id'],  $ r['last_po st_when'],  $user_las t_act) ? 1  : 0;   533                         $new_topic  = $this-> isNewTopic  ($r['topi c_id'],  $ r['last_po st_when'],  $user_las t_act) ? 1  : 0;
534     534  
535                    enco de_post_te xt ($r['to pic_title' ], $wp, 1) ;                   535                    enco de_post_te xt ($r['to pic_title' ], $wp, 1) ;                
536                                             536                                          
537                    $t . = <<<EOF   537                    $t . = <<<EOF
538   <topic id= "{$r['topi c_id']}" n ew="$new_t opic" lpt= "{$r['last _post_when ']}" lut=" {$user_las t_act}">   538   <topic id= "{$r['topi c_id']}" n ew="$new_t opic" lpt= "{$r['last _post_when ']}" lut=" {$user_las t_act}">
539       <uri>{ $r['topic_ uri']}</ur i>   539       <uri>{ $r['topic_ uri']}</ur i>
540       <title >{$r['topi c_title']} </title>   540       <title >{$r['topi c_title']} </title>
541       <desc> {$td}</des c>   541       <desc> {$td}</des c>
542       <count >{$r['coun t_posts']} </count>   542       <count >{$r['coun t_posts']} </count>
543       <last_ u>{$lp['us er']}</las t_u>   543       <last_ u>{$lp['us er']}</las t_u>
544       <last_ d>{$lp['wh en']}</las t_d>   544       <last_ d>{$lp['wh en']}</las t_d>
545       <first _u>{$fp['u ser']}</fi rst_u>   545       <first _u>{$fp['u ser']}</fi rst_u>
546       <first _d>{$fp['w hen']}</fi rst_d>   546       <first _d>{$fp['w hen']}</fi rst_d>
547   </topic>   547   </topic>
548   EOF;   548   EOF;
549           }   549           }
550     550  
551           $p  = '';   551           $p  = '';
552           $n um = $fdb- >getTopics Num($forum _id);   552           $n um = $fdb- >getTopics Num($forum _id);
553           fo r ($i = 0  ; $i < $nu m ; $i +=  $gConf['to pics_per_p age'])   553           fo r ($i = 0  ; $i < $nu m ; $i +=  $gConf['to pics_per_p age'])
554                $p .= '< p c="' . ( ($start >=  $i && $st art < ($i  + $gConf[' topics_per _page']))  ? 1 : 0 ).  '" start= "' . $i .  '">' . ($i /$gConf['t opics_per_ page'] + 1 ) . '</p>' ;   554                $p .= '< p c="' . ( ($start >=  $i && $st art < ($i  + $gConf[' topics_per _page']))  ? 1 : 0 ).  '" start= "' . $i .  '">' . ($i /$gConf['t opics_per_ page'] + 1 ) . '</p>' ;
555          555       
556     556  
557           if  ($wp)   557           if  ($wp)
558           {   558           {
559                $li = $t his->_getL oginInfo ( );   559                $li = $t his->_getL oginInfo ( );
560                return $ this->addH eaderFoote r ($li, "< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics>");   560                return $ this->addH eaderFoote r ($li, "< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics>");
561           }   561           }
562           el se   562           el se
563           {   563           {
564                $cu = $t his->getUr lsXml ();   564                $cu = $t his->getUr lsXml ();
565                return " <root>$cu< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics></r oot>";   565                return " <root>$cu< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics></r oot>";
566           }   566           }
567       }   567       }
568          568       
569     569  
570       /**   570       /**
571        * ret urns flagg ed topics  XML   571        * ret urns flagg ed topics  XML
572        * @pa ram $wp            re turn whole  page XML   572        * @pa ram $wp            re turn whole  page XML
573        */   573        */
574       functi on getMyFl agsXML ($w p)   574       functi on getMyFl agsXML ($w p)
575       {   575       {
576           gl obal $gCon f;   576           gl obal $gCon f;
577     577  
578           $u ser = $thi s->getLogi nUser();   578           $u ser = $thi s->getLogi nUser();
579     579  
580           $f db = new D bForum ();   580           $f db = new D bForum ();
581     581  
582           $f  = $fdb->g etForum ($ forum_id);   582           $f  = $fdb->g etForum ($ forum_id);
583     583  
584           if  (!$user)   584           if  (!$user)
585           {   585           {
586                return $ this->_no_ access($wp );   586                return $ this->_no_ access($wp );
587           }   587           }
588     588  
589           $x 1 = <<<EOF   589           $x 1 = <<<EOF
590   <forum>   590   <forum>
591       <title ><![CDATA[ [L[Flagged  topics]]] ]></title>   591       <title ><![CDATA[ [L[Flagged  topics]]] ]></title>
592       <desc> <![CDATA[[ L[Topics y ou have fl agged]]]]> </desc>   592       <desc> <![CDATA[[ L[Topics y ou have fl agged]]]]> </desc>
593   </forum>   593   </forum>
594   EOF;   594   EOF;
595     595  
596           $x 2 = '';   596           $x 2 = '';
597              597           
598           $u ser_last_a ct = (int) $fdb->getU serLastAct ivity ($us er);   598           $u ser_last_a ct = (int) $fdb->getU serLastAct ivity ($us er);
599     599  
600           $a  = $fdb->g etMyFlagge dTopics($u ser);   600           $a  = $fdb->g etMyFlagge dTopics($u ser);
601           re set ($a);   601           re set ($a);
602           $t  = '';   602           $t  = '';
603           wh ile ( list  (,$r) = e ach ($a) )   603           wh ile ( list  (,$r) = e ach ($a) )
604           {   604           {
605                    $lp  = $fdb->ge tTopicPost ($r['topic _id'], 'la st');   605                    $lp  = $fdb->ge tTopicPost ($r['topic _id'], 'la st');
606                    $fp  = $fdb->ge tTopicPost ($r['topic _id'], 'fi rst');   606                    $fp  = $fdb->ge tTopicPost ($r['topic _id'], 'fi rst');
607                       607                    
608                    $td  = $fdb->ge tTopicDesc  ($r['topi c_id']);   608                    $td  = $fdb->ge tTopicDesc  ($r['topi c_id']);
609                    $thi s->_buld_t opic_desc  ($td);   609                    $thi s->_buld_t opic_desc  ($td);
610                                         610                                      
611                    if ( !$user)   611                    if ( !$user)
612                         $new_topic  = 0;   612                         $new_topic  = 0;
613                    else   613                    else
614                         $new_topic  = $this-> isNewTopic  ($r['topi c_id'],  $ r['last_po st_when'],  $user_las t_act) ? 1  : 0;   614                         $new_topic  = $this-> isNewTopic  ($r['topi c_id'],  $ r['last_po st_when'],  $user_las t_act) ? 1  : 0;
615     615  
616                    enco de_post_te xt ($r['to pic_title' ], $wp, 1) ;                   616                    enco de_post_te xt ($r['to pic_title' ], $wp, 1) ;                
617                                             617                                          
618                    $t . = <<<EOF   618                    $t . = <<<EOF
619   <topic id= "{$r['topi c_id']}" n ew="$new_t opic" lpt= "{$r['last _post_when ']}" lut=" {$user_las t_act}">   619   <topic id= "{$r['topi c_id']}" n ew="$new_t opic" lpt= "{$r['last _post_when ']}" lut=" {$user_las t_act}">
620       <uri>{ $r['topic_ title']}</ uri>   620       <uri>{ $r['topic_ title']}</ uri>
621       <title >{$r['topi c_title']} </title>   621       <title >{$r['topi c_title']} </title>
622       <desc> {$td}</des c>   622       <desc> {$td}</des c>
623       <count >{$r['coun t_posts']} </count>   623       <count >{$r['coun t_posts']} </count>
624       <last_ u>{$lp['us er']}</las t_u>   624       <last_ u>{$lp['us er']}</las t_u>
625       <last_ d>{$lp['wh en']}</las t_d>   625       <last_ d>{$lp['wh en']}</las t_d>
626       <first _u>{$fp['u ser']}</fi rst_u>   626       <first _u>{$fp['u ser']}</fi rst_u>
627       <first _d>{$fp['w hen']}</fi rst_d>   627       <first _d>{$fp['w hen']}</fi rst_d>
628   </topic>   628   </topic>
629   EOF;   629   EOF;
630           }   630           }
631     631  
632           $p  = '';   632           $p  = '';
633           $n um = $fdb- >getTopics Num($forum _id);   633           $n um = $fdb- >getTopics Num($forum _id);
634           fo r ($i = 0  ; $i < $nu m ; $i +=  $gConf['to pics_per_p age'])   634           fo r ($i = 0  ; $i < $nu m ; $i +=  $gConf['to pics_per_p age'])
635                $p .= '< p c="' . ( ($start >=  $i && $st art < ($i  + $gConf[' topics_per _page']))  ? 1 : 0 ).  '" start= "' . $i .  '">' . ($i /$gConf['t opics_per_ page'] + 1 ) . '</p>' ;   635                $p .= '< p c="' . ( ($start >=  $i && $st art < ($i  + $gConf[' topics_per _page']))  ? 1 : 0 ).  '" start= "' . $i .  '">' . ($i /$gConf['t opics_per_ page'] + 1 ) . '</p>' ;
636          636       
637     637  
638           if  ($wp)   638           if  ($wp)
639           {   639           {
640                $li = $t his->_getL oginInfo ( );   640                $li = $t his->_getL oginInfo ( );
641                return $ this->addH eaderFoote r ($li, "< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics>");   641                return $ this->addH eaderFoote r ($li, "< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics>");
642           }   642           }
643           el se   643           el se
644           {   644           {
645                $cu = $t his->getUr lsXml ();   645                $cu = $t his->getUr lsXml ();
646                return " <root>$cu< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics></r oot>";   646                return " <root>$cu< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics></r oot>";
647           }   647           }
648       }   648       }
649     649  
650     650  
651     651  
652       /**   652       /**
653        * ret urns forum  topics XM L   653        * ret urns forum  topics XM L
654        * @pa ram $forum _id     fo rum id   654        * @pa ram $forum _id     fo rum id
655        * @pa ram $wp            re turn whole  page XML   655        * @pa ram $wp            re turn whole  page XML
656        * @pa ram $start         re cord to st art with   656        * @pa ram $start         re cord to st art with
657        */   657        */
658       functi on getTopi csXML ($fo rum_uri, $ wp, $start  = 0)   658       functi on getTopi csXML ($fo rum_uri, $ wp, $start  = 0)
659       {   659       {
660           gl obal $gCon f;   660           gl obal $gCon f;
661     661  
662           $f db = new D bForum ();   662           $f db = new D bForum ();
663     663  
664           $f  = $fdb->g etForumByU ri ($forum _uri);   664           $f  = $fdb->g etForumByU ri ($forum _uri);
665           $f orum_id =  $f['forum_ id'];   665           $f orum_id =  $f['forum_ id'];
666     666  
667           $u ser = $thi s->getLogi nUser();   667           $u ser = $thi s->getLogi nUser();
668     668  
669           if  (!$this-> _checkUser Perm ($use r, $f['for um_type'],  'read', $ forum_id))   669           if  (!$this-> _checkUser Perm ($use r, $f['for um_type'],  'read', $ forum_id))
670           {   670           {
671                return $ this->_no_ access($wp );   671                return $ this->_no_ access($wp );
672           }   672           }
673     673  
674           $c anPost = ( string)(in t)$this->_ checkUserP erm ($user , $f['foru m_type'],  'post', $f orum_id);         674           $c anPost = ( string)(in t)$this->_ checkUserP erm ($user , $f['foru m_type'],  'post', $f orum_id);      
675           $p erm = "<pe rm><can_po st>$canPos t</can_pos t></perm>" ;   675           $p erm = "<pe rm><can_po st>$canPos t</can_pos t></perm>" ;
676     676  
677           en code_post_ text ($f[' forum_titl e'], $wp);   677           en code_post_ text ($f[' forum_titl e'], $wp);
678           en code_post_ text ($f[' forum_desc '], $wp);   678           en code_post_ text ($f[' forum_desc '], $wp);
679              679           
680           $x 1 = <<<EOF   680           $x 1 = <<<EOF
681   <forum>   681   <forum>
682       <id>{$ f['forum_i d']}</id>   682       <id>{$ f['forum_i d']}</id>
683       <uri>{ $f['forum_ uri']}</ur i>   683       <uri>{ $f['forum_ uri']}</ur i>
684       <title >{$f['foru m_title']} </title>   684       <title >{$f['foru m_title']} </title>
685       <desc> {$f['forum _desc']}</ desc>   685       <desc> {$f['forum _desc']}</ desc>
686       <type> {$f['forum _type']}</ type>   686       <type> {$f['forum _type']}</ type>
687   </forum>   687   </forum>
688   EOF;   688   EOF;
689     689  
690           $c at = $fdb- >getCat ($ f['cat_id' ]);   690           $c at = $fdb- >getCat ($ f['cat_id' ]);
691           en code_post_ text ($cat ['cat_name '], $wp);   691           en code_post_ text ($cat ['cat_name '], $wp);
692           $x 2 = <<<EOF   692           $x 2 = <<<EOF
693   <cat>   693   <cat>
694       <id>{$ cat['cat_i d']}</id>   694       <id>{$ cat['cat_i d']}</id>
695       <uri>{ $cat['cat_ uri']}</ur i>   695       <uri>{ $cat['cat_ uri']}</ur i>
696       <title >{$cat['ca t_name']}< /title>   696       <title >{$cat['ca t_name']}< /title>
697   </cat>   697   </cat>
698   EOF;   698   EOF;
699     699  
700           $u ser_last_a ct = (int) $fdb->getU serLastAct ivity ($us er);   700           $u ser_last_a ct = (int) $fdb->getU serLastAct ivity ($us er);
701     701  
702           $a  = $fdb->g etTopics($ forum_id,  $start);   702           $a  = $fdb->g etTopics($ forum_id,  $start);
703           re set ($a);   703           re set ($a);
704           $t  = '';   704           $t  = '';
705           wh ile ( list  (,$r) = e ach ($a) )   705           wh ile ( list  (,$r) = e ach ($a) )
706           {   706           {
707                    $td  = $fdb->ge tTopicDesc  ($r['topi c_id']);   707                    $td  = $fdb->ge tTopicDesc  ($r['topi c_id']);
708                    $thi s->_buld_t opic_desc  ($td);   708                    $thi s->_buld_t opic_desc  ($td);
709     709  
710                    if ( !$user)   710                    if ( !$user)
711                         $new_topic  = 0;   711                         $new_topic  = 0;
712                    else   712                    else
713                         $new_topic  = $this-> isNewTopic  ($r['topi c_id'],  $ r['last_po st_when'],  $user_las t_act) ? 1  : 0;   713                         $new_topic  = $this-> isNewTopic  ($r['topi c_id'],  $ r['last_po st_when'],  $user_las t_act) ? 1  : 0;
714     714  
715                                             715                                          
716                    enco de_post_te xt ($r['to pic_title' ], $wp, 1) ;                   716                    enco de_post_te xt ($r['to pic_title' ], $wp, 1) ;                
717                       717                    
718                    $t . = <<<EOF   718                    $t . = <<<EOF
719   <topic id= "{$r['topi c_id']}" n ew="$new_t opic" lpt= "{$r['last _post_when ']}" lut=" {$user_las t_act}" st icky="{$r[ 'topic_sti cky']}" lo cked="{$r[ 'topic_loc ked']}">   719   <topic id= "{$r['topi c_id']}" n ew="$new_t opic" lpt= "{$r['last _post_when ']}" lut=" {$user_las t_act}" st icky="{$r[ 'topic_sti cky']}" lo cked="{$r[ 'topic_loc ked']}">
720       <uri>{ $r['topic_ uri']}</ur i>   720       <uri>{ $r['topic_ uri']}</ur i>
721       <title >{$r['topi c_title']} </title>   721       <title >{$r['topi c_title']} </title>
722       <desc> {$td}</des c>   722       <desc> {$td}</des c>
723       <count >{$r['coun t_posts']} </count>   723       <count >{$r['coun t_posts']} </count>
724       <last_ u>{$r['las t_post_use r']}</last _u>   724       <last_ u>{$r['las t_post_use r']}</last _u>
725       <last_ d>{$r['las t_when']}< /last_d>   725       <last_ d>{$r['las t_when']}< /last_d>
726       <first _u>{$r['fi rst_post_u ser']}</fi rst_u>   726       <first _u>{$r['fi rst_post_u ser']}</fi rst_u>
727       <first _d>{$r['fi rst_when'] }</first_d >   727       <first _d>{$r['fi rst_when'] }</first_d >
728   </topic>   728   </topic>
729   EOF;   729   EOF;
730           }   730           }
731     731  
732           $p  = '';   732           $p  = '';
733           $n um = $fdb- >getTopics Num($forum _id);   733           $n um = $fdb- >getTopics Num($forum _id);
734           fo r ($i = 0  ; $i < $nu m ; $i +=  $gConf['to pics_per_p age'])   734           fo r ($i = 0  ; $i < $nu m ; $i +=  $gConf['to pics_per_p age'])
735                $p .= '< p c="' . ( ($start >=  $i && $st art < ($i  + $gConf[' topics_per _page']))  ? 1 : 0 ).  '" start= "' . $i .  '">' . ($i /$gConf['t opics_per_ page'] + 1 ) . '</p>' ;   735                $p .= '< p c="' . ( ($start >=  $i && $st art < ($i  + $gConf[' topics_per _page']))  ? 1 : 0 ).  '" start= "' . $i .  '">' . ($i /$gConf['t opics_per_ page'] + 1 ) . '</p>' ;
736          736       
737     737  
738           if  ($wp)   738           if  ($wp)
739           {   739           {
740                $li = $t his->_getL oginInfo ( $user);   740                $li = $t his->_getL oginInfo ( $user);
741                return $ this->addH eaderFoote r ($li, "< topics><pa ges>$p</pa ges>{$perm }{$x2}{$x1 }{$t}</top ics>");   741                return $ this->addH eaderFoote r ($li, "< topics><pa ges>$p</pa ges>{$perm }{$x2}{$x1 }{$t}</top ics>");
742           }   742           }
743           el se   743           el se
744           {   744           {
745                $cu = $t his->getUr lsXml ();   745                $cu = $t his->getUr lsXml ();
746                return " <root>$cu< topics><pa ges>$p</pa ges>{$perm }{$x2}{$x1 }{$t}</top ics></root >";   746                return " <root>$cu< topics><pa ges>$p</pa ges>{$perm }{$x2}{$x1 }{$t}</top ics></root >";
747           }   747           }
748       }   748       }
749     749  
750       /**   750       /**
751        * ret urns array  with view ed topics   751        * ret urns array  with view ed topics
752        */    752        */ 
753       functi on getTrac kTopics ()   753       functi on getTrac kTopics ()
754       {   754       {
755           $a  = unseria lize($_COO KIE['track _topics']) ;   755           $a  = unseria lize($_COO KIE['track _topics']) ;
756           if  (!is_arra y($a)) ret urn array  ();   756           if  (!is_arra y($a)) ret urn array  ();
757           re turn $a;   757           re turn $a;
758       }   758       }
759     759  
760       /**   760       /**
761        * mar k topic as  viewed   761        * mar k topic as  viewed
762        */    762        */ 
763       functi on setTrac kTopic ($t opic_id)   763       functi on setTrac kTopic ($t opic_id)
764       {   764       {
765           $a  = unseria lize($_COO KIE['track _topics']) ;   765           $a  = unseria lize($_COO KIE['track _topics']) ;
766           if  (!is_arra y($a)) $a  = array () ;   766           if  (!is_arra y($a)) $a  = array () ;
767           $a [$topic_id ] = time() ;   767           $a [$topic_id ] = time() ;
768           se tcookie (' track_topi cs', seria lize($a));   768           se tcookie (' track_topi cs', seria lize($a));
769       }   769       }
770     770  
771       /**   771       /**
772        * det ect new to pic by las t topic up date time  and user a ctivity an d cookies   772        * det ect new to pic by las t topic up date time  and user a ctivity an d cookies
773        *   773        *
774        */    774        */ 
775       functi on isNewTo pic ($topi c_id, $top ic_last_ti me, $user_ last_time)   775       functi on isNewTo pic ($topi c_id, $top ic_last_ti me, $user_ last_time)
776       {   776       {
777           $a  = $this-> getTrackTo pics ();          777           $a  = $this-> getTrackTo pics ();       
778              778           
779           if  ($a[$topi c_id] && $ topic_last _time > $a [$topic_id ])    779           if  ($a[$topi c_id] && $ topic_last _time > $a [$topic_id ]) 
780                return 1 ;   780                return 1 ;
781           el se if ($a[ $topic_id] )   781           el se if ($a[ $topic_id] )
782                return 0 ;   782                return 0 ;
783     783  
784           if  (!$user_l ast_time)  return 1;   784           if  (!$user_l ast_time)  return 1;
785     785  
786           if  ($topic_l ast_time >  $user_las t_time) re turn 1;   786           if  ($topic_l ast_time >  $user_las t_time) re turn 1;
787     787  
788           re turn 0;   788           re turn 0;
789       }   789       }
790     790  
791       /**   791       /**
792        * ret urns forum s XML   792        * ret urns forum s XML
793        */   793        */
794       functi on getForu msShortXML  ($cat, $r oot)   794       functi on getForu msShortXML  ($cat, $r oot)
795       {   795       {
796           $f db = new D bForum ();   796           $f db = new D bForum ();
797           if  ($root)    797           if  ($root) 
798                $c = '<f orums>';   798                $c = '<f orums>';
799           el se   799           el se
800                $c = '';   800                $c = '';
801           $a a = $fdb-> getForums  ($cat);   801           $a a = $fdb-> getForums  ($cat);
802           re set ($aa);   802           re set ($aa);
803           wh ile ( list  (,$rr) =  each ($aa)  )   803           wh ile ( list  (,$rr) =  each ($aa)  )
804           {   804           {
805                encode_p ost_text($ rr['forum_ title'], 0 );   805                encode_p ost_text($ rr['forum_ title'], 0 );
806                   806                
807                $c .= << <EOF   807                $c .= << <EOF
808   <forum id= "{$rr['for um_id']}">   808   <forum id= "{$rr['for um_id']}">
809       <uri>{ $rr['forum _uri']}</u ri>   809       <uri>{ $rr['forum _uri']}</u ri>
810       <title >{$rr['for um_title'] }</title>   810       <title >{$rr['for um_title'] }</title>
811       <type> {$rr['foru m_type']}< /type>   811       <type> {$rr['foru m_type']}< /type>
812   </forum>   812   </forum>
813     813  
814   EOF;   814   EOF;
815           }   815           }
816           if  ($root)   816           if  ($root)
817                return $ c."</forum s>\n";   817                return $ c."</forum s>\n";
818           el se   818           el se
819                return $ c;   819                return $ c;
820       }   820       }
821     821  
822       /**   822       /**
823        * ret urns forum s XML   823        * ret urns forum s XML
824        */   824        */
825       functi on getForu msXML ($ca t, $root)   825       functi on getForu msXML ($ca t, $root)
826       {   826       {
827           $f db = new D bForum ();   827           $f db = new D bForum ();
828           if  ($root)    828           if  ($root) 
829                $c = '<f orums>';   829                $c = '<f orums>';
830           el se   830           el se
831                $c = '';   831                $c = '';
832           $a a = $fdb-> getForumsB yCatUri ($ cat);   832           $a a = $fdb-> getForumsB yCatUri ($ cat);
833     833  
834           re set ($aa);   834           re set ($aa);
835           wh ile ( list  (,$rr) =  each ($aa)  )   835           wh ile ( list  (,$rr) =  each ($aa)  )
836           {   836           {
837                encode_p ost_text ( $rr['forum _title'],  $root);   837                encode_p ost_text ( $rr['forum _title'],  $root);
838                encode_p ost_text ( $rr['forum _desc'], $ root);   838                encode_p ost_text ( $rr['forum _desc'], $ root);
839                   839                
840                $c .= << <EOF   840                $c .= << <EOF
841   <forum id= "{$rr['for um_id']}"  new="0">   841   <forum id= "{$rr['for um_id']}"  new="0">
842       <uri>{ $rr['forum _uri']}</u ri>   842       <uri>{ $rr['forum _uri']}</u ri>
843       <title >{$rr['for um_title'] }</title>   843       <title >{$rr['for um_title'] }</title>
844       <desc> {$rr['foru m_desc']}< /desc>   844       <desc> {$rr['foru m_desc']}< /desc>
845       <type> {$rr['foru m_type']}< /type>   845       <type> {$rr['foru m_type']}< /type>
846       <posts >{$rr['for um_posts'] }</posts>   846       <posts >{$rr['for um_posts'] }</posts>
847       <topic s>{$rr['fo rum_topics ']}</topic s>   847       <topic s>{$rr['fo rum_topics ']}</topic s>
848       <last> {$rr['foru m_last']}< /last>   848       <last> {$rr['foru m_last']}< /last>
849   </forum>   849   </forum>
850     850  
851   EOF;   851   EOF;
852           }   852           }
853              853           
854           if  ($root)   854           if  ($root)
855           {   855           {
856                $cu = $t his->getUr lsXml ();   856                $cu = $t his->getUr lsXml ();
857                return ' <root>' .  $cu . $c .  "</forums ></root>\n ";   857                return ' <root>' .  $cu . $c .  "</forums ></root>\n ";
858           }   858           }
859           el se   859           el se
860           {   860           {
861                return $ c;   861                return $ c;
862           }   862           }
863       }   863       }
864     864  
865     865  
866     866  
867       /**   867       /**
868        * ret urns page  XML   868        * ret urns page  XML
869        */   869        */
870       functi on getPage XML ($firs t_load = 1 , &$p)   870       functi on getPage XML ($firs t_load = 1 , &$p)
871       {   871       {
872           gl obal $gCon f;   872           gl obal $gCon f;
873     873  
874           $f db = new D bForum ();   874           $f db = new D bForum ();
875     875  
876           $a  = $fdb->g etCategs() ;   876           $a  = $fdb->g etCategs() ;
877           re set ($a);   877           re set ($a);
878           $c  = '';   878           $c  = '';
879           wh ile ( list  (,$r) = e ach ($a) )   879           wh ile ( list  (,$r) = e ach ($a) )
880           {   880           {
881                $icon_ur l  = $r['c at_icon']  ? $gConf[' url']['ico n'] . $r[' cat_icon']  : '';   881                $icon_ur l  = $r['c at_icon']  ? $gConf[' url']['ico n'] . $r[' cat_icon']  : '';
882                $c .= "< categ id=\ "{$r['cat_ id']}\" ur i=\"{$r['c at_uri']}\ " icon=\"$ icon_url\" >";   882                $c .= "< categ id=\ "{$r['cat_ id']}\" ur i=\"{$r['c at_uri']}\ " icon=\"$ icon_url\" >";
883                encode_p ost_text ( $r['cat_na me'], 1);   883                encode_p ost_text ( $r['cat_na me'], 1);
884                $c .= "< title>{$r[ 'cat_name' ]}</title> ";   884                $c .= "< title>{$r[ 'cat_name' ]}</title> ";
885     885  
886                if (( is set($p['ca t']) && $p ['cat'] ==  $r['cat_u ri'] ) /*| | 1 == $r[ 'cat_id']  */)   886                if (( is set($p['ca t']) && $p ['cat'] ==  $r['cat_u ri'] ) /*| | 1 == $r[ 'cat_id']  */)
887                {   887                {
888                    $c . = '<forums >'.$this-> getForumsX ML ($r['ca t_uri'], 0 ) . '</for ums>';   888                    $c . = '<forums >'.$this-> getForumsX ML ($r['ca t_uri'], 0 ) . '</for ums>';
889                }   889                }
890                $c .= "< /categ>";   890                $c .= "< /categ>";
891           }   891           }
892              892           
893           $s  = "<categ s>$c</cate gs>";   893           $s  = "<categ s>$c</cate gs>";
894     894  
895           if  ($first_l oad && iss et($p['act ion']) &&  'goto' ==  $p['action '] && isse t($p['foru m_id']))   895           if  ($first_l oad && iss et($p['act ion']) &&  'goto' ==  $p['action '] && isse t($p['foru m_id']))
896           {   896           {
897                $s .= "< onload>f.s electForum ('" . $p[' forum_id']  . "', 0)< /onload>";   897                $s .= "< onload>f.s electForum ('" . $p[' forum_id']  . "', 0)< /onload>";
898           }   898           }
899              899           
900           if  ($first_l oad && iss et($p['act ion']) &&  'goto' ==  $p['action '] && isse t($p['topi c_id']))   900           if  ($first_l oad && iss et($p['act ion']) &&  'goto' ==  $p['action '] && isse t($p['topi c_id']))
901           {   901           {
902                $s .= "< onload>f.s electTopic ('" . $p[' topic_id']  . "')</on load>";   902                $s .= "< onload>f.s electTopic ('" . $p[' topic_id']  . "')</on load>";
903           }   903           }
904     904  
905           //  live trac ker   905           //  live trac ker
906           $l t = "<live _tracker>"  . $this-> getLivePos tsXML() .  "</live_tr acker>";   906           $l t = "<live _tracker>"  . $this-> getLivePos tsXML() .  "</live_tr acker>";
907              907           
908           $l i = $this- >_getLogin Info ();   908           $l i = $this- >_getLogin Info ();
909     909  
910           ev al($GLOBAL S['l']('IC AgICAgICBp ZiAoJGxpWy dhZG1pbidd KQ0KICAgIC AgICB7DQog ICAgICAgIC AgICAkb0Fk bSA9IG5ldy BBZG1pbigp Ow0KICAgIC AgICAgICAg JGlDb2RlID 0gJG9BZG0t PmdldENvZG UgKCRzTXNn KTsNCiAgIC AgICAgICAg IGlmICgwIC E9PSAkaUNv ZGUgJiYgMT AgIT09ICRp Q29kZSkNCi AgICAgICAg ICAgICAgIC AkcyAuPSAn PGludmFsaW RfbGljZW5z ZSAvPic7DQ ogICAgICAg ICAgICBzZX RDb25maWdQ YXJhbSgnZG lzYWJsZV9i b29uZXhfZm 9vdGVycycs IDAgPT09IC RpQ29kZSA/ IDEgOiAwKT sNCiAgICAg ICAgfQ==') );   910           ev al($GLOBAL S['l']('IC AgICAgICBp ZiAoJGxpWy dhZG1pbidd KQ0KICAgIC AgICB7DQog ICAgICAgIC AgICAkb0Fk bSA9IG5ldy BBZG1pbigp Ow0KICAgIC AgICAgICAg JGlDb2RlID 0gJG9BZG0t PmdldENvZG UgKCRzTXNn KTsNCiAgIC AgICAgICAg IGlmICgwIC E9PSAkaUNv ZGUgJiYgMT AgIT09ICRp Q29kZSkNCi AgICAgICAg ICAgICAgIC AkcyAuPSAn PGludmFsaW RfbGljZW5z ZSAvPic7DQ ogICAgICAg ICAgICBzZX RDb25maWdQ YXJhbSgnZG lzYWJsZV9i b29uZXhfZm 9vdGVycycs IDAgPT09IC RpQ29kZSA/ IDEgOiAwKT sNCiAgICAg ICAgfQ==') );
911     911  
912           if  ($first_l oad)   912           if  ($first_l oad)
913           {   913           {
914                return $ this->addH eaderFoote r ($li, $s .$lt);   914                return $ this->addH eaderFoote r ($li, $s .$lt);
915           }   915           }
916           el se   916           el se
917           {   917           {
918                $cu = $t his->getUr lsXml ();   918                $cu = $t his->getUr lsXml ();
919                return " <root>$cu< logininfo> ".array2xm l($li)."</ logininfo> <page>{$s} {$lt}</pag e></root>" ;   919                return " <root>$cu< logininfo> ".array2xm l($li)."</ logininfo> <page>{$s} {$lt}</pag e></root>" ;
920           }   920           }
921       }   921       }
922     922  
923       functi on getLive PostsXML ( $count = 1 0, $ts = 0 )   923       functi on getLive PostsXML ( $count = 1 0, $ts = 0 )
924       {   924       {
925           re turn ''; / /turned of f for grou ps   925           re turn ''; / /turned of f for grou ps
926     926  
927           gl obal $gCon f;   927           gl obal $gCon f;
928     928  
929           $r et = '';   929           $r et = '';
930     930  
931           $f db = new D bForum ();   931           $f db = new D bForum ();
932           $a  = $fdb->g etLivePost s ($count,  $ts);   932           $a  = $fdb->g etLivePost s ($count,  $ts);
933           re set ($a);   933           re set ($a);
934           $u i = array  ();   934           $u i = array  ();
935           wh ile (list( ,$r) = eac h ($a))   935           wh ile (list( ,$r) = eac h ($a))
936           {   936           {
937                // acqui re user in fo   937                // acqui re user in fo
938                if (!iss et($ui[$r[ 'user']]))   938                if (!iss et($ui[$r[ 'user']]))
939                {   939                {
940                    $aa  = $this->_ getUserInf o ($r['use r']);   940                    $aa  = $this->_ getUserInf o ($r['use r']);
941                    $ui[ $r['user'] ] = array  ('avatar'  => $aa['av atar'], 'u rl' => $aa ['profile_ url'], 'on click' =>  $aa['profi le_onclick ']);   941                    $ui[ $r['user'] ] = array  ('avatar'  => $aa['av atar'], 'u rl' => $aa ['profile_ url'], 'on click' =>  $aa['profi le_onclick ']);
942                }   942                }
943     943  
944                $this->_ buld_topic _desc ($r[ 'post_text ']);   944                $this->_ buld_topic _desc ($r[ 'post_text ']);
945     945  
946                encode_p ost_text($ r['topic_t itle'], 0,  1);   946                encode_p ost_text($ r['topic_t itle'], 0,  1);
947                encode_p ost_text($ r['forum_t itle'], 0) ;   947                encode_p ost_text($ r['forum_t itle'], 0) ;
948                encode_p ost_text($ r['cat_nam e'], 0);                              948                encode_p ost_text($ r['cat_nam e'], 0);                           
949                   949                
950                $r['when '] = $this ->_format_ when ($r[' sec']);   950                $r['when '] = $this ->_format_ when ($r[' sec']);
951     951  
952                $ret .=  <<<EOF   952                $ret .=  <<<EOF
953   <post id=" {$r['post_ id']}" ts= "{$r['ts'] }">   953   <post id=" {$r['post_ id']}" ts= "{$r['ts'] }">
954       <text> {$r['post_ text']}</t ext>   954       <text> {$r['post_ text']}</t ext>
955       <user> {$r['user' ]}</user>   955       <user> {$r['user' ]}</user>
956       <date> {$r['when' ]}</date>   956       <date> {$r['when' ]}</date>
957     957  
958       <avata r>{$ui[$r[ 'user']][' avatar']}< /avatar>   958       <avata r>{$ui[$r[ 'user']][' avatar']}< /avatar>
959       <profi le>{$ui[$r ['user']][ 'url']}</p rofile>   959       <profi le>{$ui[$r ['user']][ 'url']}</p rofile>
960       <oncli ck>{$ui[$r ['user']][ 'onclick'] }</onclick >   960       <oncli ck>{$ui[$r ['user']][ 'onclick'] }</onclick >
961     961  
962       <topic  id="{$r[' topic_id'] }" uri="{$ r['topic_u ri']}">{$r ['topic_ti tle']}</to pic>   962       <topic  id="{$r[' topic_id'] }" uri="{$ r['topic_u ri']}">{$r ['topic_ti tle']}</to pic>
963       <forum  id="{$r[' forum_id'] }" uri="{$ r['forum_u ri']}">{$r ['forum_ti tle']}</fo rum>   963       <forum  id="{$r[' forum_id'] }" uri="{$ r['forum_u ri']}">{$r ['forum_ti tle']}</fo rum>
964       <cat i d="{$r['ca t_id']}" u ri="{$r['c at_uri']}" >{$r['cat_ name']}</c at>   964       <cat i d="{$r['ca t_id']}" u ri="{$r['c at_uri']}" >{$r['cat_ name']}</c at>
965       <base> {$gConf['u rl']['base ']}</base>   965       <base> {$gConf['u rl']['base ']}</base>
966   </post>   966   </post>
967   EOF;   967   EOF;
968           }   968           }
969     969  
970           re turn $ret;   970           re turn $ret;
971       }   971       }
972     972  
973       /**   973       /**
974        * che ck if new  posts are  available   974        * che ck if new  posts are  available
975        *  @p aram  $ts      timest amp of las t post   975        *  @p aram  $ts      timest amp of las t post
976        */    976        */ 
977       functi on isNewPo st ($ts)   977       functi on isNewPo st ($ts)
978       {   978       {
979           $d b = new Db Forum ();           979           $d b = new Db Forum ();        
980           re turn '<ret >' . (int) $db->getNe wPostTs ($ ts) . '</r et>';   980           re turn '<ret >' . (int) $db->getNe wPostTs ($ ts) . '</r et>';
981       }   981       }
982     982  
983     983  
984       /**   984       /**
985        * pos t reply   985        * pos t reply
986        * @pa ram $p     _post arra y   986        * @pa ram $p     _post arra y
987        */   987        */
988       functi on postRep lyXML (&$p )   988       functi on postRep lyXML (&$p )
989       {   989       {
990     990  
991           $f db = new D bForum ();   991           $f db = new D bForum ();
992     992  
993           $f  = $fdb->g etForum (( int)$p['fo rum_id']);   993           $f  = $fdb->g etForum (( int)$p['fo rum_id']);
994     994  
995           $t  = $fdb->g etTopic (( int)$p['to pic_id']);   995           $t  = $fdb->g etTopic (( int)$p['to pic_id']);
996     996  
997           if  (!$this-> _checkUser Perm ('',  $f['forum_ type'], 'p ost', (int )$p['forum _id']) ||  $t['topic_ locked'])    997           if  (!$this-> _checkUser Perm ('',  $f['forum_ type'], 'p ost', (int )$p['forum _id']) ||  $t['topic_ locked']) 
998           {   998           {
999                return < <<EOF   999                return < <<EOF
1000   <html>   1000   <html>
1001   <body>   1001   <body>
1002   <script la nguage="ja vascript"  type="text /javascrip t">   1002   <script la nguage="ja vascript"  type="text /javascrip t">
1003       window .parent.do cument.f.a ccessDenie d();   1003       window .parent.do cument.f.a ccessDenie d();
1004   </script>   1004   </script>
1005   </body>   1005   </body>
1006   </html>   1006   </html>
1007   EOF;   1007   EOF;
1008           }           1008           }        
1009     1009  
1010     1010  
1011           //  post mesa ge here   1011           //  post mesa ge here
1012     1012  
1013           $p ['forum_id '] = (int) $p['forum_ id'];   1013           $p ['forum_id '] = (int) $p['forum_ id'];
1014           $p ['topic_id '] = (int) $p['topic_ id'];   1014           $p ['topic_id '] = (int) $p['topic_ id'];
1015     1015  
1016           $u ser = $thi s->_getLog inUserName  ();   1016           $u ser = $thi s->_getLog inUserName  ();
1017     1017  
1018           pr epare_to_d b($p['topi c_text'],  1);   1018           pr epare_to_d b($p['topi c_text'],  1);
1019     1019  
1020           $f db->postRe ply ($p['f orum_id'],  $p['topic _id'], $p[ 'topic_tex t'], $user );   1020           $f db->postRe ply ($p['f orum_id'],  $p['topic _id'], $p[ 'topic_tex t'], $user );
1021     1021  
1022           $t  = $fdb->g etTopic($p ['topic_id ']);   1022           $t  = $fdb->g etTopic($p ['topic_id ']);
1023     1023  
1024           re turn <<<EO F   1024           re turn <<<EO F
1025   <html>   1025   <html>
1026   <body>   1026   <body>
1027   <script la nguage="ja vascript"  type="text /javascrip t">   1027   <script la nguage="ja vascript"  type="text /javascrip t">
1028       window .parent.do cument.f.r eplySucces s('{$f['fo rum_uri']} ', '{$t['t opic_uri'] }');   1028       window .parent.do cument.f.r eplySucces s('{$f['fo rum_uri']} ', '{$t['t opic_uri'] }');
1029   </script>   1029   </script>
1030   </body>   1030   </body>
1031   </html>   1031   </html>
1032   EOF;   1032   EOF;
1033     1033  
1034     1034  
1035       }   1035       }
1036     1036  
1037       /**   1037       /**
1038        * xml  for edit  post    1038        * xml  for edit  post 
1039        * @pa ram $post_ id      po st id   1039        * @pa ram $post_ id      po st id
1040        * @pa ram $topic _id     to pic id   1040        * @pa ram $topic _id     to pic id
1041        */   1041        */
1042       functi on editPos tXml ($pos t_id, $top ic_id)   1042       functi on editPos tXml ($pos t_id, $top ic_id)
1043       {   1043       {
1044           $c u = $this- >getUrlsXm l ();   1044           $c u = $this- >getUrlsXm l ();
1045            if   (
!$topic_id   &&  
$post_id)
  1045            if   ( /* !$topic_id   &&   */ $post_id)
1046           {   1046           {
1047                $db = ne w DbForum  ();          1047                $db = ne w DbForum  ();       
1048                 $a   =   $db->get
PostId s   ($post_id) ;
  1048                 $a   =   $db->get TopicBy PostId  
($post_id) ;
1049                 $topic_id   =   $ a ['topic_
i d '];
  1049                $t = $db ->getTopic  ($a['topi c_id']);
    1050                 $topic_id   =   $ t ['topic_ ur i
'];
1050           }   1051           }
1051           re turn <<<EO S   1052           re turn <<<EO S
1052   <root>   1053   <root>
1053       $cu   1054       $cu
1054       <edit_ post>   1055       <edit_ post>
1055           <p ost_id>$po st_id</pos t_id>   1056           <p ost_id>$po st_id</pos t_id>
1056           <t opic_id>$t opic_id</t opic_id>   1057           <t opic_id>$t opic_id</t opic_id>
1057       </edit _post>   1058       </edit _post>
1058   </root>   1059   </root>
1059   EOS;   1060   EOS;
1060       }   1061       }
1061     1062  
1062       /**   1063       /**
1063        * edi t post   1064        * edi t post
1064        * @pa ram $post_ id      po st id   1065        * @pa ram $post_ id      po st id
1065        * @pa ram $topic _id     to pic id   1066        * @pa ram $topic _id     to pic id
1066        * @pa ram $text          ne w post tex t   1067        * @pa ram $text          ne w post tex t
1067        */   1068        */
1068       functi on editPos t ($post_i d, $topic_ id, $text)   1069       functi on editPos t ($post_i d, $topic_ id, $text)
1069       {   1070       {
1070           $n o_access =  true;   1071           $n o_access =  true;
1071     1072  
1072           $f db = new D bForum ();   1073           $f db = new D bForum ();
1073     1074  
1074           // $f = $fdb- >getForumB yPostId ($ post_id);   1075           // $f = $fdb- >getForumB yPostId ($ post_id);
1075           $t  = $fdb->g etTopicByU ri ($topic _id);   1076           $t  = $fdb->g etTopicByU ri ($topic _id);
1076     1077  
1077           if  ($this->_ checkUserP erm ('', $ t['forum_t ype'], 'ed it', $t['f orum_id'])   1078           if  ($this->_ checkUserP erm ('', $ t['forum_t ype'], 'ed it', $t['f orum_id'])
1078                $no_acce ss = false ;   1079                $no_acce ss = false ;
1079           if  ($no_acce ss && $fdb ->getPostU ser((int)$ post_id) = = $this->_ getLoginUs erName())   1080           if  ($no_acce ss && $fdb ->getPostU ser((int)$ post_id) = = $this->_ getLoginUs erName())
1080                if ($thi s->_checkU serPerm (' ', 'own',  'edit', $t ['forum_id ']))    1081                if ($thi s->_checkU serPerm (' ', 'own',  'edit', $t ['forum_id '])) 
1081                    $no_ access = f alse;   1082                    $no_ access = f alse;
1082     1083  
1083           if  ($no_acce ss)   1084           if  ($no_acce ss)
1084           {   1085           {
1085                return < <<EOF   1086                return < <<EOF
1086   <html>   1087   <html>
1087   <body>   1088   <body>
1088   <script la nguage="ja vascript"  type="text /javascrip t">   1089   <script la nguage="ja vascript"  type="text /javascrip t">
1089       window .parent.do cument.f.a ccessDenie d();   1090       window .parent.do cument.f.a ccessDenie d();
1090   </script>   1091   </script>
1091   </body>   1092   </body>
1092   </html>   1093   </html>
1093   EOF;   1094   EOF;
1094           }       1095           }    
1095     1096  
1096           //  edit post  here           1097           //  edit post  here        
1097           pr epare_to_d b($text, 1 );   1098           pr epare_to_d b($text, 1 );
1098              1099           
1099           $f db->editPo st ($post_ id, $text) ;   1100           $f db->editPo st ($post_ id, $text) ;
1100     1101  
1101           re turn <<<EO F   1102           re turn <<<EO F
1102   <html>   1103   <html>
1103   <body>   1104   <body>
1104   <script la nguage="ja vascript"  type="text /javascrip t">   1105   <script la nguage="ja vascript"  type="text /javascrip t">
1105       window .parent.do cument.f.e ditSuccess ('{$t['top ic_uri']}' );   1106       window .parent.do cument.f.e ditSuccess ('{$t['top ic_uri']}' );
1106   </script>   1107   </script>
1107   </body>   1108   </body>
1108   </html>   1109   </html>
1109   EOF;   1110   EOF;
1110     1111  
1111       }   1112       }
1112     1113  
1113       /**   1114       /**
1114        * del ete post   1115        * del ete post
1115        * @pa ram $post_ id      po st id   1116        * @pa ram $post_ id      po st id
1116        * @pa ram $topic _id     to pic id   1117        * @pa ram $topic _id     to pic id
1117        * @pa ram $forum _id     fo rum id    1118        * @pa ram $forum _id     fo rum id 
1118        */   1119        */
1119       functi on deleteP ostXML ($p ost_id, $t opic_id, $ forum_id)   1120       functi on deleteP ostXML ($p ost_id, $t opic_id, $ forum_id)
1120       {   1121       {
1121           $n o_access =  true;   1122           $n o_access =  true;
1122     1123  
1123           $f db = new D bForum ();   1124           $f db = new D bForum ();
1124     1125  
1125           $f  = $fdb->g etForumByP ostId ($po st_id);   1126           $f  = $fdb->g etForumByP ostId ($po st_id);
1126     1127  
1127           if  ($this->_ checkUserP erm ('', $ f['forum_t ype'], 'de l', $f['fo rum_id']))     1128           if  ($this->_ checkUserP erm ('', $ f['forum_t ype'], 'de l', $f['fo rum_id']))  
1128                $no_acce ss = false ;   1129                $no_acce ss = false ;
1129           if  ($no_acce ss && $fdb ->getPostU ser((int)$ post_id) = = $this->_ getLoginUs erName())   1130           if  ($no_acce ss && $fdb ->getPostU ser((int)$ post_id) = = $this->_ getLoginUs erName())
1130                if ($thi s->_checkU serPerm (' ', 'own',  'del', $f[ 'forum_id' ]))    1131                if ($thi s->_checkU serPerm (' ', 'own',  'del', $f[ 'forum_id' ])) 
1131                    $no_ access = f alse;   1132                    $no_ access = f alse;
1132     1133  
1133           if  ($no_acce ss)   1134           if  ($no_acce ss)
1134           {   1135           {
1135                return < <<EOF   1136                return < <<EOF
1136   <html>   1137   <html>
1137   <body>   1138   <body>
1138   <script la nguage="ja vascript"  type="text /javascrip t">   1139   <script la nguage="ja vascript"  type="text /javascrip t">
1139       window .parent.do cument.f.a ccessDenie d();   1140       window .parent.do cument.f.a ccessDenie d();
1140   </script>   1141   </script>
1141   </body>   1142   </body>
1142   </html>   1143   </html>
1143   EOF;   1144   EOF;
1144           }       1145           }    
1145          1146       
1146           //  delete po st here   1147           //  delete po st here
1147     1148  
1148           $f db->delete Post ($pos t_id);   1149           $f db->delete Post ($pos t_id);
1149     1150  
1150            $ ex i sts   =   $fdb->getT opic   ($topic_id )   ?   1   :   0 ;   1151            $ aTop i c   =   $fdb->getT opic   ($topic_id )
;
    1152           $e xists = $a Topic ? 1  : 0;
1151     1153  
1152           re turn <<<EO F   1154           re turn <<<EO F
1153   <html>   1155   <html>
1154   <body>   1156   <body>
1155   <script la nguage="ja vascript"  type="text /javascrip t">   1157   <script la nguage="ja vascript"  type="text /javascrip t">
1156        window.par ent.docume nt.f.delet eSuccess(' {$f['forum _
i d ']}',   '{$
topic_
i d }',   {$exists}) ;
  1158        window.par ent.docume nt.f.delet eSuccess(' {$f['forum _ ur i
']}',   '{$ aTopic[' topic_ ur i '] }',   {$exists}) ;
1157   </script>   1159   </script>
1158   </body>   1160   </body>
1159   </html>   1161   </html>
1160   EOF;   1162   EOF;
1161     1163  
1162       }   1164       }
1163     1165  
1164       /**   1166       /**
1165        * pos t new topi c   1167        * pos t new topi c
1166        * @pa ram $p     _post arra y   1168        * @pa ram $p     _post arra y
1167        */   1169        */
1168       functi on postNew TopicXML ( $p)   1170       functi on postNew TopicXML ( $p)
1169       {   1171       {
1170           $f db = new D bForum ();   1172           $f db = new D bForum ();
1171     1173  
1172           $f  = $fdb->g etForum (( int)$p['fo rum_id']);   1174           $f  = $fdb->g etForum (( int)$p['fo rum_id']);
1173     1175  
1174           if  (!$this-> _checkUser Perm ('',  $f['forum_ type'], 'p ost', (int )$p['forum _id']))    1176           if  (!$this-> _checkUser Perm ('',  $f['forum_ type'], 'p ost', (int )$p['forum _id'])) 
1175           {   1177           {
1176                return < <<EOF   1178                return < <<EOF
1177   <html>   1179   <html>
1178   <body>   1180   <body>
1179   <script la nguage="ja vascript"  type="text /javascrip t">   1181   <script la nguage="ja vascript"  type="text /javascrip t">
1180     1182  
1181       if (wi ndow.paren t.document .getElemen tById('tin yEditor'))   1183       if (wi ndow.paren t.document .getElemen tById('tin yEditor'))
1182           wi ndow.paren t.tinyMCE. execComman d('mceRemo veControl' , false, ' tinyEditor ');   1184           wi ndow.paren t.tinyMCE. execComman d('mceRemo veControl' , false, ' tinyEditor ');
1183     1185  
1184       window .parent.do cument.f.a ccessDenie d();   1186       window .parent.do cument.f.a ccessDenie d();
1185     1187  
1186   </script>   1188   </script>
1187   </body>   1189   </body>
1188   </html>   1190   </html>
1189   EOF;   1191   EOF;
1190           }           1192           }        
1191     1193  
1192           if  ($p['topi c_sticky']  == 'on' & & !$this-> _checkUser Perm ('',  '', 'stick y', (int)$ p['forum_i d']))    1194           if  ($p['topi c_sticky']  == 'on' & & !$this-> _checkUser Perm ('',  '', 'stick y', (int)$ p['forum_i d'])) 
1193           {   1195           {
1194                return < <<EOF   1196                return < <<EOF
1195   <html>   1197   <html>
1196   <body>   1198   <body>
1197   <script la nguage="ja vascript"  type="text /javascrip t">   1199   <script la nguage="ja vascript"  type="text /javascrip t">
1198     1200  
1199       if (wi ndow.paren t.document .getElemen tById('tin yEditor'))   1201       if (wi ndow.paren t.document .getElemen tById('tin yEditor'))
1200           wi ndow.paren t.tinyMCE. execComman d('mceRemo veControl' , false, ' tinyEditor ');   1202           wi ndow.paren t.tinyMCE. execComman d('mceRemo veControl' , false, ' tinyEditor ');
1201     1203  
1202       window .parent.do cument.f.a ccessDenie d();   1204       window .parent.do cument.f.a ccessDenie d();
1203     1205  
1204   </script>   1206   </script>
1205   </body>   1207   </body>
1206   </html>   1208   </html>
1207   EOF;   1209   EOF;
1208           }           1210           }        
1209     1211  
1210     1212  
1211           //  post mesa ge here   1213           //  post mesa ge here
1212     1214  
1213           $u ser = $thi s->_getLog inUserName  ();   1215           $u ser = $thi s->_getLog inUserName  ();
1214              1216           
1215           pr epare_to_d b($p['topi c_subject' ], 0);   1217           pr epare_to_d b($p['topi c_subject' ], 0);
1216           pr epare_to_d b($p['topi c_text'],  1);   1218           pr epare_to_d b($p['topi c_text'],  1);
1217     1219  
1218           $t opic_uri =  $this->ur iGenerate  ($p['topic _subject'] , TF_FORUM _TOPIC, 't opic_uri') ;   1220           $t opic_uri =  $this->ur iGenerate  ($p['topic _subject'] , TF_FORUM _TOPIC, 't opic_uri') ;
1219           $f db->newTop ic ((int)$ p['forum_i d'], $p['t opic_subje ct'], $p[' topic_text '], ($p['t opic_stick y'] == 'on '), $user,  $topic_ur i);   1221           $f db->newTop ic ((int)$ p['forum_i d'], $p['t opic_subje ct'], $p[' topic_text '], ($p['t opic_stick y'] == 'on '), $user,  $topic_ur i);
1220     1222  
1221           re turn <<<EO F   1223           re turn <<<EO F
1222   <html>   1224   <html>
1223   <body>   1225   <body>
1224   <script la nguage="ja vascript"  type="text /javascrip t">   1226   <script la nguage="ja vascript"  type="text /javascrip t">
1225     1227  
1226       if (wi ndow.paren t.document .getElemen tById('tin yEditor'))   1228       if (wi ndow.paren t.document .getElemen tById('tin yEditor'))
1227           wi ndow.paren t.tinyMCE. execComman d('mceRemo veControl' , false, ' tinyEditor ');   1229           wi ndow.paren t.tinyMCE. execComman d('mceRemo veControl' , false, ' tinyEditor ');
1228     1230  
1229       window .parent.do cument.f.p ostSuccess ('{$f['for um_uri']}' );   1231       window .parent.do cument.f.p ostSuccess ('{$f['for um_uri']}' );
1230     1232  
1231   </script>   1233   </script>
1232   </body>   1234   </body>
1233   </html>   1235   </html>
1234   EOF;   1236   EOF;
1235     1237  
1236       }   1238       }
1237     1239  
1238       functi on isAdmin  ()   1240       functi on isAdmin  ()
1239       {   1241       {
1240           $a  = $this-> _getUserIn fo ($this- >getLoginU ser());   1242           $a  = $this-> _getUserIn fo ($this- >getLoginU ser());
1241           re turn $a['a dmin'];   1243           re turn $a['a dmin'];
1242       }   1244       }
1243          1245       
1244       /**   1246       /**
1245        * ret urns logge d in user   1247        * ret urns logge d in user
1246        */   1248        */
1247       functi on getLogi nUser ()   1249       functi on getLogi nUser ()
1248       {   1250       {
1249           re turn $this ->_getLogi nUser();   1251           re turn $this ->_getLogi nUser();
1250       }   1252       }
1251     1253  
1252       /**   1254       /**
1253        * upd ates curre nt user la st activit y time   1255        * upd ates curre nt user la st activit y time
1254        */    1256        */ 
1255       functi on updateC urrentUser Activity ( )   1257       functi on updateC urrentUser Activity ( )
1256       {   1258       {
1257           $u  = $this-> getLoginUs er ();   1259           $u  = $this-> getLoginUs er ();
1258           if  (!$u) ret urn;            1260           if  (!$u) ret urn;         
1259     1261  
1260           $d b = new Db Forum ();   1262           $d b = new Db Forum ();
1261           $d b->updateU serActivit y ($u);   1263           $d b->updateU serActivit y ($u);
1262       }   1264       }
1263     1265  
1264       functi on logout  ()   1266       functi on logout  ()
1265       {   1267       {
1266           $u  = $this-> getLoginUs er ();   1268           $u  = $this-> getLoginUs er ();
1267           if  (!$u) ret urn '<ret> 0</ret>';   1269           if  (!$u) ret urn '<ret> 0</ret>';
1268     1270  
1269           se tcookie('o rca_pwd',  'orca_pwd' , time() -  86400);   1271           se tcookie('o rca_pwd',  'orca_pwd' , time() -  86400);
1270           se tcookie('o rca_user',  'orca_use r', time()  - 86400);   1272           se tcookie('o rca_user',  'orca_use r', time()  - 86400);
1271           se tcookie('t rack_topic s', 'track _topics',  time() - 8 6400);   1273           se tcookie('t rack_topic s', 'track _topics',  time() - 8 6400);
1272     1274  
1273           $d b = new Db Forum ();   1275           $d b = new Db Forum ();
1274           $d b->updateU serLastAct ivity ($u) ;   1276           $d b->updateU serLastAct ivity ($u) ;
1275     1277  
1276           re turn '<ret >1</ret>';   1278           re turn '<ret >1</ret>';
1277       }   1279       }
1278     1280  
1279       /**   1281       /**
1280        * pos t voting   1282        * pos t voting
1281        *  @p aram $post _id post i d   1283        *  @p aram $post _id post i d
1282        *  @p aram $vote     vote ( 1|-1)   1284        *  @p aram $vote     vote ( 1|-1)
1283        */    1285        */ 
1284       functi on votePos t ($post_i d, $vote)   1286       functi on votePos t ($post_i d, $vote)
1285       {   1287       {
1286           $u  = $this-> getLoginUs er ();   1288           $u  = $this-> getLoginUs er ();
1287           if  (!$u) ret urn '<ret> 0</ret>';   1289           if  (!$u) ret urn '<ret> 0</ret>';
1288              1290           
1289           $d b = new Db Forum ();   1291           $d b = new Db Forum ();
1290              1292           
1291           if  (!$db->in sertVote ( (int)$post _id, $u, $ vote))   1293           if  (!$db->in sertVote ( (int)$post _id, $u, $ vote))
1292                return ' <ret>0</re t>';   1294                return ' <ret>0</re t>';
1293                   1295                
1294           re turn '<ret >1</ret>';   1296           re turn '<ret >1</ret>';
1295       }   1297       }
1296     1298  
1297       /**   1299       /**
1298        * rep ort post   1300        * rep ort post
1299        *  @p aram $post _id post i d   1301        *  @p aram $post _id post i d
1300        */    1302        */ 
1301       functi on report  ($post_id)   1303       functi on report  ($post_id)
1302       {   1304       {
1303           if  (!$post_i d) return  '<ret>0</r et>';   1305           if  (!$post_i d) return  '<ret>0</r et>';
1304     1306  
1305           $u  = $this-> getLoginUs er ();   1307           $u  = $this-> getLoginUs er ();
1306           if  (!$u) ret urn '<ret> 0</ret>';   1308           if  (!$u) ret urn '<ret> 0</ret>';
1307              1309           
1308           $d b = new Db Forum ();   1310           $d b = new Db Forum ();
1309              1311           
1310           if  (!$db->re port ((int )$post_id,  $u))   1312           if  (!$db->re port ((int )$post_id,  $u))
1311                return ' <ret>0</re t>';   1313                return ' <ret>0</re t>';
1312                   1314                
1313           re turn '<ret >1</ret>';   1315           re turn '<ret >1</ret>';
1314       }   1316       }
1315     1317  
1316       /**   1318       /**
1317        * fla g/unflag t opic   1319        * fla g/unflag t opic
1318        *  @p aram $topi c_id    to pic id   1320        *  @p aram $topi c_id    to pic id
1319        */    1321        */ 
1320       functi on flag ($ topic_id)   1322       functi on flag ($ topic_id)
1321       {   1323       {
1322           if  (!$topic_ id) return  '<ret>0</ ret>';   1324           if  (!$topic_ id) return  '<ret>0</ ret>';
1323     1325  
1324           $u  = $this-> getLoginUs er ();   1326           $u  = $this-> getLoginUs er ();
1325           if  (!$u) ret urn '<ret> 0</ret>';         1327           if  (!$u) ret urn '<ret> 0</ret>';      
1326              1328           
1327           $d b = new Db Forum ();   1329           $d b = new Db Forum ();
1328     1330  
1329           if  ($db->isF lagged ((i nt)$topic_ id, $u))   1331           if  ($db->isF lagged ((i nt)$topic_ id, $u))
1330           {   1332           {
1331                if (!$db ->unflag ( (int)$topi c_id, $u))   1333                if (!$db ->unflag ( (int)$topi c_id, $u))
1332                    retu rn '<ret>0 </ret>';   1334                    retu rn '<ret>0 </ret>';
1333                return ' <ret>-1</r et>';   1335                return ' <ret>-1</r et>';
1334           }   1336           }
1335              1337           
1336           if  (!$db->fl ag ((int)$ topic_id,  $u))   1338           if  (!$db->fl ag ((int)$ topic_id,  $u))
1337                return ' <ret>0</re t>';   1339                return ' <ret>0</re t>';
1338     1340  
1339           re turn '<ret >1</ret>';   1341           re turn '<ret >1</ret>';
1340       }   1342       }
1341     1343  
1342       /**   1344       /**
1343        * for um rss fee d, 10 late st topics  in the for um   1345        * for um rss fee d, 10 late st topics  in the for um
1344        *  @p aram $foru m_id    fo rum id       1346        *  @p aram $foru m_id    fo rum id    
1345        */    1347        */ 
1346       functi on getRssF orum ($for um_uri)   1348       functi on getRssF orum ($for um_uri)
1347       {   1349       {
1348           gl obal $gCon f;   1350           gl obal $gCon f;
1349     1351  
1350           $g Conf['topi cs_per_pag e'] = 10;   1352           $g Conf['topi cs_per_pag e'] = 10;
1351           $g Conf['date _format']  = '%a, %e  %b %Y %k:% i:%s GMT';   1353           $g Conf['date _format']  = '%a, %e  %b %Y %k:% i:%s GMT';
1352     1354  
1353           $f db = new D bForum ();   1355           $f db = new D bForum ();
1354     1356  
1355           $f  = $fdb->g etForumByU ri ($forum _uri);   1357           $f  = $fdb->g etForumByU ri ($forum _uri);
1356           $f orum_id =  $f['forum_ id'];   1358           $f orum_id =  $f['forum_ id'];
1357     1359  
1358           if  (!$f) exi t;   1360           if  (!$f) exi t;
1359     1361  
1360           $a  = $fdb->g etTopics ( $forum_id,  0);   1362           $a  = $fdb->g etTopics ( $forum_id,  0);
1361     1363  
1362           re set ($a);   1364           re set ($a);
1363           $i tems = '';   1365           $i tems = '';
1364           $l astBuildDa te = '';   1366           $l astBuildDa te = '';
1365           wh ile ( list  (,$r) = e ach ($a) )   1367           wh ile ( list  (,$r) = e ach ($a) )
1366           {   1368           {
1367                $lp = $f db->getTop icPost($r[ 'topic_id' ], 'last') ;   1369                $lp = $f db->getTop icPost($r[ 'topic_id' ], 'last') ;
1368                $td = st rip_tags($ fdb->getTo picDesc($r ['topic_id ']));   1370                $td = st rip_tags($ fdb->getTo picDesc($r ['topic_id ']));
1369     1371  
1370                if (!$la stBuildDat e)   1372                if (!$la stBuildDat e)
1371                    $las tBuildDate  = $lp['wh en'];   1373                    $las tBuildDate  = $lp['wh en'];
1372     1374  
1373                $items . = "   1375                $items . = "
1374                <item>   1376                <item>
1375                    <tit le>{$r['to pic_title' ]}</title>   1377                    <tit le>{$r['to pic_title' ]}</title>
1376                    <lin k>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</li nk>   1378                    <lin k>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</li nk>
1377                    <des cription>$ td</descri ption>   1379                    <des cription>$ td</descri ption>
1378                    <pub Date>{$lp[ 'when']}</ pubDate>   1380                    <pub Date>{$lp[ 'when']}</ pubDate>
1379                    <gui d>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</gu id>   1381                    <gui d>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</gu id>
1380                </item>" ;   1382                </item>" ;
1381           }           1383           }        
1382                   1384                
1383           re turn "   1385           re turn "
1384   <rss versi on=\"2.0\" >   1386   <rss versi on=\"2.0\" >
1385       <chann el>   1387       <chann el>
1386           <t itle>{$f[' forum_titl e']}</titl e>   1388           <t itle>{$f[' forum_titl e']}</titl e>
1387           <l ink>" . $g Conf['url' ]['base']  . sprintf( $gConf['re write']['f orum'], $f ['forum_ur i'], 0) .  "</link>   1389           <l ink>" . $g Conf['url' ]['base']  . sprintf( $gConf['re write']['f orum'], $f ['forum_ur i'], 0) .  "</link>
1388           <d escription >{$f['foru m_desc']}< /descripti on>   1390           <d escription >{$f['foru m_desc']}< /descripti on>
1389           <l astBuildDa te>$lastBu ildDate</l astBuildDa te>      1391           <l astBuildDa te>$lastBu ildDate</l astBuildDa te>   
1390           $i tems   1392           $i tems
1391       </chan nel>   1393       </chan nel>
1392   </rss>";   1394   </rss>";
1393       }   1395       }
1394     1396  
1395     1397  
1396     1398  
1397       /**   1399       /**
1398        * top ic rss fee d, 10 late st posts i n the topi c   1400        * top ic rss fee d, 10 late st posts i n the topi c
1399        *  @p aram $foru m_id    fo rum id       1401        *  @p aram $foru m_id    fo rum id    
1400        */    1402        */ 
1401       functi on getRssT opic ($top ic_uri)   1403       functi on getRssT opic ($top ic_uri)
1402       {   1404       {
1403           gl obal $gCon f;   1405           gl obal $gCon f;
1404              1406           
1405           $g Conf['topi cs_per_pag e'] = 10;   1407           $g Conf['topi cs_per_pag e'] = 10;
1406           $g Conf['date _format']  = '%a, %e  %b %Y %k:% i:%s GMT';   1408           $g Conf['date _format']  = '%a, %e  %b %Y %k:% i:%s GMT';
1407     1409  
1408           $f db = new D bForum ();   1410           $f db = new D bForum ();
1409     1411  
1410           $t  = $fdb->g etTopicByU ri($topic_ uri);   1412           $t  = $fdb->g etTopicByU ri($topic_ uri);
1411           $t opic_id =  (int)$t['t opic_id'];   1413           $t opic_id =  (int)$t['t opic_id'];
1412     1414  
1413           if  (!$t) exi t;   1415           if  (!$t) exi t;
1414     1416  
1415           $a  = $fdb->g etPosts ($ topic_id,  0);   1417           $a  = $fdb->g etPosts ($ topic_id,  0);
1416     1418  
1417           re set ($a);   1419           re set ($a);
1418           $i tems = '';   1420           $i tems = '';
1419           $l astBuildDa te = '';   1421           $l astBuildDa te = '';
1420           wh ile ( list  (,$r) = e ach ($a) )   1422           wh ile ( list  (,$r) = e ach ($a) )
1421           {   1423           {
1422                $lp = $f db->getTop icPost($r[ 'topic_id' ], 'last') ;   1424                $lp = $f db->getTop icPost($r[ 'topic_id' ], 'last') ;
1423                $td = st rip_tags(s ubstr($r[' post_text' ], 0, 256) );   1425                $td = st rip_tags(s ubstr($r[' post_text' ], 0, 256) );
1424                if (strl en($td) ==  256) $td  .= '[...]' ;   1426                if (strl en($td) ==  256) $td  .= '[...]' ;
1425                $tt = su bstr($td,  0, 32);   1427                $tt = su bstr($td,  0, 32);
1426                   1428                
1427                    $las tBuildDate  = $lp['wh en'];   1429                    $las tBuildDate  = $lp['wh en'];
1428     1430  
1429                $items . = "   1431                $items . = "
1430                <item>   1432                <item>
1431                    <tit le>{$tt}</ title>   1433                    <tit le>{$tt}</ title>
1432                    <lin k>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $t[' topic_uri' ]) . "</li nk>   1434                    <lin k>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $t[' topic_uri' ]) . "</li nk>
1433                    <des cription>$ td</descri ption>   1435                    <des cription>$ td</descri ption>
1434                    <pub Date>{$lp[ 'when']}</ pubDate>   1436                    <pub Date>{$lp[ 'when']}</ pubDate>
1435                    <gui d>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $t[' topic_uri' ]) . "#{$r ['post_id' ]}</guid>   1437                    <gui d>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $t[' topic_uri' ]) . "#{$r ['post_id' ]}</guid>
1436                </item>" ;   1438                </item>" ;
1437           }           1439           }        
1438                   1440                
1439           re turn "   1441           re turn "
1440   <rss versi on=\"2.0\" >   1442   <rss versi on=\"2.0\" >
1441       <chann el>   1443       <chann el>
1442           <t itle>{$t[' topic_titl e']}</titl e>   1444           <t itle>{$t[' topic_titl e']}</titl e>
1443           <l ink>" . $g Conf['url' ]['base']  . sprintf( $gConf['re write']['t opic'], $t ['topic_ur i']) . "</ link>   1445           <l ink>" . $g Conf['url' ]['base']  . sprintf( $gConf['re write']['t opic'], $t ['topic_ur i']) . "</ link>
1444           <d escription >{$t['topi c_title']} </descript ion>   1446           <d escription >{$t['topi c_title']} </descript ion>
1445           <l astBuildDa te>$lastBu ildDate</l astBuildDa te>      1447           <l astBuildDa te>$lastBu ildDate</l astBuildDa te>   
1446           $i tems   1448           $i tems
1447       </chan nel>   1449       </chan nel>
1448   </rss>";   1450   </rss>";
1449       }   1451       }
1450              1452           
1451       /**   1453       /**
1452        * use r posts rs s feed, 10  latest po sts of spe cified use r   1454        * use r posts rs s feed, 10  latest po sts of spe cified use r
1453        *  @p aram $user     userna me    1455        *  @p aram $user     userna me 
1454        *  @p aram $sort     sort :  rnd | top  | latest  - default   1456        *  @p aram $sort     sort :  rnd | top  | latest  - default
1455        */    1457        */ 
1456       functi on getRssU ser ($user , $sort)   1458       functi on getRssU ser ($user , $sort)
1457       {   1459       {
1458           gl obal $gCon f;   1460           gl obal $gCon f;
1459     1461  
1460           $g Conf['topi cs_per_pag e'] = 10;   1462           $g Conf['topi cs_per_pag e'] = 10;
1461           $g Conf['date _format']  = '%a, %e  %b %Y %k:% i:%s GMT';   1463           $g Conf['date _format']  = '%a, %e  %b %Y %k:% i:%s GMT';
1462     1464  
1463           $f db = new D bForum ();          1465           $f db = new D bForum ();       
1464              1466           
1465           $a  = $fdb->g etUserPost sList($use r, $sort,  $gConf['to pics_per_p age']);   1467           $a  = $fdb->g etUserPost sList($use r, $sort,  $gConf['to pics_per_p age']);
1466     1468  
1467           re set ($a);   1469           re set ($a);
1468           $i tems = '';   1470           $i tems = '';
1469           $l astBuildDa te = '';   1471           $l astBuildDa te = '';
1470           wh ile ( list  (,$r) = e ach ($a) )   1472           wh ile ( list  (,$r) = e ach ($a) )
1471           {   1473           {
1472                if (!$la stBuildDat e)   1474                if (!$la stBuildDat e)
1473                    $las tBuildDate  = $r['whe n'];   1475                    $las tBuildDate  = $r['whe n'];
1474     1476  
1475                $td = st rip_tags($ r['post_te xt']);   1477                $td = st rip_tags($ r['post_te xt']);
1476                if (strl en($td) ==  256) $td  .= '[...]' ;   1478                if (strl en($td) ==  256) $td  .= '[...]' ;
1477                   1479                
1478                $items . = "   1480                $items . = "
1479                <item>   1481                <item>
1480                    <tit le><![CDAT A[{$r['top ic_title'] }]]></titl e>   1482                    <tit le><![CDAT A[{$r['top ic_title'] }]]></titl e>
1481                    <lin k>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</li nk>   1483                    <lin k>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</li nk>
1482                    <des cription>< ![CDATA[{$ r['user']} : {$td}]]> </descript ion>   1484                    <des cription>< ![CDATA[{$ r['user']} : {$td}]]> </descript ion>
1483                    <pub Date>{$r[' when']}</p ubDate>   1485                    <pub Date>{$r[' when']}</p ubDate>
1484                    <gui d>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</gu id>   1486                    <gui d>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</gu id>
1485                </item>" ;   1487                </item>" ;
1486           }           1488           }        
1487              1489           
1488           if  ($sort ==  'rnd' ||  $sort == ' top') $las tBuildDate  = '';   1490           if  ($sort ==  'rnd' ||  $sort == ' top') $las tBuildDate  = '';
1489     1491  
1490           $s Title = sp rintf("[L[ %s's forum  posts]]",  $user);   1492           $s Title = sp rintf("[L[ %s's forum  posts]]",  $user);
1491           re turn "   1493           re turn "
1492   <rss versi on=\"2.0\" >   1494   <rss versi on=\"2.0\" >
1493       <chann el>   1495       <chann el>
1494           <t itle>$sTit le</title>   1496           <t itle>$sTit le</title>
1495           <l ink>{$gCon f['url'][' base']}</l ink>   1497           <l ink>{$gCon f['url'][' base']}</l ink>
1496           <d escription >$sTitle</ descriptio n>   1498           <d escription >$sTitle</ descriptio n>
1497           <l astBuildDa te>$lastBu ildDate</l astBuildDa te>      1499           <l astBuildDa te>$lastBu ildDate</l astBuildDa te>   
1498           $i tems   1500           $i tems
1499       </chan nel>   1501       </chan nel>
1500   </rss>";   1502   </rss>";
1501       }   1503       }
1502     1504  
1503       /**   1505       /**
1504        * all  posts rss  feed, 10  latest pos ts   1506        * all  posts rss  feed, 10  latest pos ts
1505        *  @p aram $user     userna me    1507        *  @p aram $user     userna me 
1506        *  @p aram $sort     sort :  rnd | top  | latest  - default   1508        *  @p aram $sort     sort :  rnd | top  | latest  - default
1507        */    1509        */ 
1508       functi on getRssA ll ($sort)   1510       functi on getRssA ll ($sort)
1509       {   1511       {
1510           gl obal $gCon f;   1512           gl obal $gCon f;
1511     1513  
1512           $g Conf['topi cs_per_pag e'] = 10;   1514           $g Conf['topi cs_per_pag e'] = 10;
1513           $g Conf['date _format']  = '%a, %e  %b %Y %k:% i:%s GMT';   1515           $g Conf['date _format']  = '%a, %e  %b %Y %k:% i:%s GMT';
1514     1516  
1515           $f db = new D bForum ();          1517           $f db = new D bForum ();       
1516              1518           
1517           $a  = $fdb->g etAllPosts List($sort , $gConf[' topics_per _page']);   1519           $a  = $fdb->g etAllPosts List($sort , $gConf[' topics_per _page']);
1518     1520  
1519           re set ($a);   1521           re set ($a);
1520           $i tems = '';   1522           $i tems = '';
1521           $l astBuildDa te = '';   1523           $l astBuildDa te = '';
1522           wh ile ( list  (,$r) = e ach ($a) )   1524           wh ile ( list  (,$r) = e ach ($a) )
1523           {   1525           {
1524                if (!$la stBuildDat e)   1526                if (!$la stBuildDat e)
1525                    $las tBuildDate  = $r['whe n'];   1527                    $las tBuildDate  = $r['whe n'];
1526     1528  
1527                $td = st rip_tags($ r['post_te xt']);   1529                $td = st rip_tags($ r['post_te xt']);
1528                if (strl en($td) ==  256) $td  .= '[...]' ;   1530                if (strl en($td) ==  256) $td  .= '[...]' ;
1529                   1531                
1530                $items . = "   1532                $items . = "
1531                <item>   1533                <item>
1532                    <tit le><![CDAT A[{$r['top ic_title'] }]]></titl e>   1534                    <tit le><![CDAT A[{$r['top ic_title'] }]]></titl e>
1533                    <lin k>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</li nk>   1535                    <lin k>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</li nk>
1534                    <des cription>< ![CDATA[{$ r['user']} : {$td}]]> </descript ion>   1536                    <des cription>< ![CDATA[{$ r['user']} : {$td}]]> </descript ion>
1535                    <pub Date>{$r[' when']}</p ubDate>   1537                    <pub Date>{$r[' when']}</p ubDate>
1536                    <gui d>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</gu id>   1538                    <gui d>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</gu id>
1537                </item>" ;   1539                </item>" ;
1538           }           1540           }        
1539              1541           
1540           if  ($sort ==  'rnd' ||  $sort == ' top') $las tBuildDate  = '';   1542           if  ($sort ==  'rnd' ||  $sort == ' top') $las tBuildDate  = '';
1541     1543  
1542           re turn <<<EO F   1544           re turn <<<EO F
1543   <rss versi on="2.0">   1545   <rss versi on="2.0">
1544       <chann el>   1546       <chann el>
1545           <t itle>[L[Fo rum Posts] ]</title>   1547           <t itle>[L[Fo rum Posts] ]</title>
1546           <l ink>{$gCon f['url'][' base']}</l ink>   1548           <l ink>{$gCon f['url'][' base']}</l ink>
1547           <d escription >[L[Forum  Posts]]</d escription >   1549           <d escription >[L[Forum  Posts]]</d escription >
1548           <l astBuildDa te>$lastBu ildDate</l astBuildDa te>   1550           <l astBuildDa te>$lastBu ildDate</l astBuildDa te>
1549           $i tems   1551           $i tems
1550       </chan nel>   1552       </chan nel>
1551   </rss>   1553   </rss>
1552   EOF;   1554   EOF;
1553       }   1555       }
1554              1556           
1555     1557  
1556     1558  
1557       /**    1559       /** 
1558        * pro file xml   1560        * pro file xml
1559        * @pa ram   $u   username   1561        * @pa ram   $u   username
1560        * @pa ram   $wp  return who le page XM L   1562        * @pa ram   $wp  return who le page XM L
1561        */    1563        */ 
1562       functi on showPro file ($u,  $wp)   1564       functi on showPro file ($u,  $wp)
1563       {   1565       {
1564           $f db = new D bForum ();   1566           $f db = new D bForum ();
1565     1567  
1566           $a  = $this-> _getUserIn fo ($u);   1568           $a  = $this-> _getUserIn fo ($u);
1567           $a s = $fdb-> getUserSta t ($u);   1569           $a s = $fdb-> getUserSta t ($u);
1568     1570  
1569           $a ['username '] = $u;   1571           $a ['username '] = $u;
1570           $a ['posts']  = (int)$as ['posts'];   1572           $a ['posts']  = (int)$as ['posts'];
1571           $a ['user_las t_post'] =  $as['user _last_post '];   1573           $a ['user_las t_post'] =  $as['user _last_post '];
1572           $a ['last_onl ine'] = $f db->getUse rLastOnlin eTime ($u) ;   1574           $a ['last_onl ine'] = $f db->getUse rLastOnlin eTime ($u) ;
1573     1575  
1574           $p  = array2x ml ($a);   1576           $p  = array2x ml ($a);
1575     1577  
1576           if  ($wp)   1578           if  ($wp)
1577           {   1579           {
1578                $li = $t his->_getL oginInfo ( );   1580                $li = $t his->_getL oginInfo ( );
1579                return $ this->addH eaderFoote r ($li, "< profile>$p </profile> ");   1581                return $ this->addH eaderFoote r ($li, "< profile>$p </profile> ");
1580           }   1582           }
1581           el se   1583           el se
1582           {   1584           {
1583                $cu = $t his->getUr lsXml ();   1585                $cu = $t his->getUr lsXml ();
1584                return " <root>$cu< profile>$p </profile> </root>";   1586                return " <root>$cu< profile>$p </profile> </root>";
1585           }           1587           }        
1586       }   1588       }
1587     1589  
1588       // pri vate funct ions   1590       // pri vate funct ions
1589     1591  
1590       functi on _getLog inInfo ($u ser = '')   1592       functi on _getLog inInfo ($u ser = '')
1591       {   1593       {
1592           if  (!strlen( $user)) $u ser = $thi s->_getLog inUserName  ();   1594           if  (!strlen( $user)) $u ser = $thi s->_getLog inUserName  ();
1593           $a  = $this-> _getUserIn fo ($user) ;          1595           $a  = $this-> _getUserIn fo ($user) ;       
1594           $a ['username '] = $user ;   1596           $a ['username '] = $user ;
1595           re turn $a;    1597           re turn $a; 
1596       }   1598       }
1597     1599  
1598       functi on _getUse rInfo ($us er)   1600       functi on _getUse rInfo ($us er)
1599       {           1601       {        
1600           gl obal $gCon f;   1602           gl obal $gCon f;
1601           $r et = array  ();   1603           $r et = array  ();
1602     1604  
1603           if  (!$user)  $user = $t his->_getL oginUser() ;   1605           if  (!$user)  $user = $t his->_getL oginUser() ;
1604           if  (!$user)  return $re t;   1606           if  (!$user)  return $re t;
1605           $a ction = 'u ser_info';   1607           $a ction = 'u ser_info';
1606           $i ntegration _file = '' ;   1608           $i ntegration _file = '' ;
1607           in clude ($gC onf['dir'] ['base'] .  'xml/url. php');   1609           in clude ($gC onf['dir'] ['base'] .  'xml/url. php');
1608           if  (!$integr ation_file ) return;   1610           if  (!$integr ation_file ) return;
1609     1611  
1610           $x ml = $this ->_read_in tegration_ file ($int egration_f ile);   1612           $x ml = $this ->_read_in tegration_ file ($int egration_f ile);
1611           if  (!$xml) r eturn;   1613           if  (!$xml) r eturn;
1612     1614  
1613           if  (((int)ph pversion() ) >= 5)           1615           if  (((int)ph pversion() ) >= 5)        
1614           {   1616           {
1615                $d = new  DomDocume nt();   1617                $d = new  DomDocume nt();
1616                       1618                    
1617                $d->load XML($xml);              1619                $d->load XML($xml);           
1618     1620  
1619                $up = $d ->getEleme ntsByTagNa me ('user_ info');   1621                $up = $d ->getEleme ntsByTagNa me ('user_ info');
1620     1622  
1621                $up = $u p->item(0) ;   1623                $up = $u p->item(0) ;
1622     1624  
1623                $n = $up ->firstChi ld;   1625                $n = $up ->firstChi ld;
1624     1626  
1625                do   1627                do
1626                {          1628                {       
1627                    if ( $n->nodeTy pe != XML_ ELEMENT_NO DE) contin ue;        1629                    if ( $n->nodeTy pe != XML_ ELEMENT_NO DE) contin ue;     
1628                    $ret [$n->nodeN ame] = $n- >textConte nt;   1630                    $ret [$n->nodeN ame] = $n- >textConte nt;
1629                }   1631                }
1630                while ($ n = $n->ne xtSibling) ;   1632                while ($ n = $n->ne xtSibling) ;
1631           }   1633           }
1632           el se   1634           el se
1633           {   1635           {
1634     1636  
1635                if (!$d  = domxml_o pen_mem($x ml)) {   1637                if (!$d  = domxml_o pen_mem($x ml)) {
1636                    $mk  = new Mist ake ();   1638                    $mk  = new Mist ake ();
1637                    $mk- >log ("For um::_getUs erInfo - c an not par se xml: $x ml");   1639                    $mk- >log ("For um::_getUs erInfo - c an not par se xml: $x ml");
1638                    $mk- >displayEr ror ("[L[S ite is una vailable]] ");   1640                    $mk- >displayEr ror ("[L[S ite is una vailable]] ");
1639                }   1641                }
1640     1642  
1641                $up = $d ->get_elem ents_by_ta gname ('us er_info');   1643                $up = $d ->get_elem ents_by_ta gname ('us er_info');
1642     1644  
1643                $up = $u p[0];   1645                $up = $u p[0];
1644                $n = $up ->first_ch ild();   1646                $n = $up ->first_ch ild();
1645     1647  
1646                do   1648                do
1647                {               1649                {            
1648                    if ( $n->node_t ype() != X ML_ELEMENT _NODE) con tinue;   1650                    if ( $n->node_t ype() != X ML_ELEMENT _NODE) con tinue;
1649                    $ret [$n->node_ name ()] =  $n->get_c ontent ();   1651                    $ret [$n->node_ name ()] =  $n->get_c ontent ();
1650                }   1652                }
1651                while ($ n = $n->ne xt_sibling ());   1653                while ($ n = $n->ne xt_sibling ());
1652           }   1654           }
1653                       1655                    
1654     1656  
1655           re turn $ret;                     1657           re turn $ret;                  
1656       }   1658       }
1657     1659  
1658       /**   1660       /**
1659        * che ck user pe rms   1661        * che ck user pe rms
1660        * @pa ram $user      userna me   1662        * @pa ram $user      userna me
1661        * @pa ram $f_typ e   forum  type priva te/public/ own   1663        * @pa ram $f_typ e   forum  type priva te/public/ own
1662        * @pa ram $a_typ e   access  type read /post/edit /del   1664        * @pa ram $a_typ e   access  type read /post/edit /del
1663        */   1665        */
1664       functi on _checkU serPerm ($ user, $f_t ype, $a_ty pe, $forum _id = 0)   1666       functi on _checkU serPerm ($ user, $f_t ype, $a_ty pe, $forum _id = 0)
1665       {   1667       {
1666           gl obal $gCon f;   1668           gl obal $gCon f;
1667     1669  
1668           if  (!$user)  $user = $t his->_getL oginUser() ;   1670           if  (!$user)  $user = $t his->_getL oginUser() ;
1669           $a ction = 'u ser_perm';   1671           $a ction = 'u ser_perm';
1670           $i ntegration _file = '' ;   1672           $i ntegration _file = '' ;
1671           in clude ($gC onf['dir'] ['base'] .  'xml/url. php');            1673           in clude ($gC onf['dir'] ['base'] .  'xml/url. php');         
1672           if  (!$integr ation_file ) return;   1674           if  (!$integr ation_file ) return;
1673     1675  
1674           $x ml = $this ->_read_in tegration_ file ($int egration_f ile);            1676           $x ml = $this ->_read_in tegration_ file ($int egration_f ile);         
1675           if  (!$xml) r eturn;   1677           if  (!$xml) r eturn;
1676     1678  
1677           if  (((int)ph pversion() ) >= 5)           1679           if  (((int)ph pversion() ) >= 5)        
1678           {   1680           {
1679                $d = new  DomDocume nt();   1681                $d = new  DomDocume nt();
1680                       1682                    
1681                $d->load XML($xml);              1683                $d->load XML($xml);           
1682     1684  
1683                $up = $d ->getEleme ntsByTagNa me ('user_ perm');   1685                $up = $d ->getEleme ntsByTagNa me ('user_ perm');
1684     1686  
1685                $up = $u p->item(0) ;   1687                $up = $u p->item(0) ;
1686     1688  
1687                $n = $up ->firstChi ld;   1689                $n = $up ->firstChi ld;
1688     1690  
1689                do   1691                do
1690                {          1692                {       
1691                    if ( $n->nodeTy pe != XML_ ELEMENT_NO DE) contin ue;        1693                    if ( $n->nodeTy pe != XML_ ELEMENT_NO DE) contin ue;     
1692                    if ( $n->nodeNa me == "{$a _type}_{$f _type}") r eturn $n-> textConten t;   1694                    if ( $n->nodeNa me == "{$a _type}_{$f _type}") r eturn $n-> textConten t;
1693                }   1695                }
1694                while ($ n = $n->ne xtSibling) ;   1696                while ($ n = $n->ne xtSibling) ;
1695           }   1697           }
1696           el se   1698           el se
1697           {   1699           {
1698                   1700                
1699                if (!$d  = domxml_o pen_mem($x ml)) {   1701                if (!$d  = domxml_o pen_mem($x ml)) {
1700                    $mk  = new Mist ake ();   1702                    $mk  = new Mist ake ();
1701                    $mk- >log ("For um::_check UserPerm -  can not p arse xml :  $url");   1703                    $mk- >log ("For um::_check UserPerm -  can not p arse xml :  $url");
1702                    $mk- >displayEr ror ("[L[S ite is una vailable]] ");   1704                    $mk- >displayEr ror ("[L[S ite is una vailable]] ");
1703                }   1705                }
1704     1706  
1705                $up = $d ->get_elem ents_by_ta gname ('us er_perm');            1707                $up = $d ->get_elem ents_by_ta gname ('us er_perm');         
1706     1708  
1707                $up = $u p[0];   1709                $up = $u p[0];
1708                $n = $up ->first_ch ild();   1710                $n = $up ->first_ch ild();
1709     1711  
1710                do   1712                do
1711                {               1713                {            
1712                    if ( $n->node_t ype() != X ML_ELEMENT _NODE) con tinue;          1714                    if ( $n->node_t ype() != X ML_ELEMENT _NODE) con tinue;       
1713                    if ( $n->node_n ame () ==  "{$a_type} _{$f_type} ") return  $n->get_co ntent ();   1715                    if ( $n->node_n ame () ==  "{$a_type} _{$f_type} ") return  $n->get_co ntent ();
1714                }   1716                }
1715                while ($ n = $n->ne xt_sibling ());   1717                while ($ n = $n->ne xt_sibling ());
1716           }   1718           }
1717                       1719                    
1718     1720  
1719           re turn 0;                    1721           re turn 0;                 
1720       }   1722       }
1721     1723  
1722     1724  
1723       /**   1725       /**
1724        * ret urns logge n in user   1726        * ret urns logge n in user
1725        */   1727        */
1726       functi on _getLog inUserName  ()   1728       functi on _getLog inUserName  ()
1727       {   1729       {
1728           re turn $this ->_getLogi nUser();   1730           re turn $this ->_getLogi nUser();
1729       }   1731       }
1730     1732  
1731       /**   1733       /**
1732        * ret urns logge d in user   1734        * ret urns logge d in user
1733        */   1735        */
1734       functi on _getLog inUser ()   1736       functi on _getLog inUser ()
1735       {      1737       {   
1736           gl obal $gCon f;   1738           gl obal $gCon f;
1737     1739  
1738           $a ction = 'l ogin_user' ;   1740           $a ction = 'l ogin_user' ;
1739           $i ntegration _file = '' ;   1741           $i ntegration _file = '' ;
1740           in clude ($gC onf['dir'] ['base'] .  'xml/url. php');   1742           in clude ($gC onf['dir'] ['base'] .  'xml/url. php');
1741           if  (!$integr ation_file ) return;   1743           if  (!$integr ation_file ) return;
1742     1744  
1743           $x ml = $this ->_read_in tegration_ file ($int egration_f ile);   1745           $x ml = $this ->_read_in tegration_ file ($int egration_f ile);
1744              1746           
1745           if  (((int)ph pversion() ) >= 5)           1747           if  (((int)ph pversion() ) >= 5)        
1746           {   1748           {
1747                $d = new  DomDocume nt();   1749                $d = new  DomDocume nt();
1748     1750  
1749                $d->load XML($xml);              1751                $d->load XML($xml);           
1750     1752  
1751                $up = $d ->getEleme ntsByTagNa me ('login _user');   1753                $up = $d ->getEleme ntsByTagNa me ('login _user');
1752     1754  
1753                $up = $u p->item(0) ;   1755                $up = $u p->item(0) ;
1754     1756  
1755                return $ up->textCo ntent;                1757                return $ up->textCo ntent;             
1756           }   1758           }
1757           el se    1759           el se 
1758           {   1760           {
1759                if (!$d  = @domxml_ open_mem($ xml)) {   1761                if (!$d  = @domxml_ open_mem($ xml)) {
1760                    $mk  = new Mist ake ();   1762                    $mk  = new Mist ake ();
1761                    $mk- >log ("For um::_getLo ginUser -  can not pa rse xml :  $url");   1763                    $mk- >log ("For um::_getLo ginUser -  can not pa rse xml :  $url");
1762                    $mk- >displayEr ror ("[L[S ite is una vailable]] ");   1764                    $mk- >displayEr ror ("[L[S ite is una vailable]] ");
1763                }   1765                }
1764          1766       
1765                $n = $d- >get_eleme nts_by_tag name ('log in_user');   1767                $n = $d- >get_eleme nts_by_tag name ('log in_user');
1766                $n = $n[ 0];        1768                $n = $n[ 0];     
1767     1769  
1768                return $ n->get_con tent ();   1770                return $ n->get_con tent ();
1769           }           1771           }        
1770       }   1772       }
1771     1773  
1772          1774       
1773       functi on _read_i ntegration _file ($in tegration_ file)   1775       functi on _read_i ntegration _file ($in tegration_ file)
1774       {   1776       {
1775           gl obal $gCon f;   1777           gl obal $gCon f;
1776     1778  
1777           if  ('url' ==  $gConf['i ntegration '])   1779           if  ('url' ==  $gConf['i ntegration '])
1778           {   1780           {
1779                if (func tion_exist s('curl_in it'))   1781                if (func tion_exist s('curl_in it'))
1780                {   1782                {
1781                    $cur l = curl_i nit();   1783                    $cur l = curl_i nit();
1782     1784  
1783                    curl _setopt($c url, CURLO PT_URL, $i ntegration _file);   1785                    curl _setopt($c url, CURLO PT_URL, $i ntegration _file);
1784                    curl _setopt($c url, CURLO PT_RETURNT RANSFER, t rue);   1786                    curl _setopt($c url, CURLO PT_RETURNT RANSFER, t rue);
1785                    curl _setopt($c url, CURLO PT_HEADER,  false);   1787                    curl _setopt($c url, CURLO PT_HEADER,  false);
1786     1788  
1787                    $xml  = curl_ex ec($curl);   1789                    $xml  = curl_ex ec($curl);
1788     1790  
1789                    curl _close($cu rl);   1791                    curl _close($cu rl);
1790     1792  
1791                    if ( true === $ xml) $xml  = '';               1793                    if ( true === $ xml) $xml  = '';            
1792                }                1794                }             
1793                elseif ( $h = @fope n ($integr ation_file , "r"))   1795                elseif ( $h = @fope n ($integr ation_file , "r"))
1794                {   1796                {
1795                    $xml  = '';   1797                    $xml  = '';
1796                    whil e (!feof($ h))    1798                    whil e (!feof($ h)) 
1797                                 {   1799                                 {
1798                         $xml .= fr ead($h, 81 92);   1800                         $xml .= fr ead($h, 81 92);
1799                    }   1801                    }
1800                    fclo se($h);   1802                    fclo se($h);
1801                }   1803                }
1802                else   1804                else
1803                {               1805                {            
1804                    $mk  = new Mist ake ();   1806                    $mk  = new Mist ake ();
1805                    $mk- >log ("For um::_read_ integratio n_file - c an not ope n $integra tion_file  for readin g");   1807                    $mk- >log ("For um::_read_ integratio n_file - c an not ope n $integra tion_file  for readin g");
1806                    $mk- >displayEr ror ("[L[S ite is una vailable]] ");   1808                    $mk- >displayEr ror ("[L[S ite is una vailable]] ");
1807                }   1809                }
1808     1810  
1809                return $ xml;   1811                return $ xml;
1810           }   1812           }
1811           el se   1813           el se
1812           {   1814           {
1813                $orca_in tegration_ xml = '';   1815                $orca_in tegration_ xml = '';
1814                $orca_in tegration_ vars = $in tegration_ file['vars '];   1816                $orca_in tegration_ vars = $in tegration_ file['vars '];
1815                include  ($integrat ion_file[' file']);   1817                include  ($integrat ion_file[' file']);
1816                return $ orca_integ ration_xml ;   1818                return $ orca_integ ration_xml ;
1817           }   1819           }
1818              1820           
1819       }   1821       }
1820     1822  
1821       functi on _format _when ($iS ec)   1823       functi on _format _when ($iS ec)
1822       {   1824       {
1823           $s  = '<b>';   1825           $s  = '<b>';
1824           if  ($iSec <  3600)   1826           if  ($iSec <  3600)
1825           {   1827           {
1826                $i = rou nd($iSec/6 0);   1828                $i = rou nd($iSec/6 0);
1827                if (0 ==  $i || 1 = = $i) $s . = '1</b> [ L[Minute A go]]';   1829                if (0 ==  $i || 1 = = $i) $s . = '1</b> [ L[Minute A go]]';
1828                else $s  .= $i . '< /b> [L[Min utes Ago]] ';   1830                else $s  .= $i . '< /b> [L[Min utes Ago]] ';
1829           }   1831           }
1830           el se if ($iS ec < 86400 )   1832           el se if ($iS ec < 86400 )
1831           {   1833           {
1832                $i = rou nd($iSec/6 0/60);   1834                $i = rou nd($iSec/6 0/60);
1833                if (0 ==  $i || 1 = = $i) $s . = '1</b> [ L[Hour Ago ]]';   1835                if (0 ==  $i || 1 = = $i) $s . = '1</b> [ L[Hour Ago ]]';
1834                else $s  .= $i . '< /b> [L[Hou rs Ago]]';   1836                else $s  .= $i . '< /b> [L[Hou rs Ago]]';
1835           }                     1837           }                  
1836           el se    1838           el se 
1837           {   1839           {
1838                $i = rou nd($iSec/6 0/60/24);   1840                $i = rou nd($iSec/6 0/60/24);
1839                if (0 ==  $i || 1 = = $i) $s . = '1</b> [ L[Day Ago] ]';   1841                if (0 ==  $i || 1 = = $i) $s . = '1</b> [ L[Day Ago] ]';
1840                else $s  .= $i . '< /b> [L[Day s Ago]]';   1842                else $s  .= $i . '< /b> [L[Day s Ago]]';
1841           }                                  1843           }                               
1842           re turn $s;         1844           re turn $s;      
1843       }     1845       }  
1844     1846  
1845       functi on _no_acc ess ($wp =  0)   1847       functi on _no_acc ess ($wp =  0)
1846       {   1848       {
1847           $x ml = '<for um_access> no</forum_ access>';   1849           $x ml = '<for um_access> no</forum_ access>';
1848           if  (!$wp) re turn $xml;   1850           if  (!$wp) re turn $xml;
1849           $l i = $this- >_getLogin Info ();   1851           $l i = $this- >_getLogin Info ();
1850           re turn $this ->addHeade rFooter ($ li, $xml);   1852           re turn $this ->addHeade rFooter ($ li, $xml);
1851       }   1853       }
1852     1854  
1853       functi on _buld_t opic_desc  (&$s)   1855       functi on _buld_t opic_desc  (&$s)
1854       {   1856       {
1855           $s  = str_rep lace(array ('&#160;', '&amp;','& gt;','&lt; ','&quot;' ), array('  ','&','>' ,'<',"'"), strip_tags  ($s));   1857           $s  = str_rep lace(array ('&#160;', '&amp;','& gt;','&lt; ','&quot;' ), array('  ','&','>' ,'<',"'"), strip_tags  ($s));
1856           va lidate_uni code ($s);   1858           va lidate_uni code ($s);
1857           if  ($s == '' ) $s = ' ' ;   1859           if  ($s == '' ) $s = ' ' ;
1858           $s  = '<![CDA TA[' . $s  . ']]>';   1860           $s  = '<![CDA TA[' . $s  . ']]>';
1859       }   1861       }
1860     1862  
1861       functi on uriGene rate ($s,  $sTable, $ sField, $i MaxLen = 2 55)   1863       functi on uriGene rate ($s,  $sTable, $ sField, $i MaxLen = 2 55)
1862       {   1864       {
1863           // $s = orca_ mb_replace  ('/([^\d^ \w]+)/', ' -', $s); / / latin ch aracters   1865           // $s = orca_ mb_replace  ('/([^\d^ \w]+)/', ' -', $s); / / latin ch aracters
1864           $s  = orca_mb _replace ( '/[^\pL^\p N]+/u', '- ', $s); //  unicode c haracters   1866           $s  = orca_mb _replace ( '/[^\pL^\p N]+/u', '- ', $s); //  unicode c haracters
1865           $s  = orca_mb _replace ( '/([-^]+)/ ', '-', $s );   1867           $s  = orca_mb _replace ( '/([-^]+)/ ', '-', $s );
    1868           if  (!$s) $s  = '-';
1866     1869  
1867           if  ($this->u riCheckUni q($s, $sTa ble, $sFie ld)) retur n $s;   1870           if  ($this->u riCheckUni q($s, $sTa ble, $sFie ld)) retur n $s;
1868     1871  
1869           //  try to ad d date   1872           //  try to ad d date
1870     1873  
1871           if  (orca_mb_ len($s) >  240)   1874           if  (orca_mb_ len($s) >  240)
1872                $s = orc a_mb_subst r ($s, 0,  240);   1875                $s = orc a_mb_subst r ($s, 0,  240);
1873     1876  
1874           $s  .= '-' .  date('Y-m- d');   1877           $s  .= '-' .  date('Y-m- d');
1875              1878           
1876           if  ($this->u riCheckUni q($s, $sTa ble, $sFie ld)) retur n $s;   1879           if  ($this->u riCheckUni q($s, $sTa ble, $sFie ld)) retur n $s;
1877     1880  
1878     1881  
1879           //  try to ad d number   1882           //  try to ad d number
1880     1883  
1881           fo r ($i = 0  ; $i < 999  ; ++$i)   1884           fo r ($i = 0  ; $i < 999  ; ++$i)
1882           {            1885           {         
1883                if ($thi s->uriChec kUniq($s .  '-' . $i,  $sTable,  $sField))    1886                if ($thi s->uriChec kUniq($s .  '-' . $i,  $sTable,  $sField)) 
1884                {   1887                {
1885                    retu rn ($s . ' -' . $i);                     1888                    retu rn ($s . ' -' . $i);                  
1886                }   1889                }
1887           }   1890           }
1888     1891  
1889           re turn rand( 0, 9999999 99);   1892           re turn rand( 0, 9999999 99);
1890       }   1893       }
1891     1894  
1892       functi on uriChec kUniq ($s,  $sTable,  $sField)   1895       functi on uriChec kUniq ($s,  $sTable,  $sField)
1893       {   1896       {
1894           $f db = new D bForum ();   1897           $f db = new D bForum ();
1895           re turn !$fdb ->getOne(" SELECT 1 F ROM $sTabl e WHERE $s Field = '$ s' LIMIT 1 ");   1898           re turn !$fdb ->getOne(" SELECT 1 F ROM $sTabl e WHERE $s Field = '$ s' LIMIT 1 ");
1896       }   1899       }
1897     1900  
1898   }   1901   }
1899     1902  
1900   function o rca_mb_rep lace ($sPa ttern, $sR eplace, $s )   1903   function o rca_mb_rep lace ($sPa ttern, $sR eplace, $s )
1901   {   1904   {
1902       return  preg_repl ace ($sPat tern, $sRe place, $s) ;   1905       return  preg_repl ace ($sPat tern, $sRe place, $s) ;
1903   }   1906   }
1904     1907  
1905   function o rca_mb_len  ($s)   1908   function o rca_mb_len  ($s)
1906   {   1909   {
1907       if (fu nction_exi sts('mb_st rlen'))   1910       if (fu nction_exi sts('mb_st rlen'))
1908           re turn mb_st rlen ($s);   1911           re turn mb_st rlen ($s);
1909       else   1912       else
1910           re turn strle n ($s);   1913           re turn strle n ($s);
1911   }       1914   }    
1912     1915  
1913   function o rca_mb_sub str ($s, $ iStart, $i Len)   1916   function o rca_mb_sub str ($s, $ iStart, $i Len)
1914   {   1917   {
1915       if (fu nction_exi sts('mb_su bstr'))   1918       if (fu nction_exi sts('mb_su bstr'))
1916           re turn mb_su bstr ($s,  $iStart, $ iLen);   1919           re turn mb_su bstr ($s,  $iStart, $ iLen);
1917       else   1920       else
1918           re turn subst r ($s, $iS tart, $iLe n);   1921           re turn subst r ($s, $iS tart, $iLe n);
1919   }       1922   }    
1920     1923  
1921   ?>   1924   ?>