diff --git a/.gitignore b/.gitignore index 4e73df6..c1ade1c 100755 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ logs/ data/* src/bu-command-local-conf.json +build-src/patch-conf.json diff --git a/build-src/db-patches/ba-commd/sqlite/p-1.sql b/build-src/db-patches/ba-commd/sqlite/p-1.sql new file mode 100755 index 0000000..ac03120 --- /dev/null +++ b/build-src/db-patches/ba-commd/sqlite/p-1.sql @@ -0,0 +1,5 @@ +-- The first 2 patches were back-engineered to match the existing DB at this point +-- So we can create a new DB from scratch if required. + +-- added by Amara base project, not required here +DROP TABLE counties; diff --git a/build-src/db-patches/ba-commd/sqlite/p-2.sql b/build-src/db-patches/ba-commd/sqlite/p-2.sql new file mode 100755 index 0000000..9f66d23 --- /dev/null +++ b/build-src/db-patches/ba-commd/sqlite/p-2.sql @@ -0,0 +1,19 @@ +-- Upgraded the users part of the database + +CREATE TABLE "BULIST" ( + "BUID" INTEGER NOT NULL, + "BUName" TEXT, + "Dir_Src" TEXT, + "Dir_Dest" TEXT, + "Files_Ex" TEXT, + "BuType" INTEGER NOT NULL, + "BuRunning" INTEGER NOT NULL DEFAULT 0, + "BU_DATE" TEXT, + "BU_TIME" TEXT, + "BU_REPEAT" TEXT DEFAULT 'N', + "BuError" TEXT, + "LastRunDt" TEXT, + Res_User TEXT, + Res_Pwd TEXT, + PRIMARY KEY("BUID" AUTOINCREMENT) +); diff --git a/build-src/patch-conf-sample.json b/build-src/patch-conf-sample.json new file mode 100644 index 0000000..9419b79 --- /dev/null +++ b/build-src/patch-conf-sample.json @@ -0,0 +1,8 @@ +{ + "db":{ + "type":"sqlite", + "db":"/data/data.db" + }, + "prefixes" : [ "amara", "am-prop" ], + "patch-dir":"/build-src/db-patches" +} diff --git a/build-src/update-db.php b/build-src/update-db.php new file mode 100644 index 0000000..09e55b0 --- /dev/null +++ b/build-src/update-db.php @@ -0,0 +1,61 @@ +open( $filename ); + +// Now apply each set of patches in order +foreach( $conf_json['prefixes'] as $prfx ){ + + $patcher->setPrefix( $prfx ); + + $pathtopatches = dirname($filename); + if($prfx=='amara'){ + if( getPackageName( "$dir_root/composer.json" ) != 'johnpearcey/amara' ){ + //running in a parent project, locate the amara package to use instead + // TODO: use \Composer\InstalledVersions::getInstallPath('johnpearcey/amara'); + $pathtopatches = "$dir_root/vendor/johnpearcey/amara/build-src"; + } + } + + $tot_applied = $patcher->apply_patches( $pathtopatches ); + echo "Finished: applied $tot_applied patches\n"; + + $version = $patcher->get_curr_patch_ver( ); + echo "DB patch($prfx) version: $version\n"; + +} + +function getPackageName( $composerfile ){ + $conf_json = json_decode( file_get_contents( $composerfile ), true ); + return $conf_json['name']; +} + +?> \ No newline at end of file diff --git a/composer.json b/composer.json index 148c3be..136c015 100644 --- a/composer.json +++ b/composer.json @@ -22,10 +22,14 @@ { "type": "vcs", "url": "http://johnpearcey:325bfbed42068584ee2d850e1934c79677e0d296@pearcey.net:8080/johnpearcey/Amara.git" - } + }, + { + "type": "vcs", + "url": "http:\/\/johnpearcey:325bfbed42068584ee2d850e1934c79677e0d296@pearcey.net:8080\/johnpearcey\/DbPatcher.git" + } ], "require": { - "johnpearcey/amara": "v0.9.13", + "johnpearcey/amara": "v0.12.5", "katzgrau/klogger": "dev-master" } diff --git a/composer.lock b/composer.lock index 71cdf4b..75c9d07 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "22664b97c2671d3a3a87d84f3b55d389", + "content-hash": "7b03978a06204efc8a16620600d02a38", "packages": [ { "name": "delight-im/auth", @@ -228,20 +228,24 @@ }, { "name": "johnpearcey/amara", - "version": "v0.9.13", + "version": "v0.12.5", "source": { "type": "git", "url": "http://johnpearcey:325bfbed42068584ee2d850e1934c79677e0d296@pearcey.net:8080/johnpearcey/Amara.git", - "reference": "32cee64205582b392edf54ca200c5b9f0da53661" + "reference": "2406d3765561562adfe57c78966d2b016300663b" }, "require": { "delight-im/auth": "^8.3", + "johnpearcey/dbpatcher": "*", "katzgrau/klogger": "dev-master", "phpmailer/phpmailer": "^6.9" }, "require-dev": { "phpunit/phpunit": "^10" }, + "bin": [ + "build-src/amara-update-ex.php" + ], "type": "library", "autoload": { "psr-4": { @@ -258,7 +262,39 @@ } ], "description": "Home grown web navigation framework complete with login", - "time": "2025-01-31T13:13:03+00:00" + "time": "2025-04-04T11:30:42+00:00" + }, + { + "name": "johnpearcey/dbpatcher", + "version": "v0.1.10", + "source": { + "type": "git", + "url": "http://johnpearcey:325bfbed42068584ee2d850e1934c79677e0d296@pearcey.net:8080/johnpearcey/DbPatcher.git", + "reference": "cbe5e09bd51b86b8f83ecb448c51735fda7a8190" + }, + "require-dev": { + "phpunit/phpunit": "^10" + }, + "bin": [ + "bin/dbpatch.php" + ], + "type": "library", + "autoload": { + "psr-4": { + "Johnpearcey\\Dbpatcher\\": "src/" + } + }, + "license": [ + "proprietary" + ], + "authors": [ + { + "name": "John Pearcey", + "email": "john@pearcey.net" + } + ], + "description": "Simple database patching code for mysql and sqlite3", + "time": "2025-02-13T11:59:26+00:00" }, { "name": "katzgrau/klogger", @@ -455,7 +491,7 @@ }, "prefer-stable": false, "prefer-lowest": false, - "platform": {}, - "platform-dev": {}, - "plugin-api-version": "2.6.0" + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.3.0" } diff --git a/html/lib/sysVcom.php b/html/lib/sysVcom.php index 7949ea0..25bc1d2 100755 --- a/html/lib/sysVcom.php +++ b/html/lib/sysVcom.php @@ -41,6 +41,9 @@ global $g_k_caller; global $g_k_reply; $g_procName = $value; + if(!is_file($g_procName)){ + touch( $g_procName ); + } $g_k_caller = ftok( $g_procName, 'A'); //caller $g_k_reply = ftok( $g_procName, 'B'); //reply debug_print( "g_k_caller key = $g_k_caller\n" ); diff --git a/html/shd/common.php b/html/shd/common.php index a120610..dd432e5 100755 --- a/html/shd/common.php +++ b/html/shd/common.php @@ -226,7 +226,7 @@ function sendHtmlError( $strErrDesc = "--blank--" ){ $rtn = getHtmlErrorAsString( $strErrDesc ); - mylog( $rtn ); + // mylog( $rtn ); //not sure where this is located??? echo $rtn; } diff --git a/notes.txt b/notes.txt index 39efa73..bdb87f3 100755 --- a/notes.txt +++ b/notes.txt @@ -49,10 +49,9 @@ Show the table cache running in the service (the numbers are column widths and optional) php main.php f:cache-show 5 5 10 10 5 5 5 5 - + (use /opt/php82/bin/php on Lars's machine) Install ------- - Much of this is defunct. Only the database updates are relevant currently. - + Defunct. Use the build-src for database updates. diff --git a/src/bu-command-nav.json b/src/bu-command-nav.json index ce7d8fd..d1a5083 100644 --- a/src/bu-command-nav.json +++ b/src/bu-command-nav.json @@ -82,9 +82,18 @@ "Navigate": { "/index.html": { - "#1" : "Same as mainpage but only if logged in", "secure":1, - "class-handler": "Johnpearcey\\Amara\\Router\\RqHandlerCls_mainpage" + "class-handler": "Johnpearcey\\Amara\\Router\\RqHandlerCls_default", + "page_builder" : { + "name" : "index_page", + "data" : { + "body_index" : { + "pagetitle" : "

Greetings Tubers

", + "login_link" : "/login", + "register_link" : "register" + } + } + } }, "/login/auth": { @@ -99,6 +108,7 @@ "/register": { "class-handler": "Johnpearcey\\Amara\\Router\\RqHandlerCls_register", "secure":1, + "roles": [ "ADMIN" ], "class_props":{ "submit_reg":"/register/auth" }