Subversion Repositories oidplus

Compare Revisions

Regard whitespace Rev 729 → Rev 730

/trunk/doc/developer_notes/feature_oids.txt
1,5 → 1,5
 
FEATURE OIDS
FEATURE OIDS ("Weak interfaces")
============
 
PHP classes belonging to the OIDplus system (such as the class handling the tree menu structure,
14,10 → 14,15
anymore if the plugin offering the interface is missing, due to a PHP compilation error.
Therefore, we use a functionality called "features".
A plugin can ask another plugin if it supports a feature (defined as OID) using
the function OIDplusPlugin::implementsFeature().
the function implementsFeature().
If it supports the feature with a given OID, the plugin promises that it
contains a set of functions defined by that OID.
 
All classes of OIDplus inherit from OIDplusBaseClass, which implements
OIDplusBaseClass::implementsFeature(). Therefore, the "feature OID" functionality
works also for plugin-like classes (e.g. OIDplusObject) and not only for the
real plugin classes (OIDplusPlugin).
 
Currently, there are following features defined in the standard plugins of OIDplus:
 
Interface <1.3.6.1.4.1.37476.2.5.2.3.1> {
/trunk/includes/classes/OIDplus.class.php
19,7 → 19,7
 
if (!defined('INSIDE_OIDPLUS')) die();
 
class OIDplus {
class OIDplus extends OIDplusBaseClass {
private static /*OIDplusPagePlugin[]*/ $pagePlugins = array();
private static /*OIDplusAuthPlugin[]*/ $authPlugins = array();
private static /*OIDplusLoggerPlugin[]*/ $loggerPlugins = array();
/trunk/includes/classes/OIDplusAltId.class.php
19,7 → 19,7
 
if (!defined('INSIDE_OIDPLUS')) die();
 
class OIDplusAltId {
class OIDplusAltId extends OIDplusBaseClass {
 
private $ns;
private $id;
/trunk/includes/classes/OIDplusAuthContentStore.class.php
19,7 → 19,7
 
if (!defined('INSIDE_OIDPLUS')) die();
 
abstract class OIDplusAuthContentStore implements OIDplusGetterSetterInterface {
abstract class OIDplusAuthContentStore extends OIDplusBaseClass implements OIDplusGetterSetterInterface {
 
// Getter / Setter
 
/trunk/includes/classes/OIDplusAuthUtils.class.php
19,7 → 19,7
 
if (!defined('INSIDE_OIDPLUS')) die();
 
class OIDplusAuthUtils {
class OIDplusAuthUtils extends OIDplusBaseClass {
 
// Useful functions
 
/trunk/includes/classes/OIDplusBaseClass.class.php
0,0 → 1,34
<?php
 
/*
* OIDplus 2.0
* Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
 
if (!defined('INSIDE_OIDPLUS')) die();
 
abstract class OIDplusBaseClass {
 
public function implementsFeature($id) {
 
// Use this function to query the plugin if it supports some specific interface
// Usually, you would use PHP Interfaces. However, the problem with PHP interfaces
// is, that there will be a fatal error if the interface can't be found (e.g. because
// the OIDplus plugin is not installed). So we need an "optional" interface.
 
return false;
}
 
}
/trunk/includes/classes/OIDplusBaseConfig.class.php
22,7 → 22,7
// OIDplusBaseConfig is the basic ("static") configuration stored in userdata/baseconfig/config.inc.php,
// e.g. database access credentials.
// Not to be confused with OIDplusConfig which are settings that are stored in the database.
class OIDplusBaseConfig implements OIDplusGetterSetterInterface {
class OIDplusBaseConfig extends OIDplusBaseClass implements OIDplusGetterSetterInterface {
 
protected $data = array();
 
/trunk/includes/classes/OIDplusConfig.class.php
23,7 → 23,7
// Not to be confused with OIDplusBaseConfig which is the basic ("static")
// configuration stored in userdata/baseconfig/config.inc.php,
// e.g. database access credentials.
class OIDplusConfig implements OIDplusGetterSetterInterface {
class OIDplusConfig extends OIDplusBaseClass implements OIDplusGetterSetterInterface {
 
/*public*/ const PROTECTION_EDITABLE = 0;
/*public*/ const PROTECTION_READONLY = 1;
/trunk/includes/classes/OIDplusCookieUtils.class.php
19,7 → 19,7
 
if (!defined('INSIDE_OIDPLUS')) die();
 
class OIDplusCookieUtils {
class OIDplusCookieUtils extends OIDplusBaseClass {
 
public function unsetcookie($name) {
$this->setcookie($name, '', time()-9999, true);
/trunk/includes/classes/OIDplusDatabaseConnection.class.php
19,7 → 19,7
 
if (!defined('INSIDE_OIDPLUS')) die();
 
abstract class OIDplusDatabaseConnection {
abstract class OIDplusDatabaseConnection extends OIDplusBaseClass {
protected /*bool*/ $connected = false;
protected /*?bool*/ $html = null;
protected /*?string*/ $last_query = null;
/trunk/includes/classes/OIDplusGui.class.php
19,7 → 19,7
 
if (!defined('INSIDE_OIDPLUS')) die();
 
class OIDplusGui {
class OIDplusGui extends OIDplusBaseClass {
 
public static function generateContentPage($id) {
$out = array();
/trunk/includes/classes/OIDplusLogger.class.php
19,7 → 19,7
 
if (!defined('INSIDE_OIDPLUS')) die();
 
class OIDplusLogger {
class OIDplusLogger extends OIDplusBaseClass {
 
private static function split_maskcodes($maskcodes) {
// This function splits a mask code containing multiple components
/trunk/includes/classes/OIDplusMailUtils.class.php
19,7 → 19,7
 
if (!defined('INSIDE_OIDPLUS')) die();
 
class OIDplusMailUtils {
class OIDplusMailUtils extends OIDplusBaseClass {
 
public static function validMailAddress($email) {
return !empty(filter_var($email, FILTER_VALIDATE_EMAIL));
/trunk/includes/classes/OIDplusMenuUtils.class.php
19,7 → 19,7
 
if (!defined('INSIDE_OIDPLUS')) die();
 
class OIDplusMenuUtils {
class OIDplusMenuUtils extends OIDplusBaseClass {
 
public static function nonjs_menu() {
$json = array();
/trunk/includes/classes/OIDplusObject.class.php
19,7 → 19,7
 
if (!defined('INSIDE_OIDPLUS')) die();
 
abstract class OIDplusObject {
abstract class OIDplusObject extends OIDplusBaseClass {
const UUID_NAMEBASED_NS_OidPlusMisc = 'ad1654e6-7e15-11e4-9ef6-78e3b5fc7f22';
 
public static function parse($node_id) { // please overwrite this function!
/trunk/includes/classes/OIDplusPlugin.class.php
19,18 → 19,8
 
if (!defined('INSIDE_OIDPLUS')) die();
 
abstract class OIDplusPlugin {
abstract class OIDplusPlugin extends OIDplusBaseClass {
 
public function implementsFeature($id) {
 
// Use this function to query the plugin if it supports some specific interface
// Usually, you would use PHP Interfaces. However, the problem with PHP interfaces
// is, that there will be a fatal error if the interface can't be found (e.g. because
// the OIDplus plugin is not installed). So we need an "optional" interface.
 
return false;
}
 
public final function getPluginDirectory() {
$reflector = new \ReflectionClass(get_called_class());
$path = dirname($reflector->getFilename());
47,4 → 37,3
public function init($html=true) {}
 
}
 
/trunk/includes/classes/OIDplusPluginManifest.class.php
19,7 → 19,7
 
if (!defined('INSIDE_OIDPLUS')) die();
 
class OIDplusPluginManifest {
class OIDplusPluginManifest extends OIDplusBaseClass {
 
private $manifestFile = null;
private $rawXML = null;
/trunk/includes/classes/OIDplusQueryResult.class.php
19,7 → 19,7
 
if (!defined('INSIDE_OIDPLUS')) die();
 
abstract class OIDplusQueryResult {
abstract class OIDplusQueryResult extends OIDplusBaseClass {
abstract public function containsResultSet(): bool;
abstract public function num_rows(): int;
abstract public function fetch_array()/*: ?array*/;
/trunk/includes/classes/OIDplusRA.class.php
19,7 → 19,7
 
if (!defined('INSIDE_OIDPLUS')) die();
 
class OIDplusRA {
class OIDplusRA extends OIDplusBaseClass {
private $email = null;
 
public function __construct($email) {
/trunk/includes/classes/OIDplusRAAuthInfo.class.php
19,7 → 19,7
 
if (!defined('INSIDE_OIDPLUS')) die();
 
class OIDplusRAAuthInfo {
class OIDplusRAAuthInfo extends OIDplusBaseClass {
 
private $salt;
private $authKey;
/trunk/includes/classes/OIDplusSessionHandler.class.php
19,7 → 19,7
 
if (!defined('INSIDE_OIDPLUS')) die();
 
class OIDplusSessionHandler implements OIDplusGetterSetterInterface {
class OIDplusSessionHandler extends OIDplusBaseClass implements OIDplusGetterSetterInterface {
 
private $secret = '';
protected $sessionLifetime = '';
/trunk/phpstan.neon.dist
1,5 → 1,8
parameters:
level: 5
fileExtensions:
- php
- phps
paths:
- .
excludePaths:
/trunk/plugins/viathinksoft/publicPages/100_whois/whois/webwhois.php
217,10 → 217,14
$out[] = 'attribute: confidential'; // DO NOT TRANSLATE!
}
 
if ($obj->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.4')) {
// Also ask $obj for extra attributes:
// This way we could add various additional information, e.g. IPv4/6 range analysis, interpretation of GUID, etc. (TODO)
$obj->whoisObjectAttributes($obj->nodeId(), $out);
}
 
foreach (OIDplus::getPagePlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.4')) {
// TODO: Also ask $obj for extra attributes (although it is not a plugin)?
// This way we could add various additional information, e.g. IPv4/6 range analysis, interpretation of GUID, etc.
$plugin->whoisObjectAttributes($obj->nodeId(), $out);
}
}
283,9 → 287,16
$out[] = 'ra-fax: ' . $row2->fax; // DO NOT TRANSLATE!
}
$out[] = 'ra-email: ' . $row->ra_email; // DO NOT TRANSLATE!
 
$ra = new OIDplusRA($row->ra_email);
if ($ra->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.4')) {
// Also ask $obj for extra attributes:
// This way we could add various additional information, e.g. IPv4/6 range analysis, interpretation of GUID, etc.
$ra->whoisRaAttributes($row->ra_email, $out);
}
 
foreach (OIDplus::getPagePlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.4')) {
// TODO: Also ask $ra for extra attributes (although it is not a plugin)?
$plugin->whoisRaAttributes($row->ra_email, $out);
}
}