$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}";
$res = db_res($sqlQuery . $sqlWhere . $sqlLimit);
$aFiles = fill_assoc_array($res);
TopCodeAdmin();
ContentBlockHead("");
echo getPostModMediaPage($iUser);
ContentBlockFoot();
BottomCode();
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>';
}
if (isset($_POST['check']) && is_array($_POST['check'])) {
    foreach ($_POST['check'] as $iKey => $iVal) {
        switch (true) {
            case isset($_POST['Delete']):
                deleteItem((int) $iVal);
                break;
            case isset($_POST['Approve']):
                approveItem((int) $iVal);
                break;
        }
    }
}
TopCodeAdmin();
ContentBlockHead("Profile media");
echo getPostModMediaPage($sType, $sStatus, $iUser);
ContentBlockFoot();
BottomCode();
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;