PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/apps/photos/action/view.php

https://bitbucket.org/johnroyer/phpwind8.7
PHP | 277 lines | 255 code | 20 blank | 2 comment | 81 complexity | beca2b86f57d9e05a340e7d84e3e9db7 MD5 | raw file
  1. <?php
  2. !defined('A_P') && exit('Forbidden');
  3. $basename = 'apps.php?q='.$q.'&uid='.$uid.'&';
  4. empty($space) && Showmsg('您訪問的空間不存在!');
  5. //* include_once pwCache::getPath(D_P . 'data/bbscache/o_config.php');
  6. pwCache::getData(D_P . 'data/bbscache/o_config.php');
  7. $whiteList = array(
  8. 'own',
  9. 'albumcheck',
  10. 'editalbum',
  11. 'album',
  12. 'next',
  13. 'pre',
  14. 'view',
  15. 'delphoto',
  16. 'delalbum',
  17. 'viewalbum',
  18. 'getallowflash',
  19. 'createajax'
  20. );
  21. if (!in_array($a,$whiteList)) {
  22. $a = 'own';
  23. }
  24. if ($a == 'own' && $indexRight) {
  25. list($count,$albumdb) = $photoService->getAlbumBrowseList();
  26. $pageCount = ceil($count / $perpage);
  27. $page = validatePage($page,$pageCount);
  28. $pages = numofpage($count, $page,$pageCount, "{$basename}a=$a&uid=$uid&");
  29. } elseif ($a == 'albumcheck') {
  30. S::gp(array('aid'), null, 2);
  31. S::gp(array('viewpwd'));
  32. $album = $photoService->getAlbumInfo($aid);
  33. if (empty($album)) {
  34. echo "data_error";
  35. ajax_footer();
  36. }
  37. if (!$viewpwd) {
  38. echo "empty";
  39. ajax_footer();
  40. }
  41. $viewpwd = md5($viewpwd);
  42. if ($album['albumpwd'] == $viewpwd) {
  43. Cookie('albumview_' . $album['aid'], PwdCode($viewpwd), time()+24*3600);
  44. echo "success";
  45. } else {
  46. echo "fail";
  47. }
  48. ajax_footer();
  49. } elseif ($a == 'editalbum') {
  50. define('AJAX', 1);
  51. define('F_M',true);
  52. banUser();
  53. S::gp(array('aid'));
  54. empty($aid) && Showmsg('data_error');
  55. $albumInfo = $photoService->getAlbumInfo($aid);
  56. if (empty($albumInfo) || $albumInfo['atype'] <> 0 || ($albumInfo['ownerid'] <> $winduid && !$photoService->isPermission())) {
  57. Showmsg('data_error');
  58. }
  59. if (empty($_POST['step'])) {
  60. ${'select_'.$albumInfo['private']} = 'selected';
  61. require_once PrintEot('m_ajax_photos');
  62. ajax_footer();
  63. } else {
  64. require_once(R_P.'require/postfunc.php');
  65. S::gp(array('aname','aintro','pwd','repwd'),'P');
  66. S::gp(array('private'),'P',2);
  67. !$aname && Showmsg('colony_aname_empty');
  68. if (strlen($aname)>24) Showmsg('colony_aname_toolang');
  69. if (strlen($aintro)>255) Showmsg('colony_aintro_toolang');
  70. if ($private == 3 && !$pwd && !$albumInfo['albumpwd']) {
  71. Showmsg('photo_password_add');
  72. }
  73. if ($pwd) {
  74. if (strlen($pwd) < 3 || strlen($pwd) > 15) {
  75. Showmsg('photo_password_minlimit');
  76. }
  77. $S_key = array("\\",'&',' ',"'",'"','/','*',',','<','>',"\r","\t","\n",'#','%','?');
  78. if (str_replace($S_key,'',$pwd) != $pwd) {
  79. Showmsg('illegal_password');
  80. }
  81. if ($pwd != $repwd) {
  82. Showmsg('password_confirm');
  83. }
  84. $pwd = md5($pwd);
  85. }
  86. require_once(R_P.'require/bbscode.php');
  87. $wordsfb = L::loadClass('FilterUtil', 'filter');
  88. if (($banword = $wordsfb->comprise($aname)) !== false) {
  89. Showmsg('title_wordsfb');
  90. }
  91. if (($banword = $wordsfb->comprise($aintro)) !== false) {
  92. Showmsg('content_wordsfb');
  93. }
  94. if ($private == 3 && !$pwd && $albumInfo['albumpwd']) {
  95. $pwd = $albumInfo['albumpwd'];
  96. }
  97. $data = array('aname' => $aname,
  98. 'aintro' => $aintro,
  99. 'private' => $private,
  100. 'albumpwd' => $pwd
  101. );
  102. $photoService->updateAlbumInfo($aid,$data);
  103. refreshto("{$basename}a=own",'operate_success');
  104. }
  105. } elseif ($a == 'album') {
  106. S::gp(array('aid'), null, 2);
  107. $cnpho = array();
  108. $result = $photoService->getPhotoListByAid($aid);
  109. if(!is_array($result)){
  110. $result == 'mode_o_photos_private_3' && refreshto($basename, 'mode_o_photos_private_3');
  111. Showmsg($result);
  112. }
  113. if($indexRight && !$photoRight ){
  114. Showmsg('該空間相冊設置隱私,您沒有權限查看!');
  115. }
  116. list($album,$cnpho) = $result;
  117. $count = $album['photonum'];
  118. $pageCount = ceil($count / $perpage);
  119. $page = validatePage($page,$pageCount);
  120. $pages = numofpage($count, $page,$pageCount, "{$basename}a=$a&aid=$aid&uid=$uid&");
  121. $siteName = getSiteName('o');
  122. $uSeo = USeo::getInstance();
  123. $uSeo->set(
  124. $album['aname'] . ' - ' . $space['name'] . ' - ' . $siteName,
  125. '相冊',
  126. $album['aname'] . ',' . $siteName
  127. );
  128. $ouserdataService = L::loadClass('Ouserdata', 'sns'); /* @var $ouserdataService PW_Ouserdata */
  129. $myOuserData = $ouserdataService->get($album['ownerid']);
  130. $weiboPriv = false;
  131. (!$myOuserData['index_privacy'] && !$myOuserData['photos_privacy'] && !$album['private']) && $weiboPriv = true;
  132. } elseif ($a == 'view') {
  133. S::gp(array('pid'));
  134. $result = $photoService->viewPhoto($pid);
  135. if(!is_array($result)){
  136. $result == 'mode_o_photos_private_3' && refreshto($basename, 'mode_o_photos_private_3');
  137. Showmsg($result);
  138. }
  139. list($photo,$nearphoto,$prePid,$nextPid) = $result;
  140. $username = $photo['owner'];
  141. $aid = $photo['aid'];
  142. $album = $photoService->albumViewRight($aid);
  143. if(!is_array($album)){
  144. Showmsg($album);
  145. }
  146. $page = (int)S::getGP('page');
  147. $page < 1 && $page = 1;
  148. $url = $basename.'a=view&pid='.$pid.'&';
  149. require_once(R_P.'require/bbscode.php');
  150. list($commentdb,$subcommentdb,$pages) = getCommentDbByTypeid('photo',$pid,$page,$url);
  151. $comment_type = 'photo';
  152. $comment_typeid = $pid;
  153. $siteName = getSiteName('o');
  154. $uSeo = USeo::getInstance();
  155. $uSeo->set(
  156. $photo['aname'] . ' - ' . $space['name'] . ' - ' . $siteName,
  157. '相冊',
  158. $photo['aname'] . ',' . $siteName
  159. );
  160. $ouserdataService = L::loadClass('Ouserdata', 'sns'); /* @var $ouserdataService PW_Ouserdata */
  161. $myOuserData = $ouserdataService->get($photo['ownerid']);
  162. $weiboPriv = false;
  163. (!$myOuserData['index_privacy'] && !$myOuserData['photos_privacy'] && !$photo['private']) && $weiboPriv = true;
  164. } elseif ($a == 'next') {
  165. define('AJAX',1);
  166. S::gp(array('pid'));
  167. $status = $photoService->getNextPhoto($pid);
  168. echo $status;
  169. ajax_footer();
  170. } elseif ($a == 'pre') {
  171. define('AJAX',1);
  172. S::gp(array('pid'));
  173. $status = $photoService->getPrevPhoto($pid);
  174. echo $status;
  175. ajax_footer();
  176. }elseif ($a == 'delphoto') {
  177. define('AJAX','1');
  178. S::gp(array('pid'));
  179. $photo = $photoService->delPhoto($pid);
  180. if(empty($photo)){
  181. Showmsg('data_error');
  182. }
  183. $weiboService = L::loadClass('weibo','sns'); /* @var $weiboService PW_Weibo */
  184. $weibo = $weiboService->getWeibosByObjectIdsAndType($pid,'photos');
  185. if($weibo){
  186. $weiboService->deleteWeibos($weibo['mid']);
  187. }
  188. $affected_rows = delAppAction('photo',$pid) + 1;
  189. countPosts("-$affected_rows");
  190. //積分變動
  191. require_once(R_P.'require/credit.php');
  192. $o_photos_creditset = unserialize($o_photos_creditset);
  193. $creditset = getCreditset($o_photos_creditset['Deletephoto'],false);
  194. $creditset = array_diff($creditset,array(0));
  195. if (!empty($creditset)) {
  196. require_once(R_P.'require/postfunc.php');
  197. $credit->sets($photo['uid'],$creditset,true);
  198. updateMemberid($photo['uid'],false);
  199. }
  200. if ($creditlog = unserialize($o_photos_creditlog)) {
  201. addLog($creditlog['Deletephoto'],$photo['uploader'],$photo['uid'],'photos_Deletephoto');
  202. }
  203. updateUserAppNum($photo['uid'],'photo','minus');
  204. echo 'ok'."\t".$photo['aid'];
  205. ajax_footer();
  206. } elseif ($a == 'delalbum') {
  207. define('AJAX', 1);
  208. define('F_M',true);
  209. S::gp(array('aid'), null, 2);
  210. $album = $photoService->getAlbumInfo($aid);
  211. if (empty($album) || ($album['ownerid'] != $winduid && !$photoService->isDelRight())) {
  212. Showmsg('data_error');
  213. }
  214. if (empty($_POST['step'])) {
  215. require_once PrintEot('m_ajax_photos');
  216. ajax_footer();
  217. } else {
  218. $photoService->delAlbum($aid);
  219. updateUserAppNum($album['ownerid'],'photo','minus',$album['photonum']);
  220. echo getLangInfo('msg','operate_success') . "\tjump\t{$basename}";
  221. ajax_footer();
  222. }
  223. } elseif ($a == 'viewalbum') {
  224. define('AJAX', 1);
  225. define('F_M',true);
  226. S::gp(array('aid'));
  227. $aid = (int)$aid;
  228. empty($aid) && Showmsg('data_error');
  229. require_once PrintEot('m_ajax_photos');
  230. ajax_footer();
  231. } elseif ($a == 'createajax') {
  232. define('AJAX', 1);
  233. define('F_M',true);
  234. banUser();
  235. S::gp(array('job'));
  236. require_once PrintEot('m_ajax_photos');
  237. ajax_footer();
  238. } elseif ($a == 'getallowflash') {
  239. define('AJAX', 1);
  240. define('F_M',true);
  241. S::gp(array('aid'));
  242. $aid = (int)$aid;
  243. if ($aid) {
  244. $photonums = $photoService->getAlbumInfo($aid);
  245. $o_maxphotonum && $photonums >= $o_maxphotonum && Showmsg('colony_photofull');
  246. if ($o_maxphotonum) {
  247. $allowmutinum = $o_maxphotonum - $photonums;
  248. } else {
  249. $allowmutinum = 'infinite';
  250. }
  251. }
  252. echo "ok\t$allowmutinum";
  253. ajax_footer();
  254. }
  255. require_once PrintEot('m_space_photos');
  256. pwOutPut();
  257. ?>