本文整理匯總了PHP中Import::img方法的典型用法代碼示例。如果您正苦於以下問題:PHP Import::img方法的具體用法?PHP Import::img怎麽用?PHP Import::img使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Import
的用法示例。
在下文中一共展示了Import::img方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: ajax_edit_add
function ajax_edit_add($data = array(), $id = 0)
{
if (!empty($data['width']) && !empty($data['height']) && !empty($data['link_logo'])) {
if (!empty($id)) {
$sql = "SELECT link_logo FROM `{$this->App->prefix()}friend_link` WHERE link_id='{$id}'";
$var = $this->App->findvar($sql);
if ($data['link_logo'] != $var) {
Import::fileop()->delete_file(SYS_PATH . $var);
//刪除文件
$q = dirname($var);
$h = basename($var);
Import::fileop()->delete_file(SYS_PATH . $q . DS . 'thumb_s' . DS . $h);
Import::fileop()->delete_file(SYS_PATH . $q . DS . 'thumb_b' . DS . $h);
if (file_exists(SYS_PATH . $data['link_logo'])) {
Import::img()->thumb(SYS_PATH . $data['link_logo'], SYS_PATH . $data['link_logo'], $data['width'], $data['height']);
}
}
}
}
if (empty($id)) {
if ($this->App->insert('friend_link', $data)) {
$this->action('system', 'add_admin_log', '添加友情鏈接:' . $data['link_name']);
} else {
echo "無法添加友情鏈接,意外錯誤!";
}
} else {
if ($this->App->update('friend_link', $data, 'link_id', $id)) {
$this->action('system', 'add_admin_log', '修改友情鏈接:' . $data['link_name']);
} else {
echo "數據未變動,無需更新!";
}
}
exit;
}
示例2: goodsinfo
function goodsinfo()
{
$this->layout('kong2');
$gid = isset($_GET['id']) ? intval($_GET['id']) : 0;
//$sid = isset($_GET['shopid']) ? intval($_GET['shopid']) : 0;
$sid = $this->Session->read('Shop.uid');
if ($gid > 0) {
$sql = "SELECT * FROM `{$this->App->prefix()}user_shopgoods` WHERE goods_id='{$gid}' LIMIT 1";
$rt = $this->App->findrow($sql);
$this->set('rt', $rt);
}
if (isset($_POST) && !empty($_POST)) {
$_POST['is_on_sale'] = isset($_POST['is_on_sale']) && intval($_POST['is_on_sale']) > 0 ? intval($_POST['is_on_sale']) : '0';
$_POST['is_best'] = isset($_POST['is_best']) && intval($_POST['is_best']) > 0 ? intval($_POST['is_best']) : '0';
$_POST['is_new'] = isset($_POST['is_new']) && intval($_POST['is_new']) > 0 ? intval($_POST['is_new']) : '0';
$_POST['is_hot'] = isset($_POST['is_hot']) && intval($_POST['is_hot']) > 0 ? intval($_POST['is_hot']) : '0';
$_POST['is_promote'] = isset($_POST['is_promote']) && intval($_POST['is_promote']) > 0 ? intval($_POST['is_promote']) : '0';
if ($gid > 0) {
//編輯
if ($rt['original_img'] != $_POST['original_img']) {
//修改了上傳文件 那麽重新上傳
$source_path = SYS_PATH . DS . str_replace('/', DS, $_POST['original_img']);
$pa = dirname($_POST['original_img']);
$thumb = basename($_POST['original_img']);
$tw_s = intval($GLOBALS['LANG']['th_width_s']) > 0 ? intval($GLOBALS['LANG']['th_width_s']) : 200;
$th_s = intval($GLOBALS['LANG']['th_height_s']) > 0 ? intval($GLOBALS['LANG']['th_height_s']) : 200;
$tw_b = intval($GLOBALS['LANG']['th_width_b']) > 0 ? intval($GLOBALS['LANG']['th_width_b']) : 450;
$th_b = intval($GLOBALS['LANG']['th_height_b']) > 0 ? intval($GLOBALS['LANG']['th_height_b']) : 450;
if (isset($_POST['goods_thumb']) && !empty($_POST['goods_thumb'])) {
//留空
} else {
Import::img()->thumb($source_path, dirname($source_path) . DS . 'thumb_s' . DS . $thumb, $tw_s, $th_s);
//小縮略圖
$_POST['goods_thumb'] = $pa . '/thumb_s/' . $thumb;
}
Import::img()->thumb($source_path, dirname($source_path) . DS . 'thumb_b' . DS . $thumb, $tw_b, $th_b);
//大縮略圖
$_POST['goods_img'] = $pa . '/thumb_b/' . $thumb;
}
$_POST['meta_keys'] = !empty($_POST['meta_keys']) ? str_replace(array(',', '。', '.'), ',', $_POST['meta_keys']) : "";
$this->App->update('user_shopgoods', $_POST, 'goods_id', $gid);
$this->jump(SITE_URL . 'shop/sp.php?type=photosinfo', 0, '修改成功!');
exit;
} else {
//添加
$_POST['meta_keys'] = !empty($_POST['meta_keys']) ? str_replace(array(',', '。', '.'), ',', $_POST['meta_keys']) : "";
$_POST['add_time'] = mktime();
$_POST['uid'] = $sid;
//商品圖片
if (!empty($_POST['original_img'])) {
$pa = dirname($_POST['original_img']);
$thumb = basename($_POST['original_img']);
//商品小圖
if (isset($_POST['goods_thumb']) && !empty($_POST['goods_thumb'])) {
//留空即可
} else {
$_POST['goods_thumb'] = $pa . '/thumb_s/' . $thumb;
}
//商品中圖
$_POST['goods_img'] = $pa . '/thumb_b/' . $thumb;
}
$this->App->insert('user_shopgoods', $_POST);
$this->jump(SITE_URL . 'shop/sp.php?type=photosinfo', 0, '添加成功!');
exit;
}
}
$this->set('catelist', $this->get_goods_cate_tree(0, $sid));
$this->template('goodsinfo');
}
示例3: ttest
function ttest()
{
$imgobj = Import::img();
$crawler = Import::crawler();
$iconv = Import::gz_iconv();
require_once SYS_PATH_ADMIN . 'inc' . DS . 'download.php';
//$crawler->curl_get_con('http://www.womai.com/Product-0-526333.htm');exit;
//$imgobj->grabImage("http://www.21ej.com/picture/139-848-892.gif",SYS_PATH."test.gif");
DownImageKeep("http://www.21ej.com/picture/139-848-d892.gif", "http://www.baidu.com", SYS_PATH . "test.gif", "", 0, 1);
exit;
$sql = "SELECT tb1.url,tb2.goods_preg_1,tb2.goods_preg_2,tb2.goods_preg_3,tb2.goods_preg_4,tb2.goods_preg_5 FROM `{$this->App->prefix()}goods_cache_url` AS tb1 LEFT JOIN `{$this->App->prefix()}goods_cache_site` AS tb2 ON tb2.gcid = tb1.gcid WHERE tb1.gcid='1' LIMIT 3";
$rt = $this->App->find($sql);
$str = "";
if (!empty($rt)) {
foreach ($rt as $row) {
$url = $row['url'];
echo $con = $crawler->curl_get_con($url);
exit;
if (empty($con)) {
continue;
}
$con = $iconv->ec_iconv('GB2312', 'UTF8', $con);
//分類
$goods_preg_1 = $row['goods_preg_1'];
@preg_match($goods_preg_1, $con, $arr1);
$catetitle = isset($arr1[1]) ? $arr1[1] : "";
//標題
$goods_preg_2 = $row['goods_preg_2'];
@preg_match($goods_preg_2, $con, $arr2);
$goodstitle = isset($arr2[1]) ? $arr2[1] : "";
//價格
$goods_preg_3 = $row['goods_preg_3'];
@preg_match($goods_preg_3, $con, $arr3);
$goodsprice = isset($arr3[1]) ? $arr3[1] : "";
$goods_preg_4 = $row['goods_preg_4'];
if (!empty($goods_preg_4)) {
$goods_preg_4 = str_replace('"', "'", $goods_preg_4);
@preg_match($goods_preg_4, $con, $arr4);
$goodsimg = isset($arr4[1]) ? $arr4[1] : "";
$simg = "photos/g/" . date('Ym', mktime()) . "/ej" . mktime() . substr($goodsimg, -4);
$imgobj->imagescopy("http://www.21ej.com/" . $goodsimg, SYS_PATH . $simg);
}
$goods_preg_5 = $row['goods_preg_5'];
if (!empty($goods_preg_5)) {
@preg_match($goods_preg_5, $con, $arr5);
$goodsdesc = isset($arr5[1]) ? $arr5[1] : "";
}
}
}
}
示例4: upload
function upload($filename, $filedir = "")
{
if (empty($filedir) || empty($filename)) {
return false;
}
$imgobj = Import::img();
$f_name = $_FILES[$filename]['name'];
//獲取上傳源文件名
$t = strrchr($f_name, '.');
//圖片類型
$name = time() . time() . $t;
//原始圖名稱
//設置生成縮略圖圖片的大小
$dir = basename(dirname($filedir));
$tw_s = 260;
$th_s = 260;
$tw_b = 600;
$th_b = 600;
$result = false;
switch ($dir) {
case 'articlephoto':
//文章圖片
break;
case 'catephoto':
//分類圖片
break;
case 'companylogo':
//客戶公司圖片
break;
case 'friendlogo':
//友情鏈接圖片圖片
break;
case 'site_icon':
//網站圖標
break;
case 'brand':
//品牌的banner圖
//品牌的banner圖
case 'goods':
//商品
$tw_s = intval($GLOBALS['LANG']['th_width_s']) > 0 ? intval($GLOBALS['LANG']['th_width_s']) : 260;
$th_s = intval($GLOBALS['LANG']['th_height_s']) > 0 ? intval($GLOBALS['LANG']['th_height_s']) : 260;
$tw_b = intval($GLOBALS['LANG']['th_width_b']) > 0 ? intval($GLOBALS['LANG']['th_width_b']) : 600;
$th_b = intval($GLOBALS['LANG']['th_height_b']) > 0 ? intval($GLOBALS['LANG']['th_height_b']) : 600;
break;
case 'avatar':
$tw_s = 150;
$th_s = 150;
$tw_b = 150;
$th_b = 150;
$result = true;
break;
}
$imgname = $imgobj->upload($filename, $filedir . $name);
$other = array('banner', 'brand', 'cover', 'top_img');
if (file_exists($filedir . $name)) {
if ($dir == 'avatar') {
//頭像 生成150
$imgobj->thumb($filedir . $name, $filedir . 'thumb_s' . DS . $name, $tw_s, $th_s);
@unlink($filedir . $name);
//Import::->fileop()->delete_file($filedir.$name);
$imgobj->thumb($filedir . 'thumb_s' . DS . $name, $filedir . $name, $tw_b, $th_b);
@unlink($filedir . 'thumb_b' . DS . $name);
//Import::->fileop()->delete_file($filedir.'thumb_b'.DS.$name);
} else {
if (!in_array($dir, $other)) {
$imgobj->thumb($filedir . $name, $filedir . 'thumb_s' . DS . $name, $tw_s, $th_s);
$imgobj->thumb($filedir . $name, $filedir . 'thumb_b' . DS . $name, $tw_b, $th_b);
}
}
}
return $name;
}
示例5: zhuanyi_goods
function zhuanyi_goods()
{
if (isset($_GET['kk']) && isset($_GET['maxpage'])) {
$imgobj = Import::img();
$kk = $_GET['kk'];
$list = 20;
if ($kk == 0) {
$tt = $this->App->findvar("SELECT COUNT(goods_id) FROM `{$this->App->prefix()}goods`");
$maxpage = ceil($tt / $list);
} else {
$maxpage = $_GET['maxpage'];
}
$start = $kk * $list;
$sql = "SELECT g.*,u.user_name FROM `{$this->App->prefix()}goods` AS g LEFT JOIN `{$this->App->prefix()}user` AS u ON u.user_id = g.uid LIMIT {$start},{$list}";
$rt = $this->App->find($sql);
$str = "";
if (!empty($rt)) {
foreach ($rt as $row) {
//檢查是否已經存在該記錄
if ($row['uid'] > 0) {
$sgid = $this->App->findvar("SELECT sgid FROM `{$this->App->prefix()}suppliers_goods` WHERE suppliers_id='{$row['uid']}' AND goods_id='{$row['goods_id']}'");
if (empty($sgid)) {
$this->App->insert('suppliers_goods', array('suppliers_id' => $row['uid'], 'goods_id' => $row['goods_id'], 'market_price' => $row['market_price'], 'shop_price' => $row['shop_price'], 'pifa_price' => $row['pifa_price'], 'is_on_sale' => $row['is_on_sale'], 'is_delete' => $row['is_delete'], 'is_check' => $row['is_check'], 'addtime' => mktime()));
$str .= '轉移=>供應商[' . $row['user_name'] . '] goods_id[' . $row['goods_id'] . '] 供應價[' . $row['market_price'] . '] 零售價[' . $row['shop_price'] . '] 批發價[' . $row['pifa_price'] . ']' . "<br/>";
} else {
//$this->App->update('suppliers_goods',array('suppliers_id'=>$row['uid'],'goods_id'=>$row['goods_id'],'market_price'=>$row['market_price'],'shop_price'=>$row['shop_price'],'pifa_price'=>$row['pifa_price'],'is_on_sale'=>$row['is_on_sale'],'is_delete'=>$row['is_delete'],'addtime'=>mktime()),array("goods_id='$row[goods_id]'","suppliers_id='$row[uid]'"));
$str .= "該商品已經存在=goods_id:" . $row['goods_id'] . ",正在更新!<br/>";
}
} else {
$str .= "沒有指定供應商!<br/>";
}
}
}
$kk = $kk + 1;
$str .= "<font color=red>==============Load.....page(" . $kk . ")================</font><br />";
if ($kk > $maxpage) {
$kk = "";
}
sleep(2);
$rts = array('kk' => $kk, 'url' => $str, 'maxpage' => $maxpage);
die(Import::json()->encode($rts));
}
$this->template('zhuanyi_goods');
}
示例6: ajax_upload
function ajax_upload($filename = "")
{
@set_time_limit(600);
//最大運行時間
$fop = Import::fileop();
$aid = $this->Session->read('adminid');
$fn = SYS_PATH . 'cache' . DS . 'admin-' . $aid . '.php';
//記錄錯誤日記
$fop->writefile($fn, "");
$tw_s = intval($GLOBALS['LANG']['th_width_s']) > 0 ? intval($GLOBALS['LANG']['th_width_s']) : 200;
$th_s = intval($GLOBALS['LANG']['th_height_s']) > 0 ? intval($GLOBALS['LANG']['th_height_s']) : 200;
$tw_b = intval($GLOBALS['LANG']['th_width_b']) > 0 ? intval($GLOBALS['LANG']['th_width_b']) : 450;
$th_b = intval($GLOBALS['LANG']['th_height_b']) > 0 ? intval($GLOBALS['LANG']['th_height_b']) : 450;
if (!empty($_FILES[$filename]['tmp_name'])) {
$fn = SYS_PATH . 'cache' . DS . 'admin-upload-' . $aid . '.xls';
if (file_exists($fn)) {
unlink($fn);
}
//刪除原來文件
$fop->copyfile($filename, $fn);
//複製文件到服務器
if (!file_exists($fn)) {
$fop->copyfile($filename, $fn);
if (!file_exists($fn)) {
echo '<script> alert("上傳時發生意外錯誤!"); </script>';
return false;
}
}
$data = Import::excel();
//$data->read($_FILES[$filename]['tmp_name']);
$data->read($fn);
//讀取文件
$importkey = $data->sheets[0]['cells'][1];
for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++) {
//以下注釋的for循環打印excel表數據
$this->rtData = array();
//商品數據
$this->rtData_gallery = array();
//商品相冊
for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
$this->goods_key($importkey[$j], $data->sheets[0]['cells'][$i][$j]);
//傳送 鍵=>值 處理
}
$this->rtData['is_on_sale'] = '0';
$uuid = 0;
$uuid = $this->rtData['uid'];
if (!($uuid > 0)) {
$uuid = '18';
}
$this->rtData['uid'] = $uuid;
$this->rtData['add_time'] = mktime();
$inData = $this->rtData;
//print_r($inData); exit;
$goods_id = 0;
//檢查該商品已經存在數據庫中
$sn = $inData['goods_bianhao'];
//優先級是商品編號檢查
if (!empty($sn)) {
$sql = "SELECT goods_id FROM `{$this->App->prefix()}goods` WHERE goods_bianhao='{$sn}' AND uid='{$uuid}'";
$goods_id = $this->App->findvar($sql);
//if(!empty($snvar)) continue;
} else {
$sa = $inData['goods_name'];
//商品名稱檢查是否該商品已經存在
if (!empty($sa)) {
//最後更新:2012-12-11 10:26
$sql = "SELECT goods_id FROM `{$this->App->prefix()}goods` WHERE goods_name='{$sa}' AND uid='{$uuid}'";
$goods_id = $this->App->findvar($sql);
//if(!empty($savar)) continue;
}
}
if (!empty($inData['goods_name'])) {
//商品圖片
$val = $inData['original_img'];
if (!empty($val)) {
$pa = dirname($val);
$thumb = basename($val);
if (is_file(SYS_PATH . $pa . DS . 'thumb_s' . DS . $thumb)) {
$pp = SYS_PATH . $pa . DS . 'thumb_s' . DS . mktime() . $thumb;
$pps = $pa . '/thumb_s/' . mktime() . $thumb;
} else {
$pp = SYS_PATH . $pa . DS . 'thumb_s' . DS . $thumb;
$pps = $pa . '/thumb_s/' . $thumb;
}
Import::img()->thumb(SYS_PATH . $val, $pp, $tw_s, $th_s);
//小縮略圖
$inData['goods_thumb'] = $pps;
if (is_file(SYS_PATH . $pa . DS . 'thumb_b' . DS . $thumb)) {
$pp = SYS_PATH . $pa . DS . 'thumb_b' . DS . mktime() . $thumb;
$pps = $pa . '/thumb_b/' . mktime() . $thumb;
} else {
$pp = SYS_PATH . $pa . DS . 'thumb_b' . DS . $thumb;
$pps = $pa . '/thumb_b/' . $thumb;
}
Import::img()->thumb(SYS_PATH . $val, $pp, $tw_b, $th_b);
//大縮略圖
$inData['goods_img'] = $pps;
}
if ($goods_id > 0) {
//更新
//.........這裏部分代碼省略.........
示例7: keyword
function keyword($keyword = '')
{
if (!empty($keyword)) {
$wecha_id = $this->wecha_id;
switch ($keyword) {
case '推廣鏈接':
$RL = $this->App->findrow("SELECT user_id,is_subscribe FROM `{$this->App->prefix()}user` WHERE wecha_id='{$wecha_id}' LIMIT 1");
$issubscribe = isset($RL['is_subscribe']) ? $RL['is_subscribe'] : '0';
$uid = isset($RL['user_id']) ? $RL['user_id'] : '0';
unset($RL);
if ($issubscribe == '0') {
return array('請先關注搶占分享地盤!', 'text');
exit;
}
$thisurl = SITE_URL . "m/in.php?tid=" . $uid;
return array('複製鏈接發送給朋友賺錢:' . $thisurl, 'text');
break;
case 'ranklist':
// 排行榜
$RL = $this->App->findrow("SELECT user_id,user_rank FROM `{$this->App->prefix()}user` WHERE wecha_id='{$this->wecha_id}' LIMIT 1");
$uid = isset($RL['user_id']) ? $RL['user_id'] : '0';
$purt = $this->App->findrow("SELECT ut.parent_uid,u.wecha_id FROM `{$this->App->prefix()}user_tuijian` AS ut LEFT JOIN `{$this->App->prefix()}user` AS u ON u.user_id = ut.parent_uid WHERE ut.uid='{$uid}' LIMIT 1");
$puid = isset($purt['parent_uid']) ? $purt['parent_uid'] : '0';
if ($uid > 0) {
$gzcount = $this->App->findvar("SELECT COUNT(user_id) FROM `{$this->App->prefix()}user` LIMIT 1");
$gzcount = $gzcount * 5 + 750;
if ($puid > 0) {
$nickname = $this->App->findrow("SELECT nickname FROM `{$this->App->prefix()}user` WHERE user_id = '{$puid}' LIMIT 1");
if (empty($nickname)) {
$nickname = '官網';
}
$str = '來自好友【' . $nickname['nickname'] . '】的推薦成為第【' . $gzcount . '】位會員,立即關注,搶奪店主地盤!';
} else {
$str = '來自【官網】的推薦成為第【' . $gzcount . '】位會員,立即關注,搶奪店主地盤!';
}
}
$data = '{"touser":"' . $wecha_id . '","msgtype":"text","text":{"content":"' . $str . '"}}';
$access_token = $this->_get_access_token();
$rt = $this->curlPost('https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=' . $access_token, $data, 0);
$orderid = $this->App->findvar("SELECT order_id FROM `{$this->App->prefix()}goods_order_info` where `user_id`='{$RL['user_id']}' and `pay_status`=1");
if ($orderid or $RL['user_rank'] > 1) {
return array('你已經是店主 發送你的名片給你的好友 賺錢吧', 'text');
} else {
return array("您還不是店主,請<a href=\"" . SITE_URL . "/m/oauth.php?oid=1\">購買商品</a>成為店主", 'text');
}
break;
case 'qr':
//生成二維碼
//生成二維碼
case '我的二維碼':
//生成二維碼
$yuming = str_replace(array('www', '.'), '', $_SERVER["HTTP_HOST"]);
if (!empty($yuming)) {
$yuming = $yuming . DS;
}
if (!empty($wecha_id)) {
$tb = 'markimg';
$sql = "SELECT is_subscribe,user_rank,user_id,quid,headimgurl,nickname FROM `{$this->App->prefix()}user` WHERE wecha_id='{$wecha_id}' LIMIT 1";
$RT = $this->App->findrow($sql);
if ($RT['is_subscribe'] == '0') {
return array('關注後購買成為合夥人生成推廣二維碼賺錢吧!', 'text');
exit;
}
$access_token = $this->_get_access_token();
if ($RT['user_rank'] == '1') {
//生成推薦人二維碼
$tb = 'markimg2';
/* $uid = isset($RT['user_id']) ? $RT['user_id'] : '0';
$puid = $this->return_daili_uid($uid);//返回上級分銷商 */
/*
if($puid > 0){
$sql = "SELECT is_subscribe,user_rank,user_id,quid,headimgurl,nickname FROM `{$this->App->prefix()}user` WHERE user_id='$puid' LIMIT 1";
$RT = $this->App->findrow($sql);
}else{//生成官網二維碼
$tb = 'markimg3';
$this->send(array('openid'=>$wecha_id,'appid'=>'','appsecret'=>'','nickname'=>''),$tb);
$sql = "SELECT site_url FROM `{$this->App->prefix()}systemconfig` WHERE type='basic' LIMIT 1";
$f3 = $this->App->findvar($sql);
if(!empty($f3)) $f3 = SYS_PATH.$f3;
if(file_exists($f3)){
$type = "image";
$filedata = array("media"=>"@".$f3);
$url = "http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token=$access_token&type=$type";
$result = $this->https_request($url,$filedata);
$json = json_decode($result);
$media_id = $json->media_id;
if(!empty($media_id)) $this->send(array('openid'=>$wecha_id,'appid'=>'','appsecret'=>'','media_id'=>$media_id),'markimgsend');
exit;
}
//return array('你是由官網推薦,請購買後生成你的推廣二維碼!', 'text');
exit;
}
*/
$this->send(array('openid' => $wecha_id, 'appid' => '', 'appsecret' => '', 'nickname' => ''), $tb);
//return array("對不起、您不是東家,獲得推廣圖片,請購買<a href='#'>商品<a/>成為東家", 'xml');
exit;
}
$uid = $RT['user_id'];
$quid = $RT['quid'];
//.........這裏部分代碼省略.........
示例8: info
//.........這裏部分代碼省略.........
$this->jump('goods.php?type?goods_list');
exit;
}
//當前商品的相冊
$sql = "SELECT * FROM `{$this->App->prefix()}goods_gallery` WHERE goods_id='{$gid}'";
$this->set('gallerylist', $this->App->find($sql));
//當前商品屬性的屬性
$sql = "SELECT tb1.*,tb2.attr_name,tb2.attr_is_select FROM `{$this->App->prefix()}goods_attr` AS tb1 LEFT JOIN `{$this->App->prefix()}attribute` AS tb2 ON tb1.attr_id=tb2.attr_id WHERE tb1.goods_id='{$gid}'";
$goods_attr = $this->App->find($sql);
$rt['goods_attr'] = array();
if (!empty($goods_attr)) {
foreach ($goods_attr as $row) {
$rt['goods_attr'][$row['attr_id']][] = $row;
}
unset($row, $goods_attr);
}
//商品的贈品類型
$sql = "SELECT type FROM `{$this->App->prefix()}goods_gift` WHERE goods_id='{$gid}'";
$rt['gift_type_id'] = $this->App->findcol($sql);
if (isset($_POST) && !empty($_POST)) {
if (empty($_POST['goods_name'])) {
echo '<script>alert("商品名稱不能為空!");</script>';
} else {
//貨號
if (empty($_POST['goods_sn'])) {
$_POST['goods_sn'] = 'GZFH' . str_repeat('0', 6 - strlen($gid)) . $gid;
}
//檢查當前的貨號是否存在
$checkvar = $this->App->findvar("SELECT goods_sn FROM `{$this->App->prefix()}goods` WHERE goods_sn={$_POST['goods_sn']} LIMIT 1");
if (!empty($checkvar)) {
$_POST['goods_sn'] = $_POST['goods_sn'] . '-1';
//重新定義一個
}
if ($rt['original_img'] != $_POST['original_img']) {
//修改了上傳文件 那麽重新上傳
$source_path = SYS_PATH . DS . str_replace('/', DS, $_POST['original_img']);
$pa = dirname($_POST['original_img']);
$thumb = basename($_POST['original_img']);
$tw_s = intval($GLOBALS['LANG']['th_width_s']) > 0 ? intval($GLOBALS['LANG']['th_width_s']) : 200;
$th_s = intval($GLOBALS['LANG']['th_height_s']) > 0 ? intval($GLOBALS['LANG']['th_height_s']) : 200;
$tw_b = intval($GLOBALS['LANG']['th_width_b']) > 0 ? intval($GLOBALS['LANG']['th_width_b']) : 450;
$th_b = intval($GLOBALS['LANG']['th_height_b']) > 0 ? intval($GLOBALS['LANG']['th_height_b']) : 450;
if (isset($_POST['goods_thumb']) && !empty($_POST['goods_thumb'])) {
//留空
} else {
Import::img()->thumb($source_path, dirname($source_path) . DS . 'thumb_s' . DS . $thumb, $tw_s, $th_s);
//小縮略圖
$_POST['goods_thumb'] = $pa . '/thumb_s/' . $thumb;
}
Import::img()->thumb($source_path, dirname($source_path) . DS . 'thumb_b' . DS . $thumb, $tw_b, $th_b);
//大縮略圖
$_POST['goods_img'] = $pa . '/thumb_b/' . $thumb;
}
$_POST['meta_keys'] = !empty($_POST['meta_keys']) ? str_replace(array(',', '。', '.'), ',', $_POST['meta_keys']) : "";
$_POST['last_update'] = mktime();
//更新時間
$this->App->update('goods', $_POST, 'goods_id', $gid);
//更新商品屬性[從新添加]
if (!empty($attr_id_list) && !empty($gid)) {
foreach ($attr_id_list as $kk => $id) {
if (empty($attr_value_list[$kk])) {
continue;
}
$rtdata = array();
$rtdata['attr_id'] = $id;
$rtdata['attr_value'] = isset($attr_value_list[$kk]) ? $attr_value_list[$kk] : "NULL";
示例9: ajax_addads_info
function ajax_addads_info($data = array(), $id = 0)
{
if (!empty($data['tid'])) {
//生成指定寬度高度的圖片
$tid = $data['tid'];
$sql = "SELECT ad_width,ad_height FROM `{$this->App->prefix()}ad_position` WHERE tid='{$tid}'";
$rr = $this->App->findrow($sql);
$width = $rr['ad_width'];
$height = $rr['ad_height'];
if (!empty($width) && !empty($height) && !empty($data['ad_img'])) {
if (!empty($id)) {
$sql = "SELECT ad_img FROM `{$this->App->prefix()}ad_content` WHERE pid='{$id}'";
$var = $this->App->findvar($sql);
if ($data['ad_img'] != $var) {
Import::fileop()->delete_file(SYS_PATH . $var);
//刪除文件
$q = dirname($var);
$h = basename($var);
Import::fileop()->delete_file(SYS_PATH . $q . DS . 'thumb_s' . DS . $h);
Import::fileop()->delete_file(SYS_PATH . $q . DS . 'thumb_b' . DS . $h);
if (file_exists(SYS_PATH . $data['ad_img'])) {
Import::img()->thumb(SYS_PATH . $data['ad_img'], SYS_PATH . $data['ad_img'], $width, $height);
}
}
}
}
}
if (!empty($id)) {
$data['uptime'] = time();
} else {
$data['addtime'] = time();
}
$ad_name = $data['ad_name'];
if (empty($id)) {
if ($this->App->insert('ad_content', $data)) {
@file_get_contents(SITE_URL . 'data/flashdata/dynfocus/loadjs.php');
//將數據寫入文件
$this->action('system', 'add_admin_log', '添加廣告:' . $ad_name);
} else {
echo "無法添加廣告,意外錯誤!";
}
} else {
if ($this->App->update('ad_content', $data, 'pid', $id)) {
@file_get_contents(SITE_URL . 'data/flashdata/dynfocus/loadjs.php');
//將數據寫入文件
$this->action('system', 'add_admin_log', '修改廣告:' . (empty($ad_name) ? "激活狀態" : $ad_name));
} else {
echo "數據未變動,無需更新!";
}
}
exit;
}
示例10: ajax_suppliers_upload_cache_photo
function ajax_suppliers_upload_cache_photo($data = array())
{
if (empty($data['str_spec'])) {
die("非法!");
}
$uid = $this->check_is_suppliers();
@set_time_limit(600);
//最大運行時間
$ar_spec = explode('++', $data['str_spec']);
$goods = array();
$photo_gallery_desc = array();
$photo_gallery_url = array();
foreach ($ar_spec as $str) {
$item_ar = @explode('---', $str);
if (count($item_ar) == 3) {
if (in_array($item_ar[0], array('photo_gallery_desc', 'photo_gallery_url'))) {
if ($item_ar[0] == 'photo_gallery_desc') {
$photo_gallery_desc[$item_ar[2]][] = $item_ar[1];
//相冊描述
} elseif ($item_ar[0] == 'photo_gallery_url') {
$photo_gallery_url[$item_ar[2]][] = $item_ar[1];
//相冊圖片
}
} else {
$goods[$item_ar[2]][$item_ar[0]] = $item_ar[1];
}
}
}
$datas = array();
$imgobj = Import::img();
foreach ($goods as $item => $row) {
if (empty($row['goods_bianhao'])) {
$gid = $this->App->findvar("SELECT MAX(goods_id) + 1 FROM `{$this->App->prefix()}goods`");
$gid = empty($gid) ? 1 : $gid;
$goods_bianhao = '2EJ' . str_repeat('0', 6 - strlen($gid)) . $gid;
} else {
$goods_bianhao = $row['goods_bianhao'];
}
//檢查是否已經存在
if (empty($row['goods_sn'])) {
$row['goods_sn'] = $goods_bianhao;
}
$ginfo = $this->App->findrow("SELECT goods_id,goods_thumb,goods_img,original_img FROM `{$this->App->prefix()}goods` WHERE goods_sn='{$row['goods_sn']}'");
$gid = isset($ginfo['goods_id']) ? $ginfo['goods_id'] : 0;
$datas['goods_bianhao'] = $goods_bianhao;
$datas['goods_sn'] = $row['goods_sn'];
if ($row['goods_numbers'] > 0) {
$datas['goods_number'] = $row['goods_numbers'];
}
$datas['goods_name'] = $row['goods_name'];
if ($row['pifa_price'] > 0) {
$datas['market_price'] = $row['pifa_price'];
}
if ($row['pifa_price'] > 0) {
$datas['pifa_price'] = $row['pifa_price'];
}
if ($row['shop_price'] > 0) {
$datas['shop_price'] = $row['shop_price'];
}
if ($row['cat_id'] > 0) {
$datas['cat_id'] = $row['cat_id'];
}
if ($row['brand_id'] > 0) {
$datas['brand_id'] = $row['brand_id'];
}
$datas['goods_brief'] = $row['goods_brief'];
$datas['goods_unit'] = $row['goods_unit'];
if ($row['goods_weight'] > 0) {
$datas['goods_weight'] = $row['goods_weight'];
}
if ($row['warn_number'] > 0) {
$datas['warn_number'] = $row['warn_number'];
}
if (!empty($row['sourcepathname'])) {
$imgobj->filecopy($row['sourcepathname'], $row['uploadname']);
if ($gid > 0) {
$fop = Import::fileop();
//刪除原來的圖片
$fop->delete_file(SYS_PATH . $ginfo['goods_thumb']);
$fop->delete_file(SYS_PATH . $ginfo['goods_img']);
$fop->delete_file(SYS_PATH . $ginfo['original_img']);
//商品相冊
/*$sql = "SELECT img_url FROM `{$this->App->prefix()}goods_gallery` WHERE goods_id ='$gid'";
$gallery_img = $this->App->findcol($sql);
if(!empty($gallery_img)){
foreach($gallery_img as $img){
$q = dirname($img);
$h = basename($img);
$fop->delete_file(SYS_PATH.$q.DS.'thumb_s'.DS.$h);
$fop->delete_file(SYS_PATH.$q.DS.'thumb_b'.DS.$h);
$fop->delete_file(SYS_PATH.$img); //
}
unset($gallery_img);
}*/
unset($ginfo);
}
} else {
continue;
}
if (!file_exists($row['uploadname'])) {
//.........這裏部分代碼省略.........