V P N S C R I P T

This documentation is to help you undesrstand the basic script’s structure. Please go through the documentation carefully to understand how this script is made and how to modify this properly. Basic HTML and CSS knowledge is required to customize theme of the script.

1. Getting Started & Installation

When you are ready to use the script, you must first upload the script files to a remote server. In this regard, unzip the script package you have downloaded from codecanyon. In extracted folder you can see following folders:

Installing the script

  • Create a new database with all permissions.
  • Upload all the files withing Upload folder to your server.
  • Edit system/config.php with your database information.
  • Navigate to http://yoursite.com/install in your browser to finish installation
  • Delete install.php file after installing the script!

Setting up cron jobs

  • Add to run every 15 minutes:php -q /home/username/public_html/system/cronjobs/cronjob.php > /dev/null
  • Add to run every minute:php -q /home/username/public_html/system/cronjobs/updateresponse.php > /dev/null

** Please don’t forget that you have to replace with your own path for the files!

2. Configuring Your Webiste

Once you have succesfully installed the script, please navigate to http://yoursite.com/manager (by default) and login to your administrator area with the username you have choosed while using the script installer and password administrator

After loggin in to your account navigate to the settings page from the navigation bar: System Settings

2.1. General Settings Explanation

Website Name: Put desired name for your site / company 
Website URL: The URL of your website without http:// or www. (ex; yoursite.com) 
Website Slogan: A slogan for your site / company that will be displayed in index page title only 
Website Description: A short and effective description you can set, it will be showed in index page for the search robots 
Website Email: The “From” email address for the mails being sent 
Contact Email: The receiver email of contact requests over contact page 
Site Theme: The theme you want to use in your front-end 
Admin Theme: The theme you want to use in your admin-end 
Mailing Type: Change between PHP Mailer and SMTP Mailer. Default: PHPMailer 
SMTP Host: SMTP Hostname (ex; mail.yoursite.com) 
SMTP Port: The port that your SMTP server using 
SMTP Security: Security type of your SMTP server 
SMTP Username: SMTP Username (ex; username@yoursite.com) 
SMTP Password: The password for SMTP user 
reCaptcha Public: reCaptcha v2 public key. You can obtain from https://www.google.com/recaptcha/ 
reCaptcha Private: reCaptcha v2 private key. You can obtain from https://www.google.com/recaptcha/ 
Company Address: The company address that will showed in invoices if set 
Base Directory: The base directory of your VPN Script installation 
Require E-Mail Confirmation: If checked, the users will need to confirm their e-mail addresses. Valid only for new registrations 
Allow New Registrations: If unchecked, new user registrations will be blocked 
Require Profile Info: If checked, users will have to enter their personal information in order to use the service 
Notify Admin on New Ticket: If checked, the administrator will receive an email notification to the email set in Contact Email on a new ticket submission of clients.

2.2. Payment Settings Explanation

Coinpayments Merchant: Can be found at Coinpayments Account Settings page.

Coinpayments Secret: Can be found at Coinpayments Account Settings page & “Merchant Settings” tab.

3. Managing VPN Server(s)

This system is made to work with OpenVPN installed on CentOS servers. It’s highly suggested to prepare the server with OpenVPN installed on it before adding to the system. 
** Don’t forget to install OpenVPN on your server with auth-pam plugin

As per terms of CodeCanyon support policy, we are not liable to support any 3rd party software, yet we have prepared a few help documents for you so you can use them to maintain your vpn server(s). Please don’t contact us regarding help of installing 3rd parties unless you want to hire us to do it for you. You can visit http://vixo.com.tr/help/ to see the documentation we have prepared.

Once you have a server ready with OpenVPN installed and configured to work with auth-pam, you can now simply add it to ProVPN. In order to do that please follow those steps:

  • Navigate to http://yoursite.com/manager
  • Go to “Add Server” page in your administration area
  • Fill in your server information as below: 
    Server Name – Unique name for the server (ex; Alpha or “1”) 
    Country – The full country name which is the server located in (ex; United States) 
    City / State – The server location city or state 
    IP Address – The ip address of the server, it can’t be a host name 
    Username – The root administrator username for the server (by default it should be root
    Password – The root user password. It will be hashed before saving in the database 
    Operating System – The OS of the server (currently it supports only CentOS) 
    Server Notes – Any sort of notes you want to save for the server, this field is only for administrators view
  • Once all done click on “Add Server”

When you add a fresh server, all users with active plan will be added into the new server automatically. From here, you don’t have to touch the server again, just pay the bills and take care of maintanance.

4. Modifying Themes

This script is using Smarty as the template engine. You can modify the themes easily and even create or integrate your own theme. If you are not sure about customizing the theme or integrating one, please hire a developer to do it for you.

If you are going to modify the theme, please do so by duplicating the theme files. To duplicate simply copy / paste the “default” theme with different name in themes folder. If you don’t duplicate the theme and do modifications on it, you will lose them all on a new update release.

File Structure:

|-- themes/      (Theme storage folder)    
|   -- default   (Default theme files)
|-- themes_c/    (Theme cache folder)
|-- manager            (Default admin folder)
|   --themes/          (Admin theme storage folder)    
|      -- default      (Default admin theme files)
|      -- themes_c/    (Admin theme cache folder)

5. Creating Custom Pages

You can easily create custom pages by duplicating “blank.php” and “themes/default/blank.tpl”. After you have duplicated, please modify your page according to your needs. An example would be;

example.php


<?php
ob_start();
define('vixovpn', true);
require_once 'system/config.php';
require_once 'system/globals.php';

// make sure the user is already logged in
if ($user -> loggedIn())
{
  // if the user is banned, let him logout
  if ($user -> IsBanned())
  {
    header('location: logout');
    die();
  }
} else { // redirect to login if not logged in
  header('location: login');
  die();
}

$pagetitle = 'Example Page'; # Page title, before initialising the template

initialiseTemplate($pagetitle);

$smartyvalues["active"] = 'example'; // used to check if the page is active in nav bars
$templatefile = 'example'; # we are going to duplicate blank.tpl and rename it to example.tpl

// finally output the template
outputTemplate($templatefile);
?>

example.tpl


<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
  <meta name="description" content="">
  <meta name="keywords" content="">
  <meta name="author" content="">
  <title>{$websitename} - {$pagetitle}</title>

  <!-- General CSS Files -->
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">

  <!-- CSS Libraries -->

  <!-- Template CSS -->
  <link rel="stylesheet" href="themes/{$template}/assets/css/style.css">
  <link rel="stylesheet" href="themes/{$template}/assets/css/components.css">
  <link rel="stylesheet" href="themes/{$template}/assets/css/custom.css">
</head>

<body class="layout-3">
  <div id="app">
    <div class="main-wrapper container">
      <!-- MAIN NAV -->
      {include file='./includes/main_nav.tpl'}

      <!-- SECONDARY NAV -->
      {include file='./includes/secondary_nav.tpl'}

      <!-- Main Content -->
      <div class="main-content">
        <section class="section">
          <div class="section-header">
            <h1>Top Navigation</h1>
          </div>

          <div class="section-body">
            <h2 class="section-title">This is Example Page</h2>
            <p class="section-lead">This page is just an example for you to create your own page.</p>
            <div class="card">
              <div class="card-header">
                <h4>Example Card</h4>
              </div>
              <div class="card-body">
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
                cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
                proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
              </div>
              <div class="card-footer bg-whitesmoke">
                This is card footer
              </div>
            </div>
          </div>
        </section>
      </div>
      <!-- FOOTER  -->
      {include file='./includes/footer.tpl'}
    </div>
  </div>
  
  <!-- COMMENTED TO AVOID CODE CORRUPTION -->
  <!-- General JS Scripts -->
  <!-- <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.nicescroll/3.7.6/jquery.nicescroll.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
  <script src="themes/{$template}/assets/js/stisla.js"></script>


  <!-- Template JS File -->
  <!-- <script src="themes/{$template}/assets/js/scripts.js"></script>
  <script src="themes/{$template}/assets/js/custom.js"></script> -->
</body>
</html>

5.1. Functions list that you could use for your custom pages

Check if the user is logged in:


if ($user -> loggedIn())
{
  // User is logged in, do something
}

Check if the user is banned


if ($user -> IsBanned())
{
  // User is banned, redirect to logout
  header('location: logout');
  die();
}

Check if the user is Administrator


if ($user -> IsAdministrator())
{
  // User is administrator, do something
}

Check if the user confirmed e-mail address


if ($user -> IsConfirmed() == false)
{
  // User didn't confirm e-mail
}

Check if the user has active package


if ($user -> hasActivePackage())
{
  // User has an active package
}

Get user’s vpn authentication pass


$auth_pass = $user -> getAuthPass();
echo $auth_pass;

VPN Functions


<?php
/**
 * This will check if the server is accessible with given credentials and return true if it is.
 */
$vpn -> checkPassword($ip, $username, $password);

/**
 * This will add a specific user to all available servers
 */
$vpn -> addUserToAllServers($username, $password);

/**
 * Add all users with active plan to a server
 */
$vpn -> addUsersToNewServer($ipaddr, $username, $password);

/**
 * Delete specific user from all servers
 */
$vpn -> deleteUserFromAllServers($username);
?>

5.2. Global variables you can use for custom themes or custom theme pages

Global variables for front end themes


{$websitename}  <!-- returns website name -->
{$site_desc}    <!-- returns site description -->
{$siteslogan}   <!-- returns website slogan -->
{$companyaddress} <!-- returns company address -->
{$system_url}     <!-- returns plain site url ex; yoursite.com -->
{$logo}  <!-- returns logo url if set in admin panel -->
{$filename} <!-- returns current pages file name -->
{$loggedin} <!-- returns "true" if user logged in -->
{$token} <!-- returns CSRF token  -->
{$show_username} <!-- returns username -->
{$show_user_id} <!-- returns user id -->
{$adminpath} <!-- returns administrator path -->
{$isadmin} <!-- returns true if user is admin -->
{$activesubscription} <!-- returns true if user has active plan -->

5.3. Assign custom variables to Smarty

Assign variables for front end theme


<?php
ob_start();

define('vixovpn', true);

require_once 'system/config.php';
require_once 'system/globals.php';

// check if the user is logged in
if ($user -> loggedIn())
{
  if ($user -> IsBanned())
  {
    header('location: logout');
    die();
  }
} else { // redirect to login if not
  header('location: login');
  die();
}

$pagetitle = 'Blank'; # Page title

initialiseTemplate($pagetitle);

$smartyvalues["active"] = 'blank'; 
$templatefile = 'blank'; # Define the template filename to be used without the .tpl extension

// Let's get users vpn authentication password for the example and assign it to "authpass" variable in smarty;
$smartyvalues["authpass"] = $user -> getAuthPass();
// That's it, now you can call it like {$authpass} in your $templatefile (which is set to blank.tpl)

// Find more about Smarty syntax at https://www.smarty.net/docs/en/

outputTemplate($templatefile);

?>

Assign values to admin end theme


<?php
ob_start();

define('vixovpn', true);

require_once (dirname(__DIR__).'/system/config.php');
require_once (dirname(__DIR__).'/system/globals.php');


if (!$user -> loggedIn())
{
  header('location: ../index');
  die();
}

if (!$user -> IsAdministrator())
{
  header('location: ../index');
  die();
}

$pagetitle = 'Blank'; # Page title

initialiseAdminTemplate($pagetitle);

$pagevalues["active"] = 'blank'; 
$templatefile = 'blank'; # Define the template filename to be used without the .tpl extension

// Let's get users vpn authentication password for the example and assign it to "authpass" variable in smarty;
$pagevalues["authpass"] = $user -> getAuthPass();
// That's it, now you can call it like {$authpass} in your $templatefile (which is set to blank.tpl)

// Find more about Smarty syntax at https://www.smarty.net/docs/en/

outputAdminTemplate($templatefile);

?>

6. Translating Script

You can translate the script to any language you want. In order to do that, please duplicate the application/languages/lang.en.php file and name it to lang.id.php (id = 2 letter language code you would like to translate, for example Turkish would be lang.tr.php)

Open the duplicated file with a desired text editor and translate all strings inside. After you are done, open system/config.php file and add the new language code to allowed languages array

$languages = array('en', 'tr');     // EXAMPLE

Now simply to change between languages, navigate to http://yoursite.com/index?lang=tr