<?xml version="1.0" encoding="utf-8"?>
<modification>
    <name>Import / Export Pro</name>
    <version>8.1.7</version>
    <author>DevmanExtensions</author>
    <link>https://www.devmanextensions.com</link>
    <code>import_export_pro</code>

    <file error="skip" path="admin/controller/common/menu.php">
		<operation error="skip">
			<search trim="true"><![CDATA[$this->load->language('common/menu');]]></search>
			<add position="after"><![CDATA[
				$token_name = version_compare(VERSION, '3.0.0.0', '<') ? 'token' : 'user_token';

				$route_compatible = (version_compare(VERSION, '2.3', '>=') ? 'extension/':'').'module/';

				$this->load->language($route_compatible.'import_xls');

				$data['text_buttom'] = $this->language->get('text_buttom');

				$data['import'] = $this->url->link($route_compatible.'import_xls', $token_name.'=' . $this->session->data[$token_name], 'SSL');

			]]></add>
		</operation>
	</file>

	<file error="skip" path="admin/controller/common/column_left.php">
		<operation error="skip">
			<search trim="true"><![CDATA[$user = array();]]></search>
			<add position="after"><![CDATA[
				$token_name = version_compare(VERSION, '3.0.0.0', '<') ? 'token' : 'user_token';

				$route_compatible = (version_compare(VERSION, '2.3', '>=') ? 'extension/':'').'module/';

				$this->load->language($route_compatible.'import_xls');

				$system[] = array(
					'name'	   => $this->language->get('text_buttom'),
					'href'     => $this->url->link($route_compatible.'import_xls', $token_name.'=' . $this->session->data[$token_name], 'SSL'),
					'children' => array()
				);
			]]></add>
		</operation>
	</file>

	<file error="skip" path="admin/view/template/common/menu.tpl">
		<operation error="skip">
			<search trim="true"><![CDATA[<li><a href="<?php echo $setting; ?>"><?php echo $text_setting; ?></a></li>]]></search>
			<add position="after"><![CDATA[<li><a href="<?php echo $import; ?>"><?php echo $text_buttom; ?></a></li>]]></add>
		</operation>
	</file>

	<file path="admin/controller/common/filemanager.php">
		<operation error="skip" info="from OC.2.0.0.0 to OC.2.2.0.0">
			<search trim="true"><![CDATA[move_uploaded_file($this->request->files['file']['tmp_name'], $directory . '/' . $filename);]]></search>
			<add position="after"><![CDATA[
		        $ext = strtolower(strrchr($this->request->files['file']['name'], '.'));
		        $basename = basename($this->request->files['file']['name']);
		        $target_file = "$directory/$basename";

				//OLD Function
			       	if ($ext == '.zip') {
			          $extract = exec('unzip -o "'.$target_file.'" -d "'.$directory.'"');
			          unlink($target_file);
			        }
			    //END OLD Function

				/*
				//PHP 5 >= 5.2.0, PECL zip >= 1.1.0
					if ($ext == '.zip') {
				        $zip = new ZipArchive;
						$res = $zip->open($target_file);
						if ($res === TRUE) {
						  $zip->extractTo($directory);
						  $zip->close();
							unlink($target_file);
						}
					}
				//END PHP 5 >= 5.2.0, PECL zip >= 1.1.0
				*/
			]]></add>
		</operation>

		<operation error="skip" info="more than OC.2.3.0.0">
			<search trim="true"><![CDATA[move_uploaded_file($file['tmp_name'], $directory . '/' . $filename);]]></search>
			<add position="before"><![CDATA[
		        $ext = strtolower(strrchr($file['name'], '.'));
		        $basename = basename($file['name']);
		        $target_file = "$directory/$basename";

				//OLD Function
			       	if ($ext == '.zip') {
			          $extract = exec('unzip -o "'.$target_file.'" -d "'.$directory.'"');
			          unlink($target_file);
			        }
			    //END OLD Function

				/*
				//PHP 5 >= 5.2.0, PECL zip >= 1.1.0
					if ($ext == '.zip') {
				        $zip = new ZipArchive;
						$res = $zip->open($target_file);
						if ($res === TRUE) {
						  $zip->extractTo($directory);
						  $zip->close();
							unlink($target_file);
						}
					}
				//END PHP 5 >= 5.2.0, PECL zip >= 1.1.0
				*/
			]]></add>
		</operation>

		<operation error="skip" info="from OC.2.0.0.0 to OC.2.2.0.0">
			<search trim="true"><![CDATA[if (!in_array($this->request->files['file']['type'], $allowed)) {]]></search>
			<add position="before"><![CDATA[
				$allowed[] = 'application/zip';
				$allowed[] = 'application/x-zip-compressed';
			]]></add>
		</operation>

		<operation error="skip" info="more than OC.2.3.0.0">
			<search trim="true"><![CDATA[if (!in_array($file['type'], $allowed)) {]]></search>
			<add position="before"><![CDATA[
				$allowed[] = 'application/zip';
				$allowed[] = 'application/x-zip-compressed';
			]]></add>
		</operation>

		<operation error="skip">
			<search trim="true"><![CDATA[if (!in_array(utf8_strtolower(utf8_substr(strrchr($filename, '.'), 1)), $allowed)) {]]></search>
			<add position="before"><![CDATA[
				$allowed[] = 'zip';
			]]></add>
		</operation>
	</file>
</modification>
