-
Notifications
You must be signed in to change notification settings - Fork 61
/
vtiger-startup.php
44 lines (39 loc) · 1.28 KB
/
vtiger-startup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
require_once __DIR__.'/vtiger-autoload.php';
function encrypt_password($username, $user_password, $crypt_type = '')
{
$salt = substr($username, 0, 2);
if ($crypt_type == '') {
$crypt_type = 'MD5';
}
if ($crypt_type == 'MD5') {
$salt = '$1$'.$salt.'$';
} elseif ($crypt_type == 'BLOWFISH') {
$salt = '$2$'.$salt.'$';
} elseif ($crypt_type == 'PHP5.3MD5') {
$salt = '$1$'.str_pad($salt, 9, '0');
}
$encrypted_password = crypt($user_password, $salt);
return $encrypted_password;
}
echo "[vtiger] Looking for database...\n";
if (!$db = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME, DB_PORT)) {
echo '[vtiger] Database: '.mysqli_connect_errno().' - '.mysqli_connect_error()."\n";
//exit(1);
}
echo "[vtiger] Update administrator settings\n";
if (!file_exists($lock = __DIR__.'/startup.lock')) {
// update password
/*
$username = getenv('VT_ADMIN_USER') ?: 'admin';
$password = encrypt_password($username, getenv('VT_ADMIN_PASSWORD') ?: 'admin');
mysqli_query($db, "
UPDATE vtiger_users
SET user_name = '{$username}'
, user_password = '{$password}'
, crypt_type = ''
WHERE id = '1'
");
file_put_contents($lock, json_encode(['lock' => true]));
*/
}