Safe to say, ive been looking around and it appears all data saves to a folder which isnt very easily accessed at the moment. So, I was hoping to save to a part of the folder where the plugin is located, take this for example.
```
Currently it seems to save into some far off locked folder which can only be accessed via Command prompt, while I would prefer it saves to `Mod/Automated_View_Script/reports/` to make it much easier for us.
Is there a simple way to do this?
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- ihayredinov@ihayredinov
ihayredinov - 0 likes
- Twitchy@Twitchy
Twitchy - 0 likes
error_reporting(E_ALL); //Get the page $title = get_input('title'); $body = get_input('body'); $date = date("l jS F Y h:i A");
//print to file
$folderName = 'Report'; $FileName = '././Reports/' . $folderName . " " . $date . '.txt'; $ReportContent = $body;
if (file_put_contents($FileName, $ReportContent)) { system_message("Report Created (" . basename($FileName) . ")"); forward(REFERER); } else { register_error("Report (" . basename($FileName) . ") was not saved!"); forward(REFERER); }
- ihayredinov@ihayredinov
ihayredinov - 0 likes
- Twitchy@Twitchy
Twitchy - 0 likes
- ihayredinov@ihayredinov
ihayredinov - 0 likes
- iionly@iionly
iionly - 0 likes
- Twitchy@Twitchy
Twitchy - 0 likes
- ihayredinov@ihayredinov
ihayredinov - 0 likes
- Twitchy@Twitchy
Twitchy - 0 likes
You must log in to post replies.Elgg files are access controlled and should not live in a publically accessible directory. All plugin files are publically accessible, so unless that's what you want, you need to reconsider your approach.
The far off locked directory is what you specified during installation.
What exactly are you trying to do?
Essentially im trying to save a text file filled with info from placeholder text and variables on a Form page. Clearly I cannot do that with Elgg as it saves to the database folder which is inaccessible for what this plugin will be used for.
I have moved towards regular PHP but regular PHP doesnt seem to want to save the file correctly after I press the save button. Does |Elgg not play nice with regular php functions?
code example
Let me know if you can!
You can save files in a regular Elgg action, just don't use ElggFile
How would I go about doing that then? Im sort of ripping my hair out here trying to figure out why I am having so much trouble saving this data to a text file.
In case you need to know, my information is brought it from a form that this save action is listed from, $body contains the information that I would like printed out in the text file.
If possible I want the file to save to /pluginfolder/Reports, or at least the /pluginfolder/actions where the save page im using is located.
I am not going to give you a solution, because I don't want to encourage insecure practices.
Example of bad practice in mod/gifts/actions/savegifts.php of the Gifts plugin (https://elgg.org/plugins/834971).
Well alright then.
Is at least possible to save in the directory specified as a text file with elggFile, rather than a database entry which it should technically do? Or is that also bad practice?
Or at least some way that the user will be able to open and read that saved file?
For the record, I am once more using the Elgg file system but even though the save is said to be successful, I cannot find it while browsing the storage location in the dataroot.
You can now find your file in:
Now if you need to open/download the file, you just use the same owner guid and filename.
This should help a lot, it might be some time before I can implement it due to other things im currently working on, but thank you for assisting me with this! I'll get to it as soon as I can.