file.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. <?php
  2. define('EmpireCMSAdmin','1');
  3. require("../../class/connect.php");
  4. require("../../class/db_sql.php");
  5. require("../../class/functions.php");
  6. require("../../data/dbcache/class.php");
  7. require "../".LoadLang("pub/fun.php");
  8. $link=db_connect();
  9. $empire=new mysqlquery();
  10. $editor=1;
  11. //验证
  12. $lur=is_login();
  13. $logininid=$lur['userid'];
  14. $loginin=$lur['username'];
  15. $loginrnd=$lur['rnd'];
  16. $loginlevel=$lur['groupid'];
  17. $loginadminstyleid=$lur['adminstyleid'];
  18. //ehash
  19. $ecms_hashur=hReturnEcmsHashStrAll();
  20. //返回按钮事件
  21. function ToReturnDoFileButton($doing,$tranfrom,$field,$file,$filename,$fileid,$filesize,$filetype,$no,$type){
  22. if($doing==1)//返回地址
  23. {
  24. $bturl="ChangeFile1(1,'".$file."');";
  25. $button="<input type=button name=button value='选择' onclick=\"javascript:".$bturl."\">";
  26. }
  27. elseif($doing==2)//返回地址
  28. {
  29. $bturl="ChangeFile1(2,'".$file."');";
  30. $button="<input type=button name=button value='选择' onclick=\"javascript:".$bturl."\">";
  31. }
  32. else
  33. {
  34. if($tranfrom==1)//编辑器选择
  35. {
  36. $bturl="EditorChangeFile('".$file."','".addslashes($filename)."','".$filetype."','".$filesize."','".addslashes($no)."');";
  37. $button="<input type=button name=button value='选择' onclick=\"javascript:".$bturl."\">";
  38. }
  39. elseif($tranfrom==2)//特殊字段选择
  40. {
  41. $bturl="SFormIdChangeFile('".addslashes($no)."','$file','$filesize','$filetype','$field');";
  42. $button="<input type=button name=button value='选择' onclick=\"javascript:".$bturl."\">";
  43. }
  44. else
  45. {
  46. $bturl="InsertFile('".$file."','".addslashes($filename)."','".$fileid."','".$filesize."','".$filetype."','','".$type."');";
  47. $button="<input type=button name=button value='插入' onclick=\"javascript:".$bturl."\">";
  48. }
  49. }
  50. $retr['button']=$button;
  51. $retr['bturl']=$bturl;
  52. return $retr;
  53. }
  54. $classid=(int)$_GET['classid'];
  55. $infoid=(int)$_GET['infoid'];
  56. $filepass=(int)$_GET['filepass'];
  57. $type=(int)$_GET['type'];
  58. $modtype=(int)$_GET['modtype'];
  59. $doing=(int)$_GET['doing'];
  60. $field=RepPostVar($_GET['field']);
  61. $tranfrom=RepPostStr($_GET['tranfrom'],1);
  62. $fileno=RepPostStr($_GET['fileno'],1);
  63. $doecmspage=RepPostStr($_GET['doecmspage'],1);
  64. if(empty($field))
  65. {
  66. $field="ecms";
  67. }
  68. include('eshoweditor.php');
  69. $add='';
  70. //附件类型
  71. $isinfofile=0;
  72. $fstb=0;
  73. if($modtype==1)//栏目
  74. {
  75. $query="select fileid,filename,filesize,path,filetime,no,fpath from {$dbtbpre}enewsfile_other where modtype=1 and type='$type'";
  76. $totalquery="select count(*) as total from {$dbtbpre}enewsfile_other where modtype=1 and type='$type'";
  77. $tranname='栏目';
  78. }
  79. elseif($modtype==2)//专题
  80. {
  81. $query="select fileid,filename,filesize,path,filetime,no,fpath from {$dbtbpre}enewsfile_other where modtype=2 and type='$type'";
  82. $totalquery="select count(*) as total from {$dbtbpre}enewsfile_other where modtype=2 and type='$type'";
  83. $tranname='专题';
  84. }
  85. elseif($modtype==3)//广告
  86. {
  87. $query="select fileid,filename,filesize,path,filetime,no,fpath from {$dbtbpre}enewsfile_other where modtype=3 and type='$type'";
  88. $totalquery="select count(*) as total from {$dbtbpre}enewsfile_other where modtype=3 and type='$type'";
  89. $tranname='广告';
  90. }
  91. elseif($modtype==4)//反馈
  92. {
  93. $query="select fileid,filename,filesize,path,filetime,no,fpath from {$dbtbpre}enewsfile_other where modtype=4 and type='$type'";
  94. $totalquery="select count(*) as total from {$dbtbpre}enewsfile_other where modtype=4 and type='$type'";
  95. $tranname='反馈';
  96. }
  97. elseif($modtype==5)//公共
  98. {
  99. $query="select fileid,filename,filesize,path,filetime,no,fpath from {$dbtbpre}enewsfile_public where type='$type'";
  100. $totalquery="select count(*) as total from {$dbtbpre}enewsfile_public where type='$type'";
  101. $tranname='公共';
  102. }
  103. elseif($modtype==7)//碎片
  104. {
  105. $query="select fileid,filename,filesize,path,filetime,no,fpath from {$dbtbpre}enewsfile_other where modtype=7 and type='$type'";
  106. $totalquery="select count(*) as total from {$dbtbpre}enewsfile_other where modtype=7 and type='$type'";
  107. $tranname='碎片';
  108. }
  109. else//信息
  110. {
  111. $isinfofile=1;
  112. if(!$classid||!$class_r[$classid]['tbname'])
  113. {
  114. printerror('ErrorUrl','history.go(-1)');
  115. }
  116. if($infoid)
  117. {
  118. $index_r=$empire->fetch1("select id,classid,checked from {$dbtbpre}ecms_".$class_r[$classid]['tbname']."_index where id='$infoid' limit 1");
  119. if(!$index_r['id'])
  120. {
  121. printerror('ErrorUrl','history.go(-1)');
  122. }
  123. //主表
  124. $infotb=ReturnInfoMainTbname($class_r[$classid]['tbname'],$index_r['checked']);//返回表
  125. $infor=$empire->fetch1("select fstb from ".$infotb." where id='$infoid' limit 1");
  126. $fstb=$infor['fstb'];
  127. }
  128. else
  129. {
  130. $fstb=$public_r['filedeftb'];
  131. }
  132. $fstb=(int)$fstb;
  133. $query="select fileid,filename,filesize,path,filetime,classid,no,fpath from {$dbtbpre}enewsfile_{$fstb} where type='$type'";
  134. $totalquery="select count(*) as total from {$dbtbpre}enewsfile_{$fstb} where type='$type'";
  135. $tranname='信息';
  136. }
  137. //栏目
  138. $searchclassid=0;
  139. $searchvarclassid='';
  140. if($isinfofile==1)
  141. {
  142. $searchclassid=RepPostStr($_GET['searchclassid'],1);
  143. if($searchclassid=='all')
  144. {
  145. $searchclassid=0;
  146. $searchvarclassid='all';
  147. }
  148. else
  149. {
  150. $searchclassid=$searchclassid?$searchclassid:$classid;
  151. $searchvarclassid=$searchclassid;
  152. }
  153. $searchclassid=(int)$searchclassid;
  154. if($searchclassid)
  155. {
  156. if($class_r[$searchclassid]['islast'])
  157. {
  158. $add.=" and classid='$searchclassid'";
  159. }
  160. else
  161. {
  162. $add.=" and ".ReturnClass($class_r[$searchclassid]['sonclass']);
  163. }
  164. }
  165. }
  166. //时间范围
  167. $filelday=(int)$_GET['filelday'];
  168. if(empty($filelday))
  169. {
  170. $filelday=$public_r['filelday'];
  171. }
  172. if($filelday&&$filelday!=1)
  173. {
  174. $ckfilelday=time()-$filelday;
  175. $add.=" and filetime>$ckfilelday";
  176. }
  177. //当前信息
  178. $sinfo=(int)$_GET['sinfo'];
  179. $select_sinfo='';
  180. if($isinfofile==1)
  181. {
  182. if($sinfo)
  183. {
  184. $add.=$infoid?" and id='$infoid'":" and id='$filepass'";
  185. }
  186. $select_sinfo='<input name="sinfo" type="checkbox" id="sinfo" value="1"'.($sinfo?' checked':'').'>当前信息';
  187. }
  188. elseif($modtype!=5)
  189. {
  190. if($sinfo)
  191. {
  192. $add.=" and id='$filepass'";
  193. }
  194. $select_sinfo='<input name="sinfo" type="checkbox" id="sinfo" value="1"'.($sinfo?' checked':'').'>当前'.$tranname;
  195. }
  196. //关键字
  197. $keyboard=RepPostVar2($_GET['keyboard']);
  198. if(!empty($keyboard))
  199. {
  200. $show=RepPostStr($_GET['show'],1);
  201. if($show==0)//搜索全部
  202. {
  203. $add.=" and (filename like '%$keyboard%' or no like '%$keyboard%' or adduser like '%$keyboard%')";
  204. }
  205. elseif($show==1)//搜索文件名
  206. {
  207. $add.=" and filename like '%$keyboard%'";
  208. }
  209. elseif($show==2)//搜索编号
  210. {
  211. $add.=" and no like '%$keyboard%'";
  212. }
  213. else//搜索上传者
  214. {
  215. $add.=" and adduser like '%$keyboard%'";
  216. }
  217. }
  218. $search="&classid=$classid&infoid=$infoid&filepass=$filepass&type=$type&modtype=$modtype&doing=$doing&tranfrom=$tranfrom&field=$field&show=$show&searchclassid=$searchvarclassid&keyboard=$keyboard&fileno=$fileno&filelday=$filelday&sinfo=$sinfo&doecmspage=$doecmspage".$ecms_hashur['ehref'];
  219. //分页
  220. $page=(int)$_GET['page'];
  221. $page=RepPIntvar($page);
  222. $start=0;
  223. $line=25;//每页显示条数
  224. if($type==1)//图片
  225. {
  226. $line=12;
  227. }
  228. $page_line=12;//每页显示链接数
  229. $offset=$page*$line;//总偏移量
  230. $query.=$add;
  231. $totalquery.=$add;
  232. $num=$empire->gettotal($totalquery);//取得总条数
  233. $query.=" order by fileid desc limit $offset,$line";
  234. $sql=$empire->query($query);
  235. $returnpage=page2($num,$line,$page_line,$start,$page,$search);
  236. ?>
  237. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  238. <html>
  239. <head>
  240. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  241. <title>选择文件</title>
  242. <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
  243. <script>
  244. function InsertFile(filename,fname,fileid,filesize,filetype,fileno,dotype){
  245. var vstr="";
  246. if(dotype!=undefined)
  247. {
  248. vstr=showModalDialog("infoeditor/epage/insertfile.php?<?=$ecms_hashur['ehref']?>&ecms="+dotype+"&fname="+fname+"&fileid="+fileid+"&filesize="+filesize+"&filetype="+filetype+"&filename="+filename, "", "dialogWidth:45.5em; dialogHeight:27.5em; status:0");
  249. if(vstr==undefined)
  250. {
  251. return false;
  252. }
  253. }
  254. parent.opener.DoFile(vstr);
  255. parent.window.close();
  256. }
  257. function TInsertFile(vstr){
  258. parent.opener.DoFile(vstr);
  259. parent.window.close();
  260. }
  261. //选择字段
  262. function ChangeFile1(obj,str){
  263. <?php
  264. if(strstr($field,'.'))
  265. {
  266. ?>
  267. parent.<?=$field?>.value=str;
  268. <?php
  269. }
  270. else
  271. {
  272. ?>
  273. if(obj==1)
  274. {
  275. parent.opener.document.add.<?=$field?>.value=str;
  276. }
  277. else
  278. {
  279. parent.opener.document.form1.<?=$field?>.value=str;
  280. }
  281. <?php
  282. }
  283. ?>
  284. parent.window.close();
  285. }
  286. //编辑器选择
  287. function EditorChangeFile(fileurl,filename,filetype,filesize,name){
  288. var returnstr;
  289. returnstr=fileurl;
  290. <?php
  291. $useeditor_r=ECMS_EditorReturnType('');
  292. if($useeditor_r['ftype']==0)
  293. {
  294. ?>
  295. returnstr=fileurl+'##'+name+'##'+filesize;
  296. <?php
  297. }
  298. ?>
  299. window.parent.opener.<?=$useeditor_r['jsfun']?>(returnstr);
  300. parent.window.close();
  301. }
  302. //变量层选择
  303. function SFormIdChangeFile(name,url,filesize,filetype,idvar){
  304. parent.opener.doSpChangeFile(name,url,filesize,filetype,idvar);
  305. parent.window.close();
  306. }
  307. //全选
  308. function CheckAll(form){
  309. for(var i=0;i<form.elements.length;i++)
  310. {
  311. var e = form.elements[i];
  312. if(e.name=='getmark'||e.name=='getsmall')
  313. {
  314. continue;
  315. }
  316. if (e.name != 'chkall')
  317. e.checked = form.chkall.checked;
  318. }
  319. }
  320. //返回编号
  321. function ExpStr(str,exp){
  322. var pos,len,ext;
  323. pos=str.lastIndexOf(exp)+1;
  324. len=str.length;
  325. ext=str.substring(pos,len);
  326. return ext;
  327. }
  328. function ReturnFileNo(obj){
  329. var filename,str,exp;
  330. if(obj.no.value!='')
  331. {
  332. return '';
  333. }
  334. if(obj.file.value!='')
  335. {
  336. str=obj.file.value;
  337. }
  338. else
  339. {
  340. str=obj.tranurl.value;
  341. }
  342. if(str.indexOf("\\")>=0)
  343. {
  344. exp="\\";
  345. }
  346. else
  347. {
  348. exp="/";
  349. }
  350. filename=ExpStr(str,exp);
  351. obj.no.value=filename;
  352. }
  353. //重新载入页面
  354. function ReloadChangeFilePage(){
  355. self.location.reload();
  356. }
  357. //上传附件时
  358. function eTranMoreForFileMain(htmlstr){
  359. self.location.reload();
  360. }
  361. </script>
  362. </head>
  363. <body>
  364. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  365. <tr valign="top">
  366. <td width="68%"> <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  367. <form action="ecmseditor.php" target="ECUploadWindow" method="post" enctype="multipart/form-data" name="etform" onsubmit="return ReturnFileNo(document.etform);">
  368. <?=$ecms_hashur['form']?>
  369. <input type=hidden name=classid value="<?=$classid?>">
  370. <input type=hidden name=infoid value="<?=$infoid?>">
  371. <input type=hidden name=filepass value="<?=$filepass?>">
  372. <input type=hidden name=enews value="TranFile">
  373. <input type=hidden name=type value="<?=$type?>">
  374. <input type=hidden name=modtype value="<?=$modtype?>">
  375. <input type=hidden name=doing value="<?=$doing?>">
  376. <input type=hidden name=fstb value="<?=$fstb?>">
  377. <input type=hidden name=sinfo value="<?=$sinfo?>">
  378. <input type=hidden name=doecmspage value="<?=$doecmspage?>">
  379. <tr class="header">
  380. <td colspan="2">上传<?=$tranname?>附件</td>
  381. </tr>
  382. <tr bgcolor="#FFFFFF">
  383. <td width="16%">远程保存</td>
  384. <td width="84%"><input name="tranurl" type="text" id="tranurl" value="http://" size="36"></td>
  385. </tr>
  386. <tr bgcolor="#FFFFFF">
  387. <td>本地上传</td>
  388. <td><input name="file" type="file" size="32"> </td>
  389. </tr>
  390. <tr bgcolor="#FFFFFF">
  391. <td>文件别名</td>
  392. <td><input name="no" type="text" id="no" value="<?=RepPostStr($_GET['fileno'],1)?>" size="36">
  393. </td>
  394. </tr>
  395. <tr bgcolor="#FFFFFF">
  396. <td>图片选项</td>
  397. <td> <input name="getmark" type="checkbox" id="getmark" value="1">
  398. <a href="../SetEnews.php<?=$ecms_hashur['whehref']?>" target="_blank">加水印</a> <input name="getsmall" type="checkbox" id="getsmall" value="1">
  399. 生成缩略图:宽度 <input name="width" type="text" id="width" value="<?=$public_r['spicwidth']?>" size="6">
  400. * 高度 <input name="height" type="text" id="height" value="<?=$public_r['spicheight']?>" size="6"></td>
  401. </tr>
  402. <tr bgcolor="#FFFFFF">
  403. <td>&nbsp;</td>
  404. <td><input type="submit" name="Submit3" value="上传">
  405. <?php
  406. if($type==1&&TranmoreIsOpen('filemain'))
  407. {
  408. ?>
  409. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" name="Submit" value="多选上传" onclick="window.open('tranmore/tranmore.php?type=<?=$type?>&classid=<?=$classid?>&filepass=<?=$filepass?>&infoid=<?=$infoid?>&modtype=<?=$modtype?>&sinfo=<?=$sinfo?>&doing=<?=$doing?>&fstb=<?=$fstb?>&ecmsdo=ecmstmfilemain&tranfrom=0<?=$ecms_hashur['ehref']?>','ecmstmpage','width=700,height=550,scrollbars=yes');">
  410. <?php
  411. }
  412. ?>
  413. </td>
  414. </tr>
  415. </form>
  416. </table>
  417. <script type="text/javascript">
  418. document.write( '<iframe name="ECUploadWindow" style="DISPLAY: none" src="images/blank.html"><\/iframe>' ) ;
  419. </script>
  420. </td>
  421. </tr>
  422. <tr>
  423. <td> <div align="center"> </div></td>
  424. </tr>
  425. </table>
  426. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="0">
  427. <form name="searchfile" method="get" action="file.php">
  428. <?=$ecms_hashur['eform']?>
  429. <input type=hidden name=type value="<?=$type?>">
  430. <input type=hidden name=classid value="<?=$classid?>">
  431. <input type=hidden name=infoid value="<?=$infoid?>">
  432. <input type=hidden name=filepass value="<?=$filepass?>">
  433. <input type=hidden name=modtype value="<?=$modtype?>">
  434. <input type=hidden name=doing value="<?=$doing?>">
  435. <input type=hidden name=tranfrom value="<?=$tranfrom?>">
  436. <input type=hidden name=field value="<?=$field?>">
  437. <input type=hidden name=fileno value="<?=$fileno?>">
  438. <input type=hidden name=doecmspage value="<?=$doecmspage?>">
  439. <tr>
  440. <td><div align="center">搜索<?=$tranname?>附件:
  441. <input name="keyboard" type="text" id="keyboard" value="<?=$keyboard?>">
  442. <select name="show" id="show">
  443. <option value="0">不限</option>
  444. <option value="1">文件名</option>
  445. <option value="2" selected>编号</option>
  446. <option value="3">上传者</option>
  447. </select>
  448. <span id="fileclassnav"></span>
  449. <select name="filelday" id="filelday">
  450. <option value="1"<?=$filelday==1?' selected':''?>>全部时间</option>
  451. <option value="86400"<?=$filelday==86400?' selected':''?>>1 天</option>
  452. <option value="172800"<?=$filelday==172800?' selected':''?>>2
  453. 天</option>
  454. <option value="604800"<?=$filelday==604800?' selected':''?>>一周</option>
  455. <option value="2592000"<?=$filelday==2592000?' selected':''?>>1
  456. 个月</option>
  457. <option value="7948800"<?=$filelday==7948800?' selected':''?>>3
  458. 个月</option>
  459. <option value="15897600"<?=$filelday==15897600?' selected':''?>>6
  460. 个月</option>
  461. <option value="31536000"<?=$filelday==31536000?' selected':''?>>1
  462. 年</option>
  463. </select>
  464. <?=$select_sinfo?>
  465. <input type="submit" name="Submit2" value="搜索">
  466. </div></td>
  467. </tr>
  468. </form>
  469. </table>
  470. <form name="dofile" method="post" action="../ecmsfile.php" onsubmit="return confirm('确认要操作?');">
  471. <?=$ecms_hashur['form']?>
  472. <input type=hidden name=enews value="DoMarkSmallPic">
  473. <input type=hidden name=type value="<?=$type?>">
  474. <input type=hidden name=classid value="<?=$classid?>">
  475. <input type=hidden name=searchclassid value="<?=$searchclassid?>">
  476. <input type=hidden name=infoid value="<?=$infoid?>">
  477. <input type=hidden name=filepass value="<?=$filepass?>">
  478. <input type=hidden name=modtype value="<?=$modtype?>">
  479. <input type=hidden name=doing value="<?=$doing?>">
  480. <input type=hidden name=field value="<?=$field?>">
  481. <input type=hidden name=fstb value="<?=$fstb?>">
  482. <input type=hidden name=sinfo value="<?=$sinfo?>">
  483. <input type=hidden name=doecmspage value="<?=$doecmspage?>">
  484. <?
  485. if($type==1)//图片
  486. {
  487. include('fileinc/editorpic.php');
  488. }
  489. elseif($type==2)//flash
  490. {
  491. include('fileinc/editorflash.php');
  492. }
  493. elseif($type==3)//多媒体文件
  494. {
  495. include('fileinc/editormedia.php');
  496. }
  497. else//附件
  498. {
  499. include('fileinc/editorfile.php');
  500. }
  501. ?>
  502. </form>
  503. <?php
  504. if($isinfofile==1)
  505. {
  506. ?>
  507. <IFRAME frameBorder="0" id="showclassnav" name="showclassnav" scrolling="no" src="../ShowClassNav.php?ecms=4&classid=<?=$searchclassid?><?=$ecms_hashur['ehref']?>" style="HEIGHT:0;VISIBILITY:inherit;WIDTH:0;Z-INDEX:1"></IFRAME>
  508. <?php
  509. }
  510. ?>
  511. </body>
  512. </html>
  513. <?
  514. db_close();
  515. $empire=null;
  516. ?>