function save_after($typeid) { if(front::$post['_ranks']) { $_ranks=serialize(front::post('_ranks')); $rank=new rank(); if(is_array($rank->getrow(array('typeid'=>front::get('id'))))) $rank->rec_update(array('ranks'=>$_ranks),'typeid='.$typeid); else $rank->rec_insert(array('typeid'=>front::get('id'),'ranks'=>$_ranks)); } else { $rank=new rank(); $rank->rec_delete('typeid='.$typeid); } }
function save_after($aid) { //$tag=preg_replace('/\s+/',' ',trim(front::$post['tag'])); $tags=explode(',',trim(front::$post['tag'])); //var_dump($tags); $tag_table=new tag(); $arctag_table=new arctag(); foreach($tags as $tag) { if($tag) if(!$tag_table->getrow('tagname="'.$tag.'"')) $tag_table->rec_insert(array('tagname'=>$tag)); $tag=$tag_table->getrow('tagname="'.$tag.'"'); $arctag_table->rec_replace(array('aid'=>$aid,'tagid'=>$tag['tagid'])); } //exit; $doit = false; if(session::get('attachment_id') ||front::post('attachment_id')) { $attachment_id=session::get('attachment_id')?session::get('attachment_id'):front::post('attachment_id'); $attachment=new attachment(); $attachment->rec_update(array('aid'=>$aid,'intro'=>front::post('attachment_intro')),$attachment_id); $doit = true; if(session::get('attachment_id')) session::del('attachment_id'); } if(front::post('attachment_path') != '' && $doit == false) { $attachment=new attachment(); $attachment->rec_insert(array('aid'=>$aid,'path'=>front::post('attachment_path'),'intro'=>front::post('attachment_intro'),'adddate'=>date('Y-m-d H:i:s'))); $doit = false; } if(front::post('_ranks')) { $_ranks=serialize(front::post('_ranks')); $rank=new rank(); if(is_array($rank->getrow(array('aid'=>$aid)))) $rank->rec_update(array('ranks'=>$_ranks),'aid='.$aid); else $rank->rec_insert(array('aid'=>$aid,'ranks'=>$_ranks)); } else { $rank=new rank(); $rank->rec_delete('aid='.$aid); } if(front::post('vote')) { $votes=front::$post['vote']; $images=front::$post['vote_image']; $vote=new vote(); $_vote=$vote->getrow('aid='.$aid); if(!$_vote) $_vote=array('aid'=>$aid); $_vote['titles']=serialize($votes); $_vote['images']=serialize($images); $vote->rec_replace($_vote,$aid); } }
public static function getInstance() { if (self::$instance === null) { self::$instance=new rank(); } return self::$instance; }
function orders_action() { $this->view->aid = trim(front::get('aid')); if (front::post('submit')) { $this->orders = new orders(); $row = $this->orders->getrow("","adddate DESC"); //var_dump(time()); if($row['adddate'] && time() - $row['adddate'] <= intval(config::get('order_time'))){ alerterror('操作频繁,请稍后再试'); return; } if (front::$post['telphone'] == '') { alerterror('联系电话为必填!'); return; } front::$post['mid'] = $this->view->user['userid'] ? $this->view->user['userid'] : 0; front::$post['adddate'] = time(); front::$post['ip'] = front::ip(); if (isset(front::$post['aid'])) { $aidarr = front::$post['aid']; unset(front::$post['aid']); foreach ($aidarr as $val) { front::$post['aid'].=$val . ','; front::$post['pnums'].=front::$post['thisnum'][$val] . ','; } } else { front::$post['aid'] = $this->view->aid; } if (!isset(front::$post['logisticsid'])) front::$post['logisticsid'] = 0; front::$post['oid'] = date('YmdHis') . '-' . front::$post['logisticsid'] . '-' . front::$post['mid'] . '-' . front::$post['payname']; $insert = $this->orders->rec_insert(front::$post); if ($insert < 1) { front::flash($this->tname . lang('添加失败!')); } else { if (config::get('sms_on') && config::get('sms_order_on')) { sendMsg(front::$post['telphone'], config::get('sms_order')); } if (config::get('sms_on') && config::get('sms_order_admin_on') && $mobile = config::get('site_mobile')) { sendMsg($mobile, '网站在' . date('Y-m-d H:i:s') . '有新订单了'); //echo 11; } $user = $this->view->user; if(config::get('email_order_send_cust') && $user['e_mail']){ $title = "您在".config::get('sitename')."的订单".front::get('oid')."已提交"; $this->sendmail($user['e_mail'], $title, $title); } if(config::get('email_order_send_admin') && config::get('email')){ $title = '网站在' . date('Y-m-d H:i:s') . '有新订单了'; $this->sendmail(config::get('email'), $title, $title); } if (front::$post['payname'] && front::$post['payname'] != 'nopay') { echo '<script type="text/javascript">alert("' . lang('orderssuccess') . ' ' . lang('现在转入支付页面') . '");window.location.href="' . url('archive/payorders/oid/' . front::$post['oid'], true) . '";</script>'; } echo '<script type="text/javascript">alert("' . lang('orderssuccess') . '");window.location.href="' . url('archive/orders/oid/' . front::$post['oid'], true) . '";</script>'; } } elseif (front::get('oid')) { preg_match_all("/-(.*)-(.*)-(.*)/isu", front::get('oid'), $oidout); $this->view->paytype = $oidout[3][0]; if($oidout[2][0] != $this->view->user['userid']){ alertinfo('查看订单失败', url::create('index/index')); } $where = array(); $where['oid'] = front::get('oid'); $this->view->orders = orders::getInstance()->getrow($where); $this->view->statusnum = $data['status'] = $this->view->orders['status']; switch ($data['status']) { case 1: $data['status'] = lang('完成'); break; case 2: $data['status'] = lang('处理中'); break; case 3: $data['status'] = lang('已发货'); break; case 4: $data['status'] = lang('客户已付款,待审核'); break; case 5: $data['status'] = lang('已核实客户支付'); break; default: $data['status'] = lang('新订单'); break; } $this->view->orders['status'] = $data['status']; if ($this->view->paytype) { $this->view->gotopaygateway = '<a href="' . url('archive/payorders/oid/' . front::get('oid'), true) . '">进入支付页面</a>'; } //var_dump($this->view->user);var_dump($_SESSION);exit(); $this->out('message/orderssuccess.html'); } elseif (front::get('aid')) { $this->view->archive = archive::getInstance()->getrow(front::get('aid')); $this->view->categorys = category::getpositionlink2($this->view->archive['catid']); $this->view->paylist = pay::getInstance()->getrows('', 50); $this->view->logisticslist = logistics::getInstance()->getrows('', 50); $prices = getPrices($this->view->archive['attr2']); $this->view->archive['attr2'] = $prices['price']; if (!is_array($this->view->archive)) $this->out('message/error.html'); if ($this->view->archive['checked'] < 1) exit(lang('未审核!')); if (!rank::arcget(front::get('aid'), $this->view->usergroupid)) { $this->out('message/error.html'); } } else { $oreders_c = cookie::get('ce_orders_cookie'); if(preg_match('/union/i', $oreders_c)){ alerterror("非法字符"); } $oreders_c = stripslashes(htmlspecialchars_decode($oreders_c)); $aid = !empty($oreders_c) ? unserialize($oreders_c) : 0; if ($aid) { foreach ($aid as $key => $val) { $archive = archive::getInstance()->getrow(intval($val['aid'])); $val['title'] = $archive['title']; $prices = getPrices($archive['attr2']); $val['attr2'] = $prices['price']; $aid[$key] = $val; } $this->view->orderaidlist = $aid; $this->view->paylist = pay::getInstance()->getrows('', 50); $this->view->logisticslist = logistics::getInstance()->getrows('', 50); } else { if (isset(front::$get['oid'])) { //echo '<script type="text/javascript">alert("' . lang('请输入订单编号!') . '");'; if ($_SERVER['HTTP_REFERER']) { front::refresh($_SERVER['HTTP_REFERER']); //echo 'window.location.href="' . $_SERVER['HTTP_REFERER'] . '";'; } else { front::refresh(url('index')); //echo 'window.location.href="' . url('index') . '";'; } //echo '</script>'; exit; } echo '<script type="text/javascript">alert("' . lang('购物车暂无商品!') . '");'; if ($_SERVER['HTTP_REFERER']) { //front::refresh($_SERVER['HTTP_REFERER']); echo 'window.location.href="' . $_SERVER['HTTP_REFERER'] . '";'; } else { //front::refresh(url('index')); echo 'window.location.href="' . url('index') . '";'; } echo '</script>'; } } }
function index_archive($catid) { $index_archive = new archive(); $index_category = category::getInstance(); $index_view_category = $index_category->category; if (front::get('page')) $page = front::get('page'); else $page = 1; $index_view_page = $page; front::check_type($page); $_catpage = category::categorypages($catid); if ($_catpage) { $index_pagesize = $_catpage; } else { $index_pagesize = config::get('list_pagesize'); } front::check_type($index_pagesize); $index_view_categorys = category::getpositionlink2($catid); $topid = category::gettopparent($catid); if (!isset($index_category->category[$catid]) || !isset($index_category->category[$topid])) { $this->out('message/error.html'); } $limit = (($index_view_page - 1) * $index_pagesize) . ',' . $index_pagesize; $categories = array(); if (@$index_category->category[$catid]['ispages']) $categories = $index_category->sons($catid); $categories[] = $catid; $index_view_pages = @$index_category->category[$catid]['ispages']; if (!rank::catget($catid, $index_view_usergroupid)) $this->out('message/error.html'); $order = "`listorder` asc,`adddate` DESC"; if (@$index_category->category[$catid]['includecatarchives']) $articles = $index_archive->getrows('catid in (' . implode(',', $categories) . ') and checked=1', $limit, $order); else $articles = $index_archive->getrows('catid=' . $catid . ' and checked=1', $limit, $order); if (!is_array($articles)) { $this->out('message/error.html'); } foreach ($articles as $order => $arc) { $articles[$order]['url'] = archive::url($arc); $articles[$order]['catname'] = category::name($arc['catid']); $articles[$order]['caturl'] = category::url($arc['catid']); $articles[$order]['adddate'] = sdate($arc['adddate']); $articles[$order]['stitle'] = strip_tags($arc['title']); $articles[$order]['strgrade'] = archive::getgrade($arc['grade']); } $index_view_archives = $articles; if (@$index_category->category[$catid]['includecatarchives']) $index_view_record_count = $index_archive->rec_count('catid in(' . implode(',', $categories) . ')'); else $index_view_record_count = $index_archive->rec_count('catid=' . $catid); front::$record_count = $index_view_record_count; return $index_view_archives; }
function down_action() { if(config::get('verifycode')) { if(cookie::get('allowdown')!=md5(url::create('attachment/downfile/aid/'.front::get('aid').'/v/ce'))) { header("Location: index.php?case=attachment&act=downfile&aid=".front::get('aid')."&v=ce"); } } front::check_type(front::get('aid')); if(!rank::arcget(front::get('aid'),$this->view->usergroupid,'down')) { $link="<script>alert(\"未取得授权,无法下载!\");</script>"; exit($link); } if(strtolower(substr(archive_attachment(front::get('aid'),'path'),0,4)) == 'http'){ echo "<script>window.location.href='".archive_attachment(front::get('aid'),'path')."';</script>"; exit; } $path=ROOT.'/'.archive_attachment(front::get('aid'),'path'); $path=iconv('utf-8','gbk//ignore',$path); if (!is_readable($path)) { header("HTTP/1.1 404 Not Found"); exit; } $size=filesize($path); $content=file_get_contents($path); $size=strlen($content); $name=preg_replace('%(.*)[\\\\\/](.*)_\d+(\.[a-z]+)$%i','$2$3',$path); $name=substr($name,-7,7); $name='CmsEasy_file_'.$name; header('Content-Type: application/octet-stream'); header("Content-Length: $size"); header("Content-Disposition: attachment; filename=\"$name\""); header("Content-Transfer-Encoding: binary"); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); echo $content; exit; }