数据库查询无法在WordPress模板页面中工作

时间:2018-02-26 19:57:36

标签: php mysql wordpress

WordPress完全陌生,我一直在寻求答案,为什么完全有效的相同代码在WordPress中不起作用。

socks5_login LoginReply;
LoginReply.Version = 5;

if (Str::Compare(UserName, PUCHAR("test")) == 0 && Str::Compare(Password, PUCHAR("test")) == 0)
    LoginReply.Status = 0; /*success*/
else
    LoginReply.Status = 1; /*failure*/

if (Http::SendProxyData(Settings->Sock, PCHAR(&LoginReply), sizeof(LoginReply), Settings->Func) != TRUE)
{
    // close the connection...
    return FALSE;
}

if (LoginReply.Status != 0)
{
    // close the connection...
    return FALSE;
}

/*
The SOCKS request is formed as follows:
    +----+-----+-------+------+----------+----------+
    |VER | CMD |  RSV  | ATYP | DST.ADDR | DST.PORT |
    +----+-----+-------+------+----------+----------+
    | 1  |  1  | X'00' |  1   | Variable |    2     |
    +----+-----+-------+------+----------+----------+
*/

socks5_request Request;

// I'm assuming that SOCKS5_Header is only the 1st 4 bytes of the request...
if (Http::ReadProxyData(Settings->Sock, PCHAR(&Request.SOCKS5_Header), sizeof(socks5_header), Settings->Func) != TRUE)
{
    // close the connection...
    return FALSE;
}

if (Request.SOCKS5_Header.Version != 5) /*SOCKS Version 5*/
{
    // I'm assuming you have something like this defined.
    // Adjust this code as needed. What is important is that
    // you need to send back a Reply code before disconnecting...
    socks5_reply Reply;
    UCHAR dst[6] = {0}; // <-- if socks5_reply doesn't have DST.ADDR/DST.PORT fields of its own...

    Reply.SOCKS5_Header.Version = 5;
    Reply.SOCKS5_Header.Status = 1; /*general SOCKS server failure*/
    Reply.SOCKS5_Header.Reserved = 0;
    Reply.SOCKS5_Header.AddressType = 1;

    Http::SendProxyData(Settings->Sock, PCHAR(&Reply.SOCKS5_Header), sizeof(socks5_header), Settings->Func);
    Http::SendProxyData(Settings->Sock, PCHAR(dst), sizeof(dst), Settings->Func);

    // close the connection...
    return FALSE;
}

if (Request.SOCKS5_Header.Command != 1) /*CONNECT*/
{
    // same as above...
    Reply.SOCKS5_Header.Status = 7; /*Command not supported*/
    ...
    return FALSE;
}

if (Request.SOCKS5_Header.AddressType != 1) /*IPv4*/
{
    // same as above...
    Reply.SOCKS5_Header.Status = 8; /*Address type not supported*/
    ...
    return FALSE;
}

// finish reading DST.ADDR and DST.PORT fields into Request...
// use Request as needed...
// send a Reply accordingly...

在WordPress模板页面中,尝试了这个:

$arr = array();
if (!empty($_POST['keywords'])) {
    $keywords = $db->real_escape_string($_POST['keywords']);
    $sql = "SELECT result_id, end_home_odd, home_name FROM tbl_live WHERE home_name LIKE '%".$keywords."%'";
    $result = $db->query($sql) or die($mysqli->error);
    if ($result->num_rows > 0) {
        while ($obj = $result->fetch_object()) {
            $arr[] = array('id' => $obj->result_id, 'home' => $obj->end_home_odd, 'title' => $obj->home_name);
        }
    }
}
echo json_encode($arr);

我错过了什么,它在WordPress中无法工作?有人能说清楚这个吗?

0 个答案:

没有答案