37. File Comparison Report

Produced on Thu Jul 17 07:17:25 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.

37.1 Files compared

# Location File Last Modified
1 Dolphin-v.6.1.2\inc utils.inc.php Thu Jun 12 09:57:40 2008 UTC
2 Dolphin-v.6.1.3\inc utils.inc.php Wed Jul 16 09:51:20 2008 UTC

37.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 5 1670
Changed 2 7
Inserted 0 0
Removed 2 3

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

37.4 Active regular expressions

No regular expressions were active.

37.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        $path   =   BX_DIRECTO RY_PATH_RO OT   .   'templates /';
435      
436        $path   =   $dir['root '] .'template s/';    
437       $templ _choices =  array();   435       $templ _choices =  array();
438       $handl e = opendi r( $path ) ;   436       $handl e = opendi r( $path ) ;
439     437  
440       while  ( false != = ($filena me = readd ir($handle )) )   438       while  ( false != = ($filena me = readd ir($handle )) )
441       {   439       {
442           if  ( is_dir( $path.$fil ename) &&  substr($fi lename, 0,  5) == 'tm pl_' )   440           if  ( is_dir( $path.$fil ename) &&  substr($fi lename, 0,  5) == 'tm pl_' )
443           {   441           {
444                $sTemplN ame = '';   442                $sTemplN ame = '';
445                @include ( $path.$f ilename.'/ scripts/Bx TemplName. php' );   443                @include ( $path.$f ilename.'/ scripts/Bx TemplName. php' );
446                if( $sTe mplName )   444                if( $sTe mplName )
447                    $tem pl_choices [substr($f ilename, 5 )] = $sTem plName;   445                    $tem pl_choices [substr($f ilename, 5 )] = $sTem plName;
448           }   446           }
449       }   447       }
450       closed ir( $handl e );   448       closed ir( $handl e );
451       return  $templ_ch oices;   449       return  $templ_ch oices;
452   }   450   }
453     451  
454   /*   452   /*
455    * The Fun ction Show  a Line wi th Templat es Names   453    * The Fun ction Show  a Line wi th Templat es Names
456   */   454   */
457     455  
458   function t emplates_s elect_txt( )   456   function t emplates_s elect_txt( )
459   {   457   {
460       global  $dir;    
461      
462       $templ _choices =  get_templ ates_array ();   458       $templ _choices =  get_templ ates_array ();
463       $curre nt_templat e = ( strl en( $_GET[ 'skin'] )  ) ? $_GET[ 'skin'] :  $_COOKIE[' skin'];   459       $curre nt_templat e = ( strl en( $_GET[ 'skin'] )  ) ? $_GET[ 'skin'] :  $_COOKIE[' skin'];
464     460  
465     461  
466       foreac h ($templ_ choices as  $tmpl_key  => $tmpl_ value)   462       foreac h ($templ_ choices as  $tmpl_key  => $tmpl_ value)
467       {   463       {
468           if  ($current _template  == $tmpl_k ey)   464           if  ($current _template  == $tmpl_k ey)
469           {   465           {
470                $ReturnR esult .= $ tmpl_value ;   466                $ReturnR esult .= $ tmpl_value ;
471                $ReturnR esult .= '  | ';   467                $ReturnR esult .= '  | ';
472           }   468           }
473           el se   469           el se
474           {   470           {
475                foreach  ($_GET as  $param_key  => $param _value)   471                foreach  ($_GET as  $param_key  => $param _value)
476                {   472                {
477     473  
478                    if (  'skin' !=  $param_ke y ) $sGetT ransfer .=  "&{$param _key}={$pa ram_value} ";   474                    if (  'skin' !=  $param_ke y ) $sGetT ransfer .=  "&{$param _key}={$pa ram_value} ";
479     475  
480                }   476                }
481     477  
482                $ReturnR esult .= ' <a href="'  . $_SERVE R['PHP_SEL F'] . '?sk in='. $tmp l_key . $s GetTransfe r . '">' .  $tmpl_val ue . '</a> ';   478                $ReturnR esult .= ' <a href="'  . $_SERVE R['PHP_SEL F'] . '?sk in='. $tmp l_key . $s GetTransfe r . '">' .  $tmpl_val ue . '</a> ';
483                $ReturnR esult .= '  | ';   479                $ReturnR esult .= '  | ';
484     480  
485           }   481           }
486       }   482       }
487     483  
488       return  $ReturnRe sult;   484       return  $ReturnRe sult;
489     485  
490     486  
491   }   487   }
492     488  
493   /**   489   /**
494    * callbac k function  for inclu ding templ ate files   490    * callbac k function  for inclu ding templ ate files
495    */   491    */
496   function g etTemplate IncludedFi le( $aFile  )   492   function g etTemplate IncludedFi le( $aFile  )
497   {   493   {
498       global  $tmpl;   494       global  $tmpl;
499     495  
500       // rea d include  file   496       // rea d include  file
501     497  
502       $sFile  = BX_DIRE CTORY_PATH _ROOT . 't emplates/t mpl_' . $t mpl . '/'.  $aFile['1 '];   498       $sFile  = BX_DIRE CTORY_PATH _ROOT . 't emplates/t mpl_' . $t mpl . '/'.  $aFile['1 '];
503     499  
504       if( fi le_exists  ($sFile) & & is_file(  $sFile )  )   500       if( fi le_exists  ($sFile) & & is_file(  $sFile )  )
505       {   501       {
506           $f p = fopen  ($sFile, " r");   502           $f p = fopen  ($sFile, " r");
507           if  ($fp)   503           if  ($fp)
508           {   504           {
509                $s = fre ad ($fp, f ilesize ($ sFile));   505                $s = fre ad ($fp, f ilesize ($ sFile));
510                fclose ( $fp);   506                fclose ( $fp);
511                return $ s;   507                return $ s;
512           }   508           }
513       }   509       }
514     510  
515       return  "<b>error  reading { $aFile[1]} </b>";   511       return  "<b>error  reading { $aFile[1]} </b>";
516   }   512   }
517     513  
518   function g etTemplate BaseFile(  $aFile )   514   function g etTemplate BaseFile(  $aFile )
519   {   515   {
520       global  $dir;    
521       global  $tmpl;   516       global  $tmpl;
522     517  
523       // rea d include  file   518       // rea d include  file
524       $sFile  = BX_DIRE CTORY_PATH _ROOT . 't emplates/b ase/' . $a File['1'];   519       $sFile  = BX_DIRE CTORY_PATH _ROOT . 't emplates/b ase/' . $a File['1'];
525     520  
526       if (fi le_exists  ($sFile) & & is_file(  $sFile ))   521       if (fi le_exists  ($sFile) & & is_file(  $sFile ))
527       {   522       {
528           $f p = fopen  ($sFile, " r");   523           $f p = fopen  ($sFile, " r");
529           if  ($fp)   524           if  ($fp)
530           {   525           {
531                $s = fre ad ($fp, f ilesize ($ sFile));   526                $s = fre ad ($fp, f ilesize ($ sFile));
532                fclose ( $fp);   527                fclose ( $fp);
533                return $ s;   528                return $ s;
534           }   529           }
535       }   530       }
536     531  
537       return  "<b>error  reading b ase {$aFil e[1]}</b>" ;   532       return  "<b>error  reading b ase {$aFil e[1]}</b>" ;
538   }   533   }
539     534  
540   function e xtFileExis ts( $sFile Src )   535   function e xtFileExis ts( $sFile Src )
541   {   536   {
542     537  
543       if( fi le_exists(  $sFileSrc  ) && is_f ile( $sFil eSrc ) )   538       if( fi le_exists(  $sFileSrc  ) && is_f ile( $sFil eSrc ) )
544       {   539       {
545           $r et = true;   540           $r et = true;
546       }   541       }
547       else   542       else
548       {   543       {
549           $r et = false ;   544           $r et = false ;
550       }   545       }
551     546  
552       return  $ret;   547       return  $ret;
553   }   548   }
554     549  
555   function e xtDirExist s( $sDirSr c )   550   function e xtDirExist s( $sDirSr c )
556   {   551   {
557     552  
558       if( fi le_exists(  $sDirSrc  ) && is_di r( $sDirSr c ) )   553       if( fi le_exists(  $sDirSrc  ) && is_di r( $sDirSr c ) )
559       {   554       {
560           $r et = true;   555           $r et = true;
561       }   556       }
562       else   557       else
563       {   558       {
564           $r et = false ;   559           $r et = false ;
565       }   560       }
566     561  
567       return  $ret;   562       return  $ret;
568   }   563   }
569     564  
570   function g etVisitorI P()   565   function g etVisitorI P()
571   {   566   {
572       $ip =  '';   567       $ip =  '';
573       if( (  isset( $_S ERVER['HTT P_X_FORWAR DED_FOR']  ) ) && ( ! empty( $_S ERVER['HTT P_X_FORWAR DED_FOR']  ) ) )   568       if( (  isset( $_S ERVER['HTT P_X_FORWAR DED_FOR']  ) ) && ( ! empty( $_S ERVER['HTT P_X_FORWAR DED_FOR']  ) ) )
574       {   569       {
575           $i p = $_SERV ER['HTTP_X _FORWARDED _FOR'];   570           $i p = $_SERV ER['HTTP_X _FORWARDED _FOR'];
576       }   571       }
577       elseif ( ( isset(  $_SERVER[ 'HTTP_CLIE NT_IP']))  && (!empty ($_SERVER[ 'HTTP_CLIE NT_IP'] )  ) )   572       elseif ( ( isset(  $_SERVER[ 'HTTP_CLIE NT_IP']))  && (!empty ($_SERVER[ 'HTTP_CLIE NT_IP'] )  ) )
578       {   573       {
579           $i p = explod e(".",$_SE RVER['HTTP _CLIENT_IP ']);   574           $i p = explod e(".",$_SE RVER['HTTP _CLIENT_IP ']);
580           $i p = $ip[3] .".".$ip[2 ].".".$ip[ 1].".".$ip [0];   575           $i p = $ip[3] .".".$ip[2 ].".".$ip[ 1].".".$ip [0];
581       }   576       }
582       elseif ((!isset(  $_SERVER[' HTTP_X_FOR WARDED_FOR '])) || (e mpty($_SER VER['HTTP_ X_FORWARDE D_FOR'])))   577       elseif ((!isset(  $_SERVER[' HTTP_X_FOR WARDED_FOR '])) || (e mpty($_SER VER['HTTP_ X_FORWARDE D_FOR'])))
583       {   578       {
584           if  ((!isset(  $_SERVER[ 'HTTP_CLIE NT_IP']))  && (empty( $_SERVER[' HTTP_CLIEN T_IP'])))   579           if  ((!isset(  $_SERVER[ 'HTTP_CLIE NT_IP']))  && (empty( $_SERVER[' HTTP_CLIEN T_IP'])))
585           {   580           {
586                $ip = $_ SERVER['RE MOTE_ADDR' ];   581                $ip = $_ SERVER['RE MOTE_ADDR' ];
587           }   582           }
588       }   583       }
589       else   584       else
590       {   585       {
591           $i p = "0.0.0 .0";   586           $i p = "0.0.0 .0";
592       }   587       }
593     588  
594       return  $ip;   589       return  $ip;
595   }   590   }
596     591  
597   function g enFlag( $c ountry )   592   function g enFlag( $c ountry )
598   {   593   {
599       global  $site;   594       global  $site;
600       $count ry = strto lower( $co untry );   595       $count ry = strto lower( $co untry );
601          596       
602       return  "<img src =\"{$site[ 'flags']}{ $country}. gif\" />";   597       return  "<img src =\"{$site[ 'flags']}{ $country}. gif\" />";
603   }   598   }
604     599  
605   // print d ebug infor mation ( e .g. arrays  )   600   // print d ebug infor mation ( e .g. arrays  )
606   function e choDbg( $w hat, $desc  = '' )   601   function e choDbg( $w hat, $desc  = '' )
607   {   602   {
608       if ( $ desc )   603       if ( $ desc )
609           ec ho "<b>$de sc:</b> ";   604           ec ho "<b>$de sc:</b> ";
610       echo " <pre>";   605       echo " <pre>";
611           pr int_r( $wh at );   606           pr int_r( $wh at );
612       echo " </pre>\n";   607       echo " </pre>\n";
613   }   608   }
614     609  
615   function c lear_xss($ val)   610   function c lear_xss($ val)
616   {   611   {
617       global  $dir;   612        require_on ce(   BX_DIRECTO RY_PATH_PL UGINS   .   '
safehtml/s afehtml.ph p '   );
618        require_on ce(   "{$dir['pl ugins ' ]} safehtml/s afehtml.ph p "   );    
619       $safeh tml =& new  safehtml( );   613       $safeh tml =& new  safehtml( );
620       $res =  $safehtml ->parse($v al);   614       $res =  $safehtml ->parse($v al);
621          615       
622       return  $res;   616       return  $res;
623   }   617   }
624     618  
625   function _ format_whe n ($iSec)  {   619   function _ format_whe n ($iSec)  {
626       $s = ' ';   620       $s = ' ';
627     621  
628       if ($i Sec>0) {   622       if ($i Sec>0) {
629           if  ($iSec <  3600) {   623           if  ($iSec <  3600) {
630                $i = rou nd($iSec/6 0);   624                $i = rou nd($iSec/6 0);
631                if (0 ==  $i || 1 = = $i) $s . = _t('_x_m inute_ago' , '1');   625                if (0 ==  $i || 1 = = $i) $s . = _t('_x_m inute_ago' , '1');
632                else $s  .= _t('_x_ minute_ago ', $i, 's' );   626                else $s  .= _t('_x_ minute_ago ', $i, 's' );
633           }   627           }
634           el se if ($iS ec < 86400 ) {   628           el se if ($iS ec < 86400 ) {
635                $i = rou nd($iSec/6 0/60);   629                $i = rou nd($iSec/6 0/60);
636                if (0 ==  $i || 1 = = $i) $s . = _t('_x_h our_ago',  '1');   630                if (0 ==  $i || 1 = = $i) $s . = _t('_x_h our_ago',  '1');
637                else $s  .= _t('_x_ hour_ago',  $i, 's');   631                else $s  .= _t('_x_ hour_ago',  $i, 's');
638           }   632           }
639           el se {   633           el se {
640                $i = rou nd($iSec/6 0/60/24);   634                $i = rou nd($iSec/6 0/60/24);
641                if (0 ==  $i || 1 = = $i) $s . = _t('_x_d ay_ago', ' 1');   635                if (0 ==  $i || 1 = = $i) $s . = _t('_x_d ay_ago', ' 1');
642                else $s  .= _t('_x_ day_ago',  $i, 's');   636                else $s  .= _t('_x_ day_ago',  $i, 's');
643           }   637           }
644       }else  {   638       }else  {
645           if  ($iSec >  -3600) {   639           if  ($iSec >  -3600) {
646                $iSec =  -$iSec;   640                $iSec =  -$iSec;
647                $i = rou nd($iSec/6 0);   641                $i = rou nd($iSec/6 0);
648                if (0 ==  $i || 1 = = $i) $s . = _t('_in_ x_minute',  '1');   642                if (0 ==  $i || 1 = = $i) $s . = _t('_in_ x_minute',  '1');
649                else $s  .= _t('_in _x_minute' , $i, 's') ;   643                else $s  .= _t('_in _x_minute' , $i, 's') ;
650           }   644           }
651           el se if ($iS ec > -8640 0) {   645           el se if ($iS ec > -8640 0) {
652                $iSec =  -$iSec;   646                $iSec =  -$iSec;
653                $i = rou nd($iSec/6 0/60);   647                $i = rou nd($iSec/6 0/60);
654                if (0 ==  $i || 1 = = $i) $s . = _t('_in_ x_hour', ' 1');   648                if (0 ==  $i || 1 = = $i) $s . = _t('_in_ x_hour', ' 1');
655                else $s  .= _t('_in _x_hour',  $i, 's');   649                else $s  .= _t('_in _x_hour',  $i, 's');
656           }   650           }
657           el seif ($iSe c < -86400 ) {   651           el seif ($iSe c < -86400 ) {
658                $iSec =  -$iSec;   652                $iSec =  -$iSec;
659                $i = rou nd($iSec/6 0/60/24);   653                $i = rou nd($iSec/6 0/60/24);
660                if (0 ==  $i || 1 = = $i) $s . = _t('_in_ x_day', '1 ');   654                if (0 ==  $i || 1 = = $i) $s . = _t('_in_ x_day', '1 ');
661                else $s  .= _t('_in _x_day', $ i, 's');   655                else $s  .= _t('_in _x_day', $ i, 's');
662           }   656           }
663       }   657       }
664       return  $s;   658       return  $s;
665   }   659   }
666     660  
667   function e xecSqlFile ( $filenam e )   661   function e xecSqlFile ( $filenam e )
668   {   662   {
669       if ( ! $f = fopen  ( $filena me, "r" )  )   663       if ( ! $f = fopen  ( $filena me, "r" )  )
670           re turn false ;   664           re turn false ;
671       db_res ( "SET NAM ES 'utf8'"  );   665       db_res ( "SET NAM ES 'utf8'"  );
672          666       
673       $s_sql  = "";   667       $s_sql  = "";
674       while  ( $s = fge ts ( $f, 1 0240) )   668       while  ( $s = fge ts ( $f, 1 0240) )
675       {   669       {
676           $s  = trim( $ s ); //Utf  with BOM  only   670           $s  = trim( $ s ); //Utf  with BOM  only
677              671           
678           if ( !strlen(  $s ) ) co ntinue;   672           if ( !strlen(  $s ) ) co ntinue;
679           if  ( mb_subs tr( $s, 0,  1 ) == '# '  ) conti nue; //pas s comments   673           if  ( mb_subs tr( $s, 0,  1 ) == '# '  ) conti nue; //pas s comments
680           if  ( mb_subs tr( $s, 0,  2 ) == '- -' ) conti nue;   674           if  ( mb_subs tr( $s, 0,  2 ) == '- -' ) conti nue;
681     675  
682           $s _sql .= $s ;   676           $s _sql .= $s ;
683              677           
684           if  ( mb_subs tr( $s, -1  ) != ';'  ) continue ;   678           if  ( mb_subs tr( $s, -1  ) != ';'  ) continue ;
685              679           
686           db _res( $s_s ql );   680           db _res( $s_s ql );
687           $s _sql = "";   681           $s _sql = "";
688       }   682       }
689     683  
690       fclose ($f);   684       fclose ($f);
691       return  true;   685       return  true;
692   }   686   }
693     687  
694   function r eplace_ful l_uris( $t ext )   688   function r eplace_ful l_uris( $t ext )
695   {   689   {
696       $text  = preg_rep lace_callb ack( '/([\ s\n\r]src\ =")([^"]+) (")/', 're place_full _uri', $te xt );   690       $text  = preg_rep lace_callb ack( '/([\ s\n\r]src\ =")([^"]+) (")/', 're place_full _uri', $te xt );
697       return  $text;   691       return  $text;
698   }   692   }
699     693  
700   function r eplace_ful l_uri( $ma tches )   694   function r eplace_ful l_uri( $ma tches )
701   {   695   {
702       global  $site;   696       global  $site;
703          697       
704       if( su bstr( $mat ches[2], 0 , 7 ) != ' http://' a nd substr(  $matches[ 2], 0, 6 )  != 'ftp:/ /' )   698       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];   699           $m atches[2]  = $site['u rl'] . $ma tches[2];
706          700       
707       return  $matches[ 1] . $matc hes[2] . $ matches[3] ;   701       return  $matches[ 1] . $matc hes[2] . $ matches[3] ;
708   }   702   }
709     703  
710   //-------- ---------- ---------- ---------- - friendly  permalink s -------- ---------- ---------- ---------- //   704   //-------- ---------- ---------- ---------- - friendly  permalink s -------- ---------- ---------- ---------- //
711   //-------- ---------- ---------- ---------- ----- main  functions  --------- ---------- ---------- ---------- //   705   //-------- ---------- ---------- ---------- ----- main  functions  --------- ---------- ---------- ---------- //
712   function u riGenerate  ($s, $sTa ble, $sFie ld, $iMaxL en = 255)   706   function u riGenerate  ($s, $sTa ble, $sFie ld, $iMaxL en = 255)
713   {   707   {
714     //$s = g et_mb_repl ace ('/[^\ pL^\pN]+/u ', '-', $s ); // unic ode charac ters   708     //$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   709     $s = get _mb_replac e ('/([^\d ^\w]+)/',  '-', $s);  // latin c haracters
716     $s = get _mb_replac e ('/([-^] +)/', '-',  $s);   710     $s = get _mb_replac e ('/([-^] +)/', '-',  $s);
717     if (!$s)  $s = '-';   711     if (!$s)  $s = '-';
718     712  
719     if (uriC heckUniq($ s, $sTable , $sField) ) return $ s;   713     if (uriC heckUniq($ s, $sTable , $sField) ) return $ s;
720     714  
721     // try t o add date   715     // try t o add date
722     716  
723     if (get_ mb_len($s)  > 240)   717     if (get_ mb_len($s)  > 240)
724        $s =  get_mb_sub str ($s, 0 , 240);   718        $s =  get_mb_sub str ($s, 0 , 240);
725     719  
726     $s .= '- ' . date(' Y-m-d');   720     $s .= '- ' . date(' Y-m-d');
727              721           
728     if (uriC heckUniq($ s, $sTable , $sField) ) return $ s;   722     if (uriC heckUniq($ s, $sTable , $sField) ) return $ s;
729     723  
730     // try t o add numb er   724     // try t o add numb er
731     725  
732     for ($i  = 0 ; $i <  999 ; ++$ i)   726     for ($i  = 0 ; $i <  999 ; ++$ i)
733     {            727     {         
734       if (ur iCheckUniq ($s . '-'  . $i, $sTa ble, $sFie ld))    728       if (ur iCheckUniq ($s . '-'  . $i, $sTa ble, $sFie ld)) 
735       {   729       {
736          ret urn ($s .  '-' . $i);                     730          ret urn ($s .  '-' . $i);                  
737       }   731       }
738     }   732     }
739      return  rand(0, 99 9999999);   733      return  rand(0, 99 9999999);
740   }   734   }
741     735  
742   function u riCheckUni q ($s, $sT able, $sFi eld)   736   function u riCheckUni q ($s, $sT able, $sFi eld)
743   {   737   {
744       return  !db_arr(" SELECT 1 F ROM $sTabl e WHERE $s Field = '$ s' LIMIT 1 ");   738       return  !db_arr(" SELECT 1 F ROM $sTabl e WHERE $s Field = '$ s' LIMIT 1 ");
745   }   739   }
746     740  
747   function g et_mb_repl ace ($sPat tern, $sRe place, $s)   741   function g et_mb_repl ace ($sPat tern, $sRe place, $s)
748   {   742   {
749       return  preg_repl ace ($sPat tern, $sRe place, $s) ;   743       return  preg_repl ace ($sPat tern, $sRe place, $s) ;
750   }   744   }
751     745  
752   function g et_mb_len  ($s)   746   function g et_mb_len  ($s)
753   {   747   {
754       if (fu nction_exi sts('mb_st rlen'))   748       if (fu nction_exi sts('mb_st rlen'))
755           re turn mb_st rlen ($s);   749           re turn mb_st rlen ($s);
756       else   750       else
757           re turn strle n ($s);   751           re turn strle n ($s);
758   }       752   }    
759     753  
760   function g et_mb_subs tr ($s, $i Start, $iL en)   754   function g et_mb_subs tr ($s, $i Start, $iL en)
761   {   755   {
762       if (fu nction_exi sts('mb_su bstr'))   756       if (fu nction_exi sts('mb_su bstr'))
763           re turn mb_su bstr ($s,  $iStart, $ iLen);   757           re turn mb_su bstr ($s,  $iStart, $ iLen);
764       else   758       else
765           re turn subst r ($s, $iS tart, $iLe n);   759           re turn subst r ($s, $iS tart, $iLe n);
766   }   760   }
767     761  
768   /*function  LocaledTi me( $sDate Time="2008 -04-15 16: 26:27" ) {   762   /*function  LocaledTi me( $sDate Time="2008 -04-15 16: 26:27" ) {
769       $sDate Key = _t(' _day_of_01 ', $iDay,  $iYear); / /   763       $sDate Key = _t(' _day_of_01 ', $iDay,  $iYear); / /
770       return  $sDateKey ;   764       return  $sDateKey ;
771   }*/   765   }*/
772     766  
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"   767   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"
774       $aDate Time = get date($sTim estamp);   768       $aDate Time = get date($sTim estamp);
775       $sResu lt = '';   769       $sResu lt = '';
776       if ($a DateTime[' year']) {   770       if ($a DateTime[' year']) {
777           sw itch ($iDT ype) {   771           sw itch ($iDT ype) {
778                case 1:   772                case 1:
779                    $sRe sult .= _t ('_day_of_ '.$aDateTi me['mon'],  $aDateTim e['mday'],  $aDateTim e['year']) ; //"April  7, 2008"  "7 Апреля  2008"   773                    $sRe sult .= _t ('_day_of_ '.$aDateTi me['mon'],  $aDateTim e['mday'],  $aDateTim e['year']) ; //"April  7, 2008"  "7 Апреля  2008"
780                    brea k;   774                    brea k;
781                case 2:   775                case 2:
782                    $sRe sult .= $a DateTime[' hours'] .  ':' . $aDa teTime['mi nutes']; / /"22:30"   776                    $sRe sult .= $a DateTime[' hours'] .  ':' . $aDa teTime['mi nutes']; / /"22:30"
783                    brea k;   777                    brea k;
784                case 3:   778                case 3:
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"   779                    $sRe sult .= _t ('_day_of_ '.$aDateTi me['mon'],  $aDateTim e['mday'],  $aDateTim e['year'])  . ', ' .  $aDateTime ['hours']  . ':' . $a DateTime[' minutes'];  //"7 Апре ля 2008, 2 2:30"
786                    brea k;   780                    brea k;
787           }   781           }
788       }   782       }
789       return  $sResult;   783       return  $sResult;
790   /*   784   /*
791     785  
792   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_1' ;   786   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_1' ;
793   SET @last_ id = LAST_ INSERT_ID( );   787   SET @last_ id = LAST_ INSERT_ID( );
794   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  января {1} ');   788   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  января {1} ');
795     789  
796   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_2' ;   790   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_2' ;
797   SET @last_ id = LAST_ INSERT_ID( );   791   SET @last_ id = LAST_ INSERT_ID( );
798   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  февраля {1 }');   792   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  февраля {1 }');
799     793  
800   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_3' ;   794   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_3' ;
801   SET @last_ id = LAST_ INSERT_ID( );   795   SET @last_ id = LAST_ INSERT_ID( );
802   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  марта {1}' );   796   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  марта {1}' );
803     797  
804   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_4' ;   798   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_4' ;
805   SET @last_ id = LAST_ INSERT_ID( );   799   SET @last_ id = LAST_ INSERT_ID( );
806   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  апреля {1} ');   800   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  апреля {1} ');
807     801  
808   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_5' ;   802   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_5' ;
809   SET @last_ id = LAST_ INSERT_ID( );   803   SET @last_ id = LAST_ INSERT_ID( );
810   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  мая {1}');   804   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  мая {1}');
811     805  
812   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_6' ;   806   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_6' ;
813   SET @last_ id = LAST_ INSERT_ID( );   807   SET @last_ id = LAST_ INSERT_ID( );
814   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  июня {1}') ;   808   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  июня {1}') ;
815     809  
816   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_7' ;   810   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_7' ;
817   SET @last_ id = LAST_ INSERT_ID( );   811   SET @last_ id = LAST_ INSERT_ID( );
818   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  июля {1}') ;   812   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  июля {1}') ;
819     813  
820   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_8' ;   814   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_8' ;
821   SET @last_ id = LAST_ INSERT_ID( );   815   SET @last_ id = LAST_ INSERT_ID( );
822   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  августа {1 }');   816   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  августа {1 }');
823     817  
824   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_9' ;   818   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_9' ;
825   SET @last_ id = LAST_ INSERT_ID( );   819   SET @last_ id = LAST_ INSERT_ID( );
826   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  сентября { 1}');   820   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  сентября { 1}');
827     821  
828   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_10 ';   822   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_10 ';
829   SET @last_ id = LAST_ INSERT_ID( );   823   SET @last_ id = LAST_ INSERT_ID( );
830   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  октября {1 }');   824   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  октября {1 }');
831     825  
832   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_11 ';   826   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_11 ';
833   SET @last_ id = LAST_ INSERT_ID( );   827   SET @last_ id = LAST_ INSERT_ID( );
834   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  ноября {1} ');   828   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  ноября {1} ');
835     829  
836   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_12 ';   830   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_12 ';
837   SET @last_ id = LAST_ INSERT_ID( );   831   SET @last_ id = LAST_ INSERT_ID( );
838   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  декабря {1 }');   832   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  декабря {1 }');
839     833  
840   */   834   */
841   }   835   }
842     836  
843   ?>   837   ?>