201. File Comparison Report

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

201.1 Files compared

# Location File Last Modified
1 Mon May 12 13:05:09 2008 UTC
2 Dolphin-v.6.1.0\inc\classes BxDolProfileFields.php Sat Apr 26 08:19:14 2008 UTC

201.2 Comparison summary

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

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

201.4 Active regular expressions

No regular expressions were active.

201.5 Comparison detail

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