inc_album.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. if (!defined('IN_MYMPS')) {
  3. exit('Forbidden');
  4. }
  5. !in_array($ac, array('upload', 'list', 'edit', 'delete')) && ($ac = 'list');
  6. $mymps_image = '';
  7. if (submit_check('album_submit')) {
  8. include MYMPS_DATA . '/config.inc.php';
  9. require_once MYMPS_INC . '/upfile.fun.php';
  10. $name_file = 'album_up';
  11. if ($ac == 'upload') {
  12. $album_maxpost = $group['album_maxpost'];
  13. $cur_album = mymps_count('member_album', ' WHERE userid = \'' . $s_uid . '\'');
  14. if ($album_maxpost <= $cur_album) {
  15. write_msg('', '?m=album&type=corp&error=49');
  16. exit();
  17. }
  18. if (empty($title)) {
  19. write_msg('', '?m=album&type=corp&ac=upload&error=28');
  20. }
  21. if ($_FILES[$name_file]['name']) {
  22. check_upimage($name_file);
  23. $destination = '/album/' . date('Ym') . '/';
  24. $mymps_image = start_upload($name_file, $destination, $mymps_global['cfg_upimg_watermark'], $mymps_mymps['cfg_memberalbum_limit']['width'], $mymps_mymps['cfg_memberalbum_limit']['height']);
  25. $sql = 'INSERT INTO `' . $db_mymps . 'member_album` (id,title,path,prepath,pubtime,userid)
  26. Values(\'\',\'' . $title . '\',\'' . $mymps_image[0] . '\',\'' . $mymps_image[1] . '\',\'' . $timestamp . '\',\'' . $s_uid . '\')';
  27. $db->query($sql);
  28. unset($destination);
  29. unset($mymps_image);
  30. }
  31. else {
  32. write_msg('', '?m=album&type=corp&ac=upload&error=29');
  33. }
  34. write_msg('', '?m=album&type=corp&ac=upload&success=12');
  35. }
  36. else if ($ac == 'edit') {
  37. if (empty($id)) {
  38. write_msg('', '?m=album&type=corp&ac=list&error=1');
  39. }
  40. if (empty($title)) {
  41. write_msg('', '?m=album&type=corp&ac=edit&error=28&id=' . $id);
  42. }
  43. if ($_FILES[$name_file]['name']) {
  44. check_upimage($name_file);
  45. $destination = '/album/' . date('Ym') . '/';
  46. $mymps_image = start_upload($name_file, $destination, 1, $mymps_mymps['cfg_memberalbum_limit']['width'], $mymps_mymps['cfg_memberalbum_limit']['height'], $path, $prepath);
  47. $path = $mymps_image[0];
  48. $prepath = $mymps_image[1];
  49. unset($destination);
  50. unset($mymps_image);
  51. }
  52. $db->query('UPDATE `' . $db_mymps . 'member_album` SET title = \'' . $title . '\',path = \'' . $path . '\', prepath = \'' . $prepath . '\',pubtime = \'' . $timestamp . '\' ' . $where . ' AND id = \'' . $id . '\'');
  53. write_msg('', '?m=album&type=corp&ac=edit&success=8&id=' . $id);
  54. }
  55. }
  56. else {
  57. if ($ac == 'upload') {
  58. $album_maxpost = $group['album_maxpost'];
  59. $cur_album = mymps_count('member_album', ' WHERE userid = \'' . $s_uid . '\'');
  60. if ($album_maxpost <= $cur_album) {
  61. write_msg('', '?m=album&type=corp&error=49');
  62. exit();
  63. }
  64. }
  65. else if ($ac == 'list') {
  66. $sql = 'SELECT * FROM ' . $db_mymps . 'member_album ' . $where . ' ORDER BY id DESC';
  67. $rows_num = mymps_count('member_album', $where);
  68. $param = setParam(array('m', 'type', 'ac'));
  69. $album = page1($sql);
  70. }
  71. else if ($ac == 'edit') {
  72. if (empty($id)) {
  73. write_msg('', '?m=album&type=corp&error=1');
  74. }
  75. $edit = $db->getRow('SELECT id,title,path,prepath FROM `' . $db_mymps . 'member_album` ' . $where . ' AND id = \'' . $id . '\'');
  76. if (empty($edit['id'])) {
  77. write_msg('', '?m=album&type=corp&ac=list&error=27');
  78. }
  79. }
  80. else if ($ac == 'delete') {
  81. if (empty($id)) {
  82. write_msg('', '?m=album&type=corp&error=1');
  83. }
  84. if (!($row = $db->getRow('SELECT path,prepath FROM `' . $db_mymps . 'member_album` ' . $where . ' AND id = \'' . $id . '\''))) {
  85. write_msg('', '?m=album&type=corp&ac=list&error=27');
  86. }
  87. else {
  88. @unlink(MYMPS_ROOT . $row['path']);
  89. @unlink(MYMPS_ROOT . $row['prepath']);
  90. $res = $db->query('DELETE FROM `' . $db_mymps . 'member_album` ' . $where . ' AND id = \'' . $id . '\'');
  91. }
  92. write_msg('', '?m=album&type=corp&ac=list&success=8');
  93. }
  94. $location = location('corp');
  95. include mymps_tpl('album_' . (in_array($ac, array('upload', 'edit')) ? 'upload' : $ac));
  96. unset($album);
  97. }
  98. ?>