204. File Comparison Report

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

204.1 Files compared

# Location File Last Modified
1 Mon May 12 13:05:10 2008 UTC
2 Dolphin-v.6.1.0\inc\classes BxDolSharedMedia.php Mon Apr 28 05:52:16 2008 UTC

204.2 Comparison summary

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

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

204.4 Active regular expressions

No regular expressions were active.

204.5 Comparison detail

    1   <?
    2   require_on ce(BX_DIRE CTORY_PATH _INC . 'he ader.inc.p hp' );
    3   require_on ce(BX_DIRE CTORY_PATH _INC . 'db .inc.php') ;
    4   require_on ce(BX_DIRE CTORY_PATH _INC . 'de sign.inc.p hp');
    5   require_on ce(BX_DIRE CTORY_PATH _INC . 'ut ils.inc.ph p');
    6   require_on ce(BX_DIRE CTORY_PATH _ROOT . "t emplates/t mpl_{$tmpl }/scripts/ BxTemplVot ingView.ph p" );
    7   require_on ce(BX_DIRE CTORY_PATH _ROOT . "t emplates/t mpl_{$tmpl }/scripts/ BxTemplCmt sView.php"  );
    8  
    9   class BxDo lSharedMed ia {
    10       
    11       // can  be music,  photo, vi deo
    12       var $s Type;
    13  
    14       // nam e of css f ile
    15       var $s CssName;
    16       
    17       // vie wer ID
    18       var $i Viewer;
    19       // vie wer passwo rd
    20       var $s ViewerPass ;
    21       
    22       // con fig dir ar ray - copy  of global  $dir arra y
    23       var $a ConfigDir;
    24       
    25       // con fig site a rray - cop y of globa l $dir arr ay
    26       var $a ConfigSite ;
    27       
    28       // pat h to media  files
    29       var $s FilesPath;
    30       
    31       // URL  to media  files
    32       var $s FilesUrl;
    33       
    34       // per malink par ametername
    35       var $s PrLinkPar;
    36       
    37       // nam e of secti on's main  table
    38       var $s MainTable;
    39       
    40       // nam e of main  table's fi elds
    41       var $a TableField s;
    42       
    43       // nam e of comme nts table
    44       var $s CommentsTa ble;
    45       
    46       // nam e of favor ite table
    47       var $s FavoriteTa ble;
    48       
    49       // act ions array
    50       var $a MainAction s = array(
    51           'F ave'  => a rray('icon '=>'action _fave.gif' ,  'link'= >'javascri pt:void(0) ;', 'onCli ck'=>'acti on=favorit e__fileID_ _'),
    52           'S hare' => a rray('icon '=>'action _share.gif ', 'link'= >'javascri pt:void(0) ;', 'onCli ck'=>'acti on=share__ fileID____ fileUrl__' ),
    53           'R eport'=> a rray('icon '=>'action _report.gi f','link'= >'javascri pt:void(0) ;', 'onCli ck'=>'acti on=report_ _fileID___ _fileUrl__ ')
    54       );
    55       
    56       //addo n actions  array
    57       var $a AddActions ;
    58       
    59       // mem bership ac tion for v iew file
    60       var $s ViewAction Name;
    61       
    62       /*
    63           co nstructor
    64           *  @param str ing $sMedi aType - ty pe of appl ication
    65           *  @param aSi te $iFile    - ID of  a file
    66           *  @param int  $iFile -  ID of a fi le
    67           *  @param int  $iFile -  ID of a fi le  
    68           *  @return ar ray
    69       */
    70       
    71       functi on BxDolSh aredMedia( $sMediaTyp e, &$aSite , &$aDir,  &$aMember)  {
    72           $s MediaType  = process_ db_input($ sMediaType );
    73           $s Name = ucf irst($sMed iaType);
    74           
    75           $t his->aConf igSite = $ aSite;
    76           $t his->aConf igDir  = $ aDir;
    77  
    78           $t his->sType        = $ sMediaType ;
    79           $t his->sCssN ame    = ' view'.$sNa me.'.css';
    80           $t his->iView er     = ( int)$aMemb er['ID'];
    81           $t his->sView erPass = $ aMember['P assword'];
    82           
    83           $t his->sComm entsTable  = 'CmtsSha red'.$sNam e;
    84           $t his->sFavo riteTable  = 'share'. $sName.'Fa vorites';
    85           
    86           sw itch($sMed iaType) {
    87                case 'ph oto':
    88                    $thi s->sPrLink Par = 'per malinks_ga llery_phot os';
    89                    $thi s->sFilesP ath = $thi s->aConfig Dir['shari ngImages'] ;
    90                    $thi s->sFilesU rl  = $thi s->aConfig Site['shar ingImages' ];
    91                    $thi s->sMainTa ble = 'sha rePhotoFil es';
    92                    
    93                    $thi s->sViewAc tionName =  ACTION_ID _VIEW_GALL ERY_PHOTO;
    94                    
    95                    $thi s->aTableF ields = ar ray(
    96                         'medID'     => 'medID ',
    97                         'medProfId '=> 'medPr ofId',
    98                         'medExt'    => 'medEx t',
    99                         'medTitle'  => 'medTi tle',
    100                         'medUri'    => 'medUr i',
    101                         'medDesc'   => 'medDe sc',
    102                         'medTags'   => 'medTa gs',
    103                         'medDate'   => 'medDa te',
    104                         'medViews'  => 'medVi ews',
    105                         'Approved'  => 'Appro ved'
    106                    );
    107                    
    108                    $thi s->aAddAct ions = arr ay(
    109                         'Original_ Size'=>arr ay( 'icon' =>'action_ download.g if','link' =>$this->s FilesUrl.' __file__', 'onClick'= >'', 'add'  => 'targe t="_blank" ')
    110                    );
    111                    
    112                    brea k;
    113                    
    114                case 'mu sic':
    115                    $thi s->sPrLink Par = 'per malinks_ga llery_musi c';
    116                    $sAd dPath          = 'ray /modules/m usic/files /';
    117                    $thi s->sFilesP ath = BX_D IRECTORY_P ATH_ROOT .  $sAddPath ;
    118                    $thi s->sFilesU rl  = $thi s->aConfig Site['url' ] . $sAddP ath;
    119                    $thi s->sMainTa ble = 'Ray MusicFiles ';
    120                    
    121                    $thi s->sViewAc tionName =  ACTION_ID _VIEW_GALL ERY_MUSIC;
    122                        
    123                    $thi s->aTableF ields = ar ray(
    124                         'medID'     => 'ID',
    125                         'medProfId '=> 'Owner ',
    126                         'medTitle'  => 'Title ',
    127                         'medUri'    => 'Uri',
    128                         'medDesc'   => 'Descr iption',
    129                         'medTags'   => 'Tags' ,
    130                         'medDate'   => 'Date' ,
    131                         'medViews'  => 'Liste ns',
    132                         'Approved'  => 'Appro ved'
    133                    );
    134                    
    135                    brea k;  
    136                
    137                case 'vi deo':
    138                    $thi s->sPrLink Par = 'per malinks_ga llery_vide os';
    139                    $sAd dPath          = 'ray /modules/m ovie/files /';
    140                    $thi s->sFilesP ath = BX_D IRECTORY_P ATH_ROOT .  $sAddPath ;
    141                    $thi s->sFilesU rl  = $thi s->aConfig Site['url' ] . $sAddP ath;
    142                    $thi s->sMainTa ble = 'Ray MovieFiles ';
    143  
    144                    $thi s->sViewAc tionName =  ACTION_ID _VIEW_GALL ERY_VIDEO;
    145                    
    146                    $thi s->aTableF ields = ar ray(
    147                         'medID'     => 'ID',
    148                         'medProfId '=> 'Owner ',
    149                         'medTitle'  => 'Title ',
    150                         'medUri'    => 'Uri',
    151                         'medDesc'   => 'Descr iption',
    152                         'medTags'   => 'Tags' ,
    153                         'medDate'   => 'Date' ,
    154                         'medViews'  => 'Views ',
    155                         'Approved'  => 'Appro ved'
    156                    );
    157                    
    158                    brea k;  
    159           }
    160       }
    161       
    162       /*
    163           Ge t info abo ut file fr om corresp onding med ia table
    164           *  @param int  $iFile -  ID of a fi le
    165           *  @return ar ray $aFile
    166       */
    167       
    168       functi on getFile Info($iFil e) {
    169           $i File = (in t)$iFile;
    170           
    171           $s qlQuery =  "SELECT ";
    172           fo reach ($th is->aTable Fields as  $sKey=>$sV al) {
    173                $sqlQuer y .= "`{$t his->sMain Table}`.`$ sVal` as ` $sKey`, ";
    174           }
    175           
    176           $s qlQuery .=  " 
    177                    COUN T(`share1` .`{$this-> aTableFiel ds['medID' ]}`) as `m edCount`, 
    178                    `Pro files`.`Ni ckName`
    179                FROM `{$ this->sMai nTable}`
    180                LEFT JOI N `{$this- >sMainTabl e}` as `sh are1` USIN G (`{$this ->aTableFi elds['medP rofId']}`)
    181                INNER JO IN `Profil es` ON `Pr ofiles`.`I D`=`{$this ->sMainTab le}`.`{$th is->aTable Fields['me dProfId']} `
    182                WHERE `{ $this->sMa inTable}`. `{$this->a TableField s['medID'] }` = $iFil e
    183                GROUP BY  `share1`. `{$this->a TableField s['medProf Id']}`
    184                ";
    185           
    186           $a File = db_ arr($sqlQu ery); 
    187           
    188           re turn $aFil e;
    189       }
    190       
    191       /*
    192           Sh ow media f ile
    193           *  @param int  $iFile -  ID of a fi le
    194           *  @return st ring $sCod e - html o utput
    195       */
    196       
    197       functi on showFil e($iFile)  {
    198           $i File = (in t)$iFile;
    199           $s Code = '';
    200           
    201           sw itch ($thi s->sType)  {
    202                case 'ph oto':
    203                    $aFi le  = $thi s->getFile Info($iFil e);
    204                    $sIm age = $thi s->sFilesU rl.$iFile. '_m.'.$aFi le[$this-> aTableFiel ds['medExt ']];
    205                    $sCo de  = '<di v id="view File" styl e="backgro und-image:  url(\''.$ sImage.'\' )">&nbsp;< /div>';
    206                    brea k;
    207                case 'mu sic':
    208                    $sCo de  = '<di v class="v iewFile" s tyle="text -align:cen ter;">'.ge tApplicati onContent( 'music','p layer',arr ay('id'=>$ iFile,'pas sword'=>$t his->sView erPass,'vI d'=>$this- >iViewer,' song'=>'tr ue'),true) .'</div>';
    209                    brea k;
    210                case 'vi deo':
    211                    $sCo de  = '<di v class="v iewFile" s tyle="text -align:cen ter;">'.ge tApplicati onContent( 'movie','p layer',arr ay('id' =>  $iFile, ' file' => ' true'),tru e).'</div> ';
    212                    brea k;
    213           }
    214           
    215           re turn $sCod e;
    216       }
    217       
    218       /*
    219           Sh ow file in fo block
    220           *  @param arr ay aFile -  file info  array
    221           *  @return st ring $sCod e - html o utput
    222       */
    223       
    224       functi on showFil eInfo($aFi le) {
    225           $s Title = st rlen($aFil e['medTitl e']) > 0 ?  $aFile['m edTitle']  : _t("_Unt itled");
    226           $i Time  = de fineTimeIn terval($aF ile['medDa te']);
    227           
    228           $s NumberAlt  = _t("_Vie ws");
    229           
    230           sw itch ($thi s->sType)  {
    231                case 'ph oto':
    232                    $sVi ew = _t("_ Photos");
    233                    $sEm bedCode =  $this->sFi lesUrl.$aF ile['medID '].'.'.$aF ile['medEx t'];
    234                    brea k;
    235                case 'mu sic':
    236                    $sVi ew = _t("_ Music file s");
    237                    $sNu mberAlt =  _t("_Playb acks");
    238                    $sEm bedCode =  getEmbedCo de('music' , 'player' , array('i d'=>$aFile ['medID'], 'song'=>'t rue'));
    239                    brea k;
    240                case 'vi deo':
    241                    $sVi ew = _t("_ Videos");
    242                    $sEm bedCode =  getEmbedCo de('movie' , 'player' , array('f ile'=>$aFi le['medID' ]));
    243                    brea k;
    244           }
    245           
    246           
    247           if  ($aFile[' medCount']  - 1 > 0)
    248                $sLinkMo re = '<a h ref="'.$th is->getMor eFilesUrl( $aFile['me dProfId'],  $aFile['N ickName']) .'">'.$aFi le['medCou nt'].'</a> ';
    249           el se
    250                $sLinkMo re = $aFil e['medCoun t'];
    251           ob _start();
    252           ?>
    253           <d iv id="vid eoInfo">
    254                <div id= "fileTop">
    255                    <div  class="fi leTitle">< ?=$sTitle? ></div>
    256                    <div  class="us erPic">
    257                         <?=get_mem ber_icon($ aFile['med ProfId'],' left')?>
    258                    </di v>
    259                    <div  class="fi leUserInfo ">
    260                         <a href="< ?=getProfi leLink($aF ile['medPr ofId'])?>" ><?=$aFile ['NickName ']?></a>
    261                    </di v>
    262                    <div >
    263                         <?=$sView? >: <b><?=$ sLinkMore? ></b>
    264                    </di v>
    265                </div>
    266                <div cla ss="clear_ both"></di v>
    267                <div id= "serviceIn fo">
    268                    <div >
    269                         <?=_t("_Ad ded")?>: < b><?=defin eTimeInter val($aFile ['medDate' ])?></b>
    270                    </di v>
    271                    <div >
    272                         <?=$sNumbe rAlt?>: <? =$aFile['m edViews']? >
    273                    </di v>
    274                    <div >
    275                         <?=_t("_UR L")?>: 
    276                         <input typ e="text" o nClick="th is.focus() ; this.sel ect();" re adonly="tr ue" value= "<?=$this- >getFileUr l($aFile[' medID'], $ aFile['med Uri'])?>"/ >
    277                    </di v>
    278                    <div >
    279                         <?=_t("_Em bed")?>: 
    280                         <input typ e="text" o nClick="th is.focus() ; this.sel ect();" re adonly="tr ue" value= "<?=htmlsp ecialchars ($sEmbedCo de)?>"/>
    281                    </di v>
    282                    <div >
    283                         <?=_t("_Ta gs")?>: 
    284                         <?=$this-> getTagLink s($aFile[' medTags']) ?>
    285                    </di v>
    286                    <div >
    287                         <?=_t("_De scriptionM edia")?>: 
    288                         <?=$aFile[ 'medDesc'] ?>
    289                    </di v>
    290                </div>
    291           </ div>
    292           <?
    293           $s Code = ob_ get_clean( );
    294           
    295           re turn $sCod e;
    296       }
    297       
    298       /*
    299           Pe rmalink ch eckin
    300           *  @return tr ue of fals e
    301       */
    302       
    303       functi on isPerma linkEnable d() {
    304           re turn isset ($this->_i sPermalink Enabled) ?  $this->_i sPermalink Enabled :  ($this->_i sPermalink Enabled =  (getParam( $this->sPr LinkPar) = = 'on'));
    305       }
    306       
    307       /*
    308           Ge t media fi le URL
    309           *  @param int  $iFileId  - ID of fi le
    310           *  @param str ing $sFile Uri - Uri  of file
    311           *  @return st ring $sLin k - full U RL of file  page
    312       */
    313       
    314       functi on getFile Url($iFile Id, $sFile Uri) {
    315           if  ($this->i sPermalink Enabled())
    316                $sLink =  $this->sT ype.'/gall ery/'.$sFi leUri;
    317           el se
    318                $sLink =  'view'.uc first($thi s->sType). '.php?file ID='.$iFil eId;
    319  
    320           re turn $GLOB ALS['site' ]['url'].$ sLink;
    321       }
    322       
    323        /*
    324           Ge t more fil e from thi s user URL
    325           *  @param int  $iUserId  - user ID
    326           *  @param str ing $sNick Name - fie l NickName
    327           *  @return st ring $sLin kMoreUrl -  full URL  of file pa ge
    328       */
    329  
    330       functi on getMore FilesUrl($ iUserId, $ sNickName)  {
    331           if  ($this->i sPermalink Enabled())
    332                $sLinkMo reUrl = $t his->sType .'/gallery /all/'.$sN ickName;
    333           el se
    334                $sLinkMo reUrl = 'b rowse'.ucf irst($this ->sType).' .php?userI D='.$iUser Id;
    335       
    336           re turn $sLin kMoreUrl;
    337       }
    338       
    339       /*
    340           Ge t tags URL
    341           *  @param str ing $sTagL ist - all  tags of fi le
    342           *  @param str ing $sNick Name - fie l NickName
    343           *  @return st ring $sLin kMoreUrl -  full URL  of file pa ge
    344       */
    345       
    346       functi on getTagL inks($sTag List) {
    347           if  (strlen($ sTagList))  {
    348                $aTags =  explode('  ', $sTagL ist);
    349                foreach  ($aTags as  $iKey =>  $sVal) {
    350                    $sVa l   = trim ($sVal,',' );
    351                    $sLi nk = $this ->isPermal inkEnabled () ? $this ->sType.'/ gallery_ta g/'.$sVal  : 'browse' .ucfirst($ this->sTyp e).'.php?t ag='.$sVal ;
    352                    $sCo de .= '<a  href="'.$G LOBALS['si te']['url' ].$sLink.' ">'.$sVal. '</a> ';
    353                }
    354           }
    355           
    356           re turn $sCod e;
    357       }
    358       
    359       /* 
    360           Sh ow rate se ction
    361           *  @param int  $iFile -  file ID
    362           *  return $sC ode - html  output
    363           
    364       */
    365       
    366       functi on showRat eSection($ iFile) {
    367           $s Code = '<c enter>' .  _t('_Galle ry video r ating is n ot enabled ') . '</ce nter>';
    368       
    369           $o VotingView  = new BxT emplVoting View ('g'. $this->sTy pe, (int)$ iFile);
    370           if ( $oVoting View->isEn abled())
    371                $sCode =  $oVotingV iew->getBi gVoting () ;
    372  
    373           re turn $sCod e;
    374       }
    375       
    376       /*
    377           Sh ow another  latest fi les from u ser
    378           *  @param arr ay $aFile  - current  file info
    379           *  return $sC ode - html  output
    380       */
    381  
    382       functi on showLat estFiles($ aFile) {
    383           $i Limit  = 2 ;
    384           $s Code   = ' ';
    385           $s qlBody = ' ';
    386  
    387           $s NumberAlt  = _t("_Vie ws");
    388           
    389           $s HeadTempl  = '<div cl ass="lastF ilesPic">
    390                                 <a  href="__l ink__">__i mage__</a>
    391                            </div>' ;
    392           
    393           
    394           sw itch ($thi s->sType)  {
    395                case 'ph oto':
    396                    $sMo reFilesAlt  = _t("_Se e all phot os of this  user");
    397                    $sHe adTempl =  '<a href=" __link__"> __image__< /a>';
    398                    $sIm age = '<im g class="l astFilesPi c"
    399                     sty le="backgr ound-image : url(\''. $this->sFi lesUrl.'__ image__\') ;" src="'. getTemplat eIcon( 'sp acer.gif'  ) . '" />' ;
    400                    brea k;
    401                case 'mu sic':
    402                    $sMo reFilesAlt  = _t("_Se e all musi c of this  user");
    403                    $sNu mberAlt     = _t("_Pl aybacks");
    404                    $sIm age = '<im g src="'.$ this->aCon figSite['i mages'].'m usic.png"> ';
    405                    brea k;
    406                case 'vi deo':
    407                    $sMo reFilesAlt  = _t("_Se e all vide os of this  user");
    408                    $sIm age = '<im g src="'.$ this->sFil esUrl.'__i mage___sma ll.jpg">';
    409                    brea k;
    410           }
    411           
    412           if  ($aFile[' medCount']  - 1 > $iL imit)
    413                $sLinkMo re = '<a h ref="'.$th is->getMor eFilesUrl( $aFile['me dProfId'],  $aFile['N ickName']) .'">'.$sMo reFilesAlt .'</a>';
    414           
    415           fo reach ($th is->aTable Fields as  $sKey => $ sVal) {
    416                $sqlBody  .= "`{$th is->sMainT able}`.`$s Val` as `$ sKey`,";
    417           }
    418           $s qlQuery =  "SELECT ". rtrim($sql Body, ',') ." FROM `{ $this->sMa inTable}`
    419                WHERE `{ $this->aTa bleFields[ 'medID']}` <>{$aFile[ 'medID']} 
    420                  AND `{ $this->aTa bleFields[ 'medProfId ']}`={$aFi le['medPro fId']}
    421                  AND `{ $this->aTa bleFields[ 'Approved' ]}`='true'
    422                ORDER BY  `{$this-> aTableFiel ds['medDat e']}` DESC
    423                LIMIT $i Limit
    424                ";
    425           
    426           $r Last = db_ res($sqlQu ery);
    427           
    428           wh ile ($aLas t = mysql_ fetch_asso c($rLast))  {
    429                $sImageP att  = iss et($aLast[ 'medExt'])  ? $aLast[ 'medID'].' _t.'.$aLas t['medExt' ] : $aLast ['medID']  ;
    430                $sImageB lock = str _replace(' __image__' , $sImageP att, $sIma ge);
    431                $sFileUr l = $this- >getFileUr l($aLast[' medID'], $ aLast['med Uri']);
    432                
    433                $sHead =  str_repla ce('__link __', $sFil eUrl, $sHe adTempl);
    434                $sHead =  str_repla ce('__imag e__', $sIm ageBlock,  $sHead);
    435                
    436                $sTitle  = strlen($ aLast['med Title']) >  0 ? $aLas t['medTitl e'] : _t(" _Untitled" );
    437                $oVoting View = new  BxTemplVo tingView ( 'g'.$this- >sType, $a Last['medI D']);
    438                
    439                if( $oVo tingView-> isEnabled( ) ) {
    440                    $sRa te = $oVot ingView->g etSmallVot ing(0);
    441                    $sSh owRate = ' <div class ="galleryR ate">'. $s Rate . '</ div>';
    442                }
    443                ob_start ();
    444                ?>
    445                <div cla ss="lastFi leUnit">
    446                    <?=$ sHead?>
    447                    <div >
    448                         <a href="< ?=$sFileUr l?>"><b><? =$sTitle?> </b></a>
    449                    </di v>
    450                    <div ><?=_t("_A dded")?>:  <b><?=defi neTimeInte rval($aLas t['medDate '])?></b>< /div>
    451                    <div ><?=$sNumb erAlt?>: < ?=$aLast[' medViews'] ?></div>
    452                    <?=$ sShowRate? >
    453                </div>
    454                <div cla ss="clear_ both"></di v>
    455                <?
    456                $sCode . = ob_get_c lean();
    457           }
    458           $s Code .= '< div class= "lastFiles Link">'.$s LinkMore.' </div>';
    459           
    460           re turn $sCod e;
    461       }
    462       
    463       /*
    464           Sh ow fiel ac tion list
    465           *  @param arr ay $aFile  - current  file info
    466           *  return $sC ode - html  output
    467       */
    468       
    469       functi on showAct ionList($a File) {
    470           if  ($this->i Viewer) {
    471                switch ( $this->sTy pe) {
    472                    case  'photo':
    473                         $this->aAd dActions[' Original_S ize']['lin k'] = str_ replace('_ _file__',  $aFile['me dID'].'.'. $aFile['me dExt'], $t his->aAddA ctions['Or iginal_Siz e']['link' ]);
    474                         if ($aFile ['medProfI d'] == $th is->iViewe r) {
    475                             $aOthe rActions =  array(
    476                                 'E dit'=>arra y('icon'=> 'edit.gif' , 'link'=> 'javascrip t:void(0); ', 'onClic k'=>'actio n=edit__fi leID__')
    477                             );
    478                         }
    479                         break;
    480                }
    481       
    482                $aAction s = is_arr ay($this-> aAddAction s) ? array _merge($th is->aMainA ctions, $t his->aAddA ctions) :  $this->aMa inActions;
    483                $aAction s = is_arr ay($aOther Actions)      ? array _merge($aA ctions, $a OtherActio ns) : $aAc tions;
    484                
    485                $sOnClic kTempl = " javascript : window.o pen( '{$th is->aConfi gSite['url ']}{$this- >sType}Act ions.php?{ action}',  'photo', ' width=500,  height=38 0, menubar =no,status =no,resiza ble=yes,sc rollbars=y es,toolbar =no,locati on=no' );" ;
    486                $sCode =  '<div id= "actionLis t">';
    487                foreach  ($aActions  as $sKey  => $aVal)  {
    488                    $sTa rget  = is set($aVal[ 'add']) ?  $aVal['add '] : '';
    489                    $sOn Click = st rlen($aVal ['onClick' ]) > 0 ? ' onclick="'  . str_rep lace('{act ion}', $aV al['onClic k'], $sOnC lickTempl)  . '"' : ' ' ;
    490                    
    491                    $sOn Click = st r_replace( '__fileID_ _',  '&amp ;fileID='. $aFile['me dID'], $sO nClick);
    492                    $sOn Click = st r_replace( '__fileUrl __', '&amp ;fileUrl=' .urlencode ($this->ge tFileUrl($ aFile['med ID'], $aFi le['medUri '])), $sOn Click);
    493                    
    494                    $sCo de .= '<di v><img src ="'.$this- >aConfigSi te['icons' ].$aVal['i con'].'" a lt="'._t(' _'.$sKey). '" /><a hr ef="'.$aVa l['link']. '" '.$sTar get.' '.$s OnClick.'> '._t('_'.$ sKey).'</a ></div>';
    495                }
    496                $sCode . = '</div>< div class= "clear_bot h"></div>' ;
    497                
    498                return $ sCode;
    499           }    
    500       }
    501       
    502       /*
    503           Ge t several  files info
    504           *  @param arr ay aCond -  array of  MySQL part s
    505           *  @param arr ay aManage  (if exist s) - array  of exact  fields
    506           *  @return re source rDa ta
    507       */
    508       
    509       functi on getFile sList($aCo nd = array (), $aMana ge = array ()) {
    510           if  (empty($a Manage))
    511                $aList =  array('me dID', 'med ProfId', ' medTitle',  'medUri',  'medDate' , 'medView s', 'medEx t');
    512           el se
    513                $aList =  $aManage;
    514  
    515           $s qlTempl =  "SELECT __ main__ __r ate_fields __ __from_ _ __main_j oin__ __ra te_join__  __where__  __order__  __limit__" ;
    516           
    517           $a Sql = arra y(
    518                    '__m ain__'=>''
    519                    '__r ate_fields __'=>'',
    520                    '__f rom__'=>'' ,
    521                    '__m ain_join__ '=>'',
    522                    '__r ate_join__ '=>'',
    523                    '__w here__'=>' ',
    524                    '__o rder__'=>' ',
    525                    '__l imit__'=>' '
    526                );
    527  
    528           
    529           fo reach ($aL ist as $sV al) {
    530                $aSql['_ _main__']  .= key_exi sts($sVal,  $this->aT ableFields ) ? "`{$th is->sMainT able}`.`{$ this->aTab leFields[$ sVal]}` as  `$sVal`,  " : "";
    531           }
    532           $a Sql['__mai n__'] .= ' `Profiles` .`NickName `';
    533           
    534           if  (isset($a Cond['rate Fields'])  && isset($ aCond['rat eJoin']))  {
    535                $aSql['_ _rate_fiel ds__'] = $ aCond['rat eFields'];
    536                $aSql['_ _rate_join __']   = $ aCond['rat eJoin'];
    537           }
    538           $a Sql['__fro m__']       = "FROM ` {$this->sM ainTable}` ";
    539           $a Sql['__mai n_join__']  = "LEFT J OIN `Profi les` ON `P rofiles`.` ID` = `{$t his->sMain Table}`.{$ this->aTab leFields[' medProfId' ]}";
    540           if  (isset($a Cond['sqlW here'])) 
    541                $aSql['_ _where__']  = $aCond[ 'sqlWhere' ];
    542           if  (isset($a Cond['sqlO rder']))
    543                $aSql['_ _order__']  = $aCond[ 'sqlOrder' ];
    544           if  ($aCond[' sqlLimit'] )
    545                $aSql['_ _limit__']  = $aCond[ 'sqlLimit' ];
    546                
    547           $a Keys    =  array_keys ($aSql);
    548           $s qlQuery =  str_replac e($aKeys,  $aSql, $sq lTempl);
    549   //      ec ho "<br/>$ sqlQuery";
    550           $r Data = db_ res($sqlQu ery);
    551  
    552           re turn $rDat a;
    553       }
    554       
    555       /*
    556           Sh ow 1 file  in browse
    557           *  @param arr ay $aData  - info arr ay about
    558           *  @param boo lean $bAdm in - admin  mode
    559           *  @return @s Code - htm l output
    560       */
    561       
    562       functi on showBro wseUnit($a Data, $bAd min = fals e) {
    563           $s Href  = $t his->getFi leUrl($aDa ta['medID' ], $aData[ 'medUri']) ;
    564           $s Title = st rlen($aDat a['medTitl e']) > 0 ?  $aData['m edTitle']  : _t("_Unt itled");
    565           $s Views = _t ('_Views') ;
    566  
    567           $s ActionLink s = $this- >iViewer = = $aData[' medProfId' ] ? '<div> <a href="' .$_SERVER[ 'PHP_SELF' ].'?action =del&fileI D='.$aData ['medID']. '"
    568                onClick= "return co nfirm( \'' ._t("_are  you sure?" ).'\');">' ._t("_Dele te").'</a> </div>' :  '' ;
    569           
    570           if  (!$bAdmin ) {
    571                $oVoting View = new  BxTemplVo tingView ( 'g'.$this- >sType, $a Data['medI D']);
    572                if( $oVo tingView-> isEnabled( )) {
    573                    $sRa te = $oVot ingView->g etSmallVot ing (0);
    574                    $sSh owRate = ' <div class ="galleryR ate">'. $s Rate . '</ div>';
    575                }
    576                $sProfLi nk = '<div  class="ad dInfo">'._ t("_By").' : <a href= "'.getProf ileLink($a Data['medP rofId']).' ">'.$aData ['NickName '].'</a></ div>';
    577                $sCheck     = '';
    578           }
    579           el se {
    580                $sShowRa te = '';
    581                $sStyle     = isset ($aData['A pproved'])  && $aData ['Approved '] == 'tru e' ? ' sty le="border : 2px soli d #00CC00; "' : ' sty le="border : 2px soli d #CC0000; "';
    582                $sProfLi nk = '<div >'._t("_By ").': <a h ref="'.$th is->aConfi gSite['url '].'pedit. php?ID='.$ aData['med ProfId'].' ">'.$aData ['NickName '].'</a></ div>';
    583                $sCheck     = '<div  class="br owseCheckb ox"><input  type="che ckbox" nam e="Check[] " value="' .$aData['m edID'].'"  id="ch'.$a Data['medI D'].'"></d iv>';
    584           }
    585           sw itch ($thi s->sType)  {
    586                case 'ph oto':
    587                    $sIm g   = $thi s->sFilesU rl.$aData[ 'medID'].' _t.'.$aDat a['medExt' ];
    588                    $sIm age = '<di v class="l astFilesPi c" style=" background -image: ur l(\''.$sIm g.'\');">
    589                           <a href= "'.$sHref. '"><img sr c="'.$this ->aConfigS ite['image s'].'space r.gif" wid th="110" h eight="110 "></a></di v>';
    590                    if ( $this->iVi ewer == $a Data['medP rofId']) {
    591                         $sActionLi nks = '<di v><a href= "javascrip t: void(0) ;"
    592                             onClic k="window. open(\''.$ this->aCon figSite['u rl'].$this ->sType.'A ctions.php ?fileID='. $aData['me dID'].'&am p;action=e dit\', 
    593                             \'phot o\', \'wid th=500, he ight=380,  menubar=no ,status=no ,resizable =yes,scrol lbars=yes, toolbar=no ,location= no\');">'
    594                         ._t("_Edit ").'</a></ div>' . $s ActionLink s;
    595                    }   
    596                    brea k;
    597                case 'mu sic':
    598                    $sIm age = '<di v class="l astFilesPi c"><a href ="'.$sHref .'"><img s rc="'.$thi s->aConfig Site['imag es'].'musi c.png"></a ></div>';
    599                    brea k;
    600                case 'vi deo':
    601                    $sIm age = '<di v class="l astFilesPi c"><a href ="'.$sHref .'"><img s rc="'.$thi s->sFilesU rl.$aData[ 'medID'].' _small.jpg "></a></di v>';
    602                    brea k;
    603           }
    604           
    605           ob _start();
    606           ?>
    607           <d iv class=" browseUnit "<?=$sStyl e?>>
    608                <?=$sChe ck?>
    609                <?=$sIma ge?>
    610                <div cla ss="addInf o">
    611                    <a h ref="<?=$s Href?>"><b ><?=$sTitl e?></b></a >
    612                </div>
    613                <?=$sPro fLink?>
    614                <div cla ss="addInf o"><?=_t(" _Added")?> : <b><?=de fineTimeIn terval($aD ata['medDa te'])?></b ></div>
    615                <div cla ss="addInf o"><?=$sVi ews?>: <b> <?=$aData[ 'medViews' ]?></b></d iv>
    616                <?=$sSho wRate.$sAc tionLinks? >
    617           </ div>
    618           <?
    619           $s Code = ob_ get_clean( );
    620           
    621           re turn $sCod e;
    622       }
    623       
    624       /*
    625           Sh ow paginat ion for cu rrent brow se page
    626           *  @param int  $iTotalPa ges - numb er of tota l elements
    627           *  @param int  $iCurPage     - numb er of curr ent browse  page
    628           *  @param int  $iPerPage     - numb er of tota l elements
    629           *  @param boo lean $bAdm in  - admi n mode
    630           
    631           *  return $sC ode - html  output
    632       */
    633       
    634       functi on showPag ination($i TotalPages , $iCurPag e, $iPerPa ge = 10, $ bAdmin = f alse) {
    635           $s MainUrl =  '';
    636           $i TotalPages  = (int)$i TotalPages ;
    637           $i CurPage     = (int)$i CurPage;
    638           $i PerPage     = (int)$i PerPage;
    639           
    640           $b LinkMode =  $this->is PermalinkE nabled() ?  true : fa lse;
    641           $b LinkMode =  $bAdmin ?  false : $ bLinkMode;
    642           if  ($iTotalP ages > 1)  {
    643                if ($bLi nkMode) {
    644                         $sMainUrl  = $this->s Type.'/all ';
    645                        
    646                         $aFields =  array( 'o wnerName',  'tag', 'r ate' );
    647                
    648                         foreach ($ aFields as  $field) {
    649                             if( is set( $_GET [$field] )  ) {
    650                                 $s Param = ht mlentities ( process_ pass_data(  $_GET[$fi eld] ));
    651                                 sw itch ($fie ld) {
    652                                      case 'ow nerName':
    653                                          $sMa inUrl = $t his->sType .'/gallery /all/'.$sP aram;
    654                                          brea k;
    655                                      case 'ta g':
    656                                          $sMa inUrl = $t his->sType .'/gallery _tag/'.$sP aram;
    657                                          brea k;
    658                                      case 'ra te':
    659                                          $sMa inUrl = $t his->sType .'/gallery _top';
    660                                          brea k;
    661                                 }
    662                             }
    663                         }
    664                         $sMainUrl  = $GLOBALS ['site'][' url'].$sMa inUrl;
    665                         $sReloc =  "'$sMainUr l/' + this .value + ' /$iCurPage '";
    666                         $sLinkTemp l = $sMain Url ."/$iP erPage/{pa ge}";
    667                }
    668                else {
    669                    $sRe quest = $_ SERVER['PH P_SELF'] .  '?';
    670           
    671                    $aFi elds = arr ay('userID ', 'tag',  'rate');
    672                    if ( $bAdmin) {
    673                         $aFields[]  = 'type';              
    674                    }
    675                    fore ach( $aFie lds as $fi eld ) {
    676                         if (isset(  $_GET[$fi eld])) 
    677                             $sRequ est .= "&a mp;{$field }=" . html entities(  process_pa ss_data( $ _GET[$fiel d] ) );
    678                    }
    679                    $sRe loc = "'$s Request&am p;page=$iC urPage&amp ;per_page= ' + this.v alue";
    680                    $sLi nkTempl =  $sRequest  . "&amp;pa ge={page}& amp;per_pa ge=$iPerPa ge";
    681                }
    682                    
    683                $sPagina tion = '<d iv style=" text-align : center;  position:  relative;  margin: 10 px 0px;">' ._t("_Resu lts per pa ge").':
    684                         <select na me="per_pa ge" onchan ge="window .location= ' . $sRelo c . ';">
    685                             <optio n value="1 0"' . ( $i PerPage ==  10 ? ' se lected="se lected"' :  '' ) . '> 10</option >
    686                             <optio n value="2 0"' . ( $i PerPage ==  20 ? ' se lected="se lected"' :  '' ) . '> 20</option >
    687                             <optio n value="5 0"' . ( $i PerPage ==  50 ? ' se lected="se lected"' :  '' ) . '> 50</option >
    688                             <optio n value="1 00"' . ( $ iPerPage = = 100 ? '  selected=" selected"'  : '' ) .  '>100</opt ion>
    689                         </select>< /div>';
    690                    
    691                $sPagina tion .= ge nPaginatio n( $iTotal Pages, $iC urPage, $s LinkTempl  );
    692           }
    693           el se
    694                return ' ';
    695           re turn $sPag ination;
    696       }
    697       
    698       /*
    699           Ge t list of  media file s for file s
    700           *  @param int  $iUser -  user ID
    701           *  @ return s tring $sCo de - html  output
    702       */
    703       
    704       functi on getBloc kCode_Shar edMedia($i User = 0)  {
    705           $i User   = ( int)$iUser ;
    706           
    707           $a Manage = a rray('medI D','medExt ','medTitl e','medUri ');
    708           
    709           $m ax_num = ( int)getPar am("top_ph otos_max_n um");
    710           $m ode    = p rocess_db_ input( get Param("top _photos_mo de") );
    711           
    712           $m ode = $_GE T['sh_'.$t his->sType .'Mode'];
    713           if ( $mode !=  'rand' &&  $mode !=  'top' && $ mode != 'l ast')
    714                $mode =  'last';
    715           
    716           $a Cond['sqlW here'] = "  WHERE `{$ this->aTab leFields[' Approved'] }`='true'" ;
    717           
    718           if  ($iUser ! = 0)
    719                $aCond[' sqlWhere']  .= " AND  `{$this->a TableField s['medProf Id']}`='$i User'";
    720           
    721           $s qlFrom = "  FROM `{$t his->sMain Table}`";
    722           
    723           $a DBTopMenu  = array();
    724            f oreach (ar ray( 'last ', 'top',  'rand' ) a s $myMode)  {
    725              switch ( $ myMode ) {
    726               case 'las t':
    727                if( $mod e == $myMo de )
    728                 $aCond[ 'sqlOrder' ] = "
    729                    ORDE R BY `{$th is->aTable Fields['me dDate']}`  DESC";
    730                 $modeTi tle = '_La test';
    731                 break;
    732               case 'ran d':
    733                if( $mod e == $myMo de )
    734                 $aCond[ 'sqlOrder' ] = "
    735                    ORDE R BY RAND( )";
    736                 $modeTi tle = '_Ra ndom';
    737                 break;
    738               case 'top ':
    739                if( $mod e == $myMo de ) {
    740                    $oVo tingView =  new BxTem plVotingVi ew ('g'.$t his->sType , 0, 0);
    741                    $aSq l        =  $oVotingV iew->getSq lParts('`' .$this->sM ainTable.' `', '`'.$t his->aTabl eFields['m edID'].'`' );
    742                    $sHo w        =  "DESC";
    743                    $aCo nd['sqlOrd er']   = $ oVotingVie w->isEnabl ed() ? "OR DER BY `vo ting_rate`  $sHow, `v oting_coun t` $sHow,  `{$this->a TableField s['medDate ']}` $sHow " : $aCond ['sqlOrder '] ;
    744                    $aCo nd['rateFi elds'] = $ aSql['fiel ds'];
    745                    $aCo nd['rateJo in']   = $ aSql['join '];
    746                    $sql From .= $a Sql['join' ];
    747                }
    748                $modeTit le = '_Top ';
    749                break;
    750              }
    751                if( base name( $_SE RVER['PHP_ SELF'] ) = = 'rewrite _name.php'  || basena me( $_SERV ER['PHP_SE LF'] ) ==  'profile.p hp' )
    752                    $sLi nk = "prof ile.php?ID ={$iUser}& ";
    753                else
    754                    $sLi nk  = "{$_ SERVER['PH P_SELF']}? ";
    755                    $sLi nk .= "sh_ ".$this->s Type."Mode =$myMode";
    756                
    757                $aDBTopM enu[$modeT itle] = ar ray('href'  => $sLink , 'dynamic ' => true,  'active'  => ( $myMo de == $mod e ));
    758            }
    759            
    760           $a Num = db_a rr( "SELEC T COUNT(`$ this->sMai nTable`.`{ $this->aTa bleFields[ 'medID']}` ) $sqlFrom  {$aCond[' sqlWhere'] }" );
    761           $n um = (int) $aNum[0];
    762           
    763           $r et = '';
    764           if ( $num ) {
    765                $pages =  ceil( $nu m / $max_n um );
    766                $page =  (int)$_GET ['page'];
    767                
    768                if( $pag e < 1 or $ mode == 'r and' )
    769                    $pag e = 1;
    770                if( $pag e > $pages  )
    771                    $pag e = $pages ;
    772                
    773                $sqlLimi tFrom = (  $page - 1  ) * $max_n um;
    774                $aCond[' sqlLimit']  = "LIMIT  $sqlLimitF rom, $max_ num";
    775            
    776            $ rData = $t his->getFi lesList($a Cond, $aMa nage);
    777                 
    778            $ ret .= '<d iv class=" clear_both "></div>';
    779            $ iCounter =  1;
    780            $ sAddon = ' ';
    781            w hile ($aDa ta = mysql _fetch_arr ay($rData) ) {
    782                $sTitle  = strlen($ aData['med Title']) >  0 ? $aDat a['medTitl e'] : _t(" _Untitled" );    
    783                $sHref   = $this->g etFileUrl( $aData['me dID'], $aD ata['medUr i']);
    784                
    785                $oVoting View = new  BxTemplVo tingView ( 'g'.$this- >sType, $a Data['medI D']);
    786                if( $oVo tingView-> isEnabled( )) {
    787                    $sRa te = $oVot ingView->g etSmallVot ing (0);
    788                    $sSh owRate = ' <div class ="galleryR ate">'. $s Rate . '</ div>';
    789                }
    790                switch ( $this->sTy pe) {
    791                    case  'photo':
    792                         $sImage =  $this->sFi lesUrl.$aD ata['medID '].'_t.'.$ aData['med Ext'];
    793                         $sPic = '< div class= "lastFiles Pic" style ="backgrou nd-image:  url(\''.$s Image.'\') ;">
    794                           <a href= "'.$sHref. '"><img sr c="'.$this ->aConfigS ite['image s'].'space r.gif" alt ="" width= "110" heig ht="110">< /a></div>< div class= "clear_bot h"></div>' ;
    795                         break;
    796                    case  'music':
    797                         $sPic = '< div class= "lastMusic Pic"><a hr ef="'.$sHr ef.'"><img  src="'.$t his->aConf igSite['im ages'].'mu sic.png">< /a></div>' ;
    798                         break;
    799                    case  'video':
    800                         $sPic = '< div class= "lastVideo Pic"><a hr ef="'.$sHr ef.'"><img  src="'.$t his->sFile sUrl.$aDat a['medID'] .'.jpg" wi dth="112px " height=" 80px"></a> </div>';
    801                         break;
    802                }
    803                
    804                
    805                $ret .=  '<div clas s="sharePh otosConten t_1">';
    806                $ret .=  $sPic.'<di v class="s hareMediaA dd"><a hre f="'.$sHre f.'">'.$sT itle.'</a> </div>'.$s ShowRate.' </div>';
    807            }
    808            
    809            $ ret .= '<d iv class=" clear_both "></div>';
    810            
    811            $ aDBBottomM enu = arra y();
    812            
    813            i f( $pages  > 1 ) {
    814                if( $pag e > 1 ) {
    815                    $pre vPage = $p age - 1;
    816                    $aDB BottomMenu [ _t('_Bac k') ] = ar ray( 'href ' => "{$_S ERVER['PHP _SELF']}?s h_".$this- >sType."Mo de=$mode&a mp;page=$p revPage",  'dynamic'  => true, ' class' =>  'backMembe rs' );
    817                }
    818                    
    819                if( $pag e < $pages  ) {
    820                    $nex tPage = $p age + 1;
    821                    $aDB BottomMenu [ _t('_Nex t') ] = ar ray( 'href ' => "{$_S ERVER['PHP _SELF']}?s h_".$this- >sType."Mo de=$mode&a mp;page=$n extPage",  'dynamic'  => true, ' class' =>  'moreMembe rs' );
    822                }
    823                $sAllUrl  = $this-> isPermalin kEnabled()  ? $this-> aConfigSit e['url'].$ this->sTyp e.'/all/10 /1' : $thi s->aConfig Site['url' ].'browse' .ucfirst($ this->sTyp e).'.php';
    824                $aDBBott omMenu[ _t ('_View Al l') ] = ar ray( 'href ' => "$sAl lUrl", 'cl ass' => 'v iewAllMemb ers' ); 
    825           }
    826        }
    827       
    828        retur n array( $ ret, $aDBT opMenu, $a DBBottomMe nu );
    829       }
    830       
    831       //---- ---------- ---------- ---------- ---------  actions -- ---------- ---------- ---------- ---------- -//
    832       
    833       /*
    834           De lete file,  his strin g in DB an d all his  child file s
    835           *  @param int  iFile - f ile ID
    836           *  @param arr ay $logged  - array o f login
    837       */
    838       
    839       functi on deleteM edia($iFil e, $logged  = array() ) {
    840           $i File = (in t)$iFile;
    841           $s qlQuery  =  "SELECT ` {$this->aT ableFields ['medProfI d']}`";
    842           $s qlQuery .=  isset($th is->aTable Fields['me dExt']) ?  ", `{$this ->aTableFi elds['medE xt']}`" :  "";
    843           $s qlQuery .=  "FROM `{$ this->sMai nTable}` W HERE `{$th is->aTable Fields['me dID']}`=$i File";
    844           
    845           $a File = db_ arr($sqlQu ery);
    846           if  (!$aFile)
    847                return f alse;
    848  
    849           if  ($logged[ 'admin'])  {
    850           }
    851           el seif ($log ged['membe r']) {
    852                $iMember ID = (int) $_COOKIE[' memberID'] ;
    853                
    854                if ($aFi le[$this-> aTableFiel ds['medPro fId']] !=  $iMemberID )
    855                    retu rn false;
    856           }
    857           el se
    858                return f alse;
    859           
    860           sw itch ($thi s->sType)  {
    861                case 'ph oto':
    862                    $aFN ame[] = $i File . '.' .$aFile['m edExt'];
    863                    $aFN ame[] = $i File.'_t.' .$aFile['m edExt'];
    864                    $aFN ame[] = $i File.'_m.' .$aFile['m edExt'];
    865                    $sCm tsName = ' sharedPhot o';
    866                    brea k;
    867                case 'mu sic':
    868                    $aFN ame[] = $i File.'.mp3 ';
    869                    $sCm tsName = ' sharedMusi c';
    870                    brea k;
    871                case 'vi deo':
    872                    $aFN ame[] = $i File.'.flv ';
    873                    $aFN ame[] = $i File.'.mpg ';
    874                    $aFN ame[] = $i File.'.jpg ';
    875                    $aFN ame[] = $i File.'_sma ll.jpg';
    876                    $sCm tsName = ' sharedVide o';
    877                    brea k;      
    878           }
    879           fo reach($aFN ame as $sV al) {
    880                $sFilePa th = $this ->sFilesPa th.$sVal;
    881                @unlink( $sFilePath );
    882           }
    883           db _res("DELE TE FROM `{ $this->sMa inTable}`  WHERE `{$t his->aTabl eFields['m edID']}`=$ iFile");
    884       
    885           re parseObjTa gs( $this- >sType, $i File );
    886           
    887           $o Voting = n ew BxDolVo ting ('g'. $this->sTy pe, 0, 0);
    888           $o Voting->de leteVoting s($iFile);
    889  
    890           $o Cmts = new  BxDolCmts ($sCmtsNam e, $iFile) ;
    891           $o Cmts->onOb jectDelete ();
    892           
    893           he ader('Loca tion:' . $ _SERVER["H TTP_REFERE R"]);
    894       }
    895       
    896       /*
    897           Ap proved med ia by admi n
    898           *  @param int  iFile - f ile ID
    899       */
    900       
    901       functi on approve Media($iFi le) {
    902           $i File = (in t)$iFile;
    903           $s qlQuery =  "UPDATE `{ $this->sMa inTable}`  SET `{$thi s->aTableF ields['App roved']}`  = IF(`{$th is->aTable Fields['Ap proved']}` ='true','f alse','tru e') WHERE  `{$this->a TableField s['medID'] }`='$iFile '";
    904           db _res($sqlQ uery);
    905           he ader('Loca tion:' . $ _SERVER["H TTP_REFERE R"]);
    906       }
    907       
    908       /*
    909           Ge t favorite  files con diton
    910           *  @param int  $iMember  - view ID
    911           *  @return $s qlQuery -  sqlQuery a ddon
    912       */
    913       
    914       functi on getFavo riteCondit ion($iMemb er) {
    915           $i Member  =  (int)$iMem ber;
    916           $s qlQuery =  "SELECT `m edID` FROM  `{$this-> sFavoriteT able}` WHE RE `userID `=$iMember ";
    917           $r List = db_ res($sqlQu ery);
    918           wh ile ($aLis t = mysql_ fetch_row( $rList)) {
    919                $sParam  .= $aList[ 0] . ',';
    920           }
    921           $s Res = " AN D `{$this- >sMainTabl e}`.`{$thi s->aTableF ields['med ID']}` IN( ";
    922           if  (strlen($ sParam) >  0)
    923                $sRes =  $sRes.trim ($sParam,' ,').')';
    924           el se
    925                $sRes =  ' AND 0';
    926  
    927           re turn $sRes ;
    928       }
    929       
    930       /*
    931           De lete all u ser's file  in curren t media ga llery
    932           *  @param int  $iMember  - view ID
    933           *  @param arr ay $logged  - array o f logins
    934       */
    935       
    936       functi on deleteU serGallery ($iUser, $ logged) {
    937           $i User = (in t)$iUser;
    938           $s qlQuery =  "SELECT `{ $this->aTa bleFields[ 'medID']}`  from `{$t his->sMain Table}` WH ERE `{$thi s->aTableF ields['med ProfId']}` =$iUser";
    939           $r Files = db _res($sqlQ uery);
    940           wh ile ($aFil e = mysql_ fetch_asso c($rFiles) ) {
    941                $this->d eleteMedia ($aFile[$t his->aTabl eFields['m edID']], $ logged);
    942                $oCmts =  new BxDol Cmts('shar ed'.ucfirs t($this->s Type), $iF ile);
    943                $oCmts-> onObjectDe lete();
    944           }
    945       }
    946       
    947       /*
    948           Ad d file to  favorite l ist
    949           *  @param int  $iFile -  file ID
    950           *  @return $s Code - htm l output
    951       */
    952       
    953       functi on addToFa vorites($i File) {
    954           $i File =(int )$iFile;
    955           if  ($iFile)  {
    956                $sqlQuer y = "SELEC T * FROM ` {$this->sF avoriteTab le}` WHERE  `medID`=' $iFile' AN D `userID` ='{$this-> iViewer}'" ;
    957                $aCheck  = db_arr($ sqlQuery);
    958                if ($aCh eck)
    959                    $sCo de = '<div  class="me diaInfo">' ._t('_File  already i s favorite ').'</div> ';
    960                else {
    961                    $sql Query = "I NSERT INTO  `{$this-> sFavoriteT able}` (`m edID`,`use rID`,`favD ate`) VALU ES('$iFile ','{$this- >iViewer}' ,NOW())";
    962                    db_r es($sqlQue ry);
    963                    $sCo de = '<div  class="me diaInfo">' ._t("_File  was added  to favori te").'</di v>';
    964                }
    965           }
    966           
    967           re turn $sCod e;
    968       }
    969       
    970       /*
    971           Se nd file in fo
    972           *  @param int  $iFile -  file ID
    973           *  @param str ing $sEmai l - email( s)
    974           *  @param str ing $sMess age - mess age
    975           *  @param str ing $sUrl  - link to  file
    976       */
    977       
    978       functi on sendFil eInfo($iFi le, $sEmai l, $sMessa ge, $sUrl)  {  
    979           $a User = get ProfileInf o($this->i Viewer);
    980           $s Url  = url decode($sU rl);
    981           
    982           $s MailHeader         =  "From: {$t his->aConf igSite['ti tle']} <{$ this->aCon figSite['e mail_notif y']}>";
    983           $s MailParame ters    =  "-f{$this- >aConfigSi te['email_ notify']}" ;
    984           
    985           $s MailHeader  = "MIME-V ersion: 1. 0\r\n" . " Content-ty pe: text/h tml; chars et=UTF-8\r \n" . $sMa ilHeader;
    986           $s MailSubjec t = $aUser ['NickName '].' share d a Photo  with you';
    987           
    988           $s MailBody     = "Hello ,\n
    989                         {$aUser['N ickName']}  shared a  {$this->sT ype} with  you: <a hr ef=\"$sUrl \">See it< /a>\n
    990                         $sMessage\ n
    991                         Regards";
    992           
    993           $a Emails = e xplode("," , $sEmail) ;
    994           fo reach ($aE mails as $ iKey => $s Mail) {
    995                $sMail =  trim($sMa il);
    996                $iSendin gResult =  mail( $sMa il, $sMail Subject, n l2br($sMai lBody), $s MailHeader , $sMailPa rameters ) ;
    997           if  ($iSendin gResult)
    998                $sCode =  '<div cla ss="mediaI nfo">'._t( "_File inf o was sent ").'</div> ';
    999           }
    1000           
    1001           re turn $sCod e;
    1002       }
    1003       
    1004       /*
    1005           Sh ow submit  form
    1006           *  @param arr ay $aActio ns - array  of all ac tion varia ble
    1007           *  @return $s Code - htm l output
    1008       */
    1009       
    1010       functi on showSub mitForm($a Action) {
    1011           $i File = (in t)$aAction ['fileID'] ;
    1012           $s Action = h tmlspecial chars_adv( $aAction[' action']);
    1013           if  ($iFile & & strlen($ sAction) >  0) {
    1014                switch ( $sAction)  {
    1015                    case  'share' :  
    1016                         $sAddr  =  '<div>'._t ("_Enter e mail(s)"). ':</div><d iv><input  type="text " size="40 " name="em ail"></div >';
    1017                         $sSites =  '<div styl e="margin- top:10px;  margin-bot tom:10px;" >'.$this-> getSitesAr ray($aActi on['fileUr l']).'</di v>';
    1018                         break;
    1019                    case  'report':  
    1020                         $sAddr  =  '<input ty pe="hidden " name="em ail" value ="'.$this- >aConfigSi te['email_ notify'].' ">';
    1021                         $sSites =  '';
    1022                         break;
    1023                }
    1024                
    1025                ob_start ();
    1026                ?>
    1027                <div cla ss="mediaI nfo">
    1028                    <for m name="su bmitAction " method=" post" acti on="<?=$_S ERVER['PHP _SELF']?>" >
    1029                         <input typ e="hidden"  name="fil eID" value ="<?=$iFil e?>">
    1030                         <input typ e="hidden"  name="fil eUrl" valu e="<?=$aAc tion['file Url']?>">
    1031                         <?=$sAddr. $sSites?>
    1032                         <div><?=_t ("_Message  text")?>< /div>
    1033                         <div><text area cols= "30" rows= "10" name= "messageTe xt"></text area></div >
    1034                         <div><inpu t type="su bmit" size ="15" name ="send" va lue="Send" >
    1035                         <input typ e="reset"  size="15"  name="send " value="R eset"></di v>
    1036                    </fo rm>
    1037                </div>  
    1038                <?
    1039                $sCode =  ob_get_cl ean();
    1040           }
    1041           re turn $sCod e;
    1042       }
    1043       
    1044       /*
    1045           Ge t shared s ites array
    1046           *  @param str ing $sLink  - file en code URL
    1047           *  @return st ring $sCod e - html o utput
    1048       */
    1049       
    1050       functi on getSite sArray($sL ink) {
    1051           $s Link = htm lentities( ($sLink));
    1052           $a Sites = ar ray(
    1053                array(
    1054                'image'= >'digg.png ',
    1055                'link'=> 'http://di gg.com/sub mit?phase= 2&url='.$s Link
    1056                ),
    1057                array(
    1058                'image'= >'deliciou s.png',
    1059                'link' = >'http://d el.icio.us /post?url= '.$sLink
    1060                ),
    1061                array(
    1062                'image'= >'blinklis t.png',
    1063                'link' = >'http://w ww.blinkli st.com/ind ex.php?Act ion=Blink/ addblink.p hp&amp;Url ='.$sLink
    1064                ),
    1065                array(
    1066                'image'= >'furl.png ',
    1067                'link' = >'http://w ww.furl.ne t/storeIt. jsp?u='.$s Link
    1068                ),
    1069                array(
    1070                'image'= >'netscape .gif',
    1071                'link' = >'http://w ww.netscap e.com/subm it/?U='.$s Link
    1072                ),
    1073                array(
    1074                'image'= >'newsvine .png',
    1075                'link' = >'http://w ww.newsvin e.com/_too ls/seed&sa ve?u='.$sL ink
    1076                ),
    1077                array(
    1078                'image'= >'reddit.p ng',
    1079                'link' = >'http://r eddit.com/ submit?url ='.$sLink
    1080                ),
    1081                array(
    1082                'image'= >'shadows. png',
    1083                'link' = >'http://w ww.shadows .com/featu res/tcr.ht m?url='.$s Link
    1084                ),
    1085                array(
    1086                'image'= >'slashdot .png',
    1087                'link' = >'http://s lashdot.or g/bookmark .pl?url='. $sLink
    1088                ),
    1089                array(
    1090                'image'= >'sphere.p ng',
    1091                'link' = >'http://w ww.sphere. com/search ?q=spherei t:'.$sLink
    1092                ),
    1093                array(
    1094                'image'= >'stumbleu pon.png',
    1095                'link' = >'http://w ww.stumble upon.com/u rl/http'.$ sLink
    1096                ),
    1097                array(
    1098                'image'= >'technora ti.png',
    1099                'link' = >'http://t echnorati. com/faves? add='.$sLi nk
    1100                )
    1101           );
    1102           $s Link = '<a  href="{Li nk}"><div  class="sha reLink" st yle="backg round-imag e:url(\'{I mage}\')"> </div></a> ';
    1103       
    1104           fo reach ($aS ites as $i Key =>$aVa l) {
    1105                $sLinkCu r = str_re place('{Im age}', get TemplateIc on($aVal[' image']),$ sLink);
    1106                $sLinkCu r = str_re place('{Li nk}', $aVa l['link'], $sLinkCur) ;
    1107                $sCode    .= $sLink Cur;
    1108           }
    1109           $s Code .= '< div class= "clear_bot h"></div>' ;
    1110           
    1111           re turn $sCod e;
    1112       }
    1113       
    1114       /*
    1115           Ge t array of  sql parts , total pa ges, curre nt page, p er page
    1116           *  @param arr ay $logged  - array o f logins
    1117           *  @return ar ray('query '(sql quer y),'total'  (totalpag es), 'per_ page' (in  1 page), ' cur_page'  (current p age num))
    1118       */
    1119       
    1120       functi on getCond itionArray ($logged)  {
    1121           $a Where = ar ray();
    1122           $a Where[] =  '1';
    1123           
    1124           $i User = 0;
    1125           
    1126           if  (isset($_ GET['owner Name'])) {
    1127                $sName =  process_d b_input($_ GET['owner Name']);
    1128                $iUser =  (int)db_v alue("SELE CT `ID` FR OM `Profil es` WHERE  `NickName` ='$sName'" );
    1129           }
    1130           el seif (isse t($_GET['u serID']))
    1131                $iUser =  (int)$_GE T['userID' ];
    1132           
    1133           if  ($iUser)
    1134                $aWhere[ ] = "`{$th is->sMainT able}`.`{$ this->aTab leFields[' medProfId' ]}`=$iUser ";   
    1135           
    1136           if  (isset($_ GET['tag'] )) {
    1137                $sTag =  htmlspecia lchars_adv ($_GET['ta g']);
    1138                $aWhere[ ] = "`{$th is->sMainT able}`.`{$ this->aTab leFields[' medTags']} ` like '%$ sTag%'";
    1139           }
    1140           
    1141           if  (isset($_ GET['actio n'])) {
    1142                $sAct =  htmlspecia lchars_adv ($_GET['ac tion']);
    1143                switch ( $sAct) {
    1144                    case  'fav':
    1145                         $sAddon =  $this->get FavoriteCo ndition($t his->iView er);
    1146                         break;
    1147                    case  'del':
    1148                         $sAddon =  '';
    1149                         if (isset( $_GET['fil eID'])) 
    1150                             $this- >deleteMed ia($_GET[' fileID'],  $logged);
    1151                         break;  
    1152                }
    1153           }
    1154           
    1155           $a SqlQuery[' sqlWhere']  = "WHERE  " . implod e( ' AND ' , $aWhere  ).$sAddon. " AND `App roved`= 't rue'";
    1156           
    1157           $i TotalNum =  db_value(  "SELECT C OUNT( * )  FROM `{$th is->sMainT able}` {$a SqlQuery[' sqlWhere'] }" );
    1158           if  (!$iTotal Num)
    1159                return f alse;
    1160           
    1161           $i PerPage =  (int)$_GET ['per_page '];
    1162           if  (!$iPerPa ge)
    1163                $iPerPag e = 10;
    1164           
    1165           $i TotalPages  = ceil( $ iTotalNum  / $iPerPag e );
    1166           
    1167           $i CurPage =  (int)$_GET ['page'];
    1168           
    1169           if  ($iCurPag e > $iTota lPages)
    1170                $iCurPag e = $iTota lPages;
    1171           
    1172           if  ($iCurPag e < 1)
    1173                $iCurPag e = 1;
    1174           
    1175           $s LimitFrom  = ( $iCurP age - 1 )  * $iPerPag e;
    1176           $a SqlQuery[' sqlLimit']  = "LIMIT  $sLimitFro m, $iPerPa ge";
    1177           
    1178           $a SqlQuery[' sqlOrder']  = 'ORDER  BY `medDat e` DESC';
    1179           
    1180           if  (isset($_ GET['rate' ])) {
    1181                $oVoting View = new  BxTemplVo tingView ( 'g'.$this- >sType, 0,  0);
    1182                
    1183                $aSql         = $oV otingView- >getSqlPar ts('`'.$th is->sMainT able.'`',  '`'.$this- >aTableFie lds['medID '].'`');
    1184                $sHow         = $_G ET['rate']  == 'top'  ? "DESC" :  "ASC";
    1185                $aSqlQue ry['sqlOrd er']   = $ oVotingVie w->isEnabl ed() ? "OR DER BY `vo ting_rate`  $sHow, `v oting_coun t` $sHow,  `medDate`  $sHow" : $ aSqlQuery[ 'sqlOrder' ] ;
    1186                $aSqlQue ry['rateFi elds']  =  $aSql['fie lds'];
    1187                $aSqlQue ry['rateJo in']    =  $aSql['joi n'];
    1188           }
    1189           
    1190           re turn array ('query'=> $aSqlQuery , 'total'= >$iTotalPa ges, 'per_ page'=>$iP erPage, 'c ur_page'=> $iCurPage) ;
    1191       }
    1192   }
    1193  
    1194   ?>