Exemplo n.º 1
0
function StartRestore($va)
{
    global $scDb;
    $nKey = (int) $va['nKey'];
    $nEnd = (int) $va['nEnd'];
    $vaTable = unserialize(GetSession("cRestore_File"));
    $cDir = "./tmp/db_restore/folder/";
    if ($nKey == 0) {
        //ddl
        if (is_file($cDir . "ddl.scdb")) {
            include_once $cDir . "ddl.scdb";
        }
    } else {
        //table
        $cFile = $vaTable[$nKey - 1];
        if (is_file($cFile)) {
            include_once $cFile;
        }
    }
    $nKey++;
    if ($nKey < $nEnd) {
        echo ' console.log("' . $cFile . '") ;onProgress_Restore(' . $nKey . ',' . $nEnd . ') ';
    } else {
        echo ' $("#tab_1").find(".cText").html("Compressing") ;';
        $cFileName = $cFolder . "scDB_" . date("dmY_his") . ".backup";
        scOdt::scZipFile($cFolder, $cFileName);
        echo '	 
					$("#tab_2").find(".cText").html("Finish") ;   
					$("#tab_2").find(".progress-bar").attr("aria-valuenow","100") ; 
  					$("#tab_2").find(".progress-bar").css("width","100%") ; 
					$(".cmdRestore").button("reset") ; 
				';
    }
}
Exemplo n.º 2
0
    public function ReplaceData($vaArray = array(), $vaImages = array())
    {
        $this->OpenFile();
        //replace data
        //key => adalah key dengan tambahan {}
        //value => isi yang akan direplace
        if ($this->lValid) {
            //get file content
            $cFile = $this->cDirTmp . $this->objFileReplace;
            if (is_file($cFile)) {
                $cContent = file_get_contents($cFile, FILE_USE_INCLUDE_PATH);
                foreach ($vaArray as $key => $value) {
                    $cContent = str_replace("{" . $key . "}", $value, $cContent);
                }
            }
            //open file and rewrite
            file_put_contents($cFile, $cContent);
            //packetkan lada
            //get ekstension
            $vaFile = pathinfo($this->cLocFile);
            $cNameOutput = $this->cDirTmp . $this->cJudul . time() . "." . $vaFile['extension'];
            if (!empty($vaImages)) {
                //va imgages key
                //loc images server
                //name file
                if ($this->objFolderImage !== "") {
                    $cDirImages = $this->cDirTmp . $this->objFolderImage;
                    foreach ($vaImages as $cKey => $vaValue) {
                        if ($vaFile['extension'] == "docx") {
                            //remove dlu imagesnya
                            unlink($cDirImages . $vaValue['name']);
                            if (!copy($vaValue['loc'], $cDirImages . $vaValue['name'])) {
                                echo $vaValue['loc'] . " " . $cDirImages . $vaValue['name'];
                            }
                        }
                    }
                }
            }
            scOdt::scZipFile($this->cDirTmp, $cNameOutput);
            $cFile = "./scdownload.odt.php";
            if (!is_file($cFile)) {
                $cFile = "../scdownload.odt.php";
            }
            if ($this->cJeru !== "") {
                $cNameOutput = str_replace($this->cLocTmp, $this->cJeru, $cNameOutput);
                $this->cDirTmp = str_replace($this->cLocTmp, $this->cJeru, $this->cDirTmp);
            }
            $cReturn = $cFile . "?file=" . rawurlencode($cNameOutput) . "&cDir=" . rawurlencode($this->cDirTmp);
            echo '  //alert("' . $this->cDirTmp . '") ;
						window.location.href = "' . $cReturn . '" ; 
						//window.open("' . $cReturn . '","_blank") ; 
					';
        } else {
            print $this->cErr;
        }
    }