Esempio n. 1
0
function frame3()
{
    global $islinux, $cmd_arg, $chmod_arg, $zip_dir, $fm_current_root, $cookie_cache_time;
    global $dir_dest, $current_dir, $dir_before;
    global $selected_file_list, $selected_dir_list, $old_name, $new_name;
    global $action, $or_by, $order_dir_list_by;
    if (!isset($order_dir_list_by)) {
        $order_dir_list_by = "1A";
        setcookie("order_dir_list_by", $order_dir_list_by, time() + $cookie_cache_time, "/");
    } elseif (strlen($or_by)) {
        $order_dir_list_by = $or_by;
        setcookie("order_dir_list_by", $or_by, time() + $cookie_cache_time, "/");
    }
    html_header();
    echo "<body>\n";
    if ($action) {
        switch ($action) {
            case 1:
                // create dir
                if (strlen($cmd_arg)) {
                    $cmd_arg = format_path($current_dir . $cmd_arg);
                    if (!file_exists($cmd_arg)) {
                        @mkdir($cmd_arg, 0755);
                        @chmod($cmd_arg, 0755);
                        reloadframe("parent", 2, "&ec_dir=" . $cmd_arg);
                    } else {
                        alert(et('FileDirExists') . ".");
                    }
                }
                break;
            case 2:
                // create arq
                if (strlen($cmd_arg)) {
                    $cmd_arg = $current_dir . $cmd_arg;
                    if (!file_exists($cmd_arg)) {
                        if ($fh = @fopen($cmd_arg, "w")) {
                            @fclose($fh);
                        }
                        @chmod($cmd_arg, 0644);
                    } else {
                        alert(et('FileDirExists') . ".");
                    }
                }
                break;
            case 3:
                // rename arq ou dir
                if (strlen($old_name) && strlen($new_name)) {
                    rename($current_dir . $old_name, $current_dir . $new_name);
                    if (is_dir($current_dir . $new_name)) {
                        reloadframe("parent", 2);
                    }
                }
                break;
            case 4:
                // delete sel
                if (strstr($current_dir, $fm_current_root)) {
                    if (strlen($selected_file_list)) {
                        $selected_file_list = explode("<|*|>", $selected_file_list);
                        if (count($selected_file_list)) {
                            for ($x = 0; $x < count($selected_file_list); $x++) {
                                $selected_file_list[$x] = trim($selected_file_list[$x]);
                                if (strlen($selected_file_list[$x])) {
                                    total_delete($current_dir . $selected_file_list[$x], $dir_dest . $selected_file_list[$x]);
                                }
                            }
                        }
                    }
                    if (strlen($selected_dir_list)) {
                        $selected_dir_list = explode("<|*|>", $selected_dir_list);
                        if (count($selected_dir_list)) {
                            for ($x = 0; $x < count($selected_dir_list); $x++) {
                                $selected_dir_list[$x] = trim($selected_dir_list[$x]);
                                if (strlen($selected_dir_list[$x])) {
                                    total_delete($current_dir . $selected_dir_list[$x], $dir_dest . $selected_dir_list[$x]);
                                }
                            }
                            reloadframe("parent", 2);
                        }
                    }
                }
                break;
            case 5:
                // copy sel
                if (strlen($dir_dest)) {
                    if (uppercase($dir_dest) != uppercase($current_dir)) {
                        if (strlen($selected_file_list)) {
                            $selected_file_list = explode("<|*|>", $selected_file_list);
                            if (count($selected_file_list)) {
                                for ($x = 0; $x < count($selected_file_list); $x++) {
                                    $selected_file_list[$x] = trim($selected_file_list[$x]);
                                    if (strlen($selected_file_list[$x])) {
                                        total_copy($current_dir . $selected_file_list[$x], $dir_dest . $selected_file_list[$x]);
                                    }
                                }
                            }
                        }
                        if (strlen($selected_dir_list)) {
                            $selected_dir_list = explode("<|*|>", $selected_dir_list);
                            if (count($selected_dir_list)) {
                                for ($x = 0; $x < count($selected_dir_list); $x++) {
                                    $selected_dir_list[$x] = trim($selected_dir_list[$x]);
                                    if (strlen($selected_dir_list[$x])) {
                                        total_copy($current_dir . $selected_dir_list[$x], $dir_dest . $selected_dir_list[$x]);
                                    }
                                }
                                reloadframe("parent", 2);
                            }
                        }
                        $current_dir = $dir_dest;
                    }
                }
                break;
            case 6:
                // move sel
                if (strlen($dir_dest)) {
                    if (uppercase($dir_dest) != uppercase($current_dir)) {
                        if (strlen($selected_file_list)) {
                            $selected_file_list = explode("<|*|>", $selected_file_list);
                            if (count($selected_file_list)) {
                                for ($x = 0; $x < count($selected_file_list); $x++) {
                                    $selected_file_list[$x] = trim($selected_file_list[$x]);
                                    if (strlen($selected_file_list[$x])) {
                                        total_move($current_dir . $selected_file_list[$x], $dir_dest . $selected_file_list[$x]);
                                    }
                                }
                            }
                        }
                        if (strlen($selected_dir_list)) {
                            $selected_dir_list = explode("<|*|>", $selected_dir_list);
                            if (count($selected_dir_list)) {
                                for ($x = 0; $x < count($selected_dir_list); $x++) {
                                    $selected_dir_list[$x] = trim($selected_dir_list[$x]);
                                    if (strlen($selected_dir_list[$x])) {
                                        total_move($current_dir . $selected_dir_list[$x], $dir_dest . $selected_dir_list[$x]);
                                    }
                                }
                                reloadframe("parent", 2);
                            }
                        }
                        $current_dir = $dir_dest;
                    }
                }
                break;
            case 71:
                // compress sel
                if (strlen($cmd_arg)) {
                    ignore_user_abort(true);
                    ini_set("display_errors", 0);
                    ini_set("max_execution_time", 0);
                    $zipfile = false;
                    if (strstr($cmd_arg, ".tar")) {
                        $zipfile = new tar_file($cmd_arg);
                    } elseif (strstr($cmd_arg, ".zip")) {
                        $zipfile = new zip_file($cmd_arg);
                    } elseif (strstr($cmd_arg, ".bzip")) {
                        $zipfile = new bzip_file($cmd_arg);
                    } elseif (strstr($cmd_arg, ".gzip")) {
                        $zipfile = new gzip_file($cmd_arg);
                    }
                    if ($zipfile) {
                        $zipfile->set_options(array('basedir' => $current_dir, 'overwrite' => 1, 'level' => 3));
                        if (strlen($selected_file_list)) {
                            $selected_file_list = explode("<|*|>", $selected_file_list);
                            if (count($selected_file_list)) {
                                for ($x = 0; $x < count($selected_file_list); $x++) {
                                    $selected_file_list[$x] = trim($selected_file_list[$x]);
                                    if (strlen($selected_file_list[$x])) {
                                        $zipfile->add_files($selected_file_list[$x]);
                                    }
                                }
                            }
                        }
                        if (strlen($selected_dir_list)) {
                            $selected_dir_list = explode("<|*|>", $selected_dir_list);
                            if (count($selected_dir_list)) {
                                for ($x = 0; $x < count($selected_dir_list); $x++) {
                                    $selected_dir_list[$x] = trim($selected_dir_list[$x]);
                                    if (strlen($selected_dir_list[$x])) {
                                        $zipfile->add_files($selected_dir_list[$x]);
                                    }
                                }
                            }
                        }
                        $zipfile->create_archive();
                    }
                    unset($zipfile);
                }
                break;
            case 72:
                // decompress arq
                if (strlen($cmd_arg)) {
                    if (file_exists($current_dir . $cmd_arg)) {
                        $zipfile = false;
                        if (strstr($cmd_arg, ".zip")) {
                            zip_extract();
                        } elseif (strstr($cmd_arg, ".bzip") || strstr($cmd_arg, ".bz2") || strstr($cmd_arg, ".tbz2") || strstr($cmd_arg, ".bz") || strstr($cmd_arg, ".tbz")) {
                            $zipfile = new bzip_file($cmd_arg);
                        } elseif (strstr($cmd_arg, ".gzip") || strstr($cmd_arg, ".gz") || strstr($cmd_arg, ".tgz")) {
                            $zipfile = new gzip_file($cmd_arg);
                        } elseif (strstr($cmd_arg, ".tar")) {
                            $zipfile = new tar_file($cmd_arg);
                        }
                        if ($zipfile) {
                            $zipfile->set_options(array('basedir' => $current_dir, 'overwrite' => 1));
                            $zipfile->extract_files();
                        }
                        unset($zipfile);
                        reloadframe("parent", 2);
                    }
                }
                break;
            case 8:
                // delete arq/dir
                if (strlen($cmd_arg)) {
                    if (file_exists($current_dir . $cmd_arg)) {
                        total_delete($current_dir . $cmd_arg);
                    }
                    if (is_dir($current_dir . $cmd_arg)) {
                        reloadframe("parent", 2);
                    }
                }
                break;
            case 9:
                // CHMOD
                if (strlen($chmod_arg) == 4 && strlen($current_dir)) {
                    if ($chmod_arg[0] == "1") {
                        $chmod_arg = "0" . $chmod_arg;
                    } else {
                        $chmod_arg = "0" . substr($chmod_arg, strlen($chmod_arg) - 3);
                    }
                    $new_mod = octdec($chmod_arg);
                    if (strlen($selected_file_list)) {
                        $selected_file_list = explode("<|*|>", $selected_file_list);
                        if (count($selected_file_list)) {
                            for ($x = 0; $x < count($selected_file_list); $x++) {
                                $selected_file_list[$x] = trim($selected_file_list[$x]);
                                if (strlen($selected_file_list[$x])) {
                                    @chmod($current_dir . $selected_file_list[$x], $new_mod);
                                }
                            }
                        }
                    }
                    if (strlen($selected_dir_list)) {
                        $selected_dir_list = explode("<|*|>", $selected_dir_list);
                        if (count($selected_dir_list)) {
                            for ($x = 0; $x < count($selected_dir_list); $x++) {
                                $selected_dir_list[$x] = trim($selected_dir_list[$x]);
                                if (strlen($selected_dir_list[$x])) {
                                    @chmod($current_dir . $selected_dir_list[$x], $new_mod);
                                }
                            }
                        }
                    }
                }
                break;
        }
        if ($action != 10) {
            dir_list_form();
        }
    } else {
        dir_list_form();
    }
    echo "</body>\n</html>";
}
function auto_update_showpage()
{
    global $db, $main_smarty, $the_template, $template_dir;
    include_once 'config.php';
    include_once mnminclude . 'html1.php';
    include_once mnminclude . 'link.php';
    include_once mnminclude . 'tags.php';
    include_once mnminclude . 'smartyvariables.php';
    include_once "archive.php";
    // Create mysql backup
    if ($_GET['download'] == 'mysql') {
        set_time_limit(0);
        require "auto_update_backup.php";
        $b = new MysqlBackup($_GET['type'] == 'zip' ? '' : $_GET['type']);
        $tmpfname = $b->backup();
        header('Content-Description: File Transfer');
        header('Pragma: no-cache');
        header('Content-Type: application/force-download');
        header('Cache-Control: no-cache, must-revalidate');
        header("Content-Disposition: attachment; filename=pligg_db_backup_" . date("Y_m_d") . ".sql" . ($_GET['type'] == 'gzip' ? '.gz' : ($_GET['type'] == 'zip' ? '.zip' : '')));
        if ($_GET['type'] == 'zip') {
            $test = new zip_file(tempnam('/tmp', ''));
            $test->set_options(array('inmemory' => 1, 'storepaths' => 0));
            $test->add_files(array($tmpfname));
            $test->create_archive();
            print $test->archive;
        } else {
            readfile($tmpfname);
            unlink($tmpfname);
        }
        exit;
    } elseif ($_GET['download'] == 'files') {
        set_time_limit(0);
        $tmpfname = tempnam('/tmp', '');
        if ($_GET['type'] == 'gzip') {
            $test = new gzip_file($tmpfname);
            $test->set_options(array('inmemory' => 1, 'basedir' => "./", 'overwrite' => 1, 'level' => 1));
        } else {
            $test = new zip_file($tmpfname);
            $test->set_options(array('inmemory' => 1, 'recurse' => 1, 'storepaths' => 1));
        }
        $test->add_files("*");
        $test->exclude_files("./cache/*");
        $test->create_archive();
        // Check for errors (you can check for errors at any point)
        if (count($test->errors) > 0) {
            print "Errors occurred.";
        }
        // Process errors here
        header('Content-Description: File Transfer');
        header('Pragma: no-cache');
        header('Content-Type: application/force-download');
        header('Cache-Control: no-cache, must-revalidate');
        header("Content-Disposition: attachment; filename=pligg_backup_" . date("Y_m_d") . ($_GET['type'] == 'gzip' ? '.tar.gz' : '.zip'));
        // Send archive to user for download
        print $test->archive;
        exit;
    }
    $main_smarty = do_sidebar($main_smarty);
    force_authentication();
    $canIhaveAccess = 0;
    $canIhaveAccess = $canIhaveAccess + checklevel('god');
    if ($canIhaveAccess == 1) {
        // breadcrumbs
        $main_smarty->assign('navbar_where', $navwhere);
        $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'));
        // breadcrumbs
        define('modulename', 'status');
        $main_smarty->assign('modulename', modulename);
        define('pagename', 'admin_modifystatus');
        $main_smarty->assign('pagename', pagename);
        if ($_GET['step'] == 2) {
            $main_smarty->assign('gzip', function_exists('gzopen'));
            $main_smarty->assign('zip', class_exists('ZipArchive', FALSE));
            $main_smarty->assign('tpl_center', auto_update_tpl_path . 'auto_update_step2');
        } elseif ($_GET['step'] == 3) {
            $_SESSION['upload_files'] = array();
            $main_smarty->assign('exists', !file_exists(mnmpath . "latest.zip") ? 'disabled' : '');
            $main_smarty->assign('tpl_center', auto_update_tpl_path . 'auto_update_step3');
        } elseif ($_GET['step'] == 4) {
            $main_smarty->assign('tpl_center', auto_update_tpl_path . 'auto_update_step4');
        } elseif ($_GET['step'] == 5) {
            $main_smarty->assign('upgrade_exists', file_exists('install/upgrade.php'));
            $main_smarty->assign('tpl_center', auto_update_tpl_path . 'auto_update_step5');
        } elseif ($_GET['step'] == 6) {
            $main_smarty->assign('tpl_center', auto_update_tpl_path . 'auto_update_step6');
        } else {
            $main_smarty->assign('tpl_center', auto_update_tpl_path . 'auto_update_main');
        }
        list($yourversion, $latestversion) = auto_update_detect_version();
        $main_smarty->assign('yourversion', $yourversion);
        $main_smarty->assign('latestversion', $latestversion);
        $main_smarty->display($template_dir . '/admin/admin.tpl');
    } else {
        header("Location: " . getmyurl('login', $_SERVER['REQUEST_URI']));
        die;
    }
}
Esempio n. 3
0
 /** Update routine.
  * This function represents the update routine, which will perform updates in background while the bot runs normally.
  * 
  * \return Nothing.
  */
 public function updateRoutine()
 {
     foreach ($this->_scheduled as $i => &$update) {
         if (!$update['started']) {
             Leelabot::message("Downloading update \$0...", array($this->_updates[$update['i']]->rev));
             if (!is_dir('tmp')) {
                 mkdir('tmp');
             }
             $update['started'] = TRUE;
             $update['infp'] = fopen($this->_updates[$update['i']]->url, 'r');
             $update['outfp'] = fopen('tmp/update_' . $this->_updates[$update['i']]->rev . '.tar.gz', 'w+');
         }
         //If we haven't downloaded all the file
         if (!feof($update['infp'])) {
             fputs($update['outfp'], fread($update['infp'], 1024));
             return;
         }
         Leelabot::message("Installing update \$0...", array($this->_updates[$update['i']]->rev));
         $gz = new gzip_file("tmp/update_" . $this->_updates[$update['i']]->rev . '.tar.gz');
         $gz->set_options(array('overwrite' => 1));
         $gz->extract_files();
         Leelabot::message("Update \$0 done.", array($this->_updates[$update['i']]->rev));
         unset($this->_scheduled[$i]);
     }
 }
Esempio n. 4
0
         $errorcount++;
         if ($config["debug"]) {
             echo $extracter->error;
         }
         //$errors.="<li>".$_FILES[$id."file_".$i]["name"]." ".$this->Lang("unpackfail");
         //$errors.=implode(",",$extracter->error)."</li>\n";
     } else {
         $message = "newuploadsuccess";
         $messagecount++;
         //$messages.="<li>".$_FILES[$id."file_".$i]["name"]." ".$this->Lang("unpacksuccess")."</li>\n";
     }
     break;
 case "bzip":
 case "bz":
     include_once dirname(__FILE__) . "/untgz.php";
     $extracter = new gzip_file($_FILES[$id . "file_" . $i]["tmp_name"]);
     $extracter->set_options(array("basedir" => $fullpath . "/tmp/testtmp/", "overwrite" => 1));
     $extracter->extract_files();
     if (count($extracter->error) > 0) {
         //$errors.="<li>".$_FILES[$id."file_".$i]["name"]." ".$this->Lang("unpackfail");
         //$errors.=implode(",",$extracter->error)."</li>\n";
         $error = "newuploadfailed";
         $errorcount++;
         if ($config["debug"]) {
             echo $extracter->error;
         }
     } else {
         $message = "newuploadsuccess";
         $messagecount++;
         //$messages.="<li>".$_FILES[$id."file_".$i]["name"]." ".$this->Lang("unpacksuccess")."</li>\n";
     }
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     //
//                                                                            //
//   This product released under GNU General Public License v2                //
////////////////////////////////////////////////////////////////////////////////
if (isset($_POST['deletebackupility'])) {
    $d = opendir(BACKUP_PATH);
    while ($f = readdir($d)) {
        if (is_file(BACKUP_PATH . $f)) {
            rcms_delete_files(BACKUP_PATH . $f);
        }
    }
    closedir($d);
}
if (!empty($_POST['backupit'])) {
    $bkupfilename = './backups/backup_' . date('H-i-s_d.m.Y') . '.tar.gz';
    $bkp = new gzip_file($bkupfilename);
    $bkp->set_options(array('basedir' => RCMS_ROOT_PATH, 'overwrite' => 1, 'level' => 9));
    $bkp->add_files('config');
    $bkp->add_files('content');
    $bkp->create_archive();
    $frm = new InputForm("", "post", $lang['admincp']['general']['backup']['getit']);
    $frm->addbreak($lang['admincp']['general']['backup']['done']);
    $frm->hidden('getit', basename($bkupfilename));
    $frm->show();
}
if (!empty($_POST['getit'])) {
    ob_end_clean();
    header('Content-Type: x-gzip');
    header("Content-disposition: attachment; filename={$_POST['getit']}");
    readfile(BACKUP_PATH . $_POST['getit']);
    exit;
Esempio n. 6
0
 public function restore($backup_id)
 {
     //clear stage cache
     $this->delStage(self::RESTORE_STAGE);
     chdir(sfConfig::get('sf_root_dir'));
     /*
      * TELL VA to reset stuff
      */
     $node_list = EtvaNodePeer::doSelect(new Criteria());
     $node_num = count($node_list);
     if ($node_num != 1) {
         /*
          * ERROR should be only one element (standard ETVA release only)
          */
         $msg = "Sould only be one Virtualization Agent! {$node_num} found!";
         $data = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'info' => $msg, 'error' => $msg);
         return $data;
     }
     $node = $node_list[0];
     /*
      * check node state ok to comm with agent
      */
     if (!$node->getState()) {
         $node_name = $node->getName();
         $msg = sfContext::getInstance()->getI18N()->__(EtvaNodePeer::_STATE_DOWN_, array('%name%' => $node_name));
         $data = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'action' => 'check_nodes', 'info' => $msg, 'error' => $msg);
         return $data;
     }
     $this->disable();
     /*
      *
      * FIRST THING....CLEANUP DESTINATION FOLDER AND GET RESTORE ARCHIVE
      *
      */
     IOFile::unlinkRecursive($this->archive_base_dir, false);
     $full_path = $this->archive_base_dir . '/' . self::ARCHIVE_FILE;
     $this->setStage(self::RESTORE_STAGE, self::GET_RESTORE);
     $response = $this->getApplianceBackup($backup_id, $full_path);
     /*
      *
      * DECOMPRESS BACKUP ARCHIVE
      *
      */
     $this->setStage(self::RESTORE_STAGE, self::ARCHIVE_RESTORE);
     $create_gz = new gzip_file($full_path);
     $base_dir = $this->archive_base_dir;
     $create_gz->set_options(array('basedir' => $base_dir, 'overwrite' => 1));
     $create_gz->extract_files();
     /*
      * get DB file and put in tmp_db_filename
      */
     $db_filename = $base_dir . '/' . self::DB_FILE;
     if (!file_exists($db_filename)) {
         return array('success' => false, 'error' => 'no file');
     }
     // move DB backup to correct folder...
     rename($db_filename, $this->tmp_db_filename);
     /*
      *
      * CLEAN DB ????
      *
      */
     /*
      * delete tables and build again....
      */
     $command = "symfony propel:insert-sql --no-confirmation";
     $path = sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR . "utils";
     ob_start();
     passthru('echo ' . $command . ' | sudo /usr/bin/php -f ' . $path . DIRECTORY_SEPARATOR . 'sudoexec.php', $return);
     $result = ob_get_contents();
     ob_end_clean();
     if ($result != 0 || $return != 0) {
         $msg = 'An error occurred while deleting DB. Aborted!' . $status;
         $data = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'action' => self::DB_RESTORE, 'info' => $msg, 'error' => $msg);
         return $data;
     }
     /*
      *
      * RESTORE CENTRAL MANAGEMENT BACKUP (DB)
      *
      *
      */
     $this->setStage(self::RESTORE_STAGE, self::DB_RESTORE);
     /*
      * load data to DB
      */
     //sfContext::getInstance()->getStorage()->regenerate(true);
     exec("symfony propel:data-load " . $this->tmp_db_filename, $output, $status);
     if ($status != 0) {
         // aconteceu erro
         $msg = 'An error occurred while generating DB dump. Aborted!' . $status;
         $data = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'action' => self::DB_RESTORE, 'info' => $msg, 'error' => $msg);
         return $data;
     }
     /*
      * 
      * generate session to stay logged in...
      *
      */
     sfContext::getInstance()->getStorage()->regenerate();
     $this->setStage(self::RESTORE_STAGE, self::VA_RESET);
     $node_va = new EtvaNode_VA($node);
     /*
      * get new uuid from DB
      */
     $backup_node = EtvaNodePeer::doSelectOne(new Criteria());
     $uuid = $backup_node->getUuid();
     $response = $node_va->send_change_uuid($uuid);
     if (!$response['success']) {
         return $response;
     }
     $response = array('success' => true);
     return $response;
 }
Esempio n. 7
0
 function ImportExtInc($filename)
 {
     include_once 'ext_scripts/archive.php';
     $zip = new gzip_file($filename);
     $zip->set_options(array('basedir' => '.', 'overwrite' => 1));
     $zip->extract_files();
 }
Esempio n. 8
0
 function ExportExtInc($filename)
 {
     include_once 'ext_scripts/archive.php';
     $zip = new gzip_file($filename);
     $zip->set_options(array('basedir' => '.', 'overwrite' => 1, 'level' => 1, 'inmemory' => 1));
     $zip->add_files(array('ext_inc'));
     #$zip->exclude_files("ext_inc/.svn/*");
     $zip->create_archive();
     header('Content-Type: application/octetstream; charset=utf-8');
     header("Content-Disposition: attachment; filename=\"{$filename}\"");
     $zip->download_file();
     if (count($zip->errors) > 0) {
         return false;
     }
     return true;
 }
Esempio n. 9
0
         /* File creation failed */
         echo "File creation of {$filename} failed";
         $have_file = false;
     } else {
         /* File creation succeeded */
         if (fwrite($fp, $file_contents)) {
             $have_file = true;
         } else {
             $have_file = false;
         }
         fclose($fp);
     }
 }
 if ($have_file) {
     require "archive.php";
     $test = new gzip_file($filename);
     $test->set_options(array('overwrite' => 1, 'inmemory' => 0));
     $test->extract_files();
     /* Doesn't create directories when running as inmemory and */
     /* doesn't create the list of files running without...     */
     $test->set_options(array('overwrite' => 1, 'inmemory' => 1));
     $test->extract_files();
     $test->make_list();
     foreach ($test->files as $file) {
         $sql = "INSERT INTO module_files (module_id, file_name) VALUES ({$module_id}, " . sanitize($file['name']) . ")";
         $result = mysqli_query($connection, $sql) or die(mysqli_error($connection));
     }
     if (isset($xml->patch->base)) {
         require "phppatcher.php";
         $patch = new PhpPatcher($xml->patch->base);
         $patch->Merge(base64_decode($xml->patch->diff));
Esempio n. 10
0
function makeArchive($fD)
{
    $my_time = time();
    $my_key = CUtils::genKey(8);
    $objResponse = new xajaxResponse();
    $objResponse->assign("archive_info", 'innerHTML', '');
    $filename = 'admin/backup/' . date('YmdHi', $my_time) . '_' . $my_key . '.tar.gz';
    $filename_sql = 'admin/backup/' . date('YmdHi', $my_time) . '_' . $my_key . '.sql';
    $filename_sql2 = 'admin/backup/' . date('YmdHi', $my_time) . '_' . $my_key . '_after_connect.sql';
    $f = fopen($GLOBALS['PRJ_DIR'] . '/' . $filename_sql2, "a");
    fwrite($f, "/*!41000 SET NAMES 'cp1251' */;");
    fclose($f);
    set_time_limit(0);
    $GLOBALS['db']->backupDB($filename_sql);
    inc_lib('tools/CArchive.php');
    $test = new gzip_file($filename);
    $test->set_options(array('basedir' => $GLOBALS['PRJ_DIR'] . '/', 'overwrite' => 1, 'level' => 5));
    $test->add_files(array("*.*"));
    //$test->exclude_files(array("admin/lib/templates_c/*.php", "*.gz"));
    $cfiles = 0;
    $sfiles = 0;
    foreach ($test->files as $key => $current) {
        if (stristr($current['name'], '.tar.gz')) {
            unset($test->files[$key]);
        } else {
            $sfiles += $current['stat'][7];
            $cfiles++;
        }
    }
    $test->create_archive();
    $text = '';
    $text .= 'Количество файлов: ' . $cfiles;
    $text .= '<br>';
    $text .= 'Размер неупакованых файлов: ' . CUtils::getSize($sfiles, 2);
    $text .= '<br>';
    $text .= 'Размер архива: ' . CUtils::getFileSize('/' . $filename, 2);
    //$text = 'test';
    @unlink($GLOBALS['PRJ_DIR'] . '/' . $filename_sql);
    @unlink($GLOBALS['PRJ_DIR'] . '/' . $filename_sql2);
    $objResponse->assign("archive_info", 'innerHTML', $text);
    $objResponse->script("hideDiv('waiting');window.location.reload()");
    return $objResponse;
}