232. File Comparison Report

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

232.1 Files compared

# Location File Last Modified
1 Dolphin-v.6.0.5\inc languages.inc.php Thu Sep 20 08:58:34 2007 UTC
2 Dolphin-v.6.1.0\inc languages.inc.php Sat Apr 26 08:19:16 2008 UTC

232.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 56 668
Changed 46 249
Inserted 2 4
Removed 8 24

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

232.4 Active regular expressions

No regular expressions were active.

232.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   require_on ce('db.inc .php');   22   require_on ce('db.inc .php');
23   require_on ce('utils. inc.php');   23   require_on ce('utils. inc.php');
24     24  
25   define('LA NGUAGE_CAT EGORY_ID_P ROFILE_FIE LDS', 24);   25   define('LA NGUAGE_CAT EGORY_ID_P ROFILE_FIE LDS', 24);
26     26  
27   $langHTMLC harset = ' ';   27   $ sC urrentLang uage   =   getCurrent LangName() ;
28   $ c urrentLang uage   =   '' ;   28   if(   ! $ sC urrentLang uage   )   {
29  
$ c urrentLang uage File   =   '';
  29       echo ' <br /><b>F atal error :</b> Cann ot apply l ocalizatio n.';
    30       exit;
    31   }
30     32  
31   function s etCurrentL anguage()   33   require_on ce( "{$dir ['root']}l angs/lang- {$sCurrent Language}. php" );
32   {    
33       global  $langHTML Charset;    
34       global  $currentL anguage;    
35       global  $currentL anguageFil e;    
36     34  
37       functi on langFil e($languag e)    
38       {    
39           gl obal $dir;    
40           re turn $dir[ 'root'].'l angs/lang- '.$languag e.'.php';    
41       }    
42     35  
43       functi on assureC ompiled($l anguage)    
44       {    
45           if  (file_exi sts(langFi le($langua ge)))    
46           {    
47                return t rue;    
48           }    
49           el se    
50           {    
51                $languag e = get_ma gic_quotes _gpc() ? $ language :  addslashe s($languag e);    
52                $langID  = mysql_qu ery("SELEC T `ID` FRO M `Localiz ationLangu ages` WHER E `Name` =  '$languag e'");    
53     36  
54                if ( mys ql_num_row s($langID)  <= 0) ret urn false;    
55     37  
56     38  
57                $langID  = mysql_fe tch_row($l angID);    
58                $langID  = $langID[ 0];    
59     39  
    40   function g etCurrentL angName()  {
    41       $sLang  = '';
60     42       
61                return c ompileLang uage($lang ID);   43       if( !$ sLang ) $s Lang = try ToGetLang(  $_GET['la ng'], true  );
62            }   44       if( !$ sLang ) $s Lang = try ToGetLang(  $_POST['l ang'], tru e );
    45       if( !$ sLang ) $s Lang = try ToGetLang(  $_COOKIE[ 'lang'] );
    46       if( !$ sLang ) $s Lang = try ToGetLang(  $_SERVER[ 'HTTP_ACCE PT_LANGUAG E'] );
    47       if( !$ sLang ) $s Lang = try ToGetLang(  getParam(  'lang_def ault' ) );
    48       if( !$ sLang ) $s Lang = try ToGetLang(  'en' );
    49  
    
    50       return  $sLang;
63       }   51   }
64     52  
65       $LANG_ SWITCHING_ ENABLED =  (int)getPa ram( "lang _enable" ) ;   53   function t ryToGetLan g( $sLangs , $bSetCoo kie = fals e ) {
    54       $sLang s = trim(  $sLangs );
    55       if( !$ sLangs )
    56           re turn '';
66     57       
67       $defau ltLanguage  = getPara m('lang_de fault');   58       $sLang s = preg_r eplace( '/ [^a-zA-Z0- 9,;-]/m',  '', $sLang s ); // we  do not ne ed 'q=0.3' . we are u sing live  queue :)
    59       $sLang s = strtol ower( $sLa ngs );
68     60       
69       if ( $ LANG_SWITC HING_ENABL ED )   61       if( !$ sLangs )
70       {   62           re turn '';
71           $c urrentLang uage = (is set($_POST ['new_sLan guage']) ?  $_POST['n ew_sLangua ge'] : $_G ET['new_sL anguage']) ;    
72     63       
73           // check if a  new langu age is set  via get/p ost variab les   64       $aLang s = explod e( ',', $s Langs ); / / ru,en-us ;q=0.7,en; q=0.3 => a rray( 'ru'  , 'en-us; q=0.7' , ' en;q=0.3'  );
    65       foreac h( $aLangs  as $sLang  ) {
    66           if ( !$sLang  ) continue ;
74     67           
75           if  ( strlen( $currentLa nguage) >  0 )   68           li st( $sLang  ) = explo de( ';', $ sLang, 2 ) ; // en-us ;q=0.7 =>  en-us
76           {   69           if ( !$sLang  ) continue ;
77                //set a  cookie wit h a new cu rrent lang uage value    
78     70           
79                 set c ookie(   " sLang uage",   '',   time()   -   3600,   "/"   );   71           //  check wit h country
80                setcooki e( "sLangu age", $cur rentLangua ge, time()  + 10000 *  3600, "/"  );   72           if ( checkLan gExists( $ sLang ) )  {
    73                if( $bSe tCookie )
    74                     set LangC ookie(   $ sLang  
);
    75                return $ sLang;
81           }   76           }
82           el seif ( iss et($_COOKI E['sLangua ge']) )    
83           {    
84                //get cu rrent lang uage from  a previous ly set coo kie    
85     77           
86                $current Language =  $_COOKIE[ 'sLanguage '];   78           // drop count ry
87           }   79           li st( $sLang , $sCntr )  = explode ( '-', $sL ang, 2 );  // en-us = > en
88           el se   80           if ( !$sLang  or !$sCntr  ) continu e; //no la ng or noth ing change d
89           {    
90                //set cu rrent lang uage to de fault one    
91     81           
92                $current Language =  $defaultL anguage;   82           // check agai n. without  country
    83           if ( checkLan gExists( $ sLang ) )  {
    84                if( $bSe tCookie )
    85                    setL angCookie(  $sLang );
    86                return $ sLang;
93           }   87           }
94       }   88       }
95       else   89  
    
96        {   90       return  '';
97           $c urrentLang uage = $de faultLangu age;    
98       }   91   }
99     92  
100       if ( ! assureComp iled($curr entLanguag e) )   93   function c heckLangEx ists( $sLa ng ) {
101       {   94       global  $dir;
102           // current la nguage is  not availa ble    
103     95       
104           if  ( $curren tLanguage  == $defaul tLanguage  || !assure Compiled($ defaultLan guage) )   96       if( fi le_exists(  "{$dir['r oot']}lang s/lang-{$s Lang}.php"  ) )
105           {   97           re turn true;
106                //curren t language  is a defa ult one or  the defau lt one is  not availa ble also    
107     98       
108                echo '<f ont color= "red">Erro r: Could n ot compile  the defau lt languag e. The scr ipt cannot  execute a ny further .</font>';   99       $sQuer y = "SELEC T `ID` FRO M `Localiz ationLangu ages` WHER E `Name` =  '$sLang'" ;
109                exit();   100       $iLang ID = (int) db_value(  $sQuery );
110           }    
111           el se    
112           {    
113                //defaul t language  is availa ble    
114     101       
115                $current Language =  $defaultL anguage;   102       if( !$ iLangID )
116           }   103           re turn false ;
117       }    
118     104       
119       $langH TMLCharset  = 'UTF-8' ;   105       if( co mpileLangu age( $iLan gID ) )
    106           re turn true;
120     107       
121       $curre ntLanguage File = lan gFile($cur rentLangua ge);   108       return  false;
122   }   109   }
123     110  
124   setCurrent Language() ;   111   function s etLangCook ie( $sLang  ) {
125     112       setcoo kie( 'lang ', '',      time() -  60*60*24,     '/' );
126   require_on ce($curren tLanguageF ile);   113       setcoo kie( 'lang ', $sLang,  time() +  60*60*24*3 65, '/' );
    114   }
127     115  
128   /**   116   function  
g
e
t LangSwi t cher ()   {
129    * Put lan guage swit ching code  : txt lin ks   117        global   $ sC urrentLang uage;
130    **/    
131   function   lan g _sel e ct_ t x t
()
   
132   {    
133        global   $ c urrentLang uage;    
134       global  $site;   118       global  $site;
135     119       
136        $a rr Langs   =   getL ocalizatio nL ang uage s
( '1' );
  120        $a
Langs   =   getL
ang
s Arr ( true );
    121       if( co unt( $aLan gs ) < 2 )
    122           re turn '';
137          123  
138       if ( c ount( $arr Langs ) <  2 )   124       $sCurL ink = $_SE RVER['REQU EST_URI'];
139           re turn false ;   125       $sCurL ink = preg _replace(  '/[\?&]lan g=[a-z-]{2 ,5}/i', '' , $sCurLin k ); //rem ove old la ng from ur i
140     126       $sCurL ink .= str pos( $sCur Link, '?',  1 ) ? '&'  : '?';
141       // Gen erate list  of GET pa rameters t hat should  be append ed to lang uage link    
142      
143       $param s = '';    
144     127       
145        foreach   (   $ _GET   as   $ k e y   =>   $ v a lue   )
  128       $sRet  = '';
146       {   129        foreach(   $ aLangs   as   $ sNam e  
=>   $ sL a ng   )   {
147           if  ( $key !=  'new_sLan guage' )   130           $s Title = ht mlspecialc hars( subs tr( $sLang , 0, -2 )  );
148           {   131           $s Flag  = $s ite['flags '] . subst r( $sLang,  -2 ) . '. gif';
149                if ( get _magic_quo tes_gpc()  )$value =  stripslash es($value) ;    
150     132           
151                $params  .= htmlspe cialchars( "&$key=$va lue");   133           if ( $sCurren tLanguage  == $sName  ) {
    134                $sRet .=  '
    135                    <img  class="la ng_selecte d" src="'  . $sFlag .  '" alt="'  . $sTitle  . '" titl e="' . $sT itle . '"  />';
    136           }  else {
    137                $sLink =  $sCurLink  . 'lang='  . $sName;
    138                $sRet .=  '
    139                    <a h ref="' . $ sLink .'"  title="' .  $sTitle .  '">
    140                         <img class ="lang_not _selected"  src="' .  $sFlag . ' " alt="' .  $sTitle .  '" title= "' . $sTit le . '" />
    141                    </a> ';
152           }   142           }
153       }   143       }
154     144       
155       foreac h($arrLang s as $valu e)   145       return  $sRet;
156        {   146   }
157           $s Name = sub str($value ,0,strlen( $value)-2) ;    
158           $s Flag = sub str($value ,-2);    
159              147  
160           $h tmlValue =  htmlspeci alchars($s Name);   148   function g etLangsArr ( $bAddFla g = false,  $bRetIDs  = false )  {
161           $s Icon = "<i mg alt=\"$ sName\" ti tle=\"$sNa me\" src=\ "".$site[' flags'].$s Flag.".gif \">";   149       $rLang s = db_res ('SELECT *  FROM `Loc alizationL anguages`  ORDER BY ` Title` ASC ');
162              150       
163           if  ( !strcmp ( $current Language,  $sName ) )   151       $aLang s = array( );
164                echo "<i mg alt=\"$ sName\" ti tle=\"$sNa me\" src=\ "".$site[' flags'].$s Flag.".gif \" style=\ "margin-le ft:5px;\"> ";   152       while(  $aLang =  mysql_fetc h_assoc($r Langs) ) {
165            else   153           $s Flag = '';
166                echo '<a  href="'.   154           $s Flag = $bA ddFlag ? (  $aLang['F lag'] ? $a Lang['Flag '] : 'xx'  ) : '';
167                    $_SE RVER['PHP_ SELF'].   155  
        
168                    '?ne w_sLanguag e='.   156           $s Key = ($bR etIDs) ? $ aLang['ID' ] : $aLang ['Name'];
169                    $htm lValue.$pa rams.'" cl ass="menu_ item_block " title="' .$sName.'" >'.$sIcon. '</a>';   157           $a Langs[ $sK ey ] = $aL ang['Title '] . $sFla g;
170       }   158       }
    159       
    160       return  $aLangs;
171   }   161   }
172     162  
173   function   deleteLang uage($lang ID   =   0)
  163   function   deleteLang uage($lang ID   =   0)   {
174   {    
175       global  $dir;   164       global  $dir;
176     165  
177       $langI D = (int)$ langID;   166       $langI D = (int)$ langID;
178     167  
179       if($la ngID <= 0)  return fa lse;   168       if($la ngID <= 0)  return fa lse;
180     169  
181       $resLa ngs = mysq l_query('   170       $resLa ngs = mysq l_query('
182                SELECT   `ID`, `Nam e`   171                SELECT   `ID`, `Nam e`
183                FROM     `Localizat ionLanguag es`   172                FROM     `Localizat ionLanguag es`
184                WHERE    `ID` = '.$ langID);   173                WHERE    `ID` = '.$ langID);
185     174  
186       if(mys ql_num_row s($resLang s) <= 0) r eturn fals e;   175       if(mys ql_num_row s($resLang s) <= 0) r eturn fals e;
187     176  
188       $arrLa ng = mysql _fetch_ass oc($resLan gs);   177       $arrLa ng = mysql _fetch_ass oc($resLan gs);
189     178  
190       $numSt rings = my sql_query( '   179       $numSt rings = my sql_query( '
191           SE LECT COUNT (`IDKey`)   180           SE LECT COUNT (`IDKey`)
192           FR OM `Locali zationStri ngs`   181           FR OM `Locali zationStri ngs`
193           WH ERE `IDLan guage` = ' .$langID);   182           WH ERE `IDLan guage` = ' .$langID);
194       $numSt rings = my sql_fetch_ row($numSt rings);   183       $numSt rings = my sql_fetch_ row($numSt rings);
195       $numSt rings = $n umStrings[ 0];   184       $numSt rings = $n umStrings[ 0];
196     185  
197       mysql_ query('DEL ETE FROM ` Localizati onStrings`  WHERE `ID Language`  = '.$langI D);   186       mysql_ query('DEL ETE FROM ` Localizati onStrings`  WHERE `ID Language`  = '.$langI D);
198     187  
199       if(mys ql_affecte d_rows() <  $numStrin gs) return  false;   188       if(mys ql_affecte d_rows() <  $numStrin gs) return  false;
200     189  
201       mysql_ query('DEL ETE FROM ` Localizati onLanguage s` WHERE ` ID` = '.$l angID);   190       mysql_ query('DEL ETE FROM ` Localizati onLanguage s` WHERE ` ID` = '.$l angID);
202     191  
203       if(mys ql_affecte d_rows() < = 0) retur n false;   192       if(mys ql_affecte d_rows() < = 0) retur n false;
204     193  
205       @unlin k($dir['ro ot'].'lang s/lang-'.$ arrLang['N ame'].'.ph p');   194       @unlin k($dir['ro ot'].'lang s/lang-'.$ arrLang['N ame'].'.ph p');
206     195  
207       return  true;   196       return  true;
208   }   197   }
209     198  
210   function   getLocaliz ation Languag e
s( $sWithFlag   =   '' )
  199   function   getLocaliz ation K e y s(
)   {
211   {    
212       $resLa ngs = db_r es('SELECT  `ID`, `Na me`, `Flag ` FROM `Lo calization Languages`  ORDER BY  `Name` ASC ');    
213      
214       $arrLa ngs = arra y();    
215      
216       while  ($arr = my sql_fetch_ assoc($res Langs))    
217       {    
218           $s Flag = '';    
219           if  ($sWithFl ag == '1')    
220           {    
221                $sFlag =  strlen($a rr['Flag'] ) ? $arr[' Flag'] : ' xx' ;    
222           }    
223           $a rrLangs[$a rr['ID']]  = $arr['Na me'].$sFla g;    
224       }    
225      
226       return  $arrLangs ;    
227   }    
228      
229   function g etLocaliza tionKeys()    
230   {    
231       $resKe ys = db_re s('SELECT  `ID`, `IDC ategory`,  `Key` FROM  `Localiza tionKeys`' );   200       $resKe ys = db_re s('SELECT  `ID`, `IDC ategory`,  `Key` FROM  `Localiza tionKeys`' );
232     201  
233       $arrKe ys = array ();   202       $arrKe ys = array ();
234     203  
235       while( $arr = mys ql_fetch_a ssoc($resK eys))   204       while( $arr = mys ql_fetch_a ssoc($resK eys))
236       {   205       {
237           $I D = $arr[' ID'];   206           $I D = $arr[' ID'];
238           un set($arr[' ID']);   207           un set($arr[' ID']);
239           $a rrKeys[$ID ] = $arr;   208           $a rrKeys[$ID ] = $arr;
240       }   209       }
241     210  
242       return  $arrKeys;   211       return  $arrKeys;
243   }   212   }
244     213  
245   function   getLocaliz ationStrin gParams($k eyID)
  214   function   getLocaliz ationStrin gParams($k eyID)   {
246   {    
247       $keyID  = (int)$k eyID;   215       $keyID  = (int)$k eyID;
248     216  
249       $resPa rams = mys ql_query("   217       $resPa rams = mys ql_query("
250           SE LECT  `IDP aram`,   218           SE LECT  `IDP aram`,
251                    `Des cription`   219                    `Des cription`
252      
253           FR OM    `Loc alizationS tringParam s`   220           FR OM    `Loc alizationS tringParam s`
254      
255           WH ERE   `IDK ey` = $key ID   221           WH ERE   `IDK ey` = $key ID
256     222            ORDER   BY   `IDParam`
257            ORDER   BY   `IDParam` ");   223       ");
258     224  
259       $arrPa rams = arr ay();   225       $arrPa rams = arr ay();
260     226  
261       while  ($arr = my sql_fetch_ assoc($res Params))   227       while  ($arr = my sql_fetch_ assoc($res Params))
262       {   228       {
263           $a rrParams[( int)$arr[' IDParam']]  = $arr['D escription '];   229           $a rrParams[( int)$arr[' IDParam']]  = $arr['D escription '];
264       }   230       }
265     231  
266       return  $arrParam s;   232       return  $arrParam s;
267   }   233   }
268     234  
269   function   getLocaliz ationCateg ories()
  235   function   getLocaliz ationCateg ories()   {
270   {    
271       $resCa tegories =  db_res('S ELECT `ID` , `Name` F ROM `Local izationCat egories` O RDER BY `N ame`');   236       $resCa tegories =  db_res('S ELECT `ID` , `Name` F ROM `Local izationCat egories` O RDER BY `N ame`');
272     237  
273       $arrCa tegories =  array();   238       $arrCa tegories =  array();
274     239  
275       while  ($arr = my sql_fetch_ assoc($res Categories ))   240       while  ($arr = my sql_fetch_ assoc($res Categories ))
276       {   241       {
277           $a rrCategori es[$arr['I D']] = $ar r['Name'];   242           $a rrCategori es[$arr['I D']] = $ar r['Name'];
278       }   243       }
279     244  
280       return  $arrCateg ories;   245       return  $arrCateg ories;
281   }   246   }
282     247  
283   function   compileLan guage($lan gID   =   0)
  248   function   compileLan guage($lan gID   =   0)   {
284   {    
285       global  $dir;   249       global  $dir;
286     250  
287       $langI D = (int)$ langID;   251       $langI D = (int)$ langID;
288     252  
289       $newLi ne = "\r\n ";   253       $newLi ne = "\r\n ";
290     254       
291        if($langID   <=   0)
  255        if($langID   <=   0)   {
292       {    
293           $r esLangs =  db_res('SE LECT `ID`,  `Name` FR OM `Locali zationLang uages`');   256           $r esLangs =  db_res('SE LECT `ID`,  `Name` FR OM `Locali zationLang uages`');
294       }   257        }   else   {
295       
else
   
296       {    
297           $r esLangs =  db_res('   258           $r esLangs =  db_res('
298                SELECT   `ID`, `Nam e`   259                SELECT   `ID`, `Nam e`
299                FROM     `Localizat ionLanguag es`   260                FROM     `Localizat ionLanguag es`
300                 WHERE     `ID`   =   '.$langID );   261                 WHERE     `ID`   =   '.$langID
    262           );
301       }   263       }
302     264  
303        if   (   mysql_num_ rows($resL angs)   <=   0   )   return   false;   265        if   (   mysql_num_ rows($resL angs)   <=   0   )
    266           re turn false ;
304     267  
305        while($arr Language   =   mysql_fetc h_assoc($r esLangs))
  268        while($arr Language   =   mysql_fetc h_assoc($r esLangs))   {
306       {    
307           $r esKeysStri ngs = db_r es("   269           $r esKeysStri ngs = db_r es("
308                SELECT   `Localizat ionKeys`.` Key` AS `K ey`,   270                SELECT   `Localizat ionKeys`.` Key` AS `K ey`,
309                         `Localizat ionStrings `.`String`  AS `Strin g`   271                         `Localizat ionStrings `.`String`  AS `Strin g`
310                FROM     `Localizat ionStrings ` INNER JO IN   272                FROM     `Localizat ionStrings ` INNER JO IN
311                         `Localizat ionKeys` O N   273                         `Localizat ionKeys` O N
312                         `Localizat ionKeys`.` ID` = `Loc alizationS trings`.`I DKey`   274                         `Localizat ionKeys`.` ID` = `Loc alizationS trings`.`I DKey`
313                WHERE `L ocalizatio nStrings`. `IDLanguag e` = {$arr Language[' ID']}");   275                WHERE `L ocalizatio nStrings`. `IDLanguag e` = {$arr Language[' ID']}");
314     276  
315           $h andle = fo pen("{$dir ['root']}l angs/lang- {$arrLangu age['Name' ]}.php", ' w');   277           $h andle = fo pen("{$dir ['root']}l angs/lang- {$arrLangu age['Name' ]}.php", ' w');
316     278  
317           if ($handle = == false)  return fal se;   279           if ($handle = == false)  return fal se;
318     280  
319           $f ileContent  = "<?{$ne wLine}\$LA NG = array (";   281           $f ileContent  = "<?{$ne wLine}\$LA NG = array (";
320     282  
321           wh ile($arrKe yString =  mysql_fetc h_assoc($r esKeysStri ngs))   283           wh ile($arrKe yString =  mysql_fetc h_assoc($r esKeysStri ngs))
322           {   284           {
323                $langKey  = str_rep lace("\\",  "\\\\", $ arrKeyStri ng['Key']) ;   285                $langKey  = str_rep lace("\\",  "\\\\", $ arrKeyStri ng['Key']) ;
324                $langKey  = str_rep lace("'",  "\\'", $la ngKey);   286                $langKey  = str_rep lace("'",  "\\'", $la ngKey);
325     287  
326                $langStr  = str_rep lace("\\",  "\\\\", $ arrKeyStri ng['String ']);   288                $langStr  = str_rep lace("\\",  "\\\\", $ arrKeyStri ng['String ']);
327                $langStr  = str_rep lace("'",  "\\'", $la ngStr);   289                $langStr  = str_rep lace("'",  "\\'", $la ngStr);
328     290  
329                $fileCon tent .= "{ $newLine}\ t'$langKey ' => '$lan gStr',";   291                $fileCon tent .= "{ $newLine}\ t'$langKey ' => '$lan gStr',";
330           }   292           }
331     293  
332           $f ileContent  = trim($f ileContent , ',');   294           $f ileContent  = trim($f ileContent , ',');
333     295  
334           $w riteResult  = fwrite( $handle, $ fileConten t."{$newLi ne});?>");   296           $w riteResult  = fwrite( $handle, $ fileConten t."{$newLi ne});?>");
335           if ($writeRes ult === fa lse) retur n false;   297           if ($writeRes ult === fa lse) retur n false;
336     298  
337           if (fclose($h andle) ===  false) re turn false ;   299           if (fclose($h andle) ===  false) re turn false ;
338     300  
339           @c hmod("{$di r['root']} langs/lang -{$arrLang uage['Name ']}.php",  0666);   301           @c hmod("{$di r['root']} langs/lang -{$arrLang uage['Name ']}.php",  0666);
340       }   302       }
341     303  
342       return  true;   304       return  true;
343   }   305   }
344     306  
345   function   addStringT oLanguage( $langKey,   $langStrin g,   $langID   =   -1,   $categoryI D   =   LANGUAGE_C ATEGORY_ID _PROFILE_F IELDS)
  307   function   addStringT oLanguage( $langKey,   $langStrin g,   $langID   =   -1,   $categoryI D   =   LANGUAGE_C ATEGORY_ID _PROFILE_F IELDS)   {
346   {    
347       // inp ut validat ion   308       // inp ut validat ion
348       $langI D = (int)$ langID;   309       $langI D = (int)$ langID;
349       $categ oryID = (i nt)$catego ryID;   310       $categ oryID = (i nt)$catego ryID;
350     311  
351       if ( $ langID ==  -1 )   312       if ( $ langID ==  -1 )
352       {   313       {
353           $r esLangs =  db_res('SE LECT `ID`,  `Name` FR OM `Locali zationLang uages`');   314           $r esLangs =  db_res('SE LECT `ID`,  `Name` FR OM `Locali zationLang uages`');
354       }   315       }
355       else   316       else
356       {   317       {
357           $r esLangs =  db_res('   318           $r esLangs =  db_res('
358                SELECT   `ID`, `Nam e`   319                SELECT   `ID`, `Nam e`
359                FROM     `Localizat ionLanguag es`   320                FROM     `Localizat ionLanguag es`
360                WHERE    `ID` = '.$ langID);   321                WHERE    `ID` = '.$ langID);
361       }   322       }
362     323  
363       $langK ey = addsl ashes($lan gKey);   324       $langK ey = addsl ashes($lan gKey);
364       $langS tring = pr ocess_db_i nput($lang String);   325       $langS tring = pr ocess_db_i nput($lang String);
365     326  
366       $resIn sertKey =  db_res( "   327       $resIn sertKey =  db_res( "
367           IN SERT INTO  `Localizat ionKeys`   328           IN SERT INTO  `Localizat ionKeys`
368           SE T          `IDCategor y` = $cate goryID,   329           SE T          `IDCategor y` = $cate goryID,
369                         `Key` = '$ langKey'",  false );   330                         `Key` = '$ langKey'",  false );
370       if ( ! $resInsert Key || mys ql_affecte d_rows() < = 0 )   331       if ( ! $resInsert Key || mys ql_affecte d_rows() < = 0 )
371           re turn false ;   332           re turn false ;
372     333  
373       $keyID  = mysql_i nsert_id() ;   334       $keyID  = mysql_i nsert_id() ;
374     335  
375       while( $arrLangua ge = mysql _fetch_ass oc($resLan gs))   336       while( $arrLangua ge = mysql _fetch_ass oc($resLan gs))
376       {   337       {
377           $r esInsertSt ring = db_ res( "   338           $r esInsertSt ring = db_ res( "
378                INSERT I NTO `Local izationStr ings`   339                INSERT I NTO `Local izationStr ings`
379                SET          `IDKey ` = $keyID ,   340                SET          `IDKey ` = $keyID ,
380                             `IDLan guage` = { $arrLangua ge['ID']},   341                             `IDLan guage` = { $arrLangua ge['ID']},
381                             `Strin g` = '$lan gString'",  false );   342                             `Strin g` = '$lan gString'",  false );
382           if  ( !$resIn sertString  || mysql_ affected_r ows() <= 0  )   343           if  ( !$resIn sertString  || mysql_ affected_r ows() <= 0  )
383                return f alse;   344                return f alse;
384       }   345       }
385     346  
386       return  true;   347       return  true;
387   }   348   }
388     349  
389   function   updateStri ngInLangua ge($langKe y,   $langStrin g,   $langID   =   -1)
  350   function   updateStri ngInLangua ge($langKe y,   $langStrin g,   $langID   =   -1)   {
390   {    
391       // inp ut validat ion   351       // inp ut validat ion
392       $langI D = (int)$ langID;   352       $langI D = (int)$ langID;
393     353  
394       if ( $ langID ==  -1 )   354       if ( $ langID ==  -1 )
395       {   355       {
396           $r esLangs =  db_res('SE LECT `ID`,  `Name` FR OM `Locali zationLang uages`');   356           $r esLangs =  db_res('SE LECT `ID`,  `Name` FR OM `Locali zationLang uages`');
397       }   357       }
398       else   358       else
399       {   359       {
400           $r esLangs =  db_res('   360           $r esLangs =  db_res('
401                SELECT   `ID`, `Nam e`   361                SELECT   `ID`, `Nam e`
402                FROM     `Localizat ionLanguag es`   362                FROM     `Localizat ionLanguag es`
403                WHERE    `ID` = '.$ langID);   363                WHERE    `ID` = '.$ langID);
404       }   364       }
405     365  
406       $langK ey = addsl ashes($lan gKey);   366       $langK ey = addsl ashes($lan gKey);
407       $langS tring = pr ocess_db_i nput($lang String);   367       $langS tring = pr ocess_db_i nput($lang String);
408     368  
409       $arrKe y = db_arr ( "   369       $arrKe y = db_arr ( "
410           SE LECT  `ID`   370           SE LECT  `ID`
411           FR OM    `Loc alizationK eys`   371           FR OM    `Loc alizationK eys`
412           WH ERE   `Key ` = '$lang Key'", fal se );   372           WH ERE   `Key ` = '$lang Key'", fal se );
413     373  
414       if ( ! $arrKey )   374       if ( ! $arrKey )
415           re turn false ;   375           re turn false ;
416     376  
417       $keyID  = $arrKey ['ID'];   377       $keyID  = $arrKey ['ID'];
418     378  
419       while( $arrLangua ge = mysql _fetch_ass oc($resLan gs))   379       while( $arrLangua ge = mysql _fetch_ass oc($resLan gs))
420       {   380       {
421           $r esUpdateSt ring = db_ res( "   381           $r esUpdateSt ring = db_ res( "
422                UPDATE   `Localizat ionStrings `   382                UPDATE   `Localizat ionStrings `
423                SET          `Strin g` = '$lan gString'   383                SET          `Strin g` = '$lan gString'
424                WHERE        `IDKey ` = $keyID   384                WHERE        `IDKey ` = $keyID
425                AND          `IDLan guage` = { $arrLangua ge['ID']}" , false );   385                AND          `IDLan guage` = { $arrLangua ge['ID']}" , false );
426           if  ( !$resUp dateString  || mysql_ affected_r ows() <= 0  )   386           if  ( !$resUp dateString  || mysql_ affected_r ows() <= 0  )
427                return f alse;   387                return f alse;
428       }   388       }
429     389  
430       return  true;   390       return  true;
431   }   391   }
432     392  
433   function   _t_action(   $str,   $arg0   =   "",   $arg1   =   "",   $arg2   =   ""   )
  393   function   _t_action(   $str,   $arg0   =   "",   $arg1   =   "",   $arg2   =   ""   )   {
434   {    
435           re turn "<div  class=\"a ction\"><d iv>"._t($s tr,$arg0,$ arg1,$arg2 )."</div>< /div>";   394       return  "<div cla ss=\"actio n\"><div>" ._t($str,$ arg0,$arg1 ,$arg2)."< /div></div >";
436   }   395   }
437     396  
438   function   _t_echo_ac tion(   $str,   $arg0   =   "",   $arg1   =   "",   $arg2   =   ""   )
  397   function   _t_echo_ac tion(   $str,   $arg0   =   "",   $arg1   =   "",   $arg2   =   ""   )   {
439   {    
440           ec ho "<div c lass=\"act ion\"><div >"._t($str ,$arg0,$ar g1,$arg2). "</div></d iv>";   398       echo " <div class =\"action\ "><div>"._ t($str,$ar g0,$arg1,$ arg2)."</d iv></div>" ;
441   }   399   }
442     400  
443   function   echo_t_err (   $str,   $arg0   =   "",   $arg1   =   "",   $arg2   =   ""   )
  401   function   echo_t_err (   $str,   $arg0   =   "",   $arg1   =   "",   $arg2   =   ""   )   {
444   {    
445           ec ho "<div c lass=\"err \"><div>". _t($str,$a rg0,$arg1, $arg2)."</ div></div> ";   402       echo " <div class =\"err\">< div>"._t($ str,$arg0, $arg1,$arg 2)."</div> </div>";
446   }   403   }
447     404  
448   function   _t_err(   $str,   $arg0   =   "",   $arg1   =   "",   $arg2   =   ""   )
  405   function   _t_err(   $str,   $arg0   =   "",   $arg1   =   "",   $arg2   =   ""   )   {
449   {    
450       return  '<div cla ss="err">< div>' . _t ( $str, $a rg0, $arg1 , $arg2 )  . '</div>< /div>';   406       return  '<div cla ss="err">< div>' . _t ( $str, $a rg0, $arg1 , $arg2 )  . '</div>< /div>';
451   }   407   }
452     408  
453   function   _t($key,   $arg0   =   "",   $arg1   =   "",   $arg2   =   "")
  409   function   _t($key,   $arg0   =   "",   $arg1   =   "",   $arg2   =   "")   {
454   {    
455       global  $LANG;   410       global  $LANG;
456     411  
457       if(iss et($LANG[$ key]))   412       if(iss et($LANG[$ key]))
458       {   413       {
459           $s tr = $LANG [$key];   414           $s tr = $LANG [$key];
460           $s tr = str_r eplace('{0 }', $arg0,  $str);   415           $s tr = str_r eplace('{0 }', $arg0,  $str);
461           $s tr = str_r eplace('{1 }', $arg1,  $str);   416           $s tr = str_r eplace('{1 }', $arg1,  $str);
462           $s tr = str_r eplace('{2 }', $arg2,  $str);   417           $s tr = str_r eplace('{2 }', $arg2,  $str);
463           re turn $str;   418           re turn $str;
464       }   419       }
465       else   420       else
466       {   421       {
467           re turn $key;   422           re turn $key;
468       }   423       }
469   }   424   }
470     425  
471   function   _t_ext($ke y,   $args)
  426   function   _t_ext($ke y,   $args)   {
472   {    
473       global  $LANG;   427       global  $LANG;
474     428  
475       if(iss et($LANG[$ key]))   429       if(iss et($LANG[$ key]))
476       {   430       {
477           $s tr = $LANG [$key];   431           $s tr = $LANG [$key];
478     432  
479           if (!is_array ($args))   433           if (!is_array ($args))
480           {   434           {
481                return s tr_replace ('{0}', $a rgs, $str) ;   435                return s tr_replace ('{0}', $a rgs, $str) ;
482           }   436           }
483     437  
484           fo reach ($ar gs as $key  => $val)   438           fo reach ($ar gs as $key  => $val)
485           {   439           {
486                $str = s tr_replace ('{'.$key. '}', $val,  $str);   440                $str = s tr_replace ('{'.$key. '}', $val,  $str);
487           }   441           }
488     442  
489           re turn $str;   443           re turn $str;
490       }   444       }
491       else   445       else
492       {   446       {
493           re turn $key;   447           re turn $key;
494       }   448       }
495   }   449   }
496   ?>