本文整理汇总了PHP中IFilter::addSlash方法的典型用法代码示例。如果您正苦于以下问题:PHP IFilter::addSlash方法的具体用法?PHP IFilter::addSlash怎么用?PHP IFilter::addSlash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFilter
的用法示例。
在下文中一共展示了IFilter::addSlash方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* @brief 修改商品数据
* @param int $id 商品ID
* @param array $paramData 商品所需数据
*/
public function update($id, $paramData)
{
$postData = array();
$nowDataTime = ITime::getDateTime();
foreach ($paramData as $key => $val) {
$postData[$key] = $val;
//数据过滤分组
if (strpos($key, 'attr_id_') !== false) {
$goodsAttrData[ltrim($key, 'attr_id_')] = IFilter::act($val);
} else {
if ($key == 'content') {
$goodsUpdateData['content'] = IFilter::addSlash($val);
} else {
if ($key[0] != '_') {
$goodsUpdateData[$key] = IFilter::act($val, 'text');
}
}
}
}
//商家发布商品默认设置
if ($this->seller_id) {
$goodsUpdateData['seller_id'] = $this->seller_id;
$goodsUpdateData['is_del'] = $goodsUpdateData['is_del'] == 2 ? 2 : 3;
//如果商户是VIP则无需审核商品
if ($goodsUpdateData['is_del'] == 3) {
$sellerDB = new IModel('seller');
$sellerRow = $sellerDB->getObj('id = ' . $this->seller_id);
if ($sellerRow['is_vip'] == 1) {
$goodsUpdateData['is_del'] = 0;
}
}
}
//上架或者下架处理
if (isset($goodsUpdateData['is_del'])) {
//上架
if ($goodsUpdateData['is_del'] == 0) {
$goodsUpdateData['up_time'] = $nowDataTime;
$goodsUpdateData['down_time'] = null;
} else {
if ($goodsUpdateData['is_del'] == 2) {
$goodsUpdateData['up_time'] = null;
$goodsUpdateData['down_time'] = $nowDataTime;
} else {
$goodsUpdateData['up_time'] = null;
$goodsUpdateData['down_time'] = null;
}
}
}
//是否存在货品
$goodsUpdateData['spec_array'] = '';
if (isset($postData['_spec_array'])) {
//生成goods中的spec_array字段数据
$goods_spec_array = array();
foreach ($postData['_spec_array'] as $key => $val) {
foreach ($val as $v) {
$tempSpec = JSON::decode($v);
if (!isset($goods_spec_array[$tempSpec['id']])) {
$goods_spec_array[$tempSpec['id']] = array('id' => $tempSpec['id'], 'name' => $tempSpec['name'], 'type' => $tempSpec['type'], 'value' => array());
}
$goods_spec_array[$tempSpec['id']]['value'][] = $tempSpec['value'];
}
}
foreach ($goods_spec_array as $key => $val) {
$val['value'] = array_unique($val['value']);
$goods_spec_array[$key]['value'] = join(',', $val['value']);
}
$goodsUpdateData['spec_array'] = JSON::encode($goods_spec_array);
}
$goodsUpdateData['goods_no'] = isset($postData['_goods_no']) ? current($postData['_goods_no']) : '';
$goodsUpdateData['store_nums'] = array_sum($postData['_store_nums']);
$goodsUpdateData['market_price'] = isset($postData['_market_price']) ? current($postData['_market_price']) : 0;
$goodsUpdateData['sell_price'] = isset($postData['_sell_price']) ? current($postData['_sell_price']) : 0;
$goodsUpdateData['cost_price'] = isset($postData['_cost_price']) ? current($postData['_cost_price']) : 0;
$goodsUpdateData['weight'] = isset($postData['_weight']) ? current($postData['_weight']) : 0;
//处理商品
$goodsDB = new IModel('goods');
if ($id) {
$goodsDB->setData($goodsUpdateData);
$where = " id = {$id} ";
if ($this->seller_id) {
$where .= " and seller_id = " . $this->seller_id;
}
if ($goodsDB->update($where) === false) {
die("更新商品错误");
}
} else {
$goodsUpdateData['create_time'] = $nowDataTime;
$goodsDB->setData($goodsUpdateData);
$id = $goodsDB->add();
}
//处理商品属性
$goodsAttrDB = new IModel('goods_attribute');
$goodsAttrDB->del('goods_id = ' . $id);
if (isset($goodsAttrData) && $goodsAttrData) {
foreach ($goodsAttrData as $key => $val) {
//.........这里部分代码省略.........
示例2: ad_edit_act
function ad_edit_act()
{
$id = IFilter::act(IReq::get('id'), 'int');
$adObj = new IModel('ad_manage');
$error_message = null;
//获取content数据
$type = IReq::get('type', 'post');
$content = IReq::get('content', 'post');
$upObj = null;
switch ($type) {
case "1":
//图片上传
$upObj = new IUpload();
$attach = 'img';
break;
case "2":
//flash上传
$upObj = new IUpload('4048', array('flv', 'swf'));
$attach = 'flash';
break;
case "3":
//文字
$content = IReq::get('text', 'post');
break;
case "4":
//代码
$content = IReq::get('code', 'post');
break;
}
if ($upObj != null) {
//目录散列
$dir = IWeb::$app->config['upload'] . '/' . date('Y') . "/" . date('m') . "/" . date('d');
$upObj->setDir($dir);
$upState = $upObj->execute();
if (!isset($upState[$attach])) {
if ($content == '') {
$error_message = '没有上传文件';
}
} else {
if ($upState[$attach][0]['flag'] == 1) {
$content = $dir . '/' . $upState[$attach][0]['name'];
} else {
$error_message = IUpload::errorMessage($upState[$attach][0]['flag']);
}
}
} else {
if ($content == '') {
$error_message = '请填写广告展示类型的内容';
}
}
$dataArray = array('content' => IFilter::addSlash($content), 'name' => IFilter::act(IReq::get('name')), 'position_id' => IFilter::act(IReq::get('position_id')), 'type' => IFilter::act(IReq::get('type')), 'link' => IFilter::addSlash(IReq::get('link')), 'start_time' => IFilter::act(IReq::get('start_time')), 'end_time' => IFilter::act(IReq::get('end_time')), 'description' => IFilter::act(IReq::get('description'), 'text'), 'order' => IFilter::act(IReq::get('order'), 'int'), 'goods_cat_id' => IFilter::act(IReq::get('goods_cat_id'), 'int'));
//上传错误
if ($error_message != null) {
if ($id) {
$dataArray['id'] = $id;
}
$this->adRow = $dataArray;
$this->redirect('ad_edit', false);
Util::showMessage($error_message);
}
$adObj->setData($dataArray);
if ($id) {
$where = 'id = ' . $id;
$adObj->update($where);
} else {
$adObj->add();
}
$this->redirect("ad_list");
}
示例3: isValidUser
/**
* @brief 校验注册用户身份信息
* @param string $login_info 用户名或者email
* @param string $password 用户名的md5密码
* @return array or false 如果合法则返回用户数据;不合法返回false
*/
public static function isValidUser($login_info, $password)
{
$login_info = IFilter::addSlash($login_info);
$password = IFilter::addSlash($password);
$userObj = new IModel('user as u,member as m');
$where = "(u.username = '{$login_info}' or u.email = '{$login_info}' or m.mobile='{$login_info}') and m.status = 1 and u.id = m.user_id";
$userRow = $userObj->getObj($where);
if ($userRow && $userRow['password'] == $password) {
return $userRow;
}
return false;
}
示例4: insertOrderGoods
/**
* @brief 把订单商品同步到order_goods表中
* @param $order_id 订单ID
* @param $goodsInfo 商品和货品信息(购物车数据结构,countSum 最终生成的格式)
*/
public function insertOrderGoods($order_id, $goodsResult = array())
{
$orderGoodsObj = new IModel('order_goods');
//清理旧的关联数据
$orderGoodsObj->del('order_id = ' . $order_id);
$goodsArray = array('order_id' => $order_id);
if (isset($goodsResult['goodsList'])) {
foreach ($goodsResult['goodsList'] as $key => $val) {
//拼接商品名称和规格数据
$specArray = array('name' => $val['name'], 'goodsno' => $val['goods_no'], 'value' => '');
if (isset($val['spec_array'])) {
$spec = block::show_spec($val['spec_array']);
foreach ($spec as $skey => $svalue) {
$specArray['value'] .= $skey . ':' . $svalue . ',';
}
$specArray['value'] = trim($specArray['value'], ',');
}
$goodsArray['product_id'] = $val['product_id'];
$goodsArray['goods_id'] = $val['goods_id'];
$goodsArray['img'] = $val['img'];
$goodsArray['goods_price'] = $val['sell_price'];
$goodsArray['real_price'] = $val['sell_price'] - $val['reduce'];
$goodsArray['goods_nums'] = $val['count'];
$goodsArray['goods_weight'] = $val['weight'];
$goodsArray['goods_array'] = IFilter::addSlash(JSON::encode($specArray));
$goodsArray['seller_id'] = $val['seller_id'];
$orderGoodsObj->setData($goodsArray);
$orderGoodsObj->add();
}
}
}
示例5: defaultShowType
$('#ad_box>div:eq('+indexVal+')').show();
}
//预定义type数据
function defaultShowType()
{
var checkedVal = "<?php
echo isset($this->adRow['type']) ? $this->adRow['type'] : "";
?>
";
<?php
if ($this->adRow['type'] != 4) {
?>
var checkedData = "<?php
echo IFilter::addSlash($this->adRow['content']);
?>
";
var typeHTML = '';
//如果有数据
if(checkedData)
{
switch(checkedVal)
{
case "1":
var typeHTML = '<img src="<?php
echo IUrl::creatUrl("") . "";
?>
'+checkedData+'" width="150px" />';
$('#ad_box>div:eq('+(checkedVal-1)+')').html($('#ad_box>div:eq('+(checkedVal-1)+')').html()+typeHTML);
示例6: run
/**
* @brief 开始运行
*/
public static function run()
{
set_time_limit(0);
ini_set("max_execution_time", 0);
$csvType = IReq::get('csvType');
$category = IFilter::act(IReq::get('category'), 'int');
$pluginDir = IWeb::$app->getBasePath() . 'plugins/csvPacketHelper/';
if (!file_exists($pluginDir)) {
die('此功能仅供授权版本使用,请您购买商业授权');
}
if (!class_exists('ZipArchive')) {
die('服务器环境中没有安装zip扩展,无法使用此功能');
}
if (extension_loaded('mbstring') == false) {
die('服务器环境中没有安装mbstring扩展,无法使用此功能');
}
//处理上传
$uploadInstance = new IUpload(9999999, array('zip'));
$uploadCsvDir = 'runtime/cvs/' . date('YmdHis');
$uploadInstance->setDir($uploadCsvDir);
$result = $uploadInstance->execute();
if (!isset($result['csvPacket'])) {
die('请上传指定大小的csv数据包');
}
if (($packetData = current($result['csvPacket'])) && $packetData['flag'] != 1) {
$message = $uploadInstance->errorMessage($packetData['flag']);
die($message);
}
$zipPath = $packetData['fileSrc'];
$zipDir = dirname($zipPath);
$imageDir = IWeb::$app->config['upload'] . '/' . date('Y/m/d');
file_exists($imageDir) ? '' : IFile::mkdir($imageDir);
//解压缩包
$zipObject = new ZipArchive();
$zipObject->open($zipPath);
$isExtract = $zipObject->extractTo($zipDir);
$zipObject->close();
if ($isExtract == false) {
$message = '解压缩到目录' . $zipDir . '失败!';
die($message);
}
//实例化商品
$goodsObject = new IModel('goods');
$photoRelationDB = new IModel('goods_photo_relation');
$photoDB = new IModel('goods_photo');
$cateExtendDB = new IModel('category_extend');
//获得配置文件中的数据
$config = new Config("site_config");
$dirHandle = opendir($zipDir);
while ($fileName = readdir($dirHandle)) {
if (strpos($fileName, '.csv') !== false) {
//创建解析对象
switch ($csvType) {
case "taobao":
include_once $pluginDir . 'taoBaoPacketHelper.php';
$helperInstance = new taoBaoPacketHelper($zipDir . '/' . $fileName, $imageDir);
$titleToCols = taoBaoTitleToColsMapping::$mapping;
break;
default:
$message = "请选择csv数据包的格式";
die($message);
}
//从csv中解析数据
$collectData = $helperInstance->collect();
//插入商品表
foreach ($collectData as $key => $val) {
$collectImage = isset($val[$titleToCols['img']]) ? $val[$titleToCols['img']] : '';
//有图片处理
if ($collectImage) {
//图片拷贝
$_FILES = array();
foreach ($collectImage as $image) {
foreach ($image as $from => $to) {
if (!is_file($from)) {
continue;
}
IFile::xcopy($from, $to);
//构造$_FILES全局数组
$_FILES[] = array('size' => 100, 'tmp_name' => $to, 'name' => basename($to), 'error' => 0);
}
}
//调用文件上传类
$photoObj = new PhotoUpload();
$uploadImg = $photoObj->run(true);
$showImg = current($uploadImg);
}
//处理商品详情图片
$toDir = IUrl::creatUrl() . dirname($to);
$goodsContent = preg_replace("|src=\".*?(?=/contentPic/)|", "src=\"{$toDir}", trim($val[$titleToCols['content']], "'\""));
$insertData = array('name' => IFilter::act(trim($val[$titleToCols['name']], '"\'')), 'goods_no' => goods_class::createGoodsNo(), 'sell_price' => IFilter::act($val[$titleToCols['sell_price']], 'float'), 'market_price' => IFilter::act($val[$titleToCols['sell_price']], 'float'), 'up_time' => ITime::getDateTime(), 'create_time' => ITime::getDateTime(), 'store_nums' => IFilter::act($val[$titleToCols['store_nums']], 'int'), 'content' => IFilter::addSlash($goodsContent), 'img' => isset($showImg['img']) ? $showImg['img'] : '', 'seller_id' => self::$seller_id);
$goodsObject->setData($insertData);
$goods_id = $goodsObject->add();
//处理商品分类
if ($category) {
foreach ($category as $catId) {
$cateExtendDB->setData(array('goods_id' => $goods_id, 'category_id' => $catId));
$cateExtendDB->add();
//.........这里部分代码省略.........
示例7: ad_edit_act
function ad_edit_act()
{
$id = IFilter::act(IReq::get('id'), 'int');
$content = IReq::get('content');
//附件上传
if (isset($_FILES) && $_FILES) {
$upType = isset($_FILES['img']) ? array("gif", "png", "jpg") : array('flv', 'swf');
$upObj = new IUpload("5000", $upType);
$dir = IWeb::$app->config['upload'] . '/' . date('Y') . "/" . date('m') . "/" . date('d');
$upObj->setDir($dir);
$upState = $upObj->execute();
$result = $upState ? current($upState) : "";
if ($result && isset($result[0]['flag']) && $result[0]['flag'] == 1) {
//最终附件路径
$content = $dir . '/' . $result[0]['name'];
} else {
if (!$content) {
IError::show(403, "请上传正确的附件数据");
}
}
}
$adObj = new IModel('ad_manage');
$dataArray = array('content' => IFilter::addSlash($content), 'name' => IFilter::act(IReq::get('name')), 'position_id' => IFilter::act(IReq::get('position_id')), 'type' => IFilter::act(IReq::get('type')), 'link' => IFilter::addSlash(IReq::get('link')), 'start_time' => IFilter::act(IReq::get('start_time')), 'end_time' => IFilter::act(IReq::get('end_time')), 'description' => IFilter::act(IReq::get('description'), 'text'), 'order' => IFilter::act(IReq::get('order'), 'int'), 'goods_cat_id' => IFilter::act(IReq::get('goods_cat_id'), 'int'));
$adObj->setData($dataArray);
if ($id) {
$where = 'id = ' . $id;
$adObj->update($where);
} else {
$adObj->add();
}
$this->redirect("ad_list");
}