function PhpArrayToJsObject_Recurse( $array ) {
	   // Base case of recursion: when the passed value is not a PHP array, just output it (in quotes).
	   if ( ! is_array( $array ) && !is_object( $array ) ) {
	       // Handle null specially: otherwise it becomes "".
	       if ( $array === null )
	       {
	           return 'null';
	       }
	       return '"' . javascript_escape( $array ) . '"';
	   }
	   // Open this JS object.
	   $retVal = "{";
	   // Output all key/value pairs as "$key" : $value
	   // * Output a JS object (using recursion), if $value is a PHP array.
	   // * Output the value in quotes, if $value is not an array (see above).
	   $first = true;
	   foreach ( $array as $key => $value ) {
	       // Add a comma before all but the first pair.
	       if ( ! $first ) {
	           $retVal .= ', ';
	       }
	       $first = false;
	       // Quote $key if it's a string.
	       if ( is_string( $key ) ) {
	           $key = '"' . $key . '"';
	       }
	       $retVal .= $key . ' : ' . PhpArrayToJsObject_Recurse( $value );
	   }
	   // Close and return the JS object.
	   return $retVal . "}";
	}
	function do_submit_player_log() {
		global $wgRequest, $psLogEveryPlayRequestPerUser;
		// do the insert into the userPlayerStats table:
		$dbr = wfGetDB( DB_READ );
		$cs = $wgRequest->getArray( 'cs', array() );
		// set up insert array:
		$insAry = array(
				'user_hash'			=> $wgRequest->getVal( 'uh' ),
				'file_url'			=> $wgRequest->getVal( 'purl' ),
				'b_user_agent'		=> $wgRequest->getVal( 'b_user_agent' ),
				// 'b_name'			=> $wgRequest->getVal( 'b_name' ),
				// 'b_version'			=> $wgRequest->getVal( 'b_version' ),
				// 'b_os'				=> $wgRequest->getVal( 'b_os' ),
				'flash_version'		=> $wgRequest->getVal( 'fv' ),
				'java_version'		=> $wgRequest->getVal( 'jv' ),
				'html5_video_enabled' => in_array( 'videoElement', $cs ),
				'java_enabled'		=> in_array( 'cortado', $cs ),
				'totem_enabled'		=> in_array( 'totem', $cs ),
				'flash_enabled'		=> in_array( 'flash', $cs ),
				'quicktime_enabled'	=> in_array( array( 'quicktime-mozilla', 'quicktime-activex' ), $cs ),
				'vlc_enabled'		=> in_array( array( 'vlc-mozilla', 'vlc-activex' ), $cs ),
				'mplayer_enabled'	=> in_array( 'mplayerplug-in', $cs ),
		);
		// check for user hash (don't collect multiple times for the same user)
		// $user_hash =
		$insert_id = $dbr->selectField( 'player_stats_log', 'id',
		array(	'user_hash' => $wgRequest->getVal( 'uh' ) ),
								'do_submit_player_log::Select User Hash' );
		// if the user_hash is not already in the db or if we are logging every request do INSERT
		if ( !$insert_id || $psLogEveryPlayRequestPerUser ) {
			$dbw = wfGetDB( DB_WRITE );
			$dbw->insert( 'player_stats_log', $insAry, 'mw_push_player_stats::Insert' );
			$insert_id = $dbw->insertId();
			$dbw->commit();
		}
		header( 'Content-Type: text/javascript' );
		if ( $wgRequest->getVal( 'cb' ) != null ) {
			return htmlspecialchars( $wgRequest->getVal( 'cb' ) ) . '(' . PhpArrayToJsObject_Recurse(
					array(
							'cb_inx' => htmlspecialchars( $wgRequest->getVal( 'cb_inx' ) ),
							'id' => htmlspecialchars( $insert_id )
					)
					) . ');';
		} else {
			return htmlspecialchars ( $insert_id );
		}
	}