示例#1
0
 public function testFindFileInIncludePath()
 {
     $_path = M3_Util_File::findFileInIncludePath("ringside/m3/util/File.php");
     $this->assertTrue(is_file($_path));
     $_path = M3_Util_File::findFileInIncludePath("does/not/exist");
     $this->assertFalse($_path);
 }
 public function validateRequest()
 {
     $this->pathname = $this->getRequiredApiParam("pathname");
     $this->useIncludePath = $this->getApiParam("useIncludePath");
     // not allowed to look for files in parent directories
     if (preg_match("/\\.\\./", $this->pathname)) {
         throw new OpenFBAPIException("Illegal pathname has been rejected");
     }
     if (isset($this->useIncludePath) && $this->useIncludePath == "true") {
         $this->pathname = M3_Util_File::findFileInIncludePath($this->pathname);
     } else {
         $_installDir = M3_Util_Settings::getRingsideServerInstallDir();
         $this->pathname = M3_Util_File::buildPathName($_installDir, $this->pathname);
     }
     if (!file_exists($this->pathname)) {
         throw new OpenFBAPIException("File [{$this->pathname}] does not exist");
     }
     // don't process request for any content larger than 1MB
     $_size = filesize($this->pathname);
     if ($_size >= M3_Util_Settings::getMaxSizeAllowedOperationGetFileContent()) {
         throw new OpenFBAPIException("File [{$this->pathname}] is too large [{$_size}]");
     }
     return;
 }
示例#3
0
 /**
  * Returns the installation directory of the Ringside Server itself.
  * 
  * @return string the pathname of the install directory
  */
 public static function getRingsideServerInstallDir()
 {
     // when in production, build.info file should always exist at the root install dir;
     // use build.info as our primary search file since we know we'll never have more than one.
     // if that isn't found, we must be in dev mode; let's hunt for the LocalSettings.php
     // which should also be in the root install dir. There may be more than one in other
     // directories, but I think we usually only have one at the root dir.  Because I'm
     // not sure if this will change in the future, that's why I key on build.info first.
     $_file = M3_Util_File::findFileInIncludePath('build.info');
     if (!$_file) {
         $_file = M3_Util_File::findFileInIncludePath('LocalSettings.php');
         if (!$_file) {
             throw Exception("Missing both build.info and LocalSettings.php! Can't find install dir");
         }
     }
     $_installDir = dirname(realpath($_file));
     return $_installDir;
 }