51. File Comparison Report

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

51.1 Files compared

# Location File Last Modified
1 Dolphin-v.6.1.1\inc utils.inc.php Sat Apr 26 08:19:16 2008 UTC
2 Dolphin-v.6.1.2\inc utils.inc.php Thu Jun 12 09:57:41 2008 UTC

51.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 1684
Changed 0 0
Inserted 1 1
Removed 0 0

51.3 Comparison options

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

51.4 Active regular expressions

No regular expressions were active.

51.5 Comparison detail

1   <?   1   <?
2     2  
3   /********* ********** ********** ********** ********** ********** ********** ******   3   /********* ********** ********** ********** ********** ********** ********** ******
4   *                              D olphin Sma rt Communi ty Builder   4   *                              D olphin Sma rt Communi ty Builder
5   *                                 --------- --------   5   *                                 --------- --------
6   *     begi n                 : M on Mar 23  2006   6   *     begi n                 : M on Mar 23  2006
7   *     copy right             : ( C) 2006 Bo onEx Group   7   *     copy right             : ( C) 2006 Bo onEx Group
8   *     webs ite               : h ttp://www. boonex.com /   8   *     webs ite               : h ttp://www. boonex.com /
9   * This fil e is part  of Dolphin  - Smart C ommunity B uilder   9   * This fil e is part  of Dolphin  - Smart C ommunity B uilder
10   *   10   *
11   * Dolphin  is free so ftware. Th is work is  licensed  under a Cr eative Com mons Attri bution 3.0  License.    11   * Dolphin  is free so ftware. Th is work is  licensed  under a Cr eative Com mons Attri bution 3.0  License. 
12   * http://c reativecom mons.org/l icenses/by /3.0/   12   * http://c reativecom mons.org/l icenses/by /3.0/
13   *   13   *
14   * Dolphin  is distrib uted in th e hope tha t it will  be useful,  but WITHO UT ANY WAR RANTY;   14   * Dolphin  is distrib uted in th e hope tha t it will  be useful,  but WITHO UT ANY WAR RANTY;
15   * without  even the i mplied war ranty of   MERCHANTAB ILITY or F ITNESS FOR  A PARTICU LAR PURPOS E.   15   * without  even the i mplied war ranty of   MERCHANTAB ILITY or F ITNESS FOR  A PARTICU LAR PURPOS E.
16   * See the  Creative C ommons Att ribution 3 .0 License  for more  details.    16   * See the  Creative C ommons Att ribution 3 .0 License  for more  details. 
17   * You shou ld have re ceived a c opy of the  Creative  Commons At tribution  3.0 Licens e along wi th Dolphin   17   * You shou ld have re ceived a c opy of the  Creative  Commons At tribution  3.0 Licens e along wi th Dolphin
18   * see lice nse.txt fi le; if not , write to  marketing @boonex.co m   18   * see lice nse.txt fi le; if not , write to  marketing @boonex.co m
19   ********** ********** ********** ********** ********** ********** ********** *****/   19   ********** ********** ********** ********** ********** ********** ********** *****/
20     20  
21   require_on ce("header .inc.php") ;   21   require_on ce("header .inc.php") ;
22     22  
23   /*   23   /*
24    * Common  functions   24    * Common  functions
25    */   25    */
26   function P rintErrorP ageCode( $ errorText  )   26   function P rintErrorP ageCode( $ errorText  )
27   {   27   {
28       ob_sta rt();   28       ob_sta rt();
29     29  
30   ?>   30   ?>
31   <!DOCTYPE  html PUBLI C "-//W3C/ /DTD XHTML  1.0 Trans itional//E N" "http:/ /www.w3.or g/TR/xhtml 1/DTD/xhtm l1-transit ional.dtd" >   31   <!DOCTYPE  html PUBLI C "-//W3C/ /DTD XHTML  1.0 Trans itional//E N" "http:/ /www.w3.or g/TR/xhtml 1/DTD/xhtm l1-transit ional.dtd" >
32   <html>   32   <html>
33       <head>   33       <head>
34           <t itle>Error </title>   34           <t itle>Error </title>
35     35  
36           <s tyle type= "text/css" >   36           <s tyle type= "text/css" >
37                div.erro r_containe r   37                div.erro r_containe r
38                {   38                {
39                    marg in-top: 2p x;   39                    marg in-top: 2p x;
40                    marg in-left: a uto;   40                    marg in-left: a uto;
41                    marg in-right:  auto;   41                    marg in-right:  auto;
42                    widt h: 400px;   42                    widt h: 400px;
43                }   43                }
44                div.erro r_head   44                div.erro r_head
45                {   45                {
46                    font -weight: b old;   46                    font -weight: b old;
47                    font -family: A rial, Helv etica, san s-serif;   47                    font -family: A rial, Helv etica, san s-serif;
48                    font -size: 11p x;   48                    font -size: 11p x;
49                    padd ing: 2px;   49                    padd ing: 2px;
50                    marg in-left: a uto;   50                    marg in-left: a uto;
51                    marg in-right:  auto;   51                    marg in-right:  auto;
52                    marg in-bottom:  2px;   52                    marg in-bottom:  2px;
53                    text -align: le ft;   53                    text -align: le ft;
54                    colo r: white;   54                    colo r: white;
55                    back ground-col or: red;   55                    back ground-col or: red;
56                    widt h: 100%;   56                    widt h: 100%;
57                    bord er: 1px so lid red;   57                    bord er: 1px so lid red;
58                }   58                }
59                div.erro r_body   59                div.erro r_body
60                {   60                {
61                    font -weight: n ormal;   61                    font -weight: n ormal;
62                    font -family: A rial, Helv etica, san s-serif;   62                    font -family: A rial, Helv etica, san s-serif;
63                    font -size: 11p x;   63                    font -size: 11p x;
64                    padd ing: 2px;   64                    padd ing: 2px;
65                    marg in-left: a uto;   65                    marg in-left: a uto;
66                    marg in-right:  auto;   66                    marg in-right:  auto;
67                    text -align: le ft;   67                    text -align: le ft;
68                    colo r: black;   68                    colo r: black;
69                    back ground-col or: white;   69                    back ground-col or: white;
70                    widt h: 100%;   70                    widt h: 100%;
71                    bord er: 1px so lid red;   71                    bord er: 1px so lid red;
72                }   72                }
73           </ style>   73           </ style>
74     74  
75       </head >   75       </head >
76       <body>   76       <body>
77     77  
78           <d iv class=" error_cont ainer">   78           <d iv class=" error_cont ainer">
79                <div cla ss="error_ head">Erro r</div>   79                <div cla ss="error_ head">Erro r</div>
80                <div cla ss="error_ body"><?=  $errorText  ?></div>   80                <div cla ss="error_ body"><?=  $errorText  ?></div>
81           </ div>   81           </ div>
82     82  
83       </body >   83       </body >
84   </html>   84   </html>
85   <?   85   <?
86     86  
87       $conte nt = ob_ge t_contents ();   87       $conte nt = ob_ge t_contents ();
88       ob_end _clean();   88       ob_end _clean();
89     89  
90       return  $content;   90       return  $content;
91   }   91   }
92     92  
93   /*   93   /*
94    * Print e rror page  with messa ge   94    * Print e rror page  with messa ge
95    */   95    */
96   function P rintErrorP age( $erro rText )   96   function P rintErrorP age( $erro rText )
97   {   97   {
98       echo P rintErrorP ageCode( $ errorText  );   98       echo P rintErrorP ageCode( $ errorText  );
99   }   99   }
100     100  
101   /*   101   /*
102    * functio n for work  with prof ile   102    * functio n for work  with prof ile
103    */   103    */
104   function i s_friends( $id1, $id2 )   104   function i s_friends( $id1, $id2 )
105   {   105   {
106       $cnt =  db_arr("S ELECT SUM( `Check`) A S 'cnt' FR OM `Friend List` WHER E `ID`='{$ id1}' AND  `Profile`= '{$id2}' O R `ID`='{$ id2}' AND  `Profile`= '{$id1}'") ;   106       $cnt =  db_arr("S ELECT SUM( `Check`) A S 'cnt' FR OM `Friend List` WHER E `ID`='{$ id1}' AND  `Profile`= '{$id2}' O R `ID`='{$ id2}' AND  `Profile`= '{$id1}'") ;
107       return  ($cnt['cn t'] > 0 ?  true : fal se);   107       return  ($cnt['cn t'] > 0 ?  true : fal se);
108   }   108   }
109     109  
110   /*   110   /*
111    * functio ns for lim iting maxi mal word l ength   111    * functio ns for lim iting maxi mal word l ength
112    */   112    */
113   function s trmaxwordl en($input,  $len = 10 0)   113   function s trmaxwordl en($input,  $len = 10 0)
114   {   114   {
115       return  $input;   115       return  $input;
116   }   116   }
117     117  
118   /*   118   /*
119    * functio ns for lim iting maxi mal text l ength   119    * functio ns for lim iting maxi mal text l ength
120    */   120    */
121   function s trmaxtextl en($input,  $len = 60 )   121   function s trmaxtextl en($input,  $len = 60 )
122   {   122   {
123       if ( s trlen($inp ut) > $len  )   123       if ( s trlen($inp ut) > $len  )
124           re turn mb_su bstr($inpu t, 0, $len  - 4) . ". ..";   124           re turn mb_su bstr($inpu t, 0, $len  - 4) . ". ..";
125       else   125       else
126           re turn $inpu t;   126           re turn $inpu t;
127   }   127   }
128     128  
129   function h tml2txt($c ontent, $t ags = "")   129   function h tml2txt($c ontent, $t ags = "")
130   {   130   {
131       while( $content ! = strip_ta gs($conten t, $tags))   131       while( $content ! = strip_ta gs($conten t, $tags))
132       {   132       {
133           $c ontent = s trip_tags( $content,  $tags);   133           $c ontent = s trip_tags( $content,  $tags);
134       }   134       }
135     135  
136       return  $content;   136       return  $content;
137   }   137   }
138     138  
139   function h tml_encode ($text)   139   function h tml_encode ($text)
140   {   140   {
141        $sear charray =   array(   141        $sear charray =   array(
142       "'([-_ \w\d.]+@[- _\w\d.]+)' ",   142       "'([-_ \w\d.]+@[- _\w\d.]+)' ",
143       "'((?: (?!://).{3 }|^.{0,2}) )(www\.[-\ d\w\.\/]+) '",   143       "'((?: (?!://).{3 }|^.{0,2}) )(www\.[-\ d\w\.\/]+) '",
144       "'(htt p[s]?:\/\/ [-_~\w\d\. \/]+)'");   144       "'(htt p[s]?:\/\/ [-_~\w\d\. \/]+)'");
145     145  
146       $repla cearray =  array(   146       $repla cearray =  array(
147       "<a hr ef=\"mailt o:\\1\">\\ 1</a>",   147       "<a hr ef=\"mailt o:\\1\">\\ 1</a>",
148       "\\1ht tp://\\2",   148       "\\1ht tp://\\2",
149       "<a hr ef=\"\\1\"  target=_b lank>\\1</ a>");   149       "<a hr ef=\"\\1\"  target=_b lank>\\1</ a>");
150     150  
151      return  preg_repla ce($search array, $re placearray , stripsla shes($text ));   151      return  preg_repla ce($search array, $re placearray , stripsla shes($text ));
152   }   152   }
153     153  
154   /*   154   /*
155    * functio ns for inp ut data in to databas e   155    * functio ns for inp ut data in to databas e
156    */   156    */
157   function p rocess_db_ input( $te xt, $strip _tags = 0,  $force_ad dslashes =  0 )   157   function p rocess_db_ input( $te xt, $strip _tags = 0,  $force_ad dslashes =  0 )
158   {   158   {
159       if ( $ strip_tags  )   159       if ( $ strip_tags  )
160           $t ext = stri p_tags($te xt);   160           $t ext = stri p_tags($te xt);
161     161  
162       if ( ! get_magic_ quotes_gpc () || $for ce_addslas hes )   162       if ( ! get_magic_ quotes_gpc () || $for ce_addslas hes )
163           re turn addsl ashes($tex t);   163           re turn addsl ashes($tex t);
164       else   164       else
165           re turn $text ;   165           re turn $text ;
166   }   166   }
167     167  
168   /*   168   /*
169    * functio n for proc essing pas s data   169    * functio n for proc essing pas s data
170    *   170    *
171    * This fu nction cle ans the GE T/POST/COO KIE data i f magic_qu otes_gpc()  is on   171    * This fu nction cle ans the GE T/POST/COO KIE data i f magic_qu otes_gpc()  is on
172    * for dat a which sh ould be ou tputed imm ediately a fter submi t   172    * for dat a which sh ould be ou tputed imm ediately a fter submi t
173    */   173    */
174   function p rocess_pas s_data( $t ext, $stri p_tags = 0  )   174   function p rocess_pas s_data( $t ext, $stri p_tags = 0  )
175   {   175   {
176       if ( $ strip_tags  )   176       if ( $ strip_tags  )
177           $t ext = stri p_tags($te xt);   177           $t ext = stri p_tags($te xt);
178     178  
179       if ( ! get_magic_ quotes_gpc () )   179       if ( ! get_magic_ quotes_gpc () )
180           re turn $text ;   180           re turn $text ;
181       else   181       else
182           re turn strip slashes($t ext);   182           re turn strip slashes($t ext);
183   }   183   }
184     184  
185   /*   185   /*
186    * functio n for outp ut data fr om databas e into htm l   186    * functio n for outp ut data fr om databas e into htm l
187    */   187    */
188   function h tmlspecial chars_adv(  $string )   188   function h tmlspecial chars_adv(  $string )
189   {   189   {
190       $patte rns = arra y( "/(?!&# \d{2,};)&/ m", "/>/m" , "/</m",  "/\"/m", " /'/m" );   190       $patte rns = arra y( "/(?!&# \d{2,};)&/ m", "/>/m" , "/</m",  "/\"/m", " /'/m" );
191       $repla ces = arra y( "&amp;" , "&gt;",  "&lt;", "& quot;", "& #039;" );   191       $repla ces = arra y( "&amp;" , "&gt;",  "&lt;", "& quot;", "& #039;" );
192       return  preg_repl ace( $patt erns, $rep laces, $st ring );   192       return  preg_repl ace( $patt erns, $rep laces, $st ring );
193   }   193   }
194     194  
195   function p rocess_tex t_output(  $text, $ma xwordlen =  100 )   195   function p rocess_tex t_output(  $text, $ma xwordlen =  100 )
196   {   196   {
197       return  nl2br( ht mlspecialc hars_adv(  strmaxword len( $text , $maxword len ) ) );   197       return  nl2br( ht mlspecialc hars_adv(  strmaxword len( $text , $maxword len ) ) );
198   }   198   }
199     199  
200   function p rocess_tex tarea_outp ut( $text,  $maxwordl en = 100 )   200   function p rocess_tex tarea_outp ut( $text,  $maxwordl en = 100 )
201   {   201   {
202       return  htmlspeci alchars_ad v( strmaxw ordlen( $t ext, $maxw ordlen ) ) ;   202       return  htmlspeci alchars_ad v( strmaxw ordlen( $t ext, $maxw ordlen ) ) ;
203   }   203   }
204     204  
205   function p rocess_tex t_withlink s_output(  $text, $ma xwordlen =  100 )   205   function p rocess_tex t_withlink s_output(  $text, $ma xwordlen =  100 )
206   {   206   {
207       return  nl2br( ht ml_encode(  htmlspeci alchars_ad v( strmaxw ordlen( $t ext, $maxw ordlen ) )  ) );   207       return  nl2br( ht ml_encode(  htmlspeci alchars_ad v( strmaxw ordlen( $t ext, $maxw ordlen ) )  ) );
208   }   208   }
209     209  
210   function p rocess_lin e_output(  $text, $ma xwordlen =  100 )   210   function p rocess_lin e_output(  $text, $ma xwordlen =  100 )
211   {   211   {
212       return  htmlspeci alchars_ad v( strmaxw ordlen( $t ext, $maxw ordlen ) ) ;   212       return  htmlspeci alchars_ad v( strmaxw ordlen( $t ext, $maxw ordlen ) ) ;
213   }   213   }
214     214  
215   function p rocess_htm l_output(  $text, $ma xwordlen =  100 )   215   function p rocess_htm l_output(  $text, $ma xwordlen =  100 )
216   {   216   {
217       return  strmaxwor dlen( $tex t, $maxwor dlen );   217       return  strmaxwor dlen( $tex t, $maxwor dlen );
218   }   218   }
219     219  
220   /*   220   /*
221    * functio ns for wor k with arr ays   221    * functio ns for wor k with arr ays
222    */   222    */
223   function a rray_stick ($base_arr , $add_arr )   223   function a rray_stick ($base_arr , $add_arr )
224   {   224   {
225       if(is_ array($bas e_arr) &&  is_array($ add_arr))   225       if(is_ array($bas e_arr) &&  is_array($ add_arr))
226       {   226       {
227           fo reach($add _arr as $k ey => $val ue)   227           fo reach($add _arr as $k ey => $val ue)
228           {   228           {
229                $base_ar r[$key] =  array_merg e($base_ar r[$key], $ value);   229                $base_ar r[$key] =  array_merg e($base_ar r[$key], $ value);
230           }   230           }
231       }   231       }
232       else   232       else
233       {   233       {
234           pr int_err("I nput argum ents are n ot arrays" );   234           pr int_err("I nput argum ents are n ot arrays" );
235       }   235       }
236       return  $base_arr ;   236       return  $base_arr ;
237   }   237   }
238     238  
239   /**   239   /**
240   *   Used t o construc t sturctur ed arrays  in GET or  POST data.  Supports  multidimen sional arr ays.   240   *   Used t o construc t sturctur ed arrays  in GET or  POST data.  Supports  multidimen sional arr ays.
241   *   241   *
242   *   @param  array     $Values Sp ecifies va lues and v alues name s, that sh ould be su bmitted. C an be mult idimension al.   242   *   @param  array     $Values Sp ecifies va lues and v alues name s, that sh ould be su bmitted. C an be mult idimension al.
243   *   243   *
244   *   @retur n string   HTML code,  which con tains <inp ut type="h idden"...>  tags with  names and  values, s pecified i n $Values  array.   244   *   @retur n string   HTML code,  which con tains <inp ut type="h idden"...>  tags with  names and  values, s pecified i n $Values  array.
245   */   245   */
246   function C onstructHi ddenValues ($Values)   246   function C onstructHi ddenValues ($Values)
247   {   247   {
248       /**   248       /**
249       *   Re cursive fu nction, pr ocesses mu ltidimensi onal array s   249       *   Re cursive fu nction, pr ocesses mu ltidimensi onal array s
250       *   250       *
251       *   @p aram strin g $Name Fu ll name of  array, in cluding al l subarray s' names   251       *   @p aram strin g $Name Fu ll name of  array, in cluding al l subarray s' names
252       *   252       *
253       *   @p aram array  $Value Ar ray of val ues, can b e multidim ensional   253       *   @p aram array  $Value Ar ray of val ues, can b e multidim ensional
254       *   254       *
255       *   @r eturn stri ng  Proper ly consctr ucted <inp ut type="h idden"...>  tags   255       *   @r eturn stri ng  Proper ly consctr ucted <inp ut type="h idden"...>  tags
256       */   256       */
257       functi on Constru ctHiddenSu bValues($N ame, $Valu e)   257       functi on Constru ctHiddenSu bValues($N ame, $Valu e)
258       {   258       {
259           if  (is_array ($Value))   259           if  (is_array ($Value))
260           {   260           {
261                $Result  = "";   261                $Result  = "";
262                foreach  ($Value as  $KeyName  => $SubVal ue)   262                foreach  ($Value as  $KeyName  => $SubVal ue)
263                {   263                {
264                    $Res ult .= Con structHidd enSubValue s("{$Name} [{$KeyName }]", $SubV alue);   264                    $Res ult .= Con structHidd enSubValue s("{$Name} [{$KeyName }]", $SubV alue);
265                }   265                }
266           }   266           }
267           el se   267           el se
268                // Exit  recurse   268                // Exit  recurse
269                $Result  = "<input  type=\"hid den\" name =\"".htmls pecialchar s($Name)." \" value=\ "".htmlspe cialchars( $Value)."\ " />\n";   269                $Result  = "<input  type=\"hid den\" name =\"".htmls pecialchar s($Name)." \" value=\ "".htmlspe cialchars( $Value)."\ " />\n";
270     270  
271           re turn $Resu lt;   271           re turn $Resu lt;
272       }   272       }
273       /* End  of Constr uctHiddenS ubValues f unction */   273       /* End  of Constr uctHiddenS ubValues f unction */
274     274  
275     275  
276       $Resul t = '';   276       $Resul t = '';
277       if (is _array($Va lues))   277       if (is _array($Va lues))
278       {   278       {
279           fo reach ($Va lues as $K eyName =>  $Value)   279           fo reach ($Va lues as $K eyName =>  $Value)
280           {   280           {
281                $Result  .= Constru ctHiddenSu bValues($K eyName, $V alue);   281                $Result  .= Constru ctHiddenSu bValues($K eyName, $V alue);
282           }   282           }
283       }   283       }
284     284  
285       return  $Result;   285       return  $Result;
286   }   286   }
287     287  
288   /**   288   /**
289   *   Return s HTML/jav ascript co de, which  redirects  to another  URL with  passing sp ecified da ta (throug h specifie d method)   289   *   Return s HTML/jav ascript co de, which  redirects  to another  URL with  passing sp ecified da ta (throug h specifie d method)
290   *   290   *
291   *   @param  string    $ActionURL   destinat ion URL   291   *   @param  string    $ActionURL   destinat ion URL
292   *   292   *
293   *   @param  array     $Params Pa rameters t o be passe d (through  GET or PO ST)   293   *   @param  array     $Params Pa rameters t o be passe d (through  GET or PO ST)
294   *   294   *
295   *   @param  string    $Method Su bmit mode.  Only two  values are  valid: 'g et' and 'p ost'   295   *   @param  string    $Method Su bmit mode.  Only two  values are  valid: 'g et' and 'p ost'
296   *   296   *
297   *   @retur n mixed    Correspond ent HTML/j avascript  code or fa lse, if in put data i s wrong   297   *   @retur n mixed    Correspond ent HTML/j avascript  code or fa lse, if in put data i s wrong
298   */   298   */
299   function R edirectCod e($ActionU RL, $Param s = NULL,  $Method =  "get", $Ti tle = 'Red irect')   299   function R edirectCod e($ActionU RL, $Param s = NULL,  $Method =  "get", $Ti tle = 'Red irect')
300   {   300   {
301       if ((s trcasecmp( trim($Meth od), "get" ) && strca secmp(trim ($Method),  "post"))  || (trim($ ActionURL)  == ""))   301       if ((s trcasecmp( trim($Meth od), "get" ) && strca secmp(trim ($Method),  "post"))  || (trim($ ActionURL)  == ""))
302           re turn false ;   302           re turn false ;
303     303  
304       ob_sta rt();   304       ob_sta rt();
305     305  
306   ?>   306   ?>
307   <html>   307   <html>
308       <head>   308       <head>
309           <t itle><?= $ Title ?></ title>   309           <t itle><?= $ Title ?></ title>
310       </head >   310       </head >
311       <body>   311       <body>
312           <f orm name=" RedirectFo rm" action ="<?= html specialcha rs($Action URL) ?>" m ethod="<?=  $Method ? >">   312           <f orm name=" RedirectFo rm" action ="<?= html specialcha rs($Action URL) ?>" m ethod="<?=  $Method ? >">
313     313  
314   <?= Constr uctHiddenV alues($Par ams) ?>   314   <?= Constr uctHiddenV alues($Par ams) ?>
315     315  
316           </ form>   316           </ form>
317           <s cript type ="text/jav ascript">   317           <s cript type ="text/jav ascript">
318                <!--   318                <!--
319                document .forms['Re directForm '].submit( );   319                document .forms['Re directForm '].submit( );
320                -->   320                -->
321           </ script>   321           </ script>
322       </body >   322       </body >
323   </html>   323   </html>
324   <?   324   <?
325     325  
326       $Resul t = ob_get _contents( );   326       $Resul t = ob_get _contents( );
327       ob_end _clean();   327       ob_end _clean();
328     328  
329       return  $Result;   329       return  $Result;
330   }   330   }
331     331  
332   /**   332   /**
333   *   Redire cts browse r to anoth er URL, pa ssing para meters thr ough POST  or GET   333   *   Redire cts browse r to anoth er URL, pa ssing para meters thr ough POST  or GET
334   *   Actual ly just pr ints code,  returned  by Redirec tCode (see  RedirectC ode)   334   *   Actual ly just pr ints code,  returned  by Redirec tCode (see  RedirectC ode)
335   */   335   */
336   function R edirect($A ctionURL,  $Params =  NULL, $Met hod = "get ", $Title  = 'Redirec t')   336   function R edirect($A ctionURL,  $Params =  NULL, $Met hod = "get ", $Title  = 'Redirec t')
337   {   337   {
338       $Redir ectCodeVal ue = Redir ectCode($A ctionURL,  $Params, $ Method, $T itle);   338       $Redir ectCodeVal ue = Redir ectCode($A ctionURL,  $Params, $ Method, $T itle);
339       if ($R edirectCod eValue !==  false)   339       if ($R edirectCod eValue !==  false)
340           ec ho $Redire ctCodeValu e;   340           ec ho $Redire ctCodeValu e;
341   }   341   }
342     342  
343   function E rrorHandle r($errno,  $errstr, $ errfile, $ errline)   343   function E rrorHandle r($errno,  $errstr, $ errfile, $ errline)
344   {   344   {
345       switch  ($errno)   345       switch  ($errno)
346       {   346       {
347       case F ATAL:   347       case F ATAL:
348                echo "<b >FATAL</b>  [$errno]  $errstr<br >\n";   348                echo "<b >FATAL</b>  [$errno]  $errstr<br >\n";
349           ec ho "  Fata l error in  line ".$e rrline." o f file ".$ errfile;   349           ec ho "  Fata l error in  line ".$e rrline." o f file ".$ errfile;
350           ec ho ", PHP  ".PHP_VERS ION." (".P HP_OS.")<b r>\n";   350           ec ho ", PHP  ".PHP_VERS ION." (".P HP_OS.")<b r>\n";
351           ec ho "Aborti ng...<br>\ n";   351           ec ho "Aborti ng...<br>\ n";
352           ex it(1);   352           ex it(1);
353       break;   353       break;
354       case E RROR:   354       case E RROR:
355            e cho "<b>ER ROR</b> [$ errno] $er rstr<br>\n ";   355            e cho "<b>ER ROR</b> [$ errno] $er rstr<br>\n ";
356       break;   356       break;
357       case W ARNING:   357       case W ARNING:
358       //     echo "<b>< /b> [$errn o] $errstr <br>\n";   358       //     echo "<b>< /b> [$errn o] $errstr <br>\n";
359       break;   359       break;
360       defaul t:   360       defaul t:
361       break;   361       break;
362       }   362       }
363     363  
364   }   364   }
365     365  
366   function i sRWAccessi ble($filen ame)   366   function i sRWAccessi ble($filen ame)
367   {   367   {
368     368  
369       clears tatcache() ;   369       clears tatcache() ;
370       $perms  = fileper ms($filena me);   370       $perms  = fileper ms($filena me);
371       return  ( $perms  & 0x0004 & & $perms &  0x0002 )  ? true : f alse;   371       return  ( $perms  & 0x0004 & & $perms &  0x0002 )  ? true : f alse;
372     372  
373   }   373   }
374     374  
375   /**   375   /**
376    * Send em ail functi on   376    * Send em ail functi on
377    *   377    *
378    * @param  string $sR ecipientEm ail        - Email wh ere email  should be  send   378    * @param  string $sR ecipientEm ail        - Email wh ere email  should be  send
379    * @param  string $sM ailSubject            - subject  of the mes sage   379    * @param  string $sM ailSubject            - subject  of the mes sage
380    * @param  string $sM ailBody               - Body of  the messag e   380    * @param  string $sM ailBody               - Body of  the messag e
381    * @param  integer $i RecipientI D          - ID of re cipient pr ofile   381    * @param  integer $i RecipientI D          - ID of re cipient pr ofile
382    * @param  array $aPl us                    - Array of  additiona l informat ion   382    * @param  array $aPl us                    - Array of  additiona l informat ion
383    *   383    *
384    *   384    *
385    * @return  boolean                         - trie if  message wa s send   385    * @return  boolean                         - trie if  message wa s send
386    *                                          - false if  not   386    *                                          - false if  not
387    */   387    */
388   function s endMail( $ sRecipient Email, $sM ailSubject , $sMailBo dy, $iReci pientID =  '', $aPlus  = '', $sE mailFlag =  'text' )  {   388   function s endMail( $ sRecipient Email, $sM ailSubject , $sMailBo dy, $iReci pientID =  '', $aPlus  = '', $sE mailFlag =  'text' )  {
389       global  $site;   389       global  $site;
390     390  
391       if( $i RecipientI D )   391       if( $i RecipientI D )
392           $a RecipientI nfo = getP rofileInfo ( $iRecipi entID );   392           $a RecipientI nfo = getP rofileInfo ( $iRecipi entID );
393     393  
394       $sMail Header         = "Fro m: =?UTF-8 ?B?" . bas e64_encode ( $site['t itle'] ) .  "?= <{$si te['email_ notify']}> ";   394       $sMail Header         = "Fro m: =?UTF-8 ?B?" . bas e64_encode ( $site['t itle'] ) .  "?= <{$si te['email_ notify']}> ";
395       $sMail Parameters     = "-f{ $site['ema il_notify' ]}";   395       $sMail Parameters     = "-f{ $site['ema il_notify' ]}";
396     396  
397       $sMail Subject    = str_repl ace( "<Sit eName>", $ site['titl e'], $sMai lSubject ) ;   397       $sMail Subject    = str_repl ace( "<Sit eName>", $ site['titl e'], $sMai lSubject ) ;
398     398  
399       $sMail Body       = str_repl ace( "<Sit eName>", $ site['titl e'], $sMai lBody );   399       $sMail Body       = str_repl ace( "<Sit eName>", $ site['titl e'], $sMai lBody );
400       $sMail Body       = str_repl ace( "<Dom ain>", $si te['url'],  $sMailBod y );   400       $sMail Body       = str_repl ace( "<Dom ain>", $si te['url'],  $sMailBod y );
401       $sMail Body       = str_repl ace( "<rec ipientID>" , $aRecipi entInfo['I D'], $sMai lBody );   401       $sMail Body       = str_repl ace( "<rec ipientID>" , $aRecipi entInfo['I D'], $sMai lBody );
402       $sMail Body       = str_repl ace( "<Rea lName>", $ aRecipient Info['Nick Name'], $s MailBody ) ;   402       $sMail Body       = str_repl ace( "<Rea lName>", $ aRecipient Info['Nick Name'], $s MailBody ) ;
403       $sMail Body       = str_repl ace( "<Nic kName>", $ aRecipient Info['Nick Name'], $s MailBody ) ;   403       $sMail Body       = str_repl ace( "<Nic kName>", $ aRecipient Info['Nick Name'], $s MailBody ) ;
404       $sMail Body       = str_repl ace( "<Ema il>", $aRe cipientInf o['Email'] , $sMailBo dy );   404       $sMail Body       = str_repl ace( "<Ema il>", $aRe cipientInf o['Email'] , $sMailBo dy );
405       $sMail Body       = str_repl ace( "<Pas sword>", $ aRecipient Info['Pass word'], $s MailBody ) ;   405       $sMail Body       = str_repl ace( "<Pas sword>", $ aRecipient Info['Pass word'], $s MailBody ) ;
406     406  
407       if( is _array($aP lus) ) {   407       if( is _array($aP lus) ) {
408           fo reach ( $a Plus as $k ey => $val ue ) {   408           fo reach ( $a Plus as $k ey => $val ue ) {
409                $sMailBo dy = str_r eplace( '< ' . $key .  '>', $val ue, $sMail Body );   409                $sMailBo dy = str_r eplace( '< ' . $key .  '>', $val ue, $sMail Body );
410           }   410           }
411       }   411       }
412     412  
413       $sMail Subject =  '=?UTF-8?B ?' . base6 4_encode(  $sMailSubj ect ) . '? =';   413       $sMail Subject =  '=?UTF-8?B ?' . base6 4_encode(  $sMailSubj ect ) . '? =';
414     414  
415       $sMail Header = " MIME-Versi on: 1.0\r\ n" . $sMai lHeader;   415       $sMail Header = " MIME-Versi on: 1.0\r\ n" . $sMai lHeader;
416     416  
417       if( 'h tml' == $s EmailFlag)  {   417       if( 'h tml' == $s EmailFlag)  {
418           $s MailHeader  = "Conten t-type: te xt/html; c harset=UTF -8\r\n" .  $sMailHead er;   418           $s MailHeader  = "Conten t-type: te xt/html; c harset=UTF -8\r\n" .  $sMailHead er;
419           $i SendingRes ult = mail ( $sRecipi entEmail,  $sMailSubj ect, $sMai lBody, $sM ailHeader,  $sMailPar ameters );   419           $i SendingRes ult = mail ( $sRecipi entEmail,  $sMailSubj ect, $sMai lBody, $sM ailHeader,  $sMailPar ameters );
420       } else  {   420       } else  {
421           $s MailHeader  = "Conten t-type: te xt/plain;  charset=UT F-8\r\n" .  $sMailHea der;   421           $s MailHeader  = "Conten t-type: te xt/plain;  charset=UT F-8\r\n" .  $sMailHea der;
422           $i SendingRes ult = mail ( $sRecipi entEmail,  $sMailSubj ect, html2 txt($sMail Body), $sM ailHeader,  $sMailPar ameters );   422           $i SendingRes ult = mail ( $sRecipi entEmail,  $sMailSubj ect, html2 txt($sMail Body), $sM ailHeader,  $sMailPar ameters );
423       }   423       }
424     424  
425       return  $iSending Result;   425       return  $iSending Result;
426   }   426   }
427     427  
428   /*   428   /*
429    * Getting  Array wit h Template s Names   429    * Getting  Array wit h Template s Names
430   */   430   */
431     431  
432   function g et_templat es_array()   432   function g et_templat es_array()
433   {   433   {
434       global  $dir;   434       global  $dir;
435     435  
436       $path  = $dir['ro ot'].'temp lates/';   436       $path  = $dir['ro ot'].'temp lates/';
437       $templ _choices =  array();   437       $templ _choices =  array();
438       $handl e = opendi r( $path ) ;   438       $handl e = opendi r( $path ) ;
439     439  
440       while  ( false != = ($filena me = readd ir($handle )) )   440       while  ( false != = ($filena me = readd ir($handle )) )
441       {   441       {
442           if  ( is_dir( $path.$fil ename) &&  substr($fi lename, 0,  5) == 'tm pl_' )   442           if  ( is_dir( $path.$fil ename) &&  substr($fi lename, 0,  5) == 'tm pl_' )
443           {   443           {
444                $sTemplN ame = '';   444                $sTemplN ame = '';
445                @include ( $path.$f ilename.'/ scripts/Bx TemplName. php' );   445                @include ( $path.$f ilename.'/ scripts/Bx TemplName. php' );
446                if( $sTe mplName )   446                if( $sTe mplName )
447                    $tem pl_choices [substr($f ilename, 5 )] = $sTem plName;   447                    $tem pl_choices [substr($f ilename, 5 )] = $sTem plName;
448           }   448           }
449       }   449       }
450       closed ir( $handl e );   450       closed ir( $handl e );
451       return  $templ_ch oices;   451       return  $templ_ch oices;
452   }   452   }
453     453  
454   /*   454   /*
455    * The Fun ction Show  a Line wi th Templat es Names   455    * The Fun ction Show  a Line wi th Templat es Names
456   */   456   */
457     457  
458   function t emplates_s elect_txt( )   458   function t emplates_s elect_txt( )
459   {   459   {
460       global  $dir;   460       global  $dir;
461     461  
462       $templ _choices =  get_templ ates_array ();   462       $templ _choices =  get_templ ates_array ();
463       $curre nt_templat e = ( strl en( $_GET[ 'skin'] )  ) ? $_GET[ 'skin'] :  $_COOKIE[' skin'];   463       $curre nt_templat e = ( strl en( $_GET[ 'skin'] )  ) ? $_GET[ 'skin'] :  $_COOKIE[' skin'];
464     464  
465     465  
466       foreac h ($templ_ choices as  $tmpl_key  => $tmpl_ value)   466       foreac h ($templ_ choices as  $tmpl_key  => $tmpl_ value)
467       {   467       {
468           if  ($current _template  == $tmpl_k ey)   468           if  ($current _template  == $tmpl_k ey)
469           {   469           {
470                $ReturnR esult .= $ tmpl_value ;   470                $ReturnR esult .= $ tmpl_value ;
471                $ReturnR esult .= '  | ';   471                $ReturnR esult .= '  | ';
472           }   472           }
473           el se   473           el se
474           {   474           {
475                foreach  ($_GET as  $param_key  => $param _value)   475                foreach  ($_GET as  $param_key  => $param _value)
476                {   476                {
477     477  
478                    if (  'skin' !=  $param_ke y ) $sGetT ransfer .=  "&{$param _key}={$pa ram_value} ";   478                    if (  'skin' !=  $param_ke y ) $sGetT ransfer .=  "&{$param _key}={$pa ram_value} ";
479     479  
480                }   480                }
481     481  
482                $ReturnR esult .= ' <a href="'  . $_SERVE R['PHP_SEL F'] . '?sk in='. $tmp l_key . $s GetTransfe r . '">' .  $tmpl_val ue . '</a> ';   482                $ReturnR esult .= ' <a href="'  . $_SERVE R['PHP_SEL F'] . '?sk in='. $tmp l_key . $s GetTransfe r . '">' .  $tmpl_val ue . '</a> ';
483                $ReturnR esult .= '  | ';   483                $ReturnR esult .= '  | ';
484     484  
485           }   485           }
486       }   486       }
487     487  
488       return  $ReturnRe sult;   488       return  $ReturnRe sult;
489     489  
490     490  
491   }   491   }
492     492  
493   /**   493   /**
494    * callbac k function  for inclu ding templ ate files   494    * callbac k function  for inclu ding templ ate files
495    */   495    */
496   function g etTemplate IncludedFi le( $aFile  )   496   function g etTemplate IncludedFi le( $aFile  )
497   {   497   {
498       global  $tmpl;   498       global  $tmpl;
499     499  
500       // rea d include  file   500       // rea d include  file
501     501  
502       $sFile  = BX_DIRE CTORY_PATH _ROOT . 't emplates/t mpl_' . $t mpl . '/'.  $aFile['1 '];   502       $sFile  = BX_DIRE CTORY_PATH _ROOT . 't emplates/t mpl_' . $t mpl . '/'.  $aFile['1 '];
503     503  
504       if( fi le_exists  ($sFile) & & is_file(  $sFile )  )   504       if( fi le_exists  ($sFile) & & is_file(  $sFile )  )
505       {   505       {
506           $f p = fopen  ($sFile, " r");   506           $f p = fopen  ($sFile, " r");
507           if  ($fp)   507           if  ($fp)
508           {   508           {
509                $s = fre ad ($fp, f ilesize ($ sFile));   509                $s = fre ad ($fp, f ilesize ($ sFile));
510                fclose ( $fp);   510                fclose ( $fp);
511                return $ s;   511                return $ s;
512           }   512           }
513       }   513       }
514     514  
515       return  "<b>error  reading { $aFile[1]} </b>";   515       return  "<b>error  reading { $aFile[1]} </b>";
516   }   516   }
517     517  
518   function g etTemplate BaseFile(  $aFile )   518   function g etTemplate BaseFile(  $aFile )
519   {   519   {
520       global  $dir;   520       global  $dir;
521       global  $tmpl;   521       global  $tmpl;
522     522  
523       // rea d include  file   523       // rea d include  file
524       $sFile  = BX_DIRE CTORY_PATH _ROOT . 't emplates/b ase/' . $a File['1'];   524       $sFile  = BX_DIRE CTORY_PATH _ROOT . 't emplates/b ase/' . $a File['1'];
525     525  
526       if (fi le_exists  ($sFile) & & is_file(  $sFile ))   526       if (fi le_exists  ($sFile) & & is_file(  $sFile ))
527       {   527       {
528           $f p = fopen  ($sFile, " r");   528           $f p = fopen  ($sFile, " r");
529           if  ($fp)   529           if  ($fp)
530           {   530           {
531                $s = fre ad ($fp, f ilesize ($ sFile));   531                $s = fre ad ($fp, f ilesize ($ sFile));
532                fclose ( $fp);   532                fclose ( $fp);
533                return $ s;   533                return $ s;
534           }   534           }
535       }   535       }
536     536  
537       return  "<b>error  reading b ase {$aFil e[1]}</b>" ;   537       return  "<b>error  reading b ase {$aFil e[1]}</b>" ;
538   }   538   }
539     539  
540   function e xtFileExis ts( $sFile Src )   540   function e xtFileExis ts( $sFile Src )
541   {   541   {
542     542  
543       if( fi le_exists(  $sFileSrc  ) && is_f ile( $sFil eSrc ) )   543       if( fi le_exists(  $sFileSrc  ) && is_f ile( $sFil eSrc ) )
544       {   544       {
545           $r et = true;   545           $r et = true;
546       }   546       }
547       else   547       else
548       {   548       {
549           $r et = false ;   549           $r et = false ;
550       }   550       }
551     551  
552       return  $ret;   552       return  $ret;
553   }   553   }
554     554  
555   function e xtDirExist s( $sDirSr c )   555   function e xtDirExist s( $sDirSr c )
556   {   556   {
557     557  
558       if( fi le_exists(  $sDirSrc  ) && is_di r( $sDirSr c ) )   558       if( fi le_exists(  $sDirSrc  ) && is_di r( $sDirSr c ) )
559       {   559       {
560           $r et = true;   560           $r et = true;
561       }   561       }
562       else   562       else
563       {   563       {
564           $r et = false ;   564           $r et = false ;
565       }   565       }
566     566  
567       return  $ret;   567       return  $ret;
568   }   568   }
569     569  
570   function g etVisitorI P()   570   function g etVisitorI P()
571   {   571   {
572       $ip =  '';   572       $ip =  '';
573       if( (  isset( $_S ERVER['HTT P_X_FORWAR DED_FOR']  ) ) && ( ! empty( $_S ERVER['HTT P_X_FORWAR DED_FOR']  ) ) )   573       if( (  isset( $_S ERVER['HTT P_X_FORWAR DED_FOR']  ) ) && ( ! empty( $_S ERVER['HTT P_X_FORWAR DED_FOR']  ) ) )
574       {   574       {
575           $i p = $_SERV ER['HTTP_X _FORWARDED _FOR'];   575           $i p = $_SERV ER['HTTP_X _FORWARDED _FOR'];
576       }   576       }
577       elseif ( ( isset(  $_SERVER[ 'HTTP_CLIE NT_IP']))  && (!empty ($_SERVER[ 'HTTP_CLIE NT_IP'] )  ) )   577       elseif ( ( isset(  $_SERVER[ 'HTTP_CLIE NT_IP']))  && (!empty ($_SERVER[ 'HTTP_CLIE NT_IP'] )  ) )
578       {   578       {
579           $i p = explod e(".",$_SE RVER['HTTP _CLIENT_IP ']);   579           $i p = explod e(".",$_SE RVER['HTTP _CLIENT_IP ']);
580           $i p = $ip[3] .".".$ip[2 ].".".$ip[ 1].".".$ip [0];   580           $i p = $ip[3] .".".$ip[2 ].".".$ip[ 1].".".$ip [0];
581       }   581       }
582       elseif ((!isset(  $_SERVER[' HTTP_X_FOR WARDED_FOR '])) || (e mpty($_SER VER['HTTP_ X_FORWARDE D_FOR'])))   582       elseif ((!isset(  $_SERVER[' HTTP_X_FOR WARDED_FOR '])) || (e mpty($_SER VER['HTTP_ X_FORWARDE D_FOR'])))
583       {   583       {
584           if  ((!isset(  $_SERVER[ 'HTTP_CLIE NT_IP']))  && (empty( $_SERVER[' HTTP_CLIEN T_IP'])))   584           if  ((!isset(  $_SERVER[ 'HTTP_CLIE NT_IP']))  && (empty( $_SERVER[' HTTP_CLIEN T_IP'])))
585           {   585           {
586                $ip = $_ SERVER['RE MOTE_ADDR' ];   586                $ip = $_ SERVER['RE MOTE_ADDR' ];
587           }   587           }
588       }   588       }
589       else   589       else
590       {   590       {
591           $i p = "0.0.0 .0";   591           $i p = "0.0.0 .0";
592       }   592       }
593     593  
594       return  $ip;   594       return  $ip;
595   }   595   }
596     596  
597   function g enFlag( $c ountry )   597   function g enFlag( $c ountry )
598   {   598   {
599       global  $site;   599       global  $site;
600       $count ry = strto lower( $co untry );   600       $count ry = strto lower( $co untry );
601          601       
602       return  "<img src =\"{$site[ 'flags']}{ $country}. gif\" />";   602       return  "<img src =\"{$site[ 'flags']}{ $country}. gif\" />";
603   }   603   }
604     604  
605   // print d ebug infor mation ( e .g. arrays  )   605   // print d ebug infor mation ( e .g. arrays  )
606   function e choDbg( $w hat, $desc  = '' )   606   function e choDbg( $w hat, $desc  = '' )
607   {   607   {
608       if ( $ desc )   608       if ( $ desc )
609           ec ho "<b>$de sc:</b> ";   609           ec ho "<b>$de sc:</b> ";
610       echo " <pre>";   610       echo " <pre>";
611           pr int_r( $wh at );   611           pr int_r( $wh at );
612       echo " </pre>\n";   612       echo " </pre>\n";
613   }   613   }
614     614  
615   function c lear_xss($ val)   615   function c lear_xss($ val)
616   {   616   {
617       global  $dir;   617       global  $dir;
618       requir e_once( "{ $dir['plug ins']}safe html/safeh tml.php" ) ;   618       requir e_once( "{ $dir['plug ins']}safe html/safeh tml.php" ) ;
619       $safeh tml =& new  safehtml( );   619       $safeh tml =& new  safehtml( );
620       $res =  $safehtml ->parse($v al);   620       $res =  $safehtml ->parse($v al);
621          621       
622       return  $res;   622       return  $res;
623   }   623   }
624     624  
625   function _ format_whe n ($iSec)  {   625   function _ format_whe n ($iSec)  {
626       $s = ' ';   626       $s = ' ';
627     627  
628       if ($i Sec>0) {   628       if ($i Sec>0) {
629           if  ($iSec <  3600) {   629           if  ($iSec <  3600) {
630                $i = rou nd($iSec/6 0);   630                $i = rou nd($iSec/6 0);
631                if (0 ==  $i || 1 = = $i) $s . = _t('_x_m inute_ago' , '1');   631                if (0 ==  $i || 1 = = $i) $s . = _t('_x_m inute_ago' , '1');
632                else $s  .= _t('_x_ minute_ago ', $i, 's' );   632                else $s  .= _t('_x_ minute_ago ', $i, 's' );
633           }   633           }
634           el se if ($iS ec < 86400 ) {   634           el se if ($iS ec < 86400 ) {
635                $i = rou nd($iSec/6 0/60);   635                $i = rou nd($iSec/6 0/60);
636                if (0 ==  $i || 1 = = $i) $s . = _t('_x_h our_ago',  '1');   636                if (0 ==  $i || 1 = = $i) $s . = _t('_x_h our_ago',  '1');
637                else $s  .= _t('_x_ hour_ago',  $i, 's');   637                else $s  .= _t('_x_ hour_ago',  $i, 's');
638           }   638           }
639           el se {   639           el se {
640                $i = rou nd($iSec/6 0/60/24);   640                $i = rou nd($iSec/6 0/60/24);
641                if (0 ==  $i || 1 = = $i) $s . = _t('_x_d ay_ago', ' 1');   641                if (0 ==  $i || 1 = = $i) $s . = _t('_x_d ay_ago', ' 1');
642                else $s  .= _t('_x_ day_ago',  $i, 's');   642                else $s  .= _t('_x_ day_ago',  $i, 's');
643           }   643           }
644       }else  {   644       }else  {
645           if  ($iSec >  -3600) {   645           if  ($iSec >  -3600) {
646                $iSec =  -$iSec;   646                $iSec =  -$iSec;
647                $i = rou nd($iSec/6 0);   647                $i = rou nd($iSec/6 0);
648                if (0 ==  $i || 1 = = $i) $s . = _t('_in_ x_minute',  '1');   648                if (0 ==  $i || 1 = = $i) $s . = _t('_in_ x_minute',  '1');
649                else $s  .= _t('_in _x_minute' , $i, 's') ;   649                else $s  .= _t('_in _x_minute' , $i, 's') ;
650           }   650           }
651           el se if ($iS ec > -8640 0) {   651           el se if ($iS ec > -8640 0) {
652                $iSec =  -$iSec;   652                $iSec =  -$iSec;
653                $i = rou nd($iSec/6 0/60);   653                $i = rou nd($iSec/6 0/60);
654                if (0 ==  $i || 1 = = $i) $s . = _t('_in_ x_hour', ' 1');   654                if (0 ==  $i || 1 = = $i) $s . = _t('_in_ x_hour', ' 1');
655                else $s  .= _t('_in _x_hour',  $i, 's');   655                else $s  .= _t('_in _x_hour',  $i, 's');
656           }   656           }
657           el seif ($iSe c < -86400 ) {   657           el seif ($iSe c < -86400 ) {
658                $iSec =  -$iSec;   658                $iSec =  -$iSec;
659                $i = rou nd($iSec/6 0/60/24);   659                $i = rou nd($iSec/6 0/60/24);
660                if (0 ==  $i || 1 = = $i) $s . = _t('_in_ x_day', '1 ');   660                if (0 ==  $i || 1 = = $i) $s . = _t('_in_ x_day', '1 ');
661                else $s  .= _t('_in _x_day', $ i, 's');   661                else $s  .= _t('_in _x_day', $ i, 's');
662           }   662           }
663       }   663       }
664       return  $s;   664       return  $s;
665   }   665   }
666     666  
667   function e xecSqlFile ( $filenam e )   667   function e xecSqlFile ( $filenam e )
668   {   668   {
669       if ( ! $f = fopen  ( $filena me, "r" )  )   669       if ( ! $f = fopen  ( $filena me, "r" )  )
670           re turn false ;   670           re turn false ;
671       db_res ( "SET NAM ES 'utf8'"  );   671       db_res ( "SET NAM ES 'utf8'"  );
672          672       
673       $s_sql  = "";   673       $s_sql  = "";
674       while  ( $s = fge ts ( $f, 1 0240) )   674       while  ( $s = fge ts ( $f, 1 0240) )
675       {   675       {
676           $s  = trim( $ s ); //Utf  with BOM  only   676           $s  = trim( $ s ); //Utf  with BOM  only
677              677           
678           if ( !strlen(  $s ) ) co ntinue;   678           if ( !strlen(  $s ) ) co ntinue;
679           if  ( mb_subs tr( $s, 0,  1 ) == '# '  ) conti nue; //pas s comments   679           if  ( mb_subs tr( $s, 0,  1 ) == '# '  ) conti nue; //pas s comments
680           if  ( mb_subs tr( $s, 0,  2 ) == '- -' ) conti nue;   680           if  ( mb_subs tr( $s, 0,  2 ) == '- -' ) conti nue;
681     681  
682           $s _sql .= $s ;   682           $s _sql .= $s ;
683              683           
684           if  ( mb_subs tr( $s, -1  ) != ';'  ) continue ;   684           if  ( mb_subs tr( $s, -1  ) != ';'  ) continue ;
685              685           
686           db _res( $s_s ql );   686           db _res( $s_s ql );
687           $s _sql = "";   687           $s _sql = "";
688       }   688       }
689     689  
690       fclose ($f);   690       fclose ($f);
691       return  true;   691       return  true;
692   }   692   }
693     693  
694   function r eplace_ful l_uris( $t ext )   694   function r eplace_ful l_uris( $t ext )
695   {   695   {
696       $text  = preg_rep lace_callb ack( '/([\ s\n\r]src\ =")([^"]+) (")/', 're place_full _uri', $te xt );   696       $text  = preg_rep lace_callb ack( '/([\ s\n\r]src\ =")([^"]+) (")/', 're place_full _uri', $te xt );
697       return  $text;   697       return  $text;
698   }   698   }
699     699  
700   function r eplace_ful l_uri( $ma tches )   700   function r eplace_ful l_uri( $ma tches )
701   {   701   {
702       global  $site;   702       global  $site;
703          703       
704       if( su bstr( $mat ches[2], 0 , 7 ) != ' http://' a nd substr(  $matches[ 2], 0, 6 )  != 'ftp:/ /' )   704       if( su bstr( $mat ches[2], 0 , 7 ) != ' http://' a nd substr(  $matches[ 2], 0, 6 )  != 'ftp:/ /' )
705           $m atches[2]  = $site['u rl'] . $ma tches[2];   705           $m atches[2]  = $site['u rl'] . $ma tches[2];
706          706       
707       return  $matches[ 1] . $matc hes[2] . $ matches[3] ;   707       return  $matches[ 1] . $matc hes[2] . $ matches[3] ;
708   }   708   }
709     709  
710   //-------- ---------- ---------- ---------- - friendly  permalink s -------- ---------- ---------- ---------- //   710   //-------- ---------- ---------- ---------- - friendly  permalink s -------- ---------- ---------- ---------- //
711   //-------- ---------- ---------- ---------- ----- main  functions  --------- ---------- ---------- ---------- //   711   //-------- ---------- ---------- ---------- ----- main  functions  --------- ---------- ---------- ---------- //
712   function u riGenerate  ($s, $sTa ble, $sFie ld, $iMaxL en = 255)   712   function u riGenerate  ($s, $sTa ble, $sFie ld, $iMaxL en = 255)
713   {   713   {
714     //$s = g et_mb_repl ace ('/[^\ pL^\pN]+/u ', '-', $s ); // unic ode charac ters   714     //$s = g et_mb_repl ace ('/[^\ pL^\pN]+/u ', '-', $s ); // unic ode charac ters
715     $s = get _mb_replac e ('/([^\d ^\w]+)/',  '-', $s);  // latin c haracters   715     $s = get _mb_replac e ('/([^\d ^\w]+)/',  '-', $s);  // latin c haracters
716     $s = get _mb_replac e ('/([-^] +)/', '-',  $s);   716     $s = get _mb_replac e ('/([-^] +)/', '-',  $s);
    717     if (!$s)  $s = '-';
717     718  
718     if (uriC heckUniq($ s, $sTable , $sField) ) return $ s;   719     if (uriC heckUniq($ s, $sTable , $sField) ) return $ s;
719     720  
720     // try t o add date   721     // try t o add date
721     722  
722     if (get_ mb_len($s)  > 240)   723     if (get_ mb_len($s)  > 240)
723        $s =  get_mb_sub str ($s, 0 , 240);   724        $s =  get_mb_sub str ($s, 0 , 240);
724     725  
725     $s .= '- ' . date(' Y-m-d');   726     $s .= '- ' . date(' Y-m-d');
726              727           
727     if (uriC heckUniq($ s, $sTable , $sField) ) return $ s;   728     if (uriC heckUniq($ s, $sTable , $sField) ) return $ s;
728     729  
729     // try t o add numb er   730     // try t o add numb er
730     731  
731     for ($i  = 0 ; $i <  999 ; ++$ i)   732     for ($i  = 0 ; $i <  999 ; ++$ i)
732     {            733     {         
733       if (ur iCheckUniq ($s . '-'  . $i, $sTa ble, $sFie ld))    734       if (ur iCheckUniq ($s . '-'  . $i, $sTa ble, $sFie ld)) 
734       {   735       {
735          ret urn ($s .  '-' . $i);                     736          ret urn ($s .  '-' . $i);                  
736       }   737       }
737     }   738     }
738      return  rand(0, 99 9999999);   739      return  rand(0, 99 9999999);
739   }   740   }
740     741  
741   function u riCheckUni q ($s, $sT able, $sFi eld)   742   function u riCheckUni q ($s, $sT able, $sFi eld)
742   {   743   {
743       return  !db_arr(" SELECT 1 F ROM $sTabl e WHERE $s Field = '$ s' LIMIT 1 ");   744       return  !db_arr(" SELECT 1 F ROM $sTabl e WHERE $s Field = '$ s' LIMIT 1 ");
744   }   745   }
745     746  
746   function g et_mb_repl ace ($sPat tern, $sRe place, $s)   747   function g et_mb_repl ace ($sPat tern, $sRe place, $s)
747   {   748   {
748       return  preg_repl ace ($sPat tern, $sRe place, $s) ;   749       return  preg_repl ace ($sPat tern, $sRe place, $s) ;
749   }   750   }
750     751  
751   function g et_mb_len  ($s)   752   function g et_mb_len  ($s)
752   {   753   {
753       if (fu nction_exi sts('mb_st rlen'))   754       if (fu nction_exi sts('mb_st rlen'))
754           re turn mb_st rlen ($s);   755           re turn mb_st rlen ($s);
755       else   756       else
756           re turn strle n ($s);   757           re turn strle n ($s);
757   }       758   }    
758     759  
759   function g et_mb_subs tr ($s, $i Start, $iL en)   760   function g et_mb_subs tr ($s, $i Start, $iL en)
760   {   761   {
761       if (fu nction_exi sts('mb_su bstr'))   762       if (fu nction_exi sts('mb_su bstr'))
762           re turn mb_su bstr ($s,  $iStart, $ iLen);   763           re turn mb_su bstr ($s,  $iStart, $ iLen);
763       else   764       else
764           re turn subst r ($s, $iS tart, $iLe n);   765           re turn subst r ($s, $iS tart, $iLe n);
765   }   766   }
766     767  
767   /*function  LocaledTi me( $sDate Time="2008 -04-15 16: 26:27" ) {   768   /*function  LocaledTi me( $sDate Time="2008 -04-15 16: 26:27" ) {
768       $sDate Key = _t(' _day_of_01 ', $iDay,  $iYear); / /   769       $sDate Key = _t(' _day_of_01 ', $iDay,  $iYear); / /
769       return  $sDateKey ;   770       return  $sDateKey ;
770   }*/   771   }*/
771     772  
772   function L ocaledData Time( $sTi mestamp='' , $iDType  = 1 ) { // 1. "April  7, 2008" " 7 Апреля 2 008"; 2. " 22:30"; 3.  "April 7,  2008" "7  Апреля 200 8, 22:30"   773   function L ocaledData Time( $sTi mestamp='' , $iDType  = 1 ) { // 1. "April  7, 2008" " 7 Апреля 2 008"; 2. " 22:30"; 3.  "April 7,  2008" "7  Апреля 200 8, 22:30"
773       $aDate Time = get date($sTim estamp);   774       $aDate Time = get date($sTim estamp);
774       $sResu lt = '';   775       $sResu lt = '';
775       if ($a DateTime[' year']) {   776       if ($a DateTime[' year']) {
776           sw itch ($iDT ype) {   777           sw itch ($iDT ype) {
777                case 1:   778                case 1:
778                    $sRe sult .= _t ('_day_of_ '.$aDateTi me['mon'],  $aDateTim e['mday'],  $aDateTim e['year']) ; //"April  7, 2008"  "7 Апреля  2008"   779                    $sRe sult .= _t ('_day_of_ '.$aDateTi me['mon'],  $aDateTim e['mday'],  $aDateTim e['year']) ; //"April  7, 2008"  "7 Апреля  2008"
779                    brea k;   780                    brea k;
780                case 2:   781                case 2:
781                    $sRe sult .= $a DateTime[' hours'] .  ':' . $aDa teTime['mi nutes']; / /"22:30"   782                    $sRe sult .= $a DateTime[' hours'] .  ':' . $aDa teTime['mi nutes']; / /"22:30"
782                    brea k;   783                    brea k;
783                case 3:   784                case 3:
784                    $sRe sult .= _t ('_day_of_ '.$aDateTi me['mon'],  $aDateTim e['mday'],  $aDateTim e['year'])  . ', ' .  $aDateTime ['hours']  . ':' . $a DateTime[' minutes'];  //"7 Апре ля 2008, 2 2:30"   785                    $sRe sult .= _t ('_day_of_ '.$aDateTi me['mon'],  $aDateTim e['mday'],  $aDateTim e['year'])  . ', ' .  $aDateTime ['hours']  . ':' . $a DateTime[' minutes'];  //"7 Апре ля 2008, 2 2:30"
785                    brea k;   786                    brea k;
786           }   787           }
787       }   788       }
788       return  $sResult;   789       return  $sResult;
789   /*   790   /*
790     791  
791   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_1' ;   792   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_1' ;
792   SET @last_ id = LAST_ INSERT_ID( );   793   SET @last_ id = LAST_ INSERT_ID( );
793   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  января {1} ');   794   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  января {1} ');
794     795  
795   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_2' ;   796   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_2' ;
796   SET @last_ id = LAST_ INSERT_ID( );   797   SET @last_ id = LAST_ INSERT_ID( );
797   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  февраля {1 }');   798   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  февраля {1 }');
798     799  
799   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_3' ;   800   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_3' ;
800   SET @last_ id = LAST_ INSERT_ID( );   801   SET @last_ id = LAST_ INSERT_ID( );
801   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  марта {1}' );   802   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  марта {1}' );
802     803  
803   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_4' ;   804   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_4' ;
804   SET @last_ id = LAST_ INSERT_ID( );   805   SET @last_ id = LAST_ INSERT_ID( );
805   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  апреля {1} ');   806   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  апреля {1} ');
806     807  
807   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_5' ;   808   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_5' ;
808   SET @last_ id = LAST_ INSERT_ID( );   809   SET @last_ id = LAST_ INSERT_ID( );
809   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  мая {1}');   810   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  мая {1}');
810     811  
811   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_6' ;   812   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_6' ;
812   SET @last_ id = LAST_ INSERT_ID( );   813   SET @last_ id = LAST_ INSERT_ID( );
813   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  июня {1}') ;   814   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  июня {1}') ;
814     815  
815   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_7' ;   816   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_7' ;
816   SET @last_ id = LAST_ INSERT_ID( );   817   SET @last_ id = LAST_ INSERT_ID( );
817   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  июля {1}') ;   818   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  июля {1}') ;
818     819  
819   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_8' ;   820   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_8' ;
820   SET @last_ id = LAST_ INSERT_ID( );   821   SET @last_ id = LAST_ INSERT_ID( );
821   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  августа {1 }');   822   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  августа {1 }');
822     823  
823   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_9' ;   824   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_9' ;
824   SET @last_ id = LAST_ INSERT_ID( );   825   SET @last_ id = LAST_ INSERT_ID( );
825   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  сентября { 1}');   826   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  сентября { 1}');
826     827  
827   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_10 ';   828   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_10 ';
828   SET @last_ id = LAST_ INSERT_ID( );   829   SET @last_ id = LAST_ INSERT_ID( );
829   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  октября {1 }');   830   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  октября {1 }');
830     831  
831   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_11 ';   832   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_11 ';
832   SET @last_ id = LAST_ INSERT_ID( );   833   SET @last_ id = LAST_ INSERT_ID( );
833   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  ноября {1} ');   834   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  ноября {1} ');
834     835  
835   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_12 ';   836   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_12 ';
836   SET @last_ id = LAST_ INSERT_ID( );   837   SET @last_ id = LAST_ INSERT_ID( );
837   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  декабря {1 }');   838   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  декабря {1 }');
838     839  
839   */   840   */
840   }   841   }
841     842  
842   ?>   843   ?>