/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $insert = $request->all(); $safeName = false; //upload image if ($file = Input::file('image')) { $fileName = $file->getClientOriginalName(); $extension = $file->getClientOriginalExtension() ?: 'png'; $folderName = '/uploads/'; $destinationPath = Config::get('app.path') . $folderName; $safeName = time() . "_" . str_random(10) . '.' . $extension; $file->move($destinationPath, $safeName); $insert['image'] = $safeName ? $folderName . $safeName : ''; } if (isset(Ad::$boolean)) { foreach (ad::$boolean as $field) { if (isset($insert[$field]) && $insert[$field] == "on") { $insert[$field] = 1; } } } ad::create($insert); return redirect('admin/ads')->with('success', Lang::get('message.success.create')); }
<?php $root = $_SERVER['DOCUMENT_ROOT']; require_once $root . "/lib/include.php"; $db = db::getInstance(); $form = new ad(); $name = htmlspecialchars(strip_tags($_POST['name'])); if (!empty($name)) { $show = $_POST['vis'] ? 1 : 0; $new = $_POST['new'] ? 1 : 0; $bestseller = $_POST['bestseller'] ? 1 : 0; $presence = $_POST['presence'] ? 1 : 0; $article = htmlspecialchars(strip_tags($_POST['article'])); $event = $_POST['event'] ? 1 : 0; $dtNow = $dtClass->dtInDB(); $id = htmlspecialchars(strip_tags($_POST['id'])); $price = (double) strip_tags($_POST['price']); $price = number_format($price, 2, '.', ''); $priority = $_POST['priority']; $weight = htmlspecialchars(strip_tags($_POST['weight'])); $description = $form->replaceToInsert($_POST['description']); if ($_POST['action'] == 'edit') { $db->query("UPDATE dial SET \n vis = '" . $show . "',\n name = '" . $name . "',\n idUserUpdate = '" . $_SESSION['userID'] . "', \n dtUpdate = '" . $dtNow . "',\n description = '" . $description . "',\n price = '" . $price . "',\n priority = '" . $priority . "',weight='" . $weight . "',\n weight_val='" . $_POST['weight_val'] . "',\n new=" . $new . ",bestseller=" . $bestseller . ",event=" . $event . ",article='" . $article . "',\n presence=" . $presence . "\n WHERE id = " . $id); } if ($_POST['action'] == 'add') { $db->query("INSERT INTO dial (vis,name,idUserCreate,dtCreate,description,price,priority,weight,weight_val,new,bestseller,event,article,presence) VALUES (" . $show . ", '" . $name . "', '" . $_SESSION['userID'] . "', '" . $dtNow . "', '" . $description . "', '" . $price . "', " . $priority . ",'" . $weight . "','" . $_POST['weight_val'] . "'," . $new . "," . $bestseller . "," . $event . ",'" . $article . "'," . $presence . ")"); $id = $db->last(); } //удалим вес состав $sql_del_sostav = "DELETE FROM sostav WHERE id_dial=" . $id; $db->query($sql_del_sostav);
function editAd($db, ad $ad) { // функция редактирования объявления $db->query('UPDATE ads SET ?a WHERE id=?d', $ad->getArray(), $ad->getId_r()); }
<?php if (!empty($_POST)) { $root = $_SERVER['DOCUMENT_ROOT']; require_once $root . "/lib/include.php"; $db = db::getInstance(); $form = new ad(); $db->query("SELECT * FROM sSubgroups WHERE idGroup = {$_POST['idGroup']} ORDER BY name ASC"); $count = $db->getCount(); if ($count > 0) { $select[0] = 'Выберите подгруппу'; $subgroups = $db->getArray(); foreach ($subgroups as $subgroup) { $select[$subgroup['id']] = $subgroup['name']; } echo $form->select('sSubgroups', 'sSubgroups', '', 'width:350px;float:left;', $select); } } ?>
<?php $root = $_SERVER['DOCUMENT_ROOT']; require_once $root . "/lib/include.php"; $db = db::getInstance(); $form = new ad(); $search = new Search('products', 'tags', 'popular', 'dtCreate DESC', 9999, $and); echo '<fieldset>'; echo '<a href="/admin/dialEditor/add">+ ДОБАВИТЬ НАБОР</a>'; $db->query("SELECT * FROM dial WHERE archive=0 ORDER BY dtCreate DESC LIMIT 9999"); $count = $db->getCount(); $products = $db->getArray(); $ifSearch = null; if ($count > 0) { echo $ifSearch ? $ifSearch : ''; foreach ($products as $i => $product) { echo '<table width="100%" id="id~' . $product['id'] . '" style="margin-bottom:4px">'; echo '<tr>'; echo '<td width="50px" align="center" rowspan="10">'; echo $i + 1; echo '</td>'; echo '<td width="160" rowspan="10" style="text-align:center;vertical-align:middle">'; $sql_select_photo = "SELECT * FROM dialphotos WHERE temp=1 AND id_dial=" . $product['id'] . " ORDER BY dtcreate DESC LIMIT 1"; $db->query($sql_select_photo); if ($db->getCount() > 0) { $arr_photo = $db->getArray(); echo "<img style='max-height:124px;max-width:160px' src='/img/dial/1000/" . $arr_photo[0]['md5_mictotime'] . "_" . $arr_photo[0]['id'] . ".jpg' />"; } echo '</td>'; echo '<td colspan="2">'; echo ' <a href="/admin/dialEditor/edit/' . $product['id'] . '"><img src="/img/admin/e.png" title="Редактировать"/></a>';
<?php $root = $_SERVER['DOCUMENT_ROOT']; require_once $root . "/lib/include.php"; $db = db::getInstance(); $form = new ad(); $err = ''; if (!empty($_POST['nameSearch'])) { $show = $_POST['show'] ? 1 : 0; $dtNow = $dtClass->dtInDB(); $id = htmlspecialchars(strip_tags($_POST['id'])); $article = htmlspecialchars(strip_tags($_POST['article'])); //проверим артикл if (!empty($article)) { $sql_s = "SELECT article FROM products WHERE article='" . $article . "' AND id<>" . $id; $db->query($sql_s); if ($db->getCount() > 0) { $err .= "такой артикул уже существует"; } } $name = htmlspecialchars(strip_tags($_POST['name'])); $category = htmlspecialchars(strip_tags($_POST['category'])); $nameSearch = htmlspecialchars(strip_tags($_POST['nameSearch'])); $id1C = htmlspecialchars(strip_tags($_POST['id1C'])); $idSection = htmlspecialchars(strip_tags($_POST['sSections'])); $idGroup = htmlspecialchars(strip_tags($_POST['sgroups'])); $idSubgroup = htmlspecialchars(strip_tags($_POST['ssubgroups'])); $composition = htmlspecialchars(strip_tags($_POST['composition'])); $safe = htmlspecialchars(strip_tags($_POST['safe'])); $shell = htmlspecialchars(strip_tags($_POST['shell'])); $pack = htmlspecialchars(strip_tags($_POST['pack']));
<?php defined('IN_DESTOON') or exit('Access Denied'); require DT_ROOT . '/module/' . $module . '/common.inc.php'; $MOD['ad_enable'] or dheader(DT_PATH); $TYPE = $L['ad_type']; require MD_ROOT . '/ad.class.php'; $do = new ad(); $currency = $MOD['ad_currency']; $unit = $currency == 'money' ? $DT['money_unit'] : $DT['credit_unit']; $typeid = isset($typeid) ? intval($typeid) : 0; $pid = isset($pid) ? intval($pid) : 0; $aid = isset($aid) ? intval($aid) : 0; if ($action == 'buy' && $pid) { dheader($MODULE[2]['linkurl'] . 'ad.php?action=add&pid=' . $pid); } else { if ($pid || $aid) { $MOD['ad_view'] or message($L['preview_close']); $filename = ''; $ad_moduleid = 0; if ($pid) { $do->pid = $pid; $p = $do->get_one_place(); $p or message($L['not_ad_place']); $head_title = lang($L['view_ad_place'], array($p['name'])); $typeid = $p['typeid']; } else { if ($aid) { $do->aid = $aid; $a = $do->get_one(); $a or message($L['not_ad']);
<?php defined('DT_ADMIN') or exit('Access Denied'); $TYPE = $L['ad_type']; $AREA or $AREA = cache_read('area.php'); require MD_ROOT . '/ad.class.php'; isset($pid) or $pid = 0; isset($aid) or $aid = 0; $menus = array(array('添加广告位', '?moduleid=' . $moduleid . '&file=' . $file . '&action=add_place'), array('广告位管理', '?moduleid=' . $moduleid . '&file=' . $file), array('广告管理', 'javascript:Dwidget(\'?moduleid=' . $moduleid . '&file=' . $file . '&action=list\', \'广告管理\');'), array('广告审核', 'javascript:Dwidget(\'?moduleid=' . $moduleid . '&file=' . $file . '&action=list&job=check\', \'广告审核\');'), array('更新广告', '?moduleid=' . $moduleid . '&file=' . $file . '&action=html'), array('模块首页', $EXT[$file . '_url'], ' target="_blank"'), array('模块设置', '?moduleid=' . $moduleid . '&file=setting#' . $file)); $menusad = array(array('添加广告', '?moduleid=' . $moduleid . '&file=' . $file . '&pid=' . $pid . '&action=add'), array('广告管理', '?moduleid=' . $moduleid . '&file=' . $file . '&pid=' . $pid . '&action=list'), array('广告审核', '?moduleid=' . $moduleid . '&file=' . $file . '&pid=' . $pid . '&action=list&job=check')); if ($_catids || $_areaids) { require DT_ROOT . '/admin/admin_check.inc.php'; } $do = new ad(); $do->pid = $pid; $do->aid = $aid; $currency = $MOD['ad_currency']; $unit = $currency == 'money' ? $DT['money_unit'] : $DT['credit_unit']; $this_forward = '?moduleid=' . $moduleid . '&file=' . $file . '&action=list&pid=' . $pid . '&page=' . $page; $this_place_forward = '?moduleid=' . $moduleid . '&file=' . $file . '&page=' . $page; switch ($action) { case 'add': $pid or msg('未指定广告位'); if ($submit) { if ($do->is_ad($ad)) { $do->add($ad); $aid = $do->aid; if ($ad['typeid'] == 6) { $MOD['linkurl'] = $MODULE[$ad['key_moduleid']]['linkurl']; } tohtml('ad', $module);