} } $json_verified[$cur_index]["Results"] = pull_values($userid, $table_name); $cur_index = $cur_index + 1; $delete_handle = $db_connection->Prepare("drop table #TempID"); $delete_handle->execute(); } else { foreach ($op_index as &$func_params) { $json_verified[$cur_index] = array(); $json_verified[$cur_index]["Table"] = $table_name; $json_verified[$cur_index]["Operation"] = $op_name; if ($op_name == 'Delete') { $json_verified[$cur_index]["Results"] = delete_values($userid, $func_params, $table_name); } else { if ($op_name == 'Insert' || $op_name == 'Update') { $json_verified[$cur_index]["Results"] = insert_or_update($userid, $op_name, $func_params, $table_name); } } $cur_index = $cur_index + 1; } } } } $json_verified['NumElements'] = $cur_index; $db_connection = null; //Auto sets to true, each operation can fail or succeed on //its own. $json_verified['Verified'] = true; $json_verified['Operation'] = "Sync"; echo json_encode($json_verified); } catch (PDOException $except) {
public function import_posts() { $response = wp_remote_get('http://deep-thoughts.dev/wp-json/wp/v2/posts/'); if (is_wp_error($response)) { return; } $post_data = json_decode(wp_remote_retrieve_body($response)); if (compare_keys()) { insert_or_update($post_data); } wp_die(); }
case "Reset": #Retrieves the json information for resetting a user $username = $http_post["Username"]; $email = $http_post["Email"]; require '../dboperations/reset_user.php'; break; case "Insert": case "Update": $userid = 0; require '/var/www/dbconnection/Sign_jwt.php'; try { $userid = JWTSign::decode_token($http_post["Token"]); $params = json_decode($http_post["Params"], true); $table = $http_post["Table"]; require '/var/www/dboperations/insert_update_values.php'; $return_json = insert_or_update($userid, $operation, $params, $table); $return_json["Operation"] = $operation; echo json_encode($return_json); } catch (Exception $except) { echo "Invalid Token. Try logging out and in again."; } break; case "Delete": $userid = 0; require '/var/www/dbconnection/Sign_jwt.php'; try { $userid = JWTSign::decode_token($http_post["Token"]); $params = json_decode($http_post["Params"], true); $table = $http_post["Table"]; require '/var/www/dboperations/delete_values.php'; $return_json = delete_values($userid, $params, $table);