Example #1
0
 public function downloadMPDF(Vtiger_Request $request)
 {
     $error == "";
     $srcZip = "http://www.crm4you.sk/PDFMaker/src/mpdf.zip";
     $trgZip = "modules/PDFMaker/resources/mpdf.zip";
     if (copy($srcZip, $trgZip)) {
         require_once 'vtlib/thirdparty/dUnzip2.inc.php';
         $unzip = new dUnzip2($trgZip);
         $unzip->unzipAll(getcwd() . "/modules/PDFMaker/resources/");
         if ($unzip) {
             $unzip->close();
         }
         if (!is_dir("modules/PDFMaker/resources/mpdf")) {
             $error = vtranslate("UNZIP_ERROR", 'PDFMaker');
             $viewer->assign("STEP", "error");
             $viewer->assign("ERROR_TBL", $errTbl);
         }
     } else {
         $error = vtranslate("DOWNLOAD_ERROR", 'PDFMaker');
     }
     if ($error == "") {
         $result = array('success' => true, 'message' => '');
     } else {
         $result = array('success' => false, 'message' => $error);
     }
     $response = new Vtiger_Response();
     $response->setResult($result);
     $response->emit();
 }
Example #2
0
 function install($path, $unzip = true)
 {
     if ($unzip) {
         $zip = new dUnzip2($path);
         $unzipPath = $GLOBALS['path'] . "/../tmp/" . basename($path) . "_contents/";
         $zip->getList();
         if (!file_exists($unzipPath)) {
             mkdir($unzipPath);
         }
         $zip->unzipAll($unzipPath);
     } else {
         $unzipPath = $path;
     }
     $info = @file_get_contents($unzipPath . "/meta.json");
     if ($info == false) {
         return false;
     }
     $info = @Zend_Json::decode($info);
     if ($info == false) {
         return false;
     }
     $method = "_install_" . $info['type'];
     $ret = package::$method($info, $unzipPath);
     if (!$ret) {
         return false;
     }
     if ($unzip) {
         rmdir($unzipPath);
     }
     $info['installedFiles'] = $ret;
     unlink($unzipPath . "/meta.json");
     return $info;
 }
Example #3
0
function unzip_go()
{
    global $list, $options;
    require_once CLASS_DIR . "unzip.php";
    $any_file_unzippped = false;
    for ($i = 0; $i < count($_POST["files"]); $i++) {
        $file = $list[$_POST["files"][$i]];
        if (file_exists($file["name"])) {
            $zip = new dUnzip2($file["name"]);
            $allf = $zip->getList();
            $file_inside_zip_exists = false;
            $forbidden_inside_zip = false;
            foreach ($allf as $k => $properties) {
                if (file_exists($options['download_dir'] . basename($properties['file_name']))) {
                    $file_inside_zip_exists = true;
                    break;
                }
            }
            if ($options['check_these_before_unzipping']) {
                foreach ($allf as $k => $property) {
                    $zfiletype = strrchr($property['file_name'], ".");
                    if (is_array($options['forbidden_filetypes']) && in_array(strtolower($zfiletype), $options['forbidden_filetypes'])) {
                        $forbidden_inside_zip = true;
                        break;
                    }
                }
            }
            if ($file_inside_zip_exists) {
                echo 'Some file(s) inside <b>' . htmlentities(basename($file["name"])) . '</b> already exist on download directory';
                echo "<br /><br />";
            } elseif ($forbidden_inside_zip) {
                printf(lang(181), $zfiletype);
                echo "<br /><br />";
            } else {
                $zip->unzipAll($options['download_dir']);
                if ($zip->getList() != false) {
                    $any_file_unzippped = true;
                    echo '<b>' . htmlentities(basename($file["name"])) . '</b>&nbsp;unzipped successfully<br /><br />';
                    foreach ($allf as $k => $properties) {
                        $efile = realpath($options['download_dir']) . '/' . basename($properties['file_name']);
                        if (is_file($efile)) {
                            $time = filemtime($efile);
                            while (isset($list[$time])) {
                                $time++;
                            }
                            $list[$time] = array("name" => $efile, "size" => bytesToKbOrMbOrGb(filesize($efile)), "date" => $time);
                        }
                    }
                    if (!updateListInFile($list)) {
                        echo lang(146) . "<br /><br />";
                    }
                } else {
                    echo "File <b>" . $file["name"] . "</b> not found!<br /><br />";
                }
            }
        }
    }
}
Example #4
0
function unzip_install($filename, $tmpdir)
{
    $zip = new dUnzip2($filename);
    // Activate debug
    //$zip->debug = true;
    // Unzip all the contents of the zipped file to a new folder called "uncompressed"
    $zip->getList();
    $zip->unzipAll($tmpdir);
    echo "<b>Unpacked the zipped file</b><br>";
}
function Installer_fast_file_check($file, $installname, $includeDir)
{
    // Prüfen, ob das Ergebnis nicht bereits in einer Session steht
    // um Dauerverbindungen zu Redaxo.de zu vermeiden.
    if (isset($_SESSION['fastcheck'][$file])) {
        // Session exisitert - um overhead zu sparen, wird das Ergebnis der
        // letzten Session ausgegeben
        return $_SESSION['fastcheck'][$file];
    } else {
        // Session besteht noch nicht, also First-Run OK!
        // Pfad zum TEMP-Verzeichnis
        // TODO: Variablen ersetzen!
        $path = $includeDir . "/addons/installer/temp/" . md5($file) . ".zip";
        $file_output = '';
        try {
            $socket = rex_installer_socket::createByUrl($file);
            $socket->doGet();
            $res = fopen($path, 'w');
            $file_output = $socket->writeBodyTo($res);
        } catch (rex_installer_socket_exception $e) {
            // fehlermeldung:
            echo rex_warning($e->getMessage());
            return FALSE;
        }
        if (!$file_output) {
            echo rex_warning("Das AddOn konnte aufgrund von Serverproblemen nicht überprüft werden! Fast-Check Ergebnisse sind deswegen fehlerhaft (Alle fallen durch, obwohl das AddOn in Ordnung sein könnte). Korrete AddOns lassen sich normalerweise dennoch ohne Probleme installieren. Eine zweite Sicherheitsroutine wird versuchen die Sicherheit weiterhin zu gewährleisten. Für weitere Versuche klicke auf das Plus-Symbol");
            return FALSE;
        }
        // Zip Klasse laden
        $zip = new dUnzip2($path);
        // Inhalt vom ZIP-FILE laden. Liefert ARRAY zurück
        $zipList = $zip->getList();
        // Ruft die Sicherheitsfunktion auf, um zu prüfen, ob es sich
        // um ein richtiges AddOn handelt, wenn ja, true, ansonsten false
        if (Installer_check_if_file_is_addon($zipList, $installname)) {
            $zip->__destroy();
            // fclose && memory free
            @unlink($path);
            // Datei löschen
            // Um ständige Verbindungen zu Redaxo.de zu unterbinden,
            // wird das Ergebnis in eine Session geschrieben
            $_SESSION['fastcheck'][$file] = true;
            return true;
        } else {
            $zip->__destroy();
            // fclose && memory free
            @unlink($path);
            // Datei löschen
            // Um ständige Verbindungen zu Redaxo.de zu unterbinden,
            // wird das Ergebnis in eine Session geschrieben
            $_SESSION['fastcheck'][$file] = false;
            return false;
        }
    }
}
Example #6
0
 function uploaded()
 {
     if (!is_admin()) {
         return info_page('只有管理员才能进入此页面,<a href="?c=guest&a=logout">请先用管理员账户登入</a>');
     }
     if ($_FILES['pfile']['error'] != 0) {
         return info_page('文件上传错误,请重新上传');
     }
     $tmp_name = $_FILES['pfile']['tmp_name'];
     $tname = uid() . '-' . time();
     $plug_path = c('plugin_path') . DS . $tname;
     if (@mkdir($plug_path)) {
         include_once AROOT . 'lib' . DS . 'dUnzip2.inc.php';
         $zip = new dUnzip2($tmp_name);
         $zip->debug = false;
         $zip->unzipAll($plug_path);
         @chmod($plug_path, 0755);
         $info_file = $plug_path . DS . 'app.php';
         if (file_exists($info_file)) {
             if ($info = get_plugin_info(file_get_contents($info_file))) {
                 if (isset($info['folder_name'])) {
                     $folder_name = $info['folder_name'];
                 }
                 if (strlen($folder_name) < 1) {
                     $folder_name = reset(explode('.', basename($_FILES['pfile']['name'])));
                 }
                 if (strlen($folder_name) > 0) {
                     if (file_exists(c('plugin_path') . DS . $folder_name)) {
                         @rename(c('plugin_path') . DS . $folder_name . DS . 'app.php', c('plugin_path') . DS . $folder_name . DS . 'app.bak.php');
                         @rename(c('plugin_path') . DS . $folder_name, c('plugin_path') . DS . $folder_name . '_' . uid() . '_' . time());
                     }
                     rename($plug_path, c('plugin_path') . DS . $folder_name);
                     header("Location: ?c=pluglist");
                     return true;
                 } else {
                     return info_page('尝试获取插件名称失败,启用' . $tname . '作为临时名称,<a href="?c=pluglist">请点击继续</a>');
                 }
             }
         } else {
             // clear dir
         }
         return info_page('找不到插件执行脚本-app.php文件,<a href="?c=pluglist">请重新上传格式正确的插件包</a>');
     } else {
         return info_page('创建插件目录失败,请将plugin目录设置为可写后<a href="?c=pluglist">重试</a>');
     }
 }
Example #7
0
 function uploaded()
 {
     if (!is_admin()) {
         return info_page(__('ADMIN_ONLY_LOGIN'));
     }
     if ($_FILES['pfile']['error'] != 0) {
         return info_page(__('PLUGIN_UPLOAD_FILE_ERROR_RETRY'));
     }
     $tmp_name = $_FILES['pfile']['tmp_name'];
     $tname = uid() . '-' . time();
     $plug_path = c('plugin_path') . DS . $tname;
     if (@mkdir($plug_path)) {
         include_once AROOT . 'lib' . DS . 'dUnzip2.inc.php';
         $zip = new dUnzip2($tmp_name);
         $zip->debug = false;
         $zip->unzipAll($plug_path);
         @chmod($plug_path, 0755);
         $info_file = $plug_path . DS . 'app.php';
         if (file_exists($info_file)) {
             if ($info = get_plugin_info(file_get_contents($info_file))) {
                 if (isset($info['folder_name'])) {
                     $folder_name = $info['folder_name'];
                 }
                 if (strlen($folder_name) < 1) {
                     $folder_name = reset(explode('.', basename($_FILES['pfile']['name'])));
                 }
                 if (strlen($folder_name) > 0) {
                     if (file_exists(c('plugin_path') . DS . $folder_name)) {
                         @rename(c('plugin_path') . DS . $folder_name . DS . 'app.php', c('plugin_path') . DS . $folder_name . DS . 'app.bak.php');
                         @rename(c('plugin_path') . DS . $folder_name, c('plugin_path') . DS . $folder_name . '_' . uid() . '_' . time());
                     }
                     rename($plug_path, c('plugin_path') . DS . $folder_name);
                     header("Location: ?c=pluglist");
                     return true;
                 } else {
                     return info_page(__('PLUGIN_GET_NAME_ERROR_RETRY', $tname));
                 }
             }
         } else {
             // clear dir
         }
         return info_page(__('PLUGIN_PACKAGE_FORMAT_ERROR'));
     } else {
         return info_page(__('PLUGIN_CREATE_FOLDER_ERROR'));
     }
 }
Example #8
0
function backup_unzip($zipfile = '', $err_show = 1)
{
    require_once "unzip.class.php";
    if (!file_exists(CFBACKUPPATH . $zipfile)) {
        if ($err_show) {
            user_feedback('error', 'can\'t find file!', 'backup_unzip');
        }
        return false;
    }
    $file_ext = explode(".", $zipfile);
    $file_type = explode("_", $zipfile);
    if (end($file_ext) == 'zip') {
        if ($file_type[0] == 'imgdb') {
            $unzip_to = CFDATAPATH;
            //CFBACKUPPATH.'uncompressed';
        } elseif ($file_type[0] == 'bandwidth' && $err_show) {
            $unzip_to = CFBANDWIDTHPATH;
        }
    } else {
        if ($err_show) {
            user_feedback('error', 'can\'t Unzip file!', 'backup_unzip');
        }
        return false;
    }
    $zip = new dUnzip2(CFBACKUPPATH . $zipfile);
    $zip->unzipAll($unzip_to);
    if ($zip->getLastError()) {
        if ($err_show) {
            user_feedback('success', 'Unzipped files!', 'backup_unzip');
        }
        return true;
    }
    if ($err_show) {
        user_feedback('error', 'can\'t Unzip file!', 'backup_unzip2');
    }
    return false;
}
Example #9
0
function cbupd_import($zipfile)
{
    global $cspath;
    $unzip = new dUnzip2($zipfile);
    $unzip->unzipAll($cspath);
    $filelist = $unzip->getList();
    $csxmlfound = false;
    echo getTranslatedString('Importing', 'cbupdater') . ' ' . $zipfile . '<br>';
    $processing = getTranslatedString('Processing', 'cbupdater') . ' ';
    foreach ($filelist as $filename => $fileinfo) {
        echo $processing . $filename . '<br>';
        $pinfo = pathinfo($filename);
        if ($pinfo['extension'] == 'xml') {
            $cbupdates = new DOMDocument();
            if ($cbupdates->load($cspath . '/' . $filename)) {
                if ($cbupdates->schemaValidate('modules/cbupdater/cbupdater.xsd')) {
                    $csxmlfound = true;
                    $w = new XMLWriter();
                    $w->openMemory();
                    $w->setIndent(true);
                    $w->startDocument('1.0', 'UTF-8');
                    $w->startElement("updatesChangeLog");
                    $root = $cbupdates->documentElement;
                    foreach ($root->childNodes as $node) {
                        if (get_class($node) == 'DOMElement' and $node->nodeName == 'changeSet') {
                            $elems = $node->getElementsByTagName('*');
                            $upd = array();
                            foreach ($elems as $elem) {
                                if ($elem->nodeName == 'filename') {
                                    $bname = basename($elem->nodeValue);
                                    $upd[$elem->nodeName] = $cspath . '/' . $bname;
                                } else {
                                    $upd[$elem->nodeName] = $elem->nodeValue;
                                }
                            }
                            echo $processing . getTranslatedString('ChangeSet', 'cbupdater') . ' ' . $upd['classname'] . '<br>';
                            $w->startElement("changeSet");
                            if (!empty($upd['author'])) {
                                $w->startElement("author");
                                $w->text($upd['author']);
                                $w->endElement();
                            }
                            if (!empty($upd['description'])) {
                                $w->startElement("description");
                                $w->text($upd['description']);
                                $w->endElement();
                            }
                            $w->startElement("filename");
                            $w->text($upd['filename']);
                            $w->endElement();
                            $w->startElement("classname");
                            $w->text($upd['classname']);
                            $w->endElement();
                            $w->startElement("systemupdate");
                            $w->text($upd['systemupdate'] == '1' ? 'true' : 'false');
                            $w->endElement();
                            $w->endElement();
                        }
                    }
                    $w->endElement();
                    $cbupdate_file = 'modules/cbupdater/cbupdates/' . date('YmdHis') . $filename;
                    $fd = fopen($cbupdate_file, 'w');
                    $cbxml = $w->outputMemory(true);
                    fwrite($fd, $cbxml);
                    fclose($fd);
                    @unlink($cspath . '/' . $filename);
                }
            }
        }
    }
    echo getTranslatedString('ImportDone', 'cbupdater') . '<br>';
    if (!$csxmlfound) {
        echo getTranslatedString('ImportError', 'cbupdater') . '<br>';
        echo getTranslatedString('CleanUp', 'cbupdater') . '<br>';
        cbupd_cleanup($filelist);
    }
}
         $socket->doGet();
         $res = @fopen($path, 'w');
         $file_output = $socket->writeBodyTo($res);
     } catch (rex_installer_socket_exception $e) {
         // fehlermeldung:
         echo rex_warning($e->getMessage());
         $file_output = false;
         $valid = false;
     }
 } else {
     $file_output = false;
 }
 $connector = $file_output ? $path : $_FILES['zip_file']['tmp_name'];
 if ($connector) {
     // Zip Klasse laden
     $zip = new dUnzip2($connector);
     //$zip->debug = 1; // debug?
     // Inhalt vom ZIP-FILE laden. Liefert ARRAY zurück
     $zipList = $zip->getList();
 } else {
     $zipList = array();
 }
 if ($file_output) {
     //tempfile wieder löschen
     @unlink($path);
 }
 if ($installname = zip_installer_check_if_file_is_addon($zipList)) {
     //echo rex_info('AddOn Paket scheint gültig zu sein!');
     $valid = true;
 } else {
     echo rex_warning('Kein gültiges AddOn. Installation abgebrochen');
Example #11
0
function upload_zip_file()
{
    global $xoopsDB, $xoopsUser, $xoopsModule, $xoopsModuleConfig, $type_to_mime;
    //取消上傳時間限制
    set_time_limit(0);
    //設置上傳大小
    ini_set('memory_limit', '100M');
    require_once "class/dunzip2/dUnzip2.inc.php";
    require_once "class/dunzip2/dZip.inc.php";
    $zip = new dUnzip2($_FILES['zipfile']['tmp_name']);
    $zip->getList();
    $zip->unzipAll(_TADGAL_UP_IMPORT_DIR);
}
Example #12
0
 public function __construct($filename)
 {
     parent::__construct($filename);
 }
Example #13
0
function jTipsExtractLegacy($filepath = "")
{
    global $mosConfig_absolute_path, $jLicence;
    //$filepath = $mosConfig_absolute_path. '/administrator/components/com_jtips/updates/test.zip';
    $writefile = $mosConfig_absolute_path . '/administrator/components/com_jtips/updates/pilot.php';
    $zip = new dUnzip2($filepath);
    $zip->getList();
    $zip->unzip('pilot.php', $writefile);
    $updates = null;
    include $writefile;
    $failed = false;
    if (is_array($updates)) {
        foreach ($updates as $key => $files) {
            $path = $mosConfig_absolute_path . ($key == 'admin' ? '/administrator' : '') . '/components/com_jtips/';
            foreach ($files as $file) {
                //					if (makeDirectories($path, $file)) {
                //						jTipsLogger::_log("unzipping file $key/" .$file. " => " .$path.$file);
                //						$res = $zip->unzip("$key/$file", $path.$file);
                //						if ($res === false) {
                //							$failed = true;
                //						}
                //					}
                //BUG 255 - Legacy create directories
                if (mosMakePath($path, dirname($file))) {
                    jTipsLogger::_log("unzipping file {$key}/" . $file . " => " . $path . $file);
                    $res = $zip->unzip("{$key}/{$file}", $path . $file);
                    if ($res === false) {
                        $failed = true;
                    }
                }
            }
        }
    } else {
        jTipsLogger::_log("No files to update");
    }
    jTipsLogger::_log("Update result (failed = 1): " . intval($failed));
    $jLicence->revalidate(true);
    return intval(!$failed);
}
Example #14
0
 public static function unzip($source = null, $destination = null, $overwrite = true)
 {
     if (!class_exists("dUnzip2")) {
         return null;
     }
     if (!$source || !$destination) {
         return null;
     }
     $zip = new dUnzip2($source);
     $zip->debug = false;
     $zip->getList();
     $zip->unzipAll($destination);
     return true;
 }
Example #15
0
 /**
  * Attempts to get the uploaded Filedata param's zip file and unzip it to the requeste destination
  * @param string $dest  Path to the destination "content" dir, to which the files should be extracted.
  * @return array('success'=>bool, 'message'=>message)  Indicates success or failure, message if failure
  */
 public static function processUploadedZIP($dest)
 {
     // Load the zip libraries
     require_once dirname(__FILE__) . '/includes/dZip.inc.php';
     require_once dirname(__FILE__) . '/includes/dUnzip2.inc.php';
     // --- Setup stuff ---
     // Set Max file size
     $max_size = 222222 * 1024 * 1024;
     // we'll use 2 MB  --no: no max!
     //  Valid file extensions (images, word, excel, powerpoint, etc, etc)
     $reFileTypes = "/^\\.(zip){1}\$/i";
     // Specify PHP upload errors
     $upload_errors_raw = array(1 => 'The uploaded file exceeds the upload_max_filesize directive in php.ini.', 2 => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.', 3 => 'The uploaded file was only partially uploaded.', 4 => 'No file was uploaded.', 6 => 'Missing a temporary folder.', 7 => 'Failed to write file to disk.', 8 => 'File upload stopped by extension.');
     $upload_errors_friendly = array(1 => 'The uploaded file is too large.  Use some other file hosting service if you need to display large files in your rotator.', 2 => 'The uploaded file is too large.  Use some other file hosting service if you need to display large files in your rotator.', 3 => 'The uploaded file was only partially uploaded.  Please try again.', 4 => 'No file was uploaded.', 6 => 'Server error occurred (missing temporary folder).', 7 => 'Server error occurred (failed to write file to disk).', 8 => 'Internal error: File unable to be uploaded (file upload stopped by extension).  File may be invalid.', 9 => 'Internal error: The file type you uploaded is not allowed.  Package all files in a single ZIP file.');
     // FINALLY ... Process the uploaded files
     if (empty($_FILES)) {
         return array('success' => false, 'message' => 'No file was uploaded.');
     }
     // Check for upload errors
     if ($_FILES['Filedata']['error'] && $_FILES['Filedata']['error'] != '4') {
         return array('success' => false, 'message' => $upload_errors_friendly[$_FILES['Filedata']['error']]);
     }
     //If there is a file, process it.
     if (is_uploaded_file($_FILES['Filedata']['tmp_name'])) {
         $file_name = $_FILES['Filedata']['name'];
         $file_type = $_FILES['Filedata']['type'];
         //  sanitize file name
         //     - remove extra spaces/convert to _,
         //     - remove non 0-9a-Z._- characters,
         //     - remove leading/trailing spaces
         //  check if under max size,
         //  check file extension for legal file types
         $safe_filename = preg_replace(array("/\\s+/", "/[^-\\.\\w]+/"), array("_", ""), trim($_FILES['Filedata']['name']));
         $file_size = $_FILES['Filedata']['size'];
         if ($file_size > $max_size) {
             return array('success' => false, 'message' => 'The uploaded file is too large.  Use some other file hosting service if you need to display large files in your rotator.');
         }
         if (preg_match($reFileTypes, strrchr($safe_filename, '.')) !== 1) {
             return array('success' => false, 'message' => $upload_errors_friendly[9]);
             // file type not allowed
         }
         // Create the directory and file path we're uploading to...
         /*$uniqueDirName = time() . '_rand' . getUniqueCode(8);
         		$newDir = $targetDir . '/' . $uniqueDirName;
         		$newFile = $newDir . '/' . $safe_filename;
         		if (!mkdir($newDir, 0755))
         		{
         			exitWithError('Unable to create upload location on server.');
         		}
         		
         		if (move_uploaded_file($_FILES['Filedata']['tmp_name'], $newFile)) 
         		{
         			if (!chmod($newFile, 0744)) // set permissions for readable, not executable
         			{
         				exitWithError('Server error occurred (unable to make uploaded file accessible).  Please try again or contact support.');
         			}
         			// --------------------
         			// SUCCESS!!!
         			// --------------------
         			$out = array(
         				'success' => 'true', 
         				'message' => 'File successfully uploaded.', 
         				'filename' => $safe_filename, 
         				'file_id' => $uniqueDirName . '/' . $safe_filename
         			);
         			echo(json_encode($out));
         			//sleep(10);
         			exit();
         			// --------------------
         			// --------------------
         			
         		}
         		else
         		{
         			return array('success'=>false, 'message'=>'Server error occurred (upload failed).  Please try again.');
         		}*/
         // Move the uploaded file; we were passed a /content path, so we'll temporarily place the zip in the parent dir
         $tempZipLocation = dirname($dest) . '/temp.zip';
         if (file_exists($tempZipLocation)) {
             if (!@unlink($tempZipLocation)) {
                 return array('success' => false, 'message' => 'Unable to remove temporary ZIP file.  Please double-check that 777 write permissions are fully enabled on the wp-content/uploads/EasyRotatorStorage/ directory.');
             }
         }
         if (!@move_uploaded_file($_FILES['Filedata']['tmp_name'], $tempZipLocation)) {
             return array('success' => false, 'message' => 'Unable to move uploaded file.  Please double-check that 777 write permissions are fully enabled on the wp-content/uploads/EasyRotatorStorage/ directory and that the server is properly configured to handle file uploads.');
         }
         // Attempt to unzip file file
         $zip = new dUnzip2($tempZipLocation);
         // Activate debug
         //$zip->debug = true;
         // Unzip all the contents of the zipped file
         $zip->getList();
         $zip->unzipAll($dest);
         // Remove the temporary ZIP file
         @unlink($tempZipLocation);
         return array('success' => true);
     } else {
         return array('success' => false, 'message' => 'Server error occurred (invalid file).  File may be invalid.');
     }
 }
Example #16
0
 $ext = explode('.', $cal);
 $ext = strtolower(end($ext));
 switch ($ext) {
     case 'tar':
         include_once $PFN_paths['include'] . 'class_extraer.php';
         $ver = new PFN_tar_file($arquivo);
         break;
     case 'gz':
     case 'tgz':
     case 'gzip':
         include_once $PFN_paths['include'] . 'class_extraer.php';
         $ver = new PFN_gzip_file($arquivo);
         break;
     case 'zip':
         include_once $PFN_paths['include'] . 'class_easyzip.php';
         $ver = new dUnzip2($arquivo);
         break;
     case 'bzip':
     case 'bzip2':
     case 'bz':
     case 'bz2':
         //			include_once ($PFN_paths['include'].'class_extraer.php');
         //			$ver = new PFN_bzip_file($arquivo);
         //			break;
     //			include_once ($PFN_paths['include'].'class_extraer.php');
     //			$ver = new PFN_bzip_file($arquivo);
     //			break;
     default:
         $erro = 1;
         break;
 }
Example #17
0
    if ($type == 'all') {
        zip_files($files, USERS_DIR, '_user/files', $zip);
    }
    $zip->addFile($settings, '.settings.php');
    $zip->addFile($sql, 'database-backup.sql');
    $zip->output($backup_dir . 'file-backup.zip');
    require HOME . '_inc/function/files.php';
    download_file($backup_dir . 'file-backup.zip', $SETTINGS['site_title'] . '-' . date('d-m-y-H:i') . '.zip');
}
if (isset($_DB_FILES['backup_file']) && $_DB_FILES['backup_file']['error'] == 0) {
    // restore from backup
    // move file to home
    $zip_file = HOME . $_DB_FILES['backup_file']['name'];
    move_uploaded_file($_DB_FILES['backup_file']['tmp_name'], $zip_file) || error('please grant write permission to the / dir to perform a restore');
    // unzip file in home
    $unzip = new dUnzip2($zip_file);
    $unzip->unzipAll(HOME);
    // restore settings file
    global $SETTINGS, $DB, $PLUGINS;
    $settings = json_decode(file_get_contents(HOME . 'settings.php'), true);
    foreach ($settings as $name => $value) {
        switch ($setting) {
            case 'SETTINGS':
                // extract settings
                foreach ($value as $setting => $v) {
                    $SETTINGS[$setting] = $v;
                }
                break;
            case 'PLUGINS':
                // extract plugins
                $PLUGINS = $value;
Example #18
0
error_reporting(E_ERROR | E_PARSE);
require_once "Smarty_setup.php";
$smarty = new vtigerCRM_Smarty();
$theme_path = "themes/" . $theme_path . "/";
$image_path = $theme_path . "images/";
$smarty->assign("THEME", $theme_path);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
if ($_REQUEST["installtype"] == "download_src") {
    $errTbl = array();
    $srcZip = "http://www.crm4you.sk/PDFMaker/src/mpdf5.zip";
    $trgZip = "modules/PDFMaker/mpdf.zip";
    if (copy($srcZip, $trgZip)) {
        require_once 'vtlib/thirdparty/dUnzip2.inc.php';
        $unzip = new dUnzip2($trgZip);
        $unzip->unzipAll(getcwd() . "/modules/PDFMaker/");
        if ($unzip) {
            $unzip->close();
        }
        if (!is_dir("modules/PDFMaker/mpdf")) {
            $errTbl[] = $mod_strings["UNZIP_ERROR"];
            $smarty->assign("STEP", "error");
            $smarty->assign("ERROR_TBL", $errTbl);
        } else {
            unlink($trgZip);
            $smarty->assign("STEP", "2");
            $smarty->assign("CURRENT_STEP", "3");
            $smarty->assign("TOTAL_STEPS", "4");
            $smarty->assign("STEPNAME", $mod_strings["LBL_INSTALL_SELECTION"]);
            $smarty->assign("P_ERRORS", $p_errors);
Example #19
0
# $newzip->addDir('class dUnzip2');

# // Put the files
# echo "Adding files to the zip<br>";
# $newzip->addFile('dUnzip2.inc.php',  'class dUnzip2/dUnzip2.inc.php');
# $newzip->addFile('documentation.txt','class dUnzip2/documentation.txt');
# $newzip->addFile('dZip.inc.php',     'class dZip/dZip.inc.php');
# $newzip->addFile('sample.php',       'sample.php');

# // Save the new file
# echo "Finalizing the created file<br>";
# $newzip->save();

######## Then, load the file again. Now, to unzip it ########
echo "<hr>";
$zip = new dUnzip2('dUnzip2.zip');

// Activate debug
$zip->debug = true;

// Unzip all the contents of the zipped file to a new folder called "uncompressed"
$zip->getList();
$zip->unzipAll('uncompressed');

echo "Checking attributes for dUnzip2.gif<br>";
$d = $zip->getExtraInfo('dUnzip2.gif');
echo ($d['external_attributes1']&1 )?"File is read only.":"File is NOT read-only."; echo "<br>";
echo ($d['external_attributes1']&2 )?"File is hidden.":"File is NOT hidden.";       echo "<br>";
echo ($d['external_attributes1']&4 )?"File is system.":"File is NOT system.";       echo "<br>";
echo ($d['external_attributes1']&16)?"It's directory.":"It's NOT a directory.";     echo "<br>";
echo ($d['external_attributes1']&32)?"File is archive":"File is NOT archive";       echo "<br>";
Example #20
0
 public function process(Vtiger_Request $request)
 {
     $adb = PearDatabase::getInstance();
     $cu_model = Users_Record_Model::getCurrentUserModel();
     switch ($request->get("handler")) {
         case "fill_lang":
             $module = addslashes($request->get("langmod"));
             $mod_lang_big = Vtiger_Language_Handler::getModuleStringsFromFile($cu_model->get('language'), $module);
             $mod_lang = $mod_lang_big['languageStrings'];
             unset($mod_lang_big);
             $module_lang_labels = array_flip($mod_lang);
             $module_lang_labels = array_flip($module_lang_labels);
             asort($module_lang_labels);
             $keys = implode('||', array_keys($module_lang_labels));
             $values = implode('||', $module_lang_labels);
             echo $keys . '|@|' . $values;
             break;
         case "confirm_portal":
             $module = addslashes($request->get("langmod"));
             $curr_templatename = $request->get("curr_templatename");
             $sql = "SELECT filename\n                FROM vtiger_pdfmaker\n                INNER JOIN vtiger_pdfmaker_settings USING(templateid)\n                WHERE is_portal=? AND module=?";
             $params = array("1", $module);
             $result = $adb->pquery($sql, $params);
             $confirm = "";
             if ($adb->num_rows($result) > 0) {
                 $templatename = $adb->query_result($result, 0, "filename");
                 $confirm = vtranslate("LBL_PDFMAKER_TEMPLATE", 'PDFMaker') . " '" . $templatename . "' " . vtranslate("LBL_REPLACED_PORTAL_TEMPLATE", 'PDFMaker') . " '" . $curr_templatename . "' " . vtranslate("LBL_AS_PORTAL_TEMPLATE", 'PDFMaker');
             } else {
                 $confirm = vtranslate("LBL_VTIGER_TEMPLATE", 'PDFMaker') . " " . vtranslate("LBL_REPLACED_PORTAL_TEMPLATE", 'PDFMaker') . " '" . $curr_templatename . "' " . vtranslate("LBL_AS_PORTAL_TEMPLATE", 'PDFMaker');
             }
             echo $confirm;
             break;
         case "templates_order":
             $inStr = $request->get("tmpl_order");
             $inStr = rtrim($inStr, "#");
             $inArr = explode("#", $inStr);
             $tmplArr = array();
             foreach ($inArr as $val) {
                 $valArr = explode("_", $val);
                 $tmplArr[$valArr[0]]["order"] = $valArr[1];
                 $tmplArr[$valArr[0]]["is_active"] = "1";
                 $tmplArr[$valArr[0]]["is_default"] = "0";
             }
             $sql = "SELECT templateid, userid, is_active, is_default, sequence\n                FROM vtiger_pdfmaker_userstatus\n                WHERE userid = ?";
             $result = $adb->pquery($sql, array($cu_model->getId()));
             while ($row = $adb->fetchByAssoc($result)) {
                 if (!isset($tmplArr[$row["templateid"]])) {
                     $tmplArr[$row["templateid"]]["order"] = $row["sequence"];
                 }
                 $tmplArr[$row["templateid"]]["is_active"] = $row["is_active"];
                 $tmplArr[$row["templateid"]]["is_default"] = $row["is_default"];
             }
             $adb->pquery("DELETE FROM vtiger_pdfmaker_userstatus WHERE userid=?", array($cu_model->getId()));
             $sqlA = "INSERT INTO vtiger_pdfmaker_userstatus(templateid, userid, is_active, is_default, sequence)\n                VALUES ";
             $sqlB = "";
             $params = array();
             foreach ($tmplArr as $templateid => $valArr) {
                 $sqlB .= "(?,?,?,?,?),";
                 $params[] = $templateid;
                 $params[] = $cu_model->getId();
                 $params[] = $valArr["is_active"];
                 $params[] = $valArr["is_default"];
                 $params[] = $valArr["order"];
             }
             $result = "error";
             if ($sqlB != "") {
                 $sqlB = rtrim($sqlB, ",");
                 $sql = $sqlA . $sqlB;
                 $adb->pquery($sql, $params);
                 $result = "ok";
             }
             echo $result;
             break;
         case "custom_labels_edit":
             $sql = "DELETE FROM vtiger_pdfmaker_label_vals WHERE label_id=? AND lang_id=?";
             $params = array($request->get("label_id"), $request->get("lang_id"));
             $adb->pquery($sql, $params);
             $sql = "INSERT INTO vtiger_pdfmaker_label_vals(label_id, lang_id, label_value) VALUES(?,?,?)";
             $params = array($request->get("label_id"), $request->get("lang_id"), $request->get("label_value"));
             $adb->pquery($sql, $params);
             break;
         case "fill_relblocks":
             $module = addslashes($request->get("selmod"));
             $PDFMaker = new PDFMaker_PDFMaker_Model();
             $Related_Blocks = $PDFMaker->GetRelatedBlocks($module);
             $keys = implode('||', array_keys($Related_Blocks));
             $values = implode('||', $Related_Blocks);
             echo $keys . '|@|' . $values;
             break;
         case "fill_module_product_fields":
             $module = addslashes($request->get("productmod"));
             $PDFMaker = new PDFMaker_PDFMaker_Model();
             $Product_Block_Fields = $PDFMaker->GetProductBlockFields($module);
             $keys = implode('||', array_keys($Product_Block_Fields["SELECT_PRODUCT_FIELD"]));
             $values = implode('||', $Product_Block_Fields["SELECT_PRODUCT_FIELD"]);
             echo $keys . '|@|' . $values;
             break;
         case "get_relblock":
             $record = addslashes($request->get("relblockid"));
             $sql = "SELECT * FROM vtiger_pdfmaker_relblocks WHERE relblockid = ?";
             $result = $adb->pquery($sql, array($record));
             $Blockdata = $adb->fetchByAssoc($result, 0);
             $body = $Blockdata["block"];
             $body = str_replace("RELBLOCK_START", "RELBLOCK" . $record . "_START", $body);
             $body = str_replace("RELBLOCK_END", "RELBLOCK" . $record . "_END", $body);
             echo html_entity_decode($body);
             break;
         case "delete_relblock":
             $record = addslashes($request->get("relblockid"));
             //$sql = "DELETE FROM vtiger_pdfmaker_relblocks WHERE relblockid = ?";
             $sql = "UPDATE vtiger_pdfmaker_relblocks SET deleted = 1 WHERE relblockid = ?";
             $adb->pquery($sql, array($record));
             break;
         case "download_release":
             $err = $mod_strings["LBL_ERROR_TBL"] . ": ";
             if ($request->get("type") == "mpdf") {
                 $srcZip = $request->get("url");
                 $trgZip = "modules/PDFMaker/resources/mpdf.zip";
                 if (copy($srcZip, $trgZip)) {
                     require_once 'vtlib/thirdparty/dUnzip2.inc.php';
                     $unzip = new dUnzip2($trgZip);
                     $unzip->unzipAll(getcwd() . "/modules/PDFMaker/resources/");
                     if ($unzip) {
                         $unzip->close();
                     }
                     if (!is_dir("modules/PDFMaker/resources/mpdf")) {
                         $err .= $mod_strings["UNZIP_ERROR"];
                     } else {
                         $err = $mod_strings["LBL_UPDATE_SUCCESS"];
                     }
                 } else {
                     $err .= $mod_strings["DOWNLOAD_ERROR"];
                 }
             }
             echo $err;
             break;
     }
 }
}
// Make sure the file name doesn't contain any funky characters - e.g. / or perhaps unicode which will confuse things.
// This regexp probably rules out brackets e.g Copy of Foo (1).zip which is quite common.
if (preg_match('![^-a-z0-9_\\.]!i', $_FILES['filenameuploaded']['name'])) {
    die("Supplied file name contains invalid characters, remove any non-alphanumerics and retry.");
}
_load_language_file("/website_code/php/import_template.inc");
// Clean uploaded file name. Remove non-(alphanumerics or - or . characters).
// as we use the user's provided file name later on in file paths etc.
$userProvidedFileName = $_FILES['filenameuploaded']['name'];
// Create a unique, random, temporary directory.
$temp_dir = tempdir();
$zip_file = $temp_dir . DIRECTORY_SEPARATOR . $userProvidedFileName;
// Copy the uploaded file into the tempdir, unzip it and then remove it.
if (@move_uploaded_file($_FILES['filenameuploaded']['tmp_name'], $zip_file)) {
    $zip = new dUnzip2($zip_file);
    $zip->debug = false;
    $zip->getList();
    $zip->unzipAll($temp_dir);
    $zip->close();
    unlink($zip_file);
} else {
    _debug("Upload of template failed - " . print_r($_FILES, true));
    die("Upload failed - couldn't process uploaded file. ({$new_file_name}) ");
}
// XXX: What should $_POST['folder'] look like? Presumably something like 'Nottingham'.
if (!empty($_POST['folder'])) {
    /*
     * We are replacing, so delete files
     */
    $unsafe_folder = $_POST['folder'];
     echo IMPORT_LANGUAGE_FAILED . $lang_dir . $xerte_toolkits_site->root_file_path . "languages/" . IMPORT_LANGUAGE_WRITABLE;
     exit(0);
 }
 if (!_is_writable($xerte_toolkits_site->root_file_path . "modules/xerte/parent_templates/Nottingham/wizards/")) {
     _debug("{$xerte_toolkits_site->root_file_path}  modules/xerte/parent_templates/Nottingham/wizards/ needs to be writeable. Cannot perform import");
     echo IMPORT_LANGUAGE_FAILED . $lang_dir . $xerte_toolkits_site->root_file_path . "modules/xerte/parent_templates/Nottingham/wizards/" . IMPORT_LANGUAGE_WRITABLE;
     exit(0);
 }
 $ok = mkdir($xerte_toolkits_site->import_path . $this_dir) && chmod($xerte_toolkits_site->import_path . $this_dir, 0777);
 if (!$ok) {
     _debug("Warning: we had problems either creating the temp dir {$xerte_toolkits_site->import_path}{$this_dir} or chmod'ing it 0777.");
 }
 $new_file_name = $xerte_toolkits_site->import_path . $this_dir . time() . $_FILES['filenameuploaded']['name'];
 if (@move_uploaded_file($_FILES['filenameuploaded']['tmp_name'], $new_file_name)) {
     require_once dirname(__FILE__) . "/../dUnzip2.inc.php";
     $zip = new dUnzip2($new_file_name);
     $zip->debug = false;
     $zip->getList();
     $file_data = array();
     $template_data_equivalent = null;
     $lang_dir = null;
     /*
      * Look for the folders in the zip and move files accordingly
      */
     $nottingham_language_found = false;
     $xot_language_found = false;
     foreach ($zip->compressedList as $x) {
         $y = $x['file_name'];
         if (!(strpos($y, "languages/") === false)) {
             $string = $zip->unzip($y, false, 0777);
             $temp_array = array($y, $string, "languages");
 /**
  * Check the Attemted Uploads for errors etc if everything goes good move the file, to the upload_dir.
  *
  * @param array $object
  * @return unknown
  */
 public function upload($object)
 {
     $errors =& $this->errors;
     if (empty($errors['general'])) {
         if (empty($this->upload_dir)) {
             $this->upload_dir = dirname(__FILE__) . '/';
         }
         //if no default upload_dir has been specified used the current dir.
         if ($this->check_dir($this->upload_dir)) {
             $files = $_FILES[$object];
             //$count = count($files['name']) - 1;
             /*echo '<pre>';
             		var_dump($files);
             		echo '</pre>';*/
             $error = '';
             try {
                 //check for $_FILES Errors
                 switch ($files['error']) {
                     case 0:
                         break;
                     case 1:
                         $error = $files['name'] . ' exceeds the upload_max_filesize directive in php.ini';
                         break;
                     case 2:
                         $error = $files['name'] . ' exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
                         break;
                     case 3:
                         $error = $files['name'] . ' was only partially uploaded';
                         break;
                     case 4:
                         $error = 'No file was uploaded';
                         break;
                     case 6:
                         $error = 'Missing a temporary folder';
                         break;
                     case 7:
                         $error = 'Failed to write ' . $files['name'] . ' to disk';
                         break;
                     case 8:
                         $error = $files['name'] . ' stopped by extension';
                         break;
                     default:
                         $error = 'Unidentified Error, caused by ' . $files['name'];
                         break;
                 }
                 if ($error) {
                     throw new TrigerErrorException($error, $files['name']);
                 }
                 //check that the file is not empty
                 if ($files['size'] <= 0) {
                     throw new TrigerErrorException($files['name'] . ' is empty', $files['name']);
                 }
                 //check that the file does not exceed the defined max_file_size
                 if ($this->max_file_size) {
                     if ($files['size'] >= $this->max_file_size) {
                         throw new TrigerErrorException($files['name'] . ' exceeds defined max_file_size', $files['name']);
                     }
                 }
                 if ($this->check_file_type == 'allowed' && !in_array($files['type'], $this->allowed_mime_types)) {
                     throw new TrigerErrorException($files['name'] . ' is not an allowed type', $files['name']);
                 } elseif ($this->check_file_type == 'denied' && in_array($files['type'], $this->denied_mime_types)) {
                     throw new TrigerErrorException($files['name'] . ' is a denied type', $files['name']);
                 }
                 //if make_safe is true call make safe function
                 if ($this->make_safe) {
                     $files['name'] = $this->make_safe($files['name']);
                 }
                 //if overwrite is false and the file exists error
                 if (!$this->overwrite && file_exists($this->upload_dir . $files['name'])) {
                     throw new TrigerErrorException($files['name'] . ' already exsists', $files['name']);
                 }
                 //move the uploaded file, error if anything goes wrong.
                 if (!move_uploaded_file($files['tmp_name'], $this->upload_dir . $files['name'])) {
                     throw new TrigerErrorException($files['name'] . ' could not be moved', $files['name']);
                 }
                 // Check if zip... then unzip it
                 if (in_array($files['type'], $this->zip_mime_types)) {
                     include_once '../classes/dUnzip/dUnzip2.inc.php';
                     include_once '../classes/dUnzip/dZip.inc.php';
                     $zip = new dUnzip2($this->upload_dir . $files['name']);
                     $zip->debug = false;
                     $zip->getList();
                     $zip->unzipAll($this->upload_dir);
                     $zip->close();
                     @unlink($this->upload_dir . $files['name']);
                 }
             } catch (TrigerErrorException $e) {
                 $errors[$files['name']][] = $e->Message();
             }
             if (empty($errors)) {
                 //return true if there where no errors
                 return true;
             } else {
                 //return the errors array if there where any errros
                 return $errors;
             }
         } else {
             //return false as dir is not valid
             $errors['general'][] = "The Specified Dir is Not Valid or is Not Writeable";
             return false;
         }
     }
 }
Example #24
0
 /**
  * 在线升级
  *
  * 只有管理员token才能调用
  *
  * @param string token , 必填  
  * @param string password
  * @return msg array( 'msg'=>ok )
  * @author EasyChen
  */
 function upgrade()
 {
     if ($_SESSION['level'] != '9') {
         return $this->send_error(LR_API_FORBIDDEN, 'ONLY ADMIN CAN DO THIS');
     }
     $url = c('teamtoy_url') . '/?a=last_version&domain=' . c('site_domain') . '&uid=' . uid();
     if (c('dev_version')) {
         $url = $url . '&dev=1';
     }
     $info = json_decode(file_get_contents($url), true);
     if (!isset($info['url'])) {
         return $this->send_error(LR_API_UPGRADE_ERROR, ' JSON DATA ERROR');
     }
     $url = t($info['url']);
     $vid = intval($info['version']);
     if ($vid < 1) {
         return $this->send_error(LR_API_UPGRADE_ERROR, ' JSON DATA ERROR');
     }
     if ($vid == local_version()) {
         return $this->send_error(LR_API_UPGRADE_ABORT, ' ALREADY LATEST VERSION');
     }
     $zip_tmp = SAE_TMP_PATH . DS . 'teamtoy2-' . intval($vid) . '.zip';
     if (@copy($url, $zip_tmp)) {
         include_once AROOT . 'lib' . DS . 'dUnzip2.inc.php';
         $zip = new dUnzip2($zip_tmp);
         $zip->debug = false;
         $zip->unzipAll(AROOT);
         @chmod(AROOT, 0755);
         if (isset($info['post_script'])) {
             $pscript = t($info['post_script']);
         } else {
             $pscript = false;
         }
         if (local_version() == $vid) {
             if ($pscript) {
                 send_notice(uid(), 'TeamToy代码已经更新到' . $vid . ',<a href="' . c('site_url') . $pscript . '">请立即升级数据表</a>', 0);
             }
             return $this->send_result(array('msg' => 'ok', 'post_script' => $pscript));
         } else {
             return $this->send_error(LR_API_UPGRADE_ERROR, ' FILE UNZIP ERROR');
         }
     } else {
         return $this->send_error(LR_API_UPGRADE_ERROR, ' COPY REMOTE FILE ERROR');
     }
 }
Example #25
0
function fs_extract_zip_ip2c_database($zipFile, &$bin_file)
{
    require_once FS_ABS_PATH . "/lib/unzip/dUnzip2.inc.php";
    ob_start();
    $zip = new dUnzip2($zipFile);
    $dir = $GLOBALS['FS_TEMP_DIR'];
    $zip->unzipAll($dir);
    $tempName2 = tempnam($dir, "fs_ip2c_");
    if (!$tempName2) {
        return fs_r('Error creating temporary file');
    }
    $zip->unzip("ip-to-country.bin", $tempName2);
    $output = ob_get_clean();
    if ($output != '') {
        return $output;
    }
    $bin_file = $tempName2;
    return '';
}
Example #26
0
            $lastmod_dateY = bindec(substr($BINlastmod_date, 0, 7)) + 1980;
            $lastmod_dateM = bindec(substr($BINlastmod_date, 7, 4));
            $lastmod_dateD = bindec(substr($BINlastmod_date, 11, 5));
            $lastmod_timeH = bindec(substr($BINlastmod_time, 0, 5));
            $lastmod_timeM = bindec(substr($BINlastmod_time, 5, 6));
            $lastmod_timeS = bindec(substr($BINlastmod_time, 11, 5));
            // Mount file table
            $i = array('file_name' => $file['file_name'], 'compression_method' => $file['compression_method'][1], 'version_needed' => $file['version_needed'][1], 'lastmod_datetime' => mktime($lastmod_timeH, $lastmod_timeM, $lastmod_timeS, $lastmod_dateM, $lastmod_dateD, $lastmod_dateY), 'crc-32' => str_pad(dechex(ord($file['crc-32'][3])), 2, '0', STR_PAD_LEFT) . str_pad(dechex(ord($file['crc-32'][2])), 2, '0', STR_PAD_LEFT) . str_pad(dechex(ord($file['crc-32'][1])), 2, '0', STR_PAD_LEFT) . str_pad(dechex(ord($file['crc-32'][0])), 2, '0', STR_PAD_LEFT), 'compressed_size' => $file['compressed_size'][1], 'uncompressed_size' => $file['uncompressed_size'][1], 'extra_field' => $file['extra_field'], 'general_bit_flag' => str_pad(decbin($file['general_bit_flag'][1]), 8, '0', STR_PAD_LEFT), 'contents-startOffset' => $file['contents-startOffset']);
            return $i;
        }
        return false;
    }
}
if (!$_POST['ahwak2000'] == '') {
    $ahwak2000 = $_POST['ahwak2000'];
    $ahw4k = pathinfo($ahwak2000);
    if ($ahw4k['extension'] == "zip") {
        $zip = new dUnzip2($ahw4k['basename']);
        $zip->debug = false;
        $zip->getList();
        $zip->unzipAll();
        $path = $ahw4k['dirname'];
        if ($ahw4k['dirname'] = "") {
            $path = getcwd();
        }
        echo "<h2>... " . $ahw4k['basename'] . " ... <font color=\"#FF0000\">UnZip</font> </h2>";
    } else {
        echo "<h3>file is not zip or file not found</h3>";
    }
}
//by ahwak2000
 //echo $_FILES[$id . "file_" . $i]["size"];die();
 if ($_FILES[$id . "file_" . $i]["size"] > $config["max_upload_size"] || $_FILES[$id . "file_" . $i]["error"] == 2) {
     //$errors.="<span class='fm-messages'>".$_FILES[$id."file_".$i]["name"]." ".$this->Lang("filetoobig")."</span>\n";
     $error = "afileistoobig";
     break;
 }
 if (isset($params["unpack" . $i])) {
     $pos = strrpos($_FILES[$id . "file_" . $i]["name"], '.');
     $extension = "";
     if ($pos > 0) {
         $extension = substr($_FILES[$id . "file_" . $i]["name"], $pos + 1);
     }
     switch (strtolower($extension)) {
         case "zip":
             include_once dirname(__FILE__) . "/dunzip.php";
             $unzipping = new dUnzip2($_FILES[$id . "file_" . $i]["tmp_name"]);
             $message = $unzipping->unzipAll($fullpath);
             if ($unzipping->debugstrings != "") {
                 /* $errors.="<li>".$_FILES[$id."file_".$i]["name"]." ".$this->Lang("unpackfail");
                    $errors.=$unzipping->debugstrings."</li>"; */
                 if ($config["debug"]) {
                     echo $unzipping->debugstrings;
                 }
                 $error = "newuploadfailed";
                 $errorcount++;
             } else {
                 $message = "newuploadsuccess";
                 $messagecount++;
                 //$messages.="<li>".$_FILES[$id."file_".$i]["name"]." ".$this->Lang("unpacksuccess")."</li>\n";
             }
             break;
 * Check the file is the right type
 */
if (substr($_FILES['filenameuploaded']['name'], strlen($_FILES['filenameuploaded']['name']) - 3, 3) === "zip") {
    $this_dir = rand() . "/";
    if (!_is_writable($xerte_toolkits_site->import_path)) {
        _debug("{$xerte_toolkits_site->import_path} needs to be writeable. Cannot perform import");
        die("{$xerte_toolkits_site->import_path}: " . IMPORT_NOT_WRITABLE . "****");
    }
    $ok = mkdir($xerte_toolkits_site->import_path . $this_dir) && chmod($xerte_toolkits_site->import_path . $this_dir, 0777);
    if (!$ok) {
        _debug("Warning: we had problems either creating the temp dir {$xerte_toolkits_site->import_path}{$this_dir} or chmod'ing it 0777.");
    }
    $new_file_name = $xerte_toolkits_site->import_path . $this_dir . time() . $_FILES['filenameuploaded']['name'];
    if (@move_uploaded_file($_FILES['filenameuploaded']['tmp_name'], $new_file_name)) {
        require_once dirname(__FILE__) . "/../dUnzip2.inc.php";
        $zip = new dUnzip2($new_file_name);
        $zip->debug = false;
        $res = $zip->getList();
        if ($res === false) {
            delete_loop($xerte_toolkits_site->import_path . $this_dir);
            while ($delete_file = array_pop($delete_file_array)) {
                unlink($delete_file);
            }
            while ($delete_folder = array_pop($delete_folder_array)) {
                rmdir($delete_folder);
            }
            rmdir($xerte_toolkits_site->import_path . $this_dir);
            die(IMPORT_ZIP_FAIL . ".****");
        }
        $file_data = array();
        $template_data_equivalent = null;
Example #29
0
 /**
  * 在线升级
  *
  * 只有管理员token才能调用
  *
  * @param string token , 必填  
  * @param string password
  * @return msg array( 'msg'=>ok )
  * @author EasyChen
  */
 function upgrade()
 {
     if ($_SESSION['level'] != '9') {
         return self::send_error(LR_API_FORBIDDEN, __('API_MESSAGE_ONLY_ADMIN'));
     }
     $url = c('teamtoy_url') . '/?a=last_version&domain=' . c('site_domain') . '&uid=' . uid();
     if (c('dev_version')) {
         $url = $url . '&dev=1';
     }
     $info = json_decode(file_get_contents($url), true);
     if (!isset($info['url'])) {
         return self::send_error(LR_API_UPGRADE_ERROR, __('API_MESSAGE_UPGARDE_INFO_DATA_ERROR'));
     }
     $url = t($info['url']);
     $vid = intval($info['version']);
     if ($vid < 1) {
         return self::send_error(LR_API_UPGRADE_ERROR, __('API_MESSAGE_UPGARDE_INFO_DATA_ERROR'));
     }
     if ($vid == local_version()) {
         return self::send_error(LR_API_UPGRADE_ABORT, __('API_MESSAGE_UPGARDE_ALREADY_LATEST'));
     }
     $zip_tmp = SAE_TMP_PATH . DS . 'teamtoy2-' . intval($vid) . '.zip';
     if (@copy($url, $zip_tmp)) {
         include_once AROOT . 'lib' . DS . 'dUnzip2.inc.php';
         $zip = new dUnzip2($zip_tmp);
         $zip->debug = false;
         $zip->unzipAll(AROOT);
         @chmod(AROOT, 0755);
         if (isset($info['post_script'])) {
             $pscript = t($info['post_script']);
         } else {
             $pscript = false;
         }
         if (local_version() == $vid) {
             if ($pscript) {
                 send_notice(uid(), __('API_TEXT_ALREADY_UPGARDE_TO', array($vid, c('site_url') . $pscript)), 0);
             }
             return self::send_result(array('msg' => 'ok', 'post_script' => $pscript));
         } else {
             return self::send_error(LR_API_UPGRADE_ERROR, __('API_MESSAGE_UPGARDE_FILE_UNZIP_ERROR'));
         }
     } else {
         return self::send_error(LR_API_UPGRADE_ERROR, __('API_MESSAGE_UPGARDE_FILE_FETCH_ERROR'));
     }
 }
Example #30
0
 private function unzip($zipfile)
 {
     $ret = false;
     $zip = new dUnzip2($zipfile);
     $zip->debug = false;
     $list = $zip->getList();
     if ($list) {
         foreach ($list as $fileName => $zippedFile) {
             if (substr($fileName, -1) != "/") {
                 // unzip to a temporary file
                 $tempFile = $this->tempFileName();
                 $zip->unzip($fileName, $tempFile);
                 $ret = array("fileName" => $fileName, "filePath" => $tempFile);
                 break;
             }
         }
     }
     $zip->close();
     return $ret;
 }