1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 07:36:44 +02:00

Use PHP 5.3 functions

This commit is contained in:
Jakub Vrana
2025-03-05 15:45:37 +01:00
parent 0bf8861dd1
commit c873ceba17
4 changed files with 5 additions and 21 deletions

View File

@@ -19,7 +19,7 @@ function email_header($header) {
* @return bool
*/
function send_mail($email, $subject, $message, $from = "", $files = array()) {
$eol = (DIRECTORY_SEPARATOR == "/" ? "\n" : "\r\n"); // PHP_EOL available since PHP 5.0.2
$eol = PHP_EOL;
$message = str_replace("\n", $eol, wordwrap(str_replace("\r", "", "$message\n")));
$boundary = uniqid("boundary");
$attachments = "";

View File

@@ -15,7 +15,7 @@ if (isset($_GET["clickhouse"])) {
'method' => 'POST',
'content' => $this->isQuerySelectLike($query) ? "$query FORMAT JSONCompact" : $query,
'header' => 'Content-type: application/x-www-form-urlencoded',
'ignore_errors' => 1, // available since PHP 5.2.10
'ignore_errors' => 1,
'follow_location' => 0,
'max_redirects' => 0,
))));

View File

@@ -21,7 +21,7 @@ if (isset($_GET["elastic5"])) {
'method' => $method,
'content' => $content !== null ? json_encode($content) : $content,
'header' => $content !== null ? 'Content-Type: application/json' : array(),
'ignore_errors' => 1, // available since PHP 5.2.10
'ignore_errors' => 1,
'follow_location' => 0,
'max_redirects' => 0,
))));

View File

@@ -391,22 +391,6 @@ if (isset($_GET["simpledb"])) {
function last_id() {
}
function hmac($algo, $data, $key, $raw_output = false) {
// can use hash_hmac() since PHP 5.1.2
$blocksize = 64;
if (strlen($key) > $blocksize) {
$key = pack("H*", $algo($key));
}
$key = str_pad($key, $blocksize, "\0");
$k_ipad = $key ^ str_repeat("\x36", $blocksize);
$k_opad = $key ^ str_repeat("\x5C", $blocksize);
$return = $algo($k_opad . pack("H*", $algo($k_ipad . $data)));
if ($raw_output) {
$return = pack("H*", $return);
}
return $return;
}
function sdb_request($action, $params = array()) {
$adminer = adminer();
$connection = connection();
@@ -422,11 +406,11 @@ if (isset($_GET["simpledb"])) {
$query .= '&' . rawurlencode($key) . '=' . rawurlencode($val);
}
$query = str_replace('%7E', '~', substr($query, 1));
$query .= "&Signature=" . urlencode(base64_encode(hmac('sha1', "POST\n" . preg_replace('~^https?://~', '', $host) . "\n/\n$query", $secret, true)));
$query .= "&Signature=" . urlencode(base64_encode(hash_hmac('sha1', "POST\n" . preg_replace('~^https?://~', '', $host) . "\n/\n$query", $secret, true)));
$file = @file_get_contents((preg_match('~^https?://~', $host) ? $host : "http://$host"), false, stream_context_create(array('http' => array(
'method' => 'POST', // may not fit in URL with GET
'content' => $query,
'ignore_errors' => 1, // available since PHP 5.2.10
'ignore_errors' => 1,
'follow_location' => 0,
'max_redirects' => 0,
))));