3)) return $Username; include(LCAS_PATH.'include/LCAS_replacement_set.inc.php'); // Build an array of characters that must be replaced // $rep_char is the replacement character ; $char_rep_arr is an array of // characters which have to be replaced. ie : // if // $conf['LCAS_replacement_set'][$Option]['e'] ='é è' // then // $char_rep_arr['é'] = 'e' ; $char_rep_arr['è'] = 'e'. $char_rep_arr = array(); foreach ( $conf['LCAS_replacement_set'][$Option] as $rep_char => $char_rep_list ) { $t = explode(' ', $char_rep_list); foreach ($t as $c) $char_rep_arr[$c] = $rep_char; } // Replacement in each string of $Username of the characters // that needs to be replaced $t = LCAS_mbStringToArray($Username); $r =''; foreach ($t as $c) { if (array_key_exists($c, $char_rep_arr)) $r.= $char_rep_arr[$c]; else $r.= $c; } // Return of the result return $r; } /* Function called from LCAS_admin.php to send notification email */ function LCAS_SendMail($id, $username) { global $conf; $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']); include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); /* We have to get the user's language in database */ $query =' SELECT user_id, language FROM '.USER_INFOS_TABLE.' WHERE user_id = '.$id.' ;'; $data = pwg_db_fetch_assoc(pwg_query($query)); /* Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language */ if (empty($data)) { /* And switch gallery to this language before using personalized and multilangual contents */ $language = pwg_get_session_var( 'lang_switch', $user['language'] ); switch_lang_to($language); } else { /* And switch gallery to this language before using personalized and multilangual contents */ switch_lang_to($data['language']); load_language('plugin.lang', LCAS_PATH); } $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Username_updated_for_%s', stripslashes($username))); if (isset($conf_LCAS[2]) and $conf_LCAS[2] <> '') { if (function_exists('get_user_language_desc')) { $customtxt = get_user_language_desc($conf_LCAS[2])."\n\n"; } else $customtxt = l10n($conf_LCAS[2])."\n\n"; } /* Send the email with subject and contents */ pwg_mail($email, array( 'subject' => $subject, 'content' => ($customtxt), )); /* Switching back to default language */ switch_lang_back(); } /* Function called from LCAS_admin.php and main.inc.php to get the plugin version and name */ function LCAS_PluginInfos($dir) { $path = $dir; $plg_data = implode( '', file($path.'main.inc.php') ); if ( preg_match("|Plugin Name: (.*)|", $plg_data, $val) ) { $plugin['name'] = trim( $val[1] ); } if (preg_match("|Version: (.*)|", $plg_data, $val)) { $plugin['version'] = trim($val[1]); } if ( preg_match("|Plugin URI: (.*)|", $plg_data, $val) ) { $plugin['uri'] = trim($val[1]); } if ($desc = load_language('description.txt', $path.'/', array('return' => true))) { $plugin['description'] = trim($desc); } elseif ( preg_match("|Description: (.*)|", $plg_data, $val) ) { $plugin['description'] = trim($val[1]); } if ( preg_match("|Author: (.*)|", $plg_data, $val) ) { $plugin['author'] = trim($val[1]); } if ( preg_match("|Author URI: (.*)|", $plg_data, $val) ) { $plugin['author uri'] = trim($val[1]); } if (!empty($plugin['uri']) and strpos($plugin['uri'] , 'extension_view.php?eid=')) { list( , $extension) = explode('extension_view.php?eid=', $plugin['uri']); if (is_numeric($extension)) $plugin['extension'] = $extension; } // IMPORTANT SECURITY ! $plugin = array_map('htmlspecialchars', $plugin); return $plugin ; } // Tri les doublons function CompareTransformedUser($a, $b) { return strcmp($a['transformed'], $b['transformed']); } // Fonctionnel mais optimisable function LCAS_GetDuplicates($source) { $users = array(); $duplicates = array(); // Liste des utilisateurs uniques foreach($source as $user) { if (isset($users[$user['transformed']])) { $users[$user['transformed']] += 1; } else { $users[$user['transformed']] = 1; } } // On récupère les doublons foreach($source as $user) { if ($users[$user['transformed']] > 1) { array_push($duplicates, $user); } } // Trier le tableau usort($duplicates, 'CompareTransformedUser'); return $duplicates; } /** * Retreive duplicate users according of case and or accent sensitivity * * @param : $rule for LCAS_change_case()) * * @return : List of duplicate $username * */ function LCAS_get_user_list($rule) { global $conf, $page; $users = array(); /* search users depending expiration date */ $query = ' SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, u.'.$conf['user_fields']['username'].' AS username, u.'.$conf['user_fields']['email'].' AS email FROM '.USERS_TABLE.' AS u ;'; $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { $user = $row; $user['transformed'] = LCAS_change_case($user['username'], $rule, false); array_push($users, $user); } return LCAS_GetDuplicates($users); } // Cleaning obsolete files at plugin upgrade function LCAS_clean_obsolete_files() { if (file_exists(LCAS_PATH.'obsolete.list') and $old_files = file(LCAS_PATH.'obsolete.list', FILE_IGNORE_NEW_LINES) and !empty($old_files)) { array_push($old_files, 'obsolete.list'); foreach($old_files as $old_file) { $path = LCAS_PATH.$old_file; if (is_file($path)) { @unlink($path); } } } } /** * Function called from main.inc.php - For test on username case sensitivity * Have to be deleted before first release build * * @param : $username typed in by user for identification * * @return : $username found in database * */ function LCAS_SearchCaseUsername($username, $rule) { global $conf; $username_c = LCAS_change_case($username, $rule); if (isset($username)) { $LCAS_users = array(); $q = pwg_query(" SELECT ".$conf['user_fields']['username']." AS username FROM `".USERS_TABLE."`; "); while ($r = pwg_db_fetch_assoc($q)) $LCAS_users[$r['username']] = LCAS_change_case($r['username'], $rule); // $LCAS_users is now an associative table where the key is the account // as registered in the DB, and the value is this same account, // transformed as stated by $rule. $users_found = array_keys($LCAS_users, $username_c); // $users_found is now a table of which the values are all the accounts // which can be written as stated by $rule the same way as $username can if (count($users_found) != 1) // If ambiguous, don't allow transformed return $username; // writing but normal writing will work else return $users_found[0]; } } /* * str_from_var3($var) * returns a string easing array var informations displaying in Piwigo : * _ the string return value starts with"

" ; * _ all "TAB" characters (chr(10)) are replaced by "
" ; * _ all spaces are replaced by " ". * * @param * $var : variable to display * @return * string easy to display in Piwigo */ function str_from_var3($var) { return '

'. str_replace( chr(10),'
', str_replace(' ',' ', print_r /* var_dump */ ($var,true)) ). '

'; } // DebugLog function function DebugLog($var1, $var2, $var3, $var4, $var5) { $fo=fopen (LCAS_PATH.'admin/debuglog.txt','a') ; fwrite($fo,"======================\n") ; fwrite($fo,'le ' . date('D, d M Y H:i:s') . "\r\n"); fwrite($fo, "\n" . $var1 . "\r\n") ; fwrite($fo, "\n" . $var2 . "\r\n") ; fwrite($fo, "\n" . $var3 . "\r\n") ; fwrite($fo, "\n" . $var4 . "\r\n") ; fwrite($fo, "\n" . $var5 . "\r\n") ; fclose($fo) ; } ?>