sample php app
Getting started with a sample php app on Eenos
This guide will help you to create a sample php app for forthe Eenos hosting control panel.
The PHP apps are generic php apps.
Download an Example PHP App
You can download an example Eenos PHP App from here :here: samplephpapp.tar.gz
app.conf
The first step is to create the app.conf . An example forof samplephpapp is given below :
[settings]
# All the settings fields are mandatory
# The Name of the parent folder of the app.
# The name may contain letters, digits, hyphen and underscore
# The name always starts with a letter and a length of 20 characters.
name = samplephpapp
# The menu name that will be showing inside the control panel pages
# Maximum menu name length is 24 characters.
menu = A Sample PHP App
# A description about the app. What is the use of this app ?
# Maximum length of description is 6o characters.
description = This is a sample PHP app for testing purpose
# The programming language , currently support python or php only
# If this is a Python Django app use python
# if this is a PHP app chose , php
# Accepted values [ python , php]
language = php
# This app version number
version = 1.0.0
# The version_check_url is a remote url shows the available current version of the app
# This url must give the version number as plain text output
# This version should ensure if the app is up-to-date
version_check_url = https://download.eenos.com/apps/sample-php-app/version.txt
# The auto update script path used to update the scripts
# You can place this in ,/scripts/ folder so that will be installed
auto_update = /usr/local/eenos/scripts/samplephpapp_update
[wap]
# The general settings for WAP admin app
# To enable or disable this app in admin panel
# Supported values ,[ on , off ]
status = on
# If you wish to open the app in new browser window during a click action
# from the control panel
# Supported values [ off, on] , default off
open_new_window = on
[rapp]
# The general settings for RAPP - Reseller control panel app
# To enable or disable this app in reseller panel
# Supported values ,[ on , off ]
status = on
# If you wish to open the app in new browser window during a click action
# from the control panel
# Supported values, [ off, on] , default off
open_new_window = on
[uapp]
# The general settings for UAPP - User control panel app
# To enable or disable this app in user panel
# Supported values, [ on , off ]
status = on
# If you wish to open the app in new browser window during a click action
# from the control panel
# Supported values [ off, on] , default off
open_new_window = on
You should set the language with value php for a PHP app.
Files and destination of php app - samplephpapp
The following table will let you know where the files will be placed during app installation time.
Sample App Item | Location to place | Description |
./hooks/* | /var/eenos/hooks/ | All hook scripts of the app |
./scripts/* | /usr/local/eenos/scripts/ | All scripts of the app |
./wap/samplephpapp | /usr/local/eenos/3rdparty/apps/wap/samplephpapp | The admin panel plugin files |
./rapp/samplephpapp | /usr/local/eenos/3rdparty/apps/rapp/samplephpapp | The reseller panel plugin file |
./uapp/samplephpapp | /usr/local/eenos/3rdparty/apps/uapp/samplephpapp | The user panel app files |
./static/samplephpapp | /usr/local/eenos/wap/public/static/default/samplephpapp | Admin panel static files |
./static/samplephpapp | /usr/local/eenos/rapp/public/static/default/samplephpapp | Reseller panel static files |
./static/samplephpapp | /usr/local/eenos/uapp/public/static/default/samplephpapp | User panel static file |
./vhosts/wap.samplephpapp.conf | /usr/local/eenos/etc/eenosd/wap.samplephpapp.conf | The admin panel nginx vhost |
./vhosts/rapp.samplephpapp.conf | /usr/local/eenos/etc/eenosd/rapp.samplephpapp.conf | Reseller panel nginx vhost |
./vhosts/uapp.samplephpapp.conf | /usr/local/eenos/etc/eenosd/uapp.samplephpapp.conf | User panel nginx vhost |
The static files are common files whichthat will be copied into the three control panel interface static folders.
App folder structure
An example folder structure of php app ,app, samplephpapp is as follows,
# tree samplephpapp
samplephpapp
├── app.conf
├── hooks
├── LICENSE
├── post
│ └── 02-post.sh
├── pre
│ └── 01-ps.sh
├── rapp
│ └── samplephpapp
│ ├── index.php
│ └── starter-template.css
├── README
├── requirements.txt
├── scripts
│ └── samplephpapp-scripts.sh
├── static
│ └── samplephpapp
│ ├── css
│ │ ├── bootstrap.min.css
│ │ ├── bootstrap.min.css.map
│ │ ├── bootstrap.rtl.min.css
│ │ └── bootstrap.rtl.min.css.map
│ └── js
│ ├── bootstrap.bundle.min.js
│ └── bootstrap.bundle.min.js.map
├── uapp
│ └── samplephpapp
│ ├── index.php
│ └── starter-template.css
├── vhosts
│ ├── rapp.samplephpapp.conf
│ ├── uapp.samplephpapp.conf
│ └── wap.samplephpapp.conf
└── wap
└── samplephpapp
├── index.php
└── starter-template.css
Python requirements
You can place all your pip requirements for your python app inside the file requirements.txt
Pre Pre-installation scripts
Put all your pre pre-installation scripts of the plugin inside the folder pre/
Post Post-installation scripts
Place all your post plugin installation scripts inside the folder post/
scripts
Place all scripts related withto your plugin in the folder scripts/
hooks
PleasePlace all youyour hooks for Eenos inside the folder hooks/
Vhosts
Place all youyour nginx vhost files inside the folder vhost/
Manage Authentication in PHP Apps
You can authenticate the php apps using the php pam module or a custom preg function. SampleThe sample code is as follows,
PAM Authentication
<?php
// Sample function to check authentication using php-pam module
function auth_pam($user,$password){
if (pam_auth($user,$password)){
return true;
}else{
return false;
}
}
Custom Preg
<?php
function is_notsuspended($username){
if (file_exists("/var/eenos/suspended/$username")){
return false;
}else{
return true;
}
}
function iseenosuer($username){
if (file_exists("/var/eenos/users/$username")){
return true;
}else{
return false;
}
}
function sauthenticate($user, $pass){
if (iseenosuer(($user))){
if (is_notsuspended($user)){
$shad = preg_split("/[$:]/",`cat /etc/shadow | grep "^$user\:"`);
if (!isset($shad[2]) || !isset($shad[3])) return false;
$mkps = preg_split("/[$:]/",crypt($pass, '$'.$shad[2].'$'.$shad[3].'$'));
return ($shad[4] == $mkps[3]);
}else{
return false;
}
}
else{
return false;
}
}
Packaging your app
To package an app create a gzip tar file of the source folder .folder. An example of samplephpapp is as follows:
tar -czf samplephpapp-1.0.0.tar.gz samplephpapp/
InstallInstall, , RemoveRemove, and Upgrade the App
To installinstall, , removeremove, or upgrade the app please read the app operations from Manage Apps page.