merging conflicts

This commit is contained in:
shubham_meena 2014-07-07 01:57:08 +05:30
commit cc6c18cb47
20 changed files with 1578 additions and 705 deletions

View file

@ -2,16 +2,20 @@
/**
* Handles the database connections. It uses PDO to connect to the different databases. It will use the argument of the constructor to setup a connection to the database
* with the matching entry in the $cfg global variable.
* @author Daan Janssens, mentored by Matthew Lagoe
*
* @author Daan Janssens, mentored by Matthew Lagoe
*/
class DBLayer {
private $PDO; /**< The PDO object, instantiated by the constructor */
private $PDO;
/**
* *< The PDO object, instantiated by the constructor
*/
/**
* The constructor.
* Instantiates the PDO object attribute by connecting to the arguments matching database(the db info is stored in the $cfg global var)
*
* @param $db String, the name of the databases entry in the $cfg global var.
*/
function __construct( $db, $dbn = null )
@ -46,6 +50,7 @@ class DBLayer{
/**
* execute a query that doesn't have any parameters
*
* @param $query the mysql query
* @return returns a PDOStatement object
*/
@ -57,6 +62,7 @@ class DBLayer{
/**
* execute a query that has parameters
*
* @param $query the mysql query
* @param $params the parameters that are being used by the query
* @return returns a PDOStatement object
@ -69,6 +75,7 @@ class DBLayer{
/**
* execute a query (an insertion query) that has parameters and return the id of it's insertion
*
* @param $query the mysql query
* @param $params the parameters that are being used by the query
* @return returns the id of the last inserted element.
@ -83,11 +90,11 @@ class DBLayer{
$sth -> bindValue( ":$key", $value );
}
$this -> PDO -> beginTransaction();
//execution
$sth -> execute();
$lastId = $this -> PDO -> lastInsertId();
$this -> PDO -> commit();
}catch (Exception $e)
}
catch ( Exception $e )
{
// for rolling back the changes during transaction
$this -> PDO -> rollBack();
@ -96,10 +103,9 @@ class DBLayer{
return $lastId;
}
/**
*
* Select function using prepared statement
*
* @param string $tb_name Table Name to Select
* @param array $data Associative array
* @param string $where where to select
@ -112,7 +118,8 @@ class DBLayer{
$this -> PDO -> beginTransaction();
$sth -> execute( $data );
$this -> PDO -> commit();
}catch(Exception $e)
}
catch( Exception $e )
{
$this -> PDO -> rollBack();
throw new Exception( "error selection" );
@ -122,8 +129,8 @@ class DBLayer{
}
/**
*
* Select function using prepared statement
*
* @param string $tb_name Table Name to Select
* @param array $data Associative array
* @param string $where where to select
@ -136,7 +143,8 @@ class DBLayer{
$this -> PDO -> beginTransaction();
$sth -> execute( $data );
$this -> PDO -> commit();
}catch(Exception $e)
}
catch( Exception $e )
{
$this -> PDO -> rollBack();
throw new Exception( "error selection" );
@ -146,8 +154,8 @@ class DBLayer{
}
/**
*
* Update function with prepared statement
*
* @param string $tb_name name of the table
* @param array $data associative array with values
* @param string $where where part
@ -158,7 +166,7 @@ class DBLayer{
$field_option_values = null;
foreach ( $data as $key => $value )
{
$field_option_values.=",$key".'=:'.$value;
$field_option_values .= ",$key" . '=:' . $key;
}
$field_option_values = ltrim( $field_option_values, ',' );
try {
@ -171,19 +179,22 @@ class DBLayer{
$this -> PDO -> beginTransaction();
$sth -> execute();
$this -> PDO -> commit();
}catch (Exception $e)
}
catch ( Exception $e )
{
$this -> PDO -> rollBack();
throw new Exception( 'error in updating' );
return false;
}
return true;
}
/**
*
* insert function using prepared statements
*
* @param string $tb_name Name of the table to insert in
* @param array $data Associative array of data to insert
*/
public function insert( $tb_name, $data )
{
$field_values = ':' . implode( ',:', array_keys( $data ) );
@ -192,6 +203,7 @@ class DBLayer{
$sth = $this -> PDO -> prepare( "INSERT INTO $tb_name ($field_options) VALUE ($field_values)" );
foreach ( $data as $key => $value )
{
$sth -> bindValue( ":$key", $value );
}
$this -> PDO -> beginTransaction();
@ -199,7 +211,8 @@ class DBLayer{
$sth -> execute();
$this -> PDO -> commit();
}catch (Exception $e)
}
catch ( Exception $e )
{
// for rolling back the changes during transaction
$this -> PDO -> rollBack();
@ -208,23 +221,23 @@ class DBLayer{
}
/**
*
* Delete database entery using prepared statement
*
* @param string $tb_name
* @param string $where
* @throws error in deleting
*/
public function delete($tb_name, $where)
public function delete( $tb_name, $data, $where )
{
try {
$sth = $this->prepare("DELETE FROM $tb_name WHERE $where");
$sth = $this -> PDO -> prepare( "DELETE FROM $tb_name WHERE $where" );
$this -> PDO -> beginTransaction();
$sth->execute();
$sth -> execute( $data );
$this -> PDO -> commit();
}
catch ( Exception $e )
{
$this->rollBack();
$this -> PDO -> rollBack();
throw new Exception( "error in deleting" );
}

View file

@ -1,8 +1,8 @@
<?php
/**
* Helper class for more site specific functions.
* @author Daan Janssens, mentored by Matthew Lagoe
*
* @author Daan Janssens, mentored by Matthew Lagoe
*/
class Helpers {
@ -10,6 +10,7 @@ class Helpers{
* workhorse of the website, it loads the template and shows it or returns th html.
* it uses smarty to load the $template, but before displaying the template it will pass the $vars to smarty. Also based on your language settings a matching
* array of words & sentences for that page will be loaded. In case the $returnHTML parameter is set to true, it will return the html instead of displaying the template.
*
* @param $template the name of the template(page) that we want to load.
* @param $vars an array of variables that should be loaded by smarty before displaying or returning the html.
* @param $returnHTML (default=false) if set to true, the html that should have been displayed, will be returned.
@ -58,9 +59,16 @@ class Helpers{
// load page specific variables that are language dependent
$variables = Helpers :: handle_language();
if ( $template != 'layout_plugin' )
{
foreach ( $variables[$template] as $key => $value ) {
$smarty -> assign( $key, $value );
}
}
// load ams content variables that are language dependent
foreach ( $variables['ams_content'] as $key => $value ) {
$smarty -> assign( $key, $value );
}
// smarty inheritance for loading the matching wrapper layout (with the matching menu bar)
if ( isset( $vars['permission'] ) && $vars['permission'] == 3 ) {
@ -84,6 +92,7 @@ class Helpers{
/**
* creates the folders that are needed for smarty.
*
* @todo for the drupal module it might be possible that drupal_mkdir needs to be used instead of mkdir, also this should be in the install.php instead.
*/
static public function create_folders() {
@ -110,6 +119,7 @@ class Helpers{
/**
* check if the http request is sent ingame or not.
*
* @return returns true in case it's sent ingame, else false is returned.
*/
static public function check_if_game_client()
@ -128,6 +138,7 @@ class Helpers{
* Handles the language specific aspect.
* The language can be changed by setting the $_GET['Language'] & $_GET['setLang'] together. This will also change the language entry of the user in the db.
* Cookies are also being used in case the user isn't logged in.
*
* @return returns the parsed content of the language .ini file related to the users language setting.
*/
static public function handle_language() {
@ -184,6 +195,7 @@ class Helpers{
/**
* Time output function for handling the time display.
*
* @return returns the time in the format specified in the $TIME_FORMAT global variable.
*/
static public function outputTime( $time, $str = 1 ) {
@ -199,6 +211,7 @@ class Helpers{
* Auto login function for ingame use.
* This function will allow users who access the website ingame, to log in without entering the username and password. It uses the COOKIE entry in the open_ring db.
* it checks if the cookie sent by the http request matches the one in the db. This cookie in the db is changed everytime the user relogs.
*
* @return returns "FALSE" if the cookies didn't match, else it returns an array with the user's id and name.
*/
static public function check_login_ingame() {
@ -206,7 +219,11 @@ class Helpers{
$dbr = new DBLayer( "ring" );
if ( isset( $_GET['UserId'] ) && isset( $_COOKIE['ryzomId'] ) ) {
$id = $_GET['UserId'];
$statement = $dbr -> select( "ring_users", array( 'id' => $id, 'cookie' => $_COOKIE['ryzomId'] ), "user_id=:id AND cookie =:cookie" );
// $statement = $dbr->execute("SELECT * FROM ring_users WHERE user_id=:id AND cookie =:cookie", array('id' => $id, 'cookie' => $_COOKIE['ryzomId']));
if ( $statement -> rowCount() ) {
$entry = $statement -> fetch();
// print_r($entry);

View file

@ -1,18 +1,19 @@
<?php
/**
* API for loading and interacting with plugins
* contains getters and setters
*
* contains the getters and setters for plugins
* @author shubham meena mentored by Matthew Lagoe
**/
*/
class Plugincache {
private $id;
private $plugin_name;
private $plugin_version;
private $plugin_type;
private $plugin_permission;
private $plugin_isactive;
private $plugin_status;
private $plugin_info = array();
private $update_info = array();
/**
* A constructor.
* Empty constructor
@ -22,16 +23,19 @@ class Plugincache{
}
public function set( $values ) {
$this->setId($values['PluginId']);
$this->setPluginName($values['PluginName']);
$this->setPluginVersion($values['PluginVersion']);
$this->setPluginPermission($values['PluginPermission']);
$this->setIsActive($values['IsActive']);
$this -> setId( $values['Id'] );
$this -> setPluginName( $values['Name'] );
$this -> setPluginType( $values['Type'] );
$this -> setPluginPermission( $values['Permission'] );
$this -> setPluginStatus( $values['Status'] );
$this -> setPluginInfo( json_decode( $values['Info'] ) );
@$this -> setUpdateInfo( json_decode( $values['UpdateInfo'] ) );
}
/**
* loads the object's attributes.
*/
public function load_With_SID() {
$dbl = new DBLayer( "lib" );
$statement = $dbl -> executeWithoutParams( "SELECT * FROM plugins" );
@ -40,14 +44,10 @@ class Plugincache{
}
/**
* updates the entry.
* get plugin id attribute of the object.
*
* @return integer id
*/
public function update(){
$dbl = new DBLayer("lib");
$values = Array('t' => $this->getPluginPermission(), 'q' => $this->getPluginVersion(), 'd' => $this->getIsActive());
$dbl->update("plugins", $values, "PluginName= $this->getPluginName()");
}
public function getId() {
return $this -> Id;
}
@ -60,17 +60,17 @@ class Plugincache{
}
/**
* get plugin version attribute of the object.
* get plugin Type attribute of the object.
*/
public function getPluginVersion(){
public function getPluginType() {
return $this -> plugin_version;
}
/**
* get plugin is active attribute of the object.
* get plugin status attribute of the object.
*/
public function getIsActive(){
return $this->plugin_isactive;
public function getPluginStatus() {
return $this -> plugin_status;
}
/**
@ -80,17 +80,25 @@ class Plugincache{
return $this -> plugin_name;
}
/**
* get plugin info array attribute of the object.
*/
public function getPluginInfo() {
return $this -> plugin_info;
}
/**
* set plugin id attribute of the object.
*
* @param $s integer id
*/
public function setId( $s ) {
$this -> Id = $s;
}
/**
* set plugin permission attribute of the object.
*
* @param $t type of the query, set permission
*/
public function setPluginPermission( $t ) {
@ -99,25 +107,164 @@ class Plugincache{
/**
* set plugin version attribute of the object.
*
* @param $q string to set plugin version
*/
public function setPluginVersion($q){
public function setPluginType( $q ) {
$this -> plugin_version = $q;
}
/**
* set plugin is active attribute of the object.
* @param $d tinyint to set plugin is active or not .
* set plugin status attribute of the object.
*
* @param $d status code type int
*/
public function setIsActive($d){
$this->plugin_isactive= $d;
public function setPluginStatus( $d ) {
$this -> plugin_status = $d;
}
/**
* set plugin name attribute of the object.
*
* @param $p_n string to set plugin name.
*/
public function setPluginName( $p_n ) {
$this -> plugin_name = $p_n;
}
/**
* set plugin info attribute array of the object.
*
* @param $p_n array
*/
public function setPluginInfo( $p_n ) {
$this -> plugin_info = $p_n;
}
/**
* functionalities for plugin updates
*/
/**
* set update info attribute array of the object.
*
* @param $p_n array
*/
public function setUpdateInfo( $p_n ) {
$this -> update_info = $p_n;
}
/**
* get plugin info array attribute of the object.
*/
public function getUpdateInfo() {
return $this -> update_info;
}
/**
* some more plugin function that requires during plugin operations
*
*/
/**
* function to remove a non empty directory
*
* @param $dir directory address
* @return boolean
*/
public static function rrmdir( $dir ) {
if ( is_dir( $dir ) ) {
$objects = scandir( $dir );
foreach ( $objects as $object ) {
if ( $object != "." && $object != ".." ) {
if ( filetype( $dir . "/" . $object ) == "dir" ) rmdir( $dir . "/" . $object );
else unlink( $dir . "/" . $object );
}
}
reset( $objects );
return rmdir( $dir );
}
}
/**
* function to unzip the zipped files
*
* @param $target_path path to the target zipped file
* @param $destination path to the destination
* @return boolean
*/
public static function zipExtraction( $target_path, $destination )
{
$zip = new ZipArchive();
$x = $zip -> open( $target_path );
if ( $x === true ) {
if ( $zip -> extractTo( $destination ) )
{
$zip -> close();
return true;
}
else
{
$zip -> close();
return false;
}
}
}
/**
* returns plugin information with respect to the id
*
* @param id $ plugin id
* @return field info for the plugin
*/
public static function pluginInfoUsingId( $id, $fieldName )
{
$db = new DBLayer( 'lib' );
$sth = $db -> selectWithParameter( $fieldName, 'plugins', array( 'id' => $id ), 'Id=:id' );
$row = $sth -> fetch();
return $row[$fieldName];
}
/**
* function provides list of active plugins
*
* @return $ac_plugins list of active plugins
*/
public static function activePlugins()
{
$db = new DBLayer( 'lib' );
$sth = $db -> selectWithParameter( 'Id', 'plugins', array( 'status' => 1 ), 'Status=:status' );
$row = $sth -> fetchAll();
return $row;
}
/**
* function to load hooks for the active plugins
* and return the contents in the hooks in an array
*
* @return $content content available in hooks
*/
public static function loadHooks()
{
$content = array();
$ac_arr = Plugincache :: activePlugins();
foreach( $ac_arr as $key => $value )
{
$plugin_path = Plugincache :: pluginInfoUsingId( $value['Id'], 'FileName' );
$pluginName = Plugincache :: pluginInfoUsingId( $value['Id'], 'Name' );
// calling hooks in the $pluginName.php
include $plugin_path . '/' . strtolower( $pluginName ) . '.php';
$arr = get_defined_functions();
foreach( $arr['user'] as $key => $value )
{
if ( stristr( $value, strtolower( $pluginName ) ) == true )
{
$content['hook_info'][$pluginName] = call_user_func( $value );
}
}
}
return $content;
}
}

View file

@ -5,6 +5,9 @@
login_info = "Please enter your MySQL Username and Password to install the database.<br>This is being loaded because the is_installed file is missing.<br>This process will take about 30 seconds."
login_here = "here"
[ams_content]
ams_title="Ryzom Account Mangement System"
[dashboard]
home_title = "Introduction"
home_info = "Welcome to the Ryzom Core - Account Management System"
@ -57,11 +60,38 @@ action = "Action"
plugin_title = "Plugin List"
plugin_info = "Here you can see the entire list of plugins . You can easily remove plugins ,activate them and add permissions"
plugins = "Plugins"
plugin_id = "ID"
plugin_name = "Name"
plugin_version = "Version"
plugin_permission= "Owner/Access Permission"
plugin_is_active= "On/Off"
plugin_description = "Description"
plugin_type = "Type"
plugin_permission = "Access</br> Permission"
plugin_status = "Status"
ip_success = "Plugin added succesfuly."
plugin_actions = "Actions"
dp_success = "Plugin deleted successfuly"
dp_error = "Error in deleting plugin.Please try again later."
ac_success = "Plugin Activated successfuly."
ac_error = "Plugin facing some error in activating. Please try again later."
dc_success = "Plugin de-Activated successfuly."
dc_error = "Plugin facing some error in de-activating. Please try again later."
up_success = "Update added successfully. Go to Updates page for installing updates."
up_install_success = "Update installed successfully."
[install_plugin]
ip_title = "Install a new Plugin"
ip_message = "For example: name.zip from your local computer"
ip_support = "Upload the plugin archieve to install.</br>The following file extension is supported: zip."
ip_info_nfound = "Info file not found in the Plugin.Please recheck"
ip_file_nfnd="Please upload a plugin before clicking on install button"
[plugins_update]
up_title = "Updates for Plugins"
up_info = "Here you can see the entire list of available updates for plugins."
up_description = "Updates Info"
plugin_name = "Name"
plugin_version = "Version"
up_updated_version = "New Version"
up_actions = "Actions"
[show_ticket]
t_title = "Ticket"
@ -136,8 +166,8 @@ go_home = "Go Home"
userlist_info = "welcome to the userlist"
[login]
login_info = "Please login with your Username and Password."
login_error_message = "The username/password were not correct!"
login_info = "Please login with your Email/Username and Password."
login_error_message = "The Email/username/password were not correct!"
login_register_message ="<strong>Register</strong> If you don't have an account yet, create one"
login_here = "here"
login_forgot_password_message = "In case you forgot your password, click"

View file

@ -0,0 +1,35 @@
<?php
/**
* This function is used in activating plugins.
*
* @author Shubham Meena, mentored by Matthew Lagoe
*/
function activate_plugin() {
// if logged in
if ( WebUsers :: isLoggedIn() ) {
if ( isset( $_GET['id'] ) )
{
// id of plugin to delete
$id = filter_var( $_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$db = new DBLayer( 'lib' );
$result = $db -> update( "plugins", array( 'Status' => '1' ), "Id = $id" );
if ( $result )
{
header( "Location: index.php?page=plugins&result=3" );
exit;
}
else
{
header( "Location: index.php?page=plugins&result=4" );
exit;
}
}
else
{
header( "Location: index.php?page=plugins&result=4" );
exit;
}
}
}

View file

@ -0,0 +1,37 @@
<?php
/**
* This function is used in deactivating plugins.
*
* @author Shubham Meena, mentored by Matthew Lagoe
*/
function deactivate_plugin() {
// if logged in
if ( WebUsers :: isLoggedIn() ) {
if ( isset( $_GET['id'] ) )
{
// id of plugin to delete
$id = filter_var( $_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$db = new DBLayer( 'lib' );
$result = $db -> update( "plugins", array( 'Status' => '0' ), "Id = $id" );
if ( $result )
{
header( "Location: index.php?page=plugins&result=5" );
exit;
}
else
{
header( "Location: index.php?page=plugins&result=6" );
exit;
}
}
else
{
header( "Location: index.php?page=plugins&result=6" );
exit;
}
}
}

View file

@ -0,0 +1,68 @@
<?php
/**
* This function is used in deleting plugins.
*
* It removes the plugin from the codebase.
*
* @author Shubham Meena, mentored by Matthew Lagoe
*/
function delete_plugin() {
// if logged in
if ( WebUsers :: isLoggedIn() ) {
if ( isset( $_GET['id'] ) )
{
// id of plugin to delete after filtering
$id = filter_var( $_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$db = new DBLayer( 'lib' );
$sth = $db -> selectWithParameter( "FileName", "plugins", array( 'id' => $id ), "Id=:id" );
$name = $sth -> fetch();
if ( is_dir( "$name[FileName]" ) )
{
// removing plugin directory from the code base
if ( rrmdir( "$name[FileName]" ) )
{
$db -> delete( 'plugins', array( 'id' => $id ), "Id=:id" );
header( "Location: index.php?page=plugins&result=2" );
exit;
}
else
{
header( "Location: index.php?page=plugins&result=0" );
exit;
}
}
}
else
{
header( "Location: index.php?page=plugins&result=0" );
exit;
}
}
}
/**
* function to remove a non empty directory
*
* @param $dir directory address
* @return boolean
*/
function rrmdir( $dir ) {
if ( is_dir( $dir ) ) {
$objects = scandir( $dir );
foreach ( $objects as $object ) {
if ( $object != "." && $object != ".." ) {
if ( filetype( $dir . "/" . $object ) == "dir" ) rmdir( $dir . "/" . $object );
else unlink( $dir . "/" . $object );
}
}
reset( $objects );
return rmdir( $dir );
}
}

View file

@ -0,0 +1,306 @@
<?php
/**
* This function is used in installing plugins
* It performs validation check for the compressed plugin
* then extract in plugin folder to get the info
*
* @author Shubham Meena, mentored by Matthew Lagoe
*/
function install_plugin() {
$result = array();
// if logged in
if ( WebUsers :: isLoggedIn() ) {
// path of temporary folder for storing files
$temp_path = "../../ams_lib/temp";
// create a temp directory if not exist
// temp folder where we first store all uploaded plugins before install
if ( !file_exists( "$temp_path" ) )
{
mkdir( $temp_path );
}
// checking the server if file is uploaded or not
if ( ( isset( $_FILES["file"] ) ) && ( $_FILES["file"]["size"] > 0 ) )
{
$fileName = $_FILES["file"]["name"]; //the files name takes from the HTML form
$fileTmpLoc = $_FILES["file"]["tmp_name"]; //file in the PHP tmp folder
$dir = trim( $_FILES["file"]["name"], ".zip" );
$target_path = "../../ams_lib/plugins/$dir"; //path in which the zip extraction is to be done
$destination = "../../ams_lib/plugins/";
// scanning plugin folder if plugin with same name is already exists or not
$x = checkForUpdate( $dir, $destination, $fileTmpLoc, $temp_path );
if ( $x == '1' )
{
echo "update found";
exit();
}
else if ( $x == '2' )
{
echo "Plugin already exists with same name .";
exit();
}
else if ( $x == '3' )
{
echo "Update info is not present in the update";
exit();
}
// checking for the command to install plugin is given or not
if ( !isset( $_POST['install_plugin'] ) )
{
if ( ( $_FILES["file"]["type"] == 'application/zip' ) )
{
if ( move_uploaded_file( $fileTmpLoc, $temp_path . "/" . $fileName ) ) {
echo "$fileName upload is complete.</br>" . "<button type='submit' class='btn btn-primary' style='margin-left:5px; margin-top:10px;' name='install_plugin'>Install Plugin</button></br>";
exit();
}
else
{
echo "Error in uploading file.";
exit();
}
}
else
{
echo "Please select a file with .zip extension to upload.";
exit();
}
}
else
{
// calling function to unzip archives
if ( zipExtraction( $temp_path . "/" . $fileName , $destination ) )
{
if ( file_exists( $target_path . "/.info" ) )
{
$result = readPluginFile( ".info", $target_path );
// sending all info to the database
$install_result = array();
$install_result['FileName'] = $target_path;
$install_result['Name'] = $result['PluginName'];
$install_result['Type'] = $result['Type'];
if ( Ticket_User :: isMod( unserialize( $_SESSION['ticket_user'] ) ) )
{
$install_result['Permission'] = 'admin';
}
else
{
$install_result['Permission'] = 'user';
}
$install_result['Info'] = json_encode( $result );
// connection with the database
$dbr = new DBLayer( "lib" );
$dbr -> insert( "plugins", $install_result );
// if everything is successfull redirecting to the plugin template
header( "Location: index.php?page=plugins&result=1" );
exit;
}
else
{
// file .info not exists
rmdir( $target_path );
header( "Location: index.php?page=install_plugin&result=2" );
exit;
}
} else
{
// extraction failed
header( "Location: index.php?page=install_plugin&result=0" );
exit;
}
}
}
else
{
echo "Please Browse for a file before clicking the upload button";
exit();
}
}
}
/**
* function to unzip the zipped files
*
* @param $target_path path to the target zipped file
* @param $destination path to the destination
* @return boolean
*/
function zipExtraction( $target_path, $destination )
{
$zip = new ZipArchive();
$x = $zip -> open( $target_path );
if ( $x === true ) {
if ( $zip -> extractTo( $destination ) )
{
$zip -> close();
return true;
}
else
{
$zip -> close();
return false;
}
}
}
/**
* function to read text files and extract
* the information into an array
*
* -----------------------------------------------------------
* format:
* -----------------------------------------------------------
* PluginName = Name of the plugin
* Version = version of the plugin
* Type = type of the plugin
* Description = Description of the plugin ,it's functionality
* -----------------------------------------------------------
*
* reads only files with name .info
*
* @param $fileName file to read
* @param $targetPath path to the folder containing .info file
* @return array containing above information in array(value => key)
*/
function readPluginFile( $fileName, $target_path )
{
$file_handle = fopen( $target_path . "/" . $fileName, "r" );
$result = array();
while ( !feof( $file_handle ) ) {
$line_of_text = fgets( $file_handle );
$parts = array_map( 'trim', explode( '=', $line_of_text, 2 ) );
@$result[$parts[0]] = $parts[1];
}
fclose( $file_handle );
return $result;
}
/**
* function to check for updates or
* if the same plugin already exists
* also, if the update founds ,check for the update info in the .info file.
* Update is saved in the temp direcotry with pluginName_version.zip
*
* @param $fileName file which is uploaded in .zip extension
* @param $findPath where we have to look for the installed plugins
* @param $tempFile path for the temporary file
* @param $tempPath path where we have to store the update
* @return 2 if plugin already exists and update not found
* @return 3 if update info tag not found in .info file
*/
function checkForUpdate( $fileName, $findPath, $tempFile, $tempPath )
{
// check for plugin if exists
$file = scandir( $findPath );
foreach( $file as $key => $value )
{
if ( strcmp( $value, $fileName ) == 0 )
{
if ( !file_exists( $tempPath . "/test" ) )
{
mkdir( $tempPath . "/test" );
}
// extracting the update
if ( zipExtraction( $tempFile, $tempPath . "/test/" ) )
{
$result = readPluginFile( ".info", $tempPath . "/test/" . $fileName );
// check for the version for the plugin
$db = new DBLayer( "lib" );
$sth = $db -> select( "plugins", array( ':name' => $result['PluginName'] ), "Name = :name" );
$info = $sth -> fetch();
$info['Info'] = json_decode( $info['Info'] );
// the two versions from main plugin and the updated part
$new_version = explode( '.', $result['Version'] );
$pre_version = explode( '.', $info['Info'] -> Version );
// For all plugins we have used semantic versioning
// Format: X.Y.Z ,X->Major, Y->Minor, Z->Patch
// change in the X Y & Z values refer the type of change in the plugin.
// for initial development only Minor an Patch MUST be 0.
// if there is bug fix then there MUST be an increment in the Z value.
// if there is change in the functionality or addition of new functionality
// then there MUST be an increment in the Y value.
// When there is increment in the X value , Y and Z MUST be 0.
// comparing if there is some change
if ( !array_intersect( $new_version , $pre_version ) )
{
// removing the uploaded file
Plugincache :: rrmdir( $tempPath . "/test/" . $fileName );
return '2';
}
else
{
// check for update info if exists
if ( !array_key_exists( 'UpdateInfo', $result ) )
{
return '3'; //update info tag not found
}
else
{
// check if update already exists
if ( pluginUpdateExists( $info['Id'], $tempPath . "/" . trim( $fileName, ".zip" ) . "_" . $result['Version'] . ".zip" ) )
{
echo "Update already exists";
exit;
}
else {
// removing the preivous update
$dbr = new DBLayer( "lib" );
$dbr -> delete( "updates", array( 'id' => $info['Id'] ), "PluginId=:id" );
// storing update in the temp directory
// format of update save
if ( move_uploaded_file( $tempFile, $tempPath . "/" . trim( $fileName, ".zip" ) . "_" . $result['Version'] . ".zip" ) ) {
// setting update information in the database
$update['PluginId'] = $info['Id'];
$update['UpdatePath'] = $tempPath . "/" . trim( $fileName, ".zip" ) . "_" . $result['Version'] . ".zip";
$update['UpdateInfo'] = json_encode( $result );
$dbr -> insert( "updates", $update );
header( "Location: index.php?page=plugins&result=7" );
exit;
}
}
}
}
}
}
}
}
/**
* Function to check for the update of a plugin already exists
*
* @param $pluginId id of the plugin for which update is available
* @param $updatePath path of the new update
* @return boolean if update for a plugin already exists or
* if update of same version is uploading
*/
function PluginUpdateExists( $pluginId, $updatePath )
{
$db = new DBLayer( 'lib' );
$sth = $db -> selectWithParameter( "UpdatePath", "updates", array( 'pluginid' => $pluginId ), "PluginId=:pluginid" );
$row = $sth -> fetch();
if ( $updatePath == $row['UpdatePath'] )
{
return true;
}
else
{
rmdir( $row['UpdatePath'] );
return false;
}
}

View file

@ -0,0 +1,34 @@
<?php
/**
* This function is used in installing updates for plugins.
*
* @author Shubham Meena, mentored by Matthew Lagoe
*/
function update_plugin() {
// if logged in
if ( WebUsers :: isLoggedIn() ) {
if ( isset( $_GET['id'] ) )
{
// id of plugin to delete
$id = filter_var( $_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$db = new DBLayer( 'lib' );
$sth = $db -> executeWithoutParams( "SELECT * FROM plugins INNER JOIN updates ON plugins.Id=updates.PluginId Where plugins.Id=$id" );
$row = $sth -> fetch();
// replacing update in the database
Plugincache :: rrmdir( $row['FileName'] );
Plugincache :: zipExtraction( $row['UpdatePath'], rtrim( $row['FileName'], strtolower( $row['Name'] ) ) );
$db -> update( "plugins", array( 'Info' => $row['UpdateInfo'] ), "Id=$row[Id]" );
// deleting the previous update
$db -> delete( "updates", array( 'id' => $row['s.no'] ), "s.no=:id" );
header( "Location: index.php?page=plugins&result=8" );
exit;
}
}
}

View file

@ -1,23 +1,18 @@
<?php
/**
* File with function plugins to get
* function plugins to get
* plugins from the Database using pagination object
* @author shubham meena mentored by Mathew Lagoe
*
* @author shubham meena mentored by Matthew Lagoe
*/
function plugins()
{
if ( Ticket_User :: isMod( unserialize( $_SESSION['ticket_user'] ) ) ) {
/**require("../../ams_lib/plugins/plugin.handler.php");
$plugin=new plugin();
$plugin->init();
print_r(plugin::$plugins);**/
$pagination = new Pagination( "SELECT * FROM plugins", "lib", 5, "Plugincache" );
$pageResult['plug']= Gui_Elements::make_table($pagination->getElements() , Array ("getId","getPluginName","getPluginVersion","getPluginPermission","getIsActive"), Array("id","plugin_name","plugin_version","plugin_permission","plugin_isactive"));
$pageResult['plug'] = Gui_Elements :: make_table( $pagination -> getElements(), Array( "getId", "getPluginName", "getPluginType", "getPluginPermission", "getPluginStatus", "getPluginInfo" ), Array( "id", "plugin_name", "plugin_type", "plugin_permission", "plugin_status", "plugin_info" ) );
$pageResult['links'] = $pagination -> getLinks( 5 );
$pageResult['lastPage'] = $pagination -> getLast();
$pageResult['currentPage'] = $pagination -> getCurrent();
@ -29,7 +24,8 @@ function plugins()
try {
$dbs = new DBLayer( "shard" );
$pageResult['shard'] = "online";
}catch(PDOException $e){
}
catch( PDOException $e ) {
$pageResult['shard'] = "offline";
}
return( $pageResult );
@ -41,5 +37,3 @@ function plugins()
}
}

View file

@ -0,0 +1,36 @@
<?php
/**
* function plugins_update to get
* plugins updates from the Database using pagination object
*
* @author shubham meena mentored by Matthew Lagoe
*/
function plugins_update()
{
if ( Ticket_User :: isMod( unserialize( $_SESSION['ticket_user'] ) ) ) {
$pagination = new Pagination( "SELECT * FROM plugins INNER JOIN updates ON plugins.Id=updates.PluginId", "lib", 5, "Plugincache" );
$pageResult['plug'] = Gui_Elements :: make_table( $pagination -> getElements(), Array( "getId", "getPluginName", "getPluginInfo", "getUpdateInfo" ), Array( "id", "plugin_name", "plugin_info", "update_info" ) );
$pageResult['links'] = $pagination -> getLinks( 5 );
$pageResult['lastPage'] = $pagination -> getLast();
$pageResult['currentPage'] = $pagination -> getCurrent();
global $INGAME_WEBPATH;
$pageResult['ingame_webpath'] = $INGAME_WEBPATH;
// check if shard is online
try {
$dbs = new DBLayer( "shard" );
$pageResult['shard'] = "online";
}
catch( PDOException $e ) {
$pageResult['shard'] = "offline";
}
return( $pageResult );
} else {
// ERROR: No access!
$_SESSION['error_code'] = "403";
header( "Location: index.php?page=error" );
exit;
}
}

View file

@ -7,13 +7,13 @@
* -# else load the inc's folder matching function related to the page
* -# set the permission and other smarty related settings
* -# call the helper function to load the page.
*
* @author Daan Janssens, mentored by Matthew Lagoe
*/
// load required pages and turn error reporting on/off
error_reporting( E_ALL );
ini_set( 'display_errors', 'on' );
require_once( '../../ams_lib/libinclude.php' );
if ( !file_exists( '../is_installed' ) ) {
// if is_installed doesnt exist run setup
require( 'installer/libsetup.php' );
@ -24,9 +24,10 @@ if (!file_exists('../is_installed')) {
// if config exists then include it
require( '../config.php' );
}
require_once( $AMS_LIB . '/libinclude.php' );
session_start();
//Running Cron?
// Running Cron
if ( isset( $_GET["cron"] ) ) {
if ( $_GET["cron"] == "true" ) {
Sync :: syncdata( false );
@ -38,6 +39,7 @@ Sync::syncdata(false);
// Decide what page to load
if ( ! isset( $_GET["page"] ) ) {
if ( isset( $_SESSION['user'] ) ) {
if ( Ticket_User :: isMod( unserialize( $_SESSION['ticket_user'] ) ) ) {
$page = 'dashboard';
@ -84,6 +86,9 @@ if ( Helpers::check_if_game_client() && ($page == "register")){
if ( isset( $_POST["function"] ) ) {
require( "func/" . $_POST["function"] . ".php" );
$return = $_POST["function"]();
} else if ( isset( $_GET["action"] ) ) {
require( "func/" . $_GET["action"] . ".php" );
$return = $_GET["action"]();
} else {
$filename = 'inc/' . $page . '.php';
if ( is_file( $filename ) ) {
@ -97,9 +102,6 @@ if(isset($_SESSION['user'])){
$return['username'] = $_SESSION['user'];
}
// Set permission
if ( isset( $_SESSION['ticket_user'] ) ) {
$return['permission'] = unserialize( $_SESSION['ticket_user'] ) -> getPermission();
@ -108,7 +110,6 @@ if(isset($_SESSION['ticket_user'])){
$return['permission'] = 0;
}
// hide sidebar + topbar in case of login/register
if ( $page == 'login' || $page == 'register' || $page == 'logout' || $page == 'forgot_password' || $page == 'reset_password' ) {
$return['no_visible_elements'] = 'TRUE';
@ -122,5 +123,12 @@ if($page == 'error'){
$return['no_visible_elements'] = 'FALSE';
}
// call to load hooks for the active plugins
$hook_content = Plugincache :: loadHooks();
foreach( $hook_content as $key => $value )
{
$return[$key] = $value;
}
// load the template with the variables in the $return array
helpers :: loadTemplate( $page , $return );

View file

@ -160,14 +160,38 @@
DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`plugins` ;
CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`plugins` (
`PluginId` INT(10) NOT NULL AUTO_INCREMENT,
`PluginName` VARCHAR(11) NOT NULL,
`PluginPermission` VARCHAR(5) NOT NULL,
`PluginVersion` INT(11) NOT NULL,
`IsActive` TINYINT(1) NOT NULL,
PRIMARY KEY (`PluginId`) )
`Id` INT(10) NOT NULL AUTO_INCREMENT,
`FileName VARCHAR(255) NOT NULL,
`Name` VARCHAR(11) NOT NULL,
`Type` VARCHAR(12) NOT NULL,
`Owner` VARCHAR(25) NOT NULL,
`Permission` VARCHAR(5) NOT NULL,
`Status` INT(11) NOT NULL DEFAULT 0,
`Weight` INT(11) NOT NULL DEFAULT 0,
`Info` TEXT NULL DEFAULT NULL,
PRIMARY KEY (`Id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `" . $cfg['db']['lib']['name'] ."`.`updates`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`updates` ;
CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`updates` (
`s.no` int(10) NOT NULL AUTO_INCREMENT,
`PluginId` int(10) DEFAULT NULL,
`UpdatePath` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`UpdateInfo` text COLLATE utf8_unicode_ci,
PRIMARY KEY (`s.no`),
KEY `PluginId` (`PluginId`))
ENGINE=InnoDB;
-- -----------------------------------------
-- Constraints for table `updates`
-- -----------------------------------------
ALTER TABLE `" . $cfg['db']['lib']['name'] ."`.`updates`
ADD CONSTRAINT `updates_ibfk_1` FOREIGN KEY (`PluginId`) REFERENCES `plugins` (`Id`);
-- -----------------------------------------------------
-- Table `" . $cfg['db']['lib']['name'] ."`.`ticket`

View file

@ -0,0 +1,36 @@
{block name=content}
<div class="row-fluid">
<div class="box span12">
<div class="box-header well">
<h2><i class="icon-info-sign"></i>{$ip_title}</h2>
<div class="box-icon">
<a href="#" class="btn btn-round" onclick="javascript:show_help('intro');return false;"><i class="icon-info-sign"></i></a>
<a href="#" class="btn btn-setting btn-round"><i class="icon-cog"></i></a>
<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
<a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
</div>
</div>
<div class="box-content">
<center>
<p>{$ip_support}</p>
<div class="alert alert-error">
<form enctype="multipart/form-data" method="post" action="index.php?page=plugin&action=install_plugin" id="upload_plugin" >
<label for="file">Filename:</label>&nbsp;&nbsp;
<input type="file" name="file" id="file"></br>
<progress id="progressBar" value="0" max="100" style="width:300px;"></progress></br>
<input type="button" value="Upload" onclick="uploadPlugin()"></br>
<h3 id="status"></h3>
{if isset($smarty.get.result) and $smarty.get.result eq "0"}<p>{$ip_file_nfnd}</p>{/if}
{if isset($smarty.get.result) and $smarty.get.result eq "2"}<p>{$ip_info_nfound}</p>{/if}
</div>
{$ip_message}
</center>
<div class="clearfix"></div>
</div>
</div>
</div>
</div><!--/span-->
</div><!--/row-->
{/block}

View file

@ -192,6 +192,50 @@
}
</script>
<!-- script for file uploading-->
<script>
function _(e1)
{
return document.getElementById(e1);
}
function uploadPlugin()
{
var fileObject = _("file").files[0];
var formdata = new FormData();
formdata.append("file",fileObject);
var ajax = new XMLHttpRequest();
ajax.upload.addEventListener("progress", progressHandler, false);
ajax.addEventListener("load", completeHandler, false);
ajax.addEventListener("error", errorHandler, false);
ajax.addEventListener("abort", abortHandler, false);
ajax.open("POST", "index.php?page=plugin&action=install_plugin");
ajax.send(formdata);
}
function progressHandler(event)
{
var percent = (event.loaded/event.total)*100;
_("progressBar").value = Math.round(percent);
}
function completeHandler(event)
{
_("status").innerHTML = event.target.responseText;
_("progressBar").value = 0;
}
function errorHandler(event)
{
_("status").innerHTML = "upload Failed";
}
function abortHandler(event)
{
_("status").innerHTML = "upload Aborted";
}
</script>
<!-- jQuery -->
<script src="js/jquery-1.7.2.min.js"></script>
<!-- jQuery UI -->

View file

@ -9,6 +9,8 @@
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=show_queue&get=todo"><i class="icon-th-list"></i><span class="hidden-tablet"> Queues</span></a></li>
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=sgroup_list"><i class="icon-briefcase"></i><span class="hidden-tablet"> Support Groups</span></a></li>
<li class="nav-header hidden-tablet">Actions</li>
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=plugins"><i class="icon-th-list"></i><span class="hidden-tablet"> Plugins</span></a></li>
{if isset($hook_info)} {foreach from=$hook_info item=element}<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=layout_plugin&&name={$element.menu_display}"><i class="icon-th-list"></i><span class="hidden-tablet"> {$element.menu_display}</span></a></li>{/foreach}{/if}
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=syncing"><i class="icon-th-list"></i><span class="hidden-tablet"> Syncing</span></a></li>
<li style="margin-left: -2px;"><a href="?page=logout"><i class="icon-off"></i><span class="hidden-tablet"> Logout </span></a></li>
{/block}

View file

@ -0,0 +1,12 @@
{block name=content}
<div class="row-fluid">
{if isset($hook_info)}
{foreach from=$hook_info item=element}
{if $element.menu_display eq $smarty.get.name}
{include file=$element.template_path}
{/if}
{/foreach}
{/if}
</div>
{/block}

View file

@ -1,4 +1,3 @@
{block name=content}
<div class="row-fluid">
<div class="box span12">
@ -10,27 +9,45 @@
<a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
</div>
</div>
{if isset($smarty.get.result) and $smarty.get.result eq "1"}<div class="alert alert-error"><p>{$ip_success}</p></div>{/if}
{if isset($smarty.get.result) and $smarty.get.result eq "0"}<div class="alert alert-error"><p>{$dp_error}</p></div>{/if}
{if isset($smarty.get.result) and $smarty.get.result eq "2"}<div class="alert alert-error"><p>{$dp_success}</p></div>{/if}
{if isset($smarty.get.result) and $smarty.get.result eq "3"}<div class="alert alert-error"><p>{$ac_success}</p></div>{/if}
{if isset($smarty.get.result) and $smarty.get.result eq "4"}<div class="alert alert-error"><p>{$ac_error}</p></div>{/if}
{if isset($smarty.get.result) and $smarty.get.result eq "5"}<div class="alert alert-error"><p>{$dc_success}</p></div>{/if}
{if isset($smarty.get.result) and $smarty.get.result eq "6"}<div class="alert alert-error"><p>{$dc_error}</p></div>{/if}
{if isset($smarty.get.result) and $smarty.get.result eq "7"}<div class="alert alert-error"><p>{$up_success}</p></div>{/if}
{if isset($smarty.get.result) and $smarty.get.result eq "8"}<div class="alert alert-error"><p>{$up_install_success}</p></div>{/if}
<div class="box-content">
<center><p>{$plugin_info}</p></center>
<center>
<a href="index.php?page=install_plugin"><button class="btn btn-primary btn-large dropdown-toggle">Install New Plugin</button></a>
<a href="index.php?page=plugins_update"><button class="btn btn-primary btn-large dropdown-toggle">Check for updates</button></a>
</center>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>{$plugin_id}</th>
<th>{$plugin_permission}</th>
<th>{$plugin_name}</th>
<th>{$plugin_status}</th>
<th width="100">{$plugin_name}</th>
<th>{$plugin_version}</th>
<th>{$plugin_is_active}</th>
<th width="350">{$plugin_description}</th>
<th width="80">{$plugin_type}</th>
<th>{$plugin_permission}</th>
<th>{$plugin_actions}</th>
</tr>
</thead>
<tbody>
{foreach from=$plug item=element}
<tr>
<td>{$element.id}</td>
<td class="center">{$element.plugin_permission}</td>
<td><input type="checkbox" name ="{$element.id}"{if ($element.plugin_status) eq "1"}checked{/if}/></td>
<td class="center">{$element.plugin_name}</td>
<td class="center">{$element.plugin_version}</td>
<td class="center">{$element.plugin_isactive}</td>
<td class="center">{$element.plugin_info->Version}</td>
<td class="center">{$element.plugin_info->Description}</td>
<td class="center">{$element.plugin_type}</td>
<td class="center">{$element.plugin_permission}</td>
<td><a href="index.php?page=plugins&action=delete_plugin&id={$element.id}"><button class="btn btn-primary btn-large">Delete</button></a>
{if ($element.plugin_status) eq "0"}<a href="index.php?page=plugins&action=activate_plugin&id={$element.id}"><button class="btn btn-primary btn-large dropdown-toggle">Activate</button></a>{/if}
{if ($element.plugin_status) eq "1"}<a href="index.php?page=plugins&action=deactivate_plugin&id={$element.id}"><button class="btn btn-primary btn-large dropdown-toggle">Deactivate</button></a>{/if}</td>
</tr>
{/foreach}
@ -48,42 +65,5 @@
</div>
</div><!--/span-->
<div class="box span3">
<div class="box-header well" data-original-title="">
<h2><i class="icon-th"></i>Actions</h2>
<div class="box-icon">
<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
<a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
</div>
</div>
<div class="box-content">
<div class="row-fluid">
<div class="btn-group">
<button class="btn btn-primary btn-large dropdown-toggle" data-toggle="dropdown">Actions<span class="caret"></span></button>
<ul class="dropdown-menu">
<li class="divider"></li>
<li><a href="">Edit Plugins</a></li>
<li><a href="">Add Plugin</a></li>
<li class="divider"></li>
{if isset($isAdmin) and $isAdmin eq 'TRUE' and $target_id neq 1}
{if $userPermission eq 1}
<li><a href="index.php?page=change_permission&user_id={$target_id}&value=2">Make Moderator</a></li>
<li><a href="index.php?page=change_permission&user_id={$target_id}&value=3">Make Admin</a></li>
{else if $userPermission eq 2 }
<li><a href="index.php?page=change_permission&user_id={$target_id}&value=1">Demote to User</a></li>
<li><a href="index.php?page=change_permission&user_id={$target_id}&value=3">Make Admin</a></li>
{else if $userPermission eq 3 }
<li><a href="index.php?page=change_permission&user_id={$target_id}&value=1">Demote to User</a></li>
<li><a href="index.php?page=change_permission&user_id={$target_id}&value=2">Demote to Moderator</a></li>
{/if}
<li class="divider"></li>
{/if}
</ul>
</div>
</div>
</div>
</div><!--/span-->
</div><!--/row-->
{/block}

View file

@ -0,0 +1,50 @@
{block name=content}
<div class="row-fluid">
<div class="box span12">
<div class="box-header well" data-original-title>
<h2><i class="icon-user"></i> {$up_title}</h2>
<div class="box-icon">
<a href="#" class="btn btn-setting btn-round"><i class="icon-cog"></i></a>
<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
<a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
</div>
</div>
<div class="box-content">
<center><p>{$up_info}</p></center>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th width="100">{$plugin_name}</th>
<th>{$plugin_version}</th>
<th>{$up_updated_version}</th>
<th width="500">{$up_description}</th>
<th>{$up_actions}</th>
</tr>
</thead>
<tbody>
{foreach from=$plug item=element}
<tr>
<td class="center">{$element.plugin_name}</td>
<td class="center">{$element.plugin_info->Version}</td>
<td class="center">{$element.update_info->Version}</td>
<td class="center">{$element.update_info->UpdateInfo}</td>
<td><a href="index.php?page=plugins&action=update_plugins&id={$element.id}"><button class="btn btn-primary btn-large">Update</button></a>
</tr>
{/foreach}
</tbody>
</table>
<div style="width: 300px; margin:0px auto;">
<ul class="pagination">
<li><a href="index.php?page=plugins&pagenum=1">&laquo;</a></li>
{foreach from=$links item=link}
<li {if $link == $currentPage}class="active"{/if}><a href="index.php?page=plugins&pagenum={$link}">{$link}</a></li>
{/foreach}
<li><a href="index.php?page=plugins&pagenum={$lastPage}">&raquo;</a></li>
</ul>
</div>
</div>
</div><!--/span-->
</div><!--/row-->
{/block}