%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/proc/self/root/proc/self/root/var/softaculous/backdrop/
Upload File :
Create Path :
Current File : //proc/self/root/proc/self/root/proc/self/root/var/softaculous/backdrop/_clone.php

<?php

//////////////////////////////////////////////////////////////
//===========================================================
// clone.php
//===========================================================
// SOFTACULOUS 
// Version : 4.2.8
// 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');

}

//The Install process
function __clone(){

global $__settings, $error, $software, $globals, $replace_data, $source_data;
	
	//Do we meet the Minimum software requirements
	__requirements();
	
	if(!empty($error)){
		return false;
	}
	
	$temp = parse_url($source_data['softurl']);
	$source_data['relativeurl'] = $temp['path'];
	
	$temp = parse_url($__settings['softurl']);
	$__settings['relativeurl'] = $temp['path'];
	
	$database = 'mysql://'.$__settings['softdbuser'].':'.$__settings['softdbpass'].'@'.$__settings['softdbhost'].'/'.$__settings['softdb'].'';
	$__settings['dbmd5'] = md5($database);
	
	$__settings['css_js_query_string'] = serialize(base_convert((int) $_SERVER['REQUEST_TIME'], 10, 36));
	$__settings['backdrop_private_key'] = serialize(srandstr(43));
	
	// settings.php
	$file = sfile($__settings['softpath'].'/settings.php');
	
	if(empty($file)){
		$error[] = 'Could not read the config file.';
		return false;
	}
	
	soft_preg_replace('/\$database_prefix(\s*?)=(\s*?)(\'|")(.*?)(\'|");/is', $file, $__settings['dbprefix'], 4);
	
	soft_preg_replace('/\/files\/config_(.*?)\//is', $file, $dbmd5, 1);
	
	$replace_data[$dbmd5] = $__settings['dbmd5'];
	
	soft_preg_replace('/\$settings\[(\'|")hash_salt(\'|")\](\s*?)=(\s*?)(\'|")(.*?)(\'|");/is', $file, $hash_salt, 6);
	
	$replace_data[$hash_salt] = __backdrop_base64_encode(__backdrop_random_bytes(32));
	
	// this is to stop database name replace with relativeurl
	if(!empty($source_data['relativeurl'])){
		$tmp = $replace_data[$source_data['relativeurl']];
		unset($replace_data[$source_data['relativeurl']]);
		sclone_replace($replace_data, $__settings['softpath'].'/settings.php', true);
		$replace_data[$source_data['relativeurl']] = $tmp;
	}else{
		sclone_replace($replace_data, $__settings['softpath'].'/settings.php', true);
	}

	//Rename Folder
	@srename($__settings['softpath'].'/files/config_'.$dbmd5.'/', $__settings['softpath'].'/files/config_'.$__settings['dbmd5'].'/');
	
	$truncate_tables = array('batch', 'cache', 'cache_admin_bar', 'cache_bootstrap', 'cache_entity_comment', 'cache_entity_file', 'cache_entity_node', 'cache_entity_taxonomy_term', 'cache_entity_user', 'cache_field', 'cache_filter', 'cache_layout_path', 'cache_menu', 'cache_page', 'cache_path', 'cache_token', 'cache_update', 'cache_views',  'cache_views_data', 'tempstore', 'watchdog');
	
	foreach($truncate_tables as $tk => $tv){
		$truncate = "TRUNCATE TABLE ".$__settings['dbprefix'].$tv.";";
		sdb_query($truncate, $__settings['softdbhost'], $__settings['softdbuser'], $__settings['softdbpass'], $__settings['softdb'], '', 1);
		
	}

	$query = "UPDATE `".$__settings['dbprefix']."state` SET `value`='".$__settings['ser_cron_key']."' WHERE `name` = 'cron_key';";
	sdb_query($query, $__settings['softdbhost'], $__settings['softdbuser'], $__settings['softdbpass'], $__settings['softdb']);
	
	$query = "UPDATE `".$__settings['dbprefix']."state` SET `value`='".$__settings['css_js_query_string']."' WHERE `name` = 'css_js_query_string';";
	sdb_query($query, $__settings['softdbhost'], $__settings['softdbuser'], $__settings['softdbpass'], $__settings['softdb']);
	
	$query = "UPDATE `".$__settings['dbprefix']."state` SET `value`='".$__settings['backdrop_private_key']."' WHERE `name` = 'private_key';";
	sdb_query($query, $__settings['softdbhost'], $__settings['softdbuser'], $__settings['softdbpass'], $__settings['softdb']);
	
	$query = "SELECT filename, info FROM `".$__settings['dbprefix']."system`;";
	$result = sdb_query($query, $__settings['softdbhost'], $__settings['softdbuser'], $__settings['softdbpass'], $__settings['softdb']);

	foreach($result as $row){
		$info = unserialize($row['info']);
		if(isset($info['explanation'])){
			$info['explanation'] = strtr($info['explanation'],array('href="'.$source_data['relativeurl'] => 'href="'.$__settings['relativeurl']));
			
			$query = "UPDATE `".$__settings['dbprefix']."system` SET `info`='".serialize($info)."' WHERE `filename` = '".$row['filename']."';";
			sdb_query($query, $__settings['softdbhost'], $__settings['softdbuser'], $__settings['softdbpass'], $__settings['softdb']);
		}
	}
	
	if(sfile_exists($__settings['softpath'].'/.htaccess')){
	
		// If the installation is on root domain we need to change the below relative URL
		if(is_dom_root($source_data['softpath'])){
			$replace_data['RewriteBase \'/\''] = 'RewriteBase \''.$__settings['relativeurl'].'\'';
			$replace_data['RewriteBase /'] = 'RewriteBase '.$__settings['relativeurl'];
			$replace_data['RewriteBase /backdrop'] = 'RewriteBase '.$__settings['relativeurl'].'/backdrop';
		}elseif(is_dom_root($__settings['softpath'])){
			$replace_data['RewriteBase \''.$source_data['relativeurl'].'\''] = 'RewriteBase \'/\'';
			$replace_data['RewriteBase '.$source_data['relativeurl']] = 'RewriteBase /';
			$replace_data['RewriteBase '.$source_data['relativeurl'].'/backdrop'] = 'RewriteBase /backdrop';
		}
		
		sclone_replace($replace_data, $__settings['softpath'].'/.htaccess', true);		
	}
	
	//Remove the contents
	srm($__settings['softpath'].'/files/css/');
	srm($__settings['softpath'].'/files/js/');
	
	// CHMOD
	@schmod($__settings['softpath'].'/files/', $globals['odc'], 1);
	
}

//Check whether the Minimum Software configuration matches
function __requirements(){

global $__settings, $error, $software;
	
	$__settings['rand_cron_key'] = srandstr(55);
	
	// Keep it here as we use it in install.xml 	
	if(empty($__settings['cron_key'])){
		$__settings['cron_key'] = drupal_hash_base64($__settings['rand_cron_key'], 10, 36);
		$__settings['ser_cron_key'] = serialize($__settings['cron_key']);
	}
	
	return true;

}

function __backdrop_base64_encode($string) {
  $data = base64_encode($string);
  // Modify the output so it's safe to use in URLs.
  return strtr($data, array('+' => '-', '/' => '_', '=' => ''));
}

function __backdrop_random_bytes($count)  {
  // $random_state does not use backdrop_static as it stores random bytes.
  static $random_state, $bytes, $has_openssl;

  $missing_bytes = $count - strlen($bytes);

  if ($missing_bytes > 0) {
    // PHP versions prior 5.3.4 experienced openssl_random_pseudo_bytes()
    // locking on Windows and rendered it unusable.
    if (!isset($has_openssl)) {
      $has_openssl = version_compare(PHP_VERSION, '5.3.4', '>=') && function_exists('openssl_random_pseudo_bytes');
    }

    // openssl_random_pseudo_bytes() will find entropy in a system-dependent
    // way.
    if ($has_openssl) {
      $bytes .= openssl_random_pseudo_bytes($missing_bytes);
    }

    // Else, read directly from /dev/urandom, which is available on many *nix
    // systems and is considered cryptographically secure.
    elseif ($fh = @fopen('/dev/urandom', 'rb')) {
      // PHP only performs buffered reads, so in reality it will always read
      // at least 4096 bytes. Thus, it costs nothing extra to read and store
      // that much so as to speed any additional invocations.
      $bytes .= fread($fh, max(4096, $missing_bytes));
      fclose($fh);
    }

    // If we couldn't get enough entropy, this simple hash-based PRNG will
    // generate a good set of pseudo-random bytes on any system.
    // Note that it may be important that our $random_state is passed
    // through hash() prior to being rolled into $output, that the two hash()
    // invocations are different, and that the extra input into the first one -
    // the microtime() - is prepended rather than appended. This is to avoid
    // directly leaking $random_state via the $output stream, which could
    // allow for trivial prediction of further "random" numbers.
    if (strlen($bytes) < $count) {
      // Initialize on the first call. The contents of $_SERVER includes a mix of
      // user-specific and system information that varies a little with each page.
      if (!isset($random_state)) {
        $random_state = print_r($_SERVER, TRUE);
        if (function_exists('getmypid')) {
          // Further initialize with the somewhat random PHP process ID.
          $random_state .= getmypid();
        }
        $bytes = '';
      }

      do {
        $random_state = hash('sha256', microtime() . mt_rand() . $random_state);
        $bytes .= hash('sha256', mt_rand() . $random_state, TRUE);
      }
      while (strlen($bytes) < $count);
    }
  }
  $output = substr($bytes, 0, $count);
  $bytes = substr($bytes, $count);
  return $output;
}

function drupal_hash_base64($data) {
  $hash = base64_encode(hash('sha256', $data, TRUE));
  // Modify the hash so it's safe to use in URLs.
  return strtr($hash, array('+' => '-', '/' => '_', '=' => ''));
}

?>

Zerion Mini Shell 1.0