23. File Comparison Report

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

23.1 Files compared

# Location File Last Modified
1 Dolphin-v.6.1.2\inc\classes BxDolProfileFields.php Wed May 28 09:31:20 2008 UTC
2 Dolphin-v.6.1.3\inc\classes BxDolProfileFields.php Wed Jul 16 09:51:19 2008 UTC

23.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 4 1660
Changed 3 10
Inserted 0 0
Removed 0 0

23.3 Comparison options

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

23.4 Active regular expressions

No regular expressions were active.

23.5 Comparison detail

1   <?php   1   <?php
2     2  
3   require_on ce(   ' B x D ol P FM .php'   );   3   require_on ce(  
B X_ D IRECTORY_ P ATH_CLASSE S   .   'Thing .php'   );
4   require_on ce(   $dir['plug ins']   .   'Services_ JSON.php'   );   4   require_on ce( BX_DIR ECTORY_PAT H_CLASSES  . 'BxDolPF M.php' );
5   require_on ce( $dir[' classes']  . 'Thing.p hp' );   5   require_on ce(   BX_DIRECTO RY_PATH_PL UGINS   .   'Services_ JSON.php'   );
6     6  
7   class   BxDolProfi leFields  
{
  7   class   BxDolProfi leFields   extends   Thing   {
8       var $i AreaID;   8       var $i AreaID;
9       var $s CacheFile;  // path t o cache fi le   9       var $s CacheFile;  // path t o cache fi le
10       var $a Area; // j ust a cach e array   10       var $a Area; // j ust a cach e array
11       var $a Blocks; //  array of  current bl ocks   11       var $a Blocks; //  array of  current bl ocks
12       var $a Cache; //  full cache  of profil e fields   12       var $a Cache; //  full cache  of profil e fields
13       var $a CoupleMutu al; //coup le mutual  fields   13       var $a CoupleMutu al; //coup le mutual  fields
14          14       
15       functi on BxDolPr ofileField s( $iAreaI D ) {   15       functi on BxDolPr ofileField s( $iAreaI D ) {
16           $t his -> iAr eaID = $iA reaID;   16           $t his -> iAr eaID = $iA reaID;
17              17           
18           $t his -> sCa cheFile =  BX_DIRECTO RY_PATH_IN C . 'db_ca ched/Profi leFields.i nc';   18           $t his -> sCa cheFile =  BX_DIRECTO RY_PATH_IN C . 'db_ca ched/Profi leFields.i nc';
19              19           
20           if ( !$this - > loadCach e() )   20           if ( !$this - > loadCach e() )
21                return f alse;   21                return f alse;
22              22           
23              23           
24       }   24       }
25          25       
26       functi on loadCac he( $bCycl e = true )  {   26       functi on loadCac he( $bCycl e = true )  {
27           if (   27           if (
28                !file_ex ists( $thi s -> sCach eFile ) or   28                !file_ex ists( $thi s -> sCach eFile ) or
29                !$sCache  = file_ge t_contents ( $this ->  sCacheFil e ) or   29                !$sCache  = file_ge t_contents ( $this ->  sCacheFil e ) or
30                !$this - > aCache =  eval( $sC ache ) or   30                !$this - > aCache =  eval( $sC ache ) or
31                !is_arra y($this ->  aCache)   31                !is_arra y($this ->  aCache)
32           )  {   32           )  {
33                $oPFM =  new BxDolP FMCacher() ;   33                $oPFM =  new BxDolP FMCacher() ;
34                   34                
35                if( !$oP FM -> crea teCache()  )   35                if( !$oP FM -> crea teCache()  )
36                    retu rn false;   36                    retu rn false;
37                   37                
38                if( $bCy cle ) //to  prevent c ycling   38                if( $bCy cle ) //to  prevent c ycling
39                    retu rn $this - > loadCach e( false ) ; // try a gaing   39                    retu rn $this - > loadCach e( false ) ; // try a gaing
40                else   40                else
41                    retu rn false;   41                    retu rn false;
42           }   42           }
43              43           
44           $t his -> aAr ea = $this  -> aCache [ $this ->  iAreaID ] ;   44           $t his -> aAr ea = $this  -> aCache [ $this ->  iAreaID ] ;
45              45           
46           // load block s   46           // load block s
47           $t his -> aBl ocks = $th is -> aAre a;   47           $t his -> aBl ocks = $th is -> aAre a;
48              48           
49           // get mutual  fields   49           // get mutual  fields
50           $t his -> _ge tCoupleMut ualFields( );   50           $t his -> _ge tCoupleMut ualFields( );
51              51           
52           re turn true;   52           re turn true;
53       }   53       }
54          54       
55       functi on genJson Errors( $a Errors, $b Couple ) {   55       functi on genJson Errors( $a Errors, $b Couple ) {
56           $a JsonErrors  = array() ;   56           $a JsonErrors  = array() ;
57              57           
58           $a JsonErrors [0] = $aEr rors[0];   58           $a JsonErrors [0] = $aEr rors[0];
59           if ( $bCouple  )   59           if ( $bCouple  )
60                $aJsonEr rors[1] =  $aErrors[1 ];   60                $aJsonEr rors[1] =  $aErrors[1 ];
61              61           
62           $o Parser = n ew Service s_JSON();   62           $o Parser = n ew Service s_JSON();
63           re turn $oPar ser -> enc ode( $aJso nErrors );   63           re turn $oPar ser -> enc ode( $aJso nErrors );
64       }   64       }
65          65       
66          66       
67       //sets  to $Error s intuitiv e array   67       //sets  to $Error s intuitiv e array
68       functi on process PostValues ( $bCouple , &$aValue s, &$aErro rs, $iPage  = 0, $iPr ofileID =  0 ) {   68       functi on process PostValues ( $bCouple , &$aValue s, &$aErro rs, $iPage  = 0, $iPr ofileID =  0 ) {
69           $i Humans = $ bCouple ?  2 : 1; //  number of  members in  profile ( single/cou ple), made  for doubl e arrays   69           $i Humans = $ bCouple ?  2 : 1; //  number of  members in  profile ( single/cou ple), made  for doubl e arrays
70              70           
71           if ( $this ->  iAreaID = = 1 ) // j oin   71           if ( $this ->  iAreaID = = 1 ) // j oin
72                $this ->  aBlocks =  $this ->  aArea[$iPa ge];   72                $this ->  aBlocks =  $this ->  aArea[$iPa ge];
73              73           
74           fo reach( $th is -> aBlo cks as $iB lockID =>  $aBlock )  {   74           fo reach( $th is -> aBlo cks as $iB lockID =>  $aBlock )  {
75                $aItems  = $aBlock[ 'Items'];   75                $aItems  = $aBlock[ 'Items'];
76                foreach  ($aItems a s $iItemID  => $aItem ) {   76                foreach  ($aItems a s $iItemID  => $aItem ) {
77                    $sIt emName = $ aItem['Nam e'];   77                    $sIt emName = $ aItem['Nam e'];
78                       78                    
79                    for(  $iHuman =  0; $iHuma n < $iHuma ns; $iHuma n ++ ) {   79                    for(  $iHuman =  0; $iHuma n < $iHuma ns; $iHuma n ++ ) {
80                         if( $iHuma n == 1 and  in_array(  $sItemNam e, $this - > aCoupleM utual ) )   80                         if( $iHuma n == 1 and  in_array(  $sItemNam e, $this - > aCoupleM utual ) )
81                             contin ue;   81                             contin ue;
82                           82                        
83                         $mValue =  null;   83                         $mValue =  null;
84                         switch( $a Item['Type '] ) {   84                         switch( $a Item['Type '] ) {
85                             case ' text':   85                             case ' text':
86                             case ' area':   86                             case ' area':
87                             case ' pass':   87                             case ' pass':
88                             case ' select_one ':   88                             case ' select_one ':
89                                 if ( isset( $ _POST[$sIt emName] )  and isset(  $_POST[$s ItemName][ $iHuman] )  )   89                                 if ( isset( $ _POST[$sIt emName] )  and isset(  $_POST[$s ItemName][ $iHuman] )  )
90                                      $mValue  = process_ pass_data(  $_POST[$s ItemName][ $iHuman] ) ;   90                                      $mValue  = process_ pass_data(  $_POST[$s ItemName][ $iHuman] ) ;
91                             break;   91                             break;
92                                92                             
93                             case ' bool':   93                             case ' bool':
94                                 if ( isset( $ _POST[$sIt emName] )  and isset(  $_POST[$s ItemName][ $iHuman] )  and $_POS T[$sItemNa me][$iHuma n] == 'yes ' )   94                                 if ( isset( $ _POST[$sIt emName] )  and isset(  $_POST[$s ItemName][ $iHuman] )  and $_POS T[$sItemNa me][$iHuma n] == 'yes ' )
95                                      $mValue  = true;   95                                      $mValue  = true;
96                                 el se   96                                 el se
97                                      $mValue  = false;   97                                      $mValue  = false;
98                             break;   98                             break;
99                                99                             
100                             case ' num':   100                             case ' num':
101                                 if ( isset( $ _POST[$sIt emName] )  and isset(  $_POST[$s ItemName][ $iHuman] )  and trim(  $_POST[$s ItemName][ $iHuman] )  !== '' )   101                                 if ( isset( $ _POST[$sIt emName] )  and isset(  $_POST[$s ItemName][ $iHuman] )  and trim(  $_POST[$s ItemName][ $iHuman] )  !== '' )
102                                      $mValue  = (int)tri m( $_POST[ $sItemName ][$iHuman]  );   102                                      $mValue  = (int)tri m( $_POST[ $sItemName ][$iHuman]  );
103                             break;   103                             break;
104                                104                             
105                             case ' date':   105                             case ' date':
106                                 if ( isset( $ _POST[$sIt emName] )  and isset(  $_POST[$s ItemName][ $iHuman] )  and trim(  $_POST[$s ItemName][ $iHuman] )  !== '' )  {   106                                 if ( isset( $ _POST[$sIt emName] )  and isset(  $_POST[$s ItemName][ $iHuman] )  and trim(  $_POST[$s ItemName][ $iHuman] )  !== '' )  {
107                                      list( $i Day, $iMon th, $iYear  ) = explo de( '/', $ _POST[$sIt emName][$i Human] );   107                                      list( $i Day, $iMon th, $iYear  ) = explo de( '/', $ _POST[$sIt emName][$i Human] );
108                                         108                                      
109                                      $iDay    = (int)$iD ay;   109                                      $iDay    = (int)$iD ay;
110                                      $iMonth  = (int)$iM onth;   110                                      $iMonth  = (int)$iM onth;
111                                      $iYear   = (int)$iY ear;   111                                      $iYear   = (int)$iY ear;
112                                         112                                      
113                                      $mValue  = "$iDay/$ iMonth/$iY ear";   113                                      $mValue  = "$iDay/$ iMonth/$iY ear";
114                                 }   114                                 }
115                             break;   115                             break;
116                                116                             
117                             case ' select_set ':   117                             case ' select_set ':
118                                 $m Value = ar ray();   118                                 $m Value = ar ray();
119                                 if ( isset( $ _POST[$sIt emName] )  and isset(  $_POST[$s ItemName][ $iHuman] )  and is_ar ray( $_POS T[$sItemNa me][$iHuma n] ) ) {   119                                 if ( isset( $ _POST[$sIt emName] )  and isset(  $_POST[$s ItemName][ $iHuman] )  and is_ar ray( $_POS T[$sItemNa me][$iHuma n] ) ) {
120                                      foreach  ($_POST[$s ItemName][ $iHuman] a s $sValue  ) {   120                                      foreach  ($_POST[$s ItemName][ $iHuman] a s $sValue  ) {
121                                          $mVa lue[] = pr ocess_pass _data( $sV alue );   121                                          $mVa lue[] = pr ocess_pass _data( $sV alue );
122                                      }   122                                      }
123                                 }   123                                 }
124                             break;   124                             break;
125                                125                             
126                             case ' range':   126                             case ' range':
127                                 if ( isset( $ _POST[$sIt emName] )  and isset(  $_POST[$s ItemName][ $iHuman] )  and is_ar ray( $_POS T[$sItemNa me][$iHuma n] ) ) {   127                                 if ( isset( $ _POST[$sIt emName] )  and isset(  $_POST[$s ItemName][ $iHuman] )  and is_ar ray( $_POS T[$sItemNa me][$iHuma n] ) ) {
128                                      $aRange  = $_POST[$ sItemName] [$iHuman];   128                                      $aRange  = $_POST[$ sItemName] [$iHuman];
129                                      $mValue  = array( n ull, null  );   129                                      $mValue  = array( n ull, null  );
130                                         130                                      
131                                      $aRange[ 0] = isset ( $aRange[ 0] ) ? tri m( $aRange [0] ) : '' ;   131                                      $aRange[ 0] = isset ( $aRange[ 0] ) ? tri m( $aRange [0] ) : '' ;
132                                      $aRange[ 1] = isset ( $aRange[ 1] ) ? tri m( $aRange [1] ) : '' ;   132                                      $aRange[ 1] = isset ( $aRange[ 1] ) ? tri m( $aRange [1] ) : '' ;
133                                         133                                      
134                                      if( $aRa nge[0] !==  '' )   134                                      if( $aRa nge[0] !==  '' )
135                                          $mVa lue[0] = ( int)$aRang e[0];   135                                          $mVa lue[0] = ( int)$aRang e[0];
136                                         136                                      
137                                      if( $aRa nge[1] !==  '' )   137                                      if( $aRa nge[1] !==  '' )
138                                          $mVa lue[1] = ( int)$aRang e[1];   138                                          $mVa lue[1] = ( int)$aRang e[1];
139                                 }   139                                 }
140                             break;   140                             break;
141                                141                             
142                             case ' system':   142                             case ' system':
143                                 sw itch( $aIt em['Name']  ) {   143                                 sw itch( $aIt em['Name']  ) {
144                                      case 'Co uple':   144                                      case 'Co uple':
145                                      case 'Te rmsOfUse':   145                                      case 'Te rmsOfUse':
146                                      case 'Fe atured': / /they are  boolean   146                                      case 'Fe atured': / /they are  boolean
147                                          if(  isset( $_P OST[$sItem Name] ) an d $_POST[$ sItemName]  == 'yes'  )   147                                          if(  isset( $_P OST[$sItem Name] ) an d $_POST[$ sItemName]  == 'yes'  )
148                                               $mValue =  true;   148                                               $mValue =  true;
149                                          else   149                                          else
150                                               $mValue =  false;   150                                               $mValue =  false;
151                                      break;   151                                      break;
152                                         152                                      
153                                      case 'Ca ptcha':   153                                      case 'Ca ptcha':
154                                      case 'St atus': //  they are s elect_one   154                                      case 'St atus': //  they are s elect_one
155                                          if(  isset( $_P OST[$sItem Name] ) )   155                                          if(  isset( $_P OST[$sItem Name] ) )
156                                               $mValue =  process_pa ss_data( $ _POST[$sIt emName] );   156                                               $mValue =  process_pa ss_data( $ _POST[$sIt emName] );
157                                      break;   157                                      break;
158                                 }   158                                 }
159                             break;   159                             break;
160                         }   160                         }
161                           161                        
162                         $rRes = $t his -> che ckPostValu e( $iBlock ID, $iItem ID, $mValu e, $iHuman , $iProfil eID );   162                         $rRes = $t his -> che ckPostValu e( $iBlock ID, $iItem ID, $mValu e, $iHuman , $iProfil eID );
163                           163                        
164                         if( $rRes  !== true )   164                         if( $rRes  !== true )
165                             $aErro rs[$iHuman ][$sItemNa me] = $rRe s; //it is  returned  error text   165                             $aErro rs[$iHuman ][$sItemNa me] = $rRe s; //it is  returned  error text
166                           166                        
167                           167                        
168                           168                        
169                         //if passw ord on edi t page   169                         //if passw ord on edi t page
170                         if( $aItem ['Type'] = = 'pass' a nd ( $this  -> iAreaI D == 2 or  $this -> i AreaID ==  3 or $this  -> iAreaI D == 4 ) )  {   170                         if( $aItem ['Type'] = = 'pass' a nd ( $this  -> iAreaI D == 2 or  $this -> i AreaID ==  3 or $this  -> iAreaI D == 4 ) )  {
171                             if( em pty($mValu e) )   171                             if( em pty($mValu e) )
172                                 $m Value = $a Values[$iH uman][$sIt emName];   172                                 $m Value = $a Values[$iH uman][$sIt emName];
173                             else   173                             else
174                                 $m Value = md 5( $mValue  );   174                                 $m Value = md 5( $mValue  );
175                         }   175                         }
176                           176                        
177                         $aValues[$ iHuman][$s ItemName]  = $mValue;   177                         $aValues[$ iHuman][$s ItemName]  = $mValue;
178                    }   178                    }
179                }   179                }
180           }   180           }
181       }   181       }
182          182       
183       functi on checkPo stValue( $ iBlockID,  $iItemID,  $mValue, $ iHuman, $i ProfileID  ) {   183       functi on checkPo stValue( $ iBlockID,  $iItemID,  $mValue, $ iHuman, $i ProfileID  ) {
184           //  get item   184           //  get item
185           $a Item = $th is -> aBlo cks[$iBloc kID]['Item s'][$iItem ID];   185           $a Item = $th is -> aBlo cks[$iBloc kID]['Item s'][$iItem ID];
186           if ( !$aItem  )   186           if ( !$aItem  )
187                return ' Item not f ound';   187                return ' Item not f ound';
188              188           
189           $a Checks = a rray(   189           $a Checks = a rray(
190                'text' = > array( ' Mandatory' , 'Min', ' Max', 'Uni que', 'Che ck' ),   190                'text' = > array( ' Mandatory' , 'Min', ' Max', 'Uni que', 'Che ck' ),
191                'area' = > array( ' Mandatory' , 'Min', ' Max', 'Uni que', 'Che ck' ),   191                'area' = > array( ' Mandatory' , 'Min', ' Max', 'Uni que', 'Che ck' ),
192                'pass' = > array( ' Mandatory' , 'Min', ' Max', 'Che ck', 'Pass Confirm' ) ,   192                'pass' = > array( ' Mandatory' , 'Min', ' Max', 'Che ck', 'Pass Confirm' ) ,
193                'date' = > array( ' Mandatory' , 'Min', ' Max', 'Che ck' ),   193                'date' = > array( ' Mandatory' , 'Min', ' Max', 'Che ck' ),
194                'select_ one' => ar ray( 'Min' , 'Max', ' Mandatory' , 'Values' , 'Check'  ),   194                'select_ one' => ar ray( 'Min' , 'Max', ' Mandatory' , 'Values' , 'Check'  ),
195                'select_ set' => ar ray( 'Min' , 'Max', ' Mandatory' , 'Values' , 'Check'  ),   195                'select_ set' => ar ray( 'Min' , 'Max', ' Mandatory' , 'Values' , 'Check'  ),
196                'num'     => array(  'Mandator y', 'Min',  'Max', 'U nique', 'C heck' ),   196                'num'     => array(  'Mandator y', 'Min',  'Max', 'U nique', 'C heck' ),
197                'range'   => array(  'Mandator y', 'Range Correct',  'Min', 'Ma x', 'Check ' ),   197                'range'   => array(  'Mandator y', 'Range Correct',  'Min', 'Ma x', 'Check ' ),
198                'system'  => array(  'System'  ),   198                'system'  => array(  'System'  ),
199                'bool'    => array(  'Mandator y' )   199                'bool'    => array(  'Mandator y' )
200           );   200           );
201              201           
202           $a MyChecks =  $aChecks[  $aItem['T ype'] ];   202           $a MyChecks =  $aChecks[  $aItem['T ype'] ];
203              203           
204           fo reach ($aM yChecks as  $sCheck )  {   204           fo reach ($aM yChecks as  $sCheck )  {
205                $sFunc =  'checkPos tValueFor'  . $sCheck ;   205                $sFunc =  'checkPos tValueFor'  . $sCheck ;
206                   206                
207                $mRes =  $this -> $ sFunc( $aI tem, $mVal ue, $iHuma n, $iProfi leID );   207                $mRes =  $this -> $ sFunc( $aI tem, $mVal ue, $iHuma n, $iProfi leID );
208                   208                
209                if( $mRe s !== true  ) {   209                if( $mRe s !== true  ) {
210                    if(  is_bool( $ mRes ) ) / / it is fa lse...   210                    if(  is_bool( $ mRes ) ) / / it is fa lse...
211                         return _t(  $aItem[ $ sCheck . ' Msg' ], $a Item[$sChe ck] );   211                         return _t(  $aItem[ $ sCheck . ' Msg' ], $a Item[$sChe ck] );
212                    else   212                    else
213                         return $mR es; // ret urned as t ext   213                         return $mR es; // ret urned as t ext
214                }   214                }
215           }   215           }
216              216           
217           re turn true;   217           re turn true;
218       }   218       }
219          219       
220       functi on checkPo stValueFor PassConfir m( $aItem,  $mValue,  $iHuman )  {   220       functi on checkPo stValueFor PassConfir m( $aItem,  $mValue,  $iHuman )  {
221           $s ConfPass =  process_p ass_data(  $_POST[ "{ $aItem['Na me']}_conf irm" ][$iH uman] );   221           $s ConfPass =  process_p ass_data(  $_POST[ "{ $aItem['Na me']}_conf irm" ][$iH uman] );
222           if ( $sConfPa ss != $mVa lue )   222           if ( $sConfPa ss != $mVa lue )
223                return _ t( '_Passw ord confir mation fai led' );   223                return _ t( '_Passw ord confir mation fai led' );
224           el se   224           el se
225                return t rue;   225                return t rue;
226       }   226       }
227          227       
228       functi on checkPo stValueFor RangeCorre ct( $aItem , $mValue  ) {   228       functi on checkPo stValueFor RangeCorre ct( $aItem , $mValue  ) {
229           if ( is_null( $mValue[0] ) or is_nu ll($mValue [1]) )   229           if ( is_null( $mValue[0] ) or is_nu ll($mValue [1]) )
230                return t rue; // if  not set,  pass this  check   230                return t rue; // if  not set,  pass this  check
231              231           
232           if ( $mValue[ 0] > $mVal ue[1] )   232           if ( $mValue[ 0] > $mVal ue[1] )
233                return _ t( '_First  value mus t be bigge r' );   233                return _ t( '_First  value mus t be bigge r' );
234              234           
235           re turn true;   235           re turn true;
236       }   236       }
237          237       
238       functi on checkPo stValueFor Min( $aIte m, $mValue  ) {   238       functi on checkPo stValueFor Min( $aIte m, $mValue  ) {
239           $i Min = $aIt em['Min'];   239           $i Min = $aIt em['Min'];
240           if ( is_null( $iMin) )   240           if ( is_null( $iMin) )
241                return t rue;   241                return t rue;
242              242           
243           sw itch( $aIt em['Type']  ) {   243           sw itch( $aIt em['Type']  ) {
244                case 'te xt':   244                case 'te xt':
245                case 'ar ea':   245                case 'ar ea':
246                    if(  strlen( $m Value ) <  $iMin )   246                    if(  strlen( $m Value ) <  $iMin )
247                         return fal se;   247                         return fal se;
248                break;   248                break;
249                   249                
250                case 'pa ss':   250                case 'pa ss':
251                    if(  strlen( $m Value ) >  0 and strl en( $mValu e ) < $iMi n )   251                    if(  strlen( $m Value ) >  0 and strl en( $mValu e ) < $iMi n )
252                         return fal se;   252                         return fal se;
253                break;   253                break;
254                   254                
255                case 'nu m':   255                case 'nu m':
256                    if(  $mValue <  $iMin )   256                    if(  $mValue <  $iMin )
257                         return fal se;   257                         return fal se;
258                break;   258                break;
259                   259                
260                case 'da te':   260                case 'da te':
261                    if(  $this -> g etAge($mVa lue) < $iM in )   261                    if(  $this -> g etAge($mVa lue) < $iM in )
262                         return fal se;   262                         return fal se;
263                break;   263                break;
264                   264                
265                case 'ra nge':   265                case 'ra nge':
266                    if(  $mValue[0]  < $iMin | | $mValue[ 1] < $iMin  )   266                    if(  $mValue[0]  < $iMin | | $mValue[ 1] < $iMin  )
267                         return fal se;   267                         return fal se;
268                break;   268                break;
269                   269                
270                case 'se lect_set':   270                case 'se lect_set':
271                    if(  count( $mV alue ) < $ iMin )   271                    if(  count( $mV alue ) < $ iMin )
272                         return fal se;   272                         return fal se;
273                break;   273                break;
274           }   274           }
275              275           
276           re turn true;   276           re turn true;
277       }   277       }
278          278       
279       functi on checkPo stValueFor Max( $aIte m, $mValue  ) {   279       functi on checkPo stValueFor Max( $aIte m, $mValue  ) {
280           $i Max = $aIt em['Max'];   280           $i Max = $aIt em['Max'];
281           if ( is_null( $iMax) )   281           if ( is_null( $iMax) )
282                return t rue;   282                return t rue;
283              283           
284           sw itch( $aIt em['Type']  ) {   284           sw itch( $aIt em['Type']  ) {
285                case 'te xt':   285                case 'te xt':
286                case 'ar ea':   286                case 'ar ea':
287                case 'pa ss':   287                case 'pa ss':
288                    if(  strlen( $m Value ) >  $iMax )   288                    if(  strlen( $m Value ) >  $iMax )
289                         return fal se;   289                         return fal se;
290                break;   290                break;
291                   291                
292                case 'nu m':   292                case 'nu m':
293                    if(  $mValue >  $iMax )   293                    if(  $mValue >  $iMax )
294                         return fal se;   294                         return fal se;
295                break;   295                break;
296                   296                
297                case 'da te':   297                case 'da te':
298                    if(  $this -> g etAge($mVa lue) > $iM ax )   298                    if(  $this -> g etAge($mVa lue) > $iM ax )
299                         return fal se;   299                         return fal se;
300                break;   300                break;
301                   301                
302                case 'ra nge':   302                case 'ra nge':
303                    if(  $mValue[0]  > $iMax | | $mValue[ 1] > $iMax  )   303                    if(  $mValue[0]  > $iMax | | $mValue[ 1] > $iMax  )
304                         return fal se;   304                         return fal se;
305                break;   305                break;
306                   306                
307                case 'se lect_set':   307                case 'se lect_set':
308                    if(  count( $mV alue ) > $ iMax )   308                    if(  count( $mV alue ) > $ iMax )
309                         return fal se;   309                         return fal se;
310                break;   310                break;
311           }   311           }
312              312           
313           re turn true;   313           re turn true;
314       }   314       }
315          315       
316       functi on checkPo stValueFor Unique( $a Item, $mVa lue, $iHum an, $iProf ileID ) {   316       functi on checkPo stValueFor Unique( $a Item, $mVa lue, $iHum an, $iProf ileID ) {
317           gl obal $logg ed;   317           gl obal $logg ed;
318              318           
319           if ( !$aItem[ 'Unique']  )   319           if ( !$aItem[ 'Unique']  )
320                return t rue;   320                return t rue;
321              321           
322           $i ProfileID  = (int)$iP rofileID;   322           $i ProfileID  = (int)$iP rofileID;
323           if ( $iProfil eID ) {   323           if ( $iProfil eID ) {
324                $sAdd =  "AND `ID`  != $iProfi leID";   324                $sAdd =  "AND `ID`  != $iProfi leID";
325           }  else   325           }  else
326                $sAdd =  '';   326                $sAdd =  '';
327              327           
328           $m Value_db =  addslashe s( $mValue  );   328           $m Value_db =  addslashe s( $mValue  );
329           $s Query = "S ELECT COUN T(*) FROM  `Profiles`  WHERE `{$ aItem['Nam e']}` = '$ mValue_db'  $sAdd";   329           $s Query = "S ELECT COUN T(*) FROM  `Profiles`  WHERE `{$ aItem['Nam e']}` = '$ mValue_db'  $sAdd";
330           if ( (int)db_ value( $sQ uery ) )   330           if ( (int)db_ value( $sQ uery ) )
331                return f alse;   331                return f alse;
332              332           
333           re turn true;   333           re turn true;
334       }   334       }
335          335       
336       functi on checkPo stValueFor Check( $aI tem, $mVal ue ) {   336       functi on checkPo stValueFor Check( $aI tem, $mVal ue ) {
337           $s Check = $a Item['Chec k'];   337           $s Check = $a Item['Chec k'];
338           if ( empty($s Check) )   338           if ( empty($s Check) )
339                return t rue;   339                return t rue;
340              340           
341           $s Func = cre ate_functi on( '$arg0 ', $sCheck  );   341           $s Func = cre ate_functi on( '$arg0 ', $sCheck  );
342              342           
343           if ( !$sFunc(  $mValue )  )   343           if ( !$sFunc(  $mValue )  )
344                return f alse;   344                return f alse;
345              345           
346           re turn true;   346           re turn true;
347       }   347       }
348          348       
349       functi on checkPo stValueFor Mandatory(  $aItem, $ mValue ) {   349       functi on checkPo stValueFor Mandatory(  $aItem, $ mValue ) {
350           if ( !$aItem[ 'Mandatory '] )   350           if ( !$aItem[ 'Mandatory '] )
351                return t rue;   351                return t rue;
352              352           
353           if ( $aItem[' Type'] ==  'num' ) {   353           if ( $aItem[' Type'] ==  'num' ) {
354                if( is_n ull($mValu e) )   354                if( is_n ull($mValu e) )
355                    retu rn false;   355                    retu rn false;
356           }  elseif( $a Item['Type '] == 'ran ge' ) {   356           }  elseif( $a Item['Type '] == 'ran ge' ) {
357                if( is_n ull($mValu e[0]) or i s_null($mV alue[1]) )   357                if( is_n ull($mValu e[0]) or i s_null($mV alue[1]) )
358                    retu rn false;   358                    retu rn false;
359           }  elseif( $a Item['Type '] == 'pas s' ) {   359           }  elseif( $a Item['Type '] == 'pas s' ) {
360                if( $thi s -> iArea ID == 2 or  $this ->  iAreaID ==  3 or $thi s -> iArea ID == 4 )  // if area  is edit,  non-mandat ory   360                if( $thi s -> iArea ID == 2 or  $this ->  iAreaID ==  3 or $thi s -> iArea ID == 4 )  // if area  is edit,  non-mandat ory
361                    retu rn true;   361                    retu rn true;
362                else   362                else
363                    if(  empty($mVa lue) ) //  standard c heck   363                    if(  empty($mVa lue) ) //  standard c heck
364                         return fal se;   364                         return fal se;
365           }  else {   365           }  else {
366                if( empt y($mValue)  )   366                if( empt y($mValue)  )
367                    retu rn false;   367                    retu rn false;
368           }   368           }
369              369           
370           re turn true;   370           re turn true;
371       }   371       }
372          372       
373       functi on checkPo stValueFor Values( $a Item, $mVa lue ) {   373       functi on checkPo stValueFor Values( $a Item, $mVa lue ) {
374           if ( empty($m Value) ) / /it is not  selected   374           if ( empty($m Value) ) / /it is not  selected
375                return t rue;   375                return t rue;
376              376           
377           if ( is_array ( $aItem[' Values'] )  )   377           if ( is_array ( $aItem[' Values'] )  )
378                $aValues  = $aItem[ 'Values'];   378                $aValues  = $aItem[ 'Values'];
379           el se   379           el se
380                $aValues  = $this - > getPrede finedKeysA rr( $aItem ['Values']  );   380                $aValues  = $this - > getPrede finedKeysA rr( $aItem ['Values']  );
381              381           
382           if ( !$aValue s )   382           if ( !$aValue s )
383                return ' Cannot fin d list';   383                return ' Cannot fin d list';
384              384           
385           if ( $aItem[' Type'] ==  'select_on e' ) {   385           if ( $aItem[' Type'] ==  'select_on e' ) {
386                if( !in_ array( $mV alue, $aVa lues ) )   386                if( !in_ array( $mV alue, $aVa lues ) )
387                    retu rn 'Value  not in lis t. Hack at tempt!';   387                    retu rn 'Value  not in lis t. Hack at tempt!';
388           }  elseif( $a Item['Type '] == 'sel ect_set' )  {   388           }  elseif( $a Item['Type '] == 'sel ect_set' )  {
389                foreach(  $mValue a s $sValue  )   389                foreach(  $mValue a s $sValue  )
390                    if(  !in_array(  $sValue,  $aValues )  )   390                    if(  !in_array(  $sValue,  $aValues )  )
391                         return 'Va lue not in  list. Hac k attempt! ';   391                         return 'Va lue not in  list. Hac k attempt! ';
392           }   392           }
393              393           
394           re turn true;   394           re turn true;
395       }   395       }
396          396       
397       functi on getPred efinedKeys Arr( $sKey  ) {   397       functi on getPred efinedKeys Arr( $sKey  ) {
398           gl obal $aPre Values;   398           gl obal $aPre Values;
399              399           
400           if ( substr(  $sKey, 0,  2 ) == '#! ' )   400           if ( substr(  $sKey, 0,  2 ) == '#! ' )
401                $sKey =  substr( $s Key, 2 );   401                $sKey =  substr( $s Key, 2 );
402              402           
403           re turn @arra y_keys( $a PreValues[ $sKey] );   403           re turn @arra y_keys( $a PreValues[ $sKey] );
404       }   404       }
405          405       
406       functi on checkPo stValueFor System( $a Item, $mVa lue ) {   406       functi on checkPo stValueFor System( $a Item, $mVa lue ) {
407              407           
408           sw itch( $aIt em['Name']  ) {   408           sw itch( $aIt em['Name']  ) {
409                case 'Ca ptcha':   409                case 'Ca ptcha':
410                    retu rn ( $this  -> checkC aptcha( $m Value ) )  ? true : _ t( '_Captc ha check f ailed' );   410                    retu rn ( $this  -> checkC aptcha( $m Value ) )  ? true : _ t( '_Captc ha check f ailed' );
411                break;   411                break;
412                   412                
413                case 'St atus':   413                case 'St atus':
414                    if(  !in_array( $mValue, $ aItem['Val ues'] ) )   414                    if(  !in_array( $mValue, $ aItem['Val ues'] ) )
415                         return 'St atus hack  attempt!';   415                         return 'St atus hack  attempt!';
416                break;   416                break;
417                   417                
418                case 'Te rmsOfUse':   418                case 'Te rmsOfUse':
419                    retu rn $mValue  ? true :  _t( '_You  must agree  with term s of use'  );   419                    retu rn $mValue  ? true :  _t( '_You  must agree  with term s of use'  );
420                break;   420                break;
421           }   421           }
422              422           
423           re turn true;   423           re turn true;
424       }   424       }
425          425       
426       functi on checkCa ptcha( $mV alue ) {   426       functi on checkCa ptcha( $mV alue ) {
427           if ( $_COOKIE ['strSec']  === md5(  $mValue )  ) {   427           if ( $_COOKIE ['strSec']  === md5(  $mValue )  ) {
428                return t rue;   428                return t rue;
429           }  else   429           }  else
430                return f alse;   430                return f alse;
431       }   431       }
432          432       
433       functi on getAge(  $sBirthDa te ) { //  28/10/1985   433       functi on getAge(  $sBirthDa te ) { //  28/10/1985
434           $b d = explod e( '/', $s BirthDate  );   434           $b d = explod e( '/', $s BirthDate  );
435           fo reach ($bd  as $i =>  $v) $bd[$i ] = (int)$ v;   435           fo reach ($bd  as $i =>  $v) $bd[$i ] = (int)$ v;
436              436           
437           if  ( date('n ') > $bd[1 ] || ( dat e('n') ==  $bd[1] &&  date('j')  >= $bd[0]  ) )   437           if  ( date('n ') > $bd[1 ] || ( dat e('n') ==  $bd[1] &&  date('j')  >= $bd[0]  ) )
438                $age = d ate('Y') -  $bd[2];   438                $age = d ate('Y') -  $bd[2];
439           el se   439           el se
440                $age = d ate('Y') -  $bd[2] -  1;   440                $age = d ate('Y') -  $bd[2] -  1;
441              441           
442           re turn $age;   442           re turn $age;
443       }   443       }
444          444       
445       // cre ate intuit ive array  of values  from defau lt text pr ofile arra y (getProf ileInfo)   445       // cre ate intuit ive array  of values  from defau lt text pr ofile arra y (getProf ileInfo)
446       functi on getValu esFromProf ile( $aPro file ) {   446       functi on getValu esFromProf ile( $aPro file ) {
447           $a Values = a rray();   447           $a Values = a rray();
448              448           
449           fo reach( $th is -> aBlo cks as $aB lock ) {   449           fo reach( $th is -> aBlo cks as $aB lock ) {
450                foreach(  $aBlock[' Items'] as  $aItem )  {   450                foreach(  $aBlock[' Items'] as  $aItem )  {
451                    $sIt emName = $ aItem['Nam e'];   451                    $sIt emName = $ aItem['Nam e'];
452                    if(  !array_key _exists( $ sItemName,  $aProfile  ) )   452                    if(  !array_key _exists( $ sItemName,  $aProfile  ) )
453                         continue;  //pass thi s   453                         continue;  //pass thi s
454                       454                    
455                    $mVa lue = $aPr ofile[$sIt emName];   455                    $mVa lue = $aPr ofile[$sIt emName];
456                       456                    
457                    swit ch( $aItem ['Type'] )  {   457                    swit ch( $aItem ['Type'] )  {
458                         case 'sele ct_set':   458                         case 'sele ct_set':
459                             $mValu e = explod e( ',', $m Value );   459                             $mValu e = explod e( ',', $m Value );
460                         break;   460                         break;
461                           461                        
462                         case 'rang e':   462                         case 'rang e':
463                             $mValu e = explod e( ',', $m Value );   463                             $mValu e = explod e( ',', $m Value );
464                             foreac h( $mValue  as $iInd  => $sValue  )   464                             foreac h( $mValue  as $iInd  => $sValue  )
465                                 $m Value[$iIn d] = (int) $sValue;   465                                 $m Value[$iIn d] = (int) $sValue;
466                         break;   466                         break;
467                           467                        
468                         case 'bool ':   468                         case 'bool ':
469                             $mValu e = (bool) $mValue;   469                             $mValu e = (bool) $mValue;
470                         break;   470                         break;
471                           471                        
472                         case 'num' :   472                         case 'num' :
473                             $mValu e = (int)$ mValue;   473                             $mValu e = (int)$ mValue;
474                         break;   474                         break;
475                           475                        
476                         case 'date ':   476                         case 'date ':
477                             $aDate  = explode ( '-', $mV alue ); // YYYY-MM-DD   477                             $aDate  = explode ( '-', $mV alue ); // YYYY-MM-DD
478                             $mValu e = (int)$ aDate[2] .  '/' . (in t)$aDate[1 ] . '/' .  $aDate[0];   478                             $mValu e = (int)$ aDate[2] .  '/' . (in t)$aDate[1 ] . '/' .  $aDate[0];
479                         break;   479                         break;
480                           480                        
481                         case 'syst em':   481                         case 'syst em':
482                             switch ( $sItemNa me ) {   482                             switch ( $sItemNa me ) {
483                                 ca se 'Couple ':   483                                 ca se 'Couple ':
484                                 ca se 'ID':   484                                 ca se 'ID':
485                                      $mValue  = (int)$mV alue;   485                                      $mValue  = (int)$mV alue;
486                                 br eak;   486                                 br eak;
487                                    487                                 
488                                 ca se 'Featur ed':   488                                 ca se 'Featur ed':
489                                      $mValue  = (bool)$m Value;   489                                      $mValue  = (bool)$m Value;
490                                 br eak;   490                                 br eak;
491                             }   491                             }
492                         break;   492                         break;
493                    }   493                    }
494                       494                    
495                    $aVa lues[$sIte mName] = $ mValue;   495                    $aVa lues[$sIte mName] = $ mValue;
496                }   496                }
497           }   497           }
498              498           
499           re turn $aVal ues;   499           re turn $aVal ues;
500       }   500       }
501          501       
502       // rev erse of pr evious fun ction. con vert intui tive array  to text a rray   502       // rev erse of pr evious fun ction. con vert intui tive array  to text a rray
503       functi on getProf ileFromVal ues( $aVal ues ) {   503       functi on getProf ileFromVal ues( $aVal ues ) {
504           $a Profile =  array();   504           $a Profile =  array();
505              505           
506           if ( $this ->  iAreaID = = 1 ) {   506           if ( $this ->  iAreaID = = 1 ) {
507                $aBlocks  = array() ;   507                $aBlocks  = array() ;
508                foreach(  array_key s( $this - > aArea )  as $iPage  )   508                foreach(  array_key s( $this - > aArea )  as $iPage  )
509                    $aBl ocks = arr ay_merge(  $aBlocks,  $this -> a Area[ $iPa ge ] );   509                    $aBl ocks = arr ay_merge(  $aBlocks,  $this -> a Area[ $iPa ge ] );
510           }  else   510           }  else
511                $aBlocks  = $this - > aBlocks;   511                $aBlocks  = $this - > aBlocks;
512              512           
513           fo reach( $aB locks as $ aBlock ) {   513           fo reach( $aB locks as $ aBlock ) {
514                foreach(  $aBlock[' Items'] as  $aItem )  {   514                foreach(  $aBlock[' Items'] as  $aItem )  {
515                    $sIt emName = $ aItem['Nam e'];   515                    $sIt emName = $ aItem['Nam e'];
516                    if(  !array_key _exists( $ sItemName,  $aValues  ) )   516                    if(  !array_key _exists( $ sItemName,  $aValues  ) )
517                         continue;  //pass thi s   517                         continue;  //pass thi s
518                       518                    
519                    $mVa lue = $aVa lues[$sIte mName];   519                    $mVa lue = $aVa lues[$sIte mName];
520                       520                    
521                    swit ch( $aItem ['Type'] )  {   521                    swit ch( $aItem ['Type'] )  {
522                         case 'date ':   522                         case 'date ':
523                             $aDate  = explode ( '/', $mV alue );   523                             $aDate  = explode ( '/', $mV alue );
524                             $mValu e = sprint f( '%04d-% 02d-%02d',  $aDate[2] , $aDate[1 ], $aDate[ 0] );   524                             $mValu e = sprint f( '%04d-% 02d-%02d',  $aDate[2] , $aDate[1 ], $aDate[ 0] );
525                         break;   525                         break;
526                           526                        
527                         //impl oth ers   527                         //impl oth ers
528                    }   528                    }
529                       529                    
530                    $aPr ofile[$sIt emName] =  $mValue;   530                    $aPr ofile[$sIt emName] =  $mValue;
531                }   531                }
532           }   532           }
533              533           
534           re turn $aPro file;   534           re turn $aPro file;
535       }   535       }
536          536       
537       //inte rnal funct ion   537       //inte rnal funct ion
538       functi on _getCou pleMutualF ields() {   538       functi on _getCou pleMutualF ields() {
539           $a AllItems =  $this ->  aCache[100 ][0]['Item s'];   539           $a AllItems =  $this ->  aCache[100 ][0]['Item s'];
540              540           
541           $t his -> aCo upleMutual  = array(  'NickName' , 'Passwor d', 'Email ' );   541           $t his -> aCo upleMutual  = array(  'NickName' , 'Passwor d', 'Email ' );
542              542           
543           fo reach( $aA llItems as  $aItem )  {   543           fo reach( $aA llItems as  $aItem )  {
544                if( $aIt em['Name']  == 'Coupl e' )   544                if( $aIt em['Name']  == 'Coupl e' )
545                    $thi s -> aCoup leMutual =  array_mer ge( $this  -> aCouple Mutual, ex plode( "\n ", $aItem[ 'Extra'] )  ); // add  specified  values   545                    $thi s -> aCoup leMutual =  array_mer ge( $this  -> aCouple Mutual, ex plode( "\n ", $aItem[ 'Extra'] )  ); // add  specified  values
546                   546                
547                if( $aIt em['Type']  == 'syste m' )   547                if( $aIt em['Type']  == 'syste m' )
548                    $thi s -> aCoup leMutual[]  = $aItem[ 'Name'];   548                    $thi s -> aCoup leMutual[]  = $aItem[ 'Name'];
549           }   549           }
550              550           
551           // echoDbg( $ this -> aC oupleMutua l );   551           // echoDbg( $ this -> aC oupleMutua l );
552       }   552       }
553          553       
554       //exte rnal funct ion   554       //exte rnal funct ion
555       functi on getCoup leMutualFi elds() {   555       functi on getCoup leMutualFi elds() {
556           re turn $this  -> aCoupl eMutual;   556           re turn $this  -> aCoupl eMutual;
557       }   557       }
558          558       
559       functi on getView ableValue(  $aItem, $ sValue ) {   559       functi on getView ableValue(  $aItem, $ sValue ) {
560           sw itch( $aIt em['Type']  ) {   560           sw itch( $aIt em['Type']  ) {
561                case 'te xt':   561                case 'te xt':
562                case 'nu m':   562                case 'nu m':
563                case 'ar ea':   563                case 'ar ea':
564                    retu rn nl2br(h tmlspecial chars_adv( $sValue));   564                    retu rn nl2br(h tmlspecial chars_adv( $sValue));
565                   565                
566                case 'da te':   566                case 'da te':
567                    retu rn $this - > getViewa bleDate( $ sValue );   567                    retu rn $this - > getViewa bleDate( $ sValue );
568                       568                    
569                case 'ra nge':   569                case 'ra nge':
570                    retu rn htmlspe cialchars_ adv( str_r eplace( ', ', ' - ',$ sValue ) ) ;   570                    retu rn htmlspe cialchars_ adv( str_r eplace( ', ', ' - ',$ sValue ) ) ;
571                   571                
572                case 'bo ol':   572                case 'bo ol':
573                    retu rn _t( $sV alue ? '_Y es' : '_No ' );   573                    retu rn _t( $sV alue ? '_Y es' : '_No ' );
574                   574                
575                case 'se lect_one':   575                case 'se lect_one':
576                    retu rn $this - > getViewa bleSelectO ne( $aItem ['Values'] , $sValue  );   576                    retu rn $this - > getViewa bleSelectO ne( $aItem ['Values'] , $sValue  );
577                       577                    
578                case 'se lect_set':   578                case 'se lect_set':
579                    retu rn $this - > getViewa bleSelectS et( $aItem ['Values'] , $sValue  );   579                    retu rn $this - > getViewa bleSelectS et( $aItem ['Values'] , $sValue  );
580                   580                
581                   581                
582                case 'sy stem':   582                case 'sy stem':
583                    swit ch( $aItem ['Name'] )  {   583                    swit ch( $aItem ['Name'] )  {
584                         case 'Date Reg':   584                         case 'Date Reg':
585                         case 'Date LastEdit':   585                         case 'Date LastEdit':
586                         case 'Date LastLogin' :   586                         case 'Date LastLogin' :
587                             return  $this ->  getViewabl eDate( $sV alue );   587                             return  $this ->  getViewabl eDate( $sV alue );
588                                588                             
589                         case 'Stat us':   589                         case 'Stat us':
590                             return  _t( "_$sV alue" );   590                             return  _t( "_$sV alue" );
591                           591                        
592                         case 'ID':   592                         case 'ID':
593                             return  $sValue;   593                             return  $sValue;
594                           594                        
595                         case 'Feat ured':   595                         case 'Feat ured':
596                             return  _t( $sVal ue ? '_Yes ' : '_No'  );   596                             return  _t( $sVal ue ? '_Yes ' : '_No'  );
597                           597                        
598                         default:   598                         default:
599                             return  '&nbsp;';   599                             return  '&nbsp;';
600                    }   600                    }
601                break;   601                break;
602                   602                
603                case 'pa ss':   603                case 'pa ss':
604                default:   604                default:
605                    retu rn '&nbsp; ';   605                    retu rn '&nbsp; ';
606           }   606           }
607       }   607       }
608          608       
609       functi on getView ableDate(  $sDate ) {   609       functi on getView ableDate(  $sDate ) {
610           re turn $sDat e;   610           re turn $sDat e;
611       }   611       }
612          612       
613       functi on getView ableSelect One( $mVal ues, $sVal ue, $sUseL Key = 'LKe y' ) {   613       functi on getView ableSelect One( $mVal ues, $sVal ue, $sUseL Key = 'LKe y' ) {
614           gl obal $aPre Values;   614           gl obal $aPre Values;
615              615           
616           if ( is_strin g($mValues ) and subs tr($mValue s, 0, 2) = = '#!' ) {   616           if ( is_strin g($mValues ) and subs tr($mValue s, 0, 2) = = '#!' ) {
617                $sKey =  substr($mV alues, 2);   617                $sKey =  substr($mV alues, 2);
618     618  
619                if( !iss et( $aPreV alues[$sKe y][$sUseLK ey] ) )   619                if( !iss et( $aPreV alues[$sKe y][$sUseLK ey] ) )
620                    $sUs eLKey = 'L Key';   620                    $sUs eLKey = 'L Key';
621     621  
622                return h tmlspecial chars_adv(  _t( $aPre Values[$sK ey][$sValu e][$sUseLK ey] ) );   622                return h tmlspecial chars_adv(  _t( $aPre Values[$sK ey][$sValu e][$sUseLK ey] ) );
623           }  elseif( is _array($mV alues) ) {   623           }  elseif( is _array($mV alues) ) {
624                if( in_a rray($sVal ue, $mValu es) )   624                if( in_a rray($sVal ue, $mValu es) )
625                    retu rn htmlspe cialchars_ adv( _t( " _FieldValu es_{$sValu e}" ) );   625                    retu rn htmlspe cialchars_ adv( _t( " _FieldValu es_{$sValu e}" ) );
626                    //re turn htmls pecialchar s_adv( _t(  "_$sValue " ) );   626                    //re turn htmls pecialchar s_adv( _t(  "_$sValue " ) );
627                else   627                else
628                    retu rn '';   628                    retu rn '';
629           }  else   629           }  else
630                return ' ';   630                return ' ';
631       }   631       }
632          632       
633       functi on getView ableSelect Set( $mVal ues, $sVal ue, $sUseL Key = 'LKe y' ) {   633       functi on getView ableSelect Set( $mVal ues, $sVal ue, $sUseL Key = 'LKe y' ) {
634           gl obal $aPre Values;   634           gl obal $aPre Values;
635              635           
636           if ( is_strin g($mValues ) and subs tr($mValue s, 0, 2) = = '#!' ) {   636           if ( is_strin g($mValues ) and subs tr($mValue s, 0, 2) = = '#!' ) {
637                $sKey =  substr($mV alues, 2);   637                $sKey =  substr($mV alues, 2);
638                if( !iss et( $aPreV alues[$sKe y] ) )   638                if( !iss et( $aPreV alues[$sKe y] ) )
639                    retu rn '&nbsp; ';   639                    retu rn '&nbsp; ';
640                   640                
641                $aValues  = explode ( ',', $sV alue );   641                $aValues  = explode ( ',', $sV alue );
642                   642                
643                $aTValue s = array( );   643                $aTValue s = array( );
644                   644                
645                foreach(  $aValues  as $sValue  )   645                foreach(  $aValues  as $sValue  )
646                    $aTV alues[] =  _t( $aPreV alues[$sKe y][$sValue ][$sUseLKe y] );   646                    $aTV alues[] =  _t( $aPreV alues[$sKe y][$sValue ][$sUseLKe y] );
647                   647                
648                return h tmlspecial chars_adv(  implode(  ', ', $aTV alues ) );   648                return h tmlspecial chars_adv(  implode(  ', ', $aTV alues ) );
649           }  elseif( is _array($mV alues) ) {   649           }  elseif( is _array($mV alues) ) {
650                $aValues  = array() ;   650                $aValues  = array() ;
651                foreach(  explode(  ',', $sVal ue ) as $s ValueOne )   651                foreach(  explode(  ',', $sVal ue ) as $s ValueOne )
652                    $aVa lues[] = _ t( "_Field Values_{$s ValueOne}"  );   652                    $aVa lues[] = _ t( "_Field Values_{$s ValueOne}"  );
653                    //$a Values[] =  _t( "_$sV alueOne" ) ;   653                    //$a Values[] =  _t( "_$sV alueOne" ) ;
654                   654                
655                return h tmlspecial chars_adv(  implode(  ', ', $aVa lues ) );   655                return h tmlspecial chars_adv(  implode(  ', ', $aVa lues ) );
656           }  else   656           }  else
657                return ' ';   657                return ' ';
658       }   658       }
659          659       
660       functi on collect SearchRequ estParams( ) {   660       functi on collect SearchRequ estParams( ) {
661           $a Params = a rray();   661           $a Params = a rray();
662              662           
663           if ( empty($_ GET) and e mpty($_POS T) )   663           if ( empty($_ GET) and e mpty($_POS T) )
664                return $ aParams;   664                return $ aParams;
665              665           
666           fo reach( $th is -> aBlo cks as $aB lock ) {   666           fo reach( $th is -> aBlo cks as $aB lock ) {
667                foreach(  $aBlock[' Items'] as  $aItem )  {   667                foreach(  $aBlock[' Items'] as  $aItem )  {
668                    $sIt emName = $ aItem['Nam e'];   668                    $sIt emName = $ aItem['Nam e'];
669                    $mVa lue = null ;   669                    $mVa lue = null ;
670                       670                    
671                    swit ch( $aItem ['Type'] )  {   671                    swit ch( $aItem ['Type'] )  {
672                         case 'text ':   672                         case 'text ':
673                         case 'area ':   673                         case 'area ':
674                             if( is set( $_REQ UEST[$sIte mName] ) a nd $_REQUE ST[$sItemN ame] )   674                             if( is set( $_REQ UEST[$sIte mName] ) a nd $_REQUE ST[$sItemN ame] )
675                                 $m Value = pr ocess_pass _data( $_R EQUEST[$sI temName] ) ;   675                                 $m Value = pr ocess_pass _data( $_R EQUEST[$sI temName] ) ;
676                         break;   676                         break;
677                           677                        
678                         case 'num' :   678                         case 'num' :
679                         case 'date ':   679                         case 'date ':
680                         case 'rang e':   680                         case 'rang e':
681                             if( is set( $_REQ UEST[$sIte mName] ) a nd is_arra y( $_REQUE ST[$sItemN ame] ) ) {   681                             if( is set( $_REQ UEST[$sIte mName] ) a nd is_arra y( $_REQUE ST[$sItemN ame] ) ) {
682                                 $m Value = ar ray();   682                                 $m Value = ar ray();
683                                    683                                 
684                                 $m Value[0] =  (int)$_RE QUEST[$sIt emName][0] ;   684                                 $m Value[0] =  (int)$_RE QUEST[$sIt emName][0] ;
685                                 $m Value[1] =  (int)$_RE QUEST[$sIt emName][1] ;   685                                 $m Value[1] =  (int)$_RE QUEST[$sIt emName][1] ;
686                                    686                                 
687                                 if ( !$mValue [0] and !$ mValue[1]  )   687                                 if ( !$mValue [0] and !$ mValue[1]  )
688                                      $mValue  = null; //  if no val ues entere d, skip th em   688                                      $mValue  = null; //  if no val ues entere d, skip th em
689                             }   689                             }
690                         break;   690                         break;
691                           691                        
692                         case 'sele ct_one':   692                         case 'sele ct_one':
693                         case 'sele ct_set':   693                         case 'sele ct_set':
694                             if( is set( $_REQ UEST[$sIte mName] ) a nd is_arra y( $_REQUE ST[$sItemN ame] ) ) {   694                             if( is set( $_REQ UEST[$sIte mName] ) a nd is_arra y( $_REQUE ST[$sItemN ame] ) ) {
695                                 $m Value = ar ray();   695                                 $m Value = ar ray();
696                                    696                                 
697                                 fo reach( $_R EQUEST[$sI temName] a s $sValue  ) {   697                                 fo reach( $_R EQUEST[$sI temName] a s $sValue  ) {
698                                      $sValue  = trim( pr ocess_pass _data( $sV alue ) );   698                                      $sValue  = trim( pr ocess_pass _data( $sV alue ) );
699                                      if( $sVa lue )   699                                      if( $sVa lue )
700                                          $mVa lue[] = $s Value;   700                                          $mVa lue[] = $s Value;
701                                 }   701                                 }
702                                    702                                 
703                                 if ( empty( $ mValue ) )   703                                 if ( empty( $ mValue ) )
704                                      $mValue  = null; // if nothing  selected,  skip   704                                      $mValue  = null; // if nothing  selected,  skip
705                             }   705                             }
706                         break;   706                         break;
707                           707                        
708                         case 'bool ':   708                         case 'bool ':
709                             if( is set( $_REQ UEST[$sIte mName] ) a nd $_REQUE ST[$sItemN ame] )   709                             if( is set( $_REQ UEST[$sIte mName] ) a nd $_REQUE ST[$sItemN ame] )
710                                 $m Value = tr ue;   710                                 $m Value = tr ue;
711                         break;   711                         break;
712                           712                        
713                         case 'syst em':   713                         case 'syst em':
714                             switch ( $sItemNa me ) {   714                             switch ( $sItemNa me ) {
715                                 ca se 'ID':   715                                 ca se 'ID':
716                                      if( isse t( $_REQUE ST[$sItemN ame] ) and  (int)$_RE QUEST[$sIt emName] )   716                                      if( isse t( $_REQUE ST[$sItemN ame] ) and  (int)$_RE QUEST[$sIt emName] )
717                                          $mVa lue = (int )$_REQUEST [$sItemNam e];   717                                          $mVa lue = (int )$_REQUEST [$sItemNam e];
718                                 br eak;   718                                 br eak;
719                                    719                                 
720                                 ca se 'Couple ':   720                                 ca se 'Couple ':
721                                      if( isse t( $_REQUE ST[$sItemN ame] ) and  is_array(  $_REQUEST [$sItemNam e] ) ) {   721                                      if( isse t( $_REQUE ST[$sItemN ame] ) and  is_array(  $_REQUEST [$sItemNam e] ) ) {
722                                          if(  isset( $_R EQUEST[$sI temName][0 ] ) and is set( $_REQ UEST[$sIte mName][1]  ) )   722                                          if(  isset( $_R EQUEST[$sI temName][0 ] ) and is set( $_REQ UEST[$sIte mName][1]  ) )
723                                               $mValue =  '-1'; //pa ss   723                                               $mValue =  '-1'; //pa ss
724                                          else if( isset(  $_REQUEST [$sItemNam e][0] ) )   724                                          else if( isset(  $_REQUEST [$sItemNam e][0] ) )
725                                               $mValue =  0;   725                                               $mValue =  0;
726                                          else if( isset(  $_REQUEST [$sItemNam e][1] ) )   726                                          else if( isset(  $_REQUEST [$sItemNam e][1] ) )
727                                               $mValue =  1;   727                                               $mValue =  1;
728                                      }   728                                      }
729                                 br eak;   729                                 br eak;
730                                    730                                 
731                                 ca se 'Locati on':   731                                 ca se 'Locati on':
732                                         732                                      
733                                 br eak;   733                                 br eak;
734                                    734                                 
735                                 ca se 'Keywor d':   735                                 ca se 'Keywor d':
736                                      if( isse t( $_REQUE ST[$sItemN ame] ) and  trim( $_R EQUEST[$sI temName] )  )   736                                      if( isse t( $_REQUE ST[$sItemN ame] ) and  trim( $_R EQUEST[$sI temName] )  )
737                                           $mValue   =   trim(   process_pa ss_data(   $
m V a lu e  
)   );
  737                                           $mValue   =   trim(   process_pa ss_data(   $ _REQUEST[$ sIte m N a m e ]   )   );
738                                 br eak;   738                                 br eak;
739                                    739                                 
740                             }   740                             }
741                         break;   741                         break;
742                    }   742                    }
743                       743                    
744                    if(  !is_null(  $mValue )  )   744                    if(  !is_null(  $mValue )  )
745                         $aParams[  $sItemName  ] = $mVal ue;   745                         $aParams[  $sItemName  ] = $mVal ue;
746                }   746                }
747           }   747           }
748              748           
749           re turn $aPar ams;   749           re turn $aPar ams;
750       }   750       }
751          751       
752       functi on getProf ilesMatch(  $aProf1,  $aProf2 )  {   752       functi on getProf ilesMatch(  $aProf1,  $aProf2 )  {
753           if ( !$this - > aArea )   753           if ( !$this - > aArea )
754                return 0 ;   754                return 0 ;
755              755           
756           $a Fields1 =  $this -> a Blocks[0][ 'Items'];   756           $a Fields1 =  $this -> a Blocks[0][ 'Items'];
757           $a Fields2 =  $this -> a Cache[100] [0]['Items '];   757           $a Fields2 =  $this -> a Cache[100] [0]['Items '];
758              758           
759           $i MyPercent  = 0;   759           $i MyPercent  = 0;
760           $i TotalPerce nt = 0;   760           $i TotalPerce nt = 0;
761           fo reach( $aF ields1 as  $aField1 )  {   761           fo reach( $aF ields1 as  $aField1 )  {
762                $aField2  = $aField s2[ $aFiel d1['MatchF ield'] ];   762                $aField2  = $aField s2[ $aFiel d1['MatchF ield'] ];
763                if( !$aF ield2 )   763                if( !$aF ield2 )
764                    cont inue;   764                    cont inue;
765                   765                
766                $iTotalP ercent +=  $aField1[' MatchPerce nt'];   766                $iTotalP ercent +=  $aField1[' MatchPerce nt'];
767                   767                
768                $sVal1 =  $aProf1[  $aField1[' Name'] ];   768                $sVal1 =  $aProf1[  $aField1[' Name'] ];
769                $sVal2 =  $aProf2[  $aField2[' Name'] ];   769                $sVal2 =  $aProf2[  $aField2[' Name'] ];
770                   770                
771                if( !str len($sVal1 ) or !strl en($sVal2)  )   771                if( !str len($sVal1 ) or !strl en($sVal2)  )
772                    cont inue;   772                    cont inue;
773                   773                
774                $iAddPar t = 0;   774                $iAddPar t = 0;
775                switch(  "{$aField1 ['Type']}  {$aField1[ 'Type']}"  ) {   775                switch(  "{$aField1 ['Type']}  {$aField1[ 'Type']}"  ) {
776                    case  'select_s et select_ one':   776                    case  'select_s et select_ one':
777                         $aVal1 = e xplode( ', ', $sVal1  );   777                         $aVal1 = e xplode( ', ', $sVal1  );
778                           778                        
779                         if( in_arr ay( $sVal2 , $aVal1 )  )   779                         if( in_arr ay( $sVal2 , $aVal1 )  )
780                             $iAddP art = 1;   780                             $iAddP art = 1;
781                    brea k;   781                    brea k;
782                       782                    
783                    case  'select_o ne select_ set':   783                    case  'select_o ne select_ set':
784                         $aVal2 = e xplode( ', ', $sVal2  );   784                         $aVal2 = e xplode( ', ', $sVal2  );
785                           785                        
786                         if( in_arr ay( $sVal1 , $aVal2 )  )   786                         if( in_arr ay( $sVal1 , $aVal2 )  )
787                             $iAddP art = 1;   787                             $iAddP art = 1;
788                    brea k;   788                    brea k;
789                       789                    
790                    case  'select_s et select_ set':   790                    case  'select_s et select_ set':
791                         $aVal1 = e xplode( ', ', $sVal1  );   791                         $aVal1 = e xplode( ', ', $sVal1  );
792                         $aVal2 = e xplode( ', ', $sVal2  );   792                         $aVal2 = e xplode( ', ', $sVal2  );
793                           793                        
794                         $iFound =  0;   794                         $iFound =  0;
795                         foreach( $ aVal1 as $ sTempVal1  ) {   795                         foreach( $ aVal1 as $ sTempVal1  ) {
796                             if( in _array( $s TempVal1,  $aVal2 ) )   796                             if( in _array( $s TempVal1,  $aVal2 ) )
797                                 $i Found ++;   797                                 $i Found ++;
798                         }   798                         }
799                           799                        
800                         $iAddPart  = $iFound  / count( $ aVal1 );   800                         $iAddPart  = $iFound  / count( $ aVal1 );
801                    brea k;   801                    brea k;
802                       802                    
803                    case  'range nu m':   803                    case  'range nu m':
804                         $aVal1 = e xplode( ', ', $sVal1  );   804                         $aVal1 = e xplode( ', ', $sVal1  );
805                         $sVal2 = ( int)$sVal2 ;   805                         $sVal2 = ( int)$sVal2 ;
806                           806                        
807                         if( (int)$ aVal1[0] < = $sVal2 a nd $sVal2  <= (int)$a Val1[0] )   807                         if( (int)$ aVal1[0] < = $sVal2 a nd $sVal2  <= (int)$a Val1[0] )
808                             $iAddP art = 1;   808                             $iAddP art = 1;
809                    brea k;   809                    brea k;
810                       810                    
811                    case  'range da te':   811                    case  'range da te':
812                         $aVal1 = e xplode( ', ', $sVal1  );   812                         $aVal1 = e xplode( ', ', $sVal1  );
813                           813                        
814                         $aDate = e xplode( '- ', $sVal2  );   814                         $aDate = e xplode( '- ', $sVal2  );
815                         $sVal2 = s printf( '% d/%d/%d',  $aDate[2],  $aDate[1] , $aDate[0 ] );   815                         $sVal2 = s printf( '% d/%d/%d',  $aDate[2],  $aDate[1] , $aDate[0 ] );
816                         $sAge = $t his -> get Age( $sVal 2 );   816                         $sAge = $t his -> get Age( $sVal 2 );
817                           817                        
818                         if( (int)$ aVal1[0] < = $sVal2 a nd $sVal2  <= (int)$a Val1[0] )   818                         if( (int)$ aVal1[0] < = $sVal2 a nd $sVal2  <= (int)$a Val1[0] )
819                             $iAddP art = 1;   819                             $iAddP art = 1;
820                    brea k;   820                    brea k;
821                       821                    
822                    defa ult:   822                    defa ult:
823                         if( $sVal1  == $sVal2  )   823                         if( $sVal1  == $sVal2  )
824                             $iAddP art = 1;   824                             $iAddP art = 1;
825                }   825                }
826                   826                
827                $iMyPerc ent    +=  round( $aF ield1['Mat chPercent' ] * $iAddP art );   827                $iMyPerc ent    +=  round( $aF ield1['Mat chPercent' ] * $iAddP art );
828           }   828           }
829              829           
830           if ( $iTotalP ercent !=  100 && $iT otalPercen t != 0 )   830           if ( $iTotalP ercent !=  100 && $iT otalPercen t != 0 )
831                $iMyPerc ent = (int )( ( $iMyP ercent / $ iTotalPerc ent ) * 10 0 );   831                $iMyPerc ent = (int )( ( $iMyP ercent / $ iTotalPerc ent ) * 10 0 );
832              832           
833           re turn $iMyP ercent;   833           re turn $iMyP ercent;
834       }   834       }
835   }   835   }