PHP ftp_get causing warning and not downloading file - php

I've got a fairly simple cron job that pulls down some files from an FTP server - none of the files are particularly large, but I'm constantly getting the following:
Connected to voip.colefabrics.com, for user colefabrics\absolute
Warning: ftp_get(): Opening BINARY mode data connection. in /home/www/colefabrics.com/httpdocs/libs/classes/class.ftpObj.php on line 56
There was a problem while downloading website/items.csv
Attempt 2:
Connected to voip.colefabrics.com, for user colefabrics\absolute
Warning: ftp_get(): Opening BINARY mode data connection. in /home/www/colefabrics.com/httpdocs/libs/classes/class.ftpObj.php on line 56
There was a problem while downloading website/items.csv
...snip...
I've been through all the other posts relating to this, tried to enforce passive mode, increased the timeout, but nothing is working.
Does anyone know what might be causing this, and what I can do to try and resolve it?
To confirm, it's working fine via a 'normal' FTP client, it's only via PHP that I have a problem.

Related

Why is the path truncated / cut off in the PHP error log?

I have a WordPress web site running on Windows Server 2012 R2 via IIS and PHP 7.1.1. Everything works well, except once or twice a day, the site returns a white screen (HTTP 500) and the error log shows the following errors:
[17-Jan-2019 15:29:15 UTC] PHP Warning: require_once(D:\Webs\www.WebS): failed to open stream: No such file or directory in D:\Webs\www.WebSite.com\wp-content\plugins\captcha\bws_menu\bws_include.php on line 91
[17-Jan-2019 15:29:15 UTC] PHP Fatal error: require_once(): Failed opening required 'D:\Webs\www.WebSite.com/wp-content/plugins/captcha/bws_menu/bws_functions.php' (include_path='.;C:\php\pear') in D:\Webs\www.WebSite.com\wp-content\plugins\captcha\bws_menu\bws_include.php on line 91
FYI - I have changed the path off of D:\Webs to show a fictitious website name.
Notice that the path is cut off. Sometimes the path is cut off in different places. Sometimes it's to completely different files for completely different plugis. Sometimes it's even complaining about WordPress core. The only thing consistent is that once this happens, the exact same path is the failure until I recycle the App Pool. When it happens again, it's a different file, but complains about the same file until I recycle the App Pool.
What gives?
The only workaround I have is to recycle the app pool or set IIS to automatically recycle on a schedule. Neither of these are good long term solutions.
I should also note that this server has about 10 other WordPress sites running. They each have their own App Pool and run from their own folder. They never, ever have this problem.
Also, resources on the server are excellent. At the highest traffic times, the CPU's are less than 50% and there is less than 75% memory utilization. There are also many gigabytes of free disk space on the system volume as well as the data volume the site runs from.
Please don't reply with "don't run PHP or WordPress on Windows/IIS." That's not helpful - I cannot change the environment and I need to figure out the solution.
I have 100% control of the server environment and can debug/troubleshoot as needed. So if there's any way to get more information, please let me know!

PHP ftp_delete() generates warning "Command okay"

I can not find any answer to this as most problems revolve around a file not existing or a delete process not working.
I have an FTP device where I generate a file with an PHP script. After that, I try to FTP in, get the file and after that, delete it.
This all works fine, I can connect, get the file and save it locally and then delete it. Except for one thing, the ftp_delete() function results in a warning.
PHP gives me the following, when executing the script:
A PHP Error was encountered
Severity: Warning
Message: ftp_delete(): Command okay
I looked up the error code, it means it was successful. And it was because the file is deleted on the FTP device.
So why does this generate an PHP error?
Cheers.
The RFC 959 (FTP specification) mandates that on a successful completion of the DELE command, the server should respond with 250 status code.
The PHP FTP implementation is very strict, yielding a warning on any other code, even if it indicates a success (2xx class).
Your server probably uses some other 2xx code, like a generic 200 Command okay.

Sessions limited on server?

2011-12-08 17:24:04 - PHP Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
2011-12-08 17:24:04 - PHP Warning: Unknown: write failed: No space left on device (28) in Unknown on line 0
Getting these errors after uploading a certain amount of content. Also, noticed that can no longer log in to admin panel. Could this be cause by too many sessions be stored on a server? Or anyone have any other ideas? First happened after uploading a few images through admin panel in open cart.
I am hosting a bunch of sites off of one server. SO it seems likely but has anyone run into this before?
Looks very likely that you've run out of space on the disk and so causing many things to fail. Try freeing up some space and try again.

More than max_user_connections in CodeIgniter app?

I'm getting what looks like rather serious database errors in my CodeIgniter application. In the log file it says:
User anders already has more than 'max_user_connections' active connections
And there are several hundred of those lines... I've read a bit by Googling, and some suggested that it was because you didn't close the connection after it was used, but others said that this was nonsense, and that the connection was automatically closed (which is what I read in the docs too).
Also, later in the log file, I have these error messages:
ERROR - 2011-10-12 10:50:19 --> Severity: Warning --> file_get_contents(http://localhost/expertinfo/error/error_general) [function.file-get-contents]: failed to open stream: HTTP request failed! /Applications/MAMP/htdocs/expertinfo/application/errors/error_general.php 4
This seems to have something to do with the fact that I'm using a custom error page by using
echo file_get_contents($config['base_url'] . 'error/error_db');
to redirect to a custom page.
Finally, I'm also getting:
ERROR - 2011-10-12 10:52:19 --> Severity: Warning --> mysql_pconnect() [function.mysql-pconnect]: Can't connect to MySQL server on 'mydb24.surftown.se' (4) /Applications/MAMP/htdocs/expertinfo/system/database/drivers/mysql/mysql_driver.php 88
In these last two, I don't understand what the local path is doing there (The path to my CodeIgniter app on my computer). I mean this is a part of the system folder and the one on the remote server should be used, right? I have the database set up as the remote database, and I don't have any local paths as far as I know....
So why does this happen, and what can I do about it?
Please help, this seems rather urgent. I'm a bit of a newbie to both php and CodeIgniter too, so a clear and simple answer would be greatly appreciated!
Local path as I see shows you file where your error happened, because your driver /Applications/MAMP/htdocs/expertinfo/system/database/drivers/mysql/mysql_driver.php possible on it's 88 line contain connect() function and it raise an exception
The problem is with your mydb24.surftown.se remote server, you should check your access credentials, etc. to find what exactly happened
Just an FYI, mysql_pconnect is usually a bad practice on shared hosting (you can see why here:http://stackoverflow.com/questions/1830830/advantages-disadvantages-of-pconnect-option-in-codeigniter)
You might just disable pconnect on application/config/database.php and see the error going away as your connections will be realluy lower.
For the quote: "mysql_pconnect is usually a bad practice on shared hosting".
I changed to use mysql_connect. It made no difference.

simplexml_load_file() error

so I'm trying implement a website which uses data stored in an xml file.
It works fine on my computer, but as soon as I try to upload it, I get the following error:
Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "..\lib\menu.xml" in /home/ogwareco/public_html/menu.php on line 2
And none of the data gets displayed on the screen. I've Googled this problem, but it's led nowhere. I've got no idea what to do here. I've even tried to set my permissions to 777 (bad idea, I know), to see if it was a permissions thing, but it's not.
It looks like you are using backslashes to refer to the file on a Linux machine. Change
..\lib\menu.xml
to
../lib/menu.xml
in your code.

Categories