0

Hello everybody

I want get website address with form POST method and show meta tags in my page.
I try writing code with Laravel-6.2 PHP and I think everything OK but don't work. I think it's wrong in Curl code.
I found a similar error in Laravel 5.2: The Process class relies on proc_open, which is not available on your PHP installation but I have use php 7.2

Please help me find the mistake Thankful


in Controller :

public function MetaChecker(Request $request){
   $rules = array(
        'url' => 'required|url|max: 255',
        'g-recaptcha-response' => 'required|captcha',
    );
    $messages = array(
        'url.required' => 'آدرس سایت معتبر نمی باشد.',
        'g-recaptcha-response.required' => 'کد امنیتی معتبر نمی باشد.',
    );
    $validator = Validator::make( $request->all(), $rules, $messages );
    if ( $validator->fails() )
    {
        return back()
            ->withErrors($validator)
            ->withInput();
    }
    $domain = $request->input('url');
    $url = str_replace(array('Array', 'http://', 'https://', 'http://www.', 'https://www.', 'www.', '/'), '', strip_tags($domain));

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

    $data = curl_exec($ch);
    curl_close($ch);

    $doc = new DOMDocument();
    @$doc->loadHTML($data);
    $nodes = $doc->getElementsByTagName('title');
    $title = $nodes->item(0)->nodeValue;

    $metas = $doc->getElementsByTagName('meta');

    for ($i = 0; $i < $metas->length; $i++)
    {
        $meta = $metas->item($i);

        if($meta->getAttribute('name') == 'viewport')
            $viewport = $meta->getAttribute('content');
        if($meta->getAttribute('name') == 'description')
            $description = $meta->getAttribute('content');
    }
    if ($data != 0) {

        return back()->with(
            'title', '<span>title : <strong class="en-font"> ' . $title . '</strong></span>')->with(
            'description', '<span>description : <strong class="en-font"> ' . $description . '</strong></span>')->with(
            'viewport', '<span>viewport : <strong class="en-font"> ' . $viewport . '</strong></span>');
    }else{
        return back()
            ->withInput()
            ->withErrors(array('error' => 'آدرس سایت معتبر نمی باشد.'));
    }
}

Error title:

LogicException

The Process class relies on proc_open, which is not available on your PHP installation.

Screenshot error

itroz
  • 13
  • 4

0 Answers0