You are here

public static function PHPExcel_Shared_File::realpath in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/File.php \PHPExcel_Shared_File::realpath()

* Returns canonicalized absolute pathname, also for ZIP archives * *

Parameters

string $pFilename: * @return string

3 calls to PHPExcel_Shared_File::realpath()
PHPExcel_Reader_Excel2007::listWorksheetInfo in vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007.php
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * *
PHPExcel_Reader_Excel2007::load in vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007.php
* Loads PHPExcel from file * *
PHPExcel_Reader_Excel2007::_getFromZipArchive in vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007.php

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/File.php, line 102

Class

PHPExcel_Shared_File
PHPExcel_Shared_File

Code

public static function realpath($pFilename) {

  // Returnvalue
  $returnValue = '';

  // Try using realpath()
  if (file_exists($pFilename)) {
    $returnValue = realpath($pFilename);
  }

  // Found something?
  if ($returnValue == '' || $returnValue === NULL) {
    $pathArray = explode('/', $pFilename);
    while (in_array('..', $pathArray) && $pathArray[0] != '..') {
      for ($i = 0; $i < count($pathArray); ++$i) {
        if ($pathArray[$i] == '..' && $i > 0) {
          unset($pathArray[$i]);
          unset($pathArray[$i - 1]);
          break;
        }
      }
    }
    $returnValue = implode('/', $pathArray);
  }

  // Return
  return $returnValue;
}