1
0

rockeditChajian.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * 连接官网在线编辑文档
  4. */
  5. class rockeditChajian extends Chajian{
  6. protected function initChajian()
  7. {
  8. $urs = $this->rock->jm->base64decode('aHR0cDovL29mZmljZS5yb2Nrb2EuY29tLw::');
  9. $url = getconfig('officebj_url', $urs);
  10. $this->agentkey = getconfig('officebj_key');
  11. if(substr($url,-1)!='/')$url.='/';
  12. $this->updatekel = $url;
  13. $this->updatekey = $url.'api.php';
  14. }
  15. public function geturlstr($mod, $act, $can=array())
  16. {
  17. $url = $this->updatekey;
  18. $url.= '?m='.$mod.'&a='.$act.'';
  19. $url.= '&host='.$this->rock->jm->base64encode(HOST).'&ip='.$this->rock->ip.'&xinhukey='.getconfig('xinhukey').'';
  20. $url.= '&adminid='.$this->adminid.'';
  21. $url.= '&agentkey='.$this->agentkey.'';
  22. foreach($can as $k=>$v)$url.='&'.$k.'='.$v.'';
  23. return $url;
  24. }
  25. /**
  26. * get获取数据
  27. */
  28. public function getdata($mod, $act, $can=array())
  29. {
  30. $url = $this->geturlstr($mod, $act, $can);
  31. $cont = c('curl')->getcurl($url);
  32. if(!isempt($cont) && contain($cont, 'success')){
  33. $data = json_decode($cont, true);
  34. }else{
  35. $data = returnerror('无法访问,'.$cont.'');
  36. }
  37. return $data;
  38. }
  39. /**
  40. * post发送数据
  41. */
  42. public function postdata($mod, $act, $can=array())
  43. {
  44. $url = $this->geturlstr($mod, $act);
  45. $cont = c('curl')->postcurl($url, $can);
  46. if(!isempt($cont) && contain($cont, 'success')){
  47. $data = json_decode($cont, true);
  48. }else{
  49. $data = returnerror('无法访问,'.$cont.'');
  50. }
  51. return $data;
  52. }
  53. public function sendedit($id, $admintoken='', $otype=0)
  54. {
  55. $frs = m('file')->getone($id);
  56. if(!$frs)return returnerror('文件不存在');
  57. $filepath = $frs['filepath'];
  58. $filepathout= arrvalue($frs, 'filepathout');
  59. $onlynum = $frs['onlynum'];
  60. $recedata = '';
  61. if(substr($filepath,0,4)!='http' && !file_exists($filepath)){
  62. if(isempt($filepathout))return returnerror('文件不存在2');
  63. $filepath = $filepathout;
  64. $recedata = $filepath;
  65. }
  66. if(isempt($onlynum)){
  67. $onlynum = md5(''.$this->rock->jm->getRandkey().date('YmdHis').'file'.$id.'');
  68. m('file')->update("`onlynum`='$onlynum'", $id);
  69. }
  70. $urs = m('admin')->getone($this->adminid);
  71. $barr = $this->getdata('file','change', array(
  72. 'filenum' => $onlynum,
  73. 'optid' => $this->adminid,
  74. 'optname' => $this->rock->jm->base64encode($this->adminname),
  75. 'face' => $this->rock->jm->base64encode(m('admin')->getface($urs['face'])),
  76. ));
  77. if(!$barr['success'])return $barr;
  78. $data = $barr['data'];
  79. $type = $data['type'];
  80. $gokey = $data['gokey'];
  81. $gourl = arrvalue($data,'gourl');
  82. if(isempt($gourl))$gourl = $this->updatekel;
  83. $bsar = $data;
  84. if($type=='0'){
  85. if($recedata=='')$recedata = $this->rock->jm->base64encode(file_get_contents($filepath));
  86. $barr = $this->postdata('file','recedata', array(
  87. 'data' => $recedata,
  88. 'fileid' => $id,
  89. 'filenum' => $onlynum,
  90. 'fileext' => $frs['fileext'],
  91. 'filename' => $frs['filename'],
  92. 'optid' => $frs['optid'],
  93. 'optname' => $frs['optname'],
  94. 'filesize' => $frs['filesize'],
  95. 'filesizecn'=> $frs['filesizecn'],
  96. ));
  97. if(!$barr['success'])return $barr;
  98. $bsar['type'] = '1';
  99. }
  100. if($bsar['type']=='1'){
  101. $url = $gourl.'api.php?m=file&a=goto&filenum='.$onlynum.'&sign='.md5($this->rock->HTTPweb).'';
  102. $url.= '&optid='.$this->adminid.'';
  103. $url.= '&gokey='.$gokey.'';
  104. $url.= '&otype='.$otype.'';
  105. if($otype==0){
  106. $callurl = $this->rock->getouturl().'api.php?m=upload&a=upfilevb&fileid='.$id.'&adminid='.$this->adminid.'&token='.$admintoken.'';
  107. $url.='&callurl='.$this->rock->jm->base64encode($callurl).'';
  108. }
  109. $bsar['url'] = $url;
  110. }
  111. return returnsuccess($bsar);
  112. }
  113. }
粤ICP备19079148号