Skip to content
This repository was archived by the owner on May 24, 2022. It is now read-only.

Use gzencode / gzdecode #130

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
/logs/*
/config.php
13 changes: 5 additions & 8 deletions app/controllers/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ public function doDbExport() {
if (x("gzip")) {
ob_end_clean();
header("Content-type: application/x-gzip");
header("Content-Disposition: attachment; filename=\"{$prefix}.gz\"");
echo gzcompress($this->contents, 9);
header("Content-Disposition: attachment; filename=\"{$prefix}.js.gz\"");
echo gzencode($this->contents, 9);
exit();
}
else {
Expand All @@ -264,12 +264,9 @@ public function doDbImport() {
$tmp = $_FILES["json"]["tmp_name"];

//read file by it's format
$body = "";
if (preg_match("/\\.gz$/", $_FILES["json"]["name"])) {
$body = gzuncompress(file_get_contents($tmp));
}
else {
$body = file_get_contents($tmp);
$body = file_get_contents($tmp);
if (preg_match("/\\.js\\.gz$/", $_FILES["json"]["name"])) {
$body = gzdecode($body);
}

//check format
Expand Down
8 changes: 8 additions & 0 deletions app/funcs/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,12 @@ function r_get_collection_icon($collectionName) {
return "table";
}

// PHP < 5.4
if (!function_exists('gzdecode')) {
// http://php.net/manual/ru/function.gzdecode.php#106397
function gzdecode($data) {
return gzinflate(substr($data,10,-8));
}
}

?>
55 changes: 0 additions & 55 deletions config.php

This file was deleted.