PageRenderTime 27ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/php/xuzhou58/xuzhou58.com/dede/inc/inc_archives_functions.php

http://jqbird.googlecode.com/
PHP | 760 lines | 721 code | 17 blank | 22 comment | 41 complexity | b30c6bc744fecbb9f9c0d4a6e4518663 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-3.0, LGPL-2.1, GPL-2.0
  1. <?php
  2. require_once(DEDEINC.'/dedehttpdown.class.php');
  3. require_once(DEDEINC.'/image.func.php');
  4. require_once(DEDEINC.'/archives.func.php');
  5. require_once(DEDEINC.'/arc.partview.class.php');
  6. $backurl = !empty($_COOKIE['ENV_GOBACK_URL']) ? $_COOKIE['ENV_GOBACK_URL'] : '';
  7. $backurl = ereg('content_', $backurl) ? "<a href='$backurl'>[<u>??????</u>]</a> &nbsp;" : '';
  8. if(!isset($_NOT_ARCHIVES))
  9. {
  10. require_once(DEDEINC.'/customfields.func.php');
  11. }
  12. //??HTML???????????
  13. function GetCurContentAlbum($body, $rfurl, &$firstdd)
  14. {
  15. global $dsql,$cfg_multi_site,$cfg_basehost,$cfg_ddimg_width;
  16. global $cfg_basedir,$pagestyle,$cuserLogin,$cfg_addon_savetype;
  17. require_once(DEDEINC.'/dedecollection.func.php');
  18. if(empty($cfg_ddimg_width)) $cfg_ddimg_width = 320;
  19. $rsimg = '';
  20. $cfg_uploaddir = $GLOBALS['cfg_image_dir'];
  21. $cfg_basedir = $GLOBALS['cfg_basedir'];
  22. $basehost = 'http://'.$_SERVER['HTTP_HOST'];
  23. $img_array = array();
  24. preg_match_all("/(src)=[\"|'| ]{0,}(http:\/\/([^>]*)\.(gif|jpg|png))/isU",$body,$img_array);
  25. $img_array = array_unique($img_array[2]);
  26. $imgUrl = $cfg_uploaddir.'/'.MyDate($cfg_addon_savetype, time());
  27. $imgPath = $cfg_basedir.$imgUrl;
  28. if(!is_dir($imgPath.'/'))
  29. {
  30. MkdirAll($imgPath,$GLOBALS['cfg_dir_purview']);
  31. CloseFtp();
  32. }
  33. $milliSecond = 'co'.dd2char( MyDate('ymdHis',time())) ;
  34. foreach($img_array as $key=>$value)
  35. {
  36. $value = trim($value);
  37. if(eregi($basehost,$value) || !eregi("^http://", $value)
  38. || ($cfg_basehost != $basehost && eregi($cfg_basehost,$value)))
  39. {
  40. continue;
  41. }
  42. $itype = substr($value, -4, 4);
  43. if( !eregi("\.(gif|jpg|png)",$itype) )
  44. {
  45. $itype = ".jpg";
  46. }
  47. $rndFileName = $imgPath.'/'.$milliSecond.'-'.$key.$itype;
  48. $iurl = $imgUrl.'/'.$milliSecond.'-'.$key.$itype;
  49. //???????
  50. $rs = DownImageKeep($value, $rfurl, $rndFileName, '', 0, 30);
  51. if($rs)
  52. {
  53. $info = '';
  54. $imginfos = GetImageSize($rndFileName, $info);
  55. $fsize = filesize($rndFileName);
  56. $filename = $milliSecond.'-'.$key.$itype;
  57. //????????
  58. $inquery = "INSERT INTO `#@__uploads`(arcid,title,url,mediatype,width,height,playtime,filesize,uptime,mid)
  59. VALUES ('0','$filename','$iurl','1','{$imginfos[0]}','$imginfos[1]','0','$fsize','".time()."','".$cuserLogin->getUserID()."'); ";
  60. $dsql->ExecuteNoneQuery($inquery);
  61. $fid = $dsql->GetLastID();
  62. AddMyAddon($fid, $iurl);
  63. if($pagestyle > 2)
  64. {
  65. $litpicname = GetImageMapDD($iurl, $cfg_ddimg_width);
  66. }
  67. else
  68. {
  69. $litpicname = $iurl;
  70. }
  71. if(empty($firstdd) && !empty($litpicname))
  72. {
  73. $firstdd = $litpicname;
  74. if(!file_exists($cfg_basedir.$firstdd))
  75. {
  76. $firstdd = $iurl;
  77. }
  78. }
  79. @WaterImg($rndFileName, 'down');
  80. $rsimg .= "{dede:img ddimg='$litpicname' text='' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}\r\n";
  81. }
  82. }
  83. return $rsimg;
  84. }
  85. //????body??????
  86. function GetCurContent($body)
  87. {
  88. global $cfg_multi_site,$cfg_basehost,$cfg_basedir,$cfg_image_dir;
  89. $cfg_uploaddir = $cfg_image_dir;
  90. $htd = new DedeHttpDown();
  91. $basehost = "http://".$_SERVER["HTTP_HOST"];
  92. $img_array = array();
  93. preg_match_all("/src=[\"|'|\s]{0,}(http:\/\/([^>]*)\.(gif|jpg|png))/isU",$body,$img_array);
  94. $img_array = array_unique($img_array[1]);
  95. $imgUrl = $cfg_uploaddir.'/'.MyDate("ymd",time());
  96. $imgPath = $cfg_basedir.$imgUrl;
  97. if(!is_dir($imgPath.'/'))
  98. {
  99. MkdirAll($imgPath,$GLOBALS['cfg_dir_purview']);
  100. CloseFtp();
  101. }
  102. $milliSecond = MyDate('His',time());
  103. foreach($img_array as $key=>$value)
  104. {
  105. if(eregi($basehost,$value))
  106. {
  107. continue;
  108. }
  109. if($cfg_basehost!=$basehost && eregi($cfg_basehost,$value))
  110. {
  111. continue;
  112. }
  113. if(!eregi("^http://",$value))
  114. {
  115. continue;
  116. }
  117. $htd->OpenUrl($value);
  118. $itype = $htd->GetHead("content-type");
  119. $itype = substr($value,-4,4);
  120. if(!eregi("\.(jpg|gif|png)",$itype))
  121. {
  122. if($itype=='image/gif')
  123. {
  124. $itype = ".gif";
  125. }
  126. else if($itype=='image/png')
  127. {
  128. $itype = ".png";
  129. }
  130. else
  131. {
  132. $itype = '.jpg';
  133. }
  134. }
  135. $milliSecondN = dd2char($milliSecond.mt_rand(1000,8000));
  136. $value = trim($value);
  137. $rndFileName = $imgPath.'/'.$milliSecondN.'-'.$key.$itype;
  138. $fileurl = $imgUrl.'/'.$milliSecondN.'-'.$key.$itype;
  139. $rs = $htd->SaveToBin($rndFileName);
  140. if($rs)
  141. {
  142. if($cfg_multi_site == 'Y')
  143. {
  144. $fileurl = $cfg_basehost.$fileurl;
  145. }
  146. $body = str_replace($value,$fileurl,$body);
  147. @WaterImg($rndFileName, 'down');
  148. }
  149. }
  150. $htd->Close();
  151. return $body;
  152. }
  153. //????????
  154. function GetRemoteImage($url,$uid=0)
  155. {
  156. global $cfg_basedir, $cfg_image_dir, $cfg_addon_savetype;
  157. $cfg_uploaddir = $cfg_image_dir;
  158. $revalues = Array();
  159. $ok = false;
  160. $htd = new DedeHttpDown();
  161. $htd->OpenUrl($url);
  162. $sparr = Array("image/pjpeg", "image/jpeg", "image/gif", "image/png", "image/xpng", "image/wbmp");
  163. if(!in_array($htd->GetHead("content-type"),$sparr))
  164. {
  165. return '';
  166. }
  167. else
  168. {
  169. $imgUrl = $cfg_uploaddir.'/'.MyDate($cfg_addon_savetype, time());
  170. $imgPath = $cfg_basedir.$imgUrl;
  171. CreateDir($imgUrl);
  172. $itype = $htd->GetHead("content-type");
  173. if($itype=="image/gif")
  174. {
  175. $itype = '.gif';
  176. }
  177. else if($itype=="image/png")
  178. {
  179. $itype = '.png';
  180. }
  181. else if($itype=="image/wbmp")
  182. {
  183. $itype = '.bmp';
  184. }
  185. else
  186. {
  187. $itype = '.jpg';
  188. }
  189. $rndname = dd2char($uid.'_'.MyDate('mdHis',time()).mt_rand(1000,9999));
  190. $rndtrueName = $imgPath.'/'.$rndname.$itype;
  191. $fileurl = $imgUrl.'/'.$rndname.$itype;
  192. $ok = $htd->SaveToBin($rndtrueName);
  193. @WaterImg($rndtrueName, 'down');
  194. if($ok)
  195. {
  196. $data = GetImageSize($rndtrueName);
  197. $revalues[0] = $fileurl;
  198. $revalues[1] = $data[0];
  199. $revalues[2] = $data[1];
  200. }
  201. }
  202. $htd->Close();
  203. return ($ok ? $revalues : '');
  204. }
  205. //??????Flash??
  206. function GetRemoteFlash($url,$uid=0)
  207. {
  208. global $cfg_addon_savetype, $cfg_media_dir, $cfg_basedir;
  209. $cfg_uploaddir = $cfg_media_dir;
  210. $revalues = '';
  211. $sparr = 'application/x-shockwave-flash';
  212. $htd = new DedeHttpDown();
  213. $htd->OpenUrl($url);
  214. if($htd->GetHead("content-type")!=$sparr)
  215. {
  216. return '';
  217. }
  218. else
  219. {
  220. $imgUrl = $cfg_uploaddir.'/'.MyDate($cfg_addon_savetype, time());
  221. $imgPath = $cfg_basedir.$imgUrl;
  222. CreateDir($imgUrl);
  223. $itype = '.swf';
  224. $milliSecond = $uid.'_'.MyDate('mdHis',time());
  225. $rndFileName = $imgPath.'/'.$milliSecond.$itype;
  226. $fileurl = $imgUrl.'/'.$milliSecond.$itype;
  227. $ok = $htd->SaveToBin($rndFileName);
  228. if($ok)
  229. {
  230. $revalues = $fileurl;
  231. }
  232. }
  233. $htd->Close();
  234. return $revalues;
  235. }
  236. //????ID
  237. function CheckChannel($typeid,$channelid)
  238. {
  239. global $dsql;
  240. if($typeid==0)
  241. {
  242. return true;
  243. }
  244. $row = $dsql->GetOne("Select ispart,channeltype From `#@__arctype` where id='$typeid' ");
  245. if($row['ispart']!=0 || $row['channeltype']!=$channelid)
  246. {
  247. return false;
  248. }
  249. else
  250. {
  251. return true;
  252. }
  253. }
  254. //??????
  255. function CheckArcAdmin($aid,$adminid)
  256. {
  257. global $dsql;
  258. $row = $dsql->GetOne("Select mid From `#@__archives` where id='$aid' ");
  259. if($row['mid']!=$adminid)
  260. {
  261. return false;
  262. }
  263. else
  264. {
  265. return true;
  266. }
  267. }
  268. //??????
  269. function SpLongBody($mybody,$spsize,$sptag)
  270. {
  271. if(strlen($mybody)<$spsize)
  272. {
  273. return $mybody;
  274. }
  275. $mybody = stripslashes($mybody);
  276. $bds = explode('<',$mybody);
  277. $npageBody = '';
  278. $istable = 0;
  279. $mybody = '';
  280. foreach($bds as $i=>$k)
  281. {
  282. if($i==0)
  283. {
  284. $npageBody .= $bds[$i]; continue;
  285. }
  286. $bds[$i] = "<".$bds[$i];
  287. if(strlen($bds[$i])>6)
  288. {
  289. $tname = substr($bds[$i],1,5);
  290. if(strtolower($tname)=='table')
  291. {
  292. $istable++;
  293. }
  294. else if(strtolower($tname)=='/tabl')
  295. {
  296. $istable--;
  297. }
  298. if($istable>0)
  299. {
  300. $npageBody .= $bds[$i]; continue;
  301. }
  302. else
  303. {
  304. $npageBody .= $bds[$i];
  305. }
  306. }
  307. else
  308. {
  309. $npageBody .= $bds[$i];
  310. }
  311. if(strlen($npageBody)>$spsize)
  312. {
  313. $mybody .= $npageBody.$sptag;
  314. $npageBody = '';
  315. }
  316. }
  317. if($npageBody!='')
  318. {
  319. $mybody .= $npageBody;
  320. }
  321. return addslashes($mybody);
  322. }
  323. //????ID???
  324. function MakeArt($aid, $mkindex=false, $ismakesign=false,$isremote=0)
  325. {
  326. global $envs, $typeid;
  327. require_once(DEDEINC.'/arc.archives.class.php');
  328. if($ismakesign) $envs['makesign'] = 'yes';
  329. $arc = new Archives($aid);
  330. $reurl = $arc->MakeHtml($isremote);
  331. return $reurl;
  332. }
  333. //??????????
  334. function GetDDImgFromBody(&$body)
  335. {
  336. $litpic = '';
  337. preg_match_all("/(src)=[\"|'| ]{0,}([^>]*\.(gif|jpg|bmp|png))/isU",$body,$img_array);
  338. $img_array = array_unique($img_array[2]);
  339. if(count($img_array)>0)
  340. {
  341. $picname = preg_replace("/[\"|'| ]{1,}/", '', $img_array[0]);
  342. if(ereg("_lit\.",$picname))
  343. {
  344. $litpic = $picname;
  345. }
  346. else
  347. {
  348. $litpic = GetDDImage('ddfirst',$picname,1);
  349. }
  350. }
  351. return $litpic;
  352. }
  353. //?????
  354. function GetDDImage($litpic,$picname,$isremote)
  355. {
  356. global $cuserLogin,$cfg_ddimg_width,$cfg_ddimg_height,$cfg_basedir,$ddcfg_image_dir,$cfg_addon_savetype;
  357. $ntime = time();
  358. if( ($litpic != 'none' || $litpic != 'ddfirst') &&
  359. !empty($_FILES[$litpic]['tmp_name']) && is_uploaded_file($_FILES[$litpic]['tmp_name']))
  360. {
  361. //???????????
  362. $istype = 0;
  363. $sparr = Array("image/pjpeg","image/jpeg","image/gif","image/png");
  364. $_FILES[$litpic]['type'] = strtolower(trim($_FILES[$litpic]['type']));
  365. if(!in_array($_FILES[$litpic]['type'],$sparr))
  366. {
  367. ShowMsg("?????????????JPEG?GIF?PNG????????","-1");
  368. exit();
  369. }
  370. $savepath = $ddcfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);
  371. CreateDir($savepath);
  372. $fullUrl = $savepath.'/'.dd2char(MyDate('mdHis',$ntime).$cuserLogin->getUserID().mt_rand(1000,9999));
  373. if(strtolower($_FILES[$litpic]['type'])=="image/gif")
  374. {
  375. $fullUrl = $fullUrl.".gif";
  376. }
  377. else if(strtolower($_FILES[$litpic]['type'])=="image/png")
  378. {
  379. $fullUrl = $fullUrl.".png";
  380. }
  381. else
  382. {
  383. $fullUrl = $fullUrl.".jpg";
  384. }
  385. @move_uploaded_file($_FILES[$litpic]['tmp_name'],$cfg_basedir.$fullUrl);
  386. $litpic = $fullUrl;
  387. if($GLOBALS['cfg_ddimg_full']=='Y') @ImageResizeNew($cfg_basedir.$fullUrl,$cfg_ddimg_width,$cfg_ddimg_height);
  388. else @ImageResize($cfg_basedir.$fullUrl,$cfg_ddimg_width,$cfg_ddimg_height);
  389. $img = $cfg_basedir.$litpic;
  390. }
  391. else
  392. {
  393. $picname = trim($picname);
  394. if($isremote==1 && eregi("^http://",$picname))
  395. {
  396. $litpic = $picname;
  397. $ddinfos = GetRemoteImage($litpic,$cuserLogin->getUserID());
  398. if(!is_array($ddinfos))
  399. {
  400. $litpic = '';
  401. }
  402. else
  403. {
  404. $litpic = $ddinfos[0];
  405. if($ddinfos[1] > $cfg_ddimg_width || $ddinfos[2] > $cfg_ddimg_height)
  406. {
  407. if($GLOBALS['cfg_ddimg_full']=='Y') @ImageResizeNew($cfg_basedir.$litpic,$cfg_ddimg_width,$cfg_ddimg_height);
  408. else @ImageResize($cfg_basedir.$litpic,$cfg_ddimg_width,$cfg_ddimg_height);
  409. }
  410. }
  411. }
  412. else
  413. {
  414. if($litpic=='ddfirst' && !eregi("^http://",$picname))
  415. {
  416. $oldpic = $cfg_basedir.$picname;
  417. $litpic = str_replace('.','-lp.',$picname);
  418. if($GLOBALS['cfg_ddimg_full']=='Y') @ImageResizeNew($oldpic,$cfg_ddimg_width,$cfg_ddimg_height,$cfg_basedir.$litpic);
  419. else @ImageResize($oldpic,$cfg_ddimg_width,$cfg_ddimg_height,$cfg_basedir.$litpic);
  420. if(!is_file($cfg_basedir.$litpic)) $litpic = '';
  421. }
  422. else
  423. {
  424. $litpic = $picname;
  425. return $litpic;
  426. }
  427. }
  428. }
  429. if($litpic=='litpic' || $litpic=='ddfirst')
  430. {
  431. $litpic = '';
  432. }
  433. return $litpic;
  434. }
  435. //????????
  436. function GetFormItemA($ctag)
  437. {
  438. return GetFormItem($ctag,'admin');
  439. }
  440. //?????????
  441. function GetFieldValueA($dvalue,$dtype,$aid=0,$job='add',$addvar='')
  442. {
  443. return GetFieldValue($dvalue,$dtype,$aid,$job,$addvar,'admin');
  444. }
  445. //???????(????)
  446. function GetFormItemValueA($ctag,$fvalue)
  447. {
  448. return GetFormItemValue($ctag,$fvalue,'admin');
  449. }
  450. //???????(????)
  451. function PrintAutoFieldsAdd(&$fieldset,$loadtype='all')
  452. {
  453. $dtp = new DedeTagParse();
  454. $dtp->SetNameSpace('field','<','>');
  455. $dtp->LoadSource($fieldset);
  456. $dede_addonfields = '';
  457. if(is_array($dtp->CTags))
  458. {
  459. foreach($dtp->CTags as $tid=>$ctag)
  460. {
  461. if($loadtype!='autofield'
  462. || ($loadtype=='autofield' && $ctag->GetAtt('autofield')==1) )
  463. {
  464. $dede_addonfields .= ( $dede_addonfields=="" ? $ctag->GetName().",".$ctag->GetAtt('type') : ";".$ctag->GetName().",".$ctag->GetAtt('type') );
  465. echo GetFormItemA($ctag);
  466. }
  467. }
  468. }
  469. echo "<input type='hidden' name='dede_addonfields' value=\"".$dede_addonfields."\">\r\n";
  470. }
  471. //???????(????)
  472. function PrintAutoFieldsEdit(&$fieldset,&$fieldValues,$loadtype='all')
  473. {
  474. $dtp = new DedeTagParse();
  475. $dtp->SetNameSpace("field","<",">");
  476. $dtp->LoadSource($fieldset);
  477. $dede_addonfields = "";
  478. if(is_array($dtp->CTags))
  479. {
  480. foreach($dtp->CTags as $tid=>$ctag)
  481. {
  482. if($loadtype!='autofield'
  483. || ($loadtype=='autofield' && $ctag->GetAtt('autofield')==1) )
  484. {
  485. $dede_addonfields .= ( $dede_addonfields=='' ? $ctag->GetName().",".$ctag->GetAtt('type') : ";".$ctag->GetName().",".$ctag->GetAtt('type') );
  486. echo GetFormItemValueA($ctag,$fieldValues[$ctag->GetName()]);
  487. }
  488. }
  489. }
  490. echo "<input type='hidden' name='dede_addonfields' value=\"".$dede_addonfields."\">\r\n";
  491. }
  492. //??HTML??
  493. //????????????????????
  494. function AnalyseHtmlBody($body,&$description,&$litpic,&$keywords,$dtype='')
  495. {
  496. global $autolitpic,$remote,$dellink,$autokey,$cfg_basehost,$cfg_auot_description,$id,$title,$cfg_soft_lang;
  497. $autolitpic = (empty($autolitpic) ? '' : $autolitpic);
  498. $body = stripslashes($body);
  499. //???????
  500. if($remote==1)
  501. {
  502. $body = GetCurContent($body);
  503. }
  504. //???????
  505. if($dellink==1)
  506. {
  507. $basehost = "http://".$_SERVER['HTTP_HOST'];
  508. $body = str_replace($cfg_basehost,'#basehost#',$body);
  509. $body = str_replace($basehost,'#2basehost2#',$body);
  510. $body = preg_replace("/(<a[ \t\r\n]{1,}href=[\"']{0,}http:\/\/[^\/]([^>]*)>)|(<\/a>)/isU","",$body);
  511. $body = str_replace('#basehost#',$cfg_basehost,$body);
  512. $body = str_replace('#2basehost2#',$basehost,$body);
  513. }
  514. //????
  515. if($description=='' && $cfg_auot_description>0)
  516. {
  517. $description = cn_substr(html2text($body),$cfg_auot_description);
  518. $description = trim(preg_replace('/#p#|#e#/','',$description));
  519. $description = addslashes($description);
  520. }
  521. //???????
  522. if($autolitpic==1 && $litpic=='')
  523. {
  524. $litpic = GetDDImgFromBody($body);
  525. }
  526. //???????
  527. if($autokey==1 && $keywords=='')
  528. {
  529. $subject = $title;
  530. $message = $body;
  531. include_once(DEDEINC.'/splitword.class.php');
  532. $keywords = '';
  533. $sp = new SplitWord($cfg_soft_lang, $cfg_soft_lang);
  534. $sp->SetSource($subject, $cfg_soft_lang, $cfg_soft_lang);
  535. $sp->StartAnalysis();
  536. $titleindexs = preg_replace("/#p#|#e#/",'',$sp->GetFinallyIndex());
  537. $sp->SetSource(Html2Text($message), $cfg_soft_lang, $cfg_soft_lang);
  538. $allindexs = preg_replace("/#p#|#e#/",'',$sp->GetFinallyIndex());
  539. if(is_array($allindexs) && is_array($titleindexs))
  540. {
  541. foreach($titleindexs as $k => $v)
  542. {
  543. if(strlen($keywords.$k)>=60)
  544. {
  545. break;
  546. }
  547. else
  548. {
  549. $keywords .= $k.',';
  550. }
  551. }
  552. foreach($allindexs as $k => $v)
  553. {
  554. if(strlen($keywords.$k)>=60)
  555. {
  556. break;
  557. }
  558. else if(!in_array($k,$titleindexs))
  559. {
  560. $keywords .= $k.',';
  561. }
  562. }
  563. }
  564. $sp = null;
  565. $keywords = addslashes($keywords);
  566. }
  567. $body = GetFieldValueA($body,$dtype,$id);
  568. $body = addslashes($body);
  569. return $body;
  570. }
  571. //????????
  572. function GetImageMapDD($filename, $maxwidth)
  573. {
  574. global $cuserLogin, $dsql, $cfg_ddimg_height, $cfg_ddimg_full;
  575. $ddn = substr($filename, -3);
  576. $ddpicok = ereg_replace("\.".$ddn."$", "-lp.".$ddn, $filename);
  577. $toFile = $GLOBALS['cfg_basedir'].$ddpicok;
  578. if($cfg_ddimg_full=='Y') ImageResizeNew($GLOBALS['cfg_basedir'].$filename, $maxwidth, $cfg_ddimg_height, $toFile);
  579. else ImageResize($GLOBALS['cfg_basedir'].$filename, $maxwidth, $cfg_ddimg_height, $toFile);
  580. //????????
  581. $fsize = filesize($toFile);
  582. $ddpicoks = explode('/', $ddpicok);
  583. $filename = $ddpicoks[count($ddpicoks)-1];
  584. $inquery = "INSERT INTO `#@__uploads`(arcid,title,url,mediatype,width,height,playtime,filesize,uptime,mid)
  585. VALUES ('0','$filename','$ddpicok','1','0','0','0','$fsize','".time()."','".$cuserLogin->getUserID()."'); ";
  586. $dsql->ExecuteNoneQuery($inquery);
  587. $fid = $dsql->GetLastID();
  588. AddMyAddon($fid, $ddpicok);
  589. return $ddpicok;
  590. }
  591. //------------------------
  592. //???????????
  593. //------------------------
  594. /*
  595. //??? upname ?????
  596. //??? handurl ???????
  597. //??? ddisremote ???????? 0 ??, 1 ??
  598. //??? ntitle ???? ????? title ?????
  599. */
  600. function UploadOneImage($upname,$handurl='',$isremote=1,$ntitle='')
  601. {
  602. global $cuserLogin,$cfg_basedir,$cfg_image_dir,$title, $dsql;
  603. if($ntitle!='')
  604. {
  605. $title = $ntitle;
  606. }
  607. $ntime = time();
  608. $filename = '';
  609. $isrm_up = false;
  610. $handurl = trim($handurl);
  611. //???????????
  612. if(!empty($_FILES[$upname]['tmp_name']) && is_uploaded_file($_FILES[$upname]['tmp_name']))
  613. {
  614. $istype = 0;
  615. $sparr = Array("image/pjpeg","image/jpeg","image/gif","image/png");
  616. $_FILES[$upname]['type'] = strtolower(trim($_FILES[$upname]['type']));
  617. if(!in_array($_FILES[$upname]['type'],$sparr))
  618. {
  619. ShowMsg("?????????????JPEG?GIF?PNG????????","-1");
  620. exit();
  621. }
  622. if(!empty($handurl) && !eregi("^http://",$handurl) && file_exists($cfg_basedir.$handurl) )
  623. {
  624. if(!is_object($dsql))
  625. {
  626. $dsql = new DedeSql();
  627. }
  628. $dsql->ExecuteNoneQuery("Delete From `#@__uploads` where url like '$handurl' ");
  629. $fullUrl = eregi_replace("\.([a-z]*)$","",$handurl);
  630. }
  631. else
  632. {
  633. $savepath = $cfg_image_dir.'/'.strftime("%Y-%m",$ntime);
  634. CreateDir($savepath);
  635. $fullUrl = $savepath.'/'.strftime("%d",$ntime).dd2char(strftime("%H%M%S",$ntime).'0'.$cuserLogin->getUserID().'0'.mt_rand(1000,9999));
  636. }
  637. if(strtolower($_FILES[$upname]['type'])=="image/gif")
  638. {
  639. $fullUrl = $fullUrl.".gif";
  640. }
  641. else if(strtolower($_FILES[$upname]['type'])=="image/png")
  642. {
  643. $fullUrl = $fullUrl.".png";
  644. }
  645. else
  646. {
  647. $fullUrl = $fullUrl.".jpg";
  648. }
  649. //??
  650. @move_uploaded_file($_FILES[$upname]['tmp_name'],$cfg_basedir.$fullUrl);
  651. $filename = $fullUrl;
  652. //??
  653. @WaterImg($imgfile,'up');
  654. $isrm_up = true;
  655. }
  656. //?????????
  657. else
  658. {
  659. if($handurl=='')
  660. {
  661. return '';
  662. }
  663. //??????????
  664. if($isremote==1 && eregi("^http://",$handurl))
  665. {
  666. $ddinfos = GetRemoteImage($handurl,$cuserLogin->getUserID());
  667. if(!is_array($ddinfos))
  668. {
  669. $litpic = "";
  670. }
  671. else
  672. {
  673. $filename = $ddinfos[0];
  674. }
  675. $isrm_up = true;
  676. //?????????????
  677. }
  678. else
  679. {
  680. $filename = $handurl;
  681. }
  682. }
  683. $imgfile = $cfg_basedir.$filename;
  684. if(is_file($imgfile) && $isrm_up && $filename!='')
  685. {
  686. $info = "";
  687. $imginfos = GetImageSize($imgfile,$info);
  688. //?????????????????????
  689. $inquery = "
  690. INSERT INTO #@__uploads(title,url,mediatype,width,height,playtime,filesize,uptime,mid)
  691. VALUES ('$title','$filename','1','".$imginfos[0]."','".$imginfos[1]."','0','".filesize($imgfile)."','".time()."','".$cuserLogin->getUserID()."');
  692. ";
  693. $dsql->ExecuteNoneQuery($inquery);
  694. }
  695. return $filename;
  696. }
  697. function GetUpdateTest()
  698. {
  699. global $arcID, $typeid, $cfg_make_andcat, $cfg_makeindex, $cfg_make_prenext;
  700. $revalue = $dolist = '';
  701. if($cfg_makeindex=='Y' || $cfg_make_andcat=='Y' || $cfg_make_prenext=='Y')
  702. {
  703. if($cfg_make_prenext=='Y' && !empty($typeid)) $dolist = 'makeprenext';
  704. if($cfg_makeindex=='Y') $dolist .= empty($dolist) ? 'makeindex' : ',makeindex';
  705. if($cfg_make_andcat=='Y') $dolist .= empty($dolist) ? 'makeparenttype' : ',makeparenttype';
  706. $dolists = explode(',', $dolist);
  707. $jumpUrl = "task_do.php?typeid={$typeid}&aid={$arcID}&dopost={$dolists[0]}&nextdo=".ereg_replace($dolists[0]."[,]{0,1}", '', $dolist);
  708. $revalue = "<table width='80%' style='border:1px dashed #cdcdcd;margin-left:20px;margin-bottom:15px' id='tgtable' align='left'><tr><td bgcolor='#EBF5C9'>&nbsp;<strong>????????????????????????</strong>\r\n</td></tr>\r\n";
  709. $revalue .= "<tr><td>\r\n<iframe name='stafrm' frameborder='0' id='stafrm' width='100%' height='200px' src='$jumpUrl'></iframe>\r\n</td></tr>\r\n";
  710. $revalue .= "</table>";
  711. }
  712. else
  713. {
  714. $revalue = '';
  715. }
  716. return $revalue;
  717. }
  718. ?>