Exemplo n.º 1
0
 public static function send($id)
 {
     foreach ($_POST as $key => $value) {
         $_POST[$key] = htmlspecialchars(trim(strip_tags($value)));
     }
     if ($_SESSION['captcha_keystring'] == $_POST['kcaptcha'] && $_SESSION['captcha_keystring'] != '') {
         $text = '';
         foreach ($_POST as $name => $item) {
             if ($_POST[$name . '_text'] && strpos($name, '_text') === false) {
                 if (strpos($name, '_area') !== false) {
                     $text .= '<b>' . $_POST[$name . '_text'] . ':</b> <br />' . nl2br($item) . '<br />';
                 } else {
                     $text .= '<b>' . $_POST[$name . '_text'] . ':</b> ' . $item . '<br />';
                 }
             }
         }
         $mail = new Email();
         $info = Tree::getInfo($id);
         if (Funcs::$conf['mail'][$info['path']]) {
             $mail->To(Funcs::$conf['mail'][$info['path']]);
         } elseif (Funcs::$conf['settings']['email']) {
             $mail->To(Funcs::$conf['settings']['email']);
         } else {
             return false;
         }
         $mail->Subject($_POST['subject'] . ' на сайте ' . $_SERVER['HTTP_HOST']);
         $mail->Text($text);
         $mail->Send();
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
    function forgot()
    {
        if ($_POST) {
            DB::escapePost();
            $sql = '
				SELECT * FROM {{users}} WHERE login=\'' . $_POST['login'] . '\'
			';
            $return = DB::getRow($sql);
            if ($return) {
                $pass = Funcs::generate_password(8);
                $sql = '
					UPDATE {{users}}
					SET pass=MD5(\'' . $pass . '\')
					WHERE login=\'' . $_POST['login'] . '\'
				';
                DB::exec($sql);
                $text = '
					Здравствуйте, ' . $return["login"] . '.<br />
					Ваш новый пароль ' . $pass . '.<br />
					Сменить пароль Вы можете в личном кабинете. 
				';
                $mail = new Email();
                $mail->To($return['email']);
                $mail->Subject('Восстановление пароля на сайте www.' . str_replace("www.", "", $_SERVER["HTTP_HOST"]));
                $mail->Text($text);
                $mail->Send();
            }
            $this->redirect('/');
        } else {
            View::$layout = 'empty';
            View::render('site/forgot');
        }
    }
Exemplo n.º 3
0
    public static function Report()
    {
        $sql = 'SELECT * FROM {{orders}} WHERE loyalty=1 AND sent=0';
        $list = DB::getAll($sql);
        foreach ($list as $order) {
            $sql = '
				SELECT * FROM {{orders_items}}
				WHERE orders=' . $order['id'] . '
			';
            $items = DB::getAll($sql);
            $data = $order;
            foreach ($items as $item) {
                $temp = Tree::getInfo($item['tree']);
                if ($temp['path'] != 'catalogopt') {
                    $data['list'][] = Catalog::getOne($item['tree']);
                }
            }
            $text = View::getRenderEmpty('email/report', $data);
            $mail = new Email();
            $mail->Text($text);
            $mail->Subject('Оставьте отзыв о товаре на сайте www.' . str_replace('www.', '', $_SERVER["HTTP_HOST"]));
            $mail->From('robot@' . str_replace('www.', '', $_SERVER["HTTP_HOST"]));
            $mail->To($order['email']);
            $mail->Send();
            $sql = '
				UPDATE {{orders}}
				SET	sent=1
				WHERE id=' . $order['id'] . '
			';
            DB::exec($sql);
        }
    }
Exemplo n.º 4
0
    public static function addMessage($touser, $message)
    {
        $sql = '
			INSERT INTO {{messages}}
			SET 
				fromuser='******'iuser']['id'] . ',
				touser='******',
				message=\'' . $message . '\',
				cdate=NOW()
		';
        DB::exec($sql);
        $sql = 'SELECT CONCAT(fname,\' \',lname) AS name, email FROM {{iusers}} WHERE id=' . $touser . '';
        $row = DB::getRow($sql);
        $toname = $row['name'];
        $email = $row['email'];
        if (trim($toname) == '') {
            $toname = 'Неизвестный';
        }
        $text = '
			Здравствуйте, ' . $toname . '!<br /><br />
			' . $_SESSION['iuser']['name'] . ' написал Вам новое сообщение на сайте <a href="http://' . $_SERVER['HTTP_HOST'] . '">' . $_SERVER['HTTP_HOST'] . '</a>.<br /><br />
		';
        $text = View::getRenderEmpty('email/simple', array('text' => $text, 'title' => 'Новое сообщение'));
        $mail = new Email();
        $mail->To($email);
        $mail->Subject('Новое сообщение от ' . $_SESSION['iuser']['name'] . ' на сайте ' . $_SERVER['HTTP_HOST']);
        $mail->Text($text);
        $mail->Send();
    }
Exemplo n.º 5
0
 private static function send($address, $subject, $text)
 {
     $mail = new Email();
     $mail->To($address);
     $mail->Subject($subject);
     $mail->Text($text);
     $mail->Send();
 }
Exemplo n.º 6
0
    function send()
    {
        $emails = array();
        $groups = array();
        if (!isset($_POST['users']) and !isset($_POST['email'])) {
            return;
        }
        $sqlGroups = '';
        if (!empty($_POST['users'])) {
            foreach ($_POST['users'] as $item) {
                if ($item == 'iusers') {
                    $sql = 'SELECT email FROM {{iusers}} WHERE visible=1';
                    $emails = array_merge($emails, DB::getAll($sql, 'email'));
                } elseif ($item == 'subscribers') {
                    $sql = 'SELECT email FROM {{subscribers}}';
                    $emails = array_merge($emails, DB::getAll($sql, 'email'));
                } elseif ($item == 'orders') {
                    $sql = 'SELECT email FROM {{orders}}';
                    $emails = array_merge($emails, DB::getAll($sql, 'email'));
                } else {
                    $groups[] = $item;
                }
            }
            $sqlGroups = 'emailgroups=\'' . implode(',', $_POST['users']) . '\',';
        }
        if (!empty($groups)) {
            $users = Iuser::getGroupUsers($groups, 'email');
            $emails = array_merge($emails, $users);
        }
        $emails[] = $_POST['email'];
        $emails = array_unique($emails);
        $text = View::getRenderFullEmpty('email/notifications', array('text' => $_POST['body'], 'title' => $_POST['subject']));
        foreach ($emails as $email) {
            $mail = new Email();
            $mail->Text($text);
            $mail->Subject($_POST['subject']);
            $mail->From($_POST['emailfrom']);
            $mail->mailTo($email);
            $mail->Send();
        }
        $sql = '
			INSERT INTO {{notification}}
			SET 
				subject=\'' . $_POST['subject'] . '\',
				body=\'' . $_POST['body'] . '\',
				email=\'' . implode(',', $emails) . '\',
				' . $sqlGroups . '
				emailfrom=\'' . $_POST['emailfrom'] . '\',
				cdate=NOW(),
				author=' . $_SESSION['user']['id'] . '
		';
        DB::exec($sql);
    }
Exemplo n.º 7
0
 public static function sendAllOrder($id)
 {
     $data = Orders::getOrderById($id);
     View::$layout = 'empty';
     $text = View::getRenderFullEmpty('email/order', $data);
     $mail = new Email();
     $mail->mailTo($data['email']);
     $mail->Subject('Статус заказа №' . (str_repeat('0', 6 - strlen($id)) . $id) . ' на сайте ' . $_SERVER['HTTP_HOST'] . ' изменен');
     $mail->From('robot@' . str_replace('www.', '', $_SERVER["HTTP_HOST"]));
     $mail->Text($text);
     $mail->Send();
 }
Exemplo n.º 8
0
 public function sendMailback()
 {
     DB::escapePost();
     $text .= '<b>Имя:</b> ' . $_POST['name'] . '<br />';
     $text .= '<b>Телефон:</b> ' . $_POST['phone'] . '<br />';
     $text .= '<b>Email:</b> ' . $_POST['email'] . '<br />';
     $text .= '<b>Сообщение:</b> ' . nl2br($_POST['message']) . '<br />';
     View::$layout = 'empty';
     $text = View::getRender('email/callback', array('text' => $text));
     $mail = new Email();
     $mail->mailTo(Funcs::$conf['email']['callback']);
     $mail->Subject('Обратная связь на сайте ' . $_SERVER['HTTP_HOST']);
     $mail->Text($text);
     $mail->Send();
 }
Exemplo n.º 9
0
    public function ask($tree)
    {
        foreach ($_POST as $key => $value) {
            $_POST[$key] = htmlspecialchars(trim(strip_tags($value)));
        }
        if ($_POST['kcaptcha'] == $_SESSION['captcha_keystring'] && $_POST['kcaptcha'] != '' && $_SESSION['captcha_keystring'] != '') {
            $sql = '
				INSERT INTO {{tree}}
				SET
					parent=' . $tree . ',
					name=\'' . trim($_POST['question']) . '\',
					path=\'' . Funcs::Transliterate(trim($_POST['question'])) . '\',
					seo_title=\'' . trim($_POST['question']) . '\',
					seo_keywords=\'' . trim($_POST['question']) . '\',
					seo_description=\'' . trim($_POST['question']) . '\',
					udate=NOW(),
					cdate=NOW(),
					visible=0,
					site=' . $_SESSION['site'] . ',
					num=0
			';
            $id = DB::exec($sql);
            $sql = '
				INSERT INTO {{relations}}
				SET
					modul1=\'tree\',
					modul2=\'faq\',
					id1=\'' . $id . '\',
					id2=1,
					cdate=NOW()
			';
            DB::exec($sql);
            //Fields::insertField($id,'answer',$_POST['message']);
            //Fields::insertField($id,'phone',$_POST['phone']);
            $text = '
				<b>Email:</b> <a href="mailto:' . trim($_POST['email']) . '">' . trim($_POST['email']) . '</a><br />
				<b>Вопрос:</b> ' . trim($_POST['question']) . '<br />
			';
            $mail = new Email();
            $mail->To(Funcs::$conf['email']['faq']);
            $mail->Subject('Задан вопрос на сайте ' . $_SERVER['HTTP_HOST']);
            $mail->Text($text);
            $mail->Send();
            return false;
        } else {
            return true;
        }
    }
Exemplo n.º 10
0
 public function send()
 {
     $form = $this->getForm(Funcs::$uri[1]);
     $text = '';
     foreach ($this->getFields(Funcs::$uri[1]) as $item) {
         if ($item['type'] == 'text') {
             $text .= '<b>' . $item['name'] . '</b><br /> ' . nl2br($_POST[$item['path']]) . '<br />';
         } elseif ($item['type'] == 'checkbox') {
             if ($_POST[$item['path']]) {
                 $text .= '<b>' . $item['name'] . '</b><br />';
             }
         } else {
             $text .= '<b>' . $item['name'] . '</b> ' . $_POST[$item['path']] . '<br />';
         }
     }
     $mail = new Email();
     $mail->mailTo($form["email"]);
     $mail->Subject($form['theme']);
     $mail->Text($text);
     $mail->Send();
 }
Exemplo n.º 11
0
    public function sendMessage()
    {
        Funcs::escapePost();
        //if($_POST['kcaptcha']==$_SESSION['captcha_keystring'] && $_POST['kcaptcha']!='' && $_SESSION['captcha_keystring']!=''){
        $text = '
				<b>ФИО:</b> ' . $_POST['fio'] . '<br />
				<b>Телефон:</b> ' . $_POST['tel'] . '<br />
				<b>Email:</b> <a href="mailto:' . $_POST['email'] . '">' . $_POST['email'] . '</a><br />
				<b>Тема:</b> ' . $_POST['theme'] . '<br />
				<b>Сообщение:</b><br />' . nl2br($_POST['quest']) . '<br />
			';
        $mail = new Email();
        $mail->To(Funcs::$conf['email']['feedback']);
        $mail->Subject('Обратная связь на сайте ' . $_SERVER['HTTP_HOST']);
        $mail->Text($text);
        $mail->Send();
        return false;
        /*}else{
        			return true;
        		}*/
    }
Exemplo n.º 12
0
 function toOrder($iuserId = 0, $id = '', $send = true)
 {
     if ($id == '') {
         $id = $this->saveBasket();
     }
     View::$layout = 'empty';
     $data = $this->getOrder();
     $data['id'] = $id;
     $data['hits'] = Index::getHits();
     $text = View::getRender('basket/mail', $data);
     $textadmin = View::getRender('basket/mailadmin', $data);
     $info = View::getRender('basket/mailinfo');
     $code = '';
     /*if($info!='Наличными'){
     			$_SESSION['code']=rand(1,9999);
     			$code='<br /><br /><b>Код подтверждения:<b/> '.$_SESSION['code'];
     		}*/
     $this->saveBasket($id, $text, $data, $info, $iuserId);
     if ($send) {
         $mail = new Email();
         $mail->Text($textadmin);
         $mail->Subject('Поступил заказ с сайта www.' . str_replace('www.', '', $_SERVER["HTTP_HOST"]));
         $mail->From('robot@' . str_replace('www.', '', $_SERVER["HTTP_HOST"]));
         $mail->To(Funcs::$conf['email']['order']);
         $mail->Send();
         if ($_SESSION['mydata']['email']) {
             $data['client'] = 1;
             $text = View::getRender('basket/mail', $data);
             $info = View::getRender('basket/mailinfo');
             $mail = new Email();
             $mail->Text($text);
             $mail->Subject('Вы оставили заказ на сайте www.' . str_replace('www.', '', $_SERVER["HTTP_HOST"]));
             $mail->From('robot@' . str_replace('www.', '', $_SERVER["HTTP_HOST"]));
             $mail->mailTo($_SESSION['mydata']['email']);
             $mail->Send();
         }
     }
     if (SMSuser) {
         file_get_contents('http://sms.spb.su/sms.cgi?user='******'&pass='******'&phone=' . Funcs::$conf['additional']['sms'] . '&flash=0&message=' . urlencode(iconv('utf-8', 'windows-1251', 'Заказ ' . $id . ' ' . $_SESSION['mydata']['name'] . ' ' . $_SESSION['mydata']['phone'])) . '&from=' . $_SERVER['HTTP_HOST'] . '');
     }
     $_SESSION['mydata'] = array();
     $_SESSION['goods'] = array();
     $_SESSION['orderId'] = $id;
 }
Exemplo n.º 13
0
    public static function setSubscribers()
    {
        DB::escapePost();
        $sql = 'SELECT email FROM {{subscribers}} WHERE email=\'' . $_POST["email"] . '\'';
        $email = DB::getOne($sql);
        if ($email) {
            $text .= '<b>Здравствуйте!</b><br />Вы уже зарегистрированы на подписку<br /><br />';
            $text .= 'Для отказа от подписки пройдите по ссылке <a href="http://' . $_SERVER['HTTP_HOST'] . '/confirm/' . md5(News::$delsalt . $email) . '">http://' . $_SERVER['HTTP_HOST'] . '/confirm/' . md5(News::$delsalt . $email) . '</a><br />';
        } else {
            $sql = '
				INSERT INTO {{subscribers}}
				SET 
					email=\'' . $_POST["email"] . '\',
					create_date=NOW()
			';
            DB::exec($sql);
            $text .= '<b>Здравствуйте!</b><br />Вы успешно зарегистрированы на подписку на сайте <a href="http://' . $_SERVER['HTTP_HOST'] . '">' . $_SERVER['HTTP_HOST'] . '</a><br /><br />';
            $text .= 'Для отказа от подписки пройдите по ссылке <a href="http://' . $_SERVER['HTTP_HOST'] . '/confirm/' . md5(News::$delsalt . $email) . '">http://' . $_SERVER['HTTP_HOST'] . '/confirm/' . md5(News::$delsalt . $email) . '</a><br />';
        }
        View::$layout = 'empty';
        $text = View::getRender('email/newssubscribe', array('text' => $text));
        $mail = new Email();
        $mail->To($_POST["email"]);
        $mail->Subject('Подписка на новости на сайте ' . $_SERVER['HTTP_HOST']);
        $mail->Text($text);
        $mail->Send();
    }
Exemplo n.º 14
0
    public function setAnketa()
    {
        Funcs::escapePost();
        $data = array();
        $text = '';
        foreach (OneSSA::$iuserStandartAdds as $title => $items) {
            $text .= '<h3>' . $title . ':</h3>';
            foreach ($items as $key => $item) {
                if ($item['type'] == 'bool') {
                    $data[$key] = $_POST[$key] == 1 ? '1' : '0';
                    $_POST[$key] = $_POST[$key] == 1 ? 'Да' : 'Нет';
                } else {
                    if ($item['main'] != 1) {
                        $data[$key] = $_POST[$key];
                    }
                }
                $text .= '<b>' . $item['name'] . ':</b> ' . $_POST[$key] . '<br />';
            }
        }
        $pass = Funcs::generate_password(8);
        $address = array();
        foreach (OneSSA::$iuserStandartAdds['1.2 Фактический адрес'] as $key => $item) {
            if ($_POST[$key] != '') {
                $address[] = $_POST[$key];
            }
        }
        if (count($address) > 0) {
            $address = implode(', ', $address);
        } else {
            $address = '';
        }
        $sql = '
			INSERT INTO {{iusers}}
			SET name=\'' . $_POST['name'] . '\',
				phone=\'' . $_POST['phone'] . '\',
				email=\'' . $_POST['email'] . '\',
				pass=\'' . md5($pass) . '\',
				address=\'' . $address . '\',
				visible=0,
				cdate=NOW()
		';
        $id = DB::exec($sql);
        $text .= '<b>Пароль:</b> ' . $pass . '<br />';
        $text .= '<b>Пользователь:</b> ' . $id . '<br />';
        foreach ($data as $key => $item) {
            $sql = '
				INSERT INTO {{iusers_adds}}
				SET iuser='******',
					name=\'' . $key . '\',
					string_value=\'' . $_POST[$key] . '\'
			';
            DB::exec($sql);
        }
        $mail = new Email();
        $mail->mailTo(Funcs::$conf['email']['anketa']);
        $mail->Subject('Новая анкета партнера на сайте ' . str_replace("www.", "", $_SERVER["HTTP_HOST"]));
        View::$layout = 'empty';
        $text = View::getRender('email/anketa', array('text' => $text));
        $mail->Text($text);
        $mail->Send();
    }
Exemplo n.º 15
0
    public static function addNewOrder($dealerId)
    {
        DB::escapePost();
        $sum = 0;
        foreach ($_POST['items'] as $key => $item) {
            $sum += $_POST['prices'][$key] * $item;
        }
        $price = $sum - $sum / 100 * $_SESSION['dealer']['sale'];
        //$sql='SELECT * FROM {{dealers_consignee}} WHERE id='.$_POST['cons'].'';
        $sql = '
			INSERT INTO {{dealers_orders}}
			SET
				status=1,
				price=\'' . $price . '\',
				sale=\'' . $sum / 100 * $_SESSION['dealer']['sale'] . '\',
				saleperc=\'' . $_SESSION['dealer']['sale'] . '\',
				cons=\'' . $_POST['cons'] . '\',
				comment=\'' . $_POST['comment'] . '\',
				dealer=\'' . $dealerId . '\',
				preorder=\'' . $_POST['preorder'] . '\',
				cdate=NOW()
		';
        $orderId = DB::exec($sql);
        $dealer = DealersMain::getOne($dealerId);
        self::addItemsToOrder($_POST['items'], $orderId, $_POST['prices']);
        self::addHistory($orderId, '', 1);
        $text = 'Новый заказ № ' . str_repeat('0', 6 - strlen($orderId)) . $orderId . ' поступил от дилера ' . $_SESSION['dealer']['company'] . '';
        $mail = new Email();
        $mail->Text($text);
        $mail->Subject('Поступил заказ от дилера с сайта www.' . str_replace('www.', '', $_SERVER["HTTP_HOST"]));
        $mail->From('robot@' . str_replace('www.', '', $_SERVER["HTTP_HOST"]));
        $mail->mailTo(Funcs::$conf['email']['dealers']);
        $mail->Send();
    }
Exemplo n.º 16
0
    public function setForgot()
    {
        foreach ($_POST as $key => $value) {
            $_POST[$key] = htmlspecialchars(trim($value));
        }
        $sql = '
			SELECT * FROM {{iusers}} WHERE email=\'' . $_POST['email'] . '\'
		';
        $return = DB::getRow($sql);
        if ($return) {
            $pass = $this->generate_password(8);
            $sql = '
				UPDATE {{iusers}}
				SET pass=MD5(\'' . $pass . '\')
				WHERE email=\'' . $_POST['email'] . '\'
			';
            DB::exec($sql);
            $text = '
				Здравствуйте, ' . $return["name"] . '.<br />
				Ваш новый пароль ' . $pass . '.<br />
				Сменить пароль Вы можете в личном кабинете. 
			';
            $mail = new Email();
            $mail->To($_POST['email']);
            $mail->Subject('Восстановление пароля на сайте www.' . str_replace("www.", "", $_SERVER["HTTP_HOST"]));
            $mail->Text($text);
            $mail->Send();
        }
    }
Exemplo n.º 17
0
    public function setReport($id)
    {
        foreach ($_POST as $key => $value) {
            $_POST[$key] = htmlspecialchars(trim(strip_tags($value)));
        }
        $cbid = 0;
        $sql = '
			INSERT INTO {{reports}}
			SET 
				`tree`=' . $id . ',
				`name`=\'' . $_POST['name'] . '\',
				`email`=\'' . $_POST['email'] . '\',
				`report`=\'' . $_POST['report'] . '\',
				`stars`=' . $_POST['stars'] . ',
				`create_date`=NOW()
		';
        DB::exec($sql);
        $sql = 'SELECT * FROM {{reports}} WHERE tree=' . $id . '';
        $list = DB::getAll($sql);
        $count = count($list);
        $sum = 0;
        foreach ($list as $item) {
            $sum += $item['stars'];
        }
        $rating = round($sum / $count);
        $sql = '
			UPDATE {{catalog}}
			SET rating=' . $rating . '
			WHERE tree=' . $id . '
		';
        DB::exec($sql);
        $path = Tree::getPathToTree($id);
        $text = View::getRenderEmpty('email/adminreport', array('path' => $path));
        $mail = new Email();
        $mail->Text($text);
        $mail->Subject('Оставлен отзыв на сайте www.' . str_replace('www.', '', $_SERVER["HTTP_HOST"]));
        $mail->From('robot@' . str_replace('www.', '', $_SERVER["HTTP_HOST"]));
        $mail->mailTo(Funcs::$conf['email']['report']);
        $mail->Send();
    }