Adding easy password filter see BT#6487

1.9.x
Julio Montoya 12 years ago
parent 3f178c6d4a
commit c2cf9c2baf
  1. 48
      main/admin/user_list.php
  2. 9
      main/inc/lib/main_api.lib.php

@ -18,11 +18,11 @@ $current_access_url_id = api_get_current_access_url_id();
// Blocks the possibility to delete a user
$delete_user_available = true;
if (isset($_configuration['deny_delete_users']) && $_configuration['deny_delete_users']) {
$delete_user_available = false;
$delete_user_available = false;
}
$url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=get_user_courses';
$htmlHeadXtra[] = '<script type="text/javascript">
$htmlHeadXtra[] = '<script>
function load_course_list (div_course,my_user_id) {
$.ajax({
contentType: "application/x-www-form-urlencoded",
@ -82,13 +82,13 @@ function clear_course_list (div_course) {
}
function display_advanced_search_form () {
if ($("#advanced_search_form").css("display") == "none") {
$("#advanced_search_form").css("display","block");
$("#img_plus_and_minus").html(\'&nbsp;'.Display::return_icon('div_hide.gif',get_lang('Hide'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedSearch').'\');
} else {
$("#advanced_search_form").css("display","none");
$("#img_plus_and_minus").html(\'&nbsp;'.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedSearch').'\');
}
if ($("#advanced_search_form").css("display") == "none") {
$("#advanced_search_form").css("display","block");
$("#img_plus_and_minus").html(\'&nbsp;'.Display::return_icon('div_hide.gif',get_lang('Hide'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedSearch').'\');
} else {
$("#advanced_search_form").css("display","none");
$("#img_plus_and_minus").html(\'&nbsp;'.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedSearch').'\');
}
}
$(document).ready(function() {
@ -105,7 +105,6 @@ $(document).ready(function() {
}
}
$(".agenda_opener").live("click", function() {
var url = this.href;
var dialog = $("#dialog");
@ -129,8 +128,7 @@ $(document).ready(function() {
//Load user calendar
function load_calendar(user_id, month, year) {
var url = "'.api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?a=get_user_agenda&user_id=" +user_id + "&month="+month+"&year="+year;
$("#dialog").load( url
);
$("#dialog").load(url);
}
</script>';
@ -313,7 +311,7 @@ function get_number_of_users() {
"AND u.official_code LIKE '%".$keyword_officialcode."%'" .
"AND u.status LIKE '".$keyword_status."'" .
$keyword_admin.$keyword_extra_value;
if($keyword_active && !$keyword_inactive) {
if ($keyword_active && !$keyword_inactive) {
$sql .= " AND u.active='1'";
} elseif($keyword_inactive && !$keyword_active) {
$sql .= " AND u.active='0'";
@ -341,14 +339,13 @@ function get_number_of_users() {
*/
function get_user_data($from, $number_of_items, $column, $direction) {
global $origin;
$user_table = Database :: get_main_table(TABLE_MAIN_USER);
$admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN);
$sql = "SELECT
u.user_id AS col0,
u.official_code AS col2,
".(api_is_western_name_order()
? "u.firstname AS col3,
? "u.firstname AS col3,
u.lastname AS col4,"
: "u.lastname AS col3,
u.firstname AS col4,")."
@ -357,8 +354,9 @@ function get_user_data($from, $number_of_items, $column, $direction) {
u.status AS col7,
u.active AS col8,
u.user_id AS col9,
u.registration_date AS col10 ".
", u.expiration_date AS exp ".
u.registration_date AS col10,
u.expiration_date AS exp,
u.password ".
" FROM $user_table u ";
// adding the filter to see the user's only of the current access_url
@ -428,6 +426,17 @@ function get_user_data($from, $number_of_items, $column, $direction) {
$sql.= " AND url_rel_user.access_url_id=".api_get_current_access_url_id();
}
$checkPassStrength = isset($_GET['check_easy_passwords']) && $_GET['check_easy_passwords'] == 1 ? true : false;
if ($checkPassStrength) {
$easyPasswordList = api_get_easy_password_list();
$easyPasswordList = array_map('api_get_encrypted_password', $easyPasswordList);
$easyPassword = implode("' OR password LIKE '", $easyPasswordList);
$sql .= "AND password LIKE '$easyPassword' ";
}
if (!in_array($direction, array('ASC','DESC'))) {
$direction = 'ASC';
}
@ -541,7 +550,6 @@ function modify_filter($user_id, $url_params, $row) {
}
if (api_is_platform_admin(true)) {
if (!$user_is_anonymous && api_global_admin_can_edit_admin($user_id, null, true)) {
$result .= '<a href="user_edit.php?user_id='.$user_id.'">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>&nbsp;';
} else {
@ -549,7 +557,6 @@ function modify_filter($user_id, $url_params, $row) {
}
}
if ($is_admin) {
$result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'),array('width'=> ICON_SIZE_SMALL, 'heigth'=> ICON_SIZE_SMALL));
} else {
@ -799,6 +806,7 @@ $active_group[] = $form->createElement('checkbox','keyword_inactive','', get_lan
$form->addGroup($active_group,'',get_lang('ActiveAccount'),'<br/>',false);
$form->addElement('html', '</td><td>');
$form->addElement('checkbox', 'check_easy_passwords', null, get_lang('CheckEasyPasswords'));
/*
* @todo fix this code
@ -824,7 +832,7 @@ if (!empty($extra_data)) {
$form->addElement('html', '</td></tr>');
$form->addElement('html', '<tr><td>');
$form->addElement('button', 'submit',get_lang('SearchUsers'));
$form->addElement('button', 'submit', get_lang('SearchUsers'));
$form->addElement('html', '</td></tr>');
$form->addElement('html', '</table>');

@ -6490,5 +6490,14 @@ function api_get_password_checker_js($inputId)
});
</script>";
return $js;
}
function api_get_easy_password_list()
{
$passwordList = array('123', '1234', '123456', 'admin', 'user', 'student', 'teacher');
$file = api_get_path(CONFIGURATION_PATH).'easy_password_list.php';
if (file_exists($file)) {
$passwordList = require_once $file;
}
return $passwordList;
}

Loading…
Cancel
Save