Example #1
0
 /**
  * 更新广告位信息
  */
 public function updateAction()
 {
     $id = reqnum('id', 0);
     $ispost = reqnum('ispost', 0);
     $model = new PSys_AdsModel();
     if ($ispost == 1) {
         //广告名
         $adname = reqstr('adname');
         //显示位置
         $colid = reqnum('colid');
         //显示系统
         $adstype = reqstr('adstype', '');
         //是否车站
         $isstation = reqnum('isstation', 0);
         //状态
         $flag = reqnum('flag', 0);
         //图片路径
         $imgurl = reqstr('imgurl', '');
         //访问路径
         $actionurl = reqstr('actionurl', '');
         //排序
         $orderby = reqnum('orderby', 0);
         //链接ID
         $tjappid = reqnum('tjappid', 0);
         //有效期
         $validity = strtotime(reqstr('validity', 0));
         //广告描述
         $addesc = reqstr('content', '');
         //根据ID获取app类型
         $appmodel = new PSys_ResModel();
         $where = array('id' => $tjappid);
         $app_data = $appmodel->GetOneGame($where);
         $tjapptype = $app_data ? $app_data['apptype'] : 0;
         //添加时间
         $data = array('adname' => $adname, 'colid' => $colid, 'adstype' => $adstype, 'station' => $isstation, 'flag' => $flag, 'imgurl' => $imgurl, 'actionurl' => $actionurl, 'orderby' => $orderby, 'tjappid' => $tjappid, 'validity' => $validity, 'addesc' => $addesc, 'colstr' => $colstr, 'ctime' => time(), 'tjapptype' => $tjapptype);
         $result = array('result' => 'ERROR');
         if ($imgurl == '') {
             MsgInfoConst::GetMsg(1041, $result);
             return $result;
         }
         if ($id == 0) {
             $returnid = $model->AddOne($data);
             //$m = new PSys_ResModel ();
             //$m->Record($data,$returnid,'db-rht_sync','ads','rhs_downsync');
             // start 写操作日志
             $log = array('logtype' => 72, 'guid' => $_SESSION['Cur_X_User']['id'], 'ctime' => time(), 'cip' => real_ip());
             $log['logdetail'] = $_SESSION['Cur_X_User']['username'] . "于" . date("Y-m-d H:i:s") . "[添加]广告位" . $adname;
             //$model->admin_syslog ( $log );
             // end 日志
             $result['result'] = 'SUCCESS';
         } else {
             $w = array('id' => $id);
             $returnid = $model->UpdateOne($data, $w);
             //$m = new PSys_ResModel ();
             //$m->Record($data,$returnid,'db-rht_sync','ads','rhs_downsync');
             // start 写操作日志
             $log = array('logtype' => 72, 'guid' => $_SESSION['Cur_X_User']['id'], 'ctime' => time(), 'cip' => real_ip());
             $log['logdetail'] = $_SESSION['Cur_X_User']['username'] . "于" . date("Y-m-d H:i:s") . "[编辑]广告位" . $adname;
             //$model->admin_syslog ( $log );
             // end 日志
             $result['result'] = 'SUCCESS';
         }
         if ($result['result'] == 'SUCCESS') {
             $file = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/temp.txt';
             $fp = fopen($file, 'w');
             fwrite($fp, '1');
             fclose($fp);
         }
         return $result;
     }
 }
Example #2
0
 public function importAction()
 {
     /*设置上传路径*/
     define('INSTALL', str_replace('\\', '/', dirname(dirname(dirname(dirname(dirname(__FILE__)))))));
     $savePath = INSTALL . '/www/traindata_appui/imgs/video/Excel/';
     $action = !empty($_GET['action']) ? trim($_GET['action']) : '';
     $file = !empty($_GET['file']) ? trim($_GET['file']) : '';
     if ($action == 'del') {
         $myfile = $savePath . $file;
         if (file_exists($myfile)) {
             if (unlink($myfile)) {
                 echo '<script type="text/javascript">alert("删除成功;返回列表");window.location.href="/res/import";</script>';
                 exit;
             }
             echo '<script type="text/javascript">alert("删除失败;返回列表");window.location.href="/res/import";</script>';
             exit;
         } else {
             echo '<script type="text/javascript">alert("文件不存在;返回列表");window.location.href="/res/import";</script>';
             exit;
         }
     } elseif (!empty($_FILES['file_stu']['name']) or $action == 'import') {
         if ($action == 'import' and !empty($file)) {
             $file_name = $file;
         } elseif (!empty($_FILES['file_stu']['name'])) {
             $tmp_file = $_FILES['file_stu']['tmp_name'];
             $file_types = explode(".", $_FILES['file_stu']['name']);
             $file_type = $file_types[count($file_types) - 1];
             /*判别是不是.xls文件,判别是不是excel文件*/
             if (strtolower($file_type) != "xls") {
                 echo '<script type="text/javascript">alert("不是Excel文件,重新上传");window.location.href="/res/import";</script>';
                 exit;
             }
             if (!is_dir($savePath)) {
                 mkdir($savePath, 0777, true);
             }
             /*以时间来命名上传的文件*/
             $str = date('Ymdhis');
             $file_name = $str . "." . $file_type;
             /*是否上传成功*/
             if (!move_uploaded_file($tmp_file, $savePath . $file_name)) {
                 echo '<script type="text/javascript">alert("上传失败,重新上传");window.location.href="/res/import";</script>';
                 exit;
             }
         }
         $res = $this->read($savePath . $file_name);
         /*对生成的数组进行数据库的写入*/
         $errmsg = '';
         $noimpor = '';
         $okmsg = '';
         $m = new PSys_ResModel();
         foreach ($res as $k => $v) {
             if ($k > 1) {
                 $data = array('vname' => $v['1'], 'cast' => $v['6'], 'cast' => $va['10'], 'direcotr' => $v['11'], 'vpath' => $v['2'], 'vimg' => $v['3'], 'sortid' => $v['14'], 'area' => $v['9'], 'colid' => $v['7'], 'vyear' => $v['8'], 'iftj' => $v['12'], 'flag' => $v['13'], 'vdesc' => $v['4'], 'vdetail' => $v['5'], 'ctime' => time(), 'vimg_2' => $v['19'], 'type' => $v['20']);
                 $svl = $m->GetOne(array('vname' => $v[1]), '*', 'rhi_videos');
                 if (empty($svl)) {
                     $m->AddVideo($data);
                     echo '<script>alert("导入成功,自动过滤从复数据!");window.location.href="/res/vlist"</script>';
                     exit;
                 } else {
                     echo '<script type="text/javascript">alert("' . $v['1'] . '在数据库已存在,请重新上传!");window.location.href="/res/import";</script>';
                     exit;
                 }
             }
         }
         if ($noimpor) {
             $logpas = ERRLOG_PATH . 'video' . DIRECTORY_SEPARATOR . date('Ymd') . DIRECTORY_SEPARATOR;
             if (!is_dir($logpas)) {
                 mkdir($logpas, 0777, true);
             }
             $log = $logpas . 'video_noimport.log';
             $str = $noimpor . "\r\n";
             error_log($str, 3, $log);
         }
         if ($errmsg) {
             $logpas = ERRLOG_PATH . 'video' . DIRECTORY_SEPARATOR . date('Ymd') . DIRECTORY_SEPARATOR;
             if (!is_dir($logpas)) {
                 mkdir($logpas, 0777, true);
             }
             $log = $logpas . 'video_error.log';
             $str = $errmsg . "\r\n";
             error_log($str, 3, $log);
         }
         echo '<script>alert("导入成功,自动过滤从复数据!");window.location.href="/res/vlist"</script>';
         exit;
     } else {
         //开始运行
         $files = $this->listDir($savePath);
         $this->smarty->assign('files', $files);
         $this->smarty->assign("active_menu", "res");
         $this->smarty->assign("active", "pageview/index");
         $this->forward = "import";
     }
 }
Example #3
0
 /**
  * 
  * 数据同步表写入
  * @param int $id	类型ID
  * @param bool $isdel	true 删除同步 false 更新同步
  */
 public function syncDb($id, $isdel)
 {
     //获取指定数据
     $data = $this->GetOne(array('id' => $id), '*', 'rhi_apps');
     if ($data['appcol'] == 1) {
         $type = 3;
     } else {
         $type = 4;
     }
     $typeid = $id;
     //选择数据库
     $this->SetDb('db-rht_sync');
     if ($isdel) {
         $method = 3;
         $data = array();
         $oldData = json_encode($data);
         $syncData = array('type' => $type, 'typeid' => $typeid, 'method' => $method, 'dataInfo' => $oldData, 'flag' => 0, 'ctime' => time());
         $num = $this->AddOne($syncData, 'rhs_sync');
         if ($num) {
             return array('result' => 'SUCCESS');
         } else {
             return array('result' => 'ERROR');
         }
     } else {
         //更新同步
         $oldData = json_encode($data);
         if ($data['utime']) {
             $method = 2;
         } else {
             $method = 1;
         }
         //数据写入
         $syncData = array('type' => $type, 'typeid' => $typeid, 'method' => $method, 'dataInfo' => $oldData, 'flag' => 0, 'ctime' => time());
         $num = $this->AddOne($syncData, 'rhs_sync');
         if ($num) {
             $this->SetDb("db-rht_idc");
             $model = new PSys_ResModel();
             $data = array('unconfirm' => 0);
             $model->UpdateGame($data, array('id' => $id));
             return array('result' => 'SUCCESS');
         } else {
             return array('result' => 'ERROR');
         }
     }
 }