Ordermain/user_restrictions.php 0000644 00000046312 14760040537 0012003 0 ustar 00 fileorganizer_optpost($restr_key),
'restrict_operations' => fileorganizer_optpost('restrict_operations'),
'private_dir' => fileorganizer_cleanpath($path),
'restrict_dirs' => fileorganizer_cleanpath(fileorganizer_optpost('restrict_dirs')),
'restrict_files' => fileorganizer_cleanpath(fileorganizer_optpost('restrict_files')),
'disable_toolbar' => fileorganizer_optpost('disable_toolbar'),
'disable_context_menu' => fileorganizer_optpost('disable_context_menu'),
);
$roles = !empty($options[$restr_option]) && is_array($options[$restr_option]) ? $options[$restr_option] : '';
// Array already exists?
if(!empty($roles) ){
$options[$restr_option] = $roles;
}
// Update or add user role.
if(!empty($_POST['rule_id']) && isset($options[$restr_option][ (int)$_POST['rule_id'] - 1])){
$options[$restr_option][(int)fileorganizer_optpost('rule_id') - 1] = $roles_;
}else{
$options[$restr_option][] = $roles_;
}
if(update_option( 'fileorganizer_options', $options )){
fileorganizer_notify(__('Settings saved successfully.'));
}
}
}
function fileorganizer_user_restriction_render(){
// Load header
fileorganizer_pro_user_restriction_header();
$settings = get_option('fileorganizer_options', array());
if(empty($settings) || !is_array($settings)){
$settings = array();
}
$file_operations = ['mkdir', 'mkfile', 'rename', 'duplicate', 'paste', 'archive', 'extract', 'copy', 'cut', 'edit', 'rm', 'download', 'upload', 'search', 'empty'];
?>
options = empty($options) ? array() : $options;
}
fileorganizer_pro_update_checker();
// Load license
fileorganizer_pro_load_license();
// Check for updates
include_once(FILEORGANIZER_PRO_DIR.'/main/plugin-update-checker.php');
$fileorganizer_updater = Fileorganizer_PucFactory::buildUpdateChecker(fileorganizer_pro_api_url().'/updates.php?version='.FILEORGANIZER_PRO_VERSION, FILEORGANIZER_PRO_FILE);
// Add the license key to query arguments
$fileorganizer_updater->addQueryArgFilter('fileorganizer_pro_updater_filter_args');
// Show the text to install the license key
add_filter('puc_manual_final_check_link-fileorganizer-pro', 'fileorganizer_pro_updater_check_link', 10, 1);
// Nag informing the user to install the free version.
if(current_user_can('activate_plugins')){
add_action('admin_notices', 'fileorganizer_pro_free_version_nag', 9);
add_action('admin_menu', 'fileorganizer_pro_add_menu', 9);
}
$is_network_wide = fileorganizer_pro_is_network_active('fileorganizer-pro');
$_fo_version = get_option('fileorganizer_version');
$req_free_update = !empty($_fo_version) && version_compare($_fo_version, '1.0.9', '<');
if($is_network_wide){
$free_installed = get_site_option('fileorganizer_free_installed');
}else{
$free_installed = get_option('fileorganizer_free_installed');
}
if(!empty($free_installed)){
return;
}
// Include the necessary stuff
include_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
include_once(ABSPATH . 'wp-admin/includes/file.php');
if(file_exists(WP_PLUGIN_DIR . '/fileorganizer/fileorganizer.php') && is_plugin_inactive('/fileorganizer/fileorganizer.php') && empty($req_free_update)) {
if($is_network_wide){
update_site_option('fileorganizer_free_installed', time());
}else{
update_option('fileorganizer_free_installed', time());
}
activate_plugin('/fileorganizer/fileorganizer.php', '', $is_network_wide);
remove_action('admin_notices', 'fileorganizer_pro_free_version_nag', 9);
remove_action('admin_menu', 'fileorganizer_pro_add_menu', 9);
return;
}
// Includes necessary for Plugin_Upgrader and Plugin_Installer_Skin
include_once(ABSPATH . 'wp-admin/includes/misc.php');
include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
// Filter to prevent the activate text
add_filter('install_plugin_complete_actions', 'fileorganizer_pro_prevent_activation_text', 10, 3);
$upgrader = new Plugin_Upgrader(new WP_Ajax_Upgrader_Skin());
// Upgrade the plugin to the latest version of free already installed.
if(!empty($req_free_update)){
$installed = $upgrader->upgrade('fileorganizer/fileorganizer.php');
}else{
$installed = $upgrader->install('https://downloads.wordpress.org/plugin/fileorganizer.zip');
}
if(!is_wp_error($installed) && $installed){
if($is_network_wide){
update_site_option('fileorganizer_free_installed', time());
}else{
update_option('fileorganizer_free_installed', time());
}
activate_plugin('fileorganizer/fileorganizer.php', '', $is_network_wide);
remove_action('admin_notices', 'fileorganizer_pro_free_version_nag', 9);
remove_action('admin_menu', 'fileorganizer_pro_add_menu', 9);
}
}
// Do not shows the activation text if
function fileorganizer_pro_prevent_activation_text($install_actions, $api, $plugin_file){
if($plugin_file == 'fileorganizer/fileorganizer.php'){
return array();
}
return $install_actions;
}
function fileorganizer_pro_free_version_nag(){
$fo_version = get_option('fileorganizer_version');
$lower_version = __('You have not installed the free version of FileOrganizer. FileOrganizer Pro depends on the free version, so you must install it first in order to use FileOrganizer Pro.');
if(!empty($fo_version) && version_compare($fo_version, '1.0.9', '<')){
$lower_version = __('You are using an older version of the free version of FileOrganizer, please update FileOrganizer to work without any issues');
}
echo '';
}
function fileorganizer_pro_add_menu(){
add_menu_page('FileOrganizer Settings', 'FileOrganizer', 'activate_plugins', 'fileorganizer', 'fileorganizer_pro_menu_page');
}
function fileorganizer_pro_menu_page(){
echo '
FileOrganizer Free version is not installed / outdated!
FileOrganizer Pro depends on the free version of FileOrganizer, so you need to install / update the free version first.
Install/Update Now
';
} main/functions.php 0000644 00000021565 14760040537 0010230 0 ustar 00 5){
$lic['license'] = $parent;
// Load license of Soft Pro
}elseif(!empty($parent)){
$license_field = 'softaculous_pro_license';
$lic = get_option('softaculous_pro_license', []);
// My license
}else{
$lic = get_option($license_field, []);
}
// Loaded license is a Soft Pro
if(!empty($lic['license']) && preg_match('/^softwp/is', $lic['license'])){
$license_field = 'softaculous_pro_license';
$license_api_url = 'https://a.softaculous.com/softwp/';
$prods = apply_filters('softaculous_pro_products', []);
}else{
$prods = [];
}
if(empty($lic['last_update'])){
$lic['last_update'] = time() - 86600;
}
// Update license details as well
if(!empty($lic) && !empty($lic['license']) && (time() - @$lic['last_update']) >= 86400){
$url = $license_api_url.'/license.php?license='.$lic['license'].'&prods='.implode(',', $prods).'&url='.rawurlencode(site_url());
$resp = wp_remote_get($url);
$lic_resp = $resp;
//Did we get a response ?
if(is_array($resp)){
$tosave = json_decode($resp['body'], true);
//Is it the license ?
if(!empty($tosave['license'])){
$tosave['last_update'] = time();
update_option($license_field, $tosave);
$lic = $tosave;
}
}
}
// If the license is Free or Expired check for Softaculous Pro license
if(empty($lic) || empty($lic['active'])){
if(function_exists('softaculous_pro_load_license')){
$softaculous_license = softaculous_pro_load_license();
if(!empty($softaculous_license['license']) &&
(!empty($softaculous_license['active']) || empty($lic['license']))
){
$lic = $softaculous_license;
}
}elseif(empty($parent)){
$lic = get_option('softaculous_pro_license', []);
if(!empty($lic)){
fileorganizer_pro_load_license(1);
}
}
}
$fileorganizer->license = $lic;
}
add_filter('softaculous_pro_products', 'fileorganizer_softaculous_pro_products', 10, 1);
function fileorganizer_softaculous_pro_products($r = []){
$r['fileorganizer'] = 'fileorganizer';
return $r;
}
// Add our license key if ANY
function fileorganizer_pro_updater_filter_args($queryArgs){
global $fileorganizer;
if (!empty($fileorganizer->license['license'])){
$queryArgs['license'] = $fileorganizer->license['license'];
}
$queryArgs['url'] = rawurlencode(site_url());
return $queryArgs;
}
// Handle the Check for update link and ask to install license key
function fileorganizer_pro_updater_check_link($final_link){
global $fileorganizer;
if(empty($fileorganizer->license['license'])){
return 'Install FileOrganizer Pro License Key';
}
return $final_link;
}
// Prevent update of fileorganizer free
function fileorganizer_pro_get_free_version_num(){
if(defined('FILEORGANIZER_VERSION')){
return FILEORGANIZER_VERSION;
}
// In case of fileorganizer deactive
return fileorganizer_pro_file_get_version_num('fileorganizer/fileorganizer.php');
}
// Prevent update of fileorganizer free
function fileorganizer_pro_file_get_version_num($plugin){
// In case of fileorganizer deactive
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
$plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/'.$plugin);
if(empty($plugin_data)){
return false;
}
return $plugin_data['Version'];
}
// Prevent update of fileorganizer free
function fileorganizer_pro_disable_manual_update_for_plugin($transient){
$plugin = 'fileorganizer/fileorganizer.php';
// Is update available?
if(!isset($transient->response) || !isset($transient->response[$plugin])){
return $transient;
}
$free_version = fileorganizer_pro_get_free_version_num();
$pro_version = FILEORGANIZER_PRO_VERSION;
if(!empty($GLOBALS['fileorganizer_pro_is_upgraded'])){
$pro_version = fileorganizer_pro_file_get_version_num('fileorganizer-pro/fileorganizer-pro.php');
}
// Update the fileorganizer version to the equivalent of Pro version
if(!empty($pro_version) && version_compare($free_version, $pro_version, '<')){
$transient->response[$plugin]->new_version = $pro_version;
$transient->response[$plugin]->package = 'https://downloads.wordpress.org/plugin/fileorganizer.'.$pro_version.'.zip';
}else{
unset($transient->response[$plugin]);
}
return $transient;
}
// Auto update free version after update pro version
function fileorganizer_pro_update_free_after_pro($upgrader_object, $options){
// Check if the action is an update for the plugins
if($options['action'] != 'update' || $options['type'] != 'plugin'){
return;
}
// Define the slugs for the free and pro plugins
$free_slug = 'fileorganizer/fileorganizer.php';
$pro_slug = 'fileorganizer-pro/fileorganizer-pro.php';
// Check if the pro plugin is in the list of updated plugins
if(
(isset($options['plugins']) && in_array($pro_slug, $options['plugins']) && !in_array($free_slug, $options['plugins'])) ||
(isset($options['plugin']) && $pro_slug == $options['plugin'])
){
// Trigger the update for the free plugin
$current_version = fileorganizer_pro_get_free_version_num();
if(empty($current_version)){
return;
}
$GLOBALS['fileorganizer_pro_is_upgraded'] = true;
// This will set the 'update_plugins' transient again
wp_update_plugins();
// Check for updates for the free plugin
$update_plugins = get_site_transient('update_plugins');
if(empty($update_plugins) || !isset($update_plugins->response[$free_slug]) || version_compare($update_plugins->response[$free_slug]->new_version, $current_version, '<=')){
return;
}
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
$skin = wp_doing_ajax()? new WP_Ajax_Upgrader_Skin() : null;
$upgrader = new Plugin_Upgrader($skin);
$upgraded = $upgrader->upgrade($free_slug);
if(!is_wp_error($upgraded) && $upgraded){
// Re-active free plugins
if( file_exists( WP_PLUGIN_DIR . '/'. $free_slug ) && is_plugin_inactive($free_slug) ){
activate_plugin($free_slug); // TODO for network
}
// Re-active pro plugins
if( file_exists( WP_PLUGIN_DIR . '/'. $pro_slug ) && is_plugin_inactive($pro_slug) ){
activate_plugin($pro_slug); // TODO for network
}
}
}
}
function fileorganizer_pro_api_url($main_server = 0, $suffix = 'fileorganizer'){
global $fileorganizer;
$r = array(
'https://s0.softaculous.com/a/softwp/',
'https://s1.softaculous.com/a/softwp/',
'https://s2.softaculous.com/a/softwp/',
'https://s3.softaculous.com/a/softwp/',
'https://s4.softaculous.com/a/softwp/',
'https://s5.softaculous.com/a/softwp/',
'https://s7.softaculous.com/a/softwp/',
'https://s8.softaculous.com/a/softwp/'
);
$mirror = $r[array_rand($r)];
// If the license is newly issued, we need to fetch from API only
if(!empty($main_server) || empty($fileorganizer->license['last_edit']) ||
(!empty($fileorganizer->license['last_edit']) && (time() - 3600) < $fileorganizer->license['last_edit'])
){
$mirror = FILEORGANIZER_API;
}
if(!empty($suffix)){
$mirror = str_replace('/softwp', '/'.$suffix, $mirror);
}
return $mirror;
} main/license.php 0000644 00000010011 14760040537 0007622 0 ustar 00 '.var_export($lic_resp, true)), 'error');
return;
}
$json = json_decode($lic_resp['body'], true);
if(empty($json['license'])){
fileorganizer_notify(__('The license key is invalid'), 'error');
return;
}
fileorganizer_notify(__('Successfully updated the license key'));
}
if(isset($_REQUEST['save_fileorganizer_license'])){
fileorganizer_pro_license();
}
?>