function viewAction() { $fc = FrontController::getInstance(); $model = new FrontModel(); $id = filter_var($fc->getParams()['id'], FILTER_SANITIZE_NUMBER_INT); if (!$id) { header('Location: /admin/notFound'); exit; } $productModel = new ProductTableModel(); $productModel->setId($id); $productModel->setTable('product'); $ImageModel = new ImageTableModel(); $ImageModel->setId($id); $ImageModel->setTable('image'); $images = $ImageModel->readRecordsById('product_id', '*', 'ORDER BY main'); $product = $productModel->readRecordsById()[0]; $categoryModel = new CategoryTableModel(); $product['category'] = $categoryModel->getCategoryById($product['category_id'])['category_name']; $product['subCategory'] = $categoryModel->getSubCategoryById($product['subcategory_id'])['subcategory_name']; if (!$product) { header('Location: /admin/notFound'); exit; } $recProducts = (new IndexWidgets())->recAndPopProductsWidget('recommended'); $model->setData(['product' => $product, 'images' => $images, 'recommendedProducts' => Generator::recommendedProducts($recProducts)]); $output = $model->render('../views/product/product.php', 'withoutSlider'); $fc->setPage($output); }
public static function getSliderWidget() { $model = new SliderTableModel(); $model->setTable('slider'); $model->readAllRecords(); $slides = $model->getAllRecords(); return Generator::sliderGenerator($slides); }
function indexAction() { $fc = FrontController::getInstance(); $model = new FrontModel(); $popProducts = (new IndexWidgets())->recAndPopProductsWidget('popular', 6); $recProducts = (new IndexWidgets())->recAndPopProductsWidget('recommended'); $model->setData(['slides' => IndexWidgets::getSliderWidget(), 'currentCategory' => (new IndexWidgets())->currentCategoryWidget(Helper::getSiteConfig()->currentCategoryWidget), 'popularProducts' => Generator::popularProducts($popProducts, 6), 'recommendedProducts' => Generator::recommendedProducts($recProducts)]); $output = $model->render('../views/index.php', 'main'); $fc->setPage($output); }
function addAllImages() { if (!empty($this->mainImage)) { $mImage = str_replace('//', '/', $this->path . 'main_' . Generator::strToLat($this->mainImage)); $this->addImage($mImage, TRUE); Helper::moveFile('mainimage', TRUE, $this->productId); } if (!empty($this->images[0]) && is_array($this->images)) { foreach ($this->images as $img) { $image = str_replace('//', '/', $this->path . Generator::strToLat($img)); $this->addImage($image, FALSE); } Helper::moveFile('images', FALSE, $this->productId); } }
public function updateAvatar() { if (empty($this->id)) { $this->id = $this->user['id']; } $this->path = $this->path . $this->id; try { if ($this->photo) { $st = $this->db->prepare("UPDATE {$this->table} SET `photo` = ? WHERE `id` = ?"); $st->execute([$this->path . '/avatar/' . Generator::strToLat($this->photo), intval($this->id)]); } } catch (Exception $ex) { $ex->getMessage(); } }
/** * Send recover email. * * @param RecoverPasswordRequest $request * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response */ public function recover(RecoverPasswordRequest $request) { $response = new AjaxResponse(); $user = User::where('email', $request->email)->first(); $response->setSuccessMessage(trans('recover.email_sent')); if (!$user) { // Email not found return response($response->get()); } $user->link = url('/recover/' . urlencode($user->id) . '/' . Generator::recoverCode($user->id)); // Send recover email Mail::send('emails.reset-password', ['user' => $user], function ($m) use($user) { $m->from('*****@*****.**', 'Nova'); $m->to($user->email, $user->first_name)->subject('Reset password'); }); // todo delete recover code after 0.5 hours return response($response->get()); }
public static function moveFile($inputName, $isMain, $id = NULL, $fileType = 'img') { if (!$id) { $id = date('d_m_Y'); } if ($fileType === 'img' || $fileType === 'image') { $path = Path::IMG_UPLOAD_DIR . $id; } elseif ($fileType === 'userimg') { $path = Path::USERIMG_UPLOAD_DIR . $id; } elseif ($fileType === 'slide') { $path = Path::IMG_UPLOAD_DIR_SLIDER . $id; } else { $path = Path::FILE_UPLOAD_DIR . $id; } if (!is_dir($path)) { if (!mkdir($path, 0777, TRUE)) { die('Не удалось создать директорию ' . $path); } } $prefix = $isMain ? 'main_' : ''; if (!empty($_FILES[$inputName]['name'])) { //for multiple if (is_array($_FILES[$inputName]['name'])) { foreach ($_FILES[$inputName]['name'] as $idx => $name) { $uploadFile = $path . '/' . $prefix . Generator::strToLat($name); copy($_FILES[$inputName]['tmp_name'][$idx], $uploadFile); } } else { //for one file $fileName = Generator::strToLat($_FILES[$inputName]['name']); $uploadFile = $path . '/' . $prefix . $fileName; copy($_FILES[$inputName]['tmp_name'], $uploadFile); } } else { return FALSE; } }
echo $start; ?> - <?php echo $end; ?> </b> из <b><?php echo $num; ?> </b> товаров </div> </div> <div class="col-sm-7"> <div class="dataTables_paginate paging_simple_numbers" id="example2_paginate"> <? if ($limit < $num): ?> <?php echo \app\helpers\Generator::pagination($limit, $page, $opt); ?> <? endif; ?> </div> </div> </div> <div class="features_items"> <h2 class="title text-center">Популярные товары</h2> <?php echo $popularProducts; ?> </div> <div class="recommended_items"> <h2 class="title text-center">Рекомендуем</h2>
<? $end = ($limit * $page < $numUsers) ? $limit * $page : $numUsers ?> На странице: <b><?php echo $start; ?> - <?php echo $end; ?> </b> из <b><?php echo $numUsers; ?> </b> товаров </div> </div> <div class="col-sm-7"> <div class="dataTables_paginate paging_simple_numbers" id="example2_paginate"> <? if ($limit < $numUsers): ?> <?php echo Generator::pagination($limit, $page, $opt); ?> <? endif; ?> </div> </div> </div> </div> </div><!-- /.box-body --> </div><!-- /.box --> </div><!-- /.col --> </div><!-- /.row --> </section> <script type="text/javascript" src="/app/template/backend/js/user/allusers.js"></script>
public function setData($formType = '', $method = 'INPUT_POST') { $this->login = Validate::validateInputVar('username', $method, 'str'); $this->password = Validate::validateInputVar('pass', $method, 'str'); $this->remember = Validate::validateInputVar('remember', $method, 'int'); if ($formType === 'reg' || $formType === 'registration') { $this->fullName = Validate::validateInputVar('fullName', $method, 'str'); $this->email = Validate::validateInputVar('email', $method, 'email'); $this->photo = $_FILES['photo']['name']; $this->validateKey = Generator::generate(10); $this->path = Path::USERIMG_UPLOAD_DIR; $this->dpassword = Validate::validateInputVar('dpass', $method, 'str'); $this->setAddressesAndPhones(); return $this->password === $this->dpassword ? TRUE : FALSE; } }
protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index = null, $content_range = null) { $file = new stdClass(); $file->name = Generator::strToLat($this->get_file_name($name, $type, $index, $content_range)); $file->size = $this->fix_integer_overflow(intval($size)); $file->type = $type; if ($this->validate($uploaded_file, $file, $error, $index)) { $this->handle_form_data($file, $index); $upload_dir = $this->get_upload_path(); if (!is_dir($upload_dir)) { mkdir($upload_dir, $this->options['mkdir_mode'], true); } $file_path = $this->get_upload_path($file->name); $append_file = $content_range && is_file($file_path) && $file->size > $this->get_file_size($file_path); if ($uploaded_file && is_uploaded_file($uploaded_file)) { // multipart/formdata uploads (POST method uploads) if ($append_file) { file_put_contents($file_path, fopen($uploaded_file, 'r'), FILE_APPEND); } else { move_uploaded_file($uploaded_file, $file_path); } } else { // Non-multipart uploads (PUT method support) file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0); } $file_size = $this->get_file_size($file_path, $append_file); if ($file_size === $file->size) { $file->url = $this->get_download_url($file->name); list($img_width, $img_height) = @getimagesize($file_path); if (is_int($img_width)) { $this->handle_image_file($file_path, $file); } } else { $file->size = $file_size; if (!$content_range && $this->options['discard_aborted_uploads']) { unlink($file_path); $file->error = 'abort'; } } $this->set_file_delete_properties($file); } return $file; }
echo $popularProducts; ?> </div><!--features_items--> <div class="category-tab"><!--category-tab--> <div class="col-sm-12"> <ul class="nav nav-tabs"> <? if (!empty($currentCategory) && is_array($currentCategory)): ?> <li class="subCatTitle pull-right"><i class="fa fa-arrow-left"></i> <?php echo $currentCategory[0]['category_name']; ?> </li> <? foreach ($currentCategory as $k => $c): ?> <? $active = ($k === 0) ? 'active' : '' ?> <? $subToLat = Generator::strToLat($c['subcategory_name']) ?> <? $sub = Helper::strSplitter($c['subcategory_name']) ?> <li class="<?php echo $active; ?> "><a href="#<?php echo $subToLat; ?> " class="showSubsProducts" data-toggle="tab" data-id="<?php echo $c['id']; ?> "><?php echo $sub; ?> </a></li> <? endforeach; ?>