245. File Comparison Report

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

245.1 Files compared

# Location File Last Modified
1 Dolphin-v.6.0.5\inc utils.inc.php Wed Mar 5 05:31:26 2008 UTC
2 Dolphin-v.6.1.0\inc utils.inc.php Sat Apr 26 08:19:16 2008 UTC

245.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 14 1384
Changed 11 43
Inserted 1 132
Removed 1 1

245.3 Comparison options

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

245.4 Active regular expressions

No regular expressions were active.

245.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("SE LECT   CO U NT (`Check`)   AS  
cnt  
FROM   `FriendLis t`   WHERE   `ID`='{$id 1}'   AND   `Profile`= '{$id2}'   OR   `ID`='{$id 2}'   AND   `Profile`= '{$id1}'") ;
  106        $cnt   =   db_arr("SE LECT   S U M (`Check`)   AS   ' cnt '   FROM   `FriendLis t`   WHERE   `ID`='{$id 1}'   AND   `Profile`= '{$id2}'   OR   `ID`='{$id 2}'   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   sendMail(   $sRecipien tEmail,   $sMailSubj ect,   $sMailBody ,   $iRecipien tID   =   '',   $aPlus   =   ''  
)
  388   function   sendMail(   $sRecipien tEmail,   $sMailSubj ect,   $sMailBody ,   $iRecipien tID   =   '',   $aPlus   =   '' ,   $sEmailFla g   =   'text'   )   {
389   {    
390       global  $site;   389       global  $site;
391     390  
392       if( $i RecipientI D )   391       if( $i RecipientI D )
393           $a RecipientI nfo = getP rofileInfo ( $iRecipi entID );   392           $a RecipientI nfo = getP rofileInfo ( $iRecipi entID );
394     393  
395       $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']}> ";
396       $sMail Parameters     = "-f{ $site['ema il_notify' ]}";   395       $sMail Parameters     = "-f{ $site['ema il_notify' ]}";
397     396  
398      
399       $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 ) ;
400     398  
401       $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 );
402       $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 );
403       $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 );
404       $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 ) ;
405       $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 ) ;
406       $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 );
407       $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 ) ;
408     406  
409     407        if(   is_array($ aPlus)   )   {
410        if(   is_array($ aPlus)   )
  408            foreach   (   $aPlus   as   $key   =>   $value   )   {
411       {    
412            foreach   (   $aPlus   as   $key   =>   $value   )
   
413           {    
414                $sMailBo dy = str_r eplace( '< ' . $key .  '>', $val ue, $sMail Body );   409                $sMailBo dy = str_r eplace( '< ' . $key .  '>', $val ue, $sMail Body );
415           }   410           }
416       }   411       }
417     412  
418       $sMail Subject =  '=?UTF-8?B ?' . base6 4_encode(  $sMailSubj ect ) . '? =';   413       $sMail Subject =  '=?UTF-8?B ?' . base6 4_encode(  $sMailSubj ect ) . '? =';
419          414  
420       $sMail Header = " MIME-Versi on: 1.0\r\ n" . $sMai lHeader;   415       $sMail Header = " MIME-Versi on: 1.0\r\ n" . $sMai lHeader;
421          416  
422        if(   ' HTML '   ==   $ aRecipient Info[' EmailFlag '] )
  417        if(   ' html '   ==   $ s EmailFlag
)   {
423       {    
424           $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;
425           $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 );
426       }   420        }   else   {
427       
else
   
428       {    
429           $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;
430           $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 );
431       }   423       }
432     424  
433       return  $iSending Result;   425       return  $iSending Result;
434   }   426   }
435     427  
436   /*   428   /*
437    * Getting  Array wit h Template s Names   429    * Getting  Array wit h Template s Names
438   */   430   */
439     431  
440   function g et_templat es_array()   432   function g et_templat es_array()
441   {   433   {
442       global  $dir;   434       global  $dir;
443     435  
444       $path  = $dir['ro ot'].'temp lates/';   436       $path  = $dir['ro ot'].'temp lates/';
445       $templ _choices =  array();   437       $templ _choices =  array();
446       $handl e = opendi r( $path ) ;   438       $handl e = opendi r( $path ) ;
447     439  
448       while  ( false != = ($filena me = readd ir($handle )) )   440       while  ( false != = ($filena me = readd ir($handle )) )
449       {   441       {
450           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_' )
451           {   443           {
452                $sTemplN ame = '';   444                $sTemplN ame = '';
453                @include ( $path.$f ilename.'/ scripts/Bx TemplName. php' );   445                @include ( $path.$f ilename.'/ scripts/Bx TemplName. php' );
454                if( $sTe mplName )   446                if( $sTe mplName )
455                    $tem pl_choices [substr($f ilename, 5 )] = $sTem plName;   447                    $tem pl_choices [substr($f ilename, 5 )] = $sTem plName;
456           }   448           }
457       }   449       }
458       closed ir( $handl e );   450       closed ir( $handl e );
459       return  $templ_ch oices;   451       return  $templ_ch oices;
460   }   452   }
461     453  
462   /*   454   /*
463    * The Fun ction Show  a Line wi th Templat es Names   455    * The Fun ction Show  a Line wi th Templat es Names
464   */   456   */
465     457  
466   function t emplates_s elect_txt( )   458   function t emplates_s elect_txt( )
467   {   459   {
468       global  $dir;   460       global  $dir;
469     461  
470       $templ _choices =  get_templ ates_array ();   462       $templ _choices =  get_templ ates_array ();
471       $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'];
472     464  
473     465  
474       foreac h ($templ_ choices as  $tmpl_key  => $tmpl_ value)   466       foreac h ($templ_ choices as  $tmpl_key  => $tmpl_ value)
475       {   467       {
476           if  ($current _template  == $tmpl_k ey)   468           if  ($current _template  == $tmpl_k ey)
477           {   469           {
478                $ReturnR esult .= $ tmpl_value ;   470                $ReturnR esult .= $ tmpl_value ;
479                $ReturnR esult .= '  | ';   471                $ReturnR esult .= '  | ';
480           }   472           }
481           el se   473           el se
482           {   474           {
483                foreach  ($_GET as  $param_key  => $param _value)   475                foreach  ($_GET as  $param_key  => $param _value)
484                {   476                {
485     477  
486                    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} ";
487     479  
488                }   480                }
489     481  
490                $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> ';
491                $ReturnR esult .= '  | ';   483                $ReturnR esult .= '  | ';
492     484  
493           }   485           }
494       }   486       }
495     487  
496       return  $ReturnRe sult;   488       return  $ReturnRe sult;
497     489  
498     490  
499   }   491   }
500     492  
501   /**   493   /**
502    * callbac k function  for inclu ding templ ate files   494    * callbac k function  for inclu ding templ ate files
503    */   495    */
504   function g etTemplate IncludedFi le( $aFile  )   496   function g etTemplate IncludedFi le( $aFile  )
505   {   497   {
506       global  $tmpl;   498       global  $tmpl;
507     499  
508       // rea d include  file   500       // rea d include  file
509     501  
510       $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 '];
511     503  
512       if( fi le_exists  ($sFile) & & is_file(  $sFile )  )   504       if( fi le_exists  ($sFile) & & is_file(  $sFile )  )
513       {   505       {
514           $f p = fopen  ($sFile, " r");   506           $f p = fopen  ($sFile, " r");
515           if  ($fp)   507           if  ($fp)
516           {   508           {
517                $s = fre ad ($fp, f ilesize ($ sFile));   509                $s = fre ad ($fp, f ilesize ($ sFile));
518                fclose ( $fp);   510                fclose ( $fp);
519                return $ s;   511                return $ s;
520           }   512           }
521       }   513       }
522     514  
523       return  "<b>error  reading { $aFile[1]} </b>";   515       return  "<b>error  reading { $aFile[1]} </b>";
524   }   516   }
525     517  
526   function g etTemplate BaseFile(  $aFile )   518   function g etTemplate BaseFile(  $aFile )
527   {   519   {
528       global  $dir;   520       global  $dir;
529       global  $tmpl;   521       global  $tmpl;
530     522  
531       // rea d include  file   523       // rea d include  file
532       $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'];
533     525  
534       if (fi le_exists  ($sFile) & & is_file(  $sFile ))   526       if (fi le_exists  ($sFile) & & is_file(  $sFile ))
535       {   527       {
536           $f p = fopen  ($sFile, " r");   528           $f p = fopen  ($sFile, " r");
537           if  ($fp)   529           if  ($fp)
538           {   530           {
539                $s = fre ad ($fp, f ilesize ($ sFile));   531                $s = fre ad ($fp, f ilesize ($ sFile));
540                fclose ( $fp);   532                fclose ( $fp);
541                return $ s;   533                return $ s;
542           }   534           }
543       }   535       }
544     536  
545       return  "<b>error  reading b ase {$aFil e[1]}</b>" ;   537       return  "<b>error  reading b ase {$aFil e[1]}</b>" ;
546   }   538   }
547     539  
548   function e xtFileExis ts( $sFile Src )   540   function e xtFileExis ts( $sFile Src )
549   {   541   {
550     542  
551       if( fi le_exists(  $sFileSrc  ) && is_f ile( $sFil eSrc ) )   543       if( fi le_exists(  $sFileSrc  ) && is_f ile( $sFil eSrc ) )
552       {   544       {
553           $r et = true;   545           $r et = true;
554       }   546       }
555       else   547       else
556       {   548       {
557           $r et = false ;   549           $r et = false ;
558       }   550       }
559     551  
560       return  $ret;   552       return  $ret;
561   }   553   }
562     554  
563   function e xtDirExist s( $sDirSr c )   555   function e xtDirExist s( $sDirSr c )
564   {   556   {
565     557  
566       if( fi le_exists(  $sDirSrc  ) && is_di r( $sDirSr c ) )   558       if( fi le_exists(  $sDirSrc  ) && is_di r( $sDirSr c ) )
567       {   559       {
568           $r et = true;   560           $r et = true;
569       }   561       }
570       else   562       else
571       {   563       {
572           $r et = false ;   564           $r et = false ;
573       }   565       }
574     566  
575       return  $ret;   567       return  $ret;
576   }   568   }
577     569  
578   function g etVisitorI P()   570   function g etVisitorI P()
579   {   571   {
580       $ip =  '';   572       $ip =  '';
581       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']  ) ) )
582       {   574       {
583           $i p = $_SERV ER['HTTP_X _FORWARDED _FOR'];   575           $i p = $_SERV ER['HTTP_X _FORWARDED _FOR'];
584       }   576       }
585       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'] )  ) )
586       {   578       {
587           $i p = explod e(".",$_SE RVER['HTTP _CLIENT_IP ']);   579           $i p = explod e(".",$_SE RVER['HTTP _CLIENT_IP ']);
588           $i p = $ip[3] .".".$ip[2 ].".".$ip[ 1].".".$ip [0];   580           $i p = $ip[3] .".".$ip[2 ].".".$ip[ 1].".".$ip [0];
589       }   581       }
590       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'])))
591       {   583       {
592           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'])))
593           {   585           {
594                $ip = $_ SERVER['RE MOTE_ADDR' ];   586                $ip = $_ SERVER['RE MOTE_ADDR' ];
595           }   587           }
596       }   588       }
597       else   589       else
598       {   590       {
599           $i p = "0.0.0 .0";   591           $i p = "0.0.0 .0";
600       }   592       }
601     593  
602       return  $ip;   594       return  $ip;
603   }   595   }
604     596  
605   function g enFlag( $c ountry )   597   function g enFlag( $c ountry )
606   {   598   {
607       global  $site;   599       global  $site;
608       $count ry = strto lower( $co untry );   600       $count ry = strto lower( $co untry );
609          601       
610       return  "<img src =\"{$site[ 'flags']}{ $country}. gif\" />";   602       return  "<img src =\"{$site[ 'flags']}{ $country}. gif\" />";
611   }   603   }
612     604  
613   // print d ebug infor mation ( e .g. arrays  )   605   // print d ebug infor mation ( e .g. arrays  )
614   function e choDbg( $w hat, $desc  = '' )   606   function e choDbg( $w hat, $desc  = '' )
615   {   607   {
616       if ( $ desc )   608       if ( $ desc )
617           ec ho "<b>$de sc:</b> ";   609           ec ho "<b>$de sc:</b> ";
618       echo " <pre>";   610       echo " <pre>";
619           pr int_r( $wh at );   611           pr int_r( $wh at );
620       echo " </pre>\n";   612       echo " </pre>\n";
621   }   613   }
622     614  
623   function c lear_xss($ val)   615   function c lear_xss($ val)
624   {   616   {
625       global  $dir;   617       global  $dir;
626       requir e_once( "{ $dir['plug ins']}safe html/safeh tml.php" ) ;   618       requir e_once( "{ $dir['plug ins']}safe html/safeh tml.php" ) ;
627       $safeh tml =& new  safehtml( );   619       $safeh tml =& new  safehtml( );
628       $res =  $safehtml ->parse($v al);   620       $res =  $safehtml ->parse($v al);
629          621       
630       return  $res;   622       return  $res;
631   }   623   }
632     624  
633   function _ format_whe n ($iSec)  {   625   function _ format_whe n ($iSec)  {
634       $s = ' ';   626       $s = ' ';
635     627  
636       if ($i Sec>0) {   628       if ($i Sec>0) {
637           if  ($iSec <  3600) {   629           if  ($iSec <  3600) {
638                $i = rou nd($iSec/6 0);   630                $i = rou nd($iSec/6 0);
639                 if   (0   ==   $i   ||   1   ==   $i)   $s   .=  
' 1   M inute   A go'
;
  631                 if   (0   ==   $i   ||   1   ==   $i)   $s   .=   _t( ' _x_m inute _a go' ,   '1') ;
640                 else   $s   .=   $i   .   '   M inute s   A go'
;
  632                 else   $s   .=   _t( ' _x_m inute _a go' ,   $i,   's') ;
641           }   633           }
642           el se if ($iS ec < 86400 ) {   634           el se if ($iS ec < 86400 ) {
643                $i = rou nd($iSec/6 0/60);   635                $i = rou nd($iSec/6 0/60);
644                 if   (0   ==   $i   ||   1   ==   $i)   $s   .=  
' 1   H our   A go'
;
  636                 if   (0   ==   $i   ||   1   ==   $i)   $s   .=   _t( ' _x_h our _a go' ,   '1') ;
645                 else   $s   .=   $i   .   '   H our s   A go'
;
  637                 else   $s   .=   _t( ' _x_h our _a go' ,   $i,   's') ;
646           }   638           }
647           el se {   639           el se {
648                $i = rou nd($iSec/6 0/60/24);   640                $i = rou nd($iSec/6 0/60/24);
649                 if   (0   ==   $i   ||   1   ==   $i)   $s   .=  
' 1   D ay   A go'
;
  641                 if   (0   ==   $i   ||   1   ==   $i)   $s   .=   _t( ' _x_d ay _a go' ,   '1') ;
650                 else   $s   .=   $i   .   '   D ay s   A go'
;
  642                 else   $s   .=   _t( ' _x_d ay _a go' ,   $i,   's') ;
651           }   643           }
652       }else  {   644       }else  {
653           if  ($iSec >  -3600) {   645           if  ($iSec >  -3600) {
654                $iSec =  -$iSec;   646                $iSec =  -$iSec;
655                $i = rou nd($iSec/6 0);   647                $i = rou nd($iSec/6 0);
656                 if   (0   ==   $i   ||   1   ==   $i)   $s   .=  
' I n   1   M inute'
;
  648                 if   (0   ==   $i   ||   1   ==   $i)   $s   .=   _t( ' _i n _x_m inute' ,   '1') ;
657                 else   $s   .=  
' In   '   .   $ i   .   '   M inute
s'
;
  649                 else   $s   .=   _t( ' _ i n_x_m inute ',   $i,   ' s' ) ;
658           }   650           }
659           el se if ($iS ec > -8640 0) {   651           el se if ($iS ec > -8640 0) {
660                $iSec =  -$iSec;   652                $iSec =  -$iSec;
661                $i = rou nd($iSec/6 0/60);   653                $i = rou nd($iSec/6 0/60);
662                 if   (0   ==   $i   ||   1   ==   $i)   $s   .=  
' I n   1   H our'
;
  654                 if   (0   ==   $i   ||   1   ==   $i)   $s   .=   _t( ' _i n _x_h our' ,   '1') ;
663                 else   $s   .=  
' I n  
'   .   $i   .   '   Hour s'
;
  655                 else   $s   .=   _t( ' _i n _x_hour ' ,   $i ,   '
s' ) ;
664           }   656           }
665           el seif ($iSe c < -86400 ) {   657           el seif ($iSe c < -86400 ) {
666                $iSec =  -$iSec;   658                $iSec =  -$iSec;
667                $i = rou nd($iSec/6 0/60/24);   659                $i = rou nd($iSec/6 0/60/24);
668                 if   (0   ==   $i   ||   1   ==   $i)   $s   .=  
' I n   1   D ay'
;
  660                 if   (0   ==   $i   ||   1   ==   $i)   $s   .=   _t( ' _i n _x_d ay' ,   '1') ;
669                 else   $s   .=  
' I n  
'   .   $i   .   '   Day s'
;
  661                 else   $s   .=   _t( ' _i n _x_day ' ,   $i ,   '
s' ) ;
670           }   662           }
671       }   663       }
672       return  $s;   664       return  $s;
673   }   665   }
674     666  
675   function e xecSqlFile ( $filenam e )   667   function e xecSqlFile ( $filenam e )
676   {   668   {
677       if ( ! $f = fopen  ( $filena me, "r" )  )   669       if ( ! $f = fopen  ( $filena me, "r" )  )
678           re turn false ;   670           re turn false ;
679       db_res ( "SET NAM ES 'utf8'"  );   671       db_res ( "SET NAM ES 'utf8'"  );
680          672       
681       $s_sql  = "";   673       $s_sql  = "";
682       while  ( $s = fge ts ( $f, 1 0240) )   674       while  ( $s = fge ts ( $f, 1 0240) )
683       {   675       {
684           $s  = trim( $ s ); //Utf  with BOM  only   676           $s  = trim( $ s ); //Utf  with BOM  only
685              677           
686           if ( !strlen(  $s ) ) co ntinue;   678           if ( !strlen(  $s ) ) co ntinue;
687           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
688           if  ( mb_subs tr( $s, 0,  2 ) == '- -' ) conti nue;   680           if  ( mb_subs tr( $s, 0,  2 ) == '- -' ) conti nue;
689     681  
690           $s _sql .= $s ;   682           $s _sql .= $s ;
691              683           
692           if  ( mb_subs tr( $s, -1  ) != ';'  ) continue ;   684           if  ( mb_subs tr( $s, -1  ) != ';'  ) continue ;
693              685           
694           db _res( $s_s ql );   686           db _res( $s_s ql );
695           $s _sql = "";   687           $s _sql = "";
696       }   688       }
697     689  
698       fclose ($f);   690       fclose ($f);
699       return  true;   691       return  true;
700   }   692   }
701     693  
702   function r eplace_ful l_uris( $t ext )   694   function r eplace_ful l_uris( $t ext )
703   {   695   {
704       $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 );
705       return  $text;   697       return  $text;
706   }   698   }
707     699  
708   function r eplace_ful l_uri( $ma tches )   700   function r eplace_ful l_uri( $ma tches )
709   {   701   {
710       global  $site;   702       global  $site;
711          703       
712       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:/ /' )
713           $m atches[2]  = $site['u rl'] . $ma tches[2];   705           $m atches[2]  = $site['u rl'] . $ma tches[2];
714          706       
715       return  $matches[ 1] . $matc hes[2] . $ matches[3] ;   707       return  $matches[ 1] . $matc hes[2] . $ matches[3] ;
716   }   708   }
717     709  
    710   //-------- ---------- ---------- ---------- - friendly  permalink s -------- ---------- ---------- ---------- //
    711   //-------- ---------- ---------- ---------- ----- main  functions  --------- ---------- ---------- ---------- //
    712   function u riGenerate  ($s, $sTa ble, $sFie ld, $iMaxL en = 255)
    713   {
    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
    716     $s = get _mb_replac e ('/([-^] +)/', '-',  $s);
    717  
    718     if (uriC heckUniq($ s, $sTable , $sField) ) return $ s;
    719  
    720     // try t o add date
    721  
    722     if (get_ mb_len($s)  > 240)
    723        $s =  get_mb_sub str ($s, 0 , 240);
    724  
    725     $s .= '- ' . date(' Y-m-d');
    726           
    727     if (uriC heckUniq($ s, $sTable , $sField) ) return $ s;
    728  
    729     // try t o add numb er
    730  
    731     for ($i  = 0 ; $i <  999 ; ++$ i)
    732     {         
    733       if (ur iCheckUniq ($s . '-'  . $i, $sTa ble, $sFie ld)) 
    734       {
    735          ret urn ($s .  '-' . $i);                  
    736       }
    737     }
    738      return  rand(0, 99 9999999);
    739   }
    740  
    741   function u riCheckUni q ($s, $sT able, $sFi eld)
    742   {
    743       return  !db_arr(" SELECT 1 F ROM $sTabl e WHERE $s Field = '$ s' LIMIT 1 ");
    744   }
    745  
    746   function g et_mb_repl ace ($sPat tern, $sRe place, $s)
    747   {
    748       return  preg_repl ace ($sPat tern, $sRe place, $s) ;
    749   }
    750  
    751   function g et_mb_len  ($s)
    752   {
    753       if (fu nction_exi sts('mb_st rlen'))
    754           re turn mb_st rlen ($s);
    755       else
    756           re turn strle n ($s);
    757   }    
    758  
    759   function g et_mb_subs tr ($s, $i Start, $iL en)
    760   {
    761       if (fu nction_exi sts('mb_su bstr'))
    762           re turn mb_su bstr ($s,  $iStart, $ iLen);
    763       else
    764           re turn subst r ($s, $iS tart, $iLe n);
    765   }
    766  
    767   /*function  LocaledTi me( $sDate Time="2008 -04-15 16: 26:27" ) {
    768       $sDate Key = _t(' _day_of_01 ', $iDay,  $iYear); / /
    769       return  $sDateKey ;
    770   }*/
    771  
    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       $aDate Time = get date($sTim estamp);
    774       $sResu lt = '';
    775       if ($a DateTime[' year']) {
    776           sw itch ($iDT ype) {
    777                case 1:
    778                    $sRe sult .= _t ('_day_of_ '.$aDateTi me['mon'],  $aDateTim e['mday'],  $aDateTim e['year']) ; //"April  7, 2008"  "7 Апреля  2008"
    779                    brea k;
    780                case 2:
    781                    $sRe sult .= $a DateTime[' hours'] .  ':' . $aDa teTime['mi nutes']; / /"22:30"
    782                    brea k;
    783                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                    brea k;
    786           }
    787       }
    788       return  $sResult;
    789   /*
    790  
    791   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_1' ;
    792   SET @last_ id = LAST_ INSERT_ID( );
    793   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  января {1} ');
    794  
    795   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_2' ;
    796   SET @last_ id = LAST_ INSERT_ID( );
    797   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  февраля {1 }');
    798  
    799   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_3' ;
    800   SET @last_ id = LAST_ INSERT_ID( );
    801   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  марта {1}' );
    802  
    803   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_4' ;
    804   SET @last_ id = LAST_ INSERT_ID( );
    805   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  апреля {1} ');
    806  
    807   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_5' ;
    808   SET @last_ id = LAST_ INSERT_ID( );
    809   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  мая {1}');
    810  
    811   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_6' ;
    812   SET @last_ id = LAST_ INSERT_ID( );
    813   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  июня {1}') ;
    814  
    815   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_7' ;
    816   SET @last_ id = LAST_ INSERT_ID( );
    817   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  июля {1}') ;
    818  
    819   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_8' ;
    820   SET @last_ id = LAST_ INSERT_ID( );
    821   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  августа {1 }');
    822  
    823   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_9' ;
    824   SET @last_ id = LAST_ INSERT_ID( );
    825   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  сентября { 1}');
    826  
    827   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_10 ';
    828   SET @last_ id = LAST_ INSERT_ID( );
    829   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  октября {1 }');
    830  
    831   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_11 ';
    832   SET @last_ id = LAST_ INSERT_ID( );
    833   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  ноября {1} ');
    834  
    835   INSERT INT O `Localiz ationKeys`  SET `IDCa tegory`='1 ', `Key`=' _day_of_12 ';
    836   SET @last_ id = LAST_ INSERT_ID( );
    837   INSERT INT O `Localiz ationStrin gs` VALUES  (@last_id , 1, '{0}  декабря {1 }');
    838  
    839   */
    840   }
    841  
718   ?>   842   ?>