Просмотр файла admin/admin_money_payment.php

Размер файла: 5.86Kb
  1. <?php
  2. /***************************************************************************
  3. * mides.ru
  4. * -------------------
  5. ***************************************************************************/
  6. define('IN_PHPBB', true);
  7.  
  8. if( !empty($setmodules) )
  9. {
  10. $file = basename(__FILE__);
  11. $module['Магазин']['Выплаты пользователям'] = $file;
  12. return;
  13. }
  14.  
  15. $phpbb_root_path = '../';
  16. require($phpbb_root_path . 'extension.inc');
  17. require('./pagestart.' . $phpEx);
  18.  
  19. if ( !$board_config['pay_money'] )
  20. {
  21. message_die(GENERAL_MESSAGE, 'Система выплат на этом форуме отключена.');
  22. }
  23.  
  24. if ( isset($HTTP_POST_VARS['start1']) )
  25. {
  26. $start1 = intval($HTTP_POST_VARS['start1']);
  27. $start = (($start1 - 1) * $board_config['topics_per_page']);
  28. } else {
  29. $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
  30. $start = ($start < 0) ? 0 : $start;
  31. }
  32.  
  33. $template->set_filenames(array(
  34. 'body' => 'admin/admin_users_payment.tpl')
  35. );
  36.  
  37. if ( isset($HTTP_GET_VARS['cancel']) )
  38. {
  39. if ( empty($HTTP_GET_VARS[POST_USERS_URL]) || $HTTP_GET_VARS[POST_USERS_URL] == ANONYMOUS )
  40. {
  41. message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
  42. }
  43. $user = intval($HTTP_GET_VARS[POST_USERS_URL]);
  44.  
  45. $sql = "SELECT *
  46. FROM " . USERS_TABLE . "
  47. WHERE user_id = '$user'";
  48. if ( !$result = $db->sql_query($sql) )
  49. {
  50. message_die(GENERAL_ERROR, 'Could not obtain user information', '', __LINE__, __FILE__, $sql);
  51. }
  52. if ( !$row = $db->sql_fetchrow($result) )
  53. {
  54. message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
  55. }
  56. $earned = $row['user_money_earned'];
  57.  
  58. $sql = "UPDATE " . USERS_TABLE . "
  59. SET user_money_earned = 0
  60. WHERE user_id = $user";
  61. if ( !($result = $db->sql_query($sql)) )
  62. {
  63. message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
  64. }
  65. $sql = "UPDATE " . CONFIG_TABLE . "
  66. SET config_value = config_value - $earned
  67. WHERE config_name = 'money_earned'";
  68. if ( !($result = $db->sql_query($sql)) )
  69. {
  70. message_die(GENERAL_ERROR, 'Could not update config table', '', __LINE__, __FILE__, $sql);
  71. }
  72.  
  73. message_die(GENERAL_MESSAGE, 'Заработанная юзером '.$row['username'].' сумма в '.$earned.' руб аннулирована.');
  74.  
  75. } elseif ( isset($HTTP_GET_VARS['pay']) ) {
  76. if ( empty($HTTP_GET_VARS[POST_USERS_URL]) || $HTTP_GET_VARS[POST_USERS_URL] == ANONYMOUS )
  77. {
  78. message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
  79. }
  80. $user = intval($HTTP_GET_VARS[POST_USERS_URL]);
  81.  
  82. $sql = "SELECT *
  83. FROM " . USERS_TABLE . "
  84. WHERE user_id = '$user'";
  85. if ( !$result = $db->sql_query($sql) )
  86. {
  87. message_die(GENERAL_ERROR, 'Could not obtain user information', '', __LINE__, __FILE__, $sql);
  88. }
  89. if ( !$row = $db->sql_fetchrow($result) )
  90. {
  91. message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
  92. }
  93. $earned = $row['user_money_earned'];
  94.  
  95. $sql = "UPDATE " . USERS_TABLE . "
  96. SET user_money_payment = user_money_payment + $earned, user_money_earned = 0
  97. WHERE user_id = $user";
  98. if ( !($result = $db->sql_query($sql)) )
  99. {
  100. message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
  101. }
  102. $sql = "UPDATE " . CONFIG_TABLE . "
  103. SET config_value = config_value + $earned
  104. WHERE config_name = 'money_payment'";
  105. if ( !($result = $db->sql_query($sql)) )
  106. {
  107. message_die(GENERAL_ERROR, 'Could not update config table', '', __LINE__, __FILE__, $sql);
  108. }
  109.  
  110. message_die(GENERAL_MESSAGE, 'Сумма в '.$earned.' руб помечена у юзера '.$row['username'].' как выплаченная.<br/>Перечислите ему эту сумму на кошелёк '.$row['user_purse'].'<br/>Скопировать:<br/><input type="text" value="'.$row['user_purse'].'" />');
  111.  
  112. } else {
  113.  
  114. $template->assign_vars(array(
  115. 'ALL_PAY' => $board_config['money_payment'],
  116. 'ALL_EARNED' => $board_config['money_earned'])
  117. );
  118.  
  119. $sql = "SELECT username, user_id, user_posts, user_money_earned
  120. FROM " . USERS_TABLE . "
  121. WHERE user_id <> " . ANONYMOUS . " AND user_money_earned > 0
  122. ORDER BY user_money_earned ASC LIMIT $start, " . $board_config['topics_per_page'];
  123. if( !($result = $db->sql_query($sql)) )
  124. {
  125. message_die(GENERAL_ERROR, 'Could not query users', '', __LINE__, __FILE__, $sql);
  126. }
  127.  
  128. if ( $row = $db->sql_fetchrow($result) )
  129. {
  130. $i = 0;
  131. do
  132. {
  133. $username = $row['username'];
  134. $user_money_earned = $row['user_money_earned'];
  135. $user_id = $row['user_id'];
  136. $posts = $row['user_posts'];
  137.  
  138. $template->assign_block_vars('memberrow', array(
  139. 'USERNAME' => $username,
  140. 'POSTS' => $posts,
  141. 'EARNED' => $user_money_earned,
  142. 'U_VIEWPROFILE' => append_sid("../profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$user_id"),
  143. 'U_PAY' => append_sid("admin_money_payment.$phpEx?pay&amp;" . POST_USERS_URL . "=$user_id"),
  144. 'U_CANCEL' => append_sid("admin_money_payment.$phpEx?cancel&amp;" . POST_USERS_URL . "=$user_id"))
  145. );
  146.  
  147. $i++;
  148. }
  149. while ( $row = $db->sql_fetchrow($result) );
  150. $db->sql_freeresult($result);
  151. } else {
  152. $template->assign_block_vars('no_pay', array() );
  153. }
  154.  
  155. $sql = "SELECT count(*) AS total
  156. FROM " . USERS_TABLE . "
  157. WHERE user_id <> " . ANONYMOUS . " AND user_money_earned > 0";
  158.  
  159. if ( !($result = $db->sql_query($sql)) )
  160. {
  161. message_die(GENERAL_ERROR, 'Error getting total users', '', __LINE__, __FILE__, $sql);
  162. }
  163.  
  164. if ( $total = $db->sql_fetchrow($result) )
  165. {
  166. $total_members = $total['total'];
  167. $pagination = generate_pagination("admin_money_payment.$phpEx", $total_members, $board_config['topics_per_page'], $start);
  168. }
  169. $db->sql_freeresult($result);
  170.  
  171. if ( $total_members > $board_config['topics_per_page'] )
  172. {
  173. $template->assign_vars(array(
  174. 'PAGINATION' => $pagination)
  175. );
  176. }
  177. $template->pparse('body');
  178. include('./page_footer_admin.'.$phpEx);
  179. }
  180.  
  181. ?>