function getLatestFile()
 {
     $aWhere[] = "1";
     foreach ($this->aCurrent['restriction'] as $sKey => $aValue) {
         if (isset($aValue['value'])) {
             switch ($sKey) {
                 case 'featured':
                 case 'owner':
                     if ((int) $aValue['value'] != 0) {
                         $aWhere[] = "`{$this->aCurrent['table']}`.`{$aValue['field']}` = '" . (int) $aValue['value'] . "'";
                     }
                     break;
                 case 'category':
                 case 'tag':
                     if (strlen($aValue['value']) > 0) {
                         $aWhere[] = "MATCH(`{$this->aCurrent['table']}`.`{$aValue['field']}`) AGAINST ('" . trim(process_db_input($aValue['value'], BX_TAGS_STRIP)) . "')";
                     }
                     break;
                 case 'allow_view':
                     if (is_array($aValue['value'])) {
                         $sqlJoin = "LEFT JOIN `sys_albums_objects` ON `sys_albums_objects`.`id_object`=`{$this->aCurrent['table']}`.`{$this->aCurrent['ident']}`\n                                        LEFT JOIN `sys_albums` ON `sys_albums_objects`.`id_album`=`sys_albums`.`ID`\n                            ";
                         $sqlCode = "`AllowAlbumView` IN(";
                         foreach ($aValue['value'] as $sValue) {
                             $sqlCode .= "{$sValue}, ";
                         }
                         $aWhere[] = rtrim($sqlCode, ", ") . ')';
                     }
                     break;
             }
         }
     }
     $sqlWhere = "WHERE " . implode(' AND ', $aWhere) . " AND `{$this->aCurrent['table']}`.`Status`= 'approved'";
     $sqlQuery = "SELECT `{$this->aCurrent['table']}`.`{$this->aCurrent['ident']}` as `{$this->aCurrent['ident']}` FROM `{$this->aCurrent['table']}` {$sqlJoin} {$sqlWhere} ORDER BY `{$this->aCurrent['ident']}` DESC LIMIT 1";
     $iFileId = db_value($sqlQuery);
     $sCode = '';
     if ($iFileId != 0) {
         $this->oTemplate->addCss('view.css');
         $oRate = new BxTemplVotingView($this->aCurrent['name'], $aInfo['medID']);
         $aInfo = $this->oModule->_oDb->getFileInfo(array('fileId' => $iFileId));
         $aDraw = array('file' => $this->oTemplate->getFileConcept($aInfo['medID'], array('ext' => $aInfo['medExt'], 'source' => $aInfo['medSource'])), 'file_url' => $this->getCurrentUrl('file', $aInfo['medID'], $aInfo['medUri']), 'title' => $aInfo['medTitle'], 'rate' => $oRate->getSmallVoting(0), 'date' => defineTimeInterval($aInfo['medDate']), 'owner_url' => getProfileLink($aInfo['medProfId']), 'owner_nick' => getNickName($aInfo['medProfId']));
         $sCode = $this->oTemplate->parseHtmlByName('latest_file.html', $aDraw);
     }
     return $sCode;
 }
function showPreviousRated($iPhotoID)
{
    global $site;
    global $oTemplConfig;
    global $max_thumb_width;
    global $max_thumb_height;
    $iBarWidth = $oTemplConfig->iRateSmallRatingBar;
    $iBarNum = $oTemplConfig->iRateSmallRatingBarNum;
    $query = "\r\n\t\tSELECT\r\n\t\t\t`media`.`med_id`,\r\n\t\t\t`med_prof_id`,\r\n\t\t\t`med_file`,\r\n\t\t\t`med_title`,\r\n\t\t\t`med_rating_count`,\r\n\t\t\t`med_rating_sum`,\r\n\t\t\t`Profiles`.`NickName`\r\n\t\tFROM `media`\r\n\t\tLEFT JOIN `media_rating` USING (`med_id`)\r\n\t\tLEFT JOIN `Profiles` ON\r\n\t\t\t(`Profiles`.`ID`=`media`.`med_prof_id`)\r\n\t\tWHERE\r\n\t\t\t`med_status` = 'active'\r\n\t\t\tAND `media`.`med_id` = {$iPhotoID}\r\n\t\t";
    $ph_arr = db_arr($query);
    if (!$ph_arr) {
        return '';
    }
    $urlImg = "{$site['profileImage']}{$ph_arr['med_prof_id']}/thumb_{$ph_arr['med_file']}";
    $urlSpacer = getTemplateIcon('spacer.gif');
    $sProfLink = getProfileLink($ph_arr['med_prof_id']);
    $sRatingBar = '';
    $oVotingView = new BxTemplVotingView('media', (int) $iPhotoID);
    if ($oVotingView->isEnabled()) {
        $sRatingBar = $oVotingView->getSmallVoting(false);
    }
    $ret .= <<<EOJ
\t<div class="rate_prev_photo_block">
\t\t<div class="thumbnail_block" style="float:none;">
\t\t\t<a href="{$site['url']}photos_gallery.php?ID={$ph_arr['med_prof_id']}&amp;photoID={$ph_arr['med_id']}" title="{$ph_arr['med_title']}">
\t\t\t\t<img style="width:{$max_thumb_width}px;height:{$max_thumb_height}px;background-image:url({$urlImg});" src="{$urlSpacer}" />
\t\t\t</a>
\t\t</div>
\t\t<div class="rate_prev_photo_nickname">
\t\t\t<a href="{$sProfLink}">{$ph_arr['NickName']}</a>
\t\t</div>
\t\t<div style="position:relative; width:50%; height:30px; overflow:visible; margin-top:10px;">
\t\t\t<div style="position:absolute; right:-94px; width:400px; height:30px;">
\t\t\t\t{$sRatingBar}
\t\t\t</div>\t\t\t
\t\t</div>

\t</div>
EOJ;
    return DesignBoxContent(_t('_Previous rated'), $ret, 1);
}
    function getBlockCode_SharedMedia($iUser = 0)
    {
        $iUser = (int) $iUser;
        $aManage = array('medID', 'medExt', 'medTitle', 'medUri');
        $max_num = (int) getParam("top_photos_max_num");
        $mode = process_db_input(getParam("top_photos_mode"));
        $mode = $_GET['sh_' . $this->sType . 'Mode'];
        if ($mode != 'rand' && $mode != 'top' && $mode != 'last') {
            $mode = 'last';
        }
        $aCond['sqlWhere'] = " WHERE `{$this->aTableFields['Approved']}`='true'";
        if ($iUser != 0) {
            $aCond['sqlWhere'] .= " AND `{$this->aTableFields['medProfId']}`='{$iUser}'";
        }
        $sqlFrom = " FROM `{$this->sMainTable}`";
        $aDBTopMenu = array();
        foreach (array('last', 'top', 'rand') as $myMode) {
            switch ($myMode) {
                case 'last':
                    if ($mode == $myMode) {
                        $aCond['sqlOrder'] = "\r\n\t\t  \t\tORDER BY `{$this->aTableFields['medDate']}` DESC";
                    }
                    $modeTitle = '_Latest';
                    break;
                case 'rand':
                    if ($mode == $myMode) {
                        $aCond['sqlOrder'] = "\r\n\t\t  \t\tORDER BY RAND()";
                    }
                    $modeTitle = '_Random';
                    break;
                case 'top':
                    if ($mode == $myMode) {
                        $oVotingView = new BxTemplVotingView('g' . $this->sType, 0, 0);
                        $aSql = $oVotingView->getSqlParts('`' . $this->sMainTable . '`', '`' . $this->aTableFields['medID'] . '`');
                        $sHow = "DESC";
                        $aCond['sqlOrder'] = $oVotingView->isEnabled() ? "ORDER BY `voting_rate` {$sHow}, `voting_count` {$sHow}, `{$this->aTableFields['medDate']}` {$sHow}" : $aCond['sqlOrder'];
                        $aCond['rateFields'] = $aSql['fields'];
                        $aCond['rateJoin'] = $aSql['join'];
                        $sqlFrom .= $aSql['join'];
                    }
                    $modeTitle = '_Top';
                    break;
            }
            if (basename($_SERVER['PHP_SELF']) == 'rewrite_name.php' || basename($_SERVER['PHP_SELF']) == 'profile.php') {
                $sLink = "profile.php?ID={$iUser}&";
            } else {
                $sLink = "{$_SERVER['PHP_SELF']}?";
            }
            $sLink .= "sh_" . $this->sType . "Mode={$myMode}";
            $aDBTopMenu[$modeTitle] = array('href' => $sLink, 'dynamic' => true, 'active' => $myMode == $mode);
        }
        $aNum = db_arr("SELECT COUNT(`{$this->sMainTable}`.`{$this->aTableFields['medID']}`) {$sqlFrom} {$aCond['sqlWhere']}");
        $num = (int) $aNum[0];
        $ret = '';
        if ($num) {
            $pages = ceil($num / $max_num);
            $page = (int) $_GET['page'];
            if ($page < 1 or $mode == 'rand') {
                $page = 1;
            }
            if ($page > $pages) {
                $page = $pages;
            }
            $sqlLimitFrom = ($page - 1) * $max_num;
            $aCond['sqlLimit'] = "LIMIT {$sqlLimitFrom}, {$max_num}";
            $rData = $this->getFilesList($aCond, $aManage);
            $ret .= '<div class="clear_both"></div>';
            $iCounter = 1;
            $sAddon = '';
            while ($aData = mysql_fetch_array($rData)) {
                $sTitle = strlen($aData['medTitle']) > 0 ? $aData['medTitle'] : _t("_Untitled");
                $sHref = $this->getFileUrl($aData['medID'], $aData['medUri']);
                $oVotingView = new BxTemplVotingView('g' . $this->sType, $aData['medID']);
                if ($oVotingView->isEnabled()) {
                    $sRate = $oVotingView->getSmallVoting(0);
                    $sShowRate = '<div class="galleryRate">' . $sRate . '</div>';
                }
                switch ($this->sType) {
                    case 'photo':
                        $sImage = $this->sFilesUrl . $aData['medID'] . '_t.' . $aData['medExt'];
                        $sPic = '<div class="lastFilesPic" style="background-image: url(\'' . $sImage . '\');">
					  <a href="' . $sHref . '"><img src="' . $this->aConfigSite['images'] . 'spacer.gif" alt="" width="110" height="110"></a></div><div class="clear_both"></div>';
                        break;
                    case 'music':
                        $sPic = '<div class="lastMusicPic"><a href="' . $sHref . '"><img src="' . $this->aConfigSite['images'] . 'music.png"></a></div>';
                        break;
                    case 'video':
                        $sPic = '<div class="lastVideoPic"><a href="' . $sHref . '"><img src="' . $this->sFilesUrl . $aData['medID'] . '.jpg" width="112px" height="80px"></a></div>';
                        break;
                }
                $ret .= '<div class="sharePhotosContent_1">';
                $ret .= $sPic . '<div class="shareMediaAdd"><a href="' . $sHref . '">' . $sTitle . '</a></div>' . $sShowRate . '</div>';
            }
            $ret .= '<div class="clear_both"></div>';
            $aDBBottomMenu = array();
            if ($pages > 1) {
                if ($page > 1) {
                    $prevPage = $page - 1;
                    $aDBBottomMenu[_t('_Back')] = array('href' => "{$_SERVER['PHP_SELF']}?sh_" . $this->sType . "Mode={$mode}&amp;page={$prevPage}", 'dynamic' => true, 'class' => 'backMembers');
                }
                if ($page < $pages) {
                    $nextPage = $page + 1;
                    $aDBBottomMenu[_t('_Next')] = array('href' => "{$_SERVER['PHP_SELF']}?sh_" . $this->sType . "Mode={$mode}&amp;page={$nextPage}", 'dynamic' => true, 'class' => 'moreMembers');
                }
                $sAllUrl = $this->isPermalinkEnabled() ? $this->aConfigSite['url'] . $this->sType . '/all/10/1' : $this->aConfigSite['url'] . 'browse' . ucfirst($this->sType) . '.php';
                $aDBBottomMenu[_t('_View All')] = array('href' => "{$sAllUrl}", 'class' => 'viewAllMembers');
            }
        }
        return array($ret, $aDBTopMenu, $aDBBottomMenu);
    }
function PageCompLastFiles()
{
    global $site;
    global $aFile;
    $iLimit = 2;
    $sQuery = "SELECT `ID` as `medID`,\r\n\t\t\t\t\t  `Title` as `medTitle`,\r\n\t\t\t\t\t  `Date` as `medDate`,\r\n\t\t\t\t\t  `Views` as `medViews`\r\n\t\t\t\t\t  FROM `RayMovieFiles` \r\n\t\t\t\t\t  WHERE `Owner`='{$aFile['medProfId']}' \r\n\t\t\t\t\t  AND `ID`<>'{$aFile['medID']}' AND `Approved`='true' ORDER BY `Date` DESC LIMIT {$iLimit}";
    $rLast = db_res($sQuery);
    $sLinkMore = '';
    if ($aFile['medCount'] - 1 > $iLimit) {
        $sLinkMore = '<a href="browseVideo.php?userID=' . $aFile['medProfId'] . '">' . _t("_See all videos of this user") . '</a>';
    }
    $sCode = '<div id="lastFiles">';
    while ($aLast = mysql_fetch_array($rLast)) {
        $sTitle = strlen($aLast['medTitle']) > 0 ? $aLast['medTitle'] : _t("_Untitled");
        $oVotingView = new BxTemplVotingView('gvideo', $aLast['medID']);
        if ($oVotingView->isEnabled()) {
            $sRate = $oVotingView->getSmallVoting(0);
            $sShowRate = '<div class="galleryRate">' . $sRate . '</div>';
        }
        $sCode .= '<div class="lastFileUnit">';
        $sCode .= '<div class="lastFilesPic">';
        $sCode .= '<a href="' . $site['url'] . 'viewVideo.php?fileID=' . $aLast['medID'] . '">';
        $sCode .= '<img src="' . $site['url'] . 'ray/modules/movie/files/' . $aLast['medID'] . '_small.jpg">';
        $sCode .= '</a>';
        $sCode .= '</div>';
        $sCode .= '<div><a href="' . $site['url'] . 'viewVideo.php?fileID=' . $aLast['medID'] . '"><b>' . $sTitle . '</b></a></div>';
        $sCode .= '<div>' . _t("_Added") . ': <b>' . defineTimeInterval($aLast['medDate']) . '</b></div>';
        $sCode .= '<div>' . _t("_Views") . ': <b>' . $aLast['medViews'] . '</b></div>';
        $sCode .= $sShowRate;
        $sCode .= '</div>';
        $sCode .= '<div class="clear_both"></div>';
    }
    $sCode .= '<div class="lastFilesLink">' . $sLinkMore . '</div>';
    $sCode .= '</div>';
    return $sCode;
}
function PageCompPageMainCode()
{
    global $site;
    global $rData;
    global $iTotalPages;
    global $iCurPage;
    global $iPerPage;
    global $member;
    $sCode = '<div style="position: relative; float: left;">';
    if (mysql_num_rows($rData)) {
        while ($aData = mysql_fetch_array($rData)) {
            $sImage = $site['sharingImages'] . $aData['medID'] . '_t.' . $aData['medExt'];
            $sProfLink = '<div>' . _t("_By") . ': <a href="' . getProfileLink($aData['medProfId']) . '">' . $aData['NickName'] . '</a></div>';
            $oVotingView = new BxTemplVotingView('gphoto', $aData['medID']);
            if ($oVotingView->isEnabled()) {
                $sRate = $oVotingView->getSmallVoting(0);
                $sShowRate = '<div class="galleryRate">' . $sRate . '</div>';
            }
            $sHref = $site['url'] . 'viewPhoto.php?fileID=' . $aData['medID'];
            $sImg = '<div class="lastFilesPic" style="background-image: url(\'' . $sImage . '\');">
					  <a href="' . $sHref . '"><img src="' . $site['images'] . 'spacer.gif" width="110" height="110"></a></div>';
            $sPicTitle = strlen($aData['medTitle']) > 0 ? $aData['medTitle'] : _t("_Untitled");
            $sDelLink = $member['ID'] == $aData['medProfId'] ? '<div><a href="' . $_SERVER['PHP_SELF'] . '?action=del&fileID=' . $aData['medID'] . '"
			onClick="return confirm( \'' . _t("_are you sure?") . '\');">' . _t("_Delete") . '</a></div>' : "";
            $sCode .= '<div class="browseUnit">';
            $sCode .= $sImg;
            $sCode .= '<div><a href="' . $sHref . '"><b>' . $sPicTitle . '</b></a></div>';
            $sCode .= $sProfLink;
            $sCode .= '<div>' . _t("_Added") . ': <b>' . defineTimeInterval($aData['medDate']) . '</b></div>';
            $sCode .= '<div>' . _t("_Views") . ': <b>' . $aData['medViews'] . '</b></div>';
            $sCode .= $sShowRate;
            $sCode .= $sDelLink;
            $sCode .= '</div>';
        }
    }
    $sCode .= '<div class="clear_both"></div>';
    // generate pagination
    if ($iTotalPages > 1) {
        $sRequest = $_SERVER['PHP_SELF'] . '?';
        $aFields = array('userID', 'tag', 'rate');
        foreach ($aFields as $field) {
            if (isset($_GET[$field])) {
                $sRequest .= "&amp;{$field}=" . htmlentities(process_pass_data($_GET[$field]));
            }
        }
        $pagination = '<div style="text-align: center; position: relative;">' . _t("_Results per page") . ':
				<select name="per_page" onchange="window.location=\'' . $sRequest . '&amp;per_page=\' + this.value;">
					<option value="10"' . ($iPerPage == 10 ? ' selected="selected"' : '') . '>10</option>
					<option value="20"' . ($iPerPage == 20 ? ' selected="selected"' : '') . '>20</option>
					<option value="50"' . ($iPerPage == 50 ? ' selected="selected"' : '') . '>50</option>
					<option value="100"' . ($iPerPage == 100 ? ' selected="selected"' : '') . '>100</option>
				</select></div>' . genPagination($iTotalPages, $iCurPage, $sRequest . '&amp;page={page}&amp;per_page=' . $iPerPage);
    } else {
        $pagination = '';
    }
    return $sCode . $pagination . '</div>';
}
function PageCompShareMusicContent($sCaption, $iID = 0)
{
    global $site;
    $max_num = (int) getParam("top_photos_max_num");
    $mode = process_db_input(getParam("top_photos_mode"));
    $mode = $_GET['shMusicMode'];
    if ($mode != 'rand' && $mode != 'top' && $mode != 'last') {
        $mode = 'last';
    }
    $sqlSelect = "SELECT `ID` as `medID`,\r\n\t\t\t\t\t\t `Title` as `medTitle`,\r\n\t\t\t\t\t\t `Date` as `medDate`\r\n\t\t\t\t\t\t ";
    $sqlFrom = " FROM `RayMusicFiles`";
    if ($iID != 0) {
        $sqlWhere = " WHERE `Approved`='true' AND `Owner`='{$iID}'";
    }
    $menu = '<div class="dbTopMenu">';
    foreach (array('last', 'top', 'rand') as $myMode) {
        switch ($myMode) {
            case 'last':
                if ($mode == $myMode) {
                    $sqlOrder = "\r\n\t  \t\tORDER BY `medDate` DESC";
                }
                $modeTitle = _t('_Latest');
                break;
            case 'rand':
                if ($mode == $myMode) {
                    $sqlOrder = "\r\n\t  \t\tORDER BY RAND()";
                }
                $modeTitle = _t('_Random');
                break;
            case 'top':
                if ($mode == $myMode) {
                    $oVotingView = new BxTemplVotingView('gmusic', 0, 0);
                    $aSql = $oVotingView->getSqlParts('`RayMusicFiles`', '`ID`');
                    $sHow = "DESC";
                    $sqlOrderBy = $oVotingView->isEnabled() ? "ORDER BY `voting_rate` {$sHow}, `voting_count` {$sHow}, `medDate` {$sHow}" : $sqlOrderBy;
                    $sqlFields = $aSql['fields'];
                    $sqlLJoin = $aSql['join'];
                    $sqlSelect .= $sqlFields;
                    $sqlFrom .= $sqlLJoin;
                    $sqlOrder = $sqlOrderBy;
                }
                $modeTitle = _t('_Top');
                break;
        }
        //if( $_SERVER['PHP_SELF'] == 'rewrite_name.php' )
        if ($myMode == $mode) {
            $menu .= "<div class=\"active\">{$modeTitle}</div>";
        } else {
            if (basename($_SERVER['PHP_SELF']) == 'rewrite_name.php' || basename($_SERVER['PHP_SELF']) == 'profile.php') {
                $menu .= "<div class=\"notActive\"><a href=\"profile.php?ID={$iID}&shMusicMode={$myMode}\" class=\"top_members_menu\" onclick=\"getHtmlData( 'show_shareMusic', this.href+'&amp;show_only=shareMusic'); return false;\">{$modeTitle}</a></div>";
            } else {
                $menu .= "<div class=\"notActive\"><a href=\"{$_SERVER['PHP_SELF']}?shMusicMode={$myMode}\" class=\"top_members_menu\" onclick=\"getHtmlData( 'show_shareMusic', this.href+'&amp;show_only=shareMusic'); return false;\">{$modeTitle}</a></div>";
            }
        }
    }
    $menu .= '</div>';
    $aNum = db_arr("SELECT COUNT(`RayMusicFiles`.`ID`) {$sqlFrom} {$sqlWhere}");
    $num = (int) $aNum[0];
    $ret = '';
    if ($num) {
        $pages = ceil($num / $max_num);
        $page = (int) $_GET['page_p'];
        if ($page < 1 or $mode == 'rand') {
            $page = 1;
        }
        if ($page > $pages) {
            $page = $pages;
        }
        $sqlLimitFrom = ($page - 1) * $max_num;
        $sqlLimit = "\r\n\t\tLIMIT {$sqlLimitFrom}, {$max_num}";
        $rData = db_res($sqlSelect . $sqlFrom . $sqlWhere . $sqlOrder . $sqlLimit);
        $sAddon = '';
        $iCounter = 1;
        $ret .= '<div class="clear_both"></div>';
        while ($aData = mysql_fetch_array($rData)) {
            $sHref = $site['url'] . 'viewMusic.php?fileID=' . $aData['medID'];
            $sVidTitle = strlen($aData['medTitle']) > 0 ? $aData['medTitle'] : _t("_Untitled");
            $sImg = '<a href="' . $sHref . '"><img src="' . $site['images'] . 'music.png"></a>';
            $oVotingView = new BxTemplVotingView('gmusic', $aData['medID']);
            if ($oVotingView->isEnabled()) {
                $sRate = $oVotingView->getSmallVoting(0);
                $sShowRate = '<div class="galleryRate">' . $sRate . '</div>';
            }
            if ($iCounter % 3 != 0) {
                $ret .= '<div class="shareMusicContent_1">';
            } else {
                $ret .= '<div class="shareMusicContent_2">';
                $sAddon = '<div class="clear_both"></div>';
            }
            $ret .= '<div class="lastMusicPic">' . $sImg . '</div>';
            $ret .= '<div><a href="' . $sHref . '">' . $sVidTitle . '</a></div>';
            $ret .= $sShowRate . '</div>';
            $ret .= $sAddon;
            $sAddon = '';
            $iCounter++;
        }
        $ret .= '<div class="clear_both"></div>';
        $ret = DesignBoxContent(_t($sCaption), $ret, 1, $menu);
    }
    return $ret;
}
function PageCompLastFiles()
{
    global $site;
    global $aFile;
    $iLimit = 2;
    $sQuery = "SELECT `medID`,\r\n\t\t\t\t\t  `medTitle`,\r\n\t\t\t\t\t  UNIX_TIMESTAMP(`medDate`) as `medDate`,\r\n\t\t\t\t\t  `medExt`,\r\n\t\t\t\t\t  `medViews`\r\n\t\t\t\t\t  FROM `sharePhotoFiles` \r\n\t\t\t\t\t  WHERE `medProfId`='{$aFile['medProfId']}' \r\n\t\t\t\t\t  AND `medID`<>'{$aFile['medID']}' AND `Approved`='true' ORDER BY `medDate` DESC LIMIT {$iLimit}";
    $rLast = db_res($sQuery);
    $sLinkMore = '';
    if ($aFile['medCount'] - 1 > $iLimit) {
        $sLinkMore = '<a href="browsePhoto.php?userID=' . $aFile['medProfId'] . '">' . _t("_See all photos of this user") . '</a>';
    }
    $sCode = '<div id="lastFiles">';
    while ($aLast = mysql_fetch_array($rLast)) {
        $sImage = $site['sharingImages'] . $aLast['medID'] . '_t.' . $aLast['medExt'];
        $sTitle = strlen($aLast['medTitle']) > 0 ? $aLast['medTitle'] : _t("_Untitled");
        $oVotingView = new BxTemplVotingView('gphoto', $aLast['medID']);
        if ($oVotingView->isEnabled()) {
            $sRate = $oVotingView->getSmallVoting(0);
            $sShowRate = '<div class="galleryRate">' . $sRate . '</div>';
        }
        $sCode .= '<div class="lastFileUnit">';
        $sCode .= '<a href="' . $site['url'] . 'viewPhoto.php?fileID=' . $aLast['medID'] . '">';
        $sCode .= '<img class="lastFilesPic" style="background-image: url(\'' . $sImage . '\');" src="' . getTemplateIcon('spacer.gif') . '" />';
        $sCode .= '</a>';
        $sCode .= '<div><a href="' . $site['url'] . 'viewPhoto.php?fileID=' . $aLast['medID'] . '"><b>' . $sTitle . '</b></a></div>';
        $sCode .= '<div>' . _t("_Added") . ': <b>' . defineTimeInterval($aLast['medDate']) . '</b></div>';
        $sCode .= '<div>' . _t("_Views") . ': <b>' . $aLast['medViews'] . '</b></div>';
        $sCode .= $sShowRate;
        $sCode .= '</div>';
        $sCode .= '<div class="clear_both"></div>';
    }
    $sCode .= '<div class="lastFilesLink">' . $sLinkMore . '</div>';
    $sCode .= '</div>';
    return $sCode;
}
 /**
  * Top Rated Profiles block (Leaders)
  */
 function getBlockCode_Leaders()
 {
     global $site;
     global $max_voting_mark;
     global $index_progressbar_w;
     global $getBlockCode_TopRated_db_num;
     global $max_thumb_height;
     global $max_thumb_width;
     global $oTemplConfig;
     // most rated profiles
     // $rate_max = get_max_votes_profile();
     $oVoting = new BxTemplVotingView('profile', 0, 0);
     $iIdMonth = $oVoting->getTopVotedItem(30, '`Profiles`', '`ID`', "AND `Profiles`.`Status` = 'Active'");
     $iIdWeek = $oVoting->getTopVotedItem(7, '`Profiles`', '`ID`', "AND `Profiles`.`Status` = 'Active' AND `ID`<>{$iIdMonth}");
     $iIdDay = $oVoting->getTopVotedItem(1, '`Profiles`', '`ID`', "AND `Profiles`.`Status` = 'Active' AND `ID`<>{$iIdMonth} AND `ID`<>{$iIdWeek}");
     $oVotingMonth = new BxTemplVotingView('profile', $iIdMonth);
     $oVotingWeek = new BxTemplVotingView('profile', $iIdWeek);
     $oVotingDay = new BxTemplVotingView('profile', $iIdDay);
     $rate_memb_month = getProfileInfo($iIdMonth);
     //db_arr( "SELECT Headline, NickName, ID, Pic_0_addon FROM Profiles WHERE `ID` = '$iIdMonth' LIMIT 1" );
     $rate_memb_week = getProfileInfo($iIdWeek);
     //db_arr( "SELECT Headline, NickName, ID, Pic_0_addon FROM Profiles WHERE `ID` = '$iIdWeek' LIMIT 1" );
     $rate_memb_day = getProfileInfo($iIdDay);
     //db_arr( "SELECT Headline, NickName, ID, Pic_0_addon FROM Profiles WHERE `ID` = '$iIdDay' LIMIT 1" );
     //$rate_memb_month  = db_arr( "SELECT Headline, NickName, Member, COUNT(*) AS `count`, SUM(Mark)/COUNT(*) AS mark, ID, Pic_0_addon  FROM `Votes` INNER JOIN Profiles ON (ID = Member) WHERE Status = 'Active' AND TO_DAYS(NOW()) - TO_DAYS(`Date`) <= 30 GROUP BY Member ORDER BY Mark DESC,`count` DESC LIMIT 1" );
     //$rate_memb_week   = db_arr( "SELECT Headline, NickName, Member, COUNT(*) AS `count`, SUM(Mark)/COUNT(*) AS mark, ID, Pic_0_addon  FROM `Votes` INNER JOIN Profiles ON (ID = Member) WHERE Status = 'Active' AND TO_DAYS(NOW()) - TO_DAYS(`Date`) <= 7 GROUP BY Member ORDER BY Mark DESC,`count` DESC LIMIT 1" );
     $ret = '';
     //#####################################################################
     $ret .= '<div class="clear_both"></div>';
     $ret .= '<div id="prof_of_month">';
     $ret .= '<div class="top_rated_head">';
     $ret .= _t("_Month");
     $ret .= '</div>';
     if (0 < $rate_memb_month['ID']) {
         $ret .= get_member_thumbnail($rate_memb_month['ID'], 'none');
         $ret .= '<div class="rate_block_position">';
         $ret .= $oVotingMonth->getSmallVoting(0);
         $ret .= '</div>';
     } else {
         $ret .= '<div class="top_prof_not_avail">';
         $ret .= '<div class="no_result">';
         $ret .= '<div>';
         $ret .= _t("_no_top_month");
         $ret .= '</div>';
         $ret .= '</div>';
         $ret .= '</div>';
     }
     $ret .= '<div class="clear_both"></div></div>';
     //#####################################################################
     $ret .= '<div id="prof_of_week">';
     $ret .= '<div class="top_rated_head">';
     $ret .= _t("_Week");
     $ret .= '</div>';
     if (0 < $rate_memb_week['ID']) {
         $ret .= get_member_thumbnail($rate_memb_week['ID'], 'none');
         $ret .= '<div class="rate_block_position">';
         $ret .= $oVotingWeek->getSmallVoting(0);
         $ret .= '</div>';
     } else {
         $ret .= '<div class="top_prof_not_avail">';
         $ret .= '<div class="no_result">';
         $ret .= '<div>';
         $ret .= _t("_no_top_week");
         $ret .= '</div>';
         $ret .= '</div>';
         $ret .= '</div>';
     }
     $ret .= '<div class="clear_both"></div></div>';
     //#####################################################################
     $ret .= '<div id="prof_of_day">';
     $ret .= '<div class="top_rated_head">';
     $ret .= _t("_Day");
     $ret .= '</div>';
     if (0 < $rate_memb_day['ID']) {
         $ret .= get_member_thumbnail($rate_memb_day['ID'], 'none');
         $ret .= '<div class="rate_block_position">';
         $ret .= $oVotingDay->getSmallVoting(0);
         $ret .= '</div>';
     } else {
         $ret .= '<div class="top_prof_not_avail">';
         $ret .= '<div class="no_result">';
         $ret .= '<div>';
         $ret .= _t("_no_top_day");
         $ret .= '</div>';
         $ret .= '</div>';
         $ret .= '</div>';
     }
     $ret .= '<div class="clear_both"></div></div>';
     $ret .= '<div class="clear_both"></div>';
     return $ret;
 }
 function getMediaBlock($iMediaID = 0)
 {
     global $site;
     global $votes_pic;
     $ret = '';
     if ($this->iMediaCount > 0) {
         $iMediaID = $iMediaID > 0 ? $iMediaID : $this->aMedia['0']['PrimPhoto'];
         $aCurPhoto = $this->getElementArrayByID($iMediaID);
         if (empty($aCurPhoto)) {
             $sPhotoUrl = getTemplateIcon($this->sSexPic);
         } else {
             $iPhotoID = $aCurPhoto['med_id'];
             $sPhotoUrl = $this->sMediaUrl . 'photo_' . $aCurPhoto['med_file'];
         }
     } else {
         $sPhotoUrl = getTemplateIcon($this->sSexPic);
     }
     $ret .= $this->getJSCode($aCurPhoto);
     $ret .= '<div class="photoBlock" id="photoKeeper">';
     $style = 'width:' . $this->aMediaConfig['size']['photoWidth'] . 'px;' . 'height:' . $this->aMediaConfig['size']['photoHeight'] . 'px;' . 'background-image:url(' . $sPhotoUrl . ');';
     $ret .= '<a href="' . $site['url'] . 'photos_gallery.php?ID=' . $this->iProfileID . '" id="temThumbLink">';
     $ret .= '<img src="' . getTemplateIcon('spacer.gif') . '" style="' . $style . '" class="photo" alt="" id="temThumbID" />';
     //$ret .= '<img src="' . getTemplateIcon('spacer.gif') . '" style="' . $style . '" class="photo" alt="" onload="return setThumb();" id="temThumbID" />';
     $ret .= '</a>';
     $ret .= '</div>';
     $ret .= '<div id="temPhotoTitle" class="photo_title">' . stripslashes($aCurPhoto['med_title']) . '</div>';
     $sJsIconsArray = '';
     $iCountPhotos = 0;
     $sIcons = $this->_getIconsList2($sJsIconsArray, $iCountPhotos);
     $oVotingView = new BxTemplVotingView('media', (int) $aCurPhoto['med_id']);
     if ($iCountPhotos && $votes_pic && $oVotingView->isEnabled()) {
         $ret .= $oVotingView->getSmallVoting();
     }
     $ret .= '<div class="clear_both"></div>';
     if (strlen($sIcons)) {
         $ret .= '<div class="scrollIconContainer">';
         $ret .= '<div class="scrollCont" id="scrollCont">';
         $ret .= '<div class="scrollLeft"  onmouseover="moveScrollLeftAuto(  \'iconBlock\', 1 );" onmouseout="moveScrollLeftAuto(  \'iconBlock\', 0 );"><img src="' . getTemplateIcon('left_arrow.gif') . '"/></div>';
         $ret .= '<div class="scrollRight" onmouseover="moveScrollRightAuto( \'iconBlock\', 1 );" onmouseout="moveScrollRightAuto( \'iconBlock\', 0 );"><img src="' . getTemplateIcon('right_arrow.gif') . '"/></div>';
         $ret .= '<div class="clear_both"></div>';
         $ret .= '</div>';
         $ret .= '<div class="iconBlockCont">';
         $ret .= '<div id="iconBlock" class="iconBlock">';
         $ret .= $sIcons;
         $ret .= '</div>';
         $ret .= '</div>';
         $ret .= '</div>';
     }
     $ret .= '<script type="text/javascript">' . $sJsIconsArray . '</script>';
     return $ret;
 }
    function getMediaBlock($iMediaID = 0, $bCouple = false)
    {
        global $site;
        global $votes_pic;
        $ret = '';
        if ($this->iMediaCount > 0) {
            $iMediaID = $iMediaID > 0 ? $iMediaID : $this->aMedia['0']['PrimPhoto'];
            $aCurPhoto = $this->getElementArrayByID($iMediaID);
            if (empty($aCurPhoto)) {
                $sPhotoUrl = getTemplateIcon($this->sSexPic);
            } else {
                $iPhotoID = $aCurPhoto['med_id'];
                $sPhotoUrl = $this->sMediaUrl . 'photo_' . $aCurPhoto['med_file'];
            }
        } else {
            $sPhotoUrl = getTemplateIcon($this->sSexPic);
        }
        $bUseFeature = getParam("profile_gallery_feature") == "on" ? true : false;
        //$bUseFeature = true;
        $bSUseFeature = $bUseFeature ? 'true' : 'false';
        $ret .= $this->getJSCode($aCurPhoto, $bSUseFeature);
        $sFeature = '';
        if ($bUseFeature) {
            for ($i = 0; $i < $this->aMediaConfig['max']['photo']; $i++) {
                $sIconSrc = $this->sMediaDir . 'photo_' . $this->aMedia[$i]['med_file'];
                if (extFileExists($sIconSrc)) {
                    $sIconUrl = $this->sMediaUrl . 'photo_' . $this->aMedia[$i]['med_file'];
                    //$atrib = "'{$this -> aMedia[$i]['med_id']}'";
                    //$sFeatImgs .= '<a href="' . $site['url'] . 'photos_gallery.php?ID=' .  $this -> iProfileID . '">';
                    $sFeatImgs .= '<img src="' . getTemplateIcon('spacer.gif') . '" style="width:' . $this->aMediaConfig['size']['photoWidth'] . 'px; height:' . $this->aMediaConfig['size']['photoHeight'] . 'px; background-image:url(' . $sIconUrl . ');position:absolute;"  alt="" class="icons" />';
                    //$sFeatImgs .= '</a>';
                }
            }
            $sFeatTotalHeight = $this->aMediaConfig['size']['photoHeight'] + 30;
            $sFeature = <<<EOF
<script type="text/javascript" src="{$site['url']}inc/js/jquery.dolPromoT.js"></script>
<script type="text/javascript">
\t\$(document).ready( function() {
\t\t\$( '#iiPPhoto' ).dolPromo( 3000, 1 );
\t} );
</script>
<div style="position:relative;width:100%;height:{$sFeatTotalHeight}px;overflow:hidden;">
\t<div id="iiPPhoto">
\t\t{$sFeatImgs}
\t</div>
</div>
EOF;
            $ret .= $sFeature;
        } else {
            $ret .= '<div class="photoBlock" id="photoKeeper">';
            $style = 'width:' . $this->aMediaConfig['size']['photoWidth'] . 'px;' . 'height:' . $this->aMediaConfig['size']['photoHeight'] . 'px;' . 'background-image:url(' . $sPhotoUrl . ');';
            $ret .= '<a href="' . $site['url'] . 'photos_gallery.php?ID=' . $this->iProfileID . '" id="temThumbLink">';
            $ret .= '<img src="' . getTemplateIcon('spacer.gif') . '" style="' . $style . '" class="photo" alt="" id="temThumbID" />';
            //$ret .= '<img src="' . getTemplateIcon('spacer.gif') . '" style="' . $style . '" class="photo" alt="" onload="return setThumb();" id="temThumbID" />';
            $ret .= '</a>';
            $ret .= '</div>';
        }
        $ret .= '<div id="temPhotoTitle" class="photo_title">' . stripslashes($aCurPhoto['med_title']) . '</div>';
        if ($bCouple) {
            return $ret . '<div class="clear_both"></div>';
        }
        $sJsIconsArray = '';
        $iCountPhotos = 0;
        $sIcons = $this->_getIconsList2($sJsIconsArray, $iCountPhotos);
        $oVotingView = new BxTemplVotingView('media', (int) $aCurPhoto['med_id']);
        if ($iCountPhotos && $votes_pic && $oVotingView->isEnabled()) {
            $ret .= $oVotingView->getSmallVoting();
        }
        $ret .= '<div class="clear_both"></div>';
        if (strlen($sIcons)) {
            $ret .= '<div class="scrollIconContainer">';
            $ret .= '<div class="scrollCont" id="scrollCont">';
            $ret .= '<div class="scrollLeft"  onmouseover="moveScrollLeftAuto(  \'iconBlock\', 1 );" onmouseout="moveScrollLeftAuto(  \'iconBlock\', 0 );"><img src="' . getTemplateIcon('left_arrow.gif') . '"/></div>';
            $ret .= '<div class="scrollRight" onmouseover="moveScrollRightAuto( \'iconBlock\', 1 );" onmouseout="moveScrollRightAuto( \'iconBlock\', 0 );"><img src="' . getTemplateIcon('right_arrow.gif') . '"/></div>';
            $ret .= '<div class="clear_both"></div>';
            $ret .= '</div>';
            $ret .= '<div class="iconBlockCont">';
            $ret .= '<div id="iconBlock" class="iconBlock">';
            $ret .= $sIcons;
            $ret .= '</div>';
            $ret .= '</div>';
            $ret .= '</div>';
        }
        $ret .= '<script type="text/javascript">' . $sJsIconsArray . '</script>';
        return $ret;
    }