Пример #1
0
		if (count($fullname) > 0) { $fname = $fullname[0]; }
		if (count($fullname) > 1) { $lname = $fullname[1]; }
		$dataInsert['tw_id'] = $content->id;
		$dataInsert['fname'] = $fname;
		$dataInsert['lname'] = $lname;
		$dataInsert['tw_name'] = $content->screen_name;
		$dataInsert['avatar'] = $content->profile_image_url;
		$dataInsert['tw_oauth_token'] = $access_token['oauth_token'];
		$dataInsert['tw_oauth_token_secret'] = $access_token['oauth_token_secret'];


		$user = $DB->selectWhatWhere("*", "tw_id = " . $content->id);
		$update_success = 0;
		$user_id = 0;
		if (empty($user)) { 
			$update_success = $DB->addItemsArray($dataInsert);
			$user_id = $DB->getLastId(); 
		} else {
			$user_id = $user[0]["users"]["id"];
			$update_success = $DB->updateWhatWhereArray2($dataInsert, "id = " . $user_id);
		}
		if ($update_success == 0) {
			$_SESSION['status'] = 'error';			
		} else {			
			$_SESSION['user_id'] = $user_id;
			$_SESSION['twitter_uid'] = $content->id;
		}
		header('Location: ./index.php');
	} else {
		header('Location: ./clearsessions.php');
	}
Пример #2
0
<?php
	$filename = "songs.json";
	include('lib/config.php');
	include('lib/sqlquery.php');
	
	// get contents of a file into a string
	$handle = fopen($filename, "r");
	$contents = fread($handle, filesize($filename));
	fclose($handle);
	
	if ($contents) {
		$songs = json_decode($contents, true);
		if (array_key_exists('songs', $songs) and is_array($songs['songs'])) {
			$DB = new SQLQuery();
			$DB->chooseTable(DB_SONGS_TABLE);
			foreach($songs['songs'] as $song) {
				$dataInsert = array();
				$dataInsert['id'] = $song['id'];
				$dataInsert['title'] = $song['title'];
				$dataInsert['artist'] = $song['artist'];
				$dataInsert['album'] = $song['album'];
				$dataInsert['length'] = $song['length'];
				$dataInsert['filename'] = $song['filename'];
				$DB->addItemsArray($dataInsert);
				echo "Added " . $song['title'] . " by " . $song['artist'] . " to the database.<br />";
			}
		}
	}
?>