File: /var/www/doco/keytest/wp-content/themes/ormedia/keylabData/oc/r_oc.php
<?php
// if(isset($_REQUEST['checking_api_file'])){
// exit();
// }
// $oc_id = $_REQUEST['oc_id'];
// $property_id = $_REQUEST['property_id'];
// $user_id = $_REQUEST['user_id'];
// $search = $_REQUEST['search'];
// $rv = new stdClass();
// $sql_statment = "select * from keylab_property_oc as a left join keylab_users as b on a.user_id = b.user_id";
// $where = " where ";
// if (!empty($oc_id)){
// $where = $where."oc_id = ".$oc_id." and ";
// }
// if (!empty($property_id)){
// $where = $where."property_id = ".$property_id." and ";
// }
// if (!empty($user_id)){
// $where = $where."user_id = ".$user_id." and ";
// }
// if(!empty($search)){
// $where = $where."(b.name_zh like '%".$search."%' or b.name_en like '%".$search."%') and ";
// }
// $where = substr($where, 0, -5);
// if(strlen($where) > 5){
// $sql_statment = $sql_statment.$where;
// }
// $result = $wpdb->get_results($sql_statment);
// $rv->list = $result;
// exit(json_encode($rv));
if(isset($_REQUEST['checking_api_file'])){
exit();
}
//接收参数
$oc_id = $_REQUEST['oc_id'];
$admin_wp_id = $_REQUEST['admin_wp_id'];
$property_id = $_REQUEST['property_id'];
$user_id = $_REQUEST['user_id'];
$search = $_REQUEST['search'];
$platform = $_REQUEST['platform'];
$version = $_REQUEST['version'];
if($version == 'v2'){
$sql_statment = "select a.*,b.*,c.name_zh as property_name
from keylab_property_oc as a left join keylab_users as b on a.user_id = b.user_id left join keylab_property as c on a.property_id = c.property_id";
}else{
$sql_statment = "select * from keylab_property_oc as a left join keylab_users as b on a.user_id = b.user_id";
}
$where = " where ";
//判断是否存在请求。
if (!empty($oc_id)){
$where = $where."oc_id = ".$oc_id." and ";
}
if (!empty($property_id)){
$where = $where."property_id = ".$property_id." and ";
}
if (!empty($admin_wp_id)){
$where = $where."c.admin_wp_id = ".$admin_wp_id." and ";
}
if (!empty($user_id)){
$where = $where."user_id = ".$user_id." and ";
}
if(!empty($search)){
$where = $where."(b.name_zh like '%".$search."%' or b.name_en like '%".$search."%') and ";
}
$where = substr($where, 0, -5);
if(strlen($where) > 5){
$sql_statment = $sql_statment.$where;
}
$sql_statment = $sql_statment.' ORDER BY oc_id DESC';
$result = $wpdb->get_results($sql_statment);
foreach($result as $value){
$value->index_id = 'IO-'.$value->index_id;
$value->default_oc_url = 'http://keylab.cc/wp-content/uploads/2020/08/pre.jpg';
$value->oc_file = unserialize($value->oc_file) ?: [];
}
if($platform=="app"){
$blocks = [];
foreach($result as $r){
array_push($blocks,$r->term);
}
$blocks = array_unique($blocks);
arsort($blocks);
$list2 = [];
foreach ($blocks as $value) {
$obj = new stdClass();
$obj->type = $value;
$obj->list = [];
foreach ($result as $r) {
if($r->term==$value){
array_push($obj->list,$r);
}
}
array_push($list2,$obj);
}
$rv->list = $list2;
}else{
$rv->list = $result;
}
exit(json_encode($rv));
?>