| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace DevOpsSantana\AAPanel; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * Class AAPanelDatabase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @package DevOpsSantana\AAPanel | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @author Rogério Santana <https://github.com/devopssantana> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @since : 2022 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | class AAPanelDatabase extends AAPanelConnect | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |      * @description Class Construct | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 15 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |     public function __construct() | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |         parent::__construct(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      * @description Set Database Permissions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      * @param string $username | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      * @param string $dataAccess | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      * @param string $access | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      * @param string|null $ssl | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     public function Permissions(string $username, string $dataAccess, string $access, ?string $ssl): mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         $url = $this->serverUrl . '/database?action=SetDatabaseAccess'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         $this->data['name']       = $username; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         $this->data['dataAccess'] = $dataAccess; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         $this->data['access']     = $access; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         $this->data['ssl']        = $ssl; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         return (parent::Execute($url, $this->data)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * @description Change Password | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * @param int $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      * @param string $username | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      * @param string $pwd | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     public function ChangePwd(int $id, string $username, string $pwd): mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $url = $this->serverUrl . '/database?action=ResDatabasePassword'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         $this->data['id']         = $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         $this->data['name']       = $username; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         $this->data['password']   = $pwd; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         return (parent::Execute($url, $this->data)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     /**  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * @description Database Check required fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @param $sqlDataUser | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * @param $sqlDataPassword | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     public function Verify(string $sqlDataUser, string $sqlDataPassword): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         if (!empty($sqlDataUser) && !empty($sqlDataPassword)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |             return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 71 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 72 |  |  |  |