56. File Comparison Report

Produced on Wed Jun 18 08:02:01 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.

56.1 Files compared

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

56.2 Comparison summary

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

56.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

56.4 Active regular expressions

No regular expressions were active.

56.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           $t his->setTr ackTopic ( $topic_id) ;   377           $t his->setTr ackTopic ( $topic_id) ;
378     378  
379           //  check use r permissi ons to del ete or edi t posts   379           //  check use r permissi ons to del ete or edi t posts
380           $g l_allow_ed it = 0;   380           $g l_allow_ed it = 0;
381           $g l_allow_de l = 0;   381           $g l_allow_de l = 0;
382              382           
383           if  ($this->_ checkUserP erm ($u, $ forum_type , 'edit',  $forum_id) )   383           if  ($this->_ checkUserP erm ($u, $ forum_type , 'edit',  $forum_id) )
384                $gl_allo w_edit = 1 ;   384                $gl_allo w_edit = 1 ;
385     385  
386           if  ($this->_ checkUserP erm ($u, $ forum_type , 'del', $ forum_id))   386           if  ($this->_ checkUserP erm ($u, $ forum_type , 'del', $ forum_id))
387                $gl_allo w_del = 1;   387                $gl_allo w_del = 1;
388     388  
389                       389                    
390           re set ($a);   390           re set ($a);
391           $p  = '';   391           $p  = '';
392           wh ile ( list  (,$r) = e ach ($a) )   392           wh ile ( list  (,$r) = e ach ($a) )
393           {   393           {
394                   394                
395                // acqui re user in fo   395                // acqui re user in fo
396                if (!$ui [$r['user' ]])   396                if (!$ui [$r['user' ]])
397                {                   397                {                
398                    $aa  = $this->_ getUserInf o ($r['use r']);   398                    $aa  = $this->_ getUserInf o ($r['use r']);
399                    $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']);   399                    $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']);
400                }   400                }
401     401  
402                $allow_e dit = $gl_ allow_edit ;   402                $allow_e dit = $gl_ allow_edit ;
403                $allow_d el = $gl_a llow_del;   403                $allow_d el = $gl_a llow_del;
404     404  
405                if (!$al low_edit & & $r['user '] == $u)   405                if (!$al low_edit & & $r['user '] == $u)
406                {   406                {
407                    if ( $this->_ch eckUserPer m ($r['use r'], 'own' , 'edit',  $forum_id) )   407                    if ( $this->_ch eckUserPer m ($r['use r'], 'own' , 'edit',  $forum_id) )
408                         $allow_edi t = 1;   408                         $allow_edi t = 1;
409                }               409                }            
410     410  
411                if (!$al low_del &&  $r['user' ] == $u)   411                if (!$al low_del &&  $r['user' ] == $u)
412                {   412                {
413                    if ( $this->_ch eckUserPer m ($r['use r'], 'own' , 'del', $ forum_id))   413                    if ( $this->_ch eckUserPer m ($r['use r'], 'own' , 'del', $ forum_id))
414                         $allow_del  = 1;   414                         $allow_del  = 1;
415                }               415                }            
416              416           
417                encode_p ost_text ( $r['post_t ext'], $wp , 1);             417                encode_p ost_text ( $r['post_t ext'], $wp , 1);          
418                   418                
419                $p .= << <EOF   419                $p .= << <EOF
420   <post id=" {$r['post_ id']}"  fo rce_show=" 0">   420   <post id=" {$r['post_ id']}"  fo rce_show=" 0">
421       <text> {$r['post_ text']}</t ext>   421       <text> {$r['post_ text']}</t ext>
422       <when> {$r['when' ]}</when>   422       <when> {$r['when' ]}</when>
423       <allow _edit>$all ow_edit</a llow_edit>   423       <allow _edit>$all ow_edit</a llow_edit>
424       <allow _del>$allo w_del</all ow_del>   424       <allow _del>$allo w_del</all ow_del>
425       <point s>{$r['vot es']}</poi nts>   425       <point s>{$r['vot es']}</poi nts>
426       <vote_ user_point >{$r['vote _user_poin t']}</vote _user_poin t>     426       <vote_ user_point >{$r['vote _user_poin t']}</vote _user_poin t>  
427       <user  posts="{$u i[$r['user ']]['posts ']}" name= "{$r['user ']}">   427       <user  posts="{$u i[$r['user ']]['posts ']}" name= "{$r['user ']}">
428           <a vatar>{$ui [$r['user' ]]['avatar ']}</avata r>   428           <a vatar>{$ui [$r['user' ]]['avatar ']}</avata r>
429           <u rl>{$ui[$r ['user']][ 'url']}</u rl>   429           <u rl>{$ui[$r ['user']][ 'url']}</u rl>
430           <o nclick>{$u i[$r['user ']]['oncli ck']}</onc lick>   430           <o nclick>{$u i[$r['user ']]['oncli ck']}</onc lick>
431       </user >   431       </user >
432       <min_p oint>{$gCo nf['min_po int']}</mi n_point>   432       <min_p oint>{$gCo nf['min_po int']}</mi n_point>
433   </post>   433   </post>
434   EOF;   434   EOF;
435                $rr = $r ;   435                $rr = $r ;
436           }   436           }
437     437  
438           $t  = $fdb->g etTopic ($ rr['topic_ id']);   438           $t  = $fdb->g etTopic ($ rr['topic_ id']);
439     439  
440     440  
441           $c at = $fdb- >getCat ($ f['cat_id' ]);   441           $c at = $fdb- >getCat ($ f['cat_id' ]);
442           en code_post_ text ($cat ['cat_name '], $wp);   442           en code_post_ text ($cat ['cat_name '], $wp);
443           $x 0 = <<<EOF   443           $x 0 = <<<EOF
444   <cat>   444   <cat>
445       <id>{$ cat['cat_i d']}</id>   445       <id>{$ cat['cat_i d']}</id>
446       <uri>{ $cat['cat_ uri']}</ur i>   446       <uri>{ $cat['cat_ uri']}</ur i>
447       <title >{$cat['ca t_name']}< /title>   447       <title >{$cat['ca t_name']}< /title>
448   </cat>   448   </cat>
449   EOF;   449   EOF;
450     450  
451           en code_post_ text ($t[' forum_titl e'], $wp);   451           en code_post_ text ($t[' forum_titl e'], $wp);
452           en code_post_ text ($t[' forum_desc '], $wp);   452           en code_post_ text ($t[' forum_desc '], $wp);
453           $x 1 = <<<EOF   453           $x 1 = <<<EOF
454   <forum>   454   <forum>
455       <id>{$ f['forum_i d']}</id>   455       <id>{$ f['forum_i d']}</id>
456       <uri>{ $f['forum_ uri']}</ur i>   456       <uri>{ $f['forum_ uri']}</ur i>
457       <title >{$t['foru m_title']} </title>   457       <title >{$t['foru m_title']} </title>
458       <desc> {$t['forum _desc']}</ desc>   458       <desc> {$t['forum _desc']}</ desc>
459       <type> {$f['forum _type']}</ type>   459       <type> {$f['forum _type']}</ type>
460   </forum>   460   </forum>
461   EOF;   461   EOF;
462           en code_post_ text ($t[' topic_titl e'], $wp,  1);   462           en code_post_ text ($t[' topic_titl e'], $wp,  1);
463           $x 2 = <<<EOF   463           $x 2 = <<<EOF
464   <topic>   464   <topic>
465       <id>{$ t['topic_i d']}</id>   465       <id>{$ t['topic_i d']}</id>
466       <uri>{ $t['topic_ uri']}</ur i>   466       <uri>{ $t['topic_ uri']}</ur i>
467       <title >{$t['topi c_title']} </title>   467       <title >{$t['topi c_title']} </title>
468       <locke d>{$t['top ic_locked' ]}</locked >   468       <locke d>{$t['top ic_locked' ]}</locked >
469   </topic>   469   </topic>
470   EOF;   470   EOF;
471     471  
472           if  ($wp)   472           if  ($wp)
473           {   473           {
474                $li = $t his->_getL oginInfo ( $u);   474                $li = $t his->_getL oginInfo ( $u);
475                return $ this->addH eaderFoote r ($li, "< posts>{$x0 }{$x1}{$x2 }{$p}</pos ts>");   475                return $ this->addH eaderFoote r ($li, "< posts>{$x0 }{$x1}{$x2 }{$p}</pos ts>");
476           }   476           }
477           el se   477           el se
478           {   478           {
479                $cu = $t his->getUr lsXml ();   479                $cu = $t his->getUr lsXml ();
480                $li = $t his->_getL oginInfo ( $u);   480                $li = $t his->_getL oginInfo ( $u);
481                return " <root><log ininfo>" .  array2xml ($li) . "< /logininfo >$cu<posts >{$x0}{$x1 }{$x2}{$p} </posts></ root>";   481                return " <root><log ininfo>" .  array2xml ($li) . "< /logininfo >$cu<posts >{$x0}{$x1 }{$x2}{$p} </posts></ root>";
482           }   482           }
483       }   483       }
484     484  
485     485  
486       /**   486       /**
487        * ret urns my th reads topi cs XML   487        * ret urns my th reads topi cs XML
488        * @pa ram $wp            re turn whole  page XML   488        * @pa ram $wp            re turn whole  page XML
489        */   489        */
490       functi on getMyTh readsXML ( $wp)   490       functi on getMyTh readsXML ( $wp)
491       {   491       {
492           gl obal $gCon f;   492           gl obal $gCon f;
493     493  
494           $u ser = $thi s->getLogi nUser();   494           $u ser = $thi s->getLogi nUser();
495     495  
496           $f db = new D bForum ();   496           $f db = new D bForum ();
497     497  
498           $f  = $fdb->g etForum ($ forum_id);   498           $f  = $fdb->g etForum ($ forum_id);
499     499  
500           if  (!$user)   500           if  (!$user)
501           {   501           {
502                return $ this->_no_ access($wp );   502                return $ this->_no_ access($wp );
503           }   503           }
504     504  
505           $x 1 = <<<EOF   505           $x 1 = <<<EOF
506   <forum>   506   <forum>
507       <title ><![CDATA[ [L[My Topi cs]]]]></t itle>   507       <title ><![CDATA[ [L[My Topi cs]]]]></t itle>
508       <desc> <![CDATA[[ L[Topics y ou partici pate in]]] ]></desc>   508       <desc> <![CDATA[[ L[Topics y ou partici pate in]]] ]></desc>
509   </forum>   509   </forum>
510   EOF;   510   EOF;
511     511  
512           $x 2 = '';   512           $x 2 = '';
513              513           
514           $u ser_last_a ct = (int) $fdb->getU serLastAct ivity ($us er);   514           $u ser_last_a ct = (int) $fdb->getU serLastAct ivity ($us er);
515     515  
516           $a  = $fdb->g etMyThread sTopics($u ser);   516           $a  = $fdb->g etMyThread sTopics($u ser);
517           re set ($a);   517           re set ($a);
518           $t  = '';   518           $t  = '';
519           wh ile ( list  (,$r) = e ach ($a) )   519           wh ile ( list  (,$r) = e ach ($a) )
520           {   520           {
521                    $lp  = $fdb->ge tTopicPost ($r['topic _id'], 'la st');   521                    $lp  = $fdb->ge tTopicPost ($r['topic _id'], 'la st');
522                    $fp  = $fdb->ge tTopicPost ($r['topic _id'], 'fi rst');   522                    $fp  = $fdb->ge tTopicPost ($r['topic _id'], 'fi rst');
523                       523                    
524                    $td  = $fdb->ge tTopicDesc  ($r['topi c_id']);   524                    $td  = $fdb->ge tTopicDesc  ($r['topi c_id']);
525                    $thi s->_buld_t opic_desc  ($td);   525                    $thi s->_buld_t opic_desc  ($td);
526     526  
527                    if ( !$user)   527                    if ( !$user)
528                         $new_topic  = 0;   528                         $new_topic  = 0;
529                    else   529                    else
530                         $new_topic  = $this-> isNewTopic  ($r['topi c_id'],  $ r['last_po st_when'],  $user_las t_act) ? 1  : 0;   530                         $new_topic  = $this-> isNewTopic  ($r['topi c_id'],  $ r['last_po st_when'],  $user_las t_act) ? 1  : 0;
531     531  
532                    enco de_post_te xt ($r['to pic_title' ], $wp, 1) ;                   532                    enco de_post_te xt ($r['to pic_title' ], $wp, 1) ;                
533                                             533                                          
534                    $t . = <<<EOF   534                    $t . = <<<EOF
535   <topic id= "{$r['topi c_id']}" n ew="$new_t opic" lpt= "{$r['last _post_when ']}" lut=" {$user_las t_act}">   535   <topic id= "{$r['topi c_id']}" n ew="$new_t opic" lpt= "{$r['last _post_when ']}" lut=" {$user_las t_act}">
536       <uri>{ $r['topic_ uri']}</ur i>   536       <uri>{ $r['topic_ uri']}</ur i>
537       <title >{$r['topi c_title']} </title>   537       <title >{$r['topi c_title']} </title>
538       <desc> {$td}</des c>   538       <desc> {$td}</des c>
539       <count >{$r['coun t_posts']} </count>   539       <count >{$r['coun t_posts']} </count>
540       <last_ u>{$lp['us er']}</las t_u>   540       <last_ u>{$lp['us er']}</las t_u>
541       <last_ d>{$lp['wh en']}</las t_d>   541       <last_ d>{$lp['wh en']}</las t_d>
542       <first _u>{$fp['u ser']}</fi rst_u>   542       <first _u>{$fp['u ser']}</fi rst_u>
543       <first _d>{$fp['w hen']}</fi rst_d>   543       <first _d>{$fp['w hen']}</fi rst_d>
544   </topic>   544   </topic>
545   EOF;   545   EOF;
546           }   546           }
547     547  
548           $p  = '';   548           $p  = '';
549           $n um = $fdb- >getTopics Num($forum _id);   549           $n um = $fdb- >getTopics Num($forum _id);
550           fo r ($i = 0  ; $i < $nu m ; $i +=  $gConf['to pics_per_p age'])   550           fo r ($i = 0  ; $i < $nu m ; $i +=  $gConf['to pics_per_p age'])
551                $p .= '< p c="' . ( ($start >=  $i && $st art < ($i  + $gConf[' topics_per _page']))  ? 1 : 0 ).  '" start= "' . $i .  '">' . ($i /$gConf['t opics_per_ page'] + 1 ) . '</p>' ;   551                $p .= '< p c="' . ( ($start >=  $i && $st art < ($i  + $gConf[' topics_per _page']))  ? 1 : 0 ).  '" start= "' . $i .  '">' . ($i /$gConf['t opics_per_ page'] + 1 ) . '</p>' ;
552          552       
553     553  
554           if  ($wp)   554           if  ($wp)
555           {   555           {
556                $li = $t his->_getL oginInfo ( );   556                $li = $t his->_getL oginInfo ( );
557                return $ this->addH eaderFoote r ($li, "< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics>");   557                return $ this->addH eaderFoote r ($li, "< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics>");
558           }   558           }
559           el se   559           el se
560           {   560           {
561                $cu = $t his->getUr lsXml ();   561                $cu = $t his->getUr lsXml ();
562                return " <root>$cu< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics></r oot>";   562                return " <root>$cu< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics></r oot>";
563           }   563           }
564       }   564       }
565          565       
566     566  
567       /**   567       /**
568        * ret urns flagg ed topics  XML   568        * ret urns flagg ed topics  XML
569        * @pa ram $wp            re turn whole  page XML   569        * @pa ram $wp            re turn whole  page XML
570        */   570        */
571       functi on getMyFl agsXML ($w p)   571       functi on getMyFl agsXML ($w p)
572       {   572       {
573           gl obal $gCon f;   573           gl obal $gCon f;
574     574  
575           $u ser = $thi s->getLogi nUser();   575           $u ser = $thi s->getLogi nUser();
576     576  
577           $f db = new D bForum ();   577           $f db = new D bForum ();
578     578  
579           $f  = $fdb->g etForum ($ forum_id);   579           $f  = $fdb->g etForum ($ forum_id);
580     580  
581           if  (!$user)   581           if  (!$user)
582           {   582           {
583                return $ this->_no_ access($wp );   583                return $ this->_no_ access($wp );
584           }   584           }
585     585  
586           $x 1 = <<<EOF   586           $x 1 = <<<EOF
587   <forum>   587   <forum>
588       <title ><![CDATA[ [L[Flagged  topics]]] ]></title>   588       <title ><![CDATA[ [L[Flagged  topics]]] ]></title>
589       <desc> <![CDATA[[ L[Topics y ou have fl agged]]]]> </desc>   589       <desc> <![CDATA[[ L[Topics y ou have fl agged]]]]> </desc>
590   </forum>   590   </forum>
591   EOF;   591   EOF;
592     592  
593           $x 2 = '';   593           $x 2 = '';
594              594           
595           $u ser_last_a ct = (int) $fdb->getU serLastAct ivity ($us er);   595           $u ser_last_a ct = (int) $fdb->getU serLastAct ivity ($us er);
596     596  
597           $a  = $fdb->g etMyFlagge dTopics($u ser);   597           $a  = $fdb->g etMyFlagge dTopics($u ser);
598           re set ($a);   598           re set ($a);
599           $t  = '';   599           $t  = '';
600           wh ile ( list  (,$r) = e ach ($a) )   600           wh ile ( list  (,$r) = e ach ($a) )
601           {   601           {
602                    $lp  = $fdb->ge tTopicPost ($r['topic _id'], 'la st');   602                    $lp  = $fdb->ge tTopicPost ($r['topic _id'], 'la st');
603                    $fp  = $fdb->ge tTopicPost ($r['topic _id'], 'fi rst');   603                    $fp  = $fdb->ge tTopicPost ($r['topic _id'], 'fi rst');
604                       604                    
605                    $td  = $fdb->ge tTopicDesc  ($r['topi c_id']);   605                    $td  = $fdb->ge tTopicDesc  ($r['topi c_id']);
606                    $thi s->_buld_t opic_desc  ($td);   606                    $thi s->_buld_t opic_desc  ($td);
607                                         607                                      
608                    if ( !$user)   608                    if ( !$user)
609                         $new_topic  = 0;   609                         $new_topic  = 0;
610                    else   610                    else
611                         $new_topic  = $this-> isNewTopic  ($r['topi c_id'],  $ r['last_po st_when'],  $user_las t_act) ? 1  : 0;   611                         $new_topic  = $this-> isNewTopic  ($r['topi c_id'],  $ r['last_po st_when'],  $user_las t_act) ? 1  : 0;
612     612  
613                    enco de_post_te xt ($r['to pic_title' ], $wp, 1) ;                   613                    enco de_post_te xt ($r['to pic_title' ], $wp, 1) ;                
614                                             614                                          
615                    $t . = <<<EOF   615                    $t . = <<<EOF
616   <topic id= "{$r['topi c_id']}" n ew="$new_t opic" lpt= "{$r['last _post_when ']}" lut=" {$user_las t_act}">   616   <topic id= "{$r['topi c_id']}" n ew="$new_t opic" lpt= "{$r['last _post_when ']}" lut=" {$user_las t_act}">
617       <uri>{ $r['topic_ title']}</ uri>   617       <uri>{ $r['topic_ title']}</ uri>
618       <title >{$r['topi c_title']} </title>   618       <title >{$r['topi c_title']} </title>
619       <desc> {$td}</des c>   619       <desc> {$td}</des c>
620       <count >{$r['coun t_posts']} </count>   620       <count >{$r['coun t_posts']} </count>
621       <last_ u>{$lp['us er']}</las t_u>   621       <last_ u>{$lp['us er']}</las t_u>
622       <last_ d>{$lp['wh en']}</las t_d>   622       <last_ d>{$lp['wh en']}</las t_d>
623       <first _u>{$fp['u ser']}</fi rst_u>   623       <first _u>{$fp['u ser']}</fi rst_u>
624       <first _d>{$fp['w hen']}</fi rst_d>   624       <first _d>{$fp['w hen']}</fi rst_d>
625   </topic>   625   </topic>
626   EOF;   626   EOF;
627           }   627           }
628     628  
629           $p  = '';   629           $p  = '';
630           $n um = $fdb- >getTopics Num($forum _id);   630           $n um = $fdb- >getTopics Num($forum _id);
631           fo r ($i = 0  ; $i < $nu m ; $i +=  $gConf['to pics_per_p age'])   631           fo r ($i = 0  ; $i < $nu m ; $i +=  $gConf['to pics_per_p age'])
632                $p .= '< p c="' . ( ($start >=  $i && $st art < ($i  + $gConf[' topics_per _page']))  ? 1 : 0 ).  '" start= "' . $i .  '">' . ($i /$gConf['t opics_per_ page'] + 1 ) . '</p>' ;   632                $p .= '< p c="' . ( ($start >=  $i && $st art < ($i  + $gConf[' topics_per _page']))  ? 1 : 0 ).  '" start= "' . $i .  '">' . ($i /$gConf['t opics_per_ page'] + 1 ) . '</p>' ;
633          633       
634     634  
635           if  ($wp)   635           if  ($wp)
636           {   636           {
637                $li = $t his->_getL oginInfo ( );   637                $li = $t his->_getL oginInfo ( );
638                return $ this->addH eaderFoote r ($li, "< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics>");   638                return $ this->addH eaderFoote r ($li, "< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics>");
639           }   639           }
640           el se   640           el se
641           {   641           {
642                $cu = $t his->getUr lsXml ();   642                $cu = $t his->getUr lsXml ();
643                return " <root>$cu< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics></r oot>";   643                return " <root>$cu< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics></r oot>";
644           }   644           }
645       }   645       }
646     646  
647     647  
648     648  
649       /**   649       /**
650        * ret urns forum  topics XM L   650        * ret urns forum  topics XM L
651        * @pa ram $forum _id     fo rum id   651        * @pa ram $forum _id     fo rum id
652        * @pa ram $wp            re turn whole  page XML   652        * @pa ram $wp            re turn whole  page XML
653        * @pa ram $start         re cord to st art with   653        * @pa ram $start         re cord to st art with
654        */   654        */
655       functi on getTopi csXML ($fo rum_uri, $ wp, $start  = 0)   655       functi on getTopi csXML ($fo rum_uri, $ wp, $start  = 0)
656       {   656       {
657           gl obal $gCon f;   657           gl obal $gCon f;
658     658  
659           $f db = new D bForum ();   659           $f db = new D bForum ();
660     660  
661           $f  = $fdb->g etForumByU ri ($forum _uri);   661           $f  = $fdb->g etForumByU ri ($forum _uri);
662           $f orum_id =  $f['forum_ id'];   662           $f orum_id =  $f['forum_ id'];
663     663  
664           $u ser = $thi s->getLogi nUser();   664           $u ser = $thi s->getLogi nUser();
665     665  
666           if  (!$this-> _checkUser Perm ($use r, $f['for um_type'],  'read', $ forum_id))   666           if  (!$this-> _checkUser Perm ($use r, $f['for um_type'],  'read', $ forum_id))
667           {   667           {
668                return $ this->_no_ access($wp );   668                return $ this->_no_ access($wp );
669           }   669           }
670     670  
671           en code_post_ text ($f[' forum_titl e'], $wp);   671           en code_post_ text ($f[' forum_titl e'], $wp);
672           en code_post_ text ($f[' forum_desc '], $wp);   672           en code_post_ text ($f[' forum_desc '], $wp);
673              673           
674           $x 1 = <<<EOF   674           $x 1 = <<<EOF
675   <forum>   675   <forum>
676       <id>{$ f['forum_i d']}</id>   676       <id>{$ f['forum_i d']}</id>
677       <uri>{ $f['forum_ uri']}</ur i>   677       <uri>{ $f['forum_ uri']}</ur i>
678       <title >{$f['foru m_title']} </title>   678       <title >{$f['foru m_title']} </title>
679       <desc> {$f['forum _desc']}</ desc>   679       <desc> {$f['forum _desc']}</ desc>
680       <type> {$f['forum _type']}</ type>   680       <type> {$f['forum _type']}</ type>
681   </forum>   681   </forum>
682   EOF;   682   EOF;
683     683  
684           $c at = $fdb- >getCat ($ f['cat_id' ]);   684           $c at = $fdb- >getCat ($ f['cat_id' ]);
685           en code_post_ text ($cat ['cat_name '], $wp);   685           en code_post_ text ($cat ['cat_name '], $wp);
686           $x 2 = <<<EOF   686           $x 2 = <<<EOF
687   <cat>   687   <cat>
688       <id>{$ cat['cat_i d']}</id>   688       <id>{$ cat['cat_i d']}</id>
689       <uri>{ $cat['cat_ uri']}</ur i>   689       <uri>{ $cat['cat_ uri']}</ur i>
690       <title >{$cat['ca t_name']}< /title>   690       <title >{$cat['ca t_name']}< /title>
691   </cat>   691   </cat>
692   EOF;   692   EOF;
693     693  
694           $u ser_last_a ct = (int) $fdb->getU serLastAct ivity ($us er);   694           $u ser_last_a ct = (int) $fdb->getU serLastAct ivity ($us er);
695     695  
696           $a  = $fdb->g etTopics($ forum_id,  $start);   696           $a  = $fdb->g etTopics($ forum_id,  $start);
697           re set ($a);   697           re set ($a);
698           $t  = '';   698           $t  = '';
699           wh ile ( list  (,$r) = e ach ($a) )   699           wh ile ( list  (,$r) = e ach ($a) )
700           {   700           {
701                    $td  = $fdb->ge tTopicDesc  ($r['topi c_id']);   701                    $td  = $fdb->ge tTopicDesc  ($r['topi c_id']);
702                    $thi s->_buld_t opic_desc  ($td);   702                    $thi s->_buld_t opic_desc  ($td);
703     703  
704                    if ( !$user)   704                    if ( !$user)
705                         $new_topic  = 0;   705                         $new_topic  = 0;
706                    else   706                    else
707                         $new_topic  = $this-> isNewTopic  ($r['topi c_id'],  $ r['last_po st_when'],  $user_las t_act) ? 1  : 0;   707                         $new_topic  = $this-> isNewTopic  ($r['topi c_id'],  $ r['last_po st_when'],  $user_las t_act) ? 1  : 0;
708     708  
709                                             709                                          
710                    enco de_post_te xt ($r['to pic_title' ], $wp, 1) ;                   710                    enco de_post_te xt ($r['to pic_title' ], $wp, 1) ;                
711                       711                    
712                    $t . = <<<EOF   712                    $t . = <<<EOF
713   <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']}">   713   <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']}">
714       <uri>{ $r['topic_ uri']}</ur i>   714       <uri>{ $r['topic_ uri']}</ur i>
715       <title >{$r['topi c_title']} </title>   715       <title >{$r['topi c_title']} </title>
716       <desc> {$td}</des c>   716       <desc> {$td}</des c>
717       <count >{$r['coun t_posts']} </count>   717       <count >{$r['coun t_posts']} </count>
718       <last_ u>{$r['las t_post_use r']}</last _u>   718       <last_ u>{$r['las t_post_use r']}</last _u>
719       <last_ d>{$r['las t_when']}< /last_d>   719       <last_ d>{$r['las t_when']}< /last_d>
720       <first _u>{$r['fi rst_post_u ser']}</fi rst_u>   720       <first _u>{$r['fi rst_post_u ser']}</fi rst_u>
721       <first _d>{$r['fi rst_when'] }</first_d >   721       <first _d>{$r['fi rst_when'] }</first_d >
722   </topic>   722   </topic>
723   EOF;   723   EOF;
724           }   724           }
725     725  
726           $p  = '';   726           $p  = '';
727           $n um = $fdb- >getTopics Num($forum _id);   727           $n um = $fdb- >getTopics Num($forum _id);
728           fo r ($i = 0  ; $i < $nu m ; $i +=  $gConf['to pics_per_p age'])   728           fo r ($i = 0  ; $i < $nu m ; $i +=  $gConf['to pics_per_p age'])
729                $p .= '< p c="' . ( ($start >=  $i && $st art < ($i  + $gConf[' topics_per _page']))  ? 1 : 0 ).  '" start= "' . $i .  '">' . ($i /$gConf['t opics_per_ page'] + 1 ) . '</p>' ;   729                $p .= '< p c="' . ( ($start >=  $i && $st art < ($i  + $gConf[' topics_per _page']))  ? 1 : 0 ).  '" start= "' . $i .  '">' . ($i /$gConf['t opics_per_ page'] + 1 ) . '</p>' ;
730          730       
731     731  
732           if  ($wp)   732           if  ($wp)
733           {   733           {
734                $li = $t his->_getL oginInfo ( $user);   734                $li = $t his->_getL oginInfo ( $user);
735                return $ this->addH eaderFoote r ($li, "< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics>");   735                return $ this->addH eaderFoote r ($li, "< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics>");
736           }   736           }
737           el se   737           el se
738           {   738           {
739                $cu = $t his->getUr lsXml ();   739                $cu = $t his->getUr lsXml ();
740                return " <root>$cu< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics></r oot>";   740                return " <root>$cu< topics><pa ges>$p</pa ges>{$x2}{ $x1}{$t}</ topics></r oot>";
741           }   741           }
742       }   742       }
743     743  
744       /**   744       /**
745        * ret urns array  with view ed topics   745        * ret urns array  with view ed topics
746        */    746        */ 
747       functi on getTrac kTopics ()   747       functi on getTrac kTopics ()
748       {   748       {
749           $a  = unseria lize($_COO KIE['track _topics']) ;   749           $a  = unseria lize($_COO KIE['track _topics']) ;
750           if  (!is_arra y($a)) ret urn array  ();   750           if  (!is_arra y($a)) ret urn array  ();
751           re turn $a;   751           re turn $a;
752       }   752       }
753     753  
754       /**   754       /**
755        * mar k topic as  viewed   755        * mar k topic as  viewed
756        */    756        */ 
757       functi on setTrac kTopic ($t opic_id)   757       functi on setTrac kTopic ($t opic_id)
758       {   758       {
759           $a  = unseria lize($_COO KIE['track _topics']) ;   759           $a  = unseria lize($_COO KIE['track _topics']) ;
760           if  (!is_arra y($a)) $a  = array () ;   760           if  (!is_arra y($a)) $a  = array () ;
761           $a [$topic_id ] = time() ;   761           $a [$topic_id ] = time() ;
762           se tcookie (' track_topi cs', seria lize($a));   762           se tcookie (' track_topi cs', seria lize($a));
763       }   763       }
764     764  
765       /**   765       /**
766        * det ect new to pic by las t topic up date time  and user a ctivity an d cookies   766        * det ect new to pic by las t topic up date time  and user a ctivity an d cookies
767        *   767        *
768        */    768        */ 
769       functi on isNewTo pic ($topi c_id, $top ic_last_ti me, $user_ last_time)   769       functi on isNewTo pic ($topi c_id, $top ic_last_ti me, $user_ last_time)
770       {   770       {
771           $a  = $this-> getTrackTo pics ();          771           $a  = $this-> getTrackTo pics ();       
772              772           
773           if  ($a[$topi c_id] && $ topic_last _time > $a [$topic_id ])    773           if  ($a[$topi c_id] && $ topic_last _time > $a [$topic_id ]) 
774                return 1 ;   774                return 1 ;
775           el se if ($a[ $topic_id] )   775           el se if ($a[ $topic_id] )
776                return 0 ;   776                return 0 ;
777     777  
778           if  (!$user_l ast_time)  return 1;   778           if  (!$user_l ast_time)  return 1;
779     779  
780           if  ($topic_l ast_time >  $user_las t_time) re turn 1;   780           if  ($topic_l ast_time >  $user_las t_time) re turn 1;
781     781  
782           re turn 0;   782           re turn 0;
783       }   783       }
784     784  
785       /**   785       /**
786        * ret urns forum s XML   786        * ret urns forum s XML
787        */   787        */
788       functi on getForu msShortXML  ($cat, $r oot)   788       functi on getForu msShortXML  ($cat, $r oot)
789       {   789       {
790           $f db = new D bForum ();   790           $f db = new D bForum ();
791           if  ($root)    791           if  ($root) 
792                $c = '<f orums>';   792                $c = '<f orums>';
793           el se   793           el se
794                $c = '';   794                $c = '';
795           $a a = $fdb-> getForums  ($cat);   795           $a a = $fdb-> getForums  ($cat);
796           re set ($aa);   796           re set ($aa);
797           wh ile ( list  (,$rr) =  each ($aa)  )   797           wh ile ( list  (,$rr) =  each ($aa)  )
798           {   798           {
799                encode_p ost_text($ rr['forum_ title'], 0 );   799                encode_p ost_text($ rr['forum_ title'], 0 );
800                   800                
801                $c .= << <EOF   801                $c .= << <EOF
802   <forum id= "{$rr['for um_id']}">   802   <forum id= "{$rr['for um_id']}">
803       <uri>{ $rr['forum _uri']}</u ri>   803       <uri>{ $rr['forum _uri']}</u ri>
804       <title >{$rr['for um_title'] }</title>   804       <title >{$rr['for um_title'] }</title>
805       <type> {$rr['foru m_type']}< /type>   805       <type> {$rr['foru m_type']}< /type>
806   </forum>   806   </forum>
807     807  
808   EOF;   808   EOF;
809           }   809           }
810           if  ($root)   810           if  ($root)
811                return $ c."</forum s>\n";   811                return $ c."</forum s>\n";
812           el se   812           el se
813                return $ c;   813                return $ c;
814       }   814       }
815     815  
816       /**   816       /**
817        * ret urns forum s XML   817        * ret urns forum s XML
818        */   818        */
819       functi on getForu msXML ($ca t, $root)   819       functi on getForu msXML ($ca t, $root)
820       {   820       {
821           $f db = new D bForum ();   821           $f db = new D bForum ();
822           if  ($root)    822           if  ($root) 
823                $c = '<f orums>';   823                $c = '<f orums>';
824           el se   824           el se
825                $c = '';   825                $c = '';
826           $a a = $fdb-> getForumsB yCatUri ($ cat);   826           $a a = $fdb-> getForumsB yCatUri ($ cat);
827     827  
828           re set ($aa);   828           re set ($aa);
829           wh ile ( list  (,$rr) =  each ($aa)  )   829           wh ile ( list  (,$rr) =  each ($aa)  )
830           {   830           {
831                encode_p ost_text ( $rr['forum _title'],  $root);   831                encode_p ost_text ( $rr['forum _title'],  $root);
832                encode_p ost_text ( $rr['forum _desc'], $ root);   832                encode_p ost_text ( $rr['forum _desc'], $ root);
833                   833                
834                $c .= << <EOF   834                $c .= << <EOF
835   <forum id= "{$rr['for um_id']}"  new="0">   835   <forum id= "{$rr['for um_id']}"  new="0">
836       <uri>{ $rr['forum _uri']}</u ri>   836       <uri>{ $rr['forum _uri']}</u ri>
837       <title >{$rr['for um_title'] }</title>   837       <title >{$rr['for um_title'] }</title>
838       <desc> {$rr['foru m_desc']}< /desc>   838       <desc> {$rr['foru m_desc']}< /desc>
839       <type> {$rr['foru m_type']}< /type>   839       <type> {$rr['foru m_type']}< /type>
840       <posts >{$rr['for um_posts'] }</posts>   840       <posts >{$rr['for um_posts'] }</posts>
841       <topic s>{$rr['fo rum_topics ']}</topic s>   841       <topic s>{$rr['fo rum_topics ']}</topic s>
842       <last> {$rr['foru m_last']}< /last>   842       <last> {$rr['foru m_last']}< /last>
843   </forum>   843   </forum>
844     844  
845   EOF;   845   EOF;
846           }   846           }
847              847           
848           if  ($root)   848           if  ($root)
849           {   849           {
850                $cu = $t his->getUr lsXml ();   850                $cu = $t his->getUr lsXml ();
851                return ' <root>' .  $cu . $c .  "</forums ></root>\n ";   851                return ' <root>' .  $cu . $c .  "</forums ></root>\n ";
852           }   852           }
853           el se   853           el se
854           {   854           {
855                return $ c;   855                return $ c;
856           }   856           }
857       }   857       }
858     858  
859     859  
860     860  
861       /**   861       /**
862        * ret urns page  XML   862        * ret urns page  XML
863        */   863        */
864       functi on getPage XML ($firs t_load = 1 , &$p)   864       functi on getPage XML ($firs t_load = 1 , &$p)
865       {   865       {
866           gl obal $gCon f;   866           gl obal $gCon f;
867     867  
868           $f db = new D bForum ();   868           $f db = new D bForum ();
869     869  
870           $a  = $fdb->g etCategs() ;   870           $a  = $fdb->g etCategs() ;
871           re set ($a);   871           re set ($a);
872           $c  = '';   872           $c  = '';
873           wh ile ( list  (,$r) = e ach ($a) )   873           wh ile ( list  (,$r) = e ach ($a) )
874           {   874           {
875                $icon_ur l  = $r['c at_icon']  ? $gConf[' url']['ico n'] . $r[' cat_icon']  : '';   875                $icon_ur l  = $r['c at_icon']  ? $gConf[' url']['ico n'] . $r[' cat_icon']  : '';
876                $c .= "< categ id=\ "{$r['cat_ id']}\" ur i=\"{$r['c at_uri']}\ " icon=\"$ icon_url\" >";   876                $c .= "< categ id=\ "{$r['cat_ id']}\" ur i=\"{$r['c at_uri']}\ " icon=\"$ icon_url\" >";
877                encode_p ost_text ( $r['cat_na me'], 1);   877                encode_p ost_text ( $r['cat_na me'], 1);
878                $c .= "< title>{$r[ 'cat_name' ]}</title> ";   878                $c .= "< title>{$r[ 'cat_name' ]}</title> ";
879     879  
880                if (( is set($p['ca t']) && $p ['cat'] ==  $r['cat_u ri'] ) /*| | 1 == $r[ 'cat_id']  */)   880                if (( is set($p['ca t']) && $p ['cat'] ==  $r['cat_u ri'] ) /*| | 1 == $r[ 'cat_id']  */)
881                {   881                {
882                    $c . = '<forums >'.$this-> getForumsX ML ($r['ca t_uri'], 0 ) . '</for ums>';   882                    $c . = '<forums >'.$this-> getForumsX ML ($r['ca t_uri'], 0 ) . '</for ums>';
883                }   883                }
884                $c .= "< /categ>";   884                $c .= "< /categ>";
885           }   885           }
886              886           
887           $s  = "<categ s>$c</cate gs>";   887           $s  = "<categ s>$c</cate gs>";
888     888  
889           if  ($first_l oad && iss et($p['act ion']) &&  'goto' ==  $p['action '] && isse t($p['foru m_id']))   889           if  ($first_l oad && iss et($p['act ion']) &&  'goto' ==  $p['action '] && isse t($p['foru m_id']))
890           {   890           {
891                $s .= "< onload>f.s electForum ('" . $p[' forum_id']  . "', 0)< /onload>";   891                $s .= "< onload>f.s electForum ('" . $p[' forum_id']  . "', 0)< /onload>";
892           }   892           }
893              893           
894           if  ($first_l oad && iss et($p['act ion']) &&  'goto' ==  $p['action '] && isse t($p['topi c_id']))   894           if  ($first_l oad && iss et($p['act ion']) &&  'goto' ==  $p['action '] && isse t($p['topi c_id']))
895           {   895           {
896                $s .= "< onload>f.s electTopic ('" . $p[' topic_id']  . "')</on load>";   896                $s .= "< onload>f.s electTopic ('" . $p[' topic_id']  . "')</on load>";
897           }   897           }
898     898  
899           //  live trac ker   899           //  live trac ker
900           $l t = "<live _tracker>"  . $this-> getLivePos tsXML() .  "</live_tr acker>";   900           $l t = "<live _tracker>"  . $this-> getLivePos tsXML() .  "</live_tr acker>";
901              901           
902           $l i = $this- >_getLogin Info ();   902           $l i = $this- >_getLogin Info ();
903     903  
904           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==') );   904           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==') );
905     905  
906           if  ($first_l oad)   906           if  ($first_l oad)
907           {   907           {
908                return $ this->addH eaderFoote r ($li, $s .$lt);   908                return $ this->addH eaderFoote r ($li, $s .$lt);
909           }   909           }
910           el se   910           el se
911           {   911           {
912                $cu = $t his->getUr lsXml ();   912                $cu = $t his->getUr lsXml ();
913                return " <root>$cu< logininfo> ".array2xm l($li)."</ logininfo> <page>{$s} {$lt}</pag e></root>" ;   913                return " <root>$cu< logininfo> ".array2xm l($li)."</ logininfo> <page>{$s} {$lt}</pag e></root>" ;
914           }   914           }
915       }   915       }
916     916  
917       functi on getLive PostsXML ( $count = 1 0, $ts = 0 )   917       functi on getLive PostsXML ( $count = 1 0, $ts = 0 )
918       {   918       {
919           gl obal $gCon f;   919           gl obal $gCon f;
920     920  
921           $r et = '';   921           $r et = '';
922     922  
923           $f db = new D bForum ();   923           $f db = new D bForum ();
924           $a  = $fdb->g etLivePost s ($count,  $ts);   924           $a  = $fdb->g etLivePost s ($count,  $ts);
925           re set ($a);   925           re set ($a);
926           $u i = array  ();   926           $u i = array  ();
927           wh ile (list( ,$r) = eac h ($a))   927           wh ile (list( ,$r) = eac h ($a))
928           {   928           {
929                // acqui re user in fo   929                // acqui re user in fo
930                if (!iss et($ui[$r[ 'user']]))   930                if (!iss et($ui[$r[ 'user']]))
931                {   931                {
932                    $aa  = $this->_ getUserInf o ($r['use r']);   932                    $aa  = $this->_ getUserInf o ($r['use r']);
933                    $ui[ $r['user'] ] = array  ('avatar'  => $aa['av atar'], 'u rl' => $aa ['profile_ url'], 'on click' =>  $aa['profi le_onclick ']);   933                    $ui[ $r['user'] ] = array  ('avatar'  => $aa['av atar'], 'u rl' => $aa ['profile_ url'], 'on click' =>  $aa['profi le_onclick ']);
934                }   934                }
935     935  
936                $this->_ buld_topic _desc ($r[ 'post_text ']);   936                $this->_ buld_topic _desc ($r[ 'post_text ']);
937     937  
938                encode_p ost_text($ r['topic_t itle'], 0,  1);   938                encode_p ost_text($ r['topic_t itle'], 0,  1);
939                encode_p ost_text($ r['forum_t itle'], 0) ;   939                encode_p ost_text($ r['forum_t itle'], 0) ;
940                encode_p ost_text($ r['cat_nam e'], 0);                              940                encode_p ost_text($ r['cat_nam e'], 0);                           
941                   941                
942                $r['when '] = $this ->_format_ when ($r[' sec']);   942                $r['when '] = $this ->_format_ when ($r[' sec']);
943     943  
944                $ret .=  <<<EOF   944                $ret .=  <<<EOF
945   <post id=" {$r['post_ id']}" ts= "{$r['ts'] }">   945   <post id=" {$r['post_ id']}" ts= "{$r['ts'] }">
946       <text> {$r['post_ text']}</t ext>   946       <text> {$r['post_ text']}</t ext>
947       <user> {$r['user' ]}</user>   947       <user> {$r['user' ]}</user>
948       <date> {$r['when' ]}</date>   948       <date> {$r['when' ]}</date>
949     949  
950       <avata r>{$ui[$r[ 'user']][' avatar']}< /avatar>   950       <avata r>{$ui[$r[ 'user']][' avatar']}< /avatar>
951       <profi le>{$ui[$r ['user']][ 'url']}</p rofile>   951       <profi le>{$ui[$r ['user']][ 'url']}</p rofile>
952       <oncli ck>{$ui[$r ['user']][ 'onclick'] }</onclick >   952       <oncli ck>{$ui[$r ['user']][ 'onclick'] }</onclick >
953     953  
954       <topic  id="{$r[' topic_id'] }" uri="{$ r['topic_u ri']}">{$r ['topic_ti tle']}</to pic>   954       <topic  id="{$r[' topic_id'] }" uri="{$ r['topic_u ri']}">{$r ['topic_ti tle']}</to pic>
955       <forum  id="{$r[' forum_id'] }" uri="{$ r['forum_u ri']}">{$r ['forum_ti tle']}</fo rum>   955       <forum  id="{$r[' forum_id'] }" uri="{$ r['forum_u ri']}">{$r ['forum_ti tle']}</fo rum>
956       <cat i d="{$r['ca t_id']}" u ri="{$r['c at_uri']}" >{$r['cat_ name']}</c at>   956       <cat i d="{$r['ca t_id']}" u ri="{$r['c at_uri']}" >{$r['cat_ name']}</c at>
957       <base> {$gConf['u rl']['base ']}</base>   957       <base> {$gConf['u rl']['base ']}</base>
958   </post>   958   </post>
959   EOF;   959   EOF;
960           }   960           }
961     961  
962           re turn $ret;   962           re turn $ret;
963       }   963       }
964     964  
965       /**   965       /**
966        * che ck if new  posts are  available   966        * che ck if new  posts are  available
967        *  @p aram  $ts      timest amp of las t post   967        *  @p aram  $ts      timest amp of las t post
968        */    968        */ 
969       functi on isNewPo st ($ts)   969       functi on isNewPo st ($ts)
970       {   970       {
971           $d b = new Db Forum ();           971           $d b = new Db Forum ();        
972           re turn '<ret >' . (int) $db->getNe wPostTs ($ ts) . '</r et>';   972           re turn '<ret >' . (int) $db->getNe wPostTs ($ ts) . '</r et>';
973       }   973       }
974     974  
975     975  
976       /**   976       /**
977        * pos t reply   977        * pos t reply
978        * @pa ram $p     _post arra y   978        * @pa ram $p     _post arra y
979        */   979        */
980       functi on postRep lyXML (&$p )   980       functi on postRep lyXML (&$p )
981       {   981       {
982     982  
983           $f db = new D bForum ();   983           $f db = new D bForum ();
984     984  
985           $f  = $fdb->g etForum (( int)$p['fo rum_id']);   985           $f  = $fdb->g etForum (( int)$p['fo rum_id']);
986     986  
987           $t  = $fdb->g etTopic (( int)$p['to pic_id']);   987           $t  = $fdb->g etTopic (( int)$p['to pic_id']);
988     988  
989           if  (!$this-> _checkUser Perm ('',  $f['forum_ type'], 'p ost', (int )$p['forum _id']) ||  $t['topic_ locked'])    989           if  (!$this-> _checkUser Perm ('',  $f['forum_ type'], 'p ost', (int )$p['forum _id']) ||  $t['topic_ locked']) 
990           {   990           {
991                return < <<EOF   991                return < <<EOF
992   <html>   992   <html>
993   <body>   993   <body>
994   <script la nguage="ja vascript"  type="text /javascrip t">   994   <script la nguage="ja vascript"  type="text /javascrip t">
995       window .parent.do cument.f.a ccessDenie d();   995       window .parent.do cument.f.a ccessDenie d();
996   </script>   996   </script>
997   </body>   997   </body>
998   </html>   998   </html>
999   EOF;   999   EOF;
1000           }           1000           }        
1001     1001  
1002     1002  
1003           //  post mesa ge here   1003           //  post mesa ge here
1004     1004  
1005           $p ['forum_id '] = (int) $p['forum_ id'];   1005           $p ['forum_id '] = (int) $p['forum_ id'];
1006           $p ['topic_id '] = (int) $p['topic_ id'];   1006           $p ['topic_id '] = (int) $p['topic_ id'];
1007     1007  
1008           $u ser = $thi s->_getLog inUserName  ();   1008           $u ser = $thi s->_getLog inUserName  ();
1009     1009  
1010           pr epare_to_d b($p['topi c_text'],  1);   1010           pr epare_to_d b($p['topi c_text'],  1);
1011     1011  
1012           $f db->postRe ply ($p['f orum_id'],  $p['topic _id'], $p[ 'topic_tex t'], $user );   1012           $f db->postRe ply ($p['f orum_id'],  $p['topic _id'], $p[ 'topic_tex t'], $user );
1013     1013  
1014           $t  = $fdb->g etTopic($p ['topic_id ']);   1014           $t  = $fdb->g etTopic($p ['topic_id ']);
1015     1015  
1016           re turn <<<EO F   1016           re turn <<<EO F
1017   <html>   1017   <html>
1018   <body>   1018   <body>
1019   <script la nguage="ja vascript"  type="text /javascrip t">   1019   <script la nguage="ja vascript"  type="text /javascrip t">
1020       window .parent.do cument.f.r eplySucces s('{$f['fo rum_uri']} ', '{$t['t opic_uri'] }');   1020       window .parent.do cument.f.r eplySucces s('{$f['fo rum_uri']} ', '{$t['t opic_uri'] }');
1021   </script>   1021   </script>
1022   </body>   1022   </body>
1023   </html>   1023   </html>
1024   EOF;   1024   EOF;
1025     1025  
1026     1026  
1027       }   1027       }
1028     1028  
1029       /**   1029       /**
1030        * xml  for edit  post    1030        * xml  for edit  post 
1031        * @pa ram $post_ id      po st id   1031        * @pa ram $post_ id      po st id
1032        * @pa ram $topic _id     to pic id   1032        * @pa ram $topic _id     to pic id
1033        */   1033        */
1034       functi on editPos tXml ($pos t_id, $top ic_id)   1034       functi on editPos tXml ($pos t_id, $top ic_id)
1035       {   1035       {
1036           $c u = $this- >getUrlsXm l ();   1036           $c u = $this- >getUrlsXm l ();
1037            if   (
!$topic_id   &&  
$post_id)
  1037            if   ( /* !$topic_id   &&   */ $post_id)
1038           {   1038           {
1039                $db = ne w DbForum  ();          1039                $db = ne w DbForum  ();       
1040                 $a   =   $db->get
PostId s   ($post_id) ;
  1040                 $a   =   $db->get TopicBy PostId  
($post_id) ;
1041                 $topic_id   =   $ a ['topic_
i d '];
  1041                $t = $db ->getTopic  ($a['topi c_id']);
    1042                 $topic_id   =   $ t ['topic_ ur i
'];
1042           }   1043           }
1043           re turn <<<EO S   1044           re turn <<<EO S
1044   <root>   1045   <root>
1045       $cu   1046       $cu
1046       <edit_ post>   1047       <edit_ post>
1047           <p ost_id>$po st_id</pos t_id>   1048           <p ost_id>$po st_id</pos t_id>
1048           <t opic_id>$t opic_id</t opic_id>   1049           <t opic_id>$t opic_id</t opic_id>
1049       </edit _post>   1050       </edit _post>
1050   </root>   1051   </root>
1051   EOS;   1052   EOS;
1052       }   1053       }
1053     1054  
1054       /**   1055       /**
1055        * edi t post   1056        * edi t post
1056        * @pa ram $post_ id      po st id   1057        * @pa ram $post_ id      po st id
1057        * @pa ram $topic _id     to pic id   1058        * @pa ram $topic _id     to pic id
1058        * @pa ram $text          ne w post tex t   1059        * @pa ram $text          ne w post tex t
1059        */   1060        */
1060       functi on editPos t ($post_i d, $topic_ id, $text)   1061       functi on editPos t ($post_i d, $topic_ id, $text)
1061       {   1062       {
1062           $n o_access =  true;   1063           $n o_access =  true;
1063     1064  
1064           $f db = new D bForum ();   1065           $f db = new D bForum ();
1065     1066  
1066           // $f = $fdb- >getForumB yPostId ($ post_id);   1067           // $f = $fdb- >getForumB yPostId ($ post_id);
1067           $t  = $fdb->g etTopicByU ri ($topic _id);   1068           $t  = $fdb->g etTopicByU ri ($topic _id);
1068     1069  
1069           if  ($this->_ checkUserP erm ('', $ t['forum_t ype'], 'ed it', $t['f orum_id'])   1070           if  ($this->_ checkUserP erm ('', $ t['forum_t ype'], 'ed it', $t['f orum_id'])
1070                $no_acce ss = false ;   1071                $no_acce ss = false ;
1071           if  ($no_acce ss && $fdb ->getPostU ser((int)$ post_id) = = $this->_ getLoginUs erName())   1072           if  ($no_acce ss && $fdb ->getPostU ser((int)$ post_id) = = $this->_ getLoginUs erName())
1072                if ($thi s->_checkU serPerm (' ', 'own',  'edit', $t ['forum_id ']))    1073                if ($thi s->_checkU serPerm (' ', 'own',  'edit', $t ['forum_id '])) 
1073                    $no_ access = f alse;   1074                    $no_ access = f alse;
1074     1075  
1075           if  ($no_acce ss)   1076           if  ($no_acce ss)
1076           {   1077           {
1077                return < <<EOF   1078                return < <<EOF
1078   <html>   1079   <html>
1079   <body>   1080   <body>
1080   <script la nguage="ja vascript"  type="text /javascrip t">   1081   <script la nguage="ja vascript"  type="text /javascrip t">
1081       window .parent.do cument.f.a ccessDenie d();   1082       window .parent.do cument.f.a ccessDenie d();
1082   </script>   1083   </script>
1083   </body>   1084   </body>
1084   </html>   1085   </html>
1085   EOF;   1086   EOF;
1086           }       1087           }    
1087     1088  
1088           //  edit post  here           1089           //  edit post  here        
1089           pr epare_to_d b($text, 1 );   1090           pr epare_to_d b($text, 1 );
1090              1091           
1091           $f db->editPo st ($post_ id, $text) ;   1092           $f db->editPo st ($post_ id, $text) ;
1092     1093  
1093           re turn <<<EO F   1094           re turn <<<EO F
1094   <html>   1095   <html>
1095   <body>   1096   <body>
1096   <script la nguage="ja vascript"  type="text /javascrip t">   1097   <script la nguage="ja vascript"  type="text /javascrip t">
1097       window .parent.do cument.f.e ditSuccess ('{$t['top ic_uri']}' );   1098       window .parent.do cument.f.e ditSuccess ('{$t['top ic_uri']}' );
1098   </script>   1099   </script>
1099   </body>   1100   </body>
1100   </html>   1101   </html>
1101   EOF;   1102   EOF;
1102     1103  
1103       }   1104       }
1104     1105  
1105       /**   1106       /**
1106        * del ete post   1107        * del ete post
1107        * @pa ram $post_ id      po st id   1108        * @pa ram $post_ id      po st id
1108        * @pa ram $topic _id     to pic id   1109        * @pa ram $topic _id     to pic id
1109        * @pa ram $forum _id     fo rum id    1110        * @pa ram $forum _id     fo rum id 
1110        */   1111        */
1111       functi on deleteP ostXML ($p ost_id, $t opic_id, $ forum_id)   1112       functi on deleteP ostXML ($p ost_id, $t opic_id, $ forum_id)
1112       {   1113       {
1113           $n o_access =  true;   1114           $n o_access =  true;
1114     1115  
1115           $f db = new D bForum ();   1116           $f db = new D bForum ();
1116     1117  
1117           $f  = $fdb->g etForumByP ostId ($po st_id);   1118           $f  = $fdb->g etForumByP ostId ($po st_id);
1118     1119  
1119           if  ($this->_ checkUserP erm ('', $ f['forum_t ype'], 'de l', $f['fo rum_id']))     1120           if  ($this->_ checkUserP erm ('', $ f['forum_t ype'], 'de l', $f['fo rum_id']))  
1120                $no_acce ss = false ;   1121                $no_acce ss = false ;
1121           if  ($no_acce ss && $fdb ->getPostU ser((int)$ post_id) = = $this->_ getLoginUs erName())   1122           if  ($no_acce ss && $fdb ->getPostU ser((int)$ post_id) = = $this->_ getLoginUs erName())
1122                if ($thi s->_checkU serPerm (' ', 'own',  'del', $f[ 'forum_id' ]))    1123                if ($thi s->_checkU serPerm (' ', 'own',  'del', $f[ 'forum_id' ])) 
1123                    $no_ access = f alse;   1124                    $no_ access = f alse;
1124     1125  
1125           if  ($no_acce ss)   1126           if  ($no_acce ss)
1126           {   1127           {
1127                return < <<EOF   1128                return < <<EOF
1128   <html>   1129   <html>
1129   <body>   1130   <body>
1130   <script la nguage="ja vascript"  type="text /javascrip t">   1131   <script la nguage="ja vascript"  type="text /javascrip t">
1131       window .parent.do cument.f.a ccessDenie d();   1132       window .parent.do cument.f.a ccessDenie d();
1132   </script>   1133   </script>
1133   </body>   1134   </body>
1134   </html>   1135   </html>
1135   EOF;   1136   EOF;
1136           }       1137           }    
1137          1138       
1138           //  delete po st here   1139           //  delete po st here
1139     1140  
1140           $f db->delete Post ($pos t_id);   1141           $f db->delete Post ($pos t_id);
1141     1142  
1142            $ ex i sts   =   $fdb->getT opic   ($topic_id )   ?   1   :   0 ;   1143            $ aTop i c   =   $fdb->getT opic   ($topic_id )
;
    1144           $e xists = $a Topic ? 1  : 0;
1143     1145  
1144           re turn <<<EO F   1146           re turn <<<EO F
1145   <html>   1147   <html>
1146   <body>   1148   <body>
1147   <script la nguage="ja vascript"  type="text /javascrip t">   1149   <script la nguage="ja vascript"  type="text /javascrip t">
1148        window.par ent.docume nt.f.delet eSuccess(' {$f['forum _
i d ']}',   '{$
topic_
i d }',   {$exists}) ;
  1150        window.par ent.docume nt.f.delet eSuccess(' {$f['forum _ ur i
']}',   '{$ aTopic[' topic_ ur i '] }',   {$exists}) ;
1149   </script>   1151   </script>
1150   </body>   1152   </body>
1151   </html>   1153   </html>
1152   EOF;   1154   EOF;
1153     1155  
1154       }   1156       }
1155     1157  
1156       /**   1158       /**
1157        * pos t new topi c   1159        * pos t new topi c
1158        * @pa ram $p     _post arra y   1160        * @pa ram $p     _post arra y
1159        */   1161        */
1160       functi on postNew TopicXML ( $p)   1162       functi on postNew TopicXML ( $p)
1161       {   1163       {
1162           $f db = new D bForum ();   1164           $f db = new D bForum ();
1163     1165  
1164           $f  = $fdb->g etForum (( int)$p['fo rum_id']);   1166           $f  = $fdb->g etForum (( int)$p['fo rum_id']);
1165     1167  
1166           if  (!$this-> _checkUser Perm ('',  $f['forum_ type'], 'p ost', (int )$p['forum _id']))    1168           if  (!$this-> _checkUser Perm ('',  $f['forum_ type'], 'p ost', (int )$p['forum _id'])) 
1167           {   1169           {
1168                return < <<EOF   1170                return < <<EOF
1169   <html>   1171   <html>
1170   <body>   1172   <body>
1171   <script la nguage="ja vascript"  type="text /javascrip t">   1173   <script la nguage="ja vascript"  type="text /javascrip t">
1172     1174  
1173       if (wi ndow.paren t.document .getElemen tById('tin yEditor'))   1175       if (wi ndow.paren t.document .getElemen tById('tin yEditor'))
1174           wi ndow.paren t.tinyMCE. execComman d('mceRemo veControl' , false, ' tinyEditor ');   1176           wi ndow.paren t.tinyMCE. execComman d('mceRemo veControl' , false, ' tinyEditor ');
1175     1177  
1176       window .parent.do cument.f.a ccessDenie d();   1178       window .parent.do cument.f.a ccessDenie d();
1177     1179  
1178   </script>   1180   </script>
1179   </body>   1181   </body>
1180   </html>   1182   </html>
1181   EOF;   1183   EOF;
1182           }           1184           }        
1183     1185  
1184           if  ($p['topi c_sticky']  == 'on' & & !$this-> _checkUser Perm ('',  '', 'stick y', (int)$ p['forum_i d']))    1186           if  ($p['topi c_sticky']  == 'on' & & !$this-> _checkUser Perm ('',  '', 'stick y', (int)$ p['forum_i d'])) 
1185           {   1187           {
1186                return < <<EOF   1188                return < <<EOF
1187   <html>   1189   <html>
1188   <body>   1190   <body>
1189   <script la nguage="ja vascript"  type="text /javascrip t">   1191   <script la nguage="ja vascript"  type="text /javascrip t">
1190     1192  
1191       if (wi ndow.paren t.document .getElemen tById('tin yEditor'))   1193       if (wi ndow.paren t.document .getElemen tById('tin yEditor'))
1192           wi ndow.paren t.tinyMCE. execComman d('mceRemo veControl' , false, ' tinyEditor ');   1194           wi ndow.paren t.tinyMCE. execComman d('mceRemo veControl' , false, ' tinyEditor ');
1193     1195  
1194       window .parent.do cument.f.a ccessDenie d();   1196       window .parent.do cument.f.a ccessDenie d();
1195     1197  
1196   </script>   1198   </script>
1197   </body>   1199   </body>
1198   </html>   1200   </html>
1199   EOF;   1201   EOF;
1200           }           1202           }        
1201     1203  
1202     1204  
1203           //  post mesa ge here   1205           //  post mesa ge here
1204     1206  
1205           $u ser = $thi s->_getLog inUserName  ();   1207           $u ser = $thi s->_getLog inUserName  ();
1206              1208           
1207           pr epare_to_d b($p['topi c_subject' ], 0);   1209           pr epare_to_d b($p['topi c_subject' ], 0);
1208           pr epare_to_d b($p['topi c_text'],  1);   1210           pr epare_to_d b($p['topi c_text'],  1);
1209     1211  
1210           $t opic_uri =  $this->ur iGenerate  ($p['topic _subject'] , TF_FORUM _TOPIC, 't opic_uri') ;   1212           $t opic_uri =  $this->ur iGenerate  ($p['topic _subject'] , TF_FORUM _TOPIC, 't opic_uri') ;
1211           $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);   1213           $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);
1212     1214  
1213           re turn <<<EO F   1215           re turn <<<EO F
1214   <html>   1216   <html>
1215   <body>   1217   <body>
1216   <script la nguage="ja vascript"  type="text /javascrip t">   1218   <script la nguage="ja vascript"  type="text /javascrip t">
1217     1219  
1218       if (wi ndow.paren t.document .getElemen tById('tin yEditor'))   1220       if (wi ndow.paren t.document .getElemen tById('tin yEditor'))
1219           wi ndow.paren t.tinyMCE. execComman d('mceRemo veControl' , false, ' tinyEditor ');   1221           wi ndow.paren t.tinyMCE. execComman d('mceRemo veControl' , false, ' tinyEditor ');
1220     1222  
1221       window .parent.do cument.f.p ostSuccess ('{$f['for um_uri']}' );   1223       window .parent.do cument.f.p ostSuccess ('{$f['for um_uri']}' );
1222     1224  
1223   </script>   1225   </script>
1224   </body>   1226   </body>
1225   </html>   1227   </html>
1226   EOF;   1228   EOF;
1227     1229  
1228       }   1230       }
1229     1231  
1230       functi on isAdmin  ()   1232       functi on isAdmin  ()
1231       {   1233       {
1232           $a  = $this-> _getUserIn fo ($this- >getLoginU ser());   1234           $a  = $this-> _getUserIn fo ($this- >getLoginU ser());
1233           re turn $a['a dmin'];   1235           re turn $a['a dmin'];
1234       }   1236       }
1235          1237       
1236       /**   1238       /**
1237        * ret urns logge d in user   1239        * ret urns logge d in user
1238        */   1240        */
1239       functi on getLogi nUser ()   1241       functi on getLogi nUser ()
1240       {   1242       {
1241           re turn $this ->_getLogi nUser();   1243           re turn $this ->_getLogi nUser();
1242       }   1244       }
1243     1245  
1244       /**   1246       /**
1245        * upd ates curre nt user la st activit y time   1247        * upd ates curre nt user la st activit y time
1246        */    1248        */ 
1247       functi on updateC urrentUser Activity ( )   1249       functi on updateC urrentUser Activity ( )
1248       {   1250       {
1249           $u  = $this-> getLoginUs er ();   1251           $u  = $this-> getLoginUs er ();
1250           if  (!$u) ret urn;            1252           if  (!$u) ret urn;         
1251     1253  
1252           $d b = new Db Forum ();   1254           $d b = new Db Forum ();
1253           $d b->updateU serActivit y ($u);   1255           $d b->updateU serActivit y ($u);
1254       }   1256       }
1255     1257  
1256       functi on logout  ()   1258       functi on logout  ()
1257       {   1259       {
1258           $u  = $this-> getLoginUs er ();   1260           $u  = $this-> getLoginUs er ();
1259           if  (!$u) ret urn '<ret> 0</ret>';   1261           if  (!$u) ret urn '<ret> 0</ret>';
1260     1262  
1261           se tcookie('o rca_pwd',  'orca_pwd' , time() -  86400);   1263           se tcookie('o rca_pwd',  'orca_pwd' , time() -  86400);
1262           se tcookie('o rca_user',  'orca_use r', time()  - 86400);   1264           se tcookie('o rca_user',  'orca_use r', time()  - 86400);
1263           se tcookie('t rack_topic s', 'track _topics',  time() - 8 6400);   1265           se tcookie('t rack_topic s', 'track _topics',  time() - 8 6400);
1264     1266  
1265           $d b = new Db Forum ();   1267           $d b = new Db Forum ();
1266           $d b->updateU serLastAct ivity ($u) ;   1268           $d b->updateU serLastAct ivity ($u) ;
1267     1269  
1268           re turn '<ret >1</ret>';   1270           re turn '<ret >1</ret>';
1269       }   1271       }
1270     1272  
1271       /**   1273       /**
1272        * pos t voting   1274        * pos t voting
1273        *  @p aram $post _id post i d   1275        *  @p aram $post _id post i d
1274        *  @p aram $vote     vote ( 1|-1)   1276        *  @p aram $vote     vote ( 1|-1)
1275        */    1277        */ 
1276       functi on votePos t ($post_i d, $vote)   1278       functi on votePos t ($post_i d, $vote)
1277       {   1279       {
1278           $u  = $this-> getLoginUs er ();   1280           $u  = $this-> getLoginUs er ();
1279           if  (!$u) ret urn '<ret> 0</ret>';   1281           if  (!$u) ret urn '<ret> 0</ret>';
1280              1282           
1281           $d b = new Db Forum ();   1283           $d b = new Db Forum ();
1282              1284           
1283           if  (!$db->in sertVote ( (int)$post _id, $u, $ vote))   1285           if  (!$db->in sertVote ( (int)$post _id, $u, $ vote))
1284                return ' <ret>0</re t>';   1286                return ' <ret>0</re t>';
1285                   1287                
1286           re turn '<ret >1</ret>';   1288           re turn '<ret >1</ret>';
1287       }   1289       }
1288     1290  
1289       /**   1291       /**
1290        * rep ort post   1292        * rep ort post
1291        *  @p aram $post _id post i d   1293        *  @p aram $post _id post i d
1292        */    1294        */ 
1293       functi on report  ($post_id)   1295       functi on report  ($post_id)
1294       {   1296       {
1295           if  (!$post_i d) return  '<ret>0</r et>';   1297           if  (!$post_i d) return  '<ret>0</r et>';
1296     1298  
1297           $u  = $this-> getLoginUs er ();   1299           $u  = $this-> getLoginUs er ();
1298           if  (!$u) ret urn '<ret> 0</ret>';   1300           if  (!$u) ret urn '<ret> 0</ret>';
1299              1301           
1300           $d b = new Db Forum ();   1302           $d b = new Db Forum ();
1301              1303           
1302           if  (!$db->re port ((int )$post_id,  $u))   1304           if  (!$db->re port ((int )$post_id,  $u))
1303                return ' <ret>0</re t>';   1305                return ' <ret>0</re t>';
1304                   1306                
1305           re turn '<ret >1</ret>';   1307           re turn '<ret >1</ret>';
1306       }   1308       }
1307     1309  
1308       /**   1310       /**
1309        * fla g/unflag t opic   1311        * fla g/unflag t opic
1310        *  @p aram $topi c_id    to pic id   1312        *  @p aram $topi c_id    to pic id
1311        */    1313        */ 
1312       functi on flag ($ topic_id)   1314       functi on flag ($ topic_id)
1313       {   1315       {
1314           if  (!$topic_ id) return  '<ret>0</ ret>';   1316           if  (!$topic_ id) return  '<ret>0</ ret>';
1315     1317  
1316           $u  = $this-> getLoginUs er ();   1318           $u  = $this-> getLoginUs er ();
1317           if  (!$u) ret urn '<ret> 0</ret>';         1319           if  (!$u) ret urn '<ret> 0</ret>';      
1318              1320           
1319           $d b = new Db Forum ();   1321           $d b = new Db Forum ();
1320     1322  
1321           if  ($db->isF lagged ((i nt)$topic_ id, $u))   1323           if  ($db->isF lagged ((i nt)$topic_ id, $u))
1322           {   1324           {
1323                if (!$db ->unflag ( (int)$topi c_id, $u))   1325                if (!$db ->unflag ( (int)$topi c_id, $u))
1324                    retu rn '<ret>0 </ret>';   1326                    retu rn '<ret>0 </ret>';
1325                return ' <ret>-1</r et>';   1327                return ' <ret>-1</r et>';
1326           }   1328           }
1327              1329           
1328           if  (!$db->fl ag ((int)$ topic_id,  $u))   1330           if  (!$db->fl ag ((int)$ topic_id,  $u))
1329                return ' <ret>0</re t>';   1331                return ' <ret>0</re t>';
1330     1332  
1331           re turn '<ret >1</ret>';   1333           re turn '<ret >1</ret>';
1332       }   1334       }
1333     1335  
1334       /**   1336       /**
1335        * for um rss fee d, 10 late st topics  in the for um   1337        * for um rss fee d, 10 late st topics  in the for um
1336        *  @p aram $foru m_id    fo rum id       1338        *  @p aram $foru m_id    fo rum id    
1337        */    1339        */ 
1338       functi on getRssF orum ($for um_uri)   1340       functi on getRssF orum ($for um_uri)
1339       {   1341       {
1340           gl obal $gCon f;   1342           gl obal $gCon f;
1341     1343  
1342           $g Conf['topi cs_per_pag e'] = 10;   1344           $g Conf['topi cs_per_pag e'] = 10;
1343           $g Conf['date _format']  = '%a, %e  %b %Y %k:% i:%s GMT';   1345           $g Conf['date _format']  = '%a, %e  %b %Y %k:% i:%s GMT';
1344     1346  
1345           $f db = new D bForum ();   1347           $f db = new D bForum ();
1346     1348  
1347           $f  = $fdb->g etForumByU ri ($forum _uri);   1349           $f  = $fdb->g etForumByU ri ($forum _uri);
1348           $f orum_id =  $f['forum_ id'];   1350           $f orum_id =  $f['forum_ id'];
1349     1351  
1350           if  (!$f) exi t;   1352           if  (!$f) exi t;
1351     1353  
1352           $a  = $fdb->g etTopics ( $forum_id,  0);   1354           $a  = $fdb->g etTopics ( $forum_id,  0);
1353     1355  
1354           re set ($a);   1356           re set ($a);
1355           $i tems = '';   1357           $i tems = '';
1356           $l astBuildDa te = '';   1358           $l astBuildDa te = '';
1357           wh ile ( list  (,$r) = e ach ($a) )   1359           wh ile ( list  (,$r) = e ach ($a) )
1358           {   1360           {
1359                $lp = $f db->getTop icPost($r[ 'topic_id' ], 'last') ;   1361                $lp = $f db->getTop icPost($r[ 'topic_id' ], 'last') ;
1360                $td = st rip_tags($ fdb->getTo picDesc($r ['topic_id ']));   1362                $td = st rip_tags($ fdb->getTo picDesc($r ['topic_id ']));
1361     1363  
1362                if (!$la stBuildDat e)   1364                if (!$la stBuildDat e)
1363                    $las tBuildDate  = $lp['wh en'];   1365                    $las tBuildDate  = $lp['wh en'];
1364     1366  
1365                $items . = "   1367                $items . = "
1366                <item>   1368                <item>
1367                    <tit le>{$r['to pic_title' ]}</title>   1369                    <tit le>{$r['to pic_title' ]}</title>
1368                    <lin k>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</li nk>   1370                    <lin k>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</li nk>
1369                    <des cription>$ td</descri ption>   1371                    <des cription>$ td</descri ption>
1370                    <pub Date>{$lp[ 'when']}</ pubDate>   1372                    <pub Date>{$lp[ 'when']}</ pubDate>
1371                    <gui d>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</gu id>   1373                    <gui d>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</gu id>
1372                </item>" ;   1374                </item>" ;
1373           }           1375           }        
1374     1376  
1375           re turn "   1377           re turn "
1376   <rss versi on=\"2.0\" >   1378   <rss versi on=\"2.0\" >
1377       <chann el>   1379       <chann el>
1378           <t itle>{$f[' forum_titl e']}</titl e>   1380           <t itle>{$f[' forum_titl e']}</titl e>
1379           <l ink>" . $g Conf['url' ]['base']  . sprintf( $gConf['re write']['f orum'], $f ['forum_ur i'], 0) .  "</link>   1381           <l ink>" . $g Conf['url' ]['base']  . sprintf( $gConf['re write']['f orum'], $f ['forum_ur i'], 0) .  "</link>
1380           <d escription >{$f['foru m_desc']}< /descripti on>   1382           <d escription >{$f['foru m_desc']}< /descripti on>
1381           <l astBuildDa te>$lastBu ildDate</l astBuildDa te>      1383           <l astBuildDa te>$lastBu ildDate</l astBuildDa te>   
1382           $i tems   1384           $i tems
1383       </chan nel>   1385       </chan nel>
1384   </rss>";   1386   </rss>";
1385       }   1387       }
1386     1388  
1387     1389  
1388     1390  
1389       /**   1391       /**
1390        * top ic rss fee d, 10 late st posts i n the topi c   1392        * top ic rss fee d, 10 late st posts i n the topi c
1391        *  @p aram $foru m_id    fo rum id       1393        *  @p aram $foru m_id    fo rum id    
1392        */    1394        */ 
1393       functi on getRssT opic ($top ic_uri)   1395       functi on getRssT opic ($top ic_uri)
1394       {   1396       {
1395           gl obal $gCon f;   1397           gl obal $gCon f;
1396              1398           
1397           $g Conf['topi cs_per_pag e'] = 10;   1399           $g Conf['topi cs_per_pag e'] = 10;
1398           $g Conf['date _format']  = '%a, %e  %b %Y %k:% i:%s GMT';   1400           $g Conf['date _format']  = '%a, %e  %b %Y %k:% i:%s GMT';
1399     1401  
1400           $f db = new D bForum ();   1402           $f db = new D bForum ();
1401     1403  
1402           $t  = $fdb->g etTopicByU ri($topic_ uri);   1404           $t  = $fdb->g etTopicByU ri($topic_ uri);
1403           $t opic_id =  (int)$t['t opic_id'];   1405           $t opic_id =  (int)$t['t opic_id'];
1404     1406  
1405           if  (!$t) exi t;   1407           if  (!$t) exi t;
1406     1408  
1407           $a  = $fdb->g etPosts ($ topic_id,  0);   1409           $a  = $fdb->g etPosts ($ topic_id,  0);
1408     1410  
1409           re set ($a);   1411           re set ($a);
1410           $i tems = '';   1412           $i tems = '';
1411           $l astBuildDa te = '';   1413           $l astBuildDa te = '';
1412           wh ile ( list  (,$r) = e ach ($a) )   1414           wh ile ( list  (,$r) = e ach ($a) )
1413           {   1415           {
1414                $lp = $f db->getTop icPost($r[ 'topic_id' ], 'last') ;   1416                $lp = $f db->getTop icPost($r[ 'topic_id' ], 'last') ;
1415                $td = st rip_tags(s ubstr($r[' post_text' ], 0, 256) );   1417                $td = st rip_tags(s ubstr($r[' post_text' ], 0, 256) );
1416                if (strl en($td) ==  256) $td  .= '[...]' ;   1418                if (strl en($td) ==  256) $td  .= '[...]' ;
1417                $tt = su bstr($td,  0, 32);   1419                $tt = su bstr($td,  0, 32);
1418                   1420                
1419                    $las tBuildDate  = $lp['wh en'];   1421                    $las tBuildDate  = $lp['wh en'];
1420     1422  
1421                $items . = "   1423                $items . = "
1422                <item>   1424                <item>
1423                    <tit le>{$tt}</ title>   1425                    <tit le>{$tt}</ title>
1424                    <lin k>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $t[' topic_uri' ]) . "</li nk>   1426                    <lin k>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $t[' topic_uri' ]) . "</li nk>
1425                    <des cription>$ td</descri ption>   1427                    <des cription>$ td</descri ption>
1426                    <pub Date>{$lp[ 'when']}</ pubDate>   1428                    <pub Date>{$lp[ 'when']}</ pubDate>
1427                    <gui d>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $t[' topic_uri' ]) . "#{$r ['post_id' ]}</guid>   1429                    <gui d>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $t[' topic_uri' ]) . "#{$r ['post_id' ]}</guid>
1428                </item>" ;   1430                </item>" ;
1429           }           1431           }        
1430                   1432                
1431           re turn "   1433           re turn "
1432   <rss versi on=\"2.0\" >   1434   <rss versi on=\"2.0\" >
1433       <chann el>   1435       <chann el>
1434           <t itle>{$t[' topic_titl e']}</titl e>   1436           <t itle>{$t[' topic_titl e']}</titl e>
1435           <l ink>" . $g Conf['url' ]['base']  . sprintf( $gConf['re write']['t opic'], $t ['topic_ur i']) . "</ link>   1437           <l ink>" . $g Conf['url' ]['base']  . sprintf( $gConf['re write']['t opic'], $t ['topic_ur i']) . "</ link>
1436           <d escription >{$t['topi c_title']} </descript ion>   1438           <d escription >{$t['topi c_title']} </descript ion>
1437           <l astBuildDa te>$lastBu ildDate</l astBuildDa te>      1439           <l astBuildDa te>$lastBu ildDate</l astBuildDa te>   
1438           $i tems   1440           $i tems
1439       </chan nel>   1441       </chan nel>
1440   </rss>";   1442   </rss>";
1441       }   1443       }
1442              1444           
1443       /**   1445       /**
1444        * use r posts rs s feed, 10  latest po sts of spe cified use r   1446        * use r posts rs s feed, 10  latest po sts of spe cified use r
1445        *  @p aram $user     userna me    1447        *  @p aram $user     userna me 
1446        *  @p aram $sort     sort :  rnd | top  | latest  - default   1448        *  @p aram $sort     sort :  rnd | top  | latest  - default
1447        */    1449        */ 
1448       functi on getRssU ser ($user , $sort)   1450       functi on getRssU ser ($user , $sort)
1449       {   1451       {
1450           gl obal $gCon f;   1452           gl obal $gCon f;
1451     1453  
1452           $g Conf['topi cs_per_pag e'] = 10;   1454           $g Conf['topi cs_per_pag e'] = 10;
1453           $g Conf['date _format']  = '%a, %e  %b %Y %k:% i:%s GMT';   1455           $g Conf['date _format']  = '%a, %e  %b %Y %k:% i:%s GMT';
1454     1456  
1455           $f db = new D bForum ();          1457           $f db = new D bForum ();       
1456              1458           
1457           $a  = $fdb->g etUserPost sList($use r, $sort,  $gConf['to pics_per_p age']);   1459           $a  = $fdb->g etUserPost sList($use r, $sort,  $gConf['to pics_per_p age']);
1458     1460  
1459           re set ($a);   1461           re set ($a);
1460           $i tems = '';   1462           $i tems = '';
1461           $l astBuildDa te = '';   1463           $l astBuildDa te = '';
1462           wh ile ( list  (,$r) = e ach ($a) )   1464           wh ile ( list  (,$r) = e ach ($a) )
1463           {   1465           {
1464                if (!$la stBuildDat e)   1466                if (!$la stBuildDat e)
1465                    $las tBuildDate  = $r['whe n'];   1467                    $las tBuildDate  = $r['whe n'];
1466     1468  
1467                $td = st rip_tags($ r['post_te xt']);   1469                $td = st rip_tags($ r['post_te xt']);
1468                if (strl en($td) ==  256) $td  .= '[...]' ;   1470                if (strl en($td) ==  256) $td  .= '[...]' ;
1469                   1471                
1470                $items . = "   1472                $items . = "
1471                <item>   1473                <item>
1472                    <tit le><![CDAT A[{$r['top ic_title'] }]]></titl e>   1474                    <tit le><![CDAT A[{$r['top ic_title'] }]]></titl e>
1473                    <lin k>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</li nk>   1475                    <lin k>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</li nk>
1474                    <des cription>< ![CDATA[{$ r['user']} : {$td}]]> </descript ion>   1476                    <des cription>< ![CDATA[{$ r['user']} : {$td}]]> </descript ion>
1475                    <pub Date>{$r[' when']}</p ubDate>   1477                    <pub Date>{$r[' when']}</p ubDate>
1476                    <gui d>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</gu id>   1478                    <gui d>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</gu id>
1477                </item>" ;   1479                </item>" ;
1478           }           1480           }        
1479              1481           
1480           if  ($sort ==  'rnd' ||  $sort == ' top') $las tBuildDate  = '';   1482           if  ($sort ==  'rnd' ||  $sort == ' top') $las tBuildDate  = '';
1481     1483  
1482           $s Title = sp rintf("[L[ %s's forum  posts]]",  $user);   1484           $s Title = sp rintf("[L[ %s's forum  posts]]",  $user);
1483           re turn "   1485           re turn "
1484   <rss versi on=\"2.0\" >   1486   <rss versi on=\"2.0\" >
1485       <chann el>   1487       <chann el>
1486           <t itle>$sTit le</title>   1488           <t itle>$sTit le</title>
1487           <l ink>{$gCon f['url'][' base']}</l ink>   1489           <l ink>{$gCon f['url'][' base']}</l ink>
1488           <d escription >$sTitle</ descriptio n>   1490           <d escription >$sTitle</ descriptio n>
1489           <l astBuildDa te>$lastBu ildDate</l astBuildDa te>      1491           <l astBuildDa te>$lastBu ildDate</l astBuildDa te>   
1490           $i tems   1492           $i tems
1491       </chan nel>   1493       </chan nel>
1492   </rss>";   1494   </rss>";
1493       }   1495       }
1494     1496  
1495       /**   1497       /**
1496        * all  posts rss  feed, 10  latest pos ts   1498        * all  posts rss  feed, 10  latest pos ts
1497        *  @p aram $user     userna me    1499        *  @p aram $user     userna me 
1498        *  @p aram $sort     sort :  rnd | top  | latest  - default   1500        *  @p aram $sort     sort :  rnd | top  | latest  - default
1499        */    1501        */ 
1500       functi on getRssA ll ($sort)   1502       functi on getRssA ll ($sort)
1501       {   1503       {
1502           gl obal $gCon f;   1504           gl obal $gCon f;
1503     1505  
1504           $g Conf['topi cs_per_pag e'] = 10;   1506           $g Conf['topi cs_per_pag e'] = 10;
1505           $g Conf['date _format']  = '%a, %e  %b %Y %k:% i:%s GMT';   1507           $g Conf['date _format']  = '%a, %e  %b %Y %k:% i:%s GMT';
1506     1508  
1507           $f db = new D bForum ();          1509           $f db = new D bForum ();       
1508              1510           
1509           $a  = $fdb->g etAllPosts List($sort , $gConf[' topics_per _page']);   1511           $a  = $fdb->g etAllPosts List($sort , $gConf[' topics_per _page']);
1510     1512  
1511           re set ($a);   1513           re set ($a);
1512           $i tems = '';   1514           $i tems = '';
1513           $l astBuildDa te = '';   1515           $l astBuildDa te = '';
1514           wh ile ( list  (,$r) = e ach ($a) )   1516           wh ile ( list  (,$r) = e ach ($a) )
1515           {   1517           {
1516                if (!$la stBuildDat e)   1518                if (!$la stBuildDat e)
1517                    $las tBuildDate  = $r['whe n'];   1519                    $las tBuildDate  = $r['whe n'];
1518     1520  
1519                $td = st rip_tags($ r['post_te xt']);   1521                $td = st rip_tags($ r['post_te xt']);
1520                if (strl en($td) ==  256) $td  .= '[...]' ;   1522                if (strl en($td) ==  256) $td  .= '[...]' ;
1521                   1523                
1522                $items . = "   1524                $items . = "
1523                <item>   1525                <item>
1524                    <tit le><![CDAT A[{$r['top ic_title'] }]]></titl e>   1526                    <tit le><![CDAT A[{$r['top ic_title'] }]]></titl e>
1525                    <lin k>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</li nk>   1527                    <lin k>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</li nk>
1526                    <des cription>< ![CDATA[{$ r['user']} : {$td}]]> </descript ion>   1528                    <des cription>< ![CDATA[{$ r['user']} : {$td}]]> </descript ion>
1527                    <pub Date>{$r[' when']}</p ubDate>   1529                    <pub Date>{$r[' when']}</p ubDate>
1528                    <gui d>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</gu id>   1530                    <gui d>" . $gCo nf['url'][ 'base'] .  sprintf($g Conf['rewr ite']['top ic'], $r[' topic_uri' ]) . "</gu id>
1529                </item>" ;   1531                </item>" ;
1530           }           1532           }        
1531              1533           
1532           if  ($sort ==  'rnd' ||  $sort == ' top') $las tBuildDate  = '';   1534           if  ($sort ==  'rnd' ||  $sort == ' top') $las tBuildDate  = '';
1533     1535  
1534           re turn <<<EO F   1536           re turn <<<EO F
1535   <rss versi on="2.0">   1537   <rss versi on="2.0">
1536       <chann el>   1538       <chann el>
1537           <t itle>[L[Fo rum Posts] ]</title>   1539           <t itle>[L[Fo rum Posts] ]</title>
1538           <l ink>{$gCon f['url'][' base']}</l ink>   1540           <l ink>{$gCon f['url'][' base']}</l ink>
1539           <d escription >[L[Forum  Posts]]</d escription >   1541           <d escription >[L[Forum  Posts]]</d escription >
1540           <l astBuildDa te>$lastBu ildDate</l astBuildDa te>   1542           <l astBuildDa te>$lastBu ildDate</l astBuildDa te>
1541           $i tems   1543           $i tems
1542       </chan nel>   1544       </chan nel>
1543   </rss>   1545   </rss>
1544   EOF;   1546   EOF;
1545       }   1547       }
1546              1548           
1547     1549  
1548     1550  
1549       /**    1551       /** 
1550        * pro file xml   1552        * pro file xml
1551        * @pa ram   $u   username   1553        * @pa ram   $u   username
1552        * @pa ram   $wp  return who le page XM L   1554        * @pa ram   $wp  return who le page XM L
1553        */    1555        */ 
1554       functi on showPro file ($u,  $wp)   1556       functi on showPro file ($u,  $wp)
1555       {   1557       {
1556           $f db = new D bForum ();   1558           $f db = new D bForum ();
1557     1559  
1558           $a  = $this-> _getUserIn fo ($u);   1560           $a  = $this-> _getUserIn fo ($u);
1559           $a s = $fdb-> getUserSta t ($u);   1561           $a s = $fdb-> getUserSta t ($u);
1560     1562  
1561           $a ['username '] = $u;   1563           $a ['username '] = $u;
1562           $a ['posts']  = (int)$as ['posts'];   1564           $a ['posts']  = (int)$as ['posts'];
1563           $a ['user_las t_post'] =  $as['user _last_post '];   1565           $a ['user_las t_post'] =  $as['user _last_post '];
1564           $a ['last_onl ine'] = $f db->getUse rLastOnlin eTime ($u) ;   1566           $a ['last_onl ine'] = $f db->getUse rLastOnlin eTime ($u) ;
1565     1567  
1566           $p  = array2x ml ($a);   1568           $p  = array2x ml ($a);
1567     1569  
1568           if  ($wp)   1570           if  ($wp)
1569           {   1571           {
1570                $li = $t his->_getL oginInfo ( );   1572                $li = $t his->_getL oginInfo ( );
1571                return $ this->addH eaderFoote r ($li, "< profile>$p </profile> ");   1573                return $ this->addH eaderFoote r ($li, "< profile>$p </profile> ");
1572           }   1574           }
1573           el se   1575           el se
1574           {   1576           {
1575                $cu = $t his->getUr lsXml ();   1577                $cu = $t his->getUr lsXml ();
1576                return " <root>$cu< profile>$p </profile> </root>";   1578                return " <root>$cu< profile>$p </profile> </root>";
1577           }           1579           }        
1578       }   1580       }
1579     1581  
1580       // pri vate funct ions   1582       // pri vate funct ions
1581     1583  
1582       functi on _getLog inInfo ($u ser = '')   1584       functi on _getLog inInfo ($u ser = '')
1583       {   1585       {
1584           if  (!strlen( $user)) $u ser = $thi s->_getLog inUserName  ();   1586           if  (!strlen( $user)) $u ser = $thi s->_getLog inUserName  ();
1585           $a  = $this-> _getUserIn fo ($user) ;          1587           $a  = $this-> _getUserIn fo ($user) ;       
1586           $a ['username '] = $user ;   1588           $a ['username '] = $user ;
1587           re turn $a;    1589           re turn $a; 
1588       }   1590       }
1589     1591  
1590       functi on _getUse rInfo ($us er)   1592       functi on _getUse rInfo ($us er)
1591       {           1593       {        
1592           gl obal $gCon f;   1594           gl obal $gCon f;
1593           $r et = array  ();   1595           $r et = array  ();
1594     1596  
1595           if  (!$user)  $user = $t his->_getL oginUser() ;   1597           if  (!$user)  $user = $t his->_getL oginUser() ;
1596           if  (!$user)  return $re t;   1598           if  (!$user)  return $re t;
1597           $a ction = 'u ser_info';   1599           $a ction = 'u ser_info';
1598           $i ntegration _file = '' ;   1600           $i ntegration _file = '' ;
1599           in clude ($gC onf['dir'] ['base'] .  'xml/url. php');   1601           in clude ($gC onf['dir'] ['base'] .  'xml/url. php');
1600           if  (!$integr ation_file ) return;   1602           if  (!$integr ation_file ) return;
1601     1603  
1602           $x ml = $this ->_read_in tegration_ file ($int egration_f ile);   1604           $x ml = $this ->_read_in tegration_ file ($int egration_f ile);
1603           if  (!$xml) r eturn;   1605           if  (!$xml) r eturn;
1604     1606  
1605           if  (((int)ph pversion() ) >= 5)           1607           if  (((int)ph pversion() ) >= 5)        
1606           {   1608           {
1607                $d = new  DomDocume nt();   1609                $d = new  DomDocume nt();
1608                       1610                    
1609                $d->load XML($xml);              1611                $d->load XML($xml);           
1610     1612  
1611                $up = $d ->getEleme ntsByTagNa me ('user_ info');   1613                $up = $d ->getEleme ntsByTagNa me ('user_ info');
1612     1614  
1613                $up = $u p->item(0) ;   1615                $up = $u p->item(0) ;
1614     1616  
1615                $n = $up ->firstChi ld;   1617                $n = $up ->firstChi ld;
1616     1618  
1617                do   1619                do
1618                {          1620                {       
1619                    if ( $n->nodeTy pe != XML_ ELEMENT_NO DE) contin ue;        1621                    if ( $n->nodeTy pe != XML_ ELEMENT_NO DE) contin ue;     
1620                    $ret [$n->nodeN ame] = $n- >textConte nt;   1622                    $ret [$n->nodeN ame] = $n- >textConte nt;
1621                }   1623                }
1622                while ($ n = $n->ne xtSibling) ;   1624                while ($ n = $n->ne xtSibling) ;
1623           }   1625           }
1624           el se   1626           el se
1625           {   1627           {
1626     1628  
1627                if (!$d  = domxml_o pen_mem($x ml)) {   1629                if (!$d  = domxml_o pen_mem($x ml)) {
1628                    $mk  = new Mist ake ();   1630                    $mk  = new Mist ake ();
1629                    $mk- >log ("For um::_getUs erInfo - c an not par se xml: $x ml");   1631                    $mk- >log ("For um::_getUs erInfo - c an not par se xml: $x ml");
1630                    $mk- >displayEr ror ("[L[S ite is una vailable]] ");   1632                    $mk- >displayEr ror ("[L[S ite is una vailable]] ");
1631                }   1633                }
1632     1634  
1633                $up = $d ->get_elem ents_by_ta gname ('us er_info');   1635                $up = $d ->get_elem ents_by_ta gname ('us er_info');
1634     1636  
1635                $up = $u p[0];   1637                $up = $u p[0];
1636                $n = $up ->first_ch ild();   1638                $n = $up ->first_ch ild();
1637     1639  
1638                do   1640                do
1639                {               1641                {            
1640                    if ( $n->node_t ype() != X ML_ELEMENT _NODE) con tinue;   1642                    if ( $n->node_t ype() != X ML_ELEMENT _NODE) con tinue;
1641                    $ret [$n->node_ name ()] =  $n->get_c ontent ();   1643                    $ret [$n->node_ name ()] =  $n->get_c ontent ();
1642                }   1644                }
1643                while ($ n = $n->ne xt_sibling ());   1645                while ($ n = $n->ne xt_sibling ());
1644           }   1646           }
1645                       1647                    
1646     1648  
1647           re turn $ret;                     1649           re turn $ret;                  
1648       }   1650       }
1649     1651  
1650       /**   1652       /**
1651        * che ck user pe rms   1653        * che ck user pe rms
1652        * @pa ram $user      userna me   1654        * @pa ram $user      userna me
1653        * @pa ram $f_typ e   forum  type priva te/public/ own   1655        * @pa ram $f_typ e   forum  type priva te/public/ own
1654        * @pa ram $a_typ e   access  type read /post/edit /del   1656        * @pa ram $a_typ e   access  type read /post/edit /del
1655        */   1657        */
1656       functi on _checkU serPerm ($ user, $f_t ype, $a_ty pe, $forum _id = 0)   1658       functi on _checkU serPerm ($ user, $f_t ype, $a_ty pe, $forum _id = 0)
1657       {   1659       {
1658           gl obal $gCon f;   1660           gl obal $gCon f;
1659     1661  
1660           if  (!$user)  $user = $t his->_getL oginUser() ;   1662           if  (!$user)  $user = $t his->_getL oginUser() ;
1661           $a ction = 'u ser_perm';   1663           $a ction = 'u ser_perm';
1662           $i ntegration _file = '' ;   1664           $i ntegration _file = '' ;
1663           in clude ($gC onf['dir'] ['base'] .  'xml/url. php');            1665           in clude ($gC onf['dir'] ['base'] .  'xml/url. php');         
1664           if  (!$integr ation_file ) return;   1666           if  (!$integr ation_file ) return;
1665     1667  
1666           $x ml = $this ->_read_in tegration_ file ($int egration_f ile);   1668           $x ml = $this ->_read_in tegration_ file ($int egration_f ile);
1667           if  (!$xml) r eturn;   1669           if  (!$xml) r eturn;
1668     1670  
1669           if  (((int)ph pversion() ) >= 5)           1671           if  (((int)ph pversion() ) >= 5)        
1670           {   1672           {
1671                $d = new  DomDocume nt();   1673                $d = new  DomDocume nt();
1672                       1674                    
1673                $d->load XML($xml);              1675                $d->load XML($xml);           
1674     1676  
1675                $up = $d ->getEleme ntsByTagNa me ('user_ perm');   1677                $up = $d ->getEleme ntsByTagNa me ('user_ perm');
1676     1678  
1677                $up = $u p->item(0) ;   1679                $up = $u p->item(0) ;
1678     1680  
1679                $n = $up ->firstChi ld;   1681                $n = $up ->firstChi ld;
1680     1682  
1681                do   1683                do
1682                {          1684                {       
1683                    if ( $n->nodeTy pe != XML_ ELEMENT_NO DE) contin ue;        1685                    if ( $n->nodeTy pe != XML_ ELEMENT_NO DE) contin ue;     
1684                    if ( $n->nodeNa me == "{$a _type}_{$f _type}") r eturn $n-> textConten t;   1686                    if ( $n->nodeNa me == "{$a _type}_{$f _type}") r eturn $n-> textConten t;
1685                }   1687                }
1686                while ($ n = $n->ne xtSibling) ;   1688                while ($ n = $n->ne xtSibling) ;
1687           }   1689           }
1688           el se   1690           el se
1689           {   1691           {
1690                   1692                
1691                if (!$d  = domxml_o pen_mem($x ml)) {   1693                if (!$d  = domxml_o pen_mem($x ml)) {
1692                    $mk  = new Mist ake ();   1694                    $mk  = new Mist ake ();
1693                    $mk- >log ("For um::_check UserPerm -  can not p arse xml :  $url");   1695                    $mk- >log ("For um::_check UserPerm -  can not p arse xml :  $url");
1694                    $mk- >displayEr ror ("[L[S ite is una vailable]] ");   1696                    $mk- >displayEr ror ("[L[S ite is una vailable]] ");
1695                }   1697                }
1696     1698  
1697                $up = $d ->get_elem ents_by_ta gname ('us er_perm');            1699                $up = $d ->get_elem ents_by_ta gname ('us er_perm');         
1698     1700  
1699                $up = $u p[0];   1701                $up = $u p[0];
1700                $n = $up ->first_ch ild();   1702                $n = $up ->first_ch ild();
1701     1703  
1702                do   1704                do
1703                {               1705                {            
1704                    if ( $n->node_t ype() != X ML_ELEMENT _NODE) con tinue;          1706                    if ( $n->node_t ype() != X ML_ELEMENT _NODE) con tinue;       
1705                    if ( $n->node_n ame () ==  "{$a_type} _{$f_type} ") return  $n->get_co ntent ();   1707                    if ( $n->node_n ame () ==  "{$a_type} _{$f_type} ") return  $n->get_co ntent ();
1706                }   1708                }
1707                while ($ n = $n->ne xt_sibling ());   1709                while ($ n = $n->ne xt_sibling ());
1708           }   1710           }
1709                       1711                    
1710     1712  
1711           re turn 0;                    1713           re turn 0;                 
1712       }   1714       }
1713     1715  
1714     1716  
1715       /**   1717       /**
1716        * ret urns logge n in user   1718        * ret urns logge n in user
1717        */   1719        */
1718       functi on _getLog inUserName  ()   1720       functi on _getLog inUserName  ()
1719       {   1721       {
1720           re turn $this ->_getLogi nUser();   1722           re turn $this ->_getLogi nUser();
1721       }   1723       }
1722     1724  
1723       /**   1725       /**
1724        * ret urns logge d in user   1726        * ret urns logge d in user
1725        */   1727        */
1726       functi on _getLog inUser ()   1728       functi on _getLog inUser ()
1727       {      1729       {   
1728           gl obal $gCon f;   1730           gl obal $gCon f;
1729     1731  
1730           $a ction = 'l ogin_user' ;   1732           $a ction = 'l ogin_user' ;
1731           $i ntegration _file = '' ;   1733           $i ntegration _file = '' ;
1732           in clude ($gC onf['dir'] ['base'] .  'xml/url. php');   1734           in clude ($gC onf['dir'] ['base'] .  'xml/url. php');
1733           if  (!$integr ation_file ) return;   1735           if  (!$integr ation_file ) return;
1734     1736  
1735           $x ml = $this ->_read_in tegration_ file ($int egration_f ile);   1737           $x ml = $this ->_read_in tegration_ file ($int egration_f ile);
1736              1738           
1737           if  (((int)ph pversion() ) >= 5)           1739           if  (((int)ph pversion() ) >= 5)        
1738           {   1740           {
1739                $d = new  DomDocume nt();   1741                $d = new  DomDocume nt();
1740     1742  
1741                $d->load XML($xml);              1743                $d->load XML($xml);           
1742     1744  
1743                $up = $d ->getEleme ntsByTagNa me ('login _user');   1745                $up = $d ->getEleme ntsByTagNa me ('login _user');
1744     1746  
1745                $up = $u p->item(0) ;   1747                $up = $u p->item(0) ;
1746     1748  
1747                return $ up->textCo ntent;                1749                return $ up->textCo ntent;             
1748           }   1750           }
1749           el se    1751           el se 
1750           {   1752           {
1751                if (!$d  = @domxml_ open_mem($ xml)) {   1753                if (!$d  = @domxml_ open_mem($ xml)) {
1752                    $mk  = new Mist ake ();   1754                    $mk  = new Mist ake ();
1753                    $mk- >log ("For um::_getLo ginUser -  can not pa rse xml :  $url");   1755                    $mk- >log ("For um::_getLo ginUser -  can not pa rse xml :  $url");
1754                    $mk- >displayEr ror ("[L[S ite is una vailable]] ");   1756                    $mk- >displayEr ror ("[L[S ite is una vailable]] ");
1755                }   1757                }
1756          1758       
1757                $n = $d- >get_eleme nts_by_tag name ('log in_user');   1759                $n = $d- >get_eleme nts_by_tag name ('log in_user');
1758                $n = $n[ 0];        1760                $n = $n[ 0];     
1759     1761  
1760                return $ n->get_con tent ();   1762                return $ n->get_con tent ();
1761           }           1763           }        
1762       }   1764       }
1763     1765  
1764          1766       
1765       functi on _read_i ntegration _file ($in tegration_ file)   1767       functi on _read_i ntegration _file ($in tegration_ file)
1766       {   1768       {
1767           gl obal $gCon f;   1769           gl obal $gCon f;
1768     1770  
1769           if  ('url' ==  $gConf['i ntegration '])   1771           if  ('url' ==  $gConf['i ntegration '])
1770           {   1772           {
1771                if (func tion_exist s('curl_in it'))   1773                if (func tion_exist s('curl_in it'))
1772                {   1774                {
1773                    $cur l = curl_i nit();   1775                    $cur l = curl_i nit();
1774     1776  
1775                    curl _setopt($c url, CURLO PT_URL, $i ntegration _file);   1777                    curl _setopt($c url, CURLO PT_URL, $i ntegration _file);
1776                    curl _setopt($c url, CURLO PT_RETURNT RANSFER, t rue);   1778                    curl _setopt($c url, CURLO PT_RETURNT RANSFER, t rue);
1777                    curl _setopt($c url, CURLO PT_HEADER,  false);   1779                    curl _setopt($c url, CURLO PT_HEADER,  false);
1778     1780  
1779                    $xml  = curl_ex ec($curl);   1781                    $xml  = curl_ex ec($curl);
1780     1782  
1781                    curl _close($cu rl);   1783                    curl _close($cu rl);
1782     1784  
1783                    if ( true === $ xml) $xml  = '';               1785                    if ( true === $ xml) $xml  = '';            
1784                }                1786                }             
1785                elseif ( $h = @fope n ($integr ation_file , "r"))   1787                elseif ( $h = @fope n ($integr ation_file , "r"))
1786                {   1788                {
1787                    $xml  = '';   1789                    $xml  = '';
1788                    whil e (!feof($ h))    1790                    whil e (!feof($ h)) 
1789                                 {   1791                                 {
1790                         $xml .= fr ead($h, 81 92);   1792                         $xml .= fr ead($h, 81 92);
1791                    }   1793                    }
1792                    fclo se($h);   1794                    fclo se($h);
1793                }   1795                }
1794                else   1796                else
1795                {               1797                {            
1796                    $mk  = new Mist ake ();   1798                    $mk  = new Mist ake ();
1797                    $mk- >log ("For um::_read_ integratio n_file - c an not ope n $integra tion_file  for readin g");   1799                    $mk- >log ("For um::_read_ integratio n_file - c an not ope n $integra tion_file  for readin g");
1798                    $mk- >displayEr ror ("[L[S ite is una vailable]] ");   1800                    $mk- >displayEr ror ("[L[S ite is una vailable]] ");
1799                }   1801                }
1800     1802  
1801                return $ xml;   1803                return $ xml;
1802           }   1804           }
1803           el se   1805           el se
1804           {   1806           {
1805                $orca_in tegration_ xml = '';   1807                $orca_in tegration_ xml = '';
1806                $orca_in tegration_ vars = $in tegration_ file['vars '];   1808                $orca_in tegration_ vars = $in tegration_ file['vars '];
1807                include  ($integrat ion_file[' file']);   1809                include  ($integrat ion_file[' file']);
1808                return $ orca_integ ration_xml ;   1810                return $ orca_integ ration_xml ;
1809           }   1811           }
1810              1812           
1811       }   1813       }
1812     1814  
1813       functi on _format _when ($iS ec)   1815       functi on _format _when ($iS ec)
1814       {   1816       {
1815           $s  = '<b>';   1817           $s  = '<b>';
1816           if  ($iSec <  3600)   1818           if  ($iSec <  3600)
1817           {   1819           {
1818                $i = rou nd($iSec/6 0);   1820                $i = rou nd($iSec/6 0);
1819                if (0 ==  $i || 1 = = $i) $s . = '1</b> [ L[Minute A go]]';   1821                if (0 ==  $i || 1 = = $i) $s . = '1</b> [ L[Minute A go]]';
1820                else $s  .= $i . '< /b> [L[Min utes Ago]] ';   1822                else $s  .= $i . '< /b> [L[Min utes Ago]] ';
1821           }   1823           }
1822           el se if ($iS ec < 86400 )   1824           el se if ($iS ec < 86400 )
1823           {   1825           {
1824                $i = rou nd($iSec/6 0/60);   1826                $i = rou nd($iSec/6 0/60);
1825                if (0 ==  $i || 1 = = $i) $s . = '1</b> [ L[Hour Ago ]]';   1827                if (0 ==  $i || 1 = = $i) $s . = '1</b> [ L[Hour Ago ]]';
1826                else $s  .= $i . '< /b> [L[Hou rs Ago]]';   1828                else $s  .= $i . '< /b> [L[Hou rs Ago]]';
1827           }                     1829           }                  
1828           el se    1830           el se 
1829           {   1831           {
1830                $i = rou nd($iSec/6 0/60/24);   1832                $i = rou nd($iSec/6 0/60/24);
1831                if (0 ==  $i || 1 = = $i) $s . = '1</b> [ L[Day Ago] ]';   1833                if (0 ==  $i || 1 = = $i) $s . = '1</b> [ L[Day Ago] ]';
1832                else $s  .= $i . '< /b> [L[Day s Ago]]';   1834                else $s  .= $i . '< /b> [L[Day s Ago]]';
1833           }                                  1835           }                               
1834           re turn $s;         1836           re turn $s;      
1835       }     1837       }  
1836     1838  
1837       functi on _no_acc ess ($wp =  0)   1839       functi on _no_acc ess ($wp =  0)
1838       {   1840       {
1839           $x ml = '<for um_access> no</forum_ access>';   1841           $x ml = '<for um_access> no</forum_ access>';
1840           if  (!$wp) re turn $xml;   1842           if  (!$wp) re turn $xml;
1841           $l i = $this- >_getLogin Info ();   1843           $l i = $this- >_getLogin Info ();
1842           re turn $this ->addHeade rFooter ($ li, $xml);   1844           re turn $this ->addHeade rFooter ($ li, $xml);
1843       }   1845       }
1844     1846  
1845       functi on _buld_t opic_desc  (&$s)   1847       functi on _buld_t opic_desc  (&$s)
1846       {   1848       {
1847           $s  = str_rep lace(array ('&#160;', '&amp;','& gt;','&lt; ','&quot;' ), array('  ','&','>' ,'<',"'"), strip_tags  ($s));   1849           $s  = str_rep lace(array ('&#160;', '&amp;','& gt;','&lt; ','&quot;' ), array('  ','&','>' ,'<',"'"), strip_tags  ($s));
1848           va lidate_uni code ($s);   1850           va lidate_uni code ($s);
1849           if  ($s == '' ) $s = ' ' ;   1851           if  ($s == '' ) $s = ' ' ;
1850           $s  = '<![CDA TA[' . $s  . ']]>';   1852           $s  = '<![CDA TA[' . $s  . ']]>';
1851       }   1853       }
1852     1854  
1853       functi on uriGene rate ($s,  $sTable, $ sField, $i MaxLen = 2 55)   1855       functi on uriGene rate ($s,  $sTable, $ sField, $i MaxLen = 2 55)
1854       {   1856       {
1855           // $s = orca_ mb_replace  ('/([^\d^ \w]+)/', ' -', $s); / / latin ch aracters   1857           // $s = orca_ mb_replace  ('/([^\d^ \w]+)/', ' -', $s); / / latin ch aracters
1856           $s  = orca_mb _replace ( '/[^\pL^\p N]+/u', '- ', $s); //  unicode c haracters   1858           $s  = orca_mb _replace ( '/[^\pL^\p N]+/u', '- ', $s); //  unicode c haracters
1857           $s  = orca_mb _replace ( '/([-^]+)/ ', '-', $s );   1859           $s  = orca_mb _replace ( '/([-^]+)/ ', '-', $s );
    1860           if  (!$s) $s  = '-';
1858     1861  
1859           if  ($this->u riCheckUni q($s, $sTa ble, $sFie ld)) retur n $s;   1862           if  ($this->u riCheckUni q($s, $sTa ble, $sFie ld)) retur n $s;
1860     1863  
1861           //  try to ad d date   1864           //  try to ad d date
1862     1865  
1863           if  (orca_mb_ len($s) >  240)   1866           if  (orca_mb_ len($s) >  240)
1864                $s = orc a_mb_subst r ($s, 0,  240);   1867                $s = orc a_mb_subst r ($s, 0,  240);
1865     1868  
1866           $s  .= '-' .  date('Y-m- d');   1869           $s  .= '-' .  date('Y-m- d');
1867              1870           
1868           if  ($this->u riCheckUni q($s, $sTa ble, $sFie ld)) retur n $s;   1871           if  ($this->u riCheckUni q($s, $sTa ble, $sFie ld)) retur n $s;
1869     1872  
1870     1873  
1871           //  try to ad d number   1874           //  try to ad d number
1872     1875  
1873           fo r ($i = 0  ; $i < 999  ; ++$i)   1876           fo r ($i = 0  ; $i < 999  ; ++$i)
1874           {            1877           {         
1875                if ($thi s->uriChec kUniq($s .  '-' . $i,  $sTable,  $sField))    1878                if ($thi s->uriChec kUniq($s .  '-' . $i,  $sTable,  $sField)) 
1876                {   1879                {
1877                    retu rn ($s . ' -' . $i);                     1880                    retu rn ($s . ' -' . $i);                  
1878                }   1881                }
1879           }   1882           }
1880     1883  
1881           re turn rand( 0, 9999999 99);   1884           re turn rand( 0, 9999999 99);
1882       }   1885       }
1883     1886  
1884       functi on uriChec kUniq ($s,  $sTable,  $sField)   1887       functi on uriChec kUniq ($s,  $sTable,  $sField)
1885       {   1888       {
1886           $f db = new D bForum ();   1889           $f db = new D bForum ();
1887           re turn !$fdb ->getOne(" SELECT 1 F ROM $sTabl e WHERE $s Field = '$ s' LIMIT 1 ");   1890           re turn !$fdb ->getOne(" SELECT 1 F ROM $sTabl e WHERE $s Field = '$ s' LIMIT 1 ");
1888       }   1891       }
1889     1892  
1890   }   1893   }
1891     1894  
1892   function o rca_mb_rep lace ($sPa ttern, $sR eplace, $s )   1895   function o rca_mb_rep lace ($sPa ttern, $sR eplace, $s )
1893   {   1896   {
1894       return  preg_repl ace ($sPat tern, $sRe place, $s) ;   1897       return  preg_repl ace ($sPat tern, $sRe place, $s) ;
1895   }   1898   }
1896     1899  
1897   function o rca_mb_len  ($s)   1900   function o rca_mb_len  ($s)
1898   {   1901   {
1899       if (fu nction_exi sts('mb_st rlen'))   1902       if (fu nction_exi sts('mb_st rlen'))
1900           re turn mb_st rlen ($s);   1903           re turn mb_st rlen ($s);
1901       else   1904       else
1902           re turn strle n ($s);   1905           re turn strle n ($s);
1903   }       1906   }    
1904     1907  
1905   function o rca_mb_sub str ($s, $ iStart, $i Len)   1908   function o rca_mb_sub str ($s, $ iStart, $i Len)
1906   {   1909   {
1907       if (fu nction_exi sts('mb_su bstr'))   1910       if (fu nction_exi sts('mb_su bstr'))
1908           re turn mb_su bstr ($s,  $iStart, $ iLen);   1911           re turn mb_su bstr ($s,  $iStart, $ iLen);
1909       else   1912       else
1910           re turn subst r ($s, $iS tart, $iLe n);   1913           re turn subst r ($s, $iS tart, $iLe n);
1911   }       1914   }    
1912     1915  
1913   ?>   1916   ?>