Forum Moderators: coopster

Message Too Old, No Replies

permission problems with fopen

         

kenfused

6:56 am on Nov 13, 2006 (gmt 0)

10+ Year Member



Help!
I'm using a script for a wordpress plugin, for a newletter function.

When I try to send a newsletter I get

"Warning: fopen(test.htm): failed to open stream: Permission denied in /home/website/plugins/st_newsletter/shiftthis-pages.php on line 229
can't open file"

What do I need to do to fix this?
chmod something?

the guy who wrote the plugin is out of town for 15 days!

[edited by: dreamcatcher at 10:31 am (utc) on Nov. 13, 2006]
[edit reason] Generalized url. [/edit]

ramoneguru

7:27 am on Nov 13, 2006 (gmt 0)

10+ Year Member



Give it a shot:

chmod u+x test.htm
--Nick

[man.he.net...]

If you didn't already have it (sounds like you did, but just wanted to make sure) :-)

kenfused

7:34 pm on Nov 13, 2006 (gmt 0)

10+ Year Member



Hmmm..
I don't know where the file test.htm resides?

There doesn't seem to be that file anywhere?

I had tried creating a blank document with that filename, then chmod it to 777, but no go.

ramoneguru

10:41 pm on Nov 13, 2006 (gmt 0)

10+ Year Member



According to the error message:
Permission denied in /home/website/plugins/st_newsletter/shiftthis-pages.php on line 229
can't open file

On line 229 of shiftthis-pages.php its attempting to do something like:
fopen($somefile) and halting right there, if you have access to the file (shiftthis-pages.php) check the code and determine where $somefile is being set. If its hard-coded like fopen("/home/rasmus/file.txt", "r") then make sure the file is in that directory and you have authorization to access it within the app, ie. it might be a security issue if access is allowed which would explain why its being denied.

If it still doesn't work, check the plugin documentation and make sure the script you have doesn't interfere with what the plugin is trying to accomplish.

I'm sure others have a better way of debugging, but those are some of the preliminary steps I'd take............also, make sure things are spelled correctly :-)

--Nick

If all that fails, call the guy up and explain the situation.

kenfused

6:05 am on Nov 15, 2006 (gmt 0)

10+ Year Member



Thanks for the suggestion.

"test.htm" is only asked for here:

<?php if ( isset($_GET['send_newsletter']) ) {
$nid = $_GET['send_newsletter'];
$from = $st_newsletter_config['newsletter_efrom'];
$title = $wpdb->get_var("SELECT st_title FROM $table_prefix"."st_newsletter WHERE st_id=$nid");
$subject = $st_newsletter_config['newsletter_esubject'].$title;
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '. $from . "\r\n";
$html = newsletter_returnhtml($nid, $email);
$filename = 'test.htm';
$ourFileHandle = fopen($filename, 'w') or die("can't open file");
fwrite($ourFileHandle, $html);
fclose($ourFileHandle);

I tried making "test.htm" and chmod to 777 in a few different directories, but to no avail!

Thanks for any suggestions

alfaguru

8:37 pm on Nov 15, 2006 (gmt 0)

10+ Year Member



Try adding

echo(realpath('test.htm'));

before the point where you get the error. That'll print the absolute path for the file.

ramoneguru

6:49 am on Nov 16, 2006 (gmt 0)

10+ Year Member



Hmmmm, use the suggestion above and if that doesn't work try using chmod 0777 instead (you need to use octal values).........after that I'm out of ideas *shrug*
--Nick

kenfused

5:16 pm on Nov 16, 2006 (gmt 0)

10+ Year Member



Thanks alfaguru!

B/c I knew where to look, I created the blank file and chmoded it to 777

Was in a totally unexpected directory!