Example #1
0
<?php

/**
 * sendMail.php
 *
 * Отправитель писем, работает по CRON
 *
 * @author      Pereskokov Yurii
 * @copyright   2016 Pereskokov Yurii
 * @license     Mediasite LLC
 * @link        http://www.mediasite.ru/
 */
require_once dirname(__FILE__) . '/../console.php';
// Достать письма
$query = new MSTable('{mails}');
$query->setFields(['*']);
$mails = $query->getItems();
// Отправить письма
foreach ($mails as $mailItem) {
    $mail = new SendMail();
    $mail->init();
    $mail->setEncoding("utf8");
    $mail->setEncType("base64");
    $mail->setSubject($mailItem['subject']);
    $mail->setMessage($mailItem['text']);
    $mail->setFrom($mailItem['from'], "apstroy");
    $mail->setFiles([$mailItem['files']]);
    $emails = MSCore::db()->getCol('SELECT `mail` FROM `' . PRFX . 'mailer`');
    foreach ($emails as $email) {
        $mail->setTo($email);
        $mail->send();
Example #2
0
 /**
  * Возвращает элементы в корзине указанного типа
  *
  * @param string $type тип товара
  *
  * @return array|null
  */
 public function getItemsType($type)
 {
     if (!$type) {
         return null;
     }
     if ($type == 'catalog') {
         $query = new MSTable('' . $this->_cartTableName . ' cart');
         $query->setFields(['cart.`amount`', 'cart.`cost`', 'cart.`type`', 'catalog.*', 'articles.`code` as path']);
         $query->setJoin('' . $this->_itemsTableName . ' catalog', 'INNER', 'cart.`item_id` = catalog.`id`', 'idJoin');
         $query->setJoin('{catalog_rent_articles} articles', 'INNER', 'catalog.`parent` = articles.`id`', 'pathJoin');
         $query->setFilter('cart.`type`="catalog"');
         $query->setFilter('cart.`user_id`="' . $this->_userId . '"');
     } elseif ($type == 'lent') {
         $query = new MSTable('' . $this->_cartTableName . ' cart');
         $query->setFields(['cart.`amount`', 'cart.`cost`', 'catalog.*']);
         $query->setJoin('' . $this->_itemsTableName2 . ' catalog', 'INNER', 'cart.`item_id` = catalog.`id`', 'pathJoin');
         $query->setFilter('cart.`type`="lent"');
         $query->setFilter('cart.`user_id`="' . $this->_userId . '"');
     } else {
         return null;
     }
     return $query->getItems();
 }
Example #3
0
<?php

require_once 'console.php';
// Перенос для каталога
$query = new MSTable('{catalog_items}');
$query->setFields(['*']);
$items = $query->getItems();
$imagies_out = [];
$galleries = [];
foreach ($items as $key => $item) {
    $r = unserialize($item['image_out']);
    $t = unserialize($item['gallery']);
    if (isset($r[0]['path']['original'])) {
        $imagies_out[$key] = $r[0]['path']['original'];
    }
    if (isset($t[0]['path']['original'])) {
        $galleries[$key] = $t[0]['path']['original'];
    }
}
//$conf = array(160, 110, true,
//    'watermark' => array(
//        'src' => DOC_ROOT . '/DESIGN/SITE/images/watermark100x100.png',
//        'offset_x' => 30,
//        'offset_y' => 0
//    ));
//
//foreach ($items as $key => $item) {
//
//    if (isset($imagies_out[$key])) {
//        $result = MSFiles::makeImageThumb(DOC_ROOT . $imagies_out[$key], $conf);
//
Example #4
0
 public function orderAction()
 {
     if (isset($_POST)) {
         $data = [];
         try {
             if (!isset($_POST['name'])) {
                 throw new Exception('name');
             }
             $data['name'] = htmlspecialchars($_POST['name']);
             if (!isset($_POST['phone'])) {
                 throw new Exception('phone');
             }
             $data['phone'] = htmlspecialchars($_POST['phone']);
             if (!isset($_POST['comment'])) {
                 throw new Exception('comment');
             }
             $data['comment'] = htmlspecialchars($_POST['comment']);
             if (!isset($_POST['path'])) {
                 throw new Exception('path');
             }
             $data['path'] = htmlspecialchars($_POST['path']);
             if (!isset($_POST['address'])) {
                 throw new Exception('honeyPot');
             }
             $honeyPot = htmlspecialchars($_POST['address']);
             $data['honeyPot'] = $honeyPot;
             // Проверка на бота
             if ($honeyPot != '') {
                 $this->errorAction(1001, 'Custom system error', ['honeyPot' => 'honeyPot']);
             }
             // Валидация
             $v = new Validator(['name' => $data['name'], 'phone' => $data['phone'], 'comment' => $data['comment']]);
             $v->rule('required', 'comment')->message('comment!');
             $v->rule('required', 'name')->message('name!');
             $v->rule('regex', 'name', '/^([a-zа-я\\s\\-]+)$/iu')->message('name!!');
             $v->rule('required', 'phone')->message('phone!');
             $v->rule('phone', 'phone')->message('phone!!');
             if ($v->validate()) {
                 if (!empty($data['path'])) {
                     $query = new MSTable('{www}');
                     $query->setFields(['title_page']);
                     $query->setFilter('path_id = ' . $data['path']);
                     $data['path'] = $query->getItem();
                     $data['path'] = $data['path']['title_page'];
                 }
                 // Проверяем есть ли файл в наличии
                 $type = 'modal';
                 if (isset($_SESSION['uploaded'][$type]['directory'])) {
                     $path = $_SESSION['uploaded'][$type]['directory'];
                     unset($_SESSION['uploaded'][$type]['directory']);
                 }
                 $title = "Заявка с сайта " . DOMAIN;
                 $msg = template('email/order', $data);
                 if (isset($path)) {
                     $files = str_replace('\\', '/', $path);
                     $from = "noreply@" . DOMAIN;
                     // Помещаем в базу
                     MSCore::db()->insert(PRFX . 'mails', ['subject' => $title, 'files' => $files, 'text' => $msg, 'from' => $from]);
                     $msg = template('email/order', $data + ['files' => $files]);
                 } else {
                     $mail = new SendMail();
                     $mail->init();
                     $mail->setEncoding("utf8");
                     $mail->setEncType("base64");
                     $mail->setSubject($title);
                     $mail->setMessage($msg);
                     $mail->setFrom("noreply@" . DOMAIN, "apstroy");
                     $emails = MSCore::db()->getCol('SELECT `mail` FROM `' . PRFX . 'mailer`');
                     foreach ($emails as $email) {
                         $mail->setTo($email);
                         $mail->send();
                     }
                 }
                 $sql = "\n                        INSERT INTO mp_list(`title`,`text`)\n                        VALUES('" . $title . "','" . $msg . "');\n                    ";
                 MSCore::db()->execute($sql);
                 $this->addData(['succes' => 'Ok']);
                 $this->successAction();
             } else {
                 $errors = $v->errors();
                 foreach ($errors as $_name => $_error) {
                     if (is_array($_error)) {
                         $errors[$_name] = reset($_error);
                     }
                 }
                 $this->errorAction(1001, 'Custom system error', ['data' => $data, 'error' => $errors]);
             }
         } catch (Exception $exception) {
             $error = $exception->getMessage();
             $this->errorAction(1001, 'Custom system error', ['error' => $error, 'postArgument' => 'noPostArgument']);
         }
     }
 }