None of my mods, wherever you find them, are abandoned.
All of them are in developement, even if i am not active on phpbb.com.

[DEV] Post Crash Protection v.0.0.2

[DEV] 3.0.* Mod Base

[DEV] Post Crash Protection v.0.0.2

Postby Sekuro » 10 Oct 2011, 00:29

Post Crash Protection

MOD-Title: Post Crash Protection
MOD-Version: 0.0.2
MOD-Author: 4seven

Credit: BNa

phpBB-Version: phpBB 3.0.x
phpBB-Languages: en
phpBB-Styles: prosilver

License: GNU General Public License v2

MOD-Description: This Mod saves the last Post and PM of each User, if Browser or Os crashes

Features: (v.0.0.2)
- Saving post and pm in adjustable interval for each reg. user
- Post/PM is saved, no matter if your browser/os crashes or you closing browser/tab
- Additions for genuine phpBB QR and Prime Quick Reply

Screens:
- post: http://www.loaditup.de/files/619571_2ttey4wwrw.jpg
- pm: http://www.loaditup.de/files/619572_b97tw4mfak.jpg

Demo:
- http://4seven.bplaced.net/forum/media/postin ... e=post&f=9 (un: tester | pw: testuser)

- Write or copy a text to postbox and close the browser (currently the post is saved each 3 sec.)
- Then start the browser, may logg in again and click on button [Insert Saved Post] (posting) / [Insert Saved PM] (pm)
- Note: Write nothing in postbox, before u insert the saved text, bcs. the saving of post start again.


Download:
Post_Crash_Protection_v.0.0.2.zip
(34.08 KiB) Downloaded 375 times

Image

Image

Requirements: Javascript enabled

Addition #1 for genuine phpBB3 QR for v.0.0.2
Instruction: viewtopic.php?p=174#p174

Demo: http://4seven.bplaced.net/forum/3/viewtopic.php?f=3&t=6 (un:tester | pw: tester)

Addition #2 for Prime Quick Reply for v.0.0.2
Instruction: viewtopic.php?p=175#p175

Demo: viewtopic.php?f=2&t=79&p=173#p173 (un:test| pw: testuser)

Screen: http://www.loaditup.de/files/624116_pnm275urmb.jpg

Fixed/Optimized: (v.0.0.2)
- Independent Posting- and PM-Save
- Linebreak bug on js insert is fixed
- Main code reviewed and corrected
- Reduce Spoiler to discrete Insert-Button
- Move Template-Code to posting_buttons.html
- More decent look and feel

Updates/Fixes: (v.0.0.2)
Very Long Post Chars Allowed Fix I for v.0.0.2
viewtopic.php?p=176#p176

Very Long Post Chars Allowed Fix II for v.0.0.2
viewtopic.php?p=177#p177
Mod-Bot / Service-Team
User avatar
Sekuro

Tiptop

Tiptop
 
Posts: 241
Joined: 11 Feb 2008, 11:49
 
Resolution: 1440x900



Addition #1 for genuine phpBB3 QR for v.0.0.2

Postby Sekuro » 18 Oct 2011, 19:11

Addition #1 for genuine phpBB3 QR for v.0.0.2

open

viewtopic.php

find


Code: Select all
            ($topic_data['topic_status'] == ITEM_LOCKED) ? $qr_hidden_fields['lock_topic'] = 1 : true;


after add

Code: Select all
    //Post Crash Protection /  Addition #1 / 4seven / 2011
    $sql_last_sel    = 'SELECT last_post_text 
                        FROM '
 . USERS_TABLE . "
                        WHERE user_id = "
 . (int) $user->data['user_id'];
    $result_last_sel = $db->sql_query_limit($sql_last_sel, 1);
    $last_sel        = $db->sql_fetchrowset($result_last_sel);
    $db->sql_freeresult($result_last_sel);
    //Post Crash Protection /  Addition #1 / 4seven / 2011        


find

Code: Select all
                'S_QUICK_REPLY'            => true,


after add

Code: Select all
                //Post Crash Protection / Addition #1 / 4seven / 2011
                'POST_SAVE_INSERT'        => (!empty($last_sel[0]['last_post_text'])) ? $last_sel[0]['last_post_text'] : '',    
                
//Post Crash Protection / Addition #1 / 4seven / 2011           


open

styles/prosilver/tenplate/quickreply_editor.html

find (the second find)

Code: Select all
    <form method="post" action="{U_QR_ACTION}">


replace with

Code: Select all
    <form method="post" id="qr_protection" action="{U_QR_ACTION}">


find (the second find)

Code: Select all
                            <dd><input type="text" name="subject" id="subject" size="45" maxlength="64" tabindex="2" value="{SUBJECT}" class="inputbox autowidth" />


after add

Code: Select all
    <!-- Post Crash Protection / Addition #1 / 4seven / 2011 -->
    <!-- IF S_USER_LOGGED_IN && (SCRIPT_NAME eq 'viewtopic') -->
    <script type="text/javascript">
    // <![CDATA[ 
    !window.jQuery && document.write('<script type="text\/javascript" src="http:\/\/code.jquery.com\/jquery-latest.min.js"><\/script>');
    // ]]> 
    </script>
    <input type="hidden" id="content" value="{POST_SAVE_INSERT}" />
    <script type="text/javascript">
    // <![CDATA[
    function imgcopy(){
    var copy = $('#content').val();
    document.forms['qr_protection'].message.value += copy;
    document.forms['qr_protection'].message.focus();
    return false;
    }
    $(document).ready(function(){
    var refreshId = setInterval(function() {
    $('#post_save').load('post_crash_protection.php?text=' +encodeURIComponent($('#message').val()));
    }, 12000);
    });
    // ]]>    
    </script>
    <input type="button" class="button2" value="{L_INSR_SAVED_POST_TEXT}" onclick="imgcopy();" />
    <div id="post_save" style="display: none;"></div>     
    <!-- ENDIF -->
    <!-- Post Crash Protection / Addition #1 / 4seven / 2011 -->


If you dont find an

id="message" before/after name="message"

in the second find of

Code: Select all
                <div id="message-box">
                    <textarea style="height: 9em;" name="message" rows="7" cols="76" tabindex="3" class="inputbox"></textarea>
                </div

than change it to

Code: Select all
                <div id="message-box">
                    <textarea style="height: 9em;" name="message" id="message" rows="7" cols="76" tabindex="3" class="inputbox"></textarea>
                </div

- Clear all Board- and Browser-Caches

- Adjust this Code-Part

Code: Select all
12000


in styles/prosilver/template/quickreply_editor.html

to set the Intervall of Saving in Milliseconds.
Mod-Bot / Service-Team
User avatar
Sekuro

Tiptop

Tiptop
 
Posts: 241
Joined: 11 Feb 2008, 11:49
 
Resolution: 1440x900



Addition #2 for Prime Quick Reply for v.0.0.2

Postby Sekuro » 18 Oct 2011, 19:13

Addition #2 for Prime Quick Reply for v.0.0.2

open

viewtopic.php

find

Code: Select all
    // Output the page
    
page_header($user->lang['VIEW_TOPIC'] . ' - ' $topic_data['topic_title'], true$forum_id); 


before add

Code: Select all
    //Post Crash Protection /  Addition #2 / 4seven / 2011
    
$sql_last_sel    'SELECT last_post_text 
                        FROM ' 
USERS_TABLE "
                        WHERE user_id = " 
. (int) $user->data['user_id'];
    
$result_last_sel $db->sql_query_limit($sql_last_sel1);
    
$last_sel        $db->sql_fetchrowset($result_last_sel);
    
$db->sql_freeresult($result_last_sel);
            
$template->assign_vars(array(
                
'POST_SAVE_INSERT'        => (!empty($last_sel[0]['last_post_text'])) ? $last_sel[0]['last_post_text'] : '' 
                
));
    
//Post Crash Protection /  Addition #2 / 4seven / 2011   


open

styles/prosilver/tenplate/prime_quick_reply.html

find

Code: Select all
                </dl>
            </
div>
            <
fieldset class="fields1" style="margin-bottom:0.5em;"


before add

Code: Select all
        <!-- Post Crash Protection Addition #2 / 4seven / 2011 -->
        
<!-- IF S_USER_LOGGED_IN && (SCRIPT_NAME eq 'viewtopic') -->
        <
dd><hr /></dd>
        <
dd>
        <
script type="text/javascript">
        
// <![CDATA[ 
        
!window.jQuery && document.write('<script type="text\/javascript" src="http:\/\/code.jquery.com\/jquery-latest.min.js"><\/script>');
        
// ]]> 
        
</script>
        <input type="hidden" id="content" value="{POST_SAVE_INSERT}" />
        <script type="text/javascript">
        // <![CDATA[
        function imgcopy(){
        var copy = $('#content').val();
        document.forms['postform'].message.value += copy;
        document.forms['postform'].message.focus();
        return false;
        }
        $(document).ready(function(){
        var refreshId = setInterval(function() {
        $('#post_save').load('post_crash_protection.php?text=' +encodeURIComponent($('#message').val()));
        }, 12000);
        });
        // ]]>    
        </script>
        <input type="button" class="button2" value="{L_INSR_SAVED_POST_TEXT}" onclick="imgcopy();" />
        <div id="post_save" style="display: none;"></div> 
        </dd>   
        <!-- ENDIF -->
        <!-- Post Crash Protection / Addition #2 / 4seven / 2011 -->


- Clear all Board- and Browser-Caches

- Adjust this Code-Part

Code: Select all
12000


in styles/prosilver/template/prime_quick_reply.html

to set the Intervall of Saving in Milliseconds.
Mod-Bot / Service-Team
User avatar
Sekuro

Tiptop

Tiptop
 
Posts: 241
Joined: 11 Feb 2008, 11:49
 
Resolution: 1440x900



Very Long Post Chars Allowed Fix I for v.0.0.2

Postby Sekuro » 18 Oct 2011, 19:20

Very Long Post Chars Allowed Fix I for v.0.0.2

If you have much more digits allowed as the most boards, change in the template-parts of edits

find (in mod edits)

Code: Select all
$('#post_save').load('post_crash_protection.php?text=' +encodeURIComponent($('#message').val()));


change to

Code: Select all
$('#post_save').load('post_crash_protection.php?sid={SESSION_ID}', {text : encodeURIComponent($('#message').val())});


clear all board-, template-, style- and browsercaches
Mod-Bot / Service-Team
User avatar
Sekuro

Tiptop

Tiptop
 
Posts: 241
Joined: 11 Feb 2008, 11:49
 
Resolution: 1440x900



Very Long Post Chars Allowed Fix II for v.0.0.2

Postby Sekuro » 18 Oct 2011, 19:22

Very Long Post Chars Allowed Fix II for v.0.0.2

If any UTF-8 issue, you can try

  • change posting_buttons.html to utf8 without bom via notepad++
  • and change

    Code: Select all
    $('#post_save').load('post_crash_protection.php?sid={SESSION_ID}', {text : encodeURIComponent($('#message').val())});

  • to

    Code: Select all
    $('#post_save').load('post_crash_protection.php?sid={SESSION_ID}', {text : $('#message').val()});
which is my favorite version, even if there are no errors. more pure.
Mod-Bot / Service-Team
User avatar
Sekuro

Tiptop

Tiptop
 
Posts: 241
Joined: 11 Feb 2008, 11:49
 
Resolution: 1440x900



Return to phpbb 3.0.* St@ff

Who is online

Users browsing this forum: No registered users and 1 guest

cron