Server IP : 173.249.157.85 / Your IP : 216.73.216.96 Web Server : Apache System : Linux server.frogzhost.com 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64 User : econtech ( 1005) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/tmp/ |
Upload File : |
<?php $this_os = strtoupper(substr(PHP_OS, 0, 3)); // Set the environment variables for the binaries if($this_os != 'WIN'){ putenv('PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/emps/bin:/usr/local/emps/sbin'); } unset($argv[0]); if(!empty($argv)){ // Get the parameters for ins_params foreach($argv as $k => $v){ $v = ltrim($v, '--'); $temp = explode('=', $v); $ins_params[$temp[0]] = @$temp[1]; } } error_reporting(E_PARSE); if(in_array('--nohttps', $argv)){ $globals['webserver'] = 'http://files.softaculous.com/'; }else{ $globals['webserver'] = 'https://files.softaculous.com/'; } $globals['softscripts'] = '/var/softaculous'; $globals['softvarbackups'] = '/var/softaculous_backups'; $globals['sn'] = 'Softaculous'; $globals['cookie_name'] = 'SOFTCookies'.rand(1, 9999); $globals['gzip'] = 1; $globals['language'] = 'english'; $globals['soft_email'] = 'admin@'.@$_SERVER['SERVER_NAME']; $globals['theme_folder'] = 'default'; $globals['timezone'] = 0; $globals['mail'] = 1; $globals['mail_server'] = ''; $globals['mail_port'] = ''; $globals['mail_user'] = ''; $globals['mail_pass'] = ''; $globals['off'] = 0; $globals['off_subject'] = ''; $globals['off_message'] = ''; $globals['update'] = 1; $globals['update_softs'] = 1; $globals['add_softs'] = 1; $globals['email_update'] = 1; $globals['email_update_softs'] = 1; $globals['cron_time'] = rand(1, 59).' '.rand(1, 23).' * * *'; $globals['chmod_files'] = ''; $globals['chmod_dir'] = ''; $globals['is_vps'] = 0; $globals['eu_news_off'] = 0; $globals['logo_url'] = ''; $globals['chmod_conf_file'] = ''; $globals['off_sync_link'] = ''; $globals['off_panel_link'] = ''; $globals['eu_enable_themes'] = 1; define('SOFTACULOUS', 1); define('SOFTADMIN', 1);//We are serving the ADMIN $user = array(); $theme = array(); //This causes some probems @ini_set('magic_quotes_runtime', 0); @ini_set('magic_quotes_sybase', 0); @set_time_limit(10000); function check_environment() { if( !is_file( '/home/interworx/plugins/softaculous/lib/softpanel.php' ) ) { die( 'interworx version 4.0 or higher is required.' . "\n" ); } } // Is there any proxy setting that user wants ?? if(in_array('proxy', $argv)){ // Get the parameters for data foreach($argv as $k => $v){ $str = substr($v, 0, 2); $temp = explode('=', $v); $data[$temp[0]] = $temp[1]; } if(array_key_exists('proxy_ip', $data)){ $tmp_data = explode(':', $data['proxy_ip']); $globals['proxy_check'] = 1; $globals['proxy_ip'] = $tmp_data[0]; $globals['proxy_port'] = (!empty($tmp_data[1]) ? $tmp_data[1] : 80); } if(array_key_exists('proxy_auth', $data)){ $tmp_data = explode(':', $data['proxy_auth']); $globals['proxy_check'] = 1; $globals['proxy_user'] = $tmp_data[0]; $globals['proxy_pass'] = $tmp_data[1]; } } // Are we to DEBUG if(in_array('debug', $argv)){ function died(){ print_r(error_get_last()); } register_shutdown_function('died'); }elseif($this_os != 'WIN'){ //File should not be deleted at the beginning on Windows server unlink(__FILE__); } ////////////////////////////////////// // Writes a file to the filename given ////////////////////////////////////// function ins_writefile($file, $data, $overwrite){ $pathinfo = pathinfo($file); $folderpath = ''; $folders = explode('/', $pathinfo['dirname']); $prefix = (substr($pathinfo['dirname'], 0, 1) == '/' ? '/' : ''); //Create folders if they are not there foreach ($folders as $folder){ if(empty($folder)) continue; $folderpath = (!empty($folderpath)) ? $folderpath.'/'.$folder : $prefix.$folder; if(!is_dir($folderpath)){ if (!@mkdir($folderpath, 0755)){ return false; } //Try to give access @chmod($folderpath, 0755); } } //Does the file exist if(file_exists($file) && empty($overwrite)){ return false; } //Create and Open the file for writing if(!$fp = @fopen($file, "wb")){ return false; } //Write the contents if (@fwrite($fp, $data) === FALSE) { return false; } //Close the handle fclose($fp); @chmod($file, 0755); return true; } function _curl_proxy($ch){ global $globals; // Setup proxy settings for cURL curl_setopt($ch, CURLOPT_PROXY, $globals['proxy_ip'].':'.$globals['proxy_port']); curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); // If Proxy server needs authentication if(!empty($globals['proxy_user']) && !empty($globals['proxy_pass'])){ curl_setopt($ch, CURLOPT_PROXYUSERPWD, $globals['proxy_user'].':'.$globals['proxy_pass']); } return true; } function ins_get_web_file($url, $writefilename = ''){ global $globals; $allow_url_open = (int) ini_get('allow_url_fopen'); if(function_exists('curl_exec')){ // Set the curl parameters. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); // If admin has setup PROXY than we have to apply proxy settings. if(!empty($globals['proxy_check'])){ _curl_proxy($ch); } // Turn off the server and peer verification (TrustManager Concept). curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); // UserAgent and Cookies curl_setopt($ch, CURLOPT_USERAGENT, 'Softaculous'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Get response from the server. $file = curl_exec($ch); curl_close($ch); }elseif(!empty($allow_url_open)){ //Read the file $file = @implode('', file($url)); }else{ return false; } //Did we get something if(empty($file)){ return false; } //Are we to store the file if(empty($writefilename)){ return $file; //Store the file }else{ $fp = @fopen($writefilename, "wb"); //This opens the file //If its opened then proceed if($fp){ if(@fwrite($fp, $file) === FALSE){ return false; //Wrote the file }else{ @fclose($fp); return true; } } } return false; }//End of function function ins_eval($code){ global $spobs; $txt = trim($code); //Is there an Opening tag if(substr($txt, 0, 5) == '<?php'){ $txt = substr($txt, 5); } //Is there a Closing tag if(substr($txt, -2) == '?>'){ $txt = substr($txt, 0, -2); } return eval($txt); } function ins_error($txt){ echo $txt; die(); } // This function id used in H-Sphere function soft_valid_ip($ip){ if(!preg_match('/^(\d){1,3}\.(\d){1,3}\.(\d){1,3}\.(\d){1,3}$/is', $ip) || substr_count($ip, '.') != 3){ return false; } $r = explode('.', $ip); foreach($r as $v){ if($v > 255){ return false; } } return true; } function read_input($txt, $default = '', $length = 20){ echo $txt.' '.(!empty($default) ? '['.$default.'] ' : '').': '; flush(); $stdin = fopen('php://stdin','r'); $argq = fread($stdin, $length); $argq = trim($argq); if(!empty($argq)){ return $argq; } return $default; } function vesta_randstr($length, $special = 0){ global $globals, $softpanel; $randstack = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); $specialchars = array('!', '[', ']', '(', ')', '.', '-', '@'); $randstr = ''; while(strlen($randstr) < $length){ $randstr .= $randstack[array_rand($randstack)]; if(!empty($special) && strlen($randstr) < $length && (strlen($randstr)%2 == 0)){ $randstr .= $specialchars[array_rand($specialchars)]; } } return str_shuffle($randstr); } function install_bg_exec($cmd, $log = '/dev/null'){ global $globals, $softpanel; if($globals['os'] == 'windows'){ $win_cmd = 'start /B "" '.$cmd.' 2>nul >nul'; $out = popen($win_cmd, 'r'); if(empty($out)){ $ret = 1; }else{ $ret = 0; pclose($out); } return true; }else{ return shell_exec($cmd.' > '.$log.' 2>&1 &'); } } function ins_output($txt){ echo $txt."\n"; } function ins_saveglobals($globals){ global $argv; // If we are reinstalling don't overwrite universal.php if(in_array('--update-files', $argv) || in_array('--reinstall', $argv)){ return true; } return saveglobals($globals); } // Try if we can detect the server is VPS or Dedicated function ins_is_vps(){ global $globals; // Some old servers might not have lscpu and can be installed by yum install util-linux exec('lscpu 2>/dev/null', $output, $return); // If we get "Hypervisor" in output it means it is a VPS. On Dedicated we do not get "Hypervisor" // E.g. output : Hypervisor vendor: KVM if(!empty($output) && preg_match('/Hypervisor/is', implode("\n", $output))){ $globals['is_vps'] = 1; } } // Check if shell_exec is enabled if(!function_exists('shell_exec')){ echo 'shell_exec() is disabled. Please enable it to continue installation'; exit(1); } // Check if ioncube is loaded if(!extension_loaded('ionCube Loader')){ echo 'ionCube Loader is not loaded. Please enable it to continue installation'; exit(1); } ins_output('/////////////////////////////// // INSTALLING SOFTACULOUS'); // Determine the Panel and execute the code according to the panel if(is_dir('/usr/local/cpanel')){ ///////////////////// CPANEL START ///////////////////// ins_output('// Detected Panel : cPanel '); $panel = 'cpanel'; $globals['path'] = '/usr/local/cpanel/whostmgr/docroot/cgi/softaculous'; $globals['enduser'] = $globals['path'].'/enduser'; $globals['mainfiles'] = $globals['enduser'].'/main'; $globals['adminfiles'] = $globals['mainfiles'].'/admin'; $globals['euthemes'] = $globals['enduser'].'/themes'; $globals['show_top_scripts'] = 'Softaculous Apps Installer'; $globals['php_bin'] = (file_exists('/usr/local/cpanel/3rdparty/bin/php') ? '/usr/local/cpanel/3rdparty/bin/php' : ''); // If user dont want to use the cpanel 3rdparty php for softaculous than dont create usecpphp. if(!in_array('--nocpphp', $argv) && !file_exists('/var/cpanel/usecpphp')){ @shell_exec('touch /var/cpanel/usecpphp'); } }elseif(is_dir('/usr/local/directadmin')){ ///////////////////// DIRECTADMIN START ///////////////////// ins_output('// Detected Panel : Directadmin '); $panel = 'directadmin'; $globals['path'] = '/usr/local/directadmin/plugins/softaculous'; $globals['enduser'] = $globals['path'].'/images'; $globals['mainfiles'] = $globals['enduser'].'/main'; $globals['adminfiles'] = $globals['mainfiles'].'/admin'; $globals['euthemes'] = $globals['enduser'].'/themes'; $globals['show_top_scripts'] = 'Softaculous Apps Installer'; $globals['php_bin'] = '/usr/local/bin/php -n -c /usr/local/directadmin/plugins/softaculous/php.ini'; $lid = (empty($_SERVER['SERVER_ADDR']) ? '00000000' : $_SERVER['SERVER_ADDR']); $ltmp = @file_get_contents('/usr/local/directadmin/scripts/setup.txt'); if(!empty($ltmp)){ preg_match('/lid\=(.*?)\n/is', $ltmp, $matches); $lid = @trim($matches[1]); } ins_writefile($globals['path'].'/ID', $lid, 1); }elseif(is_dir('/usr/local/psa/admin')){ ///////////////////// PLESK START ///////////////////// ins_output('// Detected Panel : Plesk '); // Check if posix is loaded if(!extension_loaded('posix')){ echo 'POSIX extension is not loaded in PHP. Please enable it to continue installation'; exit(1); } $panel = 'plesk'; $globals['wwwsoft'] = '/usr/local/psa/admin/htdocs/modules/softaculous'; $globals['phpbin'] = '/usr/bin/php -d open_basedir="" -d safe_mode=0'; $globals['path'] = '/usr/local/softaculous'; $globals['enduser'] = $globals['path'].'/enduser'; $globals['mainfiles'] = $globals['enduser'].'/main'; $globals['adminfiles'] = $globals['mainfiles'].'/admin'; $globals['euthemes'] = $globals['enduser'].'/themes'; $globals['php_bin'] = 'php'; }elseif(is_dir('/hsphere')){ ins_output('// Detected Panel : H-Sphere '); if(strtolower($argv[1]) == 'master'){ ///////////////////// HSPHERE MASTER ///////////////////// $prop = '/hsphere/local/home/cpanel/hsphere/WEB-INF/classes/psoft_config/hsphere.properties'; $hsphere = @file_get_contents($prop); echo "\n\n\n\n"; // See if a Softaculous config is already there ! if(!preg_match('/softaculous/is', $hsphere)){ $hsphere .= ' SOFTACULOUS_URL=softaculous/ SOFTACULOUS_ADMIN_URL=softaculous/ '; $fp = fopen($prop, 'w'); if(!$fp){ die('Could not open H-Sphere Configuration File for editing'); } //Were there any errors if(@fwrite($fp, $hsphere) === FALSE){ // We failed! Try to back it up writefile($prop.'.bak', $hsphere, 1); @chmod($prop.'.bak', 0600); @chowngrp($prop.'.bak', 'root', 'root'); die('There was some error in saving the H-Sphere Configuration. Softaculous tried to create a backup in '.$prop.'.bak'); }else{ echo 'The H-Sphere Apache service must be restarted for the changes to come into effect. Restart H-Sphere Apache now ? [y/N]'."\n"; flush(); $stdin = fopen('php://stdin','r'); $argq = fread($stdin, 3); $ans = trim($argq); if(preg_match('/y/is', $ans)){ passthru('/etc/init.d/httpdcp restart'); exit(1); }else{ die("You must restart apache later \n\n\n\n"); } } @fclose($fp); }else{ die("H-Sphere configuration file is already configured \n\n\n\n"); } }else{ ///////////////////// HSPHERE SLAVE ///////////////////// $panel = 'hsphere'; $globals['wwwsoft'] = '/hsphere/shared/apache/htdocs/softaculous'; $globals['phpbin'] = '/hsphere/shared/php5/bin/php-cli -n -c /usr/local/softaculous/php.ini'; $globals['path'] = '/usr/local/softaculous'; $globals['enduser'] = $globals['path'].'/enduser'; $globals['mainfiles'] = $globals['enduser'].'/main'; $globals['adminfiles'] = $globals['mainfiles'].'/admin'; $globals['euthemes'] = $globals['enduser'].'/themes'; $globals['php_bin'] = '/hsphere/shared/php5/bin/php-cli'; echo 'Please enter the Master IP : '."\n"; flush(); $stdin = fopen('php://stdin','r'); $argq = fread($stdin, 20); $masterip = trim($argq); $temp = explode(':', $masterip); if(!soft_valid_ip($temp[0])){ die("The Master IP is invalid. Please re-run the installer \n"); } if(!empty($temp[1]) && !is_numeric($temp[1])){ die("Please enter a valid PORT \n"); } } }elseif(is_dir('/home/interworx')){ ///////////////////// INTERWORX START ///////////////////// ins_output('// Detected Panel : Interworx '); $panel = 'interworx'; $globals['path'] = '/usr/local/softaculous'; $globals['enduser'] = $globals['path'].'/enduser'; $globals['mainfiles'] = $globals['enduser'].'/main'; $globals['adminfiles'] = $globals['mainfiles'].'/admin'; $globals['euthemes'] = $globals['enduser'].'/themes'; $globals['php_bin'] = '~iworx/bin/php'; }elseif(is_dir('/usr/local/ispmgr') || is_dir('/usr/local/mgr5')){ ///////////////////// ISP START ///////////////////// ins_output('// Detected Panel : ISPmanager '); $panel = 'isp'; $globals['wwwsoft'] = '/var/softwww'; $globals['ispetc'] = '/usr/local/ispmgr/etc'; $globals['path'] = '/usr/local/softaculous'; $globals['enduser'] = $globals['path'].'/enduser'; $globals['mainfiles'] = $globals['enduser'].'/main'; $globals['adminfiles'] = $globals['mainfiles'].'/admin'; $globals['euthemes'] = $globals['enduser'].'/themes'; // Is it ISPmanager 5 ? $GLOBALS['mgr5'] = 0; if(is_dir('/usr/local/mgr5')){ $GLOBALS['mgr5'] = 1; if(file_exists('/usr/local/mgr5/lib/ispmgrnode.so')){ $globals['ispconfd'] = '/usr/local/mgr5/etc/ispmgrnode.conf.d'; $globals['ispconf'] = '/usr/local/mgr5/etc/ispmgrnode.conf'; }else{ $globals['ispconfd'] = '/usr/local/mgr5/etc/ispmgr.conf.d'; $globals['ispconf'] = '/usr/local/mgr5/etc/ispmgr.conf'; } } }elseif(file_exists('/usr/local/ispconfig')){ ///////////////////// ISPCONFIG START ///////////////////// ins_output('// Detected Panel : ISPCONFIG '); $panel = 'ispconfig'; $globals['wwwsoft'] = '/var/softwww'; $globals['ispconfig_webroot'] = '/usr/local/ispconfig/interface/web'; $globals['phpbin'] = '/usr/bin/php -n -c /usr/local/softaculous/php.ini'; $globals['path'] = '/usr/local/softaculous'; $globals['enduser'] = $globals['path'].'/enduser'; $globals['mainfiles'] = $globals['enduser'].'/main'; $globals['adminfiles'] = $globals['mainfiles'].'/admin'; $globals['euthemes'] = $globals['enduser'].'/themes'; $globals['php_bin'] = 'php'; echo 'Please enter the Remote User : '; flush(); $stdin = fopen('php://stdin','r'); $argq = fread($stdin, 20); $remote_user = trim($argq); $command = "/usr/bin/env bash -c 'echo OK'"; if (rtrim(shell_exec($command)) !== 'OK') { die("Can't invoke bash"); return; } $command = '/usr/bin/env bash -c \'read -s -p "Enter Password: " mypassword && echo $mypassword\''; $remote_pass = rtrim(shell_exec($command)); $remote_details = $remote_user.':'.$remote_pass; }elseif(in_array('--remote', $argv)){ ///////////////////// REMOTE START ///////////////////// $panel = 'remote'; $globals['path'] = '/usr/local/softaculous'; $globals['enduser'] = $globals['path'].'/enduser'; $globals['mainfiles'] = $globals['enduser'].'/main'; $globals['adminfiles'] = $globals['mainfiles'].'/admin'; $globals['euthemes'] = $globals['enduser'].'/themes'; $globals['php_bin'] = '/usr/local/emps/bin/php'; }elseif(in_array('--enterprise', $argv)){ ///////////////////// ENTERPRISE START ///////////////////// if(in_array('--noemps', $argv)){ $globals['ent_dbhost'] = read_input('Enter MySQL DB Host', 'localhost'); $globals['ent_db'] = read_input('Enter MySQL DB Name', 'softaculous'); $globals['ent_dbuser'] = read_input('Enter MySQL DB User', 'root'); $globals['ent_dbuserpass'] = read_input('Enter MySQL DB User Password'); $globals['php_bin'] = read_input('Enter PHP Bin', 'php', 50); $conn = mysql_connect($globals['ent_dbhost'], $globals['ent_dbuser'], $globals['ent_dbuserpass']); if(!$conn){ die('Could not connect to MySQL'); } mysql_close($conn); } $panel = 'enterprise'; $globals['path'] = '/usr/local/softaculous'; $globals['enduser'] = $globals['path'].'/enduser'; $globals['mainfiles'] = $globals['enduser'].'/main'; $globals['adminfiles'] = $globals['mainfiles'].'/admin'; $globals['euthemes'] = $globals['enduser'].'/themes'; $globals['php_bin'] = (!empty($globals['php_bin']) ? $globals['php_bin'] : '/usr/local/emps/bin/php'); }elseif(file_exists('/usr/local/cwp')){ ///////////////////// CWP START ///////////////////// ins_output('// Detected Panel : CentOS Web Panel '); $panel = 'cwp'; if(is_dir('/usr/local/cwpsrv/var/services/users')){ $globals['wwwsoft'] = '/usr/local/cwpsrv/var/services/users/softaculous'; }else{ $globals['wwwsoft'] = '/usr/local/cwp/softaculous'; } $globals['path'] = '/usr/local/softaculous'; $globals['enduser'] = $globals['path'].'/enduser'; $globals['mainfiles'] = $globals['enduser'].'/main'; $globals['adminfiles'] = $globals['mainfiles'].'/admin'; $globals['euthemes'] = $globals['enduser'].'/themes'; $globals['php_bin'] = '/usr/local/cwp/php/bin/php'; }elseif(file_exists('/usr/local/vesta')){ ///////////////////// VESTA START ///////////////////// ins_output('// Detected Panel : Vesta Control Panel '); $panel = 'vesta'; $globals['wwwsoft'] = '/usr/local/vesta/web/softaculous'; $globals['path'] = '/usr/local/vesta/softaculous'; $globals['enduser'] = $globals['path'].'/enduser'; $globals['mainfiles'] = $globals['enduser'].'/main'; $globals['adminfiles'] = $globals['mainfiles'].'/admin'; $globals['euthemes'] = $globals['enduser'].'/themes'; $globals['php_bin'] = '/usr/local/vesta/php/bin/php'; }elseif(file_exists('C:/Program Files/Hosting Controller')){ //////Hosting Controller Windows///////// ins_output('// Detected Panel : Hosting Controller (Windows) '); $panel = 'hc'; $globals['hc_softpath'] = 'C:/Program Files/Hosting Controller/Tools/Softaculous'; $globals['path'] = $globals['hc_softpath'].'/setup'; $globals['enduser'] = $globals['path'].'/enduser'; $globals['mainfiles'] = $globals['enduser'].'/main'; $globals['adminfiles'] = $globals['mainfiles'].'/admin'; $globals['euthemes'] = $globals['enduser'].'/themes'; $globals['softscripts'] = $globals['hc_softpath'].'/scripts'; //Fetch the PHP Binary from the IIS System Configuration if(array_key_exists('phpbinary', $ins_params)){ $php_bin = $ins_params['phpbinary']; }else{ if(defined('PHP_BINARY')){ $php_bin = PHP_BINARY; }else{ $php_bin = str_replace('.ini', '.exe', php_ini_loaded_file()); } } if(!file_exists($php_bin)){ echo "\nPlease enter the path to your PHP Binary (php.exe): "; $php_bin = trim(fgets(STDIN)); if(!file_exists($php_bin)){ die("\nUnable to locate the specified PHP Binary on your server!!\nPlease specify the correct PHP binary path in the installer command with the parameter as \"--phpbinary = path\\to\\php.exe\""); } echo "\n"; } //HC API URL as input echo "\nPlease enter the Hosting Controller API URL accessible from your WebServer (Note: URL should be of the format 'http(s)://IP:PORT'): "; $api_url = trim(fgets(STDIN)); echo "\n"; $globals['hc_apiurl'] = $api_url; $globals['php_bin'] = '"'.$php_bin.'"'; $globals['auth_dir'] = str_replace('setup', 'auth', $globals['path']); } // See if the files exist if(!file_exists($globals['enduser'].'/index.php') || in_array('--force-download', $argv) || in_array('--update-files', $argv) || in_array('--reinstall', $argv)){ ins_output('// DOWNLOADING SOFTACULOUS PACKAGE '); #~~~~~~~~~~~~~~~~~~~~~~~ # We need to LOAD stuff #~~~~~~~~~~~~~~~~~~~~~~~ // Get the Zip Class //wget command is not supported on Windows Server if($this_os != 'WIN'){ @shell_exec('wget --no-check-certificate -O pclzip.inc '.$globals['webserver'].'pclzip.inc >> /dev/null 2>&1'); } if(!file_exists('pclzip.inc')){ @ins_eval(ins_get_web_file($globals['webserver'].'pclzip.inc')); }else{ include_once('pclzip.inc'); @unlink('pclzip.inc'); } if(!class_exists('PclZip')){ ins_error('Could not load the Unzip Class!'); } // Get the latest file revision $_data = ins_get_web_file('http://api.softaculous.com/updates.php?version=latest&panel='.$panel.'&cur_php='.rawurlencode(phpversion())); $info = @unserialize($_data); // Download the Latest Softaculous Version if(!$latest = ins_get_web_file($info['link'])){ ins_error('Could not download the Softaculous Package!'); } if(!ins_writefile($globals['path'].'/softaculous.zip', $latest, 1)){ ins_error('Could not save the Softaculous Package!'); } $zip = new PclZip($globals['path'].'/softaculous.zip'); $unzipped = $zip->extract(PCLZIP_OPT_PATH, $globals['path'], PCLZIP_OPT_REPLACE_NEWER); //Are there any files if($unzipped == 0){ ins_error('Could not UNZIP the Softaculous Package!'); } }else{ ins_output('// Softaculous Package already exists, Skipping Download... // Use --force-download parameter to forcefully download the package'); } #################################### ## BEGIN THE INSTALLATION PROCESS ## #################################### // Now Execute the code which is required before Installation if(function_exists('pre_'.$panel)){ @call_user_func('pre_'.$panel); } //Some globals vars include_once($globals['enduser'].'/globals.php'); //The necessary functions to run this SOFTACULOUS Software include_once($globals['mainfiles'].'/functions.php'); //Load the SOFTPANEL Class if(!class_exists('softpanel')){ include_once($globals['includes_path'].'/softpanel.php'); } $softpanel = new softpanel(); //GET the Categories, Scripts and iScripts catsnscripts(); //Create salt (For Remote) $globals['salt'] = generateRandStr(16); // Is it a VPS ? if(array_key_exists('is_vps', $ins_params) && !empty($ins_params['is_vps'])){ $globals['is_vps'] = 1; } //Load the Functions Language File - This will be from the default Lang Folder load_lang('index'); load_lang('admin/index'); load_lang('admin/cron'); load_lang('admin/softwares'); /////////////////////////////// // INSTALLATION PROCESS STEPS : // 1) CONFIGURE universal.php // 2) FETCH A LICENSE // 3) UPDATE categories.php // 4) UPDATE scripts.php // 5) UPDATE iscripts.php // 6) SET A CRON JOB // 7) SOFTACULOUS.CPANELPLUGIN // 8) CREATE LINKS to enduser // 9) Update Addon for RVSkin @since 3.7 // 10) REWRITE this file /////////////////////////////// // 1) CONFIGURE universal.php ins_saveglobals($globals); ins_output('// CONFIGURED universal.php'); // 2) FETCH A LICENSE loadlicense(true);//UPDATE as well ins_output('// FETCHED THE LICENSE'); // 3) UPDATE categories.php updatecats(); ins_output('// UPDATED SCRIPTS CATEGORIES'); // 4) UPDATE scripts.php // 5) UPDATE iscripts.php updatescripts(); ins_output('// UPDATED SCRIPTS LIST'); // 6) SET A CRON JOB add_cron($globals['cron_time']); ins_output('// ADDED CRON JOB'); // Now Execute the code which is required in middle of Installation if(function_exists('middle_'.$panel)){ @call_user_func('middle_'.$panel); } /* //We need to keep this ALIVE - So out put text echo '/////////////////////////////// // INSTALLING SOFTACULOUS : // 1) CONFIGURING universal.php // 2) FETCHED A LICENSE // 3) UPDATING Categories // 4) UPDATING Scripts List // 5) UPDATING Installed Scripts List // 6) SETTING A CRON JOB // 7) DOWNLOADING SCRIPTS ///////////////////////////////'."\n\r\n\r"; */ @mkdir($globals['softscripts']); if($globals['os'] != 'windows'){ @shell_exec('chmod -R 0755 '.$globals['path']); @shell_exec('chmod -R 0755 '.$globals['softscripts']); } // Make errorlog.log file writefile($globals['softscripts'].'/error_log.log', '', 1); @chmod($globals['softscripts'].'/error_log.log', 0600); // Now create cache ins_output('// BUILDING SCRIPT CACHE'); create_cache(); // Download the SitePad plans JSON file if(can_show_sitepad()){ update_sitepad_plans(); $thisip = ins_get_web_file('http://api.softaculous.com/ip.php'); if(soft_valid_ip($thisip)){ $ip_region = ip_region($thisip); if(!empty($ip_region)){ if(in_array($ip_region, array('ripe', 'apnic', 'afrinic'))){ $sitepad_data = array(); $sitepad_data['host_sm'] = 'https://eu.sitepad.com'; save_sitepad_conf($sitepad_data); } } } } // Now Execute the code which is required after Installation if(function_exists('post_'.$panel)){ @call_user_func('post_'.$panel); } // Execute CRON function in softpanel (if any) if(method_exists($softpanel, 'cron')){ $softpanel->cron(); } ##################################### ## FINISHED INSTALLING SOFTACULOUS ## ##################################### // Copy the binary to the following panel only. if(!empty($unzipped) && ($panel == 'cpanel' || $panel == 'directadmin' || $panel == 'plesk' || $panel == 'isp' || $panel == 'interworx' || $panel == 'hsphere' || $panel == 'ispconfig' || $panel == 'cwp' || $panel == 'remote' || $panel == 'vesta')){ softbinary(); @exec($globals['path'].'/bin/soft -v', $out, $ret); $out = @implode('', $out); // If we dont get the required output than it means that binary is not working // Or the file itself is not there if(!preg_match('/Softaculous Computer Binary/is', $out)){ include_once($globals['clifiles'].'/repair.php'); } } // We have to configure the cagefs hook by default for users ease. if(file_exists('/usr/bin/selectorctl')){ @rename($globals['enduser'].'/hooks/pre_install_cagefs.txt', $globals['enduser'].'/hooks/pre_install_cagefs.php'); @rename($globals['enduser'].'/hooks/pre_upgrade_cagefs.txt', $globals['enduser'].'/hooks/pre_upgrade_cagefs.php'); } // Check if rewrite module is present. We will use this in script packages to detect if mod_rewrite is enabled check_rewrite_module(); // RUN THE CRON //@shell_exec('/usr/bin/php '.$globals['path'].'/cron.php'); if(!in_array('--full', $argv)){ ins_output('// Script Packages will be downloaded in background'); ins_output('///////////////////////////////'."\n\r"); // If user wants a quick installation than we will download the scripts in background and just finish the installation. install_bg_exec($globals['php_bin'].' "'.$globals['path'].'/cron.php" sleep=30'); }else{ ins_output('// DOWNLOADING SCRIPT PACKAGES'); ins_output('///////////////////////////////'."\n\r"); foreach($iscripts as $ik => $iv){ // If we have a function in softpanel than just download SMALL PACKAGES if(method_exists($softpanel, 'updatesoftwares')){ $report = updatesoftwares($ik, 0, 1); // Else just like OLD method. All Big Packages }else{ $report = updatesoftwares($ik, 0); } echo $iv['name'].' - '.implode("\n", $report[$ik]['log'])."\n\r\n\r"; } } echo '====================================================='; if($panel == 'hsphere'){ echo ' YOU WILL NEED TO RELOAD APACHE FOR THE CHANGES TO TAKE EFFECT: root> /etc/init.d/httpd reload ====================================================='; } if($panel == 'isp' || $panel == 'ispconfig'){ // You will need to restart your server echo '===================================================== YOU WILL NEED TO RESTART YOUR SERVER FOR EFFECTS TO TAKE PLACE. Please REBOOT ASAP as only then will Softaculous be available in the Panel. '; } if($panel == 'remote' || $panel == 'enterprise'){ $thisip = ins_get_web_file('http://api.softaculous.com/ip.php'); echo ' API Key : '.$GLOBALS['apikey'].' API Password : '.$GLOBALS['apipass'].' To access the Admin Panel, go to http://'.$thisip.':2006 (2007 for HTTPS) Please write this down and keep it safe. Your user will be authenticated by this key. ===================================================== '; } // We have to add out PATH in cagefs mount point file so that users that are in cagefs can see Softaculous. if(file_exists('/usr/bin/selectorctl') && file_exists('/etc/cagefs/cagefs.mp')){ $write_mp = 0; $cagefs_mp = file_get_contents('/etc/cagefs/cagefs.mp'); if(!preg_match('/'.preg_quote($globals['path'], '/').'/is', $cagefs_mp)){ $cagefs_mp .= "\n\n!".$globals['path']."\n\n"; $write_mp = 1; } if(!preg_match('/'.preg_quote($globals['softscripts'], '/').'/is', $cagefs_mp)){ $cagefs_mp .= '!'.$globals['softscripts']."\n\n"; $write_mp = 1; } if(!empty($write_mp)){ $h = fopen('/etc/cagefs/cagefs.mp', 'w'); fwrite($h, $cagefs_mp); fclose($h); // Now remount so that all user can see softaculous from shell @shell_exec('cagefsctl --remount-all'); } } echo ' Congratulations, Softaculous was installed successfully Softaculous has been installed at: Path : '.$globals['path'].' Scripts Path : '.$globals['softscripts'].' We request you to please register for updates and notifications at : http://www.softaculous.com/board/index.php?act=register It also inspires us when you register. Registration is free and just a one minute job. If you need any support you can always count on us. Just drop in at our Support Board: http://www.softaculous.com/board Alternatively, you can contact us via Email at support@softaculous.com Thank you for using Softaculous '; function pre_cpanel(){ global $globals; //Detecting suPHP settings. According to that setting the permission for directory and files. $get_suphp = shell_exec(' /usr/local/cpanel/bin/rebuild_phpconf --current'); preg_match('/DEFAULT PHP: (.*?)\n/is', $get_suphp, $matches); if(preg_match('/(PHP|\\n)'.$matches[1].' SAPI: (suphp|cgi)/is', $get_suphp, $matches2)){ $globals['chmod_files'] = '0644'; $globals['chmod_dir'] = '0755'; } $envtype = @implode('', file('/var/cpanel/envtype')); if(trim($envtype) !== 'standard'){ $globals['is_vps'] = 1; } if(!empty($argv[1])){ echo "Fetching a License \n"; // Whats my IP ??? $thisip = ins_get_web_file('http://api.softaculous.com/ip.php'); // Call the NOC API file to issue a license ins_get_web_file('http://www.softaculous.com/noc?nocname='.rawurlencode($argv[1]).'&nocpass='.rawurlencode($argv[2]).'&ca=buy&purchase=1&ips='.rawurlencode($thisip).'&toadd=1M&servertype='.(empty($globals['is_vps']) ? 1 : 2).'&authemail='.rawurlencode($argv[3]).'&autorenew=1'); } return true; } function middle_cpanel(){ global $globals; $log_path = dirname(__FILE__).'/install.log'; $deprecated_themes = array('x', 'x2'); ins_output('// REGISTERING SOFTACULOUS PLUGIN WITH CPANEL'); ins_output('// This might take few minutes...'); // 7) SOFTACULOUS.CPANELPLUGIN @shell_exec('yum -y install file'); @shell_exec('/usr/local/cpanel/bin/register_cpanelplugin '.$globals['path'].'/softaculous.cpanelplugin >> '.$log_path); // If paper_lantern is there we have to register our plugin as per new method for paper_lantern if(is_dir('/usr/local/cpanel/base/frontend/paper_lantern')){ if(file_exists('/usr/local/cpanel/scripts/install_plugin')){ @shell_exec('/usr/local/cpanel/scripts/install_plugin '.$globals['path'].'/softaculous_plugin.tar.bz2 >> '.$log_path); }else{ @copy($globals['euthemes'].'/default/images/softaculous_48.jpg', '/usr/local/cpanel/base/frontend/paper_lantern/branding/softaculous.jpg'); } } if(is_dir('/usr/local/cpanel/base/frontend/FlatPanel')){ @copy($globals['euthemes'].'/default/images/softaculous_48.jpg', '/usr/local/cpanel/base/frontend/FlatPanel/branding/softaculous.jpg'); } @shell_exec('/usr/local/cpanel/bin/rebuild_sprites'); // 8) CREATE LINKS to enduser $cpthemes = filelist('/usr/local/cpanel/base/frontend/', 0, 1); foreach($cpthemes as $k=>$v){ // If the theme is deprecated, we dont make symlinks if(in_array(basename($k), $deprecated_themes)) continue; if(!is_link($k.'/softaculous')){ @shell_exec('ln -s '.$globals['enduser'].' '.$k.'/softaculous'); } if($v['name'] == 'bluehost'){ if(file_exists('/usr/local/cpanel/scripts/install_plugin')){ @shell_exec('/usr/local/cpanel/scripts/install_plugin '.$globals['path'].'/softaculous_plugin.tar.bz2 --theme='.$v['name'].' >> '.$log_path); } @shell_exec('/usr/local/cpanel/bin/sprite_generator --theme='.$v['name']); } } // 9) Update Addons for RVSkin @Since 3.7 if(file_exists('/root/rvadmin/autoupdatewhmaddon.pl')){ @shell_exec('/usr/bin/perl /root/rvadmin/autoupdatewhmaddon.pl'); } // 10) Make the SHORTCUT ! $data = '#!/bin/sh eval \'if [ -x /usr/local/cpanel/3rdparty/bin/perl ]; then exec /usr/local/cpanel/3rdparty/bin/perl -x -- $0 ${1+"$@"}; else exec /usr/bin/perl -x $0 ${1+"$@"}; fi;\' if 0; #!/usr/bin/perl #WHMADDON:softaculous:Softaculous - Instant Installs my $URL; if ( \'root\' eq $ENV{\'REMOTE_USER\'} ){ $URL = "../cgi/softaculous/index.php"; }else{ $URL = "../cgi/softaculous/index.cgi"; } print "Location: $URL\n\n"; '; ins_writefile('/usr/local/cpanel/whostmgr/docroot/cgi/addon_softaculous.cgi', $data, 1); @shell_exec('chmod 0755 /usr/local/cpanel/whostmgr/docroot/cgi/addon_softaculous.cgi'); schmod('/usr/local/cpanel/whostmgr/docroot/cgi/addon_softaculous.cgi', 0755); return true; } function post_cpanel(){ global $globals, $softpanel; ins_output('// REGISTERING SOFTACULOUS SCRIPTS CATEGORY WITH CPANEL'); ins_output('// This might take few minutes...'); // Run the Apps Category maker in cPanel change_app_name($globals['show_top_scripts']); ins_output('// REGISTERING SOFTACULOUS WORDPRESS MANAGER WITH CPANEL'); ins_output('// This might take few minutes...'); // Run the WordPress Manager maker in cPanel register_wordpress_manager(true); // Now put logo in specific directory to display in WHM Plugin @copy($globals['euthemes'].'/default/images/softaculous_WHM.gif', '/usr/local/cpanel/whostmgr/docroot/themes/x/icons/softaculous.gif'); @copy($globals['euthemes'].'/default/images/soft.png', '/usr/local/cpanel/whostmgr/docroot/themes/x/icons/softaculous.png'); // we have to change the admin email as on some server it was set as admin@ if(method_exists($softpanel, 'server_email')){ $globals['soft_email'] = $softpanel->server_email(); ins_saveglobals($globals); } } function pre_directadmin(){ ins_is_vps(); } function middle_directadmin(){ if(!file_exists('/usr/bin/php')){ @shell_exec('ln -s /usr/local/bin/php /usr/bin/php'); } } function post_directadmin(){ global $globals, $softpanel; schmod($globals['path'], 0755, 1); schmod($globals['softscripts'], 0755, 1); // Build the binary if(!makebinary_da()){ die('Unable to compile the binary file'); } // Run the Apps Category maker in DA change_app_name($globals['show_top_scripts']); // Create a symlink to Images folder with the name enduser @shell_exec('ln -s '.$globals['enduser'].' '.$globals['path'].'/enduser'); // we have to change the admin email as on some server it was set as admin@ if(method_exists($softpanel, 'server_email')){ $globals['soft_email'] = $softpanel->server_email(); ins_saveglobals($globals); } } function post_hsphere(){ global $globals, $masterip; // Build the binary if(!makebinary_hs()){ die('Unable to compile the binary file'); } // Copy the www files @mkdir($globals['wwwsoft'], 0755); copy($globals['path'].'/hs/index.php', $globals['wwwsoft'].'/index.php'); // Create Necessary links @shell_exec('ln -s '.$globals['enduser'].'/softimages '.$globals['wwwsoft'].'/softimages'); @shell_exec('ln -s '.$globals['enduser'].'/themes '.$globals['wwwsoft'].'/themes'); // Make the Softaculous Temporary directory @mkdir('/var/softtmp', 0777); @shell_exec('chmod 0777 /var/softtmp'); // Store the Master IP writefile($globals['path'].'/master', $masterip, 1); $apache = '/hsphere/shared/apache/conf/custom.conf'; $httpd = @file_get_contents($apache); // See if a Softaculous config is already there ! if(!preg_match('/softaculous/is', $httpd)){ $httpd .= ' <Directory /hsphere/shared/apache/htdocs/softaculous> AddType application/x-httpd-php .php .php3 .php4 .phtml php_admin_value upload_tmp_dir /tmp php_admin_value open_basedir "" php_admin_value include_path / php_admin_value session.save_path /tmp DirectoryIndex index.php </Directory>'; $fp = fopen($apache, 'w'); if(!$fp){ die('Could not open Apache Custom Configuration File for editing'); } //Were there any errors if(@fwrite($fp, $httpd) === FALSE){ // We failed! Try to back it up writefile($apache.'.bak', $httpd, 1); @chmod($apache.'.bak', 0600); @chowngrp($apache.'.bak', 'root', 'root'); die('There was some error in saving the Apache Configuration. Softaculous tried to create a backup in '.$apache.'.bak'); } @fclose($fp); } } function pre_plesk(){ ins_is_vps(); } function middle_plesk(){ // 7) CREATE LINKS if(!file_exists('/usr/bin/php')){ @shell_exec('ln -s /usr/local/bin/php /usr/bin/php'); } } function post_plesk(){ global $globals, $softpanel, $argv; // Copy the www files @mkdir($globals['wwwsoft'], 0755); copy($globals['path'].'/pl/index.php', $globals['wwwsoft'].'/index.php'); // Create Necessary links @shell_exec('ln -s '.$globals['enduser'].'/softimages '.$globals['wwwsoft'].'/softimages'); @shell_exec('ln -s '.$globals['enduser'].'/themes '.$globals['wwwsoft'].'/themes'); // Make the Softaculous Temporary directory @mkdir('/var/softtmp', 0700); @chowngrp('/var/softtmp', 'psaadm', 'psaadm'); @shell_exec('chown -R psaadm:psaadm /var/softtmp'); // Do we need to add custom button ? if(!in_array('nocustombutton', $argv)){ // MySQL Pass $pass = file_get_contents('/etc/psa/.psa.shadow'); // Install the Custom Buttons $GLOBALS["plesk_db_connection"] = soft_mysql_connect('localhost', 'admin', trim($pass)); if(!empty($GLOBALS["plesk_db_connection"])){ if(!(@soft_mysql_select_db('psa', $GLOBALS["plesk_db_connection"]))){ die('ERROR SELECTING DB'); } }else{ die('ERROR CONNECTING TO MYSQL'); } $plesk_version = @file_get_contents('/usr/local/psa/version'); $version = (int) substr($plesk_version, 0, strpos($plesk_version, '.')); $front = ($version > 9 ? ($version > 10 ? '/..' : '../../..') : ''); soft_mysql_query("DELETE FROM `custom_buttons` WHERE url like '%softaculous%'", $GLOBALS["plesk_db_connection"]); // Make the Queries soft_mysql_query("INSERT INTO `custom_buttons` (`id`, `sort_key`, `level`, `level_id`, `place`, `text`, `url`, `conhelp`, `options`, `file`) VALUES (0, 100, 1, 0, 'admin', 'Softaculous Admin', '".$front."/modules/softaculous/index.php?ap=1', 'Administration panel of Softaculous Auto Installer', 128, 'softaculous_icon.gif')", $GLOBALS["plesk_db_connection"]); // For plesk 10 "options" field value has been changed to 128. Because its not working on 0.(128 is working on both plesk 10 and 9.5.x) soft_mysql_query("INSERT INTO `custom_buttons` (`id`, `sort_key`, `level`, `level_id`, `place`, `text`, `url`, `conhelp`, `options`, `file`) VALUES (0, 100, 1, 0, 'navigation', 'Softaculous Auto Installer', '".$front."/modules/softaculous/index.php', 'Softaculous is an Instant Installer which you can use to install some of the coolest PHP Scripts', 128, 'softaculous_icon.gif')", $GLOBALS["plesk_db_connection"]); // Plesk 10 has a different interface. if($version < 10){ soft_mysql_query("INSERT INTO `custom_buttons` (`id`, `sort_key`, `level`, `level_id`, `place`, `text`, `url`, `conhelp`, `options`, `file`) VALUES (0, 100, 1, 0, 'client', 'Softaculous Auto Installer', '".$front."/modules/softaculous/index.php', 'Softaculous is an Instant Installer which you can use to install some of the coolest PHP Scripts', 128, 'softaculous_icon.gif')", $GLOBALS["plesk_db_connection"]); soft_mysql_query("INSERT INTO `custom_buttons` (`id`, `sort_key`, `level`, `level_id`, `place`, `text`, `url`, `conhelp`, `options`, `file`) VALUES (0, 100, 1, 0, 'domain', 'Softaculous Auto Installer', '".$front."/modules/softaculous/index.php', 'Softaculous is an Instant Installer which you can use to install some of the coolest PHP Scripts', 128, 'softaculous_icon.gif')", $GLOBALS["plesk_db_connection"]); } // Copy the Logo image copy($globals['path'].'/pl/softaculous_icon.gif', '/usr/local/psa/admin/htdocs/images/custom_buttons/softaculous_icon.gif'); } // we have to change the admin email as on some server it was set as admin@ if(method_exists($softpanel, 'server_email')){ $globals['soft_email'] = $softpanel->server_email(); ins_saveglobals($globals); } } function pre_interworx(){ global $globals; umask(022); // This is because IWX sets secure umask which sets permissions 0700 and 0600 check_environment(); // Is this a VPS or a dedicated server ? $VPSStatus = shell_exec('nodeworx -u -n -c Overview -a listVPSStatus'); $VPSStatus = explode(':', $VPSStatus); $is_vps = trim($VPSStatus[1]); if(!empty($is_vps)){ $globals['is_vps'] = 1; } } function post_interworx(){ global $globals; // We have to install a interworx-cli to get the session id while CRON i.e. in Command line (BUG FIX #497) @shell_exec('yum -y install interworx-cli'); // Change owner @shell_exec('chown -R iworx:iworx '.$globals['path']); @shell_exec('chown -R iworx:iworx '.$globals['softscripts']); chowngrp($globals['path'], 'iworx', 'iworx', 1); chowngrp($globals['softscripts'], 'iworx', 'iworx', 1); chowngrp('/etc/cron.d/softaculous', 'root', 'iworx'); } function pre_isp(){ ins_is_vps(); } function middle_isp(){ if(!file_exists('/usr/bin/php')){ @shell_exec('ln -s /usr/local/bin/php /usr/bin/php'); } } function post_isp(){ global $globals, $softpanel; if(!empty($GLOBALS['mgr5'])){ post_isp5(); }else{ // Copy the www files @mkdir($globals['wwwsoft'], 0755); copy($globals['path'].'/isp/index.php', $globals['wwwsoft'].'/index.php'); // Create Necessary links @shell_exec('ln -s '.$globals['enduser'].'/softimages '.$globals['wwwsoft'].'/softimages'); @shell_exec('ln -s '.$globals['enduser'].'/themes '.$globals['wwwsoft'].'/themes'); // Make the Softaculous Temporary directory @mkdir('/var/softtmp', 0700); @chowngrp('/var/softtmp', 'apache', 'apache'); @shell_exec('chown -R apache:apache /var/softtmp'); // Load the ispmgr.conf $ispmgr = @file_get_contents($globals['ispetc'].'/ispmgr.conf'); if(empty($ispmgr)){ die('Could not load ISPMGR Configuration file for system information'); } preg_replace('/path httpd\.conf (.*?)(\n|\r)/ies', '$apache = trim(\'$1\');', $ispmgr); preg_replace('/path apachectl (.*?)(\n|\r|\s)/ies', '$apachectl = \'$1\';', $ispmgr); // Copy the MOD file copy($globals['path'].'/isp/ispmgr_mod_softaculous.xml', $globals['ispetc'].'/ispmgr_mod_softaculous.xml'); // See if a extaction is already registered if(!preg_match('/extaction softaculous/is', $ispmgr)){ $ispmgr = str_replace('extaction myadmin /myadmin/', 'extaction myadmin /myadmin/ extaction softaculous /softaculous/', $ispmgr); $fp = fopen($globals['ispetc'].'/ispmgr.conf', 'w'); if(!$fp){ die('Could not open ISPMGR for registering Softaculous External Action'); } //Were there any errors if(@fwrite($fp, $ispmgr) === FALSE){ // We failed! Try to back it up writefile($globals['ispetc'].'/ispmgr.bak.conf', $ispmgr, 1); @chmod($globals['ispetc'].'/ispmgr.bak.conf', 0600); @chowngrp($globals['ispetc'].'/ispmgr.bak.conf', 'root', 'root'); die('There was some error in saving the ISPMGR Configuration. Softaculous tried to create a backup in '.$globals['ispetc'].'/ispmgr.bak.conf'); } @fclose($fp); } $httpd = @file_get_contents($apache); // Apache stuff if(empty($httpd)){ die('Could not load the APACHE Configuration'); } // See if a Softaculous Alias is already there if(!preg_match('/Alias \/softaculous/is', $httpd)){ $httpd = str_replace('Include /usr/local/ispmgr/etc/ispmgr.inc', 'Alias /softaculous '.$globals['wwwsoft'].'/ <Directory /var/softwww> AddType application/x-httpd-php .php .php3 .php4 .phtml php_admin_value upload_tmp_dir /tmp php_admin_value open_basedir none php_admin_value include_path .:.. php_admin_value session.save_path /tmp php_admin_value safe_mode off DirectoryIndex index.php </Directory> Include /usr/local/ispmgr/etc/ispmgr.inc', $httpd); $fp = fopen($apache, 'w'); if(!$fp){ die('Could not open Apache Configuration File for editing'); } //Were there any errors if(@fwrite($fp, $httpd) === FALSE){ // We failed! Try to back it up writefile($apache.'.bak', $httpd, 1); @chmod($apache.'.bak', 0600); @chowngrp($apache.'.bak', 'root', 'root'); die('There was some error in saving the Apache Configuration. Softaculous tried to create a backup in '.$apache.'.bak'); } @fclose($fp); } } // we have to change the admin email as on some server it was set as admin@ if(method_exists($softpanel, 'server_email')){ $globals['soft_email'] = $softpanel->server_email(); ins_saveglobals($globals); } } // This is for ISPmanager 5 function post_isp5(){ global $globals, $softpanel; // Copy the www files @mkdir($globals['wwwsoft'], 0755); copy($globals['path'].'/isp/index.php', $globals['wwwsoft'].'/index.php'); // Create Necessary links if(!file_exists($globals['wwwsoft'].'/softimages')) @shell_exec('ln -s '.$globals['enduser'].'/softimages '.$globals['wwwsoft'].'/softimages'); if(!file_exists($globals['wwwsoft'].'/themes')) @shell_exec('ln -s '.$globals['enduser'].'/themes '.$globals['wwwsoft'].'/themes'); // Load the ispmgr.conf $ispmgr = @file_get_contents($globals['ispconf']); if(empty($ispmgr)){ echo 'Could not load ISPMGR Configuration file for system information'; exit(1); } soft_preg_replace('/WebUser (.*?)(\n|\r)/is', $ispmgr, $webuser, 1); // Make the Softaculous Temporary directory @mkdir('/var/softtmp', 0770); @chowngrp('/var/softtmp', $webuser, 'mgrsecure'); // mgrsecure group access required when Apache MPM-ITK is installed @shell_exec('chown -R '.$webuser.':mgrsecure /var/softtmp'); @chmod('/var/softtmp', 0770); // Load the ispmgr.conf.d/apache.conf $ispapacheconf = @file_get_contents($globals['ispconfd'].'/apache.conf'); if(!empty($ispapacheconf)){ // Configure Apache soft_preg_replace('/path apache-conf\.d (.*?)(\n|\r)/is', $ispapacheconf, $apachedir, 1); soft_preg_replace('/path apachectl (.*?)(\n|\r|\s)/is', $ispapacheconf, $apachectl, 1); if(!file_exists($apachedir.'/softaculous.conf')){ $httpd = 'Alias /softaculous '.$globals['wwwsoft'].'/ <Directory /var/softwww> AddType application/x-httpd-php .php .php3 .php4 .phtml php_admin_value upload_tmp_dir /tmp php_admin_value open_basedir none php_admin_value include_path .:.. php_admin_value session.save_path /tmp php_admin_value safe_mode off DirectoryIndex index.php <IfModule authz_core_module> Require all granted </IfModule> </Directory>'; $fp = fopen($apachedir.'/softaculous.conf', 'w'); if(!$fp){ echo 'Could not open Apache Configuration File for editing'; exit(1); } //Were there any errors if(@fwrite($fp, $httpd) === FALSE){ echo 'There was some error in saving the Apache Configuration.'; exit(1); } @fclose($fp); @shell_exec($apachectl.' -k graceful'); } } else { echo 'Cannot configure Apache. Could not load ISPMGR Configuration file '.$globals['ispconfd'].'/apache.conf for system information'; } // Is it nginx ? $nginxdir = '/etc/nginx/vhosts-includes'; if(is_dir($nginxdir)){ // Configure nginx if(!file_exists($nginxdir.'/softaculous.conf')){ $httpd = 'location /softaculous { alias '.$globals['wwwsoft'].'; index index.php; } location ~* ^/softaculous/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { alias '.$globals['wwwsoft'].'/$1; error_page 404 @apache; } location ~ ^/softaculous/(.+\.php)$ { alias '.$globals['wwwsoft'].'/$1; fastcgi_pass unix:/var/run/php-fpm.'.(file_exists('/etc/redhat-release') ? 'apache' : 'www-data').'.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $request_filename; include fastcgi_params; error_page 502 = @apache; error_page 404 = @apache; } location @apache { error_log /dev/null crit; proxy_pass http://127.0.0.1:8080; proxy_redirect http://127.0.0.1:8080 /; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; }'; $fp = fopen($nginxdir.'/softaculous.conf', 'w'); if(!$fp){ echo 'Could not open NGINX Configuration File for editing'; exit(1); } //Were there any errors if(@fwrite($fp, $httpd) === FALSE){ echo 'There was some error in saving the NGINX Configuration.'; exit(1); } @fclose($fp); @shell_exec('service nginx reload'); } } } function pre_ispconfig(){ ins_is_vps(); } function post_ispconfig(){ global $globals, $remote_details; // Build the binary if(!makebinary_ispconfig()){ die('Unable to compile the binary file'); } // Store the Remote Details writefile($globals['path'].'/remote', $remote_details, 1); @chmod($globals['path'].'/remote', 0600); // Change owner @shell_exec('chown -R ispconfig:ispconfig '.$globals['path']); @shell_exec('chown -R ispconfig:ispconfig '.$globals['softscripts']); chowngrp($globals['path'], 'ispconfig', 'ispconfig', 1); chowngrp($globals['softscripts'], 'ispconfig', 'ispconfig', 1); @mkdir($globals['wwwsoft'], 0755); // check the os if(is_dir('/etc/apache2/conf.d') || is_dir('/etc/apache2/conf-enabled')){ $apache_processor = 'www-data'; $os = 'debian'; }else{ $apache_processor = 'apache'; $os = 'centos'; } // chown according to apache user @chowngrp($globals['wwwsoft'], $apache_processor, $apache_processor); @shell_exec('chown -R '.$apache_processor.':'.$apache_processor.' '.$globals['wwwsoft']); // Copy the www files copy($globals['path'].'/ispconfig/index.php', $globals['wwwsoft'].'/index.php'); // Create Necessary links @shell_exec('ln -s '.$globals['enduser'].'/softimages '.$globals['wwwsoft'].'/softimages'); @shell_exec('ln -s '.$globals['enduser'].'/themes '.$globals['wwwsoft'].'/themes'); @shell_exec('ln -s '.$globals['path'].'/load.php '.$globals['ispconfig_webroot'].'/softaculous.php'); // Make the Softaculous Temporary directory @mkdir('/var/softtmp', 0700); // chown according to apache user @chowngrp('/var/softtmp', $apache_processor, $apache_processor); @shell_exec('chown -R '.$apache_processor.':'.$apache_processor.' /var/softtmp'); // Create Link in ISPConfig Panel $create_menu = '<?php // Created by Softaculous Installer at '.date('Y-m-d H:i:s').' $items[] = array( \'title\' => \'Softaculous\', \'target\' => \'_blank\', \'link\' => (!empty($_SERVER[\'HTTPS\']) ? \'https://\' : \'http://\').((empty($_SERVER[\'SERVER_NAME\']) || $_SERVER[\'SERVER_NAME\'] == \'_\') ? $_SERVER[\'SERVER_ADDR\'] : $_SERVER[\'SERVER_NAME\']).\':8080/softaculous\'); $module[\'nav\'][] = array( \'title\' => \'Auto Installer\', \'open\' => 1, \'items\' => $items); unset($items); ?>'; writefile('/usr/local/ispconfig/interface/web/tools/lib/menu.d/softaculous.menu.php', $create_menu, 1); @chmod('/usr/local/ispconfig/interface/web/tools/lib/menu.d/softaculous.menu.php', 0750); @chowngrp('/usr/local/ispconfig/interface/web/tools/lib/menu.d/softaculous.menu.php', 'ispconfig', 'ispconfig', 1); if($apache_processor == 'www-data'){ $conffile = '/etc/apache2/conf.d/softaculous.conf'; if(is_dir('/etc/apache2/conf-enabled')){ $conffile = '/etc/apache2/conf-enabled/softaculous.conf'; // Change the content of the file as it is necessary to work on Ubuntu 14 $f_content = file_get_contents($globals['path'].'/ispconfig/softaculous.conf'); $f_content = preg_replace("/(\s+)Order Allow,Deny(\s+)Allow from all/is", "\n\tRequire all granted", $f_content); writefile($globals['path'].'/ispconfig/softaculous.conf', $f_content, 1); } }else{ $apache_data = shell_exec('httpd -v'); preg_match('/Apache\/(.*?) \(/is', $apache_data, $matches); $apache_version = $matches[1]; if(version_compare($apache_version, '2.4', '>=')){ // Change the content of the file as it is necessary to work on Apache 2.4 $f_content = file_get_contents($globals['path'].'/ispconfig/softaculous.conf'); $f_content = preg_replace("/(\s+)Order Allow,Deny(\s+)Allow from all/is", "\n\tRequire all granted", $f_content); writefile($globals['path'].'/ispconfig/softaculous.conf', $f_content, 1); } $conffile = '/etc/httpd/conf.d/softaculous.conf'; } // softaculous.conf @shell_exec('ln -s '.$globals['path'].'/ispconfig/softaculous.conf '.$conffile); } function pre_remote(){ define('SOFTINSTALLER', 1); } function middle_remote(){ } function post_remote(){ global $argv, $globals, $apikey, $apipass; shell_exec('ln -s '.$globals['path'].'/conf/remote/emps/my.cnf /usr/local/emps/etc/my.cnf'); shell_exec('ln -s '.$globals['path'].'/conf/remote/emps/php.ini /usr/local/emps/etc/php.ini'); shell_exec('ln -s '.$globals['path'].'/conf/remote/emps/php-fpm.conf /usr/local/emps/etc/php-fpm.conf'); shell_exec('ln -s '.$globals['path'].'/conf/remote/emps/nginx.conf /usr/local/emps/etc/nginx/nginx.conf'); shell_exec('ln -s '.$globals['path'].'/conf/remote/emps/emps /etc/init.d/remote'); shell_exec('ln -s '.$globals['path'].'/enduser/themes '.$globals['path'].'/enduser/remote/themes'); shell_exec('ln -s '.$globals['path'].'/enduser/softimages '.$globals['path'].'/enduser/remote/softimages'); @chmod('/etc/init.d/remote', 0755); shell_exec('cd /usr/local/emps; /usr/local/emps/bin/mysqlctl start > /dev/null 2>&1'); $mypass = generateRandStr(16); $myfile = $globals['path'].'/conf/myconf'; ins_writefile($myfile, $mypass, 1); chmod($myfile, 0600); shell_exec('/usr/local/emps/bin/mysqladmin --no-defaults -u root password '.$mypass); $host = 'localhost'; $db = 'softaculous'; $conn = mysql_connect($host, 'root', $mypass); mysql_query('CREATE DATABASE '.$db.'', $conn); shell_exec('/usr/local/emps/bin/mysql -u root -p\''.$mypass.'\' '.$db.' < /usr/local/softaculous/softaculous.sql'); //generate API Key $apikey = generateRandStr(16); $apipass = generateRandStr(32); // Default Email $data = array('email' => 'admin@'.trim(shell_exec('hostname'))); // Insert Root user mysql_query("INSERT INTO ".$db.".users SET owner = 'root', username = 'root', api_key = '".$apikey."', api_pass = '".$apipass."', num_users = '0', replace_path = '', data = '".addslashes(serialize($data))."'", $conn); $args['log'] = '/var/log/softaculous_remote.log'; //=========================== // SSL Certificates //=========================== echo "Generating the SSL Certificates\n"; $hostname = shell_exec('hostname'); $hostname = trim($hostname); shell_exec('/usr/local/emps/bin/openssl genrsa -out /usr/local/softaculous/conf/remote/softaculous.key 1024 >> '.$args['log'].' 2>&1'); shell_exec('/usr/local/emps/bin/openssl req -subj /C=US/ST=Berkshire/L=Newbury/O=\'My Company\'/CN=\''.$hostname.'\'/emailAddress=a@a.com -new -key /usr/local/softaculous/conf/remote/softaculous.key -out /usr/local/softaculous/conf/remote/softaculous.csr >> '.$args['log'].''); shell_exec('/usr/local/emps/bin/openssl x509 -req -days 365 -in /usr/local/softaculous/conf/remote/softaculous.csr -signkey /usr/local/softaculous/conf/remote/softaculous.key -out /usr/local/softaculous/conf/remote/softaculous.crt >> '.$args['log'].' 2>&1'); // Make a Fake file for the moment shell_exec('echo "" >> /usr/local/softaculous/conf/remote/softaculous-bundle.crt'); shell_exec('/etc/init.d/remote restart > '.$args['log'].' 2>&1'); shell_exec('chkconfig remote on > '.$args['log'].' 2>&1'); // Create the directory for logs @mkdir($globals['softscripts'].'/logs', 0700); @chmod($globals['softscripts'].'/logs', 0700); chowngrp($globals['softscripts'].'/logs', 'emps', 'emps', 1); // Create the directory for auto backup cron handling @mkdir($globals['softvarbackups'], 0700); @chmod($globals['softvarbackups'], 0700); chowngrp($globals['softvarbackups'], 'emps', 'emps', 1); @mkdir($globals['softvarbackups'].'/crontabs', 0700); @chmod($globals['softvarbackups'].'/crontabs', 0700); chowngrp($globals['softvarbackups'].'/crontabs', 'emps', 'emps', 1); @mkdir($globals['softvarbackups'].'/backups_todo', 0700); @chmod($globals['softvarbackups'].'/backups_todo', 0700); chowngrp($globals['softvarbackups'].'/backups_todo', 'emps', 'emps', 1); @mkdir('/home/emps', 0755); @chmod('/home/emps', 0755); chowngrp('/home/emps', 'emps', 'emps', 1); // Create the directory for split (for splitting the package and installing) @mkdir($globals['softscripts'].'/split', 0755); @chmod($globals['softscripts'].'/split', 0755); chowngrp($globals['softscripts'].'/split', 'emps', 'emps'); // We need to chown the file to emps so that we can read it chowngrp($globals['path'].'/conf/myconf', 'emps', 'emps'); // Copy the logrotate file if(file_exists('/usr/local/emps/etc/emps_logrotate')){ // We need to copy as logrotate does not work with symlink @copy('/usr/local/emps/etc/emps_logrotate', '/etc/logrotate.d/emps'); // We need to set the permissions as 0644 otherwise logrotate will not work @chmod('/etc/logrotate.d/emps', 0644); } } function pre_enterprise(){ define('SOFTINSTALLER', 1); } function middle_enterprise(){ } function post_enterprise(){ global $argv, $globals, $apikey, $apipass; if(empty($globals['ent_db'])){ shell_exec('ln -s '.$globals['path'].'/conf/ent/emps/my.cnf /usr/local/emps/etc/my.cnf'); shell_exec('ln -s '.$globals['path'].'/conf/ent/emps/php.ini /usr/local/emps/etc/php.ini'); shell_exec('ln -s '.$globals['path'].'/conf/ent/emps/php-fpm.conf /usr/local/emps/etc/php-fpm.conf'); shell_exec('ln -s '.$globals['path'].'/conf/ent/emps/nginx.conf /usr/local/emps/etc/nginx/nginx.conf'); shell_exec('ln -s '.$globals['path'].'/conf/ent/emps/emps /etc/init.d/softaculous'); @chmod('/etc/init.d/softaculous', 0755); shell_exec('cd /usr/local/emps; /usr/local/emps/bin/mysqlctl start > /dev/null 2>&1'); $_mypass = generateRandStr(16); $myfile = $globals['path'].'/conf/myconf'; ins_writefile($myfile, $_mypass, 1); chmod($myfile, 0600); shell_exec('/usr/local/emps/bin/mysqladmin --no-defaults -u root password '.$_mypass); } shell_exec('ln -s '.$globals['path'].'/enduser/themes '.$globals['path'].'/enduser/ent/themes'); shell_exec('ln -s '.$globals['path'].'/enduser/softimages '.$globals['path'].'/enduser/ent/softimages'); // Database Details $host = !empty($globals['ent_dbhost']) ? $globals['ent_dbhost'] : 'localhost'; $db = !empty($globals['ent_db']) ? $globals['ent_db'] : 'softaculous'; $myuser = !empty($globals['ent_dbuser']) ? $globals['ent_dbuser'] : 'root'; $mypass = !empty($globals['ent_dbuserpass']) ? $globals['ent_dbuserpass'] : $_mypass; $conn = mysql_connect($host, $myuser, $mypass); mysql_query('CREATE DATABASE IF NOT EXISTS '.$db, $conn); $mysql_bin = !empty($globals['ent_db']) ? 'mysql' : '/usr/local/emps/bin/mysql'; shell_exec($mysql_bin.' -u root -p\''.$mypass.'\' '.$db.' < /usr/local/softaculous/softaculous.sql'); //generate API Key $apikey = generateRandStr(16); $apipass = generateRandStr(32); // Default Email $data = array('email' => 'admin@'.trim(shell_exec('hostname'))); // Insert Root user mysql_query("INSERT INTO ".$db.".users SET owner = 'root', username = 'root', api_key = '".$apikey."', api_pass = '".$apipass."', num_users = '0', replace_path = '', _uid = '0', _gid = '0', data = '".addslashes(serialize($data))."'", $conn); $args['log'] = '/var/log/softaculous_enterprise.log'; if(empty($globals['ent_db'])){ //=========================== // SSL Certificates //=========================== echo "Generating the SSL Certificates\n"; $hostname = shell_exec('hostname'); $hostname = trim($hostname); shell_exec('/usr/local/emps/bin/openssl genrsa -out /usr/local/softaculous/conf/ent/softaculous.key 1024 >> '.$args['log'].' 2>&1'); shell_exec('/usr/local/emps/bin/openssl req -subj /C=US/ST=Berkshire/L=Newbury/O=\'My Company\'/CN=\''.$hostname.'\'/emailAddress=a@a.com -new -key /usr/local/softaculous/conf/ent/softaculous.key -out /usr/local/softaculous/conf/ent/softaculous.csr >> '.$args['log'].''); shell_exec('/usr/local/emps/bin/openssl x509 -req -days 365 -in /usr/local/softaculous/conf/ent/softaculous.csr -signkey /usr/local/softaculous/conf/ent/softaculous.key -out /usr/local/softaculous/conf/ent/softaculous.crt >> '.$args['log'].' 2>&1'); // Make a Fake file for the moment shell_exec('echo "" >> /usr/local/softaculous/conf/ent/softaculous-bundle.crt'); shell_exec('/etc/init.d/softaculous restart > '.$args['log'].' 2>&1'); shell_exec('chkconfig softaculous on > '.$args['log'].' 2>&1'); } // Create the directory for logs @mkdir($globals['softscripts'].'/logs', 0700); @chmod($globals['softscripts'].'/logs', 0700); // Create the directory for auto backup cron handling @mkdir($globals['softvarbackups'], 0700); @chmod($globals['softvarbackups'], 0700); chowngrp($globals['softvarbackups'], 'emps', 'emps', 1); @mkdir($globals['softvarbackups'].'/crontabs', 0700); @chmod($globals['softvarbackups'].'/crontabs', 0700); chowngrp($globals['softvarbackups'].'/crontabs', 'emps', 'emps', 1); @mkdir($globals['softvarbackups'].'/backups_todo', 0700); @chmod($globals['softvarbackups'].'/backups_todo', 0700); chowngrp($globals['softvarbackups'].'/backups_todo', 'emps', 'emps', 1); @mkdir('/home/emps', 0755); @chmod('/home/emps', 0755); chowngrp('/home/emps', 'emps', 'emps', 1); // Copy the logrotate file if(file_exists('/usr/local/emps/etc/emps_logrotate')){ // We need to copy as logrotate does not work with symlink @copy('/usr/local/emps/etc/emps_logrotate', '/etc/logrotate.d/emps'); // We need to set the permissions as 0644 otherwise logrotate will not work @chmod('/etc/logrotate.d/emps', 0644); } } function pre_cwp(){ ins_is_vps(); } function middle_cwp(){ if(file_exists('/usr/local/cwp/php71')){ @shell_exec('ln -s /usr/local/cwp/php71/ /usr/local/cwp/php'); }else{ @shell_exec('ln -s /usr/local/cwp/php54/ /usr/local/cwp/php'); } } function post_cwp(){ global $globals, $softpanel; @mkdir($globals['wwwsoft'], 0755); // Create Necessary links @shell_exec('ln -s '.$globals['enduser'].'/softimages '.$globals['wwwsoft'].'/softimages'); @shell_exec('ln -s '.$globals['enduser'].'/themes '.$globals['wwwsoft'].'/themes'); if(is_dir('/usr/local/cwpsrv/var/services/users')){ @shell_exec('ln -s /usr/local/cwpsrv/var/services/users/softaculous /usr/local/cwp/softaculous'); } // Make the Softaculous Temporary directory if(is_dir('/usr/local/cwpsrv/var/services/users')){ //@mkdir('/var/softtmp', 0777); //It will run as a user //@chmod('/var/softtmp', 0777); //It will run as a user }else{ @mkdir('/var/softtmp', 0600); @chmod('/var/softtmp', 0600); } // we have to change the admin email as on some server it was set as admin@ if(method_exists($softpanel, 'server_email')){ $globals['soft_email'] = $softpanel->server_email(); ins_saveglobals($globals); } // Detect if the server is VPS if(method_exists($softpanel, 'is_vps')){ $is_vps = $softpanel->is_vps(); if(!empty($is_vps)){ $globals['is_vps'] = 1; ins_saveglobals($globals); } } copy($globals['path'].'/cwp/index.php', $globals['wwwsoft'].'/index.php'); if(is_dir('/usr/local/cwpsrv/var/services/users')){ copy($globals['path'].'/cwp/softaculous.php', '/usr/local/cwpsrv/var/services/user_files/modules/softaculous.php'); @shell_exec('sh /scripts/install_api'); } // softaculous.conf // If it is the new structure of CWP with NGINX if(is_dir('/usr/local/cwpsrv/htdocs/admin/admin/')){ @shell_exec('ln -s '.$globals['path'].'/cwp/softaculous_nginx.conf /usr/local/cwpsrv/conf/include/softaculous.conf'); }else{ @shell_exec('ln -s '.$globals['path'].'/cwp/softaculous.conf /usr/local/cwpsrv/conf.d/softaculous.conf'); } @shell_exec('service cwpsrv restart'); } function pre_vesta(){ global $globals, $softpanel; // Create a random API key $api_key = vesta_randstr(32); @mkdir($globals['path'].'/conf', 0755); @shell_exec('echo '.$api_key.' > '.$globals['path'].'/conf/.api_key'); ins_is_vps(); } function middle_vesta(){ } function post_vesta(){ global $globals, $softpanel; // We need this in post because we perform a 0755 recursive after pre_vesta() @shell_exec('chmod 0600 '.$globals['path'].'/conf/.api_key'); @mkdir($globals['wwwsoft'], 0755); // Create Necessary links @shell_exec('ln -s '.$globals['enduser'].'/softimages '.$globals['wwwsoft'].'/softimages'); @shell_exec('ln -s '.$globals['enduser'].'/themes '.$globals['wwwsoft'].'/themes'); // Make the Softaculous Temporary directory @mkdir('/var/softtmp', 0700); @shell_exec('chown admin:admin /var/softtmp'); // we have to change the admin email as on some server it was set as admin@ if(method_exists($softpanel, 'server_email')){ $globals['soft_email'] = $softpanel->server_email(); ins_saveglobals($globals); } copy($globals['path'].'/vesta/index.php', $globals['wwwsoft'].'/index.php'); } function pre_hc(){ global $globals, $argv; //Grant Permissions to Softaculous directory @exec('icacls "'.$globals['hc_softpath'].'" /grant Everyone:(OI)(CI)F /T', $pret, $perr); //Copy the auth directory from the package outside setup directory if(!is_dir($globals['auth_dir'])){ @mkdir($globals['auth_dir']); } @copy($globals['path'].'/hc/home.php', $globals['auth_dir'].'/home.php'); @copy($globals['path'].'/hc/index.html', $globals['auth_dir'].'/index.html'); @copy($globals['path'].'/hc/index.php', $globals['auth_dir'].'/index.php'); @copy($globals['path'].'/hc/logout.php', $globals['auth_dir'].'/logout.php'); @copy($globals['path'].'/hc/web.config', $globals['auth_dir'].'/web.config'); } function post_hc(){ global $globals, $softpanel, $argv; // Store the API URL writefile($globals['path'].'/conf/apiurl', $globals['hc_apiurl'], 1); schmod($globals['path'].'/conf/apiurl', 0600); //Copy themes and softimages in the auth directory. We cannot create the links on Windows. if(method_exists($softpanel, 'upgrade')){ $softpanel->upgrade(); } //Add APP POOL @exec('cd %windir%\system32\inetsrv && appcmd add apppool /name:"Softaculous Auto Installer"', $apout, $apret); if(in_array('debug', $argv)){ echo '<br />Adding an Application Pool'; print_r($apout); print_r($apret); } //Assigning identity to the Softaculous APP POOL @exec('cd %windir%\system32\inetsrv && appcmd set config /section:applicationPools /"[name=\'Softaculous Auto Installer\']".processModel.identityType:LocalSystem', $idout, $idret); if(in_array('debug', $argv)){ echo '<br />Assigning Identity to APP Pool'; print_r($idout); print_r($idret); } //List of Websites added $sites_list = shell_exec('cd %windir%\system32\inetsrv && appcmd list site'); //Check Site ID duplicacy $ids = array(); soft_preg_replace_all('/\(id:(.*?),/is', $sites_list, $ids, 1); $rand_id = rand(1000, 99999); for($i = 0; $i < 10; $i++){ if(in_array($rand_id, $ids)){ $rand_id = rand(1000, 99999); }else{ break; } } //We are doing this because on windows, directories are separated by '\' instead of '/' which creates issues after the site creation on accessing Softaculous. $auth_dir = str_replace('/', '\\', $globals['auth_dir']); //Add Site @exec('cd %windir%\system32\inetsrv && appcmd add site /name:"Softaculous Auto Installer Site" /id:'.$rand_id.' /physicalPath:"'.$auth_dir.'" /bindings:http://:8077', $sout, $sret); if(in_array('debug', $argv)){ echo '<br />Adding Website'; print_r($sout); print_r($sret); } //Adding index.php in the Default Documents List of the site @exec('cd %windir%\system32\inetsrv && appcmd.exe set config "Softaculous Auto Installer Site" /section:defaultDocument /enabled:true /+files.[value=\'index.php\']', $ddout, $ddret); if(in_array('debug', $argv)){ echo '<br />Updating Default Documents List'; print_r($ddout); print_r($ddret); } //Assign the Website to the above APP Pool @exec('cd %windir%\system32\inetsrv && appcmd set site "Softaculous Auto Installer Site" /"[path=\'/\']".applicationPool:"Softaculous Auto Installer"', $waout, $waret); if(in_array('debug', $argv)){ echo '<br />Assigning Softaculous Website to the Softaculous APP Pool'; print_r($waout); print_r($waret); } //Changing Anonymous Authentication for Softaculous Site to that of Application Pool Identity @exec('cd %windir%\system32\inetsrv && appcmd set config "Softaculous Auto Installer Site" /section:anonymousAuthentication /userName: /commit:apphost', $authop, $autherr); if(in_array('debug', $argv)){ echo '<br />Changing Anonymous Authentication for Softaculous Site to that of Application Pool Identity: '; print_r($authop); print_r($autherr); } //Assigning PHP Handler Mapping to the Website $php_bin = str_replace('"', '\"', str_replace('php.exe', 'php-cgi.exe', $globals['php_bin'])); if(!file_exists(trim($php_bin, '\"'))){ echo "\nPlease set the correct PHP Handler Mapping for Softaculous website on your server before proceeding!!"; }else{ @exec('cd %windir%\system32\inetsrv && appcmd set config "Softaculous Auto Installer Site" -section:system.webServer/handlers /+"[name=\'PHP_via_FastCGI\',path=\'*.php\',verb=\'*\',modules=\'FastCgiModule\',scriptProcessor='.$php_bin.',resourceType=\'File\']" /commit:apphost', $mapop, $maperr); if(in_array('debug', $argv)){ echo '<br />Assigning PHP Handler Mapping to the Softaculous Website: '; print_r($mapop); print_r($maperr); } } } //We want the install.inc file to be mandatorily deleted after the installation ends and when not in debugging mode. if(!in_array('debug', $argv)){ unlink(__FILE__); } ?>