Subversion Repositories oidplus

Rev

Rev 1127 | Rev 1131 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1127 Rev 1130
Line 477... Line 477...
477
        /**
477
        /**
478
         * @param string $id
478
         * @param string $id
479
         * @return OIDplusSqlSlangPlugin|null
479
         * @return OIDplusSqlSlangPlugin|null
480
         */
480
         */
481
        public static function getSqlSlangPlugin(string $id)/*: ?OIDplusSqlSlangPlugin*/ {
481
        public static function getSqlSlangPlugin(string $id)/*: ?OIDplusSqlSlangPlugin*/ {
482
                if (isset(self::$sqlSlangPlugins[$id])) {
-
 
483
                        return self::$sqlSlangPlugins[$id];
482
                return self::$sqlSlangPlugins[$id] ?? null;
484
                } else {
-
 
485
                        return null;
-
 
486
                }
-
 
487
        }
483
        }
488
 
484
 
489
        // --- Database plugin
485
        // --- Database plugin
490
 
486
 
491
        /**
487
        /**
Line 1103... Line 1099...
1103
                }
1099
                }
1104
                return $out;
1100
                return $out;
1105
        }
1101
        }
1106
 
1102
 
1107
        /**
1103
        /**
1108
         * @param $pluginDirName
1104
         * @param string|array $pluginDirName
1109
         * @param $expectedPluginClass
1105
         * @param string $expectedPluginClass
1110
         * @param $registerCallback
1106
         * @param callable|null $registerCallback
1111
         * @return string[]
1107
         * @return string[]
1112
         * @throws OIDplusConfigInitializationException
1108
         * @throws OIDplusConfigInitializationException
1113
         * @throws OIDplusException
1109
         * @throws OIDplusException
1114
         * @throws \ReflectionException
1110
         * @throws \ReflectionException
1115
         */
1111
         */
1116
        public static function registerAllPlugins($pluginDirName, $expectedPluginClass, $registerCallback): array {
1112
        public static function registerAllPlugins($pluginDirName, string $expectedPluginClass, callable $registerCallback=null): array {
1117
                $out = array();
1113
                $out = array();
1118
                if (is_array($pluginDirName)) {
1114
                if (is_array($pluginDirName)) {
1119
                        $ary = array();
1115
                        $ary = array();
1120
                        foreach ($pluginDirName as $pluginDirName_) {
1116
                        foreach ($pluginDirName as $pluginDirName_) {
1121
                                $ary = array_merge($ary, self::getAllPluginManifests($pluginDirName_, false));
1117
                                $ary = array_merge($ary, self::getAllPluginManifests($pluginDirName_, false));
Line 1264... Line 1260...
1264
 
1260
 
1265
        /**
1261
        /**
1266
         * @param bool $html
1262
         * @param bool $html
1267
         * @param bool $keepBaseConfig
1263
         * @param bool $keepBaseConfig
1268
         * @return void
1264
         * @return void
1269
         * @throws OIDplusConfigInitializationException
1265
         * @throws OIDplusConfigInitializationException|OIDplusException|\ReflectionException
1270
         * @throws OIDplusException
-
 
1271
         */
1266
         */
1272
        public static function init(bool $html=true, bool $keepBaseConfig=true) {
1267
        public static function init(bool $html=true, bool $keepBaseConfig=true) {
1273
                self::$html = $html;
1268
                self::$html = $html;
1274
 
1269
 
1275
                // Reset internal state, so we can re-init verything if required
1270
                // Reset internal state, so we can re-init verything if required
Line 1630... Line 1625...
1630
                        }
1625
                        }
1631
                }
1626
                }
1632
        }
1627
        }
1633
 
1628
 
1634
        /**
1629
        /**
1635
         * @param $pubKey
1630
         * @param string $pubKey
1636
         * @return false|string
1631
         * @return false|string
1637
         */
1632
         */
1638
        private static function pubKeyToRaw($pubKey) {
1633
        private static function pubKeyToRaw(string $pubKey) {
1639
                $m = array();
1634
                $m = array();
1640
                if (preg_match('@BEGIN PUBLIC KEY\\-+([^\\-]+)\\-+END PUBLIC KEY@ismU', $pubKey, $m)) {
1635
                if (preg_match('@BEGIN PUBLIC KEY\\-+([^\\-]+)\\-+END PUBLIC KEY@ismU', $pubKey, $m)) {
1641
                        return base64_decode($m[1], false);
1636
                        return base64_decode($m[1], false);
1642
                }
1637
                }
1643
                return false;
1638
                return false;
1644
        }
1639
        }
1645
 
1640
 
1646
        /**
1641
        /**
1647
         * @param $pubKey
1642
         * @param string $pubKey
1648
         * @return false|int
1643
         * @return false|int
1649
         */
1644
         */
1650
        private static function getSystemIdFromPubKey($pubKey) {
1645
        private static function getSystemIdFromPubKey(string $pubKey) {
1651
                $rawData = self::pubKeyToRaw($pubKey);
1646
                $rawData = self::pubKeyToRaw($pubKey);
1652
                if ($rawData === false) return false;
1647
                if ($rawData === false) return false;
1653
                return smallhash($rawData);
1648
                return smallhash($rawData);
1654
        }
1649
        }
1655
 
1650
 
1656
        /**
1651
        /**
1657
         * @param $pubKey
1652
         * @param string $pubKey
1658
         * @return false|string
1653
         * @return false|string
1659
         */
1654
         */
1660
        private static function getSystemGuidFromPubKey($pubKey) {
1655
        private static function getSystemGuidFromPubKey(string $pubKey) {
1661
                $rawData = self::pubKeyToRaw($pubKey);
1656
                $rawData = self::pubKeyToRaw($pubKey);
1662
                if ($rawData === false) return false;
1657
                if ($rawData === false) return false;
1663
                $normalizedBase64 = base64_encode($rawData);
1658
                $normalizedBase64 = base64_encode($rawData);
1664
                return gen_uuid_sha1_namebased(self::UUID_NAMEBASED_NS_Base64PubKey, $normalizedBase64);
1659
                return gen_uuid_sha1_namebased(self::UUID_NAMEBASED_NS_Base64PubKey, $normalizedBase64);
1665
        }
1660
        }
Line 2178... Line 2173...
2178
        }
2173
        }
2179
 
2174
 
2180
        private static $shutdown_functions = array();
2175
        private static $shutdown_functions = array();
2181
 
2176
 
2182
        /**
2177
        /**
2183
         * @param $func
2178
         * @param callable $func
2184
         * @return void
2179
         * @return void
2185
         */
2180
         */
2186
        public static function register_shutdown_function($func) {
2181
        public static function register_shutdown_function(callable $func) {
2187
                self::$shutdown_functions[] = $func;
2182
                self::$shutdown_functions[] = $func;
2188
        }
2183
        }
2189
 
2184
 
2190
        /**
2185
        /**
2191
         * @return void
2186
         * @return void
Line 2267... Line 2262...
2267
        }
2262
        }
2268
 
2263
 
2269
        private static $translationArray = array();
2264
        private static $translationArray = array();
2270
 
2265
 
2271
        /**
2266
        /**
2272
         * @param $translation_file
2267
         * @param string $translation_file
2273
         * @return array|mixed
2268
         * @return array
2274
         */
2269
         */
2275
        protected static function getTranslationFileContents($translation_file) {
2270
        protected static function getTranslationFileContents(string $translation_file): array {
2276
                // First, try the cache
2271
                // First, try the cache
2277
                $cache_file = __DIR__ . '/../../userdata/cache/translation_'.md5($translation_file).'.ser';
2272
                $cache_file = __DIR__ . '/../../userdata/cache/translation_'.md5($translation_file).'.ser';
2278
                if (file_exists($cache_file) && (filemtime($cache_file) == filemtime($translation_file))) {
2273
                if (file_exists($cache_file) && (filemtime($cache_file) == filemtime($translation_file))) {
2279
                        $cac = @unserialize(file_get_contents($cache_file));
2274
                        $cac = @unserialize(file_get_contents($cache_file));
2280
                        if ($cac) return $cac;
2275
                        if ($cac) return $cac;