0byt3m1n1
Path:
/
var
/
www
/
listcrawler.app
/
public_html
/
admin
/
[
Home
]
File: lists.php
<?php session_start(); require_once 'config/config.php'; require_once BASE_PATH . '/includes/auth_validate.php'; // Lists class require_once BASE_PATH . '/lib/Lists/Lists.php'; $lists = new Lists(); // Get Input data from query string $order_by = filter_input(INPUT_GET, 'order_by'); $order_dir = filter_input(INPUT_GET, 'order_dir'); $search_str = filter_input(INPUT_GET, 'search_str'); // Per page limit for pagination $pagelimit = 600; // Get current page $page = filter_input(INPUT_GET, 'page'); if (!$page) { $page = 1; } // If filter types are not selected we show latest added data first if (!$order_by) { $order_by = 'id'; } if (!$order_dir) { $order_dir = 'Desc'; } // Get DB instance. i.e instance of MYSQLiDB Library $db = getDbInstance(); $select = array('id', 'list_title', 'list_desc', 'age'); // Start building query according to input parameters // If search string if ($search_str) { $db->where('list_title', '%' . $search_str . '%', 'like'); $db->orwhere('list_desc', '%' . $search_str . '%', 'like'); } // If order direction option selected if ($order_dir) { $db->orderBy($order_by, $order_dir); } // Set pagination limit $db->pageLimit = $pagelimit; // Get result of the query $rows = $db->arraybuilder()->paginate('lists', $page, $select); $total_pages = $db->totalPages; $count = ($page-1)*$pagelimit; ?> <?php include BASE_PATH . '/includes/header.php'; ?> <!-- Main container --> <div id="page-wrapper"> <div class="row"> <div class="col-lg-6"> <h1 class="page-header">Free Ads</h1> </div> <div class="col-lg-6"> <div class="page-action-links text-right"> <a href="add_list.php?operation=create" class="btn btn-success"><i class="glyphicon glyphicon-plus"></i> Add New</a> </div> </div> </div> <?php include BASE_PATH . '/includes/flash_messages.php'; ?> <!-- Filters --> <div class="well text-center filter-form"> <form class="form form-inline" action=""> <label for="input_search">Search</label> <input type="text" class="form-control" id="input_search" name="search_str" value="<?php echo htmlspecialchars($search_str, ENT_QUOTES, 'UTF-8'); ?>"> <label for="input_order">Sort By</label> <select name="order_by" class="form-control"> <?php foreach ($lists->setOrderingValues() as $opt_value => $opt_name): ($order_by === $opt_value) ? $selected = 'selected' : $selected = ''; echo ' <option value="' . $opt_value . '" ' . $selected . '>' . $opt_name . '</option>'; endforeach; ?> </select> <select name="order_dir" class="form-control" id="input_order"> <option value="Asc" <?php if ($order_dir == 'Asc') { echo 'selected'; } ?> >Asc</option> <option value="Desc" <?php if ($order_dir == 'Desc') { echo 'selected'; } ?>>Desc</option> </select> <input type="submit" value="Go" class="btn btn-primary"> </form> </div> <hr> <!-- //Filters --> <!-- Table --> <table class="table table-striped table-bordered table-condensed"> <thead> <tr> <th width="5%" class="text-center">SN. No.</th> <th width="25%">Title</th> <th width="10%">Location</th> <th width="36%">Detail</th> <th width="3%" class="text-center">Age</th> <th width="7%" class="text-center">Actions</th> </tr> </thead> <tbody> <?php foreach ($rows as $row): $count_pics = $db->rawQuery("SELECT count(*) as photo_count from photos where list_id = " . $row['id']); $getListsLocations = $db->rawQueryOne("SELECT `location_id` FROM `lists_locations` WHERE `list_id` = " . $row['id'] . " LIMIT 1 "); $location_name = ''; if ( isset($getListsLocations['location_id']) && $getListsLocations['location_id'] ) { $getLocation = $db->rawQueryOne("SELECT `location_name` FROM `locations` WHERE `id` = " . $getListsLocations['location_id'] . " LIMIT 1 "); $location_name = $getLocation["location_name"]; } ?> <tr> <td class="text-center"><?php $count++; echo $count; ?></td> <td><?php echo htmlspecialchars($row['list_title']); ?> <span class='text-primary'><?php $plural = ''; if (isset($count_pics[0]['photo_count']) && $count_pics[0]['photo_count'] > 0) { $total_pics = $count_pics[0]['photo_count']; if($total_pics > 1){$plural = 's';} echo "(". $total_pics . " pic" . $plural . ")"; } ?></span></td> <td><?php echo $location_name; ?></td> <td><?php echo htmlspecialchars($row['list_desc']); ?></td> <td class="text-center"><?php echo htmlspecialchars($row['age']); ?></td> <td class="text-center"> <a href="edit_list.php?list_id=<?php echo $row['id']; ?>&operation=edit" class="btn btn-primary"><i class="glyphicon glyphicon-edit"></i></a> <a href="#" class="btn btn-danger delete_btn" data-toggle="modal" data-target="#confirm-delete-<?php echo $row['id']; ?>"><i class="glyphicon glyphicon-trash"></i></a> </td> </tr> <!-- Delete Confirmation Modal --> <div class="modal fade" id="confirm-delete-<?php echo $row['id']; ?>" role="dialog"> <div class="modal-dialog"> <form action="delete_list.php" method="POST"> <!-- Modal content --> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Confirm</h4> </div> <div class="modal-body"> <input type="hidden" name="del_id" id="del_id" value="<?php echo $row['id']; ?>"> <p>Are you sure you want to delete this row?</p> </div> <div class="modal-footer"> <button type="submit" class="btn btn-default pull-left">Yes</button> <button type="button" class="btn btn-default" data-dismiss="modal">No</button> </div> </div> </form> </div> </div> <!-- //Delete Confirmation Modal --> <?php endforeach; ?> </tbody> </table> <!-- //Table --> <!-- Pagination --> <div class="text-center"> <?php echo paginationLinks($page, $total_pages, 'lists.php', $count); ?> </div> <!-- //Pagination --> </div> <!-- //Main container --> <?php include BASE_PATH . '/includes/footer.php'; ?>