Regex Login & Register Script Documentation

Created by: Litos Media

Created: 30.07.2017 Last Update: 16.09.2017

Web: http://regex-demo.litos.top

E-Mail: [email protected]

Regex Login & Register Script Documentation
The most complete Login & User Managemen on the Market. We have programed this Login & User Management with speed optimization and full ajax.

Installation

  1. Upload the files that are inside of the folder Regex to your server and go to your domain. Ex: http://www.yourwebsite.tld

  2. Insert Your database details. The Database must be created on you hosting.

  3. Type your Email and Password to create the Master Admin Account.

  4. You will be automatically logged in and the istallation is finished.

Updates

If you made the download of a new version of Regex and you already have it installed on you server
  • Upload the files that are inside of the folder Regex to your server exept:
  • - /theme/
  • - inc/db.php
  • - install.sql 
  • - install.php 
  • - _admin_back/theme/
  • - _admin_back/DbackupeX/dbackupex_config.php
  • - _admin_back/ImageX/imagex_config.php
  • - _admin_back/ImageX/imagex_install.php

 

  • Go to your Back-End and click on the link that will appear in order to upgrade the Database.

 

Language & Multi-Language

Set the Website Language:

Go to the Menu Languages and add the languages you need.

Exemple for German: Language Name: German, Language Code: de_DE, Language Initals: de 

As soon as you added a new Language you can choose the Website default Language on the same Panel. Note that the added Language must be activated to be able to be choosed.

 

To translate the languages go to www.yoursite.ltd/language/de_DE/LC_MESSAGES/de_DE.po for exemple to translate the german Language. For this you need the free Po-Edit Software.

 

 

Multi-Language:

Go to the Menu Languages and activate the Multi-Language option. As soon as this is activated, the users and administrators are able to choose their language. If the user do not select any language, they will see the Website on the Default Language. 

Pages

To create a new page:

If the Page should be Login protected will look like this:

include ("inc/login_required.php"); // If you want to be login protected
include ("header.php"); 

 

At file bottom add:

include ('footer.php');

 

 

 A new page will looks somthing like that:

 

<?php
include ("inc/login_required.php"); // If you want to be login protected
include ("header.php");
?>


************************************
Here comes your content with your 
Layout, html. images etc
************************************


<?php include ("footer.php");?>


  You want to add the script to your login design? The file should looks like that:

 

<?php
if(user_is_logged_in()) header("Location: ".get_website('redirect_url_after_login')); 
include ("header.php");
?>


********************************************************************************
The form must have the class ajax_send since it will be sent with ajax

the hidden input and the name of the fields are also mandatory ********************************************************************************

<form class="ajax_send"> <input required type="email" name="email" placeholder="<?php echo _('Email');?>"> <input input-lg" type="password" name="pw" placeholder="<?php echo _('Password');?>"> <input type="hidden" value="ewef34t235756g23eww" name="fazer_login"> <?php if (get_website('recaptcha_login')==1){include('inc/recaptcha-html.php');}?> <button type="submit"> <?php echo _('Make login');?> </button> </form> ******************************* If you want add social login: ******************************* <?php if(get_website('facebook_login')==1){ ?> <a href="social-login/facebook.php"><i class="fa fa-facebook"></i> <?php echo _('Facebook');?></a> <?php }?> <?php if(get_website('twitter_login')==1){ ?> <a href="social-login/twitter.php"><i class="fa fa-twitter"></i> <?php echo _('Twitter');?></a> <?php }?>

<?php include ("footer.php");?>
<script src="/assets/js/login-register.js"></script>

 


 

 To better organize your files

You can use the www.yourwebsite.com/theme/ folder to add your app files. You can also copy the exemple files that are on the root folder, paste it on the theme folder and change them as your needs. In this way you will not lose your changes if you update Regex Login Script.

 

For ex. if you add a file on theme folder: contact.php 

www.website.com/contact.php -> This one will not be used anymore

www.website.com/theme/contact.php -> This will be automatically used by the server

But if you delete www.website.com/theme/contact.php then www.website.com/contact.php will be used instead.

Permalinks

The permalinks can be set on the Backend. Also if you add a new PHP file, for exemple to add a new Page to your Website, this PHP will be showed on the Drop-Down list under the Permalinks menu on the backend. 

So you can easly add nice URLs to your new Files / Pages

 

Exemple:

1- Create a new PHP file on the root folder of your website.

2- Go to the Administrator backend and click Permalinks on the menu.

3- Pull the Drop-Down List under "Add new Permalink" and select your new file.

4- Insert your desired slug and Click on the " + " icon

 

Now this file will be  linked with your desired slug

PHP Functions User/Client

To use the user functions set this on the top of the page:

$user= new user();

 

 

 Now you can use the user functions like this:

 

If the user is logged in

If($user->user_is_logged_in()){ This can be seen by logged users} 
else { This is what the user see if is not logged in}

Get the User ID

$user->get_user('id')

Get the User Registration Date (Timestamp)

$user->get_user('reg_date')

Get the User Name

$user->get_user('username')

Get the User Email

$user->get_user('email')

Get the user IP from Registration

$user->get_user('user_ip')

Get the User IP from last Login

$user->get_user('user_ip_last_login')

Get User Last login Date (Timestamp)

$user->get_user('last_login')

Get the User Profile Headline

$user->get_user('profile_headline')

Get User Profile description

$user->get_user('profile_description')

Get User Location

$user->get_user('location')

Check if the user is administrator

if($user->is_admin()){The user is Administrator} else {The user is not administrator}

Check if the user is banned

if($user->user_ip_is_banned()){The user is banned} else {The user is not banned}

Remove Not Activated Users Accounts after the time that you set on the Backend

clean_not_activated_users();

User Roles (User Groups)

Regex has 6 Pre-made User Roles.

The identifiers of them are:

super_admin for Master Administrator
admin for Administrator
front_end_user for  Front-End Users
front_end_user_2 for Front-End Users
front_end_user_3 for Front-End Users
front_end_user_4 for Front-End Users

 

In your back-end you can easily change the name of the roles using the translation of Po-Edit.
So you can for ex. give the name "Premium user" to front_end_user_2 or "User with light package" to front_end_user_4.

 

On your front-end you can easly define user access to certain pages

You just need to add to the top of your page this code:

$user= new user(); 
$user->permited_roles('Role identifier with access','URL to redirect users without access');

 

 

A real exemple to only allow access to users wiht the role front_end_user_2 or front_end_user_4 to a page. All other users will be redirected to premium-content-info.php (Where for ex. you have the info to pay in order to have access to this page):

 

$user= new user(); 
$user->permited_roles('front_end_user_2,front_end_user_4','https://www.yoursite.com/premium-content-info.php');

 

For mixed content you can add content depending on the user roles:

 

$user= new user();
$logged_in_user_role= $user->get_logged_user('role'); 

If ($logged_in_user_role == "front_end_user_2"){
This content can only be seen by users with the user role front_end_user_2
}
elseif ($logged_in_user_role == "front_end_user_4"){
This content can only be seen by users with the user role front_end_user_4
}
elseif ($logged_in_user_role == "admin"){
This content can only be seen by users with the user role admin
}

If ($logged_in_user_role == "front_end_user_2" || $logged_in_user_role == "front_end_user_3"){
Content only for users with the user role front_end_user_2 and front_end_user_3
}
 

 

 

You can use the admin Back-end to change the user role that a user have. If you want that this will be changed automatically, for ex. after payment with a call-back. You just need to run this function:

 

$user= new user();
$user->update_user('role',$new_role,'id',$USER_ID);

// For exemple to update a user that have the role front_end_user to front_end_user_2:

$user= new user();
$user->update_user('role','front_end_user_2','id',$USER_ID);

 

 

Functions - Site Options

 Logo

 echo get_logo(); // Displays the image
 echo get_website('logo'); // Displays the image Filename

 Favicon

 echo get_favicon(); // Displays the image
 echo get_website('favicon'); // Displays the image Filename

 Website name

echo get_website('name');

 Website description

 echo get_website('description');

Website Language (Ex: en_EN)

 echo get_website('language');

Website language (Ex.: en)

 echo get_website('lang_min');

Website Url

 echo $SITE_URL;

Wesite Domain

 echo get_website('domain');

Website Email

 echo get_website('site_email');

Email Signature

 echo get_website('assinatura');

Website Copyright text

 echo get_website('copyright');

Website default Avatar Filename

 echo get_website('default_avatar');

Website Notification sound filename

 echo get_website('notification_sound');

Website default User Role

 echo get_website('default_user_role');

Website Email Header

 echo get_website('mail_header');

Website Mail Footer

 echo get_website('mail_footer');

 


 

Website Error Alert:

echo erro_box ('Your Message here');

Outputs:

Error Your Message here

 

Website Sucess Alert:

echo ok_box ('Your Message here');

Outputs:

Your Message here