| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
require_once(INCLUDEPATH . '/class.config.php'); |
|---|
| 22 |
|
|---|
| 23 |
if (@file_exists('/usr/local/etc/ispcp/ispcp.conf')) { |
|---|
| 24 |
$cfgfile = '/usr/local/etc/ispcp/ispcp.conf'; |
|---|
| 25 |
} |
|---|
| 26 |
else { |
|---|
| 27 |
$cfgfile = '/etc/ispcp/ispcp.conf'; |
|---|
| 28 |
} |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
try { |
|---|
| 32 |
Config::load($cfgfile); |
|---|
| 33 |
} catch (Exception $e) { |
|---|
| 34 |
die('<div style="text-align: center; color: red; font-weight: strong;">' . $e->getMessage() . '<br />Please contact your system administrator</div>'); |
|---|
| 35 |
} |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
function decrypt_db_password ($db_pass) { |
|---|
| 39 |
global $ispcp_db_pass_key, $ispcp_db_pass_iv; |
|---|
| 40 |
|
|---|
| 41 |
if ($db_pass == '') |
|---|
| 42 |
return ''; |
|---|
| 43 |
|
|---|
| 44 |
if (extension_loaded('mcrypt') || @dl('mcrypt.' . PHP_SHLIB_SUFFIX)) { |
|---|
| 45 |
$text = @base64_decode($db_pass . "\n"); |
|---|
| 46 |
|
|---|
| 47 |
$td = @mcrypt_module_open ('blowfish', '', 'cbc', ''); |
|---|
| 48 |
|
|---|
| 49 |
$key = $ispcp_db_pass_key; |
|---|
| 50 |
|
|---|
| 51 |
$iv = $ispcp_db_pass_iv; |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
@mcrypt_generic_init ($td, $key, $iv); |
|---|
| 55 |
|
|---|
| 56 |
$decrypted = @mdecrypt_generic ($td, $text); |
|---|
| 57 |
@mcrypt_module_close ($td); |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
return trim($decrypted); |
|---|
| 61 |
} else { |
|---|
| 62 |
system_message("ERROR: The php-extension 'mcrypt' not loaded!"); |
|---|
| 63 |
die(); |
|---|
| 64 |
} |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
function encrypt_db_password($db_pass){ |
|---|
| 68 |
global $ispcp_db_pass_key, $ispcp_db_pass_iv; |
|---|
| 69 |
|
|---|
| 70 |
if (extension_loaded('mcrypt') || @dl('mcrypt.' . PHP_SHLIB_SUFFIX)) { |
|---|
| 71 |
$td = @mcrypt_module_open (MCRYPT_BLOWFISH, '', 'cbc', ''); |
|---|
| 72 |
|
|---|
| 73 |
$key = $ispcp_db_pass_key; |
|---|
| 74 |
|
|---|
| 75 |
$iv = $ispcp_db_pass_iv; |
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
$block_size=@mcrypt_enc_get_block_size($td); |
|---|
| 79 |
$strlen=strlen($db_pass); |
|---|
| 80 |
|
|---|
| 81 |
$pads=$block_size-$strlen % $block_size; |
|---|
| 82 |
|
|---|
| 83 |
for ($i=0; $i<$pads;$i++){ |
|---|
| 84 |
$db_pass.=" "; |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
@mcrypt_generic_init ($td, $key, $iv); |
|---|
| 88 |
|
|---|
| 89 |
$encrypted = @mcrypt_generic ($td, $db_pass); |
|---|
| 90 |
@mcrypt_generic_deinit($td); |
|---|
| 91 |
@mcrypt_module_close($td); |
|---|
| 92 |
|
|---|
| 93 |
$text = @base64_encode("$encrypted"); |
|---|
| 94 |
$text=trim($text); |
|---|
| 95 |
return $text; |
|---|
| 96 |
} else { |
|---|
| 97 |
|
|---|
| 98 |
die("ERROR: The php-extension 'mcrypt' not loaded!"); |
|---|
| 99 |
} |
|---|
| 100 |
} |
|---|
| 101 |
|
|---|
| 102 |
?> |
|---|