Exemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
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.º 6
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.º 7
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();
    }
Exemplo n.º 8
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();
    }