 <?php
	if (! defined ( 'APP_PATH' ) || ! defined ( 'I_PATH' )) {
		exit ( 'Access Denied' );
	}
	
	class ld_email extends controllerBase {
		function __construct() {
			parent::__construct ();
			$this->a = $this->sysParams ( 'a', 1 );
		}
		
		function index() {
			if ($this->sysParams ( 'run' ) == 1) {
				$sysconfig = syDB ( 'sysconfig' )->findAll ();
				$data = array ();
				foreach ( $sysconfig as $v ) {
					$data [$v ['code']] = $v ['value'];
				}
				$keys = array ();
				foreach ( $data as $k => $v ) {
					$value = $this->sysParams ( $k, 1 );
					
					if ($value != NULL) {
						syDB ( 'sysconfig' )->update ( array ('code' => $k ), array ('value' => $value ) ); // "code='$k'",'value='$value');
					}
				}
				$test = $this->sysParams ( 'test', 1 );
				if ($test == 1) {
					global $iConfig;
					include I_PATH . '/mail.php';
					
					$result = ldmail ( $this->sysParams ( 'mail_test', 1 ), '篮鼎ICms邮件测试', "<a href='".$iConfig['ext']['http_path']."'> 恭喜！您的站点邮件发送设置成功！</a>" );
					if ($result == false) {
						message_a ( "邮件发送失败，请重新配置", '?c=ld_email' );
					} else {
						message_a ( "邮件发送成功，请到测试邮箱检查", '?c=ld_email' );
					}
				} else {
					message_a ( "邮件配置成功", '?c=ld_email' );
				}
			}
			$this->toptxt = '邮件配置';
			$sysconfig = syDB ( 'sysconfig' )->findAll ();
			$data = array ();
			foreach ( $sysconfig as $v ) {
				$data [$v ['code']] = $v ['value'];
			}
			$this->d = $data;
			
			$this->display ( "email.html" );
		}
	
	}	