[DEV] Post Crash Protection

A place for Extension Authors to post and receive feedback on Extensions still in development. No Extensions within this forum should be used within a live environment!
Suggested Hosts
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: Extensions Development rules

IMPORTANT FOR NEEDED EVENTS!!!
If you need an event for your extension please read this for the steps to follow to request the event(s)
Post Reply
ntvy95
Registered User
Posts: 69
Joined: Wed Jun 10, 2015 12:58 pm

[DEV] Post Crash Protection

Post by ntvy95 » Sun Jul 05, 2015 9:26 am

Post Crash Protection
Tested on: PHPBB 3.1.5 version.
This is the extension version of Post Crash Protection MOD by 4_seven. I am just a porter.
Download/Repository: GitHub
Installation Note:
- Download the zip file.
- Extract them to ext folder, directory structure: ext/ntvy95/postcrashprotection.
- Remember to move all the files (the folder itself is not included) in COPY_THESE_FILES_TO_ROOT folder to root folder.
- ACP -> Customise -> Enable "Post Crash Proctection".
Note: It also works with quick reply (not so sure with the original quick reply but quite sure with this QuickReply extension)
This is my first extension with little knowledge of PHP so I will be very grateful if anyone can point a way that no need to move files from COPY_THESE_FILES_TO_ROOT folder to root folder.
Have fun with it.
Last edited by ntvy95 on Mon Mar 05, 2018 12:38 pm, edited 2 times in total.

User avatar
david63
Registered User
Posts: 16319
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: [DEV] Post Crash Protection

Post by david63 » Sun Jul 05, 2015 9:45 am

If I am reading this correctly you are asking users to copy two files into the board root. This is not the correct procedure with an extension - all files (except, in some cases, dynamically created data files) must be contained within the extension.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

ntvy95
Registered User
Posts: 69
Joined: Wed Jun 10, 2015 12:58 pm

Re: [DEV] Post Crash Protection

Post by ntvy95 » Sun Jul 05, 2015 10:23 am

david63 wrote:If I am reading this correctly you are asking users to copy two files into the board root. This is not the correct procedure with an extension - all files (except, in some cases, dynamically created data files) must be contained within the extension.
Yes. That is why I am wondering if there is way that no need to copy/move those files to root folder. I am new to these things though...

User avatar
david63
Registered User
Posts: 16319
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: [DEV] Post Crash Protection

Post by david63 » Sun Jul 05, 2015 10:28 am

I haven't looked at all of the code in detail but the two files that you are copying to root could probably be handled as events.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
cYbercOsmOnauT
Registered User
Posts: 362
Joined: Wed Jun 16, 2004 8:22 am
Location: Goettingen, Germany
Name: Tekin Birdüzen

Re: [DEV] Post Crash Protection

Post by cYbercOsmOnauT » Sun Jul 05, 2015 11:15 am

Wouldn't it be better to solve this kind of stuff without the db but locally by using LocalStorage of the modern browsers? http://www.jstorage.info/
phpBB-installation and reparation. Prof. PHP coding with function guarantee. Just contact me at: t.birduezen@web-coding.eu.
Ex-German Support Team Member | phpBB Development Environment

ntvy95
Registered User
Posts: 69
Joined: Wed Jun 10, 2015 12:58 pm

Re: [DEV] Post Crash Protection

Post by ntvy95 » Sun Jul 05, 2015 1:04 pm

david63 wrote:I haven't looked at all of the code in detail but the two files that you are copying to root could probably be handled as events.
I am afraid it is not that simple. You may take a look at template event "posting_editor_buttons_custom_tags_before":

Code: Select all

<!-- IF not S_PRIVMSGS -->
$('#post_save').load('post_crash_protection.php?text=' +encodeURIComponent($('#message').val()));
<!-- ELSE -->
$('#post_save').load('post_crash_protection_pm.php?text=' +encodeURIComponent($('#message').val()));
<!-- ENDIF -->
cYbercOsmOnauT wrote:Wouldn't it be better to solve this kind of stuff without the db but locally by using LocalStorage of the modern browsers? http://www.jstorage.info/
Thank you very much. I will try to take a look at it. :D

User avatar
david63
Registered User
Posts: 16319
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: [DEV] Post Crash Protection

Post by david63 » Sun Jul 05, 2015 1:08 pm

koutogima wrote:I am afraid it is not that simple.
Why?

Almost everything that could be done in a 3.0 MOD can be done using events in 3.1 - although I will accept that there may not always be the necessary events in place and they will need to be requested.

Sometimes, especially when converting a MOD, you have to "think outside the box" as to how to achieve the desired result.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

ntvy95
Registered User
Posts: 69
Joined: Wed Jun 10, 2015 12:58 pm

Re: [DEV] Post Crash Protection

Post by ntvy95 » Sun Jul 05, 2015 1:18 pm

david63 wrote:
koutogima wrote:I am afraid it is not that simple.
Why?

Almost everything that could be done in a 3.0 MOD can be done using events in 3.1 - although I will accept that there may not always be the necessary events in place and they will need to be requested.

Sometimes, especially when converting a MOD, you have to "think outside the box" as to how to achieve the desired result.

I have edited the above post, now I think I should repost this:
You may take a look at template event "posting_editor_buttons_custom_tags_before":

Code: Select all

<!-- IF not S_PRIVMSGS -->
$('#post_save').load('post_crash_protection.php?text=' +encodeURIComponent($('#message').val()));
<!-- ELSE -->
$('#post_save').load('post_crash_protection_pm.php?text=' +encodeURIComponent($('#message').val()));
<!-- ENDIF -->
I didn't mean it is impossible. I believe that it is possible and it is just me the one who cannot figure out the way. The problem I have here is that:

- I have to use the global variables in services.yml such as @user, @auth, @dbal.conn.
- It looks like that my post_crash_protection.php will contain not only classes but some runable codes. The problem here is that I do not know how I should initialize the objects of the service classes my self.

I am googling around this and having no good result yet, a hint on this would be nice. Thanks. :D

User avatar
david63
Registered User
Posts: 16319
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: [DEV] Post Crash Protection

Post by david63 » Sun Jul 05, 2015 1:41 pm

Take a look at some of the extensions either validated or in development to see how things have been done. You will generally find that most things have already been done.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
draky
Registered User
Posts: 247
Joined: Tue Dec 10, 2002 2:04 pm
Location: France
Name: Gilles W.
Contact:

Re: [DEV] Post Crash Protection

Post by draky » Wed Jul 08, 2015 10:13 am

In fact, it is an autosaving feature (in draft).

As seen in Invision for instance.

Nice idea :)

Will wait for the "regular" extension (just an upload, without files to be copied).

User avatar
martti
Registered User
Posts: 752
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [DEV] Post Crash Protection

Post by martti » Thu Jul 09, 2015 8:54 pm

cYbercOsmOnauT wrote:Wouldn't it be better to solve this kind of stuff without the db but locally by using LocalStorage of the modern browsers? http://www.jstorage.info/
Yes

ntvy95
Registered User
Posts: 69
Joined: Wed Jun 10, 2015 12:58 pm

Re: [DEV] Post Crash Protection

Post by ntvy95 » Tue Jul 14, 2015 1:30 am

Fix an error related to new registration: Allow NULL value for the two columns.

You can edit the saving time interval in:
[ROOT]\ext\koutogima\postcrashprotection\styles\prosilver\template\event
In both ext_quickreply_editor_buttons_custom_tags_before.html and posting_editor_buttons_custom_tags_before.html, find:

Code: Select all

}, 60000);
60000 here is 60s, it means that every minutes the post is being saved once. You can change it into any number you want.

About the ability not to move those script into root folder: I am still not be able to do that. :'p

ntvy95
Registered User
Posts: 69
Joined: Wed Jun 10, 2015 12:58 pm

Re: [DEV] Post Crash Protection

Post by ntvy95 » Fri Aug 07, 2015 9:06 am

Fix: No more auto-replace single quote into double quotes.

Post Reply

Return to “Extensions in Development”