Exemplo n.º 1
0
function lxshell_unzip_with_throw($dir, $file, $list = null)
{
    $ret = lxshell_unzip($dir, $file, $list);
    if ($ret) {
        throw new lxException("could_not_unzip_file", '');
    }
}
Exemplo n.º 2
0
function lxshell_exists_in_zip($archive, $file)
{
    $dir = createTempDir("/tmp", "testzip");
    $ret = lxshell_unzip("__system__", $dir, $archive, array($file));
    lxfile_tmp_rm_rec($dir);
    if (!$ret) {
        return true;
    }
    return false;
}
Exemplo n.º 3
0
 function getFromRemote($p)
 {
     $filepass = $this->main->filepass;
     getFromRemote($this->main->pasteserver_realip, $filepass[$p], $this->main->fullpath, $p);
     return;
     $bp = basename($p);
     if ($filepass[$p]['type'] === 'dir') {
         $tfile = lx_tmp_file("__path_tmp", "lx_{$bp}");
         getFromFileserv($this->main->pasteserver, $this->main->filepass[$p], $tfile);
         lxfile_mkdir("{$this->main->fullpath}/{$bp}");
         lxshell_unzip("__system__", "{$this->main->fullpath}/{$bp}", $tfile);
         lunlink($tfile);
     } else {
         getFromFileserv($this->main->pasteserver, $this->main->filepass[$p], "{$this->main->fullpath}/{$bp}");
     }
 }
Exemplo n.º 4
0
 function getAndUnzipSkeleton($ip, $filepass, $dir)
 {
     $oldir = getcwd();
     // File may be a variable path.
     dprintr($filepass);
     $file = $filepass['file'];
     // The thing is this needs to be executed even on secondary master and then the primary master would be down.
     // So if we cannot connect back, we just continue. Skeleton is not an important thing.
     try {
         getFromFileserv($ip, $filepass, "{$dir}/{$file}");
     } catch (exception $e) {
         return;
     }
     lxfile_generic_chown("{$dir}/{$file}", $this->username);
     lxshell_unzip($this->username, $dir, "{$dir}/{$file}");
     lunlink("{$dir}/{$file}");
     $this->replaceVariables("{$dir}/index.html");
     // --- also copy /home/kloxo/httpd/user-logo.png to each domain path
     if (lxfile_exists("../file/user-logo.png")) {
         lxfile_cp("../file/user-logo.png", "{$dir}/images/logo.png");
     }
 }
Exemplo n.º 5
0
function do_upgrade($upversion)
{
    global $gbl, $sgbl, $login, $ghtml;
    if (file_exists("/usr/local/lxlabs/.git")) {
        print "Development system.. Not upgrading --> exit!...\n";
        exit;
    }
    $program = $sgbl->__var_program_name;
    $programfile = "{$program}-" . $upversion . ".zip";
    lxfile_rm_rec("__path_program_htmlbase/htmllib/script");
    lxfile_rm_rec("__path_program_root/pscript");
    $saveddir = getcwd();
    lxfile_rm_rec("__path_program_htmlbase/download");
    lxfile_mkdir("download");
    chdir("download");
    print "Downloading {$programfile}.....\n";
    download_source("/{$program}/{$programfile}");
    print "Download Done....\n";
    lxshell_unzip("../..", $programfile);
    chdir($saveddir);
}
Exemplo n.º 6
0
Arquivo: lib.php Projeto: zseand/kloxo
function setDefaultPages()
{
    log_cleanup("Initialize some skeletons");
    $httpdpath = "/home/kloxo/httpd";
    $sourcezip = realpath("../file/skeleton.zip");
    $targetzip = "{$httpdpath}/skeleton.zip";
    $pages = array("default", "disable", "webmail", "cp");
    $newer = false;
    if (file_exists($sourcezip)) {
        if (!checkIdenticalFile($sourcezip, $targetzip)) {
            log_cleanup("- Copy  {$sourcezip} to {$targetzip}");
            system("cp -rf {$sourcezip} {$targetzip}");
            $newer = true;
        }
    }
    foreach ($pages as $k => $p) {
        if (!file_exists("/home/kloxo/httpd/{$p}")) {
            lxfile_mkdir("/home/kloxo/httpd/{$p}");
        }
        $inc = $p !== "cp" ? $p : "cp_config";
        log_cleanup("- Php files for {$p} web page");
        lxfile_cp("../file/{$inc}_inc.php", "{$httpdpath}/{$p}/inc.php");
        lxfile_cp("../file/default_index.php", "{$httpdpath}/{$p}/index.php");
        // by-pass this code because few update files
        /*
        	if ($newer) {
        		log_cleanup("- Skeleton for {$p} web page");
        		lxshell_unzip("__system__", "{$httpdpath}/{$p}/", $targetzip);
        	}
        	else {
        		log_cleanup("- No skeleton for {$p} web page");
        	}
        */
        log_cleanup("- Skeleton for {$p} web page");
        lxshell_unzip("__system__", "{$httpdpath}/{$p}/", $targetzip);
        system("chown -R lxlabs:lxlabs {$httpdpath}/{$p}/");
        system("find {$httpdpath}/{$p}/ -type f -name \"*.php*\" -exec chmod 644 {} \\;");
        system("find {$httpdpath}/{$p}/ -type d -exec chmod 755 {} \\;");
    }
    log_cleanup("- Php files for login web page");
    lxfile_cp("../file/default_index.php", "/usr/local/lxlabs/kloxo/httpdocs/login/index.php");
    lxfile_cp("../file/login_inc.php", "/usr/local/lxlabs/kloxo/httpdocs/login/inc.php");
    lxfile_unix_chown("/usr/local/lxlabs/kloxo/httpdocs/login/index.php", "lxlabs:lxlabs");
    lxfile_unix_chmod("/usr/local/lxlabs/kloxo/httpdocs/login/index.php", "0644");
    lxfile_unix_chown("/usr/local/lxlabs/kloxo/httpdocs/login/inc.php", "lxlabs:lxlabs");
    lxfile_unix_chmod("/usr/local/lxlabs/kloxo/httpdocs/login/inc.php", "0644");
    // by-pass this code because few update files
    /*
    	if ($newer) {
    		log_cleanup("- Skeleton for login web page");
    		lxshell_unzip("__system__", "/usr/local/lxlabs/kloxo/httpdocs/login", "../file/skeleton.zip");
    	}
    	else {
    		log_cleanup("- No skeleton for login web page");
    	}
    */
    log_cleanup("- Skeleton for login web page");
    lxshell_unzip("__system__", "/usr/local/lxlabs/kloxo/httpdocs/login", "../file/skeleton.zip");
    $usersourcezip = realpath("../file/user-skeleton.zip");
    $usertargetzip = "/home/kloxo/user-httpd/user-skeleton.zip";
    if (lxfile_exists($usersourcezip)) {
        if (!checkIdenticalFile($usersourcezip, $usertargetzip)) {
            log_cleanup("- Copy {$usersourcezip} to {$usertargetzip}");
            system("cp -rf {$usersourcezip} {$usertargetzip}");
        } else {
            log_cleanup("- No new user-skeleton");
        }
    } else {
        log_cleanup("- No exists user-skeleton");
    }
    $sourcelogo = realpath("../file/user-logo.png");
    $targetlogo = "{$httpdpath}/user-logo.png";
    if (lxfile_exists($sourcelogo)) {
        if (!checkIdenticalFile($sourcelogo, $targetlogo)) {
            lxfile_cp($sourcelogo, $targetlogo);
            foreach ($pages as $k => $p) {
                log_cleanup("- Copy user-logo for {$p}");
                lxfile_cp($targetlogo, "{$httpdpath}/{$p}/images/logo.png");
            }
        } else {
            log_cleanup("- No new user-logo");
        }
    } else {
        log_cleanup("- No exists user-logo");
    }
}