Code Monkey home page Code Monkey logo

phpbb-live-new-post-notification's Introduction

Phpbb-live-new-post-notification

A Phpbb plugin developed to get live notifications of new posts

Basic installation

Download the basic_installation.zip file and unzip it. Next, go to "Configuration" step.

Installation from sources

git clone https://github.com/alexandrelefourner/Phpbb-live-new-post-notification
git clone https://github.com/Textalk/websocket-php

run a composer install on Textalk websocket library... Then, move folders "lib" and "vendors" to ext\alexlf\livenewmessages\

alt text

Configuration

They are several files to modify before starting.

python\config.py

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).

alt text

Next, we create the internal parameter for the server. In my example, my server address 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.

alt text

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.

alt text

You will need to select the address 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.

alt text

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

alt text

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 (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:

pip3 install SimpleWebSocketServer
pip3 install mysql-connector 
pip3 install asyncio

Once done, you can try to start the server.

python3 Server.py

If everything works fine, you should just see "Connection ok" printed.

ext\alexlf\livenewmessages\event\main_listener.php

Modify line 66. alt text

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 :

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

Without encryption :

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

Next line, also requires the key of the server. alt text In my example, this is daz8d94azd8az4daz6d

			$client->send("1;daz8d94azd8az4daz6d;".$event["data"]["topic_id"].";".$user->data["username"].";".$event["data"]["post_id"]);

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 :

alt text

ext\alexlf\livenewmessages\styles\all\template\styles\all\template\css\alertify_alexlf_corrected.css

If you wish to change the style of the notification, you can change this file.

You are now ready to activate the extension.

  • Upload the /ext/ folder to your board.
  • Open a command prompt and go to the directory where the server is set up with the configuration files. Next, run the server with the following command :
python3 Server.py

Todo list

  • Solving the composer.js issue (only possible in future phpbb version)
  • Using events to update the topics watched
  • Managing the parameters in main_listener/js code from admin panel
  • Adding color customisation from admin panel
  • Create a unique key per user
  • Safety against massive connections/fail connection attempts ?
  • Full migration as php websocket server ? (possible to store it in an extension without running external commands ?)

phpbb-live-new-post-notification's People

Contributors

alexandrelefourner avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.