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

Last change on this file since 8206 was 8206, checked in by Eric, 13 years ago

bug 2069 : Bad use of LCAS_change_case() function fixed

File size: 2.7 KB
RevLine 
[8141]1<?php
2/*
3Plugin Name: LCAS
[8166]4Version: 2.1.0
[8141]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
[8166]7Author: Eric, LucMorizur, Whiler
8Author URI: http://www.infernoweb.net, http://blogs.wittwer.fr/whiler/
[8141]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
[8197]49add_event_handler('init', 'LCAS_InitPage');
50 
51function LCAS_InitPage()
[8141]52{
53  global $conf;
[8197]54
[8141]55  $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']);
[8197]56 
57/* User identification */
58  if (script_basename() == 'identification')
59  {
60    if (isset($_POST['username']))
[8173]61    {
[8197]62      /* User non case sensitive */
[8203]63      if (isset($conf_LCAS[0]) and $conf_LCAS[0] == 'true' and isset($conf_LCAS[1]) and $conf_LCAS[1] == 'false')
[8197]64      {
[8206]65        $new_username = LCAS_SearchCaseUsername($_POST['username'],1);
[8197]66        $_POST['username'] = $new_username == '' ? $_POST['username'] : $new_username;
67      }
[8202]68
69      /* User non accent sensitive */
[8203]70      if (isset($conf_LCAS[0]) and $conf_LCAS[0] == 'false' and isset($conf_LCAS[1]) and $conf_LCAS[1] == 'true')
[8202]71      {
[8206]72        $new_username = LCAS_SearchCaseUsername($_POST['username'],2);
[8202]73        $_POST['username'] = $new_username == '' ? $_POST['username'] : $new_username;
74      }
[8203]75
76      /* User non accent sensitive */
77      if (isset($conf_LCAS[1]) and $conf_LCAS[1] == 'true' and isset($conf_LCAS[0]) and $conf_LCAS[0] == 'true')
78      {
[8206]79        $new_username = LCAS_SearchCaseUsername($_POST['username'],3);
[8203]80        $_POST['username'] = $new_username == '' ? $_POST['username'] : $new_username;
81      }
[8197]82    }
[8141]83  }
84}
85?>
Note: See TracBrowser for help on using the repository browser.