Tag Archives: php

[Solved] yii Frame Error: Warning!symlink() has been disabled for security reasons

Error Messages:

A symlink for "/www/wwwroot/www.atepaoutdoors.com/lib/web/mage/requirejs/mixins.js" can't be created and placed to "/www/wwwroot/www.atepaoutdoors.com/pub/static/frontend/Zemez/theme115/en_US/mage/requirejs/mixins.js". Warning!symlink() has been disabled for security reasons

When deploying the PHP project to the PHP environment on the new server, an error occurs: scandir() symlink() has been disabled for security reasons.

 

How to Solve:

In this case, just go to the PHP installation directory, find php.ini, ctrl+F and search for “disable_functions”, and find the following property configuration.

disable_functions = scandir,passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pls. restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,fsockopen

Delete scandir and symlink from “disable_functions”, save the php.ini file, restart the service, and refresh the page. This will solve the error problem.

PHP php-config is not installed error in ubuntu 16 [How to Solve]

Environment

Ubuntu 16.04.1 LTSPHP 7.0.33

Question

When compiling and installing php extensions with php config, it is found that php-config does not exist.

Check whether php-config exists or not?

$ whereis php-config
php-config:

As above, it returns null, indicating that it does not exist.

Solution:

This problem occurs because the php-dev package is not installed. You can install it once.

Install php-dev

$ apt-get install php-dev

If php5 is version, run apt-get install php5-dev.

re-check php-config

$ whereis php-config
php-config: /usr/bin/php-config /usr/bin/php-config7.0 /usr/share/man/man1/php-config.1.gz

As shown above, the installation is successful.

[Solved] PHP Error: Warning: file_get_contents(): Failed to enable crypto

I. Description
file_get_contents() error when reading https content

II. Reason
Local service is not configured ssl certificate, can not get the contents of the path to https

III. Solution
1, Linux server configuration https ssl certificate.
Linux server configuration https ssl certificate.
2. curl_ request to obtain the content (see the following method curlGet ())

    /**
     * get the content
     * @param $url
     * @return bool|string
     */
    function curlGet($url)
    {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36');
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        $content = curl_exec($ch);
        curl_close($ch);
        return ($content);
    }

3.Use file_get_contents() function to skip https authentication

        $streamOpts = [
            'ssl' => [
                'verify_peer' => false,
                'verify_peer_name' => false
            ]
        ];
        $html = file_get_contents($pageUrl, false, stream_context_create($streamOpts));

[Solved] Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 60

Guzzle

Error prompt

If an error occurs as follows:

Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/… in xxx.php

The reason is that the local CURL SSL certificate is too old to recognize.

Solution:

  • Download an up-to-date certificate from http://curl.haxx.se/ca/cacert… Then save it to an arbitrary directory.
  • Then put catr.pem in the bin directory of php and edit php.ini, open the php.ini file with notepad or notepad++, about line 1932.
  • Remove the comment “;” in front of curl.cainfo, then write the full path and file name of the cacert.pem certificate at the end, mine is as follows

Finally, restart the wamp.

Mac: make: *** [Zend/zend_language_parser.lo] Error 1

Error reporting content:

/Users/dre0m1/CTF/Study_notes/PHP_source_code/php-src/Zend/zend_language_parser.y:1317:5: error: implicit declaration of function 'yystpcpy' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

                                yystpcpy(yyres, "end of file");

                                ^

/Users/dre0m1/CTF/Study_notes/PHP_source_code/php-src/Zend/zend_language_parser.y:1317:5: note: did you mean 'stpcpy'?

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/string.h:130:7: note: 'stpcpy' declared here

char    *stpcpy(char *__dst, const char *__src);

         ^

/Users/dre0m1/CTF/Study_notes/PHP_source_code/php-src/Zend/zend_language_parser.y:1324:29: error: implicit declaration of function 'yystrlen' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

                yystr_len = (unsigned int)yystrlen(yystr);

                                          ^

/Users/dre0m1/CTF/Study_notes/PHP_source_code/php-src/Zend/zend_language_parser.y:1324:29: note: did you mean 'strlen'?

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/string.h:82:9: note: 'strlen' declared here

size_t   strlen(const char *__s);

         ^

/Users/dre0m1/CTF/Study_notes/PHP_source_code/php-src/Zend/zend_language_parser.y:1345:4: error: implicit declaration of function 'yystpcpy' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

                        yystpcpy(yyres, buffer);

                        ^

/Users/dre0m1/CTF/Study_notes/PHP_source_code/php-src/Zend/zend_language_parser.y:1352:10: error: implicit declaration of function 'yystrlen' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

                return yystrlen(yystr) - (*yystr == '"' ?2 : 0);

                       ^

/Users/dre0m1/CTF/Study_notes/PHP_source_code/php-src/Zend/zend_language_parser.y:1365:2: error: implicit declaration of function 'yystpcpy' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

        yystpcpy(yyres, yystr);

        ^

5 errors generated.

make: *** [Zend/zend_language_parser.lo] Error 1

Implicit declaration of function ‘yystpcpy’ is invalid in C99. Looking up information on the Internet, we can find that this error type is related to the header file or the previous define. From the prompts in the error report, we can see that the function yystpcpy is missing.

Access the file php-src/Zend/zend_language_parser.c. You can see this code below:

Add the definitions of yystpcpy and yystrlen to it, guess that their original functions should be stpcpy and strlen functions: re-make after modification, and compile successfully.

[Solved] tp6.0 open_basedir Error: Warning: require(): open_basedir restriction in effect.

Error message

Warning: require(): open_basedir restriction in effect. File(/work/tp6/vendor/autoload.php) is not within the allowed path(s): (/work/tp6/public/:/tmp/) in /work/tp6/public/index.php on line 15

Warning: require(/work/tp6/vendor/autoload.php): failed to open stream: Operation not permitted in /work/tp6/public/index.php on line 15

Fatal error: require(): Failed opening required '/work/tp6/public/../vendor/autoload.php' (include_path='.:') in /work/tp6/public/index.php on line 15

 

Check the problem description and data, and find that it is the problem of PHP open_basedir  configuration is that PHP cannot import the files above the authorized directory;

In general, this problem will not occur. The reason for this problem is mostly due to the server. This restriction is made for security!

If the entry file of is switched to public, the following file should be modified to remove public

Solution:

How to Solve Hyperf Failed to Start Error After Aliyun ACM Installed

Today, try installing the hyperf microservice framework

Alibaba cloud ACM is selected when installing the service

The console keeps making such mistakes

[ERROR] Client error: `GET http://139.196.135.144:8080/diamond-server/config.co?tenant=&dataId=&group=DEFAULT_GROUP` resulted in a `404 Not Found` response:
config data not exist

[line:113] in /www/hyperf/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php

Solution:

Modify the configuration in hyperf/config/autoload/config_center.php in the project root directory

return [
    'enable' => (bool) env('CONFIG_CENTER_ENABLE', false), // set to false
    'driver' => env('CONFIG_CENTER_DRIVER', 'aliyun_acm'),
    'mode' => env('CONFIG_CENTER_MODE', Mode::PROCESS),
    'drivers' => [
        'aliyun_acm' => [
            'driver' => Hyperf\ConfigAliyunAcm\AliyunAcmDriver::class,
            'interval' => 5,
            'endpoint' => env('ALIYUN_ACM_ENDPOINT', 'acm.aliyun.com'),
            'namespace' => env('ALIYUN_ACM_NAMESPACE', ''),
            'data_id' => env('ALIYUN_ACM_DATA_ID', ''),
            'group' => env('ALIYUN_ACM_GROUP', 'DEFAULT_GROUP'),
            'access_key' => env('ALIYUN_ACM_AK', ''),
            'secret_key' => env('ALIYUN_ACM_SK', ''),
            'ecs_ram_role' => env('ALIYUN_ACM_RAM_ROLE', ''),
        ],
    ],
];

Or the zone applies for Alibaba cloud ACM, and it is OK to fill in the relevant configuration successfully. It is recommended to close it in the development stage

HTML + PHP inline execute JavaScript Error [How to Solve]

Error message

read.php:1 Refused to run the JavaScript URL because it violates the following Content Security Policy directive: “script-src ‘self’”. Either the ‘unsafe-inline’ keyword, a hash (‘sha256-…’), or a nonce (‘nonce-…’) is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the ‘unsafe-hashes’ keyword is present.

 

Solution:

Add unsafe-inline in the header

header("Content-Security-Policy: script-src 'self' 'unsafe-inline';);

[Solved] Centos7 xmapp Install Error: error while loading shared libraries: libc.so.6

1. Version information:

CentOS version: CentOS release 6.9 (final)

xmapp version: xampp-linux-x64-5.6.40-1-installer.run

2. Error message:

[root@localhost ~]# /opt/lampp/lampp
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/bin/bash: error while loading shared libraries: libdl.so.2: cannot open shared object file: No such file or directory
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory

id: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/share/xampp/xampplib: line 11: test: -ne: unary operator expected
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
XAMPP: egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
netstat: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
netstat: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/httpd: error while loading shared libraries: librt.so.1: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
XAMPP: hostname: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
netstat: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
XAMPP: /bin/sh: error while loading shared libraries: libdl.so.2: cannot open shared object file: No such file or directory
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
netstat: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory

3. Solution:

1. Open /opt/lampp/lampp

vim /opt/lampp/lampp

2. Edit
Modify this line

export LD_ASSUME_KERNEL=2.2.5

to

export LD_ASSUME_KERNEL=2.8.0

Find a word in the file [under the command line/keyword, enter to find, enter n to find the next]

[Solved] Laravel admin Error: Symfony\Component\Debug\Exception\FatalThrowableError : Class ‘Doctrine\DBAL\Driver\PDOMySql\Driver’ not found

laravel-admin error

Error reporting information

An error occurs when running PHP artisan admin:make:

symfony\component\debug\exception\fatalthrowableerror: class'doc\dbal\driver\pdomysql\driver'not found

Operating environment

Windows 10
php:7.3.4
mysql:5.7.26
laravel:5.8
laravel admin:1.8.17

Cause

Doctrine/dbal not found

The reason why I read other people online may be that doctrine/dbal is 3* Caused by the version of.

Solutions

Run at terminal:

composer require doctrine/dbal:2.12.1

Or modify the composer.json as the following:

    "require": {
    	*
    	*
        "doctrine/dbal": "^2.12.1",
        *
        *
    },

Then run

composer update

[Solved] OpenSSL Error messages: error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure

In these two days, the service has been reporting when calling Baidu’s addressing and positioning interface and reverse address resolution:

file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure

The query results of the interface are affected, and finally the curl call problem is solved:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSLVERSION, 4);
$reponse = curl_exec($ch);

CURLOPT_SSLVERSION Fetch value and meaning
CURL_SSLVERSION_TLSv1_2 requires php version >= 5.5.19
TLS 1.1 and TLS 1.2 are supported since OpenSSL 1.0.1

CURL_SSLVERSION_DEFAULT (0)
CURL_SSLVERSION_TLSv1 (1),
CURL_SSLVERSION_SSLv2 (2), 
CURL_SSLVERSION_SSLv3 (3),
CURL_SSLVERSION_TLSv1_0 (4),
CURL_SSLVERSION_TLSv1_1 (5),
CURL_SSLVERSION_TLSv1_2 (6).

[Solved] Model Error: must return a relationship instance

Model Error: must return a relationship instance

There is a method in the model as follows:

public function adjustbills()
    {
        if($this->user_combined == '1'){
            $invoiceNumberArr = ['xxx'];
            return Adjustbill::whereIn('invoice_number',$invoiceNumberArr)->where('user_id', $this->user_id);
        }else{
            return $this->hasMany(Adjustbill::class, 'invoice_number', 'invoice_number')->where('user_id', $this->user_id);
        }
    }

When the calling method is model -> When adjustbills,

  1. If it goes to the following judgment, no error will be reported
  2. If it goes to the above judgment, it will report an error must return a relationship instance, because laravel uses the following hasMany relationship by default, if not, it will report an error.

Solution:

  1. Find a way to modify the above logic to the following way of relationship
  2. Called as :model->adjustbills->get()