function sms_make_images() { global $_FILES, $Name, $Title; $res = runsql("select * from sms_images_types"); while ($im = mysql_fetch_array($res)) { $f = $_FILES['Image']; //print $im[Name_rus]; $image = new cls_image($f); $im[Name_rus] = str_replace("x", "х", $im[Name_rus]); $ar = explode("х", $im[Name_rus]); //print "-$ar[0] $ar[1]-<br>"; $image->newWidth = $ar[0]; $image->newHeight = $ar[1]; $image->mix = ""; $image->fix = "width"; $image->mixpos = ""; //print "1"; $Small = new cls_image($image->imageResize()); $id = $im[TypeID]; $img1 = addslashes($Small->contents); $image = new cls_image($f); $image->newWidth = $ar[0]; $image->newHeight = $ar[1]; $image->fix = "width"; $image->mix = "image.png"; $image->mixpos = "center"; //print "2"; $Small2 = new cls_image($image->imageResize()); //print "1 $ar[0] $ar[1] $Small2->contents"; //exit; $img2 = addslashes($Small2->contents); mysql_query("insert into sms_images (\r\nName,Title,Preview,Image,Date,ImageDate,TypeID) values\r\n(\r\n'{$Name}',\r\n'{$Title}',\r\n\r\n'{$img1}',\r\n'{$img2}',\r\nunix_timestamp(),\r\nunix_timestamp(),\r\n'{$id}'\r\n)"); image_sms(mysql_insert_id(), $id, $Title, $id); } }
function SaveHTTPFile($fFileHTTPPath, $fFileSavePath, $fFileSaveName) { //记录程序开始的时间 $BeginTime = getmicrotime(); //取得文件名 $fFileSaveName = $fFileSavePath . "/" . $fFileSaveName; make_dir(dirname($fFileSaveName)); //取得文件的内容 ob_start(); readfile($fFileHTTPPath); $img = ob_get_contents(); ob_end_clean(); //$size = strlen($img); //保存到本地 $fp2 = @fopen($fFileSaveName, "a"); fwrite($fp2, $img); fclose($fp2); /*加水印代码*/ require_once ROOT_PATH . 'includes/cls_image.php'; $ext = get_extension($fFileSaveName); $fFileSaveName = convert_GIF_to_JPG($fFileSaveName); if (CopyFiles($fFileSaveName)) { $image = new cls_image(); $image->add_watermark($fFileSaveName, '', '../../../../' . $GLOBALS['waterMark']['watermark'], $GLOBALS['waterMark']['watermark_place'], $GLOBALS['waterMark']['watermark_alpha']); } if ($ext == 'gif' || $ext == '.gif') { back_JPG_to_GIF($fFileSaveName); } /*加水印代码--end*/ //记录程序运行结束的时间 $EndTime = getmicrotime(); //返回运行时间 return $EndTime - $BeginTime; }
function get_img($img_url = '') { $cls_imageobj = new cls_image(); $data = file_get_contents($img_url); $dir = date('Ym'); $filename = cls_image::random_filename(); $imgDir = $cls_imageobj->images_dir . '/' . $dir . '/source_img/' . $filename . '.jpg'; $dir = ROOT_PATH . $imgDir; $fp = @fopen($dir, "w"); @fwrite($fp, $data); fclose($fp); return $imgDir; }
$brand_id = 0; if (!empty($good_brand)) { $sql = 'INSERT INTO ' . $ecs->table('brand') . " (brand_name, is_show)" . " values('" . $good_brand . "', '1')"; $db->query($sql); $brand_id = $db->insert_Id(); } if (!empty($good_category)) { $sql = 'INSERT INTO ' . $ecs->table('category') . " (cat_name, parent_id, is_show)" . " values('" . $good_category . "', '0', '1')"; $db->query($sql); $cat_id = $db->insert_Id(); //货号 require_once ROOT_PATH . 'admin/includes/lib_goods.php'; $max_id = $db->getOne("SELECT MAX(goods_id) + 1 FROM " . $ecs->table('goods')); $goods_sn = generate_goods_sn($max_id); include_once ROOT_PATH . 'includes/cls_image.php'; $image = new cls_image($_CFG['bgcolor']); if (!empty($good_name)) { /* 检查图片:如果有错误,检查尺寸是否超过最大值;否则,检查文件类型 */ if (isset($_FILES['goods_img']['error'])) { // 最大上传文件大小 $php_maxsize = ini_get('upload_max_filesize'); $htm_maxsize = '2M'; // 商品图片 if ($_FILES['goods_img']['error'] == 0) { if (!$image->check_img_type($_FILES['goods_img']['type'])) { sys_msg($_LANG['invalid_goods_img'], 1, array(), false); } } elseif ($_FILES['goods_img']['error'] == 1) { sys_msg(sprintf($_LANG['goods_img_too_big'], $php_maxsize), 1, array(), false); } elseif ($_FILES['goods_img']['error'] == 2) { sys_msg(sprintf($_LANG['goods_img_too_big'], $htm_maxsize), 1, array(), false);
function upload_article_file($upload) { if (!make_dir("../" . DATA_DIR . "/article")) { /* 创建目录失败 */ return false; } $filename = cls_image::random_filename() . substr($upload['name'], strpos($upload['name'], '.')); $path = ROOT_PATH . DATA_DIR . "/article/" . $filename; if (move_upload_file($upload['tmp_name'], $path)) { return DATA_DIR . "/article/" . $filename; } else { return false; } }
/** * ECSHOP 广告管理程序 * ============================================================================ * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。 * 网站地址: http://www.ecshop.com; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ * $Author: liubo $ * $Id: ads.php 17217 2011-01-19 06:29:08Z liubo $ */ define('IN_ECS', true); require dirname(__FILE__) . '/includes/init.php'; include_once ROOT_PATH . 'includes/cls_image.php'; $image = new cls_image($_CFG['bgcolor']); $exc = new exchange($ecs->table("ad"), $db, 'ad_id', 'ad_name'); /* act操作项的初始化 */ if (empty($_REQUEST['act'])) { $_REQUEST['act'] = 'list'; } else { $_REQUEST['act'] = trim($_REQUEST['act']); } /*------------------------------------------------------ */ //-- 广告列表页面 /*------------------------------------------------------ */ if ($_REQUEST['act'] == 'list') { $pid = !empty($_REQUEST['pid']) ? intval($_REQUEST['pid']) : 0; $smarty->assign('ur_here', $_LANG['ad_list']); $smarty->assign('action_link', array('text' => $_LANG['ads_add'], 'href' => 'ads.php?act=add')); $smarty->assign('pid', $pid);
/** * ECSHOP 分销商管理程序 * ============================================================================ * * 版权所有 2008-2015 秦皇岛商之翼网络科技有限公司,并保留所有权利。 * 网站地址: http://www.68ecshop.com; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ * $Author: dqy $ * $Id: distributor.php 17217 2011-01-19 06:29:08Z dqy $ */ define('IN_ECS', true); require dirname(__FILE__) . '/includes/init.php'; include_once ROOT_PATH . '/includes/cls_image.php'; $image = new cls_image($_CFG['bgcolor']); $exc = new exchange($ecs->table('users'), $db, 'user_id', 'user_name'); /*------------------------------------------------------ */ //-- 分销商列表 /*------------------------------------------------------ */ if ($_REQUEST['act'] == 'list') { $sql = "SELECT rank_id, rank_name, min_points FROM " . $ecs->table('user_rank') . " ORDER BY min_points ASC "; $rs = $db->query($sql); $ranks = array(); while ($row = $db->FetchRow($rs)) { $ranks[$row['rank_id']] = $row['rank_name']; } $smarty->assign('user_ranks', $ranks); $smarty->assign('ur_here', $_LANG['01_users_list']); //判断是否是分销商 $distrib_rank = $_CFG['distrib_rank'];
/* 清除缓存 */ clear_cache_files(); /* 提示信息 */ $links[] = array('href' => 'supplier_rebate.php?act=list', 'text' => '返回本期佣金列表'); sys_msg('恭喜,处理成功!', 0, $links); } elseif ($_REQUEST['act'] == 'finish') { /* 检查权限 */ admin_priv('supplier_rebate'); /* 提交值 */ $rebate_id = intval($_POST['id']); $remark = isset($_POST['remark']) ? addslashes($_POST['remark']) : ''; if (($rebates = rebateHave($rebate_id)) === false) { sys_msg('该返佣记录不存在!'); } include_once ROOT_PATH . '/includes/cls_image.php'; $image = new cls_image($_CFG['bgcolor']); if ($_FILES['rebate_img']['size'] <= 0) { sys_msg('汇票凭证必须上传!'); } if ($_FILES['rebate_img']['error'] == 0) { if (!$image->check_img_type($_FILES['rebate_img']['type'])) { sys_msg($_LANG['invalid_goods_thumb'], 1, array(), false); } } $dir = 'rebate/' . local_date("Ymd", gmtime()) . '/' . $rebates['supplier_id']; $rebate_img = $image->upload_image($_FILES['rebate_img'], $dir); $rebate = array('is_pay_ok' => 1, 'pay_time' => gmtime(), 'rebate_img' => $rebate_img, 'status' => 4); /* 保存返佣信息 */ $db->autoExecute($ecs->table('supplier_rebate'), $rebate, 'UPDATE', "rebate_id = '" . $rebate_id . "'"); $loginfo = array('rebateid' => $rebate_id, 'addtime' => $addtime, 'reason' => '佣金' . createSign($rebates['rebate_id'], $rebates['supplier_id']) . '转帐:' . $rebates['payable_price'], 'supplier_money' => $rebates['payable_price'], 'doman' => '平台方:' . $_SESSION['user_name'], 'supplier_id' => $rebates['supplier_id']); $db->autoExecute($ecs->table('supplier_money_log'), $loginfo, 'INSERT');
/** * ECSHOP 包装管理程序 * ============================================================================ * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。 * 网站地址: http://www.ecshop.com; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ * $Author: liubo $ * $Id: pack.php 17217 2011-01-19 06:29:08Z liubo $ */ define('IN_ECS', true); require dirname(__FILE__) . '/includes/init.php'; include_once ROOT_PATH . 'includes/cls_image.php'; $image = new cls_image($_CFG['bgcolor']); $exc = new exchange($ecs->table("pack"), $db, 'pack_id', 'pack_name'); /*------------------------------------------------------ */ //-- 包装列表 /*------------------------------------------------------ */ if ($_REQUEST['act'] == 'list') { $smarty->assign('ur_here', $_LANG['06_pack_list']); $smarty->assign('action_link', array('text' => $_LANG['pack_add'], 'href' => 'pack.php?act=add')); $smarty->assign('full_page', 1); $packs_list = packs_list(); $smarty->assign('packs_list', $packs_list['packs_list']); $smarty->assign('filter', $packs_list['filter']); $smarty->assign('record_count', $packs_list['record_count']); $smarty->assign('page_count', $packs_list['page_count']); assign_query_info(); $smarty->display('pack_list.htm');
/** * 图片处理函数 * * @access public * @param integer $page * @param integer $page_size * @param integer $type * @param boolen $thumb 是否生成缩略图 * @param boolen $watermark 是否生成水印图 * @param boolen $change true 生成新图,删除旧图 false 用新图覆盖旧图 * @param boolen $silent 是否执行能忽略错误 * * @return void */ function process_image($page = 1, $page_size = 100, $type = 0, $thumb = true, $watermark = true, $change = false, $silent = true) { if ($type == 0) { $sql = "SELECT g.goods_id, g.original_img, g.goods_img, g.goods_thumb FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE g.original_img > ''" . $GLOBALS['goods_where']; $res = $GLOBALS['db']->SelectLimit($sql, $page_size, ($page - 1) * $page_size); while ($row = $GLOBALS['db']->fetchRow($res)) { $goods_thumb = ''; $image = ''; /* 水印 */ if ($watermark) { /* 获取加水印图片的目录 */ if (empty($row['goods_img'])) { $dir = dirname(ROOT_PATH . $row['original_img']) . '/'; } else { $dir = dirname(ROOT_PATH . $row['goods_img']) . '/'; } $image = $GLOBALS['image']->make_thumb(ROOT_PATH . $row['original_img'], $GLOBALS['_CFG']['image_width'], $GLOBALS['_CFG']['image_height'], $dir); //先生成缩略图 if (!$image) { //出错返回 $msg = sprintf($GLOBALS['_LANG']['error_pos'], $row['goods_id']) . "\n" . $GLOBALS['image']->error_msg(); if ($silent) { $GLOBALS['err_msg'][] = $msg; continue; } else { make_json_error($msg); } } $image = $GLOBALS['image']->add_watermark(ROOT_PATH . $image, '', $GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']); if (!$image) { //出错返回 $msg = sprintf($GLOBALS['_LANG']['error_pos'], $row['goods_id']) . "\n" . $GLOBALS['image']->error_msg(); if ($silent) { $GLOBALS['err_msg'][] = $msg; continue; } else { make_json_error($msg); } } /* 重新格式化图片名称 */ $image = reformat_image_name('goods', $row['goods_id'], $image, 'goods'); if ($change || empty($row['goods_img'])) { /* 要生成新链接的处理过程 */ if ($image != $row['goods_img']) { $sql = "UPDATE " . $GLOBALS['ecs']->table('goods') . " SET goods_img = '{$image}' WHERE goods_id = '" . $row['goods_id'] . "'"; $GLOBALS['db']->query($sql); /* 防止原图被删除 */ if ($row['goods_img'] != $row['original_img']) { @unlink(ROOT_PATH . $row['goods_img']); } } } else { replace_image($image, $row['goods_img'], $row['goods_id'], $silent); } } /* 缩略图 */ if ($thumb) { if (empty($row['goods_thumb'])) { $dir = dirname(ROOT_PATH . $row['original_img']) . '/'; } else { $dir = dirname(ROOT_PATH . $row['goods_thumb']) . '/'; } $goods_thumb = $GLOBALS['image']->make_thumb(ROOT_PATH . $row['original_img'], $GLOBALS['_CFG']['thumb_width'], $GLOBALS['_CFG']['thumb_height'], $dir); /* 出错处理 */ if (!$goods_thumb) { $msg = sprintf($GLOBALS['_LANG']['error_pos'], $row['goods_id']) . "\n" . $GLOBALS['image']->error_msg(); if ($silent) { $GLOBALS['err_msg'][] = $msg; continue; } else { make_json_error($msg); } } /* 重新格式化图片名称 */ $goods_thumb = reformat_image_name('goods_thumb', $row['goods_id'], $goods_thumb, 'thumb'); if ($change || empty($row['goods_thumb'])) { if ($row['goods_thumb'] != $goods_thumb) { $sql = "UPDATE " . $GLOBALS['ecs']->table('goods') . " SET goods_thumb = '{$goods_thumb}' WHERE goods_id = '" . $row['goods_id'] . "'"; $GLOBALS['db']->query($sql); /* 防止原图被删除 */ if ($row['goods_thumb'] != $row['original_img']) { @unlink(ROOT_PATH . $row['goods_thumb']); } } } else { replace_image($goods_thumb, $row['goods_thumb'], $row['goods_id'], $silent); } } } } else { /* 遍历商品相册 */ $sql = "SELECT album.goods_id, album.img_id, album.img_url, album.thumb_url, album.img_original FROM " . $GLOBALS['ecs']->table('goods_gallery') . " AS album " . $GLOBALS['album_where']; $res = $GLOBALS['db']->SelectLimit($sql, $page_size, ($page - 1) * $page_size); while ($row = $GLOBALS['db']->fetchRow($res)) { $thumb_url = ''; $image = ''; /* 水印 */ if ($watermark && file_exists(ROOT_PATH . $row['img_original'])) { if (empty($row['img_url'])) { $dir = dirname(ROOT_PATH . $row['img_original']) . '/'; } else { $dir = dirname(ROOT_PATH . $row['img_url']) . '/'; } $file_name = cls_image::unique_name($dir); $file_name .= cls_image::get_filetype(empty($row['img_url']) ? $row['img_original'] : $row['img_url']); copy(ROOT_PATH . $row['img_original'], $dir . $file_name); $image = $GLOBALS['image']->add_watermark($dir . $file_name, '', $GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']); if (!$image) { @unlink($dir . $file_name); $msg = sprintf($GLOBALS['_LANG']['error_pos'], $row['goods_id']) . "\n" . $GLOBALS['image']->error_msg(); if ($silent) { $GLOBALS['err_msg'][] = $msg; continue; } else { make_json_error($msg); } } /* 重新格式化图片名称 */ $image = reformat_image_name('gallery', $row['goods_id'], $image, 'goods'); if ($change || empty($row['img_url']) || $row['img_original'] == $row['img_url']) { if ($image != $row['img_url']) { $sql = "UPDATE " . $GLOBALS['ecs']->table('goods_gallery') . " SET img_url='{$image}' WHERE img_id='{$row['img_id']}'"; $GLOBALS['db']->query($sql); if ($row['img_original'] != $row['img_url']) { @unlink(ROOT_PATH . $row['img_url']); } } } else { replace_image($image, $row['img_url'], $row['goods_id'], $silent); } } /* 缩略图 */ if ($thumb) { if (empty($row['thumb_url'])) { $dir = dirname(ROOT_PATH . $row['img_original']) . '/'; } else { $dir = dirname(ROOT_PATH . $row['thumb_url']) . '/'; } $thumb_url = $GLOBALS['image']->make_thumb(ROOT_PATH . $row['img_original'], $GLOBALS['_CFG']['thumb_width'], $GLOBALS['_CFG']['thumb_height'], $dir); if (!$thumb_url) { $msg = sprintf($GLOBALS['_LANG']['error_pos'], $row['goods_id']) . "\n" . $GLOBALS['image']->error_msg(); if ($silent) { $GLOBALS['err_msg'][] = $msg; continue; } else { make_json_error($msg); } } /* 重新格式化图片名称 */ $thumb_url = reformat_image_name('gallery_thumb', $row['goods_id'], $thumb_url, 'thumb'); if ($change || empty($row['thumb_url'])) { if ($thumb_url != $row['thumb_url']) { $sql = "UPDATE " . $GLOBALS['ecs']->table('goods_gallery') . " SET thumb_url='{$thumb_url}' WHERE img_id='{$row['img_id']}'"; $GLOBALS['db']->query($sql); @unlink(ROOT_PATH . $row['thumb_url']); } } else { replace_image($thumb_url, $row['thumb_url'], $row['goods_id'], $silent); } } } } }
function set_form_params($str, $i) { global $search, $site_url, $engine_path, $r, $REMOTE_ADDR, $HTTP_POST_FILES, $HTTP_POST_VARS, $HTTP_GET_VARS, $id, $secpass, $lang, $auth, $er; $ndate = 0; $st = $str; if (count($HTTP_GET_VARS) > count($HTTP_POST_VARS)) { $HTTP_POST_VARS = $HTTP_GET_VARS; } if ($HTTP_POST_VARS['numrows']) { $mult = 1; } if (!$HTTP_POST_VARS['Time']) { $Time = mktime(); } if (!$HTTP_POST_VARS['Date']) { $Date = mktime(); } if (!$HTTP_POST_VARS['IP']) { $IP = $REMOTE_ADDR; } if ($this->act == "select") { $inner = $this->document->getElementsByTagName("header"); $fields = $inner[0]->getElementsByTagName("item"); } else { $inner = $this->document->getElementsByTagName("fields"); $fields = $inner[0]->getElementsByTagName("field"); } foreach ($fields as $field) { $item = $this->getTemplateControl($field); //$name=$field->getAttribute("name","no"); $name = $item->name; if ($name == "IP") { ${$name} = $REMOTE_ADDR; } $items[$name] = $item; if ($item->default && !$HTTP_POST_VARS[$name]) { $HTTP_POST_VARS[$name] = $item->default; } elseif ($item->type == "stringlike") { $HTTP_POST_VARS[$name] = "%{$HTTP_POST_VARS[$name]}%"; } if ($HTTP_POST_VARS[$name] == "%%") { $HTTP_POST_VARS[$name] = "%"; } if ($mult) { $f['name'] = $HTTP_POST_FILES[$name]['name'][$i]; $f['tmp_name'] = $HTTP_POST_FILES[$name]['tmp_name'][$i]; $f['size'] = $HTTP_POST_FILES[$name]['size'][$i]; $f['type'] = $HTTP_POST_FILES[$name]['type'][$i]; } else { $f = $HTTP_POST_FILES[$name]; } $type = $item->type; if (($type == "file" || $type == "image" || $type == "flag") && $f[name]) { $file = fopen($f['tmp_name'], "r"); //print $f[name].$f['tmp_name']; //exit; if (!$file) { $er = sysmessage(4) . "<br>"; } $fname = $f['tmp_name']; $maxsize = $field->getAttribute("maxsize", ''); $format = $field->getAttribute("format", ''); if (!strstr($format, strtolower(substr($f['name'], strpos($f['name'], ".") + 1))) && $format) { $er = sysmessage(5) . " .{$format}!<br>"; } ${$name} = fread($file, filesize($fname)); //обработка файлов-------------------- if ($item->type == "file" && $f[name]) { if (!$id) { $q = select("select 1+max(" . $name . "ID) from " . $this->table); } else { $q[0] = $id; } $dir = "files/" . $q[0] . "." . substr($f['name'], 1 + strpos($f['name'], ".")); move_uploaded_file($fname, $engine_path . $dir); ${$name} = $site_url . $dir; //print $par_val; //exit; } } if (($type == "flag" || $type == "image") && $f[name]) { $image = new cls_image($f); $image->maxsize = $field->getAttribute("maxsize", ''); $image->mix = $field->getAttribute("mix", ''); $image->mixpos = $field->getAttribute("mixpos", ''); if ($width = $field->getAttribute("width", '')) { $image->newWidth = $width; $image->fix = "width"; } if ($height = $field->getAttribute("height", '')) { $image->newHeight = $height; $image->fix = "height"; } $image->check(); ${$name} = $image->contents; $Type = $image->type; $ph[$name] = 1; $ph['Small'] = 1; if ($image->type != "gif") { $Small = new cls_image($image->imageResize()); $Small = $Small->contents; } else { $Small = ${$name}; } $ImageFormat = $image->imtype; } elseif ($type == "date" || $type == "currentdate" || $type == "datetime" || $type == "currentdatetime") { ${$name} = mktime($HTTP_POST_VARS['hour'][$ndate], $HTTP_POST_VARS['minute'][$ndate], $HTTP_POST_VARS['seconds'][$ndate], $HTTP_POST_VARS['month'][$ndate], $HTTP_POST_VARS['day'][$ndate], $HTTP_POST_VARS['year'][$ndate]); if (${$name} == -1 || !$HTTP_POST_VARS['month'][$ndate] || !$HTTP_POST_VARS['day'][$ndate] || !$HTTP_POST_VARS['year'][$ndate]) { unset(${$name}); } $ndate++; } elseif ($type == "sqldate") { ${$name} = $HTTP_POST_VARS['year'][$ndate] . "-" . $HTTP_POST_VARS['month'][$ndate] . "-" . $HTTP_POST_VARS['day'][$ndate]; if (${$name} == -1 || !$HTTP_POST_VARS['month'][$ndate] || !$HTTP_POST_VARS['day'][$ndate] || !$HTTP_POST_VARS['year'][$ndate]) { unset(${$name}); } $ndate++; } if (($type == "url" || $name == "url") && ${$name} && !strstr(${$name}, "http://")) { ${$name} = "http://" . ${$name}; } } while ($q = strpos($str, "\$")) { $par_name = substr($str, 1 + $q, strpos($str, ";", 1 + $q) - $q - 1); if (strstr($par_name, "->")) { $ob = substr($par_name, 0, strpos($par_name, "->")); $var = substr($par_name, 2 + strpos($par_name, "->")); $vname = $ob . $var; $st = str_replace($par_name, $vname, $st); $str = str_replace($par_name, $vname, $str); $par_name = $vname; if (!${$par_name}) { ${$par_name} = ${$ob}->{$var}; } } elseif (strstr($par_name, "[")) { $ob = substr($par_name, 0, strpos($par_name, "[")); $var = substr($par_name, 1 + strpos($par_name, "[")); $var = substr($var, 0, strlen($var) - 1); $st = str_replace($par_name, $var, $st); $str = str_replace($par_name, $var, $str); $par_name = $var; if (!${$par_name}) { ${$par_name} = ${$ob}[$var]; } } else { if ($r[$par_name]) { ${$par_name} = $r[$par_name]; } elseif ($HTTP_POST_VARS[$par_name]) { ${$par_name} = $HTTP_POST_VARS[$par_name]; } if (!${$par_name} && !strstr($par_name, ">")) { $p = select("select @{$par_name}"); if ($p[0]) { ${$par_name} = $p[0]; } } if (is_Array(${$par_name})) { $parval = ${$par_name}; ${$par_name} = $parval[$i]; } $str = substr($str, 1 + $q); $st = str_replace("\$" . $par_name . ";", ${$par_name}, $st); $str = str_replace("\$" . $par_name . ";", ${$par_name}, $str); } } $str = $st; $w = 0; while ($q = strpos($str, "@")) { //отсекаем до ; $pos = strpos($str, ";", 1 + $q); if ($pos && (!($pos2 = strpos($str, "=", 1 + $q)) || $pos < $pos2) && (!($pos2 = strpos($str, ",", 1 + $q)) || $pos < $pos2) && (!($pos2 = strpos($str, " ", 1 + $q)) || $pos < $pos2)) { $par_name = substr($str, 1 + $q, $pos - $q - 1); $str = substr($str, 1 + $q); $item = $items[$par_name]; if ($item->unique && $mult) { foreach ($HTTP_POST_VARS[$par_name] as $val) { if ($ar[$val]) { $er .= sysmessage(6) . " {$item->caption}={$val} " . sysmessage(7) . "!<br>"; } else { $ar[$val] = 1; } } } if (!${$par_name} && is_Array($HTTP_POST_VARS[$par_name])) { $par_val = $HTTP_POST_VARS[$par_name][$i]; } elseif (!${$par_name}) { $par_val = $HTTP_POST_VARS[$par_name]; } else { $par_val = ${$par_name}; } $error = $er; if ($item->type == "email") { $item->preg = "/^[_a-zA-Z0-9-]+(\\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*(\\.[a-zA-Z]{2,4})\$/"; } if ($item->preg && $par_val && !preg_match($item->preg, $par_val)) { $er .= sysmessage(8) . " {$item->caption}<br>"; } if (strlen($par_val) == 0 && $item->needed) { $er .= sysmessage(9) . " {$item->caption}<br>"; } if ($par_val && $item->maxlength && strlen($par_val) > $item->maxlength) { $er .= sysmessage(10) . " {$item->caption} " . sysmessage(11) . " {$item->maxlength}"; } if ($par_val && $item->minlength && strlen($par_val) < $item->minlength) { $er .= sysmessage(10) . " {$item->caption} " . sysmessage(12) . " {$item->minlength}"; } if (strlen($par_val) && strlen($item->max) && $par_val > $item->max) { $er = sysmessage(6) . " {$item->caption} " . sysmessage(13) . " {$item->max}<br>"; } if (strlen($par_val) && strlen($item->min) && $par_val < $item->min) { $er = sysmessage(6) . " {$item->caption} " . sysmessage(14) . " {$item->min}<br>"; } if ($er != $error) { $this->wrong[$w] = $par_name; $w++; } if ($par_name) { if ($item->type != "file" && $item->type != "flag" && $item->type != "image" && $par_name != "Small") { $par_val = str_replace("<", "<", $par_val); $par_val = str_replace(">", ">", $par_val); //if($item->type=="numeric") $par_val=intval($par_val); if ($item->type == "text" || $item->type == "editor" || $item->type == "string") { $search .= strip_tags($par_val) . " "; } if ($item->type == "text" || $item->type == "editor") { if ($item->type != "editor") { $par_val = str_replace("\r\n", "<br />", $par_val); $par_val = mysql_real_escape_string($par_val); } $par_val = stripslashes($par_val); } else { $par_val = mysql_real_escape_string($par_val); $par_val = stripslashes($par_val); } $par_val = stripslashes($par_val); } $par_val = addslashes($par_val); $sql = "SET @" . "{$par_name}='{$par_val}'"; mysql_query($sql); //print substr($sql,0,1000)."<br>"; } $par_val = stripslashes($par_val); //$a=$par_val; if ($item->unique && $par_val && !$mult) { $sql = "select * from {$this->table} where {$par_name}='{$par_val}' and {$item->unique}"; if ($this->select) { $sq .= " and " . str_replace("=", "<>", substr($this->select, strpos($this->select, "where ") + 6)); while (strstr($sq, ".")) { $sq = substr($sq, 0, strpos($sq, ".") - 1) . substr($sq, 1 + strpos($sq, ".")); } $sql .= $sq; } $res = runsql($sql, $this->name); if (mysql_num_rows($res)) { $er .= sysmessage(3) . " {$item->caption}={$par_val}<br>"; } } } else { $str = substr($str, 1 + $q); } //if($a!=$par_val) print "$par_name изменилс¤<br>"; } return $st; }
* ECSHOP 商品分类管理程序 * ============================================================================ * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。 * 网站地址: http://www.ecshop.com; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ * $Author: liubo $ * $Id: category.php 17217 2011-01-19 06:29:08Z liubo $ */ define('IN_ECTOUCH', true); require dirname(__FILE__) . '/includes/init.php'; // 新增加的开始 include_once ROOT_PATH . 'include/cls_image.php'; $image = new cls_image($_CFG['bgcolor']); // 新增加的结束 $exc = new exchange($ecs->table("category"), $db, 'cat_id', 'cat_name'); /* act操作项的初始化 */ if (empty($_REQUEST['act'])) { $_REQUEST['act'] = 'list'; } else { $_REQUEST['act'] = trim($_REQUEST['act']); } /*------------------------------------------------------ */ //-- 商品分类列表 /*------------------------------------------------------ */ if ($_REQUEST['act'] == 'list') { /* 获取分类列表 */ $cat_list = cat_list(0, 0, false); /* 模板赋值 */
* 版权所有 2005-2010 上海商派网络科技有限公司,并保留所有权利。 * 网站地址: http://www.ecshop.com; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ * $Author: liuhui $ * $Id: group_buy.php 17063 2010-03-25 06:35:46Z liuhui $ */ define('IN_ECS', true); require(dirname(__FILE__) . '/includes/init.php'); require_once(ROOT_PATH . 'includes/lib_goods.php'); require_once(ROOT_PATH . 'includes/lib_order.php'); include_once(ROOT_PATH . '/includes/cls_image.php'); $image = new cls_image($_CFG['bgcolor']); $exc = new exchange($ecs->table('goods_activity'), $db, 'act_id', 'act_name'); /* 检查权限 */ admin_priv('group_by'); /* act操作项的初始化 */ if (empty($_REQUEST['act'])) { $_REQUEST['act'] = 'list'; } else { $_REQUEST['act'] = trim($_REQUEST['act']); }
} elseif (empty($adArr['url'])) { $error = '广告链接不能为空'; } elseif (empty($img)) { $error = '图片不能为空'; } elseif (empty($adArr['file'])) { $error = '使用页面不能为空'; } if (isset($error)) { sys_msg($error, 0, $link); } $old_img = $db->getOne("SELECT img FROM " . $ecs->table('ad_new') . " WHERE ad_name = '{$adArr['ad_name']}'"); if ($db->getOne("SELECT id FROM " . $ecs->table('ad_new') . " WHERE ad_name = '{$adArr['ad_name']}' AND id <> {$id} AND admin_agency_id = {$adArr['admin_agency_id']}")) { sys_msg('广告名称已存在', 0, $link); } if (isset($img['error']) && $img['error'] == 0) { $image = new cls_image($_CFG['bgcolor']); //实例化图片处理函数 if ($image->check_img_type($img['type'])) { $img_name = $image->upload_image($img, ''); } if (!$img_name) { sys_msg('上传图片失败', 1); } $adArr['img'] = $img_name; if (!$db->getOne("SELECT id FROM " . $ecs->table('ad_new') . " WHERE img ='{$old_img}' AND id<>{$id}")) { @unlink('../' . $old_img); } } if (!isset($adArr['img'])) { $adArr['img'] = $outer_img; }
* ECSHOP 商品分类管理程序 * ============================================================================ * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。 * 网站地址: http://www.ecshop.com; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ * $Author: liubo $ * $Id: category.php 17217 2011-01-19 06:29:08Z liubo $ */ define('IN_ECS', true); require dirname(__FILE__) . '/includes/init.php'; /***修改:分类属性添加图片***/ include_once ROOT_PATH . 'includes/cls_image.php'; $image = new cls_image($_CFG['bgcolor']); /***修改:分类属性添加图片结束***/ $exc = new exchange($ecs->table("category"), $db, 'cat_id', 'cat_name'); /* act操作项的初始化 */ if (empty($_REQUEST['act'])) { $_REQUEST['act'] = 'list'; } else { $_REQUEST['act'] = trim($_REQUEST['act']); } /*------------------------------------------------------ */ //-- 商品分类列表 /*------------------------------------------------------ */ if ($_REQUEST['act'] == 'list') { /* 获取分类列表 */ $cat_list = cat_list(0, 0, false); /* 模板赋值 */
function gd_version_tianxin100() { include_once ROOT_PATH . 'include/cls_image_tianxin.php'; return cls_image::gd_version(); }
/** * 获得GD的版本号 * * @access public * @return string 返回版本号,可能的值为0,1,2 */ function get_gd_version() { include_once ROOT_PATH . 'includes/cls_image.php'; $image = new cls_image(); return $image->gd_version(); }
if ($favourable['act_type'] == FAT_GOODS) { $favourable['act_type_ext'] = round($favourable['act_type_ext']); } /* 保存数据 */ if ($is_add) { $db->autoExecute($ecs->table('favourable_activity'), $favourable, 'INSERT'); $favourable['act_id'] = $db->insert_id(); } else { $db->autoExecute($ecs->table('favourable_activity'), $favourable, 'UPDATE', "act_id = '{$favourable['act_id']}'"); } //代表图片上传 if ($_FILES['logo']['size']) { $save['supplier_id'] = 0; //自营运营商 include_once ROOT_PATH . 'includes/cls_image.php'; $image = new cls_image($_CFG['bgcolor']); $logo_path .= $save['supplier_id']; $logo_name = "original" . $save['supplier_id'] . '_' . $favourable['act_id'] . substr($_FILES['logo']['name'], -4); $picinfo = $image->upload_image($_FILES['logo'], $logo_path, $logo_name); $parray = pathinfo($picinfo); if ($picinfo) { $create_pic_info = array('580x260' => array('width' => 580, 'height' => 260)); foreach ($create_pic_info as $key => $val) { $path = ROOT_PATH . $parray['dirname'] . '/'; $image->create_pic_name = "original" . $save['supplier_id'] . '_' . $favourable['act_id'] . "_" . $key; $pinfo = $image->make_thumb(ROOT_PATH . $picinfo, $val['width'], $val['height'], $path); } $save['logo'] = '/' . $pinfo; } $pic_sql = "update " . $ecs->table('favourable_activity') . " set logo='" . $save['logo'] . "' where act_id=" . $favourable['act_id']; $db->query($pic_sql);
<?php define('IN_ECS', true); require dirname(__FILE__) . '/includes/init.php'; include_once ROOT_PATH . 'includes/cls_image.php'; $image = new cls_image($_CFG['bgcolor']); $exc = new exchange($ecs->table("card"), $db, 'card_id', 'card_name'); /*------------------------------------------------------ */ //-- 包装列表 /*------------------------------------------------------ */ if ($_REQUEST['act'] == 'list') { assign_query_info(); $smarty->assign('ur_here', $_LANG['07_card_list']); $smarty->assign('action_link', array('text' => $_LANG['card_add'], 'href' => 'card.php?act=add')); $smarty->assign('full_page', 1); $cards_list = cards_list(); $smarty->assign('card_list', $cards_list['card_list']); $smarty->assign('filter', $cards_list['filter']); $smarty->assign('record_count', $cards_list['record_count']); $smarty->assign('page_count', $cards_list['page_count']); $smarty->display('card_list.htm'); } elseif ($_REQUEST['act'] == 'query') { $cards_list = cards_list(); $smarty->assign('card_list', $cards_list['card_list']); $smarty->assign('filter', $cards_list['filter']); $smarty->assign('record_count', $cards_list['record_count']); $smarty->assign('page_count', $cards_list['page_count']); $sort_flag = sort_flag($cards_list['filter']); $smarty->assign($sort_flag['tag'], $sort_flag['img']); make_json_result($smarty->fetch('card_list.htm'), '', array('filter' => $cards_list['filter'], 'page_count' => $cards_list['page_count'])); } elseif ($_REQUEST['act'] == 'remove') {
//新文件名 $thumb_file_name = date("His") . rand(10000, 99999); $new_file_name = $thumb_file_name . '.' . $file_ext; //移动文件 $file_path = $save_path . $new_file_name; if (move_uploaded_file($tmp_name, $file_path) === false) { alert("上传文件失败。"); } @chmod($file_path, 0644); $file_url = $save_url . $new_file_name; $type = $_FILES['imgFile']['type']; $type1 = substr($type, 0, 5); //判断上传是否是图片 if ($type1 == 'image') { require_once 'cls_image.php'; $images = new cls_image(); if ($filename = $images->make_thumb($file_path, 600, '', $save_path, $thumb_file_name)) { $file_url = $save_url . $filename; } else { alert($images->error_msg); } } header('Content-type: text/html; charset=UTF-8'); $json = new Services_JSON(); echo $json->encode(array('error' => 0, 'url' => $file_url)); exit; } function alert($msg) { header('Content-type: text/html; charset=UTF-8'); $json = new Services_JSON();
/** * 获得服务器上的 GD 版本 * * @access public * @return int 可能的值为0,1,2 */ function gd_version() { include_once(ROOT_PATH . 'includes/cls_image.php'); return cls_image::gd_version(); }
* 昊海电商 商品分类管理程序 * ============================================================================ * * 版权所有 2012-2014 西安昊海网络科技有限公司,并保留所有权利。 * 网站地址: http://www.xaphp.cn; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ * $Author: pangbin $ * $Id: category.php 17217 2014-05-12 06:29:08Z pangbin $ */ define('IN_HHS', true); require dirname(__FILE__) . '/includes/init.php'; $exc = new exchange($hhs->table("category"), $db, 'cat_id', 'cat_name'); include_once ROOT_PATH . '/includes/cls_image.php'; $image = new cls_image($_CFG['bgcolor']); /* act操作项的初始化 */ if (empty($_REQUEST['act'])) { $_REQUEST['act'] = 'list'; } else { $_REQUEST['act'] = trim($_REQUEST['act']); } /*------------------------------------------------------ */ //-- 商品分类列表 /*------------------------------------------------------ */ if ($_REQUEST['act'] == 'list') { /* 获取分类列表 */ $cat_list = cat_list(0, 0, false); /* 模板赋值 */ $smarty->assign('ur_here', $_LANG['03_category_list']); $smarty->assign('action_link', array('href' => 'category.php?act=add', 'text' => $_LANG['04_category_add']));
/** * ECSHOP 管理中心品牌管理 * ============================================================================ * 版权所有 2005-2010 上海商派网络科技有限公司,并保留所有权利。 * 网站地址: http://www.ecshop.com; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ * $Author: liuhui $ * $Id: brand.php 17063 2010-03-25 06:35:46Z liuhui $ */ define('IN_ECS', true); require dirname(__FILE__) . '/includes/init.php'; include_once ROOT_PATH . 'includes/cls_image.php'; $image = new cls_image($_CFG['bgcolor']); $exc = new exchange($ecs->table("brand"), $db, 'brand_id', 'brand_name'); /*------------------------------------------------------ */ //-- 品牌列表 /*------------------------------------------------------ */ if ($_REQUEST['act'] == 'list') { $smarty->assign('ur_here', $_LANG['06_goods_brand_list']); $smarty->assign('action_link', array('text' => $_LANG['07_brand_add'], 'href' => 'brand.php?act=add')); $smarty->assign('full_page', 1); $brand_list = get_brandlist(); $smarty->assign('brand_list', $brand_list['brand']); $smarty->assign('filter', $brand_list['filter']); $smarty->assign('record_count', $brand_list['record_count']); $smarty->assign('page_count', $brand_list['page_count']); assign_query_info(); $smarty->display('brand_list.htm');
/** * ECSHOP 管理中心品牌管理 * ============================================================================ * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。 * 网站地址: http://www.ecshop.com; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ * $Author: liubo $ * $Id: brand.php 17217 2011-01-19 06:29:08Z liubo $ */ define('IN_ECTOUCH', true); require dirname(__FILE__) . '/includes/init.php'; include_once ROOT_PATH . 'include/cls_image.php'; $image = new cls_image($_CFG['bgcolor']); $exc = new exchange($ecs->table("brand"), $db, 'brand_id', 'brand_name'); /*------------------------------------------------------ */ //-- 品牌列表 /*------------------------------------------------------ */ if ($_REQUEST['act'] == 'list') { $smarty->assign('ur_here', $_LANG['06_goods_brand_list']); $smarty->assign('action_link', array('text' => $_LANG['07_brand_add'], 'href' => 'brand.php?act=add')); $smarty->assign('full_page', 1); $brand_list = get_brandlist(); $smarty->assign('brand_list', $brand_list['brand']); $smarty->assign('filter', $brand_list['filter']); $smarty->assign('record_count', $brand_list['record_count']); $smarty->assign('page_count', $brand_list['page_count']); assign_query_info(); $smarty->display('brand_list.htm');
/** * ECSHOP 友情链接管理 * ============================================================================ * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。 * 网站地址: http://www.ecshop.com; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ * $Author: liubo $ * $Id: friend_link.php 17217 2011-01-19 06:29:08Z liubo $ */ define('IN_ECS', true); require dirname(__FILE__) . '/includes/init.php'; include_once ROOT_PATH . 'includes/cls_image.php'; $image = new cls_image($_CFG['bgcolor']); $exc = new exchange($ecs->table('friend_link'), $db, 'link_id', 'link_name'); /* act操作项的初始化 */ if (empty($_REQUEST['act'])) { $_REQUEST['act'] = 'list'; } else { $_REQUEST['act'] = trim($_REQUEST['act']); } /*------------------------------------------------------ */ //-- 友情链接列表页面 /*------------------------------------------------------ */ if ($_REQUEST['act'] == 'list') { /* 模板赋值 */ $smarty->assign('ur_here', $_LANG['list_link']); $smarty->assign('action_link', array('text' => $_LANG['add_link'], 'href' => 'friend_link.php?act=add')); $smarty->assign('full_page', 1);
$smarty->assign('goods_list', $goods_list); // 字段名称列表 $smarty->assign('title_list', $_LANG['upload_goods']); // 显示的字段列表 $smarty->assign('field_show', array('goods_name' => true, 'goods_sn' => true, 'brand_name' => true, 'market_price' => true, 'shop_price' => true)); /* 参数赋值 */ $smarty->assign('ur_here', $_LANG['goods_upload_confirm']); /* 显示模板 */ assign_query_info(); $smarty->display('goods_batch_confirm.htm'); } elseif ($_REQUEST['act'] == 'insert') { /* 检查权限 */ admin_priv('batch_add'); if (isset($_POST['checked'])) { include_once ROOT_PATH . 'includes/cls_image.php'; $image = new cls_image($_CFG['bgcolor']); /* 字段默认值 */ $default_value = array('brand_id' => 0, 'goods_number' => 0, 'goods_weight' => 0, 'market_price' => 0, 'shop_price' => 0, 'warn_number' => 0, 'is_real' => 1, 'is_on_sale' => 1, 'is_alone_sale' => 1, 'integral' => 0, 'is_best' => 0, 'is_new' => 0, 'is_hot' => 0, 'goods_type' => 0); /* 查询品牌列表 */ $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']; } /* 字段列表 */ $field_list = array_keys($_LANG['upload_goods']); $field_list[] = 'goods_class'; //实体或虚拟商品 /* 获取商品good id */ $max_id = $db->getOne("SELECT MAX(goods_id) + 1 FROM " . $ecs->table('goods'));
/** * 生成指定目录不重名的文件名 * * @access public * @param string $dir 要检查是否有同名文件的目录 * * @return string 文件名 */ function unique_name($dir) { $filename = ''; while (empty($filename)) { $filename = cls_image::random_filename(); if (is_file($dir . $filename . '.jpg') || file_exists($dir . $filename . '.gif') || is_file($dir . $filename . '.png')) { $filename = ''; } } return $filename; }
/** * 添加商品 * * @param array $post */ function API_AddGoods($post) { //debug_text(); global $_CFG; /* 加载后台操作类与函数 */ require_once ROOT_PATH . ADMIN_PATH . '/includes/lib_main.php'; require_once ROOT_PATH . ADMIN_PATH . '/includes/lib_goods.php'; require_once ROOT_PATH . 'includes/cls_image.php'; /* 检查权限 */ admin_privilege('goods_manage'); $image = new cls_image($GLOBALS['_CFG']['bgcolor']); $code = empty($_POST['extension_code']) ? '' : trim($_POST['extension_code']); /* 插入还是更新的标识 */ $is_insert = $_POST['act'] == 'insert'; /* 如果是更新,先检查该商品是否存在,不存在,则退出。 */ if (!$is_insert) { $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('goods') . " WHERE goods_id = '{$_POST['goods_id']}' AND is_delete = 0"; if ($GLOBALS['db']->getOne($sql) <= 0) { client_show_message(240); //货号重复 } } /* 检查货号是否重复 */ if ($_POST['goods_sn']) { $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('goods') . " WHERE goods_sn = '{$_POST['goods_sn']}' AND is_delete = 0 AND goods_id <> '{$_POST['goods_id']}'"; if ($GLOBALS['db']->getOne($sql) > 0) { client_show_message(200); //货号重复 } } /* 处理商品图片 */ $goods_img = ''; // 初始化商品图片 $goods_thumb = ''; // 初始化商品缩略图 $original_img = ''; // 初始化原始图片 $old_original_img = ''; // 初始化原始图片旧图 $allow_file_type = array('jpg', 'jpeg', 'png', 'gif'); if (!empty($_POST['goods_img']['Data'])) { if (!in_array($_POST['goods_img']['Type'], $allow_file_type)) { client_show_message(201); } if (client_check_image_size($_POST['goods_img']['Data']) === false) { client_show_message(202); } if ($_POST['goods_id'] > 0) { /* 删除原来的图片文件 */ $sql = "SELECT goods_thumb, goods_img, original_img " . " FROM " . $GLOBALS['ecs']->table('goods') . " WHERE goods_id = '{$_POST['goods_id']}'"; $row = $GLOBALS['db']->getRow($sql); if ($row['goods_thumb'] != '' && is_file(ROOT_PATH . '/' . $row['goods_thumb'])) { @unlink(ROOT_PATH . '/' . $row['goods_thumb']); } if ($row['goods_img'] != '' && is_file(ROOT_PATH . '/' . $row['goods_img'])) { @unlink(ROOT_PATH . '/' . $row['goods_img']); } if ($row['original_img'] != '' && is_file(ROOT_PATH . '/' . $row['original_img'])) { /* 先不处理,以防止程序中途出错停止 */ //$old_original_img = $row['original_img']; //记录旧图路径 } } $original_img = upload_image($_POST['goods_img']); // 原始图片 if ($original_img === false) { client_show_message(210); // 写入商品图片出错 } $goods_img = $original_img; // 商品图片 /* 复制一份相册图片 */ $img = $original_img; // 相册图片 $pos = strpos(basename($img), '.'); $newname = dirname($img) . '/' . random_filename() . substr(basename($img), $pos); if (!copy(ROOT_PATH . '/' . $img, ROOT_PATH . '/' . $newname)) { client_show_message(211); // 复制相册图片时出错 } $img = $newname; $gallery_img = $img; $gallery_thumb = $img; /* 图片属性 */ $img_property = $image->gd_version() > 0 ? getimagesize(ROOT_PATH . '/' . $goods_img) : array(); // 如果系统支持GD,缩放商品图片,且给商品图片和相册图片加水印 if ($image->gd_version() > 0 && $image->check_img_function($img_property[2])) { // 如果设置大小不为0,缩放图片 if ($GLOBALS['_CFG']['image_width'] != 0 || $GLOBALS['_CFG']['image_height'] != 0) { $goods_img = $image->make_thumb(ROOT_PATH . '/' . $goods_img, $GLOBALS['_CFG']['image_width'], $GLOBALS['_CFG']['image_height']); if ($goods_img === false) { client_show_message(212); } } // 加水印 if (intval($GLOBALS['_CFG']['watermark_place']) > 0 && !empty($GLOBALS['_CFG']['watermark'])) { if ($image->add_watermark(ROOT_PATH . '/' . $goods_img, '', $GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']) === false) { client_show_message(213); } $newname = dirname($img) . '/' . random_filename() . substr(basename($img), $pos); if (!copy(ROOT_PATH . '/' . $img, ROOT_PATH . '/' . $newname)) { client_show_message(214); } $gallery_img = $newname; if ($image->add_watermark(ROOT_PATH . '/' . $gallery_img, '', $GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']) === false) { client_show_message(213); } } // 相册缩略图 if ($_CFG['thumb_width'] != 0 || $_CFG['thumb_height'] != 0) { $gallery_thumb = $image->make_thumb(ROOT_PATH . '/' . $img, $GLOBALS['_CFG']['thumb_width'], $GLOBALS['_CFG']['thumb_height']); if ($gallery_thumb === false) { client_show_message(215); } } } } if (!empty($_POST['goods_thumb']['Data'])) { if (!in_array($_POST['goods_thumb']['Type'], $allow_file_type)) { client_show_message(203); } if (client_check_image_size($_POST['goods_thumb']['Data']) === false) { client_show_message(204); } $goods_thumb = upload_image($_POST['goods_thumb']); if ($goods_thumb === false) { client_show_message(217); } } else { // 未上传,如果自动选择生成,且上传了商品图片,生成所略图 if (isset($_POST['auto_thumb']) && !empty($original_img)) { // 如果设置缩略图大小不为0,生成缩略图 if ($_CFG['thumb_width'] != 0 || $_CFG['thumb_height'] != 0) { $goods_thumb = $image->make_thumb(ROOT_PATH . '/' . $original_img, $GLOBALS['_CFG']['thumb_width'], $GLOBALS['_CFG']['thumb_height']); if ($goods_thumb === false) { client_show_message(218); } } else { $goods_thumb = $original_img; } } } /* 如果没有输入商品货号则自动生成一个商品货号 */ if (empty($_POST['goods_sn'])) { $max_id = $is_insert ? $GLOBALS['db']->getOne("SELECT MAX(goods_id) + 1 FROM " . $GLOBALS['ecs']->table('goods')) : $_POST['goods_id']; $goods_sn = generate_goods_sn($max_id); } else { $goods_sn = $_POST['goods_sn']; } /* 处理商品数据 */ $is_promote = isset($_POST['is_promote']) && $_POST['is_promote'] ? 1 : 0; $shop_price = !empty($_POST['shop_price']) ? $_POST['shop_price'] : 0; $market_price = !empty($_POST['market_price']) ? $_POST['market_price'] : $GLOBALS['_CFG']['market_price_rate'] * $shop_price; $promote_price = !empty($_POST['promote_price']) ? floatval($_POST['promote_price']) : 0; $promote_start_date = $is_promote && !empty($_POST['promote_start_date']) ? local_strtotime($_POST['promote_start_date']) : 0; $promote_end_date = $is_promote && !empty($_POST['promote_end_date']) ? local_strtotime($_POST['promote_end_date']) : 0; $goods_weight = !empty($_POST['goods_weight']) ? $_POST['goods_weight'] * $_POST['weight_unit'] : 0; $is_best = isset($_POST['is_best']) && $_POST['is_best'] ? 1 : 0; $is_new = isset($_POST['is_new']) && $_POST['is_new'] ? 1 : 0; $is_hot = isset($_POST['is_hot']) && $_POST['is_hot'] ? 1 : 0; $is_on_sale = isset($_POST['is_on_sale']) && $_POST['is_on_sale'] ? 1 : 0; $is_alone_sale = isset($_POST['is_alone_sale']) && $_POST['is_alone_sale'] ? 1 : 0; $goods_number = isset($_POST['goods_number']) ? $_POST['goods_number'] : 0; $warn_number = isset($_POST['warn_number']) ? $_POST['warn_number'] : 0; $goods_type = isset($_POST['goods_type']) ? $_POST['goods_type'] : 0; $goods_name_style = $_POST['goods_name_color'] . '+' . $_POST['goods_name_style']; $catgory_id = empty($_POST['cat_id']) ? '' : intval($_POST['cat_id']); $brand_id = empty($_POST['brand_id']) ? '' : intval($_POST['brand_id']); $new_brand_name = empty($_POST['new_brand_name']) ? '' : trim($_POST['new_brand_name']); $new_cat_name = empty($_POST['new_cat_name']) ? '' : trim($_POST['new_cat_name']); if ($catgory_id == '' && $new_cat_name != '') { if (cat_exists($new_cat_name, $_POST['parent_cat'])) { /* 同级别下不能有重复的分类名称 */ client_show_message(219); } } if ($brand_id == '' && $new_brand_name != '') { if (brand_exists($new_brand_name)) { /* 同级别下不能有重复的品牌名称 */ client_show_message(220); } } //处理快速添加分类 if ($catgory_id == '' && $new_cat_name != '') { $sql = "INSERT INTO " . $GLOBALS['ecs']->table('category') . "(cat_name, parent_id, is_show)" . "VALUES ( '{$new_cat_name}', '{$_POST['parent_cat']}', 1)"; $GLOBALS['db']->query($sql); $catgory_id = $GLOBALS['db']->insert_id(); } //处理快速添加品牌 if ($brand_id == '' && $new_brand_name != '') { $sql = "INSERT INTO " . $GLOBALS['ecs']->table('brand') . "(brand_name) " . "VALUES ('{$new_brand_name}')"; $GLOBALS['db']->query($sql); $brand_id = $GLOBALS['db']->insert_id(); } /* 处理商品详细描述 */ $_POST['goods_desc'] = htmlspecialchars_decode($_POST['goods_desc']); /* 入库 */ if ($is_insert) { if ($code == '') { $sql = "INSERT INTO " . $GLOBALS['ecs']->table('goods') . " (goods_name, goods_name_style, goods_sn, " . "cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " . "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " . "seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, " . "is_on_sale, is_alone_sale, goods_desc, add_time, last_update, goods_type)" . "VALUES ('{$_POST['goods_name']}', '{$goods_name_style}', '{$goods_sn}', '{$catgory_id}', " . "'{$brand_id}', '{$shop_price}', '{$market_price}', '{$is_promote}','{$promote_price}', " . "'{$promote_start_date}', '{$promote_end_date}', '{$goods_img}', '{$goods_thumb}', '{$original_img}', " . "'{$_POST['keywords']}', '{$_POST['goods_brief']}', '{$_POST['seller_note']}', '{$goods_weight}', '{$goods_number}'," . " '{$warn_number}', '{$_POST['integral']}', '" . intval($_POST['give_integral']) . "', '{$is_best}', '{$is_new}', '{$is_hot}', '{$is_on_sale}', '{$is_alone_sale}', " . " '{$_POST['goods_desc']}', '" . gmtime() . "', '" . gmtime() . "', '{$goods_type}')"; } else { $sql = "INSERT INTO " . $GLOBALS['ecs']->table('goods') . " (goods_name, goods_name_style, goods_sn, " . "cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " . "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " . "seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_real, " . "is_on_sale, is_alone_sale, goods_desc, add_time, last_update, goods_type, extension_code)" . "VALUES ('{$_POST['goods_name']}', '{$goods_name_style}', '{$goods_sn}', '{$catgory_id}', " . "'{$brand_id}', '{$shop_price}', '{$market_price}', '{$is_promote}', '{$promote_price}', " . "'{$promote_start_date}', '{$promote_end_date}', '{$goods_img}', '{$goods_thumb}', '{$original_img}', " . "'{$_POST['keywords']}', '{$_POST['goods_brief']}', '{$_POST['seller_note']}', '{$goods_weight}', '{$goods_number}'," . " '{$warn_number}', '{$_POST['integral']}', '" . intval($_POST['give_integral']) . "', '{$is_best}', '{$is_new}', '{$is_hot}', 0, '{$is_on_sale}', '{$is_alone_sale}', " . " '{$_POST['goods_desc']}', '" . gmtime() . "', '" . gmtime() . "', '{$goods_type}', '{$code}')"; } } else { /* 将上传的新图片图片名改为原图片 */ if ($goods_img && $row['goods_img']) { if (is_file(ROOT_PATH . $row['goods_img'])) { @unlink(ROOT_PATH . $row['goods_img']); } @rename(ROOT_PATH . $goods_img, ROOT_PATH . $row['goods_img']); if (is_file(ROOT_PATH . $row['original_img'])) { @unlink(ROOT_PATH . $row['original_img']); } @rename(ROOT_PATH . $original_img, ROOT_PATH . $row['original_img']); } if ($goods_thumb && $row['goods_thumb']) { if (is_file(ROOT_PATH . $row['goods_thumb'])) { @unlink(ROOT_PATH . $row['goods_thumb']); } @rename(ROOT_PATH . $goods_thumb, ROOT_PATH . $row['goods_thumb']); } $sql = "UPDATE " . $GLOBALS['ecs']->table('goods') . " SET " . "goods_name = '{$_POST['goods_name']}', " . "goods_name_style = '{$goods_name_style}', " . "goods_sn = '{$goods_sn}', " . "cat_id = '{$catgory_id}', " . "brand_id = '{$brand_id}', " . "shop_price = '{$shop_price}', " . "market_price = '{$market_price}', " . "is_promote = '{$is_promote}', " . "promote_price = '{$promote_price}', " . "promote_start_date = '{$promote_start_date}', " . "promote_end_date = '{$promote_end_date}', "; /* 如果以前没上传过图片,需要更新数据库 */ if ($goods_img && empty($row['goods_img'])) { $sql .= "goods_img = '{$goods_img}', original_img = '{$original_img}', "; } if (!empty($goods_thumb)) { $sql .= "goods_thumb = '{$goods_thumb}', "; } if ($code != '') { $sql .= "is_real=0, extension_code='{$code}', "; } $sql .= "keywords = '{$_POST['keywords']}', " . "goods_brief = '{$_POST['goods_brief']}', " . "seller_note = '{$_POST['seller_note']}', " . "goods_weight = '{$goods_weight}'," . "goods_number = '{$goods_number}', " . "warn_number = '{$warn_number}', " . "integral = '{$_POST['integral']}', " . "give_integral = '" . $_POST['give_integral'] . "', " . "is_best = '{$is_best}', " . "is_new = '{$is_new}', " . "is_hot = '{$is_hot}', " . "is_on_sale = '{$is_on_sale}', " . "is_alone_sale = '{$is_alone_sale}', " . "goods_desc = '{$_POST['goods_desc']}', " . "last_update = '" . gmtime() . "', " . "goods_type = '{$goods_type}' " . "WHERE goods_id = '{$_POST['goods_id']}' LIMIT 1"; } $GLOBALS['db']->query($sql); /* 商品编号 */ $goods_id = $is_insert ? $GLOBALS['db']->insert_id() : $_POST['goods_id']; /* 记录日志 */ if ($is_insert) { admin_log($_POST['goods_name'], 'add', 'goods'); } else { admin_log($_POST['goods_name'], 'edit', 'goods'); } /* 处理属性 */ if (isset($_POST['attr_id_list']) && isset($_POST['attr_value_list'])) { // 取得原有的属性值 $goods_attr_list = array(); $keywords_arr = explode(" ", $_POST['keywords']); $keywords_arr = array_flip($keywords_arr); if (isset($keywords_arr[''])) { unset($keywords_arr['']); } $sql = "SELECT attr_id, attr_index FROM " . $GLOBALS['ecs']->table('attribute') . " WHERE cat_id = '{$goods_type}' "; $attr_res = $GLOBALS['db']->query($sql); $attr_list = array(); while ($row = $GLOBALS['db']->fetchRow($attr_res)) { $attr_list[$row['attr_id']] = $row['attr_index']; } $sql = "SELECT * FROM " . $GLOBALS['ecs']->table('goods_attr') . " WHERE goods_id = '{$goods_id}' "; $res = $GLOBALS['db']->query($sql); while ($row = $GLOBALS['db']->fetchRow($res)) { $goods_attr_list[$row['attr_id']][$row['attr_value']] = array('sign' => 'delete', 'goods_attr_id' => $row['goods_attr_id']); } // 循环现有的,根据原有的做相应处理 foreach ($_POST['attr_id_list'] as $key => $attr_id) { $attr_value = $_POST['attr_value_list'][$key]; $attr_price = $_POST['attr_price_list'][$key]; if (!empty($attr_value)) { if (isset($goods_attr_list[$attr_id][$attr_value])) { // 如果原来有,标记为更新 $goods_attr_list[$attr_id][$attr_value]['sign'] = 'update'; $goods_attr_list[$attr_id][$attr_value]['attr_price'] = $attr_price; } else { // 如果原来没有,标记为新增 $goods_attr_list[$attr_id][$attr_value]['sign'] = 'insert'; $goods_attr_list[$attr_id][$attr_value]['attr_price'] = $attr_price; } $val_arr = explode(' ', $attr_value); foreach ($val_arr as $k => $v) { if (!isset($keywords_arr[$v]) && $attr_list[$attr_id] == "1") { $keywords_arr[$v] = $v; } } } } $keywords = join(' ', array_flip($keywords_arr)); $sql = "UPDATE " . $GLOBALS['ecs']->table('goods') . " SET keywords = '{$keywords}' WHERE goods_id = '{$goods_id}' LIMIT 1"; $GLOBALS['db']->query($sql); /* 插入、更新、删除数据 */ foreach ($goods_attr_list as $attr_id => $attr_value_list) { foreach ($attr_value_list as $attr_value => $info) { if ($info['sign'] == 'insert') { $sql = "INSERT INTO " . $GLOBALS['ecs']->table('goods_attr') . " (attr_id, goods_id, attr_value, attr_price)" . "VALUES ('{$attr_id}', '{$goods_id}', '{$attr_value}', '{$info['attr_price']}')"; } elseif ($info['sign'] == 'update') { $sql = "UPDATE " . $GLOBALS['ecs']->table('goods_attr') . " SET attr_price = '{$info['attr_price']}' WHERE goods_attr_id = '{$info['goods_attr_id']}' LIMIT 1"; } else { $sql = "DELETE FROM " . $GLOBALS['ecs']->table('goods_attr') . " WHERE goods_attr_id = '{$info['goods_attr_id']}' LIMIT 1"; } $GLOBALS['db']->query($sql); } } } /* 处理会员价格 */ if (isset($_POST['user_rank']) && isset($_POST['user_price'])) { handle_member_price($goods_id, $_POST['user_rank'], $_POST['user_price']); } /* 处理扩展分类 */ if (isset($_POST['other_cat'])) { handle_other_cat($goods_id, array_unique($_POST['other_cat'])); } if ($is_insert) { /* 处理关联商品 */ handle_link_goods($goods_id); /* 处理组合商品 */ handle_group_goods($goods_id); /* 处理关联文章 */ handle_goods_article($goods_id); } /* 如果有图片,把商品图片加入图片相册 */ if (isset($img)) { $sql = "INSERT INTO " . $GLOBALS['ecs']->table('goods_gallery') . " (goods_id, img_url, img_desc, thumb_url, img_original) " . "VALUES ('{$goods_id}', '{$gallery_img}', '', '{$gallery_thumb}', '{$img}')"; $GLOBALS['db']->query($sql); } /* 处理相册图片 handle_gallery_image($goods_id, $_FILES['img_url'], $_POST['img_desc']); */ if (!empty($_POST['img_url'])) { foreach ($_POST['img_url'] as $key => $img_url) { if (!in_array($img_url['Type'], $allow_file_type)) { client_show_message(205); } if (client_check_image_size($img_url['Data']) === false) { client_show_message(206); } $img_original = upload_image($img_url); if ($img_original === false) { continue; } // 暂停生成缩略图 /* $thumb_url = $image->make_thumb(ROOT_PATH . $img_original, $GLOBALS['_CFG']['thumb_width'], $GLOBALS['_CFG']['thumb_height']); $thumb_url = is_string($thumb_url) ? $thumb_url : ''; $img_url = $img_original; // 如果服务器支持GD 则添加水印 if (gd_version() > 0) { $pos = strpos(basename($img_original), '.'); $newname = dirname($img_original) . '/' . random_filename() . substr(basename($img_original), $pos); copy(ROOT_PATH . '/' . $img_original, ROOT_PATH . '/' . $newname); $img_url = $newname; $image->add_watermark(ROOT_PATH . $img_url,'',$GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']); } */ $img_url = $thumb_url = $img_original; $img_desc = $_POST['img_desc'][$key]; $sql = "INSERT INTO " . $GLOBALS['ecs']->table('goods_gallery') . " (goods_id, img_url, img_desc, thumb_url, img_original) " . "VALUES ('{$goods_id}', '{$img_url}', '{$img_desc}', '{$thumb_url}', '{$img_original}')"; $GLOBALS['db']->query($sql); } } /* 编辑时处理相册图片描述 */ if (!$is_insert && isset($_POST['old_img_desc'])) { foreach ($_POST['old_img_desc'] as $img_id => $img_desc) { $sql = "UPDATE " . $GLOBALS['ecs']->table('goods_gallery') . " SET img_desc = '{$img_desc}' WHERE img_id = '{$img_id}' LIMIT 1"; $GLOBALS['db']->query($sql); } } /* 清空缓存 */ clear_cache_files(); /* 提示页面 */ client_show_message(0, true, '', $goods_id); }
function action_shaidan_save() { $user = $GLOBALS['user']; $_CFG = $GLOBALS['_CFG']; $_LANG = $GLOBALS['_LANG']; $smarty = $GLOBALS['smarty']; $db = $GLOBALS['db']; $ecs = $GLOBALS['ecs']; $user_id = $_SESSION['user_id']; include_once dirname(__FILE__) . '/includes/cls_image.php'; $image = new cls_image($_CFG['bgcolor']); $rec_id = intval($_POST['rec_id']); $goods_id = intval($_POST['goods_id']); $title = trim($_POST['title']); $message = $_POST['message']; $add_time = gmtime(); $status = $_CFG['shaidan_check']; $hide_username = intval($_POST['hide_username']); $sql = "INSERT INTO " . $ecs->table('shaidan') . "(rec_id, goods_id, user_id, title, message, add_time, status, hide_username)" . "VALUES ('{$rec_id}', '{$goods_id}', '{$user_id}', '{$title}', '{$message}', '{$add_time}', '{$status}', '{$hide_username}')"; $db->query($sql); $shaidan_id = $db->insert_id(); $db->query("UPDATE " . $ecs->table('order_goods') . " SET shaidan_state = 1 WHERE rec_id = '{$rec_id}'"); // 处理图片 $img_srcs = $_POST['img_srcs']; $img_names = $_POST['img_names']; if (is_array($img_srcs)) { foreach ($img_srcs as $i => $src) { $thumb = $image->make_thumb($src, 100, 100); $sql = "INSERT INTO " . $ecs->table('shaidan_img') . "(shaidan_id, `desc`, image, thumb)" . "VALUES ('{$shaidan_id}', '" . $img_names[$i] . "', '{$src}', '{$thumb}')"; $db->query($sql); } } // 需要审核 if ($status == 0) { $msg = '您的信息提交成功,需要管理员审核后才能显示!'; } else { $info = $db->GetRow("SELECT * FROM " . $ecs->table('shaidan') . " WHERE shaidan_id='{$shaidan_id}'"); // 该商品第几位晒单者 $res = $db->getAll("SELECT shaidan_id FROM " . $ecs->table("shaidan") . " WHERE goods_id = '{$info['goods_id']}' ORDER BY add_time ASC"); foreach ($res as $key => $value) { if ($shaidan_id == $value['shaidan_id']) { $weizhi = $key + 1; } } // 图片数量 $imgnum = count($img_srcs); // 是否赠送积分 if ($info['is_points'] == 0 && $weizhi <= $_CFG['shaidan_pre_num'] && $imgnum >= $_CFG['shaidan_img_num']) { $pay_points = $_CFG['shaidan_pay_points']; $db->query("UPDATE " . $ecs->table('shaidan') . " SET pay_points = '{$pay_points}', is_points = 1 WHERE shaidan_id = '{$shaidan_id}'"); $db->query("INSERT INTO " . $ecs->table('account_log') . "(user_id, rank_points, pay_points, change_time, change_desc, change_type) " . "VALUES ('{$info['user_id']}', 0, '" . $pay_points . "', " . gmtime() . ", '晒单获得积分', '99')"); $log = $db->getRow("SELECT SUM(rank_points) AS rank_points, SUM(pay_points) AS pay_points FROM " . $ecs->table("account_log") . " WHERE user_id = '{$info['user_id']}'"); $db->query("UPDATE " . $ecs->table('users') . " SET rank_points = '" . $log['rank_points'] . "', pay_points = '" . $log['pay_points'] . "' WHERE user_id = '{$info['user_id']}'"); } $msg = '您的信息提交成功!'; } echo "<script>alert('{$msg}');self.location='user.php?act=my_comment';</script>"; exit; }
/** * 获得服务器上的 GD 版本 * * @access public * @return int 可能的值为0,1,2 */ function gd_version() { include_once ROOT_PATH . 'czk/includes/cls_image.php'; return cls_image::gd_version(); }