Google API PHP client trouble - php

I have tried everything, but can't seem to simply get it to work.
I was using these scripts happily on a bluehost hosting, till I decided to move to digital ocean.
https://github.com/google/google-api-php-client/tree/1.1.4
https://github.com/asimlqt/php-google-spreadsheet-client/tree/2.3.5
I built a custom function to read spreadsheets and use it as a database for a client who needed the ability to edit the website texts himself.
I took a Digital Ocean Ubuntu 14.04 server, installed Sentora Panel on it, normal PHP code works, but specifically this Google API script is throwing this error.
[Fri Jul 29 05:21:24.569294 2016] [:error] [pid 2429] [client 14.139.122.50:53019] PHP Warning: file_exists(): open_basedir restriction in effect. File(/tmp/Google_Client/5f/5fa67135f8773ebac807e4dda0aa1084) is not within the allowed path(s): (/var/sentora/hostdata/zadmin/public_html/test2_ipleaders_in:/var/sentora/temp/) in /var/sentora/hostdata/zadmin/public_html/test2_ipleaders_in/process/google/google-api-php/src/Google/Cache/File.php on line 52
[Fri Jul 29 05:21:25.985927 2016] [:error] [pid 2429] [client 14.139.122.50:53019] PHP Warning: is_dir(): open_basedir restriction in effect. File(/tmp/Google_Client/5f) is not within the allowed path(s): (/var/sentora/hostdata/zadmin/public_html/test2_ipleaders_in:/var/sentora/temp/) in /var/sentora/hostdata/zadmin/public_html/test2_ipleaders_in/process/google/google-api-php/src/Google/Cache/File.php on line 148
[Fri Jul 29 05:21:25.986025 2016] [:error] [pid 2429] [client 14.139.122.50:53019] PHP Warning: mkdir(): open_basedir restriction in effect. File(/tmp/Google_Client/5f) is not within the allowed path(s): (/var/sentora/hostdata/zadmin/public_html/test2_ipleaders_in:/var/sentora/temp/) in /var/sentora/hostdata/zadmin/public_html/test2_ipleaders_in/process/google/google-api-php/src/Google/Cache/File.php on line 149
[Fri Jul 29 05:21:25.986373 2016] [:error] [pid 2429] [client 14.139.122.50:53019] PHP Fatal error: Uncaught exception 'Google_Cache_Exception' with message 'Could not create storage directory: /tmp/Google_Client/5f' in /var/sentora/hostdata/zadmin/public_html/test2_ipleaders_in/process/google/google-api-php/src/Google/Cache/File.php:154\nStack trace:\n#0 /var/sentora/hostdata/zadmin/public_html/test2_ipleaders_in/process/google/google-api-php/src/Google/Cache/File.php(139): Google_Cache_File->getCacheDir('ff3dffdeef0acdf...', true)\n#1 /var/sentora/hostdata/zadmin/public_html/test2_ipleaders_in/process/google/google-api-php/src/Google/Cache/File.php(134): Google_Cache_File->getCacheFile('ff3dffdeef0acdf...', true)\n#2 /var/sentora/hostdata/zadmin/public_html/test2_ipleaders_in/process/google/google-api-php/src/Google/Cache/File.php(95): Google_Cache_File->getWriteableCacheFile('ff3dffdeef0acdf...')\n#3 /var/sentora/hostdata/zadmin/public_html/test2_ipleaders_in/process/google/google-api-php/src/Google/Auth/OAuth2.php(315): Google_Cache_File->set('ff3dffdeef0acdf...', '{"access_token"...')\n#4 /var/sentora/hostda in /var/sentora/hostdata/zadmin/public_html/test2_ipleaders_in/process/google/google-api-php/src/Google/Cache/File.php on line 154
This is the error log I am receiving. I have checked for file permissions, and have kept it 777 in many places and especially in the tmp folder as mentioned in the error log. I desperately seek help on this, any insight is helpful.

Just as the error message says, it appears that php's open_basedir setting is preventing the script from reading the files from /tmp path. You probably want to check with your hosting provider if you are able to change that setting, or alternatively, change the temporary path in your application/library settings to the directory you have access to.

I solved this one beautifully!
So as I was using Sentora, I searched for 'open_basedir Sentora' on Google, and found this: http://forums.sentora.org/showthread.php?tid=1674
I made a custom vhost entry:
Admin > Module Admin (on Sentora CP).
Apache Config (it's the very first option).
Scrolled Down to the end of the page and under the Override a Virtual
Host Setting I choose the website I wanted.
Now on the text area input: Custom Entry I entered the following:
php_admin_value open_basedir none
And now the Google Script is working fine! Thanks to #Unix-One's answer I was on the right track.

Related

Unable to acces site after unwanted cancelling of plugin-installation

After trying to install a plugin on my website I'm unable to access the site (front- and backend).
[php7:error] [pid 10111]PHP Fatal error: Class
'Joomla\CMS\Plugin\CMSPlugin' not found in
/home/public/sites/www.modderaandebanden.nl/plugins/system/sessiongc/sessiongc.php
on line 22 [Sat Jul 21 17:34:46.681638 2018] [:error] [pid 11113] PHP
Fatal error: Class 'Joomla\CMS\Plugin\CMSPlugin' not found in
/home/public/sites/www.modderaandebanden.nl/plugins/system/sessiongc/sessiongc.php
on line 23
This seems to be the problem but I'm not sure what I should do. Already tried the solution in "user3063937" problem but this doesn't work for me (change sessiongc folder to sessiongc.bak).
Any suggestions what I should do?
If you have access to phpmyadmin, login and open your database for your site. Navigate to the #__extensions table, search for the plugin and disable there.

No such file or directory error CakePHP

I inherited a CakePHP project and I am having issues getting the project running. I am running into these errors
[Fri Feb 02 00:05:35.920569 2018] [:error] [pid 536] [client 172.18.0.1:38124] PHP Warning: include(/home/tablereserv/web/tablereserv.com/public_html/lib/Cake/Error/ErrorHandler.php): failed to open stream: No such file or directory in /src/lib/Cake/Core/App.php on line 547
[Fri Feb 02 00:05:35.920638 2018] [:error] [pid 536] [client 172.18.0.1:38124] PHP Warning: include(): Failed opening '/home/tablereserv/web/tablereserv.com/public_html/lib/Cake/Error/ErrorHandler.php' for inclusion (include_path='.:/usr/share/php') in /src/lib/Cake/Core/App.php on line 547
[Fri Feb 02 00:05:35.920658 2018] [:error] [pid 536] [client 172.18.0.1:38124] PHP Warning: set_error_handler() expects the argument (ErrorHandler::handleError) to be a valid callback in /src/lib/Cake/Core/Configure.php on line 443
The file path that is trying to be included, /home/tablereserv/web/tablereserv.com/public_html/lib/Cake/Error/ErrorHandler.php does exist and the actual path to that file is /src/lib/Cake/Error/ErrorHandler.php
I have found some similar questions like the ones below, but none of the answers were particularly helpful
CakePHP ErrorHandler error
PHP Warning: include(/var/www/html/....../lib/Cake/Error/ErrorHandler.php): failed to open stream Error
When I print out the CAKE_CORE_INCLUDE_PATH variable, I get the correct path but something is obviously going wrong somewhere and I can’t seem to find it.
I also think I should mention that I set up a docker container to run the project in, I’m not sure if that could have an impact on it.
Any help would be greatly appreciated.
In my case, I found out that file mappings are stored in a file with a name similar to appname_cake_core_file_map. Once I deleted the cache file and ran the request again, a new mapping was generated with the correct path.

PHP error : "open_basedir restriction in effect"

I am actually trying to set up my localhost Wordpress installation to my apache server and I have some trouble to access the index.php or any other file in my Wordpress installation. Indeed I have a blank page while accessing "www.mysite.com/blog". Knowing that I can't modify apache2.conf or any configuration file by myself, I wanted to know if there is any other solution to fix this.
Here is what I obtain in error.log:
[Thu Jul 02 08:57:21 2015] [error] [client 104.6.36.81] PHP Warning: Unknown: open_basedir restriction in effect. File(/var/www/vhosts/mysite.com/httpdocs/blog/index.php) is not within the allowed path(s): (/var/www/vhosts/mysite.com/httpdocs:/tmp) in Unknown on line 0
[Thu Jul 02 08:57:21 2015] [error] [client 104.6.36.81] PHP Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0
[Thu Jul 02 08:57:21 2015] [error] [client 104.6.36.81] PHP Fatal error: Unknown: Failed opening required '/var/www/vhosts/mysite.com/httpdocs/blog/index.php' (include_path='.:') in Unknown on line 0
Moreover, the owner of "blog" is me.
Any help would be welcomed :)
First, 777 permissions are bad, even on localhost where there is limited external access. Changing File Permissions « WordPress Codex for the correct and secure permissions scheme.
Second, open_basedir restriction in effect is a PHP configuration error. You need to make changes in httpd.conf. You need to find the location of httpd.conf for your OS and Apache.
See http://php.net/manual/en/ini.core.php#ini.open-basedir :
In httpd.conf, open_basedir can be turned off (e.g. for some virtual
hosts) the same way as any other configuration directive with
"php_admin_value open_basedir none"

Magento open_basedir restriction in effect. File(/tmp) is not within the allowed path(s):

i'm having some trouble about uploading image on Magento CMS in all page/product.
I've enabled erro log and i'll report it to check.
NOTE: Only for post now, I have sobstitute my address domain with "mydomain.com". Only for sample.
[Sun Feb 02 15:02:14 2014] [error] [client 146.105.28.41] client
denied by server configuration:
/var/www/vhosts/mydomain.com/httpdocs/app/etc/local.xml
[Sun Feb 02 15:02:18 2014] [error] [client 146.105.28.41] client
denied by server configuration:
/var/www/vhosts/mydomain.com/httpdocs/app/etc/local.xml
[Sun Feb 02 15:02:36 2014] [warn] [client 151.67.115.48] mod_fcgid:
stderr: PHP Warning: Unknown: open_basedir restriction in effect.
File(/tmp) is not within the allowed path(s):
(/var/www/vhosts/mydomain.com:/usr/share/php:/usr/share/pear) in
Unknown on line 0
[Sun Feb 02 15:02:36 2014] [warn] [client 151.67.115.48] mod_fcgid:
stderr: PHP Warning: File upload error - unable to create a temporary
file in Unknown on line 0
You will need to add an open_basedir exemption for /tmp, turn open_basedir off entirely, or change the php temp directory to something within /var/www/vhosts/mydomain.com.
I recommend the first.
I've read reports (With no explanation) that you should do the second.
You can do the 3rd from within the Apache config:
<Directory /var/www/vhosts/mydomain.com/>
php_admin_value upload_tmp_dir /var/www/vhosts/mydomain.com/temp
</Directory>
Answers here did not work for me:
an open_basedir exception for /tmp is usually not the best solution, because it means that users have access to other users' tmp files (possible security issue)
open_basedir is usually active for a reason, switching it off entirely might be a security issue
the problem still occured after modifying the upload_tmp_dir
For me, the magento installation worked after I set the php.ini value sys_temp_dir to a value within the open_basedir directory.
To be safe, I checked all tmp paths displayed in phpinfo() and changed them like this:
<Directory /var/www/myvirtualhost>
php_admin_value upload_tmp_dir /var/www/myvirtualhost/tmp
php_admin_value soap.wsdl_cache_dir /var/www/myvirtualhost/tmp
php_admin_value opcache.lockfile_path /var/www/myvirtualhost/tmp
php_admin_value sys_temp_dir /var/www/myvirtualhost/tmp
</Directory>

Moved Facebook app to a new server, now its broken

My app was working fine on my server. I moved it to another server, updated all the app settings in developers.facebook.com and now all i get is a blank page. The error_log for the server shows this error.
[Wed May 23 22:20:01 2012] [error] [client 184.65.142.249] PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0, referer: http://static.ak.facebook.com/platform/page_proxy.php?v=4
[Wed May 23 22:20:01 2012] [error] [client 184.65.142.249] PHP Fatal error: Unknown: Failed opening required '/var/www/html/explorebc/home.php' (include_path='.:/usr/share/pear:/usr/share/php') in Unknown on line 0, referer: http://static.ak.facebook.com/platform/page_proxy.php?v=4
I've searched high and low for an answer to this, I could really use somebody's help for a push in the right direction.
The paths are right, the facebook settings are right, the init call is in there, the config file has been updated with new server paths.
Cheers,
Cody
You should make sure that the right permissions are set for files. [Source]
It was SELinux that was blocking the site from working correctly. It was unrelated to code or direction, it was just simply blocking things from working.

Categories