[ABD] [ALPHA] [3.2] Live notification using Websockets

Any abandoned Extensions will be moved to this forum.

WARNING: Extensions in this forum are not currently being supported or maintained by the original Extension author. Proceed at your own risk.
Forum rules
IMPORTANT: Extension Development Forum rules

WARNING: Extensions in this forum are not currently being supported nor updated by the original Extension author. Proceed at your own risk.
Locked
lexlf
Registered User
Posts: 13
Joined: Fri Apr 12, 2019 3:50 pm

[ABD] [ALPHA] [3.2] Live notification using Websockets

Post by lexlf »

Extension Name: Live new messages
Author: alexlf

Extension Description: This extension allows to be notified from new post without the need to reload the page. A discrete notification will be displayed in the corner right of the page.
Image

Extension Version: 0.4.0

Requirements: 3.2+
Extra Requirements: Python3

Features: The plugin uses a Python Websocket Server (which supports TLS encryption for https board) and the extension itself.
If a user follows a topic, he is able to receive an instant notification anywhere on the forum (except ACP), with a link to the new post. There is no need to reload the page


Installation process:
  • Download the basic_installation.zip file and unzip it.
  • Open python\config.py file (with notepad or any text editor.
    Modify the DATABASE_CONFIG parameters. You should put the informations required for the Python server to connect to mysql.

    Please note the server only requires a read access to the tables "users" and "topics".
    You should create a specific mysql user which will only have these rights (facultative, but highly recommended).
    If you plan to run the server from another hardware, the firewall and mysql access should allow the other ip.

    In my example, I will run on the same hardware (127.0.0.1). My database is called "forum_php_bb" and I use a root user without password. My mysql database is configured by default (port 3306).

    Image

    Next, we create the internal parameter for the server.
    In my example, my server adress is 79.130.XX.XXX, and I have configured my firewall to open port 9001.
    I also need to set up a specific key that will be used by phpbb to be recognized. This can be anything, just take care to avoid semicolon (;).
    I use daz8d94azd8az4daz6d for this example.

    Image

    Next, we need to choose if we use SSL or not. If your apache server is not configured to use SSL, just keep "USE_SSL = 0" and go to "board_url" configuration.
    If your board uses SSL, you will need to use SSL too. Otherwise, web browsers will not allow the connexion for safety reasons.
    You will need to configure the path of your certificate and its key, and set "USE_SSL" to 1.

    Image

    You will need to select the adress of the board, as it will be used for the correct redirection for the posts.
    The information is available in script path from the home Admin Panel.

    Image

    In my example, my board is localized in /forum2/ and I have let the default prefix for phpbb table : "phpbb_"

    Image

    You can next edit the message sent to the users when a new post has been set up. (I will let it by default).

    The debug variable is set to False. It gives more information about the different actions of the server.

    Once done, you should install python3 if it has not yet been done. I developed the server with Python3.6.4 and it should run on all upper version.
    You can download python [here](https://www.python.org/downloads/) (do not forget to install pip when it will be proposed in the installation. we need it right after !)

    To install the dependancies, simply paste the following commands:

    Code: Select all

    pip3 install SimpleWebSocketServer
    pip3 install mysql-connector 
    pip3 install asyncio
    Once done, you can try to start the server.

    Code: Select all

    python3 Server.py
    If everything works fine, you should just see "Connection ok" printed.
  • Open ext\alexlf\livenewmessages\event\main_listener.php
    Modify line 66.

    Image

    If you run without SSL encryption, use "ws://" as protocol. Otherwise, write "wss://".
    Next, add the host of the server (it can be IP or DNS...), next the port.

    For example, if I have an encrypted connexion and my dns is "www.superboard.com", running on port 9001, my line should look like :

    Code: Select all

    $client = new Client("wss://www.superboard.com:9001/");
    Without encryption :

    Code: Select all

    $client = new Client("wss://www.superboard.com:9001/");
    Next line, also requires the key of the server.

    Image

    In my example, this is daz8d94azd8az4daz6d

    Code: Select all

    $client->send("1;daz8d94azd8az4daz6d;".$event["data"]["topic_id"].";".$user->data["username"].";".$event["data"]["post_id"]);
  • Open ext\alexlf\livenewmessages\styles\all\template\styles\all\template\js\websocket.js
    Modify line 1 and 8 to match the correct address of the Python server (as you did for the $client variable line 66 of main_listener).
    In my example, I get the following :

    Image
  • If you wish to modify the style of the notification, you can modify this css : ext\alexlf\livenewmessages\styles\all\template\styles\all\template\css\alertify_alexlf_corrected.css
Future modifications planned: I face multiple issues that I need to fix for release. The alpha is however available (and I use it for one of my websites).
  • Fixing "vendor" folder: A basic_installation.zip is provided in the github repro. The installation process has been updated in the README. According to this post, it is not yet possible to download the associated repro and composer install them automatically. This part will be probably updated when phpbb future version will allow the modification.
  • Using events to update the topics watched: The server requires to know which topics are followed by each user logged in. I planned to perform this through events, but they are not natively available on the public phpbb version. For this reason, the server updates all elements every 5 seconds. (which is not optimized and needs to be fixed as a priority).
  • Parameters management from ACP: For the moment, a lot of parameters are managed by the administrator from the .php files. Creating an interface into the ACP is planned.
  • Customization: The message can be easily customized from the server. However, AlertifyJS is used to animate the notification. Giving more possibilities from ACP is planned.
  • Create a unique key per user: Today, the system recognize the user based on his registration date and id (extracted from the main_listener.php). I wanted to use the sessions table, but it is not updated as much as I wish. It seems necessary to create extension management to correctly manipulate user security keys.
  • Safety against massive connections/fail connection attempts: Today, the server works, but is not secured against DDOS attempts by massive connections. A cleaning security should be set up to avoid bruteforce attacks.
  • Full migration as php websocket server: I do not know if this is possible but having a websocket server running only from a simple extension installation, without Python or external command line would be the optimal solution.
  • User management: Once set up, the notification system is used by all user. Giving them the possibility to disable it seems a good option.
  • Mobile version: Even if I did not experience real issues working on mobile... I imagine it would be better to adapt the notification for mobile version. I don't have precise idea of the shape it will take however.
Extension Download: https://github.com/alexandrelefourner/P ... tification

Last update: 06.22.2019

Special thanks:
  • david63 for his feedback about composer.js and the missing normalization in the extension.
Last edited by lexlf on Sat Jun 22, 2019 4:11 pm, edited 1 time in total.
User avatar
RomaamoR
Registered User
Posts: 188
Joined: Tue Feb 24, 2015 4:45 pm
Contact:

Re: [ALPHA] [3.2] Live notification using Websockets

Post by RomaamoR »

Code: Select all

[phpBB Debug] PHP Warning: in file [ROOT]/ext/alexlf/livenewmessages/event/main_listener.php on line 12: require([ROOT]/ext/alexlf/livenewmessages/vendor/autoload.php): failed to open stream: No such file or directory
[phpBB Debug] PHP Warning: in file [ROOT]/ext/alexlf/livenewmessages/event/main_listener.php on line 12: require([ROOT]/ext/alexlf/livenewmessages/vendor/autoload.php): failed to open stream: No such file or directory
User avatar
david63
Registered User
Posts: 18105
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: [ALPHA] [3.2] Live notification using Websockets

Post by david63 »

Can I suggest that if you are considering at some point to submit this extension to the CDB that you familiarise yourself with phpBB's Coding Guidelines as currently there are quite a few areas where your extension is falling short.
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
lexlf
Registered User
Posts: 13
Joined: Fri Apr 12, 2019 3:50 pm

Re: [ALPHA] [3.2] Live notification using Websockets

Post by lexlf »

RomaamoR wrote:
Sat Jun 22, 2019 10:49 am

Code: Select all

[phpBB Debug] PHP Warning: in file [ROOT]/ext/alexlf/livenewmessages/event/main_listener.php on line 12: require([ROOT]/ext/alexlf/livenewmessages/vendor/autoload.php): failed to open stream: No such file or directory
[phpBB Debug] PHP Warning: in file [ROOT]/ext/alexlf/livenewmessages/event/main_listener.php on line 12: require([ROOT]/ext/alexlf/livenewmessages/vendor/autoload.php): failed to open stream: No such file or directory
As explained in the github installation process, you need to run "composer install" in the "websocket-php" directory and transfer both "vendor" and "lib" libraries into the extension.
Update: All files are now available in a zip file. No need to compile anything. Just unzip and follow the installation process from "configuration".
david63 wrote:
Sat Jun 22, 2019 12:00 pm
Can I suggest that if you are considering at some point to submit this extension to the CDB that you familiarise yourself with phpBB's Coding Guidelines as currently there are quite a few areas where your extension is falling short.
Hello david63, thank you for your feedback. Could you precise which part would need more attention ?... Because Python is not a language where you will use brackets and it is not clear which part should be fixed this way... I corrected the indentation if you're talking about the style file... but a more detailed feedback would be welcome :)
Last edited by lexlf on Sat Jun 22, 2019 4:15 pm, edited 1 time in total.
User avatar
david63
Registered User
Posts: 18105
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: [ALPHA] [3.2] Live notification using Websockets

Post by david63 »

lexlf wrote:
Sat Jun 22, 2019 1:20 pm
Could you precise which part would need more attention
There are quite a lot
  1. You cannot use global $user; in an event - you need to inject $user (which you have done
  2. Opening { should be on a new line.
  3. If you are using vendor file then you need to load it via composer.json
  4. You should be using Twig syntax in your template file.
  5. js code should be in its own file.
  6. Loading remote files is not normally allowed for security reasons - the .css and .js files should be held locally.
There may be a few more that I have missed.
lexlf wrote:
Sat Jun 22, 2019 1:20 pm
As explained in the github installation process, you need to run "composer install" in the "websocket-php" directory and transfer both "vendor" and "lib" libraries into the extension.
An extension has to be totally self contained - you cannot ask/expect a user to run composer - many would not even know what it is.
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
lexlf
Registered User
Posts: 13
Joined: Fri Apr 12, 2019 3:50 pm

Re: [ALPHA] [3.2] Live notification using Websockets

Post by lexlf »

david63 wrote:
Sat Jun 22, 2019 2:27 pm
There are quite a lot
  1. You cannot use global $user; in an event - you need to inject $user (which you have done
  2. Opening { should be on a new line.
  3. If you are using vendor file then you need to load it via composer.json
  4. You should be using Twig syntax in your template file.
  5. js code should be in its own file.
  6. Loading remote files is not normally allowed for security reasons - the .css and .js files should be held locally.
There may be a few more that I have missed.
lexlf wrote:
Sat Jun 22, 2019 1:20 pm
As explained in the github installation process [...]
An extension has to be totally self contained - you cannot ask/expect a user to run composer - many would not even know what it is.
Thank you for this detailed answer! I did not hear of Twig syntax before and I did my best to make them conform. I also changed the composer system to have everything packaged in a zip file and removed cdn to store everything at the same place.
User avatar
</Solidjeuh>
Registered User
Posts: 1788
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [ALPHA] [3.2] Live notification using Websockets

Post by </Solidjeuh> »

lexlf wrote:
Fri Jun 21, 2019 9:09 pm
Open python\config.py file (with notepad or any text editor.
Modify the DATABASE_CONFIG parameters. You should put the informations required for the Python server to connect to mysql.
I don't think all of this will pass phpBB validation. An ext should be "ready to use" and any configurations should be done via ACP... Most users are not that "technical". ;)
lexlf
Registered User
Posts: 13
Joined: Fri Apr 12, 2019 3:50 pm

Re: [ALPHA] [3.2] Live notification using Websockets

Post by lexlf »

</Solidjeuh> wrote:
Sat Jun 22, 2019 4:50 pm
lexlf wrote:
Fri Jun 21, 2019 9:09 pm
Open python\config.py file (with notepad or any text editor.
Modify the DATABASE_CONFIG parameters. You should put the informations required for the Python server to connect to mysql.
I don't think all of this will pass phpBB validation. An ext should be "ready to use" and any configurations should be done via ACP... Most users are not that "technical". ;)
Indeed. For the phpbb, I work on ACP management.
However, to configure the Python Server at the same time... At first, I imagined a minimum of the config file will be necessary... but since you mentioned it, maybe the config file could be created by the ACP management itself...
User avatar
RomaamoR
Registered User
Posts: 188
Joined: Tue Feb 24, 2015 4:45 pm
Contact:

Re: [ALPHA] [3.2] Live notification using Websockets

Post by RomaamoR »

Too many edits to install an extension. For an ordinary user - painful. I would not even call it an extension. In the idiale, all settings must be in the ACP. All edits that you have done above work. But for PHPBB3 this is not acceptable.
Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 26372
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: [ABD] [ALPHA] [3.2] Live notification using Websockets

Post by Paul »

This topic has been marked as [ABD] - Abandoned as the extension author has not been active recently. If the extension author wishes to continue development, please PM anyone on the Extension Customisations Team to request this topic be unlocked.

Notice!
We do not recommend that a user of the phpBB software install this extension, or any other extension that is marked as "abandoned" or "in development", on a live forum. Doing so may cause your forum to not perform in the manner it should.


Thank you,
The phpBB Extension Customisations Team
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development
Locked

Return to “Abandoned Extensions”