From 8f5a624b1c55aa6e1ea4910d684fc5c37833c540 Mon Sep 17 00:00:00 2001
From: Mitan Omar <22119228+MitanOmar@users.noreply.github.com>
Date: Tue, 16 Apr 2019 20:25:20 +0200
Subject: [PATCH 01/15] Update j_plugins.php
---
includes/adm/j_plugins.php | 205 ++++++++++++++++++++++++++++++++++++-
1 file changed, 200 insertions(+), 5 deletions(-)
diff --git a/includes/adm/j_plugins.php b/includes/adm/j_plugins.php
index 0b368c1..8575f87 100755
--- a/includes/adm/j_plugins.php
+++ b/includes/adm/j_plugins.php
@@ -32,15 +32,19 @@ $plugin_install_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&
$plugin_uninstall_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&case=uninstall&' . $GET_FORM_KEY . '&plg=';
$plugin_enable_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&case=enable&' . $GET_FORM_KEY . '&plg=';
$plugin_disable_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&case=disable&' . $GET_FORM_KEY . '&plg=';
+$plugin_download_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&case=download&' . $GET_FORM_KEY . '&plg=';
+$plugin_update_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&case=update&' . $GET_FORM_KEY . '&plg=';
//check _GET Csrf token
-if ($case && in_array($case, array('install', 'uninstall', 'enable', 'disable')))
+if (!$case || ! in_array($case, array('install', 'uninstall', 'enable', 'disable' , 'download' , 'update')))
{
- if (!kleeja_check_form_key_get('PLUGINS_FORM_KEY'))
- {
- kleeja_admin_err($lang['INVALID_GET_KEY'], $action);
- }
+ kleeja_admin_err('dont play with links', $action);
+}
+elseif (!kleeja_check_form_key_get('PLUGINS_FORM_KEY'))
+{
+ kleeja_admin_err($lang['INVALID_GET_KEY'], $action);
+ exit;
}
@@ -49,6 +53,7 @@ if(ip('newplugin'))
if(!kleeja_check_form_key('adm_plugins'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action);
+ exit;
}
$case = 'upload';
@@ -134,6 +139,50 @@ switch ($case):
$no_plugins = sizeof($available_plugins) == 0 && sizeof($installed_plugins) == 0;
+
+ // plugins avilable in kleeja store
+
+
+ $store_link = 'https://raw.githubusercontent.com/kleeja-official/plugin-catalog/master/plugins.json';
+
+ $get_store_plugins = fetch_remote_file($store_link);
+ $get_store_plugins = json_decode($get_store_plugins , true);
+
+ // make useful plugin list to searching in array
+ $useful_plugins_list = array();
+
+ foreach ($available_plugins as $value)
+ {
+ $useful_plugins_list[] = $value['name']; // the important think is plugin name , we dont want display the plugin again
+ }
+
+
+
+ $store_plugins = array();
+
+ // make an arry for all plugins in kleeja store that not included in our server
+ foreach ($get_store_plugins as $plugin_info)
+ {
+ if ( ! in_array($plugin_info['name'] , $useful_plugins_list) && empty($installed_plugins[$plugin_info['name']]) )
+ {
+ $store_plugins[$plugin_info['name']] = array(
+ 'name' => $plugin_info['name'] ,
+ 'developer' => $plugin_info['developer'] ,
+ 'version' => $plugin_info['file']['version'] ,
+ 'title' => ! empty($plugin_info['title'][$config['language']]) ? $plugin_info['title'][$config['language']] : $plugin_info['title']['en'] ,
+ 'website' => $plugin_info['website'] ,
+ 'kj_min_version' => $plugin_info['kleeja_version']['min'] ,
+ 'kj_max_version' => $plugin_info['kleeja_version']['max'] ,
+ 'icon' => $plugin_info['icon'] ,
+ 'NotCompatible' => ( version_compare(strtolower($plugin_info['kleeja_version']['min']), KLEEJA_VERSION , '<=')
+ && version_compare(strtolower($plugin_info['kleeja_version']['max']), KLEEJA_VERSION , '>=') )
+ ? false : true,
+ );
+ }
+
+ }
+
+
$stylee = "admin_plugins";
break;
@@ -472,4 +521,150 @@ switch ($case):
break;
+ case 'download':
+
+
+ if(intval($userinfo['founder']) !== 1)
+ {
+ kleeja_admin_err($lang['HV_NOT_PRVLG_ACCESS'], ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
+ exit;
+ }
+
+ // plugins avilable in kleeja store
+
+
+ $store_link = 'https://raw.githubusercontent.com/kleeja-official/plugin-catalog/master/plugins.json';
+
+ $get_store_plugins = fetch_remote_file($store_link);
+
+ if ($get_store_plugins)
+ {
+ $get_store_plugins = json_decode($get_store_plugins , true);
+
+ $store_plugins = array();
+
+ // make an arry for all plugins in kleeja store that not included in our server
+ foreach ($get_store_plugins as $plugin_info)
+ {
+ $store_plugins[$plugin_info['name']] = array(
+ 'name' => $plugin_info['name'] ,
+ 'plg_version' => $plugin_info['file']['version'] ,
+ 'url' => $plugin_info['file']['url'] ,
+ 'kj_min_version' => $plugin_info['kleeja_version']['min'] ,
+ 'kj_max_version' => $plugin_info['kleeja_version']['max'] ,
+ );
+ }
+
+
+
+ $downPlugin = g('plg');
+
+ if (isset($store_plugins[$downPlugin])) // => this plugin is hosted in our store
+ {
+ // check if the version of the plugin is compatible with our kleeja version or not
+ if (
+ version_compare(strtolower($store_plugins[$downPlugin]['kj_min_version']), KLEEJA_VERSION , '<=')
+ && version_compare(strtolower($store_plugins[$downPlugin]['kj_max_version']), KLEEJA_VERSION , '>=')
+ ) {
+ $plgDownLink = $store_plugins[$downPlugin]['url'];
+
+ $pluginZipFile = fetch_remote_file($plgDownLink, PATH . 'cache/'.$downPlugin.'.zip', 60, false, 10, true);
+
+ if ($pluginZipFile)
+ {
+ if ( file_exists( PATH . 'cache/'.$downPlugin.'.zip' ) )
+ {
+ $zip = new ZipArchive();
+ if ($zip->open( PATH . 'cache/'.$downPlugin.'.zip' ) === true)
+ {
+ if( $zip->extractTo(PATH . KLEEJA_PLUGINS_FOLDER))
+ {
+ $zip->close();
+
+ // we dont need the zip file anymore
+ unlink(PATH . 'cache/'.$downPlugin.'.zip');
+
+ // for example :: When we extract zip file , the name will be ( advanced-extras-1.0 )
+ // so we need to remove the version from folder name and replace ( - ) with ( _ )
+ // and done
+ $pluginFolderName = PATH . KLEEJA_PLUGINS_FOLDER. '/' . str_replace('_' , '-' , $downPlugin) . '-' . $store_plugins[$downPlugin]['plg_version'];
+ rename( $pluginFolderName , PATH . KLEEJA_PLUGINS_FOLDER. '/' . $downPlugin );
+
+ // download or update msg
+ ig('update') ? $doMsg = "Plugin {$downPlugin} is updated successfuly"
+ : $doMsg = "Plugin {$downPlugin} is downloaded successfuly";
+
+ kleeja_admin_info($doMsg , ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
+ exit;
+ }
+ else // please dont arrive to here , i think every think will be ok
+ {
+ kleeja_admin_err('error when extracting zip file');
+ }
+ }
+ }
+ else // not found plugin zip file
+ {
+ kleeja_admin_err('the zip file is not founded');
+ }
+ }
+ else // not connected to kleeja store or return empty content
+ {
+ kleeja_admin_err("error in the url of {$downPlugin} plugin");
+ }
+ }
+ else // not compatible with kleeja version
+ {
+ kleeja_admin_err("the version of {$downPlugin} is not compatible with your kleeja version");
+ }
+ }
+ else
+ {
+ kleeja_admin_err("plugin {$downPlugin} is not hosted in kleeja store");
+ }
+ }
+ else // the kleeja plugins.json is not found
+ {
+ kleeja_admin_err('error in connection with kleeja store');
+ }
+
+
+
+ break;
+
+ case 'update':
+
+ $plgUpdate = g('plg');
+
+ $plgFolder = PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plgUpdate;
+
+ if ( is_dir( $plgFolder ) )
+ {
+ delete_plugin_folder( $plgFolder );
+ }
+
+ redirect( $plugin_download_link . $plgUpdate . '&update' );
+
+ break;
+
+
+
+
endswitch;
+
+
+
+function get_root_plugin_info($plgName)
+{
+ $init = PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plgName . '/init.php';
+
+ $return = false;
+
+ if ( file_exists( $init ) )
+ {
+ require_once $init;
+ $return = $kleeja_plugin[$plgName]['information'];
+ }
+
+ return $return;
+}
From be0e2e6480768300c3941d47f307e35dae1909fe Mon Sep 17 00:00:00 2001
From: Mitan Omar <22119228+MitanOmar@users.noreply.github.com>
Date: Tue, 16 Apr 2019 20:28:20 +0200
Subject: [PATCH 02/15] Update admin_plugins.html
---
admin/Masmak/admin_plugins.html | 53 +++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/admin/Masmak/admin_plugins.html b/admin/Masmak/admin_plugins.html
index 6441c3e..0797df8 100755
--- a/admin/Masmak/admin_plugins.html
+++ b/admin/Masmak/admin_plugins.html
@@ -96,7 +96,60 @@
+
+
+
Store Plugins
+
+
+
+
+ -
+
+
+
{{title}}
+
+
+
+
+
+
+
+
+
+
Plugin Name : {{title}}
+
Plugin Developer : {{developer}}
+
Plugin Version : {{version}}
+
+
requested version of kleeja : ( min = {{kj_min_version}} ) , ( max = {{kj_max_version}} )
+
+
+ This plugin is not compatible with your version
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 3f73f6d94942e4fa51ee64fb930d2fec74983138 Mon Sep 17 00:00:00 2001
From: Abdulrahman
Date: Tue, 16 Apr 2019 22:54:33 +0300
Subject: [PATCH 03/15] fixes
---
includes/adm/j_plugins.php | 194 +++++++++++++++----------------------
1 file changed, 77 insertions(+), 117 deletions(-)
diff --git a/includes/adm/j_plugins.php b/includes/adm/j_plugins.php
index 8575f87..0d1ca58 100755
--- a/includes/adm/j_plugins.php
+++ b/includes/adm/j_plugins.php
@@ -37,14 +37,13 @@ $plugin_update_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&c
//check _GET Csrf token
-if (!$case || ! in_array($case, array('install', 'uninstall', 'enable', 'disable' , 'download' , 'update')))
+if (!empty($case) && in_array($case, array('install', 'uninstall', 'enable', 'disable' , 'download' , 'update')))
{
- kleeja_admin_err('dont play with links', $action);
-}
-elseif (!kleeja_check_form_key_get('PLUGINS_FORM_KEY'))
-{
- kleeja_admin_err($lang['INVALID_GET_KEY'], $action);
- exit;
+ if (!kleeja_check_form_key_get('PLUGINS_FORM_KEY'))
+ {
+ kleeja_admin_err($lang['INVALID_GET_KEY'], $action);
+ exit;
+ }
}
@@ -139,31 +138,27 @@ switch ($case):
$no_plugins = sizeof($available_plugins) == 0 && sizeof($installed_plugins) == 0;
-
- // plugins avilable in kleeja store
-
-
- $store_link = 'https://raw.githubusercontent.com/kleeja-official/plugin-catalog/master/plugins.json';
-
- $get_store_plugins = fetch_remote_file($store_link);
- $get_store_plugins = json_decode($get_store_plugins , true);
-
- // make useful plugin list to searching in array
- $useful_plugins_list = array();
-
- foreach ($available_plugins as $value)
+ // plugins avilable in kleeja remote catalog
+ if (!($catalog_plugins = $cache->get('catalog_plugins')))
{
- $useful_plugins_list[] = $value['name']; // the important think is plugin name , we dont want display the plugin again
+ $store_link = 'https://raw.githubusercontent.com/kleeja-official/plugin-catalog/master/plugins.json';
+
+ $catalog_plugins = fetch_remote_file($store_link);
+ $catalog_plugins = json_decode($catalog_plugins , true);
+
+ if(json_last_error() == JSON_ERROR_NONE)
+ {
+ $cache->save('catalog_plugins', $catalog_plugins);
+ }
}
-
-
+ // make an array for all plugins in kleeja remote catalog
+ // that are not exsisted locally.
$store_plugins = array();
-
- // make an arry for all plugins in kleeja store that not included in our server
- foreach ($get_store_plugins as $plugin_info)
+ $available_plugins_names = array_column($available_plugins, 'name');
+ foreach ($catalog_plugins as $plugin_info)
{
- if ( ! in_array($plugin_info['name'] , $useful_plugins_list) && empty($installed_plugins[$plugin_info['name']]) )
+ if (! in_array($plugin_info['name'] , $available_plugins_names) && empty($installed_plugins[$plugin_info['name']]) )
{
$store_plugins[$plugin_info['name']] = array(
'name' => $plugin_info['name'] ,
@@ -179,10 +174,8 @@ switch ($case):
? false : true,
);
}
-
}
-
$stylee = "admin_plugins";
break;
@@ -192,11 +185,8 @@ switch ($case):
//upload a plugin
//
case 'upload':
-
-
$ERRORS = array();
-
if(intval($userinfo['founder']) !== 1)
{
$ERRORS[] = $lang['HV_NOT_PRVLG_ACCESS'];
@@ -209,8 +199,6 @@ switch ($case):
$ERRORS[] = $lang['CHOSE_F'];
}
-
-
#extract it to plugins folder
if(!sizeof($ERRORS))
{
@@ -241,7 +229,6 @@ switch ($case):
@unlink($_FILES['plugin_file']['tmp_name']);
}
-
if(!sizeof($ERRORS))
{
kleeja_admin_info($lang['NO_PROBLEM_AFTER_ZIP'], true, '', true, $action);
@@ -259,17 +246,14 @@ switch ($case):
//
case 'install':
-
if(intval($userinfo['founder']) !== 1)
{
kleeja_admin_err($lang['HV_NOT_PRVLG_ACCESS'], ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
exit;
}
-
$plg_name = g('plg', 'str');
-
if (empty($plg_name))
{
if (defined('DEBUG'))
@@ -339,13 +323,11 @@ switch ($case):
delete_cache('', true);
-
if (is_array($plugin_info['plugin_description']))
{
$plugin_info['plugin_description'] = !empty($plugin_info['plugin_description']['en']) ? $plugin_info['plugin_description']['en'] : $plugin_info['plugin_description'][0];
}
-
#add to database
$insert_query = array(
'INSERT' => '`plg_name` ,`plg_ver`, `plg_author`, `plg_dsc`, `plg_icon`, `plg_uninstall`, `plg_instructions`, `plg_store`, `plg_files`',
@@ -355,14 +337,12 @@ switch ($case):
$SQL->build($insert_query);
-
#may God protect you brother.
if(is_callable($install_callback))
{
$install_callback($SQL->insert_id());
}
-
#show done, msg
$text = '' . $lang['NEW_PLUGIN_ADDED'] . '
';
if ($plugin_first_run)
@@ -394,10 +374,8 @@ switch ($case):
exit;
}
-
$plg_name = g('plg', 'str');
-
if (empty($plg_name))
{
if (defined('DEV_STAGE'))
@@ -439,16 +417,13 @@ switch ($case):
'WHERE' => "plg_name='" . $SQL->escape($plg_name) . "'"
);
-
$result = $SQL->build($query);
$pluginDatabaseInfo = $SQL->fetch($result);
-
#sad to see you go, brother
$uninstall_callback(!empty($pluginDatabaseInfo) ? $pluginDatabaseInfo['plg_id'] : 0);
-
delete_cache('', true);
#remove from database
@@ -463,7 +438,6 @@ switch ($case):
$text = '' . $lang['PLUGIN_DELETED'] . '
';
$text .= '' . "\n";
-
$stylee = 'admin_info';
}
@@ -471,7 +445,7 @@ switch ($case):
//
- //disable a plugin
+ // disable a plugin
//
case 'disable':
case 'enable':
@@ -482,10 +456,8 @@ switch ($case):
exit;
}
-
$plg_name = g('plg', 'str');
-
if (empty($plg_name))
{
if (defined('DEV_STAGE'))
@@ -507,7 +479,6 @@ switch ($case):
$SQL->build($update_query);
-
delete_cache('', true);
#show done, msg
@@ -520,9 +491,7 @@ switch ($case):
break;
-
- case 'download':
-
+ case 'download':
if(intval($userinfo['founder']) !== 1)
{
@@ -531,20 +500,18 @@ switch ($case):
}
// plugins avilable in kleeja store
-
-
$store_link = 'https://raw.githubusercontent.com/kleeja-official/plugin-catalog/master/plugins.json';
- $get_store_plugins = fetch_remote_file($store_link);
+ $catalog_plugins = fetch_remote_file($store_link);
- if ($get_store_plugins)
+ if ($catalog_plugins)
{
- $get_store_plugins = json_decode($get_store_plugins , true);
-
+ $catalog_plugins = json_decode($catalog_plugins , true);
+
$store_plugins = array();
// make an arry for all plugins in kleeja store that not included in our server
- foreach ($get_store_plugins as $plugin_info)
+ foreach ($catalog_plugins as $plugin_info)
{
$store_plugins[$plugin_info['name']] = array(
'name' => $plugin_info['name'] ,
@@ -554,116 +521,109 @@ switch ($case):
'kj_max_version' => $plugin_info['kleeja_version']['max'] ,
);
}
-
-
-
- $downPlugin = g('plg');
-
- if (isset($store_plugins[$downPlugin])) // => this plugin is hosted in our store
+
+ $download_plugin = g('plg');
+
+ // // => this plugin is hosted in our store
+ if (isset($store_plugins[$download_plugin]))
{
// check if the version of the plugin is compatible with our kleeja version or not
if (
- version_compare(strtolower($store_plugins[$downPlugin]['kj_min_version']), KLEEJA_VERSION , '<=')
- && version_compare(strtolower($store_plugins[$downPlugin]['kj_max_version']), KLEEJA_VERSION , '>=')
- ) {
- $plgDownLink = $store_plugins[$downPlugin]['url'];
-
- $pluginZipFile = fetch_remote_file($plgDownLink, PATH . 'cache/'.$downPlugin.'.zip', 60, false, 10, true);
-
- if ($pluginZipFile)
+ version_compare(strtolower($store_plugins[$download_plugin]['kj_min_version']), KLEEJA_VERSION , '<=')
+ && version_compare(strtolower($store_plugins[$download_plugin]['kj_max_version']), KLEEJA_VERSION , '>=')
+ )
+ {
+ $download_plugin_link = $store_plugins[$download_plugin]['url'];
+
+ $downloaded_plugin_zip = fetch_remote_file($download_plugin_link, PATH . 'cache/' . $download_plugin . '.zip', 60, false, 10, true);
+
+ if ($downloaded_plugin_zip)
{
- if ( file_exists( PATH . 'cache/'.$downPlugin.'.zip' ) )
+ if (file_exists(PATH . 'cache/' . $download_plugin . '.zip' ) )
{
$zip = new ZipArchive();
- if ($zip->open( PATH . 'cache/'.$downPlugin.'.zip' ) === true)
+ if ($zip->open(PATH . 'cache/' . $download_plugin . '.zip' ) === true)
{
if( $zip->extractTo(PATH . KLEEJA_PLUGINS_FOLDER))
{
$zip->close();
-
// we dont need the zip file anymore
- unlink(PATH . 'cache/'.$downPlugin.'.zip');
-
+ unlink(PATH . 'cache/' . $download_plugin . '.zip');
+
// for example :: When we extract zip file , the name will be ( advanced-extras-1.0 )
// so we need to remove the version from folder name and replace ( - ) with ( _ )
// and done
- $pluginFolderName = PATH . KLEEJA_PLUGINS_FOLDER. '/' . str_replace('_' , '-' , $downPlugin) . '-' . $store_plugins[$downPlugin]['plg_version'];
- rename( $pluginFolderName , PATH . KLEEJA_PLUGINS_FOLDER. '/' . $downPlugin );
-
+ $plugin_folder_name = PATH . KLEEJA_PLUGINS_FOLDER. '/' . str_replace('_' , '-' , $download_plugin) . '-' . $store_plugins[$download_plugin]['plg_version'];
+ rename($plugin_folder_name , PATH . KLEEJA_PLUGINS_FOLDER. '/' . $download_plugin);
+
// download or update msg
- ig('update') ? $doMsg = "Plugin {$downPlugin} is updated successfuly"
- : $doMsg = "Plugin {$downPlugin} is downloaded successfuly";
-
- kleeja_admin_info($doMsg , ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
+ kleeja_admin_info(
+ ig('update') ? "Plugin {$downPlugin} is updated successfuly" : "Plugin {$downPlugin} is downloaded successfuly",
+ ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
+
exit;
}
- else // please dont arrive to here , i think every think will be ok
+ else
{
- kleeja_admin_err('error when extracting zip file');
+ kleeja_admin_err('error during extracting zip file...');
}
}
}
- else // not found plugin zip file
+ else
{
- kleeja_admin_err('the zip file is not founded');
+ kleeja_admin_err('the plugin zip file is not founded');
}
}
else // not connected to kleeja store or return empty content
{
- kleeja_admin_err("error in the url of {$downPlugin} plugin");
+ kleeja_admin_err("error in the url of {$download_plugin} plugin");
}
}
else // not compatible with kleeja version
{
- kleeja_admin_err("the version of {$downPlugin} is not compatible with your kleeja version");
+ kleeja_admin_err("the version of { $download_plugin} is not compatible with your kleeja version");
}
}
else
{
- kleeja_admin_err("plugin {$downPlugin} is not hosted in kleeja store");
+ kleeja_admin_err("plugin {$download_plugin} is not hosted in kleeja store");
}
}
- else // the kleeja plugins.json is not found
+ else
{
- kleeja_admin_err('error in connection with kleeja store');
+ kleeja_admin_err('Connection error to kleeja remote plugin catalog.');
}
+ break;
+ case 'update':
- break;
+ $update_plugin = g('plg');
- case 'update':
+ $plugin_folder_name = PATH . KLEEJA_PLUGINS_FOLDER . '/' . $update_plugin;
- $plgUpdate = g('plg');
-
- $plgFolder = PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plgUpdate;
-
- if ( is_dir( $plgFolder ) )
- {
- delete_plugin_folder( $plgFolder );
- }
-
- redirect( $plugin_download_link . $plgUpdate . '&update' );
-
- break;
-
-
+ if (is_dir($plugin_folder_name))
+ {
+ delete_plugin_folder($plugin_folder_name);
+ }
+ redirect($plugin_download_link . $update_plugin . '&update' );
+ break;
endswitch;
-function get_root_plugin_info($plgName)
+function get_root_plugin_info($plugin_name)
{
- $init = PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plgName . '/init.php';
+ $init = PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plugin_name . '/init.php';
$return = false;
- if ( file_exists( $init ) )
+ if (file_exists($init))
{
require_once $init;
- $return = $kleeja_plugin[$plgName]['information'];
+ $return = $kleeja_plugin[$plugin_name]['information'];
}
return $return;
From 31c86085fcfe7047a76f3f523c0cb2d94e55dc33 Mon Sep 17 00:00:00 2001
From: Abdulrahman
Date: Tue, 16 Apr 2019 23:01:08 +0300
Subject: [PATCH 04/15] add delete_plugin_folder function
---
includes/functions_adm.php | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/includes/functions_adm.php b/includes/functions_adm.php
index 8ec15e5..3a66342 100755
--- a/includes/functions_adm.php
+++ b/includes/functions_adm.php
@@ -380,4 +380,25 @@ function adm_is_start_box_hidden($name)
is_array($plugin_run_result = Plugins::getInstance()->run('adm_start_boxes_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
return in_array($name, $boxes);
+}
+
+/**
+ * delete plugin folder
+ * @param string $dir plugin folder path
+ * @return void
+ */
+function delete_plugin_folder($dir)
+{
+ $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
+ $files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
+ foreach ($files as $file) {
+ if ($file->isLink()) {
+ unlink($file->getPathname());
+ } else if ($file->isDir()) {
+ rmdir($file->getPathname());
+ } else {
+ unlink($file->getPathname());
+ }
+ }
+ rmdir($dir);
}
\ No newline at end of file
From cae058e35b3c7c869f7db084f94d0465b88bc032 Mon Sep 17 00:00:00 2001
From: Abdulrahman
Date: Fri, 19 Apr 2019 23:08:22 +0300
Subject: [PATCH 05/15] fixes
---
includes/adm/j_plugins.php | 64 ++++++++++++++++----------------------
includes/functions_adm.php | 22 ++++++++-----
lang/en/acp.php | 13 +++++---
3 files changed, 49 insertions(+), 50 deletions(-)
diff --git a/includes/adm/j_plugins.php b/includes/adm/j_plugins.php
index 0d1ca58..9b195d8 100755
--- a/includes/adm/j_plugins.php
+++ b/includes/adm/j_plugins.php
@@ -119,7 +119,8 @@ switch ($case):
$available_plugins = array();
while (false !== ($folder_name = readdir($dh)))
{
- if (is_dir(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $folder_name) && preg_match('/[a-z0-9_.]{3,}/', $folder_name)) {
+ if (is_dir(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $folder_name) && preg_match('/[a-z0-9_.]{3,}/', $folder_name))
+ {
if (empty($installed_plugins[$folder_name]))
{
array_push($available_plugins,
@@ -169,8 +170,8 @@ switch ($case):
'kj_min_version' => $plugin_info['kleeja_version']['min'] ,
'kj_max_version' => $plugin_info['kleeja_version']['max'] ,
'icon' => $plugin_info['icon'] ,
- 'NotCompatible' => ( version_compare(strtolower($plugin_info['kleeja_version']['min']), KLEEJA_VERSION , '<=')
- && version_compare(strtolower($plugin_info['kleeja_version']['max']), KLEEJA_VERSION , '>=') )
+ 'NotCompatible' => version_compare(strtolower($plugin_info['kleeja_version']['min']), KLEEJA_VERSION , '<=')
+ && version_compare(strtolower($plugin_info['kleeja_version']['max']), KLEEJA_VERSION , '>=')
? false : true,
);
}
@@ -192,7 +193,6 @@ switch ($case):
$ERRORS[] = $lang['HV_NOT_PRVLG_ACCESS'];
}
-
#is uploaded?
if(empty($_FILES['plugin_file']['tmp_name']))
{
@@ -235,7 +235,7 @@ switch ($case):
}
else
{
- kleeja_admin_err('- ' . implode('
- ', $ERRORS), ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
+ kleeja_admin_err('- ' . implode('
- ', $ERRORS), true, '', true, ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
}
break;
@@ -279,7 +279,7 @@ switch ($case):
#if already installed, show a message
if (!empty(Plugins::getInstance()->installed_plugin_info($plg_name)))
{
- kleeja_admin_info($lang['PLUGIN_EXISTS_BEFORE'], ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
+ kleeja_admin_info($lang['PLUGIN_EXISTS_BEFORE'], true, '', true, ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
exit;
}
@@ -300,7 +300,6 @@ switch ($case):
$plugin_first_run = $kleeja_plugin[$plg_name]['first_run']['en'];
}
-
#check if compatible with kleeja
#'plugin_kleeja_version_min' => '1.8',
# Max version of Kleeja that's required to run this plugin
@@ -308,7 +307,10 @@ switch ($case):
if (version_compare(KLEEJA_VERSION, $plugin_info['plugin_kleeja_version_min'], '<'))
{
- kleeja_admin_info($lang['PLUGIN_N_CMPT_KLJ'] . '
k:' . KLEEJA_VERSION . '|<|p.min:' . $plugin_info['plugin_kleeja_version_min'], ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
+ kleeja_admin_info(
+ $lang['PLUGIN_N_CMPT_KLJ'] . '
k:' . KLEEJA_VERSION . '|<|p.min:' . $plugin_info['plugin_kleeja_version_min'],
+ true, '', true, ADMIN_PATH . '?cp=' . basename(__file__, '.php')
+ );
exit;
}
@@ -316,7 +318,10 @@ switch ($case):
{
if (version_compare(KLEEJA_VERSION, $plugin_info['plugin_kleeja_version_max'], '>'))
{
- kleeja_admin_info($lang['PLUGIN_N_CMPT_KLJ'] . '
k:' . KLEEJA_VERSION . '|>|p.max:' . $plugin_info['plugin_kleeja_version_max'], ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
+ kleeja_admin_info(
+ $lang['PLUGIN_N_CMPT_KLJ'] . '
k:' . KLEEJA_VERSION . '|>|p.max:' . $plugin_info['plugin_kleeja_version_max'],
+ true, '', true, ADMIN_PATH . '?cp=' . basename(__file__, '.php')
+ );
exit;
}
}
@@ -361,8 +366,6 @@ switch ($case):
break;
-
-
//
//uninstall a plugin
//
@@ -382,6 +385,7 @@ switch ($case):
{
exit('empty($plg_name)');
}
+
//no plugin selected? back
redirect(ADMIN_PATH . "?cp=" . basename(__file__, '.php'));
}
@@ -558,40 +562,41 @@ switch ($case):
// download or update msg
kleeja_admin_info(
- ig('update') ? "Plugin {$downPlugin} is updated successfuly" : "Plugin {$downPlugin} is downloaded successfuly",
- ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
+ sprintf($lang[ig('update') ? 'PLUGIN_UPDATED' : 'PLUGIN_DOWNLOADED'], $download_plugin),
+ ADMIN_PATH . '?cp=' . basename(__file__, '.php')
+ );
exit;
}
else
{
- kleeja_admin_err('error during extracting zip file...');
+ kleeja_admin_err($lang['EXTRACT_ZIP_FAILED']);
}
}
}
else
{
- kleeja_admin_err('the plugin zip file is not founded');
+ kleeja_admin_err($lang['PLUGIN_FILE_NOT_FOUND']);
}
}
- else // not connected to kleeja store or return empty content
+ else
{
- kleeja_admin_err("error in the url of {$download_plugin} plugin");
+ kleeja_admin_err($lang['PLUGINS_SERVER_ERROR']);
}
}
- else // not compatible with kleeja version
+ else
{
- kleeja_admin_err("the version of { $download_plugin} is not compatible with your kleeja version");
+ kleeja_admin_err($lang['PLUGIN_N_CMPT_KLJ']);
}
}
else
{
- kleeja_admin_err("plugin {$download_plugin} is not hosted in kleeja store");
+ kleeja_admin_err(sprintf($lang['PLUGIN_REMOTE_FILE_MISSING'], $download_plugin));
}
}
else
{
- kleeja_admin_err('Connection error to kleeja remote plugin catalog.');
+ kleeja_admin_err($lang['PLUGINS_SERVER_ERROR']);
}
break;
@@ -611,20 +616,3 @@ switch ($case):
break;
endswitch;
-
-
-
-function get_root_plugin_info($plugin_name)
-{
- $init = PATH . KLEEJA_PLUGINS_FOLDER . '/' . $plugin_name . '/init.php';
-
- $return = false;
-
- if (file_exists($init))
- {
- require_once $init;
- $return = $kleeja_plugin[$plugin_name]['information'];
- }
-
- return $return;
-}
diff --git a/includes/functions_adm.php b/includes/functions_adm.php
index 3a66342..059974b 100755
--- a/includes/functions_adm.php
+++ b/includes/functions_adm.php
@@ -391,14 +391,20 @@ function delete_plugin_folder($dir)
{
$it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
- foreach ($files as $file) {
- if ($file->isLink()) {
- unlink($file->getPathname());
- } else if ($file->isDir()) {
- rmdir($file->getPathname());
- } else {
- unlink($file->getPathname());
- }
+ foreach ($files as $file)
+ {
+ if ($file->isLink())
+ {
+ unlink($file->getPathname());
+ }
+ else if ($file->isDir())
+ {
+ rmdir($file->getPathname());
}
+ else
+ {
+ unlink($file->getPathname());
+ }
+ }
rmdir($dir);
}
\ No newline at end of file
diff --git a/lang/en/acp.php b/lang/en/acp.php
index 1644514..db6ee2e 100755
--- a/lang/en/acp.php
+++ b/lang/en/acp.php
@@ -262,8 +262,13 @@ return array(
'NO_PROBLEM_AFTER_ZIP' => 'The file has been extracted successfully and it\'s ready to be enabled',
'SESSION_ENDED' => 'Session has ended, do you want to login again?',
//3.0.3
- 'CUSTOMIZATION' => 'Customization',
- 'SHOW' => 'Show',
- 'HIDE' => 'Hide',
- 'STATS_BOXES' => 'Stats Boxes',
+ 'CUSTOMIZATION' => 'Customization',
+ 'SHOW' => 'Show',
+ 'HIDE' => 'Hide',
+ 'STATS_BOXES' => 'Stats Boxes',
+ 'PLUGIN_UPDATED' => 'Plugin "%s" has been updated successfully ..',
+ 'PLUGIN_DOWNLOADED' => 'Plugin "%s" has been downloaded successfully ..',
+ 'PLUGIN_FILE_NOT_FOUND' => 'The plugin file is missing!',
+ 'PLUGIN_REMOTE_FILE_MISSING'=> 'The plugin "%s" is not on Kleeja remote server!',
+ 'PLUGINS_SERVER_ERROR' => 'We encountered an error while connecting to the plugins remote server ...',
);
From 34620261f8603747396f0085fffc19890d35219b Mon Sep 17 00:00:00 2001
From: Abdulrahman
Date: Fri, 19 Apr 2019 23:54:23 +0300
Subject: [PATCH 06/15] fixes
---
admin/Masmak/admin_plugins.html | 159 ++++++++++++++++----------------
includes/adm/j_plugins.php | 20 ++--
lang/ar/acp.php | 19 +++-
lang/en/acp.php | 11 ++-
4 files changed, 118 insertions(+), 91 deletions(-)
diff --git a/admin/Masmak/admin_plugins.html b/admin/Masmak/admin_plugins.html
index 0797df8..3659092 100755
--- a/admin/Masmak/admin_plugins.html
+++ b/admin/Masmak/admin_plugins.html
@@ -6,25 +6,33 @@
+
-
-
+
+
-
+
+
+
+ {lang.NO_PLUGINS}
+
+
+
-
-

@@ -60,24 +68,20 @@
-
-
-
-
-
-
-
-
-
-
-
Store Plugins
-
-
-
-
- -
-
-
-
{{title}}
-
-
-
-
-
-
-
-
-
-
-
Plugin Name : {{title}}
-
Plugin Developer : {{developer}}
-
Plugin Version : {{version}}
-
-
requested version of kleeja : ( min = {{kj_min_version}} ) , ( max = {{kj_max_version}} )
-
-
- This plugin is not compatible with your version
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -180,3 +126,58 @@
+
+
+
+
+
+
+
+ -
+
+
+
{{title}}
+
+
+
+
+
+
+
+
+
+
+ -
+ {lang.DEVELOPER}: {{developer}}
+
+
+ - {lang.VERSION}: {{version}}
+ - {{kj_version_cmtp}}
+
+ -
+ {lang.PLUGIN_N_CMPT_KLJ}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/includes/adm/j_plugins.php b/includes/adm/j_plugins.php
index 9b195d8..8991841 100755
--- a/includes/adm/j_plugins.php
+++ b/includes/adm/j_plugins.php
@@ -20,7 +20,7 @@ if (!defined('IN_ADMIN'))
#get current case
-$case = g('case', 'str');
+$case = g('case', 'str', 'installed');
#set _get form key
$GET_FORM_KEY = kleeja_add_form_key_get('PLUGINS_FORM_KEY');
@@ -61,6 +61,8 @@ if(ip('newplugin'))
switch ($case):
default:
+ case 'local':
+ case 'store':
# Get installed plugins
$query = array(
@@ -137,7 +139,15 @@ switch ($case):
}
@closedir($dh);
- $no_plugins = sizeof($available_plugins) == 0 && sizeof($installed_plugins) == 0;
+ $no_plugins = TRUE;
+
+ $stylee = "admin_plugins";
+
+ //do not proceed if not store case
+ if($case != 'store')
+ {
+ break;
+ }
// plugins avilable in kleeja remote catalog
if (!($catalog_plugins = $cache->get('catalog_plugins')))
@@ -169,19 +179,17 @@ switch ($case):
'website' => $plugin_info['website'] ,
'kj_min_version' => $plugin_info['kleeja_version']['min'] ,
'kj_max_version' => $plugin_info['kleeja_version']['max'] ,
+ 'kj_version_cmtp' => sprintf($lang[ 'KLJ_VER_NO_PLUGIN'], $plugin_info['kleeja_version']['min'], $plugin_info['kleeja_version']['max']),
'icon' => $plugin_info['icon'] ,
'NotCompatible' => version_compare(strtolower($plugin_info['kleeja_version']['min']), KLEEJA_VERSION , '<=')
&& version_compare(strtolower($plugin_info['kleeja_version']['max']), KLEEJA_VERSION , '>=')
? false : true,
);
}
- }
-
- $stylee = "admin_plugins";
+ }
break;
-
//
//upload a plugin
//
diff --git a/lang/ar/acp.php b/lang/ar/acp.php
index cf04f7a..0e30ae2 100755
--- a/lang/ar/acp.php
+++ b/lang/ar/acp.php
@@ -262,10 +262,19 @@ return array(
'NO_ZIP_ARCHIVE' => 'يبدو أن ZipArchive ليس متوفراً علي خادمك، قم بتثبيته فهو من المتطلبات.',
'EXTRACT_ZIP_FAILED' => 'صادفتنا مشكلة أثناء فك الأرشيف! تأكد من أنه ملف zip صالح، وأن مجلد "%s" قابل للكتابة.',
'NO_PROBLEM_AFTER_ZIP' => 'لقد تم فك الملف بنجاح وهو جاهز للتفعيل.',
- 'SESSION_ENDED' => 'انتهت الجلسة، هل تريد تسجل الدخول من جديد؟',
+ 'SESSION_ENDED' => 'انتهت الجلسة، هل تريد تسجل الدخول من جديد؟',
//3.0.3
- 'CUSTOMIZATION' => 'تخصيص',
- 'SHOW' => 'عرض',
- 'HIDE' => 'إخفاء',
- 'STATS_BOXES' => 'صناديق الإحصائيات',
+ 'CUSTOMIZATION' => 'تخصيص',
+ 'SHOW' => 'عرض',
+ 'HIDE' => 'إخفاء',
+ 'VIEW' => 'إستعراض',
+ 'INSTALL' => 'تثبيت',
+ 'CLOSE' => 'إغلاق',
+ 'STATS_BOXES' => 'صناديق الإحصائيات',
+ 'INSTALLED_PLUGINS' => 'الإضافات المثبتة',
+ 'LOCAL_PLUGINS' => 'الإضافات المحلية',
+ 'KLEEJA_STORE' => 'متجر كليجا',
+ 'KLJ_VER_NO_PLUGIN' => 'هذه الإضافة يمكنها العمل على إصدار كليجا %1$s حتى إصدار %2$s.',
+ 'VERSION' => 'الإصدار',
+ 'DEVELOPER' => 'المطور',
);
diff --git a/lang/en/acp.php b/lang/en/acp.php
index db6ee2e..f33abe2 100755
--- a/lang/en/acp.php
+++ b/lang/en/acp.php
@@ -120,7 +120,7 @@ return array(
'PLUGIN_DELETED' => 'Plugin deleted...',
'PLGUIN_DISABLED_ENABLED' => 'Plugin Enabled / Disabled',
- 'NO_PLUGINS' => 'No plugins found',
+ 'NO_PLUGINS' => 'No plugins found! You could start browsing plugins and installing them by clicking the tab "Kleeja Store" or upload a plugin file from the tab "Local Plugins".',
'NEW_PLUGIN_ADDED' => 'Plugin added ... ',
'PLUGIN_EXISTS_BEFORE' => 'This plugin exists before with same version or above, so no need to update it!.',
'R_CHECK_UPDATE' => 'Check for updates',
@@ -265,10 +265,19 @@ return array(
'CUSTOMIZATION' => 'Customization',
'SHOW' => 'Show',
'HIDE' => 'Hide',
+ 'VIEW' => 'View',
+ 'INSTALL' => 'Install',
+ 'CLOSE' => 'Close',
'STATS_BOXES' => 'Stats Boxes',
'PLUGIN_UPDATED' => 'Plugin "%s" has been updated successfully ..',
'PLUGIN_DOWNLOADED' => 'Plugin "%s" has been downloaded successfully ..',
'PLUGIN_FILE_NOT_FOUND' => 'The plugin file is missing!',
'PLUGIN_REMOTE_FILE_MISSING'=> 'The plugin "%s" is not on Kleeja remote server!',
'PLUGINS_SERVER_ERROR' => 'We encountered an error while connecting to the plugins remote server ...',
+ 'INSTALLED_PLUGINS' => 'Installed Plugins',
+ 'LOCAL_PLUGINS' => 'Local Plugins',
+ 'KLEEJA_STORE' => 'Kleeja Store',
+ 'KLJ_VER_NO_PLUGIN' => 'This plugin can works on Kleeja version %1$s up to version %2$s.',
+ 'VERSION' => 'Version',
+ 'DEVELOPER' => 'Developer',
);
From ea01c7d2a7f91c874e5ad79b5bc9e9a53a36eb25 Mon Sep 17 00:00:00 2001
From: Abdulrahman
Date: Fri, 19 Apr 2019 23:55:21 +0300
Subject: [PATCH 07/15] fix
---
includes/adm/j_plugins.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/adm/j_plugins.php b/includes/adm/j_plugins.php
index 8991841..2c7551c 100755
--- a/includes/adm/j_plugins.php
+++ b/includes/adm/j_plugins.php
@@ -139,7 +139,7 @@ switch ($case):
}
@closedir($dh);
- $no_plugins = TRUE;
+ $no_plugins = sizeof($available_plugins) == 0 && sizeof($installed_plugins) == 0;
$stylee = "admin_plugins";
From 73b7fbf19d7150fce712c4a047cd761ba38e0606 Mon Sep 17 00:00:00 2001
From: Abdulrahman
Date: Thu, 2 May 2019 19:51:46 +0300
Subject: [PATCH 08/15] plugins update tab
---
admin/Masmak/admin_plugins.html | 14 ++++++--
includes/adm/j_plugins.php | 51 +++++++++++++++++++----------
includes/style.php | 57 ++++++++++++++++++---------------
lang/ar/acp.php | 1 +
lang/en/acp.php | 1 +
5 files changed, 80 insertions(+), 44 deletions(-)
diff --git a/admin/Masmak/admin_plugins.html b/admin/Masmak/admin_plugins.html
index 3659092..5f26158 100755
--- a/admin/Masmak/admin_plugins.html
+++ b/admin/Masmak/admin_plugins.html
@@ -16,6 +16,9 @@
{lang.KLEEJA_STORE}
+
+ {lang.R_CHECK_UPDATE}
+
@@ -130,7 +133,14 @@
-
+
+
+
+
+ {lang.ALL_PLUGINS_UPDATED}{lang.NO_PLUGINS}
+
+
+
-
@@ -139,7 +149,7 @@
{{title}}
diff --git a/includes/adm/j_plugins.php b/includes/adm/j_plugins.php
index 2c7551c..b4299b3 100755
--- a/includes/adm/j_plugins.php
+++ b/includes/adm/j_plugins.php
@@ -63,6 +63,7 @@ switch ($case):
default:
case 'local':
case 'store':
+ case 'check':
# Get installed plugins
$query = array(
@@ -144,7 +145,7 @@ switch ($case):
$stylee = "admin_plugins";
//do not proceed if not store case
- if($case != 'store')
+ if(! in_array($case, ['store', 'check']))
{
break;
}
@@ -169,24 +170,40 @@ switch ($case):
$available_plugins_names = array_column($available_plugins, 'name');
foreach ($catalog_plugins as $plugin_info)
{
- if (! in_array($plugin_info['name'] , $available_plugins_names) && empty($installed_plugins[$plugin_info['name']]) )
+ if ($case == 'store' && in_array($plugin_info['name'] , $available_plugins_names) &&
+ ! empty($installed_plugins[$plugin_info['name']])
+ )
{
- $store_plugins[$plugin_info['name']] = array(
- 'name' => $plugin_info['name'] ,
- 'developer' => $plugin_info['developer'] ,
- 'version' => $plugin_info['file']['version'] ,
- 'title' => ! empty($plugin_info['title'][$config['language']]) ? $plugin_info['title'][$config['language']] : $plugin_info['title']['en'] ,
- 'website' => $plugin_info['website'] ,
- 'kj_min_version' => $plugin_info['kleeja_version']['min'] ,
- 'kj_max_version' => $plugin_info['kleeja_version']['max'] ,
- 'kj_version_cmtp' => sprintf($lang[ 'KLJ_VER_NO_PLUGIN'], $plugin_info['kleeja_version']['min'], $plugin_info['kleeja_version']['max']),
- 'icon' => $plugin_info['icon'] ,
- 'NotCompatible' => version_compare(strtolower($plugin_info['kleeja_version']['min']), KLEEJA_VERSION , '<=')
- && version_compare(strtolower($plugin_info['kleeja_version']['max']), KLEEJA_VERSION , '>=')
- ? false : true,
- );
+ continue;
}
- }
+
+ // is there a new version of this in the store
+ if ($case == 'check' && (! empty($installed_plugins[$plugin_info['name']]) &&
+ version_compare(
+ strtolower($installed_plugins[$row['plg_name']]['extra_info']['plugin_version']),
+ $plugin_info['file']['version'],
+ '>=') || empty($installed_plugins[$plugin_info['name']]))
+ ) {
+ continue;
+ }
+
+ $store_plugins[$plugin_info['name']] = array(
+ 'name' => $plugin_info['name'],
+ 'developer' => $plugin_info['developer'],
+ 'version' => $plugin_info['file']['version'],
+ 'title' => ! empty($plugin_info['title'][$config['language']]) ? $plugin_info['title'][$config['language']] : $plugin_info['title']['en'],
+ 'website' => $plugin_info['website'],
+ 'kj_min_version' => $plugin_info['kleeja_version']['min'],
+ 'kj_max_version' => $plugin_info['kleeja_version']['max'],
+ 'kj_version_cmtp' => sprintf($lang[ 'KLJ_VER_NO_PLUGIN'], $plugin_info['kleeja_version']['min'], $plugin_info['kleeja_version']['max']),
+ 'icon' => $plugin_info['icon'] ,
+ 'NotCompatible' => version_compare(strtolower($plugin_info['kleeja_version']['min']), KLEEJA_VERSION , '<=')
+ && version_compare(strtolower($plugin_info['kleeja_version']['max']), KLEEJA_VERSION , '>=')
+ ? false : true,
+ );
+ }
+
+ $no_store_plugins = sizeof($store_plugins) == 0;
break;
diff --git a/includes/style.php b/includes/style.php
index b315538..8b3fe93 100755
--- a/includes/style.php
+++ b/includes/style.php
@@ -174,38 +174,19 @@ class kleeja_style
*/
protected function _if_callback($matches)
{
- $char = array(' eq ', ' lt ', ' gt ', ' lte ', ' gte ', ' neq ', '==', '!=', '>=', '<=', '<', '>');
- $reps = array('==', '<', '>', '<=', '>=', '!=', '==', '!=', '>=', '<=', '<', '>');
$atts = call_user_func(array('kleeja_style', '_get_attributes'), $matches[0]);
- $con = trim(!empty($atts['NAME']) ? $atts['NAME'] : (empty($atts['LOOP']) ? '' : $atts['LOOP']));
-
- $con = str_replace('$this->vars', '[----this-vars----]', $con);
-
- if (preg_match('/(.*)(' . implode('|', $char) . ')(.*)/i', $con, $arr))
+ $condition = '';
+ foreach(['NAME' => '', 'LOOP' => '', 'AND' => ' && ', 'OR' => ' || '] as $attribute=>$separator)
{
- $arr[1] = trim($arr[1]);
- $var1 = $arr[1][0] != '$' ? call_user_func(array('kleeja_style', '_var_callback'), (!empty($atts['NAME']) ? '{' . $arr[1] . '}' : '{{' . $arr[1] . '}}')) : $arr[1];
- $opr = str_replace($char, $reps, $arr[2]);
- $var2 = trim($arr[3]);
-
- #check for type
- if ($var2[0] != '$' && !preg_match('/[0-9]/', $var2))
+ if(! empty($atts[$attribute]))
{
- $var2 = '"' . str_replace('"', '\"', $var2) . '"';
+ $condition .= $separator . $this->parse_condition($atts[$attribute]);
}
-
- $con = "$var1$opr$var2";
}
- elseif ($con[0] !== '$' && strpos($con, '(') === false)
- {
- $con = call_user_func(array('kleeja_style', '_var_callback'), (!empty($atts['NAME']) ? '{' . $con . '}' : '{{' . $con . '}}'));
- }
-
- $con = str_replace( '[----this-vars----]', '$this->vars', $con);
return strtoupper($matches[1]) == 'IF'
- ? ''
- : (strtoupper($matches[1]) == 'UNLESS' ? '' : '');
+ ? ''
+ : (strtoupper($matches[1]) == 'UNLESS' ? '' : '');
}
@@ -219,6 +200,32 @@ class kleeja_style
return '' . $matches[2] . '' . $matches[3] . '';
}
+ protected function parse_condition($condition)
+ {
+ $char = array(' eq ', ' lt ', ' gt ', ' lte ', ' gte ', ' neq ', '==', '!=', '>=', '<=', '<', '>');
+ $reps = array('==', '<', '>', '<=', '>=', '!=', '==', '!=', '>=', '<=', '<', '>');
+
+ $con = str_replace('$this->vars', '[----this-vars----]', $condition);
+
+ if (preg_match('/(.*)(' . implode('|', $char) . ')(.*)/i', $con, $arr)) {
+ $arr[1] = trim($arr[1]);
+ $var1 = $arr[1][0] != '$' ? call_user_func(array('kleeja_style', '_var_callback'), (!empty($condition) ? '{' . $arr[1] . '}' : '{{' . $arr[1] . '}}')) : $arr[1];
+ $opr = str_replace($char, $reps, $arr[2]);
+ $var2 = trim($arr[3]);
+
+ #check for type
+ if ($var2[0] != '$' && !preg_match('/[0-9]/', $var2)) {
+ $var2 = '"' . str_replace('"', '\"', $var2) . '"';
+ }
+
+ $con = "$var1 $opr $var2";
+ } elseif ($con[0] !== '$' && strpos($con, '(') === false) {
+ $con = call_user_func(array('kleeja_style', '_var_callback'), (!empty($condition) ? '{' . $con . '}' : '{{' . $con . '}}'));
+ }
+
+ return str_replace('[----this-vars----]', '$this->vars', $con);
+ }
+
/**
* make variable printable
diff --git a/lang/ar/acp.php b/lang/ar/acp.php
index 0e30ae2..47d81df 100755
--- a/lang/ar/acp.php
+++ b/lang/ar/acp.php
@@ -277,4 +277,5 @@ return array(
'KLJ_VER_NO_PLUGIN' => 'هذه الإضافة يمكنها العمل على إصدار كليجا %1$s حتى إصدار %2$s.',
'VERSION' => 'الإصدار',
'DEVELOPER' => 'المطور',
+ 'ALL_PLUGINS_UPDATED' => 'لا يوجد إضافات تحتاج تحديث حالياً ... ',
);
diff --git a/lang/en/acp.php b/lang/en/acp.php
index f33abe2..801a2ee 100755
--- a/lang/en/acp.php
+++ b/lang/en/acp.php
@@ -280,4 +280,5 @@ return array(
'KLJ_VER_NO_PLUGIN' => 'This plugin can works on Kleeja version %1$s up to version %2$s.',
'VERSION' => 'Version',
'DEVELOPER' => 'Developer',
+ 'ALL_PLUGINS_UPDATED' => 'There are no plugins that require an update currently...',
);
From 47a973e402cfcaa87370995d4e073ce5f6f6524f Mon Sep 17 00:00:00 2001
From: Abdulrahman
Date: Thu, 2 May 2019 20:02:11 +0300
Subject: [PATCH 09/15] fixes bugs
---
admin/Masmak/admin_calls.html | 2 +-
includes/style.php | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/admin/Masmak/admin_calls.html b/admin/Masmak/admin_calls.html
index 6918028..d3789e9 100755
--- a/admin/Masmak/admin_calls.html
+++ b/admin/Masmak/admin_calls.html
@@ -3,7 +3,7 @@
- {lang.R_CPINDEX}
- {lang.R_CALLS}
- - {lang.SHOW_FROM_24H}
+ - {lang.SHOW_FROM_24H}
diff --git a/includes/style.php b/includes/style.php
index 8b3fe93..398a9b4 100755
--- a/includes/style.php
+++ b/includes/style.php
@@ -180,7 +180,7 @@ class kleeja_style
{
if(! empty($atts[$attribute]))
{
- $condition .= $separator . $this->parse_condition($atts[$attribute]);
+ $condition .= $separator . $this->parse_condition($atts[$attribute], !empty($atts['LOOP']));
}
}
@@ -200,7 +200,7 @@ class kleeja_style
return '' . $matches[2] . '' . $matches[3] . '';
}
- protected function parse_condition($condition)
+ protected function parse_condition($condition, $is_loop)
{
$char = array(' eq ', ' lt ', ' gt ', ' lte ', ' gte ', ' neq ', '==', '!=', '>=', '<=', '<', '>');
$reps = array('==', '<', '>', '<=', '>=', '!=', '==', '!=', '>=', '<=', '<', '>');
@@ -209,7 +209,7 @@ class kleeja_style
if (preg_match('/(.*)(' . implode('|', $char) . ')(.*)/i', $con, $arr)) {
$arr[1] = trim($arr[1]);
- $var1 = $arr[1][0] != '$' ? call_user_func(array('kleeja_style', '_var_callback'), (!empty($condition) ? '{' . $arr[1] . '}' : '{{' . $arr[1] . '}}')) : $arr[1];
+ $var1 = $arr[1][0] != '$' ? call_user_func(array('kleeja_style', '_var_callback'), (! $is_loop ? '{' . $arr[1] . '}' : '{{' . $arr[1] . '}}')) : $arr[1];
$opr = str_replace($char, $reps, $arr[2]);
$var2 = trim($arr[3]);
@@ -220,7 +220,7 @@ class kleeja_style
$con = "$var1 $opr $var2";
} elseif ($con[0] !== '$' && strpos($con, '(') === false) {
- $con = call_user_func(array('kleeja_style', '_var_callback'), (!empty($condition) ? '{' . $con . '}' : '{{' . $con . '}}'));
+ $con = call_user_func(array('kleeja_style', '_var_callback'), (!$is_loop ? '{' . $con . '}' : '{{' . $con . '}}'));
}
return str_replace('[----this-vars----]', '$this->vars', $con);
From 0f179db4a31c94a31ed1541e604588c65aa931e7 Mon Sep 17 00:00:00 2001
From: Mitan Omar <22119228+MitanOmar@users.noreply.github.com>
Date: Thu, 2 May 2019 21:50:23 +0200
Subject: [PATCH 10/15] fixes
---
includes/adm/j_plugins.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/includes/adm/j_plugins.php b/includes/adm/j_plugins.php
index b4299b3..c58d23c 100755
--- a/includes/adm/j_plugins.php
+++ b/includes/adm/j_plugins.php
@@ -170,8 +170,8 @@ switch ($case):
$available_plugins_names = array_column($available_plugins, 'name');
foreach ($catalog_plugins as $plugin_info)
{
- if ($case == 'store' && in_array($plugin_info['name'] , $available_plugins_names) &&
- ! empty($installed_plugins[$plugin_info['name']])
+ if ($case == 'store' && (in_array($plugin_info['name'] , $available_plugins_names) ||
+ ! empty($installed_plugins[$plugin_info['name']]) )
)
{
continue;
From 675a6df464e3c3d77bdc8107b7c0b704c68b7eb2 Mon Sep 17 00:00:00 2001
From: Mitan Omar <22119228+MitanOmar@users.noreply.github.com>
Date: Thu, 2 May 2019 22:57:44 +0200
Subject: [PATCH 11/15] Update j_plugins.php
---
includes/adm/j_plugins.php | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/includes/adm/j_plugins.php b/includes/adm/j_plugins.php
index c58d23c..0847770 100755
--- a/includes/adm/j_plugins.php
+++ b/includes/adm/j_plugins.php
@@ -178,7 +178,7 @@ switch ($case):
}
// is there a new version of this in the store
- if ($case == 'check' && (! empty($installed_plugins[$plugin_info['name']]) &&
+ elseif ($case == 'check' && (! empty($installed_plugins[$plugin_info['name']]) &&
version_compare(
strtolower($installed_plugins[$row['plg_name']]['extra_info']['plugin_version']),
$plugin_info['file']['version'],
@@ -528,6 +528,15 @@ switch ($case):
exit;
}
+ $download_plugin = g('plg');
+
+ // update it , rename function doesn't move the folder , if the folder is exists on the new dir
+ if( file_exists( PATH . KLEEJA_PLUGINS_FOLDER. '/' . $download_plugin . '/init.php' ) )
+ {
+ redirect( $plugin_update_link . $download_plugin );
+ exit;
+ }
+
// plugins avilable in kleeja store
$store_link = 'https://raw.githubusercontent.com/kleeja-official/plugin-catalog/master/plugins.json';
@@ -551,8 +560,6 @@ switch ($case):
);
}
- $download_plugin = g('plg');
-
// // => this plugin is hosted in our store
if (isset($store_plugins[$download_plugin]))
{
From a824aea55493ef8ef49d585e59d65d713df6607c Mon Sep 17 00:00:00 2001
From: Abdulrahman
Date: Fri, 3 May 2019 00:07:56 +0300
Subject: [PATCH 12/15] fixes
---
admin/Masmak/admin_plugins.html | 15 +++++++++------
includes/adm/j_plugins.php | 5 +++--
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/admin/Masmak/admin_plugins.html b/admin/Masmak/admin_plugins.html
index 5f26158..4efdeaf 100755
--- a/admin/Masmak/admin_plugins.html
+++ b/admin/Masmak/admin_plugins.html
@@ -131,12 +131,12 @@
-
+
-
+
{lang.ALL_PLUGINS_UPDATED}{lang.NO_PLUGINS}
@@ -146,11 +146,14 @@
-
-
{{title}}
+
{{title}}
-
+
+ {{version}} → {{current_version}}
+
+
diff --git a/includes/adm/j_plugins.php b/includes/adm/j_plugins.php
index 0847770..f77c991 100755
--- a/includes/adm/j_plugins.php
+++ b/includes/adm/j_plugins.php
@@ -180,8 +180,8 @@ switch ($case):
// is there a new version of this in the store
elseif ($case == 'check' && (! empty($installed_plugins[$plugin_info['name']]) &&
version_compare(
- strtolower($installed_plugins[$row['plg_name']]['extra_info']['plugin_version']),
- $plugin_info['file']['version'],
+ strtolower($installed_plugins[$plugin_info['name']]['extra_info']['plugin_version']),
+ strtolower($plugin_info['file']['version']),
'>=') || empty($installed_plugins[$plugin_info['name']]))
) {
continue;
@@ -193,6 +193,7 @@ switch ($case):
'version' => $plugin_info['file']['version'],
'title' => ! empty($plugin_info['title'][$config['language']]) ? $plugin_info['title'][$config['language']] : $plugin_info['title']['en'],
'website' => $plugin_info['website'],
+ 'current_version' => ! empty($installed_plugins[$plugin_info['name']]) ? strtolower($installed_plugins[$plugin_info['name']]['extra_info']['plugin_version']) : '',
'kj_min_version' => $plugin_info['kleeja_version']['min'],
'kj_max_version' => $plugin_info['kleeja_version']['max'],
'kj_version_cmtp' => sprintf($lang[ 'KLJ_VER_NO_PLUGIN'], $plugin_info['kleeja_version']['min'], $plugin_info['kleeja_version']['max']),
From 4723c7a06379ae2ebdbe2e3308adc85bfed7e6be Mon Sep 17 00:00:00 2001
From: Abdulrahman
Date: Fri, 3 May 2019 00:09:21 +0300
Subject: [PATCH 13/15] fix
---
admin/Masmak/admin_plugins.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/admin/Masmak/admin_plugins.html b/admin/Masmak/admin_plugins.html
index 4efdeaf..d4ae9fc 100755
--- a/admin/Masmak/admin_plugins.html
+++ b/admin/Masmak/admin_plugins.html
@@ -149,7 +149,7 @@
{{title}}
-
{{version}} → {{current_version}}
+
{{current_version}} → {{version}}
From edba79731fcaa8715c6dcad9af8595160181d557 Mon Sep 17 00:00:00 2001
From: Abdulrahman
Date: Fri, 3 May 2019 00:23:04 +0300
Subject: [PATCH 14/15] fixes
---
admin/Masmak/admin_plugins.html | 4 ++--
lang/ar/acp.php | 5 +++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/admin/Masmak/admin_plugins.html b/admin/Masmak/admin_plugins.html
index d4ae9fc..9d3f26f 100755
--- a/admin/Masmak/admin_plugins.html
+++ b/admin/Masmak/admin_plugins.html
@@ -148,8 +148,8 @@
{{title}}
-
-
{{current_version}} → {{version}}
+
+
{{current_version}} → {{version}}
diff --git a/lang/ar/acp.php b/lang/ar/acp.php
index 47d81df..3c01a02 100755
--- a/lang/ar/acp.php
+++ b/lang/ar/acp.php
@@ -271,6 +271,11 @@ return array(
'INSTALL' => 'تثبيت',
'CLOSE' => 'إغلاق',
'STATS_BOXES' => 'صناديق الإحصائيات',
+ 'PLUGIN_UPDATED' => 'الإضافة "%s" تم تحديثها بنجاح ..',
+ 'PLUGIN_DOWNLOADED' => 'الإضافة "%s" تم تحميلها بنجاح ..',
+ 'PLUGIN_FILE_NOT_FOUND' => 'ملف الإضافة مفقود لايمكن إيجاده!',
+ 'PLUGIN_REMOTE_FILE_MISSING' => 'الإضافة "%s" ليست على موجوة على متجر كليجا الخارجي!',
+ 'PLUGINS_SERVER_ERROR' => 'واجهنا خطأ أثناء الإتصال بخادم متجر كليجا الخارجي...',
'INSTALLED_PLUGINS' => 'الإضافات المثبتة',
'LOCAL_PLUGINS' => 'الإضافات المحلية',
'KLEEJA_STORE' => 'متجر كليجا',
From b0fce58aeef5c9e80f374c1a58dd2ed9336c5d22 Mon Sep 17 00:00:00 2001
From: Abdulrahman
Date: Fri, 3 May 2019 00:27:34 +0300
Subject: [PATCH 15/15] store button
---
admin/Masmak/admin_plugins.html | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/admin/Masmak/admin_plugins.html b/admin/Masmak/admin_plugins.html
index 9d3f26f..bfcf248 100755
--- a/admin/Masmak/admin_plugins.html
+++ b/admin/Masmak/admin_plugins.html
@@ -79,11 +79,14 @@
-
+
{lang.ADD_NEW_PLUGIN}
-
+
{lang.UPLOAD_LOCAL_PC}
+
+ {lang.KLEEJA_STORE}
+