fopen works on local server but not on webserver - php

I'm using fopen to create a new file. On my localserver it works fine, however on my webserver (linux shared hosting with goDaddy) I get:
Warning: fopen(invoices/qbImport519.iif) [function.fopen]: failed to open stream: No such file or directory in /home/content/c/h/i/chiseled/html/tracking_admin/qbInvoices.php on line 97
Thinking that it was settings on the webserver, I contacted GoDaddy who responded that everything was setup on my account correctly for this to work. Any ideas?
Here's is my code:
$qbFile = fopen("invoices/qbImport".$Hits.".iif","ab");
if (is_writable("invoices/qbImport".$Hits.".iif")){
if (fwrite($qbFile,$iifWrite)){
echo'Download Your File<br/>';
else {
echo "<p>Cannot add your entry</p>";
}
}
else {
echo "<p>The file is not writeable</p>";
}
fclose($qbFile);
I have tried the paths /home/content/c/h/i/chiseled/html/tracking_admin/invoices and invoices/.
The file does not exists since it's based on the $hits variable which is incremented each time. So for some reason it's not able to create the new file. I have also tried just a for the fopen mode.
Any help would be great. thanks.

I had created the directory as "Invoices" not "invoices". No more coding till 4am!

it is because fwrite is not supported in godaddy. godaddy has alot of restriction. It is better you go with other good hosts like bluehost, ipage. Godaddy may be good in domains but hosting is poor. even wordpress won't run perfectly in godaddy.
Matt Mullenweg the creator of wordpress says that
http://wordpress.org/support/topic/more-godaddy-installation-problems

Related

Laragon : Error message : (include_path='.;C:/laragon/etc/php/pear') in Unknown on line 0

I have two machine (LapTop & DeskTop),
so I use WWW in a cloud OneDrive folder,
pro easier synchronisation.
Strangely I didn't had any trouble until june,
when I installed the last Windows 10 2019 Creator Update…
I formatted my C drive and installed the update,
but the problem is that I use an other drive of 1To pro my OneDrive files (with 1To subscription),
and of course in properties,
the authorisation using my login who is linked to my Hotmail,
was not recognized,
and shown as a long number
I changed all authorisation with the actual login.
But now when I launch a php page on local host, I get this message :
Laragon
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'I:/Users/nemza/OneDrive/www/taocodex/templates/ueb/wp/converter/WP_converter_18_columns.php' (include_path='.;C:/laragon/etc/php/pear') in Unknown on line 0
wamp64 :
( ! ) FWarning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
( ! ) Fatal error: Unknown: Failed opening required 'I:/Users/nemza/OneDrive/www/index.php' (include_path='.;C:\php\pear') in Unknown on line 0
I can't find a solution on Google, and I know that before it was working, I don’t have trouble with HTML files,
any solution ?
Don’t tell & answer me to use www in Laragon folder, I don’t want to do this.
Few day after,
I have formated the I:\ drive, and reinstalled and downloaded the OneDrive files.
But I still have this problem ?
If use i:\users\nemza\www it's working fine,
if use i:\users\nemza\OneDrive\www, not.
{Image refused because not 10 of reputation.}
What are the "security setting" that I should use ?
What is the problem ?
I written in Laragon forum without any response !
Any advice please ?
Can someone help please ?
Thank you, good day.
Changed security settings in properties.
Reinstalled application with administrator power.
Formatted the drive.
added path ".;C:\laragon\etc\php\pear" & "C:\laragon\etc\php\pear" in System & User Environment variable, with no success.
Asked a friend to install Laragon, and set WWW in OneDrive, exactly the same problem.
If you don't want to use default www folder of laragon try any other folder outside Onedrive. you can do c:/www.
If you want to use Onedrive for syncing purposes i do recommend to use git instead
If you want to collaborate with somebody i do recommend to use following addons of VScode Live Share or Remote Development (Depends on use case)
I wrote above based on my experience and reasons why i wanted to use Onedrive for my code projects, even if you find a way to make it work again with Onedrive i do not recommend using it for servers, code or basically any project with multiple files that are being updated frequently.
I had cases of syncing issues where files were not uploaded fully on the server not showing any signs of errors, or onedrive corrupting files inside my local environment.
No issues so far for regular use, like archiving, syncing images or working with office documents.

file_get_contents() security issue on local domain only with CentOS security settings

I know there are a hundred posts about file_get_contents() on SO but nothing seems to solve my problem:
Everything was working fine fifteen minutes ago, until I ran some security stuff via SSH. I added some iptables rules and I file_get_contents and I ran service proftpd restart and a few installs/uninstalls which seems to have disabled PHP's fopen() functions somehow.
In php.ini, I have: allow_url_fopen = on & extension=php_openssl.dll on
I'm trying a simple test: (this file loads fine via the browser)
echo file_get_contents("https://www.this-domain.com/logo.gif");
//...failed to open stream:HTTP request failed! HTTP/1.1 404 Not Found...
//However both of the following work absolutely fine:
echo file_get_contents("https://www.google.com/");
echo file_get_contents("/home/user/domains/this-domain.com/private_html/media/logospin.gif");
I cannot change the file_get_contents() code (to cURL or otherwise) - this is a server settings issue. Possibly something to do with the firewall. Can someone please suggest a fix?
The problem was in fact a DNS issue. file_get_contents() was bizarrely routing through our backup nameservers (ns3 & ns4) for some reason, while browsers were routing through the primary nameservers (ns1 & ns2). Unlike the primaries, the backups point to a different server, which does not yet have identical files - hence the unusual 404.
I had set up these backup nameservers only a few hours before tinkering with the firewall etc and by the time they propagated, it looked very much like the ssh commands had taken file_get_contents() offline.
Thanks for all the comments guys - very much appreciated.

FTP fopen() error 550—not a plain file

Well, this is a problem I have never seen before.
I am trying to stream an FTP file using PHP's fopen() and feof() in order to copy it from one server to my own. This works fine when using normal http:// URLs. However, when using the ftp:// protocol, I'm receiving the following error:
fopen(ftp://.../streaming/planted2.mp4) [0function.fopen0]: failed to open stream: FTP server reports 550 /streaming/planted2.mp4: not a plain file.
Bear in mind that I have confirmed the URL is correct.
If I pop it into my browser's search bar, it always loads correctly.
Following this error, any attempt to use feof() or fread() on the wrapper results in an error complaining that the respective function expects a resource, but that instead a boolean is being provided. This would not be the case if fopen() was not failing.
As the files are quite large (several gigabytes at times) streaming is mandatory. Also, due to the configuration of the server, I need a way to loop through each chunk in order to buffer some output. If I don't, the server holds up. It's a weird configuration on Rackspace's behalf. That's why I'm using feof().
So, without further ado, my question is this: What does the 550 error mean, and what is a "plain file"? If it is a problem with the configuration of the server I am attempting to download from, what are my options, given my limitations?
EDIT
I have determined this is a server issue. However, the problem is still unresolved.
I contacted my boss and our server administrator, and the server guy told me to test this out on a different Windows-based server instead of the Linux-based one I was playing with. My script works with the Windows server, so I have confirmed my script is not in error.
Unfortunately, my boss still wants me to figure out the problem, and find out why it's not working on the Linux box. I have absolutely no idea why, and don't know where to look. Any hints would be greatly appreciated!
I've just come across this issue when trying to get a file from a sco unix server.
Server File Location: /home/user/data/myfile.csv
I can put the below into any browser and it gets the file.
ftp://user:password#host/data/myfile.csv
However if I run the below, I get the same error as you
$f = fopen("ftp://user:password#host/data/myfile.csv", "r");
However, if I put the full path into fopen - it works fine.
$f = fopen("ftp://user:password#host/home/user/data/myfile.csv", "r");
I'm not sure if this will fix it for you, but works for me.

PHP - fopen($url) failed to open stream: Permission denied in

I have to website with a very similar php configuration (actually on the same hosting account), with almost identical php code and with identical file structure. At some point, I call fopen(http://example.com/rssfedd.xml) to retrieve a RSS feed.
on http://sfdmorin.com/accueil/index.php everything works fine, on http://danielpoiriergda.ca/accueil/index.php i get:
Warning: fopen(http://affaires.lapresse.ca/rss/2399.xml)
[function.fopen]: failed to open stream: Permission denied in
/var/www/vhosts/danielpoiriergda.ca/httpdocs/snippet/lastRSS.php on
line 143
$f = fopen("http://affaires.lapresse.ca/rss/2399.xml", 'r');
Both website have php debug mode enabled and both have the same permissions for file and folders.
Both info.php have *allow_url_fopen* enabled for local and master value
Here are the major differences I found on both phpinfo() file:
not working site: Server API CGI/FastCGI
working site: Server API Apache 2.0 Handler
and on the working site there are no php.ini file in the path given by the loaded configuration file field
EDIT:
I know this thread is probably dead, but not the problem.
I check, with Netbeans fill diff, all the PHP code and php.ini are exactly the same on both domain.
I know similar questions were ask, but they did not help me.
Thank you!
Finally, I contacted my webserver tech support and they solve the problem. They did by:
adding an exception to SELinux
I dont have a clue wwhat SELinux is or what they did specificaly.

YII framework: CHTML.php not including

My site was working all fine on localhost but since when i have uploaded. It is showing an error
include(CHTML.php) [<a href='function.include'>function.include</a>]:
failed to open stream: No such file or directory
I am searching it since long and did many things for it..
Like importing 'system.web.helpers.*' in main.php,Still its not working.
Please somebody help and do help in detail, am new to YII.
Thanks in advance.
Is your local machine Windows and your remote server a *nix box? In that case, check your capitalization. CHTML.php suggests that you have case-mismatches, try using CHtml in your code instead.
Dev in Windows, deploy into Unix: Case sensitive issue.

Categories