260. File Comparison Report

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

260.1 Files compared

# Location File Last Modified
1 Dolphin-v.6.0.5\orca\classes Forum.php Mon Jan 21 04:08:26 2008 UTC
2 Dolphin-v.6.1.0\orca\classes Forum.php Thu Apr 10 09:53:28 2008 UTC

260.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 137 3296
Changed 117 355
Inserted 13 82
Removed 6 8

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

260.4 Active regular expressions

No regular expressions were active.

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