SnippetMaster Support Forums
Return to main website
 
May 24, 2012, 07:49:12 AM
* Show unread posts since last visit.
* Show new replies to your posts.
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 24, 2012, 07:49:12 AM

Login with username, password and session length
Search:  
Advanced search
* Home Help Search Login Register
SnippetMaster Support Forums  |  General  |  General Discussion & Support  |  Topic: Notification of unwritable files « previous next »
Pages: [1] Print
Author Topic: Notification of unwritable files  (Read 1433 times)
James
Guest


Email
[-] Notification of unwritable files
« on: April 23, 2003, 07:16:17 PM »

Hi,

I've been frustrated a number of times forgetting to make snippet files editable. Here's a short addition which adds a 'not writable' comment to filenames in the drop-down list.
Add this line into 'includes/shared.lib.php', in the fileDropDown() function, after the line '$snippet_found = true;'
Code:
if (!is_writable($myfile)){ $myfile = "$myfile (Cannot Save)"; }

The dropdown will now add '(Cannot Save)' to filenames that aren't writable, but it causes a problem when trying to open the file since the filename is now incorrect. The best solution is to then fix the permission problem.
If you still want to load these files, even though you cannot save them, then the following line needs to be changed in the extractInfo() function. Near the start of the function, replace this:
Code:
if(!file_exists($path)) $this->returnError("The file located at \"$path\" does not exist<br>FUNC: extractInfo()");

with:
Code:
if(!file_exists($path)) { $path = preg_replace('/ \(.*\)$/', '', $path); if(!file_exists($path)) { $this->returnError("The file located at \"$path\" does not exist<br>FUNC: extractInfo()");} }

If a file doesn't exist it will check if the filename without comments (enclosed in brackets) exists, and will use that if it can.

Handy?
Report to moderator   Logged
admin
Forum Administrator
*
Posts: 3070

SnippetMaster Author


WWW
[-] Notification of unwritable files
« Reply #1 on: April 30, 2003, 07:01:28 PM »

This is excellent little piece of code.  Thanks!

Make sure to remind me to add this functionality into the next version of SnippetMaster... I'm just working on other parts at the moment, and don't want to overlook this.

(Be sure to sign up for the newsletter/mailing list so you know when I'm getting close to release.. probably about a month or so.)

Cheers!   Very Happy
Report to moderator   Logged
Pages: [1] Print 
SnippetMaster Support Forums  |  General  |  General Discussion & Support  |  Topic: Notification of unwritable files « previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!