Ejemplo n.º 1
0
 public function exportSameData($directory = '')
 {
     if ($directory) {
         self::$sameDatas = $directory;
     }
     $langId = Context::getContext()->language->id;
     $link = mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_);
     mysql_select_db(_DB_NAME_, $link);
     $currentOption = Configuration::get('OVIC_CURRENT_DIR');
     if ($currentOption) {
         $currentOption .= '.';
     } else {
         $currentOption = '';
     }
     foreach (self::$tables as $table => $type) {
         $fields = array();
         $query2 = mysql_query('SHOW COLUMNS FROM ' . _DB_PREFIX_ . $table);
         while ($row = mysql_fetch_row($query2)) {
             $fields[] = $row[0];
         }
         $return = '';
         if ($type == 'lang') {
             $query1 = mysql_query('SELECT * FROM ' . _DB_PREFIX_ . $table . " Where id_lang = " . $langId);
             $num_fields = mysql_num_fields($query1);
             for ($i = 0; $i < $num_fields; $i++) {
                 while ($row = mysql_fetch_row($query1)) {
                     $return .= 'INSERT INTO PREFIX_' . $table . ' VALUES(';
                     for ($j = 0; $j < $num_fields; $j++) {
                         $row[$j] = addslashes($row[$j]);
                         $row[$j] = str_replace(array("\n", "\r"), '', $row[$j]);
                         if (isset($row[$j])) {
                             if ($fields[$j] == 'id_lang') {
                                 $return .= '"id_lang"';
                             } else {
                                 $return .= '"' . $row[$j] . '"';
                             }
                         } else {
                             $return .= '""';
                         }
                         if ($j < $num_fields - 1) {
                             $return .= ',';
                         }
                     }
                     $return .= ");\n";
                 }
             }
         } else {
             $query1 = mysql_query('SELECT * FROM ' . _DB_PREFIX_ . $table);
             $num_fields = mysql_num_fields($query1);
             for ($i = 0; $i < $num_fields; $i++) {
                 while ($row = mysql_fetch_row($query1)) {
                     $return .= 'INSERT INTO PREFIX_' . $table . ' VALUES(';
                     for ($j = 0; $j < $num_fields; $j++) {
                         $row[$j] = addslashes($row[$j]);
                         $row[$j] = str_replace(array("\n", "\r"), '', $row[$j]);
                         if (isset($row[$j])) {
                             $return .= '"' . $row[$j] . '"';
                         } else {
                             $return .= '""';
                         }
                         if ($j < $num_fields - 1) {
                             $return .= ',';
                         }
                     }
                     $return .= ");\n";
                 }
             }
         }
         $return .= "\n";
         $handle = fopen(self::$sameDatas . $currentOption . $table . '.sql', 'w+');
         fwrite($handle, $return);
         fclose($handle);
     }
     return true;
     $files = scandir($this->pathImage);
     foreach ($files as $file) {
         if ($file != '.' && $file != '..' && $file != 'temps') {
             copy($this->pathImage . $file, $this->sameDatas . $file);
         }
     }
     $zip = new ZipArchive();
     $zip->open($this->sameDatas . 'bak.zip', ZipArchive::CREATE);
     $handle = fopen($this->sameDatas . $currentOption . $table . '.sql', 'w+');
     while (false !== ($file = readdir($handle))) {
         if ($file != '.' && $file != '..' && is_dir($this->sameDatas . $file)) {
             //$fileContents = file_get_contents($this->sameDatas.$file);
             $zip->addFile($this->sameDatas . $file, $file);
         }
     }
     closedir($handle);
     $zip->close();
     header("Location: bak.zip");
     exit;
 }
Ejemplo n.º 2
0
<?php

require_once dirname(__FILE__) . '../../../config/config.inc.php';
require_once dirname(__FILE__) . '../../../init.php';
require_once dirname(__FILE__) . '/flexbanner.php';
$module = new FlexBanner();
$response = new stdClass();
if (!Tools::isSubmit('secure_key') || Tools::getValue('secure_key') != $module->secure_key) {
    $response->status = 0;
    $response->fileName = "";
    $response->msg = $module->l("you need to login with the admin account.");
} else {
    $fileType = strtolower(pathinfo($_FILES["uploader"]["name"], PATHINFO_EXTENSION));
    $fileName = time() . '.' . $fileType;
    $fileTemp = $module->pathImage . 'temps/' . $fileName;
    if (isset($_POST['width']) && intval($_POST['width']) > 0) {
        $width = intval($_POST['width']);
    } else {
        $width = null;
    }
    if (isset($_POST['height']) && intval($_POST['height']) > 0) {
        $height = intval($_POST['height']);
    } else {
        $height = null;
    }
    if (isset($_POST['maxFileSize']) && $_POST['maxFileSize']) {
        $maxFileSize = $_POST['maxFileSize'];
    }
    $maxFileSize = 1;
    // MB
    if (isset($_POST['uploadType']) && $_POST['uploadType']) {