當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Sanitize::sanitizeFilename方法代碼示例

本文整理匯總了PHP中Sanitize::sanitizeFilename方法的典型用法代碼示例。如果您正苦於以下問題:PHP Sanitize::sanitizeFilename方法的具體用法?PHP Sanitize::sanitizeFilename怎麽用?PHP Sanitize::sanitizeFilename使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sanitize的用法示例。


在下文中一共展示了Sanitize::sanitizeFilename方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: doImport

 /**
  * Handles the whole import logic
  *
  * @param array &$sql_data 2-element array with sql data
  *
  * @return void
  */
 public function doImport(&$sql_data = array())
 {
     global $db, $error, $finished, $import_file, $local_import_file, $message;
     $GLOBALS['finished'] = false;
     $compression = $GLOBALS['import_handle']->getCompression();
     $shp = new ShapeFileImport(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) {
         if ($GLOBALS['import_handle']->openZip('/^.*\\.shp$/i') === false) {
             $message = PMA\libraries\Message::error(__('There was an error importing the ESRI shape file: "%s".'));
             $message->addParam($GLOBALS['import_handle']->getError());
             return;
         }
     }
     $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, $dbf_file_name);
                 if ($extracted !== false) {
                     $dbf_file_path = realpath($GLOBALS['cfg']['TempDir']) . (PMA_IS_WINDOWS ? '\\' : '/') . Sanitize::sanitizeFilename($dbf_file_name, true);
                     $handle = fopen($dbf_file_path, 'wb');
                     if ($handle !== false) {
                         fwrite($handle, $extracted);
                         fclose($handle);
                         $temp_dbf_file = true;
                         // Replace the .dbf with .*, as required
                         // by the bsShapeFiles library.
                         $file_name = substr($dbf_file_path, 0, 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;
         }
     }
     // Delete the .dbf file extracted to 'TempDir'
     if ($temp_dbf_file && isset($dbf_file_path) && file_exists($dbf_file_path)) {
         unlink($dbf_file_path);
     }
     // 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;
     }
     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;
             $message = PMA\libraries\Message::error(__('MySQL Spatial Extension does not support ESRI type "%s".'));
             $message->addParam($shp->getShapeName());
             return;
     }
     if (isset($gis_type)) {
         /** @var GISMultilinestring|\PMA\libraries\gis\GISMultipoint|\PMA\libraries\gis\GISPoint|GISPolygon $gis_obj */
//.........這裏部分代碼省略.........
開發者ID:phpmyadmin,項目名稱:phpmyadmin,代碼行數:101,代碼來源:ImportShp.php


注:本文中的Sanitize::sanitizeFilename方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。