- <?php
-
-
- function save_bu_schedule( $postVars ){
-
- global $g_database_path;
-
- $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 );
- $db_st->bindValue(':bud', $postVars['sched_date'] );
- $db_st->bindValue(':but', $postVars['sched_time'] );
- $db_st->bindValue(':bur', $postVars['sched_period'] );
- $db_st->execute();
-
- if( $db->lastErrorCode()!==0){
- return $db->lastErrorCode();
- }
- return 0;
- }
-
- /**
- * Both inserts as well as edits a single backup item.
- */
- function save_bu_item( $postVars, $bu_id=0 ){
-
- global $g_database_path;
-
- $db = new SQLite3( $g_database_path );
- $db_st = null;
- if( $postVars['new_bu_is_dbType'] ){
- if($bu_id==0){
- $db_st = $db->prepare('INSERT INTO BULIST ( BUName, Dir_Src, Dir_Dest, BuType ) values( :bun, :bus, :bud, 1 )');
- }else{
- $db_st = $db->prepare('update BULIST set BUName=:bun, Dir_Src=:bus, Dir_Dest=:bud where BUID=:buid');
- }
- }else{
- if($bu_id==0){
- $db_st = $db->prepare('INSERT INTO BULIST ( BUName, Dir_Src, Dir_Dest, Files_Ex, BuType ) values( :bun, :bus, :bud, :buex, 0 )');
- }else{
- $db_st = $db->prepare('update BULIST set BUName=:bun, Dir_Src=:bus, Dir_Dest=:bud, Files_Ex=:buex where BUID=:buid');
- }
- }
-
- if($bu_id>0){
- $db_st->bindValue(':buid', $bu_id );
- }
-
- $db_st->bindValue(':bun', $postVars['new_bu_name'] );
- $db_st->bindValue(':bus', $postVars['new_bu_source'] );
- $db_st->bindValue(':bud', $postVars['new_bu_dest'] );
- if( !$postVars['new_bu_is_dbType'] ){
- $db_st->bindValue(':buex', $postVars['new_bu_exf'] );
- }
-
- $db_st->execute();
-
- if( $db->lastErrorCode()!==0){
- return $db->lastErrorCode();
- }
-
- }
-
- /**
- * Set the error string in the database.
- */
- function set_bu_error_db( $buid, $str_errs ){
-
- global $g_database_path;
-
- $db = new SQLite3( $g_database_path );
- if($str_errs==''){
- return $db->exec("update BULIST set BuError = NULL where BUID=$buid");
- }
- $p = $db->prepare("update BULIST set BuError=:str_errs where BUID=:buid");
- $p->bindValue(':str_errs', $str_errs );
- $p->bindValue(':buid', $buid );
- $p->execute();
-
- if( $db->lastErrorCode()!==0){
- return $db->lastErrorCode();
- }
- return 0;
- }
-
- /**
- * Set (unset) the running datbase flag. Return true on success.
- */
- function set_bu_running_db( $id, bool $setit ){
-
- global $g_database_path;
- $db = new SQLite3( $g_database_path );
-
- $setit_int = $setit?1:0;
- return $db->exec("update BULIST set BuRunning=$setit_int where BUID=$id");
- }
-
- function set_last_run_date_db( $buid, $str_dt ){
-
- global $g_database_path;
- $db = new SQLite3( $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 );
- $p->execute();
-
- if( $db->lastErrorCode()!==0){
- return $db->lastErrorCode();
- }
- return 0;
- }
-
-
- function set_sched_date_db( $buid, $dt_new ){
-
- global $g_database_path;
- $db = new SQLite3( $g_database_path );
-
- $p = $db->prepare("update BULIST set BU_DATE=:str_dt where BUID=:buid");
- $p->bindValue(':str_dt', $dt_new );
- $p->bindValue(':buid', $buid );
- $p->execute();
-
- if( $db->lastErrorCode()!==0){
- return $db->lastErrorCode();
- }
- return 0;
- }
-
- function delete_bu_item_db( $id ){
-
- global $g_database_path;
- $db = new SQLite3( $g_database_path );
-
- $db_st = $db->prepare('delete from BULIST where BUID=:buid');
- $db_st->bindValue(':buid', $id );
- $db_st->execute();
-
- if( $db->lastErrorCode()!==0){
- return $db->lastErrorCode();
- }
-
- }
-
-
- ?>