コード例 #1
0
 public function testzip_files_list()
 {
     //execute the method and verify the if zipped file exist
     $cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\');
     $file = $cache_dir . '/ziplistTest.zip';
     $files_list = array('config.php', 'config_override.php');
     if (file_exists($file)) {
         unlink($file);
     }
     $result = zip_files_list($file, $files_list);
     $this->assertTrue($result);
     $this->assertFileExists($file);
     unlink($file);
 }
コード例 #2
0
ファイル: Bug44896Test.php プロジェクト: jgera/sugarcrm_dev
 public function createTempModule()
 {
     if (!is_file(self::$manifest_location)) {
         file_put_contents(self::$manifest_location, $this->manifest_content);
         zip_files_list(self::$zip_location, array(self::$manifest_location));
     }
 }
コード例 #3
0
function get_encoded_portal_zip_file($session, $md5file, $last_sync, $is_md5_sync = 1)
{
    // files might be big
    global $sugar_config;
    ini_set("memory_limit", "-1");
    $md5 = "";
    $data = "";
    $error = new SoapError();
    $the_error = "";
    if (!validate_authenticated($session)) {
        $the_error = "Invalid session";
    }
    require "install/data/disc_client.php";
    $tempdir_parent = create_cache_directory("disc_client");
    $temp_dir = tempnam($tempdir_parent, "sug");
    sugar_mkdir($temp_dir, 0775);
    $temp_file = tempnam($temp_dir, "sug");
    write_encoded_file($md5file, $temp_dir, $temp_file);
    $ignore = false;
    //generate md5 files on server
    require_once $temp_file;
    $server_files = array();
    // used later for removing unneeded local files
    $zip_file = tempnam(tempdir_parent, $session);
    $root_files = array();
    $custom_files = array();
    $file_list = array();
    if (!$is_md5_sync) {
        if (is_dir("portal")) {
            $root_files = findAllTouchedFiles("portal", array(), $last_sync);
        }
        if (is_dir("custom/portal")) {
            $custom_files = findAllTouchedFiles("custom/portal", array(), $last_sync);
        }
        $all_src_files = array_merge($root_files, $custom_files);
        foreach ($all_src_files as $src_file) {
            $ignore = false;
            foreach ($disc_client_ignore as $ignore_pattern) {
                if (preg_match("#" . $ignore_pattern . "#", $src_file)) {
                    $ignore = true;
                }
            }
            if (!$ignore) {
                //we have to strip off portal or custom/portal before the src file to look it up
                $key = str_replace('custom/portal/', '', $src_file);
                $key = str_replace('portal/', '', $key);
                if ($client_file_list != null && isset($client_file_list[$key])) {
                    //we have found a file out of sync
                    $file_list[] = $src_file;
                    //since we have processed this element of the client
                    //list of files, remove it from the list
                    unset($client_file_list[$key]);
                } else {
                    //this file does not exist on the client side
                    $file_list[] = $src_file;
                }
            }
        }
    } else {
        if (is_dir("portal")) {
            $root_files = findAllFiles("portal", array());
        }
        if (is_dir("custom/portal")) {
            $custom_files = findAllFiles("custom/portal", array());
        }
        $all_src_files = array_merge($root_files, $custom_files);
        foreach ($all_src_files as $src_file) {
            $ignore = false;
            foreach ($disc_client_ignore as $ignore_pattern) {
                if (preg_match("#" . $ignore_pattern . "#", $src_file)) {
                    $ignore = true;
                }
            }
            if (!$ignore) {
                $value = md5_file($src_file);
                //we have to strip off portal or custom/portal before the src file to look it up
                $key = str_replace('custom/portal/', '', $src_file);
                $key = str_replace('portal/', '', $key);
                if ($client_file_list != null && isset($client_file_list[$key])) {
                    if ($value != $client_file_list[$key]) {
                        //we have found a file out of sync
                        $file_list[] = $src_file;
                        //since we have processed this element of the client
                        //list of files, remove it from the list
                    }
                    unset($client_file_list[$key]);
                } else {
                    //this file does not exist on the client side
                    $file_list[] = $src_file;
                }
            }
        }
    }
    zip_files_list($zip_file, $file_list, '|.*portal/|');
    $contents = sugar_file_get_contents($zip_file);
    // encode data
    $data = base64_encode($contents);
    unlink($zip_file);
    return array('result' => $data, 'error' => $error->get_soap_array());
}