function init() { if(!config::get('guestbook_enable')){ alerterror('留言本功能已关闭'); } $user=''; if(cookie::get('login_username') &&cookie::get('login_password')) { $user=new user(); $user=$user->getrow(array('username'=>cookie::get('login_username'))); } $this->view->user=$user; $this->_user=new user; $this->table='guestbook'; $this->_table=new $this->table; if(!$this->_table->getFields()) exit('PAGE NOT FOUND!'); $this->view->form=$this->_table->get_form(); $this->_pagesize=config::get('manage_pagesize'); $this->view->manage=$this->table; $this->view->primary_key=$this->_table->primary_key; $fieldlimit=$this->_table->getcols(front::$act=='list'?'user_list':'user_modify'); $field=$this->_table->getFields(); helper::filterField($field,$fieldlimit); $this->view->field=$field; if(!front::get('page')) front::$get['page']=1; }
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 import_action(){ $this->_view_table = ''; if(front::post('submit')){ if($_FILES['excelFile']['tmp_name']){ $upload=new upload(); $upload->dir='attachment'; if (!$_FILES['excelFile']['name'] ||!preg_match('/\.xls$/i',$_FILES['excelFile']['name'])){ alerterror('请选择Excel2003文件'); } $name = $upload->run($_FILES['excelFile']); $reader = PHPExcel_IOFactory::createReader('Excel5'); $PHPExcel = $reader->load($name); $sheet = $PHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); $highestColumm = $sheet->getHighestColumn(); $i = 0; for ($row = 2; $row <= $highestRow; $row++){ if($sheet->getCell('A'.$row)->getValue()){ $data['catid'] = $sheet->getCell('A'.$row)->getValue(); $data['typeid'] = intval($sheet->getCell('B'.$row)->getValue()); $data['spid'] = intval($sheet->getCell('C'.$row)->getValue()); $data['title'] = $sheet->getCell('D'.$row)->getValue(); $data['content'] = $sheet->getCell('E'.$row)->getValue(); $data['tag'] = $sheet->getCell('F'.$row)->getValue(); $data['adddate'] = $sheet->getCell('G'.$row)->getValue(); if($data['adddate'] == ''){ $data['adddate'] = date('Y-m-d H:i:s'); } $data['author'] = $sheet->getCell('H'.$row)->getValue(); $data['attr3'] = $sheet->getCell('I'.$row)->getValue(); $data['checked'] = intval($sheet->getCell('J'.$row)->getValue()); $data['attr2'] = $sheet->getCell('K'.$row)->getValue(); $data['thumb'] = $sheet->getCell('L'.$row)->getValue(); $data['pics'] = serialize(explode('|',$sheet->getCell('M'.$row)->getValue())); $data['userid'] = $this->view->user['userid']; $this->_table->rec_insert($data); $i++; } } front::flash("{$this->tname}导入{$i}条数据成功!"); }else{ alerterror('请选择要导入的Excel2003文件'); } } }
function add_action() { if(front::$post['submit']) { if(config::get('verifycode')) { if(!session::get('verify') ||front::post('verify')<>session::get('verify')) { alerterror(lang('验证码错误!')); $this->render(@setting::$var[$this->table]['myform']['template']); $this->end=false; return; } } front::$post['checked']=0; front::$post['userid']=$this->view->user['userid']; front::$post['username']=$this->view->user['username']; front::$post['author']=$this->view->user['username']; front::$post['adddate']=date('Y-m-d H:i:s'); front::$post['ip']=front::ip(); foreach(front::$post as $k=>$p) { if( is_array($p)) front::$post[$k]=implode(',',$p); } $data=front::$post; $insert=$this->_table->rec_insert($data); if($insert<1) { front::flash(lang('表单提交失败!')); } else { if(is_array(front::$post) &&!empty(front::$post)) { foreach(front::$post as $k =>$v) { if(preg_match('/^my_.*?mail$/i',$k) &&strstr($v,'@')) { $email = front::$post[$k]; break; } } foreach(front::$post as $k =>$v) { if(preg_match('/^my_.*?tel$/i',$k) &&strstr($v,'@')) { $tel = front::$post[$k]; break; } } } $code = ''; foreach ($this->view->field as $k =>$v) { $cname = setting::$var[$this->table][$k]['cname']; $val = front::$post[$k]; $code .= $cname.": ".$val."<br>"; } $smtpemailto = config::get('email'); $title = setting::$var[$this->table]['myform']['cname'].lang('的结果'); if(config::get('email_form_on') && $email) { $this->sendmail($email,$title,$code); } if(config::get('email_form_on') && $smtpemailto) { $this->sendmail($smtpemailto,$title,$code); } if($tel) { if(config::get('sms_on') && config::get('sms_form_on')){ sendMsg($tel,config::get('sms_form')); } if(config::get('sms_on') && config::get('sms_form_admin_on') && $mobile = config::get('site_mobile')){ sendMsg($mobile,front::$post['username'].'在'.date('Y-m-d H:i:s').'提交了表单'); } } if(front::$post['aid']){ echo "<script>alert('表单提交成功!');window.location.href='".url::create('/archive/show/aid/'.front::$post['aid'])."'</script>"; //front::redirect(); }else{ front::redirect(url::create('/form/message')); } } } $this->render(@setting::$var[$this->table]['myform']['template']); $this->end=false; }
<?php if (!defined('ROOT')) exit('Can\'t Access !'); class config_admin extends admin { function init() {