本文整理汇总了PHP中PMA_getZipContents函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_getZipContents函数的具体用法?PHP PMA_getZipContents怎么用?PHP PMA_getZipContents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_getZipContents函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
* @return void
*/
protected function setUp()
{
//setting
$GLOBALS['plugin_param'] = 'table';
$GLOBALS['finished'] = false;
$GLOBALS['read_limit'] = 100000000;
$GLOBALS['offset'] = 0;
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$GLOBALS['cfg']['ServerDefault'] = 0;
$GLOBALS['cfg']['AllowUserDropDatabase'] = false;
$GLOBALS['import_file'] = 'test/test_data/timezone.shp.zip';
//Mock DBI
$dbi = $this->getMockBuilder('PMA_DatabaseInterface')->disableOriginalConstructor()->getMock();
$GLOBALS['dbi'] = $dbi;
include_once 'libraries/plugins/import/ImportShp.class.php';
$this->object = new ImportShp();
/**
* Load interface for zip extension.
*/
include_once 'libraries/zip_extension.lib.php';
$result = PMA_getZipContents($GLOBALS['import_file']);
$GLOBALS['import_text'] = $result["data"];
$GLOBALS['compression'] = 'application/zip';
$GLOBALS['read_multiply'] = 10;
$GLOBALS['import_type'] = 'ods';
$GLOBALS['import_handle'] = @fopen($GLOBALS['import_file'], 'r');
}
示例2: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
* @return void
*/
protected function setUp()
{
$GLOBALS['plugin_param'] = "csv";
$this->object = new ImportOds();
//setting
$GLOBALS['finished'] = false;
$GLOBALS['read_limit'] = 100000000;
$GLOBALS['offset'] = 0;
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$GLOBALS['import_file'] = 'test/test_data/db_test.ods';
/**
* Load interface for zip extension.
*/
include_once 'libraries/zip_extension.lib.php';
$result = PMA_getZipContents($GLOBALS['import_file']);
$GLOBALS['import_text'] = $result["data"];
$GLOBALS['compression'] = 'application/zip';
$GLOBALS['read_multiply'] = 10;
$GLOBALS['import_type'] = 'ods';
$GLOBALS['import_handle'] = @fopen($GLOBALS['import_file'], 'r');
//variable for Ods
$_REQUEST['ods_recognize_percentages'] = true;
$_REQUEST['ods_recognize_currency'] = true;
$_REQUEST['ods_empty_rows'] = true;
}
示例3: testGetZipContents
/**
* Test zip file content
*
* @param string $file zip file
* @param string $specific_entry regular expression to match a file
* @param mixed $output expected output
*
* @dataProvider providerForTestGetZipContents
* @return void
*/
public function testGetZipContents($file, $specific_entry, $output)
{
$this->assertEquals(
PMA_getZipContents($file, $specific_entry),
$output
);
}
示例4: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
* @return void
*/
protected function setUp()
{
// Drizzle does not support GIS data types
if (!defined("PMA_DRIZZLE")) {
define("PMA_DRIZZLE", false);
} else {
if (PMA_DRIZZLE) {
//PMA_DRIZZLE is defined and PMA_DRIZZLE = true
if (PMA_HAS_RUNKIT) {
runkit_constant_redefine("PMA_DRIZZLE", false);
} else {
//Drizzle does not support GIS data types
$this->markTestSkipped("Drizzle does not support GIS data types");
}
}
}
//setting
$GLOBALS['plugin_param'] = 'table';
$GLOBALS['finished'] = false;
$GLOBALS['read_limit'] = 100000000;
$GLOBALS['offset'] = 0;
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$GLOBALS['cfg']['ServerDefault'] = 0;
$GLOBALS['cfg']['AllowUserDropDatabase'] = false;
$GLOBALS['import_file'] = 'test/test_data/timezone.shp.zip';
//Mock DBI
$dbi = $this->getMockBuilder('PMA_DatabaseInterface')->disableOriginalConstructor()->getMock();
$GLOBALS['dbi'] = $dbi;
include_once 'libraries/plugins/import/ImportShp.class.php';
$this->object = new ImportShp();
/**
* Load interface for zip extension.
*/
include_once 'libraries/zip_extension.lib.php';
$result = PMA_getZipContents($GLOBALS['import_file']);
$GLOBALS['import_text'] = $result["data"];
$GLOBALS['compression'] = 'application/zip';
$GLOBALS['read_multiply'] = 10;
$GLOBALS['import_type'] = 'ods';
$GLOBALS['import_handle'] = @fopen($GLOBALS['import_file'], 'r');
}
示例5: compression
case 'application/gzip':
if ($cfg['GZipDump'] && @function_exists('gzopen')) {
$import_handle = @gzopen($import_file, 'r');
} else {
$message = PMA_Message::error(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'));
$message->addParam($compression);
$error = TRUE;
}
break;
case 'application/zip':
if ($cfg['ZipDump'] && @function_exists('zip_open')) {
/**
* Load interface for zip extension.
*/
include_once './libraries/zip_extension.lib.php';
$result = PMA_getZipContents($import_file);
if (!empty($result['error'])) {
$message = PMA_Message::rawError($result['error']);
$error = TRUE;
} else {
$import_text = $result['data'];
}
} else {
$message = PMA_Message::error(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'));
$message->addParam($compression);
$error = TRUE;
}
break;
case 'none':
$import_handle = @fopen($import_file, 'r');
break;
示例6: doImport
/**
* Handles the whole import logic
*
* @return void
*/
public function doImport()
{
global $db, $error, $finished, $compression, $import_file, $local_import_file, $message;
$GLOBALS['finished'] = false;
$shp = new ShapeFile(1);
// If the zip archive has more than one file,
// get the correct content to the buffer from .shp file.
if ($compression == 'application/zip' && PMA_getNoOfFilesInZip($import_file) > 1) {
$zip_content = PMA_getZipContents($import_file, '/^.*\\.shp$/i');
$GLOBALS['import_text'] = $zip_content['data'];
}
$temp_dbf_file = false;
// We need dbase extension to handle .dbf file
if (extension_loaded('dbase')) {
// If we can extract the zip archive to 'TempDir'
// and use the files in it for import
if ($compression == 'application/zip' && !empty($GLOBALS['cfg']['TempDir']) && is_writable($GLOBALS['cfg']['TempDir'])) {
$dbf_file_name = PMA_findFileFromZipArchive('/^.*\\.dbf$/i', $import_file);
// If the corresponding .dbf file is in the zip archive
if ($dbf_file_name) {
// Extract the .dbf file and point to it.
$extracted = PMA_zipExtract($import_file, realpath($GLOBALS['cfg']['TempDir']), array($dbf_file_name));
if ($extracted) {
$dbf_file_path = realpath($GLOBALS['cfg']['TempDir']) . (PMA_IS_WINDOWS ? '\\' : '/') . $dbf_file_name;
$temp_dbf_file = true;
// Replace the .dbf with .*, as required
// by the bsShapeFiles library.
$file_name = mb_substr($dbf_file_path, 0, mb_strlen($dbf_file_path) - 4) . '.*';
$shp->FileName = $file_name;
}
}
} elseif (!empty($local_import_file) && !empty($GLOBALS['cfg']['UploadDir']) && $compression == 'none') {
// If file is in UploadDir, use .dbf file in the same UploadDir
// to load extra data.
// Replace the .shp with .*,
// so the bsShapeFiles library correctly locates .dbf file.
$file_name = mb_substr($import_file, 0, mb_strlen($import_file) - 4) . '.*';
$shp->FileName = $file_name;
}
}
// Load data
$shp->loadFromFile('');
if ($shp->lastError != "") {
$error = true;
$message = PMA\libraries\Message::error(__('There was an error importing the ESRI shape file: "%s".'));
$message->addParam($shp->lastError);
return;
}
// Delete the .dbf file extracted to 'TempDir'
if ($temp_dbf_file && isset($dbf_file_path) && file_exists($dbf_file_path)) {
unlink($dbf_file_path);
}
$esri_types = array(0 => 'Null Shape', 1 => 'Point', 3 => 'PolyLine', 5 => 'Polygon', 8 => 'MultiPoint', 11 => 'PointZ', 13 => 'PolyLineZ', 15 => 'PolygonZ', 18 => 'MultiPointZ', 21 => 'PointM', 23 => 'PolyLineM', 25 => 'PolygonM', 28 => 'MultiPointM', 31 => 'MultiPatch');
switch ($shp->shapeType) {
// ESRI Null Shape
case 0:
break;
// ESRI Point
// ESRI Point
case 1:
$gis_type = 'point';
break;
// ESRI PolyLine
// ESRI PolyLine
case 3:
$gis_type = 'multilinestring';
break;
// ESRI Polygon
// ESRI Polygon
case 5:
$gis_type = 'multipolygon';
break;
// ESRI MultiPoint
// ESRI MultiPoint
case 8:
$gis_type = 'multipoint';
break;
default:
$error = true;
if (!isset($esri_types[$shp->shapeType])) {
$message = PMA\libraries\Message::error(__('You tried to import an invalid file or the imported file' . ' contains invalid data!'));
} else {
$message = PMA\libraries\Message::error(__('MySQL Spatial Extension does not support ESRI type "%s".'));
$message->addParam($esri_types[$shp->shapeType]);
}
return;
}
if (isset($gis_type)) {
/** @var GISMultilinestring|\PMA\libraries\gis\GISMultipoint|\PMA\libraries\gis\GISPoint|GISPolygon $gis_obj */
$gis_obj = GISFactory::factory($gis_type);
} else {
$gis_obj = null;
}
$num_rows = count($shp->records);
// If .dbf file is loaded, the number of extra data columns
//.........这里部分代码省略.........
示例7: open
/**
* Attempts to open the file.
*
* @return bool
*/
public function open()
{
if (!$this->_decompress) {
$this->_handle = @fopen($this->getName(), 'r');
}
switch ($this->getCompression()) {
case false:
return false;
case 'application/bzip2':
if ($GLOBALS['cfg']['BZipDump'] && @function_exists('bzopen')) {
$this->_handle = @bzopen($this->getName(), 'r');
} else {
$this->errorUnsupported();
return false;
}
break;
case 'application/gzip':
if ($GLOBALS['cfg']['GZipDump'] && @function_exists('gzopen')) {
$this->_handle = @gzopen($this->getName(), 'r');
} else {
$this->errorUnsupported();
return false;
}
break;
case 'application/zip':
if ($GLOBALS['cfg']['ZipDump'] && @function_exists('zip_open')) {
include_once './libraries/zip_extension.lib.php';
$result = PMA_getZipContents($this->getName());
if (!empty($result['error'])) {
$this->_error_message = (string) PMA_Message::rawError($result['error']);
return false;
} else {
$this->content_uncompressed = $result['data'];
}
unset($result);
} else {
$this->errorUnsupported();
return false;
}
break;
case 'none':
$this->_handle = @fopen($this->getName(), 'r');
break;
default:
$this->errorUnsupported();
return false;
break;
}
return true;
}
示例8: open
/**
*
*/
function open()
{
if (!$this->_decompress) {
$this->_handle = @fopen($this->getName(), 'r');
}
switch ($this->getCompression()) {
case false:
return false;
case 'application/bzip2':
if ($GLOBALS['cfg']['BZipDump'] && @function_exists('bzopen')) {
$this->_handle = @bzopen($this->getName(), 'r');
} else {
$this->_error_message = sprintf(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'), $this->getCompression());
return false;
}
break;
case 'application/gzip':
if ($GLOBALS['cfg']['GZipDump'] && @function_exists('gzopen')) {
$this->_handle = @gzopen($this->getName(), 'r');
} else {
$this->_error_message = sprintf(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'), $this->getCompression());
return false;
}
break;
case 'application/zip':
if ($GLOBALS['cfg']['ZipDump'] && @function_exists('zip_open')) {
include_once './libraries/zip_extension.lib.php';
$result = PMA_getZipContents($this->getName());
if (!empty($result['error'])) {
$this->_error_message = PMA_Message::rawError($result['error']);
return false;
} else {
$this->content_uncompressed = $result['data'];
}
unset($result);
} else {
$this->_error_message = sprintf(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'), $this->getCompression());
return false;
}
break;
case 'none':
$this->_handle = @fopen($this->getName(), 'r');
break;
default:
$this->_error_message = sprintf(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'), $this->getCompression());
return false;
break;
}
}
示例9: openZip
/**
* Opens file from zip
*
* @param string|null $specific_entry Entry to open
*
* @return bool
*/
public function openZip($specific_entry = null)
{
include_once './libraries/zip_extension.lib.php';
$result = PMA_getZipContents($this->getName(), $specific_entry);
if (!empty($result['error'])) {
$this->_error_message = Message::rawError($result['error']);
return false;
}
$this->_content = $result['data'];
$this->_offset = 0;
return true;
}
示例10: array
if (!isset($this->SHPData["parts"][$partIndex]["points"]) || !is_array($this->SHPData["parts"][$partIndex]["points"])) {
$this->SHPData["parts"][$partIndex] = array();
$this->SHPData["parts"][$partIndex]["points"] = array();
}
while (!in_array($readPoints, $this->SHPData["parts"]) && $readPoints < $this->SHPData["numpoints"]) {
$this->SHPData["parts"][$partIndex]["points"][] = $this->_loadPoint();
$readPoints++;
}
}
}
}
$shp = new PMA_ShapeFile(1);
// If the zip archive has more than one file,
// get the correct content to the buffer from .shp file.
if ($compression == 'application/zip' && PMA_getNoOfFilesInZip($import_file) > 1) {
$zip_content = PMA_getZipContents($import_file, '/^.*\\.shp$/i');
$GLOBALS['import_text'] = $zip_content['data'];
}
$temp_dbf_file = false;
// We need dbase extension to handle .dbf file
if (extension_loaded('dbase')) {
// If we can extract the zip archive to 'TempDir'
// and use the files in it for import
if ($compression == 'application/zip' && !empty($cfg['TempDir']) && is_writable($cfg['TempDir'])) {
$dbf_file_name = PMA_findFileFromZipArchive('/^.*\\.dbf$/i', $import_file);
// If the corresponding .dbf file is in the zip archive
if ($dbf_file_name) {
// Extract the .dbf file and point to it.
$extracted = PMA_zipExtract($import_file, realpath($cfg['TempDir']), array($dbf_file_name));
if ($extracted) {
$dbf_file_path = realpath($cfg['TempDir']) . (PMA_IS_WINDOWS ? '\\' : '/') . $dbf_file_name;