$iVal) { switch (true) { case isset($_POST['Delete']): deleteItem((int)$iVal); break; case isset($_POST['Approve']): approveItem((int)$iVal); break; } } } TopCodeAdmin(); ContentBlockHead(""); echo getPostModMediaPage($sType,$sStatus,$iUser); ContentBlockFoot(); BottomCode(); function getPostModMediaPage($sType = 'photo', $sStatus = 'passive', $iUser = 0) { global $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 = << window.location.href = '{$site['url']}{$admin_dir}/profiles.php?media=photo&status=passive'; 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 .= '
'; $ret .= "" ; $ret .= '
'; foreach( $aFiles as $aMedia ) { $sThumbUrl = $site['profileImage'] . $aMedia['medProfId'] . '/thumb_' . $aMedia['medFile']; $sMedia = '
 
'; $sProf = ''.$aMedia['NickName'].''; $ret .= '
'; $ret .= '
'; $ret .= '
'; $ret .= $sMedia; $ret .= '
'; $ret .= '
'; $ret .= '
'.$aMedia['medTitle'].'
'; $ret .= '
by '.$sProf.'
'; $ret .= '
Added: '.date('y-m-d',$aMedia['medDate']).'
'; $ret .= '
'; $ret .= '
'; } $ret .= '
'; $sAppBut = $sStatus == 'passive' ? '' : ''; $sCheck = count($aFiles) > 1 ? 'Check all' : ''; $ret .= '
'.$sCheck.' '; $ret .= $sAppBut.'
'; $ret .= '
'; } else { $ret .= '
There is nothing to approve
'; } /////////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 .= "&{$vField}=" . htmlentities( process_pass_data( $_GET[$vField] ) ); $sPagination = '
'._t("_Results per page").':
' . genPagination( $iTotalPages, $iCurPage, ( $sRequest . '&page={page}&per_page='.$iPerPage ) ); } else $sPagination = ''; /////////////////////////// return $ret.$sPagination; } function getUnapprovedFilesCnt($sType, $sStatus, $iUser) { $ret = ''; $sAdd = "AND `med_status` = '$sStatus'"; $sAdd .= " AND `med_type` = '$sType'"; $sAdd .= $iUser != 0 ? " AND `med_prof_id`='$iUser'" : ""; $sQuery = " SELECT COUNT(`media`.`med_id`) as `Cnt` FROM `media` LEFT JOIN `Profiles` ON `Profiles`.`ID`=`media`.`med_prof_id` WHERE 1 $sAdd ORDER BY `media`.`med_date` "; $res = db_value( $sQuery ); return $res; } function getUnapprovedFilesArray($sType, $sStatus, $iUser, $sqlLimit = '') { $ret = ''; $sAdd = "AND `med_status` = '$sStatus'"; $sAdd .= " AND `med_type` = '$sType'"; $sAdd .= $iUser != 0 ? " AND `med_prof_id`='$iUser'" : ""; $sQuery = " SELECT `media`.`med_id` as `medID`, `media`.`med_prof_id` as `medProfId`, `media`.`med_type` as `medType`, `media`.`med_file` as `medFile`, `media`.`med_title` as `medTitle`, UNIX_TIMESTAMP(`media`.`med_date`) as `medDate`, `Profiles`.`NickName` FROM `media` LEFT JOIN `Profiles` ON `Profiles`.`ID`=`media`.`med_prof_id` WHERE 1 $sAdd ORDER BY `media`.`med_date` {$sqlLimit} "; $res = db_res( $sQuery ); $ret = fill_assoc_array( $res ); return $ret; } function deleteItem( $iMedia ) { global $dir; $aFile = db_arr("SELECT * FROM `media` WHERE `med_id`='$iMedia'"); $sIconFile = $dir['profileImage'] . $aFile['med_prof_id'] . '/icon_' . $aFile['med_file']; $sThumbFile = $dir['profileImage'] . $aFile['med_prof_id'] . '/thumb_' . $aFile['med_file']; $sPhotoFile = $dir['profileImage'] . $aFile['med_prof_id'] . '/photo_' . $aFile['med_file']; $sqlQuery = " DELETE FROM `media` WHERE `med_id` = '$iMedia'; "; $res = db_res( $sqlQuery ); // delete votings require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolVoting.php' ); $oVotingMedia = new BxDolVoting ('media', 0, 0); $oVotingMedia->deleteVotings ($aMedia['med_id']); @unlink( $sIconFile ); @unlink( $sThumbFile ); @unlink( $sPhotoFile ); return $res; } function approveItem( $iMedia ) { $sQuery = " UPDATE `media` SET `med_status` = 'active' WHERE `med_id` = '$iMedia' "; return db_res( $sQuery ); } function approveAllItems() { $sQuery = " UPDATE `media` SET `med_status` = 'active' "; return db_res( $sQuery ); } ?>