Subversion Repositories oidplus

Compare Revisions

Regard whitespace Rev 1115 → Rev 1116

/trunk/.idea/.gitignore
0,0 → 1,8
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
/trunk/.idea/codeStyles/codeStyleConfig.xml
0,0 → 1,5
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
/trunk/.idea/inspectionProfiles/Project_Default.xml
0,0 → 1,162
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="BadExpressionStatementJS" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="CallerJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="CommaExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ConstantConditionalExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ContinueOrBreakFromFinallyBlockJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ES6BindWithArrowFunction" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ES6CheckImport" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="ES6ClassMemberInitializationOrder" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ES6ConvertIndexedForToForOf" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="ES6ConvertLetToConst" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="ES6ConvertModuleExportToExport" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="ES6ConvertRequireIntoImport" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="ES6ConvertToForOf" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="ES6ConvertVarToLetConst" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="ES6DestructuringVariablesMerge" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="ES6MissingAwait" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="ES6PossiblyAsyncFunction" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="ES6PreferShortImport" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ES6RedundantAwait" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="ES6RedundantNestingInTemplateLiteral" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="ES6ShorthandObjectProperty" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="ES6UnusedImports" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="EmptyStatementBodyJS" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_reportEmptyBlocks" value="false" />
</inspection_tool>
<inspection_tool class="ExceptionCaughtLocallyJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="FallThroughInSwitchStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="FlowJSConfig" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="FlowJSFlagCommentPlacement" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="GrazieInspection" enabled="false" level="GRAMMAR_ERROR" enabled_by_default="false" />
<inspection_tool class="IncompatibleMaskJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="InfiniteLoopJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="InfiniteRecursionJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSAccessibilityCheck" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSAnnotator" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="JSArrowFunctionBracesCanBeRemoved" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="JSAssignmentUsedAsCondition" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSBitwiseOperatorUsage" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSCheckFunctionSignatures" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="JSClosureCompilerSyntax" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSCommentMatchesSignature" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSComparisonWithNaN" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSConsecutiveCommasInArrayLiteral" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSConstantReassignment" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="JSDeprecatedSymbols" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="JSDuplicateCaseLabel" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSDuplicatedDeclaration" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSEqualityComparisonWithCoercion" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSFileReferences" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSFunctionExpressionToArrowFunction" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="JSIgnoredPromiseFromCall" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="JSIncompatibleTypesComparison" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="JSJQueryEfficiency" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSJoinVariableDeclarationAndAssignment" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="JSLastCommaInArrayLiteral" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSLastCommaInObjectLiteral" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSMethodCanBeStatic" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="JSMismatchedCollectionQueryUpdate" enabled="false" level="WARNING" enabled_by_default="false">
<option name="queries" value="trace,write,forEach,length,size" />
<option name="updates" value="pop,push,shift,splice,unshift,add,insert,remove,reverse,copyWithin,fill,sort" />
</inspection_tool>
<inspection_tool class="JSMissingSwitchBranches" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="JSMissingSwitchDefault" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="JSNonASCIINames" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSObjectNullOrUndefined" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSOctalInteger" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="JSPotentiallyInvalidConstructorUsage" enabled="false" level="WARNING" enabled_by_default="false">
<option name="myConsiderUppercaseFunctionsToBeConstructors" value="true" />
</inspection_tool>
<inspection_tool class="JSPotentiallyInvalidTargetOfIndexedPropertyAccess" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSPotentiallyInvalidUsageOfClassThis" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSPotentiallyInvalidUsageOfThis" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSPrimitiveTypeWrapperUsage" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSRedundantSwitchStatement" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="JSReferencingMutableVariableFromClosure" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSRemoveUnnecessaryParentheses" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="JSStringConcatenationToES6Template" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="JSSuspiciousEqPlus" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSSuspiciousNameCombination" enabled="false" level="WARNING" enabled_by_default="false">
<group names="x,width,left,right" />
<group names="y,height,top,bottom" />
<exclude classes="Math" />
</inspection_tool>
<inspection_tool class="JSSwitchVariableDeclarationIssue" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSTestFailedLine" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSTypeOfValues" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSUndeclaredVariable" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="JSUndefinedPropertyAssignment" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="JSUnnecessarySemicolon" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSUnreachableSwitchBranches" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSUnresolvedExtXType" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSUnresolvedFunction" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="JSUnresolvedLibraryURL" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSUnresolvedVariable" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="JSUnusedAssignment" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSUnusedGlobalSymbols" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSUnusedLocalSymbols" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSUrlImportUsage" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="JSValidateJSDoc" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSValidateTypes" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="JSVoidFunctionReturnValueUsed" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="JSXNamespaceValidation" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="JSXUnresolvedComponent" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="KarmaConfigFile" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="LanguageDetectionInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="LoopStatementThatDoesntLoopJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="NodeCoreCodingAssistance" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="NpmUsedModulesInstalled" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="PackageJsonMismatchedDependency" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PointlessArithmeticExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PointlessBooleanExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ReservedWordUsedAsNameJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ReturnFromFinallyBlockJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ShiftOutOfRangeJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SillyAssignmentJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
<inspection_tool class="SuspiciousTypeOfGuard" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ThisExpressionReferencesGlobalObjectJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ThrowFromFinallyBlockJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="TrivialConditionalJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="TrivialIfJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="TypeScriptAbstractClassConstructorCanBeMadeProtected" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="TypeScriptCheckImport" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="TypeScriptConfig" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="TypeScriptDuplicateUnionOrIntersectionType" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="TypeScriptExplicitMemberType" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="TypeScriptFieldCanBeMadeReadonly" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="TypeScriptJSXUnresolvedComponent" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="TypeScriptLibrary" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="TypeScriptMissingAugmentationImport" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="TypeScriptMissingConfigOption" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="TypeScriptRedundantGenericType" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="TypeScriptSmartCast" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="TypeScriptSuspiciousConstructorParameterAssignment" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="TypeScriptUMDGlobal" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="TypeScriptUnresolvedFunction" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="TypeScriptUnresolvedVariable" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="TypeScriptValidateGenericTypes" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="TypeScriptValidateJSTypes" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="TypeScriptValidateTypes" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="UnnecessaryContinueJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="UnnecessaryLabelJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="UnnecessaryLabelOnBreakStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="UnnecessaryLabelOnContinueStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="UnnecessaryLocalVariableJS" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_ignoreImmediatelyReturnedVariables" value="false" />
<option name="m_ignoreAnnotatedVariables" value="false" />
</inspection_tool>
<inspection_tool class="UnnecessaryReturnJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="UnreachableCodeJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="UpdateDependencyToLatestVersion" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="WebpackConfigHighlighting" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="WithStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
</profile>
</component>
/trunk/.idea/jsLinters/jshint.xml
0,0 → 1,16
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JSHintConfiguration" version="2.13.0" use-config-file="true" use-custom-config-file="true" custom-config-file-path="$PROJECT_DIR$/vendor/components/jqueryui/ui/.jshintrc">
<option bitwise="true" />
<option browser="true" />
<option curly="true" />
<option eqeqeq="true" />
<option forin="true" />
<option maxerr="50" />
<option noarg="true" />
<option noempty="true" />
<option nonew="true" />
<option strict="true" />
<option undef="true" />
</component>
</project>
/trunk/.idea/modules.xml
0,0 → 1,8
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/trunk.iml" filepath="$PROJECT_DIR$/.idea/trunk.iml" />
</modules>
</component>
</project>
/trunk/.idea/php.xml
0,0 → 1,49
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MessDetectorOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCSFixerOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCodeSnifferOptionsConfiguration">
<option name="highlightLevel" value="WARNING" />
<option name="transferred" value="true" />
</component>
<component name="PhpIncludePathManager">
<include_path>
<path value="$PROJECT_DIR$/vendor/tinymce/tinymce" />
<path value="$PROJECT_DIR$/vendor/firebase/php-jwt" />
<path value="$PROJECT_DIR$/vendor/gedmarc/layout" />
<path value="$PROJECT_DIR$/vendor/composer" />
<path value="$PROJECT_DIR$/vendor/phpseclib/phpseclib" />
<path value="$PROJECT_DIR$/vendor/components/jqueryui" />
<path value="$PROJECT_DIR$/vendor/script47/bs5-utils" />
<path value="$PROJECT_DIR$/vendor/components/jquery" />
<path value="$PROJECT_DIR$/vendor/matthiasmullie/path-converter" />
<path value="$PROJECT_DIR$/vendor/matthiasmullie/minify" />
<path value="$PROJECT_DIR$/vendor/emn178/js-sha3" />
<path value="$PROJECT_DIR$/vendor/tweeb/tinymce-i18n" />
<path value="$PROJECT_DIR$/vendor/dcodeio/bcrypt.js" />
<path value="$PROJECT_DIR$/vendor/twbs/bootstrap" />
<path value="$PROJECT_DIR$/vendor/vakata/jstree" />
<path value="$PROJECT_DIR$/vendor/spamspan/spamspan" />
<path value="$PROJECT_DIR$/vendor/danielmarschall/oidconverter" />
<path value="$PROJECT_DIR$/vendor/danielmarschall/php-sha3" />
<path value="$PROJECT_DIR$/vendor/danielmarschall/vnag" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" />
<path value="$PROJECT_DIR$/vendor/danielmarschall/php_utils" />
<path value="$PROJECT_DIR$/vendor/paragonie/constant_time_encoding" />
<path value="$PROJECT_DIR$/vendor/danielmarschall/uuid_mac_utils" />
<path value="$PROJECT_DIR$/vendor/paragonie/random_compat" />
<path value="$PROJECT_DIR$/vendor/danielmarschall/fileformats" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="7.0" />
<component name="PhpStanOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PsalmOptionsConfiguration">
<option name="transferred" value="true" />
</component>
</project>
/trunk/.idea/trunk.iml
0,0 → 1,36
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/vendor/tinymce/tinymce" />
<excludeFolder url="file://$MODULE_DIR$/vendor/firebase/php-jwt" />
<excludeFolder url="file://$MODULE_DIR$/vendor/gedmarc/layout" />
<excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phpseclib/phpseclib" />
<excludeFolder url="file://$MODULE_DIR$/vendor/components/jqueryui" />
<excludeFolder url="file://$MODULE_DIR$/vendor/script47/bs5-utils" />
<excludeFolder url="file://$MODULE_DIR$/vendor/components/jquery" />
<excludeFolder url="file://$MODULE_DIR$/vendor/matthiasmullie/path-converter" />
<excludeFolder url="file://$MODULE_DIR$/vendor/matthiasmullie/minify" />
<excludeFolder url="file://$MODULE_DIR$/vendor/emn178/js-sha3" />
<excludeFolder url="file://$MODULE_DIR$/vendor/tweeb/tinymce-i18n" />
<excludeFolder url="file://$MODULE_DIR$/vendor/dcodeio/bcrypt.js" />
<excludeFolder url="file://$MODULE_DIR$/vendor/twbs/bootstrap" />
<excludeFolder url="file://$MODULE_DIR$/vendor/vakata/jstree" />
<excludeFolder url="file://$MODULE_DIR$/vendor/spamspan/spamspan" />
<excludeFolder url="file://$MODULE_DIR$/vendor/danielmarschall/oidconverter" />
<excludeFolder url="file://$MODULE_DIR$/vendor/danielmarschall/php-sha3" />
<excludeFolder url="file://$MODULE_DIR$/vendor/danielmarschall/vnag" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
<excludeFolder url="file://$MODULE_DIR$/vendor/danielmarschall/php_utils" />
<excludeFolder url="file://$MODULE_DIR$/vendor/paragonie/constant_time_encoding" />
<excludeFolder url="file://$MODULE_DIR$/vendor/danielmarschall/uuid_mac_utils" />
<excludeFolder url="file://$MODULE_DIR$/vendor/paragonie/random_compat" />
<excludeFolder url="file://$MODULE_DIR$/vendor/danielmarschall/fileformats" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
/trunk/.idea/workspace.xml
0,0 → 1,102
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AnalysisUIOptions">
<option name="ANALYZE_INJECTED_CODE" value="false" />
</component>
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="df2a484b-bed2-4376-a9d2-11f38408a62e" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ComposerSettings" doNotAsk="true" synchronizationState="SYNCHRONIZE">
<pharConfigPath>$PROJECT_DIR$/composer.json</pharConfigPath>
<execution />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="PhpWorkspaceProjectConfiguration">
<include_path>
<path value="$PROJECT_DIR$/vendor/tinymce/tinymce" />
<path value="$PROJECT_DIR$/vendor/firebase/php-jwt" />
<path value="$PROJECT_DIR$/vendor/gedmarc/layout" />
<path value="$PROJECT_DIR$/vendor/composer" />
<path value="$PROJECT_DIR$/vendor/phpseclib/phpseclib" />
<path value="$PROJECT_DIR$/vendor/components/jqueryui" />
<path value="$PROJECT_DIR$/vendor/script47/bs5-utils" />
<path value="$PROJECT_DIR$/vendor/components/jquery" />
<path value="$PROJECT_DIR$/vendor/matthiasmullie/path-converter" />
<path value="$PROJECT_DIR$/vendor/matthiasmullie/minify" />
<path value="$PROJECT_DIR$/vendor/emn178/js-sha3" />
<path value="$PROJECT_DIR$/vendor/tweeb/tinymce-i18n" />
<path value="$PROJECT_DIR$/vendor/dcodeio/bcrypt.js" />
<path value="$PROJECT_DIR$/vendor/twbs/bootstrap" />
<path value="$PROJECT_DIR$/vendor/vakata/jstree" />
<path value="$PROJECT_DIR$/vendor/spamspan/spamspan" />
<path value="$PROJECT_DIR$/vendor/danielmarschall/oidconverter" />
<path value="$PROJECT_DIR$/vendor/danielmarschall/php-sha3" />
<path value="$PROJECT_DIR$/vendor/danielmarschall/vnag" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" />
<path value="$PROJECT_DIR$/vendor/danielmarschall/php_utils" />
<path value="$PROJECT_DIR$/vendor/paragonie/constant_time_encoding" />
<path value="$PROJECT_DIR$/vendor/danielmarschall/uuid_mac_utils" />
<path value="$PROJECT_DIR$/vendor/paragonie/random_compat" />
<path value="$PROJECT_DIR$/vendor/danielmarschall/fileformats" />
</include_path>
</component>
<component name="ProblemsViewState">
<option name="selectedTabId" value="CurrentFile" />
</component>
<component name="ProjectId" id="2N1iLsvnSxtAjQSwVh6njExUvVK" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;last_opened_file_path&quot;: &quot;D:/SVN/OIDplus/trunk&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;run.code.analysis.last.selected.profile&quot;: &quot;pProject Default&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;Errors&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="SvnConfiguration">
<configuration>C:\Users\danie\AppData\Roaming\Subversion</configuration>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="df2a484b-bed2-4376-a9d2-11f38408a62e" name="Changes" comment="" />
<created>1678837935819</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1678837935819</updated>
<workItem from="1678837937240" duration="5602000" />
<workItem from="1678844463270" duration="60000" />
<workItem from="1678909665345" duration="14715000" />
<workItem from="1678925977020" duration="53000" />
<workItem from="1678997532226" duration="9394000" />
<workItem from="1679080899605" duration="1262000" />
<workItem from="1679253191500" duration="2860000" />
<workItem from="1679522068670" duration="9367000" />
<workItem from="1679603456581" duration="1368000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
</project>
/trunk/ajax.php
61,9 → 61,6
}
 
$json_out = $plugin->action($_REQUEST['action'], $params);
if (!is_array($json_out)) {
throw new OIDplusException(_L('Plugin with OID %1 did not output array of result data',$_REQUEST['plugin']));
}
if (!isset($json_out['status'])) $json_out['status'] = -1;
 
if (!OIDplus::baseconfig()->getValue('DISABLE_AJAX_TRANSACTIONS',false) && OIDplus::db()->transaction_supported()) {
/trunk/composer.json
120,7 → 120,8
"danielmarschall/php-sha3": "*@dev",
"tweeb/tinymce-i18n": "^2.0",
"phpseclib/phpseclib": "~3.0",
"script47/bs5-utils": "*"
"script47/bs5-utils": "*",
"ext-json": "*"
},
"config": {
"secure-http": false,
/trunk/dev/oidinfo_add_missing
25,10 → 25,10
die("OIDINFO_API_URL not available (API is currently not public)\n");
}
 
define('VERBOSE', false);
define('DEFAULT_EMAIL', 'oidra@viathinksoft.de');
define('ALL_OID_LIST', '/home/oidplus/all_oids.txt'); // contains all OIDs (non-public file)
define('DESIRED_ROOT', '1.3.6.1.4.1.37476');
const VERBOSE = false;
const DEFAULT_EMAIL = 'oidra@viathinksoft.de';
const ALL_OID_LIST = '/home/oidplus/all_oids.txt'; // contains all OIDs (non-public file)
const DESIRED_ROOT = '1.3.6.1.4.1.37476';
 
# ---
 
/trunk/dev/oidinfo_compare
22,8 → 22,8
 
OIDplus::init(true);
 
define('ALL_OID_LIST', '/home/oidplus/all_oids.txt'); // contains all OIDs (non-public file)
define('DESIRED_ROOT', '1.3.6.1.4.1.37476');
const ALL_OID_LIST = '/home/oidplus/all_oids.txt'; // contains all OIDs (non-public file)
const DESIRED_ROOT = '1.3.6.1.4.1.37476';
 
# ---
 
/trunk/dev/oidinfo_compare_asn1_iri_identifiers
25,10 → 25,10
die("OIDINFO_API_URL not available (API is currently not public)\n");
}
 
define('VERBOSE', false);
define('DEFAULT_EMAIL', 'oidra@viathinksoft.de');
define('ALL_OID_LIST', '/home/oidplus/all_oids.txt'); // contains all OIDs (non-public file)
define('DESIRED_ROOT', '1.3.6.1.4.1.37476');
const VERBOSE = false;
const DEFAULT_EMAIL = 'oidra@viathinksoft.de';
const ALL_OID_LIST = '/home/oidplus/all_oids.txt'; // contains all OIDs (non-public file)
const DESIRED_ROOT = '1.3.6.1.4.1.37476';
 
# ---
 
/trunk/dev/systemid_collider
18,7 → 18,7
* limitations under the License.
*/
 
define('TARGET_ID', '6175446'); // ViaThinkSoft RA
const TARGET_ID = '6175446'; // ViaThinkSoft RA
 
$config = array("digest_alg" => "sha512",
"private_key_bits" => 2048,
/trunk/dev/translation/message_regenerate.phps
109,8 → 109,7
$stats_translated = 0;
$stats_not_translated = 0;
 
$cont = '';
$cont .= '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'."\n";
$cont = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'."\n";
$cont .= '<translation'."\n";
$cont .= ' xmlns="urn:oid:1.3.6.1.4.1.37476.2.5.2.5.4.1"'."\n";
$cont .= ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'."\n";
/trunk/dev/translation/show_nontranslated_code.phps
22,9 → 22,7
 
// ---
 
$all_cont = '';
 
$all_cont .= "<?php\n";
$all_cont = "<?php\n";
$all_cont .= "__halt_compiler();\n"; // avoid that the FastPHP code explorer runs crazy
$all_cont .= "?>\n";
 
/trunk/includes/classes/OIDplus.class.php
24,29 → 24,86
// phpcs:enable PSR1.Files.SideEffects
 
class OIDplus extends OIDplusBaseClass {
/**
* @var OIDplusPagePlugin[]
*/
private static /*OIDplusPagePlugin[]*/ $pagePlugins = array();
/**
* @var OIDplusAuthPlugin[]
*/
private static /*OIDplusAuthPlugin[]*/ $authPlugins = array();
/**
* @var OIDplusLoggerPlugin[]
*/
private static /*OIDplusLoggerPlugin[]*/ $loggerPlugins = array();
/**
* @var OIDplusObjectTypePlugin[]
*/
private static /*OIDplusObjectTypePlugin[]*/ $objectTypePlugins = array();
/**
* @var string[]|OIDplusObject[] Classnames of OIDplusObject classes
*/
private static /*string[]*/ $enabledObjectTypes = array();
/**
* @var string[]|OIDplusObject[] Classnames of OIDplusObject classes
*/
private static /*string[]*/ $disabledObjectTypes = array();
/**
* @var OIDplusDatabasePlugin[]
*/
private static /*OIDplusDatabasePlugin[]*/ $dbPlugins = array();
/**
* @var OIDplusCaptchaPlugin[]
*/
private static /*OIDplusCaptchaPlugin[]*/ $captchaPlugins = array();
/**
* @var OIDplusSqlSlangPlugin[]
*/
private static /*OIDplusSqlSlangPlugin[]*/ $sqlSlangPlugins = array();
/**
* @var OIDplusLanguagePlugin[]
*/
private static /*OIDplusLanguagePlugin[]*/ $languagePlugins = array();
/**
* @var OIDplusDesignPlugin[]
*/
private static /*OIDplusDesignPlugin[]*/ $designPlugins = array();
 
/**
* @var bool
*/
protected static $html = true;
 
/*public*/ const PATH_RELATIVE = 1; // e.g. "../"
/*public*/ const PATH_ABSOLUTE = 2; // e.g. "http://www.example.com/oidplus/"
/*public*/ const PATH_ABSOLUTE_CANONICAL = 3; // e.g. "http://www.example.org/oidplus/" (if baseconfig CANONICAL_SYSTEM_URL is set)
/*public*/ const PATH_RELATIVE_TO_ROOT = 4; // e.g. "/oidplus/"
/*public*/ const PATH_RELATIVE_TO_ROOT_CANONICAL = 5; // e.g. "/oidplus/" (if baseconfig CANONICAL_SYSTEM_URL is set)
/**
* e.g. "../"
*/
/*public*/ const PATH_RELATIVE = 1;
 
// These plugin types can contain HTML code and therefore may
// emit (non-setup) CSS/JS code via their manifest.
// Note that design plugins may only output CSS, not JS.
/**
* e.g. "http://www.example.com/oidplus/"
*/
/*public*/ const PATH_ABSOLUTE = 2;
 
/**
* e.g. "http://www.example.org/oidplus/" (if baseconfig CANONICAL_SYSTEM_URL is set)
*/
/*public*/ const PATH_ABSOLUTE_CANONICAL = 3;
 
/**
* e.g. "/oidplus/"
*/
/*public*/ const PATH_RELATIVE_TO_ROOT = 4;
 
/**
* e.g. "/oidplus/" (if baseconfig CANONICAL_SYSTEM_URL is set)
*/
/*public*/ const PATH_RELATIVE_TO_ROOT_CANONICAL = 5;
 
/**
* These plugin types can contain HTML code and therefore may
* emit (non-setup) CSS/JS code via their manifest.
* Note that design plugins may only output CSS, not JS.
*/
/*public*/ const INTERACTIVE_PLUGIN_TYPES = array(
'publicPages',
'raPages',
57,9 → 114,16
 
const UUID_NAMEBASED_NS_Base64PubKey = 'fd16965c-8bab-11ed-8744-3c4a92df8582';
 
/**
* Private constructor (Singleton)
*/
private function __construct() {
}
 
/**
* @return bool
* @throws OIDplusException
*/
private static function insideSetup(): bool {
if (PHP_SAPI == 'cli') return false;
if (!isset($_SERVER['REQUEST_URI'])) return false;
70,9 → 134,12
 
private static $baseConfig = null;
private static $oldConfigFormatLoaded = false;
public static function baseConfig() {
$first_init = false;
 
/**
* @return OIDplusBaseConfig
* @throws OIDplusException, OIDplusConfigInitializationException
*/
public static function baseConfig(): OIDplusBaseConfig {
if ($first_init = is_null(self::$baseConfig)) {
self::$baseConfig = new OIDplusBaseConfig();
}
200,7 → 267,12
}
 
private static $config = null;
public static function config() {
 
/**
* @return OIDplusConfig
* @throws OIDplusException
*/
public static function config(): OIDplusConfig {
if ($first_init = is_null(self::$config)) {
self::$config = new OIDplusConfig();
}
302,7 → 374,11
}
 
private static $gui = null;
public static function gui() {
 
/**
* @return OIDplusGui
*/
public static function gui(): OIDplusGui {
if (is_null(self::$gui)) {
self::$gui = new OIDplusGui();
}
310,7 → 386,11
}
 
private static $authUtils = null;
public static function authUtils() {
 
/**
* @return OIDplusAuthUtils
*/
public static function authUtils(): OIDplusAuthUtils {
if (is_null(self::$authUtils)) {
self::$authUtils = new OIDplusAuthUtils();
}
318,7 → 398,11
}
 
private static $mailUtils = null;
public static function mailUtils() {
 
/**
* @return OIDplusMailUtils
*/
public static function mailUtils(): OIDplusMailUtils {
if (is_null(self::$mailUtils)) {
self::$mailUtils = new OIDplusMailUtils();
}
326,7 → 410,11
}
 
private static $cookieUtils = null;
public static function cookieUtils() {
 
/**
* @return OIDplusCookieUtils
*/
public static function cookieUtils(): OIDplusCookieUtils {
if (is_null(self::$cookieUtils)) {
self::$cookieUtils = new OIDplusCookieUtils();
}
334,7 → 422,11
}
 
private static $menuUtils = null;
public static function menuUtils() {
 
/**
* @return OIDplusMenuUtils
*/
public static function menuUtils(): OIDplusMenuUtils {
if (is_null(self::$menuUtils)) {
self::$menuUtils = new OIDplusMenuUtils();
}
342,7 → 434,11
}
 
private static $logger = null;
public static function logger() {
 
/**
* @return OIDplusLogger
*/
public static function logger(): OIDplusLogger {
if (is_null(self::$logger)) {
self::$logger = new OIDplusLogger();
}
352,7 → 448,9
// --- SQL slang plugin
 
/**
* @param OIDplusSqlSlangPlugin $plugin
* @return void
* @throws OIDplusException
*/
private static function registerSqlSlangPlugin(OIDplusSqlSlangPlugin $plugin) {
$name = $plugin::id();
369,11 → 467,18
self::$sqlSlangPlugins[$name] = $plugin;
}
 
public static function getSqlSlangPlugins() {
/**
* @return OIDplusSqlSlangPlugin[]
*/
public static function getSqlSlangPlugins(): array {
return self::$sqlSlangPlugins;
}
 
public static function getSqlSlangPlugin($id)/*: ?OIDplusSqlSlangPlugin*/ {
/**
* @param string $id
* @return OIDplusSqlSlangPlugin|null
*/
public static function getSqlSlangPlugin(string $id)/*: ?OIDplusSqlSlangPlugin*/ {
if (isset(self::$sqlSlangPlugins[$id])) {
return self::$sqlSlangPlugins[$id];
} else {
384,7 → 489,9
// --- Database plugin
 
/**
* @param OIDplusDatabasePlugin $plugin
* @return void
* @throws OIDplusException
*/
private static function registerDatabasePlugin(OIDplusDatabasePlugin $plugin) {
$name = $plugin::id();
401,11 → 508,18
self::$dbPlugins[$name] = $plugin;
}
 
public static function getDatabasePlugins() {
/**
* @return OIDplusDatabasePlugin[]
*/
public static function getDatabasePlugins(): array {
return self::$dbPlugins;
}
 
public static function getActiveDatabasePlugin() {
/**
* @return OIDplusDatabasePlugin
* @throws OIDplusException, OIDplusConfigInitializationException
*/
public static function getActiveDatabasePlugin(): OIDplusDatabasePlugin {
$db_plugin_name = OIDplus::baseConfig()->getValue('DATABASE_PLUGIN','');
if ($db_plugin_name === '') {
throw new OIDplusConfigInitializationException(_L('No database plugin selected in config file'));
418,8 → 532,16
throw new OIDplusConfigInitializationException(_L('Database plugin "%1" not found',$db_plugin_name));
}
 
/**
* @var OIDplusDatabaseConnection|null
*/
private static $dbMainSession = null;
public static function db() {
 
/**
* @return OIDplusDatabaseConnection
* @throws OIDplusException, OIDplusConfigInitializationException
*/
public static function db(): OIDplusDatabaseConnection {
if (is_null(self::$dbMainSession)) {
self::$dbMainSession = self::getActiveDatabasePlugin()->newConnection();
}
427,8 → 549,16
return self::$dbMainSession;
}
 
/**
* @var OIDplusDatabaseConnection|null
*/
private static $dbIsolatedSession = null;
public static function dbIsolated() {
 
/**
* @return OIDplusDatabaseConnection
* @throws OIDplusException, OIDplusConfigInitializationException
*/
public static function dbIsolated(): OIDplusDatabaseConnection {
if (is_null(self::$dbIsolatedSession)) {
self::$dbIsolatedSession = self::getActiveDatabasePlugin()->newConnection();
}
439,7 → 569,9
// --- CAPTCHA plugin
 
/**
* @param OIDplusCaptchaPlugin $plugin
* @return void
* @throws OIDplusException
*/
private static function registerCaptchaPlugin(OIDplusCaptchaPlugin $plugin) {
$name = $plugin::id();
456,11 → 588,18
self::$captchaPlugins[$name] = $plugin;
}
 
public static function getCaptchaPlugins() {
/**
* @return OIDplusCaptchaPlugin[]
*/
public static function getCaptchaPlugins(): array {
return self::$captchaPlugins;
}
 
public static function getActiveCaptchaPluginId() {
/**
* @return string
* @throws OIDplusException, OIDplusConfigInitializationException
*/
public static function getActiveCaptchaPluginId(): string {
$captcha_plugin_name = OIDplus::baseConfig()->getValue('CAPTCHA_PLUGIN', '');
 
if (OIDplus::baseConfig()->getValue('RECAPTCHA_ENABLED', false) && ($captcha_plugin_name === '')) {
473,7 → 612,11
return $captcha_plugin_name;
}
 
public static function getActiveCaptchaPlugin() {
/**
* @return OIDplusCaptchaPlugin
* @throws OIDplusException, OIDplusConfigInitializationException
*/
public static function getActiveCaptchaPlugin(): OIDplusCaptchaPlugin {
$captcha_plugin_name = OIDplus::getActiveCaptchaPluginId();
foreach (self::$captchaPlugins as $name => $plugin) {
if (strtolower($name) == strtolower($captcha_plugin_name)) {
486,6 → 629,7
// --- Page plugin
 
/**
* @param OIDplusPagePlugin $plugin
* @return void
*/
private static function registerPagePlugin(OIDplusPagePlugin $plugin) {
492,13 → 636,20
self::$pagePlugins[] = $plugin;
}
 
public static function getPagePlugins() {
/**
* @return OIDplusPagePlugin[]
*/
public static function getPagePlugins(): array {
return self::$pagePlugins;
}
 
// --- Auth plugin
 
public static function getAuthPluginByFoldername($foldername)/*: ?OIDplusAuthPlugin*/ {
/**
* @param string $foldername
* @return OIDplusAuthPlugin|null
*/
public static function getAuthPluginByFoldername(string $foldername)/*: ?OIDplusAuthPlugin*/ {
$plugins = OIDplus::getAuthPlugins();
foreach ($plugins as $plugin) {
if (basename($plugin->getPluginDirectory()) === $foldername) {
508,7 → 659,13
return null;
}
 
private static function checkRaAuthPluginAvailable($plugin_foldername, $must_hash) {
/**
* @param string $plugin_foldername
* @param bool $must_hash
* @return void
* @throws OIDplusException
*/
private static function checkRaAuthPluginAvailable(string $plugin_foldername, bool $must_hash) {
// if (!wildcard_is_dir(OIDplus::localpath().'plugins/'.'*'.'/auth/'.$plugin_foldername)) {
$plugin = OIDplus::getAuthPluginByFoldername($plugin_foldername);
if (is_null($plugin)) {
524,13 → 681,17
}
}
 
public static function getDefaultRaAuthPlugin($must_hash)/*: OIDplusAuthPlugin*/ {
/**
* @param bool $must_hash
* @return OIDplusAuthPlugin|null
* @throws OIDplusException
*/
public static function getDefaultRaAuthPlugin(bool $must_hash)/*: OIDplusAuthPlugin*/ {
// 1. Priority: Use the auth plugin the user prefers
$def_plugin_foldername = OIDplus::config()->getValue('default_ra_auth_method');
if (trim($def_plugin_foldername) !== '') {
OIDplus::checkRaAuthPluginAvailable($def_plugin_foldername, $must_hash);
$plugin = OIDplus::getAuthPluginByFoldername($def_plugin_foldername);
return $plugin;
return OIDplus::getAuthPluginByFoldername($def_plugin_foldername);
}
 
// 2. Priority: If empty (i.e. OIDplus may decide), choose the best ViaThinkSoft plugin that is supported on this system
565,7 → 726,10
}
 
/**
* @param OIDplusAuthPlugin $plugin
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
private static function registerAuthPlugin(OIDplusAuthPlugin $plugin) {
$reason = '';
580,8 → 744,6
throw new OIDplusException(_L('Auth plugin "%1" is erroneous: %2',basename($plugin->getPluginDirectory()),$e->getMessage()));
}
 
$authKey = $authInfo->getAuthKey();
 
$authInfo_AuthKeyDiff = clone $authInfo;
$authInfo_AuthKeyDiff->setAuthKey(strrev($authInfo_AuthKeyDiff->getAuthKey()));
 
595,7 → 757,10
self::$authPlugins[] = $plugin;
}
 
public static function getAuthPlugins() {
/**
* @return OIDplusAuthPlugin[]
*/
public static function getAuthPlugins(): array {
return self::$authPlugins;
}
 
602,6 → 767,7
// --- Language plugin
 
/**
* @param OIDplusLanguagePlugin $plugin
* @return void
*/
private static function registerLanguagePlugin(OIDplusLanguagePlugin $plugin) {
608,7 → 774,10
self::$languagePlugins[] = $plugin;
}
 
public static function getLanguagePlugins() {
/**
* @return OIDplusLanguagePlugin[]
*/
public static function getLanguagePlugins(): array {
return self::$languagePlugins;
}
 
615,6 → 784,7
// --- Design plugin
 
/**
* @param OIDplusDesignPlugin $plugin
* @return void
*/
private static function registerDesignPlugin(OIDplusDesignPlugin $plugin) {
621,11 → 791,18
self::$designPlugins[] = $plugin;
}
 
public static function getDesignPlugins() {
/**
* @return OIDplusDesignPlugin[]
*/
public static function getDesignPlugins(): array {
return self::$designPlugins;
}
 
public static function getActiveDesignPlugin() {
/**
* @return OIDplusDesignPlugin|null
* @throws OIDplusException
*/
public static function getActiveDesignPlugin()/*: ?OIDplusDesignPlugin*/ {
$plugins = OIDplus::getDesignPlugins();
foreach ($plugins as $plugin) {
if ((basename($plugin->getPluginDirectory())) == OIDplus::config()->getValue('design','default')) {
638,6 → 815,7
// --- Logger plugin
 
/**
* @param OIDplusLoggerPlugin $plugin
* @return void
*/
private static function registerLoggerPlugin(OIDplusLoggerPlugin $plugin) {
644,7 → 822,10
self::$loggerPlugins[] = $plugin;
}
 
public static function getLoggerPlugins() {
/**
* @return OIDplusLoggerPlugin[]
*/
public static function getLoggerPlugins(): array {
return self::$loggerPlugins;
}
 
651,7 → 832,9
// --- Object type plugin
 
/**
* @param OIDplusObjectTypePlugin $plugin
* @return void
* @throws OIDplusException
*/
private static function registerObjectTypePlugin(OIDplusObjectTypePlugin $plugin) {
self::$objectTypePlugins[] = $plugin;
661,7 → 844,9
}
 
/**
* @param string|OIDplusObject $ot Object type class name (OIDplusObject)
* @return void
* @throws OIDplusException
*/
private static function registerObjectType($ot) {
$ns = $ot::ns();
692,7 → 877,6
$enabled_ary = empty($enabled) ? array() : explode(';', $enabled);
$enabled_ary = array_map('trim', $enabled_ary);
 
$do_enable = false;
if (in_array($ns, $enabled_ary)) {
// If it is in the list of enabled object types, it is enabled (obviously)
$do_enable = true;
738,11 → 922,17
}
}
 
public static function getObjectTypePlugins() {
/**
* @return OIDplusObjectTypePlugin[]
*/
public static function getObjectTypePlugins(): array {
return self::$objectTypePlugins;
}
 
public static function getObjectTypePluginsEnabled() {
/**
* @return OIDplusObjectTypePlugin[]
*/
public static function getObjectTypePluginsEnabled(): array {
$res = array();
foreach (self::$objectTypePlugins as $plugin) {
$ot = $plugin::getObjectTypeClassName();
751,7 → 941,10
return $res;
}
 
public static function getObjectTypePluginsDisabled() {
/**
* @return OIDplusObjectTypePlugin[]
*/
public static function getObjectTypePluginsDisabled(): array {
$res = array();
foreach (self::$objectTypePlugins as $plugin) {
$ot = $plugin::getObjectTypeClassName();
760,17 → 953,26
return $res;
}
 
public static function getEnabledObjectTypes() {
/**
* @return string[]|OIDplusObject[] Classname of a OIDplusObject class
*/
public static function getEnabledObjectTypes(): array {
return self::$enabledObjectTypes;
}
 
public static function getDisabledObjectTypes() {
/**
* @return string[]|OIDplusObject[] Classname of a OIDplusObject class
*/
public static function getDisabledObjectTypes(): array {
return self::$disabledObjectTypes;
}
 
// --- Plugin handling functions
 
public static function getAllPlugins()/*: array*/ {
/**
* @return OIDplusPlugin[]
*/
public static function getAllPlugins(): array {
$res = array();
$res = array_merge($res, self::$pagePlugins);
$res = array_merge($res, self::$authPlugins);
780,11 → 982,14
$res = array_merge($res, self::$captchaPlugins);
$res = array_merge($res, self::$sqlSlangPlugins);
$res = array_merge($res, self::$languagePlugins);
$res = array_merge($res, self::$designPlugins);
return $res;
return array_merge($res, self::$designPlugins);
}
 
public static function getPluginByOid($oid)/*: ?OIDplusPlugin*/ {
/**
* @param string $oid
* @return OIDplusPlugin|null
*/
public static function getPluginByOid(string $oid)/*: ?OIDplusPlugin*/ {
$plugins = self::getAllPlugins();
foreach ($plugins as $plugin) {
if (oid_dotnotation_equal($plugin->getManifest()->getOid(), $oid)) {
794,7 → 999,11
return null;
}
 
public static function getPluginByClassName($classname)/*: ?OIDplusPlugin*/ {
/**
* @param string $classname
* @return OIDplusPlugin|null
*/
public static function getPluginByClassName(string $classname)/*: ?OIDplusPlugin*/ {
$plugins = self::getAllPlugins();
foreach ($plugins as $plugin) {
if (get_class($plugin) === $classname) {
806,7 → 1015,7
 
/**
* Checks if the plugin is disabled
* @return boolean true if plugin is enabled, false if plugin is disabled
* @return bool true if plugin is enabled, false if plugin is disabled
* @throws OIDplusException if the class name or config file (disabled setting) does not contain a namespace
*/
private static function pluginCheckDisabled($class_name): bool {
829,9 → 1038,12
}
 
/**
* @return array<OIDplusPluginManifest>|array<string,array<string,OIDplusPluginManifest>>
* @param string $pluginFolderMasks
* @param bool $flat
* @return OIDplusPluginManifest[]|array<string,array<string,OIDplusPluginManifest>>
* @throws OIDplusException
*/
public static function getAllPluginManifests($pluginFolderMasks='*', $flat=true): array {
public static function getAllPluginManifests(string $pluginFolderMasks='*', bool $flat=true): array {
$out = array();
// Note: glob() will sort by default, so we do not need a page priority attribute.
// So you just need to use a numeric plugin directory prefix (padded).
879,7 → 1091,7
if ($flat) {
$out[] = $manifest;
} else {
$plugintype_folder = basename(dirname(dirname($ini)));
$plugintype_folder = basename(dirname($ini, 2));
$pluginname_folder = basename(dirname($ini));
 
if (!isset($out[$plugintype_folder])) $out[$plugintype_folder] = array();
891,7 → 1103,13
}
 
/**
* @return array<string>
* @param $pluginDirName
* @param $expectedPluginClass
* @param $registerCallback
* @return string[]
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
* @throws \ReflectionException
*/
public static function registerAllPlugins($pluginDirName, $expectedPluginClass, $registerCallback): array {
$out = array();
1027,7 → 1245,14
 
// --- Initialization of OIDplus
 
public static function init($html=true, $keepBaseConfig=true) {
/**
* @param bool $html
* @param bool $keepBaseConfig
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public static function init(bool $html=true, bool $keepBaseConfig=true) {
self::$html = $html;
 
// Reset internal state, so we can re-init verything if required
1260,7 → 1485,7
foreach ($http_headers as $name => $val) {
 
// Plugins can remove standard OIDplus headers by setting the value to null.
if (is_null($val)) continue; /** @phpstan-ignore-line */
if (is_null($val)) continue;
 
// Some headers can be written as arrays to make it easier for plugin authors
// to manipulate/extend the contents.
1297,6 → 1522,9
 
// --- System URL, System ID, PKI, and other functions
 
/**
* @return void
*/
private static function recognizeSystemUrl() {
try {
$url = OIDplus::webpath(null,self::PATH_ABSOLUTE_CANONICAL);
1305,6 → 1533,9
}
}
 
/**
* @return false|int
*/
private static function getExecutingScriptPathDepth() {
if (PHP_SAPI == 'cli') {
global $argv;
1323,7 → 1554,10
return $steps_up;
}
 
public static function isSSL() {
/**
* @return bool
*/
public static function isSSL(): bool {
return isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === 'on');
}
 
1334,8 → 1568,9
* results in an absolute URL. OIDplus::PATH_ABSOLUTE_CANONICAL is an absolute URL,
* but a canonical path (set by base config setting CANONICAL_SYSTEM_URL) is preferred.
* @return string|false The URL, with guaranteed trailing path delimiter for directories
* @throws OIDplusException
*/
private static function getSystemUrl($mode) {
private static function getSystemUrl(int $mode) {
if ($mode === self::PATH_RELATIVE) {
$steps_up = self::getExecutingScriptPathDepth();
if ($steps_up === false) {
1379,6 → 1614,10
}
}
 
/**
* @param $pubKey
* @return false|string
*/
private static function pubKeyToRaw($pubKey) {
$m = array();
if (preg_match('@BEGIN PUBLIC KEY\\-+([^\\-]+)\\-+END PUBLIC KEY@ismU', $pubKey, $m)) {
1387,6 → 1626,10
return false;
}
 
/**
* @param $pubKey
* @return false|int
*/
private static function getSystemIdFromPubKey($pubKey) {
$rawData = self::pubKeyToRaw($pubKey);
if ($rawData === false) return false;
1393,6 → 1636,10
return smallhash($rawData);
}
 
/**
* @param $pubKey
* @return false|string
*/
private static function getSystemGuidFromPubKey($pubKey) {
$rawData = self::pubKeyToRaw($pubKey);
if ($rawData === false) return false;
1401,7 → 1648,13
}
 
private static $system_id_cache = null;
public static function getSystemId($oid=false) {
 
/**
* @param bool $oid
* @return false|string
* @throws OIDplusException
*/
public static function getSystemId(bool $oid=false) {
if (!is_null(self::$system_id_cache)) {
$out = self::$system_id_cache;
} else {
1418,6 → 1671,11
}
 
private static $system_guid_cache = null;
 
/**
* @return false|string
* @throws OIDplusException
*/
public static function getSystemGuid() {
if (!is_null(self::$system_guid_cache)) {
$out = self::$system_guid_cache;
1434,6 → 1692,9
return $out;
}
 
/**
* @return array|string
*/
public static function getOpenSslCnf() {
// The following functions need a config file, otherway they don't work
// - openssl_csr_new
1451,10 → 1712,16
return __DIR__.'/../../vendor/phpseclib/phpseclib/phpseclib/openssl.cnf';
}
 
private static function getPrivKeyPassphraseFilename() {
/**
* @return string
*/
private static function getPrivKeyPassphraseFilename(): string {
return OIDplus::localpath() . 'userdata/privkey_secret.php';
}
 
/**
* @return void
*/
private static function tryCreatePrivKeyPassphrase() {
$file = self::getPrivKeyPassphraseFilename();
 
1471,6 → 1738,9
@file_put_contents($file, $cont);
}
 
/**
* @return string|false
*/
private static function getPrivKeyPassphrase() {
$file = self::getPrivKeyPassphraseFilename();
if (!file_exists($file)) return false;
1480,6 → 1750,10
return $m[1];
}
 
/**
* @return string|false
* @throws OIDplusException
*/
public static function getSystemPrivateKey() {
$privKey = OIDplus::config()->getValue('oidplus_private_key');
if ($privKey == '') return false;
1497,6 → 1771,10
return $privKey;
}
 
/**
* @return string|false
* @throws OIDplusException
*/
public static function getSystemPublicKey() {
$pubKey = OIDplus::config()->getValue('oidplus_public_key');
if ($pubKey == '') return false;
1503,7 → 1781,12
return $pubKey;
}
 
public static function getPkiStatus($try_generate=false) {
/**
* @param bool $try_generate
* @return bool
* @throws OIDplusException
*/
public static function getPkiStatus(bool $try_generate=false): bool {
if (!function_exists('openssl_pkey_new')) return false;
 
if ($try_generate) {
1574,6 → 1857,9
return verify_private_public_key($privKey, $pubKey);
}
 
/**
* @return string|void
*/
public static function getInstallType() {
$counter = 0;
 
1610,6 → 1896,9
}
}
 
/**
* @return void
*/
private static function recognizeVersion() {
try {
$ver_prev = OIDplus::config()->getValue("last_known_version");
1626,6 → 1915,9
}
}
 
/**
* @return false|string|null
*/
public static function getVersion() {
static $cachedVersion = null;
if (!is_null($cachedVersion)) {
1644,7 → 1936,7
}
 
if ($installType === 'git-wc') {
$ver = OIDplus::getGitsvnRevision(OIDplus::localpath());
$ver = OIDplus::getGitsvnRevision();
if ($ver)
return ($cachedVersion = 'svn-'.$ver);
}
1667,6 → 1959,11
const ENFORCE_SSL_YES = 1;
const ENFORCE_SSL_AUTO = 2;
private static $sslAvailableCache = null;
 
/**
* @return bool|void|null
* @throws OIDplusException, OIDplusConfigInitializationException
*/
public static function isSslAvailable() {
if (!is_null(self::$sslAvailableCache)) return self::$sslAvailableCache;
 
1749,11 → 2046,11
 
/**
* Gets a local path pointing to a resource
* @param string $target Target resource (file or directory must exist), or null to get the OIDplus base directory
* @param boolean $relative If true, the returning path is relative to the currently executed PHP file (not the CLI working directory)
* @param string|null $target Target resource (file or directory must exist), or null to get the OIDplus base directory
* @param bool $relative If true, the returning path is relative to the currently executed PHP file (not the CLI working directory)
* @return string|false The local path, with guaranteed trailing path delimiter for directories
*/
public static function localpath($target=null, $relative=false) {
public static function localpath(string $target=null, bool $relative=false) {
if (is_null($target)) {
$target = __DIR__.'/../../';
}
1778,21 → 2075,20
 
if (is_dir($target)) $res .= '/';
 
$res = str_replace('/', DIRECTORY_SEPARATOR, $res);
 
return $res;
return str_replace('/', DIRECTORY_SEPARATOR, $res);
}
 
/**
* Gets a URL pointing to a resource
* @param string $target Target resource (file or directory must exist), or null to get the OIDplus base directory
* @param int|boolean $mode If true or OIDplus::PATH_RELATIVE, the returning path is relative to the currently executed
* @param string|null $target Target resource (file or directory must exist), or null to get the OIDplus base directory
* @param int|bool $mode If true or OIDplus::PATH_RELATIVE, the returning path is relative to the currently executed
* PHP script (i.e. index.php , not the plugin PHP script!). False or OIDplus::PATH_ABSOLUTE is
* results in an absolute URL. OIDplus::PATH_ABSOLUTE_CANONICAL is an absolute URL,
* but a canonical path (set by base config setting CANONICAL_SYSTEM_URL) is preferred.
* @return string|false The URL, with guaranteed trailing path delimiter for directories
* @throws OIDplusException
*/
public static function webpath($target=null, $mode=self::PATH_ABSOLUTE_CANONICAL) {
public static function webpath(string $target=null, $mode=self::PATH_ABSOLUTE_CANONICAL) {
// backwards compatibility
if ($mode === true) $mode = self::PATH_RELATIVE;
if ($mode === false) $mode = self::PATH_ABSOLUTE;
1830,6 → 2126,10
return $res;
}
 
/**
* @return false|string
* @throws OIDplusException
*/
public static function canonicalURL() {
// First part: OIDplus system URL (or canonical system URL)
$sysurl = OIDplus::getSystemUrl(self::PATH_ABSOLUTE_CANONICAL);
1854,10 → 2154,18
}
 
private static $shutdown_functions = array();
 
/**
* @param $func
* @return void
*/
public static function register_shutdown_function($func) {
self::$shutdown_functions[] = $func;
}
 
/**
* @return void
*/
public static function invoke_shutdown() {
foreach (self::$shutdown_functions as $func) {
$func();
1864,7 → 2172,11
}
}
 
public static function getAvailableLangs() {
/**
* @return string[]
* @throws OIDplusException
*/
public static function getAvailableLangs(): array {
$langs = array();
foreach (OIDplus::getAllPluginManifests('language') as $pluginManifest) {
$code = $pluginManifest->getLanguageCode();
1873,7 → 2185,12
return $langs;
}
 
public static function getDefaultLang() {
/**
* @return string
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public static function getDefaultLang(): string {
static $thrownOnce = false; // avoid endless loop inside OIDplusConfigInitializationException
 
$lang = self::baseConfig()->getValue('DEFAULT_LANGUAGE', 'enus');
1890,6 → 2207,11
return $lang;
}
 
/**
* @return false|string
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public static function getCurrentLang() {
if (isset($_GET['lang'])) {
$lang = $_GET['lang'];
1900,10 → 2222,13
} else {
$lang = self::getDefaultLang();
}
$lang = substr(preg_replace('@[^a-z]@ismU', '', $lang),0,4); // sanitize
return $lang;
return substr(preg_replace('@[^a-z]@ismU', '', $lang),0,4); // sanitize
}
 
/**
* @return void
* @throws OIDplusException
*/
public static function handleLangArgument() {
if (isset($_GET['lang'])) {
// The "?lang=" argument is only for NoScript-Browsers/SearchEngines
1918,6 → 2243,11
}
 
private static $translationArray = array();
 
/**
* @param $translation_file
* @return array|mixed
*/
protected static function getTranslationFileContents($translation_file) {
// First, try the cache
$cache_file = __DIR__ . '/../../userdata/cache/translation_'.md5($translation_file).'.ser';
1939,7 → 2269,13
@touch($cache_file,filemtime($translation_file));
return $cac;
}
public static function getTranslationArray($requested_lang='*') {
 
/**
* @param string $requested_lang
* @return array
* @throws OIDplusException
*/
public static function getTranslationArray(string $requested_lang='*'): array {
foreach (OIDplus::getAllPluginManifests('language') as $pluginManifest) {
$lang = $pluginManifest->getLanguageCode();
if (strpos($lang,'/') !== false) continue; // just to be sure
1970,10 → 2306,16
return self::$translationArray;
}
 
/**
* @return mixed
*/
public static function getEditionInfo() {
return @parse_ini_file(__DIR__.'/../edition.ini', true)['Edition'];
}
 
/**
* @return false|string
*/
public static function findGitFolder() {
// Git command line saves git information in folder ".git"
// Plesk git saves git information in folder "../../../git/oidplus/" (or similar)
1995,7 → 2337,10
return false;
}
 
public static function getGitsvnRevision($dir='') {
/**
* @return false|string
*/
public static function getGitsvnRevision() {
try {
// tries command line and binary parsing
// requires vendor/danielmarschall/git_utils.inc.php
2014,7 → 2359,12
}
}
 
public static function prefilterQuery($static_node_id, $throw_exception) {
/**
* @param string $static_node_id
* @param bool $throw_exception
* @return string
*/
public static function prefilterQuery(string $static_node_id, bool $throw_exception): string {
// Let namespace be case-insensitive
$ary = explode(':', $static_node_id, 2);
$ary[0] = strtolower($ary[0]);
2028,18 → 2378,23
return $static_node_id;
}
 
public static function isCronjob() {
/**
* @return bool
*/
public static function isCronjob(): bool {
return explode('.',basename($_SERVER['SCRIPT_NAME']))[0] === 'cron';
}
 
/**
* Since OIDplus svn-184, entries in the database need to have a canonical ID
* If the ID is not canonical (e.g. GUIDs missing hyphens), the object cannot be opened in OIDplus
* This script re-canonizes the object IDs if required.
* In SVN Rev 856, the canonization for GUID, IPv4 and IPv6 have changed, requiring another
* re-canonization
* @return void
* @throws OIDplusException
*/
private static function recanonizeObjects() {
//
// Since OIDplus svn-184, entries in the database need to have a canonical ID
// If the ID is not canonical (e.g. GUIDs missing hyphens), the object cannot be opened in OIDplus
// This script re-canonizes the object IDs if required.
// In SVN Rev 856, the canonization for GUID, IPv4 and IPv6 have changed, requiring another
// re-canonization
//
$res = OIDplus::db()->query("select id from ###objects");
while ($row = $res->fetch_array()) {
$ida = $row['id'];
/trunk/includes/classes/OIDplusAltId.class.php
30,7 → 30,13
private $desc;
private $suffix;
 
function __construct($ns, $id, $desc, $suffix='') {
/**
* @param string $ns
* @param string $id
* @param string $desc
* @param string $suffix
*/
function __construct(string $ns, string $id, string $desc, string $suffix='') {
$this->ns = $ns;
$this->id = $id;
$this->desc = $desc;
37,19 → 43,31
$this->suffix = $suffix;
}
 
function getNamespace() {
/**
* @return string
*/
function getNamespace(): string {
return $this->ns;
}
 
function getId() {
/**
* @return string
*/
function getId(): string {
return $this->id;
}
 
function getDescription() {
/**
* @return string
*/
function getDescription(): string {
return $this->desc;
}
 
function getSuffix() {
/**
* @return string
*/
function getSuffix(): string {
return $this->suffix;
}
 
/trunk/includes/classes/OIDplusAuthContentStore.class.php
27,31 → 27,81
 
// Getter / Setter
 
public abstract function getValue($name, $default = NULL);
/**
* @param string $name
* @param mixed|null $default
* @return mixed|null
*/
public abstract function getValue(string $name, $default = NULL);
 
public abstract function setValue($name, $value);
/**
* @param string $name
* @param mixed $value
* @return void
*/
public abstract function setValue(string $name, $value);
 
public abstract function exists($name);
/**
* @param string $name
* @return bool
*/
public abstract function exists(string $name): bool;
 
public abstract function delete($name);
/**
* @param string $name
* @return void
*/
public abstract function delete(string $name);
 
public abstract static function getActiveProvider();
/**
* @return OIDplusAuthContentStore|null
* @throws OIDplusException
*/
public abstract static function getActiveProvider()/*: ?OIDplusAuthContentStore*/;
 
/**
* @return mixed
*/
public abstract function destroySession();
 
/**
* @return mixed
*/
public abstract function activate();
 
public abstract function raLoginEx($email, &$loginfo);
/**
* @param string $email
* @param string $loginfo
* @return void
*/
public abstract function raLoginEx(string $email, string &$loginfo);
 
public abstract function raLogoutEx($email, &$loginfo);
/**
* @param string $email
* @param string $loginfo
* @return void
*/
public abstract function raLogoutEx(string $email, string &$loginfo);
 
public abstract function adminLoginEx(&$loginfo);
/**
* @param string $loginfo
* @return void
*/
public abstract function adminLoginEx(string &$loginfo);
 
public abstract function adminLogoutEx(&$loginfo);
/**
* @param string $loginfo
* @return void
*/
public abstract function adminLogoutEx(string &$loginfo);
 
// RA authentication functions (low-level)
 
public function raLogin($email) {
/**
* @param string $email
* @return void
*/
public function raLogin(string $email) {
if (strpos($email, '|') !== false) return;
 
$list = $this->getValue('oidplus_ra_logged_in');
64,7 → 114,11
$this->setValue('oidplus_ra_logged_in', $list);
}
 
public function raLogout($email) {
/**
* @param string $email
* @return void
*/
public function raLogout(string $email) {
$list = $this->getValue('oidplus_ra_logged_in');
if (is_null($list)) $list = '';
 
76,11 → 130,17
$this->setValue('oidplus_ra_logged_in', $list);
}
 
public function raNumLoggedIn() {
/**
* @return int
*/
public function raNumLoggedIn(): int {
return count($this->loggedInRaList());
}
 
public function loggedInRaList() {
/**
* @return OIDplusRA[]
*/
public function loggedInRaList(): array {
$list = $this->getValue('oidplus_ra_logged_in');
if (is_null($list)) $list = '';
 
92,7 → 152,11
return $res;
}
 
public function isRaLoggedIn($email) {
/**
* @param string $email
* @return bool
*/
public function isRaLoggedIn(string $email) {
foreach ($this->loggedInRaList() as $ra) {
if ($email == $ra->raEmail()) return true;
}
101,15 → 165,24
 
// Admin authentication functions (low-level)
 
/**
* @return void
*/
public function adminLogin() {
$this->setValue('oidplus_admin_logged_in', 1);
}
 
/**
* @return void
*/
public function adminLogout() {
$this->setValue('oidplus_admin_logged_in', 0);
}
 
public function isAdminLoggedIn() {
/**
* @return bool
*/
public function isAdminLoggedIn(): bool {
return $this->getValue('oidplus_admin_logged_in') == 1;
}
 
/trunk/includes/classes/OIDplusAuthContentStoreDummy.class.php
30,19 → 30,37
 
// Override some abstract functions
 
public function getValue($name, $default = NULL) {
/**
* @param string $name
* @param mixed|null $default
* @return mixed|null
*/
public function getValue(string $name, $default = NULL) {
return isset($this->content[$name]) ? $this->content[$name] : $default;
}
 
public function setValue($name, $value) {
/**
* @param string $name
* @param mixed $value
* @return void
*/
public function setValue(string $name, $value) {
$this->content[$name] = $value;
}
 
public function exists($name) {
/**
* @param string $name
* @return bool
*/
public function exists(string $name): bool {
return isset($this->content[$name]);
}
 
public function delete($name) {
/**
* @param string $name
* @return void
*/
public function delete(string $name) {
unset($this->content[$name]);
}
 
/trunk/includes/classes/OIDplusAuthContentStoreJWT.class.php
31,12 → 31,23
const JWT_GENERATOR_LOGIN = 1; // "Remember me" login method
const JWT_GENERATOR_MANUAL = 2; // "Manually crafted" JWT tokens
 
private static function jwtGetBlacklistConfigKey($gen, $sub) {
/**
* @param int $gen OIDplusAuthContentStoreJWT::JWT_GENERATOR_...
* @param string $sub
* @return string
*/
private static function jwtGetBlacklistConfigKey(int $gen, string $sub): string {
// Note: Needs to be <= 50 characters!
return 'jwt_blacklist_gen('.$gen.')_sub('.trim(base64_encode(md5($sub,true)),'=').')';
}
 
public static function jwtBlacklist($gen, $sub) {
/**
* @param int $gen OIDplusAuthContentStoreJWT::JWT_GENERATOR_...
* @param string $sub
* @return void
* @throws OIDplusException
*/
public static function jwtBlacklist(int $gen, string $sub) {
$cfg = self::jwtGetBlacklistConfigKey($gen, $sub);
$bl_time = time()-1;
 
45,16 → 56,27
if ($gen === self::JWT_GENERATOR_LOGIN) $gen_desc = 'Login ("Remember me")';
if ($gen === self::JWT_GENERATOR_MANUAL) $gen_desc = 'Manually created';
 
OIDplus::config()->prepareConfigKey($cfg, 'Revoke timestamp of all JWT tokens for $sub with generator $gen ($gen_desc)', $bl_time, OIDplusConfig::PROTECTION_HIDDEN, function($value) {});
OIDplus::config()->prepareConfigKey($cfg, 'Revoke timestamp of all JWT tokens for $sub with generator $gen ($gen_desc)', "$bl_time", OIDplusConfig::PROTECTION_HIDDEN, function($value) {});
OIDplus::config()->setValue($cfg, $bl_time);
}
 
public static function jwtGetBlacklistTime($gen, $sub) {
/**
* @param int $gen OIDplusAuthContentStoreJWT::JWT_GENERATOR_...
* @param string $sub
* @return int
* @throws OIDplusException
*/
public static function jwtGetBlacklistTime(int $gen, string $sub): int {
$cfg = self::jwtGetBlacklistConfigKey($gen, $sub);
return OIDplus::config()->getValue($cfg,0);
return (int)OIDplus::config()->getValue($cfg,0);
}
 
private static function jwtSecurityCheck($contentProvider) {
/**
* @param OIDplusAuthContentStore $contentProvider
* @return void
* @throws OIDplusException
*/
private static function jwtSecurityCheck(OIDplusAuthContentStore $contentProvider) {
// Check if the token is intended for us
if ($contentProvider->getValue('aud','') !== OIDplus::getEditionInfo()['jwtaud']) {
throw new OIDplusException(_L('Token has wrong audience'));
140,11 → 162,18
 
// Override abstract functions
 
/**
* @return void
*/
public function activate() {
// Send cookie at the end of the HTTP request, in case there are multiple activate() calls
OIDplus::register_shutdown_function(array($this,'activateNow'));
}
 
/**
* @return void
* @throws OIDplusException
*/
public function activateNow() {
$token = $this->getJWTToken();
$exp = $this->getValue('exp',0);
151,21 → 180,40
OIDplus::cookieUtils()->setcookie(self::COOKIE_NAME, $token, $exp, false);
}
 
/**
* @return void
* @throws OIDplusException
*/
public function destroySession() {
OIDplus::cookieUtils()->unsetcookie(self::COOKIE_NAME);
}
 
public function raLogout($email) {
/**
* @param string $email
* @return void
* @throws OIDplusException
*/
public function raLogout(string $email) {
$gen = $this->getValue('oidplus_generator', -1);
if ($gen >= 0) self::jwtBlacklist($gen, $email);
parent::raLogout($email);
}
 
public function raLogoutEx($email, &$loginfo) {
/**
* @param string $email
* @param string $loginfo
* @return void
* @throws OIDplusException
*/
public function raLogoutEx(string $email, string &$loginfo) {
$this->raLogout($email);
$loginfo = 'from JWT session';
}
 
/**
* @return void
* @throws OIDplusException
*/
public function adminLogout() {
$gen = $this->getValue('oidplus_generator', -1);
if ($gen >= 0) self::jwtBlacklist($gen, 'admin');
172,13 → 220,23
parent::adminLogout();
}
 
public function adminLogoutEx(&$loginfo) {
/**
* @param string $loginfo
* @return void
* @throws OIDplusException
*/
public function adminLogoutEx(string &$loginfo) {
$this->adminLogout();
$loginfo = 'from JWT session';
}
 
private static $contentProvider = null;
public static function getActiveProvider() {
 
/**
* @return OIDplusAuthContentStore|null
* @throws OIDplusException
*/
public static function getActiveProvider()/*: ?OIDplusAuthContentStore*/ {
if (!self::$contentProvider) {
$jwt = '';
if (isset($_COOKIE[self::COOKIE_NAME])) $jwt = $_COOKIE[self::COOKIE_NAME];
212,7 → 270,13
return self::$contentProvider;
}
 
public function raLoginEx($email, &$loginfo) {
/**
* @param string $email
* @param string $loginfo
* @return void
* @throws OIDplusException
*/
public function raLoginEx(string $email, string &$loginfo) {
if (is_null(self::getActiveProvider())) {
$this->raLogin($email);
$loginfo = 'into new JWT session';
237,7 → 301,12
}
}
 
public function adminLoginEx(&$loginfo) {
/**
* @param string $loginfo
* @return void
* @throws OIDplusException
*/
public function adminLoginEx(string &$loginfo) {
if (is_null(self::getActiveProvider())) {
$this->adminLogin();
$loginfo = 'into new JWT session';
264,7 → 333,12
 
// Individual functions
 
public function loadJWT($jwt) {
/**
* @param string $jwt
* @return void
* @throws OIDplusException
*/
public function loadJWT(string $jwt) {
\Firebase\JWT\JWT::$leeway = 60; // leeway in seconds
if (OIDplus::getPkiStatus()) {
$pubKey = OIDplus::getSystemPublicKey();
278,7 → 352,11
}
}
 
public function getJWTToken() {
/**
* @return string
* @throws OIDplusException
*/
public function getJWTToken(): string {
$payload = $this->content;
$payload["iss"] = OIDplus::getEditionInfo()['jwtaud'];
$payload["aud"] = OIDplus::getEditionInfo()['jwtaud'];
/trunk/includes/classes/OIDplusAuthContentStoreSession.class.php
25,7 → 25,10
 
class OIDplusAuthContentStoreSession extends OIDplusAuthContentStore {
 
protected static function getSessionHandler() {
/**
* @return OIDplusSessionHandler
*/
protected static function getSessionHandler(): OIDplusSessionHandler {
static $sesHandler = null;
if (is_null($sesHandler)) {
$sesHandler = new OIDplusSessionHandler();
36,7 → 39,13
// Override abstract functions
# TODO: shouldn't we just include OIDplusSessionHandler in this class?
 
public function getValue($name, $default = NULL) {
/**
* @param string $name
* @param mixed|null $default
* @return mixed|null
* @throws OIDplusException
*/
public function getValue(string $name, $default = NULL) {
try {
return self::getSessionHandler()->getValue($name, $default);
} catch (\Exception $e) {
46,23 → 55,46
}
}
 
public function setValue($name, $value) {
return self::getSessionHandler()->setValue($name, $value);
/**
* @param string $name
* @param mixed $value
* @return void
* @throws OIDplusException
*/
public function setValue(string $name, $value) {
self::getSessionHandler()->setValue($name, $value);
}
 
public function exists($name) {
/**
* @param string $name
* @return bool
* @throws OIDplusException
*/
public function exists(string $name): bool {
return self::getSessionHandler()->exists($name);
}
 
public function delete($name) {
return self::getSessionHandler()->delete($name);
/**
* @param string $name
* @return void
* @throws OIDplusException
*/
public function delete(string $name) {
self::getSessionHandler()->delete($name);
}
 
/**
* @return void
* @throws OIDplusException
*/
public function destroySession() {
return self::getSessionHandler()->destroySession();
self::getSessionHandler()->destroySession();
}
 
public static function getActiveProvider() {
/**
* @return OIDplusAuthContentStoreSession|null
*/
public static function getActiveProvider()/*: ?OIDplusAuthContentStore*/ {
static $contentProvider = null;
 
if (!$contentProvider) {
74,7 → 106,12
return $contentProvider;
}
 
public function raLoginEx($email, &$loginfo) {
/**
* @param string $email
* @param string $loginfo
* @return void
*/
public function raLoginEx(string $email, string &$loginfo) {
$this->raLogin($email);
if (is_null(self::getActiveProvider())) {
$loginfo = 'into new PHP session';
83,7 → 120,11
}
}
 
public function adminLoginEx(&$loginfo) {
/**
* @param string $loginfo
* @return void
*/
public function adminLoginEx(string &$loginfo) {
$this->adminLogin();
if (is_null(self::getActiveProvider())) {
$loginfo = 'into new PHP session';
92,19 → 133,30
}
}
 
public function raLogoutEx($email, &$loginfo) {
/**
* @param string $email
* @param string $loginfo
* @return void
*/
public function raLogoutEx(string $email, string &$loginfo) {
$this->raLogout($email);
$loginfo = 'from PHP session';
}
 
public function adminLogoutEx(&$loginfo) {
/**
* @param string $loginfo
* @return void
*/
public function adminLogoutEx(string &$loginfo) {
$this->adminLogout();
$loginfo = 'from PHP session';
}
 
/**
* @return void
*/
public function activate() {
# Sessions automatically activate during setValue()
return;
}
 
}
/trunk/includes/classes/OIDplusAuthPlugin.class.php
24,8 → 24,28
// phpcs:enable PSR1.Files.SideEffects
 
abstract class OIDplusAuthPlugin extends OIDplusPlugin {
public abstract function verify(OIDplusRAAuthInfo $authKey, $check_password);
public abstract function generate($password): OIDplusRAAuthInfo;
public abstract function availableForHash(&$reason): bool;
public abstract function availableForVerify(&$reason): bool;
/**
* @param OIDplusRAAuthInfo $authInfo
* @param string $check_password
* @return bool
*/
public abstract function verify(OIDplusRAAuthInfo $authInfo, string $check_password): bool;
 
/**
* @param string $password
* @return OIDplusRAAuthInfo
*/
public abstract function generate(string $password): OIDplusRAAuthInfo;
 
/**
* @param string $reason
* @return bool
*/
public abstract function availableForHash(string &$reason): bool;
 
/**
* @param string $reason
* @return bool
*/
public abstract function availableForVerify(string &$reason): bool;
}
/trunk/includes/classes/OIDplusAuthUtils.class.php
27,6 → 27,11
 
// Useful functions
 
/**
* @param string $password
* @return string
* @throws OIDplusException
*/
private static function raPepperProcessing(string $password): string {
// Additional feature: Pepper
// The pepper is stored inside the base configuration file
43,7 → 48,7
} else {
$hmac = hash_hmac($algo, $password, $pepper);
}
if ($hmac === false) throw new OIDplusException(_L('HMAC failed'));
if ($hmac === "") throw new OIDplusException(_L('HMAC failed'));
return $hmac;
} else {
return $password;
52,6 → 57,10
 
// Content provider
 
/**
* @return string
* @throws OIDplusException
*/
public function getAuthMethod() {
$acs = $this->getAuthContentStore();
if (is_null($acs)) return 'null';
58,7 → 67,11
return get_class($acs);
}
 
protected function getAuthContentStore() {
/**
* @return OIDplusAuthContentStore|null
* @throws OIDplusException
*/
protected function getAuthContentStore()/*: ?OIDplusAuthContentStore*/ {
// Logged in via JWT
$tmp = OIDplusAuthContentStoreJWT::getActiveProvider();
if ($tmp) return $tmp;
72,7 → 85,13
return null;
}
 
public function getExtendedAttribute($name, $default=NULL) {
/**
* @param string $name
* @param mixed|null $default
* @return mixed
* @throws OIDplusException
*/
public function getExtendedAttribute(string $name, $default=NULL) {
$acs = $this->getAuthContentStore();
if (is_null($acs)) return $default;
return $acs->getValue($name, $default);
80,19 → 99,35
 
// RA authentication functions
 
public function raLogin($email) {
/**
* @param string $email
* @return void
* @throws OIDplusException
*/
public function raLogin(string $email) {
$acs = $this->getAuthContentStore();
if (is_null($acs)) return;
return $acs->raLogin($email);
$acs->raLogin($email);
}
 
public function raLogout($email) {
/**
* @param string $email
* @return void
* @throws OIDplusException
*/
public function raLogout(string $email) {
$acs = $this->getAuthContentStore();
if (is_null($acs)) return;
return $acs->raLogout($email);
$acs->raLogout($email);
}
 
public function raCheckPassword($ra_email, $password) {
/**
* @param string $ra_email
* @param string $password
* @return bool
* @throws OIDplusException
*/
public function raCheckPassword(string $ra_email, string $password): bool {
$ra = new OIDplusRA($ra_email);
 
// Get RA info from RA
111,13 → 146,21
return false;
}
 
public function raNumLoggedIn() {
/**
* @return int
* @throws OIDplusException
*/
public function raNumLoggedIn(): int {
$acs = $this->getAuthContentStore();
if (is_null($acs)) return 0;
return $acs->raNumLoggedIn();
}
 
public function loggedInRaList() {
/**
* @return OIDplusRA[]
* @throws OIDplusException
*/
public function loggedInRaList(): array {
if ($this->forceAllLoggedOut()) {
return array();
} else {
127,7 → 170,12
}
}
 
public function isRaLoggedIn($email) {
/**
* @param string $email
* @return bool
* @throws OIDplusException
*/
public function isRaLoggedIn(string $email): bool {
$acs = $this->getAuthContentStore();
if (is_null($acs)) return false;
return $acs->isRaLoggedIn($email);
134,7 → 182,15
}
 
// "High level" function including logging and checking for valid JWT alternations
public function raLoginEx($email, $remember_me, $origin='') {
 
/**
* @param string $email
* @param bool $remember_me
* @param string $origin
* @return void
* @throws OIDplusException
*/
public function raLoginEx(string $email, bool $remember_me, string $origin='') {
$loginfo = '';
$acs = $this->getAuthContentStore();
if (!is_null($acs)) {
163,12 → 219,17
OIDplus::logger()->log("[OK]RA($email)!", $logmsg);
}
 
public function raLogoutEx($email) {
/**
* @param string $email
* @return void
* @throws OIDplusException
*/
public function raLogoutEx(string $email) {
$loginfo = '';
 
$acs = $this->getAuthContentStore();
if (is_null($acs)) return;
$res = $acs->raLogoutEx($email, $loginfo);
$acs->raLogoutEx($email, $loginfo);
 
OIDplus::logger()->log("[OK]RA($email)!", "RA '$email' logged out ($loginfo)");
 
179,25 → 240,36
// Get a new token for the remaining users
$acs->activate();
}
 
return $res;
}
 
// Admin authentication functions
 
/**
* @return void
* @throws OIDplusException
*/
public function adminLogin() {
$acs = $this->getAuthContentStore();
if (is_null($acs)) return;
return $acs->adminLogin();
$acs->adminLogin();
}
 
/**
* @return void
* @throws OIDplusException
*/
public function adminLogout() {
$acs = $this->getAuthContentStore();
if (is_null($acs)) return;
return $acs->adminLogout();
$acs->adminLogout();
}
 
public function adminCheckPassword($password) {
/**
* @param string $password
* @return bool
* @throws OIDplusException
*/
public function adminCheckPassword(string $password): bool {
$cfgData = OIDplus::baseConfig()->getValue('ADMIN_PASSWORD', '');
if (empty($cfgData)) {
throw new OIDplusException(_L('No admin password set in %1','userdata/baseconfig/config.inc.php'));
227,7 → 299,11
return false;
}
 
public function isAdminLoggedIn() {
/**
* @return bool
* @throws OIDplusException
*/
public function isAdminLoggedIn(): bool {
if ($this->forceAllLoggedOut()) {
return false;
} else {
237,8 → 313,14
}
}
 
// "High level" function including logging and checking for valid JWT alternations
public function adminLoginEx($remember_me, $origin='') {
/**
* "High level" function including logging and checking for valid JWT alternations
* @param bool $remember_me
* @param string $origin
* @return void
* @throws OIDplusException
*/
public function adminLoginEx(bool $remember_me, string $origin='') {
$loginfo = '';
$acs = $this->getAuthContentStore();
if (!is_null($acs)) {
267,12 → 349,16
OIDplus::logger()->log("[OK]A!", $logmsg);
}
 
/**
* @return void
* @throws OIDplusException
*/
public function adminLogoutEx() {
$loginfo = '';
 
$acs = $this->getAuthContentStore();
if (is_null($acs)) return;
$res = $acs->adminLogoutEx($loginfo);
$acs->adminLogoutEx($loginfo);
 
if ($this->raNumLoggedIn() == 0) {
// Nobody here anymore. Destroy the cookie to make GDPR people happy
283,22 → 369,35
}
 
OIDplus::logger()->log("[OK]A!", "Admin logged out ($loginfo)");
return $res;
}
 
// Authentication keys for validating arguments (e.g. sent by mail)
 
public static function makeAuthKey($data) {
/**
* @param string $data
* @return string
* @throws OIDplusException
*/
public static function makeAuthKey(string $data): string {
return sha3_512_hmac($data, 'authkey:'.OIDplus::baseConfig()->getValue('SERVER_SECRET'), false);
}
 
public static function validateAuthKey($data, $auth_key) {
/**
* @param string $data
* @param string $auth_key
* @return bool
* @throws OIDplusException
*/
public static function validateAuthKey(string $data, string $auth_key): bool {
return hash_equals(self::makeAuthKey($data), $auth_key);
}
 
// "Veto" functions to force logout state
 
protected function forceAllLoggedOut() {
/**
* @return bool
*/
protected function forceAllLoggedOut(): bool {
if (isset($_SERVER['SCRIPT_FILENAME']) && (basename($_SERVER['SCRIPT_FILENAME']) == 'sitemap.php')) {
// The sitemap may not contain any confidential information,
// even if the user is logged in, because the admin could
314,18 → 413,32
 
private $enable_csrf = true;
 
/**
* @return void
*/
public function enableCSRF() {
$this->enable_csrf = true;
}
 
/**
* @return void
*/
public function disableCSRF() {
$this->enable_csrf = false;
}
 
public function genCSRFToken() {
/**
* @return string
* @throws \Random\RandomException
*/
public function genCSRFToken(): string {
return random_bytes_ex(64, false, false);
}
 
/**
* @return void
* @throws OIDplusException
*/
public function checkCSRF() {
if (!$this->enable_csrf) return;
 
346,7 → 459,12
 
// Generate RA passwords
 
public static function raGeneratePassword($password): OIDplusRAAuthInfo {
/**
* @param string $password
* @return OIDplusRAAuthInfo
* @throws OIDplusException
*/
public static function raGeneratePassword(string $password): OIDplusRAAuthInfo {
$plugin = OIDplus::getDefaultRaAuthPlugin(true);
return $plugin->generate(self::raPepperProcessing($password));
}
/trunk/includes/classes/OIDplusBaseClass.class.php
25,13 → 25,15
 
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.
 
/**
* 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.
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
return false;
}
 
/trunk/includes/classes/OIDplusBaseConfig.class.php
30,23 → 30,41
 
protected $data = array();
 
public function getValue($name, $default=null) {
/**
* @param string $name
* @param mixed|null $default
* @return mixed|null
*/
public function getValue(string $name, $default=null) {
return $this->exists($name) ? $this->data[$name] : $default;
}
 
public function setValue($name, $value) {
/**
* @param string $name
* @param mixed $value
* @return void
*/
public function setValue(string $name, $value) {
// Note: The value is only set at run time level!
// This function will NOT change the userdata/baseconfig/config.inc.php file!
$this->data[$name] = $value;
}
 
public function delete($name) {
/**
* @param string $name
* @return void
*/
public function delete(string $name) {
// Note: The value is only deleted at run time level!
// This function will NOT change the userdata/baseconfig/config.inc.php file!
unset($this->data[$name]);
}
 
public function exists($name) {
/**
* @param string $name
* @return bool
*/
public function exists(string $name): bool {
return isset($this->data[$name]);
}
 
/trunk/includes/classes/OIDplusCaptchaPlugin.class.php
25,14 → 25,33
 
abstract class OIDplusCaptchaPlugin extends OIDplusPlugin {
 
/**
* @return string
*/
public abstract static function id(): string; // this is the name that is set to the configuration value OIDplus::baseConfig()->getValue('CAPTCHA_PLUGIN') to identify the CAPTCHA plugin
 
/**
* @return bool
*/
public abstract function isVisible(): bool;
 
public abstract function captchaGenerate($header_text=null, $footer_text=null);
/**
* @param string|null $header_text
* @param string|null $footer_text
* @return string
*/
public abstract function captchaGenerate(string $header_text=null, string $footer_text=null): string;
 
public abstract function captchaVerify($params, $fieldname=null);
/**
* @param string[] $params
* @param string|null $fieldname
* @return void
*/
public abstract function captchaVerify(array $params, string $fieldname=null);
 
/**
* @return string
*/
public abstract static function setupHTML(): string;
 
}
/trunk/includes/classes/OIDplusConfig.class.php
41,7 → 41,16
protected $visibleSettings = array();
protected $validateCallbacks = array();
 
public function prepareConfigKey($name, $description, $init_value, $protection, $validateCallback) {
/**
* @param string $name
* @param string $description
* @param string $init_value
* @param int $protection
* @param $validateCallback
* @return void
* @throws OIDplusException
*/
public function prepareConfigKey(string $name, string $description, string $init_value, int $protection, $validateCallback) {
// Check if the protection flag is valid
switch ($protection) {
case OIDplusConfig::PROTECTION_EDITABLE:
111,11 → 120,19
}
}
 
/**
* @return void
* @throws OIDplusException
*/
public function clearCache() {
$this->configTableReadOnce = false;
$this->buildConfigArray();
}
 
/**
* @return void
* @throws OIDplusException
*/
protected function buildConfigArray() {
if ($this->configTableReadOnce) return;
 
134,7 → 151,13
$this->configTableReadOnce = true;
}
 
public function getValue($name, $default=null) {
/**
* @param string $name
* @param mixed|null $default
* @return mixed|null
* @throws OIDplusException
*/
public function getValue(string $name, $default=null) {
// Read all config settings once and write them in array $this->values
$this->buildConfigArray();
 
146,11 → 169,22
}
}
 
public function exists($name) {
/**
* @param string $name
* @return bool
* @throws OIDplusException
*/
public function exists(string $name): bool {
return !is_null($this->getValue($name, null));
}
 
public function setValue($name, $value) {
/**
* @param string $name
* @param mixed $value
* @return void
* @throws OIDplusException
*/
public function setValue(string $name, $value) {
// Read all config settings once and write them in array $this->values
$this->buildConfigArray();
 
172,7 → 206,13
$this->values[$name] = $value;
}
 
public function setValueNoCallback($name, $value) {
/**
* @param string $name
* @param string $value
* @return void
* @throws OIDplusException
*/
public function setValueNoCallback(string $name, string $value) {
// Read all config settings once and write them in array $this->values
$this->buildConfigArray();
 
188,7 → 228,12
$this->values[$name] = $value;
}
 
public function delete($name) {
/**
* @param string $name
* @return void
* @throws OIDplusException
*/
public function delete(string $name) {
if ($this->configTableReadOnce) {
if (isset($this->values[$name])) {
OIDplus::db()->query("delete from ###config where name = ?", array($name));
/trunk/includes/classes/OIDplusCookieUtils.class.php
25,11 → 25,20
 
class OIDplusCookieUtils extends OIDplusBaseClass {
 
public function unsetcookie($name) {
/**
* @param string $name
* @return void
* @throws OIDplusException
*/
public function unsetcookie(string $name) {
$this->setcookie($name, '', time()-9999, true);
}
 
private function getCookieDomain() {
/**
* @return string
* @throws OIDplusException
*/
private function getCookieDomain(): string {
$default_domain = ''; // ini_get('session.cookie_domain');
$domain = OIDplus::baseConfig()->getValue('COOKIE_DOMAIN', $default_domain);
if ($domain === '(auto)') {
43,7 → 52,11
return $domain;
}
 
private function getCookiePath() {
/**
* @return string
* @throws OIDplusException
*/
private function getCookiePath(): string {
$default_path = '/'; // ini_get('session.cookie_path');
$path = OIDplus::baseConfig()->getValue('COOKIE_PATH', $default_path);
if ($path === '(auto)') {
62,7 → 75,17
}
 
// TODO: There are several PHPSESSID cookies set. That's not very nice. We should collect the cookies and then at script ending only send the last definition one time.
public function setcookie($name, $value, $expires=0, $allowJS=false, $samesite=null, $forceInsecure=false) {
/**
* @param string $name
* @param string $value
* @param int $expires
* @param bool $allowJS
* @param string|null $samesite
* @param bool $forceInsecure
* @return void
* @throws OIDplusException
*/
public function setcookie(string $name, string $value, int $expires=0, bool $allowJS=false, /*?string*/ $samesite=null, bool $forceInsecure=false) {
$domain = $this->getCookieDomain();
$path = $this->getCookiePath();
$secure = $forceInsecure ? false : OIDplus::isSSL();
/trunk/includes/classes/OIDplusDatabaseConnection.class.php
29,21 → 29,62
protected /*?string*/ $last_query = null;
protected /*bool*/ $slangDetectionDone = false;
 
protected abstract function doQuery(string $sql, /*?array*/ $prepared_args=null): OIDplusQueryResult;
/**
* @param string $sql
* @param array|null $prepared_args
* @return OIDplusQueryResult
* @throws OIDplusException
*/
protected abstract function doQuery(string $sql, array $prepared_args=null): OIDplusQueryResult;
 
/**
* @return string
*/
public abstract function error(): string;
 
/**
* @return void
*/
public abstract function transaction_begin()/*: void*/;
 
/**
* @return void
*/
public abstract function transaction_commit()/*: void*/;
 
/**
* @return void
*/
public abstract function transaction_rollback()/*: void*/;
 
/**
* @return bool
*/
public abstract function transaction_supported(): bool;
 
/**
* @return int
*/
public abstract function transaction_level(): int;
 
/**
* @return void
*/
protected abstract function doConnect()/*: void*/;
 
/**
* @return void
*/
protected abstract function doDisconnect()/*: void*/;
 
/**
* @return OIDplusDatabasePlugin|null
*/
public function getPlugin()/*: ?OIDplusDatabasePlugin*/ {
$res = null;
$plugins = OIDplus::getDatabasePlugins();
foreach ($plugins as $plugin) {
if (get_class($this) == get_class($plugin::newConnection($this))) {
if (get_class($this) == get_class($plugin::newConnection())) {
return $plugin;
}
}
50,6 → 91,10
return $res;
}
 
/**
* @return int
* @throws OIDplusException
*/
public function insert_id(): int {
// This is the "fallback" variant. If your database provider (e.g. PDO) supports
// a function to detect the last inserted id, please override this
58,7 → 103,12
return $this->getSlang()->insert_id($this);
}
 
public final function getTable(string $sql) {
/**
* @param string $sql
* @return array[]
* @throws OIDplusException
*/
public final function getTable(string $sql): array {
$out = array();
$res = $this->query($sql);
while ($row = $res->fetch_array()) {
67,6 → 117,11
return $out;
}
 
/**
* @param string $sql
* @return mixed|null
* @throws OIDplusException
*/
public final function getScalar(string $sql) {
$res = $this->query($sql);
$row = $res->fetch_array();
73,6 → 128,12
return $row ? reset($row) : null;
}
 
/**
* @param string $sql
* @param array|null $prepared_args
* @return OIDplusQueryResult
* @throws OIDplusException
*/
public final function query(string $sql, /*?array*/ $prepared_args=null): OIDplusQueryResult {
 
$query_logfile = OIDplus::baseConfig()->getValue('QUERY_LOGFILE', '');
100,6 → 161,10
return $this->doQuery($sql, $prepared_args);
}
 
/**
* @return void
* @throws OIDplusException
*/
public final function connect()/*: void*/ {
if ($this->connected) return;
$this->beforeConnect();
110,6 → 175,9
$this->afterConnect();
}
 
/**
* @return void
*/
public final function disconnect()/*: void*/ {
if (!$this->connected) return;
$this->beforeDisconnect();
118,7 → 186,13
$this->afterDisconnect();
}
 
public function natOrder($fieldname, $order='asc'): string {
/**
* @param string $fieldname
* @param string $order
* @return string
* @throws OIDplusException
*/
public function natOrder(string $fieldname, string $order='asc'): string {
$slang = $this->getSlang();
if (!is_null($slang)) {
return $slang->natOrder($fieldname, $order);
133,14 → 207,31
}
}
 
/**
* @return void
*/
protected function beforeDisconnect()/*: void*/ {}
 
/**
* @return void
*/
protected function afterDisconnect()/*: void*/ {}
 
/**
* @return void
*/
protected function beforeConnect()/*: void*/ {}
 
/**
* @return void
*/
protected function afterConnect()/*: void*/ {}
 
/**
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
private function afterConnectMandatory()/*: void*/ {
// Check if the config table exists. This is important because the database version is stored in it
$this->initRequireTables(array('config'));
163,7 → 254,13
$this->getSlang();
}
 
private function initRequireTables($tableNames)/*: void*/ {
/**
* @param string[] $tableNames
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
private function initRequireTables(array $tableNames)/*: void*/ {
$msgs = array();
foreach ($tableNames as $tableName) {
$prefix = OIDplus::baseConfig()->getValue('TABLENAME_PREFIX', '');
176,7 → 273,11
}
}
 
public function tableExists($tableName): bool {
/**
* @param string $tableName
* @return bool
*/
public function tableExists(string $tableName): bool {
try {
// Attention: This query could interrupt transactions if Rollback-On-Error is enabled
$this->query("select 0 from ".$tableName." where 1=0");
186,14 → 287,25
}
}
 
/**
* @return bool
*/
public function isConnected(): bool {
return $this->connected;
}
 
public function init($html = true)/*: void*/ {
/**
* @param bool $html
* @return void
*/
public function init(bool $html = true)/*: void*/ {
$this->html = $html;
}
 
/**
* @return string
* @throws OIDplusException
*/
public function sqlDate(): string {
$slang = $this->getSlang();
if (!is_null($slang)) {
203,6 → 315,12
}
}
 
/**
* @param bool $mustExist
* @return OIDplusSqlSlangPlugin|null
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
protected function doGetSlang(bool $mustExist=true)/*: ?OIDplusSqlSlangPlugin*/ {
$res = null;
 
234,6 → 352,12
return $res;
}
 
/**
* @param bool $mustExist
* @return OIDplusSqlSlangPlugin|null
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public final function getSlang(bool $mustExist=true)/*: ?OIDplusSqlSlangPlugin*/ {
static /*?OIDplusSqlSlangPlugin*/ $slangCache = null;
 
/trunk/includes/classes/OIDplusDatabasePlugin.class.php
25,10 → 25,19
 
abstract class OIDplusDatabasePlugin extends OIDplusPlugin {
 
/**
* @return string
*/
public abstract static function id(): string; // this is the name that is set to the configuration value OIDplus::baseConfig()->getValue('DATABASE_PLUGIN') to identify the database plugin
 
/**
* @return OIDplusDatabaseConnection
*/
public abstract static function newConnection(): OIDplusDatabaseConnection;
 
/**
* @return string
*/
public abstract static function setupHTML(): string;
 
}
/trunk/includes/classes/OIDplusDesignPlugin.class.php
25,7 → 25,10
 
abstract class OIDplusDesignPlugin extends OIDplusPlugin {
 
function getThemeColor() {
/**
* @return string
*/
function getThemeColor(): string {
return ''; // no theme color
}
 
/trunk/includes/classes/OIDplusGetterSetterInterface.class.php
25,9 → 25,30
 
interface OIDplusGetterSetterInterface {
 
public function getValue($name, $default=null);
public function setValue($name, $value);
public function exists($name);
public function delete($name);
/**
* @param string $name
* @param mixed|null $default
* @return mixed|null
*/
public function getValue(string $name, $default=null);
 
/**
* @param string $name
* @param mixed $value
* @return void
*/
public function setValue(string $name, $value);
 
/**
* @param string $name
* @return bool
*/
public function exists(string $name): bool;
 
/**
* @param string $name
* @return void
*/
public function delete(string $name);
 
}
/trunk/includes/classes/OIDplusGui.class.php
25,7 → 25,11
 
class OIDplusGui extends OIDplusBaseClass {
 
public static function generateContentPage($id) {
/**
* @param string $id
* @return array
*/
public static function generateContentPage(string $id): array {
$out = array();
 
$handled = false;
56,7 → 60,12
return $out;
}
 
public static function link($goto, $new_window=false): string {
/**
* @param string $goto
* @param bool $new_window
* @return string
*/
public static function link(string $goto, bool $new_window=false): string {
if ($new_window) {
return 'href="?goto='.urlencode($goto).'" target="_blank"';
} else {
69,9 → 78,15
}
}
 
public static function getLanguageBox($goto, $useJs) {
$out = '';
$out .= '<div id="languageBox">';
/**
* @param string $goto
* @param bool $useJs
* @return string
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public static function getLanguageBox(string $goto, bool $useJs) {
$out = '<div id="languageBox">';
$langbox_entries = array();
$non_default_languages = 0;
foreach (OIDplus::getAllPluginManifests('language') as $pluginManifest) {
83,7 → 98,7
} else {
$class = 'lng_flag picture_ghost';
}
$add = (!is_null($goto)) ? '&amp;goto='.urlencode($goto) : '';
$add = ($goto != '') ? '&amp;goto='.urlencode($goto) : '';
 
$dirs = glob(OIDplus::localpath().'plugins/'.'*'.'/language/'.$code.'/');
 
101,7 → 116,12
return $out;
}
 
public static function html_exception_handler($exception) {
/**
* @param \Throwable $exception
* @return void
* @throws OIDplusException
*/
public static function html_exception_handler(\Throwable $exception) {
if ($exception instanceof OIDplusConfigInitializationException) {
echo '<!DOCTYPE HTML>';
echo '<html><head><title>'.htmlentities(_L('OIDplus initialization error')).'</title></head><body>';
125,9 → 145,12
}
}
 
private static function getExceptionTechInfo($exception) {
$out = '';
$out .= '<p><b>'.htmlentities(_L('Technical information about the problem')).':</b></p>';
/**
* @param \Throwable $exception
* @return string
*/
private static function getExceptionTechInfo(\Throwable $exception) {
$out = '<p><b>'.htmlentities(_L('Technical information about the problem')).':</b></p>';
$out .= '<pre>';
$out .= get_class($exception)."\n";
$out .= _L('at file %1 (line %2)',$exception->getFile(),"".$exception->getLine())."\n\n";
137,33 → 160,62
return $out;
}
 
/**
* @return string
*/
public function tabBarStart() {
return '<ul class="nav nav-tabs" id="myTab" role="tablist">';
}
 
/**
* @return string
*/
public function tabBarEnd() {
return '</ul>';
}
 
public function tabBarElement($id, $title, $active) {
/**
* @param string $id
* @param string $title
* @param bool $active
* @return string
*/
public function tabBarElement(string $id, string $title, bool $active) {
// data-bs-toggle is for Bootstrap 5
// data-toggle is for Bootstrap 4 (InternetExplorer compatibility)
return '<li class="nav-item"><a class="nav-link'.($active ? ' active' : '').'" id="'.$id.'-tab" data-bs-toggle="tab" data-toggle="tab" href="#'.$id.'" role="tab" aria-controls="'.$id.'" aria-selected="'.($active ? 'true' : 'false').'">'.$title.'</a></li>';
}
 
/**
* @return string
*/
public function tabContentStart() {
return '<div class="tab-content" id="myTabContent">';
}
 
/**
* @return string
*/
public function tabContentEnd() {
return '</div>';
}
 
public function tabContentPage($id, $content, $active) {
/**
* @param string $id
* @param string $content
* @param bool $active
* @return string
*/
public function tabContentPage(string $id, string $content, bool $active) {
return '<div class="tab-pane fade'.($active ? ' show active' : '').'" id="'.$id.'" role="tabpanel" aria-labelledby="'.$id.'-tab">'.$content.'</div>';
}
 
public function combine_systemtitle_and_pagetitle($systemtitle, $pagetitle) {
/**
* @param string $systemtitle
* @param string $pagetitle
* @return string
*/
public function combine_systemtitle_and_pagetitle(string $systemtitle, string $pagetitle) {
// Please also change the function in oidplus_base.js
if ($systemtitle == $pagetitle) {
return $systemtitle;
172,7 → 224,12
}
}
 
private function getCommonHeadElems($title) {
/**
* @param string $title
* @return string[]
* @throws OIDplusException
*/
private function getCommonHeadElems(string $title): array {
// Get theme color (color of title bar)
$design_plugin = OIDplus::getActiveDesignPlugin();
$theme_color = is_null($design_plugin) ? '' : $design_plugin->getThemeColor();
198,11 → 255,22
return $head_elems;
}
 
public function showMainPage($page_title_1, $page_title_2, $static_icon, $static_content, $extra_head_tags=array(), $static_node_id='') {
/**
* @param string $page_title_1
* @param string $page_title_2
* @param string $static_icon
* @param string $static_content
* @param array $extra_head_tags
* @param string $static_node_id
* @return string
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function showMainPage(string $page_title_1, string $page_title_2, string $static_icon, string $static_content, array $extra_head_tags=array(), string $static_node_id='') {
$head_elems = $this->getCommonHeadElems($page_title_1);
$head_elems = array_merge($head_elems, $extra_head_tags);
 
$plugins = OIDplus::getPagePlugins();
$plugins = OIDplus::getAllPlugins();
foreach ($plugins as $plugin) {
$plugin->htmlHeaderUpdate($head_elems);
}
274,7 → 342,7
 
# ---
 
$plugins = OIDplus::getPagePlugins();
$plugins = OIDplus::getAllPlugins();
foreach ($plugins as $plugin) {
$plugin->htmlPostprocess($out);
}
282,7 → 350,17
return $out;
}
 
public function showSimplePage($page_title_1, $page_title_2, $static_icon, $static_content, $extra_head_tags=array()) {
/**
* @param string $page_title_1
* @param string $page_title_2
* @param string $static_icon
* @param string $static_content
* @param string[] $extra_head_tags
* @return string
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function showSimplePage(string $page_title_1, string $page_title_2, string $static_icon, string $static_content, array $extra_head_tags=array()) {
$head_elems = $this->getCommonHeadElems($page_title_1);
$head_elems = array_merge($head_elems, $extra_head_tags);
 
320,7 → 398,7
 
$out .= '</div>';
 
$out .= OIDplus::gui()->getLanguageBox(null, true);
$out .= OIDplus::gui()->getLanguageBox('', true);
 
$out .= '</div>';
 
/trunk/includes/classes/OIDplusLanguagePlugin.class.php
25,7 → 25,10
 
abstract class OIDplusLanguagePlugin extends OIDplusPlugin {
 
public function getLanguageCode() {
/**
* @return string
*/
public function getLanguageCode(): string {
return $this->getManifest()->getLanguageCode();
}
 
/trunk/includes/classes/OIDplusLogger.class.php
25,29 → 25,32
 
class OIDplusLogger extends OIDplusBaseClass {
 
private static function split_maskcodes($maskcodes) {
// This function splits a mask code containing multiple components
// (delimited by '+' or '/') in single components
// It takes care that '+' and '/' inside brackets won't be used to split the codes
// Also, brackets can be escaped.
// The severity block (optional, must be standing in front of a component)
// is handled too. Inside the severity block, you may only use '/' to split components.
// The severity block will be implicitly repeated from the previous components if a component
// does not feature one.
//
// "[S]AAA(BBB)+CCC(DDD)" ==> array(
// array(array("S"),"AAA(BBB)"),
// array(array("S"),"CCC(DDD)")
// )
// "[S]AAA(B+BB)+CCC(DDD)" ==> array(
// array(array("S"),"AAA(B+BB)"),
// array(array("S"),"CCC(DDD)")
// )
// "[S]AAA(B\)BB)+CCC(DDD)" ==> array(
// array(array("S"),"AAA(B\)BB)"),
// array(array("S"),"CCC(DDD)")
// )
 
/**
* This function splits a mask code containing multiple components
* (delimited by '+' or '/') in single components
* It takes care that '+' and '/' inside brackets won't be used to split the codes
* Also, brackets can be escaped.
* The severity block (optional, must be standing in front of a component)
* is handled too. Inside the severity block, you may only use '/' to split components.
* The severity block will be implicitly repeated from the previous components if a component
* does not feature one.
*
* "[S]AAA(BBB)+CCC(DDD)" ==> array(
* array(array("S"),"AAA(BBB)"),
* array(array("S"),"CCC(DDD)")
* )
* "[S]AAA(B+BB)+CCC(DDD)" ==> array(
* array(array("S"),"AAA(B+BB)"),
* array(array("S"),"CCC(DDD)")
* )
* "[S]AAA(B\)BB)+CCC(DDD)" ==> array(
* array(array("S"),"AAA(B\)BB)"),
* array(array("S"),"CCC(DDD)")
* )
* @param string $maskcodes
* @return array|false
*/
private static function split_maskcodes(string $maskcodes) {
$out = array();
$sevs = array(); // Note: The severity block will repeat for the next components if not changed explicitly
 
170,7 → 173,11
 
private static $missing_plugin_queue = array();
 
public static function reLogMissing() {
/**
* @return bool
* @throws OIDplusException
*/
public static function reLogMissing(): bool {
while (count(self::$missing_plugin_queue) > 0) {
$item = self::$missing_plugin_queue[0];
if (!self::log_internal($item[0], $item[1], false)) return false;
179,12 → 186,25
return true;
}
 
public static function log($maskcodes, $event) {
/**
* @param string $maskcodes
* @param string $event
* @return bool
* @throws OIDplusException
*/
public static function log(string $maskcodes, string $event): bool {
self::reLogMissing(); // try to re-log failed requests
return self::log_internal($maskcodes, $event, true);
}
 
private static function log_internal($maskcodes, $event, $allow_delayed_log) {
/**
* @param string $maskcodes
* @param string $event
* @param bool $allow_delayed_log
* @return bool
* @throws OIDplusException
*/
private static function log_internal(string $maskcodes, string $event, bool $allow_delayed_log): bool {
$loggerPlugins = OIDplus::getLoggerPlugins();
if (count($loggerPlugins) == 0) {
// The plugin might not be initialized in OIDplus::init()
205,7 → 225,7
// so, instead of logging into 3 logbooks separately,
// you would create a mask code that tells the system
// to put the message into the logbooks of person X,
// house A and house B.
// house A, and house B.
 
$users = array();
$objects = array();
/trunk/includes/classes/OIDplusLoggerPlugin.class.php
25,7 → 25,18
 
abstract class OIDplusLoggerPlugin extends OIDplusPlugin {
 
public abstract static function log($event, $users, $objects)/*: bool*/;
public abstract static function available(&$reason)/*: bool*/;
/**
* @param string $event
* @param array<int,string>[] $users Array of "Severity => username"
* @param array<int,string>[] $objects Array of "Severity => objectname"
* @return bool
*/
public abstract static function log(string $event, array $users, array $objects): bool;
 
/**
* @param string $reason
* @return bool
*/
public abstract static function available(string &$reason): bool;
 
}
/trunk/includes/classes/OIDplusMailUtils.class.php
25,11 → 25,21
 
class OIDplusMailUtils extends OIDplusBaseClass {
 
public static function validMailAddress($email) {
/**
* @param string $email
* @return bool
*/
public static function validMailAddress(string $email): bool {
return !empty(filter_var($email, FILTER_VALIDATE_EMAIL));
}
 
public static function secureEmailAddress($email, $linktext, $level=1) {
/**
* @param string $email
* @param string $linktext
* @param int $level
* @return string|null
*/
public static function secureEmailAddress(string $email, string $linktext, int $level=1)/*: ?string*/ {
 
// see http://www.spamspan.de/
 
137,7 → 147,17
*/
}
 
public static function sendMail($to, $title, $msg, $cc='', $bcc='') {
/**
* @param string $to
* @param string $title
* @param string $msg
* @param string $cc
* @param string $bcc
* @return void
* @throws OIDplusException
* @throws OIDplusMailException
*/
public static function sendMail(string $to, string $title, string $msg, string $cc='', string $bcc='') {
$h = new \SecureMailer();
 
// DM 14.04.2022: Added Reply-To, because some servers might change the 'From' attribute (Anti-Spoof?)
/trunk/includes/classes/OIDplusMenuUtils.class.php
25,7 → 25,12
 
class OIDplusMenuUtils extends OIDplusBaseClass {
 
public static function nonjs_menu() {
/**
* @return string
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public static function nonjs_menu(): string {
$json = array();
 
$static_node_id = isset($_REQUEST['goto']) ? $_REQUEST['goto'] : 'oidplus:system';
56,12 → 61,15
return $out;
}
 
// req_id comes from jsTree via AJAX
// req_goto comes from the user (GET argument)
public static function json_tree($req_id, $req_goto) {
/**
* @param string $req_id comes from jsTree via AJAX
* @param string $req_goto comes from the user (GET argument)
* @return string[]
*/
public static function json_tree(string $req_id, string $req_goto): array {
$json = array();
 
if (!isset($req_id) || ($req_id == '#')) {
if ($req_id === '#') {
foreach (OIDplus::getPagePlugins() as $plugin) {
// Note: The system (OIDplusMenuUtils) does only show the menu of
// publicPage plugins. Menu entries for RAs and Admins are
74,13 → 82,16
$json = self::tree_populate($req_id);
}
 
self::addHrefIfRequired($json);
if (is_array($json)) self::addHrefIfRequired($json);
 
return $json;
}
 
protected static function addHrefIfRequired(&$json) {
if (!is_array($json)) return;
/**
* @param array $json
* @return void
*/
protected static function addHrefIfRequired(array &$json) {
foreach ($json as &$item) {
if (isset($item['id'])) {
if (!isset($item['conditionalselect']) || ($item['conditionalselect'] != 'false')) {
93,7 → 104,7
}
 
if (isset($item['children'])) {
self::addHrefIfRequired($item['children']);
if (is_array($item['children'])) self::addHrefIfRequired($item['children']);
}
}
}
/trunk/includes/classes/OIDplusObject.class.php
26,7 → 26,12
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!
/**
* Please overwrite this function!
* @param string $node_id
* @return OIDplusObject|null
*/
public static function parse(string $node_id)/*: ?OIDplusObject*/ {
foreach (OIDplus::getEnabledObjectTypes() as $ot) {
try {
$good = false;
45,7 → 50,11
return null;
}
 
public function /*OIDplusAltId[]*/ getAltIds() {
/**
* @return OIDplusAltId[]
* @throws OIDplusException
*/
public function getAltIds(): array {
if ($this->isRoot()) return array();
 
$ids = array();
82,7 → 91,7
// ... but not for OIDs below oid:1.3.6.1.4.1.37476.30.9, because these are the definition of these Information Object AIDs (which will be decoded in the OID object type plugin)
if (($this->ns() != 'aid') && !str_starts_with($this->nodeId(true), 'oid:1.3.6.1.4.1.37476.30.9.')) {
$sid = OIDplus::getSystemId(false);
if (!empty($sid)) {
if ($sid !== false) {
$ns_oid = $this->getPlugin()->getManifest()->getOid();
if (str_starts_with($ns_oid, '1.3.6.1.4.1.37476.2.5.2.')) {
// Official ViaThinkSoft object type plugins
95,7 → 104,7
$hash_payload = $ns_oid.':'.$this->nodeId(false);
}
 
$sid_hex = strtoupper(str_pad(dechex($sid),8,'0',STR_PAD_LEFT));
$sid_hex = strtoupper(str_pad(dechex((int)$sid),8,'0',STR_PAD_LEFT));
$obj_hex = strtoupper(str_pad(dechex(smallhash($hash_payload)),8,'0',STR_PAD_LEFT));
$aid = 'D276000186B20005'.$sid_hex.$obj_hex;
$ids[] = new OIDplusAltId('aid', $aid, _L('OIDplus Information Object Application Identifier (ISO/IEC 7816)'), ' ('._L('No PIX allowed').')');
105,56 → 114,114
return $ids;
}
 
public abstract static function objectTypeTitle();
/**
* @return string
*/
public abstract static function objectTypeTitle(): string;
 
public abstract static function objectTypeTitleShort();
/**
* @return string
*/
public abstract static function objectTypeTitleShort(): string;
 
/**
* @return OIDplusObjectTypePlugin|null
*/
public function getPlugin()/*: ?OIDplusObjectTypePlugin */ {
$res = null;
$plugins = OIDplus::getObjectTypePlugins();
foreach ($plugins as $plugin) {
if (get_class($this) == $plugin::getObjectTypeClassName($this)) {
if (get_class($this) == $plugin::getObjectTypeClassName()) {
return $plugin;
}
}
return $res;
return null;
}
 
public abstract static function ns();
/**
* @return string
*/
public abstract static function ns(): string;
 
public abstract static function root();
/**
* @return string
*/
public abstract static function root(): string;
 
public abstract function isRoot();
/**
* @return bool
*/
public abstract function isRoot(): bool;
 
public abstract function nodeId($with_ns=true);
/**
* @param bool $with_ns
* @return string
*/
public abstract function nodeId(bool $with_ns=true): string;
 
public abstract function addString($str);
/**
* @param string $str
* @return string mixed
* @throws OIDplusException
*/
public abstract function addString(string $str): string;
 
public abstract function crudShowId(OIDplusObject $parent);
/**
* @param OIDplusObject $parent
* @return string
*/
public abstract function crudShowId(OIDplusObject $parent): string;
 
public function crudInsertPrefix() {
/**
* @return string
*/
public function crudInsertPrefix(): string {
return '';
}
 
public function crudInsertSuffix() {
/**
* @return string
*/
public function crudInsertSuffix(): string {
return '';
}
 
public abstract function jsTreeNodeName(OIDplusObject $parent = null);
/**
* @param OIDplusObject|null $parent
* @return string
*/
public abstract function jsTreeNodeName(OIDplusObject $parent = null): string;
 
public abstract function defaultTitle();
/**
* @return string
*/
public abstract function defaultTitle(): string;
 
public abstract function isLeafNode();
/**
* @return bool
*/
public abstract function isLeafNode(): bool;
 
public abstract function getContentPage(&$title, &$content, &$icon);
/**
* @param string $title
* @param string $content
* @param string $icon
* @return void
*/
public abstract function getContentPage(string &$title, string &$content, string &$icon);
 
public static function getRaRoots($ra_email=null) {
if ($ra_email instanceof OIDplusRA) $ra_email = $ra_email->raEmail();
/**
* @param OIDplusRA|string|null $ra
* @return array
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public static function getRaRoots($ra=null) : array{
if ($ra instanceof OIDplusRA) $ra = $ra->raEmail();
 
$out = array();
 
if (!OIDplus::baseConfig()->getValue('OBJECT_CACHING', true)) {
if (!$ra_email) {
if (!$ra) {
$res = OIDplus::db()->query("select oChild.id as id, oChild.ra_email as child_mail, oParent.ra_email as parent_mail from ###objects as oChild ".
"left join ###objects as oParent on oChild.parent = oParent.id ".
"order by ".OIDplus::db()->natOrder('oChild.id'));
170,7 → 237,7
"where (".OIDplus::db()->getSlang()->isNullFunction('oParent.ra_email',"''")." <> ? and ".
OIDplus::db()->getSlang()->isNullFunction('oChild.ra_email',"''")." = ?) or ".
" (oParent.ra_email is null and ".OIDplus::db()->getSlang()->isNullFunction('oChild.ra_email',"''")." = ?) ".
"order by ".OIDplus::db()->natOrder('oChild.id'), array($ra_email, $ra_email, $ra_email));
"order by ".OIDplus::db()->natOrder('oChild.id'), array($ra, $ra, $ra));
while ($row = $res->fetch_array()) {
$x = self::parse($row['id']); // can be FALSE if namespace was disabled
if ($x) $out[] = $x;
177,11 → 244,11
}
}
} else {
if (!$ra_email) {
if (!$ra) {
$ra_mails_to_check = OIDplus::authUtils()->loggedInRaList();
if (count($ra_mails_to_check) == 0) return $out;
} else {
$ra_mails_to_check = array($ra_email);
$ra_mails_to_check = array($ra);
}
 
self::buildObjectInformationCache();
210,7 → 277,11
return $out;
}
 
public static function getAllNonConfidential() {
/**
* @return array
* @throws OIDplusException
*/
public static function getAllNonConfidential(): array {
$out = array();
 
if (!OIDplus::baseConfig()->getValue('OBJECT_CACHING', true)) {
239,7 → 310,11
return $out;
}
 
public function isConfidential() {
/**
* @return bool
* @throws OIDplusException
*/
public function isConfidential(): bool {
if (!OIDplus::baseConfig()->getValue('OBJECT_CACHING', true)) {
//static $confidential_cache = array();
$curid = $this->nodeId();
277,7 → 352,12
}
}
 
public function isChildOf(OIDplusObject $obj) {
/**
* @param OIDplusObject $obj
* @return bool
* @throws OIDplusException
*/
public function isChildOf(OIDplusObject $obj): bool {
if (!OIDplus::baseConfig()->getValue('OBJECT_CACHING', true)) {
$curid = $this->nodeId();
while (($res = OIDplus::db()->query("select parent from ###objects where id = ?", array($curid)))->any()) {
298,7 → 378,11
}
}
 
public function getChildren() {
/**
* @return array
* @throws OIDplusException
*/
public function getChildren(): array {
$out = array();
if (!OIDplus::baseConfig()->getValue('OBJECT_CACHING', true)) {
$res = OIDplus::db()->query("select id from ###objects where parent = ?", array($this->nodeId()));
322,18 → 406,28
return $out;
}
 
public function getRa() {
/**
* @return OIDplusRA
* @throws OIDplusException
*/
public function getRa(): OIDplusRA {
return new OIDplusRA($this->getRaMail());
}
 
public function userHasReadRights($ra_email=null) {
if ($ra_email instanceof OIDplusRA) $ra_email = $ra_email->raEmail();
/**
* @param OIDplusRA|string|null $ra
* @return bool
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function userHasReadRights($ra=null): bool {
if ($ra instanceof OIDplusRA) $ra = $ra->raEmail();
 
// If it is not confidential, everybody can read/see it.
// Note: This also checks if superior OIDs are confidential.
if (!$this->isConfidential()) return true;
 
if (!$ra_email) {
if (!$ra) {
// Admin may do everything
if (OIDplus::authUtils()->isAdminLoggedIn()) return true;
 
341,13 → 435,13
if (OIDplus::authUtils()->isRaLoggedIn($this->getRaMail())) return true;
} else {
// If this OID belongs to the requested RA, then they may see it.
if ($this->getRaMail() == $ra_email) return true;
if ($this->getRaMail() == $ra) return true;
}
 
// If someone has rights to an object below our confidential node,
// we let him see the confidential node,
// Otherwise he could not browse through to his own node.
$roots = $this->getRaRoots($ra_email);
$roots = $this->getRaRoots($ra);
foreach ($roots as $root) {
if ($root->isChildOf($this)) return true;
}
355,7 → 449,12
return false;
}
 
public function getIcon($row=null) {
/**
* @param array|null $row
* @return string|null
* @throws OIDplusException
*/
public function getIcon(array $row=null) {
$namespace = $this->ns(); // must use $this, not self::, otherwise the virtual method will not be called
 
if (is_null($row)) {
383,7 → 482,12
return $icon;
}
 
public static function exists(string $id) {
/**
* @param string $id
* @return bool
* @throws OIDplusException
*/
public static function exists(string $id): bool {
if (!OIDplus::baseConfig()->getValue('OBJECT_CACHING', true)) {
$res = OIDplus::db()->query("select id from ###objects where id = ?", array($id));
return $res->any();
393,8 → 497,12
}
}
 
// Get parent gives the next possible parent which is EXISTING in OIDplus
// It does not give the immediate parent
/**
* Get parent gives the next possible parent which is EXISTING in OIDplus
* It does not give the immediate parent
* @return OIDplusObject|null
* @throws OIDplusException
*/
public function getParent()/*: ?OIDplusObject*/ {
if (!OIDplus::baseConfig()->getValue('OBJECT_CACHING', true)) {
$res = OIDplus::db()->query("select parent from ###objects where id = ?", array($this->nodeId()));
422,11 → 530,15
$prev = $cur;
$cur = $cur->one_up();
if (!$cur) return null;
} while ($prev != $cur);
} while ($prev !== $cur);
}
return null;
}
 
/**
* @return false|string|null
* @throws OIDplusException
*/
public function getRaMail() {
if (!OIDplus::baseConfig()->getValue('OBJECT_CACHING', true)) {
$res = OIDplus::db()->query("select ra_email from ###objects where id = ?", array($this->nodeId()));
442,6 → 554,10
}
}
 
/**
* @return false|string|null
* @throws OIDplusException
*/
public function getTitle() {
if (!OIDplus::baseConfig()->getValue('OBJECT_CACHING', true)) {
$res = OIDplus::db()->query("select title from ###objects where id = ?", array($this->nodeId()));
457,6 → 573,10
}
}
 
/**
* @return false|string|null
* @throws OIDplusException
*/
public function getDescription() {
if (!OIDplus::baseConfig()->getValue('OBJECT_CACHING', true)) {
$res = OIDplus::db()->query("select description from ###objects where id = ?", array($this->nodeId()));
472,6 → 592,10
}
}
 
/**
* @return false|string|null
* @throws OIDplusException
*/
public function getComment() {
if (!OIDplus::baseConfig()->getValue('OBJECT_CACHING', true)) {
$res = OIDplus::db()->query("select comment from ###objects where id = ?", array($this->nodeId()));
487,6 → 611,10
}
}
 
/**
* @return false|string|null
* @throws OIDplusException
*/
public function getCreatedTime() {
if (!OIDplus::baseConfig()->getValue('OBJECT_CACHING', true)) {
$res = OIDplus::db()->query("select created from ###objects where id = ?", array($this->nodeId()));
502,6 → 630,10
}
}
 
/**
* @return false|string|null
* @throws OIDplusException
*/
public function getUpdatedTime() {
if (!OIDplus::baseConfig()->getValue('OBJECT_CACHING', true)) {
$res = OIDplus::db()->query("select updated from ###objects where id = ?", array($this->nodeId()));
517,34 → 649,52
}
}
 
public function userHasParentalWriteRights($ra_email=null) {
if ($ra_email instanceof OIDplusRA) $ra_email = $ra_email->raEmail();
/**
* @param OIDplusRA|string|null $ra
* @return bool
* @throws OIDplusException
*/
public function userHasParentalWriteRights($ra=null) {
if ($ra instanceof OIDplusRA) $ra = $ra->raEmail();
 
if (!$ra_email) {
if (!$ra) {
if (OIDplus::authUtils()->isAdminLoggedIn()) return true;
}
 
$objParent = $this->getParent();
if (!$objParent) return false;
return $objParent->userHasWriteRights($ra_email);
return $objParent->userHasWriteRights($ra);
}
 
public function userHasWriteRights($ra_email=null) {
if ($ra_email instanceof OIDplusRA) $ra_email = $ra_email->raEmail();
/**
* @param OIDplusRA|string|null $ra
* @return bool
* @throws OIDplusException
*/
public function userHasWriteRights($ra=null): bool {
if ($ra instanceof OIDplusRA) $ra = $ra->raEmail();
 
if (!$ra_email) {
if (!$ra) {
if (OIDplus::authUtils()->isAdminLoggedIn()) return true;
return OIDplus::authUtils()->isRaLoggedIn($this->getRaMail());
} else {
return $this->getRaMail() == $ra_email;
return $this->getRaMail() == $ra;
}
}
 
public function distance($to) {
/**
* @param string|OIDplusObject $to
* @return int|null
*/
public function distance($to)/*: ?int*/ {
return null; // not implemented
}
 
public function equals($obj) {
/**
* @param OIDplusObject $obj
* @return bool
*/
public function equals(OIDplusObject $obj): bool {
if (!is_object($obj)) $obj = OIDplusObject::parse($obj);
if (!($obj instanceof $this)) return false;
 
554,6 → 704,11
return $this->nodeId() == $obj->nodeId(); // otherwise compare the node id case-sensitive
}
 
/**
* @param string $id
* @return OIDplusObject|false
* @throws OIDplusException
*/
public static function findFitting(string $id) {
$obj = OIDplusObject::parse($id);
if (!$obj) return false; // e.g. if ObjectType plugin is disabled
577,7 → 732,10
}
}
 
public function one_up() {
/**
* @return OIDplusObject|null
*/
public function one_up()/*: ?OIDplusObject*/ {
return null; // not implemented
}
 
585,6 → 743,9
 
protected static $object_info_cache = null;
 
/**
* @return void
*/
public static function resetObjectInformationCache() {
self::$object_info_cache = null;
}
599,6 → 760,10
const CACHE_UPDATED = 'updated';
const CACHE_COMMENT = 'comment';
 
/**
* @return void
* @throws OIDplusException
*/
private static function buildObjectInformationCache() {
if (is_null(self::$object_info_cache)) {
self::$object_info_cache = array();
609,15 → 774,23
}
}
 
// override this function if you want your object type to save
// attachments in directories with easy names.
// Take care that your custom directory name will not allow jailbreaks (../) !
public function getDirectoryName() {
/**
* override this function if you want your object type to save
* attachments in directories with easy names.
* Take care that your custom directory name will not allow jailbreaks (../) !
* @return string
* @throws OIDplusException
*/
public function getDirectoryName(): string {
if ($this->isRoot()) return $this->ns();
return $this->getLegacyDirectoryName();
}
 
public final function getLegacyDirectoryName() {
/**
* @return string
* @throws OIDplusException
*/
public final function getLegacyDirectoryName(): string {
if ($this::ns() == 'oid') {
$oid = $this->nodeId(false);
} else {
641,7 → 814,11
}
}
 
public static function treeIconFilename($mode) {
/**
* @param string $mode
* @return string
*/
public static function treeIconFilename(string $mode): string {
// for backwards-compatibility with older plugins
return 'img/treeicon_'.$mode.'.png';
}
/trunk/includes/classes/OIDplusObjectTypePlugin.class.php
25,9 → 25,17
 
abstract class OIDplusObjectTypePlugin extends OIDplusPlugin {
 
public static abstract function getObjectTypeClassName();
/**
* @return string
*/
public static abstract function getObjectTypeClassName(): string;
 
public static function prefilterQuery($static_node_id, $throw_exception) {
/**
* @param string $static_node_id
* @param bool $throw_exception
* @return string
*/
public static function prefilterQuery(string $static_node_id, bool $throw_exception): string {
return $static_node_id;
}
 
/trunk/includes/classes/OIDplusPagePlugin.class.php
24,18 → 24,32
// phpcs:enable PSR1.Files.SideEffects
 
abstract class OIDplusPagePlugin extends OIDplusPlugin {
public function htmlHeaderUpdate(&$head_elems) {}
public function htmlPostprocess(&$html) {}
public function action($actionID, $params) {}
public function gui($id, &$out, &$handled) {}
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {}
public function tree_search($request) {}
public function handle404($request) { return false; }
 
public function csrfUnlock($actionID) {
// override this method if you want that your plugin
// can accept ajax.php requests from outside, without CSRF check
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
*/
public function gui(string $id, array &$out, bool &$handled) {}
 
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto To which node should be auto-expanded to? (Special values: ""=no auto expand. "*"=expand all.)
* @return bool
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
return false;
}
 
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
 
}
/trunk/includes/classes/OIDplusPagePluginPublic.class.php
25,6 → 25,10
 
abstract class OIDplusPagePluginPublic extends OIDplusPagePlugin {
 
public function publicSitemap(&$out) {}
/**
* @param string[] $out
* @return void
*/
public function publicSitemap(array &$out) {}
 
}
/trunk/includes/classes/OIDplusPlugin.class.php
25,13 → 25,19
 
abstract class OIDplusPlugin extends OIDplusBaseClass {
 
public final function getPluginDirectory() {
/**
* @return string
*/
public final function getPluginDirectory(): string {
$reflector = new \ReflectionClass(get_called_class());
$path = dirname($reflector->getFilename());
return $path;
}
 
public function getManifest() {
/**
* @return OIDplusPluginManifest|null
*/
public function getManifest()/*: ?OIDplusPluginManifest*/ {
$dir = $this->getPluginDirectory();
$ini = $dir.DIRECTORY_SEPARATOR.'manifest.xml';
$manifest = new OIDplusPluginManifest();
38,8 → 44,56
return $manifest->loadManifest($ini) ? $manifest : null;
}
 
public function init($html=true) {}
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {}
 
public function httpHeaderCheck(&$http_headers) {}
/**
* @param string $actionID
* @param array $params
* @return array
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
throw new OIDplusException(_L('Invalid action ID'));
}
 
/**
* override this method if you want that your plugin
* can accept ajax.php requests from outside, without CSRF check
* @param string $actionID
* @return bool
*/
public function csrfUnlock(string $actionID): bool {
return false;
}
 
/**
* @param string $request
* @return bool Handled?
*/
public function handle404(string $request): bool {
return false;
}
 
/**
* @param string $html
* @return void
*/
public function htmlPostprocess(string &$html) {}
 
/**
* @param array $head_elems
* @return void
*/
public function htmlHeaderUpdate(array &$head_elems) {}
 
/**
* @param string[] $http_headers
* @return void
*/
public function httpHeaderCheck(array &$http_headers) {}
 
}
/trunk/includes/classes/OIDplusPluginManifest.class.php
54,22 → 54,37
private $languageFlag = '';
private $languageMessages = '';
 
/**
* @return string
*/
public function getTypeClass(): string {
return $this->type;
}
 
/**
* @return string
*/
public function getName(): string {
return $this->name;
}
 
/**
* @return string
*/
public function getAuthor(): string {
return $this->author;
}
 
/**
* @return string
*/
public function getLicense(): string {
return $this->license;
}
 
/**
* @return string
*/
public function getVersion(): string {
if (str_starts_with($this->oid,'1.3.6.1.4.1.37476.2.5.2.4.') && ($this->version == '')) {
$sysver = OIDplus::getVersion();
85,20 → 100,29
}
}
 
/**
* @return string
*/
public function getHtmlDescription(): string {
return $this->htmlDescription;
}
 
/**
* @return string
*/
public function getOid(): string {
return $this->oid;
}
 
/**
* @return string
*/
public function getPhpMainClass(): string {
return $this->phpMainClass;
}
 
/**
* @return array<string>
* @return string[]
*/
public function getCSSFiles(): array {
return $this->cssFiles;
105,7 → 129,7
}
 
/**
* @return array<string>
* @return string[]
*/
public function getJSFiles(): array {
return $this->jsFiles;
112,7 → 136,7
}
 
/**
* @return array<string>
* @return string[]
*/
public function getCSSFilesSetup(): array {
return $this->cssFilesSetup;
119,28 → 143,43
}
 
/**
* @return array<string>
* @return string[]
*/
public function getJSFilesSetup(): array {
return $this->jsFilesSetup;
}
 
/**
* @return string
*/
public function getManifestFile(): string {
return $this->manifestFile;
}
 
/**
* @return \SimpleXMLElement
*/
public function getRawXml(): \SimpleXMLElement {
return $this->rawXML;
}
 
/**
* @return string
*/
public function getLanguageCode(): string {
return $this->languageCode;
}
 
/**
* @return string
*/
public function getLanguageFlag(): string {
return $this->languageFlag;
}
 
/**
* @return string
*/
public function getLanguageMessages(): string {
return $this->languageMessages;
}
148,7 → 187,8
/**
* Lists all files referenced by the manifest files
* Not included are other files like menu images or other PHP classes
* @return array<string>
* @return string[]
* @throws \ReflectionException
*/
public function getManifestLinkedFiles(): array {
$files = array_merge(
163,10 → 203,14
return $files;
}
 
public function loadManifest($filename) {
/**
* @param string $filename
* @return bool
*/
public function loadManifest(string $filename) {
if (!file_exists($filename)) return false;
$xmldata = @simplexml_load_file($filename);
if ($xmldata === false) return false;
if ($xmldata === false) return false; // TODO: rather throw an Exception and let the method return void only
 
$this->manifestFile = $filename;
$this->rawXML = $xmldata;
195,8 → 239,10
$this->cssFiles[] = $file;
}
 
// The following functionalities are only available for page plugins
// The following functionalities are only available for page plugins, captcha plugins, and object type plugins
// XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.2.1
// XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.10.1
// XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.12.1
foreach ((array)$xmldata->js->file as $js_file) {
$file = dirname($filename).DIRECTORY_SEPARATOR.$js_file;
//if (!file_exists($file)) continue;
/trunk/includes/classes/OIDplusQueryResult.class.php
24,16 → 24,35
// phpcs:enable PSR1.Files.SideEffects
 
abstract class OIDplusQueryResult extends OIDplusBaseClass {
 
/**
* @return bool
*/
abstract public function containsResultSet(): bool;
 
/**
* @return int
*/
abstract public function num_rows(): int;
 
/**
* @return array|null
*/
abstract public function fetch_array()/*: ?array*/;
 
/**
* @return object|null
*/
abstract public function fetch_object()/*: ?object*/;
 
/**
* The any() function returns true if there is at least one
* row in the section. By default, num_rows() will be used.
* Plugins can override this method if they have a possibility
* of making this functionality more efficient.
* @return bool
*/
public function any(): bool {
// The any() function returns true if there is at least one
// row in the section. By default, num_rows() will be used.
// Plugins can override this method if they have a possibility
// of making this functionality more efficient.
return $this->num_rows() > 0;
}
}
/trunk/includes/classes/OIDplusRA.class.php
26,20 → 26,34
class OIDplusRA extends OIDplusBaseClass {
private $email = null;
 
public function __construct($email) {
/**
* @param string $email
*/
public function __construct(string $email) {
$this->email = $email;
}
 
public function raEmail() {
/**
* @return string
*/
public function raEmail(): string {
return $this->email;
}
 
public function existing() {
/**
* @return bool
* @throws OIDplusException
*/
public function existing(): bool {
$res = OIDplus::db()->query("select email from ###ra where email = ?", array($this->email));
return ($res->any());
}
 
public function raName() {
/**
* @return string
* @throws OIDplusException
*/
public function raName(): string {
$res = OIDplus::db()->query("select ra_name from ###ra where email = ?", array($this->email));
if (!$res->any()) return _L('(RA not in database)');
$row = $res->fetch_array();
46,7 → 60,11
return $row['ra_name'];
}
 
public static function getAllRAs() {
/**
* @return OIDplusRA[]
* @throws OIDplusException
*/
public static function getAllRAs(): array {
$out = array();
$res = OIDplus::db()->query("select email from ###ra");
while ($row = $res->fetch_array()) {
55,17 → 73,32
return $out;
}
 
public function change_password($new_password) {
/**
* @param string $new_password
* @return void
* @throws OIDplusException
*/
public function change_password(string $new_password) {
$authInfo = OIDplus::authUtils()->raGeneratePassword($new_password);
$calc_authkey = $authInfo->getAuthKey();
OIDplus::db()->query("update ###ra set authkey=? where email = ?", array($calc_authkey, $this->email));
}
 
public function change_email($new_email) {
/**
* @param string $new_email
* @return void
* @throws OIDplusException
*/
public function change_email(string $new_email) {
OIDplus::db()->query("update ###ra set email = ? where email = ?", array($new_email, $this->email));
}
 
public function register_ra($new_password) {
/**
* @param string|null $new_password
* @return void
* @throws OIDplusException
*/
public function register_ra(/*?string*/ $new_password) {
if (is_null($new_password)) {
// Invalid password (used for LDAP/OAuth)
$calc_authkey = '';
77,6 → 110,10
OIDplus::db()->query("insert into ###ra (authkey, email, registered, ra_name, personal_name, organization, office, street, zip_town, country, phone, mobile, fax) values (?, ?, ".OIDplus::db()->sqlDate().", ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array($calc_authkey, $this->email, "", "", "", "", "", "", "", "", "", ""));
}
 
/**
* @return OIDplusRAAuthInfo|null
* @throws OIDplusException
*/
public function getAuthInfo()/*: ?OIDplusRAAuthInfo*/ {
$ra_res = OIDplus::db()->query("select authkey from ###ra where email = ?", array($this->email));
if (!$ra_res->any()) return null; // User not found
85,19 → 122,37
return new OIDplusRAAuthInfo($ra_row['authkey']);
}
 
public function checkPassword($password) {
/**
* @param string $password
* @return bool
* @throws OIDplusException
*/
public function checkPassword(string $password): bool {
return OIDplus::authUtils()->raCheckPassword($this->email, $password);
}
 
/**
* @return void
* @throws OIDplusException
*/
public function delete() {
OIDplus::db()->query("delete from ###ra where email = ?", array($this->email));
}
 
public function setRaName($ra_name) {
/**
* @param string $ra_name
* @return void
* @throws OIDplusException
*/
public function setRaName(string $ra_name) {
OIDplus::db()->query("update ###ra set ra_name = ? where email = ?", array($ra_name, $this->email));
}
 
public function isPasswordLess() {
/**
* @return bool|null
* @throws OIDplusException
*/
public function isPasswordLess()/*: ?bool*/ {
$authInfo = $this->getAuthInfo();
if (!$authInfo) return null; // user not found
return $authInfo->isPasswordLess();
/trunk/includes/classes/OIDplusRAAuthInfo.class.php
27,22 → 27,36
 
private $authKey;
 
public function setAuthKey($authKey) {
/**
* @param string $authKey
* @return void
* @throws OIDplusException
*/
public function setAuthKey(string $authKey) {
// 250 is the length of the database field
if (strlen($authKey) > 250) throw new OIDplusException(_L('Field %1 is too long. Max allowed %2','Auth key',250));
if (is_null($authKey) || ($authKey === false)) throw new OIDplusException(_L('Field %1 is invalid','Auth key'));
$this->authKey = $authKey;
}
 
public function getAuthKey() {
/**
* @return string
*/
public function getAuthKey(): string {
return $this->authKey;
}
 
public function __construct($authKey) {
/**
* @param string $authKey
* @throws OIDplusException
*/
public function __construct(string $authKey) {
$this->setAuthKey($authKey);
}
 
public function isPasswordLess() {
/**
* @return bool
*/
public function isPasswordLess(): bool {
return empty($this->authKey);
}
 
/trunk/includes/classes/OIDplusRAAuthInfo.class.php.bak
0,0 → 1,69
<?php
 
/*
* OIDplus 2.0
* Copyright 2019 - 2023 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.
*/
 
namespace ViaThinkSoft\OIDplus;
 
// phpcs:disable PSR1.Files.SideEffects
\defined('INSIDE_OIDPLUS') or die;
// phpcs:enable PSR1.Files.SideEffects
 
class OIDplusRAAuthInfo extends OIDplusBaseClass {
 
private $authKey;
 
/**
* @param string $authKey
* @return void
* @throws OIDplusException
*/
public function setAuthKey(string $authKey) {
// 250 is the length of the database field
if (strlen($authKey) > 250) throw new OIDplusException(_L('Field %1 is too long. Max allowed %2','Auth key',250));
<<<<<<< .mine
||||||| .r1112
if (is_null($authKey) || ($authKey === false)) throw new OIDplusException(_L('Field %1 is too invalid','Auth key'));
=======
if (is_null($authKey) || ($authKey === false)) throw new OIDplusException(_L('Field %1 is invalid','Auth key'));
>>>>>>> .r1115
$this->authKey = $authKey;
}
 
/**
* @return string
*/
public function getAuthKey(): string {
return $this->authKey;
}
 
/**
* @param string $authKey
* @throws OIDplusException
*/
public function __construct(string $authKey) {
$this->setAuthKey($authKey);
}
 
/**
* @return bool
*/
public function isPasswordLess(): bool {
return empty($this->authKey);
}
 
}
/trunk/includes/classes/OIDplusSQLException.class.php
25,7 → 25,11
 
class OIDplusSQLException extends OIDplusException {
 
public function __construct($sql, $message) {
/**
* @param string $sql
* @param string $message
*/
public function __construct(string $sql, string $message) {
parent::__construct(_L('%1 at query "%2"',$message,$sql));
}
 
/trunk/includes/classes/OIDplusSessionHandler.class.php
28,6 → 28,9
private $secret = '';
protected $sessionLifetime = 0;
 
/**
* @throws OIDplusException
*/
public function __construct() {
$this->sessionLifetime = OIDplus::baseConfig()->getValue('SESSION_LIFETIME', 30*60);
$this->secret = OIDplus::baseConfig()->getValue('SERVER_SECRET');
56,6 → 59,10
@ini_set('session.gc_maxlifetime', $this->sessionLifetime);
}
 
/**
* @return void
* @throws OIDplusException
*/
protected function sessionSafeStart() {
if (!isset($_SESSION)) {
// TODO: session_name() makes some problems. Leave it away for now.
83,6 → 90,9
}
}
 
/**
* @return void
*/
function __destruct() {
session_write_close();
}
89,7 → 99,13
 
private $cacheSetValues = array(); // Important if you do a setValue() followed by an getValue()
 
public function setValue($name, $value) {
/**
* @param string $name
* @param mixed $value
* @return void
* @throws OIDplusException
*/
public function setValue(string $name, $value) {
$enc_data = self::encrypt($value, $this->secret);
 
$this->cacheSetValues[$name] = $enc_data;
100,7 → 116,13
$_SESSION[$name] = $enc_data;
}
 
public function getValue($name, $default = NULL) {
/**
* @param string $name
* @param mixed|null $default
* @return mixed|null
* @throws OIDplusException
*/
public function getValue(string $name, $default = NULL) {
if (isset($this->cacheSetValues[$name])) return self::decrypt($this->cacheSetValues[$name], $this->secret);
 
if (!$this->isActive()) return $default; // GDPR: Only start a session when we really need one
111,7 → 133,12
return self::decrypt($_SESSION[$name], $this->secret);
}
 
public function exists($name) {
/**
* @param string $name
* @return bool
* @throws OIDplusException
*/
public function exists(string $name): bool {
if (isset($this->cacheSetValues[$name])) return true;
 
if (!$this->isActive()) return false; // GDPR: Only start a session when we really need one
118,10 → 145,15
$this->sessionSafeStart();
OIDplus::cookieUtils()->setcookie(session_name(),session_id(),time()+$this->sessionLifetime);
 
if (!isset($_SESSION[$name])) return false;
return isset($_SESSION[$name]);
}
 
public function delete($name) {
/**
* @param string $name
* @return void
* @throws OIDplusException
*/
public function delete(string $name) {
if (isset($this->cacheSetValues[$name])) unset($this->cacheSetValues[$name]);
 
if (!$this->isActive()) return; // GDPR: Only start a session when we really need one
131,6 → 163,10
unset($_SESSION[$name]);
}
 
/**
* @return void
* @throws OIDplusException
*/
public function destroySession() {
if (!$this->isActive()) return;
 
143,11 → 179,20
OIDplus::cookieUtils()->unsetcookie(session_name()); // remove cookie, so GDPR people are happy
}
 
public function isActive() {
/**
* @return bool
*/
public function isActive(): bool {
return isset($_COOKIE[session_name()]);
}
 
protected static function encrypt($data, $key) {
/**
* @param string $data
* @param string $key
* @return string
* @throws \Exception
*/
protected static function encrypt(string $data, string $key): string {
if (function_exists('openssl_encrypt')) {
$iv = random_bytes(16); // AES block size in CBC mode
// Encryption
168,7 → 213,13
}
}
 
protected static function decrypt($data, $key) {
/**
* @param string $data
* @param string $key
* @return string
* @throws OIDplusException
*/
protected static function decrypt(string $data, string $key): string {
if (function_exists('openssl_decrypt')) {
$hmac = mb_substr($data, 0, 64, '8bit');
$iv = mb_substr($data, 64, 16, '8bit');
/trunk/includes/classes/OIDplusSqlSlangPlugin.class.php
25,33 → 25,85
 
abstract class OIDplusSqlSlangPlugin extends OIDplusPlugin {
 
/**
* @return string
*/
public abstract static function id(): string;
 
public abstract function natOrder($fieldname, $order='asc'): string;
/**
* @param string $fieldname
* @param string $order
* @return string
*/
public abstract function natOrder(string $fieldname, string $order='asc'): string;
 
/**
* @return string
*/
public abstract function sqlDate(): string;
 
/**
* @param OIDplusDatabaseConnection $db
* @return bool
*/
public abstract function detect(OIDplusDatabaseConnection $db): bool;
 
// Please note: This insert_id() function should use SQL to receive
// the last inserted ID. If the database connection provider (e.g. PDO)
// offers a way to fetch the last inserted ID, please use this instead!
// So, please do NOT use OIDplus::db()->getSlang()->insert_id()
// but instead use OIDplus::db()->insert_id()
// This way, the database connection provider can override that function
// with their own method of fetching the last inserted ID.
/**
* Please note: This insert_id() function should use SQL to receive
* the last inserted ID. If the database connection provider (e.g. PDO)
* offers a way to fetch the last inserted ID, please use this instead!
* So, please do NOT use OIDplus::db()->getSlang()->insert_id()
* but instead use OIDplus::db()->insert_id()
* This way, the database connection provider can override that function
* with their own method of fetching the last inserted ID.
* @param OIDplusDatabaseConnection $db
* @return int 0 on failure.
*/
public abstract function insert_id(OIDplusDatabaseConnection $db): int;
 
public abstract function setupSetTablePrefix($cont, $table, $prefix): string;
/**
* @param string $cont
* @param string $table
* @param string $prefix
* @return string
*/
public abstract function setupSetTablePrefix(string $cont, string $table, string $prefix): string;
 
public abstract function setupCreateDbIfNotExists($database): string;
/**
* @param string $database
* @return string
*/
public abstract function setupCreateDbIfNotExists(string $database): string;
 
public abstract function setupUseDatabase($database): string;
/**
* @param string $database
* @return string
*/
public abstract function setupUseDatabase(string $database): string;
 
public abstract function filterQuery($sql): string;
/**
* @param string $sql
* @return string
*/
public abstract function filterQuery(string $sql): string;
 
public abstract function getSQLBool($bool): string;
/**
* @param bool $bool
* @return string
*/
public abstract function getSQLBool(bool $bool): string;
 
public abstract function escapeString($str): string;
/**
* @param string $str
* @return string
*/
public abstract function escapeString(string $str): string;
 
/**
* @param string $expr1
* @param string $expr2
* @return string
*/
public abstract function isNullFunction(string $expr1, string $expr2): string;
 
}
/trunk/includes/db_updates/update1002.inc.php
18,11 → 18,13
*/
 
use ViaThinkSoft\OIDplus\OIDplusDatabaseConnection;
use ViaThinkSoft\OIDplus\OIDplusException;
 
/**
* This function is internally called by oidplus_dbupdate_1002().
* It changes the auth keys A1*# and A2# to VTS-MCF and A3# to BCrypt-MCF.
* @param OIDplusDatabaseConnection $db is the OIDplusDatabaseConnection class
* @throws OIDplusException
*/
function oidplus_dbupdate_1002_migrate_ra_passwords(OIDplusDatabaseConnection $db) {
$res = $db->query("select * from ###ra ");
/trunk/includes/functions.inc.php
48,9 → 48,9
);
$privKeyNew = @openssl_pkey_get_private($privKeyOld, $passphrase_old);
if ($privKeyNew === false) return false;
@openssl_pkey_export($privKeyNew, $privKeyNewExport, $passphrase_new, $pkey_config);
if ($privKeyNewExport === false) return false;
return $privKeyNewExport."";
if (!@openssl_pkey_export($privKeyNew, $privKeyNewExport, $passphrase_new, $pkey_config)) return false;
if ($privKeyNewExport === "") return false;
return "$privKeyNewExport";
}
 
function decrypt_private_key($privKey, $passphrase) {
/trunk/includes/oidplus.inc.php
23,7 → 23,7
// will get a compilation error and then they won't see our friendly error message.
// More information about the required PHP version: doc/developer_notes/php7_compat.txt
 
define('INSIDE_OIDPLUS', true);
const INSIDE_OIDPLUS = true;
 
if (version_compare(PHP_VERSION, $oidplus_min_version='7.0.0') < 0) {
// Note: These strings are not translated, because in case of an incompatible
52,7 → 52,7
if (count($missing_dependencies) >= 1) {
// Note that there are no translations _L() because if we get an error at this
// stage, then we have no language plugins anyways.
$message = '<p>'.sprintf('The following PHP extensions need to be installed in order to run OIDplus:').'</p>';
$message = '<p>The following PHP extensions need to be installed in order to run OIDplus:</p>';
$message .= '<p><ul>';
foreach ($missing_dependencies as $dependency) {
$message .= '<li>'.$dependency.'<br><br></li>';
85,7 → 85,7
// Functions
 
function oidplus_dependency_panic($message)/*: never*/ {
$title = sprintf('OIDplus startup error');
$title = 'OIDplus startup error';
if (PHP_SAPI === 'cli') {
$message = str_replace('<li>', "- ", $message);
$message = str_replace('<br>', "\n", $message);
/trunk/includes/oidplus_autoloader.inc.php
51,7 → 51,7
if (!isset($class_refs[$cn])) {
$class_refs[$cn] = array($filename);
} else {
$class_refs[$cn][] = $filename;;
$class_refs[$cn][] = $filename;
}
}
};
/trunk/includes/oidplus_dependency.inc.php
69,7 → 69,7
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$install_hint1 = sprintf('On Windows, install it by enabling the line %s in your PHP.ini',
'extension=php_gmp.dll');
$install_hint2 = sprintf('On Windows, it should be installed by default');
$install_hint2 = 'On Windows, it should be installed by default';
} else {
$install_hint1 = sprintf('On Linux, install it by running e.g. %s, and then restart your webserver service, e.g. by running %s',
'<code>sudo apt-get update && sudo apt-get install php-gmp</code>',
79,7 → 79,7
'<code>sudo service apache2 restart</code>');
}
$missing_dependencies[] = 'GMP ('.$install_hint1.')'.
'<br>'.sprintf('or alternatively').'<br>' .
'<br>or alternatively<br>' .
'BCMath ('.$install_hint2.')';
}
 
94,15 → 94,15
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$install_hint1 = sprintf('On Windows, install it by enabling the line %s in your PHP.ini',
'extension=php_mbstring.dll');
$install_hint2 = sprintf('On Windows, it should be installed by default');
$install_hint2 = 'On Windows, it should be installed by default';
} else {
$install_hint1 = sprintf('On Linux, install it by running e.g. %s, and then restart your webserver service, e.g. by running %s',
'<code>sudo apt-get update && sudo apt-get install php-mbstring</code>',
'<code>sudo service apache2 restart</code>');
$install_hint2 = sprintf('On Linux, it should be installed by default'); // Alpine Linux: apk add php-iconv
$install_hint2 = 'On Linux, it should be installed by default'; // Alpine Linux: apk add php-iconv
}
$missing_dependencies[] = 'MBString ('.$install_hint1.')'.
'<br>'.sprintf('or alternatively').'<br>' .
'<br>or alternatively<br>' .
'iconv ('.$install_hint2.')';
}
 
113,7 → 113,7
// dev/translation/*.phps (only for developers)
// Note: This should not happen because of vendor/danielmarschall/php_utils/simplexml_supplement.inc.php
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$install_hint = sprintf('On Windows, it should be installed by default');
$install_hint = 'On Windows, it should be installed by default';
} else {
$install_hint = sprintf('On Linux, install it by running e.g. %s, and then restart your webserver service, e.g. by running %s',
'<code>sudo apt-get update && sudo apt-get install php-xml</code>',
/trunk/index.php
34,7 → 34,7
 
if (isset($_REQUEST['h404'])) {
$handled = false;
$plugins = OIDplus::getPagePlugins();
$plugins = OIDplus::getAllPlugins();
foreach ($plugins as $plugin) {
if ($plugin->handle404($_REQUEST['h404'])) $handled = true;
}
/trunk/oidplus.min.css.php
49,7 → 49,7
$minifier = new Minify\CSS($filename);
$cont = $minifier->minify();
} else {
return;
return '';
}
} else {
if (file_exists($filename_full)) {
59,7 → 59,7
$filename = $filename_min;
$cont = file_get_contents($filename);
} else {
return;
return '';
}
}
 
/trunk/plugins/frdl/publicPages/1276945_rdap/OIDplusPagePublicRdap.class.php
28,17 → 28,34
 
class OIDplusPagePublicRdap extends OIDplusPagePluginPublic {
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.2') return true; // modifyContent
return false;
}
 
public function modifyContent($id, &$title, &$icon, &$text) {
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.2
* @param string $id
* @param string $title
* @param string $icon
* @param string $text
* @return void
* @throws \ViaThinkSoft\OIDplus\OIDplusException
*/
public function modifyContent(string $id, string &$title, string &$icon, string &$text) {
$text .= '<br /> <a href="'.OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE)
.'rdap/rdap.php?query='.urlencode($id).'" class="gray_footer_font" target="_blank">'._L('RDAP').'</a>';
}
 
public function handle404($request) {
/**
* @param string $request
* @return bool
*/
public function handle404(string $request): bool {
$namespaces = array();
foreach (OIDplus::getEnabledObjectTypes() as $ot) {
$namespaces[] = $ot::ns();
52,8 → 69,10
list($out_content, $out_type) = $x->rdapQuery($query);
if ($out_type) header('Content-Type:'.$out_type);
echo $out_content;
die(); // return true;
die();
// return true;
}
return false;
}
 
}
/trunk/plugins/frdl/publicPages/1276945_rdap/OIDplusRDAP.class.php
37,6 → 37,9
protected $rdapCacheDir;
protected $rdapCacheExpires;
 
/**
* @throws \ViaThinkSoft\OIDplus\OIDplusException
*/
public function __construct() {
$this->rdapBaseUri = OIDplus::baseConfig()->getValue('RDAP_BASE_URI', OIDplus::webpath() );
$this->useCache = OIDplus::baseConfig()->getValue('RDAP_CACHE_ENABLED', false );
44,6 → 47,11
$this->rdapCacheExpires = OIDplus::baseConfig()->getValue('RDAP_CACHE_EXPIRES', 60 * 3 );
}
 
/**
* @param $query
* @return array
* @throws \ViaThinkSoft\OIDplus\OIDplusException
*/
public function rdapQuery($query) {
$query = str_replace('oid:.', 'oid:', $query);
$n = explode(':', $query);
114,7 → 122,7
$out['objectClassName'] = $ns;
$out['handle'] = $ns.':'.$n[1];
$out['parentHandle'] = (null !== $parentHandle && is_callable([$parentHandle, 'nodeId']) )
? $obj->one_up()->nodeId(true)
? $parentHandle->nodeId(true)
: null;
 
$out['rdapConformance'] = [
235,11 → 243,21
return $this->rdap_out($out);
}
 
/**
* @param $out
* @param $cacheFile
* @return void
*/
protected function rdap_write_cache($out, $cacheFile){
if (!is_string($cacheFile)) return;
@file_put_contents($cacheFile, serialize($out));
}
 
/**
* @param $cacheFile
* @param $rdapCacheExpires
* @return array|null
*/
protected function rdap_read_cache($cacheFile, $rdapCacheExpires){
if (is_string($cacheFile) && file_exists($cacheFile) && filemtime($cacheFile) >= time() - $rdapCacheExpires) {
$out = unserialize(file_get_contents($cacheFile));
250,6 → 268,10
return null;
}
 
/**
* @param $out
* @return array
*/
protected function rdap_out($out){
$out_content = json_encode($out);
$out_type = 'application/rdap+json';
/trunk/plugins/frdl/publicPages/altids/OIDplusPagePublicAltIds.class.php
19,22 → 19,49
 
class OIDplusPagePublicAltIds extends OIDplusPagePluginPublic {
 
public function action($actionID, $params) {
 
/**
* @param string $actionID
* @param array $params
* @return array
* @throws \ViaThinkSoft\OIDplus\OIDplusException
*/
public function action(string $actionID, array $params): array {
return parent::action($actionID, $params);
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
*/
public function gui(string $id, array &$out, bool &$handled) {
 
}
 
public function publicSitemap(&$out) {
/**
* @param array $out
* @return void
*/
public function publicSitemap(array &$out) {
 
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
return false;
}
 
/**
* @return string|null
* @throws \ViaThinkSoft\OIDplus\OIDplusException
*/
private function cache_id() {
static $cache_id = null;
if (!is_null($cache_id)) return $cache_id;
50,6 → 77,11
return $cache_id;
}
 
/**
* @param $noCache
* @return array[]|mixed|null
* @throws \ViaThinkSoft\OIDplus\OIDplusException
*/
public function readAll($noCache = false) {
static $local_cache = null;
 
100,6 → 132,11
return $data;
}
 
/**
* @param $id
* @return array|mixed|string[]
* @throws \ViaThinkSoft\OIDplus\OIDplusException
*/
public function getAlternativesForQuery($id/* 1.3.6.1.4.1.37476.2.5.2.3.7 signature takes just 1 param!? , $noCache = false*/) {
 
static $caches = array();
151,16 → 188,29
return $res;
}
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.4') return true; // whois*Attributes
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.7') return true; // getAlternativesForQuery
return false;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
 
/**
* @param $id
* @return false|mixed|string
* @throws \ViaThinkSoft\OIDplus\OIDplusException
*/
public function getCanonical($id){
foreach($this->getAlternativesForQuery($id) as $alt){
if (strpos($alt,':') !== false) {
174,9 → 224,14
return false;
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.4
* @param $id
* @param $out
* @return void
* @throws \ViaThinkSoft\OIDplus\OIDplusException
*/
public function whoisObjectAttributes($id, &$out) {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.4
 
$xmlns = 'oidplus-frdlweb-altids-plugin';
$xmlschema = 'urn:oid:1.3.6.1.4.1.37553.8.1.8.8.53354196964.641310544.1714020422';
$xmlschemauri = OIDplus::webpath(__DIR__.'/altids.xsd',OIDplus::PATH_ABSOLUTE);
227,8 → 282,14
}
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.4
* @param $email
* @param $out
* @return void
*/
public function whoisRaAttributes($email, &$out) {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.4
 
}
 
}
/trunk/plugins/manifest_plugin_auth.xsd
15,6 → 15,8
maxOccurs="1" />
<xs:element type="xs:string" name="author"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="license"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="version"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="descriptionHTML"
/trunk/plugins/manifest_plugin_captcha.xsd
15,6 → 15,8
maxOccurs="1" />
<xs:element type="xs:string" name="author"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="license"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="version"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="descriptionHTML"
/trunk/plugins/manifest_plugin_database.xsd
15,6 → 15,8
maxOccurs="1" />
<xs:element type="xs:string" name="author"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="license"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="version"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="descriptionHTML"
/trunk/plugins/manifest_plugin_design.xsd
15,6 → 15,8
maxOccurs="1" />
<xs:element type="xs:string" name="author"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="license"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="version"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="descriptionHTML"
/trunk/plugins/manifest_plugin_language.xsd
15,6 → 15,8
maxOccurs="1" />
<xs:element type="xs:string" name="author"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="license"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="version"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="descriptionHTML"
/trunk/plugins/manifest_plugin_logger.xsd
15,6 → 15,8
maxOccurs="1" />
<xs:element type="xs:string" name="author"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="license"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="version"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="descriptionHTML"
/trunk/plugins/manifest_plugin_objectTypes.xsd
15,6 → 15,8
maxOccurs="1" />
<xs:element type="xs:string" name="author"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="license"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="version"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="descriptionHTML"
/trunk/plugins/manifest_plugin_other.xsd
15,6 → 15,8
maxOccurs="1" />
<xs:element type="xs:string" name="author"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="license"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="version"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="descriptionHTML"
/trunk/plugins/manifest_plugin_page.xsd
15,6 → 15,8
maxOccurs="1" />
<xs:element type="xs:string" name="author"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="license"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="version"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="descriptionHTML"
43,7 → 45,16
</xs:complexType>
</xs:element>
 
<xs:element name="js" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="file" minOccurs="0"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
 
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
/trunk/plugins/manifest_plugin_sqlSlang.xsd
15,6 → 15,8
maxOccurs="1" />
<xs:element type="xs:string" name="author"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="license"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="version"
minOccurs="1" maxOccurs="1" />
<xs:element type="xs:string" name="descriptionHTML"
/trunk/plugins/tushevorg/publicPages/2000_uitweaks/OIDplusPagePublicUITweaks.class.php
37,7 → 37,12
 
class OIDplusPagePublicUITweaks extends OIDplusPagePluginPublic {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
* @throws OIDplusException
*/
public function init(bool $html=true) {
OIDplus::config()->prepareConfigKey('uitweaks_expand_objects_tree', 'UITweaks plugin: 1=Fully expand objects tree on page reload, 0=Default behavior', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
if (!is_numeric($value) || ($value < 0) || ($value > 1)) {
throw new OIDplusException(_L('Please enter a valid value.'));
71,7 → 76,12
});
}
 
public function htmlHeaderUpdate(&$head_elems) {
/**
* @param array $head_elems
* @return void
* @throws OIDplusException
*/
public function htmlHeaderUpdate(array &$head_elems) {
$w = js_escape(OIDplus::config()->getValue('uitweaks_menu_width'));
$rw = OIDplus::config()->getValue('uitweaks_menu_remember_width') == 1 ? 'true' : 'false';
$o = OIDplus::config()->getValue('uitweaks_expand_objects_tree') == 1 ? 'true' : 'false';
93,6 → 103,4
$head_elems[] = $s;
}
 
 
 
}
/trunk/plugins/viathinksoft/adminPages/010_notifications/OIDplusPageAdminNotifications.class.php
25,10 → 25,21
 
class OIDplusPageAdminNotifications extends OIDplusPagePluginAdmin {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
$parts = explode('$',$id);
$id = $parts[0];
 
63,7 → 74,7
 
foreach (OIDplus::getAllPlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.8')) {
$notifications = $plugin->getNotifications($ra_email);
$notifications = $plugin->getNotifications($ra_email); /** @phpstan-ignore-line */
if ($notifications) {
foreach ($notifications as $notification) {
list($severity, $htmlMessage) = $notification;
110,7 → 121,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
if (file_exists(__DIR__.'/img/main_icon16.png')) {
128,18 → 147,33
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications()
return false;
}
 
private function webAccessWorks($dir) {
// Attention! This check does not work if OIDplus is password protected!
// The only real solution is to check via JavaScript, which is done by setup/
/**
* Checks if the system can be accessed publicly
* Attention! This check does not work if OIDplus is password protected (solution would be to check via JavaScript,
* which is done in setup/), or the URL is in the IntraNet rather than the Internet (only solution would be a
* remote URL check service)
* @param string $dir
* @return false|string
* @throws OIDplusException
*/
private function webAccessWorks(string $dir) {
$url = OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).$dir;
$access_worked = url_get_contents($url) !== false;
if ($access_worked) return $url;
155,7 → 189,12
return false;
}
 
private function getNotificationsCheckDirAccess($dir) {
/**
* @param string $dir
* @return array
* @throws OIDplusException
*/
private function getNotificationsCheckDirAccess(string $dir) {
$notifications = array();
if (($url = $this->webAccessWorks($dir)) !== false) {
// Re-use message taken from setup/includes/setup_base.js
165,9 → 204,14
return $notifications;
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.8
* These are some basic "system" checks, no checks from other plugin. So we add them to our plugin instead.
* @param $user
* @return array
* @throws OIDplusException
*/
public function getNotifications($user=null): array {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.8
// These are some basic "system" checks, no checks from other plugin. So we add them to our plugin instead.
$notifications = array();
if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) {
// Check if critical directories are world-readable
/trunk/plugins/viathinksoft/adminPages/050_oobe/OIDplusPageAdminOOBE.class.php
25,16 → 25,26
 
class OIDplusPageAdminOOBE extends OIDplusPagePluginAdmin {
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
*/
public function gui(string $id, array &$out, bool &$handled) {
// Nothing
}
 
public function oobeRequired() {
/**
* @return bool
* @throws OIDplusException
*/
public function oobeRequired(): bool {
$oobe_done = OIDplus::config()->getValue('oobe_main_done') == '1';
 
foreach (OIDplus::getAllPlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.1')) {
if ($plugin->oobeRequested()) {
if ($plugin->oobeRequested()) { /** @phpstan-ignore-line */
$oobe_done = false;
break;
}
44,7 → 54,12
return !$oobe_done;
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
* @throws OIDplusException
*/
public function init(bool $html=true) {
OIDplus::config()->delete('reg_wizard_done'); // deprecated name
OIDplus::config()->prepareConfigKey('oobe_main_done', '"Out Of Box Experience" wizard for the system settings done once?', '0', OIDplusConfig::PROTECTION_HIDDEN, function($value) {});
 
79,11 → 94,22
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
/trunk/plugins/viathinksoft/adminPages/050_oobe/oobe.php
87,7 → 87,7
}
 
#------------------------
$do_edits = isset($_POST['sent']) && $edits_possible;;
$do_edits = isset($_POST['sent']) && $edits_possible;
#------------------------
 
# ---
144,7 → 144,7
 
foreach (OIDplus::getAllPlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.1')) {
$plugin->oobeEntry($step++, $do_edits, $errors_happened);
$plugin->oobeEntry($step++, $do_edits, $errors_happened); /** @phpstan-ignore-line */
}
}
 
/trunk/plugins/viathinksoft/adminPages/100_wellknown_oids/OIDplusPageAdminWellKnownOIDs.class.php
25,11 → 25,22
 
class OIDplusPageAdminWellKnownOIDs extends OIDplusPagePluginAdmin {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
// Nothing
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if ($id === 'oidplus:well_known_oids') {
$handled = true;
$out['title'] = _L('Well known OIDs');
41,9 → 52,7
return;
}
 
$out['text'] = '';
 
$out['text'] .= '<p>'._L('Well-known OIDs are OIDs of Registration Authorities which are assigning OIDs to customers, i.e. they are most likely to be used by OIDplus users as their root OID. Well-known OIDs have the following purposes:').'<ol>';
$out['text'] = '<p>'._L('Well-known OIDs are OIDs of Registration Authorities which are assigning OIDs to customers, i.e. they are most likely to be used by OIDplus users as their root OID. Well-known OIDs have the following purposes:').'<ol>';
$out['text'] .= '<li>'._L('When a new OIDplus user creates his root OID into OIDplus, then the ASN.1 identifiers and Unicode labels of the superior OIDs are automatically added.').'</li>';
$out['text'] .= '<li>'._L('In the automatic oid-info.com publishing, well-known OIDs will not be transmitted (because it is unlikely that RAs of well-known OIDs will be using OIDplus in combination with automatic publishing to oid-info.com). Instead, all children inside these well-known OIDs are most likely to be yours, so these will be reported to oid-info.com instead.').'</li>';
// $out['text'] .= '<li>'._L('In OID-WHOIS, if a user requests information about an unknown OID which is inside a well-known OID, then OID-WHOIS will output information at which place more information can be retrieved from.').'</li>';
95,7 → 104,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
if (file_exists(__DIR__.'/img/main_icon16.png')) {
113,7 → 130,11
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
/trunk/plugins/viathinksoft/adminPages/110_system_config/OIDplusPageAdminSystemConfig.class.php
25,7 → 25,13
 
class OIDplusPageAdminSystemConfig extends OIDplusPagePluginAdmin {
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return int[]
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
if ($actionID == 'config_update') {
if (!OIDplus::authUtils()->isAdminLoggedIn()) {
throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')));
51,15 → 57,26
 
return array("status" => 0);
} else {
throw new OIDplusException(_L('Unknown action ID'));
return parent::action($actionID, $params);
}
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
// Nothing
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if (explode('$',$id)[0] == 'oidplus:edit_config') {
$handled = true;
$out['title'] = _L('System configuration');
71,8 → 88,7
return;
}
 
$output = '';
$output .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
$output = '<div class="container box"><div id="suboid_table" class="table-responsive">';
$output .= '<table class="table table-bordered table-striped">';
$output .= ' <tr>';
$output .= ' <th>'._L('Setting').'</th>';
118,7 → 134,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
if (file_exists(__DIR__.'/img/main_icon16.png')) {
136,7 → 160,11
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
/trunk/plugins/viathinksoft/adminPages/111_systeminfo/OIDplusPageAdminSysteminfo.class.php
25,12 → 25,26
 
class OIDplusPageAdminSysteminfo extends OIDplusPagePluginAdmin {
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return array
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
return parent::action($actionID, $params);
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
}
 
/**
* @return array|mixed|string|string[]
*/
private function getLoadedInis() {
$s_inis = '';
 
51,7 → 65,15
return $s_inis;
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if ($id === 'oidplus:phpinfo') {
$handled = true;
$out['title'] = _L('PHP information');
145,7 → 167,7
$out['text'] .= ' </tr>';
 
$sysid = OIDplus::getSystemId(false);
$sysid_aid = $sysid ? 'D276000186B20005'.strtoupper(str_pad(dechex($sysid),8,'0',STR_PAD_LEFT)) : '';
$sysid_aid = $sysid ? 'D276000186B20005'.strtoupper(str_pad(dechex((int)$sysid),8,'0',STR_PAD_LEFT)) : '';
$out['text'] .= ' <tr>';
$out['text'] .= ' <td>'._L('System AID').' <abbr title="'._L('Application Identifier (ISO/IEC 7816) based on the system ID (which is based on the hash of the public key of your OIDplus system).').'">(?)</abbr></td>';
$out['text'] .= ' <td>'.(!$sysid_aid ? '<i>'._L('unknown').'</i>' : htmlentities($sysid_aid)).' ('._L('No PIX allowed').')</td>';
327,7 → 349,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
if (file_exists(__DIR__.'/img/main_icon16.png')) {
356,11 → 386,19
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
return false;
}
}
/trunk/plugins/viathinksoft/adminPages/120_registration/OIDplusPageAdminRegistration.class.php
30,12 → 30,22
/*private*/ const QUERY_LISTALLSYSTEMIDS_V1 = '1.3.6.1.4.1.37476.2.5.2.1.3.1';
/*private*/ const QUERY_LIVESTATUS_V1 = '1.3.6.1.4.1.37476.2.5.2.1.4.1';
 
public function csrfUnlock($actionID) {
/**
* @param string $actionID
* @return bool
*/
public function csrfUnlock(string $actionID): bool {
if ($actionID == 'verify_pubkey') return true;
return parent::csrfUnlock($actionID);
}
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return array
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
if ($actionID == 'verify_pubkey') {
_CheckParamExists($params, 'challenge');
 
51,11 → 61,19
"response" => base64_encode($signature)
);
} else {
throw new OIDplusException(_L('Unknown action ID'));
return parent::action($actionID, $params);
}
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if ($id === 'oidplus:srv_registration') {
$handled = true;
$out['title'] = _L('System registration settings');
208,7 → 226,11
}
}
 
protected function areWeRegistered() {
/**
* @return bool
* @throws OIDplusException
*/
protected function areWeRegistered(): bool {
// To check if we are registered. Check it "anonymously" (i.e. without revealing our system ID)
$res = url_get_contents('https://oidplus.viathinksoft.com/reg2/query.php?query='.self::QUERY_LISTALLSYSTEMIDS_V1);
 
231,6 → 253,11
return in_array(OIDplus::getSystemId(false), $list);
}
 
/**
* @param $privacy_level
* @return false|void
* @throws OIDplusException
*/
public function sendRegistrationQuery($privacy_level=null) {
 
if (is_null($privacy_level)) {
297,13 → 324,9
}
 
if (isset($json['error']) || ($json['status'] < 0)) {
if (isset($json['error'])) {
return false; // throw new OIDplusException(_L('Received error status code: %1',$json['error']));
} else {
return false; // throw new OIDplusException(_L('Received error status code: %1',$json['status']));
return false; // throw new OIDplusException(_L('Received error status code: %1',isset($json['error']) ? $json['error'] : $json['status']));
}
}
}
} else {
if ($privacy_level == 0) {
$adminExportPlugin = OIDplus::getPluginByOid('1.3.6.1.4.1.37476.2.5.2.4.3.400'); // OIDplusPageAdminOIDInfoExport
423,7 → 446,12
}
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
* @throws OIDplusException
*/
public function init(bool $html=true) {
if (OIDplus::getEditionInfo()['vendor'] != 'ViaThinkSoft') {
throw new OIDplusException(_L('This plugin is only available in the ViaThinkSoft edition of OIDplus'));
}
481,7 → 509,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
if (file_exists(__DIR__.'/img/main_icon16.png')) {
499,25 → 535,43
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.1') return true; // oobeEntry, oobeRequested
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications()
return false;
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.1
* @return bool
* @throws OIDplusException
*/
public function oobeRequested(): bool {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.1
 
return OIDplus::config()->getValue('oobe_registration_done') == '0';
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.1
* @param $step
* @param $do_edits
* @param $errors_happened
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function oobeEntry($step, $do_edits, &$errors_happened)/*: void*/ {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.1
 
echo '<h2>'._L('Step %1: System registration and automatic publishing (optional)',$step).'</h2>';
 
if (file_exists(__DIR__ . '/info$'.OIDplus::getCurrentLang().'.html')) {
620,8 → 674,13
echo '</p>';
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.8
* @param $user
* @return array
* @throws OIDplusException
*/
public function getNotifications($user=null): array {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.8
$notifications = array();
if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) {
if (!function_exists('curl_init')) {
/trunk/plugins/viathinksoft/adminPages/125_forgot_password_admin/OIDplusPageAdminForgotPasswordAdmin.class.php
25,13 → 25,31
 
class OIDplusPageAdminForgotPasswordAdmin extends OIDplusPagePluginAdmin {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
*/
public function gui(string $id, array &$out, bool &$handled) {
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
if (is_null(OIDplus::getPluginByOid('1.3.6.1.4.1.37476.2.5.2.4.1.92'))) return false; // OIDplusPagePublicForgotPasswordAdmin
 
50,7 → 68,11
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
/trunk/plugins/viathinksoft/adminPages/130_create_ra/OIDplusPageAdminCreateRa.class.php
25,7 → 25,13
 
class OIDplusPageAdminCreateRa extends OIDplusPagePluginAdmin {
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return int[]
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
if ($actionID == 'create_ra') {
if (!OIDplus::authUtils()->isAdminLoggedIn()) {
throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')));
64,15 → 70,26
 
return array("status" => 0);
} else {
throw new OIDplusException(_L('Unknown action ID'));
return parent::action($actionID, $params);
}
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
// Nothing
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
$parts = explode('$',$id);
$id = $parts[0];
 
96,7 → 113,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
if (file_exists(__DIR__.'/img/main_icon16.png')) {
114,7 → 139,11
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
/trunk/plugins/viathinksoft/adminPages/400_oidinfo_export/OIDplusPageAdminOIDInfoExport.class.php
28,7 → 28,13
/*private*/ const QUERY_LIST_OIDINFO_OIDS_V1 = '1.3.6.1.4.1.37476.2.5.2.1.5.1';
/*private*/ const QUERY_GET_OIDINFO_DATA_V1 = '1.3.6.1.4.1.37476.2.5.2.1.6.1';
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return array|int[]
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
 
if ($actionID == 'import_xml_file') {
if (!OIDplus::authUtils()->isAdminLoggedIn()) {
150,15 → 156,26
return array("status" => 0);
}
} else {
throw new OIDplusException(_L('Unknown action ID'));
return parent::action($actionID, $params);
}
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
// Nothing
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
$ary = explode('$', $id);
if (isset($ary[1])) {
$id = $ary[0];
640,7 → 657,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
if (file_exists(__DIR__.'/img/main_icon16.png')) {
658,10 → 683,20
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
 
/**
* @param $only_non_existing
* @return string[]
* @throws OIDplusException
* @throws \OIDInfoException
*/
public static function outputXML($only_non_existing) {
$out_type = null;
$out_content = '';
862,6 → 897,10
return array($out_content, $out_type);
}
 
/**
* @param $str
* @return mixed|string
*/
private static function _formatdate($str) {
$str = explode(' ',$str)[0];
if ($str == '0000-00-00') $str = '';
868,6 → 907,11
return $str;
}
 
/**
* @param $str
* @return array|string|string[]|null
* @throws OIDplusException
*/
private static function repair_relative_links($str) {
$str = preg_replace_callback('@(href\s*=\s*([\'"]))(.+)(\\2)@ismU', function($treffer) {
$url = $treffer[3];
883,6 → 927,10
return $str;
}
 
/**
* @param $address
* @return array|string[]
*/
private static function split_address_country($address) {
global $oidinfo_countries;
$ary = explode("\n", $address);
895,6 → 943,10
}
}
 
/**
* @param $name
* @return array
*/
private static function split_name($name) {
// uses regex that accepts any word character or hyphen in last name
// https://stackoverflow.com/questions/13637145/split-text-string-into-first-and-last-name-in-php
908,6 → 960,14
/*protected*/ const ORPHAN_AUTO_DEORPHAN = 1;
/*protected*/ const ORPHAN_DISALLOW_ORPHANS = 2;
 
/**
* @param $xml_contents
* @param $errors
* @param $replaceExistingOIDs
* @param $orphan_mode
* @return array|int[]
* @throws OIDplusException
*/
protected function oidinfoImportXML($xml_contents, &$errors, $replaceExistingOIDs=false, $orphan_mode=self::ORPHAN_AUTO_DEORPHAN) {
// TODO: Implement RA import (let the user decide)
// TODO: Let the user decide about $replaceExistingOIDs
1081,13 → 1141,22
 
}
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications()
return false;
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.8
* @param $user
* @return array
* @throws OIDplusException
*/
public function getNotifications($user=null): array {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.8
$notifications = array();
if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) {
if (!function_exists('curl_init')) {
/trunk/plugins/viathinksoft/adminPages/500_list_ras/OIDplusPageAdminListRAs.class.php
25,11 → 25,20
 
class OIDplusPageAdminListRAs extends OIDplusPagePluginAdmin {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
// Nothing
}
 
private function get_ralist() {
/**
* @return array
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
private function get_ralist(): array {
$tmp = array();
if (OIDplus::db()->getSlang()->id() == 'mysql') {
$res = OIDplus::db()->query("select distinct BINARY(email) as email from ###ra"); // "binary" because we want to ensure that 'distinct' is case sensitive
56,7 → 65,15
return $tmp;
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if ($id === 'oidplus:list_ra') {
$handled = true;
$out['title'] = _L('RA Listing');
99,7 → 116,16
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
if (file_exists(__DIR__.'/img/main_icon16.png')) {
152,7 → 178,11
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
// We don't need this, because the list of RAs is loaded without lazy-loading,
// so the node does not need to be searched
/*
/trunk/plugins/viathinksoft/adminPages/600_log/OIDplusPageAdminLogEvents.class.php
25,10 → 25,21
 
class OIDplusPageAdminLogEvents extends OIDplusPagePluginAdmin {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if ($id == 'oidplus:system_log') {
$handled = true;
$out['title'] = _L('All log messages');
78,7 → 89,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
if (file_exists(__DIR__.'/img/main_icon16.png')) {
96,7 → 115,11
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
}
/trunk/plugins/viathinksoft/adminPages/700_colors/OIDplusPageAdminColors.class.php
25,7 → 25,12
 
class OIDplusPageAdminColors extends OIDplusPagePluginAdmin {
 
public function htmlHeaderUpdate(&$head_elems) {
/**
* @param array $head_elems
* @return void
* @throws OIDplusException
*/
public function htmlHeaderUpdate(array &$head_elems) {
foreach ($head_elems as &$line) {
if (strpos($line,'oidplus.min.css.php') !== false) {
$add_css_args = array();
57,7 → 62,13
}
}
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return int[]
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
if ($actionID == 'color_update') {
if (!OIDplus::authUtils()->isAdminLoggedIn()) {
throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')));
79,11 → 90,16
 
return array("status" => 0);
} else {
throw new OIDplusException(_L('Unknown action ID'));
return parent::action($actionID, $params);
}
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
* @throws OIDplusException
*/
public function init(bool $html=true) {
OIDplus::config()->prepareConfigKey('color_hue_shift', 'HSV Hue shift of CSS colors (-360..360)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
if (!is_numeric($value) || ($value < -360) || ($value > 360)) {
throw new OIDplusException(_L('Please enter a valid value.'));
120,7 → 136,14
OIDplus::config()->prepareConfigKey('oobe_colors_done', '"Out Of Box Experience" wizard for OIDplusPageAdminColors done once?', '0', OIDplusConfig::PROTECTION_HIDDEN, function($value) {});
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if ($id === 'oidplus:colors') {
$handled = true;
$out['title'] = _L('Design');
180,7 → 203,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
if (file_exists(__DIR__.'/img/main_icon16.png')) {
198,24 → 229,41
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.1') return true; // oobeEntry, oobeRequested
return false;
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.1
* @return bool
* @throws OIDplusException
*/
public function oobeRequested(): bool {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.1
 
return OIDplus::config()->getValue('oobe_colors_done') == '0';
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.1
* @param $step
* @param $do_edits
* @param $errors_happened
* @return void
* @throws OIDplusException
*/
public function oobeEntry($step, $do_edits, &$errors_happened)/*: void*/ {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.1
 
echo '<h2>'._L('Step %1: Color Theme',$step).'</h2>';
 
echo '<input type="checkbox" name="color_invert" id="color_invert"';
/trunk/plugins/viathinksoft/adminPages/800_plugins/OIDplusPageAdminPlugins.class.php
25,9 → 25,17
 
class OIDplusPageAdminPlugins extends OIDplusPagePluginAdmin {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
}
 
/**
* @param $out
* @return void
*/
private function pluginTableHead(&$out) {
$out['text'] .= ' <tr>';
$out['text'] .= ' <th width="30%">'._L('Class name').'</th>';
38,6 → 46,13
$out['text'] .= ' </tr>';
}
 
/**
* @param $out
* @param $plugin
* @param $modifier
* @param $na_reason
* @return void
*/
private function pluginTableLine(&$out, $plugin, $modifier=0, $na_reason='') {
$html_reason = empty($na_reason) ? '' : ' ('.htmlentities($na_reason).')';
$out['text'] .= ' <tr>';
58,7 → 73,15
$out['text'] .= ' </tr>';
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
$tmp = explode('$',$id);
$classname = isset($tmp[1]) ? $tmp[1] : null;
 
391,12 → 414,12
 
if ($can_hash && !$can_verify) {
$note = _L('Only hashing, no verification');
if (!empty($reason_verify)) $note .= '. '.$reason_verify; /* @phpstan-ignore-line */
if (!empty($reason_verify)) $note .= '. '.$reason_verify;
$modifier = $default ? 1 : 0;
}
else if (!$can_hash && $can_verify) {
$note = _L('Only verification, no hashing');
if (!empty($reason_hash)) $note .= '. '.$reason_hash; /* @phpstan-ignore-line */
if (!empty($reason_hash)) $note .= '. '.$reason_hash;
$modifier = $default ? 1 : 0;
}
else if (!$can_hash && !$can_verify) {
403,8 → 426,8
$note = _L('Not available on this system');
$app1 = '';
$app2 = '';
if (!empty($reason_verify)) $app1 = $reason_verify; /* @phpstan-ignore-line */
if (!empty($reason_hash)) $app2 = $reason_hash; /* @phpstan-ignore-line */
if (!empty($reason_verify)) $app1 = $reason_verify;
if (!empty($reason_hash)) $app2 = $reason_hash;
if ($app1 != $app2) {
$note .= '. '.$app1.'. '.$app2;
} else {
497,7 → 520,16
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
if (file_exists(__DIR__.'/img/main_icon16.png')) {
784,7 → 816,11
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
// Not required, because all sub-nodes are loaded at the same time; no lazy-loading
return false;
}
/trunk/plugins/viathinksoft/adminPages/900_software_update/OIDplusPageAdminSoftwareUpdate.class.php
25,18 → 25,34
 
class OIDplusPageAdminSoftwareUpdate extends OIDplusPagePluginAdmin {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
}
 
private function getGitCommand() {
/**
* @return string
*/
private function getGitCommand(): string {
return 'git --git-dir='.escapeshellarg(OIDplus::findGitFolder().'/').' --work-tree='.escapeshellarg(OIDplus::localpath()).' -C "" pull origin master -s recursive -X theirs';
}
 
private function getSvnCommand() {
/**
* @return string
*/
private function getSvnCommand(): string {
return 'svn update --accept theirs-full';
}
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return array
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
if ($actionID == 'update_now') {
@set_time_limit(0);
 
148,15 → 164,26
// In this version, the client will call the web-update file.
// This has the advantage that it will also work if the system is htpasswd protected
return array("status" => 0, "update_file" => $tmp_filename, "rev" => $rev);
} else {
throw new OIDplusException(_L("Unexpected update version"));
}
}
else {
throw new OIDplusException(_L('Multiple version files/directories (oidplus_version.txt, .version.php, .git, or .svn) are existing! Therefore, the version is ambiguous!'));
}
} else {
return parent::action($actionID, $params);
}
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
$parts = explode('.',$id,2);
if (!isset($parts[1])) $parts[1] = '';
if ($parts[0] == 'oidplus:software_update') {
273,7 → 300,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
if (file_exists(__DIR__.'/img/main_icon16.png')) {
291,12 → 326,23
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
 
/**
* @var null
*/
private $releases_ser = null;
 
/**
* @param $local_ver
* @return false|string
*/
private function showChangelog($local_ver) {
 
try {
332,6 → 378,9
 
}
 
/**
* @return false|string
*/
private function getLatestRevision() {
try {
if (is_null($this->releases_ser)) {
359,6 → 408,11
}
}
 
/**
* @param $local_installation
* @param $newest_version
* @return string
*/
private function showPreview($local_installation, $newest_version) {
$out = '<h2 id="update_header">'._L('Preview of update %1 &rarr; %2',$local_installation,$newest_version).'</h2>';
 
377,13 → 431,22
return $out;
}
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications()
return false;
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.8
* @param $user
* @return array
* @throws OIDplusException
*/
public function getNotifications($user=null): array {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.8
$notifications = array();
if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) {
 
/trunk/plugins/viathinksoft/adminPages/901_vnag_version_check/OIDplusPageAdminVNagVersionCheck.class.php
25,7 → 25,12
 
class OIDplusPageAdminVNagVersionCheck extends OIDplusPagePluginAdmin {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
* @throws OIDplusException
*/
public function init(bool $html=true) {
OIDplus::config()->prepareConfigKey('vnag_version_check_password_protected', 'If set to 1 ("on"), the VNag version check is password protected', '1', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
if (($value != '0') && ($value != '1')) {
throw new OIDplusException(_L('Please enter either 0 ("off") or 1 ("on").'));
33,10 → 38,25
});
}
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return array
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
return parent::action($actionID, $params);
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
$parts = explode('.',$id,2);
if (!isset($parts[1])) $parts[1] = '';
if ($parts[0] == 'oidplus:vnag_version_check') {
87,7 → 107,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
if (file_exists(__DIR__.'/img/main_icon16.png')) {
105,10 → 133,18
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
 
/**
* @return string
* @throws OIDplusException
*/
public static function vnag_password() {
return sha3_512(OIDplus::baseConfig()->getValue('SERVER_SECRET').'/VNAG');
}
/trunk/plugins/viathinksoft/adminPages/901_vnag_version_check/vnag.php
24,7 → 24,7
include __DIR__ . '/../../../../vendor/danielmarschall/vnag/framework/vnag_framework.inc.php';
include __DIR__ . '/../../../../includes/oidplus.inc.php';
 
define('OIDPLUS_VNAG_MAX_CACHE_AGE', 60); // seconds (TODO: in base config?)
const OIDPLUS_VNAG_MAX_CACHE_AGE = 60; // seconds (TODO: in base config?)
 
OIDplus::init(false);
 
/trunk/plugins/viathinksoft/adminPages/902_systemfile_check/OIDplusPageAdminSystemFileCheck.class.php
25,13 → 25,31
 
class OIDplusPageAdminSystemFileCheck extends OIDplusPagePluginAdmin {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
}
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return array
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
return parent::action($actionID, $params);
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
$parts = explode('.',$id,2);
if (!isset($parts[1])) $parts[1] = '';
if ($parts[0] == 'oidplus:system_file_check') {
135,7 → 153,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
if (file_exists(__DIR__.'/img/main_icon16.png')) {
153,10 → 179,20
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
 
/**
* @param $dir
* @param $basepath
* @param $results
* @return array|mixed
*/
private static function getDirContents($dir, $basepath = null, &$results = array()) {
if (is_null($basepath)) $basepath = $dir;
$basepath = realpath($basepath) . DIRECTORY_SEPARATOR;
179,6 → 215,10
return $results;
}
 
/**
* @param $checksumfile
* @return array|false
*/
private static function checksumFileToArray($checksumfile) {
$out = array();
 
/trunk/plugins/viathinksoft/adminPages/910_automated_ajax_calls/OIDplusPageAdminAutomatedAJAXCalls.class.php
28,7 → 28,13
 
class OIDplusPageAdminAutomatedAJAXCalls extends OIDplusPagePluginAdmin {
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return int[]
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
if ($actionID == 'blacklistJWT') {
if (!OIDplus::authUtils()->isAdminLoggedIn()) {
throw new OIDplusException(_L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')));
45,11 → 51,18
 
return array("status" => 0);
} else {
throw new OIDplusException(_L('Unknown action ID'));
return parent::action($actionID, $params);
}
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if ($id === 'oidplus:automated_ajax_information_admin') {
$handled = true;
$out['title'] = _L('Automated AJAX calls');
125,7 → 138,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
if (file_exists(__DIR__.'/img/main_icon16.png')) {
143,7 → 164,11
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
/trunk/plugins/viathinksoft/adminPages/920_nostalgia/OIDplusPageAdminNostalgia.class.php
28,7 → 28,14
 
class OIDplusPageAdminNostalgia extends OIDplusPagePluginAdmin {
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if ($id === 'oidplus:nostalgia') {
$handled = true;
$out['title'] = _L('Nostalgia');
62,7 → 69,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
if (file_exists(__DIR__.'/img/main_icon16.png')) {
80,17 → 95,30
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications()
return false;
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.8
* @param $user
* @return array
* @throws OIDplusException
*/
public function getNotifications($user=null): array {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.8
$notifications = array();
if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) {
if (!class_exists('ZipArchive')) {
/trunk/plugins/viathinksoft/adminPages/920_nostalgia/export_dos.php
106,19 → 106,17
}
 
// https://github.com/danielmarschall/oidplus_dos/blob/master/OIDFILE.PAS
define('CMD_VERSION', 'VERS');
define('CMD_OWN_ID', 'SELF');
define('CMD_PARENT', 'SUPR');
define('CMD_CHILD', 'CHLD');
define('CMD_ASN1_IDENTIFIER', 'ASN1');
define('CMD_UNICODE_LABEL', 'UNIL');
define('CMD_DESCRIPTION', 'DESC');
const CMD_VERSION = 'VERS';
const CMD_OWN_ID = 'SELF';
const CMD_PARENT = 'SUPR';
const CMD_CHILD = 'CHLD';
const CMD_ASN1_IDENTIFIER = 'ASN1';
const CMD_UNICODE_LABEL = 'UNIL';
const CMD_DESCRIPTION = 'DESC';
 
foreach ($dos_ids as $oid => $dos_id) {
$cont = '';
$cont = make_line(CMD_VERSION, 2022);
 
$cont .= make_line(CMD_VERSION, 2022);
 
$cont .= make_line(CMD_OWN_ID, $dos_id.$oid);
 
$parent_oid = $parent_oids[$oid];
/trunk/plugins/viathinksoft/auth/A3_bcrypt/OIDplusAuthPluginBCrypt.class.php
25,16 → 25,25
 
class OIDplusAuthPluginBCrypt extends OIDplusAuthPlugin {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
* @throws OIDplusException
*/
public function init(bool $html=true) {
// Note: Example #3 here https://www.php.net/manual/en/function.password-hash.php can help you with finding a good cost value
OIDplus::config()->prepareConfigKey('ra_bcrypt_cost', 'How complex should the BCrypt hash of RA passwords be? (Only for plugin A3_bcrypt; values 4-31, default 10)', 10, OIDplusConfig::PROTECTION_EDITABLE, function($value) {
if (empty($value) || !is_int($value) || ($value<4) || ($value>31)) {
OIDplus::config()->prepareConfigKey('ra_bcrypt_cost', 'How complex should the BCrypt hash of RA passwords be? (Only for plugin A3_bcrypt; values 4-31, default 10)', '10', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
if (empty($value) || !is_numeric($value) || ($value<4) || ($value>31)) {
throw new OIDplusException(_L('Invalid value for "cost" (must be 4-31, default 10).'));
}
});
}
 
private function supportedCryptAlgo($authKey) {
/**
* @param string $authKey
* @return bool
*/
private function supportedCryptAlgo(string $authKey): bool {
return str_starts_with($authKey, '$2$') ||
str_starts_with($authKey, '$2a$') ||
str_starts_with($authKey, '$2b$') ||
42,7 → 51,12
str_starts_with($authKey, '$2y$');
}
 
public function verify(OIDplusRAAuthInfo $authInfo, $check_password) {
/**
* @param OIDplusRAAuthInfo $authInfo
* @param string $check_password
* @return bool
*/
public function verify(OIDplusRAAuthInfo $authInfo, string $check_password): bool {
$authKey = $authInfo->getAuthKey();
 
if (!$this->supportedCryptAlgo($authKey)) {
57,7 → 71,12
return password_verify($check_password, $authKey);
}
 
public function generate($password): OIDplusRAAuthInfo {
/**
* @param string $password
* @return OIDplusRAAuthInfo
* @throws OIDplusException
*/
public function generate(string $password): OIDplusRAAuthInfo {
if (strlen($password) > 72) throw new OIDplusException(_L('Password is too long (max %1 bytes)',72));
$cost = OIDplus::config()->getValue('ra_bcrypt_cost', 10);
$calc_authkey = password_hash($password, PASSWORD_BCRYPT, array("cost" => $cost));
66,7 → 85,11
return new OIDplusRAAuthInfo($calc_authkey);
}
 
public function availableForHash(&$reason): bool {
/**
* @param string $reason
* @return bool
*/
public function availableForHash(string &$reason): bool {
if (version_compare(PHP_VERSION, '7.4.0') >= 0) {
$ok = in_array('2', password_algos()) ||
in_array('2a', password_algos()) ||
84,7 → 107,11
return false;
}
 
public function availableForVerify(&$reason): bool {
/**
* @param string $reason
* @return bool
*/
public function availableForVerify(string &$reason): bool {
return $this->availableForHash($reason);
}
 
/trunk/plugins/viathinksoft/auth/A4_argon2/OIDplusAuthPluginArgon2.class.php
25,16 → 25,29
 
class OIDplusAuthPluginArgon2 extends OIDplusAuthPlugin {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
// TODO: Let the admin decide about the memory, iterations, and parallelism options
}
 
private function supportedCryptAlgo($authKey) {
/**
* @param string $authKey
* @return bool
*/
private function supportedCryptAlgo(string $authKey): bool {
return str_starts_with($authKey, '$argon2i$') ||
str_starts_with($authKey, '$argon2id$');
}
 
public function verify(OIDplusRAAuthInfo $authInfo, $check_password) {
/**
* @param OIDplusRAAuthInfo $authInfo
* @param string $check_password
* @return bool
*/
public function verify(OIDplusRAAuthInfo $authInfo, string $check_password): bool {
$authKey = $authInfo->getAuthKey();
 
if (!$this->supportedCryptAlgo($authKey)) {
49,7 → 62,10
return password_verify($check_password, $authKey);
}
 
private function getBestHashAlgo() {
/**
* @return string|int|false
*/
private function getBestHashAlgo() { /* @phpstan-ignore-line */
if ($this->supportsArgon2id()) {
$hashalgo = PASSWORD_ARGON2ID;
} else if ($this->supportsArgon2i()) {
60,7 → 76,12
return $hashalgo;
}
 
public function generate($password): OIDplusRAAuthInfo {
/**
* @param string $password
* @return OIDplusRAAuthInfo
* @throws OIDplusException
*/
public function generate(string $password): OIDplusRAAuthInfo {
$hashalgo = $this->getBestHashAlgo();
assert($hashalgo !== false); // Should not happen if we called available() before!
$calc_authkey = password_hash($password, $hashalgo);
69,6 → 90,9
return new OIDplusRAAuthInfo($calc_authkey);
}
 
/**
* @return bool
*/
private function supportsArgon2i(): bool {
if (version_compare(PHP_VERSION, '7.4.0') >= 0) {
return in_array('argon2i', password_algos());
77,6 → 101,9
}
}
 
/**
* @return bool
*/
private function supportsArgon2id(): bool {
if (version_compare(PHP_VERSION, '7.4.0') >= 0) {
return in_array('argon2id', password_algos());
85,7 → 112,11
}
}
 
public function availableForHash(&$reason): bool {
/**
* @param string $reason
* @return bool
*/
public function availableForHash(string &$reason): bool {
if (!$this->supportsArgon2i() && !$this->supportsArgon2id()) {
$reason = _L('No fitting hash algorithm found');
return false;
94,7 → 125,11
}
}
 
public function availableForVerify(&$reason): bool {
/**
* @param string $reason
* @return bool
*/
public function availableForVerify(string &$reason): bool {
return $this->availableForHash($reason);
}
 
/trunk/plugins/viathinksoft/auth/A5_vts_mcf/OIDplusAuthPluginVtsMcf.class.php
25,7 → 25,12
 
class OIDplusAuthPluginVtsMcf extends OIDplusAuthPlugin {
 
public function verify(OIDplusRAAuthInfo $authInfo, $check_password) {
/**
* @param OIDplusRAAuthInfo $authInfo
* @param string $check_password
* @return bool
*/
public function verify(OIDplusRAAuthInfo $authInfo, string $check_password): bool {
$authKey = $authInfo->getAuthKey();
 
if (vts_crypt_version($authKey) != '0') {
35,7 → 40,12
}
}
 
public function generate($password): OIDplusRAAuthInfo {
/**
* @param string $password
* @return OIDplusRAAuthInfo
* @throws OIDplusException
*/
public function generate(string $password): OIDplusRAAuthInfo {
$calc_authkey = vts_password_hash($password, PASSWORD_VTS_MCF1, array(
'algo' => 'sha3-512', // we can safely use it, because we have a pure-PHP implementation shipped with OIDplus
'mode' => 'hmac'
43,11 → 53,19
return new OIDplusRAAuthInfo($calc_authkey);
}
 
public function availableForHash(&$reason): bool {
/**
* @param string $reason
* @return bool
*/
public function availableForHash(string &$reason): bool {
return function_exists('vts_password_hash');
}
 
public function availableForVerify(&$reason): bool {
/**
* @param string $reason
* @return bool
*/
public function availableForVerify(string &$reason): bool {
return function_exists('vts_password_verify');
}
 
/trunk/plugins/viathinksoft/auth/A6_crypt/OIDplusAuthPluginCrypt.class.php
25,22 → 25,40
 
class OIDplusAuthPluginCrypt extends OIDplusAuthPlugin {
 
public function verify(OIDplusRAAuthInfo $authInfo, $check_password) {
/**
* @param OIDplusRAAuthInfo $authInfo
* @param string $check_password
* @return bool
*/
public function verify(OIDplusRAAuthInfo $authInfo, string $check_password): bool {
$authKey = $authInfo->getAuthKey();
return password_verify($check_password, $authKey);
}
 
public function generate($password): OIDplusRAAuthInfo {
/**
* @param string $password
* @return OIDplusRAAuthInfo
* @throws OIDplusException
*/
public function generate(string $password): OIDplusRAAuthInfo {
$hashalgo = PASSWORD_SHA512; // choose the best out of crypt()
$calc_authkey = vts_password_hash($password, $hashalgo);
return new OIDplusRAAuthInfo($calc_authkey);
}
 
public function availableForHash(&$reason): bool {
/**
* @param string $reason
* @return bool
*/
public function availableForHash(string &$reason): bool {
return function_exists('vts_password_hash');
}
 
public function availableForVerify(&$reason): bool {
/**
* @param string $reason
* @return bool
*/
public function availableForVerify(string &$reason): bool {
return function_exists('vts_password_verify');
}
 
/trunk/plugins/viathinksoft/captcha/hcaptcha/OIDplusCaptchaPluginHCaptcha.class.php
25,15 → 25,27
 
class OIDplusCaptchaPluginHCaptcha extends OIDplusCaptchaPlugin {
 
/**
* @return string
*/
public static function id(): string {
return 'hCaptcha';
}
 
/**
* @return bool
*/
public function isVisible(): bool {
return true;
}
 
public function captchaGenerate($header_text=null, $footer_text=null) {
/**
* @param string|null $header_text
* @param string|null $footer_text
* @return string
* @throws OIDplusException
*/
public function captchaGenerate(string $header_text=null, string $footer_text=null): string {
return ($header_text ? '<p>'.$header_text.'</p>' : '') .
'<noscript>'.
'<p><font color="red">'._L('You need to enable JavaScript to solve the CAPTCHA.').'</font></p>'.
46,7 → 58,13
($footer_text ? '<p>'.$footer_text.'</p>' : '');
}
 
public function captchaVerify($params, $fieldname=null) {
/**
* @param string[] $params
* @param string|null $fieldname
* @return void
* @throws OIDplusException
*/
public function captchaVerify(array $params, string $fieldname=null) {
$sitekey=OIDplus::baseConfig()->getValue('HCAPTCHA_SITEKEY', '');
$secret=OIDplus::baseConfig()->getValue('HCAPTCHA_SECRET', '');
 
79,6 → 97,9
}
}
 
/**
* @return string
*/
public static function setupHTML(): string {
$curl_status = function_exists('curl_init') ? 1 : 0;
return '<div id="CAPTCHAPLUGIN_PARAMS_HCAPTCHA">'.
90,7 → 111,11
'</div>';
}
 
function httpHeaderCheck(&$http_headers) {
/**
* @param array $http_headers
* @return void
*/
function httpHeaderCheck(array &$http_headers) {
 
// If you use CSP headers, please add the following to your configuration:
// script-src should include https://hcaptcha.com, https://*.hcaptcha.com
/trunk/plugins/viathinksoft/captcha/none/OIDplusCaptchaPluginNone.class.php
25,15 → 25,26
 
class OIDplusCaptchaPluginNone extends OIDplusCaptchaPlugin {
 
/**
* @return string
*/
public static function id(): string {
return 'None';
}
 
/**
* @return bool
*/
public function isVisible(): bool {
return false;
}
 
public function captchaGenerate($header_text=null, $footer_text=null) {
/**
* @param string|null $header_text
* @param string|null $footer_text
* @return string
*/
public function captchaGenerate(string $header_text=null, string $footer_text=null): string {
return '<script>
var oidplus_captcha_response = function() {
return OIDplusCaptchaPluginNone.captchaResponse();
44,10 → 55,18
</script>';
}
 
public function captchaVerify($params, $fieldname=null) {
/**
* @param array $params
* @param string|null $fieldname
* @return bool
*/
public function captchaVerify(array $params, string $fieldname=null): bool {
return true;
}
 
/**
* @return string
*/
public static function setupHTML(): string {
return '<div id="CAPTCHAPLUGIN_PARAMS_NONE">'.
'<p>'._L('No CAPTCHA will be used. Please note that your system will be prone to "Brute force" attacks.').'</p>'.
/trunk/plugins/viathinksoft/captcha/recaptcha/OIDplusCaptchaPluginRecaptcha.class.php
29,15 → 29,28
/*public*/ const RECAPTCHA_V2_INVISIBLE = 2;
/*public*/ const RECAPTCHA_V3 = 3;
 
/**
* @return string
*/
public static function id(): string {
return 'reCAPTCHA'; // TODO: Now it is called "reCAPTCHA"
}
 
/**
* @return bool
* @throws OIDplusException
*/
public function isVisible(): bool {
return OIDplus::baseConfig()->getValue('RECAPTCHA_VERSION', self::RECAPTCHA_V2_CHECKBOX) == self::RECAPTCHA_V2_CHECKBOX;
}
 
public function captchaGenerate($header_text=null, $footer_text=null) {
/**
* @param string|null $header_text
* @param string|null $footer_text
* @return string
* @throws OIDplusException
*/
public function captchaGenerate(string $header_text=null, string $footer_text=null): string {
return '<noscript>'.
'<p><font color="red">'._L('You need to enable JavaScript to solve the CAPTCHA.').'</font></p>'.
'</noscript>'.
76,7 → 89,13
(!$this->isVisible() || !$footer_text ? '' : '<p>'.$footer_text.'</p>');
}
 
public function captchaVerify($params, $fieldname=null) {
/**
* @param array $params
* @param string|null $fieldname
* @return void
* @throws OIDplusException
*/
public function captchaVerify(array $params, string $fieldname=null) {
$secret=OIDplus::baseConfig()->getValue('RECAPTCHA_PRIVATE', '');
 
if (is_null($fieldname)) $fieldname = 'oidplus-recaptcha-response'; // no individual AJAX field name (created by oidplus_captcha_response()) means that it is a plain POST event (e.g. by oobe.php)
100,6 → 119,9
}
}
 
/**
* @return string
*/
public static function setupHTML(): string {
return '<div id="CAPTCHAPLUGIN_PARAMS_RECAPTCHA">'.
'<p>(<a href="https://developers.google.com/recaptcha/intro" target="_blank">'._L('more information and obtain key').'</a>)</p>'.
114,7 → 136,11
'</div>';
}
 
function httpHeaderCheck(&$http_headers) {
/**
* @param array $http_headers
* @return void
*/
function httpHeaderCheck(array &$http_headers) {
$http_headers["Content-Security-Policy"]["script-src"][] = "https://www.google.com/";
$http_headers["Content-Security-Policy"]["script-src"][] = "https://www.gstatic.com/";
$http_headers["Content-Security-Policy"]["img-src"][] = "https://www.google.com/";
/trunk/plugins/viathinksoft/captcha/vts_challenge/OIDplusCaptchaPluginVtsClientChallenge.class.php
25,22 → 25,36
 
class OIDplusCaptchaPluginVtsClientChallenge extends OIDplusCaptchaPlugin {
 
/**
* @return string
*/
public static function id(): string {
return 'ViaThinkSoft Client Challenge';
}
 
/**
* @return bool
*/
public function isVisible(): bool {
return false;
}
 
public function csrfUnlock($actionID) {
if ($actionID == 'get_challenge') {
return true;
/**
* @param string $actionID
* @return bool
*/
public function csrfUnlock(string $actionID): bool {
if ($actionID == 'get_challenge') return true;
return parent::csrfUnlock($actionID);
}
return false;
}
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return array
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
if ($actionID == 'get_challenge') {
$server_secret='VtsClientChallenge:'.OIDplus::baseConfig()->getValue('SERVER_SECRET');
 
67,9 → 81,17
// Autosolve on=calculate result on page load; off=calculate result on form submit
"autosolve" => OIDplus::baseConfig()->getValue('VTS_CAPTCHA_AUTOSOLVE', true)
);
} else {
return parent::action($actionID, $params);
}
}
 
/**
* @param $ip_target
* @param $random
* @return string
* @throws OIDplusException
*/
private static function getOpenTransFileName($ip_target, $random) {
$dir = OIDplus::localpath().'/userdata/cache';
$server_secret='VtsClientChallenge:'.OIDplus::baseConfig()->getValue('SERVER_SECRET');
86,7 → 108,13
return $dir.'/vts_client_challenge_'.sha3_512_hmac($ip_target.'/'.$random, $server_secret).'.tmp';
}
 
public function captchaGenerate($header_text=null, $footer_text=null) {
/**
* @param string|null $header_text
* @param string|null $footer_text
* @return string
* @throws OIDplusException
*/
public function captchaGenerate(string $header_text=null, string $footer_text=null): string {
return '<noscript>'.
'<p><font color="red">'._L('You need to enable JavaScript to solve the CAPTCHA.').'</font></p>'.
'</noscript>'.
96,7 → 124,13
'</script>';
}
 
public function captchaVerify($params, $fieldname=null) {
/**
* @param array $params
* @param string|null $fieldname
* @return void
* @throws OIDplusException
*/
public function captchaVerify(array $params, string $fieldname=null) {
 
if (is_null($fieldname)) $fieldname = 'vts_validation_result';
 
133,6 → 167,9
}
}
 
/**
* @return string
*/
public static function setupHTML(): string {
return '<div id="CAPTCHAPLUGIN_PARAMS_VtsClientChallenge">'.
'<p>'._L('ViaThinkSoft Client Challenge lets the client computer solve a cryptographic problem instead of letting the user solve a CAPTCHA. This slows down brute-force attacks.').'</p>'.
/trunk/plugins/viathinksoft/database/mysqli/OIDplusDatabaseConnectionMySQLi.class.php
28,7 → 28,13
private $prepare_cache = array();
private $last_error = null; // we need that because MySQL divides prepared statement errors and normal query errors, but we have only one "error()" method
 
public function doQuery(string $sql, /*?array*/ $prepared_args=null): OIDplusQueryResult {
/**
* @param string $sql
* @param array|null $prepared_args
* @return OIDplusQueryResultMySQL|OIDplusQueryResultMySQLNoNativeDriver
* @throws OIDplusException
*/
public function doQuery(string $sql, array $prepared_args=null): OIDplusQueryResult {
$this->last_error = null;
if (is_null($prepared_args)) {
$res = $this->conn->query($sql, MYSQLI_STORE_RESULT);
46,7 → 52,7
 
foreach ($prepared_args as &$value) {
// MySQLi has problems converting "true/false" to the data type "tinyint(1)"
// It seems to be the same issue like in PDO reported 14 years ago at https://bugs.php.net/bug.php?id=57157
// It seems to be the same issue as in PDO reported 14 years ago at https://bugs.php.net/bug.php?id=57157
if (is_bool($value)) $value = $value ? '1' : '0';
}
 
87,10 → 93,16
}
}
 
/**
* @return int
*/
public function insert_id(): int {
return $this->conn->insert_id;
}
 
/**
* @return string
*/
public function error(): string {
$err = $this->last_error;
if ($err == null) $err = '';
97,6 → 109,11
return $err;
}
 
/**
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
protected function doConnect()/*: void*/ {
if (!function_exists('mysqli_connect')) throw new OIDplusException(_L('PHP extension "%1" not installed','MySQLi'));
 
120,6 → 137,9
$this->query("SET NAMES 'utf8'");
}
 
/**
* @return void
*/
protected function doDisconnect()/*: void*/ {
$this->prepare_cache = array();
if (!is_null($this->conn)) {
128,16 → 148,29
}
}
 
/**
* @var bool
*/
private $intransaction = false;
 
/**
* @return bool
*/
public function transaction_supported(): bool {
return true;
}
 
/**
* @return int
*/
public function transaction_level(): int {
return $this->intransaction ? 1 : 0;
}
 
/**
* @return void
* @throws OIDplusException
*/
public function transaction_begin()/*: void*/ {
if ($this->intransaction) throw new OIDplusException(_L('Nested transactions are not supported by this database plugin.'));
$this->conn->autocommit(false);
145,6 → 178,9
$this->intransaction = true;
}
 
/**
* @return void
*/
public function transaction_commit()/*: void*/ {
$this->conn->commit();
$this->conn->autocommit(true);
151,6 → 187,9
$this->intransaction = false;
}
 
/**
* @return void
*/
public function transaction_rollback()/*: void*/ {
$this->conn->rollback();
$this->conn->autocommit(true);
157,15 → 196,27
$this->intransaction = false;
}
 
/**
* @return string
*/
public function sqlDate(): string {
return 'now()';
}
 
/**
* @return bool
* @throws OIDplusException
*/
public static function nativeDriverAvailable(): bool {
return function_exists('mysqli_fetch_all') && (OIDplus::baseConfig()->getValue('MYSQL_FORCE_MYSQLND_SUPPLEMENT', false) === false);
}
 
private static function bind_placeholder_vars(&$stmt,$params): bool {
/**
* @param object $stmt
* @param array $params
* @return bool
*/
private static function bind_placeholder_vars(object &$stmt, array $params): bool {
// Credit to: Dave Morgan
// Code taken from: http://www.devmorgan.com/blog/2009/03/27/dydl-part-3-dynamic-binding-with-mysqli-php/
// https://stackoverflow.com/questions/17219214/how-to-bind-in-mysqli-dynamically
201,6 → 252,11
}
}
 
/**
* @param bool $mustExist
* @return OIDplusSqlSlangPlugin|null
* @throws OIDplusConfigInitializationException
*/
protected function doGetSlang(bool $mustExist=true)/*: ?OIDplusSqlSlangPlugin*/ {
$slang = OIDplus::getSqlSlangPlugin('mysql');
if (is_null($slang)) {
/trunk/plugins/viathinksoft/database/mysqli/OIDplusDatabasePluginMySQLi.class.php
25,14 → 25,23
 
class OIDplusDatabasePluginMySQLi extends OIDplusDatabasePlugin {
 
/**
* @return string
*/
public static function id(): string {
return "MySQL";
}
 
/**
* @return OIDplusDatabaseConnection
*/
public static function newConnection(): OIDplusDatabaseConnection {
return new OIDplusDatabaseConnectionMySQLi();
}
 
/**
* @return string
*/
public static function setupHTML(): string {
return '<div id="DBPLUGIN_PARAMS_MySQL">'.
' <p>'._L('MySQL hostname and port').':<br><input id="mysql_host" type="text" value="localhost:3306" onkeypress="rebuild()" onkeyup="rebuild()"> <span id="mysql_host_warn"></span></p>'.
/trunk/plugins/viathinksoft/database/mysqli/OIDplusQueryResultMySQL.class.php
27,6 → 27,9
protected $no_resultset;
protected $res;
 
/**
* @param $res
*/
public function __construct($res) {
$this->no_resultset = is_bool($res);
 
35,24 → 38,42
}
}
 
/**
*
*/
public function __destruct() {
if ($this->res) $this->res->close();
}
 
/**
* @return bool
*/
public function containsResultSet(): bool {
return !$this->no_resultset;
}
 
/**
* @return int
* @throws OIDplusException
*/
public function num_rows(): int {
if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
return $this->res->num_rows;
}
 
/**
* @return array|null
* @throws OIDplusException
*/
public function fetch_array()/*: ?array*/ {
if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
return $this->res->fetch_array(MYSQLI_ASSOC);
}
 
/**
* @return object|null
* @throws OIDplusException
*/
public function fetch_object()/*: ?object*/ {
if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
return $this->res->fetch_object("stdClass");
/trunk/plugins/viathinksoft/database/mysqli/OIDplusQueryResultMySQLNoNativeDriver.class.php
30,6 → 30,9
protected $nCols = null;
protected $no_resultset = null;
 
/**
* @param $stmt
*/
public function __construct($stmt) {
$metadata = mysqli_stmt_result_metadata($stmt);
 
45,10 → 48,17
}
}
 
/**
* @return bool
*/
public function containsResultSet(): bool {
return !$this->no_resultset;
}
 
/**
* @return int
* @throws OIDplusException
*/
public function num_rows(): int {
if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
 
56,6 → 66,10
return $this->stmt->num_rows;
}
 
/**
* @return array|null
* @throws OIDplusException
*/
public function fetch_array()/*: ?array*/ {
if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
 
96,6 → 110,11
return $ret;
}
 
/**
* @return \stdClass|null
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function fetch_object()/*: ?object*/ {
if ($this->no_resultset) throw new OIDplusConfigInitializationException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
 
/trunk/plugins/viathinksoft/database/oci/OIDplusDatabaseConnectionOci.class.php
27,7 → 27,13
private $conn = null;
private $last_error = null; // do the same like MySQL+PDO, just to be equal in the behavior
 
public function doQuery(string $sql, /*?array*/ $prepared_args=null): OIDplusQueryResult {
/**
* @param string $sql
* @param array|null $prepared_args
* @return OIDplusQueryResultOci
* @throws OIDplusException
*/
public function doQuery(string $sql, array $prepared_args=null): OIDplusQueryResult {
$this->last_error = null;
 
$mode = $this->intransaction ? OCI_NO_AUTO_COMMIT : OCI_COMMIT_ON_SUCCESS;
87,6 → 93,9
}
}
 
/**
* @return string
*/
public function error(): string {
$err = $this->last_error;
if ($err == null) $err = '';
106,6 → 115,11
return $err;
}
 
/**
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
protected function doConnect()/*: void*/ {
if (!function_exists('oci_connect')) throw new OIDplusConfigInitializationException(_L('PHP extension "%1" not installed','OCI8'));
 
134,6 → 148,9
$this->last_error = null;
}
 
/**
* @return void
*/
protected function doDisconnect()/*: void*/ {
if (!is_null($this->conn)) {
oci_close($this->conn);
141,16 → 158,29
}
}
 
/**
* @var bool
*/
private $intransaction = false;
 
/**
* @return bool
*/
public function transaction_supported(): bool {
return true;
}
 
/**
* @return int
*/
public function transaction_level(): int {
return $this->intransaction ? 1 : 0;
}
 
/**
* @return void
* @throws OIDplusException
*/
public function transaction_begin()/*: void*/ {
if ($this->intransaction) throw new OIDplusException(_L('Nested transactions are not supported by this database plugin.'));
// Later, in oci_execute() we will include OCI_NO_AUTO_COMMIT
157,16 → 187,27
$this->intransaction = true;
}
 
/**
* @return void
*/
public function transaction_commit()/*: void*/ {
oci_commit($this->conn);
$this->intransaction = false;
}
 
/**
* @return void
*/
public function transaction_rollback()/*: void*/ {
oci_rollback($this->conn);
$this->intransaction = false;
}
 
/**
* @param bool $mustExist
* @return OIDplusSqlSlangPlugin|null
* @throws OIDplusConfigInitializationException
*/
protected function doGetSlang(bool $mustExist=true)/*: ?OIDplusSqlSlangPlugin*/ {
$slang = OIDplus::getSqlSlangPlugin('oracle');
if (is_null($slang)) {
/trunk/plugins/viathinksoft/database/oci/OIDplusDatabasePluginOci.class.php
25,14 → 25,23
 
class OIDplusDatabasePluginOci extends OIDplusDatabasePlugin {
 
/**
* @return string
*/
public static function id(): string {
return "Oracle (OCI8)";
}
 
/**
* @return OIDplusDatabaseConnection
*/
public static function newConnection(): OIDplusDatabaseConnection {
return new OIDplusDatabaseConnectionOci();
}
 
/**
* @return string
*/
public static function setupHTML(): string {
return '<div id="DBPLUGIN_PARAMS_OCI">'.
' <p>'._L('Oracle connection string, e.g. %1', 'localhost/orcl').':<br><input id="oci_conn_str" type="text" onkeypress="rebuild()" onkeyup="rebuild()"> <span id="oci_conn_str_warn"></span></p>'.
/trunk/plugins/viathinksoft/database/oci/OIDplusQueryResultOci.class.php
27,6 → 27,9
protected $no_resultset;
protected $res;
 
/**
* @param $res
*/
public function __construct($res) {
$this->no_resultset = is_bool($res);
 
35,6 → 38,9
}
}
 
/**
*
*/
public function __destruct() {
if ($this->res) {
oci_free_statement($this->res);
41,13 → 47,27
}
}
 
/**
* @return bool
*/
public function containsResultSet(): bool {
return !$this->no_resultset;
}
 
/**
* @var ?array
*/
private $prefetchedArray = null;
 
/**
* @var int
*/
private $countAlreadyFetched = 0;
 
/**
* @return int
* @throws OIDplusException
*/
public function num_rows(): int {
if (!is_null($this->prefetchedArray)) {
return count($this->prefetchedArray) + $this->countAlreadyFetched;
63,6 → 83,10
return count($this->prefetchedArray) + $this->countAlreadyFetched;
}
 
/**
* @return array|mixed|null
* @throws OIDplusException
*/
public function fetch_array()/*: ?array*/ {
if (!is_null($this->prefetchedArray)) {
$ret = array_shift($this->prefetchedArray);
86,6 → 110,10
return $ret;
}
 
/**
* @param $ary
* @return \stdClass
*/
private static function array_to_stdobj($ary) {
$obj = new \stdClass;
foreach ($ary as $name => $val) {
101,6 → 129,10
return $obj;
}
 
/**
* @return false|object|\stdClass|null
* @throws OIDplusException
*/
public function fetch_object()/*: ?object*/ {
if (!is_null($this->prefetchedArray)) {
$ary = array_shift($this->prefetchedArray);
115,7 → 147,7
// Oracle returns $ret['VALUE'] because unquoted column-names are always upper-case
// We can't quote every single column throughout the whole program, so we use this workaround...
if ($ret) {
foreach ($ret as $name => $val) {
foreach ($ret as $name => $val) { /* @phpstan-ignore-line */
$ret->{strtoupper($name)} = $val;
$ret->{strtolower($name)} = $val;
}
/trunk/plugins/viathinksoft/database/odbc/OIDplusDatabaseConnectionODBC.class.php
28,6 → 28,10
private $last_error = null; // do the same like MySQL+PDO, just to be equal in the behavior
private $transactions_supported = false;
 
/**
* @return bool|null
* @throws OIDplusException
*/
protected function forcePrepareEmulation() {
$mode = OIDplus::baseConfig()->getValue('PREPARED_STATEMENTS_EMULATION', 'auto');
if ($mode === 'on') return true;
43,7 → 47,15
return $res;
}
 
protected function doQueryInternalPrepare(string $sql, /*?array*/ $prepared_args=null): OIDplusQueryResult {
/**
* @param string $sql
* @param array|null $prepared_args
* @return OIDplusQueryResultODBC
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
* @throws OIDplusSQLException
*/
protected function doQueryInternalPrepare(string $sql, array $prepared_args=null): OIDplusQueryResultODBC {
foreach ($prepared_args as &$value) {
// ODBC/SQLServer has problems converting "true" to the data type "bit"
// Error "Invalid character value for cast specification"
77,7 → 89,15
 
}
 
protected function doQueryPrepareEmulation(string $sql, /*?array*/ $prepared_args=null): OIDplusQueryResult {
/**
* @param string $sql
* @param array|null $prepared_args
* @return OIDplusQueryResultODBC
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
* @throws OIDplusSQLException
*/
protected function doQueryPrepareEmulation(string $sql, array $prepared_args=null): OIDplusQueryResultODBC {
// For some drivers (e.g. Microsoft Access), we need to do this kind of emulation, because odbc_prepare() does not work
$sql = str_replace('?', chr(1), $sql);
foreach ($prepared_args as $arg) {
109,7 → 129,13
return new OIDplusQueryResultODBC($ps);
}
 
public function doQuery(string $sql, /*?array*/ $prepared_args=null): OIDplusQueryResult {
/**
* @param string $sql
* @param array|null $prepared_args
* @return OIDplusQueryResultODBC
* @throws OIDplusException
*/
public function doQuery(string $sql, array $prepared_args=null): OIDplusQueryResult {
$this->last_error = null;
if (is_null($prepared_args)) {
$res = @odbc_exec($this->conn, $sql);
133,13 → 159,20
}
}
 
/**
* @return string
*/
public function error(): string {
$err = $this->last_error;
if ($err == null) $err = '';
$err = vts_utf8_encode($err); // because ODBC might output weird stuff ...
return $err;
return vts_utf8_encode($err); // UTF-8 encode, because ODBC might output weird stuff ...
}
 
/**
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
protected function doConnect()/*: void*/ {
if (!function_exists('odbc_connect')) throw new OIDplusConfigInitializationException(_L('PHP extension "%1" not installed','ODBC'));
 
172,6 → 205,9
@odbc_autocommit($this->conn, true);
}
 
/**
* @return void
*/
protected function doDisconnect()/*: void*/ {
if (!is_null($this->conn)) {
@odbc_close($this->conn);
179,12 → 215,21
}
}
 
/**
* @var bool
*/
private $intransaction = false;
 
/**
* @return bool
*/
public function transaction_supported(): bool {
return $this->transactions_supported;
}
 
/**
* @return int
*/
public function transaction_level(): int {
if (!$this->transaction_supported()) {
// TODO?
193,6 → 238,10
return $this->intransaction ? 1 : 0;
}
 
/**
* @return void
* @throws OIDplusException
*/
public function transaction_begin()/*: void*/ {
if (!$this->transaction_supported()) {
// TODO?
203,6 → 252,9
$this->intransaction = true;
}
 
/**
* @return void
*/
public function transaction_commit()/*: void*/ {
if (!$this->transaction_supported()) {
// TODO?
213,6 → 265,9
$this->intransaction = false;
}
 
/**
* @return void
*/
public function transaction_rollback()/*: void*/ {
if (!$this->transaction_supported()) {
// TODO?
/trunk/plugins/viathinksoft/database/odbc/OIDplusDatabasePluginODBC.class.php
25,14 → 25,23
 
class OIDplusDatabasePluginODBC extends OIDplusDatabasePlugin {
 
/**
* @return string
*/
public static function id(): string {
return "ODBC";
}
 
/**
* @return OIDplusDatabaseConnection
*/
public static function newConnection(): OIDplusDatabaseConnection {
return new OIDplusDatabaseConnectionODBC();
}
 
/**
* @return string
*/
public static function setupHTML(): string {
return '<div id="DBPLUGIN_PARAMS_ODBC">'.
' <p>'._L('ODBC DSN').' (<a href="https://www.connectionstrings.com/" target="_blank">'._L('examples').'</a>):<br><input id="odbc_dsn" type="text" value="DRIVER={SQL Server};SERVER=localhost\instancename;DATABASE=oidplus;CHARSET=UTF8" onkeypress="rebuild()" onkeyup="rebuild()" style="width:600px"> <span id="odbc_dsn_warn"></span>'.
/trunk/plugins/viathinksoft/database/odbc/OIDplusQueryResultODBC.class.php
27,6 → 27,9
protected $no_resultset;
protected $res;
 
/**
* @param $res
*/
public function __construct($res) {
$this->no_resultset = is_bool($res);
 
35,14 → 38,23
}
}
 
/**
*
*/
public function __destruct() {
// odbc_close_cursor($this->res);
}
 
/**
* @return bool
*/
public function containsResultSet(): bool {
return !$this->no_resultset;
}
 
/**
* @return int
*/
private function num_rows_workaround(): int {
$dummy = 0;
 
66,6 → 78,10
return $ret;
}
 
/**
* @return int
* @throws OIDplusException
*/
public function num_rows(): int {
if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
$ret = odbc_num_rows($this->res);
78,6 → 94,10
return $ret;
}
 
/**
* @return array|null
* @throws OIDplusException
*/
public function fetch_array()/*: ?array*/ {
if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
$ret = odbc_fetch_array($this->res);
104,6 → 124,10
return $ret;
}
 
/**
* @return false|object|null
* @throws OIDplusException
*/
public function fetch_object()/*: ?object*/ {
if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
$ret = odbc_fetch_object($this->res);
/trunk/plugins/viathinksoft/database/pdo/OIDplusDatabaseConnectionPDO.class.php
28,7 → 28,13
private $last_error = null; // we need that because PDO divides prepared statement errors and normal query errors, but we have only one "error()" method
private $transactions_supported = false;
 
public function doQuery(string $sql, /*?array*/ $prepared_args=null): OIDplusQueryResult {
/**
* @param string $sql
* @param array|null $prepared_args
* @return OIDplusQueryResultPDO
* @throws OIDplusException
*/
public function doQuery(string $sql, array $prepared_args=null): OIDplusQueryResult {
$this->last_error = null;
if (is_null($prepared_args)) {
$res = $this->conn->query($sql);
73,6 → 79,10
}
}
 
/**
* @return int
* @throws OIDplusException
*/
public function insert_id(): int {
try {
$out = @($this->conn->lastInsertId());
83,6 → 93,9
}
}
 
/**
* @return string
*/
public function error(): string {
$err = $this->last_error;
if ($err == null) $err = '';
89,6 → 102,11
return $err;
}
 
/**
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
protected function doConnect()/*: void*/ {
if (!class_exists('PDO')) throw new OIDplusConfigInitializationException(_L('PHP extension "%1" not installed','PDO'));
 
135,16 → 153,28
}
}
 
/**
* @return void
*/
protected function doDisconnect()/*: void*/ {
$this->conn = null; // the connection will be closed by removing the reference
}
 
/**
* @var bool
*/
private $intransaction = false;
 
/**
* @return bool
*/
public function transaction_supported(): bool {
return $this->transactions_supported;
}
 
/**
* @return int
*/
public function transaction_level(): int {
if (!$this->transaction_supported()) {
// TODO?
153,6 → 183,10
return $this->intransaction ? 1 : 0;
}
 
/**
* @return void
* @throws OIDplusException
*/
public function transaction_begin()/*: void*/ {
if (!$this->transaction_supported()) {
// TODO?
163,6 → 197,9
$this->intransaction = true;
}
 
/**
* @return void
*/
public function transaction_commit()/*: void*/ {
if (!$this->transaction_supported()) {
// TODO?
172,6 → 209,9
$this->intransaction = false;
}
 
/**
* @return void
*/
public function transaction_rollback()/*: void*/ {
if (!$this->transaction_supported()) {
// TODO?
/trunk/plugins/viathinksoft/database/pdo/OIDplusDatabasePluginPDO.class.php
25,20 → 25,28
 
class OIDplusDatabasePluginPDO extends OIDplusDatabasePlugin {
 
/**
* @return string
*/
public static function id(): string {
return "PDO";
}
 
/**
* @return OIDplusDatabaseConnection
*/
public static function newConnection(): OIDplusDatabaseConnection {
return new OIDplusDatabaseConnectionPDO();
}
 
/**
* @return string
*/
public static function setupHTML(): string {
return '<div id="DBPLUGIN_PARAMS_PDO">'.
' <p>PDO DSN (<a href="https://www.php.net/manual/de/pdo.drivers.php" target="_blank">more information</a>):<br><input id="pdo_dsn" type="text" value="mysql:dbname=oidplus;host=localhost" onkeypress="rebuild()" onkeyup="rebuild()" style="width:600px"> <span id="pdo_dsn_warn"></span>'.
' <br><font size="-1">'._L('Example for MySQL/MariaDB').': <i>mysql:dbname=oidplus;host=localhost;port=3306</i>'.
' <br>'._L('Example for PostgreSQL').': <i>pgsql:dbname=oidplus;host=localhost;port=5432</i></font></p>'.
''.
' <p>'._L('PDO Username').':<br><input id="pdo_username" type="text" value="root" onkeypress="rebuild()" onkeyup="rebuild()"> <span id="pdo_username_warn"></span></p>'.
' <p>'._L('PDO Password').':<br><input id="pdo_password" type="password" value="" onkeypress="rebuild()" onkeyup="rebuild()"> <span id="pdo_password_warn"></span></p>'.
' <p>'._L('Which DBMS (SQL dialect) is used?').'<br>'.
/trunk/plugins/viathinksoft/database/pdo/OIDplusQueryResultPDO.class.php
27,6 → 27,9
protected $no_resultset;
protected $res;
 
/**
* @param $res
*/
public function __construct($res) {
$this->no_resultset = is_bool($res);
 
38,17 → 41,34
$this->prefetchedArray = $this->res->fetchAll();
}
 
/**
*
*/
public function __destruct() {
if ($this->res) $this->res->closeCursor();
}
 
/**
* @return bool
*/
public function containsResultSet(): bool {
return !$this->no_resultset;
}
 
/**
* @var ?array
*/
private $prefetchedArray = null;
 
/**
* @var int
*/
private $countAlreadyFetched = 0;
 
/**
* @return int
* @throws OIDplusException
*/
public function num_rows(): int {
if (!is_null($this->prefetchedArray)) {
return count($this->prefetchedArray) + $this->countAlreadyFetched;
67,6 → 87,10
return $ret;
}
 
/**
* @return array|mixed|null
* @throws OIDplusException
*/
public function fetch_array()/*: ?array*/ {
if (!is_null($this->prefetchedArray)) {
$ret = array_shift($this->prefetchedArray);
90,6 → 114,10
return $ret;
}
 
/**
* @param $ary
* @return \stdClass
*/
private static function array_to_stdobj($ary) {
$obj = new \stdClass;
foreach ($ary as $name => $val) {
98,6 → 126,10
return $obj;
}
 
/**
* @return object|\stdClass|null
* @throws OIDplusException
*/
public function fetch_object()/*: ?object*/ {
if (!is_null($this->prefetchedArray)) {
$ary = array_shift($this->prefetchedArray);
/trunk/plugins/viathinksoft/database/pgsql/OIDplusDatabaseConnectionPgSql.class.php
28,7 → 28,13
private $already_prepared = array();
private $last_error = null; // do the same like MySQL+PDO, just to be equal in the behavior
 
public function doQuery(string $sql, /*?array*/ $prepared_args=null): OIDplusQueryResult {
/**
* @param string $sql
* @param array|null $prepared_args
* @return OIDplusQueryResultPgSql
* @throws OIDplusException
*/
public function doQuery(string $sql, array $prepared_args=null): OIDplusQueryResult {
$this->last_error = null;
if (is_null($prepared_args)) {
$res = @pg_query($this->conn, $sql);
74,6 → 80,9
}
}
 
/**
* @return int
*/
public function insert_id(): int {
try {
return (int)$this->query('select lastval() as id')->fetch_object()->id;
82,6 → 91,9
}
}
 
/**
* @return string
*/
public function error(): string {
$err = $this->last_error;
if ($err == null) $err = '';
88,6 → 100,11
return $err;
}
 
/**
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
protected function doConnect()/*: void*/ {
if (!function_exists('pg_connect')) throw new OIDplusConfigInitializationException(_L('PHP extension "%1" not installed','PostgreSQL'));
 
135,6 → 152,9
}
}
 
/**
* @return void
*/
protected function doDisconnect()/*: void*/ {
$this->already_prepared = array();
if (!is_null($this->conn)) {
143,16 → 163,29
}
}
 
/**
* @var bool
*/
private $intransaction = false;
 
/**
* @return bool
*/
public function transaction_supported(): bool {
return true;
}
 
/**
* @return int
*/
public function transaction_level(): int {
return $this->intransaction ? 1 : 0;
}
 
/**
* @return void
* @throws OIDplusException
*/
public function transaction_begin()/*: void*/ {
if ($this->intransaction) throw new OIDplusException(_L('Nested transactions are not supported by this database plugin.'));
$this->query('begin transaction');
159,20 → 192,36
$this->intransaction = true;
}
 
/**
* @return void
* @throws OIDplusException
*/
public function transaction_commit()/*: void*/ {
$this->query('commit');
$this->intransaction = false;
}
 
/**
* @return void
* @throws OIDplusException
*/
public function transaction_rollback()/*: void*/ {
$this->query('rollback');
$this->intransaction = false;
}
 
/**
* @return string
*/
public function sqlDate(): string {
return 'now()';
}
 
/**
* @param bool $mustExist
* @return OIDplusSqlSlangPlugin|null
* @throws OIDplusConfigInitializationException
*/
protected function doGetSlang(bool $mustExist=true)/*: ?OIDplusSqlSlangPlugin*/ {
$slang = OIDplus::getSqlSlangPlugin('pgsql');
if (is_null($slang)) {
/trunk/plugins/viathinksoft/database/pgsql/OIDplusDatabasePluginPgSql.class.php
25,14 → 25,23
 
class OIDplusDatabasePluginPgSql extends OIDplusDatabasePlugin {
 
/**
* @return string
*/
public static function id(): string {
return "PgSQL";
}
 
/**
* @return OIDplusDatabaseConnection
*/
public static function newConnection(): OIDplusDatabaseConnection {
return new OIDplusDatabaseConnectionPgSql();
}
 
/**
* @return string
*/
public static function setupHTML(): string {
return '<div id="DBPLUGIN_PARAMS_PgSQL">'.
' <p>'._L('PgSQL hostname and port').':<br><input id="pgsql_host" type="text" value="localhost:5432" onkeypress="rebuild()" onkeyup="rebuild()"> <span id="pgsql_host_warn"></span></p>'.
/trunk/plugins/viathinksoft/database/pgsql/OIDplusQueryResultPgSql.class.php
27,6 → 27,9
protected $no_resultset;
protected $res;
 
/**
* @param $res
*/
public function __construct($res) {
$this->no_resultset = is_bool($res);
 
35,6 → 38,9
}
}
 
/**
*
*/
public function __destruct() {
if ($this->res) {
pg_free_result($this->res);
41,15 → 47,26
}
}
 
/**
* @return bool
*/
public function containsResultSet(): bool {
return !$this->no_resultset;
}
 
/**
* @return int
* @throws OIDplusException
*/
public function num_rows(): int {
if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
return pg_num_rows($this->res);
}
 
/**
* @return array|false|null
* @throws OIDplusException
*/
public function fetch_array()/*: ?array*/ {
if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
$ret = pg_fetch_array($this->res, null, PGSQL_ASSOC);
65,6 → 82,10
return $ret;
}
 
/**
* @return false|object|null
* @throws OIDplusException
*/
public function fetch_object()/*: ?object*/ {
if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
$ret = pg_fetch_object($this->res);
/trunk/plugins/viathinksoft/database/sqlite3/OIDplusDatabaseConnectionSQLite3.class.php
28,7 → 28,13
private $prepare_cache = array();
private $last_error = null; // do the same like MySQL+PDO, just to be equal in the behavior
 
public function doQuery(string $sql, /*?array*/ $prepared_args=null): OIDplusQueryResult {
/**
* @param string $sql
* @param array|null $prepared_args
* @return OIDplusQueryResultSQLite3
* @throws OIDplusException
*/
public function doQuery(string $sql, array $prepared_args=null): OIDplusQueryResult {
$this->last_error = null;
if (is_null($prepared_args)) {
try {
90,6 → 96,9
}
}
 
/**
* @return int
*/
public function insert_id(): int {
try {
// Note: This will always give results even for tables that do not
102,6 → 111,9
}
}
 
/**
* @return string
*/
public function error(): string {
$err = $this->last_error;
if ($err == null) $err = '';
108,6 → 120,10
return $err;
}
 
/**
* @return void
* @throws OIDplusConfigInitializationException
*/
protected function doConnect()/*: void*/ {
if (!class_exists('SQLite3')) throw new OIDplusConfigInitializationException(_L('PHP extension "%1" not installed','SQLite3'));
 
135,21 → 151,37
$this->last_error = null;
}
 
/**
* @return void
*/
protected function doDisconnect()/*: void*/ {
$this->prepare_cache = array();
$this->conn = null;
}
 
/**
* @var bool
*/
private $intransaction = false;
 
/**
* @return bool
*/
public function transaction_supported(): bool {
return true;
}
 
/**
* @return int
*/
public function transaction_level(): int {
return $this->intransaction ? 1 : 0;
}
 
/**
* @return void
* @throws OIDplusException
*/
public function transaction_begin()/*: void*/ {
if ($this->intransaction) throw new OIDplusException(_L('Nested transactions are not supported by this database plugin.'));
$this->query('begin transaction');
156,21 → 188,37
$this->intransaction = true;
}
 
/**
* @return void
* @throws OIDplusException
*/
public function transaction_commit()/*: void*/ {
$this->query('commit');
$this->intransaction = false;
}
 
/**
* @return void
* @throws OIDplusException
*/
public function transaction_rollback()/*: void*/ {
$this->query('rollback');
$this->intransaction = false;
}
 
/**
* @return string
*/
public function sqlDate(): string {
return 'datetime()';
}
 
public function natOrder($fieldname, $order='asc'): string {
/**
* @param string $fieldname
* @param string $order
* @return string
*/
public function natOrder(string $fieldname, string $order='asc'): string {
 
// This collation is defined in the database plugin using SQLite3::createCollation()
return "$fieldname COLLATE NATURAL_CMP $order";
177,6 → 225,11
 
}
 
/**
* @param bool $mustExist
* @return OIDplusSqlSlangPlugin|null
* @throws OIDplusConfigInitializationException
*/
protected function doGetSlang(bool $mustExist=true)/*: ?OIDplusSqlSlangPlugin*/ {
$slang = OIDplus::getSqlSlangPlugin('sqlite');
if (is_null($slang)) {
/trunk/plugins/viathinksoft/database/sqlite3/OIDplusDatabasePluginSQLite3.class.php
25,14 → 25,23
 
class OIDplusDatabasePluginSQLite3 extends OIDplusDatabasePlugin {
 
/**
* @return string
*/
public static function id(): string {
return "SQLite3";
}
 
/**
* @return OIDplusDatabaseConnection
*/
public static function newConnection(): OIDplusDatabaseConnection {
return new OIDplusDatabaseConnectionSQLite3();
}
 
/**
* @return string
*/
public static function setupHTML(): string {
return '<div id="DBPLUGIN_PARAMS_SQLite3">'.
' <p>'._L('SQLite3 database file').':<br><input id="sqlite3_file" type="text" value="userdata/database/oidplus.db" onkeypress="rebuild()" onkeyup="rebuild()"> <span id="sqlite3_file_warn"></span><br>'.
/trunk/plugins/viathinksoft/database/sqlite3/OIDplusQueryResultSQLite3.class.php
29,6 → 29,9
protected $all_results = array();
protected $cursor = 0;
 
/**
* @param $res
*/
public function __construct($res) {
if (is_bool($res) || ($res->numColumns() == 0)) {
// Why do qe need to check numColumns() ?
49,6 → 52,9
}
}
 
/**
*
*/
public function __destruct() {
$this->all_results = array();
if (!is_null($this->res)) {
57,15 → 63,26
}
}
 
/**
* @return bool
*/
public function containsResultSet(): bool {
return !$this->no_resultset;
}
 
/**
* @return int
* @throws OIDplusException
*/
public function num_rows(): int {
if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
return count($this->all_results);
}
 
/**
* @return array|mixed|null
* @throws OIDplusException
*/
public function fetch_array()/*: ?array*/ {
if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
 
80,6 → 97,10
return $ret;
}
 
/**
* @return \stdClass|null
* @throws OIDplusException
*/
public function fetch_object()/*: ?object*/ {
if ($this->no_resultset) throw new OIDplusException(_L('The query has returned no result set (i.e. it was not a SELECT query)'));
 
/trunk/plugins/viathinksoft/design/default/OIDplusDesignPluginDefault.class.php
25,7 → 25,10
 
class OIDplusDesignPluginDefault extends OIDplusDesignPlugin {
 
function getThemeColor() {
/**
* @return string
*/
function getThemeColor(): string {
return '#A9DCF0';
}
 
/trunk/plugins/viathinksoft/design/ironbase/OIDplusDesignPluginIronBase.class.php
25,7 → 25,10
 
class OIDplusDesignPluginIronBase extends OIDplusDesignPlugin {
 
function getThemeColor() {
/**
* @return string
*/
function getThemeColor(): string {
return '#F9F9F9';
}
 
/trunk/plugins/viathinksoft/language/dede/messages.xml
2270,14 → 2270,6
</message>
<message>
<source><![CDATA[
Field %1 is invalid
]]></source>
<target><![CDATA[
Feld %1 ist ungültig
]]></target>
</message>
<message>
<source><![CDATA[
Field %1 is too long. Max allowed %2
]]></source>
<target><![CDATA[
5446,14 → 5438,6
</message>
<message>
<source><![CDATA[
Plugin with OID %1 did not output array of result data
]]></source>
<target><![CDATA[
Plugin mit OID %1 hat kein Array bestehend aus Ergebnis-Daten geliefert
]]></target>
</message>
<message>
<source><![CDATA[
Plugins
]]></source>
<target><![CDATA[
7390,18 → 7374,18
</message>
<message>
<source><![CDATA[
Unicode label "%1" is too long (max allowed length %2)
Unexpected update version
]]></source>
<target><![CDATA[
Unicode-Label "%1" ist zu lang (Maximale Länge: %2)
Unerwartete Update-Version
]]></target>
</message>
<message>
<source><![CDATA[
Unknown action ID
Unicode label "%1" is too long (max allowed length %2)
]]></source>
<target><![CDATA[
Unbekannte Action-ID
Unicode-Label "%1" ist zu lang (Maximale Länge: %2)
]]></target>
</message>
<message>
/trunk/plugins/viathinksoft/logger/000_database/OIDplusLoggerPluginDatabase.class.php
25,16 → 25,27
 
class OIDplusLoggerPluginDatabase extends OIDplusLoggerPlugin {
 
public static function available(&$reason)/*: bool*/ {
/**
* @param string $reason
* @return bool
*/
public static function available(string &$reason): bool {
$reason = '';
return true;
}
 
public static function log($event, $users, $objects)/*: bool*/ {
/**
* @param string $event
* @param array $users
* @param array $objects
* @return bool
* @throws OIDplusException
*/
public static function log(string $event, array $users, array $objects): bool {
$addr = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
OIDplus::dbIsolated()->query("insert into ###log (addr, unix_ts, event) values (?, ?, ?)", array($addr, time(), $event));
$log_id = OIDplus::dbIsolated()->insert_id();
if ($log_id == 0) {
if ($log_id === 0) {
$res = OIDplus::dbIsolated()->query("select max(id) as last_id from ###log");
if (!$res->any()) throw new OIDplusException(_L('Could not log event'));
$row = $res->fetch_array();
/trunk/plugins/viathinksoft/logger/100_linux_syslog/OIDplusLoggerPluginLinuxSyslog.class.php
25,7 → 25,11
 
class OIDplusLoggerPluginLinuxSyslog extends OIDplusLoggerPlugin {
 
public static function available(&$reason)/*: bool*/ {
/**
* @param string $reason
* @return bool
*/
public static function available(string &$reason): bool {
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$reason = _L('Functionality not available on Windows');
return false;
45,7 → 49,13
return true;
}
 
public static function log($event, $users, $objects)/*: bool*/ {
/**
* @param string $event
* @param array $users
* @param array $objects
* @return bool
*/
public static function log(string $event, array $users, array $objects): bool {
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') return false;
 
if (!@file_exists('/var/log/syslog')) return false;
/trunk/plugins/viathinksoft/logger/200_windows_eventlog/OIDplusLoggerPluginWindowsEventLog.class.php
34,7 → 34,11
 
const LOGPROVIDER = 'OIDplus'; // "Source name" (should be registered in the registry = mapped to a message file DLL)
 
public static function available(&$reason)/*: bool*/ {
/**
* @param string $reason
* @return bool
*/
public static function available(string &$reason): bool {
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
$reason = _L('Functionality only available on Windows systems');
return false;
56,7 → 60,11
}
}
 
private static function convertOIDplusToWindowsSeverity($sev) {
/**
* @param int $sev
* @return int
*/
private static function convertOIDplusToWindowsSeverity(int $sev): int {
switch ($sev) {
case 0:
return self::LOGEVENT_MSG_INFORMATIONAL; // undefined
75,7 → 83,13
}
}
 
public static function log($event, $users, $objects)/*: bool*/ {
/**
* @param string $event
* @param array $users
* @param array $objects
* @return bool
*/
public static function log(string $event, array $users, array $objects): bool {
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
return false;
}
/trunk/plugins/viathinksoft/logger/300_userdata_logfile/OIDplusLoggerPluginUserdataLogfile.class.php
25,7 → 25,11
 
class OIDplusLoggerPluginUserdataLogfile extends OIDplusLoggerPlugin {
 
public static function available(&$reason)/*: bool*/ {
/**
* @param string $reason
* @return bool
*/
public static function available(string &$reason): bool {
if (!is_dir(OIDplus::localpath().'userdata/logs/')) {
$reason = _L('Directory userdata/logs/ not existing');
return false;
40,7 → 44,13
return true;
}
 
public static function log($event, $users, $objects)/*: bool*/ {
/**
* @param string $event
* @param array $users
* @param array $objects
* @return bool
*/
public static function log(string $event, array $users, array $objects): bool {
if (!is_dir(OIDplus::localpath().'userdata/logs/')) return false;
 
$users_names = array();
/trunk/plugins/viathinksoft/objectTypes/aid/OIDplusAid.class.php
26,42 → 26,73
class OIDplusAid extends OIDplusObject {
private $aid;
 
/**
* @param $aid
*/
public function __construct($aid) {
// TODO: syntax checks
$this->aid = $aid;
}
 
public static function parse($node_id) {
/**
* @param string $node_id
* @return OIDplusAid|null
*/
public static function parse(string $node_id)/*: ?OIDplusAid*/ {
@list($namespace, $aid) = explode(':', $node_id, 2);
if ($namespace !== self::ns()) return false;
if ($namespace !== self::ns()) return null;
return new self($aid);
}
 
public static function objectTypeTitle() {
/**
* @return string
*/
public static function objectTypeTitle(): string {
return _L('Application Identifier (ISO/IEC 7816)');
}
 
public static function objectTypeTitleShort() {
/**
* @return string
*/
public static function objectTypeTitleShort(): string {
return _L('AID');
}
 
public static function ns() {
/**
* @return string
*/
public static function ns(): string {
return 'aid';
}
 
public static function root() {
/**
* @return string
*/
public static function root(): string {
return self::ns().':';
}
 
public function isRoot() {
/**
* @return bool
*/
public function isRoot(): bool {
return $this->aid == '';
}
 
public function nodeId($with_ns=true) {
/**
* @param bool $with_ns
* @return string
*/
public function nodeId(bool $with_ns=true): string {
return $with_ns ? self::root().$this->aid : $this->aid;
}
 
public function addString($str) {
/**
* @param string $str
* @return string
* @throws OIDplusException
*/
public function addString(string $str): string {
$m = array();
 
$str = str_replace(' ','',$str);
94,30 → 125,54
return $this->nodeId(true).strtoupper($str);
}
 
public function crudShowId(OIDplusObject $parent) {
/**
* @param OIDplusObject $parent
* @return string
*/
public function crudShowId(OIDplusObject $parent): string {
return $this->chunkedNotation(false);
}
 
public function crudInsertPrefix() {
/**
* @return string
*/
public function crudInsertPrefix(): string {
return $this->isRoot() ? '' : $this->chunkedNotation(false);
}
 
public function jsTreeNodeName(OIDplusObject $parent = null) {
/**
* @param OIDplusObject|null $parent
* @return string
*/
public function jsTreeNodeName(OIDplusObject $parent = null): string {
if ($parent == null) return $this->objectTypeTitle();
return substr($this->nodeId(), strlen($parent->nodeId()));
}
 
public function defaultTitle() {
/**
* @return string
*/
public function defaultTitle(): string {
return $this->aid;
}
 
public function isLeafNode() {
/**
* @return bool
*/
public function isLeafNode(): bool {
// We don't know when an AID is "leaf", because an AID can have an arbitary length <= 16 Bytes.
// But if it is 16 bytes long (32 nibbles), then we are 100% certain that it is a leaf node.
return (strlen($this->nodeId(false)) == 32);
}
 
public function getContentPage(&$title, &$content, &$icon) {
/**
* @param string $title
* @param string $content
* @param string $icon
* @return void
* @throws OIDplusException
*/
public function getContentPage(string &$title, string &$content, string &$icon) {
$icon = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
 
if ($this->isRoot()) {
168,6 → 223,11
 
# ---
 
/**
* @param $withAbbr
* @return string
* @throws OIDplusException
*/
public function chunkedNotation($withAbbr=true) {
$curid = self::root().$this->aid;
 
204,13 → 264,20
return implode(' ', $full);
}
 
public function one_up() {
return OIDplusObject::parse($this->ns().':'.substr($this->aid,0,strlen($this->aid)-1));
/**
* @return OIDplusAid|null
*/
public function one_up()/*: ?OIDplusAid*/ {
return self::parse($this->ns().':'.substr($this->aid,0,strlen($this->aid)-1));
}
 
/**
* @param $to
* @return int|null
*/
public function distance($to) {
if (!is_object($to)) $to = OIDplusObject::parse($to);
if (!($to instanceof $this)) return false;
if (!($to instanceof $this)) return null;
 
$a = $to->aid;
$b = $this->aid;
221,13 → 288,17
$min_len = min(strlen($ary), strlen($bry));
 
for ($i=0; $i<$min_len; $i++) {
if ($ary[$i] != $bry[$i]) return false;
if ($ary[$i] != $bry[$i]) return null;
}
 
return strlen($ary) - strlen($bry);
}
 
public function getAltIds() {
/**
* @return array|OIDplusAltId[]
* @throws OIDplusException
*/
public function getAltIds(): array {
if ($this->isRoot()) return array();
$ids = parent::getAltIds();
 
397,12 → 468,19
return $ids;
}
 
public function getDirectoryName() {
/**
* @return string
*/
public function getDirectoryName(): string {
if ($this->isRoot()) return $this->ns();
return $this->ns().'_'.$this->nodeId(false); // safe, because there are only AIDs
}
 
public static function treeIconFilename($mode) {
/**
* @param string $mode
* @return string
*/
public static function treeIconFilename(string $mode): string {
return 'img/'.$mode.'_icon16.png';
}
}
/trunk/plugins/viathinksoft/objectTypes/aid/OIDplusObjectTypePluginAid.class.php
25,17 → 25,28
 
class OIDplusObjectTypePluginAid extends OIDplusObjectTypePlugin {
 
public static function getObjectTypeClassName() {
/**
* @return string
*/
public static function getObjectTypeClassName(): string {
return OIDplusAid::class;
}
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.6') return true; // gridGeneratorLinks
return false;
}
 
public function gridGeneratorLinks($objParent) { // Interface 1.3.6.1.4.1.37476.2.5.2.3.6
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.6
* @param $objParent
* @return string
*/
public function gridGeneratorLinks($objParent): string {
if ($objParent->isRoot()) {
return '<br><a href="javascript:OIDplusObjectTypePluginAid.generateRandomAID()">('._L('Generate a random AID - not unique!').')</a>'.
'<br><a href="https://oidplus.viathinksoft.com/oidplus/?goto=aid%3AD276000186F" target="_blank">('._L('Request a free AID from ViaThinkSoft').')</a>';
44,7 → 55,12
}
}
 
public static function prefilterQuery($static_node_id, $throw_exception) {
/**
* @param string $static_node_id
* @param bool $throw_exception
* @return string
*/
public static function prefilterQuery(string $static_node_id, bool $throw_exception): string {
if (str_starts_with($static_node_id,'aid:')) {
$static_node_id = str_replace(' ', '', $static_node_id);
 
/trunk/plugins/viathinksoft/objectTypes/doi/OIDplusDoi.class.php
26,42 → 26,73
class OIDplusDoi extends OIDplusObject {
private $doi;
 
/**
* @param $doi
*/
public function __construct($doi) {
// TODO: syntax checks
$this->doi = $doi;
}
 
public static function parse($node_id) {
/**
* @param string $node_id
* @return OIDplusDoi|null
*/
public static function parse(string $node_id)/*: ?OIDplusDoi*/ {
@list($namespace, $doi) = explode(':', $node_id, 2);
if ($namespace !== self::ns()) return false;
if ($namespace !== self::ns()) return null;
return new self($doi);
}
 
public static function objectTypeTitle() {
/**
* @return string
*/
public static function objectTypeTitle(): string {
return _L('Digital Object Identifier (DOI)');
}
 
public static function objectTypeTitleShort() {
/**
* @return string
*/
public static function objectTypeTitleShort(): string {
return _L('DOI');
}
 
public static function ns() {
/**
* @return string
*/
public static function ns(): string {
return 'doi';
}
 
public static function root() {
/**
* @return string
*/
public static function root(): string {
return self::ns().':';
}
 
public function isRoot() {
/**
* @return bool
*/
public function isRoot(): bool {
return $this->doi == '';
}
 
public function nodeId($with_ns=true) {
/**
* @param bool $with_ns
* @return string
*/
public function nodeId(bool $with_ns=true): string {
return $with_ns ? self::root().$this->doi : $this->doi;
}
 
public function addString($str) {
/**
* @param string $str
* @return string
* @throws OIDplusException
*/
public function addString(string $str): string {
if ($this->isRoot()) {
// Parent is root, so $str is the base DOI (10.xxxx)
$base = $str;
78,15 → 109,27
}
}
 
public function crudShowId(OIDplusObject $parent) {
/**
* @param OIDplusObject $parent
* @return string
*/
public function crudShowId(OIDplusObject $parent): string {
return $this->doi;
}
 
public function crudInsertPrefix() {
/**
* @return string
* @throws OIDplusException
*/
public function crudInsertPrefix(): string {
return $this->isRoot() ? '' : substr($this->addString(''), strlen(self::ns())+1);
}
 
public function jsTreeNodeName(OIDplusObject $parent = null) {
/**
* @param OIDplusObject|null $parent
* @return string
*/
public function jsTreeNodeName(OIDplusObject $parent = null): string {
if ($parent == null) return $this->objectTypeTitle();
$out = $this->doi;
$ary = explode('/', $out, 2);
94,15 → 137,28
return $out;
}
 
public function defaultTitle() {
/**
* @return string
*/
public function defaultTitle(): string {
return _L('DOI %1',$this->doi);
}
 
public function isLeafNode() {
/**
* @return bool
*/
public function isLeafNode(): bool {
return false;
}
 
public function getContentPage(&$title, &$content, &$icon) {
/**
* @param string $title
* @param string $content
* @param string $icon
* @return void
* @throws OIDplusException
*/
public function getContentPage(string &$title, string &$content, string &$icon) {
$icon = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
 
if ($this->isRoot()) {
144,12 → 200,19
 
# ---
 
public static function validBaseDoi($doi) {
/**
* @param string $doi
* @return bool
*/
public static function validBaseDoi(string $doi): bool {
$m = array();
return preg_match('@^10\.\d{4}$@', $doi, $m);
}
 
public function one_up() {
/**
* @return OIDplusDoi|null
*/
public function one_up()/*: ?OIDplusDoi*/ {
$oid = $this->doi;
 
$p = strrpos($oid, '/');
161,9 → 224,13
return self::parse(self::ns().':'.$oid_up);
}
 
/**
* @param $to
* @return int|null
*/
public function distance($to) {
if (!is_object($to)) $to = OIDplusObject::parse($to);
if (!($to instanceof $this)) return false;
if (!($to instanceof $this)) return null;
 
$a = $to->doi;
$b = $this->doi;
177,18 → 244,25
$min_len = min(count($ary), count($bry));
 
for ($i=0; $i<$min_len; $i++) {
if ($ary[$i] != $bry[$i]) return false;
if ($ary[$i] != $bry[$i]) return null;
}
 
return count($ary) - count($bry);
}
 
public function getDirectoryName() {
/**
* @return string
*/
public function getDirectoryName(): string {
if ($this->isRoot()) return $this->ns();
return $this->ns().'_'.md5($this->nodeId(false));
}
 
public static function treeIconFilename($mode) {
/**
* @param string $mode
* @return string
*/
public static function treeIconFilename(string $mode): string {
return 'img/'.$mode.'_icon16.png';
}
}
/trunk/plugins/viathinksoft/objectTypes/doi/OIDplusObjectTypePluginDoi.class.php
25,7 → 25,10
 
class OIDplusObjectTypePluginDoi extends OIDplusObjectTypePlugin {
 
public static function getObjectTypeClassName() {
/**
* @return string
*/
public static function getObjectTypeClassName(): string {
return OIDplusDoi::class;
}
 
/trunk/plugins/viathinksoft/objectTypes/domain/OIDplusDomain.class.php
26,42 → 26,73
class OIDplusDomain extends OIDplusObject {
private $domain;
 
public function __construct($domain) {
/**
* @param string $domain
*/
public function __construct(string $domain) {
// TODO: syntax checks
$this->domain = $domain;
}
 
public static function parse($node_id) {
/**
* @param string $node_id
* @return OIDplusDomain|null
*/
public static function parse(string $node_id)/*: ?OIDplusDomain*/ {
@list($namespace, $domain) = explode(':', $node_id, 2);
if ($namespace !== self::ns()) return false;
if ($namespace !== self::ns()) return null;
return new self($domain);
}
 
public static function objectTypeTitle() {
/**
* @return string
*/
public static function objectTypeTitle(): string {
return _L('Domain Names');
}
 
public static function objectTypeTitleShort() {
/**
* @return string
*/
public static function objectTypeTitleShort(): string {
return _L('Domain');
}
 
public static function ns() {
/**
* @return string
*/
public static function ns(): string {
return 'domain';
}
 
public static function root() {
/**
* @return string
*/
public static function root(): string {
return self::ns().':';
}
 
public function isRoot() {
/**
* @return bool
*/
public function isRoot(): bool {
return $this->domain == '';
}
 
public function nodeId($with_ns=true) {
/**
* @param bool $with_ns
* @return string
*/
public function nodeId(bool $with_ns=true): string {
return $with_ns ? self::root().$this->domain : $this->domain;
}
 
public function addString($str) {
/**
* @param string $str
* @return string
* @throws OIDplusException
*/
public function addString(string $str): string {
if ($this->isRoot()) {
return self::root().$str;
} else {
70,28 → 101,53
}
}
 
public function crudShowId(OIDplusObject $parent) {
/**
* @param OIDplusObject $parent
* @return string
*/
public function crudShowId(OIDplusObject $parent): string {
return $this->domain;
}
 
public function crudInsertSuffix() {
/**
* @return string
* @throws OIDplusException
*/
public function crudInsertSuffix(): string {
return $this->isRoot() ? '' : substr($this->addString(''), strlen(self::ns())+1);
}
 
public function jsTreeNodeName(OIDplusObject $parent = null) {
/**
* @param OIDplusObject|null $parent
* @return string
*/
public function jsTreeNodeName(OIDplusObject $parent = null): string {
if ($parent == null) return $this->objectTypeTitle();
return $this->domain;
}
 
public function defaultTitle() {
/**
* @return string
*/
public function defaultTitle(): string {
return $this->domain;
}
 
public function isLeafNode() {
/**
* @return bool
*/
public function isLeafNode(): bool {
return false;
}
 
public function getContentPage(&$title, &$content, &$icon) {
/**
* @param string $title
* @param string $content
* @param string $icon
* @return void
* @throws OIDplusException
*/
public function getContentPage(string &$title, string &$content, string &$icon) {
$icon = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
 
if ($this->isRoot()) {
130,7 → 186,10
}
}
 
public function one_up() {
/**
* @return OIDplusDomain|null
*/
public function one_up()/*: ?OIDplusDomain*/ {
$oid = $this->domain;
 
$p = strpos($oid, '.');
141,9 → 200,13
return self::parse(self::ns().':'.$oid_up);
}
 
/**
* @param $to
* @return int|null
*/
public function distance($to) {
if (!is_object($to)) $to = OIDplusObject::parse($to);
if (!($to instanceof $this)) return false;
if (!($to instanceof $this)) return null;
 
$a = $to->domain;
$b = $this->domain;
160,18 → 223,25
$min_len = min(count($ary), count($bry));
 
for ($i=0; $i<$min_len; $i++) {
if ($ary[$i] != $bry[$i]) return false;
if ($ary[$i] != $bry[$i]) return null;
}
 
return count($ary) - count($bry);
}
 
public function getDirectoryName() {
/**
* @return string
*/
public function getDirectoryName(): string {
if ($this->isRoot()) return $this->ns();
return $this->ns().'_'.md5($this->nodeId(false));
}
 
public static function treeIconFilename($mode) {
/**
* @param string $mode
* @return string
*/
public static function treeIconFilename(string $mode): string {
return 'img/'.$mode.'_icon16.png';
}
}
/trunk/plugins/viathinksoft/objectTypes/domain/OIDplusObjectTypePluginDomain.class.php
25,11 → 25,19
 
class OIDplusObjectTypePluginDomain extends OIDplusObjectTypePlugin {
 
public static function getObjectTypeClassName() {
/**
* @return string
*/
public static function getObjectTypeClassName(): string {
return OIDplusDomain::class;
}
 
public static function prefilterQuery($static_node_id, $throw_exception) {
/**
* @param string $static_node_id
* @param bool $throw_exception
* @return string
*/
public static function prefilterQuery(string $static_node_id, bool $throw_exception): string {
if (str_starts_with($static_node_id,'domain:')) {
$static_node_id = str_replace(' ', '', $static_node_id);
}
/trunk/plugins/viathinksoft/objectTypes/fourcc/OIDplusFourCC.class.php
26,12 → 26,16
class OIDplusFourCC extends OIDplusObject {
private $fourcc;
 
// FourCC Syntax examples:
// fourcc_transform('8BIM') === array(56,66,73,77); // Adobe Photoshop
// fourcc_transform('AVI') === array(65,86,73,32); // AVI File (padded with whitespace)
// fourcc_transform('Y3[10][10]') === array(89,51,10,10); // 10bit Y'CbCr 4:2:2 video
// Non-FourCC: fourcc_transform returns false.
private function fourcc_transform($fourcc) {
/**
* FourCC Syntax examples:
* fourcc_transform('8BIM') === array(56,66,73,77); // Adobe Photoshop
* fourcc_transform('AVI') === array(65,86,73,32); // AVI File (padded with whitespace)
* fourcc_transform('Y3[10][10]') === array(89,51,10,10); // 10bit Y'CbCr 4:2:2 video
* Non-FourCC: fourcc_transform returns false.
* @param string $fourcc
* @return array|false
*/
private function fourcc_transform(string $fourcc) {
$out = array();
if ($fourcc === '') return false;
for ($i=0; $i<4; $i++) {
52,6 → 56,9
return $out;
}
 
/**
* @param $fourcc
*/
public function __construct($fourcc) {
if (self::fourcc_transform($fourcc) !== false) {
$this->fourcc = $fourcc; // leaf node
60,37 → 67,64
}
}
 
public static function parse($node_id) {
/**
* @param string $node_id
* @return OIDplusFourCC|null
*/
public static function parse(string $node_id)/*: ?OIDplusFourCC*/ {
@list($namespace, $fourcc) = explode(':', $node_id, 2);
if ($namespace !== self::ns()) return false;
if ($namespace !== self::ns()) return null;
return new self($fourcc);
}
 
public static function objectTypeTitle() {
/**
* @return string
*/
public static function objectTypeTitle(): string {
return _L('Four-Character-Code (FourCC)');
}
 
public static function objectTypeTitleShort() {
/**
* @return string
*/
public static function objectTypeTitleShort(): string {
return _L('FourCC');
}
 
public static function ns() {
/**
* @return string
*/
public static function ns(): string {
return 'fourcc';
}
 
public static function root() {
/**
* @return string
*/
public static function root(): string {
return self::ns().':';
}
 
public function isRoot() {
/**
* @return bool
*/
public function isRoot(): bool {
return $this->fourcc == '';
}
 
public function nodeId($with_ns=true) {
/**
* @param bool $with_ns
* @return string
*/
public function nodeId(bool $with_ns=true): string {
return $with_ns ? self::root().$this->fourcc : $this->fourcc;
}
 
public function addString($str) {
/**
* @param string $str
* @return string
*/
public function addString(string $str): string {
 
// Y3[10] [10] --> Y3[10][10]
$test_str = trim($str);
113,7 → 147,11
}
}
 
public function crudShowId(OIDplusObject $parent) {
/**
* @param OIDplusObject $parent
* @return string
*/
public function crudShowId(OIDplusObject $parent): string {
if ($this->isLeafNode()) {
// We don't parse '/' in a valid FourCC code (i.e. Leaf node)
return $this->nodeId(false);
126,20 → 164,33
}
}
 
public function jsTreeNodeName(OIDplusObject $parent = null) {
/**
* @param OIDplusObject|null $parent
* @return string
*/
public function jsTreeNodeName(OIDplusObject $parent = null): string {
if ($parent == null) return $this->objectTypeTitle();
return $this->crudShowId($parent);
}
 
public function defaultTitle() {
/**
* @return string
*/
public function defaultTitle(): string {
return $this->fourcc;
}
 
public function isLeafNode() {
/**
* @return bool
*/
public function isLeafNode(): bool {
return self::fourcc_transform($this->fourcc) !== false;
}
 
private function getTechInfo() {
/**
* @return array
*/
private function getTechInfo(): array {
$tech_info = array();
$tech_info[_L('FourCC code')] = $this->fourcc;
$tech_info[_L('C/C++ Literal')] = $this->getMultiCharLiteral();
149,7 → 200,14
return $tech_info;
}
 
public function getContentPage(&$title, &$content, &$icon) {
/**
* @param string $title
* @param string $content
* @param string $icon
* @return void
* @throws OIDplusException
*/
public function getContentPage(string &$title, string &$content, string &$icon) {
$icon = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
 
if ($this->isRoot()) {
203,7 → 261,12
}
}
 
public function getIcon($row=null) {
/**
* @param array|null $row
* @return string|null
* @throws OIDplusException
*/
public function getIcon(array $row=null) {
$in_login_treenode = false;
foreach (debug_backtrace() as $trace) {
// If we are inside the "Login" area (i.e. "Root object links"), we want the
216,17 → 279,28
return parent::getIcon($row);
}
 
public function one_up() {
/**
* @return OIDplusFourCC|null
*/
public function one_up()/*: ?OIDplusFourCC*/ {
// A FourCC is a FourCC, there is no hierarchy
return false;
return null;
}
 
/**
* @param $to
* @return null
*/
public function distance($to) {
// Distance between FourCCs is not possible
return null;
}
 
public function getAltIds() {
/**
* @return array|OIDplusAltId[]
* @throws OIDplusException
*/
public function getAltIds(): array {
if ($this->isRoot()) return array();
if (!$this->isLeafNode()) return array();
$ids = parent::getAltIds();
233,6 → 307,10
return $ids;
}
 
/**
* @param $big_endian
* @return false|int|mixed
*/
private function getInt($big_endian) {
$type = self::fourcc_transform($this->fourcc);
if ($type === false) return false;
242,6 → 320,10
return $dec;
}
 
/**
* @param $big_endian
* @return string
*/
private function getHex($big_endian) {
$dec = $this->getInt($big_endian);
$hex = str_pad(dechex($dec), 8, "0", STR_PAD_LEFT);
248,6 → 330,9
return $hex;
}
 
/**
* @return false|string
*/
private function getMultiCharLiteral() {
$type = self::fourcc_transform($this->fourcc);
if ($type === false) return false;
254,7 → 339,11
return c_literal($type);
}
 
public function getDirectoryName() {
/**
* @return string
* @throws OIDplusException
*/
public function getDirectoryName(): string {
if ($this->isLeafNode()) {
// Leaf (FourCC)
// Example output: "fourcc_23496d52" for 'fourcc:#ImR'
265,7 → 354,11
}
}
 
public static function treeIconFilename($mode) {
/**
* @param string $mode
* @return string
*/
public static function treeIconFilename(string $mode): string {
return 'img/'.$mode.'_icon16.png';
}
}
/trunk/plugins/viathinksoft/objectTypes/fourcc/OIDplusObjectTypePluginFourCC.class.php
25,7 → 25,10
 
class OIDplusObjectTypePluginFourCC extends OIDplusObjectTypePlugin {
 
public static function getObjectTypeClassName() {
/**
* @return string
*/
public static function getObjectTypeClassName(): string {
return OIDplusFourCC::class;
}
 
/trunk/plugins/viathinksoft/objectTypes/gs1/OIDplusGs1.class.php
26,42 → 26,73
class OIDplusGs1 extends OIDplusObject {
private $number;
 
/**
* @param $number
*/
public function __construct($number) {
// TODO: syntax checks
$this->number = $number;
}
 
public static function parse($node_id) {
/**
* @param string $node_id
* @return OIDplusGs1|null
*/
public static function parse(string $node_id)/*: ?OIDplusGs1*/ {
@list($namespace, $number) = explode(':', $node_id, 2);
if ($namespace !== self::ns()) return false;
if ($namespace !== self::ns()) return null;
return new self($number);
}
 
public static function objectTypeTitle() {
/**
* @return string
*/
public static function objectTypeTitle(): string {
return _L('GS1 Based IDs (GLN/GTIN/SSCC/...)');
}
 
public static function objectTypeTitleShort() {
/**
* @return string
*/
public static function objectTypeTitleShort(): string {
return _L('GS1');
}
 
public static function ns() {
/**
* @return string
*/
public static function ns(): string {
return 'gs1';
}
 
public static function root() {
/**
* @return string
*/
public static function root(): string {
return self::ns().':';
}
 
public function isRoot() {
/**
* @return bool
*/
public function isRoot(): bool {
return $this->number == '';
}
 
public function nodeId($with_ns=true) {
/**
* @param bool $with_ns
* @return string
*/
public function nodeId(bool $with_ns=true): string {
return $with_ns ? self::root().$this->number : $this->number;
}
 
public function addString($str) {
/**
* @param string $str
* @return string
* @throws OIDplusException
*/
public function addString(string $str): string {
$m = array();
if (!preg_match('@^\\d+$@', $str, $m)) {
throw new OIDplusException(_L('GS1 value needs to be numeric'));
70,28 → 101,52
return $this->nodeId() . $str;
}
 
public function crudShowId(OIDplusObject $parent) {
/**
* @param OIDplusObject $parent
* @return string
*/
public function crudShowId(OIDplusObject $parent): string {
return $this->chunkedNotation(false);
}
 
public function crudInsertPrefix() {
/**
* @return string
*/
public function crudInsertPrefix(): string {
return $this->isRoot() ? '' : $this->chunkedNotation(false);
}
 
public function jsTreeNodeName(OIDplusObject $parent = null) {
/**
* @param OIDplusObject|null $parent
* @return string
*/
public function jsTreeNodeName(OIDplusObject $parent = null): string {
if ($parent == null) return $this->objectTypeTitle();
return substr($this->nodeId(), strlen($parent->nodeId()));
}
 
public function defaultTitle() {
/**
* @return string
*/
public function defaultTitle(): string {
return $this->number;
}
 
public function isLeafNode() {
/**
* @return bool
*/
public function isLeafNode(): bool {
return !$this->isBaseOnly();
}
 
public function getContentPage(&$title, &$content, &$icon) {
/**
* @param string $title
* @param string $content
* @param string $icon
* @return void
* @throws OIDplusException
*/
public function getContentPage(string &$title, string &$content, string &$icon) {
$icon = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
 
if ($this->isRoot()) {
138,11 → 193,19
 
# ---
 
public function isBaseOnly() {
/**
* @return bool
*/
public function isBaseOnly(): bool {
return strlen($this->number) <= 7;
}
 
public function chunkedNotation($withAbbr=true) {
/**
* @param bool $withAbbr
* @return string
* @throws OIDplusException
*/
public function chunkedNotation(bool $withAbbr=true): string {
$curid = self::root().$this->number;
 
$obj = OIDplusObject::findFitting($curid);
178,11 → 241,17
return implode(' ', $full);
}
 
public function fullNumber() {
/**
* @return string
*/
public function fullNumber(): string {
return $this->number . $this->checkDigit();
}
 
public function checkDigit() {
/**
* @return int
*/
public function checkDigit(): int {
$mul = 3;
$sum = 0;
for ($i=strlen($this->number)-1; $i>=0; $i--) {
192,11 → 261,19
return 10 - ($sum % 10);
}
 
public function one_up() {
return OIDplusObject::parse($this->ns().':'.substr($this->number,0,strlen($this->number)-1));
/**
* @return OIDplusGs1|null
*/
public function one_up()/*: ?OIDplusGs1*/ {
return self::parse($this->ns().':'.substr($this->number,0,strlen($this->number)-1));
}
 
private static function distance_($a, $b) {
/**
* @param string $a
* @param string $b
* @return false|int
*/
private static function distance_(string $a, string $b) {
$min_len = min(strlen($a), strlen($b));
 
for ($i=0; $i<$min_len; $i++) {
206,9 → 283,13
return strlen($a) - strlen($b);
}
 
/**
* @param $to
* @return int|null
*/
public function distance($to) {
if (!is_object($to)) $to = OIDplusObject::parse($to);
if (!($to instanceof $this)) return false;
if (!($to instanceof $this)) return null;
 
// This is pretty tricky, because the whois service should accept GS1 numbers with and without checksum
if ($this->number == $to->number) return 0;
218,22 → 299,26
$b = $this->number;
$a = $to->number;
$tmp = self::distance_($a, $b);
if ($tmp != false) return $tmp;
if ($tmp !== false) return $tmp;
 
$b = $this->number.$this->checkDigit();
$a = $to->number;
$tmp = self::distance_($a, $b);
if ($tmp != false) return $tmp;
if ($tmp !== false) return $tmp;
 
$b = $this->number;
$a = $to->number.$to->checkDigit();
$tmp = self::distance_($a, $b);
if ($tmp != false) return $tmp;
if ($tmp !== false) return $tmp;
 
return null;
}
 
public function getAltIds() {
/**
* @return array|OIDplusAltId[]
* @throws OIDplusException
*/
public function getAltIds(): array {
if ($this->isRoot()) return array();
$ids = parent::getAltIds();
 
247,12 → 332,19
return $ids;
}
 
public function getDirectoryName() {
/**
* @return string
*/
public function getDirectoryName(): string {
if ($this->isRoot()) return $this->ns();
return $this->ns().'_'.$this->nodeId(false); // safe, because there are only numbers
}
 
public static function treeIconFilename($mode) {
/**
* @param string $mode
* @return string
*/
public static function treeIconFilename(string $mode): string {
return 'img/'.$mode.'_icon16.png';
}
}
/trunk/plugins/viathinksoft/objectTypes/gs1/OIDplusObjectTypePluginGs1.class.php
25,11 → 25,19
 
class OIDplusObjectTypePluginGs1 extends OIDplusObjectTypePlugin {
 
public static function getObjectTypeClassName() {
/**
* @return string
*/
public static function getObjectTypeClassName(): string {
return OIDplusGs1::class;
}
 
public static function prefilterQuery($static_node_id, $throw_exception) {
/**
* @param string $static_node_id
* @param bool $throw_exception
* @return string
*/
public static function prefilterQuery(string $static_node_id, bool $throw_exception): string {
if (str_starts_with($static_node_id,'gs1:')) {
$static_node_id = str_replace(' ', '', $static_node_id);
}
/trunk/plugins/viathinksoft/objectTypes/guid/OIDplusGuid.class.php
26,6 → 26,9
class OIDplusGuid extends OIDplusObject {
private $guid;
 
/**
* @param $guid
*/
public function __construct($guid) {
if (uuid_valid($guid)) {
$this->guid = strtolower(uuid_canonize($guid)); // It is a real GUID (leaf node)
34,37 → 37,64
}
}
 
public static function parse($node_id) {
/**
* @param string $node_id
* @return OIDplusGuid|null
*/
public static function parse(string $node_id)/*: ?OIDplusGuid*/ {
@list($namespace, $guid) = explode(':', $node_id, 2);
if ($namespace !== self::ns()) return false;
if ($namespace !== self::ns()) return null;
return new self($guid);
}
 
public static function objectTypeTitle() {
/**
* @return string
*/
public static function objectTypeTitle(): string {
return _L('Globally Unique Identifier (GUID)');
}
 
public static function objectTypeTitleShort() {
/**
* @return string
*/
public static function objectTypeTitleShort(): string {
return _L('GUID');
}
 
public static function ns() {
/**
* @return string
*/
public static function ns(): string {
return 'guid';
}
 
public static function root() {
/**
* @return string
*/
public static function root(): string {
return self::ns().':';
}
 
public function isRoot() {
/**
* @return bool
*/
public function isRoot(): bool {
return $this->guid == '';
}
 
public function nodeId($with_ns=true) {
/**
* @param bool $with_ns
* @return string
*/
public function nodeId(bool $with_ns=true): string {
return $with_ns ? self::root().$this->guid : $this->guid;
}
 
public function addString($str) {
/**
* @param string $str
* @return string
*/
public function addString(string $str): string {
if (uuid_valid($str)) {
// real GUID
return self::root() . strtolower(uuid_canonize($str));
78,7 → 108,11
}
}
 
public function crudShowId(OIDplusObject $parent) {
/**
* @param OIDplusObject $parent
* @return string
*/
public function crudShowId(OIDplusObject $parent): string {
if ($this->isLeafNode()) {
// We don't parse '/' in a valid FourCC code (i.e. Leaf node)
return $this->nodeId(false);
91,20 → 125,33
}
}
 
public function jsTreeNodeName(OIDplusObject $parent = null) {
/**
* @param OIDplusObject|null $parent
* @return string
*/
public function jsTreeNodeName(OIDplusObject $parent = null): string {
if ($parent == null) return $this->objectTypeTitle();
return $this->crudShowId($parent);
}
 
public function defaultTitle() {
/**
* @return string
*/
public function defaultTitle(): string {
return $this->guid;
}
 
public function isLeafNode() {
/**
* @return bool
*/
public function isLeafNode(): bool {
return uuid_valid($this->guid);
}
 
private function getTechInfo() {
/**
* @return array
*/
private function getTechInfo(): array {
$tech_info = array();
$tech_info[_L('UUID')] = strtolower(uuid_canonize($this->guid));
$tech_info[_L('C++ notation')] = uuid_c_syntax($this->guid);
123,7 → 170,14
return $tech_info;
}
 
public function getContentPage(&$title, &$content, &$icon) {
/**
* @param string $title
* @param string $content
* @param string $icon
* @return void
* @throws OIDplusException
*/
public function getContentPage(string &$title, string &$content, string &$icon) {
$icon = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
 
if ($this->isRoot()) {
179,7 → 233,12
}
}
 
public function getIcon($row=null) {
/**
* @param array|null $row
* @return string|null
* @throws OIDplusException
*/
public function getIcon(array $row=null) {
$in_login_treenode = false;
foreach (debug_backtrace() as $trace) {
// If we are inside the "Login" area (i.e. "Root object links"), we want the
192,17 → 251,28
return parent::getIcon($row);
}
 
public function one_up() {
/**
* @return OIDplusGuid|null
*/
public function one_up()/*: ?OIDplusGuid*/ {
// A GUID is a GUID, there is no hierarchy
return false;
return null;
}
 
/**
* @param $to
* @return null
*/
public function distance($to) {
// Distance between GUIDs is not possible
return null;
}
 
public function getAltIds() {
/**
* @return array|OIDplusAltId[]
* @throws OIDplusException
*/
public function getAltIds(): array {
if ($this->isRoot()) return array();
if (!$this->isLeafNode()) return array();
$ids = parent::getAltIds();
210,7 → 280,11
return $ids;
}
 
public function getDirectoryName() {
/**
* @return string
* @throws OIDplusException
*/
public function getDirectoryName(): string {
if ($this->isLeafNode()) {
// Leaf (UUID)
// Example output: "guid_adb0b042_5b57_11eb_b0d9_3c4a92df8582"
224,7 → 298,11
}
}
 
public static function treeIconFilename($mode) {
/**
* @param string $mode
* @return string
*/
public static function treeIconFilename(string $mode): string {
return 'img/'.$mode.'_icon16.png';
}
}
/trunk/plugins/viathinksoft/objectTypes/guid/OIDplusObjectTypePluginGuid.class.php
25,20 → 25,37
 
class OIDplusObjectTypePluginGuid extends OIDplusObjectTypePlugin {
 
public static function getObjectTypeClassName() {
/**
* @return string
*/
public static function getObjectTypeClassName(): string {
return OIDplusGuid::class;
}
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.6') return true; // gridGeneratorLinks
return false;
}
 
public function gridGeneratorLinks($objParent) { // Interface 1.3.6.1.4.1.37476.2.5.2.3.6
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.6
* @param $objParent
* @return string
*/
public function gridGeneratorLinks($objParent) {
return '<br><a href="javascript:OIDplusObjectTypePluginGuid.generateRandomGUID(false)">('._L('Generate a random GUID').')</a>';
}
 
public static function prefilterQuery($static_node_id, $throw_exception) {
/**
* @param string $static_node_id
* @param bool $throw_exception
* @return string
*/
public static function prefilterQuery(string $static_node_id, bool $throw_exception): string {
// Redirect UUID to GUID
// The OID-IP Internet Draft writes at section "Alternative Namespaces":
// "If available, a formal URN namespace identifier (as defined in RFC\08141, section\05.1 [RFC8141]) SHOULD be used, e.g. 'uuid' should be used instead of 'guid'."
/trunk/plugins/viathinksoft/objectTypes/ipv4/OIDplusIpv4.class.php
28,6 → 28,10
private $bare;
private $cidr;
 
/**
* @param $ipv4
* @throws OIDplusException
*/
public function __construct($ipv4) {
$this->ipv4 = $ipv4;
 
45,37 → 49,65
}
}
 
public static function parse($node_id) {
/**
* @param string $node_id
* @return OIDplusIpv4|null
*/
public static function parse(string $node_id)/*: ?OIDplusIpv4*/ {
@list($namespace, $ipv4) = explode(':', $node_id, 2);
if ($namespace !== self::ns()) return false;
if ($namespace !== self::ns()) return null;
return new self($ipv4);
}
 
public static function objectTypeTitle() {
/**
* @return string
*/
public static function objectTypeTitle(): string {
return _L('IPv4 Network Blocks');
}
 
public static function objectTypeTitleShort() {
/**
* @return string
*/
public static function objectTypeTitleShort(): string {
return _L('IPv4');
}
 
public static function ns() {
/**
* @return string
*/
public static function ns(): string {
return 'ipv4';
}
 
public static function root() {
/**
* @return string
*/
public static function root(): string {
return self::ns().':';
}
 
public function isRoot() {
/**
* @return bool
*/
public function isRoot(): bool {
return $this->ipv4 == '';
}
 
public function nodeId($with_ns=true) {
/**
* @param bool $with_ns
* @return string
*/
public function nodeId(bool $with_ns=true): string {
return $with_ns ? self::root().$this->ipv4 : $this->ipv4;
}
 
public function addString($str) {
/**
* @param string $str
* @return string
* @throws OIDplusException
*/
public function addString(string $str): string {
if (strpos($str, '/') === false) $str .= "/32";
 
if (!$this->isRoot()) {
92,24 → 124,41
return self::root().$ipv4_normalized.'/'.$cidr; // overwrite; no hierarchical tree
}
 
public function crudShowId(OIDplusObject $parent) {
/**
* @param OIDplusObject $parent
* @return string
*/
public function crudShowId(OIDplusObject $parent): string {
return $this->ipv4;
}
 
public function jsTreeNodeName(OIDplusObject $parent = null) {
/**
* @param OIDplusObject|null $parent
* @return string
*/
public function jsTreeNodeName(OIDplusObject $parent = null): string {
if ($parent == null) return $this->objectTypeTitle();
return $this->ipv4;
}
 
public function defaultTitle() {
/**
* @return string
*/
public function defaultTitle(): string {
return $this->ipv4;
}
 
public function isLeafNode() {
/**
* @return bool
*/
public function isLeafNode(): bool {
return $this->cidr >= 32;
}
 
private function getTechInfo() {
/**
* @return array
*/
private function getTechInfo(): array {
if ($this->isRoot()) return array();
 
$tech_info = array();
123,7 → 172,14
return $tech_info;
}
 
public function getContentPage(&$title, &$content, &$icon) {
/**
* @param string $title
* @param string $content
* @param string $icon
* @return void
* @throws OIDplusException
*/
public function getContentPage(string &$title, string &$content, string &$icon) {
$icon = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
 
if ($this->isRoot()) {
174,21 → 230,32
}
}
 
public function one_up() {
/**
* @return OIDplusIpv4|null
*/
public function one_up()/*: ?OIDplusIpv4*/ {
$cidr = $this->cidr - 1;
if ($cidr < 0) return false; // cannot go further up
if ($cidr < 0) return null; // cannot go further up
 
$tmp = ipv4_normalize_range($this->bare . '/' . $cidr);
return self::parse($this->ns() . ':' . $tmp);
}
 
/**
* @param $to
* @return float|int|mixed|string|null
*/
public function distance($to) {
if (!is_object($to)) $to = OIDplusObject::parse($to);
if (!($to instanceof $this)) return false;
return ipv4_distance($to->ipv4, $this->ipv4);
if (!($to instanceof $this)) return null;
$res = ipv4_distance($to->ipv4, $this->ipv4);
return $res !== false ? $res : null;
}
 
public function getDirectoryName() {
/**
* @return string
*/
public function getDirectoryName(): string {
if ($this->isRoot()) return $this->ns();
$bare = str_replace('.','_',ipv4_normalize($this->bare));
if ($this->isLeafNode()) {
198,7 → 265,11
}
}
 
public static function treeIconFilename($mode) {
/**
* @param string $mode
* @return string
*/
public static function treeIconFilename(string $mode): string {
return 'img/'.$mode.'_icon16.png';
}
}
/trunk/plugins/viathinksoft/objectTypes/ipv4/OIDplusObjectTypePluginIpv4.class.php
25,7 → 25,10
 
class OIDplusObjectTypePluginIpv4 extends OIDplusObjectTypePlugin {
 
public static function getObjectTypeClassName() {
/**
* @return string
*/
public static function getObjectTypeClassName(): string {
return OIDplusIpv4::class;
}
 
/trunk/plugins/viathinksoft/objectTypes/ipv6/OIDplusIpv6.class.php
28,6 → 28,10
private $bare;
private $cidr;
 
/**
* @param $ipv6
* @throws OIDplusException
*/
public function __construct($ipv6) {
$this->ipv6 = $ipv6;
 
45,37 → 49,65
}
}
 
public static function parse($node_id) {
/**
* @param string $node_id
* @return OIDplusIpv6|null
*/
public static function parse(string $node_id)/*: ?OIDplusIpv6*/ {
@list($namespace, $ipv6) = explode(':', $node_id, 2);
if ($namespace !== self::ns()) return false;
if ($namespace !== self::ns()) return null;
return new self($ipv6);
}
 
public static function objectTypeTitle() {
/**
* @return string
*/
public static function objectTypeTitle(): string {
return _L('IPv6 Network Blocks');
}
 
public static function objectTypeTitleShort() {
/**
* @return string
*/
public static function objectTypeTitleShort(): string {
return _L('IPv6');
}
 
public static function ns() {
/**
* @return string
*/
public static function ns(): string {
return 'ipv6';
}
 
public static function root() {
/**
* @return string
*/
public static function root(): string {
return self::ns().':';
}
 
public function isRoot() {
/**
* @return bool
*/
public function isRoot(): bool {
return $this->ipv6 == '';
}
 
public function nodeId($with_ns=true) {
/**
* @param bool $with_ns
* @return string
*/
public function nodeId(bool $with_ns=true): string {
return $with_ns ? self::root().$this->ipv6 : $this->ipv6;
}
 
public function addString($str) {
/**
* @param string $str
* @return string
* @throws OIDplusException
*/
public function addString(string $str): string {
if (strpos($str, '/') === false) $str .= "/128";
 
if (!$this->isRoot()) {
92,24 → 124,41
return self::root().$ipv6_normalized.'/'.$cidr; // overwrite; no hierarchical tree
}
 
public function crudShowId(OIDplusObject $parent) {
/**
* @param OIDplusObject $parent
* @return string
*/
public function crudShowId(OIDplusObject $parent): string {
return $this->ipv6;
}
 
public function jsTreeNodeName(OIDplusObject $parent = null) {
/**
* @param OIDplusObject|null $parent
* @return string
*/
public function jsTreeNodeName(OIDplusObject $parent = null): string {
if ($parent == null) return $this->objectTypeTitle();
return $this->ipv6;
}
 
public function defaultTitle() {
/**
* @return string
*/
public function defaultTitle(): string {
return $this->ipv6;
}
 
public function isLeafNode() {
/**
* @return bool
*/
public function isLeafNode(): bool {
return $this->cidr >= 128;
}
 
private function getTechInfo() {
/**
* @return array
*/
private function getTechInfo(): array {
if ($this->isRoot()) return array();
 
$tech_info = array();
123,7 → 172,14
return $tech_info;
}
 
public function getContentPage(&$title, &$content, &$icon) {
/**
* @param string $title
* @param string $content
* @param string $icon
* @return void
* @throws OIDplusException
*/
public function getContentPage(string &$title, string &$content, string &$icon) {
$icon = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
 
if ($this->isRoot()) {
174,21 → 230,32
}
}
 
public function one_up() {
/**
* @return OIDplusIpv6|null
*/
public function one_up()/*: ?OIDplusIpv6*/ {
$cidr = $this->cidr - 1;
if ($cidr < 0) return false; // cannot go further up
if ($cidr < 0) return null; // cannot go further up
 
$tmp = ipv6_normalize_range($this->bare . '/' . $cidr);
return self::parse($this->ns() . ':' . $tmp);
}
 
/**
* @param $to
* @return float|int|mixed|string|null
*/
public function distance($to) {
if (!is_object($to)) $to = OIDplusObject::parse($to);
if (!($to instanceof $this)) return false;
return ipv6_distance($to->ipv6, $this->ipv6);
if (!($to instanceof $this)) return null;
$res = ipv6_distance($to->ipv6, $this->ipv6);
return $res !== false ? $res : null;
}
 
public function getDirectoryName() {
/**
* @return string
*/
public function getDirectoryName(): string {
if ($this->isRoot()) return $this->ns();
$bare = str_replace(':','_',ipv6_normalize($this->bare));
if ($this->isLeafNode()) {
198,7 → 265,11
}
}
 
public static function treeIconFilename($mode) {
/**
* @param string $mode
* @return string
*/
public static function treeIconFilename(string $mode): string {
return 'img/'.$mode.'_icon16.png';
}
}
/trunk/plugins/viathinksoft/objectTypes/ipv6/OIDplusObjectTypePluginIpv6.class.php
25,7 → 25,10
 
class OIDplusObjectTypePluginIpv6 extends OIDplusObjectTypePlugin {
 
public static function getObjectTypeClassName() {
/**
* @return string
*/
public static function getObjectTypeClassName(): string {
return OIDplusIpv6::class;
}
 
/trunk/plugins/viathinksoft/objectTypes/java/OIDplusJava.class.php
26,42 → 26,73
class OIDplusJava extends OIDplusObject {
private $java;
 
/**
* @param $java
*/
public function __construct($java) {
// TODO: syntax checks
$this->java = $java;
}
 
public static function parse($node_id) {
/**
* @param string $node_id
* @return OIDplusJava|null
*/
public static function parse(string $node_id)/*: ?OIDplusJava*/ {
@list($namespace, $java) = explode(':', $node_id, 2);
if ($namespace !== self::ns()) return false;
if ($namespace !== self::ns()) return null;
return new self($java);
}
 
public static function objectTypeTitle() {
/**
* @return string
*/
public static function objectTypeTitle(): string {
return _L('Java Package Names');
}
 
public static function objectTypeTitleShort() {
/**
* @return string
*/
public static function objectTypeTitleShort(): string {
return _L('Package');
}
 
public static function ns() {
/**
* @return string
*/
public static function ns(): string {
return 'java';
}
 
public static function root() {
/**
* @return string
*/
public static function root(): string {
return self::ns().':';
}
 
public function isRoot() {
/**
* @return bool
*/
public function isRoot(): bool {
return $this->java == '';
}
 
public function nodeId($with_ns=true) {
/**
* @param bool $with_ns
* @return string
*/
public function nodeId(bool $with_ns=true): string {
return $with_ns ? self::root().$this->java : $this->java;
}
 
public function addString($str) {
/**
* @param string $str
* @return string
* @throws OIDplusException
*/
public function addString(string $str): string {
if ($this->isRoot()) {
return self::root().$str;
} else {
70,28 → 101,53
}
}
 
public function crudShowId(OIDplusObject $parent) {
/**
* @param OIDplusObject $parent
* @return string
*/
public function crudShowId(OIDplusObject $parent): string {
return $this->java;
}
 
public function crudInsertPrefix() {
/**
* @return string
* @throws OIDplusException
*/
public function crudInsertPrefix(): string {
return $this->isRoot() ? '' : substr($this->addString(''), strlen(self::ns())+1);
}
 
public function jsTreeNodeName(OIDplusObject $parent = null) {
/**
* @param OIDplusObject|null $parent
* @return string
*/
public function jsTreeNodeName(OIDplusObject $parent = null): string {
if ($parent == null) return $this->objectTypeTitle();
return $this->java;
}
 
public function defaultTitle() {
/**
* @return string
*/
public function defaultTitle(): string {
return $this->java;
}
 
public function isLeafNode() {
/**
* @return bool
*/
public function isLeafNode(): bool {
return false;
}
 
public function getContentPage(&$title, &$content, &$icon) {
/**
* @param string $title
* @param string $content
* @param string $icon
* @return void
* @throws OIDplusException
*/
public function getContentPage(string &$title, string &$content, string &$icon) {
$icon = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
 
if ($this->isRoot()) {
130,7 → 186,10
}
}
 
public function one_up() {
/**
* @return OIDplusJava|null
*/
public function one_up()/*: ?OIDplusJava*/ {
$oid = $this->java;
 
$p = strrpos($oid, '.');
142,9 → 201,13
return self::parse(self::ns().':'.$oid_up);
}
 
/**
* @param $to
* @return int|null
*/
public function distance($to) {
if (!is_object($to)) $to = OIDplusObject::parse($to);
if (!($to instanceof $this)) return false;
if (!($to instanceof $this)) return null;
 
$a = $to->java;
$b = $this->java;
158,18 → 221,25
$min_len = min(count($ary), count($bry));
 
for ($i=0; $i<$min_len; $i++) {
if ($ary[$i] != $bry[$i]) return false;
if ($ary[$i] != $bry[$i]) return null;
}
 
return count($ary) - count($bry);
}
 
public function getDirectoryName() {
/**
* @return string
*/
public function getDirectoryName(): string {
if ($this->isRoot()) return $this->ns();
return $this->ns().'_'.md5($this->nodeId(false));
}
 
public static function treeIconFilename($mode) {
/**
* @param string $mode
* @return string
*/
public static function treeIconFilename(string $mode): string {
return 'img/'.$mode.'_icon16.png';
}
}
/trunk/plugins/viathinksoft/objectTypes/java/OIDplusObjectTypePluginJava.class.php
25,7 → 25,10
 
class OIDplusObjectTypePluginJava extends OIDplusObjectTypePlugin {
 
public static function getObjectTypeClassName() {
/**
* @return string
*/
public static function getObjectTypeClassName(): string {
return OIDplusJava::class;
}
 
/trunk/plugins/viathinksoft/objectTypes/oid/OIDplusObjectTypePluginOid.class.php
25,17 → 25,28
 
class OIDplusObjectTypePluginOid extends OIDplusObjectTypePlugin {
 
public static function getObjectTypeClassName() {
/**
* @return string
*/
public static function getObjectTypeClassName(): string {
return OIDplusOid::class;
}
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.6') return true; // gridGeneratorLinks
return false;
}
 
public function gridGeneratorLinks($objParent) { // Interface 1.3.6.1.4.1.37476.2.5.2.3.6
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.6
* @param OIDplusObject $objParent
* @return string
*/
public function gridGeneratorLinks(OIDplusObject $objParent): string {
if ($objParent->nodeId() === 'oid:2.25') {
return '<br><a href="javascript:OIDplusObjectTypePluginOid.generateRandomUUID(false)">('._L('Generate a random UUID OID').')</a>';
} else if ($objParent->isRoot()) {
43,12 → 54,18
'<br><a href="https://oidplus.viathinksoft.com/oidplus/?goto=oidplus%3Acom.viathinksoft.freeoid" target="_blank">('._L('Request a free OID from ViaThinkSoft').')</a>'.
'<br><a href="https://pen.iana.org/pen/PenApplication.page" target="_blank">('._L('Request a free PEN/OID from IANA').')</a>';
} else {
// No generation for normal OIDs atm. TODO: MAYBE in future a feature "next free"
// No generation for normal OIDs atm. TODO: MAYBE in the future a feature like "next free / sequencial OID"
return '';
}
}
 
public static function prefilterQuery($static_node_id, $throw_exception) {
/**
* @param string $static_node_id
* @param bool $throw_exception
* @return string
* @throws OIDplusException
*/
public static function prefilterQuery(string $static_node_id, bool $throw_exception): string {
// Convert WEID to OID
// A WEID is just a different notation of an OID.
// To allow that people use OID-IP or the GoTo-box with a "weid:" identifier, rewrite it to "oid:", so that the plugin OIDplusObjectTypePluginOid can handle it.
/trunk/plugins/viathinksoft/objectTypes/oid/OIDplusOid.class.php
26,6 → 26,10
class OIDplusOid extends OIDplusObject {
private $oid;
 
/**
* @param $oid
* @throws OIDplusException
*/
public function __construct($oid) {
$bak_oid = $oid;
 
42,37 → 46,65
$this->oid = $oid;
}
 
public static function parse($node_id) {
/**
* @param string $node_id
* @return OIDplusOid|null
*/
public static function parse(string $node_id)/*: ?OIDplusOid*/ {
@list($namespace, $oid) = explode(':', $node_id, 2);
if ($namespace !== self::ns()) return false;
if ($namespace !== self::ns()) return null;
return new self($oid);
}
 
public static function objectTypeTitle() {
/**
* @return string
*/
public static function objectTypeTitle(): string {
return _L('Object Identifier (OID)');
}
 
public static function objectTypeTitleShort() {
/**
* @return string
*/
public static function objectTypeTitleShort(): string {
return _L('OID');
}
 
public static function ns() {
/**
* @return string
*/
public static function ns(): string {
return 'oid';
}
 
public static function root() {
/**
* @return string
*/
public static function root(): string {
return self::ns().':';
}
 
public function isRoot() {
/**
* @return bool
*/
public function isRoot(): bool {
return $this->oid == '';
}
 
public function nodeId($with_ns=true) {
/**
* @param bool $with_ns
* @return string
*/
public function nodeId(bool $with_ns=true): string {
return $with_ns ? self::root().$this->oid : $this->oid;
}
 
public function addString($str) {
/**
* @param string $str
* @return string
* @throws OIDplusException
*/
public function addString(string $str): string {
if (!$this->isRoot()) {
if (strpos($str,'.') !== false) throw new OIDplusException(_L('Please only submit one arc (not an absolute OID or multiple arcs).'));
}
80,13 → 112,23
return $this->appendArcs($str)->nodeId();
}
 
public function crudShowId(OIDplusObject $parent) {
/**
* @param OIDplusObject $parent
* @return string
*/
public function crudShowId(OIDplusObject $parent): string {
if ($parent instanceof OIDplusOid) {
return $this->deltaDotNotation($parent);
} else {
return '';
}
}
 
public function jsTreeNodeName(OIDplusObject $parent = null) {
/**
* @param OIDplusObject|null $parent
* @return string
*/
public function jsTreeNodeName(OIDplusObject $parent = null): string {
if ($parent == null) return $this->objectTypeTitle();
if ($parent instanceof OIDplusOid) {
return $this->viewGetArcAsn1s($parent);
95,15 → 137,24
}
}
 
public function defaultTitle() {
/**
* @return string
*/
public function defaultTitle(): string {
return _L('OID %1',$this->oid);
}
 
public function isLeafNode() {
/**
* @return bool
*/
public function isLeafNode(): bool {
return false;
}
 
private function getTechInfo() {
/**
* @return array
*/
private function getTechInfo(): array {
$tech_info = array();
 
$tmp = _L('Dot notation');
129,13 → 180,23
return $tech_info;
}
 
protected function isClassCWeid() {
/**
* @return bool
*/
protected function isClassCWeid(): bool {
$dist = oid_distance($this->oid, '1.3.6.1.4.1.37553.8');
if ($dist === false) return false;
return $dist >= 0;
}
 
public function getContentPage(&$title, &$content, &$icon) {
/**
* @param string $title
* @param string $content
* @param string $icon
* @return void
* @throws OIDplusException
*/
public function getContentPage(string &$title, string &$content, string &$icon) {
if ($this->isClassCWeid()) {
// TODO: Also change treeview menu mini-icon?
$icon = file_exists(__DIR__.'/img/weid_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/weid_icon.png' : '';
193,7 → 254,10
 
# ---
 
// Gets the last arc of an WEID
/**
* Gets the last arc of an WEID
* @return false|string
*/
public function weidArc() {
// Dirty hack: We prepend '0.' in front of the OID to enforce the
// creation of a Class A weid (weid:root:) . Otherwise we could not
207,7 → 271,11
return $x[count($x)-2];
}
 
public function getWeidNotation($withAbbr=true) {
/**
* @param bool $withAbbr
* @return string
*/
public function getWeidNotation(bool $withAbbr=true): string {
$weid = \Frdl\Weid\WeidOidConverter::oid2weid($this->getDotNotation());
if ($withAbbr) {
$ary = explode(':', $weid);
236,7 → 304,12
return $weid;
}
 
public function appendArcs(String $arcs) {
/**
* @param string|int $arcs
* @return OIDplusOid
* @throws OIDplusException
*/
public function appendArcs($arcs): OIDplusOid {
$out = new self($this->oid);
 
if ($out->isRoot()) {
270,6 → 343,10
return $out;
}
 
/**
* @param OIDplusOid $parent
* @return false|string
*/
public function deltaDotNotation(OIDplusOid $parent) {
if (!$parent->isRoot()) {
if (substr($this->oid, 0, strlen($parent->oid)+1) == $parent->oid.'.') {
282,7 → 359,11
}
}
 
public function getAsn1Ids() {
/**
* @return array
* @throws OIDplusException
*/
public function getAsn1Ids(): array {
$asn_ids = array();
$res_asn = OIDplus::db()->query("select * from ###asn1id where oid = ? order by lfd", array("oid:".$this->oid));
while ($row_asn = $res_asn->fetch_array()) {
294,7 → 375,11
return $asn_ids;
}
 
public function getIris() {
/**
* @return array
* @throws OIDplusException
*/
public function getIris(): array {
$iri_ids = array();
$res_iri = OIDplus::db()->query("select * from ###iri where oid = ? order by lfd", array("oid:".$this->oid));
while ($row_iri = $res_iri->fetch_array()) {
306,7 → 391,13
return $iri_ids;
}
 
public function viewGetArcAsn1s(OIDplusOid $parent=null, $separator = ' | ') {
/**
* @param OIDplusOid|null $parent
* @param $separator
* @return string
* @throws OIDplusException
*/
public function viewGetArcAsn1s(OIDplusOid $parent=null, $separator = ' | '): string {
$asn_ids = array();
 
if (is_null($parent)) $parent = OIDplusOid::parse(self::root());
324,7 → 415,12
return implode($separator, $asn_ids);
}
 
public function getAsn1Notation($withAbbr=true) {
/**
* @param bool $withAbbr
* @return string
* @throws OIDplusException
*/
public function getAsn1Notation(bool $withAbbr=true): string {
$asn1_notation = '';
$arcs = explode('.', $this->oid);
 
358,7 → 454,12
return "{ ".trim($asn1_notation)." }";
}
 
public function getIriNotation($withAbbr=true) {
/**
* @param bool $withAbbr
* @return string
* @throws OIDplusException
*/
public function getIriNotation(bool $withAbbr=true): string {
$iri_notation = '';
$arcs = explode('.', $this->oid);
 
397,11 → 498,18
return $iri_notation;
}
 
public function getDotNotation() {
/**
* @return string
*/
public function getDotNotation(): string {
return $this->oid;
}
 
public function isWellKnown() {
/**
* @return bool
* @throws OIDplusException
*/
public function isWellKnown(): bool {
$res = OIDplus::db()->query("select oid from ###asn1id where oid = ? and well_known = ?", array("oid:".$this->oid,true));
if ($res->any()) return true;
 
411,7 → 519,13
return false;
}
 
public function replaceAsn1Ids($demandedASN1s=array(), $simulate=false) {
/**
* @param array $demandedASN1s
* @param bool $simulate
* @return void
* @throws OIDplusException
*/
public function replaceAsn1Ids(array $demandedASN1s=array(), bool $simulate=false) {
if ($this->isWellKnown()) {
throw new OIDplusException(_L('OID "%1" is a "well-known" OID. Its identifiers cannot be changed.',$this->oid));
}
450,7 → 564,13
}
}
 
public function replaceIris($demandedIris=array(), $simulate=false) {
/**
* @param array $demandedIris
* @param bool $simulate
* @return void
* @throws OIDplusException
*/
public function replaceIris(array $demandedIris=array(), bool $simulate=false) {
if ($this->isWellKnown()) {
throw new OIDplusException(_L('OID "%1" is a "well-known" OID. Its identifiers cannot be changed.',$this->oid));
}
488,17 → 608,29
}
}
 
public function one_up() {
/**
* @return OIDplusOid|null
*/
public function one_up()/*: ?OIDplusOid*/ {
return self::parse(self::ns().':'.oid_up($this->oid));
}
 
/**
* @param $to
* @return int|null
*/
public function distance($to) {
if (!is_object($to)) $to = OIDplusObject::parse($to);
if (!($to instanceof $this)) return false;
return oid_distance($to->oid, $this->oid);
if (!($to instanceof $this)) return null;
$res = oid_distance($to->oid, $this->oid);
return $res !== false ? $res : null;
}
 
public function getAltIds() {
/**
* @return array|OIDplusAltId[]
* @throws OIDplusException
*/
public function getAltIds(): array {
if ($this->isRoot()) return array();
$ids = parent::getAltIds();
 
622,13 → 754,20
return $ids;
}
 
public function getDirectoryName() {
/**
* @return string
*/
public function getDirectoryName(): string {
if ($this->isRoot()) return $this->ns();
$oid = $this->nodeId(false);
return $this->ns().'_'.str_replace('.', '_', $oid);
}
 
public static function treeIconFilename($mode) {
/**
* @param string $mode
* @return string
*/
public static function treeIconFilename(string $mode): string {
return 'img/'.$mode.'_icon16.png';
}
}
/trunk/plugins/viathinksoft/objectTypes/oid/OIDplusOidAsn1Id.class.php
24,24 → 24,57
// phpcs:enable PSR1.Files.SideEffects
 
class OIDplusOidAsn1Id {
/**
* @var string
*/
private $name = '';
 
/**
* @var bool
*/
private $standardized = false;
 
/**
* @var bool
*/
private $well_known = false;
function __construct($name, $standardized, $well_known) {
 
/**
* @param string $name
* @param bool $standardized
* @param bool $well_known
*/
function __construct(string $name, bool $standardized, bool $well_known) {
$this->name = $name;
$this->standardized = $standardized;
$this->well_known = $well_known;
}
function getName() {
 
/**
* @return string
*/
function getName(): string {
return $this->name;
}
function isStandardized() {
 
/**
* @return bool
*/
function isStandardized(): bool {
return $this->standardized;
}
function isWellKnown() {
 
/**
* @return bool
*/
function isWellKnown(): bool {
return $this->well_known;
}
function __toString() {
 
/**
* @return string
*/
function __toString(): string {
return $this->name;
}
}
/trunk/plugins/viathinksoft/objectTypes/oid/OIDplusOidIri.class.php
24,24 → 24,57
// phpcs:enable PSR1.Files.SideEffects
 
class OIDplusOidIri {
/**
* @var string
*/
private $name = '';
 
/**
* @var bool
*/
private $longarc = false;
 
/**
* @var bool
*/
private $well_known = false;
function __construct($name, $longarc, $well_known) {
 
/**
* @param string $name
* @param bool $longarc
* @param bool $well_known
*/
function __construct(string $name, bool $longarc, bool $well_known) {
$this->name = $name;
$this->longarc = $longarc;
$this->well_known = $well_known;
}
function getName() {
 
/**
* @return string
*/
function getName(): string {
return $this->name;
}
function isLongarc() {
 
/**
* @return bool
*/
function isLongarc(): bool {
return $this->longarc;
}
function isWellKnown() {
 
/**
* @return bool
*/
function isWellKnown(): bool {
return $this->well_known;
}
function __toString() {
 
/**
* @return string
*/
function __toString(): string {
return $this->name;
}
}
/trunk/plugins/viathinksoft/objectTypes/oid/WeidOidConverter.class.php
3,7 → 3,7
/**
* WEID<=>OID Converter
* (c) Webfan.de, ViaThinkSoft
* Revision 2022-03-06
* Revision 2023-03-22
**/
 
// What is a WEID?
24,11 → 24,15
// - Padding with '0' characters is valid (e.g. weid:000EXAMPLE-3)
// The paddings do not count into the WeLuhn check-digit.
 
namespace Frdl\Weid; // TODO: Namespace mit Till abklären
namespace Frdl\Weid;
 
class WeidOidConverter {
 
protected static function weLuhnGetCheckDigit($str) {
/**
* @param string $str
* @return false|int
*/
protected static function weLuhnGetCheckDigit(string $str) {
// Padding zeros don't count to the check digit (December 2021)
$ary = explode('-', $str);
foreach ($ary as &$a) {
63,7 → 67,11
return ($sum%10) == 0 ? 0 : 10-($sum%10);
}
 
private static function oidSanitize($oid) {
/**
* @param string $oid
* @return false|string
*/
private static function oidSanitize(string $oid) {
$oid = trim($oid);
 
if (substr($oid,0,1) == '.') $oid = substr($oid,1); // remove leading dot
78,9 → 86,9
if (preg_match('/^0+$/', $elem, $m)) {
$elem = '0';
} else {
$elem = preg_replace('/^0+/', '', $elem);
$elem = ltrim($elem, "0");
}
};
}
$oid = implode('.', $elements);
 
if ((count($elements) > 0) && ($elements[0] != '0') && ($elements[0] != '1') && ($elements[0] != '2')) return false;
90,12 → 98,16
return $oid;
}
 
// Translates a weid to an oid
// "weid:EXAMPLE-3" becomes "1.3.6.1.4.1.37553.8.32488192274"
// If it failed (e.g. wrong namespace, wrong checksum, etc.) then false is returned.
// If the weid ends with '?', then it will be replaced with the checksum,
// e.g. weid:EXAMPLE-? becomes weid:EXAMPLE-3
public static function weid2oid(&$weid) {
/**
* Translates a weid to an oid
* "weid:EXAMPLE-3" becomes "1.3.6.1.4.1.37553.8.32488192274"
* If it failed (e.g. wrong namespace, wrong checksum, etc.) then false is returned.
* If the weid ends with '?', then it will be replaced with the checksum,
* e.g. weid:EXAMPLE-? becomes weid:EXAMPLE-3
* @param string $weid
* @return false|string
*/
public static function weid2oid(string &$weid) {
$weid = trim($weid);
 
$p = strrpos($weid,':');
134,7 → 146,7
} else {
// If checksum is '?', it will be replaced by the actual checksum,
// e.g. weid:EXAMPLE-? becomes weid:EXAMPLE-3
$weid = str_replace('?', $expected_checksum, $weid);
$weid = str_replace('?', "$expected_checksum", $weid);
}
foreach ($elements as &$arc) {
//$arc = strtoupper(base_convert($arc, 36, 10));
150,9 → 162,13
return $oid;
}
 
// Converts an OID to WEID
// "1.3.6.1.4.1.37553.8.32488192274" becomes "weid:EXAMPLE-3"
public static function oid2weid($oid) {
/**
* Converts an OID to WEID
* "1.3.6.1.4.1.37553.8.32488192274" becomes "weid:EXAMPLE-3"
* @param string $oid
* @return false|string
*/
public static function oid2weid(string $oid) {
$oid = self::oidSanitize($oid);
if ($oid === false) return false;
 
190,12 → 206,16
return false;
}
 
$weid = $namespace . ($weidstr == '' ? $checksum : $weidstr . '-' . $checksum);
 
return $weid;
return $namespace . ($weidstr == '' ? $checksum : $weidstr . '-' . $checksum);
}
 
protected static function base_convert_bigint($numstring, $frombase, $tobase) {
/**
* @param string $numstring
* @param int $frombase
* @param int $tobase
* @return string
*/
protected static function base_convert_bigint(string $numstring, int $frombase, int $tobase): string {
$frombase_str = '';
for ($i=0; $i<$frombase; $i++) {
$frombase_str .= strtoupper(base_convert((string)$i, 10, 36));
/trunk/plugins/viathinksoft/objectTypes/other/OIDplusObjectTypePluginOther.class.php
25,7 → 25,10
 
class OIDplusObjectTypePluginOther extends OIDplusObjectTypePlugin {
 
public static function getObjectTypeClassName() {
/**
* @return string
*/
public static function getObjectTypeClassName(): string {
return OIDplusOther::class;
}
 
/trunk/plugins/viathinksoft/objectTypes/other/OIDplusOther.class.php
26,42 → 26,72
class OIDplusOther extends OIDplusObject {
private $other;
 
/**
* @param $other
*/
public function __construct($other) {
// No syntax checks
$this->other = $other;
}
 
public static function parse($node_id) {
/**
* @param string $node_id
* @return OIDplusOther|null
*/
public static function parse(string $node_id)/*: ?OIDplusOther*/ {
@list($namespace, $other) = explode(':', $node_id, 2);
if ($namespace !== self::ns()) return false;
if ($namespace !== self::ns()) return null;
return new self($other);
}
 
public static function objectTypeTitle() {
/**
* @return string
*/
public static function objectTypeTitle(): string {
return _L('Other objects');
}
 
public static function objectTypeTitleShort() {
/**
* @return string
*/
public static function objectTypeTitleShort(): string {
return _L('Object');
}
 
public static function ns() {
/**
* @return string
*/
public static function ns(): string {
return 'other';
}
 
public static function root() {
/**
* @return string
*/
public static function root(): string {
return self::ns().':';
}
 
public function isRoot() {
/**
* @return bool
*/
public function isRoot(): bool {
return $this->other == '';
}
 
public function nodeId($with_ns=true) {
/**
* @param bool $with_ns
* @return string
*/
public function nodeId(bool $with_ns=true): string {
return $with_ns ? self::root().$this->other : $this->other;
}
 
public function addString($str) {
/**
* @param string $str
* @return string
*/
public function addString(string $str): string {
if ($this->isRoot()) {
return self::root() . $str;
} else {
69,7 → 99,11
}
}
 
public function crudShowId(OIDplusObject $parent) {
/**
* @param OIDplusObject $parent
* @return string
*/
public function crudShowId(OIDplusObject $parent): string {
if ($parent->isRoot()) {
return substr($this->nodeId(), strlen($parent->nodeId()));
} else {
77,7 → 111,11
}
}
 
public function jsTreeNodeName(OIDplusObject $parent = null) {
/**
* @param OIDplusObject|null $parent
* @return string
*/
public function jsTreeNodeName(OIDplusObject $parent = null): string {
if ($parent == null) return $this->objectTypeTitle();
if ($parent->isRoot()) {
return substr($this->nodeId(), strlen($parent->nodeId()));
86,17 → 124,30
}
}
 
public function defaultTitle() {
/**
* @return string
*/
public function defaultTitle(): string {
$ary = explode('\\', $this->other); // TODO: but if an arc contains "\", this does not work. better read from db?
$ary = array_reverse($ary);
return $ary[0];
}
 
public function isLeafNode() {
/**
* @return bool
*/
public function isLeafNode(): bool {
return false;
}
 
public function getContentPage(&$title, &$content, &$icon) {
/**
* @param string $title
* @param string $content
* @param string $icon
* @return void
* @throws OIDplusException
*/
public function getContentPage(string &$title, string &$content, string &$icon) {
$icon = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
 
if ($this->isRoot()) {
133,7 → 184,10
}
}
 
public function one_up() {
/**
* @return OIDplusOther|null
*/
public function one_up()/*: ?OIDplusOther*/ {
$oid = $this->other;
 
$p = strrpos($oid, '\\');
145,9 → 199,13
return self::parse(self::ns().':'.$oid_up);
}
 
/**
* @param $to
* @return int|null
*/
public function distance($to) {
if (!is_object($to)) $to = OIDplusObject::parse($to);
if (!($to instanceof $this)) return false;
if (!($to instanceof $this)) return null;
 
$a = $to->other;
$b = $this->other;
161,18 → 219,25
$min_len = min(count($ary), count($bry));
 
for ($i=0; $i<$min_len; $i++) {
if ($ary[$i] != $bry[$i]) return false;
if ($ary[$i] != $bry[$i]) return null;
}
 
return count($ary) - count($bry);
}
 
public function getDirectoryName() {
/**
* @return string
*/
public function getDirectoryName(): string {
if ($this->isRoot()) return $this->ns();
return $this->ns().'_'.md5($this->nodeId(false));
}
 
public static function treeIconFilename($mode) {
/**
* @param string $mode
* @return string
*/
public static function treeIconFilename(string $mode): string {
return 'img/'.$mode.'_icon16.png';
}
}
/trunk/plugins/viathinksoft/publicPages/000_objects/OIDplusPagePublicObjects.class.php
25,7 → 25,11
 
class OIDplusPagePublicObjects extends OIDplusPagePluginPublic {
 
private function get_treeicon_root($ot) {
/**
* @param $ot
* @return string|null
*/
private function get_treeicon_root($ot)/*: ?string*/ {
$dirs = glob(OIDplus::localpath().'plugins/'.'*'.'/objectTypes/'.$ot::ns());
 
if (count($dirs) == 0) {
42,6 → 46,14
return $icon;
}
 
/**
* @param $id
* @param $old_ra
* @param $new_ra
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
private function ra_change_rec($id, $old_ra, $new_ra) {
if (is_null($old_ra)) $old_ra = '';
OIDplus::db()->query("update ###objects set ra_email = ?, updated = ".OIDplus::db()->sqlDate()." where id = ? and ".OIDplus::db()->getSlang()->isNullFunction('ra_email',"''")." = ?", array($new_ra, $id, $old_ra));
53,7 → 65,14
}
}
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return array|int[]
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
 
// Action: Delete
// Method: POST
63,7 → 82,7
_CheckParamExists($params, 'id');
$id = $params['id'];
$obj = OIDplusObject::parse($id);
if ($obj === null) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','DELETE',$id));
if (!$obj) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','DELETE',$id));
 
if (!OIDplusObject::exists($id)) {
throw new OIDplusException(_L('Object %1 does not exist',$id));
74,7 → 93,7
 
foreach (OIDplus::getAllPlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) {
$plugin->beforeObjectDelete($id);
$plugin->beforeObjectDelete($id); /** @phpstan-ignore-line */
}
}
 
111,7 → 130,7
 
foreach (OIDplus::getAllPlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) {
$plugin->afterObjectDelete($id);
$plugin->afterObjectDelete($id); /** @phpstan-ignore-line */
}
}
 
129,7 → 148,7
_CheckParamExists($params, 'id');
$id = $params['id'];
$obj = OIDplusObject::parse($id);
if ($obj === null) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','UPDATE',$id));
if (!$obj) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','UPDATE',$id));
 
if (!OIDplusObject::exists($id)) {
throw new OIDplusException(_L('Object %1 does not exist',$id));
140,12 → 159,13
 
foreach (OIDplus::getAllPlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) {
$plugin->beforeObjectUpdateSuperior($id, $params);
$plugin->beforeObjectUpdateSuperior($id, $params); /** @phpstan-ignore-line */
}
}
 
// First, do a simulation for ASN.1 IDs and IRIs to check if there are any problems (then an Exception will be thrown)
if ($obj::ns() == 'oid') {
assert($obj instanceof OIDplusOid); //assert(get_class($obj) === "ViaThinkSoft\OIDplus\OIDplusOid");
if (!$obj->isWellKnown()) {
if (isset($params['iris'])) {
$ids = ($params['iris'] == '') ? array() : explode(',',$params['iris']);
166,6 → 186,7
// Validate RA email address
$new_ra = $params['ra_email'];
if ($obj::ns() == 'oid') {
assert($obj instanceof OIDplusOid); //assert(get_class($obj) === "ViaThinkSoft\OIDplus\OIDplusOid");
if ($obj->isWellKnown()) {
$new_ra = '';
}
197,6 → 218,7
 
// Replace ASN.1 IDs und IRIs
if ($obj::ns() == 'oid') {
assert($obj instanceof OIDplusOid); //assert(get_class($obj) === "ViaThinkSoft\OIDplus\OIDplusOid");
if (!$obj->isWellKnown()) {
if (isset($params['iris'])) {
$ids = ($params['iris'] == '') ? array() : explode(',',$params['iris']);
239,6 → 261,7
}
 
if ($obj::ns() == 'oid') {
assert($obj instanceof OIDplusOid); //assert(get_class($obj) === "ViaThinkSoft\OIDplus\OIDplusOid");
if ($obj->isWellKnown()) {
$status += 4;
}
246,7 → 269,7
 
foreach (OIDplus::getAllPlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) {
$plugin->afterObjectUpdateSuperior($id, $params);
$plugin->afterObjectUpdateSuperior($id, $params); /** @phpstan-ignore-line */
}
}
 
261,7 → 284,7
_CheckParamExists($params, 'id');
$id = $params['id'];
$obj = OIDplusObject::parse($id);
if ($obj === null) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','UPDATE2',$id));
if (!$obj) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','UPDATE2',$id));
 
if (!OIDplusObject::exists($id)) {
throw new OIDplusException(_L('Object %1 does not exist',$id));
272,7 → 295,7
 
foreach (OIDplus::getAllPlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) {
$plugin->beforeObjectUpdateSelf($id, $params);
$plugin->beforeObjectUpdateSelf($id, $params); /** @phpstan-ignore-line */
}
}
 
295,7 → 318,7
 
foreach (OIDplus::getAllPlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) {
$plugin->afterObjectUpdateSelf($id, $params);
$plugin->afterObjectUpdateSelf($id, $params); /** @phpstan-ignore-line */
}
}
 
324,7 → 347,7
// Check if you have write rights on the parent (to create a new object)
_CheckParamExists($params, 'parent');
$objParent = OIDplusObject::parse($params['parent']);
if ($objParent === null) throw new OIDplusException(_L('%1 action failed because parent object "%2" cannot be parsed!','INSERT',$params['parent']));
if (!$objParent) throw new OIDplusException(_L('%1 action failed because parent object "%2" cannot be parsed!','INSERT',$params['parent']));
 
if (!$objParent->isRoot()) {
$idParent = $objParent->nodeId();
341,6 → 364,7
 
// For the root objects, let the user also enter a WEID
if ($objParent::ns() == 'oid') {
assert($objParent instanceof OIDplusOid); //assert(get_class($objParent) === "ViaThinkSoft\OIDplus\OIDplusOid");
if (strtolower(substr(trim($params['id']),0,5)) === 'weid:') {
if ($objParent->isRoot()) {
$params['id'] = \Frdl\Weid\WeidOidConverter::weid2oid($params['id']);
363,16 → 387,17
}
 
$obj = OIDplusObject::parse($id);
if ($obj === null) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','INSERT',$id));
if (!$obj) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','INSERT',$id));
 
foreach (OIDplus::getAllPlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) {
$plugin->beforeObjectInsert($id, $params);
$plugin->beforeObjectInsert($id, $params); /** @phpstan-ignore-line */
}
}
 
// First simulate if there are any problems of ASN.1 IDs und IRIs
if ($obj::ns() == 'oid') {
assert($obj instanceof OIDplusOid); //assert(get_class($obj) === "ViaThinkSoft\OIDplus\OIDplusOid");
if (!$obj->isWellKnown()) {
if (isset($params['iris'])) {
$ids = ($params['iris'] == '') ? array() : explode(',',$params['iris']);
392,6 → 417,7
$parent = $params['parent'];
$ra_email = isset($params['ra_email']) ? $params['ra_email'] : '';
if ($obj::ns() == 'oid') {
assert($obj instanceof OIDplusOid); //assert(get_class($obj) === "ViaThinkSoft\OIDplus\OIDplusOid");
if ($obj->isWellKnown()) {
$ra_email = '';
}
420,6 → 446,7
 
// Set ASN.1 IDs und IRIs
if ($obj::ns() == 'oid') {
assert($obj instanceof OIDplusOid); //assert(get_class($obj) === "ViaThinkSoft\OIDplus\OIDplusOid");
if (!$obj->isWellKnown()) {
if (isset($params['iris'])) {
$ids = ($params['iris'] == '') ? array() : explode(',',$params['iris']);
445,6 → 472,7
}
 
if ($obj::ns() == 'oid') {
assert($obj instanceof OIDplusOid); //assert(get_class($obj) === "ViaThinkSoft\OIDplus\OIDplusOid");
if ($obj->isWellKnown()) {
$status += 4;
}
452,7 → 480,7
 
foreach (OIDplus::getAllPlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) {
$plugin->afterObjectInsert($id, $params);
$plugin->afterObjectInsert($id, $params); /** @phpstan-ignore-line */
}
}
 
461,11 → 489,16
"inserted_id" => $id
);
} else {
throw new OIDplusException(_L('Unknown action ID'));
return parent::action($actionID, $params);
}
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
* @throws OIDplusException
*/
public function init(bool $html=true) {
OIDplus::config()->prepareConfigKey('oobe_objects_done', '"Out Of Box Experience" wizard for OIDplusPagePublicObjects done once?', '0', OIDplusConfig::PROTECTION_HIDDEN, function($value) {});
OIDplus::config()->prepareConfigKey('oid_grid_show_weid', 'Show WEID/Base36 column in CRUD grid of OIDs?', '1', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
if (!is_numeric($value) || ($value < 0) || ($value > 1)) {
474,12 → 507,18
});
}
 
/**
* @param $id
* @param $out
* @return array|false
* @throws OIDplusException
*/
private function tryObject($id, &$out) {
$parent = null;
$res = null;
$row = null;
$obj = OIDplusObject::parse($id);
if (is_null($obj)) return false;
if (!$obj) return false;
if ($obj->isRoot()) {
$obj->getContentPage($out['title'], $out['text'], $out['icon']);
$objParent = null; // $obj->getParent();
496,6 → 535,10
return array($id, $obj, $objParent);
}
 
/**
* @param $id
* @return array
*/
public static function getAlternativesForQuery($id) {
// Attention: This is NOT an implementation of 1.3.6.1.4.1.37476.2.5.2.3.7 !
// This is the function that calls getAlternativesForQuery() of every plugin that implements 1.3.6.1.4.1.37476.2.5.2.3.7
504,7 → 547,7
$alternatives = array();
foreach (OIDplus::getAllPlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.7')) {
$tmp = $plugin->getAlternativesForQuery($id);
$tmp = $plugin->getAlternativesForQuery($id); /** @phpstan-ignore-line */
if (is_array($tmp)) {
$alternatives = array_merge($tmp, $alternatives);
}
524,7 → 567,15
return $alternatives;
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if ($id === 'oidplus:system') {
$handled = true;
 
559,8 → 610,6
$tmp .= '</ul>';
$out['text'] = str_replace('%%OBJECT_TYPE_LIST%%', $tmp, $out['text']);
}
 
return;
}
 
// Never answer to an object type that is called 'oidplus:',
588,7 → 637,7
$obj = OIDplusObject::parse($id);
 
if ($test === false) {
if (is_null($obj)) {
if (!$obj) {
// Object type disabled or not known (e.g. ObjectType "oidplus:").
$handled = false;
return;
630,6 → 679,7
} else {
$parent_title = $objParent->getTitle();
if (empty($parent_title) && ($objParent->ns() == 'oid')) {
assert($objParent instanceof OIDplusOid); //assert(get_class($objParent) === "ViaThinkSoft\OIDplus\OIDplusOid");
// If not title is available, then use an ASN.1 identifier
$res_asn = OIDplus::db()->query("select name from ###asn1id where oid = ?", array($objParent->nodeId()));
if ($res_asn->any()) {
699,12 → 749,17
 
foreach (OIDplus::getAllPlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.2')) {
$plugin->modifyContent($obj->nodeId(), $out['title'], $out['icon'], $out['text']);
$plugin->modifyContent($obj->nodeId(), $out['title'], $out['icon'], $out['text']); /** @phpstan-ignore-line */
}
}
}
}
 
/**
* @param $json
* @param $out
* @return void
*/
private function publicSitemap_rec($json, &$out) {
foreach ($json as $x) {
if (isset($x['id']) && $x['id']) {
716,13 → 771,26
}
}
 
public function publicSitemap(&$out) {
/**
* @param array $out
* @return void
*/
public function publicSitemap(array &$out) {
$json = array();
$this->tree($json, null/*RA EMail*/, false/*HTML tree algorithm*/, true/*display all*/);
$this->tree($json, null/*RA EMail*/, false/*HTML tree algorithm*/, "*"/*display all*/);
$this->publicSitemap_rec($json, $out);
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if ($nonjs) {
$json[] = array(
'id' => 'oidplus:system',
745,7 → 813,7
);
 
$tmp = OIDplusObject::parse($req_goto);
if (!is_null($tmp) && ($ot == get_class($tmp))) {
if ($tmp && ($ot == get_class($tmp))) {
// TODO: Instead of just having 3 levels (parent, this and children), it would be better if we'd had a full tree of all parents
// on the other hand, for giving search engines content, this is good enough
if (empty($parent)) {
769,7 → 837,7
$stufen = array();
while ($row = $res->fetch_object()) {
$obj = OIDplusObject::parse($row->id);
if (is_null($obj)) continue; // might happen if the objectType is not available/loaded
if (!$obj) continue; // might happen if the objectType is not available/loaded
if (!$obj->userHasReadRights()) continue;
$txt = $row->title == '' ? '' : ' -- '.htmlentities($row->title);
 
790,9 → 858,9
 
return true;
} else {
if ($req_goto === true) {
if ($req_goto === "*") {
$goto_path = true; // display everything recursively
} else if (isset($req_goto)) {
} else if ($req_goto !== "") {
$goto = $req_goto;
$path = array();
while (true) {
840,7 → 908,11
}
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
$ary = array();
$found_leaf = false;
if ($obj = OIDplusObject::parse($request)) {
873,8 → 945,17
return $ary;
}
 
/**
* @var int
*/
private static $crudCounter = 0;
 
/**
* @param $parent
* @return string|void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
protected static function showCrud($parent='oid:') {
$items_total = 0;
$items_hidden = 0;
919,8 → 1000,7
 
$enable_weid_presentation = OIDplus::config()->getValue('oid_grid_show_weid');
 
$output = '';
$output .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
$output = '<div class="container box"><div id="suboid_table" class="table-responsive">';
$output .= '<table class="table table-bordered table-striped">';
$output .= ' <tr>';
$output .= ' <th>'._L('ID').(($parentNS == 'gs1') ? ' '._L('(without check digit)') : '').'</th>';
970,10 → 1050,12
$output .= ' <td><a href="?goto='.urlencode($row->id).'" onclick="openAndSelectNode('.js_escape($row->id).', '.js_escape($parent).'); return false;">'.htmlentities($show_id).'</a>';
if ($enable_weid_presentation && ($parentNS == 'oid') && $objParent->isRoot()) {
// To save space horizontal space, the WEIDs were written below the OIDs
assert($obj instanceof OIDplusOid); //assert(get_class($obj) === "ViaThinkSoft\OIDplus\OIDplusOid");
$output .= '<br>'.$obj->getWeidNotation(true);
}
$output .= '</td>';
if ($enable_weid_presentation && ($parentNS == 'oid') && !$objParent->isRoot()) {
assert($obj instanceof OIDplusOid); //assert(get_class($obj) === "ViaThinkSoft\OIDplus\OIDplusOid");
$output .= ' <td>'.htmlentities($obj->weidArc()).'</td>';
}
if ($objParent->userHasWriteRights()) {
1017,7 → 1099,7
$suffix = is_null($objParent) ? '' : $objParent->crudInsertSuffix();
foreach (OIDplus::getObjectTypePlugins() as $plugin) {
if (($plugin::getObjectTypeClassName()::ns() == $parentNS) && $plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.6')) {
$suffix .= $plugin->gridGeneratorLinks($objParent);
$suffix .= $plugin->gridGeneratorLinks($objParent); /** @phpstan-ignore-line */
}
}
 
1074,6 → 1156,10
return $output;
}
 
/**
* @param $html
* @return array|string|string[]|null
*/
protected static function objDescription($html) {
// We allow HTML, but no hacking
$html = anti_xss($html);
1081,16 → 1167,26
return trim_br($html);
}
 
// 'quickbars' added 11 July 2019: Disabled because of two problems:
// 1. When you load TinyMCE via AJAX using the left menu, the quickbar is immediately shown, even if TinyMCE does not have the focus
// 2. When you load a page without TinyMCE using the left menu, the quickbar is still visible, although there is no edit
// 'colorpicker', 'textcolor' and 'contextmenu' added in 07 April 2020, because it is built in in the core.
// 'importcss' added 17 September 2020, because it breaks the "Format/Style" dropdown box ("styleselect" toolbar)
// 'legacyoutput' added 24 September 2021, because it is declared as deprecated
// 'spellchecker' added 6 October 2021, because it is declared as deprecated and marked for removal in TinyMCE 6.0
// 'imagetools' and 'toc' added 23 February 2022, because they are declared as deprecated and marked for removal in TinyMCE 6.0 ("moving to premium")
/**
* 'quickbars' added 11 July 2019: Disabled because of two problems:
* 1. When you load TinyMCE via AJAX using the left menu, the quickbar is immediately shown, even if TinyMCE does not have the focus
* 2. When you load a page without TinyMCE using the left menu, the quickbar is still visible, although there is no edit
* 'colorpicker', 'textcolor' and 'contextmenu' added in 07 April 2020, because it is built in in the core.
* 'importcss' added 17 September 2020, because it breaks the "Format/Style" dropdown box ("styleselect" toolbar)
* 'legacyoutput' added 24 September 2021, because it is declared as deprecated
* 'spellchecker' added 6 October 2021, because it is declared as deprecated and marked for removal in TinyMCE 6.0
* 'imagetools' and 'toc' added 23 February 2022, because they are declared as deprecated and marked for removal in TinyMCE 6.0 ("moving to premium")
* @var string[]
*/
public static $exclude_tinymce_plugins = array('fullpage', 'bbcode', 'quickbars', 'colorpicker', 'textcolor', 'contextmenu', 'importcss', 'legacyoutput', 'spellchecker', 'imagetools', 'toc');
 
/**
* @param $name
* @param $content
* @return string
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
protected static function showMCE($name, $content) {
$mce_plugins = array();
foreach (glob(OIDplus::localpath().'vendor/tinymce/tinymce/plugins/*') as $m) { // */
1147,7 → 1243,11
return $out;
}
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.1') return true; // oobeEntry, oobeRequested()
// Important: Do NOT 1.3.6.1.4.1.37476.2.5.2.3.7 because our getAlternativesForQuery() is the one that calls others!
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications()
1154,15 → 1254,23
return false;
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.1
* @return bool
* @throws OIDplusException
*/
public function oobeRequested(): bool {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.1
 
return OIDplus::config()->getValue('oobe_objects_done') == '0';
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.1
* @param $step
* @param $do_edits
* @param $errors_happened
* @return void
*/
public function oobeEntry($step, $do_edits, &$errors_happened)/*: void*/ {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.1
 
echo '<h2>'._L('Step %1: Enable/Disable object type plugins',$step).'</h2>';
echo '<p>'._L('Which object types do you want to manage using OIDplus?').'</p>';
 
1208,8 → 1316,13
echo ' <font color="red"><b>'.$msg.'</b></font>';
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.8
* @param $user
* @return array
* @throws OIDplusException
*/
public function getNotifications($user=null): array {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.8
$notifications = array();
$res = OIDplus::db()->query("select id, title from ###objects order by ".OIDplus::db()->natOrder('id'));
if ($res->any()) {
/trunk/plugins/viathinksoft/publicPages/001_ra_base/OIDplusPagePublicRaBaseUtils.class.php
26,7 → 26,13
 
class OIDplusPagePublicRaBaseUtils extends OIDplusPagePluginPublic {
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return int[]
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
 
// Action: delete_ra
// Method: POST
56,12 → 62,17
 
return array("status" => 0);
} else {
throw new OIDplusException(_L('Unknown action ID'));
return parent::action($actionID, $params);
}
 
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
* @throws OIDplusException
*/
public function init(bool $html=true) {
// Will be used by: plugins admin-130, public-091, public-200, ra-092, ra-101
OIDplus::config()->prepareConfigKey('ra_min_password_length', 'Minimum length for RA passwords', '6', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
if (!is_numeric($value) || ($value < 1)) {
70,16 → 81,38
});
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
*/
public function gui(string $id, array &$out, bool &$handled) {
}
 
public function publicSitemap(&$out) {
/**
* @param array $out
* @return void
*/
public function publicSitemap(array &$out) {
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
return false;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
}
/trunk/plugins/viathinksoft/publicPages/090_login/OIDplusPagePublicLogin.class.php
25,7 → 25,13
 
class OIDplusPagePublicLogin extends OIDplusPagePluginPublic {
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return int[]
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
// === RA LOGIN/LOGOUT ===
 
if ($actionID == 'ra_login') {
104,11 → 110,16
return array("status" => 0);
}
else {
throw new OIDplusException(_L('Unknown action ID'));
return parent::action($actionID, $params);
}
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
* @throws OIDplusException
*/
public function init(bool $html=true) {
OIDplus::config()->prepareConfigKey('log_failed_ra_logins', 'Log failed RA logins', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
if (!is_numeric($value) || (($value != 0) && (($value != 1)))) {
throw new OIDplusException(_L('Valid values: 0 (off) or 1 (on).'));
121,7 → 132,14
});
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
$ary = explode('$', $id);
$desired_ra = '';
if (isset($ary[1])) {
138,9 → 156,7
$out['title'] = _L('Login');
$out['icon'] = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/login_icon.png';
 
$out['text'] = '';
 
$out['text'] .= '<noscript>';
$out['text'] = '<noscript>';
$out['text'] .= '<p>'._L('You need to enable JavaScript to use the login area.').'</p>';
$out['text'] .= '</noscript>';
 
198,7 → 214,7
$alt_logins_html = array();
foreach (OIDplus::getAllPlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.5')) {
$logins = $plugin->alternativeLoginMethods();
$logins = $plugin->alternativeLoginMethods(); /* @phpstan-ignore-line */
foreach ($logins as $data) {
if (isset($data[2]) && !empty($data[2])) {
$img = '<img src="'.$data[2].'" alt="'.htmlentities($data[1]).'"> ';
264,11 → 280,24
}
}
 
public function publicSitemap(&$out) {
/**
* @param array $out
* @return void
*/
public function publicSitemap(array &$out) {
$out[] = 'oidplus:login';
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
$loginChildren = array();
 
if (OIDplus::authUtils()->isAdminLoggedIn()) {
351,7 → 380,11
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
/trunk/plugins/viathinksoft/publicPages/091_forgot_password/OIDplusPagePublicForgotPassword.class.php
25,7 → 25,14
 
class OIDplusPagePublicForgotPassword extends OIDplusPagePluginPublic {
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return int[]
* @throws OIDplusException
* @throws OIDplusMailException
*/
public function action(string $actionID, array $params): array {
if ($actionID == 'forgot_password') {
_CheckParamExists($params, 'email');
$email = $params['email'];
86,11 → 93,16
 
return array("status" => 0);
} else {
throw new OIDplusException(_L('Unknown action ID'));
return parent::action($actionID, $params);
}
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
* @throws OIDplusException
*/
public function init(bool $html=true) {
OIDplus::config()->prepareConfigKey('max_ra_pwd_reset_time', 'Max RA password reset time in seconds (0 = infinite)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
if (!is_numeric($value) || ($value < 0)) {
throw new OIDplusException(_L('Please enter a valid value.'));
98,7 → 110,14
});
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if (explode('$',$id)[0] == 'oidplus:forgot_password') {
$handled = true;
 
148,15 → 167,31
}
}
 
public function publicSitemap(&$out) {
/**
* @param array $out
* @return void
*/
public function publicSitemap(array &$out) {
$out[] = 'oidplus:forgot_password';
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
return false;
}
 
private function getForgotPasswordText($email) {
/**
* @param string $email
* @return string
* @throws OIDplusException
*/
private function getForgotPasswordText(string $email): string {
$res = OIDplus::db()->query("select * from ###ra where email = ?", array($email));
if (!$res->any()) {
throw new OIDplusException(_L('This RA does not exist.'));
173,7 → 208,11
return $message;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
/trunk/plugins/viathinksoft/publicPages/092_forgot_password_admin/OIDplusPagePublicForgotPasswordAdmin.class.php
25,10 → 25,21
 
class OIDplusPagePublicForgotPasswordAdmin extends OIDplusPagePluginPublic {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if (explode('$',$id)[0] == 'oidplus:forgot_password_admin') {
$handled = true;
 
48,15 → 59,30
}
}
 
public function publicSitemap(&$out) {
/**
* @param array $out
* @return void
*/
public function publicSitemap(array &$out) {
$out[] = 'oidplus:forgot_password_admin';
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
return false;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
/trunk/plugins/viathinksoft/publicPages/093_rainfo/OIDplusPagePublicRaInfo.class.php
25,10 → 25,22
 
class OIDplusPagePublicRaInfo extends OIDplusPagePluginPublic {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if (explode('$',$id)[0] == 'oidplus:rainfo') {
$handled = true;
 
129,7 → 141,13
}
}
 
public function publicSitemap(&$out) {
/**
* @param array $out
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function publicSitemap(array &$out) {
if (OIDplus::db()->getSlang()->id() == 'mysql') {
$res = OIDplus::db()->query("select distinct BINARY(email) as email from ###ra"); // "binary" because we want to ensure that 'distinct' is case sensitive
} else {
140,10 → 158,22
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
return false;
}
 
/**
* @param $email
* @return array|string|string[]|null
* @throws OIDplusException
*/
public static function showRAInfo($email) {
$out = '';
 
188,7 → 218,11
return trim_br($out);
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
/trunk/plugins/viathinksoft/publicPages/095_attachments/OIDplusPagePublicAttachments.class.php
27,6 → 27,11
 
const DIR_UNLOCK_FILE = 'oidplus_upload.dir';
 
/**
* @param $dir
* @return void
* @throws OIDplusException
*/
private static function checkUploadDir($dir) {
if (!is_dir($dir)) {
throw new OIDplusException(_L('The attachment directory "%1" is not existing.', $dir));
84,7 → 89,11
}
}
 
private static function isCriticalWindowsDirectory($dir) {
/**
* @param $dir
* @return bool
*/
private static function isCriticalWindowsDirectory($dir): bool {
$dir .= '\\';
$windir = isset($_SERVER['SystemRoot']) ? $_SERVER['SystemRoot'].'\\' : 'C:\\Windows\\';
if (stripos($dir,$windir) === 0) return true;
91,7 → 100,11
return false;
}
 
private static function isCriticalLinuxDirectory($dir) {
/**
* @param $dir
* @return bool
*/
private static function isCriticalLinuxDirectory($dir): bool {
if ($dir == '/') return true;
$dir .= '/';
if (strpos($dir,'/bin/') === 0) return true;
123,7 → 136,12
return false;
}
 
public static function getUploadDir($id=null) {
/**
* @param $id
* @return string
* @throws OIDplusException
*/
public static function getUploadDir($id=null): string {
// Get base path
$cfg = OIDplus::config()->getValue('attachment_upload_dir', '');
$cfg = trim($cfg);
148,7 → 166,7
// Get object-specific path
if (!is_null($id)) {
$obj = OIDplusObject::parse($id);
if ($obj === null) throw new OIDplusException(_L('Invalid object "%1"',$id));
if (!$obj) throw new OIDplusException(_L('Invalid object "%1"',$id));
 
$path_v1 = $basepath . DIRECTORY_SEPARATOR . $obj->getLegacyDirectoryName();
$path_v1_bug = $basepath . $obj->getLegacyDirectoryName();
162,21 → 180,35
}
}
 
/**
* @return mixed|null
* @throws OIDplusException
*/
private function raMayDelete() {
return OIDplus::config()->getValue('attachments_allow_ra_delete', 0);
}
 
/**
* @return mixed|null
* @throws OIDplusException
*/
private function raMayUpload() {
return OIDplus::config()->getValue('attachments_allow_ra_upload', 0);
}
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return int[]
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
 
if ($actionID == 'deleteAttachment') {
_CheckParamExists($params, 'id');
$id = $params['id'];
$obj = OIDplusObject::parse($id);
if ($obj === null) throw new OIDplusException(_L('Invalid object "%1"',$id));
if (!$obj) throw new OIDplusException(_L('Invalid object "%1"',$id));
if (!$obj->userHasWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as admin, or as the RA of "%1" to upload an attachment.',$id));
 
if (!OIDplus::authUtils()->isAdminLoggedIn() && !$this->raMayDelete()) {
217,7 → 249,7
_CheckParamExists($params, 'id');
$id = $params['id'];
$obj = OIDplusObject::parse($id);
if ($obj === null) throw new OIDplusException(_L('Invalid object "%1"',$id));
if (!$obj) throw new OIDplusException(_L('Invalid object "%1"',$id));
if (!$obj->userHasWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as admin, or as the RA of "%1" to upload an attachment.',$id));
 
if (!OIDplus::authUtils()->isAdminLoggedIn() && !$this->raMayUpload()) {
299,11 → 331,16
 
return array("status" => 0);
} else {
throw new OIDplusException(_L('Unknown action ID'));
return parent::action($actionID, $params);
}
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
* @throws OIDplusException
*/
public function init(bool $html=true) {
OIDplus::config()->prepareConfigKey('attachments_block_extensions', 'Block file name extensions being used in file attachments (comma separated)', 'exe,scr,pif,bat,com,vbs,cmd', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
// TODO: check if a blacklist entry is also on the whitelist (which is not allowed)
});
340,25 → 377,52
});
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
*/
public function gui(string $id, array &$out, bool &$handled) {
// Nothing
}
 
public function publicSitemap(&$out) {
/**
* @param array $out
* @return void
*/
public function publicSitemap(array &$out) {
// Nothing
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
return false;
}
 
private static function convert_filesize($bytes, $decimals = 2){
/**
* Convert amount of bytes to human-friendly name
* @param int $bytes
* @param int $decimals
* @return string
*/
private static function convert_filesize(int $bytes, int $decimals = 2): string {
$size = array(_L('Bytes'),_L('KiB'),_L('MiB'),_L('GiB'),_L('TiB'),_L('PiB'),_L('EiB'),_L('ZiB'),_L('YiB'));
$factor = floor((strlen($bytes) - 1) / 3);
$factor = floor((strlen("$bytes") - 1) / 3);
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' ' . @$size[$factor];
}
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.2') return true; // modifyContent
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.3') return true; // beforeObject*, afterObject*
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.4') return true; // whois*Attributes
365,9 → 429,15
return false;
}
 
public function modifyContent($id, &$title, &$icon, &$text) {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.2
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.2
* @param string $id
* @param string $title
* @param string $icon
* @param string $text
* @return void
*/
public function modifyContent(string $id, string &$title, string &$icon, string &$text) {
$output = '';
$doshow = false;
 
377,7 → 447,7
$found_files = false;
 
$obj = OIDplusObject::parse($id);
if ($obj === null) throw new OIDplusException(_L('Invalid object "%1"',$id));
if (!$obj) throw new OIDplusException(_L('Invalid object "%1"',$id));
$can_upload = OIDplus::authUtils()->isAdminLoggedIn() || ($this->raMayUpload() && $obj->userHasWriteRights());
$can_delete = OIDplus::authUtils()->isAdminLoggedIn() || ($this->raMayDelete() && $obj->userHasWriteRights());
 
445,10 → 515,21
if ($doshow) $text .= $output;
}
 
public function beforeObjectDelete($id) {} // Interface 1.3.6.1.4.1.37476.2.5.2.3.3
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.3
* @param $id
* @return void
*/
public function beforeObjectDelete($id) {}
 
/**
* Delete the attachment folder including all files in it (note: Subfolders are not possible)
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.3
* @param $id
* @return void
* @throws OIDplusException
*/
public function afterObjectDelete($id) {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.3
// Delete the attachment folder including all files in it (note: Subfolders are not possible)
$uploaddir = self::getUploadDir($id);
if ($uploaddir != '') {
$ary = @glob($uploaddir . DIRECTORY_SEPARATOR . '*');
459,20 → 540,71
}
}
}
public function beforeObjectUpdateSuperior($id, &$params) {} // Interface 1.3.6.1.4.1.37476.2.5.2.3.3
public function afterObjectUpdateSuperior($id, &$params) {} // Interface 1.3.6.1.4.1.37476.2.5.2.3.3
public function beforeObjectUpdateSelf($id, &$params) {} // Interface 1.3.6.1.4.1.37476.2.5.2.3.3
public function afterObjectUpdateSelf($id, &$params) {} // Interface 1.3.6.1.4.1.37476.2.5.2.3.3
public function beforeObjectInsert($id, &$params) {} // Interface 1.3.6.1.4.1.37476.2.5.2.3.3
public function afterObjectInsert($id, &$params) {} // Interface 1.3.6.1.4.1.37476.2.5.2.3.3
 
public function tree_search($request) {
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.3
* @param $id
* @param $params
* @return void
*/
public function beforeObjectUpdateSuperior($id, &$params) {}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.3
* @param $id
* @param $params
* @return void
*/
public function afterObjectUpdateSuperior($id, &$params) {}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.3
* @param $id
* @param $params
* @return void
*/
public function beforeObjectUpdateSelf($id, &$params) {}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.3
* @param $id
* @param $params
* @return void
*/
public function afterObjectUpdateSelf($id, &$params) {}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.3
* @param $id
* @param $params
* @return void
*/
public function beforeObjectInsert($id, &$params) {}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.3
* @param $id
* @param $params
* @return void
*/
public function afterObjectInsert($id, &$params) {}
 
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.4
* @param $id
* @param $out
* @return void
* @throws OIDplusException
*/
public function whoisObjectAttributes($id, &$out) {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.4
 
$xmlns = 'oidplus-attachment-plugin';
$xmlschema = 'urn:oid:1.3.6.1.4.1.37476.2.5.2.4.1.95.1';
$xmlschemauri = OIDplus::webpath(__DIR__.'/attachments.xsd',OIDplus::PATH_ABSOLUTE);
499,5 → 631,12
}
 
}
public function whoisRaAttributes($email, &$out) {} // Interface 1.3.6.1.4.1.37476.2.5.2.3.4
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.4
* @param $email
* @param $out
* @return void
*/
public function whoisRaAttributes($email, &$out) {}
}
/trunk/plugins/viathinksoft/publicPages/100_whois/OIDplusOIDIP.class.php
30,6 → 30,9
protected $JSON_SCHEMA_URN;
protected $JSON_SCHEMA_URL;
 
/**
* @throws OIDplusException
*/
public function __construct() {
// NOTES:
// - XML_SCHEMA_URN must be equal to the string in the .xsd file!
40,6 → 43,11
$this->JSON_SCHEMA_URL = OIDplus::webpath(__DIR__,OIDplus::PATH_ABSOLUTE).'whois/draft-viathinksoft-oidip-05.json';
}
 
/**
* @param $query
* @return array|void
* @throws OIDplusException
*/
public function oidipQuery($query) {
 
$out_type = null;
251,6 → 259,8
}
 
if (substr($query,0,4) === 'oid:') {
assert($obj instanceof OIDplusOid); //assert(get_class($obj) === "ViaThinkSoft\OIDplus\OIDplusOid");
 
$out[] = $this->_oidip_attr('asn1-notation', $obj->getAsn1Notation(false)); // DO NOT TRANSLATE!
$out[] = $this->_oidip_attr('iri-notation', $obj->getIriNotation(false)); // DO NOT TRANSLATE!
 
282,12 → 292,12
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.
$obj->whoisObjectAttributes($obj->nodeId(), $out);
$obj->whoisObjectAttributes($obj->nodeId(), $out); /** @phpstan-ignore-line */
}
 
foreach (OIDplus::getAllPlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.4')) {
$plugin->whoisObjectAttributes($obj->nodeId(), $out);
$plugin->whoisObjectAttributes($obj->nodeId(), $out); /** @phpstan-ignore-line */
}
}
 
377,7 → 387,7
 
foreach (OIDplus::getAllPlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.4')) {
$plugin->whoisRaAttributes($obj->getRaMail(), $out);
$plugin->whoisRaAttributes($obj->getRaMail(), $out); /** @phpstan-ignore-line */
}
}
 
393,7 → 403,7
if ($obj) {
foreach (OIDplus::getAllPlugins() as $plugin) {
if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.4')) {
$plugin->whoisRaAttributes($obj->getRaMail(), $out);
$plugin->whoisRaAttributes($obj->getRaMail(), $out); /** @phpstan-ignore-line */
}
}
}
627,6 → 637,11
return array($out_content, $out_type);
}
 
/**
* @param $id
* @return string
* @throws OIDplusException
*/
protected function show_asn1_appendix($id) {
if (substr($id,0,4) === 'oid:') {
$appendix_asn1ids = array();
643,10 → 658,19
return $appendix;
}
 
/**
* @param $id
* @return bool
*/
protected function is_root($id) {
return empty(explode(':',$id,2)[1]);
}
 
/**
* @param $content
* @param $authTokens
* @return bool
*/
protected function authTokenAccepted($content, $authTokens) {
foreach ($authTokens as $token) {
if (OIDplusPagePublicWhois::genWhoisAuthToken($content) == $token) return true;
654,6 → 678,12
return false;
}
 
/**
* @param $obj
* @param $authTokens
* @return bool
* @throws OIDplusException
*/
protected function allowObjectView($obj, $authTokens) {
// Master auth token (TODO: Have an object-master-token and a ra-master-token?)
$authToken = trim(OIDplus::config()->getValue('whois_auth_token'));
679,6 → 709,12
return true;
}
 
/**
* @param $row_ra
* @param $authTokens
* @return bool
* @throws OIDplusException
*/
protected function allowRAView($row_ra, $authTokens) {
// Master auth token (TODO: Have an object-master-token and a ra-master-token?)
$authToken = trim(OIDplus::config()->getValue('whois_auth_token'));
692,6 → 728,11
return true;
}
 
/**
* @param $name
* @param $value
* @return array
*/
protected function _oidip_attr($name, $value) {
return array(
'xmlns' => '',
702,6 → 743,10
);
}
 
/**
* @param $out
* @return void
*/
protected function _oidip_newout_format(&$out) {
foreach ($out as &$line) {
if (is_string($line)) {
/trunk/plugins/viathinksoft/publicPages/100_whois/OIDplusPagePublicWhois.class.php
25,7 → 25,12
 
class OIDplusPagePublicWhois extends OIDplusPagePluginPublic {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
* @throws OIDplusException
*/
public function init(bool $html=true) {
OIDplus::config()->prepareConfigKey('whois_auth_token', 'OID-over-WHOIS authentication token to display confidential data', '', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
$test_value = preg_replace('@[0-9a-zA-Z]*@', '', $value);
if ($test_value != '') {
53,6 → 58,10
});
}
 
/**
* @return mixed|string
* @throws OIDplusException
*/
private function getExampleId() {
$firsts = array();
$first_ns = null;
72,7 → 81,14
}
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if (explode('$',$id)[0] == 'oidplus:whois') {
$handled = true;
 
90,8 → 106,7
$out['title'] = _L('OID Information Protocol (OID-IP) / WHOIS');
$out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
 
$out['text'] = '';
$out['text'] .= '<p>'._L('With the OID Information Protocol (OID-IP), you can query object information in a format that is human-readable and machine-readable.').'</p>';
$out['text'] = '<p>'._L('With the OID Information Protocol (OID-IP), you can query object information in a format that is human-readable and machine-readable.').'</p>';
 
// Use this if webwhois.php matches the currently uploaded Internet Draft:
$out['text'] .= '<p>'._L('RFC Internet Draft').': <a target="_blank" href="https://datatracker.ietf.org/doc/draft-viathinksoft-oidip/">draft-viathinksoft-oidip-05</a></p>';
150,11 → 165,23
}
}
 
public function publicSitemap(&$out) {
/**
* @param array $out
* @return void
*/
public function publicSitemap(array &$out) {
$out[] = 'oidplus:whois';
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (file_exists(__DIR__.'/img/main_icon16.png')) {
$tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png';
} else {
170,14 → 197,25
return true;
}
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.2') return true; // modifyContent
return false;
}
 
public function modifyContent($id, &$title, &$icon, &$text) {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.2
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.2
* @param string $id
* @param string $title
* @param string $icon
* @param string $text
* @return void
* @throws OIDplusException
*/
public function modifyContent(string $id, string &$title, string &$icon, string &$text) {
$text .= '<br><img src="'.OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/page_pictogram.png" height="15" alt=""> <a href="'.OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'whois/webwhois.php?query='.urlencode($id).'" class="gray_footer_font" target="_blank">'._L('Whois').'</a>';
 
$obj = OIDplusObject::parse($id);
188,10 → 226,19
 
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
 
/**
* @param $id
* @return int
* @throws OIDplusException
*/
public static function genWhoisAuthToken($id) {
return smallhash(OIDplus::baseConfig()->getValue('SERVER_SECRET').'/WHOIS/'.$id);
}
/trunk/plugins/viathinksoft/publicPages/200_viathinksoft_freeoid/OIDplusPagePublicFreeOID.class.php
25,10 → 25,21
 
class OIDplusPagePublicFreeOID extends OIDplusPagePluginPublic {
 
/**
* @param $with_ns
* @return string
* @throws OIDplusException
*/
private static function getFreeRootOid($with_ns) {
return ($with_ns ? 'oid:' : '').OIDplus::config()->getValue('freeoid_root_oid');
}
 
/**
* @param $email
* @param $getId
* @return bool|mixed|null
* @throws OIDplusException
*/
public static function alreadyHasFreeOid($email, $getId = false){
$res = OIDplus::db()->query("select id from ###objects where ra_email = ? and id like ? order by ".OIDplus::db()->natOrder('id'), array($email, self::getFreeRootOid(true).'.%'));
while ($row = $res->fetch_array()) {
37,7 → 48,14
return $getId ? null : false;
}
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return array|int[]
* @throws OIDplusException
* @throws OIDplusMailException
*/
public function action(string $actionID, array $params): array {
if (empty(self::getFreeRootOid(false))) throw new OIDplusException(_L('FreeOID service not available. Please ask your administrator.'));
 
if ($actionID == 'request_freeoid') {
156,7 → 174,7
 
$message = "OID delegation report\n";
$message .= "\n";
$message .= "OID: ".$new_oid."\n";;
$message .= "OID: ".$new_oid."\n";
$message .= "\n";
$message .= "RA Name: $ra_name\n";
$message .= "RA eMail: $email\n";
181,11 → 199,16
"status" => 0
);
} else {
throw new OIDplusException(_L('Unknown action ID'));
return parent::action($actionID, $params);
}
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
* @throws OIDplusException
*/
public function init(bool $html=true) {
OIDplus::config()->prepareConfigKey('freeoid_root_oid', 'Root-OID of free OID service (a service where visitors can create their own OID using email verification)', '', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
if (($value != '') && !oid_valid_dotnotation($value,false,false,1)) {
throw new OIDplusException(_L('Please enter a valid OID in dot notation or nothing'));
193,7 → 216,14
});
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if (empty(self::getFreeRootOid(false))) return;
 
if (explode('$',$id)[0] == 'oidplus:com.viathinksoft.freeoid') {
291,12 → 321,25
}
}
 
public function publicSitemap(&$out) {
/**
* @param array $out
* @return void
* @throws OIDplusException
*/
public function publicSitemap(array &$out) {
if (empty(self::getFreeRootOid(false))) return;
$out[] = 'oidplus:com.viathinksoft.freeoid';
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (empty(self::getFreeRootOid(false))) return false;
 
if (file_exists(__DIR__.'/img/main_icon16.png')) {
316,7 → 359,11
 
# ---
 
protected static function freeoid_max_id() {
/**
* @return int
* @throws OIDplusException
*/
protected static function freeoid_max_id(): int {
$res = OIDplus::db()->query("select id from ###objects where id like ? order by ".OIDplus::db()->natOrder('id'), array(self::getFreeRootOid(true).'.%'));
$highest_id = 0;
while ($row = $res->fetch_array()) {
326,7 → 373,11
return $highest_id;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
/trunk/plugins/viathinksoft/publicPages/300_search/OIDplusPagePublicSearch.class.php
25,7 → 25,12
 
class OIDplusPagePublicSearch extends OIDplusPagePluginPublic {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
* @throws OIDplusException
*/
public function init(bool $html=true) {
OIDplus::config()->prepareConfigKey('search_min_term_length', 'Minimum length of a search term', '3', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
if (!is_numeric($value) || ($value < 0)) {
throw new OIDplusException(_L('Please enter a valid value.'));
33,6 → 38,11
});
}
 
/**
* @param $params
* @param $is_searching
* @return void
*/
private function prepareSearchParams(&$params, $is_searching) {
$params['term'] = isset($params['term']) ? trim($params['term']) : '';
$params['namespace'] = isset($params['namespace']) ? trim($params['namespace']) : '';
51,10 → 61,20
}
}
 
/**
* @param $html
* @param $term
* @return array|string|string[]
*/
private function highlight_match($html, $term) {
return str_replace(htmlentities($term), '<font color="red">'.htmlentities($term).'</font>', $html);
}
 
/**
* @param $params
* @return string
* @throws OIDplusException
*/
private function doSearch($params) {
$output = '';
 
143,17 → 163,32
return $output;
}
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return array
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
 
if ($actionID == 'search') {
// Search with JavaScript/AJAX
$ret = $this->doSearch($params);
return array("status" => 0, "output" => $ret);
} else {
return parent::action($actionID, $params);
}
 
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if (explode('$',$id)[0] == 'oidplus:search') {
$handled = true;
 
215,11 → 250,23
}
}
 
public function publicSitemap(&$out) {
/**
* @param array $out
* @return void
*/
public function publicSitemap(array &$out) {
$out[] = 'oidplus:search';
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (file_exists(__DIR__.'/img/main_icon16.png')) {
$tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png';
} else {
235,7 → 282,11
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
/trunk/plugins/viathinksoft/publicPages/500_resources/OIDplusPagePublicResources.class.php
25,11 → 25,19
 
class OIDplusPagePublicResources extends OIDplusPagePluginPublic {
 
/**
* @return array|mixed|string|string[]
*/
private function getMainTitle() {
return _L('Documents and Resources');
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
* @throws OIDplusException
*/
public function init(bool $html=true) {
OIDplus::config()->prepareConfigKey('resource_plugin_autoopen_level', 'Resource plugin: How many levels should be open in the treeview when OIDplus is loaded?', '1', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
if (!is_numeric($value) || ($value < 0)) {
throw new OIDplusException(_L('Please enter a valid value.'));
44,6 → 52,12
});
}
 
/**
* @param $file
* @return string
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
private static function getDocumentContent($file) {
$file = self::realname($file);
$file2 = preg_replace('/\.([^.]+)$/', '$'.OIDplus::getCurrentLang().'.\1', $file);
60,6 → 74,12
return $cont;
}
 
/**
* @param $file
* @return array|mixed|string
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
private static function getDocumentTitle($file) {
$file = self::realname($file);
$file2 = preg_replace('/\.([^.]+)$/', '$'.OIDplus::getCurrentLang().'.\1', $file);
81,6 → 101,11
return pathinfo($file, PATHINFO_FILENAME); // filename without extension
}
 
/**
* @param $source
* @return bool
* @throws OIDplusException
*/
protected static function mayAccessResource($source) {
if (OIDplus::authUtils()->isAdminLoggedIn()) return true;
 
110,6 → 135,12
return true;
}
 
/**
* @param $reldir
* @param $onlydir
* @return array
* @throws OIDplusException
*/
private static function myglob($reldir, $onlydir=false) {
$out = array();
 
136,6 → 167,10
}, ARRAY_FILTER_USE_BOTH);
}
 
/**
* @param $rel
* @return string|null
*/
private static function realname($rel) {
$candidate1 = OIDplus::localpath().'userdata/resources/'.$rel;
$candidate2 = OIDplus::localpath().'res/'.$rel;
144,6 → 179,11
return null;
}
 
/**
* @param $source
* @param $target
* @return bool
*/
protected static function checkRedirect($source, &$target): bool {
$candidates = array(
OIDplus::localpath().'userdata/resources/redirect.ini',
161,7 → 201,15
return false;
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if (explode('$',$id,2)[0] === 'oidplus:resources') {
$handled = true;
 
294,7 → 342,6
$out['title'] = _L('Unknown file type');
$out['icon'] = 'img/error.png';
$out['text'] = '<p>'._L('The system does not know how to handle this file type.').'</p>';
return;
}
} else if (is_dir($realfile)) {
$out['title'] = ($file == '') ? $this->getMainTitle() : self::getFolderTitle($realfile);
402,9 → 449,17
}
}
 
private function tree_rec(&$children, $rootdir=null, $depth=0) {
/**
* @param $children
* @param ?string $rootdir
* @param int $depth
* @return void
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
private function tree_rec(&$children, string $rootdir=null, int $depth=0)/*: void*/ {
if (is_null($rootdir)) $rootdir = '';
if ($depth > 100) return false; // something is wrong!
if ($depth > 100) return; // something is wrong!
 
$dirs = self::myglob($rootdir.'*'.'/', true);
natcasesort($dirs);
491,6 → 546,11
}
}
 
/**
* @param $json
* @param $out
* @return void
*/
private function publicSitemap_rec($json, &$out) {
foreach ($json as $x) {
if (isset($x['id']) && $x['id']) {
502,13 → 562,26
}
}
 
public function publicSitemap(&$out) {
/**
* @param array $out
* @return void
*/
public function publicSitemap(array &$out) {
$json = array();
$this->tree($json, null/*RA EMail*/, false/*HTML tree algorithm*/, true/*display all*/);
$this->tree($json, null/*RA EMail*/, false/*HTML tree algorithm*/, "*"/*display all*/);
$this->publicSitemap_rec($json, $out);
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
$children = array();
 
$this->tree_rec($children, '/');
532,10 → 605,20
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
 
/**
* @param $file
* @return array|mixed|string|string[]|null
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
private static function getHyperlinkTitle($file) {
$file2 = preg_replace('/\.([^.]+)$/', '$'.OIDplus::getCurrentLang().'.\1', $file);
if (file_exists($file2)) $file = $file2;
565,6 → 648,12
}
}
 
/**
* @param $file
* @return mixed
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
private static function getHyperlinkURL($file) {
$file2 = preg_replace('/\.([^.]+)$/', '$'.OIDplus::getCurrentLang().'.\1', $file);
if (file_exists($file2)) $file = $file2;
610,6 → 699,12
 
}
 
/**
* @param $dir
* @return mixed|string
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
private static function getFolderTitle($dir) {
$data = @parse_ini_file("$dir/folder\$".OIDplus::getCurrentLang().".ini", true);
if ($data && isset($data['Folder']) && isset($data['Folder']['Title'])) {
/trunk/plugins/viathinksoft/publicPages/800_login_ldap/OIDplusPagePublicLoginLDAP.class.php
25,6 → 25,12
 
class OIDplusPagePublicLoginLdap extends OIDplusPagePluginPublic {
 
/**
* @param $ra
* @param $ldap_userinfo
* @return void
* @throws OIDplusException
*/
private function registerRA($ra, $ldap_userinfo) {
$email = $ra->raEmail();
 
73,6 → 79,13
}
}
 
/**
* @param $remember_me
* @param $email
* @param $ldap_userinfo
* @return void
* @throws OIDplusException
*/
private function doLoginRA($remember_me, $email, $ldap_userinfo) {
$ra = new OIDplusRA($email);
if (!$ra->existing()) {
85,6 → 98,11
OIDplus::db()->query("UPDATE ###ra set last_login = ".OIDplus::db()->sqlDate()." where email = ?", array($email));
}
 
/**
* @param $upn
* @return int
* @throws OIDplusException
*/
private function getDomainNumber($upn) {
$numDomains = OIDplus::baseConfig()->getValue('LDAP_NUM_DOMAINS', 1);
for ($i=1; $i<=$numDomains; $i++) {
95,7 → 113,14
return -1;
}
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return int[]
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
if ($actionID == 'ra_login_ldap') {
if (!OIDplus::baseConfig()->getValue('LDAP_ENABLED', false)) {
throw new OIDplusException(_L('LDAP authentication is disabled on this system.'));
197,15 → 222,26
 
return array("status" => 0);
} else {
throw new OIDplusException(_L('Unknown action ID'));
return parent::action($actionID, $params);
}
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
// Nothing
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if ($id === 'oidplus:login_ldap') {
$handled = true;
$out['title'] = _L('Login using LDAP / ActiveDirectory');
223,9 → 259,7
return;
}
 
$out['text'] = '';
 
$out['text'] .= '<noscript>';
$out['text'] = '<noscript>';
$out['text'] .= '<p>'._L('You need to enable JavaScript to use the login area.').'</p>';
$out['text'] .= '</noscript>';
 
296,26 → 330,49
}
}
 
public function publicSitemap(&$out) {
/**
* @param array $out
* @return void
*/
public function publicSitemap(array &$out) {
$out[] = 'oidplus:login_ldap';
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.5') return true; // alternativeLoginMethods()
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications()
return false;
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.5
* @return array
* @throws OIDplusException
*/
public function alternativeLoginMethods() {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.5
$logins = array();
if (OIDplus::baseConfig()->getValue('LDAP_ENABLED', false)) {
$logins[] = array(
327,8 → 384,13
return $logins;
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.8
* @param $user
* @return array
* @throws OIDplusException
*/
public function getNotifications($user=null): array {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.8
$notifications = array();
if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) {
if (OIDplus::baseConfig()->getValue('LDAP_ENABLED', false)) {
/trunk/plugins/viathinksoft/publicPages/810_login_google/OIDplusPagePublicLoginGoogle.class.php
25,15 → 25,32
 
class OIDplusPagePublicLoginGoogle extends OIDplusPagePluginPublic {
 
public function action($actionID, $params) {
throw new OIDplusException(_L('Unknown action ID'));
/**
* @param string $actionID
* @param array $params
* @return array
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
return parent::action($actionID, $params);
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
// Nothing
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if ($id === 'oidplus:login_google') {
$handled = true;
$out['title'] = _L('Login using Google');
56,26 → 73,49
}
}
 
public function publicSitemap(&$out) {
/**
* @param array $out
* @return void
*/
public function publicSitemap(array &$out) {
$out[] = 'oidplus:login_google';
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.5') return true; // alternativeLoginMethods()
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications()
return false;
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.5
* @return array
* @throws OIDplusException
*/
public function alternativeLoginMethods() {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.5
$logins = array();
if (OIDplus::baseConfig()->getValue('GOOGLE_OAUTH2_ENABLED', false)) {
$logins[] = array(
87,8 → 127,13
return $logins;
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.8
* @param $user
* @return array
* @throws OIDplusException
*/
public function getNotifications($user=null): array {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.8
$notifications = array();
if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) {
if (OIDplus::baseConfig()->getValue('GOOGLE_OAUTH2_ENABLED', false)) {
/trunk/plugins/viathinksoft/publicPages/820_login_facebook/OIDplusPagePublicLoginFacebook.class.php
25,15 → 25,32
 
class OIDplusPagePublicLoginFacebook extends OIDplusPagePluginPublic {
 
public function action($actionID, $params) {
throw new OIDplusException(_L('Unknown action ID'));
/**
* @param string $actionID
* @param array $params
* @return array
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
return parent::action($actionID, $params);
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
// Nothing
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if ($id === 'oidplus:login_facebook') {
$handled = true;
$out['title'] = _L('Login using Facebook');
55,26 → 72,49
}
}
 
public function publicSitemap(&$out) {
/**
* @param array $out
* @return void
*/
public function publicSitemap(array &$out) {
$out[] = 'oidplus:login_facebook';
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.5') return true; // alternativeLoginMethods()
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications()
return false;
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.5
* @return array
* @throws OIDplusException
*/
public function alternativeLoginMethods() {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.5
$logins = array();
if (OIDplus::baseConfig()->getValue('FACEBOOK_OAUTH2_ENABLED', false)) {
$logins[] = array(
86,8 → 126,13
return $logins;
}
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.8
* @param $user
* @return array
* @throws OIDplusException
*/
public function getNotifications($user=null): array {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.8
$notifications = array();
if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) {
if (OIDplus::baseConfig()->getValue('FACEBOOK_OAUTH2_ENABLED', false)) {
/trunk/plugins/viathinksoft/publicPages/900_contact_admin/OIDplusPagePublicContactEMail.class.php
25,11 → 25,22
 
class OIDplusPagePublicContactEMail extends OIDplusPagePluginPublic {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
// Nothing
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if ($id === 'oidplus:contact') {
$handled = true;
$out['title'] = _L('Contact administrator');
44,11 → 55,23
}
}
 
public function publicSitemap(&$out) {
/**
* @param array $out
* @return void
*/
public function publicSitemap(array &$out) {
$out[] = 'oidplus:contact';
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (file_exists(__DIR__.'/img/main_icon16.png')) {
$tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png';
} else {
64,7 → 87,11
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
}
/trunk/plugins/viathinksoft/publicPages/999_antispam_filter/OIDplusPagePublicAntiSpamFilter.class.php
25,7 → 25,11
 
class OIDplusPagePublicAntiSpamFilter extends OIDplusPagePluginPublic {
 
public function htmlPostprocess(&$html) {
/**
* @param string $html
* @return void
*/
public function htmlPostprocess(string &$html) {
$html = preg_replace_callback(
'|<a\s([^>]*)href="mailto:([^"]+)"([^>]*)>([^<]*)</a>|ismU',
function ($treffer) {
/trunk/plugins/viathinksoft/raPages/010_notifications/OIDplusPageRaNotifications.class.php
25,10 → 25,22
 
class OIDplusPageRaNotifications extends OIDplusPagePluginRa {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!$ra_email) return false;
if (!OIDplus::authUtils()->isRaLoggedIn($ra_email) && !OIDplus::authUtils()->isAdminLoggedIn()) return false;
if (is_null(OIDplus::getPluginByOid('1.3.6.1.4.1.37476.2.5.2.4.3.10'))) return false; // OIDplusPageAdminNotifications
48,7 → 60,11
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
/trunk/plugins/viathinksoft/raPages/092_invite/OIDplusPageRaInvite.class.php
25,7 → 25,14
 
class OIDplusPageRaInvite extends OIDplusPagePluginRa {
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return int[]
* @throws OIDplusException
* @throws OIDplusMailException
*/
public function action(string $actionID, array $params): array {
if ($actionID == 'invite_ra') {
$email = $params['email'];
 
87,11 → 94,16
 
return array("status" => 0);
} else {
throw new OIDplusException(_L('Unknown action ID'));
return parent::action($actionID, $params);
}
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
* @throws OIDplusException
*/
public function init(bool $html=true) {
OIDplus::config()->prepareConfigKey('max_ra_invite_time', 'Max RA invite time in seconds (0 = infinite)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
if (!is_numeric($value) || ($value < 0)) {
throw new OIDplusException(_L('Please enter a valid value.'));
104,7 → 116,14
});
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if (explode('$',$id)[0] == 'oidplus:invite_ra') {
$handled = true;
 
181,7 → 200,14
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
//if (!$ra_email) return false;
//if (!OIDplus::authUtils()->isRaLoggedIn($ra_email) && !OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
188,6 → 214,11
return false;
}
 
/**
* @param $email
* @return void
* @throws OIDplusException
*/
private function inviteSecurityCheck($email) {
$res = OIDplus::db()->query("select * from ###ra where email = ?", array($email));
if ($res->any()) {
200,7 → 231,7
$res = OIDplus::db()->query("select parent from ###objects where ra_email = ?", array($email));
while ($row = $res->fetch_array()) {
$objParent = OIDplusObject::parse($row['parent']);
if (is_null($objParent)) throw new OIDplusException(_L('Type of %1 unknown',$row['parent']));
if (!$objParent) throw new OIDplusException(_L('Type of %1 unknown',$row['parent']));
if ($objParent->userHasWriteRights()) {
$ok = true;
}
211,7 → 242,12
}
}
 
private function getInvitationText($email) {
/**
* @param $email
* @return string
* @throws OIDplusException
*/
private function getInvitationText($email): string {
$list_of_oids = array();
$res = OIDplus::db()->query("select id from ###objects where ra_email = ?", array($email));
while ($row = $res->fetch_array()) {
231,7 → 267,11
return $message;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
/trunk/plugins/viathinksoft/raPages/099_object_log/OIDplusPageRaObjectLog.class.php
25,13 → 25,30
 
class OIDplusPageRaObjectLog extends OIDplusPagePluginRa {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
*/
public function gui(string $id, array &$out, bool &$handled) {
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
//if (!$ra_email) return false;
//if (!OIDplus::authUtils()->isRaLoggedIn($ra_email) && !OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
38,14 → 55,25
return false;
}
 
public function implementsFeature($id) {
/**
* @param string $id
* @return bool
*/
public function implementsFeature(string $id): bool {
if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.2') return true; // modifyContent
return false;
}
 
public function modifyContent($id, &$title, &$icon, &$text) {
// Interface 1.3.6.1.4.1.37476.2.5.2.3.2
 
/**
* Implements interface 1.3.6.1.4.1.37476.2.5.2.3.2
* @param string $id
* @param string $title
* @param string $icon
* @param string $text
* @return void
* @throws \ViaThinkSoft\OIDplus\OIDplusException
*/
public function modifyContent(string $id, string &$title, string &$icon, string &$text) {
$obj = OIDplusObject::parse($id);
if (!$obj) return;
if (!$obj->userHasWriteRights()) return;
82,7 → 110,11
 
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
}
/trunk/plugins/viathinksoft/raPages/100_edit_contact_data/OIDplusPageRaEditContactData.class.php
25,7 → 25,13
 
class OIDplusPageRaEditContactData extends OIDplusPagePluginRa {
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return int[]
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
if ($actionID == 'change_ra_data') {
_CheckParamExists($params, 'email');
 
69,15 → 75,26
 
return array("status" => 0);
} else {
throw new OIDplusException(_L('Unknown action ID'));
return parent::action($actionID, $params);
}
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
// Nothing
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if (explode('$',$id)[0] == 'oidplus:edit_ra') {
$handled = true;
 
136,7 → 153,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!$ra_email) return false;
if (!OIDplus::authUtils()->isRaLoggedIn($ra_email) && !OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
155,7 → 180,11
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
/trunk/plugins/viathinksoft/raPages/101_change_password/OIDplusPageRaChangePassword.class.php
25,7 → 25,13
 
class OIDplusPageRaChangePassword extends OIDplusPagePluginRa {
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return int[]
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
if ($actionID == 'change_ra_password') {
_CheckParamExists($params, 'email');
 
77,15 → 83,26
 
return array("status" => 0);
} else {
throw new OIDplusException(_L('Unknown action ID'));
return parent::action($actionID, $params);
}
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
// Nothing
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if (explode('$',$id)[0] == 'oidplus:change_ra_password') {
$handled = true;
 
124,7 → 141,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!$ra_email) return false;
if (!OIDplus::authUtils()->isRaLoggedIn($ra_email) && !OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
145,7 → 170,11
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
/trunk/plugins/viathinksoft/raPages/102_change_email/OIDplusPageRaChangeEMail.class.php
25,7 → 25,14
 
class OIDplusPageRaChangeEMail extends OIDplusPagePluginRa {
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return int[]
* @throws OIDplusException
* @throws OIDplusMailException
*/
public function action(string $actionID, array $params): array {
if ($actionID == 'change_ra_email') {
if (!OIDplus::config()->getValue('allow_ra_email_change') && !OIDplus::authUtils()->isAdminLoggedIn()) {
throw new OIDplusException(_L('This functionality has been disabled by the administrator.'));
182,11 → 189,16
 
return array("status" => 0);
} else {
throw new OIDplusException(_L('Unknown action ID'));
return parent::action($actionID, $params);
}
}
 
public function init($html=true) {
/**
* @param bool $html
* @return void
* @throws OIDplusException
*/
public function init(bool $html=true) {
OIDplus::config()->prepareConfigKey('max_ra_email_change_time', 'Max RA email change time in seconds (0 = infinite)', '0', OIDplusConfig::PROTECTION_EDITABLE, function($value) {
if (!is_numeric($value) || ($value < 0)) {
throw new OIDplusException(_L('Please enter a valid value.'));
199,7 → 211,14
});
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if (explode('$',$id)[0] == 'oidplus:change_ra_email') {
$handled = true;
 
312,7 → 331,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!$ra_email) return false;
if (!OIDplus::authUtils()->isRaLoggedIn($ra_email) && !OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
331,7 → 358,11
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
/trunk/plugins/viathinksoft/raPages/200_log/OIDplusPageRaLogEvents.class.php
25,10 → 25,21
 
class OIDplusPageRaLogEvents extends OIDplusPagePluginRa {
 
public function init($html=true) {
/**
* @param bool $html
* @return void
*/
public function init(bool $html=true) {
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if (explode('$',$id)[0] == 'oidplus:ra_log') {
$handled = true;
 
71,7 → 82,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!$ra_email) return false;
if (!OIDplus::authUtils()->isRaLoggedIn($ra_email) && !OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
90,7 → 109,11
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
}
/trunk/plugins/viathinksoft/raPages/910_automated_ajax_calls/OIDplusPageRaAutomatedAJAXCalls.class.php
28,7 → 28,13
 
class OIDplusPageRaAutomatedAJAXCalls extends OIDplusPagePluginRa {
 
public function action($actionID, $params) {
/**
* @param string $actionID
* @param array $params
* @return int[]
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
if ($actionID == 'blacklistJWT') {
if (!OIDplus::baseConfig()->getValue('JWT_ALLOW_AJAX_USER', true)) {
throw new OIDplusException(_L('The administrator has disabled this feature. (Base configuration setting %1).','JWT_ALLOW_AJAX_USER'));
48,11 → 54,18
 
return array("status" => 0);
} else {
throw new OIDplusException(_L('Unknown action ID'));
return parent::action($actionID, $params);
}
}
 
public function gui($id, &$out, &$handled) {
/**
* @param string $id
* @param array $out
* @param bool $handled
* @return void
* @throws OIDplusException
*/
public function gui(string $id, array &$out, bool &$handled) {
if (explode('$',$id)[0] == 'oidplus:automated_ajax_information_ra') {
$handled = true;
 
131,7 → 144,15
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
/**
* @param array $json
* @param string|null $ra_email
* @param bool $nonjs
* @param string $req_goto
* @return bool
* @throws OIDplusException
*/
public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
if (!$ra_email) return false;
if (!OIDplus::authUtils()->isRaLoggedIn($ra_email) && !OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
150,7 → 171,11
return true;
}
 
public function tree_search($request) {
/**
* @param string $request
* @return array|false
*/
public function tree_search(string $request) {
return false;
}
}
/trunk/plugins/viathinksoft/sqlSlang/access/OIDplusSqlSlangPluginAccess.class.php
25,11 → 25,19
 
class OIDplusSqlSlangPluginAccess extends OIDplusSqlSlangPlugin {
 
/**
* @return string
*/
public static function id(): string {
return 'access';
}
 
public function natOrder($fieldname, $order='asc'): string {
/**
* @param string $fieldname
* @param string $order
* @return string
*/
public function natOrder(string $fieldname, string $order='asc'): string {
 
// TODO: Implement
return "$fieldname $order";
36,10 → 44,17
 
}
 
/**
* @return string
*/
public function sqlDate(): string {
return 'date()';
}
 
/**
* @param OIDplusDatabaseConnection $db
* @return bool
*/
public function detect(OIDplusDatabaseConnection $db): bool {
/*
if ($tables = @odbc_tables($db->conn)) {
76,6 → 91,11
return (!empty($err_a) && !empty($err_b) && ($err_a != $err_b));
}
 
/**
* @param OIDplusDatabaseConnection $db
* @return int
* @throws OIDplusException
*/
public function insert_id(OIDplusDatabaseConnection $db): int {
$res = $db->query("SELECT @@IDENTITY AS ID");
$row = $res->fetch_array();
82,7 → 102,13
return (int)$row['ID'];
}
 
public function setupSetTablePrefix($cont, $table, $prefix): string {
/**
* @param string $cont
* @param string $table
* @param string $prefix
* @return string
*/
public function setupSetTablePrefix(string $cont, string $table, string $prefix): string {
$cont = str_replace('['.$table.']', '['.$prefix.$table.']', $cont);
$cont = str_replace('PK_'.$table, 'PK_'.$prefix.$table, $cont);
$cont = str_replace('IX_'.$table, 'PK_'.$prefix.$table, $cont);
89,19 → 115,36
return $cont;
}
 
public function setupCreateDbIfNotExists($database): string {
/**
* @param string $database
* @return string
*/
public function setupCreateDbIfNotExists(string $database): string {
return "";
}
 
public function setupUseDatabase($database): string {
/**
* @param string $database
* @return string
*/
public function setupUseDatabase(string $database): string {
return "";
}
 
public function isNullFunction($expr1, $expr2): string {
/**
* @param string $expr1
* @param string $expr2
* @return string
*/
public function isNullFunction(string $expr1, string $expr2): string {
return "iif($expr1 is null, $expr2, $expr1)";
}
 
public function filterQuery($sql): string {
/**
* @param string $sql
* @return string
*/
public function filterQuery(string $sql): string {
// value => [value]
$sql = preg_replace('@\\b(value)\\b@i', '[\\1]', $sql);
 
123,11 → 166,19
return $sql;
}
 
public function getSQLBool($bool): string {
/**
* @param bool $bool
* @return string
*/
public function getSQLBool(bool $bool): string {
return $bool ? '-1' : '0';
}
 
public function escapeString($str): string {
/**
* @param string $str
* @return string
*/
public function escapeString(string $str): string {
return str_replace("'", "''", $str);
}
}
/trunk/plugins/viathinksoft/sqlSlang/mssql/OIDplusSqlSlangPluginMsSQL.class.php
25,11 → 25,20
 
class OIDplusSqlSlangPluginMsSQL extends OIDplusSqlSlangPlugin {
 
/**
* @return string
*/
public static function id(): string {
return 'mssql';
}
 
public function natOrder($fieldname, $order='asc'): string {
/**
* @param string $fieldname
* @param string $order
* @return string
* @throws OIDplusException
*/
public function natOrder(string $fieldname, string $order='asc'): string {
 
$order = strtolower($order);
if (($order != 'asc') && ($order != 'desc')) {
55,10 → 64,17
 
}
 
/**
* @return string
*/
public function sqlDate(): string {
return 'getdate()';
}
 
/**
* @param OIDplusDatabaseConnection $db
* @return bool
*/
public function detect(OIDplusDatabaseConnection $db): bool {
try {
$vers = $db->query("select @@version as dbms_version")->fetch_object()->dbms_version;
69,6 → 85,11
}
}
 
/**
* @param OIDplusDatabaseConnection $db
* @return int
* @throws OIDplusException
*/
public function insert_id(OIDplusDatabaseConnection $db): int {
// Note: SCOPE_IDENTITY() does not work, does only give 0.
// $res = $db->query("SELECT SCOPE_IDENTITY() AS ID");
77,7 → 98,13
return (int)$row['ID'];
}
 
public function setupSetTablePrefix($cont, $table, $prefix): string {
/**
* @param string $cont
* @param string $table
* @param string $prefix
* @return string
*/
public function setupSetTablePrefix(string $cont, string $table, string $prefix): string {
$cont = str_replace('['.$table.']', '['.$prefix.$table.']', $cont);
$cont = str_replace("'dbo.$table'", "'dbo.$prefix$table'", $cont);
$cont = str_replace('PK_'.$table, 'PK_'.$prefix.$table, $cont);
86,27 → 113,52
return $cont;
}
 
public function setupCreateDbIfNotExists($database): string {
/**
* @param string $database
* @return string
*/
public function setupCreateDbIfNotExists(string $database): string {
return "";
}
 
public function setupUseDatabase($database): string {
/**
* @param string $database
* @return string
*/
public function setupUseDatabase(string $database): string {
return "USE [$database]\n\nGO\n\n";
}
 
public function isNullFunction($expr1, $expr2): string {
/**
* @param string $expr1
* @param string $expr2
* @return string
*/
public function isNullFunction(string $expr1, string $expr2): string {
return "isnull($expr1, $expr2)";
}
 
public function filterQuery($sql): string {
/**
* @param string $sql
* @return string
*/
public function filterQuery(string $sql): string {
return $sql;
}
 
public function getSQLBool($bool): string {
/**
* @param bool $bool
* @return string
*/
public function getSQLBool(bool $bool): string {
return $bool ? '1' : '0';
}
 
public function escapeString($str): string {
/**
* @param string $str
* @return string
*/
public function escapeString(string $str): string {
return str_replace("'", "''", $str);
}
}
/trunk/plugins/viathinksoft/sqlSlang/mysql/OIDplusSqlSlangPluginMySQL.class.php
25,11 → 25,20
 
class OIDplusSqlSlangPluginMySQL extends OIDplusSqlSlangPlugin {
 
/**
* @return string
*/
public static function id(): string {
return 'mysql';
}
 
public function natOrder($fieldname, $order='asc'): string {
/**
* @param string $fieldname
* @param string $order
* @return string
* @throws OIDplusException
*/
public function natOrder(string $fieldname, string $order='asc'): string {
 
$order = strtolower($order);
if (($order != 'asc') && ($order != 'desc')) {
58,10 → 67,17
 
}
 
/**
* @return string
*/
public function sqlDate(): string {
return 'now()';
}
 
/**
* @param OIDplusDatabaseConnection $db
* @return bool
*/
public function detect(OIDplusDatabaseConnection $db): bool {
try {
$vers = $db->query("select version() as dbms_version")->fetch_object()->dbms_version;
72,6 → 88,11
}
}
 
/**
* @param OIDplusDatabaseConnection $db
* @return int
* @throws OIDplusException
*/
public function insert_id(OIDplusDatabaseConnection $db): int {
$res = $db->query("SELECT LAST_INSERT_ID() AS ID");
$row = $res->fetch_array();
78,33 → 99,63
return (int)$row['ID'];
}
 
 
public function setupSetTablePrefix($cont, $table, $prefix): string {
/**
* @param string $cont
* @param string $table
* @param string $prefix
* @return string
*/
public function setupSetTablePrefix(string $cont, string $table, string $prefix): string {
$cont = str_replace('`'.$table.'`', '`'.$prefix.$table.'`', $cont);
return $cont;
}
 
public function setupCreateDbIfNotExists($database): string {
/**
* @param string $database
* @return string
*/
public function setupCreateDbIfNotExists(string $database): string {
return "CREATE DATABASE IF NOT EXISTS `$database`;\n\n";
}
 
public function setupUseDatabase($database): string {
/**
* @param string $database
* @return string
*/
public function setupUseDatabase(string $database): string {
return "USE `$database`;\n\n";
}
 
public function isNullFunction($expr1, $expr2): string {
/**
* @param string $expr1
* @param string $expr2
* @return string
*/
public function isNullFunction(string $expr1, string $expr2): string {
return "ifnull($expr1, $expr2)";
}
 
public function filterQuery($sql): string {
/**
* @param string $sql
* @return string
*/
public function filterQuery(string $sql): string {
return $sql;
}
 
public function getSQLBool($bool): string {
/**
* @param bool $bool
* @return string
*/
public function getSQLBool(bool $bool): string {
return $bool ? '1' : '0';
}
 
public function escapeString($str): string {
/**
* @param string $str
* @return string
*/
public function escapeString(string $str): string {
return str_replace("'", "''", $str);
}
}
/trunk/plugins/viathinksoft/sqlSlang/oracle/OIDplusSqlSlangPluginOracle.class.php
25,11 → 25,20
 
class OIDplusSqlSlangPluginOracle extends OIDplusSqlSlangPlugin {
 
/**
* @return string
*/
public static function id(): string {
return 'oracle';
}
 
public function natOrder($fieldname, $order='asc'): string {
/**
* @param string $fieldname
* @param string $order
* @return string
* @throws OIDplusException
*/
public function natOrder(string $fieldname, string $order='asc'): string {
 
$order = strtolower($order);
if (($order != 'asc') && ($order != 'desc')) {
60,10 → 69,17
 
}
 
/**
* @return string
*/
public function sqlDate(): string {
return 'SYSDATE';
}
 
/**
* @param OIDplusDatabaseConnection $db
* @return bool
*/
public function detect(OIDplusDatabaseConnection $db): bool {
try {
$vers = $db->query("SELECT banner FROM v\$version WHERE banner LIKE 'Oracle%'")->fetch_object()->banner;
74,8 → 90,16
}
}
 
/**
* @var ?string
*/
private $last_insert_table = null;
 
/**
* @param OIDplusDatabaseConnection $db
* @return int
* @throws OIDplusException
*/
public function insert_id(OIDplusDatabaseConnection $db): int {
if (!$this->last_insert_table) return 0;
$res = $db->query("select sequence_name from user_tab_identity_cols where table_name = '".strtoupper($this->last_insert_table)."'");
87,8 → 111,13
return (int)$row['CURRVAL'];
}
 
 
public function setupSetTablePrefix($cont, $table, $prefix): string {
/**
* @param string $cont
* @param string $table
* @param string $prefix
* @return string
*/
public function setupSetTablePrefix(string $cont, string $table, string $prefix): string {
$table = strtoupper($table);
$prefix = strtoupper($prefix);
$cont = str_replace('"'.$table.'"', '"'.$prefix.$table.'"', $cont);
95,22 → 124,39
return $cont;
}
 
public function setupCreateDbIfNotExists($database): string {
/**
* @param string $database
* @return string
*/
public function setupCreateDbIfNotExists(string $database): string {
// TODO! Implement
return "";
}
 
public function setupUseDatabase($database): string {
/**
* @param string $database
* @return string
*/
public function setupUseDatabase(string $database): string {
// TODO! Implement
return "";
}
 
public function isNullFunction($expr1, $expr2): string {
/**
* @param string $expr1
* @param string $expr2
* @return string
*/
public function isNullFunction(string $expr1, string $expr2): string {
// Test via "SELECT NVL(null, 'foo') FROM DUAL;"
return "NVL($expr1, $expr2)";
}
 
public function filterQuery($sql): string {
/**
* @param string $sql
* @return string
*/
public function filterQuery(string $sql): string {
 
// "select 1" is not valid. You need to add "from dual"
if ((stripos($sql,'select') !== false) && (stripos($sql,'from') === false)) {
132,16 → 178,22
}
 
// Comment is a keyword and cannot be used as column name
$sql = str_ireplace('comment', '"COMMENT"', $sql);
 
return $sql;
return str_ireplace('comment', '"COMMENT"', $sql);
}
 
public function getSQLBool($bool): string {
/**
* @param bool $bool
* @return string
*/
public function getSQLBool(bool $bool): string {
return $bool ? '1' : '0';
}
 
public function escapeString($str): string {
/**
* @param string $str
* @return string
*/
public function escapeString(string $str): string {
return str_replace("'", "''", $str);
}
}
/trunk/plugins/viathinksoft/sqlSlang/pgsql/OIDplusSqlSlangPluginPgSQL.class.php
25,11 → 25,20
 
class OIDplusSqlSlangPluginPgSQL extends OIDplusSqlSlangPlugin {
 
/**
* @return string
*/
public static function id(): string {
return 'pgsql';
}
 
public function natOrder($fieldname, $order='asc'): string {
/**
* @param string $fieldname
* @param string $order
* @return string
* @throws OIDplusException
*/
public function natOrder(string $fieldname, string $order='asc'): string {
 
$order = strtolower($order);
if (($order != 'asc') && ($order != 'desc')) {
53,10 → 62,17
 
}
 
/**
* @return string
*/
public function sqlDate(): string {
return 'now()';
}
 
/**
* @param OIDplusDatabaseConnection $db
* @return bool
*/
public function detect(OIDplusDatabaseConnection $db): bool {
try {
$vers = $db->query("select version() as dbms_version")->fetch_object()->dbms_version;
67,6 → 83,11
}
}
 
/**
* @param OIDplusDatabaseConnection $db
* @return int
* @throws OIDplusException
*/
public function insert_id(OIDplusDatabaseConnection $db): int {
$res = $db->query("SELECT LASTVAL() AS ID");
$row = $res->fetch_array();
73,33 → 94,64
return (int)$row['ID'];
}
 
public function setupSetTablePrefix($cont, $table, $prefix): string {
/**
* @param string $cont
* @param string $table
* @param string $prefix
* @return string
*/
public function setupSetTablePrefix(string $cont, string $table, string $prefix): string {
$cont = str_replace('"'.$table.'"', '"'.$prefix.$table.'"', $cont);
$cont = str_replace('"index_'.$table, '"index_'.$prefix.$table, $cont);
return $cont;
}
 
public function setupCreateDbIfNotExists($database): string {
/**
* @param string $database
* @return string
*/
public function setupCreateDbIfNotExists(string $database): string {
return "-- CREATE DATABASE $database;\n\n";
}
 
public function setupUseDatabase($database): string {
/**
* @param string $database
* @return string
*/
public function setupUseDatabase(string $database): string {
return "-- \connect $database;\n\n";
}
 
public function isNullFunction($expr1, $expr2): string {
/**
* @param string $expr1
* @param string $expr2
* @return string
*/
public function isNullFunction(string $expr1, string $expr2): string {
return "coalesce($expr1, $expr2)";
}
 
public function filterQuery($sql): string {
/**
* @param string $sql
* @return string
*/
public function filterQuery(string $sql): string {
return $sql;
}
 
public function getSQLBool($bool): string {
/**
* @param bool $bool
* @return string
*/
public function getSQLBool(bool $bool): string {
return $bool ? '1' : '0';
}
 
public function escapeString($str): string {
/**
* @param string $str
* @return string
*/
public function escapeString(string $str): string {
return str_replace("'", "''", $str);
}
}
/trunk/plugins/viathinksoft/sqlSlang/sqlite/OIDplusSqlSlangPluginSQLite.class.php
25,11 → 25,20
 
class OIDplusSqlSlangPluginSQLite extends OIDplusSqlSlangPlugin {
 
/**
* @return string
*/
public static function id(): string {
return 'sqlite';
}
 
public function natOrder($fieldname, $order='asc'): string {
/**
* @param string $fieldname
* @param string $order
* @return string
* @throws OIDplusException
*/
public function natOrder(string $fieldname, string $order='asc'): string {
 
$order = strtolower($order);
if (($order != 'asc') && ($order != 'desc')) {
73,10 → 82,17
 
}
 
/**
* @return string
*/
public function sqlDate(): string {
return 'datetime()';
}
 
/**
* @param OIDplusDatabaseConnection $db
* @return bool
*/
public function detect(OIDplusDatabaseConnection $db): bool {
try {
$db->query("select sqlite_version as dbms_version");
86,6 → 102,11
}
}
 
/**
* @param OIDplusDatabaseConnection $db
* @return int
* @throws OIDplusException
*/
public function insert_id(OIDplusDatabaseConnection $db): int {
$res = $db->query("SELECT last_insert_rowid() AS ID");
$row = $res->fetch_array();
92,32 → 113,63
return (int)$row['ID'];
}
 
public function setupSetTablePrefix($cont, $table, $prefix): string {
/**
* @param string $cont
* @param string $table
* @param string $prefix
* @return string
*/
public function setupSetTablePrefix(string $cont, string $table, string $prefix): string {
$cont = str_replace('`'.$table.'`', '`'.$prefix.$table.'`', $cont);
return $cont;
}
 
public function setupCreateDbIfNotExists($database): string {
/**
* @param string $database
* @return string
*/
public function setupCreateDbIfNotExists(string $database): string {
return "";
}
 
public function setupUseDatabase($database): string {
/**
* @param string $database
* @return string
*/
public function setupUseDatabase(string $database): string {
return "";
}
 
public function isNullFunction($expr1, $expr2): string {
/**
* @param string $expr1
* @param string $expr2
* @return string
*/
public function isNullFunction(string $expr1, string $expr2): string {
return "ifnull($expr1, $expr2)";
}
 
public function filterQuery($sql): string {
/**
* @param string $sql
* @return string
*/
public function filterQuery(string $sql): string {
return $sql;
}
 
public function getSQLBool($bool): string {
/**
* @param bool $bool
* @return string
*/
public function getSQLBool(bool $bool): string {
return $bool ? '1' : '0';
}
 
public function escapeString($str): string {
/**
* @param string $str
* @return string
*/
public function escapeString(string $str): string {
return str_replace("'", "''", $str);
}
}
/trunk/polyfill.min.js.php
22,7 → 22,7
// So, the OIDplus webserver will act as proxy.
 
// see https://polyfill.io/v3/url-builder/
define('REQUIRED_POLYFILLS', array(
const REQUIRED_POLYFILLS = array(
// Internet Explorer for various AJAX calls
'fetch',
'URL',
32,11 → 32,11
 
// Internet Explorer for TinyMCE if it is included inside oidplus.min.js.php ( https://github.com/tinymce/tinymce/blob/5c1702a119e683f93e03ecc2231f11d17ce57395/modules/tinymce/src/core/main/ts/api/EditorManager.ts#L271 )
'document.currentScript'
));
);
 
define('MINIFY_POLYFILL', true); // TODO: put into baseconfig?
const MINIFY_POLYFILL = true; // TODO: put into baseconfig?
 
define('POLYFILL_CACHE_MAX_AGE', 24*60*60); // 1 day, TODO: put into baseconfig?
const POLYFILL_CACHE_MAX_AGE = 24 * 60 * 60; // 1 day, TODO: put into baseconfig?
 
# ---
 
/trunk/setup/index.php
24,8 → 24,8
 
require_once __DIR__ . '/../includes/oidplus.inc.php';
 
define('BASECONFIG_FILE_OLD', 'includes/config.inc.php');
define('BASECONFIG_FILE_NEW', 'userdata/baseconfig/config.inc.php');
const BASECONFIG_FILE_OLD = 'includes/config.inc.php';
const BASECONFIG_FILE_NEW = 'userdata/baseconfig/config.inc.php';
$existing_config = '';
if (file_exists(__DIR__.'/../'.BASECONFIG_FILE_OLD)) $existing_config = BASECONFIG_FILE_OLD;
if (file_exists(__DIR__.'/../'.BASECONFIG_FILE_NEW)) $existing_config = BASECONFIG_FILE_NEW;
/trunk/setup/setup.min.css.php
34,7 → 34,7
function process_file($filename) {
global $do_minify;
 
if (!file_exists($filename)) return;
if (!file_exists($filename)) return "";
 
$thisdir = __DIR__;
$thisdir = str_replace('\\', '/', $thisdir); // change Windows Backslashes into Web-Slashes