155. public function __construct(array $config = [])
156. {
157. $this->defaultConfig = Config::default('ZN\Database\DatabaseDefaultConfiguration')
158. ::get('Database', 'database');
159. $this->config = array_merge($this->defaultConfig, $config);
160. $this->db = $this->runDriver();
161. $this->prefix = $this->config['prefix'];
162. Properties::$prefix = $this->prefix;
163.
164. $this->db->connect($this->config);
165. }
166.
167. /**
168. * Magic Debug Info
169. */
170. public function __debugInfo()
171. {
172. return ['return' => $this->stringQuery ?: 'This is a general object, please call the sub method!'];
173. }
174.
108.
109. $this->senderMail = $emailSenderInfo['mail'];
110. $this->senderName = $emailSenderInfo['name'];
111.
112. # If no language file is found, predefined settings will be enabled.
113. $this->getLang = Lang::default('ZN\Authentication\AuthenticationDefaultLanguage')
114. ::select('Authentication');
115.
116. # PThe necessary classes are called for the User class.
117. $this->dbClass = Singleton::class('ZN\Database\DB');
118. $this->sessionClass = Singleton::class('ZN\Storage\Session');
119. $this->cookieClass = Singleton::class('ZN\Storage\Cookie');
120. }
121.
122. /**
123. * Get unique username key
124. *
125. * @return string
126. */
127. public function getUniqueUsernameKey()
7. {
8. const exclude = ['h2strss'];
9. /**
10. * The codes to run at startup.
11. * It enters the circuit before all controllers.
12. * You can change this setting in Config/Starting.php file.
13. */
14. public function main()
15. {
16. View::isLogin(User::isLogin());
17. if( User::isLogin() ) {
18. //View::user($user = User::data());
19. $user = User::data();
20. Permission::roleId($user->roleid);
21. View::currentuser($user->username);
22. View::currentnamesurname($user->namesurname);
23. # Home page
24. View::currentavatar(URL::base(UPLOADS_DIR.$user->avatar))
25. ->get('home');
26. }
139. $this->connect = new MySQLi;
140.
141. $this->connect->options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true);
142. $this->connect->ssl_set($ssl['key'] ?? NULL, $ssl['cert'] ?? NULL, $ssl['ca'] ?? NULL, $ssl['capath'] ?? NULL, $ssl['cipher'] ?? NULL);
143. $this->connect->real_connect($host, $user, $pass, $db, $port, NULL, MYSQLI_CLIENT_SSL);
144. }
145. // @codeCoverageIgnoreEnd
146. else
147. {
148. $this->connect = new MySQLi($host, $user, $pass, $db, $port);
149. }
150. restore_error_handler();
151.
152. if( $this->connect->connect_errno )
153. {
154. throw new ConnectionErrorException(NULL, $this->connect->connect_error); // @codeCoverageIgnore
155. }
156.
157. mysqli_report(MYSQLI_REPORT_OFF);
158.