function unzipFile($filename, $filenameRail, $feedDirectory)
{
    $results = unzip($filename, $dest_dir = false, $create_zip_name_dir = true, $overwrite = true);
    $results2 = unzip($filenameRail, $dest_dir = false, $create_zip_name_dir = true, $overwrite = true);
    $filenameRailFolder = $feedDirectory . "/gtfs/" . basename($filenameRail, ".zip");
    $test = copy_directory($filenameRailFolder, $feedDirectory . "/" . basename($filenameRail, ".zip"));
}
Exemple #2
0
function install()
{
    if (!isset($_GET['step'])) {
        hello_screen();
    } else {
        $step = $_GET['step'];
        switch ($step) {
            case 'test':
                testserver();
                break;
            case 'unzip':
                unzip();
                break;
            case 'database':
                dbconfig();
                break;
            case 'admin':
                adminconf();
                break;
            case 'final':
                finalstep();
                break;
            default:
                hello_screen();
        }
    }
}
Exemple #3
0
function getOSZ($id)
{
    $osz = downloadOSZ($id);
    if ($osz === true) {
        unzip(ROOT . '/ddl/' . $id . '.osz', ROOT . '/ddl/' . $id . '/');
    } else {
        echo $osz . 'sec';
    }
}
 function uploadSkin()
 {
     // Check for upload error
     if ($_FILES["uploadSkin"]["error"]) {
         $this->esoTalk->message("invalidSkin");
         return false;
     }
     // Move the uploaded file
     move_uploaded_file($_FILES["uploadSkin"]["tmp_name"], "skins/{$_FILES["uploadSkin"]["name"]}");
     // Upzip it
     if (!($files = unzip("skins/{$_FILES["uploadSkin"]["name"]}", "skins/"))) {
         $this->esoTalk->message("invalidSkin");
     } else {
         $directories = 0;
         $infoFound = false;
         $skinFound = false;
         foreach ($files as $k => $file) {
             if (substr($file["name"], 0, 9) == "__MACOSX/" or substr($file["name"], -9) == ".DS_Store") {
                 unset($files[$k]);
                 continue;
             }
             if ($file["directory"]) {
                 $directories++;
             }
             if (substr($file["name"], -8) == "skin.php") {
                 $skinFound = true;
             }
         }
         // If we found a skin.php, info.php, and a base directory, write the files
         if ($skinFound and $directories == 1) {
             $error = false;
             foreach ($files as $k => $file) {
                 if ($file["directory"] and !is_dir("skins/{$file["name"]}")) {
                     mkdir("skins/{$file["name"]}");
                 } elseif (!$file["directory"]) {
                     if (file_exists("skins/{$file["name"]}") and !is_writeable("skins/{$file["name"]}")) {
                         $this->esoTalk->message("notWritable", false, "skins/{$file["name"]}");
                         $error = true;
                         break;
                     }
                     $handle = fopen("skins/{$file["name"]}", "w");
                     chmod("skins/{$file["name"]}", 0777);
                     fwrite($handle, $file["content"]);
                     fclose($handle);
                 }
             }
             if (!$error) {
                 $this->esoTalk->message("skinAdded");
             }
         } else {
             $this->esoTalk->message("invalidSkin");
         }
     }
     unlink("skins/{$_FILES["uploadSkin"]["name"]}");
 }
function setOpenZipFile($vars_file, $vars_code)
{
    $i = 0;
    $vars_array = array();
    $zip = @zip_open($vars_file);
    if ($zip) {
        echo 'id;filename;filesize;md5' . "\n\r";
        while ($zip_entry = zip_read($zip)) {
            if (zip_entry_filesize($zip_entry) > 0) {
                $i++;
                $vars_array = unzip($vars_file, $i);
                echo $i . ';' . zip_entry_name($zip_entry) . ';' . zip_entry_filesize($zip_entry) . ';' . md5($vars_array[1]) . "\n\r";
            }
        }
        zip_close($zip);
    }
}
 public function testunzip()
 {
     //execute the method and test if it returns true and verify the if unzipped files exist
     $cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\');
     $files_list = array('config.php', 'config_override.php');
     $file = $cache_dir . '/zipTest.zip';
     //creata a zip file first, to unzip
     if (!file_exists($file)) {
         zip_files_list($file, $files_list);
     }
     $result = unzip($file, $cache_dir);
     $this->assertTrue($result);
     $this->assertFileExists($cache_dir . '/config.php');
     $this->assertFileExists($cache_dir . '/config_override.php');
     unlink($cache_dir . '/config.php');
     unlink($cache_dir . '/config_override.php');
 }
Exemple #7
0
     require CLASS_DIR . 'options/md5change.php';
     md5_change();
     break;
 case 'md5_change_go':
     if (!empty($options['disable_md5_change'])) {
         break;
     }
     require CLASS_DIR . 'options/md5change.php';
     md5_change_go();
     break;
 case 'unzip':
     if (!empty($options['disable_unzip'])) {
         break;
     }
     require CLASS_DIR . 'options/unzip.php';
     unzip();
     break;
 case 'unzip_go':
     if (!empty($options['disable_unzip'])) {
         break;
     }
     require CLASS_DIR . 'options/unzip.php';
     unzip_go();
     break;
 case 'split':
     if (!empty($options['disable_split'])) {
         break;
     }
     require CLASS_DIR . 'options/split.php';
     rl_split();
     break;
Exemple #8
0
 public function testExtractFailsWhenExtractDirectoryDoesNotExist()
 {
     $this->assertFalse(unzip($this->testdir . '/testarchive.zip', $this->testdir . '/testarchiveoutputnothere'));
 }
Exemple #9
0
 public function restore_backup()
 {
     //Upload File
     $file_upload = $this->do_upload();
     $filename = $file_upload['file_name'];
     $filname_without_ext = pathinfo($filename, PATHINFO_FILENAME);
     if (isset($file_upload['error'])) {
         $data['error'] = $file_upload['error'];
         $this->load->view('templates/header');
         $this->load->view('templates/menu');
         $this->load->view('settings/backup', $data);
         $this->load->view('templates/footer');
     } elseif ($file_upload['file_ext'] != '.zip') {
         $data['error'] = "The file you are trying to upload is not a .zip file. Please try again.";
         $this->load->view('templates/header');
         $this->load->view('templates/menu');
         $this->load->view('settings/backup', $data);
         $this->load->view('templates/footer');
     } else {
         $data['file_upload'] = $file_upload;
         //Unzip
         $full_path = $file_upload['full_path'];
         $file_path = $file_upload['file_path'];
         $raw_name = $file_upload['raw_name'];
         $return_code = unzip($full_path, $file_path);
         if ($return_code === TRUE) {
             //execute sql file
             $sql_file_name = $file_path . $raw_name . '.sql';
             $file_content = file_get_contents($sql_file_name);
             $query_list = explode(";", $file_content);
             foreach ($query_list as $query) {
                 //Remove Comments like # # Commment #
                 $pos1 = strpos($query, "#\n# ");
                 if ($pos1 !== FALSE) {
                     $pos2 = strpos($query, "\n#", $pos1 + 3);
                     $comment = substr($query, $pos1, $pos2 - $pos1) . "<br/>";
                     $query = substr($query, $pos2 + 2);
                 }
                 $this->db->query($query);
             }
         } else {
             $data['error'] = $return_code;
         }
         $this->load->view('templates/header');
         $this->load->view('templates/menu');
         $this->load->view('settings/backup', $data);
         $this->load->view('templates/footer');
     }
 }
Exemple #10
0
                    }
                    // soe stripped out all the name.
                    $targetFile = $targetPath . '/' . internalToFilesystem($seoname);
                    if (file_exists($targetFile)) {
                        $append = '_' . time();
                        $seoname = stripSuffix($seoname) . $append . '.' . getSuffix($seoname);
                        $targetFile = $targetPath . '/' . internalToFilesystem($seoname);
                    }
                    if (move_uploaded_file($tempFile, $targetFile)) {
                        @chmod($targetFile, 0666 & CHMOD_VALUE);
                        $album = new Album($gallery, $folder);
                        $image = newImage($album, $seoname);
                        $image->setOwner($_zp_current_admin_obj->getUser());
                        if ($name != $seoname && $image->getTitle() == substr($seoname, 0, strrpos($seoname, '.'))) {
                            $image->setTitle(substr($name, 0, strrpos($name, '.')));
                        }
                        $image->save();
                    } else {
                        $error = UPLOAD_ERR_NO_FILE;
                    }
                } else {
                    if (is_zip($name)) {
                        unzip($tempFile, $targetPath);
                    }
                }
            }
        }
    }
}
$file = $_FILES['file'];
echo '{"name":"' . $file['name'] . '","type":"' . $file['type'] . '","size":"' . $file['size'] . '","error":' . $error . '}';
Exemple #11
0
                         $append = '_' . time();
                         $soename = stripSuffix($soename) . $append . '.' . getSuffix($soename);
                         $uploadfile = $targetPath . '/' . internalToFilesystem($soename);
                     }
                     move_uploaded_file($tmp_name, $uploadfile);
                     @chmod($uploadfile, FILE_MOD);
                     $image = newImage($album, $soename);
                     $image->setOwner($_zp_current_admin_obj->getUser());
                     if ($name != $soename) {
                         $image->setTitle(stripSuffix($name));
                     }
                     $image->save();
                 }
             } else {
                 if (is_zip($name)) {
                     unzip($tmp_name, $targetPath);
                 } else {
                     $error = UPLOAD_ERR_EXTENSION;
                     // invalid file uploaded
                     break;
                 }
             }
         }
     } else {
         break;
     }
 }
 if ($error == UPLOAD_ERR_OK && ($filecount || isset($_POST['newalbum']))) {
     if ($album->albumSubRights() & MANAGED_OBJECT_RIGHTS_EDIT) {
         //	he has edit rights, allow new album creation
         header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin-edit.php?page=edit&album=' . pathurlencode($folder) . '&uploaded&subpage=1&tab=imageinfo&albumimagesort=id_desc');
 $_SESSION['unzip_dir'] = $unzip_dir;
 $_SESSION['install_file'] = $install_file;
 $_SESSION['zip_from_dir'] = $zip_from_dir;
 if (is_dir($unzip_dir . '/scripts')) {
     rmdir_recursive($unzip_dir . '/scripts');
 }
 if (is_file($unzip_dir . '/manifest.php')) {
     rmdir_recursive($unzip_dir . '/manifest.php');
 }
 mkdir_recursive($unzip_dir);
 if (!is_dir($unzip_dir)) {
     echo "\n{$unzip_dir} is not an available directory\nFAILURE\n";
     fwrite(STDERR, "\n{$unzip_dir} is not an available directory\nFAILURE\n");
     exit(1);
 }
 unzip($argv[1], $unzip_dir);
 // mimic standard UW by copy patch zip to appropriate dir
 copy($argv[1], $install_file);
 ////	END UPGRADE PREP
 ///////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////
 ////	UPGRADE UPGRADEWIZARD
 $zipBasePath = "{$unzip_dir}/{$zip_from_dir}";
 $uwFiles = findAllFiles("{$zipBasePath}/modules/UpgradeWizard", array());
 $destFiles = array();
 foreach ($uwFiles as $uwFile) {
     $destFile = str_replace($zipBasePath . "/", '', $uwFile);
     copy($uwFile, $destFile);
 }
 require_once 'modules/UpgradeWizard/uw_utils.php';
 // must upgrade UW first
Exemple #13
0
 $show_files = true;
 if (empty($unzip_dir)) {
     $unzip_dir = mk_temp_dir($base_tmp_upgrade_dir);
 }
 $zip_from_dir = ".";
 $zip_to_dir = ".";
 $zip_force_copy = array();
 if (!$unzip_dir) {
     logThis('Could not create a temporary directory using mk_temp_dir( $base_tmp_upgrade_dir )');
     die($mod_strings['ERR_UW_NO_CREATE_TMP_DIR']);
 }
 //double check whether unzipped .
 if (file_exists($unzip_dir . "/scripts") && file_exists($unzip_dir . "/manifest.php")) {
     //already unzipped
 } else {
     unzip($install_file, $unzip_dir);
 }
 // assumption -- already validated manifest.php at time of upload
 require_once "{$unzip_dir}/manifest.php";
 if (isset($manifest['copy_files']['from_dir']) && $manifest['copy_files']['from_dir'] != "") {
     $zip_from_dir = $manifest['copy_files']['from_dir'];
 }
 if (isset($manifest['copy_files']['to_dir']) && $manifest['copy_files']['to_dir'] != "") {
     $zip_to_dir = $manifest['copy_files']['to_dir'];
 }
 if (isset($manifest['copy_files']['force_copy']) && $manifest['copy_files']['force_copy'] != "") {
     $zip_force_copy = $manifest['copy_files']['force_copy'];
 }
 if (isset($manifest['version'])) {
     $version = $manifest['version'];
 }
 function performUninstall($name)
 {
     $uh = new UpgradeHistory();
     $uh->name = $name;
     $uh->id_name = $name;
     $found = $uh->checkForExisting($uh);
     if ($found != null) {
         global $sugar_config;
         global $mod_strings;
         global $current_language;
         $base_upgrade_dir = sugar_cached("/upgrades");
         $base_tmp_upgrade_dir = "{$base_upgrade_dir}/temp";
         if (!isset($GLOBALS['mi_remove_tables'])) {
             $GLOBALS['mi_remove_tables'] = true;
         }
         $unzip_dir = mk_temp_dir($base_tmp_upgrade_dir);
         unzip($found->filename, $unzip_dir);
         $mi = new ModuleInstaller();
         $mi->silent = true;
         $mi->uninstall("{$unzip_dir}");
         $found->delete();
         unlink(remove_file_extension($found->filename) . '-manifest.php');
         unlink($found->filename);
     }
 }
Exemple #15
0
/**
 * change from using the older SugarCache in 6.1 and below to the new one in 6.2
 */
function upgradeSugarCache($file)
{
    global $sugar_config;
    $cacheUploadUpgradesTemp = mk_temp_dir(sugar_cached('upgrades/temp'));
    unzip($file, $cacheUploadUpgradesTemp);
    if (!file_exists(clean_path("{$cacheUploadUpgradesTemp}/manifest.php"))) {
        logThis("*** ERROR: no manifest file detected while bootstraping upgrade wizard files!");
        return;
    } else {
        include clean_path("{$cacheUploadUpgradesTemp}/manifest.php");
    }
    $from_dir = "{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}";
    $allFiles = array();
    if (file_exists("{$from_dir}/include/SugarCache")) {
        $allFiles = findAllFiles("{$from_dir}/include/SugarCache", $allFiles);
    }
    if (file_exists("{$from_dir}/include/database")) {
        $allFiles = findAllFiles("{$from_dir}/include/database", $allFiles);
    }
    if (file_exists("{$from_dir}/include/utils/external_cache.php")) {
        $allFiles[] = "{$from_dir}/include/utils/external_cache.php";
    }
    if (file_exists("{$from_dir}/include/utils/sugar_file_utils.php")) {
        $allFiles[] = "{$from_dir}/include/utils/sugar_file_utils.php";
    }
    if (file_exists("{$from_dir}/include/utils/sugar_file_utils.php")) {
        $allFiles[] = "{$from_dir}/include/utils/sugar_file_utils.php";
    }
    foreach ($allFiles as $k => $file) {
        $destFile = str_replace($from_dir . "/", "", $file);
        if (!is_dir(dirname($destFile))) {
            mkdir_recursive(dirname($destFile));
            // make sure the directory exists
        }
        if (stristr($file, 'uw_main.tpl')) {
            logThis('Skipping "' . $file . '" - file copy will during commit step.');
        } else {
            logThis('updating UpgradeWizard code: ' . $destFile);
            copy_recursive($file, $destFile);
        }
    }
}
Exemple #16
0
                    }
                    if (zip_entry_open($zip, $zip_entry, 'r')) {
                        $fd = fopen($complete_name, 'w');
                        fwrite($fd, zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)));
                        fclose($fd);
                        zip_entry_close($zip_entry);
                    }
                }
            }
            umask($old_umask);
            zip_close($zip);
            return true;
        }
        zip_close($zip);
    }
    if (!($err = @unzip(realpath("{$startpath}/" . $_REQUEST['file']), realpath($startpath)))) {
        echo '<span class="warning"><b>' . $_lang['file_unzip_fail'] . ($err === 0 ? 'Missing zip library (php_zip.dll / zip.so)' : '') . '</b></span><br /><br />';
    } else {
        echo '<span class="success"><b>' . $_lang['file_unzip'] . '</b></span><br /><br />';
    }
}
// End Unzip - Raymond
// New Folder & Delete Folder option - Raymond
if (is_writable($startpath)) {
    // Delete Folder
    if ($_REQUEST['mode'] == 'deletefolder') {
        $folder = $_REQUEST['folderpath'];
        if (!@rmdir($folder)) {
            echo '<span class="warning"><b>' . $_lang['file_folder_not_deleted'] . '</b></span><br /><br />';
        } else {
            echo '<span class="success"><b>' . $_lang['file_folder_deleted'] . '</b></span><br /><br />';
Exemple #17
0
	public function _home() {
		global $config, $user, $cache, $upload;

		if (_button()) {
			$event_id = request_var('event_id', 0);

			$filepath_1 = $config['events_path'] . 'tmp/';
			$filepath_2 = $config['events_path'] . 'gallery/';
			$filepath_3 = $filepath_1 . $event_id . '/';
			$filepath_4 = $filepath_3 . 'thumbnails/';

			$f = $upload->process($filepath_1, 'add_zip', 'zip');
			if (!sizeof($upload->error) && $f !== false) {
				@set_time_limit(0);

				foreach ($f as $row) {
					$zip_folder = unzip($filepath_1 . $row['filename'], $filepath_3, true);
					_rm($filepath_1 . $row['filename']);
				}

				if (!empty($zip_folder)) {
					$zip_folder = substr($zip_folder, 0, -1);

					$fp = @opendir($filepath_3 . $zip_folder);
					while ($file = @readdir($fp)) {
						if (!is_level($file)) {
							$ftp->ftp_rename($ftp->dfolder() . 'data/tmp/' . $event_id . '/' . $zip_folder . '/' . $file, $ftp->dfolder() . 'data/tmp/' . $event_id . '/' . $file);
							//@rename($filepath_3 . $zip_folder . '/' . $file, $filepath_3 . $file);
						}
					}
					@closedir($fp);

					_rm($filepath_3 . $zip_folder);
				}

				if (!@file_exists($filepath_4)) {
					a_mkdir($ftp->dfolder() . 'data/tmp/' . $event_id, 'thumbnails');
				}

				$footer_data = '';
				$filerow_list = w();
				$count_images = $img = $event_pre = 0;

				$check_is = w();
				if (@file_exists($filepath_2 . $event_id)) {
					$fp = @opendir($filepath_2 . $event_id);
					while ($filerow = @readdir($fp)) {
						if (preg_match('#(\d+)\.(jpg)#is', $filerow)) {
							$dis = getimagesize($filepath_2 . $event_id . $filerow);
							$disd = intval(_decode('4e6a4177'));
							if (($dis[0] > $dis[1] && $dis[0] < $disd) || ($dis[1] > $dis[0] && $dis[1] < $disd)) {
								$check_is[] = $filerow;
								continue;
							}

							$event_pre++;
						}
					}
					@closedir($fp);

					if (count($check_is)) {
						echo lang('dis_invalid');

						foreach ($check_is as $row) {
							echo $row . '<br />';
						}
						exit;
					}

					$img = $event_pre;
				}

				$filerow_list = array_dir($filepath_3);
				array_multisort($filerow_list, SORT_ASC, SORT_NUMERIC);

				foreach ($filerow_list as $filerow) {
					if (preg_match('#(\d+)\.(jpg)#is', $filerow))
					{
						$row = $upload->_row($filepath_3, $filerow);
						if (!@copy($filepath_3 . $filerow, $row['filepath'])) {
							continue;
						}

						$img++;
						$xa = $upload->resize($row, $filepath_3, $filepath_3, $img, array(600, 450), false, true, true, 'w2');
						if ($xa === false) {
							continue;
						}
						$xb = $upload->resize($row, $filepath_3, $filepath_4, $img, array(100, 75), false, false);

						$insert = array(
							'event_id' => (int) $event_id,
							'image' => (int) $img,
							'width' => (int) $xa['width'],
							'height' => (int) $xa['height'],
							'allow_dl' => 1
						);
						sql_insert('events_images', $insert);

						$count_images++;
					} elseif (preg_match('#(info)\.(txt)#is', $filerow)) {
						$footer_data = $filerow;
					}
				}

				if (!empty($footer_data) && @file_exists($filepath_3 . $footer_data)) {
					$footer_info = @file($filepath_3 . $footer_data);
					foreach ($footer_info as $linerow) {
						$part = explode(':', $linerow);
						$part = array_map('trim', $part);

						$numbs = explode('-', $part[0]);
						$numbs[1] = (isset($numbs[1])) ? $numbs[1] : $numbs[0];

						for ($i = ($numbs[0] + $event_pre), $end = ($numbs[1] + $event_pre + 1); $i < $end; $i++) {
							$sql = 'UPDATE _events_images SET image_footer = ?
								WHERE event_id = ?
									AND image = ?';
							sql_query(sql_filter($sql, htmlencode($part[1]), $event_id, $i));
						}
					}

					_rm($filepath_3 . $footer_data);
				}

				$sql = 'SELECT *
					FROM _events_colab
					WHERE colab_event = ?
						AND colab_uid = ?';
				if (!$row = sql_fieldrow(sql_filter($sql, $event_ud, $user->d('user_id')))) {
					$sql_insert = array(
						'colab_event' => $event_id,
						'colab_uid' => $user->d('user_id')
					);
					sql_insert('events_colab', $sql_insert);
				}

				$sql = 'UPDATE _events SET images = images + ??
					WHERE id = ?';
				sql_query(sql_filter($sql, $count_images, $event_id));

				$ftp->ftp_rename($ftp->dfolder() . 'data/tmp/' . $event_id . '/', $ftp->dfolder() . 'data/events/gallery/' . $event_id . '/');
				//@rename($filepath_3, $filepath_2 . $event_id);
				$ftp->ftp_quit();

				redirect(s_link('events', $event_id));
			}

			_style('error', array(
				'MESSAGE' => parse_error($upload->error))
			);
		}

		$sql = 'SELECT *
			FROM _events
			WHERE date < ??
			ORDER BY date DESC';
		$result = sql_rowset(sql_filter($sql, (time() + 86400)));

		foreach ($result as $row) {
			_style('event_list', array(
				'EVENT_ID' => $row['id'],
				'EVENT_TITLE' => (($row['images']) ? '* ' : '') . $row['title'],
				'EVENT_DATE' => $user->format_date($row['date']))
			);
		}

		return;
	}
         if ($error == UPLOAD_ERR_OK) {
             $tmp_name = $_FILES['files']['tmp_name'][$key];
             $name = $_FILES['files']['name'][$key];
             $soename = UTF8toFilesystem(seoFriendlyURL($name));
             if (is_valid_image($name) || is_valid_other_type($name)) {
                 $uploadfile = $uploaddir . '/' . $soename;
                 move_uploaded_file($tmp_name, $uploadfile);
                 @chmod($uploadfile, 0666 & CHMOD_VALUE);
                 $image = newImage($album, $soename);
                 if ($name != $soename) {
                     $image->setTitle($name);
                     $image->save();
                 }
             } else {
                 if (is_zip($name)) {
                     unzip($tmp_name, $uploaddir);
                 }
             }
         }
     }
     header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin-edit.php?page=edit&album=' . urlencode($folder) . '&uploaded&subpage=1&tab=imageinfo');
     exit;
 } else {
     // Handle the error and return to the upload page.
     $page = "upload";
     $_GET['page'] = 'upload';
     $error = true;
     if ($files_empty) {
         $errormsg = gettext("You must upload at least one file.");
     } else {
         if (empty($_POST['folder'])) {
Exemple #19
0
}
$target_path = "C:/www/archive/static_files/";
$meetingKey = $_REQUEST["meetingKey"];
if (isset($meetingKey)) {
    @mkdir($target_path . $meetingKey);
    $target_path = $target_path . $meetingKey . "/" . $_FILES['Filedata']['name'];
} else {
    $target_path = $target_path . basename($_FILES['Filedata']['name']);
}
if (move_uploaded_file($_FILES['Filedata']['tmp_name'], $target_path)) {
    echo "The file " . basename($_FILES['Filedata']['name']) . " has been uploaded";
    echo "The file uploaded to " . $target_path;
    $za = new ZipArchive();
    echo "created zip archive..";
    $za->open($target_path);
    print_r($za);
    var_dump($za);
    echo "numFiles: " . $za->numFiles . "\n";
    echo "status: " . $za->status . "\n";
    echo "statusSys: " . $za->statusSys . "\n";
    echo "filename: " . $za->filename . "\n";
    echo "comment: " . $za->comment . "\n";
    #for ($i=0; $i<$za->numFiles;$i++) {
    #    echo "index: $i\n";
    #    print_r($za->statIndex($i));
    #}
    echo "numFile:" . $za->numFiles . "\n";
    unzip("C:/www/archive/static_files/" . $meetingKey . "/", $_FILES['Filedata']['name'], 1);
} else {
    echo "There was an error uploading the file, please try again!";
}
Exemple #20
0
     up();
     break;
 case "upload":
     upload($_FILES['upfile'], $_REQUEST['ndir']);
     break;
 case "del":
     del($_REQUEST['dename']);
     break;
 case "delete":
     delete($_REQUEST['dename']);
     break;
 case "zip":
     zip($_REQUEST['file']);
     break;
 case "unzip":
     unzip($_REQUEST['file']);
     break;
 case "edit":
     edit($_REQUEST['fename']);
     break;
 case "save":
     save($_REQUEST['ncontent'], $_REQUEST['fename']);
     break;
 case "cr":
     cr();
     break;
 case "create":
     create($_REQUEST['nfname'], $_REQUEST['isfolder'], $_REQUEST['ndir']);
     break;
 case "ren":
     ren($_REQUEST['file']);
Exemple #21
0
function preflightCheck()
{
    require_once 'modules/UpgradeWizard/uw_files.php';
    global $sugar_config;
    global $mod_strings;
    global $sugar_version;
    if (!isset($sugar_version) || empty($sugar_version)) {
        require_once './sugar_version.php';
    }
    unset($_SESSION['rebuild_relationships']);
    unset($_SESSION['rebuild_extensions']);
    // don't bother if are rechecking
    $manualDiff = array();
    if (!isset($_SESSION['unzip_dir']) || empty($_SESSION['unzip_dir'])) {
        logThis('unzipping files in upgrade archive...');
        $errors = array();
        $base_upgrade_dir = $sugar_config['upload_dir'] . "/upgrades";
        $base_tmp_upgrade_dir = "{$base_upgrade_dir}/temp";
        $unzip_dir = '';
        //Following is if User logged out unexpectedly and then logged into UpgradeWizard again.
        //also come up with mechanism to read from upgrade-progress file.
        if (!isset($_SESSION['install_file']) || empty($_SESSION['install_file']) || !is_file($_SESSION['install_file'])) {
            if (file_exists(clean_path($base_tmp_upgrade_dir)) && ($handle = opendir(clean_path($base_tmp_upgrade_dir)))) {
                while (false !== ($file = readdir($handle))) {
                    if ($file != "." && $file != "..") {
                        //echo $base_tmp_upgrade_dir."/".$file.'</br>';
                        if (is_file($base_tmp_upgrade_dir . "/" . $file . "/manifest.php")) {
                            require_once $base_tmp_upgrade_dir . "/" . $file . "/manifest.php";
                            $package_name = $manifest['copy_files']['from_dir'];
                            //echo file_exists($base_tmp_upgrade_dir."/".$file."/".$package_name).'</br>';
                            if (file_exists($base_tmp_upgrade_dir . "/" . $file . "/" . $package_name) && file_exists($base_tmp_upgrade_dir . "/" . $file . "/scripts") && file_exists($base_tmp_upgrade_dir . "/" . $file . "/manifest.php")) {
                                //echo 'Yeah this the directory '. $base_tmp_upgrade_dir."/".$file;
                                $unzip_dir = $base_tmp_upgrade_dir . "/" . $file;
                                if (file_exists($sugar_config['upload_dir'] . '/upgrades/patch/' . $package_name . '.zip')) {
                                    $_SESSION['install_file'] = $sugar_config['upload_dir'] . '/upgrades/patch/' . $package_name . '.zip';
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
        if (!isset($_SESSION['install_file']) || empty($_SESSION['install_file'])) {
            unlinkTempFiles();
            resetUwSession();
            echo 'Upload File not found so redirecting to Upgrade Start ';
            $redirect_new_wizard = $sugar_config['site_url'] . '/index.php?module=UpgradeWizard&action=index';
            echo '<form name="redirect" action="' . $redirect_new_wizard . '"  method="POST">';
            $upgrade_directories_not_found = <<<eoq
\t<table cellpadding="3" cellspacing="0" border="0">
\t\t<tr>
\t\t\t<th colspan="2" align="left">
\t\t\t\t<span class='error'><b>'Upload file missing or has been deleted. Refresh the page to go back to UpgradeWizard start'</b></span>
\t\t\t</th>
\t\t</tr>
\t</table>
eoq;
            $uwMain = $upgrade_directories_not_found;
            return '';
        }
        $install_file = urldecode($_SESSION['install_file']);
        $show_files = true;
        if (empty($unzip_dir)) {
            $unzip_dir = mk_temp_dir($base_tmp_upgrade_dir);
        }
        $zip_from_dir = ".";
        $zip_to_dir = ".";
        $zip_force_copy = array();
        if (!$unzip_dir) {
            logThis('Could not create a temporary directory using mk_temp_dir( $base_tmp_upgrade_dir )');
            die($mod_strings['ERR_UW_NO_CREATE_TMP_DIR']);
        }
        //double check whether unzipped .
        if (file_exists($unzip_dir . "/scripts") && file_exists($unzip_dir . "/manifest.php")) {
            //already unzipped
        } else {
            unzip($install_file, $unzip_dir);
        }
        // assumption -- already validated manifest.php at time of upload
        require_once "{$unzip_dir}/manifest.php";
        if (isset($manifest['copy_files']['from_dir']) && $manifest['copy_files']['from_dir'] != "") {
            $zip_from_dir = $manifest['copy_files']['from_dir'];
        }
        if (isset($manifest['copy_files']['to_dir']) && $manifest['copy_files']['to_dir'] != "") {
            $zip_to_dir = $manifest['copy_files']['to_dir'];
        }
        if (isset($manifest['copy_files']['force_copy']) && $manifest['copy_files']['force_copy'] != "") {
            $zip_force_copy = $manifest['copy_files']['force_copy'];
        }
        if (isset($manifest['version'])) {
            $version = $manifest['version'];
        }
        if (!is_writable("config.php")) {
            return $mod_strings['ERR_UW_CONFIG'];
        }
        $_SESSION['unzip_dir'] = clean_path($unzip_dir);
        $_SESSION['zip_from_dir'] = clean_path($zip_from_dir);
        //logThis('unzip done.');
    } else {
        $unzip_dir = $_SESSION['unzip_dir'];
        $zip_from_dir = $_SESSION['zip_from_dir'];
    }
    //check if $_SESSION['unzip_dir'] and $_SESSION['zip_from_dir'] exist
    if (!isset($_SESSION['unzip_dir']) || !file_exists($_SESSION['unzip_dir']) || !isset($_SESSION['install_file']) || empty($_SESSION['install_file']) || !file_exists($_SESSION['install_file'])) {
        //redirect to start
        unlinkTempFiles();
        resetUwSession();
        echo 'Upload File not found so redirecting to Upgrade Start ';
        $redirect_new_wizard = $sugar_config['site_url'] . '/index.php?module=UpgradeWizard&action=index';
        echo '<form name="redirect" action="' . $redirect_new_wizard . '"  method="POST">';
        $upgrade_directories_not_found = <<<eoq
\t<table cellpadding="3" cellspacing="0" border="0">
\t\t<tr>
\t\t\t<th colspan="2" align="left">
\t\t\t\t<span class='error'><b>'Upload file missing or has been deleted. Refresh the page to go back to UpgradeWizard start'</b></span>
\t\t\t</th>
\t\t</tr>
\t</table>
eoq;
        $uwMain = $upgrade_directories_not_found;
        return '';
    }
    //copy minimum required files
    fileCopy('include/utils/sugar_file_utils.php');
    if (file_exists('include/utils/file_utils.php')) {
    }
    $upgradeFiles = findAllFiles(clean_path("{$unzip_dir}/{$zip_from_dir}"), array());
    $cache_html_files = array();
    if (is_dir("{$GLOBALS['sugar_config']['cache_dir']}layout")) {
        //$cache_html_files = findAllFilesRelative( "cache/layout", array());
    }
    // get md5 sums
    $md5_string = array();
    if (file_exists(clean_path(getcwd() . '/files.md5'))) {
        require clean_path(getcwd() . '/files.md5');
    }
    // file preflight checks
    logThis('verifying md5 checksums for files...');
    foreach ($upgradeFiles as $file) {
        if (in_array(str_replace(clean_path("{$unzip_dir}/{$zip_from_dir}") . "/", '', $file), $uw_files)) {
            continue;
        }
        // skip already loaded files
        if (strpos($file, '.md5')) {
            continue;
        }
        // skip md5 file
        // normalize file paths
        $file = clean_path($file);
        // check that we can move/delete the upgraded file
        if (!is_writable($file)) {
            $errors[] = $mod_strings['ERR_UW_FILE_NOT_WRITABLE'] . ": " . $file;
        }
        // check that destination files are writable
        $destFile = getcwd() . str_replace(clean_path($unzip_dir . '/' . $zip_from_dir), '', $file);
        if (is_file($destFile)) {
            // of course it needs to exist first...
            if (!is_writable($destFile)) {
                $errors[] = $mod_strings['ERR_UW_FILE_NOT_WRITABLE'] . ": " . $destFile;
            }
        }
        ///////////////////////////////////////////////////////////////////////
        ////	DIFFS
        // compare md5s and build up a manual merge list
        $targetFile = clean_path("." . str_replace(getcwd(), '', $destFile));
        $targetMd5 = '0';
        if (is_file($destFile)) {
            if (strpos($targetFile, '.php')) {
                // handle PHP files that were hit with the security regex
                $fp = '';
                if (function_exists('sugar_fopen')) {
                    $fp = sugar_fopen($destFile, 'r');
                } else {
                    $fp = fopen($destFile, 'r');
                }
                $filesize = filesize($destFile);
                if ($filesize > 0) {
                    $fileContents = fread($fp, $filesize);
                    $targetMd5 = md5($fileContents);
                }
            } else {
                $targetMd5 = md5_file($destFile);
            }
        }
        if (isset($md5_string[$targetFile]) && $md5_string[$targetFile] != $targetMd5) {
            logThis('found a file with a differing md5: [' . $targetFile . ']');
            $manualDiff[] = $destFile;
        }
        ////	END DIFFS
        ///////////////////////////////////////////////////////////////////////
    }
    logThis('md5 verification done.');
    $errors['manual'] = $manualDiff;
    return $errors;
}
Exemple #22
0
 function performUninstall($name)
 {
     $uh = new UpgradeHistory();
     $uh->name = $name;
     $uh->id_name = $name;
     $found = $uh->checkForExisting($uh);
     if ($found != null) {
         global $sugar_config;
         global $mod_strings;
         global $current_language;
         $base_upgrade_dir = $this->upload_dir . '/upgrades';
         $base_tmp_upgrade_dir = "{$base_upgrade_dir}/temp";
         if (is_file($found->filename)) {
             if (!isset($GLOBALS['mi_remove_tables'])) {
                 $GLOBALS['mi_remove_tables'] = true;
             }
             $unzip_dir = mk_temp_dir($base_tmp_upgrade_dir);
             unzip($found->filename, $unzip_dir);
             $mi = new ModuleInstaller();
             $mi->silent = true;
             $mi->uninstall("{$unzip_dir}");
             $found->delete();
             unlink(remove_file_extension($found->filename) . '-manifest.php');
             unlink($found->filename);
         } else {
             //file(s_ have been deleted or are not found in the directory, allow database delete to happen but no need to change filesystem
             $found->delete();
         }
     }
 }
Exemple #23
0
 $datei = $_FILES['zip']['name'];
 $galerieName = $_POST['galerieName'];
 $adminID = $_SESSION['adminID'];
 $upload = uploadZip();
 $datei_location = "upload/galerie/" . $datei;
 $galerie_location = str_replace(".zip", "", $datei_location);
 //Falls der Termin in der Vergangenheit liegt
 if ($endZeit > $now) {
     //Falls die Endzeit nach der Startzeit ist
     if ($startZeit < $endZeit) {
         //Prüfen, ob die Zeiten in der Datenbank bereits besetzt sind
         if (checkBetween($startZeit, $endZeit)) {
             //Zip erfolgreich hochgeladen
             if ($upload == "true") {
                 require_once 'includes/pclzip.lib.php';
                 $unzip = unzip();
                 if ($unzip == "true") {
                     $resized = resizeImagesInFolder($galerie_location);
                     if ($resized == "true") {
                         $sql = "INSERT INTO folie(`dateTimeVon`, `dateTimeBis`, `strText1`, `strPath`, `intAdmin_ID`, `intTemplate_ID`) VALUES('{$startZeit}','{$endZeit}', '{$galerieName}', '{$galerie_location}', '{$adminID}','2')";
                         $result = $db->query($sql);
                         if ($result) {
                             //Folie wurde erfolgreich gespeichert
                             $message = 10;
                         }
                     } else {
                         //Resize fehlgeschlagen
                     }
                 } else {
                     $message = 11;
                 }
Exemple #24
0
            echo "<a class='navbar' href='http://{$domain}{$script}?editfile={$file2}'>{$file2}</a><br>";
            $matches++;
        }
    }
    if ($matches == 0) {
        error("No files that match {$searchval}");
    } else {
        echo "<font color='#14ab00' size='3'>{$matches} files found that match {$searchval}</font><br>";
        success("files_found", $matches);
    }
}
//Unzip
if (isset($_GET['unzipfile'])) {
    $unzipfile = $_GET['unzipfile'];
    $redir = dirname($unzipfile);
    unzip($unzipfile, rtrim($redir, '/'));
}
//Exectue Command
if (isset($_POST['do_exe_command'])) {
    $ecmd = $_POST['exe_command'];
    $exe_cmd = cmd2($ecmd, $dir);
    echo "<center><font color='#14ab00'>\n<form action='' method='post'>\n<input type='text' class='text' name='exe_command' size='60'>\n<input type='submit' name='do_exe_command' value='Execute'><br>\n</form>\nResult:<br>\n<textarea rows='20' cols='150' name='massdeface_source' style='color:#000'>\n{$exe_cmd}\n</textarea></font></center><br><br>";
}
//wget file
if (isset($_POST['do_wget_file'])) {
    $wget_file = $_POST['wget_file'];
    $wecmd = "wget {$wget_file}";
    $wget_ecmd = cmd2($wecmd, $dir);
    echo "<center><font color='#14ab00'>\nResult:<br>\n<textarea rows='20' cols='150' name='massdeface_source' style='color:#000'>\n{$wget_ecmd}\n</textarea></font></center><br><br>";
}
//Domain information
Exemple #25
0
     }
     break;
 case "upload":
     if (!isset($_FILES['upfile'])) {
         printerror('您没有选择文件!');
     } elseif (isset($_REQUEST['ndir'])) {
         upload($_FILES['upfile'], $_REQUEST['ndir'], @$_REQUEST['unzip'], @$_REQUEST['delzip']);
     } else {
         upload($_FILES['upfile'], './', @$_REQUEST['unzip'], @$_REQUEST['delzip']);
     }
     break;
 case "unz":
     unz($_REQUEST['dename']);
     break;
 case "unzip":
     unzip($_REQUEST['dename'], $_REQUEST['ndir'], @$_REQUEST['del']);
     break;
 case "sqlb":
     sqlb();
     break;
 case "sqlbackup":
     sqlbackup($_POST['ip'], $_POST['sql'], $_POST['username'], $_POST['password']);
     break;
 case "ftpa":
     ftpa();
     break;
 case "ftpall":
     ftpall($_POST['ftpip'], $_POST['ftpuser'], $_POST['ftppass'], $_POST['goto'], $_POST['ftpfile'], $_POST['del']);
     break;
 case "edit":
     edit($_REQUEST['fename']);
function get_required_upgrades($soapclient, $session)
{
    global $sugar_config, $sugar_version;
    require_once 'vendor/nusoap//nusoap.php';
    $errors = array();
    $upgrade_history = new UpgradeHistory();
    $upgrade_history->disable_row_level_security = true;
    $installeds = $upgrade_history->getAllOrderBy('date_entered ASC');
    $history = array();
    require_once 'soap/SoapError.php';
    $error = new SoapError();
    foreach ($installeds as $installed) {
        $history[] = array('id' => $installed->id, 'filename' => $installed->filename, 'md5' => $installed->md5sum, 'type' => $installed->type, 'status' => $installed->status, 'version' => $installed->version, 'date_entered' => $installed->date_entered, 'error' => $error->get_soap_array());
    }
    $result = $soapclient->call('get_required_upgrades', array('session' => $session, 'client_upgrade_history' => $history, 'client_version' => $sugar_version));
    $tempdir_parent = create_cache_directory("disc_client");
    $temp_dir = tempnam($tempdir_parent, "sug");
    sugar_mkdir($temp_dir, 0775);
    $upgrade_installed = false;
    if (empty($soapclient->error_str) && $result['error']['number'] == 0) {
        foreach ($result['upgrade_history_list'] as $upgrade) {
            $file_result = $soapclient->call('get_encoded_file', array('session' => $session, 'filename' => $upgrade['filename']));
            if (empty($soapclient->error_str) && $result['error']['number'] == 0) {
                if ($file_result['md5'] == $upgrade['md5']) {
                    $newfile = write_encoded_file($file_result, $temp_dir);
                    unzip($newfile, $temp_dir);
                    global $unzip_dir;
                    $unzip_dir = $temp_dir;
                    if (file_exists("{$temp_dir}/manifest.php")) {
                        require_once "{$temp_dir}/manifest.php";
                        global $manifest_arr;
                        $manifest_arr = $manifest;
                        if (!isset($manifest['offline_client_applicable']) || $manifest['offline_client_applicable'] == true || $manifest['offline_client_applicable'] == 'true') {
                            if (file_exists("{$temp_dir}/scripts/pre_install.php")) {
                                require_once "{$temp_dir}/scripts/pre_install.php";
                                pre_install();
                            }
                            if (isset($manifest['copy_files']['from_dir']) && $manifest['copy_files']['from_dir'] != "") {
                                $zip_from_dir = $manifest['copy_files']['from_dir'];
                            }
                            $source = "{$temp_dir}/{$zip_from_dir}";
                            $dest = getcwd();
                            copy_recursive($source, $dest);
                            if (file_exists("{$temp_dir}/scripts/post_install.php")) {
                                require_once "{$temp_dir}/scripts/post_install.php";
                                post_install();
                            }
                            //save newly installed upgrade
                            $new_upgrade = new UpgradeHistory();
                            $new_upgrade->filename = $upgrade['filename'];
                            $new_upgrade->md5sum = $upgrade['md5'];
                            $new_upgrade->type = $upgrade['type'];
                            $new_upgrade->version = $upgrade['version'];
                            $new_upgrade->status = "installed";
                            $new_upgrade->save();
                            $upgrade_installed = true;
                        }
                    }
                }
            }
        }
    }
    return $upgrade_installed;
}
function commitModules($unlink = false, $type = 'module')
{
    require_once 'ModuleInstall/ModuleInstaller.php';
    require_once 'include/entryPoint.php';
    global $mod_strings;
    global $base_upgrade_dir;
    global $base_tmp_upgrade_dir;
    global $db;
    $GLOBALS['db'] = $db;
    $errors = array();
    $files = array();
    global $current_user;
    $current_user = new User();
    $current_user->is_admin = '1';
    $old_mod_strings = $mod_strings;
    if (is_dir(sugar_cached("upload/upgrades"))) {
        $files = findAllFiles(sugar_cached("upload/upgrades/{$type}"), $files);
        $mi = new ModuleInstaller();
        $mi->silent = true;
        $mod_strings = return_module_language('en', "Administration");
        foreach ($files as $file) {
            if (!preg_match('#.*\\.zip\\$', $file)) {
                continue;
            }
            $lic_name = 'accept_lic_' . str_replace('.', '_', urlencode(basename($file)));
            $can_install = true;
            if (isset($_REQUEST[$lic_name])) {
                if ($_REQUEST[$lic_name] == 'yes') {
                    $can_install = true;
                } else {
                    $can_install = false;
                }
            }
            if ($can_install) {
                // handle manifest.php
                $target_manifest = remove_file_extension($file) . '-manifest.php';
                if ($type == 'langpack') {
                    $_REQUEST['manifest'] = $target_manifest;
                    $_REQUEST['zipFile'] = $file;
                    commitLanguagePack();
                    continue;
                }
                include $target_manifest;
                $unzip_dir = mk_temp_dir($base_tmp_upgrade_dir);
                unzip($file, $unzip_dir);
                $_REQUEST['install_file'] = $file;
                $mi->install($unzip_dir);
                $new_upgrade = new UpgradeHistory();
                $new_upgrade->filename = $file;
                $new_upgrade->md5sum = md5_file($file);
                $new_upgrade->type = $manifest['type'];
                $new_upgrade->version = $manifest['version'];
                $new_upgrade->status = "installed";
                // $new_upgrade->author        = $manifest['author'];
                $new_upgrade->name = $manifest['name'];
                $new_upgrade->description = $manifest['description'];
                $new_upgrade->id_name = isset($installdefs['id_name']) ? $installdefs['id_name'] : '';
                $serial_manifest = array();
                $serial_manifest['manifest'] = isset($manifest) ? $manifest : '';
                $serial_manifest['installdefs'] = isset($installdefs) ? $installdefs : '';
                $serial_manifest['upgrade_manifest'] = isset($upgrade_manifest) ? $upgrade_manifest : '';
                $new_upgrade->manifest = base64_encode(serialize($serial_manifest));
                $new_upgrade->save();
                //unlink($file);
            }
            //fi
        }
        //rof
    }
    //fi
    $mod_strings = $old_mod_strings;
}
Exemple #28
0
}
include ROOT_PATH . "/include/config_" . $web_idx . ".php";
if (count($_POST) > 0) {
    $content = "";
    if ($method == "import") {
        $log_info = $setting['language']['admin_func_backup_import'];
        $path_upload = ROOT_PATH . "/" . $setting['path']['upload'] . "/tmp/";
        $upload = $mystep->getInstance("MyUploader", $path_upload, true);
        $upload->DoIt(false);
        if (count($upload->upload_result) > 0) {
            if ($upload->upload_result[0]['error'] == 0) {
                $db->SelectDB($setting_sub['db']['name']);
                if ($upload->upload_result[0]['type'] == "application/x-zip-compressed") {
                    require ROOT_PATH . "/source/class/myzip.class.php";
                    $dir = $path_upload . date("/Ymd_") . rand(1000, 9999) . "/";
                    unzip($path_upload . $upload->upload_result[0]['new_name'], $dir);
                    $result_exe = array();
                    if ($handle = opendir($dir)) {
                        while (false !== ($file = readdir($handle))) {
                            if (is_file($file) && GetFileExt($file) == "sql") {
                                $result_exe += $db->ExeSqlFile($file);
                            }
                        }
                        closedir($handle);
                    }
                    $result = count($result_exe) > 0 ? $setting['language']['admin_func_backup_import_done'] : $setting['language']['admin_func_backup_import_failed'];
                    MultiDel($dir);
                } else {
                    $result_exe = $db->ExeSqlFile($path_upload . $upload->upload_result[0]['new_name']);
                    $result = count($result_exe) > 0 ? $setting['language']['admin_func_backup_import_done'] : $setting['language']['admin_func_backup_import_failed'];
                }
Exemple #29
0
function preflightCheckJsonFindUpgradeFiles($persistence)
{
    global $sugar_config;
    global $mod_strings;
    unset($persistence['rebuild_relationships']);
    unset($persistence['rebuild_extensions']);
    // don't bother if are rechecking
    $manualDiff = array();
    if (!isset($persistence['unzip_dir']) || empty($persistence['unzip_dir'])) {
        logThis('unzipping files in upgrade archive...');
        $errors = array();
        $base_upgrade_dir = "upload://upgrades";
        $base_tmp_upgrade_dir = sugar_cached("upgrades/temp");
        $install_file = urldecode($persistence['install_file']);
        $show_files = true;
        $unzip_dir = mk_temp_dir($base_tmp_upgrade_dir);
        $zip_from_dir = ".";
        $zip_to_dir = ".";
        $zip_force_copy = array();
        unzip($install_file, $unzip_dir);
        // assumption -- already validated manifest.php at time of upload
        include "{$unzip_dir}/manifest.php";
        if (isset($manifest['copy_files']['from_dir']) && $manifest['copy_files']['from_dir'] != "") {
            $zip_from_dir = $manifest['copy_files']['from_dir'];
        }
        if (isset($manifest['copy_files']['to_dir']) && $manifest['copy_files']['to_dir'] != "") {
            $zip_to_dir = $manifest['copy_files']['to_dir'];
        }
        if (isset($manifest['copy_files']['force_copy']) && $manifest['copy_files']['force_copy'] != "") {
            $zip_force_copy = $manifest['copy_files']['force_copy'];
        }
        if (isset($manifest['version'])) {
            $version = $manifest['version'];
        }
        if (!is_writable("config.php")) {
            logThis('BAD error');
            return $mod_strings['ERR_UW_CONFIG'];
        }
        logThis('setting "unzip_dir" to ' . $unzip_dir);
        $persistence['unzip_dir'] = clean_path($unzip_dir);
        $persistence['zip_from_dir'] = clean_path($zip_from_dir);
        logThis('unzip done.');
    } else {
        $unzip_dir = $persistence['unzip_dir'];
        $zip_from_dir = $persistence['zip_from_dir'];
    }
    $persistence['upgrade_files'] = uwFindAllFiles(clean_path("{$unzip_dir}/{$zip_from_dir}"), array(), true, array(), true);
    return $persistence;
}
 /**
  * @todo extract zip function basedomain/zip/extract
  * 
  * @see s_linux_unzip Function
  * @see unzip Function
  * @see createFolder Function
  * @see getContents Function
  * @see resize & crop Function
  * @see validateUsername Function
  * @see imagezip class
  * 
  * */
 function extract($status = NULL, $msg = NULL, $data = NULL)
 {
     global $CONFIG;
     $name = $_POST['imagezip'];
     $path = '';
     $path_file = $CONFIG['default']['upload_path'];
     //get data user from session
     $session = new Session();
     //$sess_user = $session->get_session();
     //$sess_data = $sess_user['ses_user'];
     $sess_data = $session->get_session();
     $username = $sess_data['login']['username'];
     $personID = $sess_data['login']['id'];
     $password = $sess_data['login']['password'];
     if (empty($username) || empty($personID) || empty($password)) {
         $status = "error";
         $msg = "Kesalahan terjadi saat validasi data pengguna, silakan logout kemudian login kembali";
         echo json_encode(array('status' => $status, 'message' => $msg));
         exit;
     }
     //$email = $_POST['email'];
     /*$username = $_POST['username'];
             
             $validateUsername = $this->validateUsername($username);
     
             if($validateUsername['status'] != 'success'){
                 $status = "error";
                 $msg = "Error occured while validating username";
                 
                 echo json_encode(array('status' => $status, 'message' => $msg));
                 exit;
             }
             
             $personID = $validateUsername['personID'];*/
     // input with email
     /*$validateEmail = $this->validateEmail($email);
       if($validateEmail['status'] != 'success'){
           $status = "error";
           $msg = "Error occured while validating email";
           
           echo json_encode(array('status' => $status, 'message' => $msg));
           exit;
       }
       $personID = $validateEmail['personID'];
       $username = $validateEmail['short_namecode'];*/
     //end input with email
     //move zip file to tmp folder
     $copy_zip = sftpServices($CONFIG['default']['hostname'], $username, $password, $name);
     logFile($copy_zip);
     if (!$copy_zip) {
         $status = "error";
         $msg = "Kesalahan saat mengambil file zip atau file zip tidak ditemukan";
         echo json_encode(array('status' => $status, 'message' => $msg));
         exit;
     }
     if (!empty($name)) {
         if (preg_match('#\\.(zip|ZIP)$#i', $name)) {
             $tmp_path = md5($name);
             $path_extract = $path_file . 'imgprocess/' . $tmp_path;
             $file = $path_file . $name;
             //check file zip exist
             if (!file_exists($file)) {
                 $status = "error";
                 $msg = "Sistem tidak dapat menemukan file yang ditentukan";
                 echo json_encode(array('status' => $status, 'message' => $msg));
                 exit;
             }
             if ($CONFIG['default']['unzip'] == 's_linux_unzip') {
                 s_linux_unzip($file, $path_extract);
             } elseif ($CONFIG['default']['unzip'] == 'zipArchive') {
                 unzip($file, $path_extract);
             }
             $path_data = 'public_assets/';
             //$path_user = $path_data.$username;
             $path_img = $path_data . '/img';
             $path_img_ori = $path_img . '/ori';
             $path_img_1000px = $path_img . '/1000px';
             $path_img_500px = $path_img . '/500px';
             $path_img_100px = $path_img . '/100px';
             $toCreate = array($path_img, $path_img_ori, $path_img_1000px, $path_img_500px, $path_img_100px);
             $permissions = 0755;
             if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
                 createFolder($toCreate, $permissions);
             } else {
                 shell_createFolder($toCreate);
             }
             $images = $this->GetContents($path_extract);
             $list = count($images);
             $dataNotExist = array();
             foreach ($images as $image) {
                 $entry = $image['filename'];
                 $path_entry = $image['path'];
                 $len = strlen($path_extract);
                 $folder = substr($path_entry, $len);
                 if (preg_match('#\\.(jpg|jpeg|JPG|JPEG)$#i', $entry)) {
                     $image_name_encrypt = md5(str_shuffle($CONFIG['default']['salt'] . $entry));
                     $fileinfo = getimagesize($path_entry . '/' . $entry);
                     if (!$fileinfo) {
                         $status = "error";
                         $msg = "Tidak ada informasi jenis berkas";
                     } else {
                         $valid_types = array(IMAGETYPE_JPEG);
                         $valid_mime = array('image/jpeg');
                         if (in_array($fileinfo[2], $valid_types) || in_array($fileinfo['mime'], $valid_mime)) {
                             $mime = true;
                         } else {
                             $mime = false;
                         }
                         if ($mime) {
                             //check file exist here
                             //$dataExist = $this->imagezip->dataExist($entry);
                             $dataExist = $this->imagezip->imageExist($entry);
                             //add file information to array
                             $fileToInsert = array('filename' => $entry, 'md5sum' => $image_name_encrypt, 'directory' => $folder, 'mimetype' => $fileinfo['mime']);
                             if ($dataExist) {
                                 //get detail image
                                 $detail_image = $this->imagezip->get_image_by_name($entry);
                                 if ($detail_image['md5sum']) {
                                     $delete_image = array($path_img_ori . '/' . $detail_image['md5sum'] . '.ori.jpg', $path_img_1000px . '/' . $detail_image['md5sum'] . '.1000px.jpg', $path_img_500px . '/' . $detail_image['md5sum'] . '.500px.jpg', $path_img_100px . '/' . $detail_image['md5sum'] . '.100px.jpg');
                                     //delete old image
                                     $this->delete_img($delete_image);
                                 }
                                 copy($path_entry . "/" . $entry, $path_img_ori . '/' . $image_name_encrypt . '.ori.jpg');
                                 copy($path_entry . "/" . $entry, $path_img_1000px . '/' . $image_name_encrypt . '.1000px.jpg');
                                 if (!@copy($path_entry . "/" . $entry, $path_img_1000px . '/' . $image_name_encrypt . '.1000px.jpg')) {
                                     $status = "error";
                                     $msg = error_get_last();
                                 } else {
                                     $src_tmp = $path_entry . "/" . $entry;
                                     $dest_1000px = $CONFIG['default']['root_path'] . '/' . $path_img_1000px . '/' . $image_name_encrypt . '.1000px.jpg';
                                     $dest_500px = $CONFIG['default']['root_path'] . '/' . $path_img_500px . '/' . $image_name_encrypt . '.500px.jpg';
                                     $dest_100px = $CONFIG['default']['root_path'] . '/' . $path_img_100px . '/' . $image_name_encrypt . '.100px.jpg';
                                     if ($fileinfo[0] >= 1000 || $fileinfo[1] >= 1000) {
                                         if ($fileinfo[0] > $fileinfo[1]) {
                                             $percentage = 1000 / $fileinfo[0];
                                             $config['width'] = $percentage * $fileinfo[0];
                                             $config['height'] = $percentage * $fileinfo[1];
                                         } else {
                                             $percentage = 1000 / $fileinfo[1];
                                             $config['width'] = $percentage * $fileinfo[0];
                                             $config['height'] = $percentage * $fileinfo[1];
                                         }
                                         $this->resize_pic($src_tmp, $dest_1000px, $config);
                                         unset($config);
                                     }
                                     //Set cropping for y or x axis, depending on image orientation
                                     if ($fileinfo[0] > $fileinfo[1]) {
                                         $config['width'] = $fileinfo[1];
                                         $config['height'] = $fileinfo[1];
                                         $config['x_axis'] = $fileinfo[0] / 2 - $config['width'] / 2;
                                         $config['y_axis'] = 0;
                                     } else {
                                         $config['width'] = $fileinfo[0];
                                         $config['height'] = $fileinfo[0];
                                         $config['x_axis'] = 0;
                                         $config['y_axis'] = $fileinfo[1] / 2 - $config['height'] / 2;
                                     }
                                     $this->cropToSquare($src_tmp, $dest_500px, $config);
                                     unset($config);
                                     //set new config
                                     $config['width'] = 500;
                                     $config['height'] = 500;
                                     $this->resize_pic($dest_500px, $dest_500px, $config);
                                     unset($config);
                                     $config['width'] = 100;
                                     $config['height'] = 100;
                                     $this->resize_pic($dest_500px, $dest_100px, $config);
                                     unset($config);
                                     //update data
                                     $insertImage = $this->imagezip->updateImage($personID, $fileToInsert);
                                 }
                                 // end if copy
                             } else {
                                 //add data information to array
                                 array_push($dataNotExist, $fileToInsert);
                             }
                         }
                     }
                 }
             }
             $count_dataNotExist = count($dataNotExist);
             if ($list == $count_dataNotExist) {
                 $status = 'warning';
                 $msg = 'File berhasil diekstrak. Tidak ada gambar yang sesuai dengan data.';
                 $data['dataNotExist'] = $dataNotExist;
             } else {
                 //send dataNotExist information to user
                 $status = 'success';
                 $msg = 'File berhasil diekstrak.';
                 $data['dataNotExist'] = $dataNotExist;
             }
             deleteDir($path_extract);
         } else {
             $status = "error";
             $msg = 'Nama file harus file zip';
         }
     } else {
         $status = "error";
         $msg = 'Nama file tidak boleh kosong';
     }
     echo json_encode(array('status' => $status, 'message' => $msg, 'data' => $data));
     exit;
 }