function getPostModMediaPage($sType = 'photo', $sStatus = 'passive', $iUser = 0)
{
    global $dir;
    global $site, $max_thumb_width, $max_thumb_height, $max_photo_width, $max_photo_height;
    $ret = '';
    $aFiles = getUnapprovedFilesArray($sType, $sStatus, $iUser);
    $style = '
		float:left;
		margin:5px 11px;
		padding:5px;
		border:1px solid silver;
		text-align:center;

	';
    $style2 = '
		width:' . $max_thumb_width . 'px;
		height:' . $max_thumb_height . 'px;
		background-color:#f1f1f1;
		border:1px solid silver;
	';
    $ret .= '<div style="clear:both;"></div>';
    $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'] . '">';
    foreach ($aFiles as $aMedia) {
        $sThumbFile = $dir['profileImage'] . $aMedia['med_prof_id'] . '/thumb_' . $aMedia['med_file'];
        if (extFileExists($sThumbFile)) {
            $sThumbUrl = $site['profileImage'] . $aMedia['med_prof_id'] . '/thumb_' . $aMedia['med_file'];
            $sMediaUrl = $site['profileImage'] . $aMedia['med_prof_id'] . '/photo_' . $aMedia['med_file'];
            $ret .= '<div style="' . $style . '">';
            $ret .= '<div style="' . $style2 . '">';
            $ret .= '<img src="' . $sThumbUrl . '" onclick="window.open(\'' . $sMediaUrl . '\', \'photo\',\'width=' . ($max_photo_width + 10) . ',height=' . ($max_photo_height + 10) . ',left=100,top=100,copyhistory=no,directories=no,menubar=no,location=no,resizable=yes,scrollbars=yes\');" />';
            $ret .= '</div>';
            $ret .= '<br />';
            $ret .= '<div><input type="checkbox" name="check[]" id="ch' . $aMedia['med_id'] . '" value="' . $aMedia['med_id'] . '"></div>';
            $ret .= '</div>';
        }
    }
    $ret .= '<div style="clear:both;"></div>';
    if (!empty($aFiles)) {
        $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>';
    return $ret;
}
function getPostModMediaPage($sType = 'photo', $sStatus = 'passive', $iUser = 0)
{
    global $dir;
    global $site, $max_thumb_width, $max_thumb_height, $max_photo_width, $max_photo_height;
    $ret = '';
    $aFiles = getUnapprovedFilesArray($sType, $sStatus, $iUser);
    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'] . 'profile_edit.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>';
    }
    return $ret;
}
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;
}