/** * @param int $limit * @param int $offset * * @return array */ public function findLimit($limit, $offset = 0) { return MSCore::db()->getAll(' SELECT * FROM ' . PRFX . 'news LIMIT ' . $offset . ',' . $limit); }
public function callAction() { $data = array_intersect_key($_POST, array_flip(array('phone', 'fio', 'formid'))); // Validate data $validator = new Validator($data); $validator->rule('empty', 'formid')->message('Некорректный идентификатор формы'); $validator->rule('required', 'phone')->message('Поле не заполнено'); $validator->rule('phone', 'phone')->message('Некорректный номер телефона'); if ($validator->validate()) { if (empty($data['fio'])) { $data['fio'] = 'Личный номер'; } unset($data['formid']); // Send to subscribers $mailers = MSCore::db()->getCol('SELECT mail FROM `' . PRFX . 'mailer` WHERE type = ' . self::TARGET_CALL . ' OR type = 0'); $data['date'] = date('Y-m-d H:i:s'); MSCore::db()->insert(PRFX . 'order_call', $data); if (is_array($mailers) && !empty($mailers)) { // Send email $sendMail = new SendMail(); $sendMail->init(); $sendMail->setSubject('Обратный звонок на ' . DOMAIN); $sendMail->setFrom('noreply@' . DOMAIN, 'Первая кровельная'); // Prepare body $message = template('email/call', array('data' => $data)); $sendMail->setMessage($message); foreach ($mailers as $_email) { $sendMail->setTo($_email); $sendMail->send(); } unset($sendMail); } $content = template('ajax/success/call'); $this->addData(array('content' => $content)); } else { $errors = $validator->errors(); foreach ($errors as $_name => $_error) { if (is_array($_error)) { $errors[$_name] = reset($_error); } } $this->errorAction(1001, 'Некорректно заполненные поля', array('errors' => $errors)); } }
<?php $CONFIG = MSCore::modules()->getModuleConfig($module['module_name']); $filename = str_Replace(PRFX, '', isset($CONFIG['table']['items']['db_name']) ? $CONFIG['table']['items']['db_name'] : $module['module_name']); $table = PRFX . $filename; MSCore::db()->execute('DROP TABLE `' . $table . '`', false);
* @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(); } } // Удалить письма и файлы foreach ($mails as $mailItem) { MSCore::db()->execute("DELETE FROM `" . PRFX . 'mails' . "` WHERE `id` = " . $mailItem['id']); if (file_exists($mailItem['files'])) { unlink($mailItem['files']); } }
foreach ($items as $key => $item) { if (isset($galleries[$key])) { $result = MSFiles::makeImageThumb(DOC_ROOT . $galleries[$key], $conf); $result2 = MSFiles::makeImageThumb(DOC_ROOT . $galleries[$key], $conf2); $result3 = MSFiles::makeImageThumb(DOC_ROOT . $galleries[$key], $conf3); $r = unserialize($item['gallery']); $r[0]['path']['min'] = $result; $r[0]['path']['first'] = $result2; $r[0]['path']['win'] = $result3; $r = serialize($r); $items[$key]['gallery'] = $r; } } foreach ($items as $key => $item) { $sql = 'UPDATE ' . PRFX . "catalog_items SET `gallery`='" . $item['gallery'] . "' WHERE `id`=" . $item['id']; MSCore::db()->execute($sql); } //$count = 0; // //foreach ($items as $key =>$item) { // // if (isset($imagies_out[$key]) && isset($galleries[$key])) { // ++$count; // } // // $r = unserialize($item['image_out']); // $t = unserialize($item['gallery']); // // if (isset($r[0]['path']['original'])) { // $imagies_out[$key] = $r[0]['path']['original']; // }
/** * Возвращает id всех элементов в корзине, указанного типа в корзине * * @return array|null */ public function getItemsId($type) { if (!$type) { return null; } $ids = MSCore::db()->getAll('SELECT cart.item_id FROM `' . $this->_cartTableName . '` AS cart ' . 'WHERE cart.user_id = "' . $this->_userId . '"' . ' AND `type`="' . $type . '"'); $newIds = []; foreach ($ids as $key => $id) { $newIds[$id['item_id']] = $key; } return $newIds; }
* TODO: Сейчас на все ошибки одна причина, исправить :) */ } } else { $vars['CONFIG'] = $CONFIG; $vars[$key_field] = (int) $new_item_id; $vars['path_id'] = (int) $path_id; $vars['page'] = $page; $vars['output_id'] = $output_id; $vars['_FORM_'] = MSCore::forms()->make($CONFIG['tables']['items']['config']); echo template('moduleTape/add', $vars); } /* ACTION */ die; break; case 'delete': $path_id = isset(MSCore::urls()->vars[2]) ? (int) MSCore::urls()->vars[2] : 0; $page = isset(MSCore::urls()->vars[3]) ? (int) MSCore::urls()->vars[3] : 0; $id = isset(MSCore::urls()->vars[4]) ? (int) MSCore::urls()->vars[4] : 0; /* ACTION */ if ($id > 0) { MSCore::db()->execute("DELETE FROM `" . PRFX . $table_name . "` WHERE `" . $key_field . "`=" . $id); $vars = $Tape->generateVars(); $_RESULT = array('content' => template('moduleTape/fast', $vars)); die(json_encode($_RESULT)); } /* ACTION */ exit; break; } die;
<?php $CONFIG = MSCore::modules()->getModuleConfig($module['module_name']); MSCore::db()->moduleType = 'lenta'; MSCore::db()->createModuleTable($CONFIG['tables']['items']); unset($CONFIG); unset($module_name);
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']); } } }
public function callAction() { 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['email'])) { throw new Exception('email'); } $data['email'] = htmlspecialchars($_POST['email']); if (!isset($_POST['comment'])) { throw new Exception('comment'); } $data['comment'] = htmlspecialchars($_POST['comment']); 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'], 'email' => $data['email'], '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!!'); $v->rule('required', 'email')->message('email!'); $v->rule('email', 'email')->message('email!!'); if ($v->validate()) { $msg = template('email/call', $data); $title = "Вопрос с сайта " . DOMAIN; $mail = new SendMail(); $mail->init(); $mail->setEncoding("utf8"); $mail->setEncType("base64"); $mail->setSubject($title); $mail->setMessage($msg); $mail->setFrom("noreply@" . DOMAIN, "eko"); $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']); } } }