/** * Encrypts your mail settings * * @param $username * * @param $password * * @param null $callback * * @return bool */ public static function EncryptMailSettings($username, $password, $callback = null) { if (FileMethods::FileExists(PathFinder::RealPath('Json/encrypted/mailer_settings.json'))) { /** * We already have settings! */ return false; } /** * The decryption key */ $key = Random::RandomMD5(); /** * If not, lets create an array, encrypting each value */ $array = ['decryption_key' => $key, 'mailer_settings' => ['username' => Encryption::EncryptString($username, $key), 'password' => Encryption::EncryptString($password, $key)]]; /** * Write file */ JsonWriter::PathWrite('Json/encrypted/mailer_settings.json', $array); /** * Is there a callback? */ if ($callback != null) { call_user_func($callback); } /** * Return true! */ return true; }
/** * 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 HTML template to send this email * * @param $template_name * * @return null */ private function GetHTMLTemplate($template_name) { $result = $this->GetTemplate($template_name); if ($result != null) { return FileMethods::OpenFile(PathFinder::RealPath($result["html"])); } 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'); }
/** * Saves the payload */ public function SavePayload() { if ($this->payload != null) { JsonWriter::Write(PathFinder::RealPath("Json/resource/generated_groups.json"), $this->payload); } }
/** * 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; }
/** * Write that log. */ public function WriteLog() { JsonWriter::Write(PathFinder::RealPath("/Json/resource/install_log.json"), Install::$log); }