source: extensions/LCAS/trunk/main.inc.php @ 8192

Last change on this file since 8192 was 8173, checked in by Eric, 14 years ago
  • Case sensitivity check at identification (testing in progress but does not work at this time)
File size: 3.0 KB
Line 
1<?php
2/*
3Plugin Name: LCAS
4Version: 2.1.0
5Description: Allow to disable login/register name to be sensible to the case/accents
6Plugin URI: http://fr.piwigo.org/forum/viewtopic.php?pid=158563
7Author: Eric, LucMorizur, Whiler
8Author URI: http://www.infernoweb.net, http://blogs.wittwer.fr/whiler/
9*/
10
11/* History:  LCAS_PATH.'Changelog.txt.php' */
12
13/*
14 ***** TODO List *****
15See project bugtracker: http://piwigo.org/bugs/my_view_page.php
16*/
17
18if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
19if (!defined('LCAS_DIR')) define('LCAS_DIR' , basename(dirname(__FILE__)));
20if (!defined('LCAS_PATH')) define('LCAS_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
21
22include_once (LCAS_PATH.'include/constants.php');
23include_once (LCAS_PATH.'include/functions.inc.php');
24
25load_language('plugin.lang', LCAS_PATH);
26
27
28/* Plugin admin */
29add_event_handler('get_admin_plugin_menu_links', 'LCAS_admin_menu');
30
31function LCAS_admin_menu($menu)
32{
33// +-----------------------------------------------------------------------+
34// |                      Getting plugin name                              |
35// +-----------------------------------------------------------------------+
36  $plugin =  LCAS_PluginInfos(LCAS_PATH);
37  $name = $plugin['name'];
38 
39  array_push($menu,
40    array(
41      'NAME' => $name,
42      'URL'  => get_admin_plugin_menu_link(LCAS_PATH.'/admin/LCAS_admin.php')
43    )
44  );
45
46  return $menu;
47}
48
49// Trigger sensitivity on user identification
50if (script_basename() == 'identification')
51{
52  global $conf;
53 
54  $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']);
55 
56  /* Username non case sensitive */
57  //if (isset($conf_LCAS[1]) and $conf_LCAS[1] == 'false')
58  //{
59    // This does not work - Unable to invalidate try_log_user() function
60    add_event_handler('login_success', 'LCAS_action');
61    add_event_handler('login_failure', 'LCAS_action');
62   
63    function LCAS_action()
64    {
65  global $conf;
66  // retrieving the encrypted password of the login submitted
67  $query = '
68SELECT '.$conf['user_fields']['id'].' AS id,
69       '.$conf['user_fields']['password'].' AS password
70  FROM '.USERS_TABLE.'
71  WHERE LOWER('.$conf['user_fields']['username'].') = \''.pwg_db_real_escape_string(strtolower($_POST['username'])).'\'
72;';
73  $row = pwg_db_fetch_assoc(pwg_query($query));
74  if ($row['password'] == $conf['pass_convert']($_POST['password']))
75  {
76    //log_user($row['id'], $remember_me);
77    //trigger_action('login_success', stripslashes($_POST['username']));
78    //return true;
79$var1 = 'Typed login : '.$_POST['username'];
80$var2 = 'Typed login lowercase : '.strtolower($_POST['username']);
81$var3 = 'Typed pwd hash : '.$conf['pass_convert'] ($_POST['password']);
82$var4 = 'Pwd hash in DB : '.$row['password'];
83$var5 = 'User ID in DB : '.$row['id'];
84/* ********************** */
85DebugLog($var1,$var2,$var3,$var4,$var5);
86/* ********************** */
87
88  }
89  //trigger_action('login_failure', stripslashes($_POST['username']));
90  return false;
91    }
92  //}
93}
94?>
Note: See TracBrowser for help on using the repository browser.