Adding easy password filter see BT#6487

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

@ -22,7 +22,7 @@ if (isset($_configuration['deny_delete_users']) && $_configuration['deny_delete
} }
$url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=get_user_courses'; $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) { function load_course_list (div_course,my_user_id) {
$.ajax({ $.ajax({
contentType: "application/x-www-form-urlencoded", contentType: "application/x-www-form-urlencoded",
@ -105,7 +105,6 @@ $(document).ready(function() {
} }
} }
$(".agenda_opener").live("click", function() { $(".agenda_opener").live("click", function() {
var url = this.href; var url = this.href;
var dialog = $("#dialog"); var dialog = $("#dialog");
@ -129,8 +128,7 @@ $(document).ready(function() {
//Load user calendar //Load user calendar
function load_calendar(user_id, month, year) { 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; 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>'; </script>';
@ -313,7 +311,7 @@ function get_number_of_users() {
"AND u.official_code LIKE '%".$keyword_officialcode."%'" . "AND u.official_code LIKE '%".$keyword_officialcode."%'" .
"AND u.status LIKE '".$keyword_status."'" . "AND u.status LIKE '".$keyword_status."'" .
$keyword_admin.$keyword_extra_value; $keyword_admin.$keyword_extra_value;
if($keyword_active && !$keyword_inactive) { if ($keyword_active && !$keyword_inactive) {
$sql .= " AND u.active='1'"; $sql .= " AND u.active='1'";
} elseif($keyword_inactive && !$keyword_active) { } elseif($keyword_inactive && !$keyword_active) {
$sql .= " AND u.active='0'"; $sql .= " AND u.active='0'";
@ -341,7 +339,6 @@ function get_number_of_users() {
*/ */
function get_user_data($from, $number_of_items, $column, $direction) { function get_user_data($from, $number_of_items, $column, $direction) {
global $origin; global $origin;
$user_table = Database :: get_main_table(TABLE_MAIN_USER); $user_table = Database :: get_main_table(TABLE_MAIN_USER);
$admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN); $admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN);
$sql = "SELECT $sql = "SELECT
@ -357,8 +354,9 @@ function get_user_data($from, $number_of_items, $column, $direction) {
u.status AS col7, u.status AS col7,
u.active AS col8, u.active AS col8,
u.user_id AS col9, u.user_id AS col9,
u.registration_date AS col10 ". u.registration_date AS col10,
", u.expiration_date AS exp ". u.expiration_date AS exp,
u.password ".
" FROM $user_table u "; " FROM $user_table u ";
// adding the filter to see the user's only of the current access_url // 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(); $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'))) { if (!in_array($direction, array('ASC','DESC'))) {
$direction = 'ASC'; $direction = 'ASC';
} }
@ -541,7 +550,6 @@ function modify_filter($user_id, $url_params, $row) {
} }
if (api_is_platform_admin(true)) { if (api_is_platform_admin(true)) {
if (!$user_is_anonymous && api_global_admin_can_edit_admin($user_id, null, 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;'; $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 { } else {
@ -549,7 +557,6 @@ function modify_filter($user_id, $url_params, $row) {
} }
} }
if ($is_admin) { if ($is_admin) {
$result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'),array('width'=> ICON_SIZE_SMALL, 'heigth'=> ICON_SIZE_SMALL)); $result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'),array('width'=> ICON_SIZE_SMALL, 'heigth'=> ICON_SIZE_SMALL));
} else { } else {
@ -799,6 +806,7 @@ $active_group[] = $form->createElement('checkbox','keyword_inactive','', get_lan
$form->addGroup($active_group,'',get_lang('ActiveAccount'),'<br/>',false); $form->addGroup($active_group,'',get_lang('ActiveAccount'),'<br/>',false);
$form->addElement('html', '</td><td>'); $form->addElement('html', '</td><td>');
$form->addElement('checkbox', 'check_easy_passwords', null, get_lang('CheckEasyPasswords'));
/* /*
* @todo fix this code * @todo fix this code
@ -824,7 +832,7 @@ if (!empty($extra_data)) {
$form->addElement('html', '</td></tr>'); $form->addElement('html', '</td></tr>');
$form->addElement('html', '<tr><td>'); $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', '</td></tr>');
$form->addElement('html', '</table>'); $form->addElement('html', '</table>');

@ -6490,5 +6490,14 @@ function api_get_password_checker_js($inputId)
}); });
</script>"; </script>";
return $js; 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