Files
CRM/GeneratePassWord.php
BACHIR SOULDI 2794e62571 first commit
2025-09-28 08:49:37 +01:00

77 lines
1.9 KiB
PHP

<?php
require_once 'include/utils/utils.php';
require_once './SUtiles.php';
if(isset($_POST['username'])){
$user_name = $_POST['username'];
$crypt_type = 'PHP5.3MD5';
$result = generatePassword($user_name, $crypt_type);
global $adb;
$query = "UPDATE vtiger_users SET user_password=?, confirm_password=?, user_hash=?, ".
"crypt_type=? where user_name=?";
$params = array($result[0], $result[0], $result[1], $crypt_type, $user_name);
//print_r($params);
$adb->pquery($query, $params);
$query = "SELECT * FROM access where username=?";
$sql_get_result = $adb->pquery($query,[$user_name]);
$resultqa = array();
while ($recordinfo = $adb->fetch_array($sql_get_result)) {
$resultqa[] = $recordinfo;
}
if(count($resultqa) > 0) {
$query = "UPDATE access SET pwd=? where username=?";
$adb->pquery($query, [$result[2], $user_name]);
} else {
$query = "INSERT INTO access (username, pwd) VALUES (?, ?)";
echo $query.$user_name.$result[2];
$adb->pquery($query, array($user_name, $result[2]));
}
}
$query = "SELECT * FROM access";
$sql_get_result = $adb->pquery($query,[]);
$result = array();
while ($recordinfo = $adb->fetch_array($sql_get_result)) {
$result[] = $recordinfo;
}
echo '<form method="post">
<input type="text" name="username" placeholder="user name">
</form>';
echo '<table>
<tr>
<th >username</th>
<th >password</th>
</tr>';
foreach ($result as $account){
echo '<tr class="center borderline">
<td>'.$account['username'].'</td>
<td>'.$account['pwd'].'</td>
</tr>';
}
echo '</table>';
?>
<style>
table, th, td {
border: 1px solid black;
}
th, td {
width: 150px;
}
</style>