Location: PHPKode > projects > mailqui > mailqui/mailqui.php
<?php
/**
 * The contents of this file are subject to the Guara. You may not use
 * this file except in compliance with the License.
 * You may obtain a copy of the License at http://www.gnu.org/licenses/gpl.html
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * Mailq - main
 *
 * @version Revision: 24 - 27/11/2006
 * @author Andreas Hansen <hide@address.com>, IdeiaLivre - Software Livre como Estrategia
 * @package mailqui
 *
 **/

/** Include Config Options File **/
include ( "config.inc.php" );

/** Verify Session Presence **/
if ( file_exists( "mailqui.ini" ) AND $_REQUEST["action"] != "firstLogin" ) checkLogin(); 

if ( $_REQUEST["action"] != "settings" AND $_REQUEST["action"] != "firstLogin" ) { 
	require_once ( INCLUDE_DIR . "/qActions.class" );
	$qActions = new qActions;
	
	require_once ( INCLUDE_DIR . "/parseQueue.class" );
	$queue = new parseQueue;

	/** If mailServer Select have changed **/
	if ( $_REQUEST["action"] == "changeMailServer" OR $_REQUEST["mailServer"] ) {
		$queue->MTA = $config->get ( 'MTAProvider', 'mailServer_' . $_REQUEST["mailServer"] );
		if ( $config->get ( 'remote', 'mailServer_' . $_REQUEST["mailServer"] ) == "on" ) {
			$default["sshConn"] = openSSHConnection( 'mailServer_' . $_REQUEST["mailServer"] );
		}
		$_SESSION["mailServerSelected"] = $_REQUEST["mailServer"];
	} else {
		if ( !$_SESSION["mailServerSelected"] ) {
			if ( $config->get( 'DefaultMailServer', 'global' ) == "" ) {
				$mailServer = getMailServers();
				$_SESSION["mailServerSelected"] = $mailServer[0];
			} else {
				$_SESSION["mailServerSelected"] = $config->get( 'DefaultMailServer', 'global' );
 			}
			$queue->MTA = $config->get ( 'MTAProvider', 'mailServer_' . $_SESSION["mailServerSelected"] );
			if ( $config->get ( 'remote', 'mailServer_' . $_SESSION["mailServerSelected"] ) == "on" ) {
				$default["sshConn"] = openSSHConnection( 'mailServer_' . $_SESSION["mailServerSelected"] );
			}
		} else {
			if ( $config->get ( 'remote', 'mailServer_' . $_SESSION["mailServerSelected"] ) == "on" ) {
				$default["sshConn"] = openSSHConnection( 'mailServer_' . $_SESSION["mailServerSelected"] );
			}
			$queue->MTA = $config->get ( 'MTAProvider', 'mailServer_' . $_SESSION["mailServerSelected"] );
		}
	}
	
	/**
	* Verify Action and execute
	**/ 
	switch ( $_REQUEST["action"] ) {
		case "rQMessage":
			$result = $qActions->removeFromQueue($_REQUEST["qid"]);
			break;
		case "requeue":
			$result = $qActions->reQueue( $_REQUEST["qid"] );
			break;
		case "filterDomain":
			if ( $_REQUEST["domain"] == "all" ) {
				$mailQueue = $queue->getParsedQueue();
			} else {
				$mailQueue = $queue->getParsedQueue( $_REQUEST["domain"] );
			}
			break;
		case "cleanQueue":
			$result = $qActions->cleanQueue();
			break;
		case "flushQueue":
			$result = $qActions->flushQueue();
			break;
		case "removeSelected":
			while (list ($key,$val) = @each ($_REQUEST['mailquiID'])) {
				$result = $qActions->removeFromQueue($val);
			}
			break;
		case "changePage":
			if ( $_REQUEST["gotoPage"] == '' ) {
				$actualPage = $_REQUEST["selectPage"];
			} else {
				$actualPage = $_REQUEST["gotoPage"];
			}
			break;
	}
	
	/** Get Parsed Queue **/
	$mailQueue = $queue->getParsedQueue();
	
	if ( $config->get( 'EnablePagination', 'global' ) == "on" ) {
		if ( !$actualPage ) $actualPage = "1";
		$mailQueue_Paged = array_chunk($mailQueue,$config->get( 'MessagesPerPage', 'global' ) );
		$mailQueue = $mailQueue_Paged[$actualPage-1];
		$messagePages = ceil( $queue->mailsInQueue / $config->get( 'MessagesPerPage', 'global' ) );
	}
	
	/**
	* Include file that render page
	**/
	include_once ( OUTPUT_DIR . "/main.php" );
} else {

	if ( !file_exists( "mailqui.ini" ) ) {
		require_once ( "lib/configMagik.class" );
		$config = new ConfigMagik ( 'mailqui.ini', true, true );
	}
	/** Get available languages **/
	$availableLanguages = getInstalledLanguages();

	/** Get available Authentication Methods **/
	$authMethods = getAuthMethods();

	/** Register Xajax function **/
	$xajax->registerFunction("addMailServer");
	$xajax->registerFunction("removeMailServer");
	$xajax->registerFunction("updateMailServer");
	$xajax->registerFunction("updateGlobalOptions");
	$xajax->registerFunction("updateAuthenticationOptions");
	/** Include file with Specific functions **/
	require_once ( INCLUDE_DIR . "/settings.inc.php" );
	$xajax->processRequests();
	
	/**
	* Include file that render page
	**/
	include_once ( OUTPUT_DIR . "/settings.php" );
}
?>
Return current item: mailqui