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.
Extension Version: 0.4.0
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
- 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).
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.
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.
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.
In my example, my board is localized in /forum2/ and I have let the default prefix for phpbb table : "phpbb_"
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:Once done, you can try to start the server.
Code: Select all
pip3 install SimpleWebSocketServer pip3 install mysql-connector pip3 install asyncioIf everything works fine, you should just see "Connection ok" printed.
Code: Select all
- Open ext\alexlf\livenewmessages\event\main_listener.php
Modify line 66.
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 :Without encryption :
Code: Select all
$client = new Client("wss://www.superboard.com:9001/");Next line, also requires the key of the server.
Code: Select all
$client = new Client("wss://www.superboard.com:9001/");
In my example, this is daz8d94azd8az4daz6d
Code: Select all
- 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 :
- 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
- 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.
Last update: 06.22.2019
- david63 for his feedback about composer.js and the missing normalization in the extension.