/**
  * 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;
 }
 /**
  * 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;
 }
Example #3
0
 /**
  * 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;
 }
Example #4
0
 /**
  * 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;
 }
Example #7
0
 /**
  * Encrypts and writes our database settings to file
  *
  * @param $username
  *
  * @param $password
  *
  * @param $location
  *
  * @param $address
  *
  * @param $callback
  *
  * @return bool|null
  */
 public function InitializeDatabase($username, $password, $location, $address, $callback = null)
 {
     /**
      * We first check if we already have settings
      */
     if (FileMethods::FileExists(PathFinder::RealPath('Json/encrypted/database_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, 'database_settings' => ['username' => Encryption::EncryptString($username, $key), 'password' => Encryption::EncryptString($password, $key), 'database' => Encryption::EncryptString($location, $key), 'host' => Encryption::EncryptString($address, $key)]];
     /**
      * Write file
      */
     JsonWriter::PathWrite('Json/encrypted/database_settings.json', $array);
     /**
      * Is there a callback?
      */
     if ($callback != null) {
         call_user_func($callback);
     }
     /**
      * Return true!
      */
     return true;
 }