Are the contents of $_SERVER[‘HTTP_USER_AGENT’] always English characters

I have looked for a list of all $_SERVER[‘HTTP_USER_AGENT’] but could not find one that was robust. I want to know if the contents of the $_SERVER[‘HTTP_USER_AGENT’] are always unicode English characters, so that I can strip high AND low level bytes from the string before I evaluate it.

such as:

$_SERVER['HTTP_USER_AGENT'] = filter_var($_SERVER['HTTP_USER_AGENT'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
          $_SERVER['HTTP_USER_AGENT'] = filter_var($_SERVER['HTTP_USER_AGENT'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);

Do any foreign browsers use local language characters?

Advertisements

Part of an array is no accessed trough foreach

I am creating a bot for telegram using Botman and I have an issue when trying to get a value from an API response.

This is my class that proccesses the response and returns the message to the user, you can see the API adress.

class TaxiService {

protected $client;
const TAXI_ENDPOINT = 'http://35.204.38.8:4000/api/v1/taxis/%s';

/**
 * DogService constructor
 *
 * @return void
 */
public function __construct(){
    $this->client = new Client();
}

public function hireTaxi(){
    try {
        $lon="Hello";
        $endpoint = sprintf(self::TAXI_ENDPOINT, 'Madrid');

        $response = json_decode(
            $this->client->get($endpoint)->getBody()
        );

        foreach($response as $key => $value){
            foreach($value as $key2 => $value2){
                if(is_array($value2)){
                    foreach($value2 as $key3 => $value3){
                        $lon = $value3;
                    }
                }
            }
        }

        return $lon;
    } catch (Exception $e) {
        // If anything goes wrong, we will be sending the user this error message.
        return 'An unexpected error occurred. Please try again later.';
    }
}

}

This is the response I get when calling the API.

[{"state":"free","name":"Opel","location": 
 {"lon":1.399,"lat":38.88},"city":"Madrid"}, 
 {"state":"free","name":"Skoda4","location": 
 {"lon":1.3123,"lat":38.123},"city":"Madrid"}, 
 {"state":"free","name":"Hyundai","location": 
 {"lon":1.2313,"lat":38.41},"city":"Madrid"}]

When I iterate trough the Array given by ´json_decode´ the ´$long´ variable returns ´Hello´, it doesn’t set any value when looping trough the array.

What I want to get is one of the values in the location position of the JSON.

I have tested my function with this site: http://sandbox.onlinephpfunctions.com/ and it gives me a value belonging to the JSON which is what I want but it seems the function is not working in my application.

Yii Framework and Authorize.net Create profile

I have a little problem with authorize.net and yiiframework
I need to create a customer account in authorize.net system with data from my webiste with api.
I’m using this extension https://www.yiiframework.com/extension/authorize-net-cim-yii-extension , but without success.
Share with you what I’m trying to do
ajax return is with code 500
The variable error should return error or success, but actually return nothing
thanks in advance

            $userInfo = [
                'type' => 'Payment',    //Payment OR Withdraw
                'user_id' => 12314,
                'profile_id' => 1231231,
                'email' => $this->data['email_address'],
            ];
            echo Yii::app()->authorizenetCIM->authNetCreateProfile($userInfo);
            // $result = Yii::app()->authorizenetCIM->authNetCreateProfile($userInfo);
            if ($result != "error") {
                $this->msg = t("success");
                return ;
            } else {
                $this->msg=t("error");
                return ;
            }



    public function authNetCreateProfile($data) //$type = Payment OR Withdraw
{
    //build xml to post
    $content =
        "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
        "<createCustomerProfileRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
        $this->getMerchantAuthenticationBlock().
        "<profile>".
        "<merchantCustomerId>" . CHtml::encode(strip_tags($data['type']))."-".CHtml::encode(strip_tags($data['user_id']))."-".CHtml::encode(strip_tags($data['profile_id']))  ."</merchantCustomerId>". // Your own identifier for the customer.
        "<description></description>".
        "<email>" . CHtml::encode(strip_tags($data['email'])) . "</email>".
        "</profile>".
        "</createCustomerProfileRequest>";  

    $response = $this->sendXMLRequest($content);    
    $parsedresponse = $this->parseAPIResponse($response);   

    if ("Ok" == $parsedresponse->messages->resultCode) {
        return htmlspecialchars($parsedresponse->customerProfileId);
    }   

    return "error";
}

[unixODBC][Driver Manager]Can’t open lib ‘/opt/vertica/lib64/libverticaodbc.so’ : file not found

Right now I am trying to connect with vertica using PHP on Ubuntu. And I am getting this error

PHP 7.2.7
Ubuntu 18.04

[unixODBC][Driver Manager]Can't open lib '/opt/vertica/lib64/libverticaodbc.so' : file not found

I already have that file in that route with all permissions.

This is my /etc/odbcinst.ini

[Vertica]
Description = Vertica driver
Driver   = /opt/vertica/lib64/libverticaodbc.so
Driver64 = /opt/vertica/lib64/libverticaodbc.so

This is my /etc/vertica.ini

[Driver]
DriverManagerEncoding=UTF-16
ODBCInstLib = /usr/lib/x86_64-linux-gnu/libodbcinst.so.1
ErrorMessagesPath=/opt/vertica/lib64
LogLevel=4
LogPath=/tmp

I got the libverticaodbc.so file from vertica-client-fips-9.1.0-0.x86_64.rpm

I hope someone can help me

Edit search target of a post grid plugin on wordpress

i have a website called “cinemate.in”.
i installed a plugin called “Post grid” which displays the posts on my website in a grid format based on pre specified categories and custom taxanomies.
Now when i use the native search option of my wordpress theme it does not display the result in the format as the post grid so i am forced to use the search option provided inside the post grid plugin.
The only problem with the search option in the post grid plugin is that i can enable or disable the search option for a specific post grid and that the search of that specific post grid will only look for posts that belong in that specific grid.
taking an example: if i make a grid based on the category “comedy” that grid will only display posts that fall into the category “comedy” and when i search from the search bar of that post it will only search for posts that belong to the category “comedy” and not for all the posts.
so basically i made a grid and selected all the categories in it, so now the search for grid can search posts of all categories. What i want is for the search from all my various grids to use the search i made for a the grid with all the categories.
i would also like to change the functionality of the search, the current way of its functioning is “type to search”, “press enter to reset” and i would like to change it to “press enter once to search”, “press enter twice to reset”.

Inspect element of the search of the grid which includes all categories (i want all other searches from other grids to search from this grid/search)

screenshot of another grid with a search option, i want to edit the search option of this grid and i want it to use the search from the previous grid as shown in the screenshot

Screenshot of the post grid plugin

Receiving HTTP ERROR 500 when attempting to write code to SQL server in PHP [duplicate]

This question already has an answer here:

I’m trying to create a login for my website but I keep receiving HTTP ERROR 500. I’ve read that this error is a server error and could be caused by using an outdated version of MySQL. I am using Godaddy Cpannel hosting so I don’t have the option to update it. Could there be anything fundamentally wrong with my code that is causing this error instead?

<?php
session_start();

$con = mysqli_connect('localhost','simpleusereitan','12345','nuthead_database');

//fail
if(mysqli_connect_errno())
{
   echo "Failed to connect:" . mysqli_connect_error();
}
//success
if(mysqli_ping($con))
{
   echo "Connection ok";
}
else
{
   echo "Error: " . mysqli_error($con);
} 
//consistently returns connection ok

if isset($_POST['submit'])) {

    $uid = mysqli_real_escape_string($con, $_POST['uid']);
    $pwd = mysqli_real_escape_string($con, $_POST['uid']);

    //Error handlers
    //Check if inputs are empty
    if (empty($uid) || empty($pwd)) {
        header("Location: ../index.html?login=empty")
        exit();
    } else {
        $sql = "SELECT * FROM users WHERE user_uid='$uid'";
        $result = mysqli_query($con, $sql);
        $resultCheck = mysqli_num_rows($result);
        if ($resultCheck < 1) {
            header("Location: ../index.html?login=error")
            exit();
        } else {
            if ($row = mysqli_fetch_assoc($result)) {
                //De-hasing the password
                $hashedPwdCheck = password_verify($pwd, $row['user_pwd']);

                if ($hashedPwdCheck == false) {
                    header("Location: ../index.html?login=error")
                    exit();
                } elseif ($hashedPwdCheck == true){
                    //log in user here
                    $_SESSION['u_id'] = $row['user_id'];
                    $_SESSION['u_first'] = $row['user_first'];
                    $_SESSION['u_last'] = $row['user_last'];
                    $_SESSION['u_email'] = $row['user_email'];
                    $_SESSION['u_uid'] = $row['user_uid'];
                    header("Location: ../index.html?login=success")
                    exit();
                }
            }
        }
    }

}   else {
    header("Location: ../index.html?login=error")
    exit();
}