📄 shopex46.php
字号:
<?php
/**
* shopex4.6转换程序插件
* ============================================================================
* 版权所有 2005-2008 上海商派网络科技有限公司,并保留所有权利。
* 网站地址: http://www.ecshop.com;
* ----------------------------------------------------------------------------
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
* 使用;不允许对程序代码以任何形式任何目的的再发布。
* ============================================================================
* $Author: testyang $
* $Id: shopex46.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'] = 'shopex46_desc';
/* 作者 */
$modules[$i]['author'] = 'ECSHOP R&D TEAM';
return;
}
/**
* 类
*/
class shopex46
{
/**
* 数据库连接 ADOConnection 对象
*/
var $sdb;
/**
* 表前缀
*/
var $sprefix;
/**
* 原系统根目录
*/
var $sroot;
/**
* 新系统根目录
*/
var $troot;
/**
* 新系统网站根目录
*/
var $tdocroot;
/**
* 原系统字符集
*/
var $scharset;
/**
* 新系统字符集
*/
var $tcharset;
/**
* 构造函数
*/
function shopex46(&$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_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/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()
{
/* 复制 html 编辑器的图片 */
$from = $this->sroot . '/syssite/home/shop/1/pictures/newsimg/';
$to = $this->troot . '/images/upload/';
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/';
/* 复制证书 */
$from = $this->sroot . '/cert/';
$to = $this->troot . '/cert/';
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();
}
/* 检查该分类是否有属性 */
$has_attr = false;
for ($i = 1; $i <= 40; $i++)
{
if (trim($row["attr".$i]) != '')
{
$has_attr = TRUE;
break;
}
}
/* 如果该分类有属性,插入商品类型,类型名称取分类名称 */
if ($has_attr)
{
if (!$db->autoExecute($ecs->table('goods_type'), $cat, 'INSERT', '', 'SILENT'))
{
//return $db->error();
}
}
/* 插入属性 */
$attr = array();
$attr['cat_id'] = $row['catid'];
$attr['attr_input_type'] = ATTR_INPUT;
$attr['attr_type'] = ATTR_NOT_NEED_SELECT;
for ($i = 1; $i <= 40; $i++)
{
if (trim($row["attr".$i]) != '')
{
$attr['attr_name'] = ecs_iconv($this->scharset, $this->tcharset, $row["attr".$i]);
$attr['sort_order'] = $i;
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 DISTINCT brand FROM ".$this->sprefix."mall_goods WHERE TRIM(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'])),
'brand_desc' => '',
);
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');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -