Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Added Encryption to the project and updated the readme #73

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
1e413bb
Changed: #24 – Array keys on query results() and resultDocuments() ch…
timothymarois Aug 17, 2018
a05fc65
Fixing php5.6 test on query.
timothymarois Aug 17, 2018
3d34748
Revert "Fixing php5.6 test on query."
timothymarois Aug 17, 2018
4b17cee
Revert "Changed: #24 – Array keys on query results() and resultDocume…
timothymarois Aug 17, 2018
1041aca
Json format: refactor error handling + add JSON_UNESCAPED_UNICODE
zoldia Aug 28, 2018
f3f0b25
add & use Filesystem exceptions + test not encodable document
zoldia Aug 28, 2018
d0774ed
Updated readme [ci skip]
timothymarois Aug 28, 2018
47ec1f9
Updated readme
timothymarois Aug 28, 2018
45907af
Updated readme [ci skip]
timothymarois Aug 28, 2018
b6a4e50
test format json
zoldia Sep 3, 2018
3e2a65c
update readme
zoldia Sep 3, 2018
c7b426a
Merge pull request #25 from assemblie/refactor-format-error-handling
timothymarois Sep 3, 2018
83f864d
Add Yaml format
jrondorf Sep 19, 2018
e1792e7
Only unlink existing files
tobias-kuendig Sep 29, 2018
33c4afe
Merge pull request #31 from OFFLINE-GmbH/1.0
timothymarois Sep 29, 2018
1a06682
Updated readme for composer install
timothymarois Dec 27, 2018
a1d393a
Merge pull request #30 from jrondorf/1.0
timothymarois Dec 27, 2018
433190a
Updated composer symfony/yaml to allow php 5.6
timothymarois Dec 27, 2018
fbe4e8d
#42 Sort by update or create time
Feb 8, 2019
f4badc8
#40 Add ability to query on document ids
Feb 8, 2019
a1b57bc
add delete method for remove items with custom filter
Feb 9, 2019
5cd3f44
add unit test for delete (delete with closure)
Feb 9, 2019
686939d
Add ability to sort by multiple fields
Feb 14, 2019
5789827
Correct logic in multi-sortorder queries
Feb 15, 2019
c694ff9
Merge pull request #47 from faryar76/1.0
timothymarois Feb 21, 2019
40049fa
Updated test for the correct directory.
timothymarois Feb 21, 2019
9fccaab
Updated readme and changelog [ci skip]
timothymarois Feb 21, 2019
6bc9a4a
Merge pull request #1 from filebase/1.0
faryar76 Feb 22, 2019
1a3beaf
add support call "Query::class" methods on database directly
Feb 22, 2019
13e720a
add test for call query methods on database directly
Feb 22, 2019
089fec7
refactor
Feb 22, 2019
ce06f29
refactor
Feb 22, 2019
c2d4174
Merge pull request #48 from faryar76/1.0
timothymarois Feb 23, 2019
8050f6b
Updated changelog and readme [ci skip]
timothymarois Feb 23, 2019
7b1d927
Merge branch 'feature/sort-by-time' of https://github.com/sumpygump/F…
timothymarois Feb 23, 2019
cae03d2
Merge branch 'sumpygump-feature/sort-by-time' into 1.0
timothymarois Feb 23, 2019
2242961
Updated readme and changelog [ci skip]
timothymarois Feb 23, 2019
3228dd6
Add documentation for update to orderBy
sumpygump Feb 23, 2019
0c7216c
Slight update to README
Feb 24, 2019
9a41207
Merge branch '1.0' into feature/multi-orderby
Feb 24, 2019
def58f7
Update test on query orderby to account for difference change in sort…
Feb 24, 2019
757919f
Merge pull request #49 from sumpygump/feature/multi-orderby
timothymarois Feb 24, 2019
deec627
Merge branch 'feature/where-using-id' of https://github.com/sumpygump…
timothymarois Feb 24, 2019
20c9caa
Updated changelog and updated readme [ci skip]
timothymarois Feb 24, 2019
9cd6ccf
Updated query delete method to allow delete of all items in query (ma…
timothymarois Feb 24, 2019
b64f8af
Updated changelog and readme [ci skip]
timothymarois Feb 24, 2019
e847412
Standardizing the comment blocks, cleaning up notes. (all classes) [c…
timothymarois Feb 24, 2019
66b17e8
Merge pull request #2 from filebase/1.0
faryar76 Feb 24, 2019
d7630c4
fix bug #41 "results() returns document instead of array #41"
Feb 24, 2019
a012b72
Merge pull request #50 from faryar76/1.0
timothymarois Feb 24, 2019
b660650
Updated changelog and minor comment block updates.
timothymarois Feb 24, 2019
efe82dc
Updated composer (minor change)
timothymarois Jun 26, 2019
6f436e3
Updated readme [ci skip]
timothymarois Jun 26, 2019
2801db9
Update readme for composer require [ci skip]
timothymarois Jun 26, 2019
f369cfb
Updated readme with discord invite link
timothymarois Feb 24, 2021
db19fc2
New updated version - Encryption was added to project
mitmelon Jan 25, 2023
da5546e
New updated version - Encryption was added to project
mitmelon Jan 25, 2023
910eccb
New updated version - Encryption was added to project
mitmelon Jan 25, 2023
261eaea
New updated version - Encryption was added to project
mitmelon Jan 25, 2023
1f6c7a9
New updated version - Encryption was added to project
mitmelon Jan 25, 2023
8f90cc8
New updated version - Encryption was added to project
mitmelon Jan 25, 2023
46d7a70
New updated version - Encryption was added to project
mitmelon Jan 25, 2023
6ea5ef6
New updated version - Encryption was added to project
mitmelon Jan 25, 2023
510392f
Fixed Bug
mitmelon Oct 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ php:
- 5.6
- 7
- 7.1
- 7.2

sudo: required
dist: precise
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
Change Log
==========

### 02/24/2019 - 1.0.24
* Merged [Pull Request](https://github.com/filebase/Filebase/pull/50) Fixed [bug](https://github.com/filebase/Filebase/issues/41) returning unexpected results.

### 02/24/2019 - 1.0.23
* Merged [Pull Request](https://github.com/filebase/Filebase/pull/49) Added support for order by multiple columns
* Merged [Pull Request](https://github.com/filebase/Filebase/pull/46) Added ability to query document ids (internal id)
* Added ability to use query `delete()` on all items that match the query (making the custom filter optional)

### 02/23/2019 - 1.0.22
* Merged [Pull Request](https://github.com/filebase/Filebase/pull/47) for deleting items with a custom filter. (this adds the `delete()` method on queries.)
* Merged [Pull Request](https://github.com/filebase/Filebase/pull/48) for calling to the Query methods directly on the database class.
* Merged [Pull Request](https://github.com/filebase/Filebase/pull/45) for sorting by update/created at times (ability to fetch `__created_at` and `__updated_at`)

### 12/26/2018 - 1.0.21
* Merged [Pull Request](https://github.com/filebase/Filebase/pull/30) for YAML format.

### 08/16/2018 - 1.0.20
* Fixed #23 – Caching is cleared when deleting/saving documents to prevent cache from being out of sync with document data.

Expand Down
173 changes: 131 additions & 42 deletions README.md

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"description": "A Simple but Powerful Flat File Database Storage.",
"keywords": ["filebase", "key-value","file-files", "flat", "file", "database", "document", "flat-file", "serverless"],
"name": "filebase/filebase",
"homepage": "https://github.com/filebase/Filebase",
"name": "tmarois/filebase",
"homepage": "https://github.com/tmarois/Filebase",
"type": "package",
"licence": "MIT",

Expand All @@ -14,14 +14,20 @@
],

"require": {
"php": ">=5.6"
"php": ">=5.6",
"paragonie/halite": "5"
},

"require-dev": {
"satooshi/php-coveralls": "^2.0",
"phpunit/phpunit": "5.*"
"php-coveralls/php-coveralls": "^2.0",
"phpunit/phpunit": "5.*",
"symfony/yaml": "^3.4"
},

"suggest": {
"symfony/yaml": "Allows Yaml format"
},

"autoload": {
"psr-4": {
"Filebase\\": "src/"
Expand Down
141 changes: 48 additions & 93 deletions src/Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ class Backup
*/
protected $backupLocation;


//--------------------------------------------------------------------


/**
* $config
*
Expand All @@ -24,27 +20,20 @@ class Backup
*/
protected $config;


//--------------------------------------------------------------------


/**
* $database
*
* \Filebase\Database
*/
protected $database;


//--------------------------------------------------------------------


/**
* __construct
*
*/
public function __construct($backupLocation = '', Database $database)
public function __construct($backupLocation, Database $database)
{

$this->backupLocation = $backupLocation;
$this->config = $database->getConfig();
$this->database = $database;
Expand All @@ -63,10 +52,6 @@ public function __construct($backupLocation = '', Database $database)
}
}


//--------------------------------------------------------------------


/**
* save()
*
Expand All @@ -84,10 +69,6 @@ public function create()
throw new \Exception('Error backing up database.');
}


//--------------------------------------------------------------------


/**
* find()
*
Expand All @@ -109,10 +90,6 @@ public function find()
return $backups;
}


//--------------------------------------------------------------------


/**
* clean()
*
Expand All @@ -124,10 +101,6 @@ public function clean()
return array_map('unlink', glob(realpath($this->backupLocation)."/*.zip"));
}


//--------------------------------------------------------------------


/**
* rollback()
*
Expand All @@ -144,10 +117,6 @@ public function rollback()
return $this->extract($restore, $this->config->dir);
}


//--------------------------------------------------------------------


/**
* extract()
*
Expand All @@ -157,28 +126,21 @@ public function rollback()
*/
protected function extract($source = '', $target = '')
{
if (extension_loaded('zip'))
if (!extension_loaded('zip') && !file_exists($source))
{
if (file_exists($source))
{
$zip = new \ZipArchive();
if ($zip->open($source) === TRUE)
{
$zip->extractTo($target);
$zip->close();

return true;
}
}
return false;
}
$zip = new \ZipArchive();
if ($zip->open($source) === TRUE)
{
$zip->extractTo($target);
$zip->close();

return true;
}
return false;
}


//--------------------------------------------------------------------


/**
* zip()
*
Expand All @@ -187,52 +149,45 @@ protected function extract($source = '', $target = '')
*/
protected function zip($source = '', $target = '')
{
if (extension_loaded('zip'))
if (!extension_loaded('zip') || !file_exists($source))
{
if (file_exists($source))
{
$zip = new \ZipArchive();
if ($zip->open($target, \ZIPARCHIVE::CREATE))
{
$source = realpath($source);
if (is_dir($source))
{
$iterator = new \RecursiveDirectoryIterator($source);
$iterator->setFlags(\RecursiveDirectoryIterator::SKIP_DOTS);
$files = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($files as $file)
{
$file = realpath($file);

if (preg_match('|'.realpath($this->backupLocation).'|',$file))
{
continue;
}

if (is_dir($file))
{
$zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
}
else if (is_file($file))
{
$zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
}
}

}
else if (is_file($source))
{
$zip->addFromString(basename($source), file_get_contents($source));
}
}

return $zip->close();
}
}

return false;
}
return false;
}

$zip = new \ZipArchive();
if (!$zip->open($target, \ZIPARCHIVE::CREATE))
{
$zip->addFromString(basename($source), file_get_contents($source));
}
$source = realpath($source);
if (is_dir($source))
{
$iterator = new \RecursiveDirectoryIterator($source);
$iterator->setFlags(\RecursiveDirectoryIterator::SKIP_DOTS);
$files = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($files as $file)
{
$file = realpath($file);

if (preg_match('|'.realpath($this->backupLocation).'|',$file))
{
continue;
}

if (is_dir($file))
{
$zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
}
else if (is_file($file))
{
$zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
}
}

}

return $zip->close();

}

}
35 changes: 0 additions & 35 deletions src/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ class Cache
*/
protected $key;


//--------------------------------------------------------------------

/**
* __construct()
*
Expand All @@ -44,10 +41,6 @@ public function __construct(Database $database)
]);
}


//--------------------------------------------------------------------


/**
* setKey()
*
Expand All @@ -60,10 +53,6 @@ public function setKey($key)
$this->key = md5($key);
}


//--------------------------------------------------------------------


/**
* getKey()
*
Expand All @@ -73,10 +62,6 @@ public function getKey()
return $this->key;
}


//--------------------------------------------------------------------


/**
* flush()
*
Expand All @@ -86,10 +71,6 @@ public function flush()
$this->cache_database->flush(true);
}


//--------------------------------------------------------------------


/**
* expired()
*
Expand All @@ -106,10 +87,6 @@ public function expired($time)
return true;
}


//--------------------------------------------------------------------


/**
* getDocuments()
*
Expand All @@ -125,10 +102,6 @@ public function getDocuments($documents)
return $d;
}


//--------------------------------------------------------------------


/**
* get()
*
Expand All @@ -155,10 +128,6 @@ public function get()
return $this->getDocuments($cache_doc->toArray());
}


//--------------------------------------------------------------------


/**
* store()
*
Expand All @@ -173,8 +142,4 @@ public function store($data)
return $this->cache_database->get( $this->getKey() )->set($data)->save();
}


//--------------------------------------------------------------------


}
Loading