/** * 编辑 * */ public function edit() { $flModel = D('FriendLink'); $link_id = intval($_REQUEST['link_id']); if ($this->isPost()) { if (C('TOKEN_ON') && !checkFormToken($_REQUEST)) { die('hack attemp.'); } if (!$_REQUEST['site_name'] || !$_REQUEST['sort_order']) { die('data invalid.'); } $link_type = intval($_REQUEST['link_type']); $flModel = D('FriendLink'); $data = array('site_name' => $_REQUEST['site_name'], 'link_type' => $link_type, 'link_url' => $_REQUEST['link_url'], 'position_id' => intval($_REQUEST['position_id']), 'sort_order' => intval($_REQUEST['sort_order'])); //文字链接 if ($link_type == 1) { $data['link_code'] = $_REQUEST['link_text']; } elseif ($link_type == 2) { if (!$_REQUEST['logo_url'] && (!$_FILES['link_logo'] || $_FILES['link_logo']['size'] == 0 || $_FILES['link_logo']['error'] != 0)) { die('data invalid.'); } if ($_REQUEST['logo_url']) { $data['link_code'] = $_REQUEST['logo_url']; } if ($_FILES['link_logo'] && $_FILES['link_logo']['size'] > 0 && $_FILES['link_logo']['error'] == 0) { $upfile = array(); $upfile = upload_one_file($_FILES['link_logo']); if ($upfile['error']) { $this->error($upfile['error']); } $data['link_code'] = $upfile['file_name']; } } if ($flModel->editLink($link_id, $data)) { $params = null; B('FriendLinks', $params); $this->assign('jumpUrl', '?g=' . GROUP_NAME . '&m=' . MODULE_NAME); $this->success('编辑成功'); } else { $this->error('编辑失败'); } } $fl = $flModel->info($link_id); if (is_file(DOC_ROOT_PATH . FixedUploadedFileUrl($fl['link_code']))) { $fl['link_code'] = 'http://' . $_SERVER['HTTP_HOST'] . FixedUploadedFileUrl($fl['link_code']); } $this->assign('link', $fl); $this->assign('link_position_conf', $this->_link_position_conf); $this->assign('ur_href', '友情链接管理 > 编辑链接'); $this->assign('_hash_', buildFormToken()); $this->display('post'); }
public function edit() { $id = intval($_REQUEST['id']); $ccmModel = D('MallPromotion'); $promotion = $ccmModel->info(array(), $id); $promotion or die('id invalid'); if ($this->isPost()) { if (C('TOKEN_ON') && !checkFormToken($_REQUEST, 'hash')) { die('hack attemp.'); } if (!$_REQUEST['title'] || !$_REQUEST['cate_id'] || !$_REQUEST['gourl'] || !$_REQUEST['expiry'] || !$_REQUEST['m_id'] || !$_REQUEST['description'] || !$_REQUEST['sort_order']) { $this->error('请填写所有的必填项'); } $logo = ''; if ($_FILES['logo']['size'] > 0 && $_FILES['logo']['error'] == 0) { $upfile = array(); $upfile = upload_one_file($_FILES['logo']); if ($upfile['error']) { $this->error($upfile['error']); } $logo = $upfile['file_name']; } $localTimeObj = LocalTime::getInstance(); $addtime = $localTimeObj->gmtime(); $_REQUEST['expiry'] = $localTimeObj->local_strtotime($_REQUEST['expiry'] . ' 23:59:59'); $data = array('cate_id' => intval($_REQUEST['cate_id']), 'title' => $_REQUEST['title'], 'gourl' => $_REQUEST['gourl'], 'expiry' => $_REQUEST['expiry'], 'description' => $_REQUEST['description'], 'm_id' => intval($_REQUEST['m_id']), 'm_name' => $_REQUEST['m_name'], 'sort_order' => intval($_REQUEST['sort_order']), 'detail' => $_REQUEST['detail']); if ($logo) { $data['logo'] = $logo; } if ($ccmModel->update($id, $data)) { $this->assign('jumpUrl', '?g=' . GROUP_NAME . '&m=' . MODULE_NAME); $this->success('编辑成功'); } else { $this->error('编辑失败'); } } $promotion['expiry'] = LocalTime::getInstance()->local_date($this->_CFG['date_format'], $promotion['expiry']); $this->assign('promotion', $promotion); $categorys = array(); $cccService = service('CouponCodeCategory'); $data = $cccService->getTree(); foreach ($data as $rs) { $categorys[$rs['id']] = $rs; $categorys[$rs['id']]['prefix'] = str_repeat(" ", $rs['level']); } $this->assign('categorys', $categorys); $this->assign('ur_href', '促销活动管理 > 编辑活动'); $this->assign('hash', buildFormToken('hash')); $this->display('post'); }
public function edit() { $id = intval($_REQUEST['id']); $ccmModel = D('MallZhekou'); $zhekou = $ccmModel->info(array(), $id); $zhekou or die('id invalid'); if ($this->isPost()) { if (C('TOKEN_ON') && !checkFormToken($_REQUEST, 'hash')) { die('hack attemp.'); } if (!$_REQUEST['title'] || !$_REQUEST['cate_id'] || !$_REQUEST['gourl'] || !$_REQUEST['m_id'] || !$_REQUEST['description'] || !$_REQUEST['sort_order']) { $this->error('请填写所有的必填项'); } $logo = ''; if ($_FILES['logo']['size'] > 0 && $_FILES['logo']['error'] == 0) { $upfile = array(); $upfile = upload_one_file($_FILES['logo']); if ($upfile['error']) { $this->error($upfile['error']); } $logo = $upfile['file_name']; } $data = array('cate_id' => intval($_REQUEST['cate_id']), 'title' => $_REQUEST['title'], 'gourl' => $_REQUEST['gourl'], 'price' => floatval($_REQUEST['price']), 'description' => $_REQUEST['description'], 'm_id' => intval($_REQUEST['m_id']), 'm_name' => $_REQUEST['m_name'], 'sort_order' => intval($_REQUEST['sort_order']), 'use_coupon' => intval($_REQUEST['use_coupon'])); if ($logo) { $data['logo'] = $logo; } if ($ccmModel->update($id, $data)) { $this->assign('jumpUrl', '?g=' . GROUP_NAME . '&m=' . MODULE_NAME); $this->success('编辑成功'); } else { $this->error('编辑失败'); } } $this->assign('zhekou', $zhekou); $categorys = array(); $service = service('ZhekouCategory'); $categorys = $service->getAll(); $this->assign('categorys', $categorys); $this->assign('ur_href', '折扣商品管理 > 编辑折扣商品'); $this->assign('hash', buildFormToken('hash')); $this->display('post'); }
public function import() { if (!is_file(LIB_PATH . 'ORG/phpExcel/PHPExcel.php')) { $this->error('请先上传PHPExcel类库'); } if ($this->isPost()) { if (C('TOKEN_ON') && !checkFormToken($_REQUEST, 'hash')) { die('hack attemp.'); } $m_id = intval($_REQUEST['m_id']); $m_name = $_REQUEST['m_name']; $import_format = $_REQUEST['import_format']; $file = ''; if ($_FILES['codes']['size'] > 0 && $_FILES['codes']['error'] == 0) { $upfile = array(); $upfile = upload_one_file($_FILES['codes']); if ($upfile['error']) { $this->error($upfile['error']); } $file = DOC_ROOT_PATH . get_upload_path() . $upfile['file_name']; } else { $this->error('Excel文件导入失败,请重试.'); } if (!is_file($file)) { $this->error('Excel文件导入失败,请重试.'); } $hanlder = "_import_coupons_" . $import_format . "_handler"; $this->{$hanlder}($m_id, $m_name, $file); $this->assign('jumpUrl', '?g=' . GROUP_NAME . '&m=' . MODULE_NAME); $this->success('导入成功'); } $this->assign('import_format_conf', $this->_import_format_conf); $this->assign('hash', buildFormToken('hash')); $this->assign('ur_href', '优惠券管理 > 批量导入'); $this->display(); }
/** * 编辑 * */ public function edit() { $adModel = D('Ad'); $ad_id = intval($_REQUEST['ad_id']); if ($this->isPost()) { if (C('TOKEN_ON') && !checkFormToken($_REQUEST)) { die('hack attemp.'); } if (!$_REQUEST['ad_name'] || !$_REQUEST['start_time'] || !$_REQUEST['end_time']) { die('data invalid.'); } $media_type = intval($_REQUEST['media_type']); $localTimeObj = LocalTime::getInstance(); $start_time = $localTimeObj->local_strtotime($_REQUEST['start_time']); $end_time = $localTimeObj->local_strtotime($_REQUEST['end_time']); $upload_path = get_upload_path(); $file_prefix = 'http://' . $_SERVER['HTTP_HOST'] . __ROOT__ . '/' . $upload_path; $adModel = D('Ad'); $data = array('ad_name' => $_REQUEST['ad_name'], 'media_type' => $media_type, 'position_id' => intval($_REQUEST['position_id']), 'enabled' => intval($_REQUEST['enabled']), 'start_time' => $start_time, 'end_time' => $end_time); //图片广告 if ($media_type == 101) { if (!$_REQUEST['ad_link'] || !$_REQUEST['img_url'] && (!$_FILES['ad_img'] || $_FILES['ad_img']['size'] == 0 || $_FILES['ad_img']['error'] != 0)) { die('data invalid.'); } $data['ad_link'] = $_REQUEST['ad_link']; if ($_REQUEST['img_url']) { $data['ad_code'] = str_replace($file_prefix, '', $_REQUEST['img_url']); } if ($_FILES['ad_img'] && $_FILES['ad_img']['size'] > 0 && $_FILES['ad_img']['error'] == 0) { $upfile = array(); $upfile = upload_one_file($_FILES['ad_img']); if ($upfile['error']) { $this->error($upfile['error']); } $data['ad_code'] = $upfile['file_name']; } } elseif ($media_type == 102) { if (!$_REQUEST['flash_url'] && (!$_FILES['upfile_flash'] || $_FILES['upfile_flash']['size'] == 0 || $_FILES['upfile_flash']['error'] != 0)) { die('data invalid.'); } if ($_REQUEST['flash_url']) { $data['ad_code'] = str_replace($file_prefix, '', $_REQUEST['flash_url']); } if ($_FILES['upfile_flash'] && $_FILES['upfile_flash']['size'] > 0 && $_FILES['upfile_flash']['error'] == 0) { $upfile = array(); $upfile = upload_one_file($_FILES['upfile_flash']); if ($upfile['error']) { $this->error($upfile['error']); } $data['ad_code'] = $upfile['file_name']; } } elseif ($media_type == 103) { if (!$_REQUEST['ad_code']) { die('data invalid.'); } $data['ad_code'] = htmlentities($_REQUEST['ad_code']); } elseif ($media_type == 104) { if (!$_REQUEST['ad_link2'] || !$_REQUEST['ad_text']) { die('data invalid.'); } $data['ad_link'] = $_REQUEST['ad_link2']; $data['ad_code'] = $_REQUEST['ad_text']; } if ($adModel->editAd($ad_id, $data)) { //更新缓存 $params = array('ad_id' => $ad_id); B('Adv', $params); $this->assign('jumpUrl', '?g=' . GROUP_NAME . '&m=' . MODULE_NAME); $this->success('编辑成功'); } else { $this->error('编辑失败'); } } $localTimeObj = LocalTime::getInstance(); $ad = $adModel->info($ad_id); $ad['start_time'] = $localTimeObj->local_date($this->_CFG['time_format'], $ad['start_time']); $ad['end_time'] = $localTimeObj->local_date($this->_CFG['time_format'], $ad['end_time']); $upload_path = get_upload_path(); if (is_file(DOC_ROOT_PATH . $upload_path . $ad['ad_code'])) { //$upload_path = str_replace('./','/',$upload_path); $ad['ad_code'] = 'http://' . $_SERVER['HTTP_HOST'] . FixedUploadedFileUrl($ad['ad_code']); } $this->assign('ad', $ad); $apModel = D('AdPosition'); $res = $apModel->getPositions(); $positions = array(); foreach ($res as $rs) { $position = $apModel->info($rs['position_id']); $positions[] = $position; } $this->assign('positions', $positions); $this->assign('ad_media_type_conf', $this->_ad_media_type_conf); $this->assign('ur_href', '广告管理 > 编辑广告'); $this->assign('_hash_', buildFormToken()); $this->display('post'); }
public function edit() { $id = intval($_REQUEST['id']); $ccmModel = D('CouponCodeMall'); $mall = $ccmModel->info($id); $mall or die('id invalid'); if ($this->isPost()) { if (C('TOKEN_ON') && !checkFormToken($_REQUEST)) { die('hack attemp.'); } if (!$_REQUEST['name'] || !$_REQUEST['c_id'] || !$_REQUEST['website'] || !$_REQUEST['tel'] || !$_REQUEST['description']) { $this->error('请填写所有的必填项'); } $logo = ''; if ($_FILES['logo']['size'] > 0 && $_FILES['logo']['error'] == 0) { $upfile = array(); $upfile = upload_one_file($_FILES['logo']); if ($upfile['error']) { $this->error($upfile['error']); } $logo = $upfile['file_name']; } $figure_image = ''; if ($_FILES['figure_image']['size'] > 0 && $_FILES['figure_image']['error'] == 0) { $upfile = array(); $upfile = upload_one_file($_FILES['figure_image']); if ($upfile['error']) { $this->error($upfile['error']); } $figure_image = $upfile['file_name']; } $data = array('c_id' => intval($_REQUEST['c_id']), 'name' => $_REQUEST['name'], 'website' => $_REQUEST['website'], 'gourl' => $_REQUEST['gourl'], 'tel' => $_REQUEST['tel'], 'description' => $_REQUEST['description'], 'how2use' => $_REQUEST['how2use'], 'seo_title' => $_REQUEST['seo_title'], 'seo_keywords' => $_REQUEST['seo_keywords'], 'seo_desc' => $_REQUEST['seo_desc']); if ($logo) { $data['logo'] = $logo; } if ($figure_image) { $data['figure_image'] = $figure_image; } if ($ccmModel->_edit($id, $data)) { //更新旗下所有优惠券的商家名称 M('CouponCode')->where("m_id='{$id}'")->save(array('m_name' => $_REQUEST['name'])); M('MallPromotion')->where("m_id='{$id}'")->save(array('m_name' => $_REQUEST['name'])); $params = array('id' => $id); B('CouponCodeMall', $params); $this->assign('jumpUrl', '?g=' . GROUP_NAME . '&m=' . MODULE_NAME); $this->success('编辑成功'); } else { $this->error('编辑失败'); } } $this->assign('mall', $mall); $categorys = array(); $cccService = service('CouponCodeCategory'); $data = $cccService->getTree(); foreach ($data as $rs) { $categorys[$rs['id']] = $rs; $categorys[$rs['id']]['prefix'] = str_repeat(" ", $rs['level']); } $this->assign('categorys', $categorys); $this->assign('ur_href', '商家管理 > 编辑商家'); $this->assign('_hash_', buildFormToken()); $this->display('post'); }