Exemplo n.º 1
0
            if ($page < 1) {
                $page = 1;
            }
            if ($page > $pagesNum) {
                $page = $pagesNum;
            }
            $sqlFrom = ($page - 1) * $resPerPage;
            $sQuery = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\t`Groups`.*,\r\n\t\t\t\t\tCOUNT( `GroupsMembers`.`memberID` ) AS `membersCount`,\r\n\t\t\t\t\t`GroupsGallery`.`seed`,\r\n\t\t\t\t\t`GroupsGallery`.`ext` AS `thumbExt`\r\n\t\t\t\tFROM `Groups`\r\n\t\t\t\tLEFT JOIN `GroupsMembers`\r\n\t\t\t\t\tON (`GroupsMembers`.`groupID` = `Groups`.`ID` AND `GroupsMembers`.`status`='Active')\r\n\t\t\t\tLEFT JOIN `GroupsGallery`\r\n\t\t\t\t\tON (`Groups`.`thumb` = `GroupsGallery`.`ID`)\r\n\t\t\t\tWHERE `categID`={$cat}\r\n\t\t\t\tGROUP BY `Groups`.`ID` DESC\r\n\t\t\t\tLIMIT {$sqlFrom}, {$resPerPage}\r\n\t\t\t\t";
            $resGroups = db_res($sQuery);
            $numOnPage = mysql_num_rows($resGroups);
            $showingFrom = $sqlFrom + 1;
            $showingTo = $sqlFrom + $numOnPage;
            $showingResults = "Showing results: <b>{$showingFrom}</b> - <b>{$showingTo}</b> of <b>{$iGroupsNum}</b>";
            if ($pagesNum > 1) {
                $pagesUrl = "{$_SERVER['PHP_SELF']}?view_cat={$cat}&amp;page={page}#view_cat";
                $pagination = genPagination($pagesNum, $page, $pagesUrl);
            } else {
                $pagination = '';
            }
            $sRowTmpl = file_get_contents("{$dir['root']}admin/group_searchrow.html");
            $date_format_php = getParam('php_date_format');
            ?>
<div style="text-align:center;"><?php 
            echo $pagination;
            ?>
</div><?php 
            ?>
<div style="text-align:center;"><?php 
            echo $showingResults;
            ?>
</div><?php 
/**
 * page code function
 */
function PageCompMainCode()
{
    global $memberID;
    global $groupID;
    global $arrGroup;
    global $site;
    global $bcd;
    global $oTemplConfig;
    global $_page_cont;
    global $_ni;
    if ($_REQUEST['mode'] == 'edit' and $arrGroup['creatorID'] == $memberID) {
        $editMode = true;
        $editModeReq = 'mode=edit&amp;';
        $editModeSql = "`memberID`!={$arrGroup['creatorID']} AND";
    } else {
        $editMode = false;
        $editModeReq = '';
        $editModeSql = '';
    }
    $breadCrumbs = <<<EOJ
\t\t<div class="groups_breadcrumbs">
\t\t\t<a href="{$site['url']}">{$site['title']}</a> {$bcd}
\t\t\t<a href="{$site['url']}groups_home.php">__Groups__</a> {$bcd}
\t\t\t<a href="{$site['url']}group.php?ID={$groupID}">{$arrGroup['Name_html']}</a> {$bcd}
\t\t\t<span class="active_link">__Group members__</span>
\t\t</div>
EOJ;
    $breadCrumbs = str_replace("__Groups__", _t("_Groups"), $breadCrumbs);
    $breadCrumbs = str_replace("__Group members__", _t("_Group members"), $breadCrumbs);
    $arrMemNum = db_arr("SELECT COUNT(`memberID`) FROM `GroupsMembers` WHERE {$editModeSql} `groupID`={$groupID}  AND `status`='Active'");
    $totalNum = (int) $arrMemNum[0];
    if ($totalNum) {
        $resPerPage = $oTemplConfig->iGroupMembersResPerPage;
        $pagesNum = ceil($totalNum / $resPerPage);
        $page = (int) $_REQUEST['page'];
        if ($page < 1) {
            $page = 1;
        }
        if ($page > $pagesNum) {
            $page = $pagesNum;
        }
        $sqlFrom = ($page - 1) * $resPerPage;
        $query = "\r\n\t\t\tSELECT\r\n\t\t\t\t`GroupsMembers`.`memberID`,\r\n\t\t\t\t`Profiles`.`NickName`,\r\n\t\t\t\tIF( `GroupsMembers`.`memberID`={$arrGroup['creatorID']}, 1, 0 ) AS `isCreator`\r\n\t\t\tFROM\r\n\t\t\t\t`GroupsMembers`, `Profiles`\r\n\t\t\tWHERE\r\n\t\t\t\t{$editModeSql}\r\n\t\t\t\t`GroupsMembers`.`groupID`={$groupID} AND\r\n\t\t\t\t`GroupsMembers`.`status`='Active' AND\r\n\t\t\t\t`GroupsMembers`.`memberID`=`Profiles`.`ID`\r\n\t\t\tORDER BY\r\n\t\t\t\t`isCreator` DESC,\r\n\t\t\t\t`GroupsMembers`.`Date` DESC\r\n\t\t\tLIMIT {$sqlFrom}, {$resPerPage}\r\n\t\t\t";
        $resMembers = db_res($query);
        $numOnPage = mysql_num_rows($resMembers);
        $showingFrom = $sqlFrom + 1;
        $showingTo = $sqlFrom + $numOnPage;
        $showingResults = _t('_Showing results:', $showingFrom, $showingTo, $totalNum);
        if ($pagesNum > 1) {
            $pagesUrl = "{$_SERVER['PHP_SELF']}?{$editModeReq}ID={$groupID}&amp;page={page}";
            $pagination = genPagination($pagesNum, $page, $pagesUrl);
        }
        $_page_cont[$_ni]['bread_crumbs'] = $breadCrumbs;
        $_page_cont[$_ni]['showing_results'] = $showingResults;
        $_page_cont[$_ni]['pagination'] = $pagination;
        ob_start();
        ?>
				<div class="clear_both"></div>
		<?php 
        while ($arrMember = mysql_fetch_assoc($resMembers)) {
            ?>
				<div class="group_member">
			<?php 
            echo get_member_thumbnail($arrMember['memberID'], 'none');
            echo "<a href=\"" . getProfileLink($arrMember['memberID']) . "\">{$arrMember['NickName']}</a>";
            if ((int) $arrMember['isCreator']) {
                echo '<div class="mygroup_leader_is">' . _t('_group creator') . '</div>';
            }
            if ($editMode) {
                echo '<div class="group_member_edit"><a href="' . "{$site['url']}group_actions.php?ID={$groupID}&amp;a=delmem&amp;mem={$arrMember['memberID']}" . '" onclick="return confirm(\'' . _t('_Are you sure want to delete this member?') . '\')">' . _t('_Delete member') . '</a></div>';
            }
            ?>
				</div>
			<?php 
        }
        ?>
				<div class="clear_both"></div>
		<?php 
        $_page_cont[$_ni]['page_main_code'] = ob_get_clean();
    } else {
        $_page_cont[$_ni]['bread_crumbs'] = '';
        $_page_cont[$_ni]['pagination'] = '';
        $_page_cont[$_ni]['showing_results'] = '';
        $_page_cont[$_ni]['page_main_code'] = _t('_Sorry, no members are found');
    }
}
    /**
     * Generate List of Blogs
     *
     * @param $sType - tyle of list ('top', 'last')
     * @return HTML presentation of data
     */
    function GenBlogLists($sType = '')
    {
        $sDescriptionC = _t('_Description');
        $sPostsC = _t('_Posts');
        $sNoBlogsC = _t('_Sorry, nothing found');
        $sAllBlogsC = _t('_All Blogs');
        $sTopBlogsC = _t('_Top Blogs');
        $iCheckedMemberID = $this->aBlogConf['visitorID'];
        $sRestrictRes = $this->CheckRestrictionToView($iCheckedMemberID);
        if ($sRestrictRes != '') {
            return $sRestrictRes;
        }
        $sBlogsSQL = "\n\t\t\tSELECT `Blogs`. * , `Profiles`.`Nickname` \n\t\t\tFROM `Blogs` \n\t\t\tINNER JOIN `Profiles` ON `Blogs`.`OwnerID` = `Profiles`.`ID`\n\t\t";
        //////////////////pagination addition//////////////////////////
        $iTotalNum = db_value("SELECT COUNT(*) FROM `Blogs` INNER JOIN `Profiles` ON `Blogs`.`OwnerID` = `Profiles`.`ID`");
        if (!$iTotalNum) {
            return MsgBox($sNoBlogsC);
        }
        $iPerPage = (int) $_GET['per_page'];
        if (!$iPerPage) {
            $iPerPage = $this->iPerPageElements;
        }
        $iTotalPages = ceil($iTotalNum / $iPerPage);
        $iCurPage = (int) $_GET['page'];
        if ($iCurPage > $iTotalPages) {
            $iCurPage = $iTotalPages;
        }
        if ($iCurPage < 1) {
            $iCurPage = 1;
        }
        $sLimitFrom = ($iCurPage - 1) * $iPerPage;
        $sqlLimit = "LIMIT {$sLimitFrom}, {$iPerPage}";
        ////////////////////////////
        $sCaption = $sAllBlogsC;
        if ($sType == 'top') {
            $sBlogsSQL = "\n\t\t\t\tSELECT `Blogs`.`ID` , `Blogs`.`OwnerID` , `Blogs`.`Description` , `Profiles`.`Nickname` , MAX(`PostDate`) AS 'MPD', COUNT(`BlogPosts`.`PostID`) AS 'PostCount'\n\t\t\t\tFROM `Blogs` \n\t\t\t\tINNER JOIN `BlogCategories` ON `BlogCategories`.`OwnerID` = `Blogs`.`OwnerID` \n\t\t\t\tINNER JOIN `Profiles` ON `Profiles`.`ID` = `Blogs`.`OwnerID` \n\t\t\t\tINNER JOIN `BlogPosts` ON `BlogPosts`.`CategoryID` = `BlogCategories`.`CategoryID`\n\t\t\t\tWHERE `PostStatus`='approval'\n\t\t\t\tGROUP BY `Blogs`.`ID` \n\t\t\t\tORDER BY `PostCount` DESC\n\t\t\t\t{$sqlLimit}\n\t\t\t";
            $sCaption = $sTopBlogsC;
        } elseif ($sType == 'last') {
            $sBlogsSQL = "\n\t\t\t\tSELECT `Blogs`.`ID` , `Blogs`.`OwnerID` , `Blogs`.`Description` , `Profiles`.`Nickname` , MAX( `PostDate` ) AS 'MPD', COUNT( `BlogPosts`.`PostID` ) AS 'PostCount'\n\t\t\t\tFROM `Blogs` \n\t\t\t\tINNER JOIN `BlogCategories` ON `BlogCategories`.`OwnerID` = `Blogs`.`OwnerID` \n\t\t\t\tINNER JOIN `Profiles` ON `Profiles`.`ID` = `Blogs`.`OwnerID` \n\t\t\t\tINNER JOIN `BlogPosts` ON `BlogPosts`.`CategoryID` = `BlogCategories`.`CategoryID`\n\t\t\t\tWHERE `PostStatus`='approval'\n\t\t\t\tGROUP BY `Blogs`.`ID`\n\t\t\t\tORDER BY `MPD` DESC\n\t\t\t\t{$sqlLimit}\n\t\t\t";
        }
        // process database queries
        $vBlogsRes = db_res($sBlogsSQL);
        if (mysql_affected_rows() == 0) {
            return MsgBox($sNoBlogsC);
        }
        while ($aBlogsRes = mysql_fetch_assoc($vBlogsRes)) {
            if ($aBlogsRes['PostCount'] == 0 && $sType == 'top') {
                //in Top blogs skip blogs with 0 comments
                continue;
            }
            $sCont = get_member_thumbnail($aBlogsRes['OwnerID'], 'left', TRUE);
            $sBlogOwnerLink = $this->genBlogLink('show_member_blog', array('Permalink' => $aBlogsRes['Nickname'], 'Link' => $aBlogsRes['OwnerID']));
            $sRetHtml .= <<<EOF
<div>
\t<div class="clear_both"></div>
\t\t{$sCont}
\t<div class="cls_res_info_nowidth">
\t\t<div>
\t\t\t<a href="{$sBlogOwnerLink}">
\t\t\t\t{$aBlogsRes['Nickname']} Blog
\t\t\t</a>
\t\t</div>
\t\t<div>
\t\t\t{$aBlogsRes['PostCount']} {$sPostsC}
\t\t</div>
\t\t<div>
\t\t\t{$sDescriptionC}: <div class="clr3">{$aBlogsRes['Description']}</div>
\t\t</div>
\t</div>
\t<div class="clear_both"></div>
</div>
EOF;
        }
        /////////pagination addition//////////////////
        if ($this->isPermalinkEnabled() == false) {
            //old variant
            if ($iTotalPages > 1) {
                $sRequest = $_SERVER['PHP_SELF'] . '?';
                $aFields = array('action');
                foreach ($aFields as $vField) {
                    if (isset($_GET[$vField])) {
                        $sRequest .= "&amp;{$vField}=" . htmlentities(process_pass_data($_GET[$vField]));
                    }
                }
                $sPagination = '<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 {
                $sPagination = '';
            }
        } else {
            if ($iTotalPages > 1) {
                $sRequest = $_REQUEST['action'] == 'top_blogs' ? 'blogs/top/' : 'blogs/all/';
                $sPaginAddon = '';
                //$sPaginAddon = '/' . process_db_input($_GET['catUri']);
                /*$aFields = array( 'bClassifiedID', 'bSubClassifiedID', 'catUri', 'scatUri' );
                		
                		foreach( $aFields as $field )
                			if( isset( $_GET[$field] ) )
                				$sRequest .= "&amp;{$field}=" . htmlentities( process_pass_data( $_GET[$field] ) );*/
                $sPagination = '<div style="text-align: center; position: relative;">' . _t("_Results per page") . ':
						<select name="per_page" onchange="window.location=\'' . $sRequest . '\' + this.value + \'/1' . $sPaginAddon . '\';">
							<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 . $iPerPage . '/{page}' . $sPaginAddon);
            } else {
                $sPagination = '';
            }
        }
        ///////////////////////////
        return DesignBoxContent($sCaption, $sRetHtml . $sPagination, 1);
    }
    /**
     * Generate array of filtered Advertisements
     *
     * @return HTML presentation of data
     */
    function PrintFilteredAllAdvertisements()
    {
        global $site;
        global $aPreValues;
        $sRetHtml = '';
        $sCategory = (int) process_db_input($_REQUEST['FilterCat']);
        $sSubCategory = (int) process_db_input($_REQUEST['FilterSubCat']);
        $sCountry = process_db_input($_REQUEST['FilterCountry']);
        $sKeywords = process_db_input($_REQUEST['FilterKeywords']);
        if ($sSubCategory <= 0) {
            return MsgBox(_t('SubCategory is required'));
        }
        if (ereg("([0-9]+)", process_db_input($_REQUEST['CustomFieldValue1']), $aRegs)) {
            $sCustomFieldValue1 = $aRegs[1];
        }
        if (ereg("([0-9]+)", process_db_input($_REQUEST['CustomFieldValue2']), $aRegs)) {
            $sCustomFieldValue2 = $aRegs[1];
        }
        $sCustomFieldCaption1 = process_db_input($_REQUEST['CustomFieldCaption1']);
        $sCustomFieldCaption2 = process_db_input($_REQUEST['CustomFieldCaption2']);
        $sCustAction1 = "";
        $sCustAction2 = "";
        if ($sCustomFieldCaption1 != '' and $sCustomFieldCaption1 != 'NaN') {
            $sCustAction1 = mb_substr(html_entity_decode($sCustomFieldCaption1), 0, 3);
        }
        if ($sCustomFieldCaption2 != '' and $sCustomFieldCaption2 != 'NaN') {
            $sCustAction2 = mb_substr(html_entity_decode($sCustomFieldCaption2), 0, 3);
        }
        $aAllowActions = array('<', '>', '=');
        switch ($sCustAction1) {
            case 'Max':
                $sCustAction1 = '<';
                break;
            case 'Min':
                $sCustAction1 = '>';
                break;
            case 'Equ':
                $sCustAction1 = '=';
                break;
        }
        switch ($sCustAction2) {
            case 'Max':
                $sCustAction2 = '<';
                break;
            case 'Min':
                $sCustAction2 = '>';
                break;
            case 'Equ':
                $sCustAction2 = '=';
                break;
        }
        $sCategoryCat = $sCategory > 0 ? "`ClassifiedsSubs`.`IDClassified` = '{$sCategory}'" : '';
        $sSubCategoryCat = $sSubCategory > 0 ? "`ClassifiedsSubs`.`ID` = '{$sSubCategory}'" : '';
        $sCountryCat = $sCountry == '-1' ? '' : "`Profiles`.`Country`='{$sCountry}'";
        $sKeywordCat = $sKeywords == '' ? '' : "(`ClassifiedsAdvertisements`.`Subject` LIKE '%{$sKeywords}%' OR `ClassifiedsAdvertisements`.`Message` LIKE '%{$sKeywords}%')";
        $sCustom1Cat = (in_array($sCustAction1, $aAllowActions) == false or $sCustomFieldValue1 == '') ? '' : "CAST(`ClassifiedsAdvertisements`.`CustomFieldValue1`AS UNSIGNED) {$sCustAction1} {$sCustomFieldValue1}";
        $sCustom2Cat = (in_array($sCustAction2, $aAllowActions) == false or $sCustomFieldValue2 == '') ? '' : "CAST(`ClassifiedsAdvertisements`.`CustomFieldValue2`AS UNSIGNED) {$sCustAction2} {$sCustomFieldValue2}";
        $aWheres = array($sCategoryCat, $sSubCategoryCat, $sCountryCat, $sKeywordCat, $sCustom1Cat, $sCustom2Cat);
        $sQuery = "\r\n\t\t\tFROM `ClassifiedsAdvertisements`\r\n\t\t\tINNER JOIN `ClassifiedsSubs`\r\n\t\t\tON (`ClassifiedsAdvertisements`.`IDClassifiedsSubs`=`ClassifiedsSubs`.`ID`)\r\n\t\t\tINNER JOIN `Classifieds`\r\n\t\t\tON (`Classifieds`.`ID`=`ClassifiedsSubs`.`IDClassified`)\r\n\t\t\tLEFT JOIN `Profiles`\r\n\t\t\tON (`ClassifiedsAdvertisements`.`IDProfile`=`Profiles`.`ID`)\r\n\t\t\tWHERE\r\n\t\t\tDATE_ADD(`ClassifiedsAdvertisements`.`DateTime`, INTERVAL `ClassifiedsAdvertisements`.`LifeTime` DAY) > NOW()";
        foreach ($aWheres as $val) {
            $sQuery .= $val == '' ? '' : " AND " . $val;
        }
        $sQuery .= " ORDER BY `ClassifiedsAdvertisements`.`DateTime` ";
        ////////////////////////////
        $sQueryCnt = "SELECT COUNT( `ClassifiedsAdvertisements`.`ID` ) AS 'Cnt' " . $sQuery;
        $aTotalNum = db_arr($sQueryCnt);
        $iTotalNum = $aTotalNum['Cnt'];
        if (!$iTotalNum) {
            return MsgBox(_t('_Sorry, nothing found'));
        }
        $iPerPage = (int) $_GET['per_page'];
        if (!$iPerPage) {
            $iPerPage = $this->iPerPageElements;
        }
        $iTotalPages = ceil($iTotalNum / $iPerPage);
        $iCurPage = (int) $_GET['page'];
        if ($iCurPage > $iTotalPages) {
            $iCurPage = $iTotalPages;
        }
        if ($iCurPage < 1) {
            $iCurPage = 1;
        }
        $sLimitFrom = ($iCurPage - 1) * $iPerPage;
        $sqlLimit = "LIMIT {$sLimitFrom}, {$iPerPage}";
        ////////////////////////////
        $sQuery = "SELECT `ClassifiedsAdvertisements`.*, `Classifieds`.`Unit`, (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`DateTime`)) AS 'sec' " . $sQuery . $sqlLimit;
        $vSqlRes = db_res($sQuery);
        if (mysql_affected_rows() == -1) {
            return $this->GetSQLError($sQuery);
        }
        if (mysql_affected_rows() > 0) {
            $sFilteredC = _t('_Filtered');
            $sListingC = _t('_Listing');
            $sOutC = _t('_out');
            $sOfC = _t('_of');
            $sContStrs = '';
            while ($aSqlResStrA = mysql_fetch_assoc($vSqlRes)) {
                $sContStrs .= $this->ComposeResultStringAdv($aSqlResStrA);
            }
            ///////////////////////////
            if ($iTotalPages > 1) {
                $sRequest = $_SERVER['PHP_SELF'] . '?';
                $aFields = array('action', 'FilterCat', 'FilterSubCat', 'FilterCountry', 'FilterKeywords', 'CustomFieldValue1', 'CustomFieldValue2', 'CustomFieldCaption1', 'CustomFieldCaption2');
                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 = '';
            }
            ///////////////////////////
            $sRetHtml .= DesignBoxContent(_t('_SEARCH_RESULT_H'), $sContStrs . $pagination, 1);
        } else {
            $sRetHtml .= '<div>No listing..</div>';
        }
        return $sRetHtml;
    }
function getPostModMediaPage($iUser = 0)
{
    global $dir, $site, $max_thumb_width, $max_thumb_height, $max_photo_width, $max_photo_height;
    global $aFiles;
    global $iTotalPages, $iCurPage;
    $ret = '';
    $ret .= "<script>\r\n\tfunction checkAll( _pref, do_check )\r\n\t{\r\n\t\taElems = document.getElementsByTagName( 'input' );\r\n\t\t\r\n\t\tfor( i = 0; i < aElems.length; i ++ )\r\n\t\t{\r\n\t\t\telt = aElems[i];\r\n\t\t\tif( elt.name.substr( 0, _pref.length ) == _pref )\r\n\t\t\t\telt.checked = do_check;\r\n\t\t}\r\n\t}\r\n\t</script>";
    $ret .= '<div><form method="post" action="' . $_HTTP['REFERER'] . '">';
    $iCounter = 1;
    foreach ($aFiles as $aMedia) {
        $sPic = '<img src="' . $site['admin'] . 'images/music.png">';
        $sMediaLink = "<a href=\"javascript:openRayWidget('mp3','player','" . $aMedia['medID'] . "','1','1','true')\">" . $aMedia['medTitle'] . "</a>";
        $sProf = '<a href="' . $site['url'] . 'profile_edit.php?ID=' . $aMedia['medProfId'] . '">' . $aMedia['NickName'] . '</a>';
        $sStyle = $aMedia['Approved'] == 'true' ? ' style="border: 2px solid #00CC00;"' : ' style="border: 2px solid #CC0000;"';
        $ret .= '<div class="mainBlock"' . $sStyle . '>';
        $ret .= '<div class="checkBox">
						<input type="checkbox" name="check[]" id="ch' . $aMedia['medID'] . '" value="' . $aMedia['medID'] . '">
					</div>';
        $ret .= '<div class="picture">';
        $ret .= $sPic;
        $ret .= '</div>';
        $ret .= '<div class="fileInfo">';
        $ret .= '<div>';
        $ret .= $sMediaLink;
        $ret .= '</div>';
        $ret .= '<div>by ' . $sProf . '</div>';
        $ret .= '<div>Added: ' . defineTimeInterval($aMedia['medDate']) . '</div>';
        $ret .= '</div>';
        $ret .= '</div>';
        if ($iCounter % 2 == 0) {
            $ret .= '<div class="clear_both"></div>';
        }
        $iCounter++;
    }
    if (!empty($aFiles)) {
        $sCheck = count($aFiles) > 1 ? '<input type="checkbox" name=\\"ch_all" onclick="checkAll( \'ch\', this.checked )" />Check all' : '';
        $ret .= '<div style="clear:both; font-weight:bold; text-align:center;">' . $sCheck . '<input type="submit" name="Approve" value="Change status">
		<input type="submit" name="Delete" value="Delete"></div>';
    }
    if ($iTotalPages > 1) {
        $sRequest = $_SERVER['PHP_SELF'] . '?page={page}';
        $pagination = '<div style="text-align:center; margin: 10px 0px 10px 0px;">' . genPagination($iTotalPages, $iCurPage, $sRequest) . '</div>';
    } else {
        $pagination = '';
    }
    return $ret . $pagination . '</form></div>';
}
Exemplo n.º 6
0
function PageCompVideos()
{
    global $site;
    global $dir;
    global $tmpl;
    // number of videos
    $max_num = 12;
    $mode = 'rand';
    $sqlSelect = "\n\t\tSELECT\n\t\t\t`media`.`med_id`,\n\t\t\t`med_prof_id`,\n\t\t\t`med_file`,\n\t\t\t`med_title`";
    $sqlFrom = "\n\t\tFROM `media`";
    $sqlWhere = "\n\t\tWHERE\n\t\t\t`med_type` = 'video'";
    if ($_GET['mode'] == 'rand' or $_GET['mode'] == 'last' or $_GET['mode'] == 'top') {
        $mode = $_GET['mode'];
    }
    $menu = '';
    switch ($mode) {
        case 'last':
            $sqlOrder = " ORDER BY `med_date` DESC";
            break;
        case 'rand':
            $sqlOrder = " ORDER BY RAND()";
            break;
        case 'top':
            $sqlSelect .= ",\n\t(`med_rating_sum`/`med_rating_count`) AS `avg_mark`";
            $sqlFrom .= "\n\tINNER JOIN `media_rating` USING (`med_id`) ";
            $sqlOrder = "\n\tORDER BY `avg_mark` DESC";
            break;
    }
    $aNum = db_arr("SELECT COUNT(`media`.`med_id`) {$sqlFrom} {$sqlWhere}");
    $num = (int) $aNum[0];
    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;
        $sqlLimit = "\n\t\tLIMIT {$sqlLimitFrom}, {$max_num}";
        //$max_thumb_width  = (int)getParam( 'max_thumb_width' );
        //$max_thumb_height = (int)getParam( 'max_thumb_height' );
        $ret = '<div class="clear_both"></div>';
        $tmplBlock = file_get_contents("{$dir['root']}templates/tmpl_{$tmpl}/media_page_block.html");
        $result = db_res($sqlSelect . $sqlFrom . $sqlWhere . $sqlOrder . $sqlLimit);
        while ($ph_arr = mysql_fetch_assoc($result)) {
            $block = $tmplBlock;
            $memNickName = getNickName($ph_arr['med_prof_id']);
            $aReplace['media_title'] = process_line_output($ph_arr['med_title']);
            $aReplace['media_icon'] = "<a href=\"{$site['url']}media/video/{$ph_arr['med_prof_id']}/{$ph_arr['med_file']}\" title=\"" . _t('_download') . "\"><img src=\"" . getTemplateIcon('video.jpg') . "\" alt=\"video\" /></a>";
            $aReplace['nickname'] = "<a href=\"" . getProfileLink($ph_arr['med_prof_id']) . "\">{$memNickName}</a>";
            $aReplace['download'] = '';
            $aReplace['delete'] = '';
            foreach ($aReplace as $key => $val) {
                $block = str_replace("__{$key}__", $val, $block);
            }
            $ret .= $block;
        }
        $ret .= '<div class="clear_both"></div>';
        if ($pages > 1) {
            $pagination = '<div class="video_pages">' . genPagination($pages, $page, $_SERVER['PHP_SELF'] . "?mode={$mode}&amp;page={page}") . '</div>';
            $ret = $pagination . $ret . $pagination;
        }
    } else {
        $ret .= '<div class="no_result">';
        $ret .= '<div>';
        $ret .= _t("_No results found");
        $ret .= '</div>';
        $ret .= '</div>';
    }
    return $ret;
}
function PageCompGroupsSearchResults($keyword, $searchby, $categID, $Country, $City, $sortby, $isTopGroupsPage = false)
{
    global $oTemplConfig;
    global $site;
    global $dir;
    global $tmpl;
    global $prof;
    $date_format_php = getParam('php_date_format');
    if ($sortby == 'created' or $sortby == 'membersCount') {
        $sortOrder = 'DESC';
    } else {
        $sortOrder = 'ASC';
    }
    $aQueryWhere = array();
    //array will contain search conditions combined by AND
    if ($keyword) {
        if ($searchby == 'name') {
            $aQueryWhere[] = "UPPER(`Groups`.`Name`) LIKE '%{$keyword}%'";
        } else {
            $aQueryWhere[] = "(UPPER(`Groups`.`Name`) LIKE '%{$keyword}%') OR (UPPER(`Groups`.`About`) LIKE '%{$keyword}%') OR (UPPER(`Groups`.`Desc`) LIKE '%{$keyword}%')";
        }
    }
    if ($categID) {
        $aQueryWhere[] = "`Groups`.`categID`='{$categID}'";
    }
    if ($Country) {
        $aQueryWhere[] = "`Groups`.`Country`='{$Country}'";
    }
    if ($City) {
        $aQueryWhere[] = "UPPER(`Groups`.`City`) LIKE '%{$City}%'";
    }
    $aQueryWhere[] = "`Groups`.`status` = 'Active'";
    $sQueryWhere = "WHERE (" . implode(") AND (", $aQueryWhere) . ")";
    if ($isTopGroupsPage) {
        $SRdbTitle = _t('_Top Groups');
    } else {
        $SRdbTitle = _t('_Groups search results');
    }
    //SearchResultDesignBoxTitle
    $arrNum = db_arr("SELECT COUNT(`ID`) FROM `Groups` {$sQueryWhere}");
    $totalNum = (int) $arrNum[0];
    if ($totalNum > 0) {
        $resPerPage = $oTemplConfig->iGroupsSearchResPerPage;
        $pagesNum = ceil($totalNum / $resPerPage);
        $page = (int) $_REQUEST['page'];
        if ($page < 1) {
            $page = 1;
        }
        if ($page > $pagesNum) {
            $page = $pagesNum;
        }
        $sqlFrom = ($page - 1) * $resPerPage;
        $sQuery = "\r\n\t\t\tSELECT\r\n\t\t\t\t`Groups`.*,\r\n\t\t\t\t`GroupsCateg`.`Name` AS `categName`,\r\n\t\t\t\tCOUNT( `GroupsMembers`.`memberID` ) AS `membersCount`,\r\n\t\t\t\t`GroupsGallery`.`seed`,\r\n\t\t\t\t`GroupsGallery`.`ext` AS `thumbExt`\r\n\t\t\tFROM `Groups`\r\n\t\t\tINNER JOIN `GroupsCateg` ON `GroupsCateg`.`ID` = `Groups`.`categID`\r\n\t\t\tLEFT JOIN `GroupsMembers`\r\n\t\t\t\tON (`GroupsMembers`.`groupID` = `Groups`.`ID` AND `GroupsMembers`.`status`='Active')\r\n\t\t\tLEFT JOIN `GroupsGallery`\r\n\t\t\t\tON (`Groups`.`thumb` = `GroupsGallery`.`ID`)\r\n\t\t\t{$sQueryWhere}\r\n\t\t\tGROUP BY `Groups`.`ID`\r\n\t\t\tORDER BY `{$sortby}` {$sortOrder}, `Groups`.`ID` DESC\r\n\t\t\tLIMIT {$sqlFrom}, {$resPerPage}\r\n\t\t\t";
        $resGroups = db_res($sQuery);
        $numOnPage = mysql_num_rows($resGroups);
        $showingFrom = $sqlFrom + 1;
        $showingTo = $sqlFrom + $numOnPage;
        $showingResults = _t('_Showing results:', $showingFrom, $showingTo, $totalNum);
        if ($pagesNum > 1 and !$isTopGroupsPage) {
            $pagesUrl = "javascript:void(0);";
            $pagesOnclick = "switchGroupsSearchPage({page}); return false;";
            $pagination = genPagination($pagesNum, $page, $pagesUrl, $pagesOnclick);
        }
        $sRowTmpl = file_get_contents("{$dir['root']}templates/tmpl_{$tmpl}/searchrow_group.html");
        $breadCrumbs = '';
        if ($categID) {
            $arrCateg = db_arr("SELECT `Name` FROM `GroupsCateg` WHERE `ID`={$categID}");
            if ($arrCateg['Name']) {
                $sCategName = _t('_Category') . ': ' . htmlspecialchars_adv($arrCateg['Name']);
                $SRdbTitle = $sCategName;
                $bcd = getParam('breadCrampDivider');
                $breadCrumbs = <<<EOJ
\t\t<div class="groups_breadcrumbs">
\t\t\t<a href="{$site['url']}">{$site['title']}</a> {$bcd}
\t\t\t<a href="{$site['url']}groups_home.php">__Groups__</a> {$bcd}
\t\t\t<span class="active_link">{$sCategName}</span>
\t\t</div>
EOJ;
                $breadCrumbs = str_replace("__Groups__", _t("_Groups"), $breadCrumbs);
            }
        }
        ob_start();
        if (!$isTopGroupsPage) {
            echo $breadCrumbs;
            ?>
			<div class="groups_showing_results">
				<?php 
            echo $showingResults;
            ?>
			</div>
			<div class="groups_pagination">
				<?php 
            echo $pagination;
            ?>
			</div>
			<?php 
        }
        ?>
		<div class="groups_result_wrapper">
		<?php 
        while ($arrGroup = mysql_fetch_assoc($resGroups)) {
            $aRowTmpl = array();
            if ($arrGroup['thumb'] and file_exists(BX_DIRECTORY_PATH_GROUPS_GALLERY . "{$arrGroup['ID']}_{$arrGroup['thumb']}_{$arrGroup['seed']}_.{$arrGroup['thumbExt']}")) {
                $groupImageUrl = "{$site['groups_gallery']}{$arrGroup['ID']}_{$arrGroup['thumb']}_{$arrGroup['seed']}_.{$arrGroup['thumbExt']}";
            } else {
                $groupImageUrl = "{$site['groups_gallery']}no_pic.gif";
            }
            if ((int) $arrGroup['hidden_group']) {
                $typeHelp = 7;
            } else {
                if ((int) $arrGroup['open_join']) {
                    $typeHelp = 5;
                } else {
                    $typeHelp = 6;
                }
            }
            $typeHelpLink = "{$site['url']}groups_help.php?i={$typeHelp}";
            $aRowTmpl['group_name_l'] = _t('_Group name');
            $aRowTmpl['category_l'] = _t('_Category');
            $aRowTmpl['about_group_l'] = _t('_About group');
            $aRowTmpl['members_count_l'] = _t('_Members count');
            $aRowTmpl['created_l'] = _t('_Created');
            $aRowTmpl['group_type_l'] = _t('_Group type');
            $aRowTmpl['location_l'] = _t('_Location');
            $aRowTmpl['group_type_help'] = '<a href="' . $typeHelpLink . '" target="_blank" onclick="window.open(this.href,\'helpwin\',\'width=350,height=200\');return false;" >' . _t("_help") . '</a>';
            $sSpacerPath = 'templates/base/images/icons/spacer.gif';
            $sSpacerName = $site['url'] . $sSpacerPath;
            $aRowTmpl['thumbnail'] = "<!--<div class=\"group_thumb\">--><a href=\"{$site['url']}group.php?ID={$arrGroup['ID']}\">\r\n\t\t\t\t\t\t\t\t\t\t\t<!--<img src=\"{$groupImageUrl}\" />-->\r\n\t\t\t\t\t\t\t\t\t\t\t<img src=\"{$sSpacerName}\" style=\"width:110px;height:110px; background-image: url({$groupImageUrl});\" class=\"photo1\"/>\r\n\t\t\t\t\t\t\t\t\t\t\t</a><!--</div>-->";
            $aRowTmpl['group_name'] = "<a class=\"actions\" href=\"{$site['url']}group.php?ID={$arrGroup['ID']}\">" . htmlspecialchars_adv($arrGroup['Name']) . "</a>";
            $aRowTmpl['group_about'] = htmlspecialchars_adv($arrGroup['About']);
            $aRowTmpl['category'] = "<a href=\"{$site['url']}groups_browse.php?categID={$arrGroup['categID']}\">" . htmlspecialchars_adv($arrGroup['categName']) . "</a>";
            $aRowTmpl['members_count'] = $arrGroup['membersCount'];
            $aRowTmpl['created'] = date($date_format_php, strtotime($arrGroup['created']));
            $aRowTmpl['group_type'] = _t(((int) $arrGroup['open_join'] and !(int) $arrGroup['hidden_group']) ? '_Public group' : '_Private group');
            $aRowTmpl['country'] = _t('__' . $prof['countries'][$arrGroup['Country']]);
            $aRowTmpl['city'] = htmlspecialchars_adv($arrGroup['City']);
            $sRow = $sRowTmpl;
            foreach ($aRowTmpl as $what => $to) {
                $sRow = str_replace("__{$what}__", $to, $sRow);
            }
            echo $sRow;
        }
        ?>
				<div class="clear_both"></div>
			</div>
		<?php 
        if (!$isTopGroupsPage) {
            ?>
			<div class="groups_showing_results">
				<?php 
            echo $showingResults;
            ?>
			</div>
			<div class="groups_pagination">
				<?php 
            echo $pagination;
            ?>
			</div>
			<?php 
        }
        $ret = ob_get_clean();
    } else {
        $ret = MsgBox(_t('_Sorry, no groups found'));
    }
    return DesignBoxContent($SRdbTitle, $ret, $oTemplConfig->iGroupsSearchResults_dbnum);
}
Exemplo n.º 8
0
function PageCompPhotos()
{
    global $site;
    global $tmpl;
    // number of photos
    $max_num = 12;
    $mode = 'top';
    $sqlSelect = "\n\t\tSELECT\n\t\t\t`media`.`med_id`,\n\t\t\t`med_prof_id`,\n\t\t\t`med_file`,\n\t\t\t`med_title`";
    $sqlFrom = "\n\t\tFROM `media`";
    $sqlWhere = "\n\t\tWHERE\n\t\t\t`med_type` = 'photo' AND\n\t\t\t`med_status` = 'active'";
    if ($_GET['mode'] == 'rand' or $_GET['mode'] == 'last' or $_GET['mode'] == 'top') {
        $mode = $_GET['mode'];
    }
    $menu = '';
    switch ($mode) {
        case 'last':
            $sqlOrder = " ORDER BY `med_date` DESC";
            break;
        case 'rand':
            $sqlOrder = " ORDER BY RAND()";
            break;
        case 'top':
            $sqlSelect .= ",\n\t(`med_rating_sum`/`med_rating_count`) AS `avg_mark`";
            $sqlFrom .= "\n\tINNER JOIN `media_rating` USING (`med_id`) ";
            $sqlOrder = "\n\tORDER BY `avg_mark` DESC";
            break;
    }
    $aNum = db_arr("SELECT COUNT(`media`.`med_id`) {$sqlFrom} {$sqlWhere}");
    $num = (int) $aNum[0];
    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;
        $sqlLimit = "\n\t\tLIMIT {$sqlLimitFrom}, {$max_num}";
        $max_thumb_width = (int) getParam('max_thumb_width');
        $max_thumb_height = (int) getParam('max_thumb_height');
        $ret = '<div class="clear_both"></div>';
        $result = db_res($sqlSelect . $sqlFrom . $sqlWhere . $sqlOrder . $sqlLimit);
        while ($ph_arr = mysql_fetch_assoc($result)) {
            $urlImg = "{$site['profileImage']}{$ph_arr['med_prof_id']}/thumb_{$ph_arr['med_file']}";
            $urlSpacer = getTemplateIcon('spacer.gif');
            $ph_arr['med_title'] = htmlspecialchars_adv($ph_arr['med_title']);
            //$memNickName = getNickName( $ph_arr['med_prof_id'] );
            $ret .= <<<EOJ
\t\t\t<div class="photo_block">
\t\t\t\t<div class="thumbnail_block" style="float:none;">
\t\t\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\t\t<img style="width:{$max_thumb_width}px;height:{$max_thumb_height}px;background-image:url({$urlImg});" src="{$urlSpacer}" />
\t\t\t\t\t</a>
\t\t\t\t</div>
\t\t\t\t<div class="photo_nickname">
\t\t\t\t\t<a href="{$site['url']}{$memNickName}">{$memNickName}</a>
\t\t\t\t</div>
\t\t\t</div>
EOJ;
        }
        $ret .= '<div class="clear_both"></div>';
        if ($pages > 1) {
            $pagination = '<div class="photos_pages">' . genPagination($pages, $page, $_SERVER['PHP_SELF'] . "?mode={$mode}&amp;page={page}") . '</div>';
            $ret = $pagination . $ret . $pagination;
        }
    } else {
        $ret .= '<div class="no_result">';
        $ret .= '<div>';
        $ret .= _t("_No results found");
        $ret .= '</div>';
        $ret .= '</div>';
    }
    return $ret;
}
    /**
     * Generate User`s Blog Page
     *
     * @param $iUserID - User ID
     * @return HTML presentation of data
     */
    function GenMemberBlog($iUserID = 0)
    {
        global $site;
        $iCheckedMemberID = $this->aBlogConf['visitorID'];
        $sRestrictRes = $this->CheckRestrictionToView($iCheckedMemberID);
        if ($sRestrictRes != '') {
            return $sRestrictRes;
        }
        $sRetHtml = '';
        $sBlogPosts = '';
        $iMemberID = $this->defineUserId();
        if ($iUserID > 0) {
            $iMemberID = $iUserID;
        }
        $iCategoryID = $this->defineCategoryId();
        $sEditC = _t('_Edit');
        $sDeleteC = _t('_Delete');
        $sSureC = _t("_Are you sure");
        $sPostCommentC = _t('_Post Comment');
        $sDescriptionC = _t('_Description');
        $sAddCommentC = _t('_Add comment');
        $sNewPostC = _t('_New Post');
        $sTagsC = _t('_Tags');
        $sPostsC = _t('_Posts');
        $sBlogsSQL = "\n\t\t\tSELECT `Blogs`. * , `Profiles`.`Nickname` \n\t\t\tFROM `Blogs` \n\t\t\tINNER JOIN `Profiles` ON `Blogs`.`OwnerID` = `Profiles`.`ID`\n\t\t\tWHERE `Blogs`.`OwnerID` = {$iMemberID}\n\t\t\tLIMIT 1\n\t\t";
        $aBlogsRes = db_arr($sBlogsSQL);
        if (!$aBlogsRes) {
            if ($iMemberID == $iCheckedMemberID) {
                return $this->GenCreateBlogForm();
            } else {
                return MsgBox(_t('_Sorry, nothing found'));
            }
        }
        $sCategoryAddon = $iCategoryID > 0 ? "AND `BlogPosts`.`CategoryID` = {$iCategoryID}" : '';
        $sOwnerAddAp = $iCheckedMemberID != $iMemberID ? "AND `PostStatus`='approval'" : '';
        //////////////////pagination addition//////////////////////////
        $sCntSQL = "SELECT COUNT(`BlogPosts`.`PostID`) AS `Cnt`\n\t\t\t\t\t\tFROM `BlogPosts`\n\t\t\t\t\t\tINNER JOIN `BlogCategories` ON `BlogCategories`.`CategoryID`=`BlogPosts`.`CategoryID`\n\t\t\t\t\t\tWHERE `BlogCategories`.`OwnerID` = {$iMemberID}\n\t\t\t\t\t\t{$sCategoryAddon}\n\t\t\t\t\t\t{$sOwnerAddAp}\n\t\t";
        $iTotalNum = db_value($sCntSQL);
        if (!$iTotalNum) {
            $sBlogPosts .= MsgBox(_t('_Sorry, nothing found'));
        }
        $iPerPage = (int) $_GET['per_page'];
        if (!$iPerPage) {
            $iPerPage = $this->iPerPageElements;
        }
        $iTotalPages = ceil($iTotalNum / $iPerPage);
        $iCurPage = (int) $_GET['page'];
        if ($iCurPage > $iTotalPages) {
            $iCurPage = $iTotalPages;
        }
        if ($iCurPage < 1) {
            $iCurPage = 1;
        }
        $sLimitFrom = ($iCurPage - 1) * $iPerPage;
        $sqlLimit = "LIMIT {$sLimitFrom}, {$iPerPage}";
        ////////////////////////////
        $oCmts = new BxDolCmts('blogposts', 0, 0);
        $sBlogPostsSQL = "\n\t\t\tSELECT `BlogPosts`.*, COUNT(`cmt_id`) AS `CountComments`, `BlogCategories`.`OwnerID`, `BlogCategories`.`CategoryName`, `BlogCategories`.`CategoryUri`,\n\t\t\tUNIX_TIMESTAMP( `BlogPosts`.`PostDate` ) AS `PostDate_UTS`\n\t\t\tFROM `BlogPosts`\n\t\t\tLEFT JOIN `" . $oCmts->getCommentsTableName() . "` AS `tc` ON `BlogPosts`.`PostID` = `tc`.`cmt_object_id`\n\t\t\tINNER JOIN `BlogCategories` ON `BlogCategories`.`CategoryID`=`BlogPosts`.`CategoryID`\n\t\t\tWHERE `BlogCategories`.`OwnerId` = {$iMemberID}\n\t\t\t{$sCategoryAddon}\n\t\t\t{$sOwnerAddAp}\n\t\t\tGROUP BY `BlogPosts`.`PostID`\n\t\t\tORDER BY `PostDate` DESC, `CountComments` DESC\n\t\t\t{$sqlLimit}\n\t\t";
        $vBlogPosts = db_res($sBlogPostsSQL);
        $sCurCategory = '';
        if ($iCategoryID > 0) {
            $sBlogCategSQL = "\n\t\t\t\tSELECT `BlogCategories`.`CategoryName`, `BlogCategories`.`CategoryUri`\n\t\t\t\tFROM `BlogCategories`\n\t\t\t\tWHERE `BlogCategories`.`CategoryID` = '{$iCategoryID}'\n\t\t\t\tLIMIT 1\n\t\t\t";
            $aBlogCateg = db_arr($sBlogCategSQL);
            $sCurCategory = $aBlogCateg['CategoryName'];
            $sCurCategoryURI = $aBlogCateg['CategoryUri'];
        }
        while ($aResSQL = mysql_fetch_assoc($vBlogPosts)) {
            if ('friends' == $aResSQL['PostReadPermission'] && !$this->aBlogConf['isFriend'] && !$this->aBlogConf['isOwner'] && !$this->bAdminMode) {
                $sBlogPosts .= $this->GenPostString($aResSQL);
            } else {
                $sBlogPosts .= $this->GenPostString($aResSQL);
            }
        }
        $sNewPost = '';
        if ($this->aBlogConf['visitorID'] == $aBlogsRes['OwnerID']) {
            $sNewPost = <<<EOF
<div class="caption_item">
\t<span style="vertical-align:middle;"><img src="{$site['icons']}post_new.png" class="marg_icon" alt="{$sNewPostC}" /></span>
\t<a href="{$_SERVER['PHP_SELF']}?action=new_post" style="text-transform:none;">{$sNewPostC}</a>
</div>
EOF;
        }
        $sUser = getNickName($aBlogsRes['OwnerID']);
        $sOwnerBlogLink = $this->genBlogLink('show_member_blog_home', array('Permalink' => $sUser, 'Link' => $aBlogsRes['OwnerID']));
        $sAsBlog = _t('_Members_blog', $sUser);
        /////////pagination addition//////////////////
        if ($this->isPermalinkEnabled() == false) {
            //old variant
            if ($iTotalPages > 1) {
                $sRequest = $_SERVER['PHP_SELF'] . '?';
                $aFields = array('action', 'ownerName', 'categoryUri', 'ownerID', 'category');
                foreach ($aFields as $vField) {
                    if (isset($_GET[$vField])) {
                        $sRequest .= "&{$vField}=" . htmlentities(process_pass_data($_GET[$vField]));
                    }
                }
                $sPagination = '<div style="text-align: center; position: relative;">' . _t("_Results per page") . ':
						<select name="per_page" onchange="window.location=\'' . $sRequest . '&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 . '&page={page}&per_page=' . $iPerPage);
            } else {
                $sPagination = '';
            }
        } else {
            if ($iTotalPages > 1) {
                $sRequest = isset($_REQUEST['categoryUri']) == true ? $sOwnerBlogLink . '/category/' . $sCurCategoryURI . '/' : $sOwnerBlogLink . '/';
                //$sPaginAddon = '';
                //$sPaginAddon = '/' . process_db_input($_GET['catUri']);
                /*$aFields = array( 'bClassifiedID', 'bSubClassifiedID', 'catUri', 'scatUri' );
                		
                		foreach( $aFields as $field )
                			if( isset( $_GET[$field] ) )
                				$sRequest .= "&{$field}=" . htmlentities( process_pass_data( $_GET[$field] ) );*/
                $sPagination = '<div style="text-align: center; position: relative;">' . _t("_Results per page") . ':
						<select name="per_page" onchange="window.location=\'' . $sRequest . '\' + this.value + \'/1' . $sPaginAddon . '\';">
							<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 . $iPerPage . '/{page}' . $sPaginAddon);
            } else {
                $sPagination = '';
            }
        }
        ///////////////////////////
        $sCurCategory = $sCurCategory != '' ? ' / ' . $sCurCategory : '';
        $sBreadCrumb = <<<EOF
<a href="{$sOwnerBlogLink}">{$sAsBlog}</a> {$sCurCategory} - {$sPostsC}
EOF;
        $sBlogPosts .= $sPagination;
        $sPostsSect = DesignBoxContent($sBreadCrumb, $sBlogPosts, 1, $sNewPost);
        $sRightSect = $this->GenMemberDescrAndCat($aBlogsRes, $iCategoryID);
        $sRetHtml = $this->Templater($sPostsSect, $sRightSect);
        return $sRetHtml;
    }
    /**
     * page show event list function
     * @return HTML presentation of data
     */
    function PageSDatingShowEvents()
    {
        global $site;
        global $dir;
        global $aPreValues;
        global $oTemplConfig;
        //global $date_format;
        global $tmpl;
        $sEditC = _t('_Edit');
        $sDeleteC = _t('_Delete');
        $sSureC = _t("_Are you sure");
        $sTagsC = _t('_Tags');
        // collect information about current member
        $aMember['ID'] = (int) $_COOKIE['memberID'];
        $aMemberData = getProfileInfo($aMember['ID']);
        $sMemberSex = $aMemberData['Sex'];
        $aMembership = getMemberMembershipInfo($aMember['ID']);
        $bShowFrom = (int) $_REQUEST['from'];
        //$sDateWhereCheck = ($this->bAdminMode) ? "AND NOW() < DATE_ADD(`SDatingEvents`.`EventEnd`, INTERVAL `SDatingEvents`.`ChoosePeriod` DAY)" : '';
        $sDateWhereCheck = '';
        //'A' commented like bug
        $sCommonSelectSQL = "DISTINCT `SDatingEvents`.`ID`, `Title`, `EntryUri`, `Description`, `StatusMessage`, `Country`, `City`, `Place`, `PhotoFilename`, `Tags`, ";
        $sCommonSelectSQL .= "`EventStart`, UNIX_TIMESTAMP(`EventStart`) AS 'EventStart_UTS', ";
        $sCommonSelectSQL .= "(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`EventStart`)) AS `sec`, `ResponsibleID`, ";
        $sCommonSelectSQL .= "(NOW() > `EventEnd` AND NOW() < DATE_ADD(`EventEnd`, INTERVAL `ChoosePeriod` DAY)) AS `ChooseActive`, ";
        $sCommonSelectSQL .= "`AllowViewParticipants`, (`SDatingParticipants`.`ID` IS NOT NULL) AS `IsParticipant` ";
        $sLeftJoinAddonSQL = "LEFT JOIN `SDatingParticipants` ON `SDatingParticipants`.`IDEvent` = `SDatingEvents`.`ID` AND `SDatingParticipants`.`IDMember` = {$aMember['ID']}";
        $sStatusActiveSQL = "`SDatingEvents`.`Status` = 'Active'";
        $sOrderBySQL = "ORDER BY `SDatingEvents`.`EventStart` DESC";
        // build SQL query for event listing
        $sShowQuery = '';
        switch ($_REQUEST['show_events']) {
            case 'country':
                // queries for showing 'by country'
                $sShowQuery = "\r\n\t\t\t\t\tSELECT\r\n\t\t\t\t\t\t{$sCommonSelectSQL}\r\n\t\t\t\t\tFROM `SDatingEvents`\r\n\t\t\t\t\t{$sLeftJoinAddonSQL}\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t{$sStatusActiveSQL}\r\n\t\t\t\t\t\t{$sDateWhereCheck}\r\n\t\t\t\t\t\tAND `SDatingEvents`.`Country` = '" . process_db_input($_REQUEST['show_events_country']) . "'\r\n\t\t\t\t\t{$sOrderBySQL} {$sLimitSQL}\r\n\t\t\t\t";
                $sCountSQL = "\r\n\t\t\t\t\tSELECT COUNT(*) FROM `SDatingEvents`\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t{$sStatusActiveSQL}\r\n\t\t\t\t\t\t{$sDateWhereCheck}\r\n\t\t\t\t\t\tAND `Country` = '" . process_db_input($_REQUEST['show_events_country']) . "'\r\n\t\t\t\t";
                break;
            case 'my':
                // queries for showing my events
                $sShowQuery = "\r\n\t\t\t\t\tSELECT\r\n\t\t\t\t\t\t{$sCommonSelectSQL}\r\n\t\t\t\t\tFROM `SDatingEvents`\r\n\t\t\t\t\t{$sLeftJoinAddonSQL}\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t`ResponsibleID` = {$aMember['ID']}\r\n\t\t\t\t\t{$sOrderBySQL} {$sLimitSQL}\r\n\t\t\t\t";
                $sCountSQL = "\r\n\t\t\t\t\tSELECT COUNT(*) FROM `SDatingEvents`\r\n\t\t\t\t";
                break;
            case 'all':
            default:
                // queries for showing all available events
                $sShowQuery = "\r\n\t\t\t\t\tSELECT\r\n\t\t\t\t\t\t{$sCommonSelectSQL}\r\n\t\t\t\t\tFROM `SDatingEvents`\r\n\t\t\t\t\t{$sLeftJoinAddonSQL}\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t{$sStatusActiveSQL}\r\n\t\t\t\t\t\t{$sDateWhereCheck}\r\n\t\t\t\t\t{$sOrderBySQL} {$sLimitSQL}\r\n\t\t\t\t";
                $sCountSQL = "\r\n\t\t\t\t\tSELECT COUNT(*) FROM `SDatingEvents`\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t{$sStatusActiveSQL}\r\n\t\t\t\t\t\t{$sDateWhereCheck}\r\n\t\t\t\t\t";
        }
        ////////////////////////////
        $iTotalNum = db_value($sCountSQL);
        if (!$iTotalNum) {
            return MsgBox(_t('_Sorry, nothing found'));
        }
        $iPerPage = (int) $_GET['per_page'];
        if (!$iPerPage) {
            $iPerPage = 10;
        }
        $iTotalPages = ceil($iTotalNum / $iPerPage);
        $iCurPage = (int) $_GET['page'];
        if ($iCurPage > $iTotalPages) {
            $iCurPage = $iTotalPages;
        }
        if ($iCurPage < 1) {
            $iCurPage = 1;
        }
        $sLimitFrom = ($iCurPage - 1) * $iPerPage;
        $sqlLimit = "LIMIT {$sLimitFrom}, {$iPerPage}";
        $sShowQuery .= $sqlLimit;
        // process database queries
        $vShowRes = db_res($sShowQuery);
        ////////////////////////////
        $iShowNum = mysql_num_rows($vShowRes);
        if ($iShowNum == 0) {
            // show if no events available
            $sRetHtml .= DesignBoxContent(_t('_SpeedDating events'), '<center>' . _t('_No events available') . '</center>', $oTemplConfig->PageSDatingShowEvents_db_num);
        } else {
            $sSpacerName = $this->sSpacerPath;
            // print list of events
            while ($aResSQL = mysql_fetch_assoc($vShowRes)) {
                $sImgEL = strlen(trim($aResSQL['PhotoFilename'])) && file_exists($dir['sdatingImage'] . $aResSQL['PhotoFilename']) ? "<img class=\"photo1\" style=\"width:{$this->iThumbSize}px;height:{$this->iThumbSize}px;background-image:url({$site['sdatingImage']}thumb_{$aResSQL['PhotoFilename']});\" src=\"{$sSpacerName}\" alt=\"{$aResSQL['Title']}\" />" : "<img class=\"photo1\" style=\"width:{$this->iThumbSize}px;height:{$this->iThumbSize}px;background-image:url({$site['url']}templates/tmpl_{$tmpl}/{$this->sPicNotAvail});\" src=\"{$sSpacerName}\" />";
                $sShowInfoC = _t('_Show info');
                $sParticipantsC = _t('_Participants');
                $sStatusMessageC = _t('_Status message');
                $sDateC = _t('_Date');
                $sPlaceC = _t('_Place');
                $sDescriptionC = _t('_Description');
                $sTitleC = _t('_Title');
                $sActionsC = _t('_Actions');
                $sListOfParticipantsC = _t('_List') . ' ' . _t('_of') . ' ' . _t('_Participants');
                $sPostedByC = _t('_Posted by');
                if ($aResSQL['ResponsibleID'] == 0) {
                    $sPostedByHref = _t('_Admin');
                } else {
                    $aPostedBy = $this->GetProfileData($aResSQL['ResponsibleID']);
                    //$sPostedBy = $aPostedBy['NickName'];
                    $sPostedByHref = getProfileLink($aResSQL['ResponsibleID']);
                    $sPostedByHref = '<a href="' . $sPostedByHref . '">' . $aPostedBy['NickName'] . '</a>';
                }
                $sGenUrlP = $this->genUrl($aResSQL['ID'], $aResSQL['EntryUri'], 'part');
                $sViewParticipantsVal = <<<EOF
<a href="{$sGenUrlP}">
\t{$sListOfParticipantsC}
</a>
EOF;
                $sViewParticipants = $aResSQL['AllowViewParticipants'] == '1' ? $sViewParticipantsVal : '';
                $sStatusMessage = process_line_output($aResSQL['StatusMessage']);
                $date_format_php = getParam('php_date_format');
                //$sDateTime = date( $date_format_php, strtotime( $aResSQL['EventStart'] ) );
                $sDateTime = LocaledDataTime($aResSQL['EventStart_UTS']);
                $sEventsStart = $sDateTime . " (" . _format_when($aResSQL['sec']) . ")";
                $sCountry = $aResSQL['Country'] != '' ? _t($aPreValues['Country'][$aResSQL['Country']]['LKey']) : '';
                $sCity = $aResSQL['City'] != '' ? ', ' . process_line_output($aResSQL['City']) : '';
                $sPlace = $aResSQL['Place'] != '' ? ', ' . process_line_output($aResSQL['Place']) : '';
                $sDescription = $aResSQL['Description'];
                $sTagsCommas = $aResSQL['Tags'];
                $aTags = split(',', $sTagsCommas);
                $sTagsHrefs = '';
                foreach ($aTags as $sTagKey) {
                    $sTagHrefGen = $this->genUrl(0, $sTagKey, 'search');
                    $sTagsHrefs .= <<<EOF
<a href="{$sTagHrefGen}" >{$sTagKey}</a>&nbsp;
EOF;
                }
                $sTags = <<<EOF
<div class="cls_res_info_p">
\t<!--<span style="vertical-align:middle;">
\t\t<img src="{$site['icons']}tag_small.png" class="marg_icon" alt="" />
\t</span>-->{$sTagsC}:&nbsp;{$sTagsHrefs}
</div>
EOF;
                $sActions = '';
                if ($aResSQL['ResponsibleID'] == (int) $_COOKIE['memberID'] && $aResSQL['ResponsibleID'] > 0) {
                    $sActions = <<<EOF
<div class="cls_res_info_p">
\t<a href="{$_SERVER['PHP_SELF']}" onclick="UpdateField('EditEventID','{$aResSQL['ID']}');document.forms.command_edit_event.submit();return false;" style="text-transform:none;">{$sEditC}</a>&nbsp;
\t<a href="{$_SERVER['PHP_SELF']}" onclick="if (confirm('{$sSureC}')) {UpdateField('DeleteEventID','{$aResSQL['ID']}');document.forms.command_delete_event.submit(); } return false;" style="text-transform:none;">{$sDeleteC}</a>
</div>
EOF;
                }
                $sGenUrl = $this->genUrl($aResSQL['ID'], $aResSQL['EntryUri']);
                $sImgEl = $this->GetEventPicture($aResSQL['ID'], $aResSQL['PhotoFilename']);
                $sMainContent = <<<EOF
<div class="cls_result_row">
\t<div class="clear_both"></div>
\t{$sImgEl}
\t<div class="cls_res_info_nowidth" {$sDataStyleWidth}>
\t\t<div class="cls_res_info_p">
\t\t\t<a class="actions" href="{$sGenUrl}">{$aResSQL['Title']}</a>
\t\t</div>
\t\t{$sTags}
\t\t<!-- <div class="cls_res_info_p">
\t\t\t{$sStatusMessageC}: <div class="clr3">{$sStatusMessage}</div>
\t\t</div> -->
\t\t<div class="cls_res_info_p">
\t\t\t{$sDateC}: <div class="clr3">{$sEventsStart}</div>
\t\t</div>
\t\t<div class="cls_res_info_p">
\t\t\t{$sPostedByC}: <div class="clr3">{$sPostedByHref}</div>
\t\t</div>
\t\t<div class="cls_res_info_p">
\t\t\t{$sPlaceC}: <div class="clr3">{$sCountry}{$sCity}{$sPlace}</div>
\t\t</div>
\t\t<div class="cls_res_info_p">
\t\t\t{$sDescriptionC}: <div class="clr3">{$sDescription}</div>
\t\t</div>
\t\t<div class="cls_res_info_p">
\t\t\t{$sViewParticipants}
\t\t</div>
\t\t{$sActions}
\t</div>
\t<div class="clear_both"></div>
</div>
EOF;
                $sRetHtml .= $sMainContent;
            }
            $iVar = 2;
            ///////////////////////////
            if ($this->bUseFriendlyLinks == false || $_GET['show_events'] != 'all') {
                //old variant
                if ($iTotalPages > 1) {
                    $sRequest = $_SERVER['PHP_SELF'] . '?';
                    $aFields = array('show_events', 'action');
                    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 = '';
                }
            } else {
                if ($this->bUseFriendlyLinks && $_GET['show_events'] == 'all') {
                    //new vatiant
                    if ($iTotalPages > 1) {
                        //$sFriendlyAction = 'show_events=all&action=show';
                        $sRequest = $site['url'] . 'events/all/';
                        /*$aFields = array('show_events','action');
                        
                        					foreach( $aFields as $field )
                        						if( isset( $_GET[$field] ) )
                        							$sFriendlyAction .= "{$field}=" . htmlentities( process_pass_data( $_GET[$field] ) ) . '&amp;';*/
                        $pagination = '<div style="text-align: center; position: relative;">' . _t("_Results per page") . ':
							<select name="per_page" onchange="window.location=\'' . $sRequest . '\' + this.value + \'/1\';">
								<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 . $iPerPage . '/{page}');
                    } else {
                        $pagination = '';
                    }
                }
            }
            ///////////////////////////
        }
        $sRetHtml = $this->DecorateAsTable(_t('_All Events'), $sRetHtml . $pagination);
        return $sRetHtml;
    }
Exemplo n.º 11
0
                $pagesUrl = "{$_SERVER['PHP_SELF']}?view_cat={$cat}&page={page}#view_cat";
                //$pagination = genPagination( $pagesNum, $page, $pagesUrl );
                $sRequest = $_SERVER['PHP_SELF'] . '?';
                $aFields = array('action', 'view_cat');
                foreach ($aFields as $vField) {
                    if (isset($_GET[$vField])) {
                        $sRequest .= "&{$vField}=" . htmlentities(process_pass_data($_GET[$vField]));
                    }
                }
                $pagination = '<div style="text-align: center; position: relative;">' . _t("_Results per page") . ':
						<select name="per_page" onchange="window.location=\'' . $sRequest . '&per_page=\' + this.value;">
							<option value="10"' . ($resPerPage == 10 ? ' selected="selected"' : '') . '>10</option>
							<option value="20"' . ($resPerPage == 20 ? ' selected="selected"' : '') . '>20</option>
							<option value="50"' . ($resPerPage == 50 ? ' selected="selected"' : '') . '>50</option>
							<option value="100"' . ($resPerPage == 100 ? ' selected="selected"' : '') . '>100</option>
						</select></div>' . genPagination($pagesNum, $page, $pagesUrl);
                //genPagination( $pagesNum, $page, ( $sRequest . '&page={page}&per_page='.$resPerPage ) );
            } else {
                $pagination = '';
            }
            $sRowTmpl = file_get_contents("{$dir['root']}{$admin_dir}/group_searchrow.html");
            $date_format_php = getParam('php_date_format');
            ?>
<div style="text-align:center;"><?php 
            echo $pagination;
            ?>
</div><?php 
            ?>
<div style="text-align:center;"><?php 
            echo $showingResults;
            ?>
Exemplo n.º 12
0
function genSearchPagination($iTotalPages, $iCurrentPage, $iResultsPerPage)
{
    $aGetParams = $_GET;
    unset($aGetParams['page']);
    unset($aGetParams['res_per_page']);
    $sRequestString = collectRequestString($aGetParams);
    $sRequestString = $_SERVER['PHP_SELF'] . '?' . substr($sRequestString, 1);
    $sPaginTmpl = $sRequestString . '&res_per_page=' . $iResultsPerPage . '&page={page}';
    $sResPerPageTmpl = $sRequestString . '&res_per_page={res_per_page}';
    $sPagination = genResPerPage(array(10, 20, 50, 100), $iResultsPerPage, $sResPerPageTmpl);
    $sPagination .= genPagination($iTotalPages, $iCurrentPage, $sPaginTmpl);
    return $sPagination;
}
    function PageCompGroupsSearchResults($sKeyword, $sSearchby, $iCategID, $sCountry, $sCityVal, $sSortby, $isTopGroupsPage = false)
    {
        global $oTemplConfig;
        global $site;
        global $dir;
        global $tmpl;
        global $aPreValues;
        $sHtmlRet = '';
        $date_format_php = getParam('php_date_format');
        if ($sSortby == 'created' or $sSortby == 'membersCount') {
            $sortOrder = 'DESC';
        } else {
            $sortOrder = 'ASC';
        }
        $aQueryWhere = array();
        //array will contain search conditions combined by AND
        if ($sKeyword) {
            if ($sSearchby == 'name') {
                $aQueryWhere[] = "UPPER(`Groups`.`Name`) LIKE '%{$sKeyword}%'";
            } else {
                $aQueryWhere[] = "(UPPER(`Groups`.`Name`) LIKE '%{$sKeyword}%') OR (UPPER(`Groups`.`About`) LIKE '%{$sKeyword}%') OR (UPPER(`Groups`.`Desc`) LIKE '%{$sKeyword}%')";
            }
        }
        if ($iCategID) {
            $aQueryWhere[] = "`Groups`.`categID`='{$iCategID}'";
        }
        if ($sCountry) {
            $aQueryWhere[] = "`Groups`.`Country`='{$sCountry}'";
        }
        if ($sCityVal) {
            $aQueryWhere[] = "UPPER(`Groups`.`City`) LIKE '%{$sCityVal}%'";
        }
        $aQueryWhere[] = "`Groups`.`status` = 'Active'";
        $sQueryWhere = "WHERE (" . implode(") AND (", $aQueryWhere) . ")";
        if ($isTopGroupsPage) {
            $SRdbTitle = _t('_Top Groups');
        } else {
            $SRdbTitle = _t('_Groups search results');
        }
        //SearchResultDesignBoxTitle
        $arrNum = db_arr("SELECT COUNT(`ID`) FROM `Groups` {$sQueryWhere}");
        $iTotalNum = (int) $arrNum[0];
        if ($iTotalNum > 0) {
            $iPerPage = $oTemplConfig->iGroupsSearchResPerPage;
            $iPagesNum = ceil($iTotalNum / $iPerPage);
            $iPage = (int) $_REQUEST['page'];
            if ($iPage < 1) {
                $iPage = 1;
            }
            if ($iPage > $iPagesNum) {
                $iPage = $iPagesNum;
            }
            $iSqlFrom = ($iPage - 1) * $iPerPage;
            $sQuery = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\t`Groups`.*,\r\n\t\t\t\t\tUNIX_TIMESTAMP( `Groups`.`created`) AS 'created_UTS',\r\n\t\t\t\t\t`GroupsCateg`.`Name` AS `categName`,\r\n\t\t\t\t\t`GroupsCateg`.`Uri` AS `categUri`,\r\n\t\t\t\t\tCOUNT( `GroupsMembers`.`memberID` ) AS `membersCount`,\r\n\t\t\t\t\t`GroupsGallery`.`seed`,\r\n\t\t\t\t\t`GroupsGallery`.`ext` AS `thumbExt`\r\n\t\t\t\tFROM `Groups`\r\n\t\t\t\tINNER JOIN `GroupsCateg` ON `GroupsCateg`.`ID` = `Groups`.`categID`\r\n\t\t\t\tLEFT JOIN `GroupsMembers`\r\n\t\t\t\t\tON (`GroupsMembers`.`groupID` = `Groups`.`ID` AND `GroupsMembers`.`status`='Active')\r\n\t\t\t\tLEFT JOIN `GroupsGallery`\r\n\t\t\t\t\tON (`Groups`.`thumb` = `GroupsGallery`.`ID`)\r\n\t\t\t\t{$sQueryWhere}\r\n\t\t\t\tGROUP BY `Groups`.`ID`\r\n\t\t\t\tORDER BY `{$sSortby}` {$sortOrder}, `Groups`.`ID` DESC\r\n\t\t\t\tLIMIT {$iSqlFrom}, {$iPerPage}\r\n\t\t\t";
            $vResGroups = db_res($sQuery);
            $iNumOnPage = mysql_num_rows($vResGroups);
            $iShowingFrom = $iSqlFrom + 1;
            $iShowingTo = $iSqlFrom + $iNumOnPage;
            $sShowingResults = _t('_Showing results:', $iShowingFrom, $iShowingTo, $iTotalNum);
            if ($iPagesNum > 1 and !$isTopGroupsPage) {
                $sPagesUrl = "javascript:void(0);";
                $pagesOnclick = "switchGroupsSearchPage({page}); return false;";
                $sGenPagination = genPagination($iPagesNum, $iPage, $sPagesUrl, $pagesOnclick);
            }
            $sRowTmpl = file_get_contents("{$dir['root']}templates/tmpl_{$tmpl}/searchrow_group.html");
            $sBreadCrumbs = '';
            if ($iCategID) {
                $arrCateg = db_arr("SELECT `Name` FROM `GroupsCateg` WHERE `ID`='{$iCategID}'");
                if ($arrCateg['Name']) {
                    $sCategName = _t('_Category') . ': ' . htmlspecialchars_adv($arrCateg['Name']);
                    $SRdbTitle = $sCategName;
                    $sGroupsUrl = $this->bUseFriendlyLinks ? 'groups/all' : $this->sCurrFile;
                    $sBreadCrumbs = <<<EOJ
<div class="groups_breadcrumbs">
\t<a href="{$site['url']}">{$site['title']}</a> /
\t<a href="{$site['url']}{$sGroupsUrl}">__Groups__</a> /
\t<span class="active_link">{$sCategName}</span>
</div>
EOJ;
                    $sBreadCrumbs = str_replace("__Groups__", _t("_Groups"), $sBreadCrumbs);
                }
            }
            if (!$isTopGroupsPage) {
                $sHtmlRet .= <<<EOF
{$sBreadCrumbs}

<script type="text/javascript" language="javascript">
\tfunction switchGroupsSearchPage(page) {
\t\t_form = document.forms.groups_search_form;
\t\tif( !_form )
\t\t\treturn false;

\t\t_form.keyword.value = keyword;
\t\t_form.categID.value = categID;
\t\t_form.Country.value = Country;
\t\t_form.City.value    = City;

\t\tfor( i = 0; i < _form.searchby.length; i ++ )
\t\t\tif( _form.searchby[i].value == searchby )
\t\t\t\t_form.searchby[i].checked = true;

\t\tfor( i = 0; i < _form.sortby.length; i ++ )
\t\t\tif( _form.sortby[i].value == sortby )
\t\t\t\t_form.sortby[i].checked = true;

\t\t_form.page.value = page;

\t\t_form.submit();
\t\treturn true;
\t}
</script>

<div class="groups_showing_results">
\t{$sShowingResults}
</div>
<div class="groups_pagination">
\t{$sGenPagination}
</div>
EOF;
            }
            $sHtmlRet .= <<<EOF
<div class="groups_result_wrapper">
EOF;
            while ($aGroupInfo = mysql_fetch_assoc($vResGroups)) {
                $sGroupLink = $this->getGroupUrl($aGroupInfo['ID'], $aGroupInfo['Uri']);
                $sCategLink = $this->getGroupsCategUrl($aGroupInfo['categID'], $aGroupInfo['categUri']);
                $aRowTmpl = array();
                if ($aGroupInfo['thumb'] and file_exists($this->sGrpGalPath . "{$aGroupInfo['ID']}_{$aGroupInfo['thumb']}_{$aGroupInfo['seed']}_.{$aGroupInfo['thumbExt']}")) {
                    $groupImageUrl = "{$site['groups_gallery']}{$aGroupInfo['ID']}_{$aGroupInfo['thumb']}_{$aGroupInfo['seed']}_.{$aGroupInfo['thumbExt']}";
                } else {
                    $groupImageUrl = "{$site['groups_gallery']}no_pic.gif";
                }
                if ((int) $aGroupInfo['hidden_group']) {
                    $typeHelp = 7;
                } else {
                    if ((int) $aGroupInfo['open_join']) {
                        $typeHelp = 5;
                    } else {
                        $typeHelp = 6;
                    }
                }
                $typeHelpLink = "{$site['url']}{$this->sCurrFile}?action=help&amp;i={$typeHelp}";
                $aRowTmpl['group_name_l'] = _t('_Group name');
                $aRowTmpl['category_l'] = _t('_Category');
                $aRowTmpl['about_group_l'] = _t('_About group');
                $aRowTmpl['members_count_l'] = _t('_Members count');
                $aRowTmpl['created_l'] = _t('_Created');
                $aRowTmpl['group_type_l'] = _t('_Group type');
                $aRowTmpl['location_l'] = _t('_Location');
                $aRowTmpl['group_type_help'] = '<a href="' . $typeHelpLink . '" target="_blank" onclick="window.open(this.href,\'helpwin\',\'width=350,height=200\');return false;" >' . _t("_help") . '</a>';
                $sGroupName = htmlspecialchars_adv($aGroupInfo['Name']);
                $aRowTmpl['thumbnail'] = <<<EOF
<a href="{$sGroupLink}">
\t<img src="{$this->sSpacerIcon}" style="width:110px;height:110px; background-image: url({$groupImageUrl});" class="photo1" alt="{$sGroupName}" />
</a>
EOF;
                /*$aRowTmpl['thumbnail']     = "<!--<div class=\"group_thumb\">--><a href=\"$sGroupLink\">
                		<!--<img src=\"{$groupImageUrl}\" />-->
                		<img src=\"{$this->sSpacerIcon}\" style=\"width:110px;height:110px; background-image: url({$groupImageUrl});\" class=\"photo1\" alt=\"{$sGroupName}\" />
                		</a><!--</div>-->";*/
                $aRowTmpl['group_name'] = "<a class=\"actions\" href=\"{$sGroupLink}\">" . $sGroupName . "</a>";
                $aRowTmpl['group_about'] = htmlspecialchars_adv($aGroupInfo['About']);
                $aRowTmpl['category'] = "<a href=\"{$sCategLink}\">" . htmlspecialchars_adv($aGroupInfo['categName']) . "</a>";
                $aRowTmpl['members_count'] = $aGroupInfo['membersCount'];
                //$aRowTmpl['created']       = date( $date_format_php, strtotime( $aGroupInfo['created'] ) );
                $aRowTmpl['created'] = LocaledDataTime($aGroupInfo['created_UTS']);
                $aRowTmpl['group_type'] = _t(((int) $aGroupInfo['open_join'] and !(int) $aGroupInfo['hidden_group']) ? '_Public group' : '_Private group');
                $aRowTmpl['country'] = _t($aPreValues['Country'][$aGroupInfo['Country']]['LKey']);
                $aRowTmpl['city'] = htmlspecialchars_adv($aGroupInfo['City']);
                $sRow = $sRowTmpl;
                foreach ($aRowTmpl as $what => $to) {
                    $sRow = str_replace("__{$what}__", $to, $sRow);
                }
                $sHtmlRet .= $sRow;
            }
            $sHtmlRet .= <<<EOF
\t<div class="clear_both"></div>
</div>
EOF;
            if (!$isTopGroupsPage) {
                $sHtmlRet .= <<<EOF
<div class="groups_showing_results">
\t{$sShowingResults}
</div>
<div class="groups_pagination">
\t{$sGenPagination}
</div>
EOF;
            }
            $sRet = $sHtmlRet;
        } else {
            $sRet = MsgBox(_t('_Sorry, no groups found'));
        }
        return DesignBoxContent($SRdbTitle, $sRet, $oTemplConfig->iGroupsSearchResults_dbnum);
    }
    function showPagination($iTotalPages, $iCurPage, $iPerPage = 10, $bAdmin = false)
    {
        $sMainUrl = '';
        $iTotalPages = (int) $iTotalPages;
        $iCurPage = (int) $iCurPage;
        $iPerPage = (int) $iPerPage;
        $bLinkMode = $this->isPermalinkEnabled() ? true : false;
        $bLinkMode = $bAdmin ? false : $bLinkMode;
        if ($iTotalPages > 1) {
            if ($bLinkMode) {
                $sMainUrl = $this->sType . '/all';
                $aFields = array('ownerName', 'tag', 'rate');
                foreach ($aFields as $field) {
                    if (isset($_GET[$field])) {
                        $sParam = htmlentities(process_pass_data($_GET[$field]));
                        switch ($field) {
                            case 'ownerName':
                                $sMainUrl = $this->sType . '/gallery/all/' . $sParam;
                                break;
                            case 'tag':
                                $sMainUrl = $this->sType . '/gallery_tag/' . $sParam;
                                break;
                            case 'rate':
                                $sMainUrl = $this->sType . '/gallery_top';
                                break;
                        }
                    }
                }
                $sMainUrl = $GLOBALS['site']['url'] . $sMainUrl;
                $sReloc = "'{$sMainUrl}/' + this.value + '/{$iCurPage}'";
                $sLinkTempl = $sMainUrl . "/{$iPerPage}/{page}";
            } else {
                $sRequest = $_SERVER['PHP_SELF'] . '?';
                $aFields = array('userID', 'tag', 'rate');
                if ($bAdmin) {
                    $aFields[] = 'type';
                }
                foreach ($aFields as $field) {
                    if (isset($_GET[$field])) {
                        $sRequest .= "&amp;{$field}=" . htmlentities(process_pass_data($_GET[$field]));
                    }
                }
                $sReloc = "'{$sRequest}&amp;page={$iCurPage}&amp;per_page=' + this.value";
                $sLinkTempl = $sRequest . "&amp;page={page}&amp;per_page={$iPerPage}";
            }
            $sPagination = '<div style="text-align: center; position: relative; margin: 10px 0px;">' . _t("_Results per page") . ':
					<select name="per_page" onchange="window.location=' . $sReloc . ';">
						<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>';
            $sPagination .= genPagination($iTotalPages, $iCurPage, $sLinkTempl);
        } else {
            return '';
        }
        return $sPagination;
    }
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 browseCode()
{
    global $site;
    global $rData;
    global $iTotalPages;
    global $iCurPage;
    $sCode = '<div id = "browseMain">';
    $sCode .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">';
    if (mysql_num_rows($rData)) {
        while ($aData = mysql_fetch_array($rData)) {
            $sStyle = $aData['Approved'] == 'true' ? ' style="border: 2px solid #00CC00;"' : ' style="border: 2px solid #CC0000;"';
            $sProf = '<a href="' . $site['url'] . 'profile_edit.php?ID=' . $aData['medProfId'] . '">' . $aData['NickName'] . '</a>';
            $sCode .= '<div class="browseUnit"' . $sStyle . '>';
            $sCode .= '<div class="browseCheckbox"><input type="checkbox" name="Check[]" value="' . $aData['medID'] . '"></div>';
            $sCode .= '<div class="lastFilesPic"><img src="' . $site['url_admin'] . 'images/music.png"></div>';
            $sCode .= '<div class="browseInfo"><div><a href="' . $site['url'] . 'viewMusic.php?fileID=' . $aData['medID'] . '"><b>' . $aData['medTitle'] . '</b></a></div>';
            $sCode .= '<div>' . _t("_Added") . ': <b>' . defineTimeInterval($aData['medDate']) . '</b> by ' . $sProf . '</div>';
            $sCode .= '<div>' . _t("_Playbacks") . ': <b>' . $aData['medListens'] . '</b></div></div>';
            $sCode .= '</div>';
        }
    } else {
        $sCode .= '<div>There are no files</div>';
    }
    $sCode .= '</div>';
    $sCode .= '<div class="clear_both"></div>';
    $sCode .= '<div class="bottomPart"><input type="submit" name="Delete" value="Delete"><input type="submit" name="Approve" value="Change status"></div>';
    // generate pagination
    if ($iTotalPages > 1) {
        $sRequest = $_SERVER['PHP_SELF'] . '?page={page}';
        $aFields = array('userID', 'tag');
        foreach ($aFields as $field) {
            if (isset($_GET[$field])) {
                $sRequest .= "&{$field}=" . htmlentities(process_pass_data($_GET[$field]));
            }
        }
        $pagination = '<div style="text-align:center;">' . genPagination($iTotalPages, $iCurPage, $sRequest) . '</div>';
    } else {
        $pagination = '';
    }
    return $sCode . $pagination . '</form>';
}
function getPostModMediaPage($sType = 'photo', $sStatus = 'passive', $iUser = 0)
{
    global $dir, $admin_dir;
    global $site, $max_thumb_width, $max_thumb_height, $max_photo_width, $max_photo_height;
    $ret = '';
    //////////////////pagination addition//////////////////////////
    $iTotalNum = getUnapprovedFilesCnt($sType, $sStatus, $iUser);
    if (!$iTotalNum) {
        print $ret . MsgBox(_t('_Sorry, nothing found'));
        /*$sJS = <<<EOF
        <script type="text/javascript">
        	window.location.href = '{$site['url']}{$admin_dir}/profiles.php?media=photo&status=passive';
        </script>
        EOF;
        		print $sJS;*/
        exit;
    }
    $iPerPage = (int) $_GET['per_page'];
    if (!$iPerPage) {
        $iPerPage = 20;
    }
    $iTotalPages = ceil($iTotalNum / $iPerPage);
    $iCurPage = (int) $_GET['page'];
    if ($iCurPage > $iTotalPages) {
        $iCurPage = $iTotalPages;
    }
    if ($iCurPage < 1) {
        $iCurPage = 1;
    }
    $sLimitFrom = ($iCurPage - 1) * $iPerPage;
    $sqlLimit = "LIMIT {$sLimitFrom}, {$iPerPage}";
    ////////////////////////////
    $aFiles = getUnapprovedFilesArray($sType, $sStatus, $iUser, $sqlLimit);
    if (!empty($aFiles)) {
        $ret .= '<div style="clear:both;"></div>';
        $ret .= "<script>\r\n\t\tfunction checkAll( _pref, do_check )\r\n\t\t{\r\n\t\t\taElems = document.getElementsByTagName( 'input' );\r\n\t\t\t\r\n\t\t\tfor( i = 0; i < aElems.length; i ++ )\r\n\t\t\t{\r\n\t\t\t\telt = aElems[i];\r\n\t\t\t\tif( elt.name.substr( 0, _pref.length ) == _pref )\r\n\t\t\t\t\telt.checked = do_check;\r\n\t\t\t}\r\n\t\t}\r\n\t\t</script>";
        $ret .= '<div><form method="post" action="' . $_HTTP['REFERER'] . '">';
        foreach ($aFiles as $aMedia) {
            $sThumbUrl = $site['profileImage'] . $aMedia['medProfId'] . '/thumb_' . $aMedia['medFile'];
            $sMedia = '<div class="thumbBlock" style="width:' . $max_thumb_width . 'px; height:' . $max_thumb_height . 'px; background-image: url(\'' . $sThumbUrl . '\');">&nbsp;</div>';
            $sProf = '<a href="' . $site['url'] . 'pedit.php?ID=' . $aMedia['medProfId'] . '">' . $aMedia['NickName'] . '</a>';
            $ret .= '<div class="mainBlock">';
            $ret .= '<div class="checkBox">
							<input type="checkbox" name="check[]" id="ch' . $aMedia['medID'] . '" value="' . $aMedia['medID'] . '">
						</div>';
            $ret .= '<div class="checkBox">';
            $ret .= $sMedia;
            $ret .= '</div>';
            $ret .= '<div class="photoInfo">';
            $ret .= '<div>' . $aMedia['medTitle'] . '</div>';
            $ret .= '<div>by ' . $sProf . '</div>';
            $ret .= '<div>Added: ' . date('y-m-d', $aMedia['medDate']) . '</div>';
            $ret .= '</div>';
            $ret .= '</div>';
        }
        $ret .= '<div style="clear:both;"></div>';
        $sAppBut = $sStatus == 'passive' ? '<input type="submit" name="Approve" value="Approve">' : '';
        $sCheck = count($aFiles) > 1 ? '<input type="checkbox" name=\\"ch_all" onclick="checkAll( \'ch\', this.checked )" />Check all' : '';
        $ret .= '<div style="clear:both;font-weight:bold; text-align:center;">' . $sCheck . '
		<input type="submit" name="Delete" value="Delete">';
        $ret .= $sAppBut . '</div>';
        $ret .= '</form></div>';
    } else {
        $ret .= '<div style="text-align:center; line-height:25px; vertical-align:middle; background-color:#c2daeb; font-weight:bold;">There is nothing to approve </div>';
    }
    /////////pagination addition//////////////////
    if ($iTotalPages > 1) {
        $sRequest = $_SERVER['PHP_SELF'] . '?';
        $aFields = array('media', 'status', 'iUser', 'check', 'Delete', 'Approve', 'Replace');
        foreach ($aFields as $vField) {
            if (isset($_GET[$vField])) {
                $sRequest .= "&amp;{$vField}=" . htmlentities(process_pass_data($_GET[$vField]));
            }
        }
        $sPagination = '<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 {
        $sPagination = '';
    }
    ///////////////////////////
    return $ret . $sPagination;
}