insert-video.php 1.2 KB
<?php
ignore_user_abort(TRUE);
set_time_limit(0);

define( 'DOING_AJAX', true );
define( 'WP_ADMIN', true );
/** Load WordPress Bootstrap */
require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
/** Load WordPress Administration APIs */
require_once( ABSPATH . 'wp-admin/includes/admin.php' );

global $wpdb;
$res=@file_get_contents('php://input');
if(!$res){
    die();
}
$data=json_decode($res,true);
if(!isset($data['term_id'])||!isset($data['api_key'])||!isset($data['hrefs'])){
    die();
}
if($data['api_key']!=sha1(md5('dst').$data['term_id'])){
    die();
}
$is_exist_term_id=$wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM wp_term_flag  WHERE  term_id = %d", $data['term_id'] ) );
if(!$is_exist_term_id){
    die();
}
if($data['hrefs']){
    $time=date('Y-m-d H:i:s');
    $temp=false;
    foreach ($data['hrefs'] as $vv){
        $temp = $wpdb->query($wpdb->prepare("INSERT INTO wp_term_news (term_id,vurl,adtime,sorts) VALUES (%d,%s,%s,%d)",$data['term_id'],$vv,$time,2));
    }
    if($temp){
        $wpdb->query($wpdb->prepare("UPDATE wp_term_flag SET tflag=2 WHERE term_id = %d",$data['term_id']));
    }
}
die();