Example #1
0
            } else {
                $errors[] = 'Failed to ' . $action . ' photo! Are you sure this photo exists?!';
            }
            $remove = '&a=' . $action . '&PID=' . $PID;
            break;
        default:
            $errors[] = 'Invalid action. Allowed actions: delete, activate, suspend and unflag!';
    }
}
$query = constructQuery();
$sql = $query['count'];
$rs = $conn->execute($sql);
$total_photos = $rs->fields['total_photos'];
$pagination = new Pagination($query['page_items']);
$limit = $pagination->getLimit($total_photos);
$paging = $pagination->getAdminPagination($remove);
$sql = $query['select'] . " LIMIT " . $limit;
$rs = $conn->execute($sql);
$photos = $rs->getrows();
function constructQuery()
{
    global $smarty;
    $query = array();
    $query_select = "SELECT p.*, s.username, f.*\n                           FROM photos AS p, signup AS s, photo_flags AS f\n                           WHERE p.PID = f.PID AND f.UID = s.UID";
    $query_count = "SELECT COUNT(f.PID) AS total_photos\n                           FROM photos AS p, signup AS s, photo_flags AS f\n                           WHERE p.PID = f.PID AND f.UID = s.UID";
    $query_option = array();
    $option = array('flagger' => '', 'sort' => 'p.PID', 'order' => 'DESC', 'display' => 10);
    if (isset($_POST['search_flags'])) {
        $option['flagger'] = trim($_POST['flagger']);
        $option['sort'] = trim($_POST['sort']);
        $option['order'] = trim($_POST['order']);
Example #2
0
    $action = trim($_GET['a']);
    $id = isset($_GET['CID']) && is_numeric($_GET['CID']) ? (int) $_GET['CID'] : 0;
    if ($id) {
        switch ($action) {
            case 'delete':
                $sql = "DELETE FROM notice_images WHERE image_id = " . $id . " LIMIT 1";
                $conn->execute($sql);
                @unlink($config['BASE_DIR'] . '/images/notice_images/' . $id . '.jpg');
                @unlink($config['BASE_DIR'] . '/images/notice_images/thumbs/' . $id . '.jpg');
                $messages[] = 'Image was successfuly delete!';
                break;
            default:
                $errors[] = 'Invalid action!';
                break;
        }
    } else {
        $errors[] = 'Invalid image id! Are you sure this image exists!?';
    }
}
$sql = "SELECT COUNT(image_id) AS total_images FROM notice_images";
$rs = $conn->execute($sql);
$images_total = $rs->fields['total_images'];
$pagination = new Pagination(20);
$limit = $pagination->getLimit($images_total);
$paging = $pagination->getAdminPagination();
$sql = "SELECT * FROM notice_images ORDER BY addtime DESC LIMIT " . $limit;
$rs = $conn->execute($sql);
$images = $rs->getrows();
$smarty->assign('images', $images);
$smarty->assign('images_total', $images_total);
$smarty->assign('paging', $paging);