PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/Quản lý website đọc truyện online PHP/users/album.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 131 lines | 94 code | 8 blank | 29 comment | 15 complexity | 80af2e0a6761bec25e8d8195e5062c24 MD5 | raw file
  1. <?php
  2. /**
  3. * @package JohnCMS
  4. * @link http://johncms.com
  5. * @copyright Copyright (C) 2008-2011 JohnCMS Community
  6. * @license LICENSE.txt (see attached file)
  7. * @version VERSION.txt (see attached file)
  8. * @author http://johncms.com/about
  9. */
  10. define('_IN_JOHNCMS', 1);
  11. require_once('../incfiles/core.php');
  12. if(!$website)
  13. require(''.$_SERVER['DOCUMENT_ROOT'].'/incfiles/websiteb.php');
  14. $lng_profile = core::load_lng('profile');
  15. $textl = $lng_profile['album'];
  16. $headmod = 'album';
  17. $max_album = 10;
  18. $max_photo = 200;
  19. $al = isset($_REQUEST['al']) ? abs(intval($_REQUEST['al'])) : NULL;
  20. $img = isset($_REQUEST['img']) ? abs(intval($_REQUEST['img'])) : NULL;
  21. /*
  22. -----------------------------------------------------------------
  23. Закрываем от неавторизованных юзеров
  24. -----------------------------------------------------------------
  25. */
  26. if (!$user_id) {
  27. require('../incfiles/head.php');
  28. echo functions::display_error($lng['access_guest_forbidden']);
  29. require('../incfiles/end.php');
  30. exit;
  31. }
  32. /*
  33. -----------------------------------------------------------------
  34. Получаем данные пользователя
  35. -----------------------------------------------------------------
  36. */
  37. $user = functions::get_user($user);
  38. if (!$user) {
  39. require('../incfiles/head.php');
  40. echo functions::display_error($lng['user_does_not_exist']);
  41. require('../incfiles/end.php');
  42. exit;
  43. }
  44. /*
  45. -----------------------------------------------------------------
  46. Функция голосований за фотографии
  47. -----------------------------------------------------------------
  48. */
  49. function vote_photo($arg = null) {
  50. global $lng, $datauser, $user_id, $ban;
  51. if ($arg) {
  52. $rating = $arg['vote_plus'] - $arg['vote_minus'];
  53. if ($rating > 0)
  54. $color = 'C0FFC0';
  55. elseif ($rating < 0)
  56. $color = 'F196A8';
  57. else
  58. $color = 'CCC';
  59. $out = '<div class="gray">' . $lng['rating'] . ': <span style="color:#000;background-color:#' . $color . '">&#160;&#160;<big><b>' . $rating . '</b></big>&#160;&#160;</span> ' .
  60. '(' . $lng['vote_against'] . ': ' . $arg['vote_minus'] . ', ' . $lng['vote_for'] . ': ' . $arg['vote_plus'] . ')';
  61. if ($user_id != $arg['user_id'] && !$ban && $datauser['postforum'] > 10 && $datauser['total_on_site'] > 1200) {
  62. // Проверяем, имеет ли юзер право голоса
  63. $req = mysql_query("SELECT * FROM `cms_album_votes` where `website` = '$website' AND `user_id` = '$user_id' AND `file_id` = '" . $arg['id'] . "' LIMIT 1");
  64. if (!mysql_num_rows($req))
  65. $out .= '<br />' . $lng['vote'] . ': <a href="album.php?act=vote&amp;mod=minus&amp;img=' . $arg['id'] . '">&lt;&lt; -1</a> | ' .
  66. '<a href="album.php?act=vote&amp;mod=plus&amp;img=' . $arg['id'] . '">+1 &gt;&gt;</a>';
  67. }
  68. $out .= '</div>';
  69. return $out;
  70. } else {
  71. return false;
  72. }
  73. }
  74. /*
  75. -----------------------------------------------------------------
  76. Переключаем режимы работы
  77. -----------------------------------------------------------------
  78. */
  79. $array = array (
  80. 'comments' => 'includes/album',
  81. 'delete' => 'includes/album',
  82. 'edit' => 'includes/album',
  83. 'image_delete' => 'includes/album',
  84. 'image_download' => 'includes/album',
  85. 'image_edit' => 'includes/album',
  86. 'image_move' => 'includes/album',
  87. 'image_upload' => 'includes/album',
  88. 'list' => 'includes/album',
  89. 'new_comm' => 'includes/album',
  90. 'show' => 'includes/album',
  91. 'sort' => 'includes/album',
  92. 'top' => 'includes/album',
  93. 'users' => 'includes/album',
  94. 'vote' => 'includes/album'
  95. );
  96. $path = !empty($array[$act]) ? $array[$act] . '/' : '';
  97. if (array_key_exists($act, $array) && file_exists($path . $act . '.php')) {
  98. require_once($path . $act . '.php');
  99. } else {
  100. require('../incfiles/head.php');
  101. $albumcount = mysql_result(mysql_query("SELECT COUNT(DISTINCT `user_id`) FROM `cms_album_files`where `website` = '$website'"), 0);
  102. $newcount = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_album_files` where `website` = '$website' AND `time` > '" . (time() - 259200) . "' AND `access` > '1'"), 0);
  103. echo '<div class="phdr"><b>' . $lng['photo_albums'] . '</b></div>' .
  104. '<div class="gmenu"><p>' .
  105. '<img src="http://img.infoviet.net/images/users.png" width="16" height="16"/>&#160;<a href="album.php?act=top">' . $lng_profile['new_photo'] . '</a> (' . $newcount . ')<br />' .
  106. '<img src="http://img.infoviet.net/images/guestbook.gif" width="16" height="16"/>&#160;<a href="album.php?act=top&amp;mod=last_comm">' . $lng_profile['new_comments'] . '</a>' .
  107. '</p></div>' .
  108. '<div class="menu">' .
  109. '<p><h3><img src="http://img.infoviet.net/images/users.png" width="16" height="16" class="left" />&#160;' . $lng['albums'] . '</h3><ul>' .
  110. '<li><a href="album.php?act=users">' . $lng_profile['album_list'] . '</a> (' . $albumcount . ')</li>' .
  111. '</ul></p>' .
  112. '<p><h3><img src="http://img.infoviet.net/images/rate.gif" width="16" height="16" class="left" />&#160;' . $lng['rating'] . '</h3><ul>' .
  113. '<li><a href="album.php?act=top&amp;mod=votes">' . $lng_profile['top_votes'] . '</a></li>' .
  114. '<li><a href="album.php?act=top&amp;mod=downloads">' . $lng_profile['top_downloads'] . '</a></li>' .
  115. '<li><a href="album.php?act=top&amp;mod=views">' . $lng_profile['top_views'] . '</a></li>' .
  116. '<li><a href="album.php?act=top&amp;mod=comments">' . $lng_profile['top_comments'] . '</a></li>' .
  117. '<li><a href="album.php?act=top&amp;mod=trash">' . $lng_profile['top_trash'] . '</a></li>' .
  118. '</ul></p>' .
  119. '</div>' .
  120. '<div class="phdr"><a href="index.php">' . $lng['users'] . '</a></div>';
  121. }
  122. require('../incfiles/end.php');
  123. ?>