<?

/* ------------------------------------------------------------------- */
/*

*************************************************
*			UWAGA! SKRYPT NIE JEST DARMOWY.			*
*		DALSZE ROZPOWSZECHNIANIE BEZ ZGODY 			*
*			FIRMY ArtGlobal JEST ZABRONIONE.			*
*************************************************

*************************************************
*	WWW.ArtGlobal.PL		PRODUCENT OPROGRAMOWANIA	*
*	NAZWA SKRYPTU:		NIERUCHOMOSCI 6.0			*
*	WERSJA FINALNA:	04.10.2010						*
*	KONTAKT:				kontakt@artglobal.pl			*
*************************************************

Copyright (c) 2010 ArtGlobal. Wszelkie prawa zastrzeżone.

*/
/* ------------------------------------------------------------------- */

$smarty -> assign('ma', '');

$sql = "SELECT * FROM config ORDER by cfgId ASC";
$q = mysql_query( $sql );
$c = array();
while ( $db = mysql_fetch_array( $q ) )
{
        $c[] = $db;
}

$cfg['www'] = $c[0]['cfgTxt'];
$cfg['mailLogo'] = $c[1]['cfgTxt'];
$cfg['mailFooter'] = $c[2]['cfgTxt'];
$cfg['mailSmtpHost'] = $c[3]['cfgTxt'];
$cfg['smtpAuth'] = $c[4]['cfgTxt'];
$cfg['mailLogin'] = $c[5]['cfgTxt'];
$cfg['mailPass'] = $c[6]['cfgTxt'];
$cfg['mailAdmin'] = $c[7]['cfgTxt'];
$cfg['wwwSubStr'] =  $www = str_replace(array('http://', 'www.', '/'), '', $cfg['www']);

require_once('../class/mail.class.php');

if ( isset( $_POST['mail'] ) )
{
        $mailing = new sendMail;
        
        $title = $_POST['title'];
        $smarty -> assign('title', $title);
        $txt = $_POST['txt'];
        $smarty -> assign('txt', $txt);
        
        if ( empty( $title ) )
        {
                $error = 'Nie podano tytułu mailingu!';
        }
        else if ( empty( $txt ) )
        {
                $error = 'Nie podano treści mailingu!';
        }
        else
        {
                $sql = "SELECT userName, userEmail FROM users WHERE UserConfirm = '1'";
                $q = mysql_query( $sql );
                while ( $db = mysql_fetch_array( $q ) )
                {
                        $mailing -> mailer ( $db['userEmail'], $db['userName'], '', $title, $txt );
                }

                $success = 'Mailing został wysłany!';
        }
}

$smarty -> assign('success', $success);
$smarty -> assign('error', $error);
?>
