spacecp_upload.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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: spacecp_upload.php 32041 2012-11-01 07:28:28Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $albumid = empty($_GET['albumid'])?0:intval($_GET['albumid']);
  12. if($_GET['op'] == 'recount') {
  13. $newsize = C::t('home_pic')->count_size_by_uid($_G['uid']);
  14. C::t('common_member_count')->update($_G['uid'], array('attachsize'=>$newsize));
  15. showmessage('do_success', 'home.php?mod=spacecp&ac=upload');
  16. }
  17. if(submitcheck('albumsubmit') && helper_access::check_module('album')) {
  18. if(!count($_POST['title'])) {
  19. showmessage('upload_select_image');
  20. }
  21. if($_POST['albumop'] == 'creatalbum') {
  22. $catid = intval($catid);
  23. $_POST['albumname'] = empty($_POST['albumname'])?'':getstr($_POST['albumname'], 50);
  24. $_POST['albumname'] = censor($_POST['albumname'], NULL, TRUE);
  25. if(is_array($_POST['albumname']) && $_POST['albumname']['message']) {
  26. showmessage($_POST['albumname']['message']);
  27. }
  28. if(empty($_POST['albumname'])) $_POST['albumname'] = gmdate('Ymd');
  29. $_POST['friend'] = intval($_POST['friend']);
  30. $_POST['target_ids'] = '';
  31. if($_POST['friend'] == 2) {
  32. $uids = array();
  33. $names = empty($_POST['target_names']) ? array() : explode(' ', str_replace(array(lang('spacecp', 'tab_space'), "\r\n", "\n", "\r"), ' ', $_POST['target_names']));
  34. if($names) {
  35. $uids = C::t('common_member')->fetch_all_uid_by_username($names);
  36. }
  37. if(empty($uids)) {
  38. $_POST['friend'] = 3;
  39. } else {
  40. $_POST['target_ids'] = implode(',', $uids);
  41. }
  42. } elseif($_POST['friend'] == 4) {
  43. $_POST['password'] = trim($_POST['password']);
  44. if($_POST['password'] == '') $_POST['friend'] = 0;
  45. }
  46. if($_POST['friend'] !== 2) {
  47. $_POST['target_ids'] = '';
  48. }
  49. if($_POST['friend'] !== 4) {
  50. $_POST['password'] = '';
  51. }
  52. $setarr = array();
  53. $setarr['albumname'] = $_POST['albumname'];
  54. $setarr['catid'] = intval($_POST['catid']);
  55. $setarr['uid'] = $_G['uid'];
  56. $setarr['username'] = $_G['username'];
  57. $setarr['dateline'] = $setarr['updatetime'] = $_G['timestamp'];
  58. $setarr['friend'] = $_POST['friend'];
  59. $setarr['password'] = $_POST['password'];
  60. $setarr['target_ids'] = $_POST['target_ids'];
  61. $setarr['depict'] = dhtmlspecialchars($_POST['depict']);
  62. $albumid = C::t('home_album')->insert($setarr ,true);
  63. if($setarr['catid']) {
  64. C::t('home_album_category')->update_num_by_catid('1', $setarr[catid]);
  65. }
  66. if(empty($space['albumnum'])) {
  67. $space['albums'] = C::t('home_album')->count_by_uid($space['uid']);
  68. C::t('common_member_count')->update($_G['uid'], array('albums' => $space['albums']));
  69. } else {
  70. C::t('common_member_count')->increase($_G['uid'], array('albums' => 1));
  71. }
  72. } else {
  73. $albumid = intval($_POST['albumid']);
  74. }
  75. $havetitle = trim(implode('', $_POST['title']));
  76. if(!empty($havetitle)) {
  77. foreach($_POST['title'] as $picid => $title) {
  78. $title = dhtmlspecialchars($title);
  79. C::t('home_pic')->update_for_uid($_G['uid'], $picid, array('title'=>$title, 'albumid' => $albumid));
  80. }
  81. } else {
  82. $picids = array_keys($_POST['title']);
  83. C::t('home_pic')->update_for_uid($_G['uid'], $picids, array('albumid' => $albumid));
  84. }
  85. if($albumid) {
  86. album_update_pic($albumid);
  87. }
  88. if(ckprivacy('upload', 'feed')) {
  89. require_once libfile('function/feed');
  90. feed_publish($albumid, 'albumid');
  91. }
  92. showmessage('upload_images_completed', "home.php?mod=space&uid=$_G[uid]&do=album&quickforward=1&id=".(empty($albumid)?-1:$albumid));
  93. } else {
  94. if(!checkperm('allowupload') || !helper_access::check_module('album')) {
  95. showmessage('no_privilege_upload', '', array(), array('return' => true));
  96. }
  97. cknewuser();
  98. $config = urlencode($_G['siteroot'].'home.php?mod=misc&ac=swfupload&op=config'.($_GET['op'] == 'cam'? '&cam=1' : ''));
  99. $albums = getalbums($_G['uid']);
  100. $actives = ($_GET['op'] == 'flash' || $_GET['op'] == 'cam')?array($_GET['op']=>' class="a"'):array('js'=>' class="a"');
  101. $maxspacesize = checkperm('maxspacesize');
  102. if(!empty($maxspacesize)) {
  103. space_merge($space, 'count');
  104. space_merge($space, 'field_home');
  105. $maxspacesize = $maxspacesize + $space['addsize'] * 1024 * 1024;
  106. $haveattachsize = ($maxspacesize < $space['attachsize'] ? '-':'').formatsize($maxspacesize - $space['attachsize']);
  107. } else {
  108. $haveattachsize = 0;
  109. }
  110. require_once libfile('function/friend');
  111. $groups = friend_group_list();
  112. loadcache('albumcategory');
  113. $category = $_G['cache']['albumcategory'];
  114. $categoryselect = '';
  115. if($category) {
  116. include_once libfile('function/portalcp');
  117. $categoryselect = category_showselect('album', 'catid', !$_G['setting']['albumcategoryrequired'] ? true : false, $_GET['catid']);
  118. }
  119. }
  120. $navtitle = lang('core', 'title_'.(!empty($_GET['op']) ? $_GET['op'] : 'normal').'_upload');
  121. require_once libfile('function/upload');
  122. $swfconfig = getuploadconfig($_G['uid'], 0, false);
  123. include_once template("home/spacecp_upload");
  124. ?>