===========================================================*/ $recipient = Config::get('mail/receive_orders_to'); $subject = 'Заказ'; $body = 'Адрес: <b>' . Input::escape(Input::get('address')) . '</b><br>'; $body .= 'Ф.И.О.: <b>' . Input::escape(Input::get('customer_name')) . '</b><br>'; if (empty(Input::get('quantity')) === false) { $body .= 'Количество экземпляров: <b>' . Input::get('quantity') . '</b><br>'; } if (empty(Input::get('info')) === false) { $body .= 'Дополнительная информация: <b>' . Input::escape(Input::get('info')) . '</b><br>'; } /** * compose a section of email conserning book info * (desired fields can be configured by website administrator through config.ini) **/ $desiredMailData = Config::csvToArray(Config::get('mail/product_info')); $mailData = ''; foreach ($desiredMailData as $field) { $mailData .= $field . ': <b>' . $book->{$field} . '</b><br>'; } $body .= '<br>Информация о товаре:<br> ' . $mailData; // send it $mailer->mail($recipient, $subject, $body); if ($errorHandler->hasErrors() === true) { Session::flash('home', 'Произошла ошибка при попытке отправить письмо с информацией о заказе.'); Redirect::to('index.php'); } else { Session::flash('home', 'Спасибо за заказ.'); Redirect::to('index.php'); } }
* warnings and to make overall experience a bit more user friendly **/ $postMaxSize = Info::convertToBytes(ini_get('post_max_size')); if (isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH'] > $postMaxSize) { Session::flash('home', 'Вы пытаетесь загрузить слишком большой файл.'); Redirect::to(); } $errorHandler = new ErrorHandler(); if (Input::exists()) { if (Token::check(Input::get('token'))) { /*================================== = Validation = ==================================*/ if (empty($_FILES) === false) { $fileValidator = new ValidateFile($errorHandler); $fileValidator->check($_FILES, ['cover' => ['sizeAllowed' => Config::get('upload_book_cover/max_file_size'), 'typeAllowed' => Config::csvToArray(Config::get('upload_book_cover/mime_types')), 'extensionAllowed' => Config::csvToArray(Config::get('upload_book_cover/extensions')), 'isImage' => true]]); } $validator = new Validate($errorHandler); $validator->check($_POST, ['author' => ['required' => true, 'minLength' => 3, 'partMinLength' => [3, ','], 'maxLength' => 240, 'partMaxLength' => [60, ',']], 'title' => ['required' => true, 'minLength' => 3, 'maxLength' => 80], 'title_secondary' => ['minLength' => 3, 'maxLength' => 80], 'genre' => ['required' => true, 'minLength' => 4, 'partMinLength' => [4, ','], 'maxLength' => 120, 'partMaxLength' => [30, ',']], 'publisher' => ['minLength' => 3, 'partMinLength' => [3, ','], 'maxLength' => 100, 'partMaxLength' => [50, ',']], 'year' => ['required' => true, 'digit' => true, 'exactLength' => 4], 'isbn' => ['required' => true, 'minLength' => 10, 'partMinLength' => [10, ','], 'maxLength' => 36, 'partMaxLength' => [17, ',']], 'pages' => ['digit' => true, 'minLength' => 2, 'maxLength' => 4], 'dimensions' => ['minLength' => 5, 'maxLength' => 10], 'price' => ['price' => true, 'minLength' => 2, 'maxLength' => 7]]); /*===================================== = Book creation = =====================================*/ if ($errorHandler->hasErrors() === false) { $bookManager = new BookManage(); $data = ['author' => Input::get('author'), 'title' => Input::get('title'), 'title_secondary' => Input::get('title_secondary'), 'description' => Input::get('description'), 'genre' => strtolower(Input::get('genre')), 'publisher' => Input::get('publisher'), 'year' => Input::get('year'), 'isbn' => Input::get('isbn'), 'pages' => Input::get('pages'), 'dimensions' => Input::get('dimensions'), 'price' => Input::get('price')]; $bookManager->update($data, $book->id); $message = 'Информация о книге(' . $book->title . ', ' . $book->id . ') была отредактирована.'; Log::getInstance()->message($message, 'book_manage'); if (empty($_FILES) === false) { $upload = new UploadBookCover($fileValidator, $book->id); $uploaded = $upload->to(Config::get('upload_book_cover/default_folder'));