ACP Mod - Where should generated text files be stored?

Discussion forum for MOD Writers regarding MOD Development.
Locked
microUgly
Registered User
Posts: 88
Joined: Sat Jun 02, 2007 5:35 am

ACP Mod - Where should generated text files be stored?

Post by microUgly »

I have an ACP module that needs to generate some text files. The url for the text files will then be loaded by flash object in the ACP. The files will be constantly overwritten.

Where is the best place to write these files to? I was thinking the cache, since it's the only folder I know of that will have write access, but web access is forbidden (the flash object needs a URL).

I could make the text files php files, but that would require having to duplicate a lot of code, implement security, etc ,etc. And I would still need to store it somewhere. If they are just plain text files I don't need to be concerned about people prodding them if they find them.

I'm aiming to make the mod easily distributable.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52299
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: ACP Mod - Where should generated text files be stored?

Post by Brf »

Why dont you just create a new folder?
microUgly
Registered User
Posts: 88
Joined: Sat Jun 02, 2007 5:35 am

Re: ACP Mod - Where should generated text files be stored?

Post by microUgly »

Brf wrote:Why dont you just create a new folder?
I didn't want to create unneccessary extra steps if an appropriate area already exists. I'm thinking I might need to step back and look at the problem again. Writing a text file isn't going to be a good solution in a multi-user system.
User avatar
th23
Registered User
Posts: 233
Joined: Sat Jul 03, 2004 7:36 am
Location: Germany
Contact:

Re: ACP Mod - Where should generated text files be stored?

Post by th23 »

Maybe think about storing the value in the $config array and pass the value on to the flash as a param value...just came across my mind, can't tell you how to handle this in Flash
Life is what happens...while you're busy making other plans!
User avatar
JRSweets
Registered User
Posts: 2047
Joined: Wed Apr 14, 2004 8:37 pm
Location: Massachusetts

Re: ACP Mod - Where should generated text files be stored?

Post by JRSweets »

microUgly wrote:I have an ACP module that needs to generate some text files. The url for the text files will then be loaded by flash object in the ACP. The files will be constantly overwritten.

Where is the best place to write these files to? I was thinking the cache, since it's the only folder I know of that will have write access, but web access is forbidden (the flash object needs a URL).

I could make the text files php files, but that would require having to duplicate a lot of code, implement security, etc ,etc. And I would still need to store it somewhere. If they are just plain text files I don't need to be concerned about people prodding them if they find them.

I'm aiming to make the mod easily distributable.
What about the /store folder? It should be writable...
microUgly
Registered User
Posts: 88
Joined: Sat Jun 02, 2007 5:35 am

Re: ACP Mod - Where should generated text files be stored?

Post by microUgly »

Nah, store is forbidden also.

I've started a new thread that looks at the overall problem - http://www.phpbb.com/community/viewtopi ... 1&t=930335
User avatar
igorw
Former Team Member
Posts: 8024
Joined: Fri Dec 16, 2005 12:23 pm
Location: {postrow.POSTER_FROM}
Name: Igor Wiedler

Re: ACP Mod - Where should generated text files be stored?

Post by igorw »

I don't see why you are generating text files anyway. Why don't you just generate them in the ACP module? You just add a new "text" mode and have the swf call that. No need to write to any files at all.
Igor Wiedler | area51 | GitHub | trashbin | Formerly known as evil less than three
microUgly
Registered User
Posts: 88
Joined: Sat Jun 02, 2007 5:35 am

Re: ACP Mod - Where should generated text files be stored?

Post by microUgly »

eviL<3 wrote:I don't see why you are generating text files anyway. Why don't you just generate them in the ACP module? You just add a new "text" mode and have the swf call that. No need to write to any files at all.
This is the kind of suggestion I was looking for :) But I don't quite get how it would work. When you say "text mode" you do mean a mode of a module (where a module can have several modes). How do you create a plain text mode--one that doesn't use the ACP template?
microUgly
Registered User
Posts: 88
Joined: Sat Jun 02, 2007 5:35 am

Re: ACP Mod - Where should generated text files be stored?

Post by microUgly »

Don't answer that. I really should have looked at how modules worked before asking.

What i've done is create an acp style that doesn't include any files and uses only one template variable to create the plain text mode. The plain text template file is loaded only for that mode, otherwise all other modes load the normal template file.

I also wasn't sure about how to properly write the URL for the mode because of the session id, but I think append_sid gets around that.

I really like how modules work in phpBB3.
User avatar
igorw
Former Team Member
Posts: 8024
Joined: Fri Dec 16, 2005 12:23 pm
Location: {postrow.POSTER_FROM}
Name: Igor Wiedler

Re: ACP Mod - Where should generated text files be stored?

Post by igorw »

In fact, for this you don't even have to use the template system.

Code: Select all

<?php

header('Content-type: text/plain; charset=utf-8');

echo 'I am a text file.';

exit;

?>
Igor Wiedler | area51 | GitHub | trashbin | Formerly known as evil less than three
microUgly
Registered User
Posts: 88
Joined: Sat Jun 02, 2007 5:35 am

Re: ACP Mod - Where should generated text files be stored?

Post by microUgly »

Won't this upset the module? I found that the mode needed a template file to be loaded otherwise phpBB reported an error.

I probably need to use the header code anyway--but I think I have to still specify a template file.
microUgly
Registered User
Posts: 88
Joined: Sat Jun 02, 2007 5:35 am

Re: ACP Mod - Where should generated text files be stored?

Post by microUgly »

Unfortunately, I can't set the header content type. I think the template code must override it.

If I don't define $this->tpl_name I get the error:
General Error
template->_tpl_load_file(): File ./style/.html does not exist or is empty
Is there a trick to get around this? It doesn't really matter if I use a template or not, but I think it would be best to set the content type to plain text. Thanks.
User avatar
igorw
Former Team Member
Posts: 8024
Joined: Fri Dec 16, 2005 12:23 pm
Location: {postrow.POSTER_FROM}
Name: Igor Wiedler

Re: ACP Mod - Where should generated text files be stored?

Post by igorw »

It seems you forgot the exit;, if that's missing then it tries to load a template file.
Igor Wiedler | area51 | GitHub | trashbin | Formerly known as evil less than three
microUgly
Registered User
Posts: 88
Joined: Sat Jun 02, 2007 5:35 am

Re: ACP Mod - Where should generated text files be stored?

Post by microUgly »

Ah, thankyou. This has worked charm. Thanks for your guidance. I would never have thought to use a mode to generate the text file.
User avatar
igorw
Former Team Member
Posts: 8024
Joined: Fri Dec 16, 2005 12:23 pm
Location: {postrow.POSTER_FROM}
Name: Igor Wiedler

Re: ACP Mod - Where should generated text files be stored?

Post by igorw »

No problem, glad to help :)
Igor Wiedler | area51 | GitHub | trashbin | Formerly known as evil less than three
Locked

Return to “[3.0.x] MOD Writers Discussion”