$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('+' => '-', '/' => '_', '=' => '')); } ?>