コード例 #1
0
ファイル: InventoryGetApi.php プロジェクト: jkinner/ringside
 /**
  * Returns an array containing information on an API.
  *
  * @return array info on an API
  */
 public function execute()
 {
     $_apiNamePieces = explode('.', $this->apiName);
     $_apiNamespace = $_apiNamePieces[0];
     $_apiPkg = $_apiNamePieces[1];
     $_apiShortName = $_apiNamePieces[2];
     $_apiClassFile = ucfirst($_apiPkg) . ucfirst($_apiShortName) . '.php';
     // we need to scan the rest locations so we can get the full path info
     $_restLocations = M3_Util_Settings::getRestLocations();
     $_deployedApiLocations = M3_Util_Settings::getDeployedApiLocations();
     $_foundPathname = null;
     foreach ($_restLocations as $_restLocation) {
         foreach ($_deployedApiLocations as $_deployedApiLocation) {
             $_dir = M3_Util_File::buildPathName($_restLocation, $_deployedApiLocation);
             $_pathname = M3_Util_File::buildPathName($_dir, $_apiClassFile);
             if (file_exists($_pathname)) {
                 $_foundPathname = $_pathname;
                 break;
             }
         }
         if (!is_null($_foundPathname)) {
             break;
         }
     }
     $_info = array();
     if (!is_null($_foundPathname)) {
         $_info['api_name'] = $this->apiName;
         $_info['pathname'] = $_foundPathname;
     }
     return array('api' => $_info);
 }
コード例 #2
0
 public function validateRequest()
 {
     if (!M3_Util_Settings::getAllowOperationEvaluatePhpCode()) {
         throw new OpenFBAPIException("Evaluation of PHP code is disallowed");
     }
     $this->phpCode = $this->getRequiredApiParam("phpCode");
 }
コード例 #3
0
ファイル: index.php プロジェクト: jkinner/ringside
function echo_errorlog()
{
    $_errorLogPath = M3_Util_Settings::getPhpErrorLogPathName();
    if ($_errorLogPath) {
        if (get_request_param("clearerrorlog")) {
            if (!M3_Util_File::truncateFile($_errorLogPath)) {
                echo "<i>Count not truncate error log [{$_errorLogPath}]</i>";
            }
        }
        echo <<<EOL1
        <h2 align="center">{$_errorLogPath}</h2>
        <table align="center"><tr><td>
        <form action="index.php">
           <input type="hidden" name="show" value="errorlog"/>
           <input type="hidden" name="clearerrorlog" value="true"/>
           <input type="submit" value="Clear"/>
        </form>
        </td></tr></table>
EOL1;
        echo "<pre>";
        echo htmlentities(file_get_contents($_errorLogPath));
        echo "</pre>";
    } else {
        echo "Cannot determine where the error log is";
    }
}
コード例 #4
0
 /**
  * Returns an associative, multi-dimensional array containing version
  * information about different software components in the server.
  *
  * @return array all version information
  */
 public function execute()
 {
     $_ringside = array('version' => $this->getRingsideServerVersion(), 'build_number' => $this->getRingsideServerBuildNumber(), 'build_date' => $this->getRingsideServerBuildDate(), 'svn_revision' => $this->getRingsideServerSvnRevision(), 'install_dir' => M3_Util_Settings::getRingsideServerInstallDir());
     $_php = array('version' => $this->getPhpVersionReal(), 'doctrine_version' => Doctrine::VERSION, 'php_ini_file' => M3_Util_Settings::getPhpIniFileLocation());
     // get all loaded extension versions
     $_extensions = array();
     $_loadedExtensions = get_loaded_extensions();
     foreach ($_loadedExtensions as $_loadedExtension) {
         $_extensions[strtolower($_loadedExtension)] = $this->getPhpVersionForExtension($_loadedExtension);
     }
     // There are some extensions we know we need, so force ourselves to get
     // their information. This is so we can show unloaded extensions in the list
     // to let the caller know something is missing that we expect to be loaded.
     $_extensions['tidy'] = $this->getPhpVersionForExtension('tidy');
     $_extensions['curl'] = $this->getPhpVersionForExtension('curl');
     $_extensions['xsl'] = $this->getPhpVersionForExtension('xsl');
     $_extensions['mcrypt'] = $this->getPhpVersionForExtension('mcrypt');
     $_extensions['pdo'] = $this->getPhpVersionForExtension('pdo');
     ksort($_extensions);
     $_extList = array();
     foreach ($_extensions as $_name => $_version) {
         $_extList[] = array('name' => $_name, 'version' => $_version);
     }
     return array('ringside' => $_ringside, 'php' => $_php, 'extensions' => array('extension' => $_extList));
 }
コード例 #5
0
 /**
  * Returns an associative array of all php.ini configuration settings.
  * The list returned is an array of name/value pair arrays.
  * 
  * @return array php.ini configuration settings, or false on error
  */
 public function execute()
 {
     $_settings = M3_Util_Settings::getPhpIniSettings();
     if ($_settings) {
         $_nameValues = array();
         foreach ($_settings as $_name => $_value) {
             $_nameValues[] = array('name' => $_name, 'value' => $_value);
         }
         return array('php_ini_setting' => $_nameValues);
     } else {
         return false;
     }
 }
コード例 #6
0
 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;
 }
コード例 #7
0
ファイル: InventoryGetApis.php プロジェクト: jkinner/ringside
 /**
  * Returns the APIs that are currently deployed in the given rest directory name.
  * The returned names will be the full REST API name that REST clients can use
  * to invoke the APIs.  This includes the three-parts to the REST API:
  * <namespace>.<package>.<class>; e.g. "m3.inventory.getApis"
  *
  * @param $apiNamespace the namespace of the APIs found in the given directory
  * @param $restDir the directory name where the API classes can be found
  *
  * @return array names of all APIs deployed in the server in the given directory
  *         the array is associative, where the key is the API name and the value
  *         is the php file that implements that API
  */
 private function getApiNamesInDirectory($apiNamespace, $restDir)
 {
     $_rootDirs = M3_Util_Settings::getRestLocations();
     $_names = array();
     foreach ($_rootDirs as $_dir) {
         $_fullApiDirectory = $_dir . $restDir;
         if (file_exists($_fullApiDirectory)) {
             $_files = scandir($_fullApiDirectory);
             foreach ($_files as $_file) {
                 if (!is_dir($_file)) {
                     $_apiName = $this->determineApiName($_file);
                     if (!empty($_apiName)) {
                         $_name = $apiNamespace . '.' . $_apiName;
                         if (!$this->isIgnoredName($_name)) {
                             $_names[$_name] = $_fullApiDirectory . '/' . $_file;
                         }
                     }
                 }
             }
         }
     }
     return $_names;
 }
コード例 #8
0
ファイル: SettingsTestCase.php プロジェクト: jkinner/ringside
 public function testGetErrorLogs()
 {
     $_phpErrorLog = M3_Util_Settings::getPhpErrorLogPathName();
     $_webInstallDir = M3_Util_Settings::getWebServerInstallationDirectory();
     $_webErrorLog = M3_Util_Settings::getWebServerErrorLogPathName();
 }
コード例 #9
0
 public function testPhpIniFile()
 {
     $_phpLocation = M3_Util_Settings::getPhpIniFileLocation();
     $this->assertTrue(!empty($_phpLocation));
     $_php = new M3_Util_IniSettings($_phpLocation, false);
     $_php->readIniFile($_phpSettings, true);
     $this->assertArrayHasKey('PHP', $_phpSettings);
     $this->assertArrayHasKey('engine', $_phpSettings['PHP']);
     $this->assertEquals('on', strtolower($_phpSettings['PHP']['engine']));
 }
コード例 #10
0
// Set up validation FIXME: this really breaks out stuff, not good
//$manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
// Set up caching
if (isset($useDbCache) && $useDbCache === true) {
    $sqlite_conn = Doctrine_Manager::connection(new PDO('sqlite:memory'));
    $cacheDriver = new Doctrine_Cache_Db(array('connection' => $sqlite_conn, 'tableName' => 'ringside_api'));
    try {
        $cacheDriver->createTable();
    } catch (Doctrine_Connection_Exception $e) {
        if ($e->getPortableCode() !== Doctrine::ERR_ALREADY_EXISTS) {
            $cacheDriver = null;
        }
    }
    if (null !== $cacheDriver) {
        $manager->setAttribute(Doctrine::ATTR_QUERY_CACHE, $cacheDriver);
        $manager->setAttribute(Doctrine::ATTR_RESULT_CACHE, $cacheDriver);
        // Result cache set for 5 minutes - FIXME: this causes php to crash.  Riddle me that!
        //$manager->setAttribute(Doctrine::ATTR_RESULT_CACHE_LIFESPAN, 300);
        //Doctrine::ATTR_RESULT_CACHE_LIFESPAN;
        //Doctrine::ATTR_QUERY_CACHE_LIFESPAN
    }
}
$conn = Doctrine_Manager::connection($dsn);
require_once 'ringside/m3/util/Settings.php';
if (M3_Util_Settings::getDbProfilerEnable()) {
    require_once 'ringside/m3/metric/DoctrineProfiler.php';
    $profiler = new M3_Metric_DoctrineProfiler();
    $conn->setListener($profiler);
}
$conn->setAttribute('portability', Doctrine::PORTABILITY_ALL);
spl_autoload_register(array('RingsideApiServer', 'autoload'));
コード例 #11
0
 /**
  * Creates a new listener that can listen for events when API invocations occur.
  * The returned listener object also provides methods that can be used to retrieve
  * aggregated information about the API invocations that have occurred.
  * 
  * @return M3_Metric_IApiInvocationListener the listener created
  */
 public static function createApiInvocationListener()
 {
     $_ds = M3_Util_Settings::getDatastore();
     if ($_ds->isDB()) {
         $_listener = new M3_Db_ApiInvocationListener();
     }
     return $_listener;
 }
コード例 #12
0
ファイル: AbstractRest.php プロジェクト: jkinner/ringside
 /**
  * Validate the M3 request by ensuring the request was properly signed
  * with the M3 secret key. The verification algorithm is as follows:
  * <ol>
  *    <li>Ensure the request has a signature string (found in the context)</li>
  *    <li>Sort all request parameters via PHP ksort() method</li>
  *    <li>Build a single string with request parameter "name=value" pairs</li>
  *    <li>Append to the string the M3 secret key that is configured in the server</li>
  *    <li>Calculate an MD5 hashcode for the string</li>
  *    <li>Verify that the MD5 hashcode matches the signature string passed in with the request</li>
  * </ol>
  */
 public function validateSig()
 {
     $_sig = $this->getContext()->getSig();
     $_request = $this->getContext()->getInitialRequest();
     $_secret = M3_Util_Settings::getM3SecretKey();
     if (!isset($_sig) || empty($_sig)) {
         throw new Exception('M3 request rejected - it is missing a signature');
     }
     ksort($_request);
     $_str = '';
     foreach ($_request as $_k => $_v) {
         if ($_k != 'sig') {
             $_str .= "{$_k}={$_v}";
         }
     }
     $_str .= $_secret;
     $_md5sig = md5($_str);
     if ($_md5sig != $_sig) {
         $_emsg = 'M3 request rejected - incorrect signature';
         error_log("{$_emsg}: _str=[{$_str}], _md5sig=[{$_md5sig}], _sig=[{$_sig}]");
         throw new Exception($_emsg);
     }
     return;
 }
コード例 #13
0
ファイル: Settings.php プロジェクト: jkinner/ringside
 /**
  * Return array of locations where REST APIs can be located.
  *
  * These are directories that deployed API locations can be rooted at.
  * In other words, get these rest locations first, then under these directories,
  * you should be able to find deployed REST APIs in the subdirectories
  * specified by {@link getDeployedApiLocations()}. 
  *
  * @return array of directory locations where REST APIs can be found
  */
 public static function getRestLocations()
 {
     if (!empty(self::$restLocations)) {
         return self::$restLocations;
     }
     $_restLocations = array();
     $_includePaths = explode(PATH_SEPARATOR, get_include_path());
     foreach ($_includePaths as $_includePath) {
         $_includePath = realpath(rtrim($_includePath, '\\/'));
         if ($_includePath) {
             $_restLocations[] = $_includePath;
         }
     }
     self::$restLocations = array_unique($_restLocations);
     // if include_path has any dups, remove them
     return self::$restLocations;
 }
コード例 #14
0
ファイル: TagRegistry.php プロジェクト: jkinner/ringside
 protected static function getCacheFileName()
 {
     $dataDir = M3_Util_Settings::getDataDirectory();
     $fname = $dataDir . DIRECTORY_SEPARATOR . 'Social_Dsl_TagRegistry.config';
     return $fname;
 }
コード例 #15
0
 protected function initClient()
 {
     unset($this->client);
     $this->client = new M3_Client_RestClient(M3_Util_Settings::getRestServerUrl(), M3_Util_Settings::getM3SecretKey(), null);
     $this->assertTrue(isset($this->client));
 }
コード例 #16
0
ファイル: DoctrineProfiler.php プロジェクト: jkinner/ringside
 /**
  * Creates a doctrine profiler.
  */
 public function __construct()
 {
     parent::__construct();
     $this->dataDirectory = M3_Util_Settings::getDataDirectory() . '/doctrine-profiler';
     $this->md5FilesCreated = array();
 }