📄 shopex47.php
字号:
<?php
/**
* shopex4.7转换程序插件
* ============================================================================
* 版权所有 2005-2008 上海商派网络科技有限公司,并保留所有权利。
* 网站地址: http://www.ecshop.com;
* ----------------------------------------------------------------------------
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
* 使用;不允许对程序代码以任何形式任何目的的再发布。
* ============================================================================
* $Author: testyang $
* $Id: shopex47.php 15013 2008-10-23 09:31:42Z testyang $
*/
if (!defined('IN_ECS'))
{
die('Hacking attempt');
}
/**
* 模块信息
*/
if (isset($set_modules) && $set_modules == TRUE)
{
$i = isset($modules) ? count($modules) : 0;
/* 代码 */
$modules[$i]['code'] = basename(__FILE__, '.php');
/* 描述对应的语言项 */
$modules[$i]['desc'] = 'shopex47_desc';
/* 作者 */
$modules[$i]['author'] = 'ECSHOP R&D TEAM';
return;
}
/* 类 */
class shopex47
{
/* 数据库连接 ADOConnection 对象 */
var $sdb;
/* 表前缀 */
var $sprefix;
/* 原系统根目录 */
var $sroot;
/* 新系统根目录 */
var $troot;
/* 新系统网站根目录 */
var $tdocroot;
/* 原系统字符集 */
var $scharset;
/* 新系统字符集 */
var $tcharset;
/* 构造函数 */
function shopex47(&$sdb, $sprefix, $sroot, $scharset = 'UTF8')
{
$this->sdb = $sdb;
$this->sprefix = $sprefix;
$this->sroot = $sroot;
$this->troot = str_replace('/includes/modules/convert', '', str_replace('\\', '/', dirname(__FILE__)));
$this->tdocroot = str_replace('/admin', '', dirname(PHP_SELF));
$this->scharset = $scharset;
if (EC_CHARSET == 'utf-8')
{
$tcharset = 'UTF8';
}
elseif (EC_CHARSET == 'gbk')
{
$tcharset = 'GB2312';
}
$this->tcharset = $tcharset;
}
/**
* 需要转换的表(用于检查数据库是否完整)
* @return array
*/
function required_tables()
{
return array(
$this->sprefix.'mall_offer_pcat',$this->sprefix.'mall_brand',$this->sprefix.'mall_goods',$this->sprefix.'mall_offer_linkgoods', $this->sprefix.'mall_member_level',$this->sprefix.'mall_member',$this->sprefix.'mall_offer_p',$this->sprefix.'mall_offer_deliverarea',$this->sprefix.'mall_offer_t',$this->sprefix.'mall_offer_ncat',$this->sprefix.'mall_offer_ncon',$this->sprefix.'mall_offer_link',
$this->sprefix.'mall_orders',$this->sprefix.'mall_items',$this->sprefix.'mall_offer',
);
}
/**
* 必需的目录
* @return array
*/
function required_dirs()
{
return array(
'/syssite/home/shop/1/pictures/brandimg/',
'/syssite/home/shop/1/pictures/newsimg/',
'/syssite/home/shop/1/pictures/productsimg/big/',
'/syssite/home/shop/1/pictures/productsimg/small/',
'/syssite/home/shop/1/pictures/linkimg/',
'/cert/',
);
}
/**
* 下一步操作:空表示结束
* @param string $step 当前操作:空表示开始
* @return string
*/
function next_step($step)
{
/* 所有操作 */
$steps = array(
'' => 'step_file',
'step_file' => 'step_cat',
'step_cat' => 'step_brand',
'step_brand' => 'step_goods',
'step_goods' => 'step_users',
'step_users' => 'step_article',
'step_article' => 'step_order',
'step_order' => 'step_config',
'step_config' => '',
);
return $steps[$step];
}
/**
* 执行某个步骤
* @param string $step
*/
function process($step)
{
$func = str_replace('step', 'process', $step);
return $this->$func();
}
/**
* 复制文件
* @return 成功返回true,失败返回错误信息
*/
function process_file()
{
/* 复制品牌图片 */
$from = $this->sroot . '/syssite/home/shop/1/pictures/brandimg/';
$to = $this->troot . '/data/brandlogo/';
copy_files($from, $to);
/* 复制 html 编辑器的图片 */
$from = $this->sroot . '/syssite/home/shop/1/pictures/newsimg/';
$to = $this->troot . '/images/upload/Image/';
copy_files($from, $to);
/* 复制商品图片 */
$to = $this->troot . '/images/' . date('Ym') . '/';
$from = $this->sroot . '/syssite/home/shop/1/pictures/productsimg/big/';
copy_files($from, $to, 'big_');
$from = $this->sroot . '/syssite/home/shop/1/pictures/productsimg/small/';
copy_files($from, $to, 'small_');
$from = $this->sroot . '/syssite/home/shop/1/pictures/productsimg/big/';
copy_files($from, $to, 'original_');
/* 复制友情链接图片 */
$from = $this->sroot . '/syssite/home/shop/1/pictures/linkimg/';
$to = $this->troot . '/data/afficheimg/';
copy_files($from, $to);
/* 复制证书 */
$from = $this->sroot . '/cert/';
$to = $this->troot . '/cert/';
copy_files($from, $to);
return TRUE;
}
/**
* 商品分类
* @return 成功返回true,失败返回错误信息
*/
function process_cat()
{
global $db, $ecs;
/* 清空分类、商品类型、属性 */
truncate_table('category');
truncate_table('goods_type');
truncate_table('attribute');
/* 查询分类并循环处理 */
$sql = "SELECT * FROM ".$this->sprefix."mall_offer_pcat";
$res = $this->sdb->query($sql);
while ($row = $this->sdb->fetchRow($res))
{
$cat = array();
$cat['cat_id'] = $row['catid'];
$cat['cat_name'] = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['cat']));
$cat['parent_id'] = $row['pid'];
$cat['sort_order'] = $row['catord'];
/* 插入分类 */
if (!$db->autoExecute($ecs->table('category'), $cat, 'INSERT', '', 'SILENT'))
{
//return $db->error();
}
}
/* 查询商品类型并循环处理 */
$sql = "SELECT * FROM ".$this->sprefix."mall_prop_category";
$res = $this->sdb->query($sql);
while ($row = $this->sdb->fetchRow($res))
{
$type = array();
$type['cat_id'] = $row['prop_cat_id'];
$type['cat_name'] = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['cat_name']));
$type['enabled'] = '1';
if (!$db->autoExecute($ecs->table('goods_type'), $type, 'INSERT', '', 'SILENT'))
{
//return $db->error();
}
}
/* 查询属性值并循环处理 */
$sql = "SELECT * FROM ".$this->sprefix."mall_prop WHERE prop_type = 'propvalue'";
$res = $this->sdb->query($sql);
while ($row = $this->sdb->fetchRow($res))
{
$attr = array();
$attr['attr_id'] = $row['prop_id'];
$attr['attr_name'] = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['prop_name']));
$attr['cat_id'] = $row['prop_cat_id'];
$attr['sort_order'] = $row['ordnum'];
$attr['attr_input_type'] = '1';
$attr['attr_type'] = '1';
$sql = "SELECT DISTINCT prop_value FROM ".$this->sprefix."mall_prop_value WHERE prop_id = '$row[prop_id]'";
$attr['attr_values']= join("\n", $this->sdb->getCol($sql));
if (!$db->autoExecute($ecs->table('attribute'), $attr, 'INSERT', '', 'SILENT'))
{
//return $db->error();
}
}
/* 返回成功 */
return TRUE;
}
/**
* 品牌
* @return 成功返回true,失败返回错误信息
*/
function process_brand()
{
global $db, $ecs;
/* 清空品牌 */
truncate_table('brand');
/* 查询品牌并插入 */
$sql = "SELECT * FROM ".$this->sprefix."mall_brand";
$res = $this->sdb->query($sql);
while ($row = $this->sdb->fetchRow($res))
{
$brand = array(
'brand_name' => ecs_iconv($this->scharset, $this->tcharset, addslashes($row['brand_name'])),
'brand_desc' => '',
'site_url' => ecs_iconv($this->scharset, $this->tcharset, addslashes($row['brand_site_url'])),
'brand_logo' => ecs_iconv($this->scharset, $this->tcharset, addslashes($row['brand_logo']))
);
if (!$db->autoExecute($ecs->table('brand'), $brand, 'INSERT', '', 'SILENT'))
{
//return $db->error();
}
}
/* 返回成功 */
return TRUE;
}
/**
* 商品
* @return 成功返回true,失败返回错误信息
*/
function process_goods()
{
global $db, $ecs;
/* 清空商品、商品扩展分类、商品属性、商品相册、关联商品、组合商品、赠品 */
truncate_table('goods');
truncate_table('goods_cat');
truncate_table('goods_attr');
truncate_table('goods_gallery');
truncate_table('link_goods');
truncate_table('group_goods');
/* 查询品牌列表 name => id */
$brand_list = array();
$sql = "SELECT brand_id, brand_name FROM " . $ecs->table('brand');
$res = $db->query($sql);
while ($row = $db->fetchRow($res))
{
$brand_list[$row['brand_name']] = $row['brand_id'];
}
/* 取得商店设置 */
$sql = "SELECT offer_pointtype, offer_pointnum FROM ".$this->sprefix."mall_offer WHERE offerid = '1'";
$config = $this->sdb->getRow($sql);
/* 取得商品分类对应的商品类型 */
$cat_type_list = array();
$sql = "SELECT catid, prop_cat_id FROM ".$this->sprefix."mall_offer_pcat";
$res = $this->sdb->query($sql);
while ($row = $this->sdb->fetchRow($res))
{
$cat_type_list[$row['catid']] = $row['prop_cat_id'];
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -