Commit b3ff654d authored by Alexandre Morin's avatar Alexandre Morin
Browse files

Fix : Directory message in config

parent ba65bf8f
......@@ -18,45 +18,66 @@
* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>.
*/
require_once __DIR__.'/Zip.php';
require_once __DIR__ . '/RequestSeda.php';
require_once __DIR__.'/Zip.php';
require_once __DIR__ . '/RequestSeda.php';
$status = 0;
$error = $content = '';
if ($_REQUEST['reference']) {
$extract = new Extract();
$zipfile = $extract->exportZip($_REQUEST['reference']);
$extract->download($zipfile);
} else {
$status = 1;
}
$status = 0;
$error = $content = '';
if ($_REQUEST['reference']) {
$extract = new Extract();
$zipfile = $extract->exportZip($_REQUEST['reference']);
$extract->download($zipfile);
} else {
$status = 1;
}
echo "{status : " . $status . ", content : '" . addslashes($content) . "', error : '" . addslashes($error) . "'}";
exit ();
echo "{status : " . $status . ", content : '" . addslashes($content) . "', error : '" . addslashes($error) . "'}";
exit ();
class Extract
{
protected $zip;
protected $zip;
public function __construct()
{
$this->zip = new Zip();
}
public function __construct()
{
$this->zip = new Zip();
$getXml = false;
$path = '';
if (file_exists(
$_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
. $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR . 'modules'
. DIRECTORY_SEPARATOR . 'export_seda'. DIRECTORY_SEPARATOR . 'xml'
. DIRECTORY_SEPARATOR . 'config.xml'
)) {
$path = $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
. $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR . 'modules'
. DIRECTORY_SEPARATOR . 'export_seda'. DIRECTORY_SEPARATOR . 'xml'
. DIRECTORY_SEPARATOR . 'config.xml';
$getXml = true;
} else if (file_exists($_SESSION['config']['corepath'] . 'modules' . DIRECTORY_SEPARATOR . 'export_seda'. DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'config.xml')) {
$path = $_SESSION['config']['corepath'] . 'modules' . DIRECTORY_SEPARATOR . 'export_seda'
. DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'config.xml';
$getXml = true;
}
public function exportZip($reference)
{
$messageDirectory = __DIR__.DIRECTORY_SEPARATOR.'message'.DIRECTORY_SEPARATOR.$reference;
$zipDirectory = __DIR__.DIRECTORY_SEPARATOR.'message'.DIRECTORY_SEPARATOR.$reference. ".zip";
if ($getXml) {
$this->xml = simplexml_load_file($path);
}
}
if (!is_file($zipDirectory)) {
public function exportZip($reference)
{
$messageDirectory = (string) $this->xml->CONFIG->directoryMessage . DIRECTORY_SEPARATOR . $reference;
$zipDirectory = (string) $this->xml->CONFIG->directoryMessage . DIRECTORY_SEPARATOR . $reference . ".zip";
if (!is_file($zipDirectory)) {
if (is_dir($messageDirectory)) {
$zip = new ZipArchive();
$zip->open($zipDirectory, ZipArchive::CREATE);
$listFiles = scandir($messageDirectory.DIRECTORY_SEPARATOR);
foreach ( $listFiles as $filename) {
foreach ($listFiles as $filename) {
if ($filename != '.' && $filename != '..') {
$zip->addFile($messageDirectory . DIRECTORY_SEPARATOR . $filename, $filename);
}
......@@ -66,9 +87,9 @@ class Extract
}
return $zipDirectory;
}
}
public function download($full_path)
public function download($full_path)
{
$file_name = basename($full_path);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment