PDA

View Full Version : Help me understand this php error (from vBlogetin)?


kira
07-16-2009, 06:45 PM
Hi guys. Like an idiot I'm using vBlogetin. This in itself is not idiocy -- or at least, it wouldn't have been a couple of years ago, when SirAdrian was in charge and the script was active. I've found it to be an excellent system, at least for my community's needs, and unlike vBlog and other products, it offers the ability for users to pick their own styles from pre-set options. I (and they) loved this.

But it's since been sold and the creators/maintainers/purchasers have gone AWOL.

Anyway, suddenly, although I've done nothing to my forum recently, my bloggers are having issues with changing styles. When they try, they receive this error:

Warning: fopen(/home/episodic/public_html/forums/blogs/datastore/972/styleid.php) [function.fopen]: failed to open stream: Permission denied in /blogs/backend/functions_blog.php on line 522

Fatal error: Could not open /home/episodic/public_html/forums/blogs/datastore/972/styleid.php for reading in /blogs/backend/functions_blog.php on line 525
#0 vb_error_handler(256, Could not open /home/episodic/public_html/forums/blogs/datastore/972/styleid.php for reading, /home/episodic/public_html/forums/blogs/backend/functions_blog.php, 525, Array ([userid] => 972,[file] => styleid,[data] => 100,[path] => /home/episodic/public_html/forums/blogs/datastore/972/,[filename] => /home/episodic/public_html/forums/blogs/datastore/972/styleid.php,[fileHandle] => )) called at [(null):0] #1 trigger_error(Could not open /home/episodic/public_html/forums/blogs/datastore/972/styleid.php for reading, 256) called at [/home/episodic/public_html/forums/blogs/backend/functions_blog.php:525] #2 saveUserFileDatastore(972, styleid, 100) called at [/home/episodic/public_html/forums/blogs/manage.php:396]

I have no flippin' idea what all this means. (I have a rudimentary capability at best in php, I'm ashamed to admit.) Can someone point me in the right direction, maybe? Just in case it helps, here are lines 505 - 530 in functions_blog.php:

function saveUserFileDatastore($userid, $file, $data)
{
$path = BLOG_DATASTORE . "/$userid/";
if (!is_dir($path))
{
$dirHandle = mkdir($path, 0777);

// umask fix
chmod($path, 0777);

if (!$dirHandle)
{
trigger_error("Could not create directory $path", E_USER_ERROR);
}
}
$filename = BLOG_DATASTORE . "/$userid/$file.php";

$fileHandle = fopen($filename, 'w');
if (!$fileHandle)
{
trigger_error("Could not open $filename for reading", E_USER_ERROR);
}

$newFile = '<?php if (!defined("BLOG_PATH")) { exit; } ';
$newFile .= '$data = ' . arrayToString($data) . '; ?>';


The weird thing is:

- Unlike the others, I can change my style. This makes sense, since I'm admin. But I cannot change others' styles, as I get the above message.

- Even weirder, I created a test user account and gave it the same permissions as others who are having problems, and this test user can change his/her style!

- New Data Point: I just went into the test user's blog from my regular admin account, and tried to manage the settings, and was able to change the style. So since I couldn't change the blog styles of the other users, something is clearly different from this blog and those of the folks having issues. But they all have the same usergroups. I don't get it. I wish I were smarter. :( I really do love this blogging system and will hate to give it up for vb4. I should've given it up once the original creators weren't able to maintain it, but it's just so much more bloggy than vBlog that I decided to stick with it. Serves me right, I guess.

It doesn't appear to be browser-specific. Both IE7 and FF are represented amongst the people having issues, as are both Vista and XP.

Does anyone have any ideas what could be the problem? Very frustrating. Again, I haven't made any changes to the forum.

Adrian Schneider
07-16-2009, 06:47 PM
I can help you over IM if you'd like.

kira
07-16-2009, 07:11 PM
OMG!!!

I would more than 'like', I would love that! I'll PM you. Thank you so much!

Edited to add: Rats, I guess I missed the opportunity. Anyone have any ideas in the meantime?

Marco van Herwaarden
07-17-2009, 08:29 AM
Most likely a permission problem on the blogs/datastore directory or 1 of it's subdirectories. All diretories (and files) under teh datastore directory must be writable by the webserver process.

kira
07-17-2009, 06:34 PM
Thanks, Marco. Yes, I do believe you're right. Adrian was kind enough to IM with me a bit yesterday, and in doing so, helped me find some possible/likely issues.

I've seen this error crop up a few times while searching on Google (and oddly it's always related to vBlogetin!), but no one seems to have a solution. So I'll give plenty of details just in case this shows up in someone else's search. Here's what I've determined so far.

First, I kinda sorta forgot that a couple of months back, my site changed servers. Heh. Yes, I'm apparently scatterbrained enough to forget a site move. In my defense, it was my webhost's doing (I'm on a shared server, which my hosts switched so they could upgrade our php version) and everything went smooth as silk, so I didn't have to do anything. So it was easy to forget that anything moved at all.

ANYway, once I remembered this vital piece of info, Adrian suggested that the server change may have reset the permissions on the files. He told me to go to FTP and check the permissions and ownership of the blogs/datastore directory, just as Marco above mentioned. He also recommended that I sign up as a new account, get a blog, and change the style so that the script would create a new styleid.php file. (Each blog owner gets his/her own directory in that blogs/datastore folder, and within that directory is a file called "styleid.php" that tells the program which style to use for that blog.)

I signed up with the test account and got a new blog, changed the style, and again had no problems. So this new account was clearly different in some way from the older accounts that couldn't change their styles.

Next I went through FTP to view permissions on the files. The permissions on the styleid.php for everyone, even the new accounts, was all the same -- 644. My own styleid.php was set to 777. So it doesn't appear to be a CHMOD solution here.

Then, after I went in through putty to view the file ownerships in the datastore folder, I saw that the 'owner' of the styleid files belonging to older blog accounts -- those that are having trouble changing styles -- is "episodic", which is the name of my hosting account. But the 'owner' of the newer files for new blogs is "nobody." For some reason, "nobody" works, but "episodic" doesn't.

Welp, that's the status so far. I haven't a clue how to fix this issue or what to do next, but am waiting hopefully for Adrian to get back to me, if he has time available. Of course, if in the meantime anyone else has any suggestions, I'd be extremely grateful! Thanks.

Marco van Herwaarden
07-20-2009, 10:57 AM
Simply reset the owner (nobody) and permissions (777) on all files and directories under ./datastore.