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; }
} 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; /* * Look for the folders in the zip and move files accordingly */ foreach ($zip->compressedList as $x) { foreach ($x as $y) { if (!(strpos($y, "media/") === false)) { $string = $zip->unzip($y, false, 0777); $temp_array = array($y, $string, "media"); array_push($file_data, $temp_array); } if (strpos($y, ".rlt") !== false) { $string = $zip->unzip($y, false, 0777); $rlt_name = $y; $temp_array = array($y, $string, "rlt"); array_push($file_data, $temp_array); if (!(strpos($string, "templateData=") === false)) { $temp = substr($string, strpos($string, "templateData=\"FileLocation + '") + strlen("templateData=\"FileLocation + '")); $temp = substr($temp, 0, strpos($temp, "'")); $template_data_equivalent = $temp; } } }
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"); array_push($file_data, $temp_array); if ($lang_dir == null) { $lang_dir = substr($y, 10, 5); } $xot_language_found = true; } if (strpos($y, "wizards/") !== false) { $string = $zip->unzip($y, false, 0777); $temp_array = array($y, $string, "wizards"); array_push($file_data, $temp_array); if ($lang_dir == null) { $lang_dir = substr($y, 8, 5); } $nottingham_language_found = true;
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 ''; }
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); }
/** * stats_update_geoip * * this function executes every month in order to update * the geo ip database. it executes in parts as to not * exceed the PHP memory limit - the db is very big, * around 8MB * * @return bool */ function stats_update_geoip() { /** * part 1, download zip */ $zip = USERS_DIR . 'stats/IpToCountry.zip'; if (!file_exists($zip)) { $contents = file_get_contents('http://software77.net/geo-ip/?DL=2'); file_put_contents($zip, $contents); return false; } /** * part 2, unzip */ $file = USERS_DIR . 'stats/IpToCountry.csv'; if (!file_exists($file)) { $unzip = new dUnzip2($zip); $unzip->unzip('IpToCountry.csv', $file); return false; } /** * part3, parse file and put output in temp file */ $newfile = USERS_DIR . 'stats/IpToCountry.tmp'; if (!file_exists($newfile)) { $handle = @fopen($file, 'r'); $new = @fopen($newfile, 'w'); if (!$handle || !$new) { return false; } while (($buffer = fgets($handle, 4096)) !== false) { if ($buffer[0] == '#') { continue; } $arr = explode(',', $buffer); $arr = implode("\t", array(trim($arr[0], "\""), trim($arr[1], "\""), trim($arr[4], "\""), str_replace('"', '', $arr[6]))); fputs($new, $arr); } fclose($handle); return false; } /** * part4, split temp file into 9 different files * with each file containing ips starting with * the appropriate number */ $dir = USERS_DIR . 'stats/'; /** * files to be created */ $files = array('0' => array('00', '01', '02', '03', '04', '05', '06', '07', '08', '09'), '1' => array('10', '11', '12', '13', '14', '15', '16', '17', '18', '19'), '2' => array('20', '21', '22', '23', '24', '25', '26', '27', '28', '29'), '3' => array('30', '31', '32', '33', '34', '35', '36', '37', '38', '39'), '4' => array('40', '41', '42', '43', '44', '45', '46', '47', '48', '49'), '5' => array('50', '51', '52', '53', '54', '55', '56', '57', '58', '59'), '6' => array('60', '61', '62', '63', '64', '65', '66', '67', '68', '69'), '7' => array('70', '71', '72', '73', '74', '75', '76', '77', '78', '79'), '8' => array('80', '81', '82', '83', '84', '85', '86', '87', '88', '89'), '9' => array('90', '91', '92', '93', '94', '95', '96', '97', '98', '99')); error_log('test1'); // open temp file for processing $new = @fopen($newfile, 'r'); if (!$new) { return false; } error_log('test2'); while (($buffer = fgets($new, 4096)) !== false) { $line = explode("\t", $buffer); $lines = stats_split_ips($line, 0); file_put_contents(HOME . 'testtest', print_r($lines, true)); return false; } fclose($new); // close fps foreach ($fp as $p) { fclose($p); } return false; /** * part4, split second quarter of file */ /** * part5, split third quarter of file */ /** * part6, split fourth quarter of file */ // @todo cleanup! /** * finished! return true to mark as done */ return true; }