diff --git a/.gitignore b/.gitignore index ea8c0d9..936a441 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ html/bin/*.txt +html/data/* install/conf.php diff --git a/html/bin/data.db b/html/bin/data.db deleted file mode 100644 index e829a56..0000000 --- a/html/bin/data.db +++ /dev/null Binary files differ diff --git a/html/bin/run-bu-by-id.php b/html/bin/run-bu-by-id.php index 7401295..7d93bf6 100644 --- a/html/bin/run-bu-by-id.php +++ b/html/bin/run-bu-by-id.php @@ -1,5 +1,6 @@ query("SELECT * FROM BULIST where BUID=$id"); @@ -30,7 +32,8 @@ if($bu_test) return true; - $db = new SQLite3( __DIR__.'/../bin/data.db' ); + global $g_database_path; + $db = new SQLite3( __DIR__."/../$g_database_path" ); $setit_int = $setit?1:0; return $db->exec("update BULIST set BuRunning=$setit_int where BUID=$id"); @@ -40,7 +43,8 @@ * Set the error string in the database. */ function set_bu_error( $buid, $str_errs ){ - $db = new SQLite3( __DIR__.'/../bin/data.db' ); + global $g_database_path; + $db = new SQLite3( __DIR__."/../$g_database_path" ); if($str_errs==''){ return $db->exec("update BULIST set BuError = NULL where BUID=$buid"); } @@ -58,7 +62,8 @@ * */ function set_last_run_date( $buid, $str_dt ){ - $db = new SQLite3( __DIR__.'/../bin/data.db' ); + global $g_database_path; + $db = new SQLite3( __DIR__."/../$g_database_path" ); $p = $db->prepare("update BULIST set LastRunDt=:str_dt where BUID=:buid"); $p->bindValue(':str_dt', $str_dt ); $p->bindValue(':buid', $buid ); @@ -119,20 +124,20 @@ $fn_e = getFilename_out( $buid, $bu_test, true ); // create the output files with the ID in the first line - exec("echo 'ID: $buid' > bin/$fn_o"); - exec("echo 'ID: $buid' > bin/$fn_e"); + exec("echo 'ID: $buid' > data/$fn_o"); + exec("echo 'ID: $buid' > data/$fn_e"); $str_exPaths = ''; if(trim( $exFiles )!=''){ $fn_x = getFilename_tmp( $buid, 'x' ); - file_put_contents( "bin/$fn_x", $exFiles ); - $str_exPaths = "--exclude-from=bin/$fn_x"; + file_put_contents( "data/$fn_x", $exFiles ); + $str_exPaths = "--exclude-from=data/$fn_x"; } // bash command //rsync -a --exclude-from=to-exclude.txt $PATH_SRC $BKUP_DEST //rsync -anv --exclude-from=to-exclude.txt $PATH_SRC $BKUP_DEST <-- for testing - $command = "rsync $flags $str_exPaths $bu_src $bu_dest 2>> bin/$fn_e 1>> bin/$fn_o"; + $command = "rsync $flags $str_exPaths $bu_src $bu_dest 2>> data/$fn_e 1>> data/$fn_o"; $output = array(); $result_code = null; @@ -143,7 +148,7 @@ set_bu_running( $buid, false, $bu_test ); // can we find any error strings in the error file? - $str_errs = file_get_contents( "bin/$fn_e" ); + $str_errs = file_get_contents( "data/$fn_e" ); $pos = strpos($str_errs, 'error' ); if($pos===FALSE){ $pos = strpos($str_errs, 'failed' ); @@ -157,7 +162,7 @@ /** - * Very similar to the file version. The common code is running the bach script. + * Very similar to the file version. The common code is running the bash script. */ function run_backup_DB( $bu_test, $buid, $bu_src, $bu_dest ){ @@ -171,7 +176,7 @@ if($bu_test){ $fn_o = getFilename_out( $buid, $bu_test, false ); - $bu_dest = "bin"; + $bu_dest = "data"; }else{ $fn_o = "$bu_src.sql"; set_bu_error( $buid, '' ); //clear any previous error @@ -180,12 +185,12 @@ // create the error files with the ID in the first line $fn_e = getFilename_out( $buid, $bu_test, true ); - exec("echo 'ID: $buid' > bin/$fn_e"); + exec("echo 'ID: $buid' > data/$fn_e"); // bash command //mysqldump johntest > /home/johnp/tmp/dbs/johntest.sql - $command = "mysqldump $bu_src 2>> bin/$fn_e 1>> $bu_dest/$fn_o"; + $command = "mysqldump $bu_src 2>> data/$fn_e 1>> $bu_dest/$fn_o"; $output = array(); $result_code = null; @@ -196,7 +201,7 @@ set_bu_running( $buid, false, $bu_test ); // can we find any error strings in the error file? - $str_errs = file_get_contents( "bin/$fn_e" ); + $str_errs = file_get_contents( "data/$fn_e" ); $pos = strpos($str_errs, 'error' ); if($pos===FALSE){ $pos = strpos($str_errs, 'failed' ); diff --git a/html/inc/bu_list_content.php b/html/inc/bu_list_content.php index b5f9a2e..a94beaa 100644 --- a/html/inc/bu_list_content.php +++ b/html/inc/bu_list_content.php @@ -1,12 +1,17 @@ query('SELECT BUID, BuRunning FROM BULIST'); while ($row = $results->fetchArray()) { @@ -21,7 +26,9 @@ */ function getbu_list_content(){ - $db = new SQLite3('bin/data.db', SQLITE3_OPEN_READONLY ); + global $g_database_path; + + $db = new SQLite3($g_database_path, SQLITE3_OPEN_READONLY ); $html_rows=''; $results = $db->query('SELECT * FROM BULIST'); diff --git a/html/inc/delete-file-bu.php b/html/inc/delete-file-bu.php index b24d99c..95b0fd6 100644 --- a/html/inc/delete-file-bu.php +++ b/html/inc/delete-file-bu.php @@ -1,9 +1,10 @@ prepare('delete from BULIST where BUID=:buid'); $db_st->bindValue(':buid', $id ); $db_st->execute(); diff --git a/html/inc/edit-sh-bu.php b/html/inc/edit-sh-bu.php index 920a1c7..89147ff 100644 --- a/html/inc/edit-sh-bu.php +++ b/html/inc/edit-sh-bu.php @@ -1,8 +1,11 @@ prepare('SELECT * FROM BULIST where BUID=:buid'); $db_st->bindValue(':buid', $db_id); @@ -92,8 +95,9 @@ function save_bu_schedule( $postVars ){ //error_log( $postVars['id'] ); + global $g_database_path; - $db = new SQLite3('bin/data.db' ); + $db = new SQLite3( $g_database_path ); $db_st = $db->prepare('UPDATE BULIST SET BU_DATE=:bud, BU_TIME=:but, BU_REPEAT=:bur where BUID=:buid'); $db_st->bindValue(':buid', $postVars['id'], SQLITE3_INTEGER ); diff --git a/html/inc/new-file-bu.php b/html/inc/new-file-bu.php index 0c6951d..fb58acb 100644 --- a/html/inc/new-file-bu.php +++ b/html/inc/new-file-bu.php @@ -132,8 +132,9 @@ function save_bu_item( $postVars, $bu_id=0 ){ //error_log( "save_bu_item id = $bu_id, new_bu_dest = {$postVars['new_bu_dest']}" ); - - $db = new SQLite3('bin/data.db' ); + global $g_database_path; + + $db = new SQLite3( $g_database_path ); $db_st = null; if( $postVars['new_bu_is_dbType'] ){ if($bu_id==0){ diff --git a/html/inc/paths.php b/html/inc/paths.php new file mode 100644 index 0000000..f1bfd5b --- /dev/null +++ b/html/inc/paths.php @@ -0,0 +1,3 @@ + diff --git a/html/post_handler.php b/html/post_handler.php index bce003d..3e06b43 100644 --- a/html/post_handler.php +++ b/html/post_handler.php @@ -6,6 +6,7 @@ //error_log("POST: " . print_r($_POST, true) ); +include_once __DIR__ . "/inc/paths.php"; include_once __DIR__ . "/inc/secure.php"; include_once __DIR__ . "/inc/common.php"; @@ -14,8 +15,6 @@ exit; } -//error_log("post_handler.php: " . $_POST['action'] ); - include_once __DIR__ . "/inc/pagemap.php"; if( invokeCommand( $_POST['action'], $_POST ) ) exit; diff --git a/install/db/data.db b/install/db/data.db new file mode 100644 index 0000000..751f6e0 --- /dev/null +++ b/install/db/data.db Binary files differ