HEX
Server: Apache/2.4.59 (Debian)
System: Linux keymana 4.19.0-21-cloud-amd64 #1 SMP Debian 4.19.249-2 (2022-06-30) x86_64
User: lijunjie (1003)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wp-content/themes/ormedia/keylabData/ie_statement/u_ie_statement.php
<?php
if (isset($_REQUEST['checking_api_file'])) {
    exit();
}
$a_delete = [];

//��ȡ������ͼƬid
$sql_statment = "select ie_statement_file from keylab_property_ie_statement where ie_statement_id = ".$_POST['ie_statement_id'];
$result = $wpdb->get_results($sql_statment);
if(!empty($result)){
	$a_ie_statement_file = unserialize($result[0]->ie_statement_file);
	$a_new_ie_statement_file = $_REQUEST['ie_statement_file'];

	foreach($a_new_ie_statement_file as $key=>$value){
		update_post_meta($value['uid'], 'in_use', 1);
	}
	foreach($a_ie_statement_file as $key1=>$value1){
		array_push($a_delete,$value1['uid']);
		foreach($a_new_ie_statement_file as $key2=>$value2){
			if($value1['uid'] == $value2['uid']){
				array_pop($a_delete);			}
		}
	}
}

$old_data = $wpdb->get_results("select * from keylab_property_ie_statement where ie_statement_id = ".$_REQUEST['ie_statement_id']);
$new_data = array(
    'property_id' => $_REQUEST['property_id'],
    'ie_statement_date' => $_REQUEST['ie_statement_date'],
	'ie_statement_file' => serialize($_REQUEST['ie_statement_file']),
	'ref'   => $_REQUEST['ref']
);

$status = false;
$status = $wpdb->update("keylab_property_ie_statement", $new_data, array('ie_statement_id' => $_POST['ie_statement_id']));
$sql = $wpdb->last_query;

//ref修改
$statement = "SELECT ie_statement_id, ref FROM keylab_property_ie_statement WHERE ref = ''";
$results = $wpdb->get_results($statement);

foreach($results as $value){
    $wpdb->update("keylab_property_ie_statement",[
        'ref' => '#'.$value->ie_statement_id
    ], [
        'ie_statement_id' => $value->ie_statement_id
    ]);
}

if ($status === false) {
    $rv->status = false;
    $rv->error = $wpdb->last_error;
} else {
//ɾ��������ͼƬ�����ݿ�λ��
if(count($a_delete) !== 0){
	foreach($a_delete as $key=>$value){
		if(!empty(wp_delete_attachment($value))){
			delete_post_meta( $value, 'in_use' );
			$rv->status = true;
    			$rv->wpdb = $wpdb;
		}else{
			$rv->status = false;
    			$rv->error = "update_error";
		}
		
	}
}else{
	$rv->status = true;
    	$rv->wpdb = $wpdb;
}
}

//log
keylab_data_log_by_user2($status, $old_data[0], $new_data, $sql, "keylab_property_ie_statement", $_POST['ie_statement_id']);


exit(json_encode($rv));
?>