diff --git a/README.md b/README.md index c143350..bc68ed9 100644 --- a/README.md +++ b/README.md @@ -167,7 +167,7 @@ if(isset($_POST['regbtn'])){ $_SESSION['username'] = $username; Reload::run(); }else{ - echo '

Error: cannot login correctly!

'; + echo PPDB::failed("Error: cannot login correctly!"); } } @@ -184,17 +184,17 @@ if(isset($_POST['regbtn'])){ if(isset($_POST['cs'])){ if(!PPDBLogic::storageExists(ROOT)){ PPDB::createStorage(ROOT); # ROOT or ROOT_FORWARD - echo '

Storage created

'; + echo PPDB::success("Storage created"); }else{ - echo '

Storage already exists

'; + echo PPDB::failed("Storage already exists."); } } if(isset($_POST['rs'])){ if(PPDBLogic::storageExists(ROOT)){ PPDB::removeStorage(ROOT, DS); # ROOT/ROOT_FORWARD || DS/DS_FORWARD - echo '

Storage Removed

'; + echo PPDB::success("Storage Removed."); }else{ - echo '

Storage does not exist.

'; + echo PPDB::failed("Storage does not exist."); } @@ -216,8 +216,49 @@ if(isset($_POST['regbtn'])){



- "; +
"; + echo "


+
+
+
Upload exported JSON file
+ +

+ +
"; } + # upload exported file + if(isset($_POST['upload_reg_import'])){ + $target_dir = "db/"; +$target_file = $target_dir . preg_replace("/\d{4}-\d{2}-\d{2}-/",'',basename($_FILES["reg_db_import"]["name"])); +$uploadOk = 1; +$extend = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); + + +// Check if file already exists +if (file_exists($target_file)) { + echo PPDB::failed("Sorry, ".$target_file." already exists."); + $uploadOk = 0; +} + +// Allow certain file formats +if($extend != "json") { + echo PPDB::failed("Sorry, only JSON files are allowed."); + $uploadOk = 0; +} + +// Check if $uploadOk is set to 0 by an error +if ($uploadOk == 0) { + echo PPDB::failed("Sorry, your file was not uploaded."); +// if everything is ok, try to upload file +} else { + if (move_uploaded_file($_FILES["reg_db_import"]["tmp_name"], $target_file)) { + echo PPDB::success("The file ". htmlspecialchars(str_replace($target_dir,'',$target_file)). " has been uploaded."); + } else { + echo PPDB::failed("Sorry, there was an error uploading your file."); + } + } +} + # reg add if(isset($_POST['dbsubmit'])){ $fileName = $_POST['dbname']; $args = PPDB::JSONTOARRAY($_POST['dbarr']); @@ -302,7 +343,7 @@ if(isset($_POST['LoadTable'])){ echo $READER->allowPageLimit([5,10,20,50,100]); echo $READER->createTable($data, PPDB::JSONTOARRAY(file_get_contents(ROOT_DB.$name.'.json')), $main ,$data)->view(VIEW_ALL); }else{ - echo '

Database does not exist.

'; + echo PPDB::failed("Database does not exist"); } } if(isset($_POST['LoadLinkedTable'])){ @@ -361,7 +402,7 @@ if(isset($_POST['exec_change_psw']) && SESSION_USER){ if($copyNew === $new){ PPDB::CHANGE_PSW(ROOT, $old, $new); }else{ - echo '

The New Password does not match.

'; + echo PPDB::failed("The New Password does not match"); } } @@ -374,10 +415,12 @@ if(isset($_POST['exec_change_psw']) && SESSION_USER){