<?php
/* 
Module:       IBPArcade score submitting module for MyArcadePlugin Pro 
Author:       Daniel B.
Author URI:   http://netreview.de
Version:      1.01
*/

// --- SCORES --- //
$RFEE6FD8A6D4876C7A2B5478AEB8AEE3A      = strtolower($_GET['act']);
$R1C096022D5294397018415D5001BC89E  = strtolower($_GET['autocom']);
$R49FC76D0829BFAA538F6EFF77D3A3651       = strtolower($_GET['do']);

global $user_ID;
  
if ( ($RFEE6FD8A6D4876C7A2B5478AEB8AEE3A == 'arcade') || ($R1C096022D5294397018415D5001BC89E == 'arcade') ) {
  
  F627A0F242E003858EA19A5D9DD5EBE5A('IBP/PHPBB Game Submitted Data: ' ."\n". 'POST: ' . print_r($_POST, true) ."\n". 'GET: ' . print_r($_GET, true) );
  
  switch ($R49FC76D0829BFAA538F6EFF77D3A3651) {
    case 'verifyscore' : {
      // -- v3 and v32 score verification -- //
      $_SESSION['time']   = time();
      $_SESSION['rand1']  = rand(1, 100);
      $_SESSION['rand2']  = rand(1, 100);
      
      echo '&randchar=', $_SESSION['rand1'] ,'&randchar2=', $_SESSION['rand2'] ,'&savescore=1&blah=OK';
      
      F627A0F242E003858EA19A5D9DD5EBE5A('Verify Score: ' . print_r($_SESSION, true) );
      
      // End here for now..
      die();
    }
    break;
      
    case 'savescore': {
      // -- v3 and v32 score -- //
      F627A0F242E003858EA19A5D9DD5EBE5A('IBP/PHP Save Score');
    
      //$R9C65084CFC54EB0D266E6D073B818630 = get_option('myarcade_general');
      $R64151BCD211855F655EF77B7038C9FF3 = $_POST['gname'];
      $R69F05BD3024E3A18B29F11DF8A3E8C79 = $wpdb->get_row("SELECT * FROM ".MYARCADE_GAME_TABLE." WHERE slug = '$R64151BCD211855F655EF77B7038C9FF3' LIMIT 1");
      
      // Save only when session is started
      if ( isset($_SESSION['time']) ) {             
        // Check the session ( Allowed delay 10 sec for testing)
        if ( (time() - $_SESSION['time']) <= 10 ) {
          $RD94C2157798BCCE313068BF1BF25A119 = (float)(!empty($_POST['score']) ? $_POST['score'] : $_POST['gscore']);
          $R1F66B67A97583629581945D27A05AC03 = $RD94C2157798BCCE313068BF1BF25A119 * $_SESSION['rand1'] ^ $_SESSION['rand2'];               
          
          get_currentuserinfo();
                        
          // Check if this is the same user
          if ( (!empty($user_ID)) && ($user_ID == $_SESSION['uuid']) ) {
            
            if ($R1F66B67A97583629581945D27A05AC03 == $_POST['enscore']) {
              // Is this game published
              if ( !empty($R69F05BD3024E3A18B29F11DF8A3E8C79->postid) ) {
                
                if ( $R69F05BD3024E3A18B29F11DF8A3E8C79->highscore_type == 'high') {
                  $R56EA904D533235F889591E04DE8C6B68 = 'DESC';
                }
                else {
                  $R56EA904D533235F889591E04DE8C6B68 = 'ASC';
                } 
                
                // Collect needed information
                $R53740C11C1930560D0EC6A4938F16AD0 = array(
                  'session'   => $_SESSION['time'],
                  'date'      => date('Y-m-d'),
                  'datatype'  => 'number',
                  'game_tag'  => $R69F05BD3024E3A18B29F11DF8A3E8C79->game_tag,
                  'user_id'   => $user_ID,
                  'score'     => $RD94C2157798BCCE313068BF1BF25A119,
                  'sortorder' => $R56EA904D533235F889591E04DE8C6B68
                );  

                F007F675CEB78537E7BF8DAFCBBA7AEF0( $R53740C11C1930560D0EC6A4938F16AD0 );
              }
            } 
          } // end user id == session user id
        }
      }

      $RC91035FD8512F06F108CEE51D9F7F62F = get_permalink($R69F05BD3024E3A18B29F11DF8A3E8C79->postid);
      header( 'Location: '.$RC91035FD8512F06F108CEE51D9F7F62F);
      die();
    }
    break;
      
    case 'newscore': {
      // -- v2 and phpBB-Amod scores -- //
      F627A0F242E003858EA19A5D9DD5EBE5A('IBP/PHPBB New Score');

      $R64151BCD211855F655EF77B7038C9FF3 = trim(!empty($_POST['game_name']) ? $_POST['game_name'] : $_POST['gname']);
      $R69F05BD3024E3A18B29F11DF8A3E8C79 = $wpdb->get_row("SELECT * FROM ".MYARCADE_GAME_TABLE." WHERE slug = '$R64151BCD211855F655EF77B7038C9FF3' LIMIT 1");
      
      // User has to be logged in
      get_currentuserinfo();
                      
      // Check if this is the same user
      if ( !empty($user_ID) ) {
        $RD94C2157798BCCE313068BF1BF25A119 = (float)(!empty($_POST['score']) ? $_POST['score'] : $_POST['gscore']);
                      
        if ( empty($_SESSION['time']) ) {
          $RA337D38989275B85567BAE0C78786D01 = time();
        }
        else {
          $RA337D38989275B85567BAE0C78786D01 = $_SESSION['time'];
        } 
        
        if ( !empty($R69F05BD3024E3A18B29F11DF8A3E8C79) ) {                  
          if ( $R69F05BD3024E3A18B29F11DF8A3E8C79->highscore_type == 'high') {
            $R56EA904D533235F889591E04DE8C6B68 = 'DESC';
          }
          else {
            $R56EA904D533235F889591E04DE8C6B68 = 'ASC';
          }  
          
          // Collect needed information
          $R53740C11C1930560D0EC6A4938F16AD0 = array(
            'session'   => $RA337D38989275B85567BAE0C78786D01,
            'date'      => date('Y-m-d'),
            'datatype'  => 'number',
            'game_tag'  => $R69F05BD3024E3A18B29F11DF8A3E8C79->game_tag,
            'user_id'   => $user_ID,
            'score'     => $RD94C2157798BCCE313068BF1BF25A119,
            'sortorder' => $R56EA904D533235F889591E04DE8C6B68
          );  

          F007F675CEB78537E7BF8DAFCBBA7AEF0( $R53740C11C1930560D0EC6A4938F16AD0 );                
        }   
      } // end if user_ID

      $RC91035FD8512F06F108CEE51D9F7F62F = get_permalink($R69F05BD3024E3A18B29F11DF8A3E8C79->postid);
      header( 'Location: '.$RC91035FD8512F06F108CEE51D9F7F62F);
      die();           
    }
    break;
  }    
}
?>