示例#1
0
 public function testSettings()
 {
     $_allowEval = M3_Util_Settings::getAllowOperationEvaluatePhpCode();
     $this->assertType('boolean', $_allowEval);
     $_maxSizeAllowedFileContent = M3_Util_Settings::getMaxSizeAllowedOperationGetFileContent();
     $this->assertGreaterThanOrEqual(0, $_maxSizeAllowedFileContent);
     $_dataDir = M3_Util_Settings::getDataDirectory();
     $this->assertFalse(empty($_dataDir));
     $_dataStoreEnum = M3_Util_Settings::getDatastore();
     $this->assertFalse(empty($_dataStoreEnum));
     $this->assertType(M3_Util_DatastoreEnum, $_dataStoreEnum);
     $_dirs = M3_Util_Settings::getDeployedApiLocations();
     $this->assertEquals(3, count($_dirs));
     $this->assertContains('/ringside/rest', $_dirs);
     $this->assertContains('/m3/rest', $_dirs);
     $this->assertContains('/ringside/api/facebook', $_dirs);
     $_php = M3_Util_Settings::getPhpIniFileLocation();
     $this->assertGreaterThan(strlen("php.ini"), strlen($_php), "should be a full path to the php.ini file");
     $_phpContent = M3_Util_Settings::getPhpIniSettings();
     $this->assertTrue(!empty($_phpContent));
     $_dbProfileEnable = M3_Util_Settings::getDbProfilerEnable();
     $this->assertNotNull($_dbProfileEnable);
     $this->assertTrue($_dbProfileEnable === true || $_dbProfileEnable === false, "Should have been a boolean");
 }
 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;
 }