95. File Comparison Report

Produced on Mon May 12 13:04:47 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.

95.1 Files compared

# Location File Last Modified
1 Dolphin-v.6.0.5\groups\orca\classes Forum.php Thu Mar 6 09:19:26 2008 UTC
2 Dolphin-v.6.1.0\groups\orca\classes Forum.php Thu Apr 10 09:53:30 2008 UTC

95.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 121 3342
Changed 102 339
Inserted 13 82
Removed 5 7

95.3 Comparison options

Whitespace
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

95.4 Active regular expressions

No regular expressions were active.

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