Current time: 05-05-2024, 09:31 AM Hello There, Guest! (LoginRegister)


Thread Closed 
[HOWTO] Using the CLI to manage ispcp via command line (scripts)
Author Message
mdilullo Offline
Newbie
*

Posts: 5
Joined: Oct 2010
Reputation: 0
Post: #57
RE: [HOWTO] Using the CLI to manage ispcp via command line (scripts)
I'm change the switch case create_mail_alias for this code:
PHP Code:
case "create_mail_alias":
                
//Requires $domain, $user, $mail_dst,
                
echo "Creating the mailbox alias $user@$domain pointing to $mail_dst\n";

                
//Alias verification
              
$result $mysqli->query("SELECT `alias_id` FROM `domain_aliasses` WHERE `alias_name`='$domain'");
            if (
$result->num_rows>0) {
                        
$row=$result->fetch_row();
                        
$alias_id=$row[0];
                        
$result->close();
         } else {
                echo 
"ERROR: You are trying to use a non-existant Alias domain\n";
                exit(
0);
      }
      
      
//Domain verification
            
$result $mysqli->query("SELECT `domain_id` FROM `domain_aliasses` WHERE `alias_name`='$domain'");
            if (
$result->num_rows>0) {
                        
$row=$result->fetch_row();
                        
$domain_id=$row[0];
                        
$result->close();
         } else {
                echo 
"ERROR: You are trying to use a non-existant domain\n";
                exit(
0);
      }

                
//Email verification
      
$result $mysqli->query("SELECT `mail_addr` FROM `mail_users` WHERE `mail_addr`='$user@$domain'");
                if (
$result->num_rows !=0) {
                        echo 
"ERROR: You are trying to create an existant mail address\n";
                        exit(
0);
                }

                
//TODO, allow the quota to be set with a parameter
                //Adding the alias
                
$sql "INSERT INTO `mail_users` VALUES  ('','" $user "','_no_" .
                        
"','" $mail_dst "','" $domain_id "','alias_forward','" $alias_id "','toadd',0,'NULL',10485760,' " .
                        
$user "@" $domain "')";
                
//echo $sql . "\n";

                //Adding the user
                
if (!$mysqli->query($sql)) {
                        
printf("ERROR: %s\n"$mysqli->error);
                        exit(
0);
                }

        break; 

This is not very pretty but it works.
The only thing that you have to do is replace the complete switch case create_mail_alias. Them you can use the function whith the same function name and the same parameters.
WARNING previous functionality is lost.
Now I am working to create a new switch case to add to domain.php but I wanted to upload this in case someone needed it.
Greetings and thanks for the help.
Sorry for my English.
(This post was last modified: 11-18-2010 03:12 PM by mdilullo.)
11-18-2010 03:11 PM
Find all posts by this user
Thread Closed 


Messages In This Thread
RE: Using the CLI with ispcp - aseques - 05-08-2009, 11:26 PM
RE: [HOWTO] Using the CLI to manage ispcp via command line (scripts) - mdilullo - 11-18-2010 03:11 PM

Forum Jump:


User(s) browsing this thread: 2 Guest(s)