// Prepare Valuess define("PROTECTED", true); Config::$dataList = array(); $siteHandle = array(); // Begin tracking sites on this server (by capturing their config file) foreach (glob(dirname(SYS_PATH) . "/*/config.php") as $filename) { Config::$dataList[] = $filename; } // Begin tracking sub-sites on the server (by capturing their config file) foreach (glob(dirname(SYS_PATH) . "/*/*/config.php") as $filename) { Config::$dataList[] = $filename; } // Capture each of the site handles in the config files foreach (Config::$dataList as $file) { $fileContents = File::read($file); $siteHandle[] = Data_Parse::between($fileContents, 'Config::$data[\'database\'][\'name\'] = "', '";'); } // Make sure the system was able to collect the appropriate site handles if ($siteHandle != array()) { foreach ($siteHandle as $sh) { if ($sh) { // Attempt to initialize another database Database::initialize($sh, Config::$siteConfig['database']['admin-user'], Config::$siteConfig['database']['admin-pass'], Config::$siteConfig['database']['host'], Config::$siteConfig['database']['type']); // Run the System Script include SYS_PATH . "/system-script.php"; echo "Ran the script for the " . $sh . " database.<br />"; } } } echo "<br /><br />Script Complete."; } else {
public static function varType($line, $before = "") { // Prepare the content that should be found before and after the matching type key $before .= "<"; // Cycle through the list of possible variables, and return the appropriate type // For example, if the line finds <str> in it, return "string" foreach (self::$typeList as $tKey => $tType) { if (strpos($line, $before . $tKey . ">") !== false) { return $tType; } } // If there is a more advanced situation, such as an array, we need to parse it differently if ($check = Data_Parse::between($line, $before, ">")) { // Split the hypothetical array into first and second parts $exp = explode(":", $check, 2); // If the second part exists, we found a proper array if (isset($exp[1])) { // Check if the first section of the array is a proper type (will be int, str, or mixed) if (isset(self::$typeList[$exp[0]])) { // The second part may be a standard type. If so, we can return the type if (isset(self::$typeList[$exp[1]])) { return "array <" . $exp[0] . ", " . $exp[1] . ">"; } // If we haven't returned, the second part is probably a nest (another array) // No more nests allowed beyond this. if (strpos($exp[1], "[") !== false) { // Repeat the same test again $nest = Data_Parse::between($exp[1], "[", "]"); $nestExp = explode(":", $nest, 2); if (isset($nestExp[1])) { if (self::$typeList[$nestExp[0]] and self::$typeList[$nestExp[1]]) { return "array <" . $exp[0] . ", " . "array<" . $nestExp[0] . ", " . $nestExp[1] . ">>"; } } } } } } // If no variable was found, return no type found (empty string) return ""; }