Location: PHPKode > projects > web-cp - Web Hosting Control Panel > webcp/web/domain/mailman.phps
<?
// Init vars
$i = 0;
$j = 0;
$k = 0;
unset($done);
unset($userlist);
unset($error);

// Get current domain's user list
$dbp = mysql_query("SELECT username FROM users WHERE id=".$domaindata['id']);

while ($tmp = mysql_fetch_array($dbp))
    $userlist[$j++] = $tmp['username'];

// If data is set (i.e the submit button has been hit)
if (isset($data) OR $action == 'remove') {
    // remove spaces and slashes.
    if ($action != 'remove') {
        while (list($key, $val) = each($data))
            $data[$key] = trim(stripslashes($val));
        reset($data);
    }
    
    // create database
    if ($action == 'create') {
        // Check database name
        if (!eregi($rx['user'],$data['name']))
            $error[$i++] = $T['err']['mm']['name'];
        
        // Name is free?
        $dbp = mysql_query('SELECT listname FROM mailman WHERE listname = "'.$data['name'].'"');
        if(mysql_num_rows($dbp)>0)
            $error[$i++] = $T['err']['mm']['exists'];
        // User not over it's limit?
        $dbp = mysql_query('SELECT listname FROM mailman WHERE domain = '.$number);
        if(mysql_num_rows($dbp)>=$cfg['mm_maxlists'])
            $error[$i++] = $T['err']['mm']['maxlist'];

        // Verify password
        if (!eregi($rx['pass'],$data['password']))
            $error[$i++] = $T['err']['mm']['password'];

        if(!$error) {
            mysql_query('INSERT INTO mailman (domain, listname, admin, password, action) VALUES("'.$number.'", "'.$data['name'].'", "'.$data['admin'].'", ENCODE("'.$data['password'].'", "'.$cfg['key'].'"), "c")');
            $done[++$k] = $T['listcreate'].' '.$data['name'];
            commit('scan');
        }
    }
    
    // update database(s)
    // remove database
    elseif ($action == 'remove') {
        // Check database name
        if (!eregi($rx['num'],$id))
            $error[$i++] = $T['err']['mm']['id'];
        
        // if no errors, update user's password
        if (!$error) {
            mysql_query('UPDATE mailman SET action = \'r\' WHERE id = '.$id.' AND domain = '.$number);
            $done[++$k] = $T['listremove'];
            commit('scan');
        }
    }
    if ($error)
        echo "<br>&nbsp;&nbsp;• ".implode("<br>\n&nbsp;&nbsp;• ",$error)."<br>\n";
    if ($done)
        echo "<br>&nbsp;&nbsp;• ".implode("<br>\n&nbsp;&nbsp;• ",$done)."<br>\n";
}

?>
<form action="<?=$current_url;?>" method="post" name="webcp" onSubmit="submitonce(this);">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" summary="" width="500">
    <tr>
        <td>
        <b class="big"><?=$T['list Creation'];?></b>
        <table border="0" cellpadding="0" cellspacing="0" summary="" class="tblbg">
            <tr>
                <td>
                <table border="0" cellspacing="1" summary="">
                    <tr>
                        <td class="row2"><b><?=$T['list Name'];?></b></td>
                        <td class="row2"><b><?=$T['Password'];?></b></td>
                        <td class="row2"><b><?=$T['Owner E-Mail'];?></b></td>                        
                    </tr>
                    <tr>
                        <td class="row1"><input type="text" name="data[name]" size="20" maxlength="25"></td>
                        <td class="row1"><input type="text" name="data[password]" size="20" maxlength="25"></td>
                        <td class="row1"><input type="text" name="data[admin]" size="20" maxlength="255"></td>
                    </tr>
                </table>
                </td>
            </tr>
        </table><br>
        <input type="hidden" name="action" value="create">
        <div align="right"><input type="submit" value="<?=$T['Create Mailing'];?>"></div>
        </td>
    </tr>
</table>
</div></form><br><br>
<?
$dbp = mysql_query('SELECT * FROM mailman WHERE action != "r" AND domain = '.$number);
if (mysql_num_rows($dbp)) { ?>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" summary="" width="500">
    <tr>
        <td>
        <b class="big"><?='Mailing list Management';?></b>
        <table border="0" cellpadding="0" cellspacing="0" summary="" class="tblbg">
            <tr>
                <td>
                <table border="0" cellspacing="1" summary="">
                    <tr>
                        <td class="row2"><b>&nbsp;<?=$T['list Name'];?>&nbsp;</b></td>
                        <td class="row2"><b>&nbsp;<?=$T['Owner E-Mail'];?>&nbsp;</b></td>
                        <td class="row2">&nbsp;</td>
                    </tr>
                    <?
                    while ($dbdata = mysql_fetch_array($dbp)) {
                        ?>
                    <tr>
                        <td class="row1"><i><?=$dbdata['listname'];?></i></td>
                        <td class="row1"><i><?=$dbdata['admin'];?></i></td>
                        <td class="row1">&nbsp;<a href="<?=$current_url;?>&action=remove&id=<?=$dbdata['id'];?>"><img src="icon/remove.gif" border="0" width="15" height="15" alt="Remove"></a>&nbsp;</td>
                    </tr>
                    <? } ?>
                </table>
                </td>
            </tr>
        </table><br>
        </td>
    </tr>
</table>
</div>
<?        }?>
Return current item: web-cp - Web Hosting Control Panel