PageRenderTime 52ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/source/function/function_spacecp.php

https://github.com/kuaileshike/upload
PHP | 731 lines | 631 code | 94 blank | 6 comment | 160 complexity | 9b0aa45b54f2adea502d300c3e52a645 MD5 | raw file
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: function_spacecp.php 31003 2012-07-06 08:42:09Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. function album_creat_by_id($albumid, $catid = 0) {
  12. global $_G, $space;
  13. preg_match("/^new\:(.+)$/i", $albumid, $matchs);
  14. if(!empty($matchs[1])) {
  15. $albumname = dhtmlspecialchars(trim($matchs[1]));
  16. if(empty($albumname)) $albumname = dgmdate($_G['timestamp'],'Ymd');
  17. $albumarr = array('albumname' => $albumname);
  18. if($catid) {
  19. $albumarr['catid'] = $catid;
  20. }
  21. $albumid = album_creat($albumarr);
  22. } else {
  23. $albumid = intval($albumid);
  24. if($albumid) {
  25. $value = C::t('home_album')->fetch_all_by_uid($_G['uid'], false, 0, 0, $albumid);
  26. if($value = $value[0]) {
  27. $albumname = addslashes($value['albumname']);
  28. $albumfriend = $value['friend'];
  29. } else {
  30. $albumname = dgmdate($_G['timestamp'],'Ymd');
  31. $albumarr = array('albumname' => $albumname);
  32. if($catid) {
  33. $albumarr['catid'] = $catid;
  34. }
  35. $albumid = album_creat($albumarr);
  36. }
  37. }
  38. }
  39. return $albumid;
  40. }
  41. function album_update_pic($albumid, $picid=0) {
  42. global $_G;
  43. $setarr = array();
  44. if(!$picid) {
  45. $piccount = C::t('home_pic')->check_albumpic($albumid, 0);
  46. if(empty($piccount) && C::t('home_pic')->check_albumpic($albumid) == 0) {
  47. C::t('home_album')->delete($albumid);
  48. return false;
  49. } else {
  50. $setarr['picnum'] = $piccount;
  51. }
  52. }
  53. $query = C::t('home_pic')->fetch_all_by_albumid($albumid, 0, 1, $picid, 1);
  54. if(!$pic = $query[0]) {
  55. return false;
  56. }
  57. $from = $pic['remote'];
  58. $pic['remote'] = $pic['remote'] > 1 ? $pic['remote'] - 2 : $pic['remote'];
  59. $basedir = !getglobal('setting/attachdir') ? (DISCUZ_ROOT.'./data/attachment/') : getglobal('setting/attachdir');
  60. $picdir = 'cover/'.substr(md5($albumid), 0, 2).'/';
  61. dmkdir($basedir.'./album/'.$picdir);
  62. if($pic['remote']) {
  63. $picsource = pic_get($pic['filepath'], $from > 1 ? 'forum' : 'album', $pic['thumb'], $pic['remote'], 0);
  64. } else {
  65. $picsource = $basedir.'./'.($from > 1 ? 'forum' : 'album').'/'.$pic['filepath'];
  66. }
  67. require_once libfile('class/image');
  68. $image = new image();
  69. if($image->Thumb($picsource, 'album/'.$picdir.$albumid.'.jpg', 120, 120, 2)) {
  70. $setarr['pic'] = $picdir.$albumid.'.jpg';
  71. $setarr['picflag'] = 1;
  72. if(getglobal('setting/ftp/on')) {
  73. if(ftpcmd('upload', 'album/'.$picdir.$albumid.'.jpg')) {
  74. $setarr['picflag'] = 2;
  75. @unlink($_G['setting']['attachdir'].'album/'.$picdir.$albumid.'.jpg');
  76. }
  77. }
  78. } else {
  79. if($pic['status'] == 0) {
  80. $setarr['pic'] = $pic['thumb'] ? getimgthumbname($pic['filepath']) : $pic['filepath'];
  81. }
  82. if($from > 1) {
  83. $setarr['picflag'] = $pic['remote'] ? 4:3;
  84. } else {
  85. $setarr['picflag'] = $pic['remote'] ? 2:1;
  86. }
  87. }
  88. $setarr['updatetime'] = $_G['timestamp'];
  89. C::t('home_album')->update($albumid, $setarr);
  90. return true;
  91. }
  92. function pic_save($FILE, $albumid, $title, $iswatermark = true, $catid = 0) {
  93. global $_G, $space;
  94. if($albumid<0) $albumid = 0;
  95. $allowpictype = array('jpg','jpeg','gif','png');
  96. $upload = new discuz_upload();
  97. $upload->init($FILE, 'album');
  98. if($upload->error()) {
  99. return lang('spacecp', 'lack_of_access_to_upload_file_size');
  100. }
  101. if(!$upload->attach['isimage']) {
  102. return lang('spacecp', 'only_allows_upload_file_types');
  103. }
  104. $oldgid = $_G['groupid'];
  105. if(empty($space)) {
  106. $_G['member'] = $space = getuserbyuid($_G['uid']);
  107. $_G['username'] = $space['username'];
  108. $_G['groupid'] = $space['groupid'];
  109. }
  110. $_G['member'] = $space;
  111. loadcache('usergroup_'.$space['groupid'], $oldgid != $_G['groupid'] ? true : false);
  112. $_G['group'] = $_G['cache']['usergroup_'.$space['groupid']];
  113. if(!checkperm('allowupload')) {
  114. return lang('spacecp', 'not_allow_upload');
  115. }
  116. if(!cknewuser(1)) {
  117. if($_G['setting']['newbiespan'] && $_G['timestamp'] - $_G['member']['regdate'] < $_G['setting']['newbiespan'] * 60) {
  118. return lang('message', 'no_privilege_newbiespan', array('newbiespan' => $_G['setting']['newbiespan']));
  119. }
  120. if($_G['setting']['need_avatar'] && empty($_G['member']['avatarstatus'])) {
  121. return lang('message', 'no_privilege_avatar');
  122. }
  123. if($_G['setting']['need_email'] && empty($_G['member']['emailstatus'])) {
  124. return lang('message', 'no_privilege_email');
  125. }
  126. if($_G['setting']['need_friendnum']) {
  127. space_merge($_G['member'], 'count');
  128. if($_G['member']['friends'] < $_G['setting']['need_friendnum']) {
  129. return lang('message', 'no_privilege_friendnum', array('friendnum' => $_G['setting']['need_friendnum']));
  130. }
  131. }
  132. }
  133. if($_G['group']['maximagesize'] && $upload->attach['size'] > $_G['group']['maximagesize']) {
  134. return lang('spacecp', 'files_can_not_exceed_size', array('extend' => $upload->attach['ext'], 'size' => sizecount($_G['group']['maximagesize'])));
  135. }
  136. $maxspacesize = checkperm('maxspacesize');
  137. if($maxspacesize) {
  138. space_merge($space, 'count');
  139. space_merge($space, 'field_home');
  140. if($space['attachsize'] + $upload->attach['size'] > $maxspacesize + $space['addsize'] * 1024 * 1024) {
  141. return lang('spacecp', 'inadequate_capacity_space');
  142. }
  143. }
  144. $showtip = true;
  145. $albumfriend = 0;
  146. if($albumid) {
  147. $catid = intval($catid);
  148. $albumid = album_creat_by_id($albumid, $catid);
  149. } else {
  150. $albumid = 0;
  151. $showtip = false;
  152. }
  153. $upload->save();
  154. if($upload->error()) {
  155. return lang('spacecp', 'mobile_picture_temporary_failure');
  156. }
  157. if(!$upload->attach['imageinfo'] || !in_array($upload->attach['imageinfo']['2'], array(1,2,3,6))) {
  158. @unlink($upload->attach['target']);
  159. return lang('spacecp', 'only_allows_upload_file_types');
  160. }
  161. $new_name = $upload->attach['target'];
  162. require_once libfile('class/image');
  163. $image = new image();
  164. $result = $image->Thumb($new_name, '', 140, 140, 1);
  165. $thumb = empty($result)?0:1;
  166. if($_G['setting']['maxthumbwidth'] && $_G['setting']['maxthumbheight']) {
  167. if($_G['setting']['maxthumbwidth'] < 300) $_G['setting']['maxthumbwidth'] = 300;
  168. if($_G['setting']['maxthumbheight'] < 300) $_G['setting']['maxthumbheight'] = 300;
  169. $image->Thumb($new_name, '', $_G['setting']['maxthumbwidth'], $_G['setting']['maxthumbheight'], 1, 1);
  170. }
  171. if ($iswatermark) {
  172. $image->Watermark($new_name, '', 'album');
  173. }
  174. $pic_remote = 0;
  175. $album_picflag = 1;
  176. if(getglobal('setting/ftp/on')) {
  177. $ftpresult_thumb = 0;
  178. $ftpresult = ftpcmd('upload', 'album/'.$upload->attach['attachment']);
  179. if($ftpresult) {
  180. @unlink($_G['setting']['attachdir'].'album/'.$upload->attach['attachment']);
  181. if($thumb) {
  182. $thumbpath = getimgthumbname($upload->attach['attachment']);
  183. ftpcmd('upload', 'album/'.$thumbpath);
  184. @unlink($_G['setting']['attachdir'].'album/'.$thumbpath);
  185. }
  186. $pic_remote = 1;
  187. $album_picflag = 2;
  188. } else {
  189. if(getglobal('setting/ftp/mirror')) {
  190. @unlink($upload->attach['target']);
  191. @unlink(getimgthumbname($upload->attach['target']));
  192. return lang('spacecp', 'ftp_upload_file_size');
  193. }
  194. }
  195. }
  196. $title = getstr($title, 200);
  197. $title = censor($title);
  198. if(censormod($title) || $_G['group']['allowuploadmod']) {
  199. $pic_status = 1;
  200. } else {
  201. $pic_status = 0;
  202. }
  203. $setarr = array(
  204. 'albumid' => $albumid,
  205. 'uid' => $_G['uid'],
  206. 'username' => $_G['username'],
  207. 'dateline' => $_G['timestamp'],
  208. 'filename' => addslashes($upload->attach['name']),
  209. 'postip' => $_G['clientip'],
  210. 'title' => $title,
  211. 'type' => addslashes($upload->attach['ext']),
  212. 'size' => $upload->attach['size'],
  213. 'filepath' => $upload->attach['attachment'],
  214. 'thumb' => $thumb,
  215. 'remote' => $pic_remote,
  216. 'status' => $pic_status,
  217. );
  218. $setarr['picid'] = C::t('home_pic')->insert($setarr, 1);
  219. C::t('common_member_count')->increase($_G['uid'], array('attachsize' => $upload->attach['size']));
  220. include_once libfile('function/stat');
  221. if($pic_status) {
  222. updatemoderate('picid', $setarr['picid']);
  223. }
  224. updatestat('pic');
  225. return $setarr;
  226. }
  227. function stream_save($strdata, $albumid = 0, $fileext = 'jpg', $name='', $title='', $delsize=0, $from = false) {
  228. global $_G, $space;
  229. if($albumid<0) $albumid = 0;
  230. $allowPicType = array('jpg','jpeg','gif','png');
  231. if(!in_array($fileext, $allowPicType)) {
  232. return -3;
  233. }
  234. $setarr = array();
  235. $upload = new discuz_upload();
  236. $filepath = $upload->get_target_dir('album').$upload->get_target_filename('album').'.'.$fileext;
  237. $newfilename = $_G['setting']['attachdir'].'./album/'.$filepath;
  238. if($handle = fopen($newfilename, 'wb')) {
  239. if(fwrite($handle, $strdata) !== FALSE) {
  240. fclose($handle);
  241. $size = filesize($newfilename);
  242. if(empty($space)) {
  243. $_G['member'] = $space = getuserbyuid($_G['uid']);
  244. $_G['username'] = $space['username'];
  245. }
  246. $_G['member'] = $space;
  247. loadcache('usergroup_'.$space['groupid']);
  248. $_G['group'] = $_G['cache']['usergroup_'.$space['groupid']];
  249. $maxspacesize = checkperm('maxspacesize');
  250. if($maxspacesize) {
  251. space_merge($space, 'count');
  252. space_merge($space, 'field_home');
  253. if($space['attachsize'] + $size - $delsize > $maxspacesize + $space['addsize'] * 1024 * 1024) {
  254. @unlink($newfilename);
  255. return -1;
  256. }
  257. }
  258. if(!$upload->get_image_info($newfilename)) {
  259. @unlink($newfilename);
  260. return -2;
  261. }
  262. require_once libfile('class/image');
  263. $image = new image();
  264. $result = $image->Thumb($newfilename, NULL, 140, 140, 1);
  265. $thumb = empty($result)?0:1;
  266. $image->Watermark($newfilename);
  267. $pic_remote = 0;
  268. $album_picflag = 1;
  269. if(getglobal('setting/ftp/on')) {
  270. $ftpresult_thumb = 0;
  271. $ftpresult = ftpcmd('upload', 'album/'.$filepath);
  272. if($ftpresult) {
  273. @unlink($_G['setting']['attachdir'].'album/'.$filepath);
  274. if($thumb) {
  275. $thumbpath = getimgthumbname($filepath);
  276. ftpcmd('upload', 'album/'.$thumbpath);
  277. @unlink($_G['setting']['attachdir'].'album/'.$thumbpath);
  278. }
  279. $pic_remote = 1;
  280. $album_picflag = 2;
  281. } else {
  282. if(getglobal('setting/ftp/mirror')) {
  283. @unlink($newfilename);
  284. @unlink(getimgthumbname($newfilename));
  285. return -3;
  286. }
  287. }
  288. }
  289. $filename = $name ? $name : substr(strrchr($filepath, '/'), 1);
  290. $title = getstr($title, 200);
  291. $title = censor($title);
  292. if(censormod($title) || $_G['group']['allowuploadmod']) {
  293. $pic_status = 1;
  294. } else {
  295. $pic_status = 0;
  296. }
  297. if($albumid) {
  298. $albumid = album_creat_by_id($albumid);
  299. } else {
  300. $albumid = 0;
  301. }
  302. $setarr = array(
  303. 'albumid' => $albumid,
  304. 'uid' => $_G['uid'],
  305. 'username' => $_G['username'],
  306. 'dateline' => $_G['timestamp'],
  307. 'filename' => $filename,
  308. 'postip' => $_G['clientip'],
  309. 'title' => $title,
  310. 'type' => $fileext,
  311. 'size' => $size,
  312. 'filepath' => $filepath,
  313. 'thumb' => $thumb,
  314. 'remote' => $pic_remote,
  315. 'status' => $pic_status,
  316. );
  317. $setarr['picid'] = C::t('home_pic')->insert($setarr, 1);
  318. C::t('common_member_count')->increase($_G['uid'], array('attachsize' => $size));
  319. include_once libfile('function/stat');
  320. updatestat('pic');
  321. return $setarr;
  322. } else {
  323. fclose($handle);
  324. }
  325. }
  326. return -3;
  327. }
  328. function album_creat($arr) {
  329. global $_G;
  330. $albumid = C::t('home_album')->fetch_albumid_by_albumname_uid($arr['albumname'], $_G['uid']);
  331. if($albumid) {
  332. return $albumid;
  333. } else {
  334. $arr['uid'] = $_G['uid'];
  335. $arr['username'] = $_G['username'];
  336. $arr['dateline'] = $arr['updatetime'] = $_G['timestamp'];
  337. $albumid = C::t('home_album')->insert($arr, TRUE);
  338. C::t('common_member_count')->increase($_G['uid'], array('albums' => 1));
  339. if(isset($arr['catid']) && $arr['catid']) {
  340. C::t('home_album_category')->update_num_by_catid('1', $arr['catid']);
  341. }
  342. return $albumid;
  343. }
  344. }
  345. function getfilepath($fileext, $mkdir=false) {
  346. global $_G;
  347. $filepath = "{$_G['uid']}_{$_G['timestamp']}".random(4).".$fileext";
  348. $name1 = gmdate('Ym');
  349. $name2 = gmdate('j');
  350. if($mkdir) {
  351. $newfilename = $_G['setting']['attachdir'].'./album/'.$name1;
  352. if(!is_dir($newfilename)) {
  353. if(!@mkdir($newfilename)) {
  354. runlog('error', "DIR: $newfilename can not make");
  355. return $filepath;
  356. }
  357. }
  358. $newfilename .= '/'.$name2;
  359. if(!is_dir($newfilename)) {
  360. if(!@mkdir($newfilename)) {
  361. runlog('error', "DIR: $newfilename can not make");
  362. return $name1.'/'.$filepath;
  363. }
  364. }
  365. }
  366. return $name1.'/'.$name2.'/'.$filepath;
  367. }
  368. function getalbumpic($uid, $id) {
  369. global $_G;
  370. $pic = C::t('home_pic')->fetch_album_pic($id, $uid);
  371. if($pic) {
  372. return $pic['thumb'] ? getimgthumbname($pic['filepath']) : $pic['filepath'];
  373. } else {
  374. return '';
  375. }
  376. }
  377. function getclassarr($uid) {
  378. global $_G;
  379. $classarr = array();
  380. $query = C::t('home_class')->fetch_all_by_uid($uid);
  381. foreach($query as $value) {
  382. $classarr[$value['classid']] = $value;
  383. }
  384. return $classarr;
  385. }
  386. function getalbums($uid) {
  387. global $_G;
  388. $albums = array();
  389. $query = C::t('home_album')->fetch_all_by_uid($uid, 'albumid');
  390. foreach($query as $value) {
  391. $albums[$value['albumid']] = $value;
  392. }
  393. return $albums;
  394. }
  395. function hot_update($idtype, $id, $hotuser) {
  396. global $_G;
  397. $hotusers = empty($hotuser)?array():explode(',', $hotuser);
  398. if($hotusers && in_array($_G['uid'], $hotusers)) {
  399. return false;
  400. } else {
  401. $hotusers[] = $_G['uid'];
  402. $hotuser = implode(',', $hotusers);
  403. }
  404. $hotuser = daddslashes($hotuser);
  405. $newhot = count($hotusers)+1;
  406. if($newhot == $_G['setting']['feedhotmin']) {
  407. $tablename = gettablebyidtype($idtype);
  408. if($tablename) {
  409. $item = C::t($tablename)->fetch_by_id_idtype($id);
  410. $itemuid = $item['uid'];
  411. updatecreditbyaction('hotinfo', $itemuid);
  412. }
  413. }
  414. switch ($idtype) {
  415. case 'blogid':
  416. C::t('home_blogfield')->update($id, array('hotuser' => $hotuser));
  417. C::t('home_blog')->increase($id, 0, array('hot' => 1));
  418. break;
  419. case 'picid':
  420. C::t('home_picfield')->insert(array('picid' => $id, 'hotuser' => $hotuser), 0, 1);
  421. C::t('home_pic')->update_hot($id);
  422. break;
  423. case 'sid':
  424. C::t('home_share')->update_hot_by_sid($id, $hotuser);
  425. break;
  426. default:
  427. return false;
  428. }
  429. if($feed = C::t('home_feed')->fetch($id, $idtype)) {
  430. if(empty($feed['friend'])) {
  431. C::t('home_feed')->update_hot_by_feedid($feed['feedid'], 1);
  432. }
  433. } elseif($idtype == 'picid') {
  434. require_once libfile('function/feed');
  435. feed_publish($id, $idtype);
  436. }
  437. return true;
  438. }
  439. function gettablebyidtype($idtype) {
  440. $tablename = '';
  441. if($idtype == 'blogid') {
  442. $tablename = 'home_blog';
  443. } elseif($idtype == 'picid') {
  444. $tablename = 'home_pic';
  445. } elseif($idtype == 'sid') {
  446. $tablename = 'home_share';
  447. }
  448. return $tablename;
  449. }
  450. function privacy_update() {
  451. global $_G, $space;
  452. C::t('common_member_field_home')->update($_G['uid'], array('privacy'=>serialize($space['privacy'])));
  453. }
  454. function ckrealname($return=0) {
  455. global $_G;
  456. $result = true;
  457. if($_G['adminid'] != 1 && $_G['setting']['verify'][6]['available'] && empty($_G['setting']['verify'][6]['viewrealname'])) {
  458. space_merge($_G['member'], 'profile');
  459. space_merge($_G['member'], 'verify');
  460. if(empty($_G['member']['realname']) || !$_G['member']['verify6']) {
  461. if(empty($return)) showmessage('no_privilege_realname', '', array(), array('return' => true));
  462. $result = false;
  463. }
  464. }
  465. return $result;
  466. }
  467. function ckvideophoto($tospace=array(), $return=0) {
  468. global $_G;
  469. if($_G['adminid'] != 1 && empty($_G['setting']['verify'][7]['available']) || $_G['member']['videophotostatus']) {
  470. return true;
  471. }
  472. space_merge($tospace, 'field_home');
  473. $result = true;
  474. if(empty($tospace) || empty($tospace['privacy']['view']['videoviewphoto'])) {
  475. if(!checkperm('videophotoignore') && empty($_G['setting']['verify'][7]['viewvideophoto']) && !checkperm('allowviewvideophoto')) {
  476. $result = false;
  477. }
  478. } elseif ($tospace['privacy']['view']['videoviewphoto'] == 2) {
  479. $result = false;
  480. }
  481. if($return) {
  482. return $result;
  483. } elseif(!$result) {
  484. showmessage('no_privilege_videophoto', '', array(), array('return' => true));
  485. }
  486. }
  487. function getvideophoto($filename) {
  488. $dir1 = substr($filename, 0, 1);
  489. $dir2 = substr($filename, 1, 1);
  490. return 'data/avatar/'.$dir1.'/'.$dir2.'/'.$filename.".jpg";
  491. }
  492. function videophoto_upload($FILE, $uid) {
  493. if($FILE['size']) {
  494. $newfilename = md5(substr($_G['timestamp'], 0, 7).$uid);
  495. $dir1 = substr($newfilename, 0, 1);
  496. $dir2 = substr($newfilename, 1, 1);
  497. if(!is_dir(DISCUZ_ROOT.'./data/avatar/'.$dir1)) {
  498. if(!mkdir(DISCUZ_ROOT.'./data/avatar/'.$dir1)) return '';
  499. }
  500. if(!is_dir(DISCUZ_ROOT.'./data/avatar/'.$dir1.'/'.$dir2)) {
  501. if(!mkdir(DISCUZ_ROOT.'./data/avatar/'.$dir1.'/'.$dir2)) return '';
  502. }
  503. $new_name = DISCUZ_ROOT.'./'.getvideophoto($newfilename);
  504. $tmp_name = $FILE['tmp_name'];
  505. if(@copy($tmp_name, $new_name)) {
  506. @unlink($tmp_name);
  507. } elseif((function_exists('move_uploaded_file') && @move_uploaded_file($tmp_name, $new_name))) {
  508. } elseif(@rename($tmp_name, $new_name)) {
  509. } else {
  510. return '';
  511. }
  512. return $newfilename;
  513. } else {
  514. return '';
  515. }
  516. }
  517. function isblacklist($touid) {
  518. global $_G;
  519. return C::t('home_blacklist')->count_by_uid_buid($touid, $_G['uid']);
  520. }
  521. function emailcheck_send($uid, $email) {
  522. global $_G;
  523. if($uid && $email) {
  524. $hash = authcode("$uid\t$email\t$_G[timestamp]", 'ENCODE', md5(substr(md5($_G['config']['security']['authkey']), 0, 16)));
  525. $verifyurl = $_G['siteurl'].'home.php?mod=misc&amp;ac=emailcheck&amp;hash='.urlencode($hash);
  526. $mailsubject = lang('email', 'email_verify_subject');
  527. $mailmessage = lang('email', 'email_verify_message', array(
  528. 'username' => $_G['member']['username'],
  529. 'bbname' => $_G['setting']['bbname'],
  530. 'siteurl' => $_G['siteurl'],
  531. 'url' => $verifyurl
  532. ));
  533. require_once libfile('function/mail');
  534. if(!sendmail($email, $mailsubject, $mailmessage)) {
  535. runlog('sendmail', "$email sendmail failed.");
  536. }
  537. }
  538. }
  539. function picurl_get($picurl, $maxlenth='200') {
  540. $picurl = dhtmlspecialchars(trim($picurl));
  541. if($picurl) {
  542. if(preg_match("/^http\:\/\/.{5,$maxlenth}\.(jpg|gif|png)$/i", $picurl)) return $picurl;
  543. }
  544. return '';
  545. }
  546. function avatar_file($uid, $size) {
  547. global $_G;
  548. $var = "home_avatarfile_{$uid}_{$size}";
  549. if(empty($_G[$var])) {
  550. $uid = abs(intval($uid));
  551. $uid = sprintf("%09d", $uid);
  552. $dir1 = substr($uid, 0, 3);
  553. $dir2 = substr($uid, 3, 2);
  554. $dir3 = substr($uid, 5, 2);
  555. $_G[$var] = $dir1.'/'.$dir2.'/'.$dir3.'/'.substr($uid, -2)."_avatar_$size.jpg";
  556. }
  557. return $_G[$var];
  558. }
  559. function makepokeaction($iconid) {
  560. global $_G;
  561. $icons = array(
  562. 0 => lang('home/template', 'say_hi'),
  563. 1 => '<img alt="cyx" src="'.STATICURL.'image/poke/cyx.gif" class="vm" /> '.lang('home/template', 'poke_1'),
  564. 2 => '<img alt="wgs" src="'.STATICURL.'image/poke/wgs.gif" class="vm" /> '.lang('home/template', 'poke_2'),
  565. 3 => '<img alt="wx" src="'.STATICURL.'image/poke/wx.gif" class="vm" /> '.lang('home/template', 'poke_3'),
  566. 4 => '<img alt="jy" src="'.STATICURL.'image/poke/jy.gif" class="vm" /> '.lang('home/template', 'poke_4'),
  567. 5 => '<img alt="pmy" src="'.STATICURL.'image/poke/pmy.gif" class="vm" /> '.lang('home/template', 'poke_5'),
  568. 6 => '<img alt="yb" src="'.STATICURL.'image/poke/yb.gif" class="vm" /> '.lang('home/template', 'poke_6'),
  569. 7 => '<img alt="fw" src="'.STATICURL.'image/poke/fw.gif" class="vm" /> '.lang('home/template', 'poke_7'),
  570. 8 => '<img alt="nyy" src="'.STATICURL.'image/poke/nyy.gif" class="vm" /> '.lang('home/template', 'poke_8'),
  571. 9 => '<img alt="gyq" src="'.STATICURL.'image/poke/gyq.gif" class="vm" /> '.lang('home/template', 'poke_9'),
  572. 10 => '<img alt="dyx" src="'.STATICURL.'image/poke/dyx.gif" class="vm" /> '.lang('home/template', 'poke_10'),
  573. 11 => '<img alt="yw" src="'.STATICURL.'image/poke/yw.gif" class="vm" /> '.lang('home/template', 'poke_11'),
  574. 12 => '<img alt="ppjb" src="'.STATICURL.'image/poke/ppjb.gif" class="vm" /> '.lang('home/template', 'poke_12'),
  575. 13 => '<img alt="yyk" src="'.STATICURL.'image/poke/yyk.gif" class="vm" /> '.lang('home/template', 'poke_13')
  576. );
  577. return isset($icons[$iconid]) ? $icons[$iconid] : $icons[0];
  578. }
  579. function interval_check($type) {
  580. global $_G;
  581. $waittime = 0;
  582. if(checkperm('disablepostctrl')) {
  583. return $waittime;
  584. }
  585. if($_G['setting']['floodctrl']) {
  586. space_merge($_G['member'], 'status');
  587. getuserprofile('lastpost');
  588. $waittime = $_G['setting']['floodctrl'] - ($_G['timestamp'] - $_G['member']['lastpost']);
  589. }
  590. return $waittime;
  591. }
  592. function geturltitle($link, $charset = '') {
  593. $title = $linkcharset = '';
  594. $linkstr = gzfile($link);
  595. $linkstr = implode('', $linkstr);
  596. if(!$charset) {
  597. preg_match('/<meta [^>]*charset="?(.*)"/i', $linkstr, $linkcharset);
  598. $charset = strtolower($linkcharset[1]);
  599. }
  600. if(!$charset) {
  601. return $title;
  602. }
  603. if($charset != strtolower(CHARSET)) {
  604. $linkstr = diconv($linkstr, $charset);
  605. }
  606. if(!empty($linkstr) && preg_match('/\<title\>(.*)\<\/title\>/i', $linkstr, $title)) {
  607. $tmptitle = explode('_', $title[1]);
  608. if($title[1] == $tmptitle[0]) {
  609. $tmptitle = explode('-', $title[1]);
  610. }
  611. $title = trim($tmptitle[0]);
  612. }
  613. return $title;
  614. }
  615. function allowverify($vid) {
  616. global $_G;
  617. if(empty($_G['setting']['verify'])) {
  618. loadcache('setting');
  619. }
  620. $allow = false;
  621. $vid = 0 < $vid && $vid < 8 ? intval($vid) : 0;
  622. if($vid) {
  623. $setting = $_G['setting']['verify'][$vid];
  624. if($setting['available'] && (empty($setting['groupid']) || in_array($_G['groupid'], $setting['groupid']))) {
  625. $allow = true;
  626. }
  627. } else {
  628. foreach($_G['setting']['verify'] as $key => $setting) {
  629. if($setting['available'] && (empty($setting['groupid']) || in_array($_G['groupid'], $setting['groupid']))) {
  630. $allow = true;
  631. break;
  632. }
  633. }
  634. }
  635. return $allow;
  636. }
  637. ?>