Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
InstallSettingsForm.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
40  class InstallSettingsForm extends CFormModel
41  {
42  public $databaseHostname = 'localhost';
43 
44  public $databaseAdminUsername;
45 
46  public $databaseAdminPassword;
47 
48  public $databaseName = 'zurmo';
49 
50  public $databaseUsername = 'zurmo';
51 
52  public $databasePassword;
53 
54  public $databasePort = 3306;
55 
56  public $superUserPassword;
57 
58  public $memcacheHostname = '127.0.0.1';
59 
60  public $memcachePortNumber = 11211;
61 
62  protected $memcacheAvailable = true;
63 
64  public $databaseType = 'mysql';
65 
66  public $removeExistingData;
67 
68  public $installDemoData = false;
69 
70  public $hostInfo = '';
71 
72  public $scriptUrl = '';
73 
74  public $submitCrashToSentry = false;
75 
76  public function rules()
77  {
78  return array(
79  array('databaseHostname', 'required'),
80  array('databaseName', 'required'),
81  array('databaseUsername', 'required'),
82  array('databasePassword', 'required'),
83  array('databasePort', 'required'),
84  array('superUserPassword', 'required'),
85  array('hostInfo', 'required'),
86  array('scriptUrl', 'required'),
87  array('databaseHostname', 'type', 'type' => 'string'),
88  array('databaseAdminUsername', 'type', 'type' => 'string'),
89  array('databaseAdminPassword', 'type', 'type' => 'string'),
90  array('databaseName', 'type', 'type' => 'string'),
91  array('databaseUsername', 'type', 'type' => 'string'),
92  array('databasePassword', 'type', 'type' => 'string'),
93  array('superUserPassword', 'type', 'type' => 'string'),
94  array('memcacheHostname', 'type', 'type' => 'string'),
95  array('memcachePortNumber', 'type', 'type' => 'integer'),
96  array('memcachePortNumber', 'numerical', 'min' => 1024),
97  array('removeExistingData', 'boolean'),
98  array('installDemoData', 'boolean'),
99  array('hostInfo', 'type', 'type' => 'string'),
100  array('scriptUrl', 'type', 'type' => 'string'),
101  array('submitCrashToSentry', 'boolean'),
102  );
103  }
104 
105  public function setMemcacheIsNotAvailable()
106  {
107  $this->memcacheAvailable = false;
108  $this->memcacheHostname = null;
109  $this->memcachePortNumber = null;
110  }
111 
112  public function getIsMemcacheAvailable()
113  {
114  return $this->memcacheAvailable;
115  }
116 
121  public function afterValidate()
122  {
123  parent::afterValidate();
124  if (count($this->getErrors()) == 0)
125  {
126  //check memcache first, since creating the db / user should be last.
127  if ($this->memcacheHostname != null)
128  {
129  if ($this->memcachePortNumber == null)
130  {
131  $this->addError('memcachePortNumber', Zurmo::t('InstallModule', 'Since you specified a memcache ' .
132  'hostname, you must specify a port.'));
133  return;
134  }
135  $memcacheResult = InstallUtil::checkMemcacheConnection($this->memcacheHostname,
136  (int)$this->memcachePortNumber);
137  if ($memcacheResult !== true)
138  {
139  $this->addError('memcacheHostname', Zurmo::t('Core', 'Error code:') . " " .
140  $memcacheResult[0] . '<br/>Message(Memcached): ' . $memcacheResult[1]);
141  return;
142  }
143  }
144 
145  if (!$this->hostInfo)
146  {
147  $this->addError('hostInfo', Zurmo::t('InstallModule', 'Please enter server IP or URL.'));
148  return;
149  }
150  else
151  {
152  if ((strpos($this->hostInfo, 'http://') === false) && (strpos($this->hostInfo, 'https://') === false))
153  {
154  $this->addError('hostInfo', Zurmo::t('InstallModule', 'Host Info must start with "http://" or "https://".'));
155  return;
156  }
157  }
158 
159  if ($this->databaseAdminUsername != null)
160  {
161  if ($this->databaseAdminPassword == null)
162  {
163  $this->addError('databaseAdminPassword', Zurmo::t('InstallModule', 'Since you specified a database ' .
164  'admin username, you must enter a password'));
165  return;
166  }
167  $connectionResult = DatabaseCompatibilityUtil::checkDatabaseConnection($this->databaseType,
168  $this->databaseHostname,
169  $this->databaseAdminUsername,
170  $this->databaseAdminPassword,
171  (int)$this->databasePort);
172  if ($connectionResult !== true)
173  {
174  $this->addError('databaseAdminUsername', Zurmo::t('Core', 'Error code:') . " " .
175  $connectionResult[0] . '<br/>Message: ' . $connectionResult[1]);
176  return;
177  }
178  $userExistsResult = DatabaseCompatibilityUtil::checkDatabaseUserExists($this->databaseType,
179  $this->databaseHostname,
180  $this->databaseAdminUsername,
181  $this->databaseAdminPassword,
182  (int)$this->databasePort,
183  $this->databaseUsername);
184  if ($userExistsResult === true)
185  {
186  $this->addError('databaseUsername', Zurmo::t('InstallModule', 'You have specified an existing user. ' .
187  'If you would like to use this user, then do not specify the database admin username and ' .
188  'password. Otherwise pick a database username that does not exist.'));
189  return;
190  }
191  $databaseExistsResult = DatabaseCompatibilityUtil::checkDatabaseExists($this->databaseType,
192  $this->databaseHostname,
193  $this->databaseAdminUsername,
194  $this->databaseAdminPassword,
195  (int)$this->databasePort,
196  $this->databaseName);
197  if ($databaseExistsResult === true)
198  {
199  $this->addError('databaseName', Zurmo::t('InstallModule', 'You have specified an existing database. ' .
200  'If you would like to use this database, then do not specify the database admin username and ' .
201  'password. Otherwise pick a database name that does not exist.'));
202  return;
203  }
204  $createDatabaseResult = DatabaseCompatibilityUtil::createDatabase($this->databaseType,
205  $this->databaseHostname,
206  $this->databaseAdminUsername,
207  $this->databaseAdminPassword,
208  (int)$this->databasePort,
209  $this->databaseName);
210  if ($createDatabaseResult === false)
211  {
212  $this->addError('databaseName', Zurmo::t('InstallModule', 'There was a problem creating the database ' .
213  'Error code:') . " " . $connectionResult[0] . '<br/>Message: ' . $connectionResult[1]);
214  return;
215  }
216  $createUserResult = DatabaseCompatibilityUtil::createDatabaseUser($this->databaseType,
217  $this->databaseHostname,
218  $this->databaseAdminUsername,
219  $this->databaseAdminPassword,
220  (int)$this->databasePort,
221  $this->databaseName,
222  $this->databaseUsername,
223  $this->databasePassword);
224  if ($createUserResult === false)
225  {
226  $this->addError('databaseUsername', Zurmo::t('InstallModule', 'There was a problem creating the user ' .
227  'Error code:') . " " . $connectionResult[0] . '<br/>Message: ' . $connectionResult[1]);
228  return;
229  }
230  }
231  else
232  {
233  $connectionResult = DatabaseCompatibilityUtil::checkDatabaseConnection($this->databaseType,
234  $this->databaseHostname,
235  $this->databaseUsername,
236  $this->databasePassword,
237  (int)$this->databasePort);
238  if ($connectionResult !== true)
239  {
240  $this->addError('databaseUsername', Zurmo::t('Core', 'Error code:') . " " .
241  $connectionResult[0] . '<br/>Message: ' . $connectionResult[1]);
242  return;
243  }
244  $databaseExistsResult = DatabaseCompatibilityUtil::checkDatabaseExists($this->databaseType,
245  $this->databaseHostname,
246  $this->databaseUsername,
247  $this->databasePassword,
248  (int)$this->databasePort,
249  $this->databaseName);
250  if ($databaseExistsResult !== true)
251  {
252  $this->addError('databaseName', Zurmo::t('InstallModule', 'The database name specified does not ' .
253  'exist or the user specified does not have access.') . '<br/>' .
254  Zurmo::t('Core', 'Error code:') . " " . $databaseExistsResult[0] .
255  '<br/>Message: ' . $databaseExistsResult[1]);
256  return;
257  }
258  else
259  {
260  if ($this->removeExistingData == false)
261  {
262  $this->addError('removeExistingData', Zurmo::t('InstallModule', 'Since you specified an existing database ' .
263  'you must check this box in order to proceed. THIS WILL REMOVE ALL EXISTING DATA.'));
264  return;
265  }
266  }
267  }
268  }
269  }
270  }
271 ?>
static createDatabase($databaseType, $host, $rootUsername, $rootPassword, $port, $databaseName)
static checkDatabaseConnection($databaseType, $host, $rootUsername, $rootPassword, $port)
static checkDatabaseUserExists($databaseType, $host, $rootUsername, $rootPassword, $port, $username)
static createDatabaseUser($databaseType, $host, $rootUsername, $rootPassword, $port, $databaseName, $username, $password)
static checkDatabaseExists($databaseType, $host, $rootUsername, $rootPassword, $port, $databaseName)
static checkMemcacheConnection($host, $port)
Generated on Mon Jul 6 2020 07:10:34
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.