Viewing File: /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/conf/mods/wp/mods.php

<?php

//////////////////////////////////////////////////////////////
//===========================================================
// mods.php(For individual softwares)
//===========================================================
// SOFTACULOUS
// Version : 1.0
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Alons
// Date:       10th Jan 2009
// Time:       21:00 hrs
// Site:       http://www.softaculous.com/ (SOFTACULOUS)
// ----------------------------------------------------------
// Please Read the Terms of use at http://www.softaculous.com
// ----------------------------------------------------------
//===========================================================
// (c)Softaculous Inc.
//
// Modified by max.nikitenko@namecheap.net
//  - Added support mange adding plugins from list
//  - Added support per directory plugin location
//===========================================================
//////////////////////////////////////////////////////////////

if(!defined('SOFTACULOUS')){

	die('Hacking Attempt');

}

/**
 * This function will allow you to modify the XML that is being passed.
 * You can modify it here and Softaculous will parse it as it parses the XML of install.xml of packages.
 *
 * @package      softaculous
 * @subpackage   scripts
 * @author       Pulkit Gupta
 * @param        string $str The key of the Language string array.
 * @return       string The parsed string if there was a equivalent language key otherwise the key itself if no key was defined.
 * @since     	 1.0
 */
/*function __wp_mod_install_xml($xml){
	
	global $__settings, $settings, $error, $software, $globals, $softpanel, $notes, $adv_software;
	
}*/

function __wp_load_mod_settings($mod) {

    global $__settings, $settings, $error, $software, $globals, $softpanel, $notes, $adv_software;

    $install = @implode(file($globals['path'].'/conf/mods/'.$software['softname'].'/'.$mod.'/mod_install.xml'));
    $install = parselanguages($install);
    $tmp_settings = array();

    if(preg_match('/<softinstall (.*?)>(.*?)<\/softinstall>/is', $install)){

        $tmp_settings = load_settings($install, $adv_software, 1);
    }

    $key = parselanguages('{{select_plugins}}');

    if (!$tmp_settings)
    {
        $error[] = "troubles while parse configuration file of ".$mod." plugin";
    }
    else {
        return $tmp_settings[$key];
    }
}

function __load_nc_custom_plugins(){
    global $__settings, $settings, $error, $software, $globals, $softpanel, $notes, $adv_software;
    $nc_custom_plugins = file(
        $globals['path'].'/conf/mods/'.$software['softname']."/nc-custom-plugins.list",
        FILE_SKIP_EMPTY_LINES|FILE_IGNORE_NEW_LINES
    );
    return $nc_custom_plugins;
}

/**
 * This function will parse your mod_install.xml and shows an option of choose plugin to users
 *
 * @package      softaculous
 * @subpackage   scripts
 * @author       Pulkit Gupta
 * @param        string $str The key of the Language string array.
 * @return       string The parsed string if there was a equivalent language key otherwise the key itself if no key was defined.
 * @since     	 1.0
 */
function __wp_mod_settings(){
	
	global $__settings, $settings, $error, $software, $globals, $softpanel, $notes, $adv_software, $nc_custom_plugins;
	
	$install = @implode(file($globals['path'].'/conf/mods/'.$software['softname'].'/mod_install.xml'));
	$install = parselanguages($install);
	
	$tmp_settings = array();
	
	if(preg_match('/<softinstall (.*?)>(.*?)<\/softinstall>/is', $install)){
		
		$tmp_settings = load_settings($install, $adv_software, 1);
	}
	
	$key = parselanguages('{{select_plugins}}');


    $nc_custom_plugins = __load_nc_custom_plugins();

    foreach ($nc_custom_plugins as $plugin) {
        $nc_tmp_settings = __wp_load_mod_settings($plugin);
        if ($nc_tmp_settings) {
            $tmp_settings[$key] = array_merge($tmp_settings[$key], $nc_tmp_settings);
        }
    }
    $settings[$key] = array_merge($tmp_settings[$key], $settings[$key]);
}

/**
 * If anything is needed to be execute before the installation procedure starts than it should be done here.
 *
 * @package      softaculous
 * @subpackage   scripts
 * @author       Pulkit Gupta
 * @param        string $str The key of the Language string array.
 * @return       string The parsed string if there was a equivalent language key otherwise the key itself if no key was defined.
 * @since     	 1.0
 */
function __pre_mod_install(){
	
	global $__settings, $settings, $error, $software, $globals, $softpanel, $notes, $adv_software, $nc_custom_plugins;

	foreach ($nc_custom_plugins as $plugin) {
        if(!empty($__settings[$plugin])) {
            $pre_install_script = $globals['path'].'/conf/mods/'.$software['softname'].'/'.$plugin.'/pre_install.php';
            if (file_exists($pre_install_script)) { include ($pre_install_script); }
        }
    }
}

/**
 * If anything is needed to be execute after the installation procedure starts than it should be done here.
 *
 * @package      softaculous
 * @subpackage   scripts
 * @author       Pulkit Gupta
 * @param        string $str The key of the Language string array.
 * @return       string The parsed string if there was a equivalent language key otherwise the key itself if no key was defined.
 * @since     	 1.0
 */
function __post_mod_install(){
	
	global $__settings, $settings, $error, $software, $globals, $softpanel, $notes, $adv_software, $nc_custom_plugins ;
	
	$__settings['active_plugins'] = array();
	
	// First get the active plugin list 
	$query = "SELECT option_value FROM ".$__settings['dbprefix']."options WHERE option_name = 'active_plugins';";
	$result = sdb_query($query, $__settings['softdbhost'], $__settings['softdbuser'], $__settings['softdbpass'], $__settings['softdb']);
	
	$__settings['active_plugins'] = _unserialize($result[0]['option_value']);
	
	// Check which plugin is checked for instllation

    //    installation custom nc plugins
    foreach ($nc_custom_plugins as $plugin) {
        if(!empty($__settings[$plugin])) {
            $post_install_script = $globals['path'].'/conf/mods/'.$software['softname'].'/'.$plugin.'/post_install.php';
            if (file_exists($post_install_script)) { include ($post_install_script); }
        }
    }


	// This should be at the end (As there may be many plugins)
	$__settings['active_plugins'] = serialize($__settings['active_plugins']);
	
	$query = "UPDATE ".$__settings['dbprefix']."options
			SET option_value = '".$__settings['active_plugins']."' 
			WHERE option_name = 'active_plugins';";
	$result = sdb_query($query, $__settings['softdbhost'], $__settings['softdbuser'], $__settings['softdbpass'], $__settings['softdb']);
	
}

?>
Back to Directory File Manager