标签:eid 技术 时间 size 系统 ann fine from 格式
分享一个destoon7.0会员模块+产品供应模块发布接口,希望对大家有帮助!
<?php @set_time_limit(0); define(‘DT_ADMIN‘, true); define(‘DT_MEMBER‘, true); require ‘common.inc.php‘; require DT_ROOT.‘/admin/global.func.php‘; require DT_ROOT.‘/include/post.func.php‘; require_once DT_ROOT.‘/include/cache.func.php‘; require_once DT_ROOT.‘/include/module.func.php‘; require DT_ROOT.‘/module/member/member.class.php‘; require DT_ROOT.‘/module/sell/sell.class.php‘; require DT_ROOT . ‘/include/remote.class.php‘; /****************配置信息华丽的分割线***************/ $config = array ( ‘注册邮件后缀‘ => ‘qq.com|||126.com|||163.com‘, //多个用|||分割 ‘注册用户名‘ => ‘a_123456|||b_123456|||c_123456|||d_123456|||e_123456|||f_123456|||g_123456‘, //发布用户名,把想充当发布的用户名放到这里,用|||分割,用户名不需要在系统已经存在,如果没有会自动注册 //跟系统格式相同不可有中文字符,用户名应为小写字母(a-z)、数字(0-9)、下划线(_)、中划线(-)组合 ‘用户密码‘ => ‘‘, //新注册用户的密码 ‘用户密码参数‘ => ‘jksdjfs‘, //用户密码参数,建议随意修改 ‘分隔符‘ => ‘|||‘, //采集器标签循环的分隔符 ); /****************配置信息华丽的分割线***************/ /** * 验证接口密码 */ $pw = ‘123456‘;//默认接口密码,此接口放在服务器上时,为了你的服务器安全请及时修改此密码参数 if(strcmp($_GET[‘pw‘] , $pw)){ exit(‘接口密码错误!‘); } /** * 获取行业分类列表 */ if(isset($_GET[‘getList‘])){ echo category_select(‘list‘, ‘请选择行业分类‘, 0, 5); exit; } //die; /** * 企业用户注册 */ $do = new member; $user = explode($config[‘分隔符‘], $config[‘注册用户名‘]); $username = !empty($_POST[‘username‘]) ? $_POST[‘username‘] : ‘‘; if(empty($username)){ $username = $user[rand(0,count($user)-1)].substr(md5(time()),1,6); } if($do->username_exists($username)){ echo(‘该用户名已经存在!‘); }else { if(!$do->is_username($username)){ exit(‘用户名不合法!‘); } $md5 = md5($username.$config[‘用户密码参数‘]); if(!empty($config[‘用户密码‘])){ $password = $config[‘用户密码‘]; }else{ $password = substr($md5, 20); } if(empty($config[‘注册邮件后缀‘])){ $mail_ext = ‘@126.com‘; }else{ $mail_arr = explode(‘|||‘, $config[‘注册邮件后缀‘]); $mail_ext = ‘@‘.$mail_arr[rand(0 , count($mail_arr)-1)]; } $email = !empty($_POST[‘email‘]) ? $_POST[‘email‘] : ‘‘; if(empty($email)) { $email = substr($md5, 0, 6) . $mail_ext; } if (!$do->is_email($email)) { exit(‘邮箱不合法!‘); } if ($do->email_exists($email)) { exit(‘该邮箱已被注册‘); } $company = !empty($_POST[‘company‘]) ? $_POST[‘company‘] : ‘‘; if(empty($company)) { $company = ‘合肥信息技术有限公司‘.substr(md5(time()),0,6); } if (empty($company)) { exit(‘公司名不可为空!‘); } if (!$do->is_company($company)) exit(‘公司名不合法!‘); if ($do->company_exists($company)) exit(‘公司名已经存在,请更换!‘); $session = new dsession(); $_SESSION[‘regemail‘] = md5(md5($email . DT_KEY . $DT_IP)); $member = array(); $_POST[‘regid‘] = 6; $data = $_POST; $member[‘mobile‘] = isset($data[‘mobile‘]) ? $data[‘mobile‘] : ‘‘; $member[‘qq‘] = isset($data[‘qq‘]) ? $data[‘qq‘] : ‘‘; $member[‘groupid‘] = $data[‘regid‘]; $member[‘passport‘] = $member[‘username‘] = $username; $member[‘email‘] = $email; $member[‘password‘] = $member[‘cpassword‘] = $password; $member[‘edittime‘] = $DT_TIME; $member[‘inviter‘] = $username; $member[‘truename‘] = !empty($data[‘truename‘]) ? $data[‘truename‘] : $username; $member[‘gender‘] = !empty($data[‘gender‘]) ? (strcmp($data[‘gender‘],‘男‘) ? 0: 1 ) : 1; $member[‘areaid‘] = 1; $member[‘company‘] = $company; $member[‘type‘] = !empty($data[‘type‘]) ? $data[‘type‘] : ‘企业单位‘; $member[‘catid‘] = ‘,3,‘; $member[‘business‘] = !empty($data[‘business‘]) ? $data[‘business‘] : ‘制造业‘; $member[‘business‘] = ‘人民币‘; $member[‘regyear‘] = !empty($data[‘regyear‘]) ? $data[‘regyear‘] : ‘2010‘; $member[‘address‘] = !empty($data[‘address‘]) ? $data[‘address‘] : ‘公司地址为空‘; $member[‘telephone‘] = !empty($data[‘telephone‘]) ? $data[‘telephone‘] : ‘0551-62864156-606‘; $member[‘introduce‘] = !empty($data[‘introduce‘]) ? $data[‘introduce‘] : ‘我公司经过多年的发展,逐渐在本行业发展成为领头企业‘; $MFD = cache_read(‘fields-member.php‘); $CFD = cache_read(‘fields-company.php‘); isset($post_fields) or $post_fields = array(); if ($MFD || $CFD) require DT_ROOT . ‘/include/fields.func.php‘; if ($MFD) fields_check($post_fields, $MFD); if ($CFD) fields_check($post_fields, $CFD); $MOD[‘introduce_length‘] = 0; $uid = $do->add($member); if ($uid) { echo ‘企业用户注册成功!‘; } else { exit(‘企业用户注册失败!‘); } } /***企业用户注册完毕*/ /** * 行业分类处理 */ //echo category_select(‘category[parentid]‘, ‘请选择行业分类‘, 0, 5); if(!empty($_POST[‘cid‘])){ $pid = $_POST[‘cid‘]; } if(!empty($_POST[‘catname‘])) { $do = new category(5,0); $table = $DT_PRE . ‘category‘; $cat_arr = $_POST[‘catname‘]; $catArr = explode(‘|||‘, $cat_arr); $pid = 0; foreach($catArr as $catname) { if (!$catname) exit(‘分类名不能为空‘); isset($catname) or $catname = ‘‘; if (!$catname || strpos($catname, "\n") !== false) exit(‘‘); if (strtoupper(DT_CHARSET) != ‘UTF-8‘) $catname = convert($catname, ‘UTF-8‘, DT_CHARSET); $catdir = $do->get_letter($catname, false); if ($do->get_catdir($catdir)) { $catgory = array(); $catgory[‘catname‘] = $catname; $catgory[‘catdir‘] = $catdir; $catgory[‘letter‘] = substr($catdir, 0, 1); $catgory[‘parentid‘] = $pid; $pid = categoryAdd($catgory, $table); echo $catname.‘此行业分类添加成功!‘; } else { $arr = catList(); foreach($arr as $key){ if(strcmp($key[‘catname‘],$catname) == 0){ $pid = $key[‘catid‘]; break; } } echo ‘已存在此行业分类!‘; continue; } } } /** * 行业分类处理完毕 */ /** * 图片上传处理 */ if(!empty($_POST[‘remotePic‘])) { $remotePic = explode(‘|||‘, $_POST[‘remotePic‘]); $num = count($remotePic); $remoteUrl = array(); if ($num > 0) { $i = 0; for ($i; $i < $num; $i++) { $remote = isset($remotePic[$i]) ? trim($remotePic[$i]) : ‘‘; $uploaddir = ‘file/upload/‘ . timetodate($DT_TIME, $DT[‘uploaddir‘]) . ‘/‘; $from = ‘album‘; is_dir(DT_ROOT . ‘/‘ . $uploaddir) or dir_create(DT_ROOT . ‘/‘ . $uploaddir); if ($remote && strlen($remote) > 17 && strpos($remote, ‘://‘) !== false) { $do = new remote($remote, $uploaddir); if ($do->save()) { $session = new dsession(); $limit = intval($MG[‘uploadlimit‘]); $total = isset($_SESSION[‘uploads‘]) ? count($_SESSION[‘uploads‘]) : 0; if ($limit && $total > $limit - 1) { file_del(DT_ROOT . ‘/‘ . $do->saveto); $errmsg = ‘Error(5)‘ . lang(‘message->upload_limit‘, array($limit)); if ($swfupload) exit(convert($errmsg, DT_CHARSET, ‘utf-8‘)); dalert($errmsg, ‘‘, $errjs); } $img_info = @getimagesize(DT_ROOT . ‘/‘ . $do->saveto); if (in_array($do->ext, array(‘jpg‘, ‘jpeg‘, ‘gif‘, ‘png‘, ‘bmp‘, ‘swf‘))) { $upload_bad = 0; if ($img_info) { $upload_mime = array(‘jpg‘ => ‘image/jpeg‘, ‘jpeg‘ => ‘image/jpeg‘, ‘gif‘ => ‘image/gif‘, ‘png‘ => ‘image/png‘, ‘bmp‘ => ‘image/bmp‘, ‘swf‘ => ‘application/x-shockwave-flash‘); if ($img_info[‘mime‘] != $upload_mime[$do->ext]) $upload_bad = 1; } else { $upload_bad = 1; } if ($upload_bad) { file_del(DT_ROOT . ‘/‘ . $do->saveto); $errmsg = ‘Error(6)‘ . lang(‘message->upload_bad‘); if ($swfupload) exit(convert($errmsg, DT_CHARSET, ‘utf-8‘)); dalert($errmsg, ‘‘, $errjs); } } if (in_array($do->ext, array(‘jpg‘, ‘jpeg‘)) && $img_info[‘channels‘] == 4) { file_del(DT_ROOT . ‘/‘ . $do->saveto); $errmsg = ‘Error(7)‘ . lang(‘message->upload_cmyk‘); if ($swfupload) exit(convert($errmsg, DT_CHARSET, ‘utf-8‘)); dalert($errmsg, ‘‘, $errjs); } $img_w = $img_h = 0; if ($do->image) { require DT_ROOT . ‘/include/image.class.php‘; if ($do->ext == ‘gif‘ && in_array($from, array(‘thumb‘, ‘album‘, ‘photo‘))) { if (!function_exists(‘imagegif‘) || !function_exists(‘imagecreatefromgif‘)) { file_del(DT_ROOT . ‘/‘ . $do->saveto); $errmsg = ‘Error(8)‘ . lang(‘message->upload_jpg‘); if ($swfupload) exit(convert($errmsg, DT_CHARSET, ‘utf-8‘)); dalert($errmsg, ‘‘, $errjs); } } if ($DT[‘bmp_jpg‘] && $do->ext == ‘bmp‘) { require DT_ROOT . ‘/include/bmp.func.php‘; $bmp_src = DT_ROOT . ‘/‘ . $do->saveto; $bmp = imagecreatefrombmp($bmp_src); if ($bmp) { $do->saveto = str_replace(‘.bmp‘, ‘.jpg‘, $do->saveto); $do->ext = ‘jpg‘; imagejpeg($bmp, DT_ROOT . ‘/‘ . $do->saveto); file_del($bmp_src); if (DT_CHMOD) @chmod(DT_ROOT . ‘/‘ . $do->saveto, DT_CHMOD); } } $img_w = $img_info[0]; $img_h = $img_info[1]; if ($DT[‘max_image‘] && in_array($from, array(‘editor‘, ‘album‘, ‘photo‘))) { if ($img_w > $DT[‘max_image‘]) { $img_h = intval($DT[‘max_image‘] * $img_h / $img_w); $img_w = $DT[‘max_image‘]; $image = new image(DT_ROOT . ‘/‘ . $do->saveto); $image->thumb($img_w, $img_h); } } if ($from == ‘thumb‘) { if ($width && $height) { $image = new image(DT_ROOT . ‘/‘ . $do->saveto); $image->thumb($width, $height, $DT[‘thumb_title‘]); $img_w = $width; $img_h = $height; $do->file_size = filesize(DT_ROOT . ‘/‘ . $do->saveto); } } else if ($from == ‘album‘ || $from == ‘photo‘) { $saveto = $do->saveto; $do->saveto = $do->saveto . ‘.thumb.‘ . $do->ext; file_copy(DT_ROOT . ‘/‘ . $saveto, DT_ROOT . ‘/‘ . $do->saveto); $middle = $saveto . ‘.middle.‘ . $do->ext; file_copy(DT_ROOT . ‘/‘ . $saveto, DT_ROOT . ‘/‘ . $middle); if ($DT[‘water_type‘] == 2) { $image = new image(DT_ROOT . ‘/‘ . $saveto); $image->waterimage(); } else if ($DT[‘water_type‘] == 1) { $image = new image(DT_ROOT . ‘/‘ . $saveto); $image->watertext(); } if ($DT[‘water_type‘] && $DT[‘water_com‘] && $_groupid > 5) { $image = new image(DT_ROOT . ‘/‘ . $saveto); $image->text = $_company; $image->pos = 5; $image->watertext(); } if ($from == ‘photo‘) $DT[‘thumb_album‘] = 0; $image = new image(DT_ROOT . ‘/‘ . $do->saveto); $image->thumb($width, $height, $DT[‘thumb_album‘]); $image = new image(DT_ROOT . ‘/‘ . $middle); $image->thumb($DT[‘middle_w‘], $DT[‘middle_h‘], $DT[‘thumb_album‘]); if ($DT[‘water_middle‘] && $DT[‘water_type‘]) { if ($DT[‘water_type‘] == 2) { $image = new image(DT_ROOT . ‘/‘ . $middle); $image->waterimage(); } else if ($DT[‘water_type‘] == 1) { $image = new image(DT_ROOT . ‘/‘ . $middle); $image->watertext(); } } } else if ($from == ‘editor‘) { if ($_groupid == 1 && !isset($watermark)) $DT[‘water_type‘] = 0; if ($DT[‘water_type‘]) { $image = new image(DT_ROOT . ‘/‘ . $do->saveto); if ($DT[‘water_type‘] == 2) { $image->waterimage(); } else if ($DT[‘water_type‘] == 1) { $image->watertext(); } } } } $remoteUrl[$i] = linkurl($do->saveto); echo ‘图片处理成功!‘; } } } } } //print_r($remoteUrl); //die; /**图片处理结束*****/ /** * 发布供应信息处理 */ $do = new sell(5); $post[‘catid‘] = $pid; $post[‘typeid‘] = !empty($_POST[‘typeid‘]) ? $_POST[‘typeid‘] : 0; $post[‘level‘] = 1; $post[‘title‘] = !empty($_POST[‘title‘]) ? $_POST[‘title‘] : ‘供应测试标题‘; $post[‘brand‘] = !empty($_POST[‘brand‘]) ? $_POST[‘brand‘] : ‘‘; $post[‘content‘] = !empty($_POST[‘content‘]) ? $_POST[‘content‘] : ‘‘; $post[‘thumb‘] = isset($remoteUrl[0]) ? $remoteUrl[0] : ‘‘; $post[‘thumb1‘] = isset($remoteUrl[1]) ? $remoteUrl[1] : ‘‘; $post[‘thumb2‘] = isset($remoteUrl[2]) ? $remoteUrl[2] : ‘‘; $post[‘totime‘] = ‘‘;//过期时间 $post[‘n1‘] = !empty($_POST[‘n1‘]) ? $_POST[‘n1‘] : ‘‘; $post[‘v1‘] = !empty($_POST[‘n1‘]) && !empty($_POST[‘v1‘]) ? $_POST[‘v1‘] : ‘‘; $post[‘n2‘] = !empty($_POST[‘n2‘]) ? $_POST[‘n2‘] : ‘‘; $post[‘v2‘] = !empty($_POST[‘n2‘]) && !empty($_POST[‘v2‘]) ? $_POST[‘v2‘] : ‘‘; $post[‘n3‘] = !empty($_POST[‘n3‘]) ? $_POST[‘n3‘] : ‘‘; $post[‘v3‘] = !empty($_POST[‘n3‘]) && !empty($_POST[‘v3‘]) ? $_POST[‘v3‘] : ‘‘; $post[‘username‘] = $username; $post[‘elite‘] = !empty($_POST[‘elite‘]) ? $_POST[‘elite‘] : 1; $post[‘fee‘] = !empty($_POST[‘fee‘]) ? (is_numeric($_POST[‘fee‘])? $_POST[‘fee‘] :0) : 0; $post[‘unit‘] = !empty($_POST[‘unit‘]) ? $_POST[‘unit‘] : ‘‘; if(!empty($_POST[‘unit‘])){ $post[‘price‘] = !empty($_POST[‘price‘]) ? $_POST[‘price‘] : ‘‘; $post[‘minamount‘] = !empty($_POST[‘minamount‘]) ? $_POST[‘minamount‘] : ‘‘; $post[‘amount‘] = !empty($_POST[‘amount‘]) ? $_POST[‘amount‘] : ‘‘; $post[‘days‘] = !empty($_POST[‘days‘]) ? $_POST[‘days‘] : ‘‘; } $post[‘status‘] = 3; $post[‘addtime‘] = date(‘Y-m-d H:i:s‘,time()); if($do->pass($post)) { $do->table = $DT_PRE . ‘sell_5‘; $do->moduleid = 5; $do->table_search = $DT_PRE . ‘sell_search_5‘; $MOD[‘split‘] = 1; $do->add($post); $update = ‘‘; $update .= "hits=‘2‘"; $linkurl = ‘show.php?itemid=‘."$do->itemid"; $update .= ",linkurl=‘$linkurl‘"; $do->db->query("UPDATE {$do->table} SET ".$update." WHERE itemid=$do->itemid"); if($do->itemid){ exit(‘供应信息发布成功!‘); }else{ exit(‘供应信息发布失败1!‘); } } else { exit(‘供应信息发布失败!‘); } /** * Class category */ class category { var $moduleid; var $catid; var $category = array(); var $db; var $table; function category($moduleid = 1, $catid = 0) { global $db, $DT_PRE, $CATEGORY; $this->moduleid = $moduleid; $this->catid = $catid; if(!isset($CATEGORY)) $CATEGORY = cache_read(‘category-‘.$this->moduleid.‘.php‘); $this->category = $CATEGORY; $this->table = $DT_PRE.‘category‘; $this->db = &$db; } function add($category) { $category[‘moduleid‘] = 5; $category[‘letter‘] = preg_match("/^[a-z]{1}+$/i", $category[‘letter‘]) ? strtolower($category[‘letter‘]) : ‘‘; $category[‘group_list‘] = ‘3,5,6,7‘; $category[‘group_show‘] = ‘3,5,6,7‘; $category[‘group_add‘] = ‘3,5,6,7‘; $sqlk = $sqlv = ‘‘; foreach($category as $k=>$v) { $sqlk .= ‘,‘.$k; $sqlv .= ",‘$v‘"; } $sqlk = substr($sqlk, 1); $sqlv = substr($sqlv, 1); $this->db->query("INSERT INTO {$this->table} ($sqlk) VALUES ($sqlv)"); $this->catid = $this->db->insert_id(); if($category[‘parentid‘]) { $category[‘catid‘] = $this->catid; $this->category[$this->catid] = $category; $arrparentid = $this->get_arrparentid($this->catid, $this->category); } else { $arrparentid = 0; } $catdir = $category[‘catdir‘] ? $category[‘catdir‘] : $this->catid; $this->db->query("UPDATE {$this->table} SET listorder=$this->catid,catdir=‘$catdir‘,arrparentid=‘$arrparentid‘ WHERE catid=$this->catid"); return $this->catid; } function edit($category) { $category[‘letter‘] = preg_match("/^[a-z]{1}+$/i", $category[‘letter‘]) ? strtolower($category[‘letter‘]) : ‘‘; if($category[‘parentid‘]) { $category[‘catid‘] = $this->catid; $this->category[$this->catid] = $category; $category[‘arrparentid‘] = $this->get_arrparentid($this->catid, $this->category); } else { $category[‘arrparentid‘] = 0; } foreach(array(‘group_list‘, ‘group_show‘, ‘group_add‘) as $v) { $category[$v] = isset($category[$v]) ? implode(‘,‘, $category[$v]) : ‘‘; } $category[‘linkurl‘] = ‘‘; $sql = ‘‘; foreach($category as $k=>$v) { $sql .= ",$k=‘$v‘"; } $sql = substr($sql, 1); $this->db->query("UPDATE {$this->table} SET $sql WHERE catid=$this->catid"); return true; } function delete($catids) { if(is_array($catids)) { foreach($catids as $catid) { if(isset($this->category[$catid])) $this->delete($catid); } } else { $catid = $catids; if(isset($this->category[$catid])) { $this->db->query("DELETE FROM {$this->table} WHERE catid=$catid"); $arrchildid = $this->category[$catid][‘arrchildid‘] ? $this->category[$catid][‘arrchildid‘] : $catid; $this->db->query("DELETE FROM {$this->table} WHERE catid IN ($arrchildid)"); if($this->moduleid > 4) $this->db->query("UPDATE ".get_table($this->moduleid)." SET status=0 WHERE catid IN (".$arrchildid.")"); } } return true; } function update($category) { if(!is_array($category)) return false; foreach($category as $k=>$v) { if(!$v[‘catname‘]) continue; $v[‘parentid‘] = intval($v[‘parentid‘]); if($k == $v[‘parentid‘]) continue; if($v[‘parentid‘] > 0 && !isset($this->category[$v[‘parentid‘]])) continue; $v[‘listorder‘] = intval($v[‘listorder‘]); $v[‘level‘] = intval($v[‘level‘]); $v[‘letter‘] = preg_match("/^[a-z0-9]{1}+$/i", $v[‘letter‘]) ? strtolower($v[‘letter‘]) : ‘‘; $v[‘catdir‘] = $this->get_catdir($v[‘catdir‘], $k); if(!$v[‘catdir‘]) $v[‘catdir‘] = $k; $this->db->query("UPDATE {$this->table} SET catname=‘$v[catname]‘,parentid=‘$v[parentid]‘,listorder=‘$v[listorder]‘,style=‘$v[style]‘,level=‘$v[level]‘,letter=‘$v[letter]‘,catdir=‘$v[catdir]‘ WHERE catid=$k "); } return true; } function repair() { $query = $this->db->query("SELECT * FROM {$this->table} WHERE moduleid=‘$this->moduleid‘ ORDER BY listorder,catid"); $CATEGORY = array(); while($r = $this->db->fetch_array($query)) { $CATEGORY[$r[‘catid‘]] = $r; } $childs = array(); foreach($CATEGORY as $catid => $category) { $CATEGORY[$catid][‘arrparentid‘] = $arrparentid = $this->get_arrparentid($catid, $CATEGORY); $CATEGORY[$catid][‘catdir‘] = $catdir = preg_match("/^[0-9a-z_\-\/]+$/i", $category[‘catdir‘]) ? $category[‘catdir‘] : $catid; $sql = "catdir=‘$catdir‘,arrparentid=‘$arrparentid‘"; if(!$category[‘linkurl‘]) { $CATEGORY[$catid][‘linkurl‘] = listurl($category); $sql .= ",linkurl=‘$category[linkurl]‘"; } $this->db->query("UPDATE {$this->table} SET $sql WHERE catid=$catid"); if($arrparentid) { $arr = explode(‘,‘, $arrparentid); foreach($arr as $a) { if($a == 0) continue; isset($childs[$a]) or $childs[$a] = ‘‘; $childs[$a] .= ‘,‘.$catid; } } } foreach($CATEGORY as $catid => $category) { if(isset($childs[$catid])) { $CATEGORY[$catid][‘arrchildid‘] = $arrchildid = $catid.$childs[$catid]; $CATEGORY[$catid][‘child‘] = 1; $this->db->query("UPDATE {$this->table} SET arrchildid=‘$arrchildid‘,child=1 WHERE catid=‘$catid‘"); } else { $CATEGORY[$catid][‘arrchildid‘] = $catid; $CATEGORY[$catid][‘child‘] = 0; $this->db->query("UPDATE {$this->table} SET arrchildid=‘$catid‘,child=0 WHERE catid=‘$catid‘"); } } $this->cache($CATEGORY); return true; } function get_arrparentid($catid, $CATEGORY) { if($CATEGORY[$catid][‘parentid‘] && $CATEGORY[$catid][‘parentid‘] != $catid) { $parents = array(); $cid = $catid; while($catid) { if($CATEGORY[$cid][‘parentid‘]) { $parents[] = $cid = $CATEGORY[$cid][‘parentid‘]; } else { break; } } $parents[] = 0; return implode(‘,‘, array_reverse($parents)); } else { return ‘0‘; } } function get_arrchildid($catid, $CATEGORY) { $arrchildid = ‘‘; foreach($CATEGORY as $category) { if(strpos(‘,‘.$category[‘arrparentid‘].‘,‘, ‘,‘.$catid.‘,‘) !== false) $arrchildid .= ‘,‘.$category[‘catid‘]; } return $arrchildid ? $catid.$arrchildid : $catid; } function get_catdir($catdir, $catid = 0) { if(preg_match("/^[0-9a-z_\-\/]+$/i", $catdir)) { $condition = "catdir=‘$catdir‘ AND moduleid=‘$this->moduleid‘"; if($catid) $condition .= " AND catid!=$catid"; $r = $this->db->get_one("SELECT catid FROM {$this->table} WHERE $condition"); if($r) { return ‘‘; } else { return $catdir; } } else { return ‘‘; } } function get_letter($catname, $letter = true) { return $letter ? strtolower(substr(gb2py($catname), 0, 1)) : str_replace(‘ ‘, ‘‘, gb2py($catname)); } function cache($data = array()) { cache_category($this->moduleid, $data); } } function categoryAdd($category = array(),$table){ require ‘common.inc.php‘; global $db; $CATEGORY = cache_read(‘category-5.php‘); $do = new category(5,0); if(!$category[‘catname‘]) msg(‘分类名不能为空‘); $category[‘catname‘] = trim($category[‘catname‘]); $childs = ‘‘; $catids = array(); if(strpos($category[‘catname‘], "\n") === false) { $category[‘catdir‘] = $do->get_catdir($category[‘catdir‘]); $do->add($category); $childs .= ‘,‘.$do->catid; $catids[] = $do->catid; } else { $catnames = explode("\n", $category[‘catname‘]); foreach($catnames as $catname) { $catname = trim($catname); if(!$catname) continue; $category[‘catname‘] = $catname; $category[‘catdir‘] = ‘‘; $category[‘letter‘] = ‘‘; $category[‘seo_title‘] = ‘‘; $category[‘seo_keywords‘] = ‘‘; $category[‘seo_description‘] = ‘‘; $do->add($category); $childs .= ‘,‘.$do->catid; $catids[] = $do->catid; } } if($category[‘parentid‘]) { $parents = array(); $cid = $category[‘parentid‘]; $parents[] = $cid; while(1) { if($CATEGORY[$cid][‘parentid‘]) { $parents[] = $cid = $CATEGORY[$cid][‘parentid‘]; } else { break; } } foreach($parents as $catid) { $arrchildid = $CATEGORY[$catid][‘child‘] ? $CATEGORY[$catid][‘arrchildid‘].$childs : $catid.$childs; $db->query("UPDATE {$table} SET child=1,arrchildid=‘$arrchildid‘ WHERE catid=$catid"); } } foreach($catids as $catid) { $CATEGORY[$catid] = $db->get_one("SELECT * FROM {$table} WHERE catid=$catid"); update_category($CATEGORY[$catid]); } return $do->catid; } function catList(){ global $db; $condition ="moduleid=5"; $result = $db->query("SELECT catid,catname,parentid FROM {$db->pre}category WHERE $condition ORDER BY listorder,catid ASC"); $arr = array(); $i = 0; while($c = $db->fetch_array($result)) { $arr[$i++] = $c; } return $arr; }
标签:eid 技术 时间 size 系统 ann fine from 格式
原文地址:https://www.cnblogs.com/68xi/p/12233498.html