0
0
mirror of https://github.com/postfixadmin/postfixadmin.git synced 2024-09-20 03:36:20 +02:00

Merge pull request #70 from Seitanas/master

virtualmaildel.php with PHP mysqli extension.
This commit is contained in:
David Goodwin 2017-08-31 12:30:08 +01:00 committed by GitHub
commit 9b16645c0f

View File

@ -6,6 +6,9 @@
// You can run this from your crontab with something like // You can run this from your crontab with something like
// //
// 0 4 * * * * vmail php -q virtualmaildel.php >/dev/null // 0 4 * * * * vmail php -q virtualmaildel.php >/dev/null
//
// 2017.08.31 updated to use PHP mysqli extension.
// Tadas Ustianvičius <tadas at ring dot lt>
// //
// Setup location of postfixadmin config files. Needed to login to mysql // Setup location of postfixadmin config files. Needed to login to mysql
@ -97,7 +100,7 @@
// //
// OK, got an array of accounts from the dir, Now connect to the DB and check them // OK, got an array of accounts from the dir, Now connect to the DB and check them
// //
$conx = mysql_connect( $CONF['database_host'],$CONF['database_user'],$CONF['database_password'] ); $conx = mysqli_connect( $CONF['database_host'],$CONF['database_user'],$CONF['database_password'] );
// //
// Is there a problem connecting? // Is there a problem connecting?
// //
@ -106,13 +109,13 @@
// //
// Select the database // Select the database
// //
mysql_select_db( $CONF['database_name'] , $conx) or die ("Can't access database postfix : " . mysql_error()); mysqli_select_db( $conx, $CONF['database_name'] ) or die ("Can't access database postfix : " . mysql_error());
// //
// Select all mailboxes to verify against dirs listed in array // Select all mailboxes to verify against dirs listed in array
// //
$query = "SELECT * FROM mailbox"; $query = "SELECT * FROM mailbox";
$result = mysql_query( $query ); $result = mysqli_query( $conx, $query );
// //
// Query the mailbox table // Query the mailbox table
@ -122,7 +125,7 @@
// //
// Fetch the list of results // Fetch the list of results
// //
while ( $row = mysql_fetch_assoc( $result ) ) while ( $row = mysqli_fetch_assoc( $result ) )
{ {
// //
// Pull apart the maildir field, needed to figure out the directory structure to compare // Pull apart the maildir field, needed to figure out the directory structure to compare
@ -136,7 +139,7 @@
// //
// If there are results. unset the domain too. // If there are results. unset the domain too.
// //
if ( count($dir[$strip[0]])==0 and mysql_num_rows($result)>0 ) if ( count($dir[$strip[0]])==0 and mysqli_num_rows($result)>0 )
unset( $dir[$strip[0]] ); unset( $dir[$strip[0]] );
} }
else else