Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.14 KB | None | 0 0
  1. <?php
  2. $root_path = './../';
  3. $gallery_path = './';
  4. define('PHPBB_ROOT_PATH', $root_path);
  5.  
  6. define('IN_PHPBB', true);
  7. define('IN_GALLERY', true);
  8. $phpbb_root_path = PHPBB_ROOT_PATH;
  9. $phpEx = substr(strrchr(__FILE__, '.'), 1);
  10. include($root_path . 'common_site.php');
  11.  
  12. $template->assign_vars(array(
  13. 'PAGE_TITLE' => 'Art Gallery - NintendoLand',
  14. 'BREADCRUMBS' => '&#187; <a href="index.php">Art Gallery</a>',
  15. 'U_SUBMIT' => append_sid("{$gallery_path}index.$phpEx", 'mode=agreement'),
  16. 'U_BROWSE' => append_sid("{$gallery_path}index.$phpEx", 'mode=browse'),
  17. ));
  18.  
  19. if($user->data['user_id'] == ANONYMOUS)
  20. {
  21. $template->assign_vars(array(
  22. 'NOT_ALLOWED' => true,
  23. ));
  24. }
  25.  
  26. $submit = request_var('submit', '');
  27. $mode = request_var('mode', '');
  28.  
  29. if($mode != '')
  30. {
  31. switch($mode)
  32. {
  33. case 'upload' :
  34. if($submit != '')
  35. {
  36. include( $root_path . 'includes/functions_posting.' . $phpEx );
  37. include( $root_path . 'includes/message_parser.' . $phpEx );
  38. include( $root_path . 'includes/mcp/mcp_queue.' . $phpEx );
  39.  
  40. $aMimeAllowed = array(
  41. 'image/gif' => 0,
  42. 'image/jpeg' => 0,
  43. 'image/png' => 0,
  44. 'image/bmp' => 0,
  45. 'image/pjpeg' => 0
  46. );
  47.  
  48. $sError = '';
  49. if(!in_array($aMimeAllowed, $_FILES['file']['type']))
  50. {
  51. $sError = 'File type '.$_FILES['file']['type'].' is not allowed.';
  52. }
  53. else
  54. {
  55. if($_FILES['file']['error'] == 0 )
  56. {
  57. // Reduce redundancy, use variables for same concatenations
  58. $sTarget= 'artwork/' . $_FILES['file']['name'];
  59. if(!file_exists($sTarget))
  60. {
  61. $template-> assign_vars(array(
  62. 'FNAME' => $_FILES['file']['name'],
  63. 'FTYPE'=> $_FILES['file']['type'],
  64. 'FSIZE'=> sprintf( '%.2f KiB', $_FILES['file']['size']/ 1024 ) // Always print 2 decimals
  65. ));
  66.  
  67. if(!move_uploaded_file($_FILES['file']['tmp_name'], $sTarget))
  68. {
  69. $sError = 'Error moving file on server!';
  70. }
  71. else
  72. {
  73.  
  74. }
  75. }
  76. else
  77. {
  78. $sError= $_FILES['file']['name'] . ' already exists.';
  79. }
  80. }
  81. else
  82. {
  83. $sError= 'Error: ' . $_FILES['file']['error'] . '<br />';
  84. }
  85. }
  86. }
  87.  
  88. $template->assign_vars(array(
  89. 'IN_UPLOAD' => true,
  90. ));
  91. break;
  92.  
  93. case 'browse' :
  94.  
  95. break;
  96.  
  97. case 'agreement' :
  98. $template->assign_vars(array(
  99. 'IN_AGREEMENT' => true,
  100. 'U_ART_SUBMISSION' => append_sid("{$gallery_path}index.$phpEx", 'mode=upload'),
  101. ));
  102.  
  103. $sql = 'SELECT * FROM phpbb_gallery_types';
  104. $result = $db->sql_query($sql);
  105. while($row = $db->sql_fetchrow($result))
  106. {
  107. $template->assign_block_vars('types', array(
  108. 'S_TYPE_ID' => $row['type_id'],
  109. 'S_TYPE_NAME' => $row['type_name'],
  110. ));
  111. }
  112.  
  113. $count = 1;
  114. $sql = 'SELECT * FROM phpbb_gallery_genres';
  115. $result = $db->sql_query($sql);
  116. while($row = $db->sql_fetchrow($result))
  117. {
  118. if($count % 2)
  119. {
  120. $template->assign_vars(array(
  121. 'IS_EVEN' => true,
  122. ));
  123. }
  124. else
  125. {
  126. $template->assign_vars(array(
  127. 'IS_ODD' => true,
  128. ));
  129. }
  130.  
  131. $template->assign_block_vars('genres', array(
  132. 'S_GENRE_ID' => $row['genre_id'],
  133. 'S_GENRE_NAME' => $row['genre_name'],
  134. ));
  135.  
  136. $count++;
  137. }
  138.  
  139.  
  140.  
  141. break;
  142.  
  143. default :
  144. $template->assign_vars(array(
  145. 'IN_DEFAULT' => true,
  146. ));
  147. break;
  148. }
  149. }
  150. else
  151. {
  152. $template->assign_vars(array(
  153. 'IN_DEFAULT' => true,
  154. ));
  155.  
  156. $sql = "SELECT g.*, u.username, u.user_id
  157. FROM phpbb_gallery g
  158. JOIN " . USERS_TABLE . " u
  159. ON g.art_author = u.user_id";
  160. $result = $db->sql_query($sql);
  161.  
  162. while($row = $db->sql_fetchrow($result))
  163. {
  164. $template->assign_block_vars('recent2', array(
  165. 'A_ID' => $row['art_id'],
  166. 'A_TITLE' => $row['art_title'],
  167. 'A_AUTHOR' => $row['username'],
  168. 'A_ART' => $row['art_filename'],
  169. 'A_DATE' => $user->format_date($row['art_time'], 'D M, Y'),
  170. ));
  171. }
  172.  
  173. }
  174. /* ----------- End Mode ----------- */
  175.  
  176. $template->set_filenames(array(
  177. 'body' => 'gallery/index.html'
  178. ));
  179.  
  180. page_footer(false);
  181. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement