$fp = fopen('/dev/urandom', 'rb'); if ($fp) { if (function_exists('stream_set_read_buffer')) { stream_set_read_buffer($fp, 0); } $sha = fread($fp, $length); fclose($fp); } } for ($i = 0; $i < $length; $i++) { $sha = hash('sha256', $sha . mt_rand(), true); $rnd .= $sha[mt_rand(0, 31)]; } return $rnd; } $options['secretkey'] = base64_encode(secure_rand(42)); } elseif (strlen($options['secretkey']) > 56) { $options['secretkey'] = base64_encode(sha1($options['secretkey'])); } $opt = var_export($options, true); $opt = strpos($opt, "\r\n") === false ? str_replace(array("\r", "\n"), "\r\n", $opt) : $opt; $opt = "<?php\r\nif (!defined('RAPIDLEECH')) {\r\n\trequire_once('index.html');\r\n\texit;\r\n}\r\n\r\n\$options = {$opt}; \r\n\r\nrequire_once('site_checker.php');\r\nrequire_once('accounts.php');\r\n\r\n\$secretkey = \$options['secretkey'];\r\n?>"; if (!@write_file(CONFIG_DIR . "config.php", $opt, 1)) { echo '<div class="div_error">It was not possible to write the configuration<br />Set permissions of "configs" folder to 0777 and try again</div>'; } else { if (is_file(CONFIG_DIR . 'config_old.php')) { if (@(!unlink(CONFIG_DIR . 'config_old.php')) && is_file(CONFIG_DIR . 'config_old.php')) { '<div class="div_message">It was not possible to delete the old configuration.<br />Manually delete "configs/config_old.php"</div><br />'; } } echo '<div class="div_message">Configuration saved! Click <a href="' . $PHP_SELF . '">here</a> to continue to rapidleech</div>';
function get_rand($bytes) { return hexdec(bin2hex(secure_rand($bytes))); }