Advertisement
Guest User

Activity Points

a guest
Oct 19th, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.32 KB | None | 0 0
  1. <?php
  2. // In Game Activity Points
  3. // by DrMath
  4. // ######################## SET PHP ENVIRONMENT ###########################
  5. error_reporting(E_ALL & ~E_NOTICE);
  6.  
  7. // #################### PRE-CACHE TEMPLATES AND DATA ######################
  8. $phrasegroups = array('style');
  9. $specialtemplates = array('products');
  10.  
  11. // ########################## REQUIRE BACK-END ############################
  12. require_once('./global.php');
  13. require_once(DIR . '/includes/adminfunctions_template.php');
  14.  
  15. $this_script = 'iga_points';
  16.  
  17. $rpm_ver = 1.0;
  18.  
  19. $rpm_mouseover_fontcolor = '#D04850';
  20.  
  21. // ######################## CHECK ADMIN PERMISSIONS #######################
  22. if (!can_administer('canadminusers'))
  23. {
  24.     print_cp_no_permission();
  25. }
  26.  
  27. print_cp_header();
  28. echo "<div class='pagetitle'>In Game Activity System</div>";
  29.  
  30. //Possible Point Values
  31. $pointreasons = array("Attended a Gamenight (+15)", "Attended a Contest/Torunament (+25)");
  32.  
  33. /////////////////////// front page
  34. if ( empty($_POST['do']) ) {
  35.     print_form_header($this_script, 'add');
  36.     print_table_header('Add Points');
  37.     print_label_row('Notice:', 'Select the point value based on the event.');
  38.     print_select_row('Points', 'points', $pointreasons);
  39.     print_label_row('Users:', 'Input the usernames of all the users you wish to give the above points to. You must separate names using a semicolon (;).');
  40.     print_textarea_row('Users', 'users','',12,100,false,false);
  41.     print_submit_row('Add Points');
  42.    
  43.     ////////////////////// edit points
  44.     print_form_header($this_script, 'edit');
  45.     print_table_header('Edit Points');
  46.     print_label_row('Username:', 'Enter the username of who you want to edit the points value of.');
  47.     print_input_row('Username', 'username');
  48.     print_submit_row('Edit Points');
  49. }
  50.  
  51. /////////////////////// add
  52. if ( $_POST['do'] == 'add' ) {
  53.    
  54.     if ( empty($_POST['points']) OR empty($_POST['users']) ) { rpm_print_stop_back('Please be sure every required field is filled out before submitting.'); }
  55.    
  56.     $vbulletin->input->clean_array_gpc('p', array(
  57.         'points'         => TYPE_UNIT,
  58.         'users'          => TYPE_STR
  59.         ));
  60.    
  61.     $apoints = $vbulletin->GPC['points'];
  62.     if ($apoints == 0) { $addpoints = 15; }
  63.     if ($apoints == 1) { $addpoints = 25; }
  64.     $ausers = $db->escape_string($vbulletin->GPC['users']);
  65.     $addusers = explode(";",$ausers);
  66.     //$adate = date("Y-m-d");
  67.    
  68.     foreach ($addusers as $u) {
  69.         $sql = "UPDATE " . TABLE_PREFIX . "user SET iga_points = iga_points + $addpoints, iga_lastpointsdate = NOW() WHERE username='$u[0]'";
  70.         $db->query_write($sql);
  71.     }
  72.    
  73.     define('CP_REDIRECT', 'iga_points.php');
  74.     print_stop_message('iga_points_added');
  75. }  
  76.  
  77. /////////////////////// edit
  78. if ( $_POST['do'] == 'edit' ) {
  79.    
  80.     if ( !isset($_POST['username']) ) { rpm_print_stop_back('Please be sure every required field is filled out before submitting.'); }
  81.    
  82.    
  83.     $vbulletin->input->clean_array_gpc('p', array(
  84.         'username'      => TYPE_STR
  85.         ));
  86.    
  87.     $edituser = $db->escape_string($vbulletin->GPC['username']);
  88.    
  89.     $sql = "SELECT iga_points FROM " . TABLE_PREFIX . "user WHERE username = '$edituser'";
  90.     $result = $db->query_read_slave($sql);
  91.     $cpoints = mysql_result($result,0);
  92.    
  93.     print_form_header($this_script, 'update');
  94.     print_table_header('Update '.$username.' Points');
  95.     echo "<input type='hidden' name='username' value='$edituser'>";
  96.     print_input_row('Points', 'points', $cpoints);
  97.     print_submit_row('Update Points');
  98. }
  99.  
  100. /////////////////////// add
  101. if ( $_POST['do'] == 'update' ) {
  102.    
  103.     if ( empty($_POST['username']) OR empty($_POST['points']) ) { rpm_print_stop_back('Please be sure every required field is filled out before submitting.'); }
  104.    
  105.     $vbulletin->input->clean_array_gpc('p', array(
  106.         'username'  => TYPE_STR,
  107.         'points'    => TYPE_UNIT
  108.         ));
  109.    
  110.     $uuser = $db->escape_string($vbulletin->GPC['username']);
  111.     $upoints = $vbulletin->GPC['points'];
  112.     //$udate = date("Y-m-d");
  113.    
  114.    
  115.     $sql = "UPDATE " . TABLE_PREFIX . "user SET iga_points=$upoints, iga_lastpointsdate=NOW() WHERE username = '$uuser'";
  116.     $db->query_write($sql);
  117.    
  118.     define('CP_REDIRECT', 'iga_points.php');
  119.     print_stop_message('iga_points_updated');
  120. }
  121.  
  122. print_cp_footer();
  123. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement