$iVal) { switch (true) { case isset($_POST['Delete']): deleteAudio((int)$iVal); break; case isset($_POST['Approve']): approveAudio((int)$iVal); break; } } } $sqlQuery = "SELECT `RayMp3Files`.`ID` as `medID`, `RayMp3Files`.`Title` as `medTitle`, `RayMp3Files`.`Description` as `medDesc`, `RayMp3Files`.`Owner` as `medProfId`, `RayMp3Files`.`Date` as `medDate`, `RayMp3Files`.`Approved`, `Profiles`.`NickName` FROM `RayMp3Files` LEFT JOIN `Profiles` ON `Profiles`.`ID`=`RayMp3Files`.`Owner` "; $sqlWhere = $iUser == 0 ? "WHERE `Owner`<>'0'" : "WHERE `Owner`='$iUser'"; $iTotalNum = db_value( "SELECT COUNT( * ) FROM `RayMp3Files` LEFT JOIN `Profiles` ON `Profiles`.`ID`=`RayMp3Files`.`Owner` $sqlWhere" ); $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 $site, $max_thumb_width, $max_thumb_height, $max_photo_width, $max_photo_height; global $aFiles; global $iTotalPages, $iCurPage; $ret = ''; $ret .= "" ; $ret .= '
'; $iCounter = 1; foreach( $aFiles as $aMedia ) { $sPic = ''; $sMediaLink = "".$aMedia['medTitle'].""; $sProf = ''.$aMedia['NickName'].''; $sStyle = $aMedia['Approved'] == 'true' ? ' style="border: 2px solid #00CC00;"' : ' style="border: 2px solid #CC0000;"' ; $ret .= '
'; $ret .= '
'; $ret .= '
'; $ret .= $sPic; $ret .= '
'; $ret .= '
'; $ret .= '
'; $ret .= $sMediaLink; $ret .= '
'; $ret .= '
by '.$sProf.'
'; $ret .= '
Added: '.defineTimeInterval($aMedia['medDate']).'
'; $ret .= '
'; $ret .= '
'; if( ( $iCounter % 2 ) == 0 ) $ret .= '
'; $iCounter++; } if( !empty( $aFiles ) ) { $sCheck = count($aFiles) > 1 ? 'Check all' : ''; $ret .= '
'.$sCheck.'
'; } else { $ret .= MsgBox( 'Sorry, nothing found' ); } if( $iTotalPages > 1) { $sRequest = $_SERVER['PHP_SELF'] . '?page={page}'; $pagination = '
' . genPagination( $iTotalPages, $iCurPage, $sRequest ) . '
'; } else $pagination = ''; return $ret.$pagination.'
'; } function deleteAudio( $iMedia ) { $sFileName = BX_DIRECTORY_PATH_ROOT . 'ray/modules/mp3/files/'.$iMedia . '.mp3'; $sqlQuery = " DELETE FROM `RayMp3Files` WHERE `ID` = '$iMedia'; "; $res = db_res( $sqlQuery ); @unlink( $sFileName ); return $res; } function approveAudio( $iMedia ) { $sqlQuery = "UPDATE `RayMp3Files` SET `Approved` = IF(`Approved`='true','false','true') WHERE `ID`='$iMedia'"; $res = db_res($sqlQuery); return $res; } ?>