/** * Our construct can take in parameters * * @param bool|true $auto * * @param array|null $array * * @param null $callback */ public function __construct($auto = true, array $array = null, $callback = null) { /** * If auto is enabled, automatically create the table on conception of this class. */ if ($auto) { /** * Read the default database diagram */ $this->database_diagram = JsonReader::ReadFile(PathFinder::RealPath("Json/default_database.json")); /** * If we have an array. */ if ($array != null) { /** * No, an stdClass won't work, go away. */ if (!is_array($array)) { return null; } /** * Create a new merged array */ $merged = array_merge($this->database_diagram, $array); /** * Create a new database class */ $class = new DatabaseCreator(); /** * Call the function */ $class->ComputeArray($merged); /** * Return */ return; } /** * Create a new database class */ $class = new DatabaseCreator(); /** * Call the function */ $class->ComputeArray($this->database_diagram); /** * Do we have a callback? */ if ($callback != null) { /** * If so blast that shit out */ call_user_func($callback); } } /** * If not, return nothing and do nothing. */ }
/** * Finds the default settings. * * @return mixed|null */ public function FindSettings() { if (FileMethods::FileExists(PathFinder::RealPath("Json/default_settings.json"))) { $result = JsonReader::ReadFile(PathFinder::RealPath("Json/default_settings.json")); return $result; } return null; }
/** * Gets the templates file * * @param $template_name * * @return null */ private function GetTemplate($template_name) { if (FileMethods::FileExists(PathFinder::RealPath('Json/default_mailing_templates.json'))) { $templates = JsonReader::ReadFile(PathFinder::RealPath('Json/default_mailing_templates.json')); if (isset($templates[$template_name])) { return $templates[$template_name]; } } return null; }
/** * Reads our access points * * @return mixed|null */ private function ReadAccessPoints() { if (FileMethods::FileExists(PathFinder::RealPath('Json/api/api_access_points.json')) == false) { return null; } return JsonReader::Read('Json/api/api_access_points.json'); }
/** * Find groups * * @return mixed|null */ private function FindGroups() { if (FileMethods::FileExists(PathFinder::RealPath("Json/default_groups.json"))) { return JsonReader::ReadFile(PathFinder::RealPath("Json/default_groups.json")); } return null; }
/** * Exactly the same as the above, except this one decrypts the mail settings! * * @return array|null */ public static function DecryptMailerSettings() { if (FileMethods::FileExists(PathFinder::RealPath('Json/encrypted/mailer_settings.json'))) { $return = array(); /** * Reads our settings */ $read_settings = JsonReader::Read('Json/encrypted/mailer_settings.json'); /** * Loop */ foreach ($read_settings['mailer_settings'] as $key => $value) { /** * Lets first get the vector */ $vector = $value['vector']; /** * Then, lets decrypt! */ $return[$key] = Encryption::DecryptString($value['encrypted_string'], $read_settings['decryption_key'], $vector); } /** * Return this array */ return $return; } /** * If no files could be found */ return null; }
/** * Gets our log * * @return mixed|null */ public function GetLog() { return JsonReader::Read('Json/resource/install_log.json'); }