ok

Mini Shell

Direktori : /home2/selectio/public_html/y1jobportal.in/apps-api/
Upload File :
Current File : /home2/selectio/public_html/y1jobportal.in/apps-api/category.php

<?php 
include_once('config/config.php');
include_once('config/custom-functions.php');
include 'config/send-sms.php';
$fn = new custom_functions();

date_default_timezone_set('Asia/Kolkata');
$today=date('d-m-Y h:m:s A'); 
try{
    error_log('lololo');
    $client_id=0;$client_name='';
 
    $where = '';
    $offset = (isset($_POST['offset']) && !empty(trim($_POST['offset'])) && is_numeric($_POST['offset'])) ? trim($fn->xss_clean($_POST['offset'])) : 0;
    $limit = (isset($_POST['limit']) && !empty(trim($_POST['limit'])) && is_numeric($_POST['limit'])) ? trim($fn->xss_clean($_POST['limit'])) : 10;
    
    $limit=100;
    $sort = (isset($_POST['sort']) && !empty(trim($_POST['sort']))) ? trim($fn->xss_clean($_POST['sort'])) : 'id';
    $order = (isset($_POST['order']) && !empty(trim($_POST['order']))) ? trim($fn->xss_clean($_POST['order'])) : 'DESC';

    
    $date=date('Y-m-d');
    $conditions='';
   
    
    $statement = $pdo->prepare("SELECT COUNT(id) as total FROM `category` where 1=1 and status=1 $conditions");
    $statement->execute();
    $res = $statement->fetchAll(PDO::FETCH_ASSOC);
    
    
    if (isset($_POST['search']) && !empty($_POST['search'])) {
        $search = $fn->xss_clean($_POST['search']);
            $conditions .= " and name like '%" . $search . "%' OR description like '%" . $search . "%'";
    }
    
    if (!empty($res)) {
        foreach ($res as $row)
            $total = $row['total'];
           
 $sql='';           
  
    $sql.="SELECT id,name as category_name,description,image,status FROM category where id!=0 and status=1"; 
    $statement = $pdo->prepare($sql. $conditions . " order by name asc LIMIT " . $offset . ", " . $limit);
    $statement->execute();
    $res = $statement->fetchAll(PDO::FETCH_ASSOC);
    $t=0;
    foreach($res as $rs){
        $res[$t]['image']=$site_url.$rs['image'];
        $t++;
    }
    
        $response['error'] = false;
        $response['message'] = "Category fatched successfully.";
        $response['total'] = $total;
        $response['data'] = $res;
        
    } else {
        $response['error'] = true;
        $response['message'] = "Something went wrong, please try again leter.";
    }
    $pdo = null;
    print_r(json_encode($response));
}catch(Exception $e){
    $response["error"]   = true;
    $response["status_code"]   = '403';
    $response["status"] = 'Forbidden'.$e;
    error_log($e);
        
    $pdo = null;
    print_r(json_encode($response));
    return 0;
}
/*}else{
    $response["error"]   = true;
    $response["status_code"]   = '400';
    $response["status"] = 'Bad Request';
    error_log("Tracking Api: Bad Request");
}
*/

?>

Zerion Mini Shell 1.0