Example #1
0
	login_do_login($oauth_token);


	#
	# good to go - fetch some player info
	#

	$ret = curl_api_call('/simple/auth.check', array(
		'oauth_token'	=> $oauth_token,
	));

	db_insert_dupe('glitchmash_players', array(
		'tsid'		=> AddSlashes($ret['player_tsid']),
		'date_added'	=> time(),
		'oauth_token'	=> AddSlashes($oauth_token),
		'name'		=> AddSlashes($ret['player_name']),
	), array(
		'oauth_token'	=> AddSlashes($oauth_token),
		'name'		=> AddSlashes($ret['player_name']),
	));


	#
	# player is logged in - go and import their avatar
	#

	$tsid_enc = AddSlashes($ret['player_tsid']);

	list($count) = db_list(db_fetch("SELECT COUNT(*) FROM glitchmash_avatars WHERE player_tsid='$tsid_enc'"));

	if ($count){
Example #2
0
			#
			# this vote counts - store it
			#

			$win = intval($win);
			$lose = intval($lose);

			$prev_ids = array($win, $lose);
			$hash = hash_ids($win, $lose);

			db_insert_dupe('glitchmash_votes', array(
				'player_tsid'	=> AddSlashes($cfg['user']['tsid']),
				'hash'		=> AddSlashes($hash),
				'win_id'	=> $win,
				'lose_id'	=> $lose,
				'date_updated'	=> time(),
			), array(
				'win_id'	=> $win,
				'lose_id'	=> $lose,
				'date_updated'	=> time(),
			));


			#
			# update counts for the 2 choices
			#

			list($wins1) = db_list(db_fetch("SELECT COUNT(*) FROM glitchmash_votes WHERE win_id=$win"));
			list($wins2) = db_list(db_fetch("SELECT COUNT(*) FROM glitchmash_votes WHERE win_id=$lose"));

			list($losses1) = db_list(db_fetch("SELECT COUNT(*) FROM glitchmash_votes WHERE lose_id=$win"));
Example #3
0
	#
	# now store the avatar
	#

	$hash = array(
		'player_tsid'	=> AddSlashes($cfg['user']['tsid']),
		'url'		=> AddSlashes($ret['avatar_172']),
		'date_added'	=> time(),
		'date_updated'	=> time(),
		'details'	=> AddSlashes(serialize($avatar)),
	);

	$hash2 = $hash;
	unset($hash2['date_added']);

	db_insert_dupe('glitchmash_avatars', $hash, $hash2);


	#
	# mark only the latest one as active
	#

	$tsid_enc = AddSlashes($cfg['user']['tsid']);

	list($latest_id) = db_list(db_fetch("SELECT id FROM glitchmash_avatars WHERE player_tsid='$tsid_enc' ORDER BY date_updated DESC LIMIT 1"));

	$latest_id = intval($latest_id);

	db_write("UPDATE glitchmash_avatars SET is_active=0 WHERE player_tsid='$tsid_enc' AND id!=$latest_id");
	db_write("UPDATE glitchmash_avatars SET is_active=1 WHERE player_tsid='$tsid_enc' AND id=$latest_id");