/** * 更新游戏信息 */ public function gupdateAction() { $id = reqnum('id', 0); $ispost = reqnum('ispost', 0); $m = new Psys_ResModel(); if ($ispost == 1) { $appname = reqstr('appname'); $appcol = reqstr('appcol'); $appid = reqstr('appid', ''); $appid = $appid ? $appid : $this->getmaxappidAction($appcol); $price = reqstr('price', 0); $downcount = reqstr('downcount', 0); $logourl = reqstr('logourl'); $appurl = reqstr('appurl'); $ver = reqstr('ver', 0); $vernum = reqstr('vernum'); $filesize = reqstr('filesize'); $apppackage = reqstr('package'); $apptype = reqstr('apptype'); $lang = reqstr('lang'); $iftj = reqstr('iftj'); $flag = reqstr('flag'); $adesc = reqstr('adesc'); $adetail = reqstr('adetail'); $typeinfo = reqstr('typeinfo'); $develop = reqstr('develop'); $sig = reqstr('sig'); $pptfilenames = reqstr('pptfilenames'); $pptiosnames = reqstr('pptios'); $sortid = reqnum('sortid', 0); //return array('result'=>$pptfilenames); //转ppt文件名连接成的字符串为数组 if (!empty($pptfilenames)) { $ppt = explode(';', $pptfilenames); } else { $ppt = array(); } if (!empty($pptiosnames)) { $pptios = explode(';', $pptiosnames); } else { $pptios = array(); } //$ext = strrchr($logourl,'.'); $ext = '.png'; $data = array('appname' => $appname, 'appid' => $appid, 'price' => $price, 'downcount' => $downcount, 'sortid' => $sortid, 'imgurl' => 'logo' . $ext, 'appurl' => $appurl, 'ver' => $ver, 'vernum' => $vernum, 'filesize' => $filesize, 'package' => $apppackage, 'appcol' => $appcol, 'apptype' => $apptype, 'lang' => $lang, 'iftj' => $iftj, 'flag' => $flag, 'adesc' => $adesc, 'adetail' => $adetail, 'signature' => $sig, 'ctime' => time(), 'utime' => time(), 'typeinfo' => $typeinfo, 'develop' => $develop); $result = array('result' => 'ERROR'); if ($logourl == '') { MsgInfoConst::GetMsg(1041, $result); return $result; } /* * // 判断APP是否存在 $where = array ( 'appid' => $appid ); $isexit = $m->GetOneGame ( $where ); if ($isexit || count ( $isexit ) > 0) { MsgInfoConst::GetMsg ( 1043, $result ); return $result; } */ if ($id == 0) { $m->AddGame($data); if ($apptype == 2) { $ppt = $pptios; } if (!empty($ppt)) { for ($i = 0; $i < count($ppt); $i++) { // APP对应PPT //$ext = '.png'; //$ext = strrchr($ppt[$i],'.'); $appimg = array('appid' => $appid, 'imgurl' => $ppt[$i], 'ctime' => time()); if (empty($appimg['imgurl'])) { break; } $res = $m->AddGamePPT($appimg); $m->Record($appimg, $res, 'db-rht_sync', 'appimg', 'rhs_downsync'); } } // start 写操作日志 $log = array('logtype' => 71, '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") . "[添加]APP" . $appname; $m->admin_syslog($log); $result['result'] = 'SUCCESS'; } else { $w = array('id' => $id); $data['utime'] = time(); //------------------------物理文件更新开始 //获取更新前数据信息 $oldData = $m->GetOneGame($w, 'imgurl,appurl'); if ($data['appcol'] == 1) { $dir = GAME_PATH; } else { $dir = APP_PATH; } $imgurlPath = $dir . '/' . $data['appid'] . '/' . $oldData['imgurl']; $appurlPath = $dir . '/' . $data['appid'] . '/' . $oldData['appurl']; if (file_exists($imgurlPath) && $data['imgurl'] != $oldData['imgurl']) { unlink($imgurlPath); } if (file_exists($appurlPath) && $data['appurl'] != $oldData['appurl']) { unlink($appurlPath); } //------------------------物理文件更新结束 $m->UpdateGame($data, $w); // 先删除PPT表里等于APPID的PPT $w = array('appid' => $appid); $m->DelOneGamePPT($w); for ($i = 0; $i < count($ppt); $i++) { // APP对应PPT //$ext = strrchr($ppt[$i],'.'); //$ext = '.png'; $appimg = array('appid' => $appid, 'imgurl' => $ppt[$i], 'ctime' => time()); if (empty($appimg['imgurl'])) { break; } $res = $m->AddGamePPT($appimg); $m->Record($appimg, $res, 'db-rht_sync', 'appimg', 'rhs_downsync'); } // start 写操作日志 $log = array('logtype' => 71, '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") . "[编辑]APP信息" . $appname; $m->admin_syslog($log); // end 日志 $result['result'] = 'SUCCESS'; } return $result; } }
/** * * 数据同步表写入 * @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'); } } }