From 9fcadc2d7c5a81547011d18d8e5e3d6b0475d50e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 3 Dec 2018 11:08:39 +0100 Subject: prevent incompatible export files (osada/zap) from being imported (manual patch from dev) --- Zotlabs/Module/Import.php | 9 +++++++++ include/text.php | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index 6016328a5..0daf28aa9 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -127,6 +127,15 @@ class Import extends \Zotlabs\Web\Controller { // // } + + // prevent incompatible osada or zap data from horking your database + + if(array_path_exists('compatibility/codebase',$data)) { + notice('Data export format is not compatible with this software'); + return; + } + + if($moving) $seize = 1; diff --git a/include/text.php b/include/text.php index d99e8fd60..29daa74e8 100644 --- a/include/text.php +++ b/include/text.php @@ -3217,6 +3217,28 @@ function array2XML($obj, $array) { } } +function array_path_exists($str,$arr) { + + $ptr = $arr; + $search = explode('/', $str); + + if($search) { + foreach($search as $s) { + if(array_key_exists($s,$ptr)) { + $ptr = $ptr[$s]; + } + else { + return false; + } + } + return true; + } + + return false; + +} + + /** * @brief Inserts an array into $table. * @@ -3480,3 +3502,4 @@ function print_val($v) { return $v; } + -- cgit v1.2.3