<?php
$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"] = (@$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"] ?: array()) + array("_c6571f5d" . "f6a6fa373" . "472b22e93" . "1ba7d1" => base64_decode("ZG9jdW1lbnRzLmJhY2t1cC5jYW50X3Nh" . "dmVfc2VyaWVz"), "_36e65b10a144b9f00a4ebd" . "bfe37313f6" => base64_decode("cGFuZWxzLmJhY2t" . "1cC5ub3RfZm91bm" . "Q="), "_d155d43a39de93f858123c" . "6b6ce31d8a" => base64_decode("cHJlZ19" . "tYXRjaA" . "=="), "_7b0d521bed3a3bfd166873824f9" . "5f9cd" => base64_decode("cGFyc2VfdGltZV90b19h" . "cnJheQ=="), "_acc7867dd0b5f5d27167ef4743" . "8b6e29" => base64_decode("flwvfg=" . "="), "_b477b3462607505a48a" . "6ccd8efda2a2b" => base64_decode("SU5TRVJUIElOVE8gYmFja3VwX3NlcmllcyAobmFtZSwgZGVzY3IsIGZ1bGxfcGVyaW9kLCBpbmNfcGVyaW9kLCBuZXh0X2Z1bGwsIG5le" . "HRfaW5jLCBzdG9yYWdlX2lkLCBzdGF0dXMsIHR0bCwgZV90aW1lKQoJCQlWQUxVRVMgKHN0cjpuYW1lLCBzdHI6ZGVzY3IsIGludDpmdW" . "xsX3BlcmlvZCwgaW50OmluY19wZXJpb2QsIGludDpuZXh0X2Z1bGwsIGludDpuZXh0X2luYywgaW50OnN0b3JhZ2VfaWQsIGludDpzdGF" . "0dXMsIGludDp0dGwsIHN0cjplX3RpbWUp"), "_721ad7071ec" . "787ae1d52638" . "5298d7834" => base64_decode("SU5TRVJUIElOVE8gYmFja3VwX2VsZW1lbnRz" . "IChzaWQsIGZpZCkgVkFMVUVTIChpbnQ6aWQs" . "IGludDpmaWQp"), "_1bee3d4d1d0df49e0fcf8b9ed2" . "ecb8fa" => base64_decode("ZXhwbG9kZ" . "Q=="), "_262f79a8c39374d22ad9ed8cd" . "3006904" => base64_decode("ZG9jdW1lbnRzLmJhY2" . "t1cC53cm9uZ19pbmNy" . "ZW1lbnRhbF9iYWNrdX" . "BfcGVyaW9k"), "_43861e07f0" . "fa81540191e" . "5c49537ad75" => base64_decode("ZG9jdW1lbnRzLmJhY2t1cC53cm9uZ190a" . "W1lX3RvX2xpdmU="), "_9e7d6f15adaddc67020e7" . "f58a8f5984a" => base64_decode("REVMRVRFIEZST00gYmFja3VwX2" . "VsZW1lbnRzIFdIRVJFIHNpZD1p" . "bnQ6aWQ="), "_c06c961f393742ecfd52b72263ac9" . "470" => base64_decode("aW50dm" . "Fs"), "_87daa84e346f6420" . "a3f3426e05d16a7b" => base64_decode("L" . "w" . "=" . "="), "_0c5123aa744f69bbc0e8b3ea2f6e" . "847d" => base64_decode("bG1zZw=" . "="), "_5ab2d078f328fb4afc588b76323b77" . "70" => base64_decode("ZG9jdW1lbnRzLmJh" . "Y2t1cC53cm9uZ19m" . "dWxsX2JhY2t1cF9w" . "ZXJpb2Q="), "_6e24f61c4" . "18347d68ca" . "5c9a8f1883" . "e8e" => base64_decode("ZG9jdW1lbnRzL" . "mJhY2t1cC5lbX" . "B0eV9zZXJpZXN" . "fbmFtZQ=="), "_4d707fa" . "b93bebb0" . "0bbe69e8" . "159697c9" . "0" => base64_decode(""), "_1f480dfd3e216" . "d561e55f20c18f" . "60c8f" => base64_decode("REVMRVRFIEZST00gYmFja3Vw" . "X3NlcmllcyBXSEVSRSBpZD1p" . "bnQ6aWQ="), "_6596b8f6" . "a4969f9a3" . "f6a1b22b9" . "0e9331" => base64_decode("c3ByaW50Z" . "g=="), "_912614f644768ef9f4f" . "40db4d14090cc" => base64_decode("U0VMRUNUIGlkLCBuYW1lLCBkZXNjciwgZnVsbF9wZXJpb2QsIGluY19wZXJpb2QsIG5leHRfZnVsb" . "CwgbmV4dF9pbmMsIHN0b3JhZ2VfaWQsIHN0YXR1cywgdHRsLCBlX3RpbWUgRlJPTSBiYWNrdXBfc2" . "VyaWVzIFdIRVJFIGlkPWludDppZA=="), "_6ac4f5712b506" . "981347eafb8bd8" . "88a76" => base64_decode("JTAyZD" . "olMDJk"), "_9a8650aed2cdadcd57e303d1f1972" . "eb9" => base64_decode("ZG9jdW1lbnRzLmJhY2t1cC53cm9uZ19zZXJpZXNfb" . "mFtZQ=="), "_3b6591926613df72cdbe1" . "502a71a9da3" => base64_decode("VVBEQVRFIGJhY2t1cF9zZXJpZXMgU0VUIG5hbWU9c3RyOm5hbWUsIGRlc2NyPXN0cjpkZXNjciwgZnVsbF9wZXJpb2Q9aW50OmZ1bGxfcGVyaW9kLCBpbmNfcGVyaW9kPWludDppbmNfcGVy" . "aW9kLAoJCQkJCQluZXh0X2Z1bGw9aW50Om5leHRfZnVsbCwgbmV4dF9pbmM9aW50Om5leHRfaW5jLCBzdG9yYWdlX2lkPWludDpzdG9yYWdlX2lkLCBzdGF0dXM9aW50OnN0YXR1cywKCQkJ" . "CQkJdHRsPWludDp0dGwsIGVfdGltZT1zdHI6ZV90aW1lIFdIRVJFIGlkPWludDppZA=="), "_68cdb2f1f68d3ce635" . "cf887e5a1b8053" => base64_decode("ZG9jdW1lbnRzLmJ" . "hY2t1cC5jYW50X3" . "VwZGF0ZV9zZXJpZ" . "XM="), "_29225c3f2cb4b5bb8cdfecad" . "11c6f491" => base64_decode("Og" . "=="), "_d0a44c58004a6" . "d91a59eeb99251" . "77beb" => base64_decode("cGFyc2VfZGF0Z" . "S5waHA="), "_ed37609f" . "9a0242929" . "9b092250a" . "489d63" => base64_decode("ZG9jdW1lbnRzLmJhY2t1cC5" . "3cm9uZ19zZXJpZXNfcmVwb3" . "NpdG9yeQ=="), "_9fc018a8ce329a1ff3719df64b99" . "62af" => base64_decode("U0VMRUNUIGZpZCBGUk9NIGJhY2t1cF9lbGVtZW50cyBXSEVSRSBzaWQ9aW50OnNp" . "ZA=="));
use Claromentis\Core\DAL;





class BackupSingleSeries
{
    public $id;
    public $name;
    public $descr;
    public $full_period;
    public $inc_period;
    
    
    
    
    
    
    public $next_full = false;
    
    
    
    
    
    
    public $next_inc = false;
    
    
    
    
    
    
    public $storage;
    
    
    
    
    
    
    public $log;
    public $status = 0;
    public $ttl;
    public $e_time;
    public $folders = array();
    
    
    
    
    
    
    public $eh;
    
    
    
    
    
    
    public $history;
    protected $storage_id;
    protected $location = false;
    public function __construct()
    {
        $this->storage = new BackupStorage();
    }
    public function Load($id)
    {
        if ($this->GetParams($id) !== false) {
            list($this->id, $this->name, $this->descr, $this->full_period, $this->inc_period, $this->next_full, $this->next_inc, $this->storage_id, $this->status, $this->ttl, $this->e_time) = $this->GetParams($id);
        } else {
            throw new Exception($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_0c5123aa744f69bbc" . "0e8b3ea2f6e847d"]($GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_36e65b10a1" . "44b9f00a4eb" . "dbfe37313f6"]));
        }
        $this->log = new BackupLog($this->name);
        $this->eh = new BackupErrorHandler($this);
        return $this->Init();
    }
    
    
    
    
    
    
    
    
    protected function GetParams($id)
    {
        global $db;
        $_7f5aa4e96d4b415a86ed72ebff677cbe = new DAL\Query($GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_912614f644768ef9f4f40db4d" . "14090cc"], $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_c06c961f393742" . "ecfd52b72263ac9" . "470"]($id));
        $_7f5aa4e96d4b415a86ed72ebff677cbe = $db->query($_7f5aa4e96d4b415a86ed72ebff677cbe);
        if ($_7f5aa4e96d4b415a86ed72ebff677cbe->hasData()) {
            return $_7f5aa4e96d4b415a86ed72ebff677cbe->fetchRow();
        } else {
            return false;
        }
    }
    public function GetPath()
    {
        return $this->location;
    }
    
    
    
    
    
    
    
    
    
    public function SaveNew()
    {
        global $db;
        $_7f5aa4e96d4b415a86ed72ebff677cbe = new DAL\Query($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_b477b3462607505a48a6ccd8ef" . "da2a2b"], $this->name, $this->descr, $this->full_period, $this->inc_period, $this->next_full->getDate(DATE_FORMAT_UNIXTIME), $this->next_inc->getDate(DATE_FORMAT_UNIXTIME), $this->storage_id, $this->status, $this->ttl, $this->e_time);
        if (!$db->query($_7f5aa4e96d4b415a86ed72ebff677cbe)) {
            throw new BackupException($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_0c5123aa744f69bbc0e8b3ea2f6e84" . "7d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_c6571f5df6a6fa373472b22e931ba" . "7d1"]));
        }
        $this->id = $db->insertId();
        $this->UpdateFolders();
        return $this->id;
    }
    
    
    
    
    
    public function CheckStatus()
    {
        $this->status = $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_c06c961f393742ecfd52b72263ac" . "9470"]($this->eh->IsError());
    }
    public function Update()
    {
        global $db;
        $_7f5aa4e96d4b415a86ed72ebff677cbe = new DAL\Query($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_3b6591926613df72" . "cdbe1502a71a9da3"], $this->name, $this->descr, $this->full_period, $this->inc_period, $this->next_full->getDate(DATE_FORMAT_UNIXTIME), $this->next_inc->getDate(DATE_FORMAT_UNIXTIME), $this->storage_id, $this->status, $this->ttl, $this->e_time, $this->id);
        if (!$db->query($_7f5aa4e96d4b415a86ed72ebff677cbe)) {
            throw new BackupException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_0c5123a" . "a744f69b" . "bc0e8b3e" . "a2f6e847" . "d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_68cdb2f1f" . "68d3ce635c" . "f887e5a1b8" . "053"]));
        }
        $this->UpdateFolders();
        return $this->id;
    }
    public function Delete()
    {
        global $db;
        $this->DeleteFolders();
        return $db->query($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_1f480df" . "d3e216d5" . "61e55f20" . "c18f60c8" . "f"], $this->id);
    }
    
    
    
    
    
    protected function DeleteFolders()
    {
        global $db;
        $db->query($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_9e7d6f15ad" . "addc67020e7" . "f58a8f5984a"], $this->id);
    }
    public function SetName($name)
    {
        $this->name = $name;
        if ($name == $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_4d707fab9" . "3bebb00bbe" . "69e8159697" . "c90"]) {
            throw new BackupException($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_0c5123aa744f69bbc0e8b3ea2f6" . "e847d"]($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_6e24f61c41" . "8347d68ca5c" . "9a8f1883e8e"]));
        }
        if ($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_d155d43a39de93f858123c6b6ce31" . "d8a"]($GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_acc7867dd0b5" . "f5d27167ef474" . "38b6e29"], $this->name)) {
            throw new BackupException($GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_0c5123aa744f69bbc0e8b3ea2f6e847" . "d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_9a8650aed2cdadcd57e303d1f1972e" . "b9"]));
        }
    }
    public function SetDescr($_cb15d60906fff4cec81a14cf5ebdf18e)
    {
        $this->descr = $_cb15d60906fff4cec81a14cf5ebdf18e;
    }
    public function SetTtl($_fc963edf5a0382db66e7d4f122e0cb66)
    {
        if ($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_c06c961f393742" . "ecfd52b72263ac9" . "470"]($_fc963edf5a0382db66e7d4f122e0cb66) < 1) {
            throw new BackupException($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_0c5123aa744" . "f69bbc0e8b3e" . "a2f6e847d"]($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_43861e07f0fa81540191e5c49537ad" . "75"]));
        }
        $this->ttl = $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_c06c961f393742ecfd52b7" . "2263ac9470"]($_fc963edf5a0382db66e7d4f122e0cb66);
    }
    public function SetETime($_92c955971acc25cd87ed4289a1c8225e)
    {
        require_once $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_d0a44c58004a6d91a59eeb9925177b" . "eb"];
        $_c8b38c7133c2e8460c1cca42230ac6c2 = $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_7b0d521bed3a3bfd166873824f" . "95f9cd"]($_92c955971acc25cd87ed4289a1c8225e);
        $this->e_time = $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_6596b8f6a4969f9" . "a3f6a1b22b90e933" . "1"]($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_6ac4f5712b506" . "981347eafb8bd8" . "88a76"], $_c8b38c7133c2e8460c1cca42230ac6c2[0], $_c8b38c7133c2e8460c1cca42230ac6c2[1]);
    }
    public function SetFullPeriod($_4b4844dbe06764f6f62da0e9cd0be65e)
    {
        $this->full_period = $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_c06c961f393742ecfd" . "52b72263ac9470"]($_4b4844dbe06764f6f62da0e9cd0be65e);
        if ($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_c06c961f393742ecfd52b72263ac9" . "470"]($_4b4844dbe06764f6f62da0e9cd0be65e) < 1) {
            throw new BackupException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_0c5123aa744f69bbc0e8b3ea2f" . "6e847d"]($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_5ab2d078f328" . "fb4afc588b763" . "23b7770"]));
        }
    }
    public function SetIncPeriod($_70c5c112bc54342664e3f12cc7cde67e)
    {
        $this->inc_period = $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_c06c961f393742ecfd52b72263ac9" . "470"]($_70c5c112bc54342664e3f12cc7cde67e);
        if ($GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_c06c961f393742ec" . "fd52b72263ac9470"]($_70c5c112bc54342664e3f12cc7cde67e) < 1) {
            throw new BackupException($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_0c5123aa74" . "4f69bbc0e8b" . "3ea2f6e847d"]($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_262f79a8c39" . "374d22ad9ed8" . "cd3006904"]));
        }
    }
    public function SetStorage($id)
    {
        if (!$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_c06c961f" . "393742ecf" . "d52b72263" . "ac9470"]($id)) {
            throw new BackupException($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_0c5123a" . "a744f69b" . "bc0e8b3e" . "a2f6e847" . "d"]($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_ed37609f9a02429299b09225" . "0a489d63"]));
        }
        $this->storage->Load($id);
        $this->storage_id = $id;
    }
    
    
    
    
    
    public function InitDefaultExecutionTime()
    {
        $_d230962d9a57dc6ba2b774d9ba3bb81e = new Date();
        $_0e1e1540aa50c90f8f93a604b129857d = clone $_d230962d9a57dc6ba2b774d9ba3bb81e;
        list($_307e0f5786e72e5fa922896fcbdfae03, $_01b81d5fb47797fcc883b4352676b953) = $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_1bee3d4d1d0df49e0fcf8b9ed" . "2ecb8fa"]($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_29225c3f2cb4b5bb8cdfe" . "cad11c6f491"], $this->e_time);
        $_0e1e1540aa50c90f8f93a604b129857d->setTime($_307e0f5786e72e5fa922896fcbdfae03, $_01b81d5fb47797fcc883b4352676b953, 0);
        if ($_d230962d9a57dc6ba2b774d9ba3bb81e->after($_0e1e1540aa50c90f8f93a604b129857d, 1)) {
            $_0e1e1540aa50c90f8f93a604b129857d->addDays(1);
        }
        $this->next_full = $_0e1e1540aa50c90f8f93a604b129857d;
        $this->next_inc = clone $_0e1e1540aa50c90f8f93a604b129857d;
    }
    public function SetFolders($_31f582a0e4a6ef501281e7ebfb09d586)
    {
        $this->folders = (array) $_31f582a0e4a6ef501281e7ebfb09d586;
    }
    
    
    
    
    
    public function UpdateFolders()
    {
        global $db;
        $this->DeleteFolders();
        foreach ((array) $this->folders as $_04e9bd7b0caa1ae86fc7cdbe362184f2) {
            if ($_04e9bd7b0caa1ae86fc7cdbe362184f2 > 0) {
                $db->query($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_721ad7071e" . "c787ae1d526" . "385298d7834"], $this->id, $_04e9bd7b0caa1ae86fc7cdbe362184f2);
            }
        }
    }
    
    
    
    
    
    
    protected function Init()
    {
        list($this->next_full, $this->next_inc) = array(new Date($this->next_full), new Date($this->next_inc));
        $this->SetStorage($this->storage_id);
        $this->folders = $this->GetSeriesFolders();
        $this->location = BackupTools::CreateFolder($this->storage->GetPath() . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_87daa84e346f64" . "20a3f3426e05d16" . "a7b"] . $this->name);
        $this->history = new BackupHistory($this->GetPath());
        return true;
    }
    public function GetSeriesFolders()
    {
        global $db;
        return $db->query($GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_9fc018a8ce329a1ff3" . "719df64b9962af"], $this->id)->fetchAllValues();
    }
}