Example #1
0
function addslashes_array($array)
{
    foreach ($array as $key => $val) {
        $array[$key] = is_array($val) ? addslashes_array($val) : addslashes($val);
    }
    return $array;
}
Example #2
0
function addslashes_array($input_arr)
{
    if (is_array($input_arr)) {
        $tmp = array();
        foreach ($input_arr as $key1 => $val) {
            $tmp[$key1] = addslashes_array($val);
        }
        return $tmp;
    } else {
        return addslashes($input_arr);
    }
}
 function addslashes_array($a){
     if(is_array($a)){
         foreach($a as $n=>$v){
             $b[$n]=addslashes_array($v);
         }
         return $b;
     }else{
         if ($a != ''){
             return addslashes($a);
         }
     }
 }
/**
* Does addslashes() on every value in an array (NOTICE: Using 
* mysql_real_escape_string() or mysql_escape_array() is MUCH BETTER
* - especially for any data to be used in MySQL This function just exists for
* rare circumstances.)
*
* @param array The array to be slashed
*/
function addslashes_array($data)
{
    if (is_array($data)) {
        foreach ($data as $key => $value) {
            $data[$key] = addslashes_array($value);
        }
        return $data;
    } else {
        if (!is_numeric($data)) {
            return addslashes($data);
        } else {
            return $data;
        }
    }
}
Example #5
0
function addslashes_array($array)
{
    if (get_magic_quotes_gpc()) {
        return $array;
    }
    if (!is_array($array)) {
        return addslashes($array);
    }
    foreach ($array as $k => $val) {
        $array[$k] = addslashes_array($val);
    }
    return $array;
}
Example #6
0
 function _add_ship_bill($order_info, $delivery_item, $type = 'delivery')
 {
     $dealer_orderid = $order_info['order_id'];
     $delivery_no = $this->_get_new_number($type);
     $_delivery_goods_items = $delivery_item['struct'];
     unset($delivery_item['struct']);
     unset($delivery_item['order_id']);
     $_data = array();
     $_data = array_merge((array) $delivery_item, (array) $order_info);
     $_data['supplier_delivery_id'] = $delivery_item['delivery_id'];
     $_data['delivery_id'] = $delivery_no;
     $_data['op_name'] = 'admin';
     $_data['logi_id'] = null;
     unset($_data['disabled']);
     $order_id = $order_info['order_id'];
     $rs = $this->db->query('SELECT * FROM sdb_delivery WHERE 0=1');
     $_data = addslashes_array($_data);
     $_sql = $this->db->GetInsertSQL($rs, $_data);
     if ($this->db->exec($_sql)) {
         foreach ($_delivery_goods_items as $_item) {
             $_data = array('product_id' => $_item['product_id'], 'delivery_id' => $delivery_no, 'product_bn' => $_item['dealer_bn'], 'item_type' => $_item['item_type'], 'product_name' => $_item['product_name'], 'number' => $_item['number']);
             $rs = $this->db->query('SELECT * FROM sdb_delivery_item WHERE 0=1');
             $_data = addslashes_array($_data);
             $_sql = $this->db->GetInsertSQL($rs, $_data);
             if (!$this->db->exec($_sql)) {
                 $this->api_response('fail', 'data fail', $result, '发货单/退货单商品清单插入失败');
             }
             //更新order_items 订单发货数量
             $_sql = sprintf('update sdb_order_items set sendnum=sendnum+%d where order_id=%s and bn=\'%s\'', ($type == 'delivery' ? 1 : -1) * $_item['number'], $dealer_orderid, $_item['dealer_bn']);
             $this->db->exec($_sql);
         }
     } else {
         $this->api_response('fail', 'data fail', null, '发货单/退货单插入失败');
     }
     //更新订单操作记录,add by hujianxin
     return $delivery_no;
 }
Example #7
0
 function update_product($data)
 {
     $data['goods'] = json_decode($data['goods'], true);
     //$data['keywords']=json_decode($data['keywords'],true);
     $goods = $data['goods'];
     $data['keywords'] = $goods['keywords'];
     if (!isset($goods['bn'])) {
         $bnsql = "select bn from sdb_goods where goods_id=" . $goods['goods_id'];
         $bnrow = $this->db->selectrow($bnsql);
         $goods['bn'] = $bnrow['bn'];
     }
     $props = $this->matrix_propsToB2c_props($goods['props']);
     $input_pids = explode(',', $goods['input_pids']);
     $input_str = json_decode($goods['input_str'], true);
     foreach ($input_pids as $k => $v) {
         $props[$v] = $input_str[$k];
     }
     foreach ($props as $k => $v) {
         $goods['p_' . $k] = $v;
     }
     //处理规格属性
     //if(isset($goods['sku_properties'])){
     if (isset($data['sku_bns'])) {
         $sku_props = explode(',', $goods['sku_properties']);
         $goods['sku_properties'] = implode(';', $sku_props);
         $stores = explode(',', $data['sku_quantities']);
         $sku_bns = explode(',', $data['sku_bns']);
         $price = explode(',', $data['sku_prices']);
         $cost = explode(',', $data['sku_costs']);
         $weight = explode(',', $data['sku_weights']);
         if (is_array($goods['sku_properties'])) {
             //add_sku流程
             $sku_properties = $goods['sku_properties'];
         } else {
             //add_product流程
             $sku_properties = $this->matrix_specToB2c_spec($goods['sku_properties']);
         }
     } else {
         unset($goods['sku_properties']);
         $sql = "select spec_desc from sdb_goods where goods_id=" . $goods['goods_id'];
         $row = $this->db->selectrow($sql);
         $spec_desc = unserialize($row['spec_desc']);
         error_log(print_r($sql, true), 3, HOME_DIR . '/logs/bbbbbbbbb.log');
         foreach ($spec_desc as $k => $v) {
             $i = 0;
             foreach ($v as $k2 => $v2) {
                 $properties[$k][$i] = $v2['spec_value_id'];
                 $i++;
             }
         }
         $sql2 = "select store,price,weight,bn,cost from sdb_products where goods_id=" . $goods['goods_id'];
         $rs = $this->db->select($sql2);
         foreach ($rs as $pk => $pv) {
             $stores .= $pv['store'] . ',';
             $sku_bns .= $pv['bn'] . ',';
             $price .= $pv['price'] . ',';
             $cost .= $pv['cost'] . ',';
             $weight .= $pv['weight'] . ',';
         }
         $stores = explode(',', trim($stores, ','));
         $sku_bns = explode(',', trim($sku_bns, ','));
         $price = explode(',', trim($price, ','));
         $cost = explode(',', trim($cost, ','));
         $weight = explode(',', trim($weight, ','));
         $sku_properties = $properties;
     }
     foreach ($sku_properties as $k => $v) {
         foreach ($v as $k2 => $v2) {
             $spec_value = $this->getSpecvalueByids($v2);
             $spec_info = $this->getSpecInfo($k);
             $pSpecId = $v2;
             $spec_desc[$k][$pSpecId]['spec_value'] = $spec_value;
             $spec_desc[$k][$pSpecId]['spec_type'] = $spec_info['spec_type'];
             $spec_desc[$k][$pSpecId]['spec_value_id'] = $v2;
             $spec_desc[$k][$pSpecId]['spec_image'] = '';
             $spec_desc[$k][$pSpecId]['spec_goods_images'] = '';
             $data['vars'][$k] = $spec_info['spec_name'];
             $data['bn'][$k2] = $sku_bns[$k2];
             $data['val'][$k][$k2] = $spec_value;
             $data['pSpecId'][$k][$k2] = $pSpecId;
             $data['specVId'][$k][$k2] = $v2;
             $data['store'][$k2] = $stores[$k2];
             $data['price'][$k2] = $price[$k2];
             $data['cost'][$k2] = $cost[$k2];
             $data['weight'][$k2] = $weight[$k2];
         }
     }
     //}
     $goods['spec_desc'] = $spec_desc;
     //       $goods['spec_desc'] = urldecode( $goods['spec_desc'] );
     //        $goods['spec_desc'] = addslashes_array($goods['spec_desc']);
     //        $goods['params'] = stripslashes_array($goods['params']);
     $objGoodsStatus = $this->system->loadModel('trading/goodsstatus');
     if ($goods['goods_id']) {
         $objGoodsStatus->checkStart($goods['goods_id'], array('goods_marketable', 'product_store', 'gimage_update', 'goods_update', 'product_update', 'goods_lv_price_update'));
         $is_new_product = false;
     } else {
         $is_new_product = true;
     }
     $udfimg = $goods['udfimg'];
     //        unset($goods['udfimg']);
     //        $goods['adjunct'] = $data['adjunct'];
     //单批方案---------------------
     //        if($data['ws_policy']){
     //            if(is_array($data['num'])&&!empty($data['num'])){
     //                $aParams = array();
     //
     //                foreach($data['num'] as $k => $v){
     //                    $nDiscount = ($data['distype']==1)?$data['discount'][$k]/100:$data['discount'][$k];
     //                    $aParams[] = array('num' => intval($v),
     //                                                        'distype' => $data['distype'],
     //                                                        'discount' => $nDiscount);
     //                }
     //                $_nums = array_item($aParams, 'num');
     //                array_multisort($_nums, SORT_ASC, $aParams);
     //                if($data['limit_quantity']){
     //                    $limit_quantity = array('num'=>intval($data['limit_quantity']),'distype'=>1,'discount'=>1);
     //                }else{
     //                    $limit_quantity = array('num'=>1,'distype'=>1,'discount'=>1);
     //                }
     //                array_unshift($aParams,$limit_quantity);
     //                $goods['wss_params'] = $aParams;
     //            }else{
     //                if($data['limit_quantity'] && $data['limit_quantity'] > 1){
     //                    $goods['wss_params'][] = array('num'=>intval($data['limit_quantity']),'distype'=>1,'discount'=>1);
     //                }else{
     //                    $goods['wss_params'] = '';
     //                }
     //            }
     //
     //            $goods['ws_policy'] = $data['ws_policy'];
     //        }else{
     //            $goods['ws_policy'] = '01';  //非单可混
     //        }
     if (isset($goods['sku_properties']) && strlen($goods['sku_properties']) == 0) {
         unset($spec_desc);
     }
     if (count($spec_desc) > 0) {
         //开启规格 多货品
         foreach ($data['vars'] as $vark => $varv) {
             $goods['spec'][$vark] = $varv;
         }
         $goods['spec'] = serialize($goods['spec']);
         $sameProFlag = array();
         foreach ($data['price'] as $k => $price) {
             //设置销售多货品销售价等价格
             $goods['price'] = $goods['price'] ? min($price, $goods['price']) : $price;
             //取最小商品价格
             $goods['cost'] = $goods['cost'] ? min($data['cost'][$k], $goods['cost']) : $data['cost'][$k];
             $goods['weight'] = $goods['weight'] ? min($data['weight'][$k], $goods['weight']) : $data['weight'][$k];
             $products[$k]['price'] = $price;
             $products[$k]['bn'] = $data['bn'][$k];
             $products[$k]['store'] = trim($data['store'][$k]) === '' ? '' : intval($data['store'][$k]);
             $products[$k]['alert'] = $data['alert'][$k];
             $products[$k]['cost'] = $data['cost'][$k];
             $products[$k]['weight'] = $data['weight'][$k];
             $products[$k]['goodsspace'] = $data['goodsspace'][$k];
             //新增货位
             $newSpecI = 0;
             $proSpecFlag = '';
             foreach ($data['vars'] as $i => $v) {
                 $products[$k]['props']['spec'][$i] = trim($data['val'][$i][$k]);
                 //array('规格(颜色)序号'=>'规格值(红色)')
                 $products[$k]['props']['spec_private_value_id'][$i] = trim($data['pSpecId'][$i][$k]);
                 $products[$k]['props']['spec_value_id'][$i] = trim($data['specVId'][$i][$k]);
                 if (!$products[$k]['props']['spec'][$i]) {
                     $this->api_response('fail', '请为所有货品定义规格值 ');
                 }
                 $proSpecFlag .= $products[$k]['props']['spec_private_value_id'][$i] . '_';
             }
             if (in_array($proSpecFlag, $sameProFlag)) {
                 $this->api_response('fail', '不能添加相同规格货品 ');
             }
             $sameProFlag[$k] = $proSpecFlag;
             reset($proSpecFlag);
             reset($data['vars'], $data['pSpecId']);
             $products[$k]['pdt_desc'] = implode('、', $products[$k]['props']['spec']);
             //物品描述
             $products[$k]['pdt_desc'] = addslashes_array($products[$k]['pdt_desc']);
             foreach ($data['idata'] as $i => $v) {
                 $products[$k]['props']['idata'][$i] = $v[$k];
             }
             //设置会员价格
             if (is_array($data['mprice'])) {
                 foreach ($data['mprice'] as $levelid => $rows) {
                     $products[$k]['mprice'][$levelid] = floatval($rows[$k]);
                 }
             }
         }
         unset($sameProFlag);
         $goods['products'] =& $products;
     } else {
         $goods['props']['idata'] = $data['idata'];
     }
     $objGoods = $this->system->loadModel('trading/goods');
     foreach ($products as $k => $p) {
         if (empty($p['bn'])) {
             continue;
         }
         if ($objGoods->checkProductBn($p['bn'], $goods['goods_id'])) {
             $this->api_response('fail', '货号重复,请检查 ');
         }
         $aBn[] = $p['bn'];
     }
     if (!empty($goods['bn'])) {
         if ($objGoods->checkProductBn($goods['bn'], $goods['goods_id'])) {
             $this->api_response('fail', '货号重复,请检查 ');
         }
     }
     if (count($aBn) > count(array_unique($aBn))) {
         $this->api_response('fail', '货号重复,请检查 ');
     }
     if (!$goods['type_id']) {
         $objCat = $this->system->loadModel('goods/productCat');
         $aCat = $objCat->getFieldById($goods['cat_id'], array('type_id'));
         $goods['type_id'] = $aCat['type_id'];
     }
     /*判断图片有无更新*/
     //        if ($goods['goods_id']){
     //            $goods['imgUPdate'] = $objGoods->check_ImgUpdate($goods['goods_id'],$data['goods']['image_file']);
     //        }
     if (!isset($goods['name']) && isset($goods['goods_id'])) {
         $getnamesql = "select name,cat_id,type_id,brand_id from sdb_goods where goods_id=" . $goods['goods_id'];
         $row = $this->db->selectrow($getnamesql);
         $goods['name'] = $row['name'];
         $goods['cat_id'] = $row['cat_id'];
         $goods['type_id'] = $row['type_id'];
         $goods['brand_id'] = $row['brand_id'];
     }
     if (!($gid = $objGoods->save($goods))) {
         $this->api_response('fail', '保存失败,请重试 ');
     }
     if (isset($data['keywords'])) {
         $keywords = array();
         foreach ($objGoods->getKeywords($gid) as $keywordvalue) {
             $keywords[] = $keywordvalue['keyword'];
         }
         $keyword = implode('|', $keywords);
         if ($keyword != $data['keywords']['keyword']) {
             $objGoods->deleteKeywords($gid);
             if ($data['keywords']['keyword']) {
                 $objGoods->addKeywords($gid, explode('|', $data['keywords']['keyword']));
             }
         }
     }
     //处理商品图片
     //$gimage= &$this->system->loadModel('goods/gimage');
     //$gimage->saveImage($goods['goods_id'], $goods['db_thumbnail_pic'], $data['image_default'], $image_file, $udfimg, $_FILES);
     if (isset($goods['image_url'])) {
         $img_result = $this->saveImage($goods);
     }
     //相关商品
     //        foreach($data['linkid'] as $k => $id){
     //            if($goods['goods_id']==$id){
     //                $this->api_response('fail','不能相关自身商品,请检查 ');
     //            }
     //            $aLink[] = array('goods_1' => $goods['goods_id'], 'goods_2' => $id, 'manual' => $data['linktype'][$id], 'rate' => 100);
     //        }
     //        $objProduct = $this->system->loadModel('goods/products');
     //        $objProduct->toInsertLink($goods['goods_id'], $aLink);
     //处理TAG
     //        $objTag = $this->system->loadModel('system/tag');
     //        $objTag->removeObjTag($goods['goods_id']);
     //        foreach(space_split(stripslashes($data['tags'])) as $tagName){
     //            $tagName = trim($tagName);
     //            if($tagName){
     //                if(!($tagid = $objTag->getTagByName('goods', $tagName))){
     //                    $tagid = $objTag->newTag($tagName, 'goods');
     //                }
     //                $objTag->addTag($tagid, $gid);
     //            }
     //        }
     //by shiy 商品op_status sync_status version_id
     //        if(!$is_new_product){
     //            $objGoodsStatus->checkEnd();
     //        }else{
     //            $objGoodsStatus->jumpCheck($gid,'new_goods');
     //        }
     $returndata = $this->getReturnData($goods['goods_id']);
     $this->api_response('true', false, $returndata);
 }
Example #8
0
<?php

/**
 * Reorder, Furasta.Org
 *
 * Accessed via AJAX, this file reorders pages
 * according to data sent via POST.
 *
 * @author     Conor Mac Aoidh <*****@*****.**>
 * @license    http://furasta.org/licence.txt The BSD License
 * @version    1.0
 * @package    admin_pages
 */
/**
 * make sure ajax script was loaded and user is
 * logged in 
 */
if (!defined('AJAX_LOADED') || !defined('AJAX_VERIFIED')) {
    die;
}
$pages = addslashes_array($_POST['node']);
foreach ($pages as $position => $page) {
    query('update ' . DB_PAGES . ' set position=' . $position . ', parent=' . $page['parent'] . ' where id=' . $page['id']);
}
cache_clear('DB_PAGES');
exit;
 function commit_to_db()
 {
     global $dbh;
     //on oublie pas que includes/global_vars.inc.php s'amuse à tout addslasher tout seul donc on le fait pas ici
     $this->type += 0;
     $this->config = addslashes_array($this->config);
     $serialized = serialize($this->config);
     $sql = "UPDATE connectors_out_sets SET connector_out_set_caption = '" . addslashes($this->caption) . "', connector_out_set_type = " . $this->type . ", connector_out_set_config = '" . addslashes($serialized) . "' WHERE connector_out_set_id = " . $this->id . "";
     pmb_mysql_query($sql, $dbh);
 }
Example #10
0
 /**
  * 下载图片
  * $retry=false && $command_id=1,表示重试下载该command_id所有需要重试下载的图片。注意点:如果反复调用带参数的方法,并且始终下载失败,那么会死锁,需要前台加以控制
  * PS:也可以由前台控制,首先把失败的标记改成成功,重新打开下载队列,这样就不需要传入参数了
  *
  * @param boolean $retry,是否重新下载失败的图片
  * @param int $command_id,同步列表的id
  * @return int -1:下载出错,1:下载成功,0:无需下载
  */
 function downloadImage($retry = false, $command_id = NULL)
 {
     $image_type = array('1' => 'gif', '2' => 'jpg', '3' => 'png', '6' => 'bmp');
     $sql = "SELECT * FROM sdb_image_sync WHERE 1=1 ";
     if ($retry) {
         $sql .= " AND failed='true'";
     } else {
         $sql .= " AND failed='false'";
     }
     if (!is_null($command_id)) {
         $sql .= " AND command_id=" . intval($command_id);
     }
     $sql .= " ORDER BY add_time ASC,img_sync_id ASC";
     $image = $this->db->selectrow($sql);
     if (!empty($image)) {
         $this->_updateLock('download_image');
         $filename = "";
         $type = $image['type'];
         $supplier_id = $image['supplier_id'];
         $object_id = $image['supplier_object_id'];
         switch ($type) {
             case 'gimage':
                 $dir = HOME_DIR . "/upload/gpic";
                 if (!is_dir($dir)) {
                     mkdir($dir, 0777);
                 }
                 $dir = HOME_DIR . "/upload/gpic/" . date("Ymd");
                 if (!is_dir($dir)) {
                     mkdir($dir, 0777);
                 }
                 $filename = $dir . "/" . md5($supplier_id . $object_id);
                 $p_type = 'gimage';
                 break;
             case 'spec_value':
                 $filename = MEDIA_DIR . "/default/" . "spec-" . md5($supplier_id . $object_id);
                 $p_type = 'spec';
                 break;
             case 'udfimg':
                 $dir = MEDIA_DIR . "/goods/" . date("Ymd");
                 if (!is_dir($dir)) {
                     mkdir($dir, 0777);
                 }
                 $filename = $dir . "/" . md5($supplier_id . $object_id);
                 $p_type = 'udfimg';
                 break;
             case 'brand_logo':
                 $dir = MEDIA_DIR . "/brand";
                 if (!is_dir($dir)) {
                     mkdir($dir, 0777);
                 }
                 $dir .= "/" . date("Ymd");
                 if (!is_dir($dir)) {
                     mkdir($dir, 0777);
                 }
                 $filename = $dir . "/" . md5($supplier_id . $object_id);
                 $p_type = 'brand';
                 break;
         }
         $send_params = array('supplier_id' => $supplier_id, 'type' => $p_type, 'id' => $object_id, 'return_data' => 'raw');
         $token = $this->system->getConf('certificate.token');
         $img_api = $this->system->api_call(IMAGESERVER, IMAGESERVER_HOST, IMAGESERVER_PATH, IMAGESERVER_PORT, $token);
         $file = $img_api->getApiData('getPicById', API_VERSION, $send_params);
         if ($file === false) {
             if (!is_null($image['command_id'])) {
                 $table = 'sdb_data_sync_' . $supplier_id;
                 $rs = $this->db->query("SELECT * FROM sdb_image_sync WHERE img_sync_id=" . intval($image['img_sync_id']));
                 $sql = $this->db->GetUpdateSQL($rs, array('failed' => 'true'));
                 $this->db->exec($sql);
                 $rs = $this->db->query("SELECT * FROM " . $table . " WHERE command_id=" . intval($image['command_id']));
                 $sql = $this->db->GetUpdateSQL($rs, array('img_down_failed' => 'true'));
                 $this->db->exec($sql);
             }
             return -1;
         } else {
             file_put_contents($filename, $file);
             list($img_width, $img_height, $img_type, $img_attr) = getimagesize($filename);
             $postfix = isset($image_type[$img_type]) ? $image_type[$img_type] : "jpg";
             rename($filename, $filename . "." . $postfix);
             $sql = "DELETE FROM sdb_image_sync WHERE img_sync_id=" . $image['img_sync_id'];
             $this->db->exec($sql);
             //下载完更新对应的gimage,spec_values的记录
             switch ($type) {
                 case 'gimage':
                     $image_path = "gpic/" . date("Ymd") . "/" . md5($supplier_id . $object_id) . "." . $postfix;
                     $supplier_gimage_id = $object_id;
                     $gimage_info = array('source' => $image_path, 'sync_time' => $image['add_time']);
                     $rs = $this->db->query("SELECT * FROM sdb_gimages WHERE supplier_id=" . floatval($supplier_id) . " AND supplier_gimage_id=" . intval($supplier_gimage_id));
                     $sql = $this->db->GetUpdateSQL($rs, addslashes_array($gimage_info));
                     $this->db->exec($sql);
                     //获取本地对应的goods信息
                     $goods = $this->db->selectrow("SELECT goods_id FROM sdb_gimages WHERE supplier_id=" . floatval($supplier_id) . " AND supplier_gimage_id=" . intval($supplier_gimage_id) . " ORDER BY goods_id DESC");
                     $local_goods_id = $goods['goods_id'];
                     $goods_info = $this->db->selectrow("SELECT goods_id,image_default,udfimg,spec_desc FROM sdb_goods WHERE goods_id=" . intval($local_goods_id));
                     //如果该商品的所有图片都下载完了,则生成所有尺寸的图片
                     if ($this->_checkGenAllImage($supplier_id, $local_goods_id)) {
                         $gimage =& $this->system->loadModel('goods/gimage');
                         //$gimage->gen_all_size_by_goods_id($goods_info['goods_id'],$goods_info['image_default'],$goods_info['udfimg']=='true');
                         $gimage->gen_all_size_by_goods_id($goods_info['goods_id'], $goods_info['image_default'], false);
                         //更新商品的spec_desc中的spec_goods_images信息(规格关联图册的信息)
                         $goods_spec_desc = unserialize($goods_info['spec_desc']);
                         if (!empty($goods_spec_desc)) {
                             foreach ($goods_spec_desc as $k1 => $v1) {
                                 if (!empty($v1)) {
                                     foreach ($v1 as $k2 => $v2) {
                                         if (isset($v2['spec_goods_images']) && !empty($v2['spec_goods_images'])) {
                                             $spec_goods_images = explode(",", $v2['spec_goods_images']);
                                             $tmp_spec_goods_images = array();
                                             foreach ($spec_goods_images as $plat_gimage_id) {
                                                 $tmp_gimage = $this->db->selectrow("SELECT gimage_id FROM sdb_gimages WHERE supplier_id=" . floatval($supplier_id) . " AND supplier_gimage_id=" . intval($plat_gimage_id));
                                                 $tmp_spec_goods_images[] = $tmp_gimage['gimage_id'];
                                             }
                                             $goods_spec_desc[$k1][$k2]['spec_goods_images'] = implode(",", $tmp_spec_goods_images);
                                         }
                                     }
                                 }
                             }
                         }
                         $rs = $this->db->query("SELECT * FROM sdb_goods WHERE goods_id=" . intval($local_goods_id));
                         $sql = $this->db->GetUpdateSQL($rs, array('spec_desc' => serialize($goods_spec_desc)));
                         $this->db->exec($sql);
                         //将下载失败的那些图片重新置空
                         $goods_gimage_info = $this->db->select("SELECT * FROM sdb_gimages WHERE goods_id=" . $local_goods_id);
                         foreach ($goods_gimage_info as $goods_gimage) {
                             if ($this->db->selectrow("SELECT img_sync_id FROM sdb_image_sync WHERE type='gimage' AND supplier_id=" . floatval($supplier_id) . " AND supplier_object_id=" . $goods_gimage['supplier_gimage_id'] . " AND failed='true'")) {
                                 $rs = $this->db->query("SELECT * FROM sdb_gimages WHERE gimage_id=" . $goods_gimage['gimage_id']);
                                 $sql = $this->db->GetUpdateSQL($rs, array('small' => '', 'big' => '', 'thumbnail' => ''));
                                 $this->db->exec($sql);
                                 if ($goods_info['image_default'] == $goods_gimage['gimage_id']) {
                                     $rs = $this->db->query("SELECT * FROM sdb_goods WHERE goods_id=" . intval($local_goods_id));
                                     $sql = $this->db->GetUpdateSQL($rs, array('thumbnail_pic' => '', 'small_pic' => '', 'big_pic' => ''));
                                     $this->db->exec($sql);
                                 }
                             }
                         }
                     }
                     break;
                 case 'spec_value':
                     $image_path = "images/default/spec-" . md5($supplier_id . $object_id) . "." . $postfix;
                     $image_path = $image_path . "|" . "default/spec-" . md5($supplier_id . $object_id) . "." . $postfix . "|fs_storager";
                     $supplier_spec_value_id = $object_id;
                     $spec_value_info = array('spec_image' => $image_path);
                     $rs = $this->db->query("SELECT * FROM sdb_spec_values WHERE supplier_id=" . floatval($supplier_id) . " AND supplier_spec_value_id=" . intval($supplier_spec_value_id));
                     $sql = $this->db->GetUpdateSQL($rs, addslashes_array($spec_value_info));
                     $this->db->exec($sql);
                     break;
                 case 'udfimg':
                     //暂时无下载自定义商品图片的需求
                     $image_path = "images/goods/" . date("Ymd") . "/" . md5($supplier_id . $object_id) . "." . $postfix;
                     $image_path = $image_path . "|" . "/goods/" . date("Ymd") . "/" . md5($supplier_id . $object_id) . "." . $postfix . "|fs_storager";
                     $goods_thumbnail_pic = array('thumbnail_pic' => $image_path);
                     $rs = $this->db->query("SELECT * FROM sdb_goods WHERE supplier_id=" . floatval($supplier_id) . " AND supplier_goods_id=" . intval($object_id));
                     $sql = $this->db->GetUpdateSQL($rs, addslashes_array($goods_thumbnail_pic));
                     $this->db->exec($sql);
                     break;
                 case 'brand_logo':
                     $image_path = "images/brand/" . date("Ymd") . "/" . md5($supplier_id . $object_id) . "." . $postfix;
                     $image_path = $image_path . "|" . "/brand/" . date("Ymd") . "/" . md5($supplier_id . $object_id) . "." . $postfix . "|fs_storager";
                     $brand_logo_info = array('brand_logo' => $image_path);
                     $rs = $this->db->query("SELECT * FROM sdb_brand WHERE supplier_id=" . floatval($supplier_id) . " AND supplier_brand_id=" . intval($object_id));
                     $sql = $this->db->GetUpdateSQL($rs, addslashes_array($brand_logo_info));
                     $this->db->exec($sql);
                     break;
             }
             return 1;
         }
     } else {
         $this->_updateLock('download_image', false);
         return 0;
     }
 }
Example #11
0
/**
 * update_options
 *
 * updates the options of a given category with a
 * given string of options
 *
 * @param array $options
 * @param string $category
 * @return bool
 */
function update_options($options, $category)
{
    if ($options == 0 || empty($options)) {
        return false;
    }
    $options = addslashes_array($options);
    if (count($options) != 0) {
        query('delete from ' . DB_OPTIONS . ' where category="' . $category . '"');
        $query = 'insert into ' . DB_OPTIONS . ' values ';
        $i = 0;
        foreach ($options as $option => $value) {
            ++$i;
            $query .= '("' . addslashes($option) . '","' . addslashes($value) . '","' . $category . '")';
            if (count($options) != $i) {
                $query .= ',';
            }
        }
        query($query);
    }
    return true;
}
Example #12
0
    }
} elseif ($pmb_notice_controle_doublons != 0 && !$analysis_id) {
    //Si control de dédoublonnage activé
    $sign = new notice_doublon();
    $signature = $sign->gen_signature();
    $requete = "select signature, niveau_biblio ,notice_id from notices where signature='{$signature}'";
    if ($serial_id) {
        $requete .= " and notice_id != '{$analysis_id}' ";
    }
    //$requete.= " limit 1 ";
    $result = pmb_mysql_query($requete, $dbh);
    if ($dbls = pmb_mysql_num_rows($result)) {
        //affichage de l'erreur, en passant tous les param postés (serialise) pour l'éventuel forcage
        $tab = new stdClass();
        $tab->POST = addslashes_array($_POST);
        $tab->GET = addslashes_array($_GET);
        $ret_url = urlencode(serialize($tab));
        require_once "{$class_path}/mono_display.class.php";
        require_once "{$class_path}/serial_display.class.php";
        print "\n\t\t\t<br /><div class='erreur'>{$msg['540']}</div>\n\t\t\t<script type='text/javascript' src='./javascript/tablist.js'></script>\n\t\t\t<div class='row'>\n\t\t\t\t<div class='colonne10'>\n\t\t\t\t\t<img src='./images/error.gif' align='left'>\n\t\t\t\t</div>\n\t\t\t\t<div class='colonne80'>\n\t\t\t\t\t<strong>" . $msg["gen_signature_erreur_similaire"] . "</strong>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class='row'>\n\t\t\t\t<form class='form-{$current_module}' name='dummy'  method='post' action='./catalog.php?categ=serials&sub=analysis&action=update&bul_id={$bul_id}&analysis_id={$analysis_id}'>\n\t\t\t\t\t<input type='hidden' name='forcage' value='1'>\n\t\t\t\t\t<input type='hidden' name='signature' value='{$signature}'>\n\t\t\t\t\t<input type='hidden' name='ret_url' value='{$ret_url}'>\n\t\t\t\t\t<input type='button' name='ok' class='bouton' value=' {$msg['76']} ' onClick='history.go(-1);'>\n\t\t\t\t\t<input type='submit' class='bouton' name='bt_forcage' value=' " . htmlentities($msg["gen_signature_forcage"], ENT_QUOTES, $charset) . " '>\n\t\t\t\t</form>\n\t\t\t\t\n\t\t\t</div>\n\t\t\t";
        if ($dbls < $nb_per_page_search) {
            $maxAffiche = $dbls;
            echo "<div class='row'><strong>" . sprintf($msg["gen_signature_erreur_similaire_nb"], $dbls, $dbls) . "</strong></div>";
        } else {
            $maxAffiche = $nb_per_page_search;
            echo "<div class='row'><strong>" . sprintf($msg["gen_signature_erreur_similaire_nb"], $maxAffiche, $dbls) . "</strong></div>";
        }
        $enCours = 1;
        while ($enCours <= $maxAffiche) {
            $r = pmb_mysql_fetch_object($result);
            if ($r->niveau_biblio != 's' && $r->niveau_biblio != 'a') {
Example #13
0
/**
 * 对数组的元素添加转义
 *
 * @param array $array
 * @return array
 */
function addslashes_array($value)
{
    if (empty($value)) {
        return $value;
    } else {
        if (is_array($value)) {
            foreach ($value as $k => $v) {
                if (is_array($v)) {
                    $value[$k] = addslashes_array($v);
                } else {
                    $value[$k] = addslashes($v);
                }
            }
            return $value;
        } else {
            return addslashes($value);
        }
    }
}
Example #14
0
 /**
  * 更新配置
  *
  * @param array $data
  * @param int $filter
  * @return boolean
  */
 function update($data, $filter)
 {
     $rule = $data['rule'];
     unset($data['rule_id']);
     unset($data['rule']);
     unset($data['__']);
     $data['rule_name'] = $this->generateRuleName($rule);
     addslashes_array($data);
     // 新增同步配置记录
     if (!$this->_update($data, $filter)) {
         trigger_error('修改失败!', E_USER_ERROR);
     }
     // 删除规则记录
     $this->deleteRuleRelation($filter['rule_id']);
     // 加入规则记录
     $this->insertRuleRelation($filter['rule_id'], $rule);
     return true;
 }
Example #15
0
 function toAdd()
 {
     $data = $_POST['goods'];
     $data['spec_desc'] = urldecode($data['spec_desc']);
     //        $data['spec_desc'] = addslashes_array($data['spec_desc']);
     $data['params'] = stripslashes_array($data['params']);
     if (!$data['goods_id']) {
         unset($data['goods_id']);
     }
     switch ($_GET['but']) {
         case 3:
             if ($data['goods_id']) {
                 $but_type = 'edit';
                 $url_href = 'index.php?ctl=goods/product&act=edit&p[0]=' . $data['goods_id'];
             } else {
                 $but_type = 'new';
                 $url_href = 'index.php?ctl=goods/product&act=index';
             }
             break;
         case 1:
             //$url_href = 'index.php?ctl=goods/product&act=addNew&p[0]='.$data['cat_id'].'&p[1]='.$data['type_id'].'&p[2]='.$data['brand_id'];
             $url_href = 'index.php?ctl=goods/product&act=addNew&p[0]=&p[1]=';
             break;
         default:
             $url_href = 'index.php?ctl=goods/product&act=index';
             break;
     }
     $this->begin($url_href);
     if (is_array($_POST['bn'])) {
         foreach ($_POST['bn'] as $aTmpBnk => $aTmpBn) {
             $_POST['bn'][$aTmpBnk] = trim($aTmpBn);
         }
     }
     $data['bn'] = trim($data['bn']);
     $data['product_bn'] = trim($data['product_bn']);
     $image_file = $data['image_file'];
     unset($data['image_file']);
     $udfimg = $data['udfimg'];
     unset($data['udfimg']);
     $data['marketable'] = $data['marketable'] ? $data['marketable'] : false;
     $data['adjunct'] = $_POST['adjunct'];
     if (count($_POST['price']) > 0) {
         //开启规格 多货品
         foreach ($_POST['vars'] as $vark => $varv) {
             $data['spec'][$vark] = $varv;
         }
         $data['spec'] = serialize($data['spec']);
         $sameProFlag = array();
         foreach ($_POST['price'] as $k => $price) {
             //设置销售多货品销售价等价格
             $data['price'] = $data['price'] ? min($price, $data['price']) : $price;
             //取最小商品价格
             $data['cost'] = $data['cost'] ? min($_POST['cost'][$k], $data['cost']) : $_POST['cost'][$k];
             $data['weight'] = $data['weight'] ? min($_POST['weight'][$k], $data['weight']) : $_POST['weight'][$k];
             if (!$_POST['mktprice'][$k]) {
                 //没有市场价
                 $oMath =& $this->system->loadModel('system/math');
                 if ($this->system->getConf('site.show_mark_price')) {
                     if ($this->system->getConf('site.market_price') == '1') {
                         $_POST['mktprice'][$k] = $this->system->getConf('site.market_rate') * $oMath->getOperationNumber($price);
                     }
                     if ($this->system->getConf('site.market_price') == '2') {
                         $_POST['mktprice'][$k] = $this->system->getConf('site.market_rate') + $oMath->getOperationNumber($price);
                     }
                 }
             }
             $products[$k]['price'] = $price;
             $products[$k]['bn'] = $_POST['bn'][$k];
             $products[$k]['store'] = trim($_POST['store'][$k]) === '' ? null : intval($_POST['store'][$k]);
             $products[$k]['alert'] = $_POST['alert'][$k];
             $products[$k]['cost'] = $_POST['cost'][$k];
             $products[$k]['weight'] = $_POST['weight'][$k];
             $products[$k]['mktprice'] = $_POST['mktprice'][$k];
             $products[$k]['store_place'] = $_POST['store_place'][$k];
             $products[$k]['marketable'] = $_POST['marketable'][$k];
             $data['mktprice'] = $data['mktprice'] ? min($_POST['mktprice'][$k], $data['mktprice']) : $_POST['mktprice'][$k];
             $newSpecI = 0;
             $proSpecFlag = '';
             foreach ($_POST['vars'] as $i => $v) {
                 $products[$k]['props']['spec'][$i] = urldecode(trim($_POST['val'][$i][$k]));
                 //array('规格(颜色)序号'=>'规格值(红色)')
                 $products[$k]['props']['spec_private_value_id'][$i] = trim($_POST['pSpecId'][$i][$k]);
                 $products[$k]['props']['spec_value_id'][$i] = trim($_POST['specVId'][$i][$k]);
                 if (trim($products[$k]['props']['spec'][$i]) === '') {
                     trigger_error(__('请为所有货品定义规格值'), E_USER_ERROR);
                     $this->end(false, __('请为所有货品定义规格值'));
                     exit;
                 }
                 $proSpecFlag .= $products[$k]['props']['spec_private_value_id'][$i] . '_';
             }
             if (in_array($proSpecFlag, $sameProFlag)) {
                 trigger_error(__('不能添加相同规格货品'), E_USER_ERROR);
                 $this->end(false, __('不能添加相同规格货品'));
                 exit;
             }
             $sameProFlag[$k] = $proSpecFlag;
             reset($proSpecFlag);
             reset($_POST['vars'], $_POST['pSpecId']);
             $products[$k]['pdt_desc'] = implode('、', $products[$k]['props']['spec']);
             //物品描述
             $products[$k]['pdt_desc'] = addslashes_array($products[$k]['pdt_desc']);
             foreach ($_POST['idata'] as $i => $v) {
                 $products[$k]['props']['idata'][$i] = $v[$k];
             }
             //设置会员价格
             if (is_array($_POST['mprice'])) {
                 foreach ($_POST['mprice'] as $levelid => $rows) {
                     $products[$k]['mprice'][$levelid] = floatval($rows[$k]);
                 }
             }
         }
         unset($sameProFlag);
         $data['products'] =& $products;
     } else {
         if (!$data['mktprice']) {
             $oMath =& $this->system->loadModel('system/math');
             if ($this->system->getConf('site.show_mark_price')) {
                 if ($this->system->getConf('site.market_price') == '1') {
                     $data['mktprice'] = $this->system->getConf('site.market_rate') * $oMath->getOperationNumber($data['price']);
                 }
                 if ($this->system->getConf('site.market_price') == '2') {
                     $data['mktprice'] = $this->system->getConf('site.market_rate') + $oMath->getOperationNumber($data['price']);
                 }
             }
         }
         $data['props']['idata'] = $_POST['idata'];
     }
     $objGoods =& $this->system->loadModel('trading/goods');
     foreach ($products as $k => $p) {
         if (empty($p['bn'])) {
             continue;
         }
         if ($objGoods->checkProductBn($p['bn'], $data['goods_id'])) {
             trigger_error(__('您所填写的货号已被使用,请检查!'), E_USER_ERROR);
             $this->end(false, __('您所填写的货号已被使用,请检查!'));
             exit;
         }
         $aBn[] = $p['bn'];
     }
     if (!empty($data['product_bn'])) {
         if ($objGoods->checkProductBn($data['product_bn'], $data['goods_id'])) {
             trigger_error(__('您所填写的货号已被使用,请检查!'), E_USER_ERROR);
             $this->end(false, __('您所填写的货号已被使用,请检查!'));
             exit;
         }
     }
     if (count($aBn) > count(array_unique($aBn))) {
         trigger_error(__('您所填写的货号已被使用,请检查!'), E_USER_ERROR);
         $this->end(false, __('您所填写的货号已被使用,请检查!'));
         exit;
     }
     if (!$data['type_id']) {
         $objCat =& $this->system->loadModel('goods/productCat');
         $aCat = $objCat->getFieldById($data['cat_id'], array('type_id'));
         $data['type_id'] = $aCat['type_id'];
     }
     //
     if (!($gid = $objGoods->save($data))) {
         $this->end(false, __('保存失败,请重试!'));
         exit;
     }
     $scheduled = array();
     $now = time();
     foreach ($_POST['scheduled'] as $time => $action) {
         if ($time > $now) {
             $scheduled[] = array('tasktime' => $time, 'action' => $action);
         }
     }
     $objGoods->set_auto_task($gid, $scheduled);
     if (isset($data['marketable']) && $data['marketable'] != $_POST['goods']['old_marketable']) {
         $objGoods->updateUpDownTime($data['marketable'], $gid, true);
     }
     $keywords = array();
     foreach ($objGoods->getKeywords($gid) as $keywordvalue) {
         $keywords[] = $keywordvalue['keyword'];
     }
     $keyword = implode('|', $keywords);
     if ($keyword != $_POST['keywords']['keyword']) {
         $objGoods->deleteKeywords($gid);
         if ($_POST['keywords']['keyword']) {
             $objGoods->addKeywords($gid, explode('|', $_POST['keywords']['keyword']));
         }
     }
     //处理商品图片
     $gimage =& $this->system->loadModel('goods/gimage');
     $gimage->saveImage($data['goods_id'], $data['db_thumbnail_pic'], $_POST['image_default'], $image_file, $udfimg, $_FILES);
     //相关商品
     foreach ($_POST['linkid'] as $k => $id) {
         $aLink[] = array('goods_1' => $data['goods_id'], 'goods_2' => $id, 'manual' => $_POST['linktype'][$id], 'rate' => 100);
     }
     $objProduct =& $this->system->loadModel('goods/products');
     $objProduct->toInsertLink($data['goods_id'], $aLink);
     /*
     * tag独立处理
             //处理TAG
             $objTag = &$this->system->loadModel('system/tag');
             $objTag->removeObjTag($data['goods_id']);
             foreach(space_split($_POST['tags']) as $tagName){
        $tagName = trim($tagName);
        if($tagName){
            if(!($tagid = $objTag->getTagByName('goods', $tagName))){
                $tagid = $objTag->newTag($tagName, 'goods');
            }
            $objTag->addTag($tagid, $data['goods_id']);
        }
             }
     */
     $oSupplier = $this->system->loadModel('distribution/supplier');
     if ($_POST['supplier_id']) {
         $newBn = array();
         if (isset($_POST['bn']) && is_array($_POST['bn'])) {
             foreach ($_POST['bn'] as $nbnk => $nbnv) {
                 $newBn[$_POST['old_bn'][$nbnk]] = $nbnv;
                 unset($_POST['source_bn'][$_POST['old_bn'][$nbnk]]);
             }
         } else {
             $newBn[$_POST['old_bn']] = $_POST['goods']['product_bn'];
             unset($_POST['src_bn']);
         }
         $oSupplier->updateSupplierPdtBn($newBn, $_POST['source_bn'], $_POST['supplier_id']);
     }
     if (isset($_POST['commandType'])) {
         if (in_array($_POST['commandType'], array('4', '5', '6'))) {
             $oSupplier->updateSyncStatus($_POST['command_id'], $_POST['supplier_id'], 'done');
         }
     }
     $oseo =& $this->system->loadModel('system/seo');
     $aData = array('keywords' => $_POST['goods']['seo']['meta_keywords'], 'descript' => $_POST['goods']['seo']['meta_description'], 'title' => $_POST['goods']['seo']['seo_title']);
     $oseo->set_seo('goods', $gid, $aData);
     //###
     if ($but_type == 'new') {
         $this->end(true, __('保存成功') . '<input type=hidden id="g_id" value=' . $gid . '>', 'index.php?ctl=goods/product&act=edit&p[0]=' . $gid);
     } else {
         if ($_GET['but'] == 1) {
             $this->end(true, __('保存成功') . '<input type=hidden id="g_id" value=' . $gid . '>', $url_href . $gid);
         } else {
             $this->end(true, __('保存成功') . '<input type=hidden id="g_id" value=' . $gid . '>');
         }
     }
 }
 function toAdd()
 {
     $data = $_POST['goods'];
     $data['spec_desc'] = urldecode($data['spec_desc']);
     //        $data['spec_desc'] = addslashes_array($data['spec_desc']);
     $data['params'] = stripslashes_array($data['params']);
     if (!$data['goods_id']) {
         unset($data['goods_id']);
     }
     switch ($_GET['but']) {
         case 3:
             if ($data['goods_id']) {
                 $but_type = 'edit';
                 $url_href = 'index.php?ctl=goods/product&act=edit&p[0]=' . $data['goods_id'];
             } else {
                 $but_type = 'new';
                 $url_href = 'index.php?ctl=goods/product&act=index';
             }
             break;
         case 1:
             //$url_href = 'index.php?ctl=goods/product&act=addNew&p[0]='.$data['cat_id'].'&p[1]='.$data['type_id'].'&p[2]='.$data['brand_id'];
             $url_href = 'index.php?ctl=goods/product&act=addNew&p[0]=&p[1]=';
             break;
         default:
             $url_href = 'index.php?ctl=goods/product&act=index';
             break;
     }
     $this->begin($url_href);
     if (count(explode('.', $_POST['scareInfo']['goodscore'])) >= 2) {
         $this->end(false, __('积分请用整数'));
         exit;
     }
     if (is_array($_POST['bn'])) {
         foreach ($_POST['bn'] as $aTmpBnk => $aTmpBn) {
             $_POST['bn'][$aTmpBnk] = trim($aTmpBn);
         }
     }
     $data['bn'] = trim($data['bn']);
     $data['product_bn'] = trim($data['product_bn']);
     $image_file = $data['image_file'];
     unset($data['image_file']);
     $udfimg = $data['udfimg'];
     unset($data['udfimg']);
     $data['marketable'] = $data['marketable'] ? $data['marketable'] : false;
     $data['adjunct'] = $_POST['adjunct'];
     if (count($_POST['price']) > 0) {
         //开启规格 多货品
         foreach ($_POST['vars'] as $vark => $varv) {
             $data['spec'][$vark] = $varv;
         }
         $data['spec'] = serialize($data['spec']);
         $sameProFlag = array();
         foreach ($_POST['price'] as $k => $price) {
             //设置销售多货品销售价等价格
             $data['price'] = $data['price'] ? min($price, $data['price']) : $price;
             //取最小商品价格
             $data['cost'] = $data['cost'] ? min($_POST['cost'][$k], $data['cost']) : $_POST['cost'][$k];
             $data['weight'] = $data['weight'] ? min($_POST['weight'][$k], $data['weight']) : $_POST['weight'][$k];
             if (!$_POST['mktprice'][$k]) {
                 //没有市场价
                 $oMath =& $this->system->loadModel('system/math');
                 if ($this->system->getConf('site.show_mark_price')) {
                     if ($this->system->getConf('site.market_price') == '1') {
                         $_POST['mktprice'][$k] = $this->system->getConf('site.market_rate') * $oMath->getOperationNumber($price);
                     }
                     if ($this->system->getConf('site.market_price') == '2') {
                         $_POST['mktprice'][$k] = $this->system->getConf('site.market_rate') + $oMath->getOperationNumber($price);
                     }
                 }
             }
             $products[$k]['price'] = $price;
             $products[$k]['bn'] = $_POST['bn'][$k];
             $products[$k]['store'] = trim($_POST['store'][$k]) === '' ? null : intval($_POST['store'][$k]);
             $products[$k]['alert'] = $_POST['alert'][$k];
             $products[$k]['cost'] = $_POST['cost'][$k];
             $products[$k]['weight'] = $_POST['weight'][$k];
             $products[$k]['mktprice'] = $_POST['mktprice'][$k];
             $products[$k]['store_place'] = $_POST['store_place'][$k];
             $products[$k]['marketable'] = $_POST['marketable'][$k];
             //数量
             $store += $products[$k]['store'];
             //end
             $data['mktprice'] = $data['mktprice'] ? min($_POST['mktprice'][$k], $data['mktprice']) : $_POST['mktprice'][$k];
             $newSpecI = 0;
             $proSpecFlag = '';
             foreach ($_POST['vars'] as $i => $v) {
                 $products[$k]['props']['spec'][$i] = urldecode(trim($_POST['val'][$i][$k]));
                 //array('规格(颜色)序号'=>'规格值(红色)')
                 $products[$k]['props']['spec_private_value_id'][$i] = trim($_POST['pSpecId'][$i][$k]);
                 $products[$k]['props']['spec_value_id'][$i] = trim($_POST['specVId'][$i][$k]);
                 if (trim($products[$k]['props']['spec'][$i]) === '') {
                     trigger_error(__('请为所有货品定义规格值'), E_USER_ERROR);
                     $this->end(false, __('请为所有货品定义规格值'));
                     exit;
                 }
                 $proSpecFlag .= $products[$k]['props']['spec_private_value_id'][$i] . '_';
             }
             if (in_array($proSpecFlag, $sameProFlag)) {
                 trigger_error(__('不能添加相同规格货品'), E_USER_ERROR);
                 $this->end(false, __('不能添加相同规格货品'));
                 exit;
             }
             $sameProFlag[$k] = $proSpecFlag;
             reset($proSpecFlag);
             reset($_POST['vars'], $_POST['pSpecId']);
             $products[$k]['pdt_desc'] = implode('、', $products[$k]['props']['spec']);
             //物品描述
             $products[$k]['pdt_desc'] = addslashes_array($products[$k]['pdt_desc']);
             foreach ($_POST['idata'] as $i => $v) {
                 $products[$k]['props']['idata'][$i] = $v[$k];
             }
             //设置会员价格
             if (is_array($_POST['mprice'])) {
                 foreach ($_POST['mprice'] as $levelid => $rows) {
                     $products[$k]['mprice'][$levelid] = floatval($rows[$k]);
                 }
             }
         }
         unset($sameProFlag);
         $data['products'] =& $products;
     } else {
         if (!$data['mktprice']) {
             $oMath =& $this->system->loadModel('system/math');
             if ($this->system->getConf('site.show_mark_price')) {
                 if ($this->system->getConf('site.market_price') == '1') {
                     $data['mktprice'] = $this->system->getConf('site.market_rate') * $oMath->getOperationNumber($data['price']);
                 }
                 if ($this->system->getConf('site.market_price') == '2') {
                     $data['mktprice'] = $this->system->getConf('site.market_rate') + $oMath->getOperationNumber($data['price']);
                 }
             }
         }
         $data['props']['idata'] = $_POST['idata'];
         //数量
         $store = $data['store'];
         //end
     }
     $objGoods =& $this->system->loadModel('trading/goods');
     foreach ($products as $k => $p) {
         if (empty($p['bn'])) {
             continue;
         }
         if ($objGoods->checkProductBn($p['bn'], $data['goods_id'])) {
             trigger_error(__('您所填写的货号已被使用,请检查!'), E_USER_ERROR);
             $this->end(false, __('您所填写的货号已被使用,请检查!'));
             exit;
         }
         $aBn[] = $p['bn'];
     }
     if (!empty($data['product_bn'])) {
         if ($objGoods->checkProductBn($data['product_bn'], $data['goods_id'])) {
             trigger_error(__('您所填写的货号已被使用,请检查!'), E_USER_ERROR);
             $this->end(false, __('您所填写的货号已被使用,请检查!'));
             exit;
         }
     }
     if (count($aBn) > count(array_unique($aBn))) {
         trigger_error(__('您所填写的货号已被使用,请检查!'), E_USER_ERROR);
         $this->end(false, __('您所填写的货号已被使用,请检查!'));
         exit;
     }
     if (!$data['type_id']) {
         $objCat =& $this->system->loadModel('goods/productCat');
         $aCat = $objCat->getFieldById($data['cat_id'], array('type_id'));
         $data['type_id'] = $aCat['type_id'];
     }
     //限时抢购
     if ($_POST['goods']['iflimit'] == 1) {
         if ($store) {
             if ($store < $_POST['scareInfo']['scare_count']) {
                 trigger_error(__('您所填写的限购数量超出库存,请检查!'), E_USER_ERROR);
                 $this->end(false, __('您所填写的限购数量超出库存,请检查!'));
                 exit;
             }
         }
         if (!empty($_POST['scareInfo']['s_hour'])) {
             if (!preg_match('/^[0-1]?[0-9]|2[0-3]:[0-5][0-9]$/', $_POST['scareInfo']['s_hour'])) {
                 trigger_error(__('请正确填写时间格式!'), E_USER_ERROR);
                 $this->end(false, __('请正确填写时间格式!'));
                 exit;
             }
             $_POST['scareInfo']['s_hour'] = explode(':', $_POST['scareInfo']['s_hour']);
         }
         if (!empty($_POST['scareInfo']['e_hour'])) {
             if (!preg_match('/^[0-1]?[0-9]|2[0-3]:[0-5][0-9]$/', $_POST['scareInfo']['e_hour'])) {
                 trigger_error(__('请正确填写时间格式!'), E_USER_ERROR);
                 $this->end(false, __('请正确填写时间格式!'));
                 exit;
             }
             $_POST['scareInfo']['e_hour'] = explode(':', $_POST['scareInfo']['e_hour']);
         }
         $data['s_time'] = strtotime($_POST['scareInfo']['s_date']) + intval($_POST['scareInfo']['s_hour'][0]) * 3600 + intval($_POST['scareInfo']['s_hour'][1]) * 60;
         $data['e_time'] = strtotime($_POST['scareInfo']['e_date']) + intval($_POST['scareInfo']['e_hour'][0]) * 3600 + intval($_POST['scareInfo']['e_hour'][1]) * 60;
         if ($data['s_time'] >= $data['e_time']) {
             trigger_error(__('您所填写的结束时间小于开始时间,请检查!'), E_USER_ERROR);
             $this->end(false, __('您所填写的结束时间小于开始时间,请检查!'));
             exit;
         }
         $special_time_bucket = array();
         if ($_POST['scareInfo']['is_special_time'] == 1) {
             $_POST['scareInfo']['specialTime'] = array_unique($_POST['scareInfo']['specialTime']);
             foreach ($_POST['specialTime'] as $key => $value) {
                 if ($value == '1|-1|-1') {
                     trigger_error(__('所填写的时间格式有误,请检查!'), E_USER_ERROR);
                     $this->end(false, __('所填写的时间格式有误,请检查!'));
                     exit;
                 }
                 $special_time = explode('|', $value);
                 if (!preg_match('/^[0-1]?[0-9]|2[0-3]:[0-5][0-9]$/', $special_time[1])) {
                     trigger_error(__('所填写的时间格式有误,请检查!'), E_USER_ERROR);
                     $this->end(false, __('所填写的时间格式有误,请检查!'));
                     exit;
                 }
                 if (!preg_match('/^[0-1]?[0-9]|2[0-3]:[0-5][0-9]$/', $special_time[2])) {
                     trigger_error(__('所填写的时间格式有误,请检查!'), E_USER_ERROR);
                     $this->end(false, __('所填写的时间格式有误,请检查!'));
                     exit;
                 }
                 $special_stime = explode(':', $special_time[1]);
                 $special_etime = explode(':', $special_time[2]);
                 $special_stime = intval($special_stime[0]) * 3600 + intval($special_stime[1]) * 60;
                 $special_etime = intval($special_etime[0]) * 3600 + intval($special_etime[1]) * 60;
                 if ($special_stime >= $special_etime) {
                     trigger_error(__('生效结束时间必须大于生效开始时间!'), E_USER_ERROR);
                     $this->end(false, __('生效结束时间必须大于生效开始时间!'));
                     exit;
                 }
                 $special_time_bucket[$key]['week'] = $special_time[0];
                 $special_time_bucket[$key]['sohour'] = $special_time[1];
                 $special_time_bucket[$key]['sthour'] = $special_stime;
                 $special_time_bucket[$key]['eohour'] = $special_time[2];
                 $special_time_bucket[$key]['ethour'] = $special_etime;
                 $special_time_bucket[$key]['original'] = $value;
                 //$special_time_bucket[]=$special_time[0].'|'.$special_stime.'|'.$special_etime;
             }
         }
     } else {
         $data['s_time'] = 0;
         $data['e_time'] = 0;
     }
     //end
     if (!($gid = $objGoods->save($data))) {
         $this->end(false, __('保存失败,请重试!'));
         exit;
     }
     //限时抢购
     $scareModel = new mdl_scare();
     if ($_POST['goods']['iflimit'] == 1) {
         $scareData = $_POST['scareInfo'];
         $scareData['goods_id'] = $gid;
         $scareData['s_time'] = $data['s_time'];
         $scareData['e_time'] = $data['e_time'];
         $scareData['iflimit'] = $_POST['goods']['iflimit'];
         $scareData['special_time_bucket'] = serialize($special_time_bucket);
         unset($pt);
         if ($scareData['forenotice_on'] == 1) {
             $scareData['forenotice_time'] = intval($scareData['forenotice_hour']) * 3600 + intval($scareData['forenotice_min']) * 60 + intval($scareData['forenotice_sec']);
         } else {
             $scareData['forenotice_time'] = 0;
         }
         if ($scareData['is_mprice'] == 1) {
             $memberLevel =& $this->system->loadModel('member/level');
             $memberLevel_scare = $memberLevel->getList('member_lv_id,name,dis_count,name');
             foreach ($_POST['scareMprice'] as $mlevel => $mprice) {
                 $scareData['scare_mprice'][$mlevel] = $mprice;
                 if (!$scareData['scare_mprice'][$mlevel]) {
                     foreach ($memberLevel_scare as $level) {
                         if ($mlevel == $level['member_lv_id']) {
                             $level['dis_count'] = $level['dis_count'] > 0 ? $level['dis_count'] : 1;
                             $scareData['scare_mprice'][$mlevel] = $level['dis_count'] * $_POST['scareInfo']['scare_price'];
                         }
                     }
                 }
             }
             $scareData['scare_mprice'] = $scareData['scare_mprice'] ? serialize($scareData['scare_mprice']) : 'null';
         }
         $scareData['count'] = $scareData['scare_count'];
         $scareModel->save($scareData);
     } else {
         $scareModel->delByGoodsId($gid);
     }
     //end
     $scheduled = array();
     $now = time();
     foreach ($_POST['scheduled'] as $time => $action) {
         if ($time > $now) {
             $scheduled[] = array('tasktime' => $time, 'action' => $action);
         }
     }
     $objGoods->set_auto_task($gid, $scheduled);
     $keywords = array();
     foreach ($objGoods->getKeywords($gid) as $keywordvalue) {
         $keywords[] = $keywordvalue['keyword'];
     }
     $keyword = implode('|', $keywords);
     if ($keyword != $_POST['keywords']['keyword']) {
         $objGoods->deleteKeywords($gid);
         if ($_POST['keywords']['keyword']) {
             $objGoods->addKeywords($gid, explode('|', $_POST['keywords']['keyword']));
         }
     }
     //处理商品图片
     $gimage =& $this->system->loadModel('goods/gimage');
     $gimage->saveImage($data['goods_id'], $data['db_thumbnail_pic'], $_POST['image_default'], $image_file, $udfimg, $_FILES);
     //相关商品
     foreach ($_POST['linkid'] as $k => $id) {
         $aLink[] = array('goods_1' => $data['goods_id'], 'goods_2' => $id, 'manual' => $_POST['linktype'][$id], 'rate' => 100);
     }
     $objProduct =& $this->system->loadModel('goods/products');
     $objProduct->toInsertLink($data['goods_id'], $aLink);
     /*
     * tag独立处理
     //处理TAG
     $objTag = &$this->system->loadModel('system/tag');
     $objTag->removeObjTag($data['goods_id']);
     foreach(space_split($_POST['tags']) as $tagName){
     $tagName = trim($tagName);
     if($tagName){
     if(!($tagid = $objTag->getTagByName('goods', $tagName))){
     $tagid = $objTag->newTag($tagName, 'goods');
     }
     $objTag->addTag($tagid, $data['goods_id']);
     }
     }
     */
     $oSupplier = $this->system->loadModel('distribution/supplier');
     if ($_POST['supplier_id']) {
         $newBn = array();
         if (isset($_POST['bn']) && is_array($_POST['bn'])) {
             foreach ($_POST['bn'] as $nbnk => $nbnv) {
                 $newBn[$_POST['old_bn'][$nbnk]] = $nbnv;
                 unset($_POST['source_bn'][$_POST['old_bn'][$nbnk]]);
             }
         } else {
             $newBn[$_POST['old_bn']] = $_POST['goods']['product_bn'];
             unset($_POST['src_bn']);
         }
         $oSupplier->updateSupplierPdtBn($newBn, $_POST['source_bn'], $_POST['supplier_id']);
     }
     if (isset($_POST['commandType'])) {
         if (in_array($_POST['commandType'], array('4', '5', '6'))) {
             $oSupplier->updateSyncStatus($_POST['command_id'], $_POST['supplier_id'], 'done');
         }
     }
     $oseo =& $this->system->loadModel('system/seo');
     $aData = array('keywords' => $_POST['goods']['seo']['meta_keywords'], 'descript' => $_POST['goods']['seo']['meta_description'], 'title' => $_POST['goods']['seo']['seo_title']);
     $oseo->set_seo('goods', $gid, $aData);
     //###
     if ($but_type == 'new') {
         $this->end(true, __('保存成功') . '<input type=hidden id="g_id" value=' . $gid . '>', 'index.php?ctl=goods/product&act=edit&p[0]=' . $gid);
     } else {
         if ($_GET['but'] == 1) {
             $this->end(true, __('保存成功') . '<input type=hidden id="g_id" value=' . $gid . '>', $url_href . $gid);
         } else {
             $this->end(true, __('保存成功') . '<input type=hidden id="g_id" value=' . $gid . '>');
         }
     }
 }
Example #17
0
 public function split_authority($id_authority)
 {
     $query = "select * from authorities_sources where num_authority = " . $id_authority . " and authority_type= '" . $this->notice->type . "' and num_origin_authority = " . $this->num_origin;
     $result = mysql_query($query);
     if (mysql_num_rows($result)) {
         $infos = mysql_fetch_object($result);
     }
     $data = addslashes_array($this->notice->specifics_data);
     switch ($this->notice->type) {
         case "author":
             $authority = new auteur(0);
             break;
         case "uniform_title":
             $authority = new titre_uniforme(0);
             break;
         case "collection":
             $authority = new collection(0);
             break;
         case "subcollection":
             $authority = new subcollection(0);
             break;
         case "category":
             //si on split une catégorie, on le fait dans la même branche...
             $query = "select num_parent from noeuds where id_noeud = " . $id_authority;
             $result = mysql_query($query);
             if (mysql_num_rows($result)) {
                 $num_parent = mysql_result($result, 0, 0);
             } else {
                 $num_parent = $this->get_parent_category();
             }
             $authority = new category(0);
             break;
         default:
             //	on fait rien...
             break;
     }
     if ($authority && !$authority->import_denied) {
         if ($this->notice->type == "category") {
             $result = $authority->update($data, $this->id_thesaurus, $num_parent, $this->notice->common_data['lang']);
         } else {
             $result = $authority->update($data, true);
         }
         if ($result) {
             $this->splitted = true;
             $this->authority_id = $authority->id;
             if ($infos->id_authority_source) {
                 $query = "update authorities_sources set \n\t\t\t\t\t\tnum_authority_source = " . $this->authority_id . ",\n\t\t\t\t\t\tauthority_favorite = 1,\n\t\t\t\t\t\tupdate_date = now() \n\t\t\t\t\twhere id_authority_source = " . $infos->id_authority_source;
                 mysql_query($query);
                 //on doit aussi gérer la séparation dans les notices
                 $query = "select * from notices_authorities_sources where num_authority_source = " . $infos->id_authority_source;
                 $result = mysql_query($query);
                 if (mysql_num_rows($result)) {
                     while ($row = mysql_fetch_object($result)) {
                         switch ($this->notice->type) {
                             case "author":
                                 $query = "update responsability set responsability_author = " . $this->authority_id . " where responsability_author = " . $info->num_authority . " and responsability_notice = " . $row->num_notice;
                                 break;
                             case "uniform_title":
                                 $query = "update notices_titres_uniformes set ntu_num_tu = " . $this->authority_id . " where ntu_num_tu = " . $info->num_authority . " and ntu_num_notice = " . $row->num_notice;
                                 break;
                             case "collection":
                                 $query = "update notices set coll_id = " . $this->authority_id . ", subcoll_id = 0 where notice_id = " . $row->num_notice;
                                 break;
                             case "subcollection":
                                 $query = "update notices set subcoll_id = " . $this->authority_id . " where notice_id = " . $row->num_notice;
                                 break;
                             case "category":
                                 $query = "update notices_categories set num_noeud = " . $this->authority_id . " where notcateg_notice = " . $row->num_notice;
                                 break;
                             default:
                                 $query = "";
                         }
                         if ($query != "") {
                             mysql_query($query);
                         }
                     }
                     return true;
                 }
             } else {
                 $query = "insert into authorities_sources set \n\t\t\t\t\t\tnum_authority = " . $this->authority_id . ",\n\t\t\t\t\t\tauthority_number = '" . $this->notice->common_data['authority_number'] . "',\t\n\t\t\t\t\t\tauthority_type = '" . $this->notice->type . "',\n\t\t\t\t\t\tnum_origin_authority = " . $this->num_origin . ",\n\t\t\t\t\t\tauthority_favorite = 1,\n\t\t\t\t\t\timport_date = now(),\n\t\t\t\t\t\tupdate_date = now()";
                 return mysql_query($query);
             }
         }
     }
     return false;
 }
Example #18
0
/**
 * 数组转义
 * @param  array $arr_r 需处理数组
 */
function addslashes_array(&$arr_r)
{
    foreach ($arr_r as &$val) {
        is_array($val) ? addslashes_array($val) : ($val = addslashes($val));
    }
    unset($val);
}
Example #19
0
	public function show(){
		global $q, $where,  $texts, $col, $site, $filter, $filterLabel,$filter_chain, $from, $count, $index, $result, $lang, $config, $printMode, $detail, $colectionData, $sort, $fmt, $media, $csa;

        if (!get_magic_quotes_gpc()) {
            $q = addslashes_array($q);
            $filter = addslashes_array($filter);
            $filter_chain = addslashes_array($filter_chain);
        }
        if (isset($q) && $q != ''){
			$getParams .= "&q=" . urlencode(utf8_decode($q));
		}
		if (isset($filter) && $filter != ''){
			$getParams .= "&filter=" . str_replace("\\\"","&quot;",$filter);
		}
		if (isset($where) && $where != 'ALL'){
			$getParams .= "&where=" . $where;
		}
		if (isset($index) && $index != ''){
			$getParams .= "&index=" . $index;
		}
		if (isset($from) && $from != ''){
			$getParams .= "&from=" . $from;
		}
		if ( isset($filter_chain) ){
			foreach($filter_chain  as $filterValue ){
				$getParams .= "&filter_chain[]=" . str_replace("\\\"","&quot;",$filterValue);
			}
		}
        if (isset($sort) && $sort != ''){
            $getParams .= "&sort=" . $sort;
        }
        foreach($csa  as $csa_key => $csa_value ){
				$getParams .= "&" . $csa_key . "=" . $csa_value;
		}

		$q_escaped = str_replace("\\\"","&quot;",$q);
                $q_escaped = str_replace("\"","&quot;",$q_escaped);

		$textsCol = parse_ini_file("./languages/" . $lang . "/texts-" . $col . ".ini", false);

		$this->template->assign('lang',$lang);

		$this->template->assign('texts', $texts + $textsCol);
		$this->template->assign('printMode',$printMode);
		$this->template->assign('detail',$detail);

		$this->template->assign('config',$config);
		$this->template->assign('q_escaped',$q_escaped);
		$this->template->assign('col',$col);
		$this->template->assign('site',$site);

		$this->template->assign('filter',$filter);
		$this->template->assign('filterLabel',$filterLabel);
		$this->template->assign('filter_chain',$filter_chain);
		$this->template->assign('index',$index);
		$this->template->assign('from',$from);
                $this->template->assign('fmt',$fmt);
		$this->template->assign('numFound',$result->diaServerResponse[0]->response->numFound);
		$this->template->assign('colectionData',$colectionData);
		$this->template->assign('getParams',$getParams);
                $this->template->assign('media',$media);
                $this->template->assign('csa',$csa);

		$total = $result->diaServerResponse[0]->response->numFound;
		$pagination = $this->pagination($from, $count, $total);

		$this->template->assign('pagination',$pagination);
		$this->template->assign('result',$result->diaServerResponse[0]);
		$this->template->assign('links',$result->diaServerResponse[1]);

        // check for media (handheld, etc) parameter to apply specific templates
        if (isset($media) && $media != ''){

            $this->template->display($media . '/top.tpl');
            $this->template->display($media . '/result.tpl');
            $this->template->display($media . '/bottom.tpl');

        }else{  // default (screen) templates

            $this->template->display('top.tpl');
            if ($detail == '1'){
                $this->template->display('result-detail.tpl');
            }else{
    			$this->template->display('result.tpl');
    		}	
        	$this->template->display('bottom.tpl');
        }

	}
Example #20
0
            nettoyer_chaine($tree[$i]->sub, $tableau, $tableau_l, $aq, $not);
        }
    }
}
$tableau = array();
$tableau_l = array();
if ($user_query && trim($user_query) != "*") {
    $aq = new analyse_query(stripslashes($user_query), 0, 0, 1, 0, $opac_stemming_active);
    if (!$aq->error) {
        nettoyer_chaine("", $tableau, $tableau_l, $aq, 1);
    }
}
$inclure_recherche = "<script type='text/javascript' src='./includes/javascript/misc.js'></script>";
$inclure_recherche .= "<script>\n";
$inclure_recherche .= "terms=new Array('" . implode("','", $tableau) . "');\n";
$inclure_recherche .= "terms_litteraux=new Array('" . implode("','", addslashes_array($tableau_l)) . "');\n";
$inclure_recherche .= "\n";
$inclure_recherche .= "codes=new Array();\n";
$j = 0;
foreach ($carac_spec->table as $key => $val) {
    $values = explode("|", substr($val, 1, strlen($val) - 2));
    $i = 0;
    $temp = "[";
    while ($values[$i] != "") {
        $temp .= $values[$i];
        $i++;
    }
    $temp .= "]";
    $inclure_recherche .= "codes['{$key}']='{$temp}';\n";
    $j++;
}
Example #21
0
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
ob_start();
session_start();
if ($_COOKIE["userid"] != '') {
    //$_SESSION["userid"] = $_COOKIE["userid"];
}
setcookie("firewall", 1, time() + 3600);
///////////////////////////////////////////////////////////////////////////////////
$db_host = "localhost";
// Giữ mặc định
$db_name = 'lib';
// Thay Đổi
$db_username = '******';
// Thay Đổi
$db_password = '';
// Thay Đổi
@mysql_connect("{$db_host}", "{$db_username}", "{$db_password}") or die("ERROR");
@mysql_select_db("{$db_name}");
@mysql_query("SET NAMES 'UTF8'");
date_default_timezone_set('Asia/Ho_Chi_Minh');
///////////////////////////////////////////////////////////////////////////////////
if (!get_magic_quotes_gpc()) {
    function addslashes_array($in)
    {
        return is_array($in) ? array_map('addslashes_array', $in) : addslashes($in);
    }
    $_REQUEST = addslashes_array($_REQUEST);
    $_GET = addslashes_array($_GET);
    $_POST = addslashes_array($_POST);
    $_COOKIE = addslashes_array($_COOKIE);
}
Example #22
0
 /**
  * 写入退货货单
  *
  * @param int $supplier_orderid po单单号
  * @param array $data
  *                 array(
  *                     'dealer_order_id' => xxx,     
  *                     'money' => xxx,
  *                     'type' => return/delivery,
  *                     'is_protect' => true/false,
  *                     'delivery' => xxx,
  *                     'logi_name' => xxx,
  *                     'logi_no' => xxx,
  *                     'ship_name' => xxx,
  *                     'ship_area' => xxx,
  *                     'ship_addr' => xxx,
  *                     'ship_zip' => xxx,
  *                     'ship_tel' => xxx,
  *                     'ship_mobile' => xxx,
  *                     'ship_email' => xxx,
  *                     'ship_tel' => xxx,
  *                     't_begin' => xxx,
  *                     't_end' => xxx,
  *                     'status' => xxx,
  *                     'memo' => xxx,
  *                     'struct' => array(
  *                         'dealer_bn' => xxx,
  *                         'item_type' => xxx,
  *                         'product_bn' => xxx,
  *                         'product_name' => xxx,
  *                         'number' => xxx,
  *                       )
  *                   )
  * @return 设置发货成功
  */
 function add_reship_bill($input_data)
 {
     $supplier_id = $input_data['supplier_id'];
     $data = json_decode($input_data['data'], true);
     //        error_log(print_r($data, true), 3, "/home/bryant/errors.log");
     //        error_log(print_r(json_decode($data,true), true), 3, "/home/bryant/errors.log");
     $delivery_no = $this->_get_new_number('delivery');
     $_delivery_items = $data['struct'];
     $dealer_orderid = $data['dealer_order_id'];
     unset($data['struct']);
     /*
             $aShipStatus = $status = array(0=>'未发货',
                                            1=>'已全部发货',
                                            2=>'部分发货',
                                            3=>'部分退货',
                                            4=>'已全部退货' );
     */
     $ship_status = 5;
     //已全部退货
     foreach ($_delivery_items as $_items) {
         $_sql = sprintf('select sendnum from sdb_orders where bn=\'%s\'', $_items['dealer_bn']);
         $_arr_tmp = $this->db->selectrow($_sql);
         if ($_arr_tmp['sendnum'] > $_items['number']) {
             $ship_status = 3;
             //部分退货
         }
     }
     $_sql = sprintf('select member_id from sdb_orders where order_id=%s', $dealer_orderid);
     if ($_order_data = $this->db->selectrow($_sql)) {
         $data['member_id'] = $_order_data['member_id'];
         $data['type'] = 'return';
         $data['op_name'] = 'admin';
         $data['order_id'] = $dealer_orderid;
         $data['logi_id'] = null;
         $data['delivery_id'] = $delivery_no;
         $rs = $this->db->query('SELECT * FROM sdb_delivery WHERE 0=1');
         $data = addslashes_array($data);
         $_sql = $this->db->GetInsertSQL($rs, $data);
         if (!$this->db->exec($_sql)) {
             $this->api_response('fail', 'data fail', null, '退货单插入失败');
         } else {
             foreach ($_delivery_items as $_item) {
                 $_data = array('delivery_id' => $delivery_no, 'product_bn' => $_item['dealer_bn'], 'item_type' => $_item['item_type'], 'product_name' => $_item['product_name'], 'number' => $_item['number']);
                 $rs = $this->db->query('SELECT * FROM sdb_delivery_item WHERE 0=1');
                 $_data = addslashes_array($_data);
                 $_sql = $this->db->GetInsertSQL($rs, $_data);
                 $this->ww($_sql);
                 if (!$this->db->exec($_sql)) {
                     $this->api_response('fail', 'data fail', $result, '退货单插入失败');
                 }
                 //更新order_items 订单发货数量
                 $_sql = sprintf('update sdb_order_items set sendnum=sendnum-%d where order_id=%s and bn=\'%s\'', $_item['number'], $dealer_orderid, $_item['dealer_bn']);
                 $this->db->exec($_sql);
                 $this->ww($_sql);
             }
         }
     } else {
         //$this->api_response('fail','data fail',null,'订单不存在');
         $this->api_response('true', false, null);
     }
     $ship_status = 4;
     //全部发货
     $_order_items = $this->db->select('select sendnum from sdb_order_items where order_id=' . $dealer_orderid);
     if (is_array($_order_items)) {
         foreach ($_order_items as $_item) {
             if ($_item['sendnum'] > 0) {
                 $ship_status = 3;
                 break;
             }
         }
     }
     $_data = array('ship_status' => $ship_status);
     $rs = $this->db->exec('SELECT * FROM sdb_orders WHERE order_id=' . $dealer_orderid);
     $_sql = $this->db->getUpdateSQL($rs, $_data);
     $this->ww($_sql);
     if (!$this->db->exec($_sql)) {
         $this->api_response('fail', 'data fail', null, '更新退货单状态失败');
     }
     //更新订单操作记录,add by hujianxin
     $this->_add_order_log($dealer_orderid, $delivery_no);
     $this->api_response('true', false, null);
 }
Example #23
0
function addslashes_array(&$array)
{
    if (is_array($array)) {
        foreach ($array as $k => $v) {
            $array[$k] = addslashes_array($v);
        }
    } elseif (is_string($array)) {
        $array = addslashes($array);
    }
    return $array;
}
Example #24
0
function sanitize_input()
{
    if (!get_magic_quotes_gpc()) {
        $_POST = addslashes_array($_POST);
        $_GET = addslashes_array($_GET);
        $_COOKIE = addslashes_array($_COOKIE);
        $_REQUEST = addslashes_array($_REQUEST);
    }
}
Example #25
0
 function commit_to_db()
 {
     if (!$this->id) {
         return;
     }
     global $dbh;
     $this->config = addslashes_array($this->config);
     $serialized = serialize($this->config);
     $sql = "REPLACE INTO connectors_out_sources SET connectors_out_source_id = " . $this->id . ", connectors_out_sources_connectornum = " . $this->connector_id . ", connectors_out_source_name='" . addslashes($this->name) . "', connectors_out_source_comment = '" . addslashes($this->comment) . "', connectors_out_source_config = '" . addslashes($serialized) . "'";
     mysql_query($sql, $dbh);
 }
Example #26
0
 /**
  * 根据供应商id,上游商品的brand_id,获取本地对应的brand_id
  *
  * @param int $supplier_id
  * @param int $supplier_brand_id
  * @return int
  */
 function _getLocalBrandByPlatBrand($supplier_id, $supplier_brand_id)
 {
     $key = md5($supplier_id . $supplier_brand_id . "brand");
     if (!isset($this->local_brand[$key])) {
         // 从平台上获取brand_name&brand_keywords 查找本地的brand_id  2009-10-13 13:20 wubin
         $brand_info = $this->api->getApiData('getBrandByID', API_VERSION, array('supplier_id' => $supplier_id, 'id' => $supplier_brand_id), true, true);
         addslashes_array($brand_info);
         if ($brand_info['brand_keywords']) {
             $local_brand_info = $this->db->selectrow("SELECT brand_id FROM sdb_brand WHERE brand_name='" . $brand_info['brand_name'] . "' AND brand_keywords='" . $brand_info['brand_keywords'] . "' ORDER BY brand_id DESC");
         } else {
             $local_brand_info = $this->db->selectrow("SELECT brand_id FROM sdb_brand WHERE brand_name='" . $brand_info['brand_name'] . "' AND (brand_keywords='' OR brand_keywords IS NULL) ORDER BY brand_id DESC");
         }
         $this->local_brand[$key] = $local_brand_info['brand_id'];
         return $this->local_brand[$key];
     } else {
         return $this->local_brand[$key];
     }
 }