Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * This is a HOOK POINT in the Softaculous Installation process.
- * NOTE : You must rename this file to pre_install_cagefs.php
- */
- //////////////////////////////////////////////////////////////
- //===========================================================
- // pre_install_cagefs.php
- //===========================================================
- // SOFTACULOUS
- // Version : 1.1
- // 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.
- //===========================================================
- //////////////////////////////////////////////////////////////
- if(!defined('SOFTACULOUS')){
- die('Hacking Attempt');
- }
- /**
- * This function will be called whenever a script is installed.
- * $software will have details of the script being installed.
- *
- * @package CageFS hooks
- * @author Pulkit Gupta
- * @return bool
- * @since 4.3.0
- */
- function __pre_install_cagefs(){
- global $soft, $software, $globals, $scripts, $softpanel, $error, $__hooks;
- // Is CageFS enabled ?
- if(file_exists('/usr/bin/selectorctl') && !defined('php_version')){
- /*// Lets check if the user is in the disabled list of CageFS
- // This is allowed only for root
- @exec("/usr/sbin/cagefsctl --list-disabled | grep ".$softpanel->user['name'], $dout, $dret);
- if(preg_match('/'.$softpanel->user['name'].'/is', implode('', $dout))){
- return true;
- }*/
- // Lets check if CageFS is enabled for this user
- @exec("/usr/bin/selectorctl --user-current --user=".$softpanel->user['name'].' 2>&1', $cout, $cret);
- if(preg_match('/ERROR/is', implode('', $cout))){
- return true;
- }
- // If it is native than we will find the verison using sphpversion()
- if(preg_match('/native/is', implode('', $cout))){
- $native = sphpversion();
- }
- // Get the list of enabled extensions for this user
- $command = '/usr/bin/selectorctl --list-user-extensions --user='.$softpanel->user['name'];
- @exec($command, $extout, $extret);
- if(!empty($extout) && is_array($extout)){
- if(in_array('nd_mysqli', $extout)){
- $__hooks['loaded_extension'][] = 'mysqli';
- }
- if(in_array('nd_mysql', $extout)){
- $__hooks['loaded_extension'][] = 'mysql';
- }
- //added check for nd_pdo_mysql extension so that script that requires pdo_mysql extension enabled will find it as enabled
- if(in_array('nd_pdo_mysql', $extout)){
- $__hooks['loaded_extension'][] = 'pdo_mysql';
- }
- if(!empty($__hooks['loaded_extension']) && is_array($__hooks['loaded_extension'])){
- $__hooks['loaded_extension'] = array_merge($__hooks['loaded_extension'], $extout);
- }else{
- $__hooks['loaded_extension'] = $extout;
- }
- }
- // Get the list of Default enabled extensions
- $curr_version = str_replace('.', '', substr($cout[0],0,3)); //current php version
- $cagefs_phpbin = '/opt/alt/php'.$curr_version.'/usr/bin/php';
- if(!empty($native)){
- define(eu_php_bin, 'php');
- $cagefs_phpbin = '/usr/bin/php';
- }
- @exec($cagefs_phpbin.' -n -m', $extout1, $extret1);
- if(!empty($extout1) && is_array($extout1)){
- if(!empty($__hooks['loaded_extension']) && is_array($__hooks['loaded_extension'])){
- $__hooks['loaded_extension'] = array_merge($__hooks['loaded_extension'], $extout1);
- }else{
- $__hooks['loaded_extension'] = $extout1;
- }
- }
- // these extensions are returned by php and we need to convert it to CageFS format
- foreach($__hooks['loaded_extension'] as $ke => $ve){
- $__hooks['loaded_extension'][$ke] = strtolower(str_replace(' ', '_', $ve));
- }
- // This indicates that the PHP extensions list loaded in $__hooks is exhaustive list
- //If cageFS has native php installed, the loaded extensions return empty value
- if(!empty($__hooks['loaded_extension']) && empty($native)){
- define('PHP_EXT_EXHAUSTIVE', 1);
- }
- // What is the user's PHP version ?
- @exec("/usr/bin/selectorctl --user-current --user=".$softpanel->user['name']." | awk '{print $2}'", $out, $ret);
- if(!empty($native)){
- $tmp_out = $native;
- }else{
- $tmp_out = current($out);
- }
- (!empty($tmp_out) ? $php_version = $tmp_out : '');
- if(!empty($scripts[$soft]['php_min'])){
- $short_ver = substr($scripts[$soft]['php_min'], 0, 3);
- // Is it lower than the required version ?
- if(sversion_compare($tmp_out, $scripts[$soft]['php_min'], '<')){
- // Can the required version be enabled ?
- @exec("/usr/bin/selectorctl --list | grep ".$short_ver." | awk '{print $2}'", $eout, $eret);
- if(!empty($eout) && sversion_compare(current($eout), $scripts[$soft]['php_min'], '>=')){
- // Ask for a confirmation
- if(!checkbox('php_version_select')){
- $error[] = 'PHP version is less than the required '.$scripts[$soft]['php_min'].'<br />
- <input type="checkbox" name="php_version_select" '.POSTChecked('php_version_select').' />
- Do you wish to enable PHP '.current($eout).' ? (Might cause issues with your existing installations).';
- // Lets enable the version for the user
- }else{
- @exec("/usr/bin/selectorctl --set-user-current=".$short_ver." --user=".$softpanel->user['name'], $sout, $sret);
- @exec("/usr/bin/selectorctl --user-current --user=".$softpanel->user['name']." | awk '{print $2}'", $nout, $nret);
- $php_version = current($nout);
- }
- }
- }
- }
- if(!empty($scripts[$soft]['php_max'])){
- $short_ver = substr($scripts[$soft]['php_max'], 0, 3) - (0.1);
- // Is it lower than the required version ?
- if(sversion_compare($tmp_out, $scripts[$soft]['php_max'], '>')){
- // Can the required version be enabled ?
- @exec("/usr/bin/selectorctl --list | grep ".$short_ver." | awk '{print $2}'", $eout, $eret);
- if(!empty($eout) && sversion_compare(current($eout), $scripts[$soft]['php_max'], '<')){
- // Ask for a confirmation
- if(!checkbox('php_max_version_select')){
- $error[] = 'This script is not compatible with PHP version : '.$scripts[$soft]['php_max'].'+<br />
- <input type="checkbox" name="php_max_version_select" '.POSTChecked('php_max_version_select').' />
- Do you wish to enable PHP '.current($eout).' ? (Might cause issues with your existing installations).';
- // Lets enable the version for the user
- }else{
- @exec("/usr/bin/selectorctl --set-user-current=".$short_ver." --user=".$softpanel->user['name'], $sout, $sret);
- @exec("/usr/bin/selectorctl --user-current --user=".$softpanel->user['name']." | awk '{print $2}'", $nout, $nret);
- $php_version = current($nout);
- }
- }
- }
- }
- }
- if(!empty($php_version)) define('php_version', $php_version);
- if(!empty($cagefs_phpbin)) define('eu_php_bin', $cagefs_phpbin);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement