HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Tips/Tricks/Mods (http://www.howtoforge.com/forums/forumdisplay.php?f=19)
-   -   UebiMiau username lookup patches (http://www.howtoforge.com/forums/showthread.php?t=2775)

fcl 27th February 2006 13:22

UebiMiau username lookup patches
 
So, I've been having fun with ISPConfig for a few months now (after having finally wrestled it onto my Slackware 10.2 distro!).

It's a nice system, we've just migrated a collection of remote mail users over to it, and in doing so I had to "fix" some usability issues with the UebiMiau implementation.

These patches do the following:

E-Mail address login is no longer case sensitive.

ISPConfig mail username can now be used as login (but NOT first time through!)

On first login, ISPConfig stored name and mail address are used as the default Name and "Reply-to", NOT mail username.

Note that though I learn't to read by reading K&R ( ;) ), I'm new to PHP (indeed, everything I know about PHP I learned by hacking this and ISPConfig), so whilst what I've done works, I make no guarantee that it's the most elegant solution, just mine!

Two files modified, msglist.php and inc/lib.php, both live in the webmail directory of your admispconfig web dir (which is /home/admispconfig/ispconfig/web/webmail on my box).

PATCHES (diff unified, should be suitable for patch) follow:

--- msglist.php 2005-05-26 13:49:35.000000000 +0100
+++ msglist.php 2006-02-27 10:46:42.000000000 +0000
@@ -16,41 +16,55 @@
$dbname = 'db_'.$go_info["server"]["db_type"];
$db = new $dbname;
if($f_email){
- list($alias,$domain) = explode("@", $f_email);
- $webs = $db->queryAllRecords("SELECT * from isp_isp_web, isp_nodes where isp_isp_web.doc_id = isp_nodes.doc_id and isp_nodes.doctype_id = '1013' and isp_isp_web.server_id = '1' and isp_nodes.status = '1'");
- if(!empty($webs)){
- foreach($webs as $web){
- if($web["web_host"] != ""){
- $domain_hosts[] = $web["web_host"].".".$web["web_domain"];
- } else {
- $domain_hosts[] = $web["web_domain"];
- }
- $codomains = $db->queryAllRecords("SELECT isp_isp_domain.domain_domain, isp_isp_domain.domain_host from isp_dep,isp_isp_domain where isp_dep.child_doc_id = isp_isp_domain.doc_id and isp_dep.child_doctype_id ='1015' and isp_dep.parent_doctype_id = '1013' and isp_dep.parent_doc_id = '".$web["doc_id"]."' and isp_isp_domain.status != 'd'");
- if(!empty($codomains)){
- foreach($codomains as $codomain){
- if($codomain["domain_host"] != ""){
- $domain_hosts[] = $codomain["domain_host"].".".$codomain["domain_domain"];
- } else {
- $domain_hosts[] = $codomain["domain_domain"];
+ if(strchr($f_email,'@')) {
+ list($alias,$domain) = explode("@", $f_email,2);
+ $domain_i = strtolower($domain);
+ $webs = $db->queryAllRecords("SELECT * from isp_isp_web, isp_nodes where isp_isp_web.doc_id = isp_nodes.doc_id and isp_nodes.doctype_id = '1013' and isp_isp_web.server_id = '1' and isp_nodes.status = '1'");
+ if(!empty($webs)){
+ foreach($webs as $web){
+ if($web["web_host"] != ""){
+ $tempdom = $domain_hosts[] = strtolower($tempdom_cs = ($web["web_host"].".".$web["web_domain"]));
+
+ } else {
+ $tempdom = $domain_hosts[] = strtolower($tempdom_cs = $web["web_domain"]);
+ }
+ $domain_hosts_cs[$tempdom]=$tempdom_cs;
+ $codomains = $db->queryAllRecords("SELECT isp_isp_domain.domain_domain, isp_isp_domain.domain_host from isp_dep,isp_isp_domain where isp_dep.child_doc_id = isp_isp_domain.doc_id and isp_dep.child_doctype_id ='1015' and isp_dep.parent_doctype_id = '1013' and isp_dep.parent_doc_id = '".$web["doc_id"]."' and isp_isp_domain.status != 'd'");
+ if(!empty($codomains)){
+ foreach($codomains as $codomain){
+ if($codomain["domain_host"] != ""){
+ $tempdom = $domain_hosts[] = strtolower($tempdom_cs = ($codomain["domain_host"].".".$codomain["domain_domain"]));
+ } else {
+ $tempdom = $domain_hosts[] = strtolower($tempdom_cs = $codomain["domain_domain"]);
+ }
+ $domain_hosts_cs[$tempdom]=$tempdom_cs;
}
}
- }
- if(in_array($domain, $domain_hosts)){
- $users = $db->queryAllRecords("SELECT * FROM isp_nodes, isp_dep, isp_isp_user WHERE isp_dep.parent_doc_id = '".$web["doc_id"]."' AND isp_dep.parent_doctype_id = '1013' AND isp_dep.child_doc_id = isp_isp_user.doc_id AND isp_dep.child_doctype_id = '1014' AND isp_nodes.doc_id = isp_isp_user.doc_id AND isp_nodes.doctype_id = '1014' AND isp_nodes.status = '1'");
- if(!empty($users)){
- foreach($users as $user){
- $aliasse = explode("\n", str_replace("\r\n", "\n", trim($user["user_emailalias"])));
- if(trim($user["user_email"]) != "") $aliasse[] = trim($user["user_email"]);
- $aliasse[] = trim($user["user_username"]);
- if(in_array($alias, $aliasse)) $f_email = $user["user_username"]."@".$domain;
+ if(in_array($domain_i, $domain_hosts)){
+ $users = $db->queryAllRecords("SELECT * FROM isp_nodes, isp_dep, isp_isp_user WHERE isp_dep.parent_doc_id = '".$web["doc_id"]."' AND isp_dep.parent_doctype_id = '1013' AND isp_dep.child_doc_id = isp_isp_user.doc_id AND isp_dep.child_doctype_id = '1014' AND isp_nodes.doc_id = isp_isp_user.doc_id AND isp_nodes.doctype_id = '1014' AND isp_nodes.status = '1'");
+ if(!empty($users)){
+ foreach($users as $user){
+ $aliasse = explode("\n", str_replace("\r\n", "\n", strtolower(trim($user["user_emailalias"]))));
+ if(trim($user["user_email"]) != "") $aliasse[] = strtolower(trim($user["user_email"]));
+ $aliasse[] = strtolower(trim($user["user_username"]));
+ if(in_array(strtolower($alias), $aliasse)) {
+ $f_email = $user["user_username"]."@".$domain;
+ $f_email_reply = $alias."@".$domain_hosts_cs[$domain_i];
+ $f_display_name = $user["user_name"];
+ }
unset($aliasse);
+ }
}
}
+ unset($domain_hosts);
+ unset($domain_hosts_cs);
}
- unset($domain_hosts);
}
+ } else {
+ $f_email = $f_email."@localhost";
}
}
+
//////////////////////// Map Alias to User Name (ISPConfig) ENDE ////////////////
require("./inc/inc.php");

--- inc/lib.php 2003-05-27 12:44:40.000000000 +0100
+++ inc/lib.php 2006-02-27 10:47:19.000000000 +0000
@@ -132,15 +132,23 @@

global $userfolder,
$sess,
- $default_preferences;
+ $default_preferences, $f_display_name, $f_email_reply;

extract($default_preferences);

$pref_file = $userfolder."_infos/prefs.upf";

if(!file_exists($pref_file)) {
- $prefs["real-name"] = UCFirst(substr($sess["email"],0,strpos($sess["email"],"@")));
- $prefs["reply-to"] = $sess["email"];
+ if(isset($f_display_name)) {
+ $prefs["real-name"] = $f_display_name;
+ } else {
+ $prefs["real-name"] = UCFirst(substr($sess["email"],0,strpos($sess["email"],"@")));
+ }
+ if(isset($f_email_reply)) {
+ $prefs["reply-to"] = $f_email_reply;
+ } else {
+ $prefs["reply-to"] = $sess["email"];
+ }
$prefs["save-to-trash"] = $send_to_trash_default;
$prefs["st-only-read"] = $st_only_ready_default;
$prefs["empty-trash"] = $empty_trash_default;


All times are GMT +2. The time now is 02:07.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.