OZEKI WEBOFFICE: Template for page '5118' not found! Create a template for this page!
<?php

	$upload_directory = 'files/';

	$zipfilename = $_FILES['file']['name'];
	if (is_uploaded_file($_FILES['file']['tmp_name']))
	{
		$upload_file = $upload_directory . basename($_FILES['file']['name']);
		move_uploaded_file($_FILES['file']['tmp_name'], $upload_file);
	}
	
	// Save some data into MySQL database
	function LogError($error)
	{
		$fp = fopen('file_upload_error.txt', 'a');
		fwrite($fp, $error);
		fclose($fp);
	}

	function ExecuteQuery($sql, $link)
	{
		$result = $link->query($sql);
		if (!$result) LogError('Invalid query: ' . mysql_error());
	} 

	$link = mysqli_connect("127.0.0.1", "root", "") or LogError("Error " . mysqli_error($link));

	$headers = apache_request_headers();
	$session_id = $link->real_escape_string($headers["SessionID"]);
	$dialed_number = $link->real_escape_string($headers["DialedNumber"]);
	$caller = $link->real_escape_string($headers["Caller"]);
	$duration_in_seconds = $link->real_escape_string($headers["DurationInSeconds"]);
	$filename = $link->real_escape_string($headers["Filename"]);
	$start_time = $link->real_escape_string($headers["StartTime"]);

	ExecuteQuery("CREATE DATABASE IF NOT EXISTS Ozeki_CallSessionRecordings;", $link);
	ExecuteQuery("CREATE TABLE IF NOT EXISTS Ozeki_CallSessionRecordings.CallSessions (session_id VARCHAR(10), dialed_number VARCHAR(20), caller VARCHAR(20), duration_in_seconds INT, filename VARCHAR(250), start_time VARCHAR(20));", $link);
	ExecuteQuery("INSERT INTO Ozeki_CallSessionRecordings.CallSessions (session_id, dialed_number, caller, duration_in_seconds, filename, start_time) VALUES ('" . $session_id . "', '" . $dialed_number .
				"', '" . $caller . "', " . $duration_in_seconds . ", '" . $filename . "', '" . $start_time . "');", $link);

	mysqli_close($link);
?>