protected function getFileInfo($path)
 {
     $fileInfo = null;
     if ($this->validPathStr($path) === false) {
         throw new \Exception('Directory path is not valid. Possible security issue.');
     }
     $basePath = $this->addEndingSlash($this->command->getGitEnvironment()->getPath());
     if ($this->command->getGitEnvironment()->getSsh() === true) {
         //Remote Directory Listing
         $fileData = $this->command->getSftpProcess()->getFileStats($basePath . $path);
         $fileData['filename'] = basename($path);
         $fileData['fullPath'] = $basePath . $path;
         $fileData['gitPath'] = $path;
         $fileInfo = new RemoteFileInfo($fileData);
     } else {
         $splFileInfo = new \SPLFileInfo($basePath . $path);
         $splFileInfo->setInfoClass('\\VersionControl\\GitCommandBundle\\Entity\\FileInfo');
         $newFileInfo = $splFileInfo->getFileInfo();
         $newFileInfo->setGitPath($basePath . $path);
         $fileInfo = $newFileInfo;
     }
     return $fileInfo;
 }
Ejemplo n.º 2
0
 public function __construct(\SPLFileInfo $asset, Pg $db)
 {
     $this->location = realpath($asset->getPathname());
     $dbSql = $this->dbSql = $db->query(new Query("SELECT * FROM build.assets WHERE location = %location:%", array('location' => $this->location)))->fetch(Result::FETCH_SINGLE);
     if ($dbSql) {
         $diff = new Diff();
         $this->diffText = $diff->diff($dbSql['sql'], file_get_contents($this->location));
     } else {
         $this->diffText = 'Asset not in database';
     }
     $this->message = sprintf("Database asset `%s` at %s changed at %s.\n%s", substr($asset->getBasename(), 0, -4), $this->location, date('Y-m-d H:i:s', $asset->getMTime()), $this->diffText);
 }
Ejemplo n.º 3
0
 public function __construct($filename, $mode = 'r', $inc = false, $ctx = null)
 {
     parent::__construct($filename);
     if (isset($context)) {
         $this->fp = fopen($filename, $mode, $inc, $ctx);
     } else {
         $this->fp = fopen($filename, $mode, $inc);
     }
     if (!$this->fp) {
         throw new Exception("Не могу прочитать файл!");
     }
     //
     $this->map = $this->fgetcsv();
     $this->currentLine = 0;
 }
Ejemplo n.º 4
0
 public function __construct($filename, $mode = 'r', $use_include_path = false, $context = NULL)
 {
     parent::__construct($filename);
     if (isset($context)) {
         $this->fp = fopen($filename, $mode, $use_include_path, $context);
     } else {
         $this->fp = fopen($filename, $mode, $use_include_path);
     }
     if (!$this->fp) {
         throw new Exception("Cannot read file");
     }
     //Get the column map
     $this->map = $this->fgetcsv();
     $this->currentLine = 0;
 }
Ejemplo n.º 5
0
/**
 * Get file informations (size, name ...)
 *
 * @param Application $app Silex Application
 * @param Request $request Request parameters
 *
 * @return JsonResponse Object containing file informations
 */
function get_infos(Application $app, Request $request)
{
    if ($app["rights.canPlayMedia"] == false) {
        $app->abort(403, "This user doesn't have the rights to retrieve file informations");
    }
    $filepath = Utils\check_path($app['cakebox.root'], $request->get('path'));
    if (!isset($filepath)) {
        $app->abort(400, "Missing parameters");
    }
    $file = new \SPLFileInfo("{$app['cakebox.root']}/{$filepath}");
    $fileinfo = [];
    $fileinfo["name"] = $file->getBasename("." . $file->getExtension());
    $fileinfo["fullname"] = $file->getFilename();
    $fileinfo["mimetype"] = mime_content_type($file->getPathName());
    $fileinfo["access"] = str_replace('%2F', '/', rawurlencode("{$app['cakebox.access']}/{$filepath}"));
    $fileinfo["size"] = $file->getSize();
    return $app->json($fileinfo);
}
Ejemplo n.º 6
0
 public function size()
 {
     return parent::getSize();
 }
 public function archive(\SPLFileInfo $packageDirectory, \SplFileInfo $targetDirectory)
 {
     $process = new Process($this->getComposerCommand() . ' archive --format=zip --dir="' . $targetDirectory->getPathname() . '" -vvv', $packageDirectory->getPathname());
     $process->run();
     $this->handleProcessResult($process);
 }
Ejemplo n.º 8
0
 /**
  * cmpSPLFileInfo
  *
  * @param   SPLFileInfo     $info1
  * @param   SPLFileInfo     $info2
  * @return  integer         -1, 0 of 1
  */
 private function cmpSPLFileInfo(SPLFileInfo $info1, SPLFileInfo $info2)
 {
     return strcmp($info1->getFileName(), $info2->getFileName());
 }
Ejemplo n.º 9
0
 /**
  * Construct
  *
  * @param string $fullPath the destination Path of a file
  * @param string $content  setup the File content
  */
 public function __construct($fullPath, $content = null)
 {
     parent::__construct($fullPath);
     $this->fullPath = $fullPath;
     $this->content = $content;
 }
Ejemplo n.º 10
0
<?php

$fileName = 'filename.txt';
$fileInfo = new SPLFileInfo($fileName);
$fileProps = array();
$fileProps['path'] = $fileInfo->getPath();
$fileProps['filename'] = $fileInfo->getFilename();
$fileProps['pathname'] = $fileInfo->getPathname();
$fileProps['perms'] = $fileInfo->getPerms();
$fileProps['inode'] = $fileInfo->getInode();
$fileProps['size'] = $fileInfo->getSize();
$fileProps['owner'] = $fileInfo->getOwner();
$fileProps['group'] = $fileInfo->getGroup();
$fileProps['atime'] = $fileInfo->getATime();
$fileProps['mtime'] = $fileInfo->getMTime();
$fileProps['ctime'] = $fileInfo->getCTime();
$fileProps['type'] = $fileInfo->getType();
$fileProps['isWritable'] = $fileInfo->isWritable();
$fileProps['isReadable'] = $fileInfo->isReadable();
$fileProps['isExecutable'] = $fileInfo->isExecutable();
$fileProps['isFile'] = $fileInfo->isFile();
$fileProps['isDir'] = $fileInfo->isDir();
$fileProps['isLink'] = $fileInfo->isLink();
var_export($fileProps);
Ejemplo n.º 11
0
<?php

echo '<style>body{font-family:sans-serif}pre{background:rgba(0,0,0,.05);border-radius:4px;padding:5px;}code{border-bottom:3px solid rgba(0,0,0,.05)}</style>';
use Radiergummi\Anacronism\Backup;
# require autoloader
require '../vendor/autoload.php';
# instantiate the backup
$backup = new Backup([]);
$backup->addFolder('../vendor')->compressWith('zip')->saveAt(['local']);
var_dump("Backup: {$backup}");
$file = new SPLFileInfo(realpath('../src/Backup.php'));
$inspected = $backup->inspect();
echo '<ul>';
foreach ($inspected as $class => $data) {
    echo '<li><h2><code>' . $class . '</h2></code>';
    echo '<ul>';
    foreach ($data as $key => $values) {
        echo '<li><h3><code>' . $key . '</h3></code>';
        echo '<ul id="' . $key . '">';
        foreach ($values as $value) {
            if ($value instanceof \ReflectionProperty) {
                $value->setAccessible(true);
                echo '<li><h4><code>' . $value->getName() . '</code>' . ($value->isPublic() ? ' [public]' : '') . '</h4><pre>' . json_encode($value->getValue($backup), JSON_PRETTY_PRINT) . '</pre>';
            } else {
                echo '<li><h4><code>' . $value->getName() . '</code>' . ($value->isPublic() ? ' [public]' : '') . '</h4><pre>' . $value . '</pre></li>';
            }
        }
        echo '</ul>';
    }
    echo '</ul>';
    echo '</li>';