VCL-1082 - This closes #8 - managementnode lastcheckin conversion to db epoch
diff --git a/managementnode/bin/install_perl_libs.pl b/managementnode/bin/install_perl_libs.pl
index 812b957..a61042d 100755
--- a/managementnode/bin/install_perl_libs.pl
+++ b/managementnode/bin/install_perl_libs.pl
@@ -85,6 +85,7 @@
 	'LWP::Protocol::https',
 	'Mail::Mailer',
 	'Mo::builder',
+	'Net::Ping::External',
 	'Net::SSH::Expect',
 	'Object::InsideOut',
 	'RPC::XML',
diff --git a/managementnode/lib/VCL/Module/OS.pm b/managementnode/lib/VCL/Module/OS.pm
index 276a3b7..2b74bf0 100644
--- a/managementnode/lib/VCL/Module/OS.pm
+++ b/managementnode/lib/VCL/Module/OS.pm
@@ -4355,6 +4355,10 @@
 				notify($ERRORS{'DEBUG'}, 0, "ignoring Subversion file: $mn_file_path");
 				next MN_FILE;
 			}
+			elsif ($mn_file_path =~ /\.gitignore/i) {
+				notify($ERRORS{'DEBUG'}, 0, "ignoring .gitignore file: $mn_file_path");
+				next MN_FILE;
+			}
 			elsif ($mn_file_path =~ /\/$other_architecture\//) {
 				notify($ERRORS{'DEBUG'}, 0, "ignoring file intended for different computer architecture: $mn_file_path");
 				next MN_FILE;
diff --git a/managementnode/lib/VCL/Module/OS/Linux/ManagementNode.pm b/managementnode/lib/VCL/Module/OS/Linux/ManagementNode.pm
index 84d3dd0..c3d0b6b 100644
--- a/managementnode/lib/VCL/Module/OS/Linux/ManagementNode.pm
+++ b/managementnode/lib/VCL/Module/OS/Linux/ManagementNode.pm
@@ -509,6 +509,13 @@
 			next;
 		}
 		
+		# Ignore the .gitignore files
+		if ($script_file_path =~ /\.gitignore/i) {
+			my $matching_section = $1;
+			notify($ERRORS{'DEBUG'}, 0, "ignoring gitignore file on management node from script directory '$matching_section': $script_file_path");
+			next;
+		}
+		
 		my $command = "chmod +x $script_file_path && $script_file_path $mn_json_file_path";
 		my ($exit_status, $output) = $self->execute($command);
 		if (!defined($output)) {
diff --git a/managementnode/lib/VCL/Module/OS/Windows.pm b/managementnode/lib/VCL/Module/OS/Windows.pm
index 3de1ad3..f245353 100644
--- a/managementnode/lib/VCL/Module/OS/Windows.pm
+++ b/managementnode/lib/VCL/Module/OS/Windows.pm
@@ -7027,7 +7027,12 @@
 	if (!$self->delete_files_by_pattern($NODE_CONFIGURATION_DIRECTORY, '.*\.svn.*')) {
 		notify($ERRORS{'WARNING'}, 0, "unable to delete Subversion files under: $NODE_CONFIGURATION_DIRECTORY");
 	}
-	
+
+	# Delete any GitIgnore files which may have been copied
+	if (!$self->delete_files_by_pattern($NODE_CONFIGURATION_DIRECTORY, '.*\.gitignore.*')) {
+		notify($ERRORS{'WARNING'}, 0, "unable to delete GitIgnore files under: $NODE_CONFIGURATION_DIRECTORY");
+	}
+
 	$self->set_file_owner($NODE_CONFIGURATION_DIRECTORY, 'root');
 	
 	# Find any files containing a 'WINDOWS_ROOT_PASSWORD' string and replace it with the root password
diff --git a/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm b/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm
index aa465ff..dc2d51a 100644
--- a/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm
+++ b/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm
@@ -1945,7 +1945,7 @@
 	}
 	
 	# The vmx file should be set to executable
-	chmod("0755", "/tmp/$vmx_file_name");
+	chmod(0755, "/tmp/$vmx_file_name");
 	
 	# Copy the temporary vmx file the the VM host
 	$self->vmhost_os->copy_file_to($temp_vmx_file_path, $vmx_file_path) || return;
diff --git a/managementnode/lib/VCL/Module/Provisioning/libvirt.pm b/managementnode/lib/VCL/Module/Provisioning/libvirt.pm
index 44691bc..b38ffff 100644
--- a/managementnode/lib/VCL/Module/Provisioning/libvirt.pm
+++ b/managementnode/lib/VCL/Module/Provisioning/libvirt.pm
@@ -1799,6 +1799,13 @@
 	#    Windows, however, expects it to be in so called 'localtime'."
 	my $clock_offset = ($image_os_type =~ /windows/) ? 'localtime' : 'utc';
 	
+	my $cpusockets = $cpu_count;
+	my $cpucores = 1;
+	if($cpu_count > 2) {
+		$cpusockets = 2;
+		$cpucores = ($cpu_count - ($cpu_count % 2)) / 2;
+	}
+
 	my $xml_hashref = {
 		'type' => $domain_type,
 		'description' => [$description],
@@ -1828,14 +1835,11 @@
 				model => {
 					'fallback' => 'allow',
 				},
-				#'topology' => [
-				#	{
-				#		'sockets' => $cpu_count,
-				#		'cores' => '2',
-				#		'threads' => '2',
-				#	}
-				#],
-				
+				topology => {
+					'sockets' => $cpusockets,
+					'cores' => $cpucores,
+					'threads' => 1,
+				},
 			}
 		],
 		'clock' => [
diff --git a/managementnode/lib/VCL/utils.pm b/managementnode/lib/VCL/utils.pm
index d33ea26..456013b 100644
--- a/managementnode/lib/VCL/utils.pm
+++ b/managementnode/lib/VCL/utils.pm
@@ -58,7 +58,7 @@
 use DBI;
 use DBI::Const::GetInfoType;
 use diagnostics;
-use Net::Ping;
+use Net::Ping::External qw(ping);
 use Fcntl qw(:DEFAULT :flock);
 use FindBin;
 use Getopt::Long;
@@ -2131,8 +2131,8 @@
 
  Parameters  : $node
  Returns     : boolean
- Description : Uses Net::Ping to check if a node is responding to ICMP echo
-               ping.
+ Description : Uses Net::Ping::External to check if a node is responding to ICMP
+               echo ping.
 
 =cut
 
@@ -2156,9 +2156,7 @@
 		}
 	}
 	
-	my $p = Net::Ping->new("icmp");
-	my $result = $p->ping($remote_connection_target, 1);
-	$p->close();
+	my $result = ping(host => $remote_connection_target, timeout => 1);
 
 	if ($result) {
 		#notify($ERRORS{'DEBUG'}, 0, "$node_string is responding to ping");
diff --git a/managementnode/tools/ESXi/Scripts/post_initial_connection/.gitignore b/managementnode/tools/ESXi/Scripts/post_initial_connection/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/ESXi/Scripts/post_initial_connection/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/ESXi/Scripts/post_load/.gitignore b/managementnode/tools/ESXi/Scripts/post_load/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/ESXi/Scripts/post_load/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/ESXi/Scripts/post_reservation/.gitignore b/managementnode/tools/ESXi/Scripts/post_reservation/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/ESXi/Scripts/post_reservation/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/ESXi/Scripts/post_reserve/.gitignore b/managementnode/tools/ESXi/Scripts/post_reserve/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/ESXi/Scripts/post_reserve/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/ESXi/Scripts/pre_capture/.gitignore b/managementnode/tools/ESXi/Scripts/pre_capture/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/ESXi/Scripts/pre_capture/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/ESXi/Scripts/pre_reload/.gitignore b/managementnode/tools/ESXi/Scripts/pre_reload/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/ESXi/Scripts/pre_reload/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Linux/Scripts/post_initial_connection/.gitignore b/managementnode/tools/Linux/Scripts/post_initial_connection/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Linux/Scripts/post_initial_connection/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Linux/Scripts/post_load/.gitignore b/managementnode/tools/Linux/Scripts/post_load/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Linux/Scripts/post_load/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Linux/Scripts/post_reservation/.gitignore b/managementnode/tools/Linux/Scripts/post_reservation/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Linux/Scripts/post_reservation/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Linux/Scripts/post_reserve/.gitignore b/managementnode/tools/Linux/Scripts/post_reserve/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Linux/Scripts/post_reserve/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Linux/Scripts/pre_capture/.gitignore b/managementnode/tools/Linux/Scripts/pre_capture/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Linux/Scripts/pre_capture/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Linux/Scripts/pre_reload/.gitignore b/managementnode/tools/Linux/Scripts/pre_reload/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Linux/Scripts/pre_reload/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/ManagementNode/Scripts/post_capture/.gitignore b/managementnode/tools/ManagementNode/Scripts/post_capture/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/ManagementNode/Scripts/post_capture/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/ManagementNode/Scripts/post_initial_connection/.gitignore b/managementnode/tools/ManagementNode/Scripts/post_initial_connection/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/ManagementNode/Scripts/post_initial_connection/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/ManagementNode/Scripts/post_load/.gitignore b/managementnode/tools/ManagementNode/Scripts/post_load/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/ManagementNode/Scripts/post_load/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/ManagementNode/Scripts/post_reservation/.gitignore b/managementnode/tools/ManagementNode/Scripts/post_reservation/.gitignore
new file mode 100755
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/ManagementNode/Scripts/post_reservation/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/ManagementNode/Scripts/post_reserve/.gitignore b/managementnode/tools/ManagementNode/Scripts/post_reserve/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/ManagementNode/Scripts/post_reserve/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/ManagementNode/Scripts/pre_capture/.gitignore b/managementnode/tools/ManagementNode/Scripts/pre_capture/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/ManagementNode/Scripts/pre_capture/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/ManagementNode/Scripts/pre_reload/.gitignore b/managementnode/tools/ManagementNode/Scripts/pre_reload/.gitignore
new file mode 100755
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/ManagementNode/Scripts/pre_reload/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/OSX/Scripts/post_initial_connection/.gitignore b/managementnode/tools/OSX/Scripts/post_initial_connection/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/OSX/Scripts/post_initial_connection/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/OSX/Scripts/post_load/.gitignore b/managementnode/tools/OSX/Scripts/post_load/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/OSX/Scripts/post_load/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/OSX/Scripts/post_reservation/.gitignore b/managementnode/tools/OSX/Scripts/post_reservation/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/OSX/Scripts/post_reservation/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/OSX/Scripts/post_reserve/.gitignore b/managementnode/tools/OSX/Scripts/post_reserve/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/OSX/Scripts/post_reserve/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/OSX/Scripts/pre_capture/.gitignore b/managementnode/tools/OSX/Scripts/pre_capture/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/OSX/Scripts/pre_capture/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/OSX/Scripts/pre_reload/.gitignore b/managementnode/tools/OSX/Scripts/pre_reload/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/OSX/Scripts/pre_reload/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Ubuntu/Scripts/post_initial_connection/.gitignore b/managementnode/tools/Ubuntu/Scripts/post_initial_connection/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Ubuntu/Scripts/post_initial_connection/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Ubuntu/Scripts/post_load/.gitignore b/managementnode/tools/Ubuntu/Scripts/post_load/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Ubuntu/Scripts/post_load/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Ubuntu/Scripts/post_reservation/.gitignore b/managementnode/tools/Ubuntu/Scripts/post_reservation/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Ubuntu/Scripts/post_reservation/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Ubuntu/Scripts/post_reserve/.gitignore b/managementnode/tools/Ubuntu/Scripts/post_reserve/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Ubuntu/Scripts/post_reserve/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Ubuntu/Scripts/pre_capture/.gitignore b/managementnode/tools/Ubuntu/Scripts/pre_capture/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Ubuntu/Scripts/pre_capture/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Ubuntu/Scripts/pre_reload/.gitignore b/managementnode/tools/Ubuntu/Scripts/pre_reload/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Ubuntu/Scripts/pre_reload/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows/Drivers/.gitignore b/managementnode/tools/Windows/Drivers/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows/Drivers/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows/Logs/.gitignore b/managementnode/tools/Windows/Logs/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows/Logs/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows/Scripts/post_initial_connection/.gitignore b/managementnode/tools/Windows/Scripts/post_initial_connection/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows/Scripts/post_initial_connection/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows/Scripts/post_load/.gitignore b/managementnode/tools/Windows/Scripts/post_load/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows/Scripts/post_load/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows/Scripts/post_reservation/.gitignore b/managementnode/tools/Windows/Scripts/post_reservation/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows/Scripts/post_reservation/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows/Scripts/post_reserve/.gitignore b/managementnode/tools/Windows/Scripts/post_reserve/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows/Scripts/post_reserve/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows/Scripts/pre_capture/.gitignore b/managementnode/tools/Windows/Scripts/pre_capture/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows/Scripts/pre_capture/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows/Scripts/pre_reload/.gitignore b/managementnode/tools/Windows/Scripts/pre_reload/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows/Scripts/pre_reload/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows/Updates/x86/.gitignore b/managementnode/tools/Windows/Updates/x86/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows/Updates/x86/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows/Updates/x86_64/.gitignore b/managementnode/tools/Windows/Updates/x86_64/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows/Updates/x86_64/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows/Utilities/WSName/.gitignore b/managementnode/tools/Windows/Utilities/WSName/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows/Utilities/WSName/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_10/Drivers/.gitignore b/managementnode/tools/Windows_10/Drivers/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_10/Drivers/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_10/Scripts/post_initial_connection/.gitignore b/managementnode/tools/Windows_10/Scripts/post_initial_connection/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_10/Scripts/post_initial_connection/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_10/Scripts/post_load/.gitignore b/managementnode/tools/Windows_10/Scripts/post_load/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_10/Scripts/post_load/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_10/Scripts/post_reservation/.gitignore b/managementnode/tools/Windows_10/Scripts/post_reservation/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_10/Scripts/post_reservation/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_10/Scripts/post_reserve/.gitignore b/managementnode/tools/Windows_10/Scripts/post_reserve/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_10/Scripts/post_reserve/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_10/Scripts/pre_capture/.gitignore b/managementnode/tools/Windows_10/Scripts/pre_capture/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_10/Scripts/pre_capture/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_10/Scripts/pre_reload/.gitignore b/managementnode/tools/Windows_10/Scripts/pre_reload/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_10/Scripts/pre_reload/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_10/Updates/.gitignore b/managementnode/tools/Windows_10/Updates/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_10/Updates/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_10/Utilities/.gitignore b/managementnode/tools/Windows_10/Utilities/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_10/Utilities/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_7/Drivers/.gitignore b/managementnode/tools/Windows_7/Drivers/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_7/Drivers/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_7/Scripts/post_initial_connection/.gitignore b/managementnode/tools/Windows_7/Scripts/post_initial_connection/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_7/Scripts/post_initial_connection/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_7/Scripts/post_load/.gitignore b/managementnode/tools/Windows_7/Scripts/post_load/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_7/Scripts/post_load/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_7/Scripts/post_reservation/.gitignore b/managementnode/tools/Windows_7/Scripts/post_reservation/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_7/Scripts/post_reservation/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_7/Scripts/post_reserve/.gitignore b/managementnode/tools/Windows_7/Scripts/post_reserve/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_7/Scripts/post_reserve/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_7/Scripts/pre_capture/.gitignore b/managementnode/tools/Windows_7/Scripts/pre_capture/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_7/Scripts/pre_capture/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_7/Scripts/pre_reload/.gitignore b/managementnode/tools/Windows_7/Scripts/pre_reload/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_7/Scripts/pre_reload/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_7/Updates/x86/.gitignore b/managementnode/tools/Windows_7/Updates/x86/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_7/Updates/x86/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_7/Updates/x86_64/.gitignore b/managementnode/tools/Windows_7/Updates/x86_64/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_7/Updates/x86_64/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_7/Utilities/.gitignore b/managementnode/tools/Windows_7/Utilities/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_7/Utilities/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_8/Drivers/.gitignore b/managementnode/tools/Windows_8/Drivers/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_8/Drivers/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_8/Scripts/post_initial_connection/.gitignore b/managementnode/tools/Windows_8/Scripts/post_initial_connection/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_8/Scripts/post_initial_connection/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_8/Scripts/post_load/.gitignore b/managementnode/tools/Windows_8/Scripts/post_load/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_8/Scripts/post_load/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_8/Scripts/post_reservation/.gitignore b/managementnode/tools/Windows_8/Scripts/post_reservation/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_8/Scripts/post_reservation/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_8/Scripts/post_reserve/.gitignore b/managementnode/tools/Windows_8/Scripts/post_reserve/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_8/Scripts/post_reserve/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_8/Scripts/pre_capture/.gitignore b/managementnode/tools/Windows_8/Scripts/pre_capture/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_8/Scripts/pre_capture/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_8/Scripts/pre_reload/.gitignore b/managementnode/tools/Windows_8/Scripts/pre_reload/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_8/Scripts/pre_reload/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_8/Updates/.gitignore b/managementnode/tools/Windows_8/Updates/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_8/Updates/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_8/Utilities/.gitignore b/managementnode/tools/Windows_8/Utilities/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_8/Utilities/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2003/Drivers/.gitignore b/managementnode/tools/Windows_Server_2003/Drivers/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2003/Drivers/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2003/Scripts/post_initial_connection/.gitignore b/managementnode/tools/Windows_Server_2003/Scripts/post_initial_connection/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2003/Scripts/post_initial_connection/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2003/Scripts/post_load/.gitignore b/managementnode/tools/Windows_Server_2003/Scripts/post_load/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2003/Scripts/post_load/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2003/Scripts/post_reservation/.gitignore b/managementnode/tools/Windows_Server_2003/Scripts/post_reservation/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2003/Scripts/post_reservation/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2003/Scripts/post_reserve/.gitignore b/managementnode/tools/Windows_Server_2003/Scripts/post_reserve/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2003/Scripts/post_reserve/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2003/Scripts/pre_capture/.gitignore b/managementnode/tools/Windows_Server_2003/Scripts/pre_capture/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2003/Scripts/pre_capture/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2003/Scripts/pre_reload/.gitignore b/managementnode/tools/Windows_Server_2003/Scripts/pre_reload/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2003/Scripts/pre_reload/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2003/Updates/x86/.gitignore b/managementnode/tools/Windows_Server_2003/Updates/x86/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2003/Updates/x86/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2003/Updates/x86_64/.gitignore b/managementnode/tools/Windows_Server_2003/Updates/x86_64/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2003/Updates/x86_64/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2003/Utilities/Sysprep/.gitignore b/managementnode/tools/Windows_Server_2003/Utilities/Sysprep/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2003/Utilities/Sysprep/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2008/Drivers/.gitignore b/managementnode/tools/Windows_Server_2008/Drivers/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2008/Drivers/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2008/Scripts/post_initial_connection/.gitignore b/managementnode/tools/Windows_Server_2008/Scripts/post_initial_connection/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2008/Scripts/post_initial_connection/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2008/Scripts/post_load/.gitignore b/managementnode/tools/Windows_Server_2008/Scripts/post_load/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2008/Scripts/post_load/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2008/Scripts/post_reservation/.gitignore b/managementnode/tools/Windows_Server_2008/Scripts/post_reservation/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2008/Scripts/post_reservation/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2008/Scripts/post_reserve/.gitignore b/managementnode/tools/Windows_Server_2008/Scripts/post_reserve/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2008/Scripts/post_reserve/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2008/Scripts/pre_capture/.gitignore b/managementnode/tools/Windows_Server_2008/Scripts/pre_capture/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2008/Scripts/pre_capture/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2008/Scripts/pre_reload/.gitignore b/managementnode/tools/Windows_Server_2008/Scripts/pre_reload/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2008/Scripts/pre_reload/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2008/Updates/x86/.gitignore b/managementnode/tools/Windows_Server_2008/Updates/x86/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2008/Updates/x86/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2008/Updates/x86_64/.gitignore b/managementnode/tools/Windows_Server_2008/Updates/x86_64/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2008/Updates/x86_64/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2008/Utilities/.gitignore b/managementnode/tools/Windows_Server_2008/Utilities/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2008/Utilities/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2012/Drivers/.gitignore b/managementnode/tools/Windows_Server_2012/Drivers/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2012/Drivers/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2012/Scripts/post_initial_connection/.gitignore b/managementnode/tools/Windows_Server_2012/Scripts/post_initial_connection/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2012/Scripts/post_initial_connection/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2012/Scripts/post_load/.gitignore b/managementnode/tools/Windows_Server_2012/Scripts/post_load/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2012/Scripts/post_load/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2012/Scripts/post_reservation/.gitignore b/managementnode/tools/Windows_Server_2012/Scripts/post_reservation/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2012/Scripts/post_reservation/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2012/Scripts/post_reserve/.gitignore b/managementnode/tools/Windows_Server_2012/Scripts/post_reserve/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2012/Scripts/post_reserve/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2012/Scripts/pre_capture/.gitignore b/managementnode/tools/Windows_Server_2012/Scripts/pre_capture/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2012/Scripts/pre_capture/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2012/Scripts/pre_reload/.gitignore b/managementnode/tools/Windows_Server_2012/Scripts/pre_reload/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2012/Scripts/pre_reload/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2012/Updates/.gitignore b/managementnode/tools/Windows_Server_2012/Updates/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2012/Updates/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2012/Utilities/.gitignore b/managementnode/tools/Windows_Server_2012/Utilities/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2012/Utilities/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2016/Drivers/.gitignore b/managementnode/tools/Windows_Server_2016/Drivers/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2016/Drivers/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2016/Scripts/post_initial_connection/.gitignore b/managementnode/tools/Windows_Server_2016/Scripts/post_initial_connection/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2016/Scripts/post_initial_connection/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2016/Scripts/post_load/.gitignore b/managementnode/tools/Windows_Server_2016/Scripts/post_load/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2016/Scripts/post_load/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2016/Scripts/post_reservation/.gitignore b/managementnode/tools/Windows_Server_2016/Scripts/post_reservation/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2016/Scripts/post_reservation/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2016/Scripts/post_reserve/.gitignore b/managementnode/tools/Windows_Server_2016/Scripts/post_reserve/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2016/Scripts/post_reserve/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2016/Scripts/pre_capture/.gitignore b/managementnode/tools/Windows_Server_2016/Scripts/pre_capture/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2016/Scripts/pre_capture/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2016/Scripts/pre_reload/.gitignore b/managementnode/tools/Windows_Server_2016/Scripts/pre_reload/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2016/Scripts/pre_reload/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2016/Updates/.gitignore b/managementnode/tools/Windows_Server_2016/Updates/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2016/Updates/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Server_2016/Utilities/.gitignore b/managementnode/tools/Windows_Server_2016/Utilities/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Server_2016/Utilities/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Version_5/Drivers/.gitignore b/managementnode/tools/Windows_Version_5/Drivers/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Version_5/Drivers/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Version_5/Scripts/post_initial_connection/.gitignore b/managementnode/tools/Windows_Version_5/Scripts/post_initial_connection/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Version_5/Scripts/post_initial_connection/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Version_5/Scripts/post_load/.gitignore b/managementnode/tools/Windows_Version_5/Scripts/post_load/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Version_5/Scripts/post_load/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Version_5/Scripts/post_reservation/.gitignore b/managementnode/tools/Windows_Version_5/Scripts/post_reservation/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Version_5/Scripts/post_reservation/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Version_5/Scripts/post_reserve/.gitignore b/managementnode/tools/Windows_Version_5/Scripts/post_reserve/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Version_5/Scripts/post_reserve/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Version_5/Scripts/pre_capture/.gitignore b/managementnode/tools/Windows_Version_5/Scripts/pre_capture/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Version_5/Scripts/pre_capture/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Version_5/Scripts/pre_reload/.gitignore b/managementnode/tools/Windows_Version_5/Scripts/pre_reload/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Version_5/Scripts/pre_reload/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Version_5/Updates/x86/.gitignore b/managementnode/tools/Windows_Version_5/Updates/x86/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Version_5/Updates/x86/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Version_5/Updates/x86_64/.gitignore b/managementnode/tools/Windows_Version_5/Updates/x86_64/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Version_5/Updates/x86_64/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Version_6/Drivers/.gitignore b/managementnode/tools/Windows_Version_6/Drivers/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Version_6/Drivers/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Version_6/Scripts/post_initial_connection/.gitignore b/managementnode/tools/Windows_Version_6/Scripts/post_initial_connection/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Version_6/Scripts/post_initial_connection/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Version_6/Scripts/post_load/.gitignore b/managementnode/tools/Windows_Version_6/Scripts/post_load/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Version_6/Scripts/post_load/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Version_6/Scripts/post_reservation/.gitignore b/managementnode/tools/Windows_Version_6/Scripts/post_reservation/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Version_6/Scripts/post_reservation/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Version_6/Scripts/post_reserve/.gitignore b/managementnode/tools/Windows_Version_6/Scripts/post_reserve/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Version_6/Scripts/post_reserve/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Version_6/Scripts/pre_capture/.gitignore b/managementnode/tools/Windows_Version_6/Scripts/pre_capture/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Version_6/Scripts/pre_capture/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Version_6/Scripts/pre_reload/.gitignore b/managementnode/tools/Windows_Version_6/Scripts/pre_reload/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Version_6/Scripts/pre_reload/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Version_6/Updates/x86/.gitignore b/managementnode/tools/Windows_Version_6/Updates/x86/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Version_6/Updates/x86/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Version_6/Updates/x86_64/.gitignore b/managementnode/tools/Windows_Version_6/Updates/x86_64/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Version_6/Updates/x86_64/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Vista/Drivers/.gitignore b/managementnode/tools/Windows_Vista/Drivers/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Vista/Drivers/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Vista/Scripts/post_initial_connection/.gitignore b/managementnode/tools/Windows_Vista/Scripts/post_initial_connection/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Vista/Scripts/post_initial_connection/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Vista/Scripts/post_load/.gitignore b/managementnode/tools/Windows_Vista/Scripts/post_load/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Vista/Scripts/post_load/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Vista/Scripts/post_reservation/.gitignore b/managementnode/tools/Windows_Vista/Scripts/post_reservation/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Vista/Scripts/post_reservation/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Vista/Scripts/post_reserve/.gitignore b/managementnode/tools/Windows_Vista/Scripts/post_reserve/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Vista/Scripts/post_reserve/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Vista/Scripts/pre_capture/.gitignore b/managementnode/tools/Windows_Vista/Scripts/pre_capture/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Vista/Scripts/pre_capture/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Vista/Scripts/pre_reload/.gitignore b/managementnode/tools/Windows_Vista/Scripts/pre_reload/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Vista/Scripts/pre_reload/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Vista/Updates/x86/.gitignore b/managementnode/tools/Windows_Vista/Updates/x86/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Vista/Updates/x86/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_Vista/Updates/x86_64/.gitignore b/managementnode/tools/Windows_Vista/Updates/x86_64/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_Vista/Updates/x86_64/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_XP/Drivers/.gitignore b/managementnode/tools/Windows_XP/Drivers/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_XP/Drivers/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_XP/Scripts/post_initial_connection/.gitignore b/managementnode/tools/Windows_XP/Scripts/post_initial_connection/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_XP/Scripts/post_initial_connection/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_XP/Scripts/post_load/.gitignore b/managementnode/tools/Windows_XP/Scripts/post_load/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_XP/Scripts/post_load/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_XP/Scripts/post_reservation/.gitignore b/managementnode/tools/Windows_XP/Scripts/post_reservation/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_XP/Scripts/post_reservation/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_XP/Scripts/post_reserve/.gitignore b/managementnode/tools/Windows_XP/Scripts/post_reserve/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_XP/Scripts/post_reserve/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_XP/Scripts/pre_capture/.gitignore b/managementnode/tools/Windows_XP/Scripts/pre_capture/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_XP/Scripts/pre_capture/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_XP/Scripts/pre_reload/.gitignore b/managementnode/tools/Windows_XP/Scripts/pre_reload/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_XP/Scripts/pre_reload/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_XP/Updates/x86/.gitignore b/managementnode/tools/Windows_XP/Updates/x86/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_XP/Updates/x86/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_XP/Updates/x86_64/.gitignore b/managementnode/tools/Windows_XP/Updates/x86_64/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_XP/Updates/x86_64/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/managementnode/tools/Windows_XP/Utilities/Sysprep/.gitignore b/managementnode/tools/Windows_XP/Utilities/Sysprep/.gitignore
new file mode 100644
index 0000000..44c6794
--- /dev/null
+++ b/managementnode/tools/Windows_XP/Utilities/Sysprep/.gitignore
@@ -0,0 +1,11 @@
+#
+# The purpose of this file is to keep this directory from being empty so the
+# directory will be retained in the git repository. The directory is used by
+# the backend code for some scripts used during provisioning, and so needs to
+# be retained.
+#
+
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/web/.gitignore b/web/.gitignore
new file mode 100644
index 0000000..54e45b2
--- /dev/null
+++ b/web/.gitignore
@@ -0,0 +1,9 @@
+.ht-inc/conf.php
+.ht-inc/cryptkey/cryptkeyid
+.ht-inc/cryptkey/private.pem
+.ht-inc/keys.pem
+.ht-inc/pubkey.pem
+.ht-inc/secrets.php
+.ht-inc/spyc-0.5.1/
+dojo/
+themes/**/css/dojo
diff --git a/web/.ht-inc/addomain.php b/web/.ht-inc/addomain.php
index e75639d..a7259d5 100644
--- a/web/.ht-inc/addomain.php
+++ b/web/.ht-inc/addomain.php
@@ -204,7 +204,7 @@
 				       . "WHERE cryptkeyid = $cryptkeyid AND "
 				       .       "secretid = $oldsecretid";
 				$qh = doQuery($query);
-				if(! ($row = mysql_fetch_assoc($qh))) {
+				if(! ($row = mysqli_fetch_assoc($qh))) {
 					# generate a new secret
 					$newsecretid = getSecretKeyID('addomain', 'secretid', 0);
 					$delids = array($oldsecretid);
@@ -221,7 +221,7 @@
 					       . "WHERE cs.secretid = $oldsecretid AND "
 					       .       "ck.hosttype = 'managementnode'";
 					$qh = doQuery($query);
-					while($row = mysql_fetch_assoc($qh))
+					while($row = mysqli_fetch_assoc($qh))
 						$secretidset[$row['mnid']][$newsecretid] = 1;
 					$values = getMNcryptkeyUpdates($secretidset, $cryptkeyid);
 					addCryptSecretKeyUpdates($values);
@@ -586,7 +586,7 @@
 		       .       "ia.imageid = i.id";
 		$qh = doQuery($query);
 		$images = array();
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$images[] = $row['prettyname'];
 		if(count($images))
 			$msg = "This AD Domain cannot be deleted because the following <strong>images</strong> are using it:<br><br>\n" . implode("<br>\n", $images);
diff --git a/web/.ht-inc/authentication.php b/web/.ht-inc/authentication.php
index 5c933aa..7a93cc0 100644
--- a/web/.ht-inc/authentication.php
+++ b/web/.ht-inc/authentication.php
@@ -91,7 +91,7 @@
 		# check to see if shibauth entry still exists for $shibauthed
 		$query = "SELECT ts FROM shibauth WHERE id = $shibauthed";
 		$qh = doQuery($query, 101);
-		if($row = mysql_fetch_assoc($qh)) {
+		if($row = mysqli_fetch_assoc($qh)) {
 			$shibstart = $row['ts'];
 			# TODO if $shibstart is too old, expire the login session
 		}
@@ -363,7 +363,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 function ldapLogin($authtype, $userid, $passwd) {
 	global $HTMLheader, $printedHTMLheader, $authMechs, $phpVer;
-	$esc_userid = mysql_real_escape_string($userid);
+	$esc_userid = vcl_mysql_escape_string($userid);
 	if(! $fh = fsockopen($authMechs[$authtype]['server'], 636, $errno, $errstr, 5)) {
 		printLoginPageWithSkin($authtype, 1);
 		return;
@@ -435,7 +435,7 @@
 		       . "WHERE unityid = '$esc_userid' AND "
 		       .       "affiliationid = {$authMechs[$authtype]['affiliationid']}";
 		$qh = doQuery($query, 101);
-		if(! mysql_num_rows($qh)) {
+		if(! mysqli_num_rows($qh)) {
 			// if not, add user
 			$newid = updateLDAPUser($authtype, $userid);
 			if(is_null($newid))
@@ -514,7 +514,7 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function validateLocalAccount($user, $pass) {
-	$user = mysql_real_escape_string($user);
+	$user = vcl_mysql_escape_string($user);
 	$query = "SELECT l.salt "
 	       . "FROM localauth l, "
 	       .      "user u, "
@@ -524,8 +524,8 @@
 	       .       "a.name = 'Local' AND "
 	       .       "l.userid = u.id";
 	$qh = doQuery($query, 101);
-	if(mysql_num_rows($qh) != 1 ||
-	   (! ($row = mysql_fetch_assoc($qh))))
+	if(mysqli_num_rows($qh) != 1 ||
+	   (! ($row = mysqli_fetch_assoc($qh))))
 		return 0;
 
 	$passhash = sha1("$pass{$row['salt']}");
@@ -539,7 +539,7 @@
 	       .       "u.affiliationid = a.id AND "
 	       .       "a.name = 'Local'";
 	$qh = doQuery($query, 101);
-	if(mysql_num_rows($qh) == 1)
+	if(mysqli_num_rows($qh) == 1)
 		return 1;
 	else
 		return 0;
@@ -559,8 +559,8 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function addLoginLog($login, $mech, $affiliationid, $passfail, $code='none') {
-	$login = mysql_real_escape_string($login);
-	$mech = mysql_real_escape_string($mech);
+	$login = vcl_mysql_escape_string($login);
+	$mech = vcl_mysql_escape_string($mech);
 	$query = "INSERT INTO loginlog "
 	       .        "(user, "
 	       .        "authmech, "
@@ -613,8 +613,8 @@
 	       . "LIMIT 3";
 	$qh = doQuery($query, 101);
 	$expire = time() - (SECINDAY * 3);
-	$rows = mysql_num_rows($qh);
-	if($row = mysql_fetch_assoc($qh)) {
+	$rows = mysqli_num_rows($qh);
+	if($row = mysqli_fetch_assoc($qh)) {
 		if($rows >= 3 || datetimeToUnix($row['start']) < $expire) {
 			if(in_array($mode, $noHTMLwrappers))
 				# do a redirect and handle removal on next page load so user can
diff --git a/web/.ht-inc/authmethods/itecsauth.php b/web/.ht-inc/authmethods/itecsauth.php
index ccdb9a4..be9b537 100644
--- a/web/.ht-inc/authmethods/itecsauth.php
+++ b/web/.ht-inc/authmethods/itecsauth.php
@@ -35,10 +35,10 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function addITECSUser($loginid) {
-	global $mysql_link_vcl, $ENABLE_ITECSAUTH;
+	global $mysqli_link_vcl, $ENABLE_ITECSAUTH;
 	if(! $ENABLE_ITECSAUTH)
 		return NULL;
-	$esc_loginid = mysql_real_escape_string($loginid);
+	$esc_loginid = vcl_mysql_escape_string($loginid);
 	$query = "SELECT id AS uid, "
 	       .        "first, " 
 	       .        "last, "
@@ -49,13 +49,13 @@
 	       . "FROM user "
 	       . "WHERE email = '$esc_loginid'";
 	$qh = doQuery($query, 101, "accounts");
-	if($row = mysql_fetch_assoc($qh)) {
+	if($row = mysqli_fetch_assoc($qh)) {
 		// FIXME test replacing ''s
 		// FIXME do we care if the account is active?
-		$first = mysql_real_escape_string($row['first']);
-		$last = mysql_real_escape_string($row['last']);
-		$loweruser = mysql_real_escape_string(strtolower($row['email']));
-		$email = mysql_real_escape_string($row['email']);
+		$first = vcl_mysql_escape_string($row['first']);
+		$last = vcl_mysql_escape_string($row['last']);
+		$loweruser = vcl_mysql_escape_string(strtolower($row['email']));
+		$email = vcl_mysql_escape_string($row['email']);
 		$query = "INSERT INTO user ("
 		       .        "uid, "
 		       .        "unityid, "
@@ -79,9 +79,9 @@
 		// FIXME might want this logged
 		doQuery($query, 101, 'vcl', 1);
 	}
-	if(mysql_affected_rows($mysql_link_vcl)) {
+	if(mysqli_affected_rows($mysqli_link_vcl)) {
 		$qh = doQuery("SELECT LAST_INSERT_ID() FROM user", 101);
-		if(! $row = mysql_fetch_row($qh)) {
+		if(! $row = mysqli_fetch_row($qh)) {
 			abort(101);
 		}
 		return $row[0];
@@ -104,14 +104,14 @@
 	global $ENABLE_ITECSAUTH;
 	if(! $ENABLE_ITECSAUTH)
 		return 0;
-	$loginid = mysql_real_escape_string($loginid);
+	$loginid = vcl_mysql_escape_string($loginid);
 	$query = "SELECT email "
 	       . "FROM user "
 	       . "WHERE email = '$loginid' AND "
 	       .       "(active = 1 OR "
 	       .       "activated = 0)";
 	$qh = doQuery($query, 101, "accounts");
-	if(mysql_num_rows($qh))
+	if(mysqli_num_rows($qh))
 		return 1;
 	return 0;
 }
@@ -160,7 +160,7 @@
 	       . "FROM user "
 	       . "WHERE email = '$userid'";
 	$qh = doQuery($query, 101, "accounts");
-	if(! ($userData = mysql_fetch_assoc($qh)))
+	if(! ($userData = mysqli_fetch_assoc($qh)))
 		return NULL;
 
 	$now = unixToDatetime(time());
@@ -191,11 +191,11 @@
 	// if get a row
 	//    update db
 	//    update results from select
-	$esc_userid = mysql_real_escape_string($userid);
-	$first = mysql_real_escape_string($userData['first']);
-	$last = mysql_real_escape_string($userData['last']);
-	$email = mysql_real_escape_string($userData['email']);
-	if($user = mysql_fetch_assoc($qh)) {
+	$esc_userid = vcl_mysql_escape_string($userid);
+	$first = vcl_mysql_escape_string($userData['first']);
+	$last = vcl_mysql_escape_string($userData['last']);
+	$email = vcl_mysql_escape_string($userData['email']);
+	if($user = mysqli_fetch_assoc($qh)) {
 		$user["unityid"] = $userid;
 		$user["firstname"] = $userData['first'];
 		$user["lastname"] = $userData["last"];
@@ -240,7 +240,7 @@
 		       . "WHERE u.affiliationid = af.id AND "
 		       .       "u.id = $id";
 		$qh = doQuery($query, 101);
-		$user = mysql_fetch_assoc($qh);
+		$user = mysqli_fetch_assoc($qh);
 
 		# add account to demo group
 		#$demoid = getUserGroupID('demo', getAffiliationID('ITECS'));
diff --git a/web/.ht-inc/authmethods/ldapauth.php b/web/.ht-inc/authmethods/ldapauth.php
index cf415c3..8aa53c6 100644
--- a/web/.ht-inc/authmethods/ldapauth.php
+++ b/web/.ht-inc/authmethods/ldapauth.php
@@ -34,13 +34,13 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function addLDAPUser($authtype, $userid) {
-	global $authMechs, $mysql_link_vcl;
+	global $authMechs, $mysqli_link_vcl;
 	$data = getLDAPUserData($authtype, $userid);
 	if(is_null($data))
 		return NULL;
 
 	$loweruserid = strtolower($userid);
-	$loweruserid = mysql_real_escape_string($loweruserid);
+	$loweruserid = vcl_mysql_escape_string($loweruserid);
 
 	# check for existance of an expired user if a numericid exists
 	if(array_key_exists('numericid', $data)) {
@@ -53,7 +53,7 @@
 		       .       "unityid != '$loweruserid'";
 		       #.       "affiliationid = {$authMechs[$authtype]['affiliationid']}";
 		$qh = doQuery($query, 101);
-		if($row = mysql_fetch_assoc($qh)) {
+		if($row = mysqli_fetch_assoc($qh)) {
 			# find the authtype for this user
 			foreach($authMechs as $index => $auth) {
 				if($auth['affiliationid'] == $row['affiliationid'] &&
@@ -95,9 +95,9 @@
 	       .        "'{$data['emailnotices']}', "
 	       .        "NOW())";
 	doQuery($query, 101, 'vcl', 1);
-	if(mysql_affected_rows($mysql_link_vcl)) {
+	if(mysqli_affected_rows($mysqli_link_vcl)) {
 		$qh = doQuery("SELECT LAST_INSERT_ID() FROM user", 101);
-		if(! $row = mysql_fetch_row($qh)) {
+		if(! $row = mysqli_fetch_row($qh)) {
 			abort(101);
 		}
 		return $row[0];
@@ -171,7 +171,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 function updateLDAPUser($authtype, $userid) {
 	global $authMechs;
-	$esc_userid = mysql_real_escape_string($userid);
+	$esc_userid = vcl_mysql_escape_string($userid);
 	$userData = getLDAPUserData($authtype, $userid);
 	if(is_null($userData))
 		return NULL;
@@ -213,7 +213,7 @@
 	# check to see if there is a matching entry where uid is NULL but unityid and affiliationid match
 	if(array_key_exists('numericid', $userData) &&
 	   is_numeric($userData['numericid']) &&
-	   ! mysql_num_rows($qh)) {
+	   ! mysqli_num_rows($qh)) {
 		$updateuid = 1;
 		$query = $qbase . "u.unityid = '$esc_userid' AND "
 		       .          "u.affiliationid = $affilid";
@@ -222,7 +222,7 @@
 	// if get a row
 	//    update db
 	//    update results from select
-	if($user = mysql_fetch_assoc($qh)) {
+	if($user = mysqli_fetch_assoc($qh)) {
 		$user["unityid"] = $userid;
 		$user["firstname"] = $userData['first'];
 		$user["lastname"] = $userData["last"];
@@ -277,7 +277,7 @@
 		       . "WHERE u.affiliationid = af.id AND "
 		       .       "u.id = $id";
 		$qh = doQuery($query, 101);
-		if(! $user = mysql_fetch_assoc($qh))
+		if(! $user = mysqli_fetch_assoc($qh))
 			return NULL;
 		$user['sshpublickeys'] = htmlspecialchars($user['sshpublickeys']);
 	}
@@ -305,9 +305,9 @@
 /// \param $userid - a userid without the affiliation part
 ///
 /// \return an array of user information with the following keys:\n
-/// \b first - first name of user (escaped with mysql_real_escape_string)\n
-/// \b last - last name of user (escaped with mysql_real_escape_string)\n
-/// \b email - email address of user (escaped with mysql_real_escape_string)\n
+/// \b first - first name of user (escaped with vcl_mysql_escape_string)\n
+/// \b last - last name of user (escaped with vcl_mysql_escape_string)\n
+/// \b email - email address of user (escaped with vcl_mysql_escape_string)\n
 /// \b emailnotices - 0 or 1, whether or not emails should be sent to user\n
 /// \b numericid - numeric id of user if $authtype is configured to include it
 ///
@@ -315,7 +315,7 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function getLDAPUserData($authtype, $userid) {
-	global $authMechs, $mysql_link_vcl;
+	global $authMechs, $mysqli_link_vcl;
 	$auth = $authMechs[$authtype];
 	$donumericid = 0;
 	if(array_key_exists('numericid', $auth))
@@ -392,16 +392,16 @@
 		}
 
 		if(array_key_exists(strtolower($auth['firstname']), $data))
-			$return['first'] = mysql_real_escape_string($data[strtolower($auth['firstname'])]);
+			$return['first'] = vcl_mysql_escape_string($data[strtolower($auth['firstname'])]);
 		else
 			$return['first'] = '';
 		if(array_key_exists(strtolower($auth['lastname']), $data))
-			$return['last'] = mysql_real_escape_string($data[strtolower($auth['lastname'])]);
+			$return['last'] = vcl_mysql_escape_string($data[strtolower($auth['lastname'])]);
 		else
 			$return['last'] = '';
 		if($donumericid && is_numeric($data[strtolower($auth['numericid'])]))
 			$return['numericid'] = $data[strtolower($auth['numericid'])];
-		$return['email'] = mysql_real_escape_string($data[strtolower($auth['email'])]);
+		$return['email'] = vcl_mysql_escape_string($data[strtolower($auth['email'])]);
 
 		return $return;
 	}
diff --git a/web/.ht-inc/authmethods/shibauth.php b/web/.ht-inc/authmethods/shibauth.php
index c814925..33d7b5d 100644
--- a/web/.ht-inc/authmethods/shibauth.php
+++ b/web/.ht-inc/authmethods/shibauth.php
@@ -39,7 +39,7 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function updateShibUser($userid) {
-	global $mysql_link_vcl;
+	global $mysqli_link_vcl;
 	$rc = getAffilidAndLogin($userid, $affilid);
 	if($rc == -1)
 		return NULL;
@@ -83,7 +83,7 @@
 	       . "WHERE unityid = '$userid' AND "
 	       .       "affiliationid = $affilid";
 	$qh = doQuery($query, 101);
-	if(! $row = mysql_fetch_assoc($qh)) {
+	if(! $row = mysqli_fetch_assoc($qh)) {
 		# add user to our db
 		$user['id'] = addShibUser($user);
 		return $user;
@@ -91,13 +91,13 @@
 
 	# update user's data in db
 	$user['id'] = $row['id'];
-	$first = mysql_real_escape_string($user['firstname']);
-	$last = mysql_real_escape_string($user['lastname']);
+	$first = vcl_mysql_escape_string($user['firstname']);
+	$last = vcl_mysql_escape_string($user['lastname']);
 	$query = "UPDATE user "
 	       . "SET firstname = '$first', "
 	       .     "lastname = '$last', ";
 	if(array_key_exists('email', $user)) {
-		$email = mysql_real_escape_string($user['email']);
+		$email = vcl_mysql_escape_string($user['email']);
 		$query .= "email = '$email', ";
 	}
     $query .=    "lastupdated = NOW(), "
@@ -124,10 +124,10 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function addShibUser($user) {
-	global $mysql_link_vcl;
-	$unityid = mysql_real_escape_string($user['unityid']);
-	$first = mysql_real_escape_string($user['firstname']);
-	$last = mysql_real_escape_string($user['lastname']);
+	global $mysqli_link_vcl;
+	$unityid = vcl_mysql_escape_string($user['unityid']);
+	$first = vcl_mysql_escape_string($user['firstname']);
+	$last = vcl_mysql_escape_string($user['lastname']);
 	$query = "INSERT INTO user "
 	       .        "(unityid, "
 	       .        "affiliationid, "
@@ -143,14 +143,14 @@
 	       .        "'$first', "
 	       .        "'$last', ";
 	if(array_key_exists('email', $user)) {
-		$email = mysql_real_escape_string($user['email']);
+		$email = vcl_mysql_escape_string($user['email']);
 		$query .=    "'$email', ";
 	}
 	$query .=       "0, "
 	       .        "NOW())";
 	doQuery($query, 101, 'vcl', 1);
-	if(mysql_affected_rows($mysql_link_vcl)) {
-		$user['id'] = mysql_insert_id($mysql_link_vcl);
+	if(mysqli_affected_rows($mysqli_link_vcl)) {
+		$user['id'] = mysqli_insert_id($mysqli_link_vcl);
 		return $user['id'];
 	}
 	else
@@ -188,18 +188,18 @@
 		# get id for the group's affiliation
 		$query = "SELECT id FROM affiliation WHERE shibname = '$shibaffil'";
 		$qh = doQuery($query, 101);
-		$row = mysql_fetch_assoc($qh);
+		$row = mysqli_fetch_assoc($qh);
 		$affilid = $row['id'];
 		# prepend shib- and escape it for mysql
-		$grp = mysql_real_escape_string("shib-" . $name);
+		$grp = vcl_mysql_escape_string("shib-" . $name);
 		array_push($newusergroups, getUserGroupID($grp, $affilid));
 	}
 
 	$query = "SELECT id, name FROM affiliation WHERE shibname = '$shibaffil'";
 	$qh = doQuery($query, 101);
-	$row = mysql_fetch_assoc($qh);
+	$row = mysqli_fetch_assoc($qh);
 	$affilid = $row['id'];
-	$grp = mysql_real_escape_string("All {$row['name']} Users");
+	$grp = vcl_mysql_escape_string("All {$row['name']} Users");
 	array_push($newusergroups, getUserGroupID($grp, $affilid));
 
 	$newusergroups = array_unique($newusergroups);
@@ -224,7 +224,7 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function addShibUserStub($affilid, $userid) {
-	global $mysql_link_vcl;
+	global $mysqli_link_vcl;
 	$query = "INSERT INTO user "
 	       .        "(unityid, "
 	       .        "affiliationid, "
@@ -238,7 +238,7 @@
 	       .        "0, "
 	       .        "0)";
 	doQuery($query);
-	if(mysql_affected_rows($mysql_link_vcl))
+	if(mysqli_affected_rows($mysqli_link_vcl))
 		return dbLastInsertID();
 	else
 		return NULL;
diff --git a/web/.ht-inc/blockallocations.php b/web/.ht-inc/blockallocations.php
index 66ee16f..9bf25e2 100644
--- a/web/.ht-inc/blockallocations.php
+++ b/web/.ht-inc/blockallocations.php
@@ -75,7 +75,7 @@
 	       . "WHERE id in ($inids) AND "
 	       .       "status = 'accepted'";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$blocks[$row['id']] = $row['name'];
 	print "<hr>\n";
 	print "<h2>" . i("Your Active Block Allocations") . "</h2>\n";
@@ -606,7 +606,7 @@
 			return;
 		}
 		$mnid = array_rand($managementnodes);
-		$escname = mysql_real_escape_string($data['name']);
+		$escname = vcl_mysql_escape_string($data['name']);
 		$query = "INSERT INTO blockRequest "
 		       .        "(name, "
 		       .        "imageid, "
@@ -644,7 +644,7 @@
 		       .       "end > NOW() AND "
 		       .       "blockRequestid = $blockreqid";
 		$qh = doQuery($query, 101);
-		if($row = mysql_fetch_assoc($qh)) {
+		if($row = mysqli_fetch_assoc($qh)) {
 			$checkCurBlockTime = 1;
 			$curBlockTime = $row;
 		}
@@ -660,7 +660,7 @@
 		$query = "DELETE FROM blockWebTime WHERE blockRequestid = $blockreqid";
 		doQuery($query, 101);
 
-		$escname = mysql_real_escape_string($data['name']);
+		$escname = vcl_mysql_escape_string($data['name']);
 		$query = "UPDATE blockRequest "
 		       . "SET name = '$escname', " 
 		       .     "imageid = {$data['imageid']}, "
@@ -673,7 +673,7 @@
 		doQuery($query, 101);
 	}
 	elseif($method == 'request') {
-		$esccomments = mysql_real_escape_string($data['comments']);
+		$esccomments = vcl_mysql_escape_string($data['comments']);
 		$query = "INSERT INTO blockRequest "
 		       .        "(name, "
 		       .        "imageid, "
@@ -811,7 +811,7 @@
 		       .       "blockRequestid = $blockreqid AND "
 		       .       "id != {$curBlockTime['id']}";
 		$qh = doQuery($query, 101);
-		if($row = mysql_fetch_assoc($qh)) {
+		if($row = mysqli_fetch_assoc($qh)) {
 			if($curBlockTime['end'] != $row['end']) {
 				# update old end time
 				$query = "UPDATE blockTimes "
@@ -1093,7 +1093,7 @@
 	       .       "u.email != ''";
 	$qh = doQuery($query);
 	$addrs = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$addrs[] = $row['email'];
 	return implode(',', $addrs);
 }
@@ -1119,7 +1119,7 @@
 	$qh = doQuery($query, 101);
 	$skips = array();
 	$noskips = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$key = "{$row['start']}:{$row['end']}";
 		if($row['skip'])
 			$skips[$key] = $row['id'];
@@ -1181,11 +1181,11 @@
 	       . "ORDER BY b.name";
 	$allblockids = array();
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if($row['group'] == '') {
 			$query3 = "SELECT name FROM usergroup WHERE id = {$row['usergroupid']}";
 			$qh3 = doQuery($query3, 101);
-			if($row3 = mysql_fetch_assoc($qh3))
+			if($row3 = mysqli_fetch_assoc($qh3))
 				$row['group'] = $row3['name'];
 		}
 		$allblockids[] = $row['id'];
@@ -1200,7 +1200,7 @@
 		        . "ORDER BY start "
 		        . "LIMIT 1";
 		$qh2 = doQuery($query2, 101);
-		if($row2 = mysql_fetch_assoc($qh2)) {
+		if($row2 = mysqli_fetch_assoc($qh2)) {
 			if(array_key_exists('tzoffset', $_SESSION['persistdata'])) {
 				$tmp = date('n/j/y+g:i=A=T', $row2['unixstart']);
 				$blocks[$row['id']]['nextstart'] = str_replace(array('+', '='), array('<br>', '&nbsp;'), $tmp);
@@ -1229,7 +1229,7 @@
 			       . "FROM blockWebDate "
 			       . "WHERE blockRequestid = $id";
 			$qh = doQuery($query, 101);
-			if(! $row = mysql_fetch_assoc($qh))
+			if(! $row = mysqli_fetch_assoc($qh))
 				abort(101);
 			$blocks[$id] = array_merge($request, $row);
 			$wdays = array();
@@ -1250,7 +1250,7 @@
 			       . "WHERE blockRequestid = {$request['id']} "
 			       . "ORDER BY startmeridian, starthour, startminute";
 			$qh = doQuery($query, 101);
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				$blocks[$id]['swhour'][$row['order']] = $row['starthour'];
 				$blocks[$id]['swminute'][$row['order']] = $row['startminute'];
 				$blocks[$id]['swmeridian'][$row['order']] = $row['startmeridian'];
@@ -1267,7 +1267,7 @@
 			       . "FROM blockWebDate "
 			       . "WHERE blockRequestid = $id";
 			$qh = doQuery($query, 101);
-			if(! $row = mysql_fetch_assoc($qh))
+			if(! $row = mysqli_fetch_assoc($qh))
 				abort(101);
 			$blocks[$id] = array_merge($request, $row);
 			$query = "SELECT starthour, "
@@ -1281,7 +1281,7 @@
 			       . "WHERE blockRequestid = {$request['id']} "
 			       . "ORDER BY startmeridian, starthour, startminute";
 			$qh = doQuery($query, 101);
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				$blocks[$id]['smhour'][$row['order']] = $row['starthour'];
 				$blocks[$id]['smminute'][$row['order']] = $row['startminute'];
 				$blocks[$id]['smmeridian'][$row['order']] = $row['startmeridian'];
@@ -1297,7 +1297,7 @@
 			       . "WHERE blockRequestid = $id "
 			       . "ORDER BY start";
 			$qh = doQuery($query, 101);
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				if($row['date'] == '00/00/00')
 					$blocks[$id]['date'][$row['order']] = '';
 				else
@@ -1313,7 +1313,7 @@
 			       . "FROM blockWebTime "
 			       . "WHERE blockRequestid = {$request['id']}";
 			$qh = doQuery($query, 101);
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				$blocks[$id]['slhour'][$row['order']] = $row['starthour'];
 				$blocks[$id]['slminute'][$row['order']] = $row['startminute'];
 				$blocks[$id]['slmeridian'][$row['order']] = $row['startmeridian'];
@@ -1528,7 +1528,7 @@
 	       . "ORDER BY b.name";
 	$qh = doQuery($query, 101);
 	$blocks = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$blocks[$row['id']] = $row;
 	if(empty($blocks))
 		return;
@@ -1543,7 +1543,7 @@
 			       . "FROM blockWebDate "
 			       . "WHERE blockRequestid = $id";
 			$qh = doQuery($query, 101);
-			if(! $row = mysql_fetch_assoc($qh))
+			if(! $row = mysqli_fetch_assoc($qh))
 				abort(101);
 			$blocks[$id] = array_merge($request, $row);
 			$wdays = array();
@@ -1564,7 +1564,7 @@
 			       . "WHERE blockRequestid = {$request['id']} "
 			       . "ORDER BY startmeridian, starthour, startminute";
 			$qh = doQuery($query, 101);
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				$blocks[$id]['swhour'][$row['order']] = $row['starthour'];
 				$blocks[$id]['swminute'][$row['order']] = $row['startminute'];
 				$blocks[$id]['swmeridian'][$row['order']] = $row['startmeridian'];
@@ -1581,7 +1581,7 @@
 			       . "FROM blockWebDate "
 			       . "WHERE blockRequestid = $id";
 			$qh = doQuery($query, 101);
-			if(! $row = mysql_fetch_assoc($qh))
+			if(! $row = mysqli_fetch_assoc($qh))
 				abort(101);
 			$blocks[$id] = array_merge($request, $row);
 			$query = "SELECT starthour, "
@@ -1595,7 +1595,7 @@
 			       . "WHERE blockRequestid = {$request['id']} "
 			       . "ORDER BY startmeridian, starthour, startminute";
 			$qh = doQuery($query, 101);
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				$blocks[$id]['smhour'][$row['order']] = $row['starthour'];
 				$blocks[$id]['smminute'][$row['order']] = $row['startminute'];
 				$blocks[$id]['smmeridian'][$row['order']] = $row['startmeridian'];
@@ -1611,7 +1611,7 @@
 			       . "WHERE blockRequestid = $id "
 			       . "ORDER BY start";
 			$qh = doQuery($query, 101);
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				if($row['date'] == '00/00/00')
 					$blocks[$id]['date'][$row['order']] = '';
 				else
@@ -1627,7 +1627,7 @@
 			       . "FROM blockWebTime "
 			       . "WHERE blockRequestid = {$request['id']}";
 			$qh = doQuery($query, 101);
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				$blocks[$id]['slhour'][$row['order']] = $row['starthour'];
 				$blocks[$id]['slminute'][$row['order']] = $row['startminute'];
 				$blocks[$id]['slmeridian'][$row['order']] = $row['startmeridian'];
@@ -1823,7 +1823,7 @@
 	$h .= "  </tr>\n";
 	$d = '';
 	$groups = getUserGroups(0, $user['affiliationid']);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if($row['repeating'] == 'weekly') {
 			$query2 = "SELECT DATE_FORMAT(start, '%m/%d/%y') AS swdate, "
 			        .        "DATE_FORMAT(end, '%m/%d/%y')AS ewdate, " 
@@ -1833,7 +1833,7 @@
 			        . "FROM blockWebDate "
 			        . "WHERE blockRequestid = {$row['id']}";
 			$qh2 = doQuery($query2, 101);
-			if(! $row2 = mysql_fetch_assoc($qh2))
+			if(! $row2 = mysqli_fetch_assoc($qh2))
 				abort(101);
 			$row = array_merge($row, $row2);
 			$wdays = array();
@@ -1854,7 +1854,7 @@
 			        . "ORDER BY startmeridian, starthour, startminute";
 			$qh2 = doQuery($query2, 101);
 			$row['times'] = array();
-			while($row2 = mysql_fetch_assoc($qh2)) {
+			while($row2 = mysqli_fetch_assoc($qh2)) {
 				$row['swhour'][$row2['order']] = $row2['starthour'];
 				$row['swminute'][$row2['order']] = $row2['startminute'];
 				$row['swmeridian'][$row2['order']] = $row2['startmeridian'];
@@ -1878,7 +1878,7 @@
 			        . "FROM blockWebDate "
 			        . "WHERE blockRequestid = {$row['id']}";
 			$qh2 = doQuery($query2, 101);
-			if(! $row2 = mysql_fetch_assoc($qh2))
+			if(! $row2 = mysqli_fetch_assoc($qh2))
 				abort(101);
 			$row = array_merge($row, $row2);
 			$query2 = "SELECT starthour, "
@@ -1893,7 +1893,7 @@
 			        . "ORDER BY startmeridian, starthour, startminute";
 			$qh2 = doQuery($query2, 101);
 			$row['times'] = array();
-			while($row2 = mysql_fetch_assoc($qh2)) {
+			while($row2 = mysqli_fetch_assoc($qh2)) {
 				$row['smhour'][$row2['order']] = $row2['starthour'];
 				$row['smminute'][$row2['order']] = $row2['startminute'];
 				$row['smmeridian'][$row2['order']] = $row2['startmeridian'];
@@ -1916,7 +1916,7 @@
 			        . "WHERE blockRequestid = {$row['id']} "
 			        . "ORDER BY start";
 			$qh2 = doQuery($query2, 101);
-			while($row2 = mysql_fetch_assoc($qh2)) {
+			while($row2 = mysqli_fetch_assoc($qh2)) {
 				if($row2['date'] == '00/00/00')
 					$row['date'][$row2['order']] = '';
 				else
@@ -1934,7 +1934,7 @@
 			        . "WHERE blockRequestid = {$row['id']}";
 			$qh2 = doQuery($query2, 101);
 			$row['slots'] = array(); # yyyy-mm-dd|hh:mm|hh:mm
-			while($row2 = mysql_fetch_assoc($qh2)) {
+			while($row2 = mysqli_fetch_assoc($qh2)) {
 				$row['slhour'][$row2['order']] = $row2['starthour'];
 				$row['slminute'][$row2['order']] = $row2['startminute'];
 				$row['slmeridian'][$row2['order']] = $row2['startmeridian'];
@@ -2467,7 +2467,7 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function AJacceptBlockAllocationSubmit() {
-	global $mysql_link_vcl, $user;
+	global $mysqli_link_vcl, $user;
 	$blockid = getContinuationVar('blockid');
 	$comments = getContinuationVar('comments');
 	$validemail = getContinuationVar('validemail');
@@ -2523,9 +2523,9 @@
 	if(! $err) {
 		# update values for block allocation
 		if($validemail)
-			$esccomments = mysql_real_escape_string("COMMENTS: $comments|EMAIL: $emailtext");
+			$esccomments = vcl_mysql_escape_string("COMMENTS: $comments|EMAIL: $emailtext");
 		else
-			$esccomments = mysql_real_escape_string("COMMENTS: $comments|USER NOT EMAILED");
+			$esccomments = vcl_mysql_escape_string("COMMENTS: $comments|USER NOT EMAILED");
 		$query = "UPDATE blockRequest "
 				 . "SET name = '$name', ";
 		if($setusergroup)
@@ -2535,7 +2535,7 @@
 			    .     "managementnodeid = '$mnid' "
 		       . "WHERE id = $blockid";
 		doQuery($query, 101);
-		if(! mysql_affected_rows($mysql_link_vcl)) {
+		if(! mysqli_affected_rows($mysqli_link_vcl)) {
 			$errmsg = i("Error encountered while updating status of block allocation.");
 			$err = 1;
 		}
@@ -2694,7 +2694,7 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function AJrejectBlockAllocationSubmit() {
-	global $mysql_link_vcl;
+	global $mysqli_link_vcl;
 	$blockid = getContinuationVar('blockid');
 	$comments = getContinuationVar('comments');
 	$validemail = getContinuationVar('validemail');
@@ -2727,16 +2727,16 @@
 	if(! $err) {
 		# update values for block allocation
 		if($validemail)
-			$esccomments = mysql_real_escape_string("COMMENTS: $comments|EMAIL: $emailtext");
+			$esccomments = vcl_mysql_escape_string("COMMENTS: $comments|EMAIL: $emailtext");
 		else
-			$esccomments = mysql_real_escape_string("COMMENTS: $comments|REJECTREASON: $emailtext");
+			$esccomments = vcl_mysql_escape_string("COMMENTS: $comments|REJECTREASON: $emailtext");
 		$query = "UPDATE blockRequest "
 				 . "SET name = 'rejected', "
 				 .     "status = 'rejected', "
 				 .     "comments = '$esccomments' "
 				 . "WHERE id = $blockid";
 		doQuery($query, 101);
-		if(! mysql_affected_rows($mysql_link_vcl)) {
+		if(! mysqli_affected_rows($mysqli_link_vcl)) {
 			$errmsg = i("Error encountered while updating status of block allocation.");
 			$err = 1;
 		}
@@ -2785,7 +2785,7 @@
 	$qh = doQuery($query, 101);
 	$data = array();
 	$items = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$items[] = $row;
 	$cont = addContinuationsEntry('AJtoggleBlockTime', array('blockid' => $blockid));
 	$data['cont'] = $cont;
@@ -2809,7 +2809,7 @@
 	       . "FROM blockTimes "
 	       . "WHERE id = $timeid";
 	$qh = doQuery($query, 101);
-	if(! ($row = mysql_fetch_assoc($qh)) || $row['blockRequestid'] != $blockid) {
+	if(! ($row = mysqli_fetch_assoc($qh)) || $row['blockRequestid'] != $blockid) {
 		$data['error'] = i("Invalid block time submitted");
 		sendJSON($data);
 		return;
@@ -3347,7 +3347,7 @@
 	       . "ORDER BY t.start "
 	       . "LIMIT 1";
 	$qh = doQuery($query, 101);
-	if($data = mysql_fetch_assoc($qh)) {
+	if($data = mysqli_fetch_assoc($qh)) {
 		if(! is_numeric($data['subimages']))
 			$data['subimages'] = 0;
 		$query = "SELECT c.id, "
@@ -3370,7 +3370,7 @@
 		       .       "c.stateid = s.id";
 		$qh = doQuery($query, 101);
 		$data['comps'] = array();
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$data['comps'][$row['id']] = $row;
 		return $data;
 	}
@@ -3454,7 +3454,7 @@
 	       . "WHERE b.id = d.blockRequestid AND "
 	       .       "b.id = $blockid";
 	$qh = doQuery($query, 101);
-	$row = mysql_fetch_assoc($qh);
+	$row = mysqli_fetch_assoc($qh);
 	if(empty($row))
 		return $rt;
 	$row['wdayschecked'] = $rt['wdayschecked'];
@@ -3505,7 +3505,7 @@
 	$blockid = getContinuationVar('blockid');
 	$query = "SELECT repeating FROM blockRequest WHERE id = $blockid";
 	$qh = doQuery($query, 101);
-	if(! ($row = mysql_fetch_assoc($qh))) {
+	if(! ($row = mysqli_fetch_assoc($qh))) {
 		sendJSON(array('error' => i("Error: Failed to fetch start/end times for block allocation.")));
 		return;
 	}
@@ -3524,7 +3524,7 @@
 		$startms = array();
 		$endhs = array();
 		$endms = array();
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			$starth = hour12to24($row['starthour'], $row['startmeridian']);
 			$endh = hour12to24($row['endhour'], $row['endmeridian']);
 			$starths[] = $starth;
@@ -3550,7 +3550,7 @@
 		       . "WHERE blockRequestid = $blockid";
 		$qh = doQuery($query, 101);
 		$data = array();
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$data[$row['order']] = $row;
 		$query = "SELECT MONTH(start) AS month, "
 		       .        "DAY(start) AS day, "
@@ -3566,7 +3566,7 @@
 		$startms = array();
 		$endhs = array();
 		$endms = array();
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			$id = $row['days'];
 			$months[] = $row['month'];
 			$days[] = $row['day'];
@@ -3696,7 +3696,7 @@
 		       . "WHERE stateid IN (2, 3, 6, 8, 11) AND "
 		       .       "type = 'blade'";
 		$qh = doQuery($query, 101);
-		if($row = mysql_fetch_row($qh))
+		if($row = mysqli_fetch_row($qh))
 			$data['total'] = $row[0];
 	}
 	else
@@ -3743,7 +3743,7 @@
 		       .       "u.affiliationid = {$user['affiliationid']}";
 	}
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		for($binstart = $start, $binend = $start + 900, $binindex = 0; 
 		   $binend <= $end;
 		   $binstart += 900, $binend += 900, $binindex++) {
@@ -3770,7 +3770,7 @@
 		       . "WHERE stateid IN (2, 3, 6, 8, 11) AND "
 		       .       "type = 'virtualmachine'";
 		$qh = doQuery($query, 101);
-		if($row = mysql_fetch_row($qh))
+		if($row = mysqli_fetch_row($qh))
 			$data['total'] = $row[0];
 	}
 	else
@@ -3817,7 +3817,7 @@
 		       .       "u.affiliationid = {$user['affiliationid']}";
 	}
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		for($binstart = $start, $binend = $start + 900, $binindex = 0; 
 		   $binend <= $end;
 		   $binstart += 900, $binend += 900, $binindex++) {
@@ -3869,15 +3869,14 @@
 	$first = 1;
 	$firststart = '';
 	$laststart = '';
-	while($row = mysql_fetch_assoc($qh)) {
-		if($first && ! is_null($row['blockStart'])) {
+	while($row = mysqli_fetch_assoc($qh)) {
+		if(is_null($row['blockStart']))
+			continue;
+		if($first) {
 			$firststart = datetimeToUnix($row['blockStart']);
 			$first = 0;
 		}
-		elseif(! is_null($row['blockStart']))
-			$laststart = datetimeToUnix($row['blockStart']);
-		if(is_null($row['blockStart']))
-			continue;
+		$laststart = datetimeToUnix($row['blockStart']);
 		$percent = (int)($row['used'] / $row['allocated'] * 100);
 		$startts = datetimeToUnix($row['blockStart']);
 		$usage[$startts] = array('percent' => $percent,
diff --git a/web/.ht-inc/computer.php b/web/.ht-inc/computer.php
index 6c6668d..3a9e117 100644
--- a/web/.ht-inc/computer.php
+++ b/web/.ht-inc/computer.php
@@ -821,7 +821,7 @@
 		       . "ORDER BY rq.start "
 		       . "LIMIT 1";
 		$qh = doQuery($query);
-		if($row = mysql_fetch_assoc($qh)) {
+		if($row = mysqli_fetch_assoc($qh)) {
 			$cdata = $this->basecdata;
 			$cdata['compid'] = $rscid;
 			$cont = addContinuationsEntry('AJcanceltovmhostinuse', $cdata, 300, 1, 0);
@@ -973,7 +973,7 @@
 				       .       "vm.stateid = 10";
 				$qh = doQuery($query);
 				$vmids = array();
-				while($row = mysql_fetch_assoc($qh))
+				while($row = mysqli_fetch_assoc($qh))
 					$vmids[] = $row['id'];
 				$allids = implode(',', $vmids);
 				if($data['provisioning'] != 'none')  {
@@ -1235,7 +1235,7 @@
 					       .       "vm.vmhostid = v.id";
 					$qh = doQuery($query);
 					$fail = 0;
-					while($row = mysql_fetch_assoc($qh)) {
+					while($row = mysqli_fetch_assoc($qh)) {
 						if(! simpleAddRequest($row['id'], $imageid, $revid, $startdt,
 						                      $enddt, 18, $vclreloadid)) {
 							$fail = 1;
@@ -1357,7 +1357,7 @@
 					       .       "vm.vmhostid = v.id";
 					$qh = doQuery($query);
 					$fails = array();
-					while($row = mysql_fetch_assoc($qh)) {
+					while($row = mysqli_fetch_assoc($qh)) {
 						if(! simpleAddRequest($row['id'], $imageid, $revid, $startdt,
 						                      $enddt, 18, $vclreloadid)) {
 							$fails[] = $row['id'];
@@ -1451,7 +1451,7 @@
 							$qh = doQuery($query);
 							$fails = array();
 							$cnt = 0;
-							while($row = mysql_fetch_assoc($qh)) {
+							while($row = mysqli_fetch_assoc($qh)) {
 								$cnt++;
 								if(! simpleAddRequest($row['id'], $imageid, $revid, $startdt,
 								                      $enddt, 18, $vclreloadid)) {
@@ -1781,7 +1781,7 @@
 			       .       "deleted = 0";
 			$qh = doQuery($query);
 			$exists = array();
-			while($row = mysql_fetch_assoc($qh))
+			while($row = mysqli_fetch_assoc($qh))
 				$exists[] = $row['hostname'];
 			if(count($exists)) {
 				$hosts = implode(', ', $exists);
@@ -2049,7 +2049,7 @@
 				       .       "rq.laststateid NOT IN (1,5,11,12) AND "
 				       .       "rq.userid != $vclreloadid";
 				$qh = doQuery($query);
-				if(mysql_num_rows($qh)) {
+				if(mysqli_num_rows($qh)) {
 					$return['error'] = 1;
 					$errormsg[] = "This computer has an active reservation. NAT settings cannot be changed for computers having<br>active reservations.";
 				}
@@ -2099,7 +2099,7 @@
 				       .       "rq.laststateid NOT IN (1,5,11,12) AND "
 				       .       "rq.userid != $vclreloadid";
 				$qh = doQuery($query);
-				if(mysql_num_rows($qh)) {
+				if(mysqli_num_rows($qh)) {
 					$return['error'] = 1;
 					$errormsg[] = "This computer is the NAT host for other computers that have active reservations. NAT host<br>settings cannot be changed while providing NAT for active reservations.";
 				}
@@ -2140,7 +2140,7 @@
 		if(! empty($compid))
 			$query .= " AND id != $compid";
 		$qh = doQuery($query);
-		if(mysql_num_rows($qh))
+		if(mysqli_num_rows($qh))
 			return 1;
 		return 0;
 	}
@@ -2170,7 +2170,7 @@
 		if(! empty($compid))
 			$query .= " AND id != $compid";
 		$qh = doQuery($query);
-		if(mysql_num_rows($qh))
+		if(mysqli_num_rows($qh))
 			return 1;
 		return 0;
 	}
@@ -2199,7 +2199,7 @@
 		if(! empty($compid))
 			$query .= " AND id != $compid";
 		$qh = doQuery($query);
-		if(mysql_num_rows($qh))
+		if(mysqli_num_rows($qh))
 			return 1;
 		return 0;
 	}
@@ -2377,7 +2377,7 @@
 	///
 	////////////////////////////////////////////////////////////////////////////////
 	function AJcanceltovmhostinuse() {
-		global $mysql_link_vcl;
+		global $mysqli_link_vcl;
 		$compid = getContinuationVar('compid');
 		$type = 'none';
 		$query = "DELETE FROM request "
@@ -2387,7 +2387,7 @@
 		       .              "FROM reservation "
 		       .              "WHERE computerid = $compid)";
 		doQuery($query);
-		if(mysql_affected_rows($mysql_link_vcl))
+		if(mysqli_affected_rows($mysqli_link_vcl))
 			$type = 'future';
 		$query = "UPDATE request rq, "
 		       .         "reservation rs, "
@@ -2399,7 +2399,7 @@
 		       .       "rq.laststateid = ls.id AND "
 		       .       "ls.name = 'tovmhostinuse'";
 		doQuery($query);
-		if(mysql_affected_rows($mysql_link_vcl))
+		if(mysqli_affected_rows($mysqli_link_vcl))
 			$type = 'current';
 		$query = "SELECT rq.start "
 		       . "FROM request rq, "
@@ -2415,7 +2415,7 @@
 		       .       "rq.end > NOW() "
 		       . "ORDER BY rq.start";
 		$qh = doQuery($query);
-		if(mysql_num_rows($qh))
+		if(mysqli_num_rows($qh))
 			$arr = array('status' => 'failed');
 		else {
 			if($type == 'now')
@@ -2477,7 +2477,7 @@
 		       . "ORDER BY rq.start "
 		       . "LIMIT 1";
 		$qh = doQuery($query);
-		if($row = mysql_fetch_assoc($qh)) {
+		if($row = mysqli_fetch_assoc($qh)) {
 			if(! retryGetSemaphore($imageid, $revid, $mnid, $compid, $startdt, $enddt, $row['id']))
 				return 0;
 			# update existing reservation
@@ -2720,7 +2720,7 @@
 			       .       "vm.vmhostid = v.id";
 			$qh = doQuery($query);
 			$fail = 0;
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				if(! simpleAddRequest($row['id'], $imageid, $revid, $startdt,
 				                      $enddt, 18, $vclreloadid)) {
 					$fail = 1;
@@ -2811,7 +2811,7 @@
 			       . "WHERE v.computerid = $compid AND "
 			       .       "vm.vmhostid = v.id";
 			$qh = doQuery($query);
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				$checkstart = getExistingChangeStateStartTime($row['id'], 18);
 				if($checkstart) {
 					if($checkstart > $start)
@@ -3069,7 +3069,7 @@
 							 .       "rq.end > '$startstamp' AND "
 							 .       "s.name NOT IN ('complete', 'deleted', 'failed', 'timeout')";
 					$qh = doQuery($query);
-					if(! mysql_num_rows($qh))
+					if(! mysqli_num_rows($qh))
 						$reloadnow[] = $compid;
 					else
 						$reloadasap[] = $compid;
@@ -3160,7 +3160,7 @@
 		       .       "s.name NOT IN ('deleted', 'failed', 'complete') AND "
 		       .       "rq.end > NOW()";
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$skipcompids[] = $row['computerid'];
 		$query = "SELECT DISTINCT bc.computerid "
 		       . "FROM blockTimes bt, "
@@ -3173,7 +3173,7 @@
 		       .       "bt.skip = 0 AND "
 		       .       "br.status = 'accepted'";
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$skipcompids[] = $row['computerid'];
 		$delids = array_diff($compids, $skipcompids);
 		$msg = '';
@@ -3254,7 +3254,7 @@
 		       .       "s.name NOT IN ('deleted', 'failed', 'complete') AND "
 		       .       "rq.end > NOW()";
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$fails[] = $row['computerid'];
 		$delids = array_diff($compids, $fails);
 
@@ -3429,7 +3429,7 @@
 			       .       "rq.stateid NOT IN (1, 5, 11, 12) AND " # TODO might not want 11 (timeout)
 			       .       "rs.computerid IN ($allids)";
 			$qh = doQuery($query);
-			while($row = mysql_fetch_assoc($qh))
+			while($row = mysqli_fetch_assoc($qh))
 				$inusecompids[$row['computerid']] = 1;
 
 			# check initial conditions
@@ -3491,7 +3491,7 @@
 				       . "WHERE h.id IN ($ids) "
 				       . "GROUP BY vh.computerid";
 				$qh = doQuery($query);
-				while($row = mysql_fetch_assoc($qh)) {
+				while($row = mysqli_fetch_assoc($qh)) {
 					if($row['count'])
 						$fails['hasvms'][] = $row['id'];
 					else
@@ -3507,7 +3507,7 @@
 				       . "LEFT JOIN computer h ON (vh.computerid = h.id) "
 				       . "WHERE vm.id IN ($ids)";
 				$qh = doQuery($query);
-				while($row = mysql_fetch_assoc($qh)) {
+				while($row = mysqli_fetch_assoc($qh)) {
 					if($row['stateid'] != 20)
 						$fails['hostfail'][] = $row['id'];
 					else
@@ -3578,7 +3578,7 @@
 				$notes = processInputVar('notes', ARG_STRING);
 				if(get_magic_quotes_gpc())
 					$notes = stripslashes($notes);
-				$notes = mysql_real_escape_string($notes);
+				$notes = vcl_mysql_escape_string($notes);
 				$notes = $user["unityid"] . " " . unixToDatetime(time()) . "@"
 				       . $notes;
 			}
@@ -3634,7 +3634,7 @@
 						       .       "vm.vmhostid = v.id";
 						$qh = doQuery($query);
 						$setnoteids = array();
-						while($row = mysql_fetch_assoc($qh)) {
+						while($row = mysqli_fetch_assoc($qh)) {
 							$checkstart = getExistingChangeStateStartTime($row['id'], 18);
 							if($checkstart) {
 								if($checkstart > $reloadstart)
@@ -3865,7 +3865,7 @@
 			       . "WHERE v.computerid IN ($allids) AND "
 			       .       "vm.vmhostid = v.id";
 			$qh = doQuery($query);
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				if(! array_key_exists($row['compid'], $maintvmids))
 					$maintvmids[$row['compid']] = array();
 				if($row['vmstateid'] == 10 &&
@@ -4000,8 +4000,8 @@
 								       . "GROUP BY rs.computerid "
 								       . "ORDER BY start";
 								$qh = doQuery($query);
-								if(mysql_num_rows($qh) == count($allvmids)) {
-									while($row = mysql_fetch_assoc($qh)) {
+								if(mysqli_num_rows($qh) == count($allvmids)) {
+									while($row = mysqli_fetch_assoc($qh)) {
 										$times[$row['start']] = 1;
 										$reqids[] = $row['id'];
 									}
@@ -4022,7 +4022,7 @@
 										       .       "rs.imageid = '{$profiles[$profileid]['imageid']}' AND "
 										       .       "rq.stateid = 21";
 										$qh = doQuery($query);
-										if($row = mysql_fetch_assoc($qh)) {
+										if($row = mysqli_fetch_assoc($qh)) {
 											# node was previously scheduled to be reloaded for vmhostinuse
 											if($times[0] > $start) {
 												# update existing reservations
@@ -4286,7 +4286,7 @@
 		       .       "rq.start <= '$startcheckdt' AND "
 		       .       "rq.end > NOW()";
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$fails[] = $row['computerid'];
 
 		$nowids = array_diff($compids, $fails);
@@ -4454,7 +4454,7 @@
 		       .       "rq.laststateid NOT IN (1,5,11,12) AND "
 		       .       "rq.userid != $vclreloadid";
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$inusecompids[] = $row['computerid'];
 
 		$tmp = getUserResources(array($this->restype . "Admin"), array("administer"), 0, 1);
@@ -4799,7 +4799,7 @@
 		       .       "s.name NOT IN ('timedout','deleted','complete')";
 		$qh = doQuery($query);
 		$data = array();
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			$msg = "<strong>{$row['hostname']}</strong><br>";
 			if($row['start'] == '') {
 				$msg .= "(No reservations)<br><hr>";
@@ -4888,7 +4888,7 @@
 		       .          "l.start DESC";
 		$qh = doQuery($query);
 		$data = array();
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			if(! is_numeric($row['end']))
 				continue;
 			$msg = "<strong>{$row['hostname']}</strong><br>";
@@ -5076,7 +5076,7 @@
 		       .       "eth1macaddress IN ('$ineth1s')";
 		$qh = doQuery($query);
 		$errmsg = '';
-		if(mysql_num_rows($qh)) {
+		if(mysqli_num_rows($qh)) {
 			$errmsg .= "The specified starting MAC address combined with the number ";
 			$errmsg .= "of computers entered will result in a MAC address already ";
 			$errmsg .= "assigned to another computer.";
diff --git a/web/.ht-inc/conf-default.php b/web/.ht-inc/conf-default.php
index 255991b..e64ea50 100644
--- a/web/.ht-inc/conf-default.php
+++ b/web/.ht-inc/conf-default.php
@@ -56,11 +56,15 @@
 
 
 #######################   end required modifications ###########################
+$host = $_SERVER['HTTP_HOST'];
+if (strpos($host, ':')) {
+	$host = substr($host, 0, strpos($host, ':'));
+}
 
 define("BASEURL", "https://{$_SERVER['HTTP_HOST']}/vcl");   // no trailing slash - all of the URL except /index.php
 define("SCRIPT", "/index.php");                 // this should only be "/index.php" unless you rename index.php to something else
 define("HOMEURL", "https://{$_SERVER['HTTP_HOST']}/vcl/"); // url to go to when someone clicks HOME or Logout
-define("COOKIEDOMAIN", "{$_SERVER['HTTP_HOST']}");       // domain in which cookies are set
+define("COOKIEDOMAIN", "$host");       // domain in which cookies are set
 
 define("DEFAULTGROUP", "adminUsers"); // if a user is in no groups, use reservation
 										  //   length attriubtes from this group
diff --git a/web/.ht-inc/config.php b/web/.ht-inc/config.php
index 3ed2cb2..531424d 100644
--- a/web/.ht-inc/config.php
+++ b/web/.ht-inc/config.php
@@ -65,7 +65,7 @@
 		$query .= "ORDER BY cv.configid, cv.name";
 		$variables = array();
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$variables[$row['configid']][$row['id']] = $row;
 
 		# config subimages
@@ -85,7 +85,7 @@
 			$query .= "AND configid = $id ";
 		$query .= "ORDER BY s.configid, i.prettyname";
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$variables[$row['configid']][$row['id']] = $row;
 
 		# configs
@@ -121,7 +121,7 @@
 			$query .= " AND c.deleted = 0";
 		$qh = doQuery($query);
 		$configs = array();
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			if(array_key_exists($row['id'], $variables))
 				$row['variables'] = $variables[$row['id']];
 			else
@@ -166,7 +166,7 @@
 		       .       "c.configtypeid = ct.id AND "
 		       .       "c.deleted = 0";
 		$qh = doQuery($query);
-		if($row = mysql_fetch_assoc($qh))
+		if($row = mysqli_fetch_assoc($qh))
 			return $row;
 		else
 			return NULL;
@@ -245,11 +245,11 @@
 		}
 		$sets = array();
 		if($curdata['name'] != $vars['name']) {
-			$name = mysql_real_escape_string($vars['name']);
+			$name = vcl_mysql_escape_string($vars['name']);
 			$sets[] = "name = '$name'";
 		}
 		if($curdata['data'] != $vars['data']) {
-			$data = mysql_real_escape_string($vars['data']);
+			$data = vcl_mysql_escape_string($vars['data']);
 			$sets[] = "data = '$data'";
 		}
 		if($curdata['ownerid'] != $vars['ownerid'])
@@ -319,11 +319,11 @@
 				}
 				$sets = array();
 				if($vardata['name'] != $newvars[$id]['name']) {
-					$name = mysql_real_escape_string($newvars[$id]['name']);
+					$name = vcl_mysql_escape_string($newvars[$id]['name']);
 					$sets[] = "name = '$name'";
 				}
 				if($vardata['identifier'] != $newvars[$id]['identifier']) {
-					$identifier = mysql_real_escape_string($newvars[$id]['identifier']);
+					$identifier = vcl_mysql_escape_string($newvars[$id]['identifier']);
 					$sets[] = "identifier = '$identifier'";
 				}
 				if($vardata['datatypeid'] != $newvars[$id]['datatypeid']) {
@@ -332,7 +332,7 @@
 					$sets[] = "datatypeid = '{$newvars[$id]['datatypeid']}'";
 				}
 				if($vardata['defaultvalue'] != $newvars[$id]['defaultvalue']) {
-					$defaultvalue = mysql_real_escape_string($newvars[$id]['defaultvalue']);
+					$defaultvalue = vcl_mysql_escape_string($newvars[$id]['defaultvalue']);
 					$sets[] = "defaultvalue = '$defaultvalue'";
 				}
 				if($vardata['required'] != $newvars[$id]['required']) {
@@ -377,9 +377,9 @@
 		$inserts = array();
 		$datatypes = getConfigDataTypes();
 		foreach($newvars as $var) {
-			$name = mysql_real_escape_string($var['name']);
-			$identifier = mysql_real_escape_string($var['identifier']);
-			$defaultvalue = mysql_real_escape_string($var['defaultvalue']);
+			$name = vcl_mysql_escape_string($var['name']);
+			$identifier = vcl_mysql_escape_string($var['identifier']);
+			$defaultvalue = vcl_mysql_escape_string($var['defaultvalue']);
 			if(! array_key_exists($var['datatypeid'], $datatypes))
 				$var['datatypeid'] = $this->findDataTypeID($var['defaultvalue'], $datatypes);
 			$inserts[] = "('$name', "
@@ -407,7 +407,7 @@
 	///
 	////////////////////////////////////////////////////////////////////////////////
 	function addResource($vars) {
-		$name = mysql_real_escape_string($vars['name']);
+		$name = vcl_mysql_escape_string($vars['name']);
 		if($vars['type'] == 'Cluster') {
 			$query = "INSERT INTO config "
 			       .        "(name, "
@@ -436,7 +436,7 @@
 			doQuery($query);
 		}
 		else {
-			$data = mysql_real_escape_string($vars['data']);
+			$data = vcl_mysql_escape_string($vars['data']);
 			$query = "INSERT INTO config "
 			       .        "(name, "
 			       .        "configtypeid, "
@@ -501,10 +501,10 @@
 			return 0;
 		}
 		# check for existance of name
-		$name = mysql_real_escape_string($return['name']);
+		$name = vcl_mysql_escape_string($return['name']);
 		$query = "SELECT id FROM config WHERE name = '$name' AND id != $configid";
 		$qh = doQuery($query);
-		if(mysql_num_rows($qh)) {
+		if(mysqli_num_rows($qh)) {
 			$this->errmsg = "Another config with this name already exists.";
 			return 0;
 		}
@@ -1152,7 +1152,7 @@
 		       .       "c.deleted = 0";
 		$configmaps = array();
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			switch($row['configmaptype']) {
 				case "Image":
 					$row['mapto'] = $row['image'];
@@ -1478,7 +1478,7 @@
 		       .       "configstageid = {$return['stageid']} AND "
 		       .       "id != $configmapid";
 		$qh = doQuery($query);
-		if(mysql_num_rows($qh)) {
+		if(mysqli_num_rows($qh)) {
 			$this->errmsg = "The specified mapping already exists.";
 			return 0;
 		}
@@ -1526,7 +1526,7 @@
 		       .       "c.id in ($inlist)";
 		$configs = array();
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$configs[$row['id']] = $row['name'];
 		return $configs;
 	}
@@ -1542,7 +1542,7 @@
 		$query = "SELECT id, name FROM configstage ORDER BY name";
 		$stages = array();
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$stages[$row['id']] = $row['name'];
 		return $stages;
 	}
@@ -1597,7 +1597,7 @@
 			       .       "ct.prettyname = 'Config' AND "
 			       .       "cm.configid = c.id";
 			$qh = doQuery($query);
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				if($row['subid'] == $configid)
 					return $row['config'];
 				if($reccnt < 20) {
@@ -1624,7 +1624,7 @@
 			       .       "ct.prettyname = 'Subimage' AND "
 			       .       "cm.configid = c.id";
 			$qh = doQuery($query);
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				if($row['configid'] == $configid)
 					return $row['config'];
 				if($reccnt < 20) {
diff --git a/web/.ht-inc/dashboard.php b/web/.ht-inc/dashboard.php
index 78e469c..3c2df3f 100644
--- a/web/.ht-inc/dashboard.php
+++ b/web/.ht-inc/dashboard.php
@@ -193,22 +193,22 @@
 				 .       "rq.end > NOW()";
 	}
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_row($qh))
+	if($row = mysqli_fetch_row($qh))
 		$data[0]['val'] = $row[0];
 
 	$query = "SELECT COUNT(id) FROM computer WHERE stateid IN (2, 3, 6, 8, 11)";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_row($qh))
+	if($row = mysqli_fetch_row($qh))
 		$data[1]['val'] = $row[0];
 
 	$query = "SELECT COUNT(id) FROM computer WHERE stateid = 8";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_row($qh))
+	if($row = mysqli_fetch_row($qh))
 		$data[2]['val'] = $row[0];
 
 	$query = "SELECT COUNT(id) FROM computer WHERE stateid = 5";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_row($qh))
+	if($row = mysqli_fetch_row($qh))
 		$data[3]['val'] = $row[0];
 	return $data;
 }
@@ -259,7 +259,7 @@
 	}
 	$data = array();
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$data[] = $row;
 	return $data;
 }
@@ -310,7 +310,7 @@
 	}
 	$data = array();
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$data[] = $row;
 	return $data;
 }
@@ -360,7 +360,7 @@
 	}
 	$data = array();
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$data[] = $row;
 	return $data;
 }
@@ -407,7 +407,7 @@
 	}
 	$data = array();
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$data[] = $row;
 	return $data;
 }
@@ -458,7 +458,7 @@
 	}
 	$data = array();
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$data[] = $row;
 	return $data;
 }
@@ -522,7 +522,7 @@
 		       .       "l.userid != $reloadid";
 	}
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if($row['stateid'] == 14)
 			$row['stateid'] = $row['laststateid'];
 		if($row['end'] > time() &&
@@ -583,7 +583,7 @@
 				 .       "bt.end > NOW()";
 	}
 	$qh = doQuery($query, 101);
-	$row = mysql_fetch_row($qh);
+	$row = mysqli_fetch_row($qh);
 	$blockcount = $row[0];
 	# computers in blockComputers for active allocations
 	if($affilid == 0) {
@@ -612,7 +612,7 @@
 	$qh = doQuery($query, 101);
 	$total = 0;
 	$used = 0;
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$total++;
 		if($row['stateid'] == 3 || $row['stateid'] == 8)
 			$used++;
@@ -642,7 +642,7 @@
 	}
 	$alloc = 0;
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$alloc += $row['numMachines'];
 	if($alloc)
 		$failed = sprintf('%d / %d (%0.2f %%)', ($alloc - $total), $alloc, (($alloc - $total) / $alloc * 100));
@@ -700,7 +700,7 @@
 	$query .= "ORDER BY rq.start";
 	$qh = doQuery($query, 101);
 	$data = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$tmp = explode('.', $row['computer']);
 		$row['computer'] = $tmp[0];
 		$row['start'] = date('D h:i', $row['start']);
@@ -758,7 +758,7 @@
 	$query .= "ORDER BY rq.start";
 	$qh = doQuery($query, 101);
 	$data = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if(is_null($row['revisioncomments']))
 			$row['revisioncomments'] = '(none)';
 		$tmp = explode('.', $row['computer']);
@@ -816,7 +816,7 @@
 	$current = array();
 	$old = array();
 	$never = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$tmp = explode('.', $row['hostname']);
 		$row['hostname'] = $tmp[0];
 		if($row['checkin'] < 0)
diff --git a/web/.ht-inc/groups.php b/web/.ht-inc/groups.php
index 29ae0f4..306395e 100644
--- a/web/.ht-inc/groups.php
+++ b/web/.ht-inc/groups.php
@@ -1102,7 +1102,7 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function checkForGroupName($name, $type, $id, $extraid) {
-	$name = mysql_real_escape_string($name);
+	$name = vcl_mysql_escape_string($name);
 	if($type == "user")
 		$query = "SELECT id FROM usergroup "
 		       . "WHERE name = '$name' AND "
@@ -1114,7 +1114,7 @@
 	if(! empty($id))
 		$query .= " AND id != $id";
 	$qh = doQuery($query, 101);
-	if(mysql_num_rows($qh))
+	if(mysqli_num_rows($qh))
 		return 1;
 	return 0;
 }
@@ -1162,7 +1162,7 @@
 		       . "WHERE id = {$data['groupid']}";
 	}
 	doQuery($query, 300);
-	return mysql_affected_rows($GLOBALS['mysql_link_vcl']);
+	return mysqli_affected_rows($GLOBALS['mysqli_link_vcl']);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1221,7 +1221,7 @@
 	}
 	$qh = doQuery($query, 305);
 	clearPrivCache();
-	return mysql_affected_rows($GLOBALS['mysql_link_vcl']);
+	return mysqli_affected_rows($GLOBALS['mysqli_link_vcl']);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1254,7 +1254,7 @@
 		       .       "rg.resourcetypeid = rt.id";
 		$usedby = array();
 		$qh = doQuery($query, 310);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$usedby[] = $row['name'];
 		if(count($usedby)) {
 			$msgs[] = "<h3>Owning User Group for Resource Groups</h3>\n"
@@ -1269,7 +1269,7 @@
 				 .       "ug.affiliationid = a.id";
 		$usedby = array();
 		$qh = doQuery($query, 313);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$usedby[] = $row['name'];
 		if(count($usedby)) {
 			$msgs[] = "<h3>'Editable by' Group for User Groups</h3>\n"
@@ -1281,7 +1281,7 @@
 		       . "WHERE usergroupid = $groupid";
 		$qh = doQuery($query);
 		$usedby = array();
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$usedby[] = getNodePath($row['privnodeid']);
 		if(count($usedby)) {
 			$msgs[] = "<h3>Assigned at Privilege Nodes</h3>\n"
@@ -1294,7 +1294,7 @@
 		       .   "AND status IN ('requested', 'accepted')";
 		$qh = doQuery($query, 311);
 		$usedby = array();
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$usedby[] = $row['name'];
 		if(count($usedby)) {
 			$msgs[] = "<h3>Assigned for Block Allocations</h3>\n"
@@ -1304,7 +1304,7 @@
 		$query = "SELECT name FROM serverprofile WHERE admingroupid = $groupid";
 		$qh = doQuery($query);
 		$usedby = array();
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$usedby[] = $row['name'];
 		if(count($usedby)) {
 			$msgs[] = "<h3>Admin User Group for Server Profiles</h3>\n"
@@ -1314,7 +1314,7 @@
 		$query = "SELECT name FROM serverprofile WHERE logingroupid = $groupid";
 		$qh = doQuery($query);
 		$usedby = array();
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$usedby[] = $row['name'];
 		if(count($usedby)) {
 			$msgs[] = "<h3>Access User Group for Server Profiles</h3>\n"
@@ -1328,7 +1328,7 @@
 		       .       "s.requestid = rq.id";
 		$qh = doQuery($query);
 		$usedby = array();
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$usedby[] = $row['name'];
 		if(count($usedby)) {
 			$msgs[] = "<h3>Admin User Group for Server Requests</h3>\n"
@@ -1342,7 +1342,7 @@
 		       .       "s.requestid = rq.id";
 		$qh = doQuery($query);
 		$usedby = array();
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$usedby[] = $row['name'];
 		if(count($usedby)) {
 			$msgs[] = "<h3>Access User Group for Server Requests</h3>\n"
@@ -1366,7 +1366,7 @@
 	$query = "SELECT hostname FROM managementnode WHERE imagelibgroupid = $groupid";
 	$qh = doQuery($query);
 	$usedby = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$usedby[] = $row['hostname'];
 	if(count($usedby)) {
 		$msgs[] = "<h3>Management Node Image Library Group</h3>\n"
@@ -1376,7 +1376,7 @@
 	$query = "SELECT DISTINCT privnodeid FROM resourcepriv WHERE resourcegroupid = $groupid";
 	$qh = doQuery($query);
 	$usedby = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$usedby[] = getNodePath($row['privnodeid']);
 	if(count($usedby)) {
 		$msgs[] = "<h3>Assigned at Privilege Nodes</h3>\n"
diff --git a/web/.ht-inc/help.php b/web/.ht-inc/help.php
index dd73adb..f632f6b 100644
--- a/web/.ht-inc/help.php
+++ b/web/.ht-inc/help.php
@@ -168,7 +168,7 @@
 	       . "ORDER BY l.finalend DESC "
 	       . "LIMIT 5";
 	$qh = doQuery($query, 290);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		# only include 1 computer from cluster reservations
 		if(array_key_exists($row['id'], $requests))
 			continue;
diff --git a/web/.ht-inc/image.php b/web/.ht-inc/image.php
index 9447aea..4e07dcd 100644
--- a/web/.ht-inc/image.php
+++ b/web/.ht-inc/image.php
@@ -187,7 +187,7 @@
 		       . "ORDER BY rq.end DESC "
 		       . "LIMIT 1";
 		$qh = doQuery($query);
-		if($row = mysql_fetch_assoc($qh))
+		if($row = mysqli_fetch_assoc($qh))
 			$msgs[] = sprintf(i("There is at least one <strong>reservation</strong> for this image. The latest end time is %s."), prettyDatetime($row['end'], 1));;
 
 		# check blockComputers
@@ -205,7 +205,7 @@
 		       . "ORDER BY bt.end DESC "
 		       . "LIMIT 1";
 		$qh = doQuery($query);
-		if($row = mysql_fetch_assoc($qh))
+		if($row = mysqli_fetch_assoc($qh))
 			$msgs[] = sprintf(i("There is at least one <strong>Block Allocation</strong> with computers currently allocated with this image. Block Allocation %s has the latest end time which is %s."), $row['name'], prettyDatetime($row['end'], 1));
 
 		# check blockRequest
@@ -221,7 +221,7 @@
 		       . "ORDER BY bt.end DESC "
 		       . "LIMIT 1";
 		$qh = doQuery($query);
-		if($row = mysql_fetch_assoc($qh))
+		if($row = mysqli_fetch_assoc($qh))
 			$msgs[] = sprintf(i("There is at least one <strong>Block Allocation</strong> configured to use this image. Block Allocation %s has the latest end time which is %s."), $row['name'], prettyDatetime($row['end'], 1));
 
 		# check serverprofile
@@ -230,7 +230,7 @@
 		       . "WHERE imageid = $rscid";
 		$qh = doQuery($query);
 		$profiles = array();
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$profiles[] = $row['name'];
 		if(count($profiles))
 			$msgs[] = i("The following <strong>Server Profiles</strong> are configured to use this image:") . "<br><br>\n" . implode("<br>\n", $profiles);
@@ -245,7 +245,7 @@
 		       .       "s.imagemetaid = im.id AND "
 		       .       "s.imageid = $rscid";
 		$images = array();
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$images[] = $row['prettyname'];
 		if(count($images))
 			$msgs[] = i("The following <strong>images</strong> have the selected image assigned as a <strong>subimage</strong>:") . "<br><br>\n" . implode("<br>\n", $images);
@@ -255,7 +255,7 @@
 		       . "FROM vmprofile "
 		       . "WHERE imageid = $rscid";
 		$profiles = array();
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$profiles[] = $row['profilename'];
 		if(count($profiles))
 			$msgs[] = i("The following <strong>VM Host Profiles</strong> have the this image selected:") . "<br><br>\n" . implode("<br>\n", $profiles);
@@ -801,12 +801,12 @@
 			$updates[] = "forcheckout = {$data['checkout']}";
 		# description
 		if($data['desc'] != $olddata['description']) {
-			$escdesc = mysql_real_escape_string($data['desc']);
+			$escdesc = vcl_mysql_escape_string($data['desc']);
 			$updates[] = "description = '$escdesc'";
 		}
 		# usage
 		if($data['usage'] != $olddata['usage']) {
-			$escusage = mysql_real_escape_string($data['usage']);
+			$escusage = vcl_mysql_escape_string($data['usage']);
 			$updates[] = "`usage` = '$escusage'";
 		}
 
@@ -821,7 +821,7 @@
 		if($olddata['ostype'] == 'windows') {
 			if($data['adauthenabled'] != $olddata['adauthenabled']) {
 				if($data['adauthenabled']) {
-					$esc_baseou = mysql_real_escape_string($data['baseou']);
+					$esc_baseou = vcl_mysql_escape_string($data['baseou']);
 					$query = "INSERT INTO imageaddomain "
 					       .        "(imageid, "
 					       .        "addomainid, "
@@ -841,7 +841,7 @@
 			elseif($data['adauthenabled'] &&
 			       ($data['addomainid'] != $olddata['addomainid'] ||
 			       $data['baseou'] != $olddata['baseOU'])) {
-				$esc_baseou = mysql_real_escape_string($data['baseou']);
+				$esc_baseou = vcl_mysql_escape_string($data['baseou']);
 				$query = "UPDATE imageaddomain "
 				       . "SET addomainid = {$data['addomainid']}, "
 				       .     "baseOU = '$esc_baseou' "
@@ -868,7 +868,7 @@
 					 .        "{$data['sethostname']})";
 			doQuery($query, 101);
 			$qh = doQuery("SELECT LAST_INSERT_ID() FROM imagemeta", 101);
-			if(! $row = mysql_fetch_row($qh))
+			if(! $row = mysqli_fetch_row($qh))
 				abort(101);
 			$imagemetaid = $row[0];
 			$query = "UPDATE image "
@@ -979,7 +979,7 @@
 		       .       "rq.id = rs.requestid";
 		doQuery($query, 101);
 
-		$agree = mysql_real_escape_string(getContinuationVar('agree'));
+		$agree = vcl_mysql_escape_string(getContinuationVar('agree'));
 		$query = "INSERT INTO clickThroughs "
 		       .        "(userid, "
 		       .        "imageid, "
@@ -1095,10 +1095,10 @@
 		       . "ORDER BY revision DESC "
 		       . "LIMIT 1";
 		$qh = doQuery($query, 101);
-		$row = mysql_fetch_assoc($qh);
+		$row = mysqli_fetch_assoc($qh);
 		$newrevision = $row['revision'] + 1;
 		$newname = preg_replace("/{$row['revision']}$/", $newrevision, $row['imagename']);
-		$comments = mysql_real_escape_string($comments);
+		$comments = vcl_mysql_escape_string($comments);
 		$query = "INSERT INTO imagerevision "
 		       .        "(imageid, "
 		       .        "revision, "
@@ -1155,7 +1155,7 @@
 		if($autocaptured)
 			return 1;
 	
-		$agree = mysql_real_escape_string(getContinuationVar('agree'));
+		$agree = vcl_mysql_escape_string(getContinuationVar('agree'));
 		$query = "INSERT INTO clickThroughs "
 		       .        "(userid, "
 		       .        "imageid, "
@@ -1188,9 +1188,9 @@
 	/////////////////////////////////////////////////////////////////////////////
 	function addResource($data) {
 		global $user;
-		$data['desc'] = mysql_real_escape_string($data['desc']);
-		$data['usage'] = mysql_real_escape_string($data['usage']);
-		$data['comments'] = mysql_real_escape_string($data['comments']);
+		$data['desc'] = vcl_mysql_escape_string($data['desc']);
+		$data['usage'] = vcl_mysql_escape_string($data['usage']);
+		$data['comments'] = vcl_mysql_escape_string($data['comments']);
 	
 		# get architecture of base image
 		$query = "SELECT i.architecture "
@@ -1199,7 +1199,7 @@
 		       . "WHERE ir.imageid = i.id AND "
 		       .       "ir.id = {$data['basedoffrevisionid']}";
 		$qh = doQuery($query);
-		$row = mysql_fetch_assoc($qh);
+		$row = mysqli_fetch_assoc($qh);
 		$arch = $row['architecture'];
 	
 		$ownerdata = getUserInfo($data['owner'], 1);
@@ -1244,7 +1244,7 @@
 
 		# ad authentication
 		if($data['adauthenabled']) {
-			$esc_baseou = mysql_real_escape_string($data['baseou']);
+			$esc_baseou = vcl_mysql_escape_string($data['baseou']);
 			$query = "INSERT INTO imageaddomain "
 			       .        "(imageid, "
 			       .        "addomainid, "
@@ -1554,7 +1554,7 @@
 				 . "FROM subimages "
 				 . "WHERE imagemetaid = $imagemetaid";
 		$qh = doQuery($query, 101);
-		$row = mysql_fetch_row($qh);
+		$row = mysqli_fetch_row($qh);
 		if($row[0] == 0) {
 			$rc = checkClearImageMeta($imagemetaid, $imageid, 'subimages');
 			if($rc)
@@ -1570,7 +1570,7 @@
 			$query = "SELECT imageid FROM subimages WHERE imagemetaid = $imagemetaid";
 			$qh = doQuery($query, 101);
 			$subimages = array();
-			while($row = mysql_fetch_assoc($qh))
+			while($row = mysqli_fetch_assoc($qh))
 				$subimages[] = $row['imageid'];
 		}
 	
@@ -1827,7 +1827,7 @@
 		if(! empty($id))
 			$query .= " AND id != $id";
 		$qh = doQuery($query, 101);
-		if(mysql_num_rows($qh))
+		if(mysqli_num_rows($qh))
 			return 1;
 		return 0;
 	}
@@ -1857,7 +1857,7 @@
 		        . "WHERE name = '$nodename' AND "
 		        .       "parent = 3";
 		$qh = doQuery($query, 101);
-		if(! $row = mysql_fetch_assoc($qh)) {
+		if(! $row = mysqli_fetch_assoc($qh)) {
 			$query2 = "INSERT INTO privnode "
 			        .        "(parent, "
 			        .        "name) "
@@ -1866,7 +1866,7 @@
 			        .        "'$nodename')";
 			doQuery($query2, 101);
 			$qh = doQuery($query, 101);
-			$row = mysql_fetch_assoc($qh);
+			$row = mysqli_fetch_assoc($qh);
 		}
 		$parent = $row['id'];
 		$query = "SELECT id "
@@ -1874,7 +1874,7 @@
 		        . "WHERE name = '{$ownerdata['login']}-$ownerid' AND "
 		        .       "parent = $parent";
 		$qh = doQuery($query, 101);
-		if($row = mysql_fetch_assoc($qh))
+		if($row = mysqli_fetch_assoc($qh))
 			$newnode = $row['id'];
 		else {
 			$query = "INSERT INTO privnode "
@@ -1882,7 +1882,7 @@
 			       . "VALUES ($parent, '{$ownerdata['login']}-$ownerid')";
 			doQuery($query, 101);
 			$qh = doQuery("SELECT LAST_INSERT_ID() FROM privnode", 101);
-			$row = mysql_fetch_row($qh);
+			$row = mysqli_fetch_row($qh);
 			$newnode = $row[0];
 		}
 	
@@ -1895,7 +1895,7 @@
 		        . "FROM usergroup "
 		        . "WHERE name = 'manageNewImages'";
 		$qh = doQuery($query, 101);
-		$row = mysql_fetch_assoc($qh);
+		$row = mysqli_fetch_assoc($qh);
 		$ownergroupid = $row['id'];
 		if($virtual)
 			$prefix = 'newvmimages';
@@ -1907,7 +1907,7 @@
 		       .       "ownerusergroupid = $ownergroupid AND "
 		       .       "resourcetypeid = 13";
 		$qh = doQuery($query, 101);
-		if($row = mysql_fetch_assoc($qh))
+		if($row = mysqli_fetch_assoc($qh))
 			$resourcegroupid = $row['id'];
 		else {
 			$query = "INSERT INTO resourcegroup "
@@ -1919,7 +1919,7 @@
 			       .         "13)";
 			doQuery($query, 305);
 			$qh = doQuery("SELECT LAST_INSERT_ID() FROM resourcegroup", 101);
-			$row = mysql_fetch_row($qh);
+			$row = mysqli_fetch_row($qh);
 			$resourcegroupid = $row[0];
 	
 			// map group to newimages/newvmimages comp group
@@ -1932,7 +1932,7 @@
 			       . "WHERE name = '$rgroupname' AND "
 			       .       "resourcetypeid = 12";
 			$qh = doQuery($query, 101);
-			$row = mysql_fetch_assoc($qh);
+			$row = mysqli_fetch_assoc($qh);
 			$compResGrpid = $row['id'];
 			$query = "INSERT INTO resourcemap "
 			       .        "(resourcegroupid1, "
@@ -1980,7 +1980,7 @@
 		       . "WHERE resourcetypeid = 13 AND "
 		       .       "subid = $imageid";
 		$qh = doQuery($query);
-		if(! ($row = mysql_fetch_assoc($qh)))
+		if(! ($row = mysqli_fetch_assoc($qh)))
 			return;
 		$resid = $row['id'];
 		$olduserdata = getUserInfo($oldownerid, 1, 1);
@@ -1994,7 +1994,7 @@
 		       .       "rgm.resourcegroupid = rg.id AND "
 		       .       "rg.name IN ($oldgroups)";
 		$qh = doQuery($query);
-		if(! ($row = mysql_fetch_assoc($qh)))
+		if(! ($row = mysqli_fetch_assoc($qh)))
 			return;
 		$oldgroup = $row['name'];
 		$oldgroupid = $row['id'];
@@ -2108,7 +2108,7 @@
 			       .       "(cm.OStypeid = ot.id OR "
 			       .        "cm.OSid = o.id)";
 			$qh = doQuery($query, 101);
-			if(! (mysql_num_rows($qh))) {
+			if(! (mysqli_num_rows($qh))) {
 				# not enabled, add entry for method and image revision
 				$query = "INSERT INTO connectmethodmap "
 				       .        "(connectmethodid, "
@@ -2157,7 +2157,7 @@
 		$methods = getContinuationVar('methods');
 		$revids = getContinuationVar('revids');
 		$curmethods = getImageConnectMethods($imageid);
-		$remidlist = mysql_real_escape_string(processInputVar('ids', ARG_STRING));
+		$remidlist = vcl_mysql_escape_string(processInputVar('ids', ARG_STRING));
 		$remids = explode(',', $remidlist);
 		$revid = processInputVar('revid', ARG_NUMERIC);
 		$newimage = getContinuationVar('newimage');
@@ -2199,7 +2199,7 @@
 				       .       "(cm.OStypeid = ot.id OR "
 				       .        "cm.OSid = o.id)";
 				$qh = doQuery($query, 101);
-				if(mysql_num_rows($qh))
+				if(mysqli_num_rows($qh))
 					# if so, add disabled entry for image revision and method
 					$insvals[] = "($id, $revid, 1)";
 			}
@@ -2246,7 +2246,7 @@
 		$comments = htmlspecialchars($comments);
 		if(get_magic_quotes_gpc())
 			$comments = stripslashes($comments);
-		$comments = mysql_real_escape_string($comments);
+		$comments = vcl_mysql_escape_string($comments);
 		$query = "UPDATE imagerevision "
 		       . "SET comments = '$comments' "
 		       . "WHERE id = $revisionid";
@@ -2306,9 +2306,9 @@
 		       .       "rs.imagerevisionid IN ($checkedids) AND "
 		       .       "rq.stateid NOT IN (1, 5, 11, 12)";
 		$qh = doQuery($query);
-		if(mysql_num_rows($qh)) {
+		if(mysqli_num_rows($qh)) {
 			$inuseids = array();
-			while($row = mysql_fetch_assoc($qh))
+			while($row = mysqli_fetch_assoc($qh))
 				$inuseids[] = $row['revision'];
 			$inuseids = implode(',', $inuseids);
 			$rc = array('status' => 'error',
diff --git a/web/.ht-inc/managementnode.php b/web/.ht-inc/managementnode.php
index 2b5b08e..dd49e2c 100644
--- a/web/.ht-inc/managementnode.php
+++ b/web/.ht-inc/managementnode.php
@@ -203,7 +203,7 @@
 		       . "ORDER BY rq.end DESC "
 		       . "LIMIT 1";
 		$qh = doQuery($query);
-		if($row = mysql_fetch_assoc($qh))
+		if($row = mysqli_fetch_assoc($qh))
 			$msgs[] = "There is at least one <strong>reservation</strong> being processed by this management node. The latest end time is " . prettyDatetime($row['end'], 1) . '.';
 
 		# check blockRequest
@@ -219,7 +219,7 @@
 		       . "ORDER BY bt.end DESC "
 		       . "LIMIT 1";
 		$qh = doQuery($query);
-		if($row = mysql_fetch_assoc($qh))
+		if($row = mysqli_fetch_assoc($qh))
 			$msgs[] = "There is at least one <strong>Block Allocation</strong> being handled by this management node. Block Allocation \"{$row['name']}\" has the latest end time which is " . prettyDatetime($row['end'], 1) . '.';
 
 
@@ -246,7 +246,7 @@
 	function toggleDeleteResource($rscid) {
 		$query = "SELECT stateid FROM managementnode WHERE id = $rscid";
 		$qh = doQuery($query);
-		if($row = mysql_fetch_assoc($qh)) {
+		if($row = mysqli_fetch_assoc($qh)) {
 			if($row['stateid'] == 1)
 				$query = "UPDATE managementnode SET stateid = 10 WHERE id = $rscid";
 			else
@@ -514,8 +514,8 @@
 			}
 		}
 		else {
-			$esc = array('sysadminemail' => mysql_real_escape_string($data['sysadminemail']),
-			             'sharedmailbox' => mysql_real_escape_string($data['sharedmailbox']));
+			$esc = array('sysadminemail' => vcl_mysql_escape_string($data['sysadminemail']),
+			             'sharedmailbox' => vcl_mysql_escape_string($data['sharedmailbox']));
 
 			$olddata = getContinuationVar('olddata');
 			$updates = array();
@@ -992,7 +992,7 @@
 				       .       "rq.laststateid NOT IN (1,5,11,12) AND "
 				       .       "rq.userid != $vclreloadid";
 				$qh = doQuery($query);
-				if(mysql_num_rows($qh)) {
+				if(mysqli_num_rows($qh)) {
 					$return['error'] = 1;
 					$errormsg[] = "This management node is the NAT host for computers that have active reservations. NAT host<br>settings cannot be changed while providing NAT for active reservations.";
 				}
@@ -1020,8 +1020,8 @@
 	function addResource($data) {
 		global $user;
 		$ownerid = getUserlistID($data['owner']);
-		$esc = array('sysadminemail' => mysql_real_escape_string($data['sysadminemail']),
-		             'sharedmailbox' => mysql_real_escape_string($data['sharedmailbox']));
+		$esc = array('sysadminemail' => vcl_mysql_escape_string($data['sysadminemail']),
+		             'sharedmailbox' => vcl_mysql_escape_string($data['sharedmailbox']));
 		$keys = array('IPaddress',            'hostname',
 		              'ownerid',              'stateid',
 		              'checkininterval',      'installpath',
@@ -1116,7 +1116,7 @@
 		if($id != 0)
 			$query .= " AND id != $id";
 		$qh = doQuery($query);
-		return mysql_num_rows($qh);
+		return mysqli_num_rows($qh);
 	}
 }
 ?>
diff --git a/web/.ht-inc/oneclick.php b/web/.ht-inc/oneclick.php
index e478fcd..d8b62c9 100755
--- a/web/.ht-inc/oneclick.php
+++ b/web/.ht-inc/oneclick.php
@@ -57,7 +57,7 @@
 	       .       "o.userid = {$user['id']}";
 	$oneclicks = array();
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$oneclicks[$row['id']] = $row;
 
 	print "<H2>" . i("VCL go Configurator") . "</H2>\n";
@@ -322,7 +322,7 @@
 	$qh = doQuery($query, 101);
 	print "<form action=\"" . BASEURL . SCRIPT . "\" method=\"post\" style=\"display: inline;\" onsubmit=\"return validateForm(this);\">\n";
 
-	if(! ($row = mysql_fetch_assoc($qh))) {
+	if(! ($row = mysqli_fetch_assoc($qh))) {
 		print i("VCL go not found") . "\n";
 		return NULL;
 	}
diff --git a/web/.ht-inc/privileges.php b/web/.ht-inc/privileges.php
index 92f6ee3..165e14b 100644
--- a/web/.ht-inc/privileges.php
+++ b/web/.ht-inc/privileges.php
@@ -256,7 +256,7 @@
 		       . "ORDER BY name";
 		$qh = doQuery($query);
 		$orderedgroups = array();
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$orderedgroups[] = $row['id'];
 		foreach($orderedgroups as $id) {
 			printUserPrivRow($id, $i, $privs["usergroups"], $usertypes["users"],
@@ -965,7 +965,7 @@
 		       . "ORDER BY name";
 		$qh = doQuery($query);
 		$orderedgroups = array();
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$orderedgroups[] = $row['id'];
 		foreach($orderedgroups as $id) {
 			$tmpArr = getUserPrivRowHTML($id, $i, $privs["usergroups"],
@@ -1125,7 +1125,7 @@
 	$query = "SELECT id, parent FROM privnode WHERE id > " . DEFAULT_PRIVNODE;
 	$qh = doQuery($query);
 	$data = 'nodedropdata = {';
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		if(checkUserHasPriv('nodeAdmin', $user['id'], $row['id']) &&
 		   ($row['parent'] == DEFAULT_PRIVNODE || checkUserHasPriv('nodeAdmin', $user['id'], $row['parent'])))
 			$data .= "{$row['id']}: '1',";
@@ -1183,7 +1183,7 @@
 	       . "WHERE name = '$newnode' AND "
 	       .       "parent = $parent";
 	$qh = doQuery($query, 335);
-	if(mysql_num_rows($qh)) {
+	if(mysqli_num_rows($qh)) {
 		$text = "A node of that name already exists "
 		      . "under " . $nodeInfo["name"];
 		print "dojo.byId('addChildNodeStatus').innerHTML = '$text';";
@@ -1198,7 +1198,7 @@
 	doQuery($query, 336);
 
 	$qh = doQuery("SELECT LAST_INSERT_ID() FROM privnode", 101);
-	if(! $row = mysql_fetch_row($qh))
+	if(! $row = mysqli_fetch_row($qh))
 		abort(101);
 	$nodeid = $row[0];
 
@@ -1228,7 +1228,7 @@
 function nodeExists($node) {
 	$query = "SELECT id FROM privnode WHERE id = $node";
 	$qh = doQuery($query, 101);
-	if(mysql_num_rows($qh))
+	if(mysqli_num_rows($qh))
 		return 1;
 	else
 		return 0;
@@ -1313,13 +1313,13 @@
 		return;
 	}
 	# check if node matching new name already exists at parent
-	$_newname = mysql_real_escape_string($newname);
+	$_newname = vcl_mysql_escape_string($newname);
 	$query = "SELECT id "
 	       . "FROM privnode "
 	       . "WHERE parent = (SELECT parent FROM privnode WHERE id = $activeNode) AND "
 	       .       "name = '$_newname'";
 	$qh = doQuery($query, 101);
-	if(mysql_num_rows($qh)) {
+	if(mysqli_num_rows($qh)) {
 		$msg = i("A sibling node of that name currently exists");
 		$arr = array('error' => 2, 'message' => $msg);
 		sendJSON($arr);
@@ -1372,7 +1372,7 @@
 	       .       "p2.parent = $newparentid AND "
 	       .       "p2.name = p1.name";
 	$qh = doQuery($query);
-	if($row = mysql_num_rows($qh)) {
+	if($row = mysqli_num_rows($qh)) {
 		$arr = array('status' => 'collision',
 		             'moveid' => $moveid,
 		             'oldparentid' => $oldparentid,
@@ -1494,7 +1494,7 @@
 	print "<INPUT type=hidden name=continuation value=\"$cont\">\n";
 	print "</FORM><br>\n";
 	if(! empty($userid)) {
-		$esc_userid = mysql_real_escape_string($userid);
+		$esc_userid = vcl_mysql_escape_string($userid);
 		if(preg_match('/,/', $userid)) {
 			$mode = 'name';
 			$force = 0;
@@ -1517,8 +1517,8 @@
 		}
 		else {
 			$tmp = explode(',', $userid);
-			$last = mysql_real_escape_string(trim($tmp[0]));
-			$first = mysql_real_escape_string(trim($tmp[1]));
+			$last = vcl_mysql_escape_string(trim($tmp[0]));
+			$first = vcl_mysql_escape_string(trim($tmp[1]));
 			$query = "SELECT CONCAT(u.unityid, '@', a.name) AS unityid "
 			       . "FROM user u, "
 			       .      "affiliation a "
@@ -1528,7 +1528,7 @@
 			       .       "a.id = $affilid";
 		}
 		$qh = doQuery($query, 101);
-		if(! mysql_num_rows($qh)) {
+		if(! mysqli_num_rows($qh)) {
 			if($mode == 'name') {
 				print "<font color=red>User not found</font><br>\n";
 				return;
@@ -1538,13 +1538,13 @@
 		}
 		elseif($force) {
 			$_SESSION['userresources'] = array();
-			$row = mysql_fetch_assoc($qh);
+			$row = mysqli_fetch_assoc($qh);
 			$newtime = unixToDatetime(time() - SECINDAY - 5);
 			$query = "UPDATE user SET lastupdated = '$newtime' WHERE id = {$row['id']}";
 			doQuery($query, 101);
 		}
 		elseif($mode == 'name') {
-			$row = mysql_fetch_assoc($qh);
+			$row = mysqli_fetch_assoc($qh);
 			$userid = $row['unityid'];
 			$esc_userid = $row['unityid'];
 		}
@@ -1659,11 +1659,11 @@
 		       . "ORDER BY p.name, "
 		       .          "upt.name";
 		$qh = doQuery($query, 101);
-		if(mysql_num_rows($qh)) {
+		if(mysqli_num_rows($qh)) {
 			print "Nodes where user is granted privileges:<br>\n";
 			print "<TABLE>\n";
 			$privnodeid = 0;
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				if($privnodeid != $row['privnodeid']) {
 					if($privnodeid) {
 						print "    </TD>\n";
@@ -1699,11 +1699,11 @@
 			       . "ORDER BY p.name, "
 			       .          "upt.name";
 			$qh = doQuery($query, 101);
-			if(mysql_num_rows($qh)) {
+			if(mysqli_num_rows($qh)) {
 				print "Nodes where user's groups are granted privileges:<br>\n";
 				print "<TABLE>\n";
 				$privnodeid = 0;
-				while($row = mysql_fetch_assoc($qh)) {
+				while($row = mysqli_fetch_assoc($qh)) {
 					if($privnodeid != $row['privnodeid']) {
 						if($privnodeid) {
 							print "    </TD>\n";
@@ -1749,7 +1749,7 @@
 		       . "LIMIT 8";
 		$logins = array();
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$logins[] = $row;
 		if(count($logins)) {
 			$logins = array_reverse($logins);
@@ -1814,7 +1814,7 @@
 		       . "ORDER BY l.start DESC "
 		       . "LIMIT 5";
 		$qh = doQuery($query, 290);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			array_push($requests, $row);
 		$requests = array_reverse($requests);
 		if(! empty($requests)) {
@@ -1924,7 +1924,7 @@
 		       . "GROUP BY rq.id "
 		       . "ORDER BY rq.start";
 		$qh = doQuery($query, 290);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			array_push($requests, $row);
 		$requests = array_reverse($requests);
 		if(! empty($requests)) {
@@ -2054,7 +2054,7 @@
 			       . "GROUP BY rq.id "
 			       . "ORDER BY rq.start";
 			$qh = doQuery($query, 290);
-			while($row = mysql_fetch_assoc($qh))
+			while($row = mysqli_fetch_assoc($qh))
 				array_push($requests, $row);
 			$requests = array_reverse($requests);
 			if(! empty($requests)) {
@@ -2156,7 +2156,7 @@
 function recurseGetChildren($node) {
 	$children = array();
 	$qh = doQuery("SELECT id FROM privnode WHERE parent = $node", 340);
-	while($row = mysql_fetch_row($qh)) {
+	while($row = mysqli_fetch_row($qh)) {
 		array_push($children, $row[0]);
 		$children = array_merge($children, recurseGetChildren($row[0]));
 	}
@@ -2444,7 +2444,7 @@
 	       . "LEFT JOIN usergroup g2 ON (g.editusergroupid = g2.id) "
 	       . "WHERE g.id = $usergrpid";
 	$qh = doQuery($query, 101);
-	if(! ($grpdata = mysql_fetch_assoc($qh))) {
+	if(! ($grpdata = mysqli_fetch_assoc($qh))) {
 		# problem getting group members
 		$msg = 'failed to fetch group members';
 		$arr = array('members' => $msg, 'domid' => $domid);
@@ -2620,7 +2620,7 @@
 	       . "WHERE rg.id = $resgrpid AND "
 	       .       "rg.resourcetypeid = rt.id";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_assoc($qh)) {
+	if($row = mysqli_fetch_assoc($qh)) {
 		$type = $row['name'];
 		if($type == 'computer' || $type == 'managementnode')
 			$field = 'hostname';
@@ -2639,7 +2639,7 @@
 			$query .= " AND t.deleted = 0";
 		$qh = doQuery($query, 101);
 		$members = '';
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$members .= "{$row['item']}<br>";
 		if($members == '')
 			$members = '(empty group)';
@@ -2719,7 +2719,7 @@
 		       .       "g.resourcetypeid = t.id "
 		       . "ORDER BY p.privnodeid";
 		$qh = doQuery($query, 350);
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			$resourcedata[$row['privnodeid']][] = $row;
 		}
 	}
@@ -2746,7 +2746,7 @@
 		       .       "u.affiliationid = a.id "
 		       . "ORDER BY u.unityid";
 		$qh = doQuery($query, 351);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$privs['users'][$row['unityid']][$row['name']] = 1;
 	}
 	if($type == "usergroups" || $type == "all") {
@@ -2766,7 +2766,7 @@
 		       .       "up.usergroupid IS NOT NULL "
 		       . "ORDER BY g.name";
 		$qh = doQuery($query, 352);
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			if(isset($privs["usergroups"][$row["id"]]))
 				$privs["usergroups"][$row["id"]]['privs'][$row['priv']] = 1;
 			else
@@ -2849,7 +2849,7 @@
 		       .       "g.resourcetypeid = t.id AND "
 		       .       "p.type = 'block'";
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			if(! isset($allblockdata[$row['privnodeid']]))
 				$allblockdata[$row['privnodeid']] = array();
 			# TODO adding the id at the end will fix the bug where blocking cascaded resource
@@ -2888,7 +2888,7 @@
 		       .       "p.privnodeid = p2.privnodeid AND "
 		       .       "p2.type = 'cascade'";
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			if(! isset($allcascadedata[$row['privnodeid']]))
 				$allcascadedata[$row['privnodeid']] = array();
 			$allcascadedata[$row['privnodeid']][] =
@@ -2939,7 +2939,7 @@
 			       .       "t.name = 'block' AND "
 			       .       "u.affiliationid = a.id";
 			$qh = doQuery($query, 355);
-			while($row = mysql_fetch_row($qh))
+			while($row = mysqli_fetch_row($qh))
 				$nodeuserblock[$row[0]][$row[1]] = 1;
 		}
 		static $nodeusercasade;
@@ -2967,7 +2967,7 @@
 			       . 		"up.userid = Cup.userid "
 			       . "ORDER BY up.privnodeid, u.unityid, t.name";
 			$qh = doQuery($query, 356);
-			while($row = mysql_fetch_row($qh))
+			while($row = mysqli_fetch_row($qh))
 				$nodeusercascade[$row[0]][$row[1]][$row[2]] = 1;
 		}
 		$mynodelist = $nodelist;
@@ -3005,7 +3005,7 @@
 			       .       "up.usergroupid IS NOT NULL AND "
 			       .       "t.name = 'block'";
 			$qh = doQuery($query, 357);
-			while($row = mysql_fetch_row($qh))
+			while($row = mysqli_fetch_row($qh))
 				$nodegroupblock[$row[0]][$row[1]] = 1;
 		}
 		static $nodegroupcascade;
@@ -3035,7 +3035,7 @@
 			       . 		"up.usergroupid = Cup.usergroupid "
 			       . "ORDER BY up.privnodeid, g.id, t.name";
 			$qh = doQuery($query, 356);
-			while($row = mysql_fetch_row($qh)) {
+			while($row = mysqli_fetch_row($qh)) {
 				if(! isset($nodegroupcascade[$row[0]][$row[1]])) {
 					$nodegroupcascade[$row[0]][$row[1]] = array('id' => $row[1],
 						                                         'name' => $row[2],
diff --git a/web/.ht-inc/requests.php b/web/.ht-inc/requests.php
index 9d8d8ce..ab13923 100644
--- a/web/.ht-inc/requests.php
+++ b/web/.ht-inc/requests.php
@@ -380,12 +380,12 @@
 			if(checkUserHasPerm('View Debug Information')) {
 				if(! is_null($requests[$i]['vmhostid'])) {
 					$query = "SELECT c.hostname "
-					       . "FROM computer c, " 
+					       . "FROM computer c, "
 					       .      "vmhost v "
 					       . "WHERE v.id = {$requests[$i]['vmhostid']} AND "
 					       .       "v.computerid = c.id";
 					$qh = doQuery($query, 101);
-					$row = mysql_fetch_assoc($qh);
+					$row = mysqli_fetch_assoc($qh);
 					$vmhost = $row['hostname'];
 				}
 				$text .= "    <TD align=center><a id=\"req{$requests[$i]['id']}\" ";
@@ -1329,7 +1329,7 @@
 						$subowner = 1;
 				}
 			}
-			if($subowner || 
+			if($subowner ||
 			   (array_key_exists($id, $imagedata) &&
 			   count($imagedata[$id]['imagerevision']) > 1 &&
 			   ($imagedata[$id]['ownerid'] == $user['id'] ||
@@ -1339,7 +1339,7 @@
 			}
 		}
 	}
-	if(in_array('serverCheckOut', $user['privileges']) && 
+	if(in_array('serverCheckOut', $user['privileges']) &&
 	   count($checkout['image'])) {
 		$serveraccess = 1;
 		/*$extraimages = getServerProfileImages($user['id']);
@@ -1369,7 +1369,7 @@
 							$subowner = 1;
 					}
 				}
-				if($subowner || 
+				if($subowner ||
 				   (array_key_exists($id, $imagedata) &&
 				   count($imagedata[$id]['imagerevision']) > 1 &&
 				   ($imagedata[$id]['ownerid'] == $user['id'] ||
@@ -1884,7 +1884,7 @@
 			$start = unixFloor15($now);
 		if($type == 'basic' || $type == 'imaging') {
 			# compute maxstart based on 11:45 pm on start day
-			$tmp = $now + DAYSAHEAD * SECINDAY; 
+			$tmp = $now + DAYSAHEAD * SECINDAY;
 			$maxstart = mktime(23, 45, 0, date('n', $tmp), date('j', $tmp), date('Y', $tmp));
 			if($start > $maxstart)
 				return;
@@ -1986,7 +1986,7 @@
 	$rc = isAvailable($images, $imageid, $imagerevisionid, $start, $end, 0, 0, 0, 0, $imaging, $fixedIP);
 	if($rc < 1) {
 		$cdata = array('now' => 0,
-		               'start' => $start, 
+		               'start' => $start,
 		               'end' => $end,
 		               'server' => 0,
 		               'imageid' => $imageid);
@@ -2410,7 +2410,7 @@
 		}
 		else {
 			$fields[] = 'name';
-			$name = mysql_real_escape_string($data['name']);
+			$name = vcl_mysql_escape_string($data['name']);
 			$values[] = "'$name'";
 		}
 		if($data['ipaddr'] != '') {
@@ -2472,7 +2472,7 @@
 	       . "ORDER BY id";
 	$qh = doQuery($query);
 	$resids = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if(! array_key_exists($row['imageid'], $resids))
 			$resids[$row['imageid']] = array();
 		$resids[$row['imageid']][] = $row['id'];
@@ -2488,7 +2488,7 @@
 		}
 	}
 	$qbase = "INSERT INTO configinstance "
-	       .        "(reservationid, " 
+	       .        "(reservationid, "
 	       .        "configid, "
 	       .        "configmapid, "
 	       .        "configinstancestatusid) "
@@ -2528,7 +2528,7 @@
 			if(array_key_exists("$cfgsubimgid/$mapid", $vars)) {
 				$sets = array();
 				foreach($vars["$cfgsubimgid/$mapid"] as $varid => $varval) {
-					$_val = mysql_real_escape_string($varval['value']);
+					$_val = vcl_mysql_escape_string($varval['value']);
 					$sets[] = "($instid, $varid, '$_val')";
 				}
 				$query = $qbase2 . implode(',', $sets);
@@ -2706,8 +2706,8 @@
 
 	if($request['currstateid'] == 11 ||
 	   ($request['currstateid'] == 12 && $request['laststateid'] == 11))
-		return "<br><span class=\"rederrormsg\">" . 
-		       i("The selected reservation has timed out and is no longer available.") . 
+		return "<br><span class=\"rederrormsg\">" .
+		       i("The selected reservation has timed out and is no longer available.") .
 		       "</span>";
 
 	if($request['imageid'] == $request['compimageid'])
@@ -2781,7 +2781,7 @@
 			       .       "reservationid = {$request['resid']} AND "
 			       .       "timestamp = '" . unixToDatetime($data['ts']) . "'";
 			$qh = doQuery($query, 101);
-			if($row = mysql_fetch_assoc($qh)) {
+			if($row = mysqli_fetch_assoc($qh)) {
 				$reason = $row['additionalinfo'];
 				$text .= "<br>" . i("retrying at state") . " \"$reason\"";
 			}
@@ -2865,7 +2865,7 @@
 				       . "ORDER BY id "
 				       . "LIMIT 1";
 				$qh = doQuery($query, 101);
-				if($row = mysql_fetch_assoc($qh)) {
+				if($row = mysqli_fetch_assoc($qh)) {
 					$reason = $row['additionalInfo'];
 					if(! empty($data))
 						$currtime = $row['ts'] - $data['ts'];
@@ -2954,7 +2954,7 @@
 	print "  </TR>\n";
 	print "  <TR>\n";
 	print "    <TH align=right>Start&nbsp;Time:</TH>\n";
-	if(datetimeToUnix($request["start"]) < 
+	if(datetimeToUnix($request["start"]) <
 	   datetimeToUnix($request["daterequested"])) {
 		print "    <TD>" . prettyDatetime($request["daterequested"]) . "</TD>\n";
 	}
@@ -3092,7 +3092,7 @@
 	$request = getRequestInfo($requestid, 1);
 	# check to see if reservation exists
 	if(is_null($request) || $request['stateid'] == 11 || $request['stateid'] == 12 ||
-	   ($request['stateid'] == 14 && 
+	   ($request['stateid'] == 14 &&
 	   ($request['laststateid'] == 11 || $request['laststateid'] == 12))) {
 		sendJSON(array('status' => 'resgone'));
 		return;
@@ -3208,14 +3208,14 @@
 	if($unixstart > $now) {
 		$tzunixstart = $unixstart + ($_SESSION['persistdata']['tzoffset'] * 60);
 		$cdata['modifystart'] = 1;
-		$txt  = i("Modify reservation for") . " <b>{$request['reservations'][0]['prettyimage']}</b> "; 
+		$txt  = i("Modify reservation for") . " <b>{$request['reservations'][0]['prettyimage']}</b> ";
 		$txt .= i("starting") . " " . prettyDatetime($request["start"]) . ": <br>";
 		$h .= preg_replace("/(.{1,60}([ \n]|$))/", '\1<br>', $txt);
 		$days = array();
 		$startday = date('l', $tzunixstart);
 		$cur = time() + ($_SESSION['persistdata']['tzoffset'] * 60);
-		for($end = $cur + DAYSAHEAD * SECINDAY; 
-		    $cur < $end; 
+		for($end = $cur + DAYSAHEAD * SECINDAY;
+		    $cur < $end;
 		    $cur += SECINDAY) {
 			$index = date('Ymd', $cur);
 			$days[$index] = date('l', $cur);
@@ -3367,13 +3367,13 @@
 	// if started, only allow end to be modified
 	# check for following reservations
 	$timeToNext = timeToNextReservation($request);
-	# check for 30 minutes because need 15 minute buffer and min can 
+	# check for 30 minutes because need 15 minute buffer and min can
 	# extend by is 15 min
 	if($timeToNext < 30) {
 		$movedall = 1;
 		$lockedall = 1;
 		if(count($request['reservations']) > 1) {
-			# get semaphore on each existing node in cluster so that nothing 
+			# get semaphore on each existing node in cluster so that nothing
 			# can get moved to the nodes during this process
 
 			$semimageid = getImageId('noimage');
@@ -3732,7 +3732,7 @@
 			return;
 		}
 		if($servername != $request['servername']) {
-			$servername = mysql_real_escape_string($servername);
+			$servername = vcl_mysql_escape_string($servername);
 			$updateservername = 1;
 		}
 	}
@@ -3826,9 +3826,9 @@
 	$rc = isAvailable($images, $imageid, $revisions, $startts,
 	                  $endts, 1, $requestid, 0, 0, 0, $ip, $mac);
 	$data = array();
-	if($rc < 1) { 
+	if($rc < 1) {
 		$cdata = array('now' => 0,
-		               'start' => $startts, 
+		               'start' => $startts,
 		               'end' => $endts,
 		               'server' => $allowindefiniteend,
 		               'imageid' => $imageid,
@@ -3936,7 +3936,7 @@
 		return;
 	}
 	if($request['stateid'] == 11 || $request['stateid'] == 12 ||
-	   ($request['stateid'] == 14 && 
+	   ($request['stateid'] == 14 &&
 	   ($request['laststateid'] == 11 || $request['laststateid'] == 12))) {
 		$data = array('error' => 1,
 		              'refresh' => 1,
@@ -4132,7 +4132,7 @@
 	if($request['serverrequest']) {
 		$query = "SELECT id FROM serverrequest WHERE requestid = $requestid";
 		$qh = doQuery($query);
-		if($row = mysql_fetch_assoc($qh)) {
+		if($row = mysqli_fetch_assoc($qh)) {
 			$query = "DELETE FROM serverrequest WHERE requestid = $requestid";
 			doQuery($query, 152);
 			deleteVariable("fixedIPsr{$row['id']}");
@@ -4160,7 +4160,7 @@
 	$requestid = getContinuationVar('requestid');
 	$reqdata = getRequestInfo($requestid, 1);
 	if(is_null($reqdata) || $reqdata['stateid'] == 11 || $reqdata['stateid'] == 12 ||
-	   ($reqdata['stateid'] == 14 && 
+	   ($reqdata['stateid'] == 14 &&
 	   ($reqdata['laststateid'] == 11 || $reqdata['laststateid'] == 12))) {
 		print "resGone('reboot'); ";
 		print "dijit.byId('editResDlg').show();";
@@ -4192,7 +4192,7 @@
 	$requestid = getContinuationVar('requestid');
 	$reqdata = getRequestInfo($requestid, 1);
 	if(is_null($reqdata) || $reqdata['stateid'] == 11 || $reqdata['stateid'] == 12 ||
-	   ($reqdata['stateid'] == 14 && 
+	   ($reqdata['stateid'] == 14 &&
 	   ($reqdata['laststateid'] == 11 || $reqdata['laststateid'] == 12))) {
 		sendJSON(array('status' => 'resgone'));
 		return;
@@ -4301,7 +4301,7 @@
 		return;
 	}
 	if($requestData['stateid'] == 11 || $requestData['stateid'] == 12 ||
-	   ($requestData['stateid'] == 14 && 
+	   ($requestData['stateid'] == 14 &&
 	   ($requestData['laststateid'] == 11 || $requestData['laststateid'] == 12))) {
 		$h = i("This reservation has timed out due to lack of user activity and is no longer available.");
 		sendJSON(array('html' => $h, 'refresh' => 1));
@@ -4374,6 +4374,8 @@
 				$conuser = $user['unityid'];
 			if($requestData['reservations'][0]['domainDNSName'] != '' && ! strlen($passwd))
 				$conuser .= "@" . $requestData['reservations'][0]['domainDNSName'];
+			elseif($requestData['reservations'][0]['OStype'] == 'windows')
+				$conuser = ".\\$conuser";
 			if(! strlen($passwd))
 				$passwd = i('(use your campus password)');
 			if($cluster)
@@ -4400,17 +4402,17 @@
 			$tos = array($conuser,
 			             $passwd,
 			             $res['connectIP']);
-			$msg = preg_replace($froms, $tos, $method['connecttext']); 
+			$msg = preg_replace($froms, $tos, $method['connecttext']);
 			foreach($method['ports'] as $port) {
 				if($usenat && array_key_exists($port['key'], $natports[$cmid]))
-					$msg = preg_replace("/{$port['key']}/", $natports[$cmid][$port['key']]['publicport'], $msg); 
+					$msg = preg_replace("/{$port['key']}/", $natports[$cmid][$port['key']]['publicport'], $msg);
 				else {
 					if((preg_match('/remote desktop/i', $method['description']) ||
-					   preg_match('/RDP/i', $method['description'])) && 
+					   preg_match('/RDP/i', $method['description'])) &&
 					   $port['key'] == '#Port-TCP-3389#')
-						$msg = preg_replace("/{$port['key']}/", $user['rdpport'], $msg); 
+						$msg = preg_replace("/{$port['key']}/", $user['rdpport'], $msg);
 					else
-						$msg = preg_replace("/{$port['key']}/", $port['port'], $msg); 
+						$msg = preg_replace("/{$port['key']}/", $port['port'], $msg);
 				}
 			}
 			#$h .= preg_replace("/(.{1,120}([ ]|$))/", '\1<br>', $msg);
@@ -4421,7 +4423,8 @@
 				#$h .= "<div id=\"connectdiv\">\n";
 				$h .= "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
 				$cdata = array('requestid' => $requestid,
-				               'resid' => $res['reservationid']);
+				               'resid' => $res['reservationid'],
+				               'cmid' => $cmid);
 				$expire = datetimeToUnix($requestData['end']) - $now + 1800; # remaining reservation time plus 30 min
 				$cont = addContinuationsEntry('sendRDPfile', $cdata, $expire);
 				$h .= "<INPUT type=hidden name=continuation value=\"$cont\">\n";
@@ -4619,7 +4622,7 @@
 	$images = removeNoCheckout($resources["image"]);
 	#$extraimages = getServerProfileImages($user['id']);
 	if((! array_key_exists($return['imageid'], $images) &&
-	   /*($return['type'] != 'server' || 
+	   /*($return['type'] != 'server' ||
 		! array_key_exists($return['imageid'], $extraimages)) &&*/
 	   ($return['type'] != 'imaging' ||
 	   ! array_key_exists($return['imageid'], $withnocheckout))) ||
@@ -4660,7 +4663,7 @@
 		$return['revisionids'][$return['imageid']][] = $revids[0];
 	else
 		$return['revisionids'][$return['imageid']][] = getProductionRevisionid($return['imageid']);
-	
+
 	# duration
 	if($return['ending'] == 'duration') {
 		$return['duration'] = processInputVar('duration', ARG_NUMERIC, 0);
@@ -4757,7 +4760,7 @@
 				$return['dnsArr'][] = $dnsaddr;
 				$cnt++;
 			}
-	
+
 			# check that a management node can handle the network
 			$mappedmns = getMnsFromImage($return['imageid']);
 			$mnnets = checkAvailableNetworks($return['ipaddr']);
@@ -4952,7 +4955,7 @@
 	       . "ORDER BY cll.timestamp DESC "
 	       . "LIMIT 1";
 	$qh = doQuery($query);
-	if($row = mysql_fetch_assoc($qh)) {
+	if($row = mysqli_fetch_assoc($qh)) {
 		if(! is_numeric($row['timestamp']))
 			return NULL;
 		if($row['loadstatename'] == 'acknowledgetimeout')
@@ -5008,8 +5011,8 @@
 	$cur = time();
 	if(array_key_exists('tzoffset', $_SESSION['persistdata']))
 		$cur += $_SESSION['persistdata']['tzoffset'] * 60;
-	for($end = $cur + DAYSAHEAD * SECINDAY; 
-	    $cur < $end; 
+	for($end = $cur + DAYSAHEAD * SECINDAY;
+	    $cur < $end;
 	    $cur += SECINDAY) {
 		$tmp = getdate($cur);
 		$index = $cur;
diff --git a/web/.ht-inc/resource.php b/web/.ht-inc/resource.php
index cecd2bb..cc55d09 100644
--- a/web/.ht-inc/resource.php
+++ b/web/.ht-inc/resource.php
@@ -574,7 +574,7 @@
 			       . "FROM `{$this->restype}` "
 			       . "WHERE id = $rscid";
 			$qh = doQuery($query);
-			if($row = mysql_fetch_assoc($qh)) {
+			if($row = mysqli_fetch_assoc($qh)) {
 				$newval = (int)(! (int)$row['deleted']);
 				$query = "UPDATE {$this->restype} "
 				       . "SET deleted = $newval "
@@ -1628,7 +1628,7 @@
 		if($id)
 			$query .= " AND id != $id";
 		$qh = doQuery($query);
-		if(mysql_num_rows($qh))
+		if(mysqli_num_rows($qh))
 			return 1;
 		return 0;
 	}
diff --git a/web/.ht-inc/schedule.php b/web/.ht-inc/schedule.php
index 57da520..d0760e8 100644
--- a/web/.ht-inc/schedule.php
+++ b/web/.ht-inc/schedule.php
@@ -188,7 +188,7 @@
 		       .       "deleted = 0";
 		$qh = doQuery($query);
 		$comps = array();
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$comps[] = $row['hostname'];
 		if(count($comps))
 			$msg = "This schedule cannot be deleted because the following <strong>computers</strong> have it selected as their schedule:<br><br>\n" . implode("<br>\n", $comps);
@@ -445,7 +445,7 @@
 		if(! empty($id))
 			$query .= " AND id != $id";
 		$qh = doQuery($query, 101);
-		if(mysql_num_rows($qh))
+		if(mysqli_num_rows($qh))
 			return 1;
 		return 0;
 	}
diff --git a/web/.ht-inc/serverprofiles.php b/web/.ht-inc/serverprofiles.php
index 951789e..2de4826 100644
--- a/web/.ht-inc/serverprofiles.php
+++ b/web/.ht-inc/serverprofiles.php
@@ -523,10 +523,10 @@
 		sendJSON($data);
 		return;
 	}
-	$name = mysql_real_escape_string($data['name']);
-	$desc = mysql_real_escape_string($data['desc']);
-	$fixedIP = mysql_real_escape_string($data['fixedIP']);
-	$fixedMAC = mysql_real_escape_string($data['fixedMAC']);
+	$name = vcl_mysql_escape_string($data['name']);
+	$desc = vcl_mysql_escape_string($data['desc']);
+	$fixedIP = vcl_mysql_escape_string($data['fixedIP']);
+	$fixedMAC = vcl_mysql_escape_string($data['fixedMAC']);
 	$ret = array();
 	if($data['profileid'] == 70000) {
 		$query = "INSERT INTO serverprofile "
@@ -626,7 +626,7 @@
 	}
 	$query = "DELETE FROM serverprofile WHERE id = $profileid";
 	doQuery($query, 101);
-	$rows = mysql_affected_rows();
+	$rows = mysqli_affected_rows();
 	if($rows == 0) {
 		$data = array('error' => 1,
 		              'msg' => 'Failed to delete selected server profile');
@@ -864,7 +864,7 @@
 	}
 	$qh = doQuery($query, 101);
 	$groups = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$groups[$row['id']] = $row['name'];
 	$_SESSION['usersessiondata'][$key] = $groups;
 	return $groups;
diff --git a/web/.ht-inc/siteconfig.php b/web/.ht-inc/siteconfig.php
index 96aedda..a8f5d39 100644
--- a/web/.ht-inc/siteconfig.php
+++ b/web/.ht-inc/siteconfig.php
@@ -1292,7 +1292,7 @@
 		$this->values = array();
 		$query = "SELECT id, helpaddress FROM affiliation ORDER BY name";
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$this->values[$row['id']] = $row['helpaddress'];
 	}
 
@@ -1310,18 +1310,18 @@
 	///
 	/////////////////////////////////////////////////////////////////////////////
 	function setValue($affilid, $value) {
-		global $mysql_link_vcl;
+		global $mysqli_link_vcl;
 		if($value === NULL)
 			$newval = 'NULL';
 		else {
-			$esc_value = mysql_real_escape_string($value);
+			$esc_value = vcl_mysql_escape_string($value);
 			$newval = "'$esc_value'";
 		}
 		$query = "UPDATE affiliation "
 		       . "SET helpaddress = $newval "
 		       . "WHERE id = $affilid";
 		doQuery($query);
-		$rc = mysql_affected_rows($mysql_link_vcl);
+		$rc = mysqli_affected_rows($mysqli_link_vcl);
 		if($rc == 1)
 			return 1;
 		return 0;
@@ -1339,12 +1339,12 @@
 	///
 	/////////////////////////////////////////////////////////////////////////////
 	function deleteValue($affilid) {
-		global $mysql_link_vcl;
+		global $mysqli_link_vcl;
 		$query = "UPDATE affiliation "
 		       . "SET helpaddress = NULL "
 		       . "WHERE id = $affilid";
 		doQuery($query);
-		$rc = mysql_affected_rows($mysql_link_vcl);
+		$rc = mysqli_affected_rows($mysqli_link_vcl);
 		if($rc == 1)
 			return 1;
 		return 0;
@@ -1391,7 +1391,7 @@
 		$this->values = array();
 		$query = "SELECT id, sitewwwaddress FROM affiliation ORDER BY name";
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$this->values[$row['id']] = $row['sitewwwaddress'];
 	}
 
@@ -1409,18 +1409,18 @@
 	///
 	/////////////////////////////////////////////////////////////////////////////
 	function setValue($affilid, $value) {
-		global $mysql_link_vcl;
+		global $mysqli_link_vcl;
 		if($value === NULL)
 			$newval = 'NULL';
 		else {
-			$esc_value = mysql_real_escape_string($value);
+			$esc_value = vcl_mysql_escape_string($value);
 			$newval = "'$esc_value'";
 		}
 		$query = "UPDATE affiliation "
 		       . "SET sitewwwaddress = $newval "
 		       . "WHERE id = $affilid";
 		doQuery($query);
-		$rc = mysql_affected_rows($mysql_link_vcl);
+		$rc = mysqli_affected_rows($mysqli_link_vcl);
 		if($rc == 1)
 			return 1;
 		return 0;
@@ -1438,12 +1438,12 @@
 	///
 	/////////////////////////////////////////////////////////////////////////////
 	function deleteValue($affilid) {
-		global $mysql_link_vcl;
+		global $mysqli_link_vcl;
 		$query = "UPDATE affiliation "
 		       . "SET sitewwwaddress = NULL "
 		       . "WHERE id = $affilid";
 		doQuery($query);
-		$rc = mysql_affected_rows($mysql_link_vcl);
+		$rc = mysqli_affected_rows($mysqli_link_vcl);
 		if($rc == 1)
 			return 1;
 		return 0;
@@ -1498,7 +1498,7 @@
 		       . "LEFT JOIN winKMS k ON (k.affiliationid = a.id) "
 		       . "ORDER BY a.id";
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			if(is_null($row['address']) && is_null($row['port'])) {
 				$this->values[$row['id']] = NULL;
 				continue;
@@ -1529,7 +1529,7 @@
 	///
 	/////////////////////////////////////////////////////////////////////////////
 	function setValue($affilid, $value) {
-		global $mysql_link_vcl;
+		global $mysqli_link_vcl;
 		$this->getValues();
 		$values = explode(',', $value);
 		# create datastructure of newly submitted hosts
@@ -1588,7 +1588,7 @@
 		# insert new hosts
 		$values = array();
 		foreach($adds as $host => $port) {
-			$esc_host = mysql_real_escape_string($host);
+			$esc_host = vcl_mysql_escape_string($host);
 			$values[] = "($affilid, '$esc_host', $port)";
 		}
 		$rc1 = 1;
@@ -1597,25 +1597,25 @@
 			       . "(affiliationid, address, port) "
 			       . "VALUES " . implode(',', $values);
 			doQuery($query);
-			$rc1 = mysql_affected_rows($mysql_link_vcl);
+			$rc1 = mysqli_affected_rows($mysqli_link_vcl);
 		}
 		# make changes
 		$rc2 = 1;
 		foreach($changes as $host => $port) {
-			$esc_host = mysql_real_escape_string($host);
+			$esc_host = vcl_mysql_escape_string($host);
 			$query = "UPDATE winKMS "
 			       . "SET port = $port "
 			       . "WHERE address = '$esc_host' AND "
 			       .       "affiliationid = $affilid";
 			doQuery($query);
-			$tmp = mysql_affected_rows($mysql_link_vcl);
+			$tmp = mysqli_affected_rows($mysqli_link_vcl);
 			if($rc2)
 				$rc2 = $tmp;
 		}
 		# delete old hosts
 		$values = array();
 		foreach($rems as $host => $port) {
-			$esc_host = mysql_real_escape_string($host);
+			$esc_host = vcl_mysql_escape_string($host);
 			$values[] = "(affiliationid = $affilid AND "
 			          . "address = '$esc_host' AND "
 			          . "port = $port)";
@@ -1625,7 +1625,7 @@
 			$query = "DELETE FROM winKMS "
 			       . "WHERE " . implode(' OR ', $values);
 			doQuery($query);
-			$rc3 = mysql_affected_rows($mysql_link_vcl);
+			$rc3 = mysqli_affected_rows($mysqli_link_vcl);
 		}
 		if($rc1 == 0 || $rc2 == 0 || $rc3 == 0)
 			return 0;
@@ -1644,11 +1644,11 @@
 	///
 	/////////////////////////////////////////////////////////////////////////////
 	function deleteValue($affilid) {
-		global $mysql_link_vcl;
+		global $mysqli_link_vcl;
 		$query = "DELETE FROM winKMS "
 		       . "WHERE affiliationid = $affilid";
 		doQuery($query);
-		$rc = mysql_affected_rows($mysql_link_vcl);
+		$rc = mysqli_affected_rows($mysqli_link_vcl);
 		if($rc == 1)
 			return 1;
 		return 0;
@@ -1715,7 +1715,7 @@
 		$this->values = array();
 		$query = "SELECT id, theme FROM affiliation ORDER BY name";
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$this->values[$row['id']] = $row['theme'];
 	}
 
@@ -1733,13 +1733,13 @@
 	///
 	/////////////////////////////////////////////////////////////////////////////
 	function setValue($affilid, $value) {
-		global $mysql_link_vcl;
-		$esc_value = mysql_real_escape_string($value);
+		global $mysqli_link_vcl;
+		$esc_value = vcl_mysql_escape_string($value);
 		$query = "UPDATE affiliation "
 		       . "SET theme = '$esc_value' "
 		       . "WHERE id = $affilid";
 		doQuery($query);
-		$rc = mysql_affected_rows($mysql_link_vcl);
+		$rc = mysqli_affected_rows($mysqli_link_vcl);
 		if($rc == 1)
 			return 1;
 		return 0;
@@ -1757,12 +1757,12 @@
 	///
 	/////////////////////////////////////////////////////////////////////////////
 	function deleteValue($affilid) {
-		global $mysql_link_vcl;
+		global $mysqli_link_vcl;
 		$query = "UPDATE affiliation "
 		       . "SET theme = NULL "
 		       . "WHERE id = $affilid";
 		doQuery($query);
-		$rc = mysql_affected_rows($mysql_link_vcl);
+		$rc = mysqli_affected_rows($mysqli_link_vcl);
 		if($rc == 1)
 			return 1;
 		return 0;
@@ -1834,7 +1834,7 @@
 		       . "WHERE name NOT IN ('Global', 'Local') "
 		       . "ORDER BY name";
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$this->values[$row['id']] = (int)(! $row['shibonly']);
 	}
 
@@ -1852,13 +1852,13 @@
 	///
 	/////////////////////////////////////////////////////////////////////////////
 	function setValue($affilid, $value) {
-		global $mysql_link_vcl;
+		global $mysqli_link_vcl;
 		$value = (int)(! $value);
 		$query = "UPDATE affiliation "
 		       . "SET shibonly = $value "
 		       . "WHERE id = $affilid";
 		doQuery($query);
-		$rc = mysql_affected_rows($mysql_link_vcl);
+		$rc = mysqli_affected_rows($mysqli_link_vcl);
 		if($rc == 1)
 			return 1;
 		return 0;
@@ -1944,7 +1944,7 @@
 		       . "WHERE name NOT IN ('Global', 'Local') "
 		       . "ORDER BY name";
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$this->values[$row['id']] = $row['shibname'];
 	}
 
@@ -1962,18 +1962,18 @@
 	///
 	/////////////////////////////////////////////////////////////////////////////
 	function setValue($affilid, $value) {
-		global $mysql_link_vcl;
+		global $mysqli_link_vcl;
 		if($value === NULL)
 			$newval = 'NULL';
 		else {
-			$esc_value = mysql_real_escape_string($value);
+			$esc_value = vcl_mysql_escape_string($value);
 			$newval = "'$esc_value'";
 		}
 		$query = "UPDATE affiliation "
 		       . "SET shibname = $newval "
 		       . "WHERE id = $affilid";
 		doQuery($query);
-		$rc = mysql_affected_rows($mysql_link_vcl);
+		$rc = mysqli_affected_rows($mysqli_link_vcl);
 		if($rc == 1)
 			return 1;
 		return 0;
@@ -1991,12 +1991,12 @@
 	///
 	/////////////////////////////////////////////////////////////////////////////
 	function deleteValue($affilid) {
-		global $mysql_link_vcl;
+		global $mysqli_link_vcl;
 		$query = "UPDATE affiliation "
 		       . "SET shibname = NULL "
 		       . "WHERE id = $affilid";
 		doQuery($query);
-		$rc = mysql_affected_rows($mysql_link_vcl);
+		$rc = mysqli_affected_rows($mysqli_link_vcl);
 		if($rc == 1)
 			return 1;
 		return 0;
@@ -2973,7 +2973,7 @@
 			sendJSON($arr);
 			return;
 		}
-		$_newval = mysql_real_escape_string($newval);
+		$_newval = vcl_mysql_escape_string($newval);
 		$query = "INSERT INTO affiliation (name) VALUES ('$_newval')";
 		doQuery($query);
 		$arr = array('status' => 'success',
@@ -2998,7 +2998,7 @@
 		foreach($tables as $table) {
 			$query = "SELECT affiliationid FROM $table WHERE affiliationid = $key LIMIT 1";
 			$qh = doQuery($query);
-			if(mysql_num_rows($qh)) {
+			if(mysqli_num_rows($qh)) {
 				$used = 1;
 				break;
 			}
@@ -3052,7 +3052,7 @@
 	function updateValue($key, $val) {
 		$tmp = explode('|', $key);
 		$key = $tmp[1];
-		$_val = mysql_real_escape_string($val);
+		$_val = vcl_mysql_escape_string($val);
 		$query = "UPDATE affiliation SET name = '$_val' WHERE id = $key";
 		doQuery($query);
 	}
@@ -3395,7 +3395,7 @@
 		       .       "value LIKE '%invalidfields%'";
 		$qh = doQuery($query);
 		$invalids = array();
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			$data = Spyc::YAMLLoad($row['value']);
 			if(array_key_exists('invalidfields', $data)) {
 				$invalids[$row['name']] = $data['invalidfields'];
diff --git a/web/.ht-inc/sitemaintenance.php b/web/.ht-inc/sitemaintenance.php
index 6dad773..fe833dc 100644
--- a/web/.ht-inc/sitemaintenance.php
+++ b/web/.ht-inc/sitemaintenance.php
@@ -279,8 +279,8 @@
 		return;
 	}
 
-	$reason = mysql_real_escape_string($data['reason']);
-	$usermessage = mysql_real_escape_string($data['usermessage']);
+	$reason = vcl_mysql_escape_string($data['reason']);
+	$usermessage = vcl_mysql_escape_string($data['usermessage']);
 	$query = "INSERT INTO sitemaintenance "
 	       .        "(start, "
 	       .        "end, "
@@ -413,8 +413,8 @@
 		return;
 	}
 
-	$reason = mysql_real_escape_string($data['reason']);
-	$usermessage = mysql_real_escape_string($data['usermessage']);
+	$reason = vcl_mysql_escape_string($data['reason']);
+	$usermessage = vcl_mysql_escape_string($data['usermessage']);
 	$query = "UPDATE sitemaintenance "
 	       . "SET start = '{$data['startdt']}', "
 	       .     "end = '{$data['enddt']}', "
diff --git a/web/.ht-inc/statistics.php b/web/.ht-inc/statistics.php
index ca81b8b..4127fe1 100644
--- a/web/.ht-inc/statistics.php
+++ b/web/.ht-inc/statistics.php
@@ -110,7 +110,7 @@
 		       . "ORDER BY prettyname";
 		$qh = doQuery($query);
 		$provs = array();
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$provs[$row['id']] = $row['prettyname'];
 		$cdata = array('mode' => 'provisioning',
 		               'provs' => $provs);
@@ -292,7 +292,7 @@
 	                 "10hrsplus" => 0);
 	$totalhours = 0;
 	$osusers = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if(! array_key_exists($row["prettyname"], $imageload2less))
 			$imageload2less[$row["prettyname"]] = 0;
 		if(! array_key_exists($row["prettyname"], $imageload2to6))
@@ -685,7 +685,7 @@
 	       .       "statdate <= '$end' AND "
 	       .       "provisioningid = $provid";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$cachepts[$row['statdate']] = $row['value'];
 	for($i = $startunix; $i < $endunix; $i += SECINDAY) {
 		$cnt++;
@@ -735,7 +735,7 @@
 				}
 			}
 			$qh = doQuery($query, 295);
-			if($row = mysql_fetch_row($qh))
+			if($row = mysqli_fetch_row($qh))
 				$value = $row[0];
 			else
 				$value = 0;
@@ -843,7 +843,7 @@
 		}
 	}
 	$qh = doQuery($query, 296);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$startmin = ($row['shour'] * 60) + $row['smin'];
 		$endmin = ($row['ehour'] * 60) + $row['emin'];
 
@@ -951,7 +951,7 @@
 	       .       "statdate <= '$end' AND "
 	       .       "provisioningid = $provid";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$cachepts[$row['statdate']] = $row['value'];
 	if((count($cachepts) + 31) < $daycnt) {
 		$data = array('nodata' => i('(too much computational time required to generate this graph)'));
@@ -1008,7 +1008,7 @@
 				}
 			}
 			$qh = doQuery($query, 101);
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				$unixstart = $row["start"];
 				$unixend = $row["end"];
 				for($binstart = $daystart, $binend = $daystart + 3600, $binindex = 0;
@@ -1095,7 +1095,7 @@
 	       .       "statdate <= '$end' AND "
 	       .       "provisioningid = $provid";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$cachepts[$row['statdate']] = $row['value'];
 	if((count($cachepts) + 31) < $daycnt) {
 		$data = array('nodata' => i('(too much computational time required to generate this graph)'));
@@ -1180,7 +1180,7 @@
 			}
 			$qh = doQuery($query, 101);
 			$comps = array();
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				$unixstart = datetimeToUnix($row["start"]);
 				$unixend = datetimeToUnix($row["end"]);
 				for($binstart = $daystart, $binend = $daystart + 3600, $binindex = 0;
@@ -1273,7 +1273,7 @@
 	       .       "statdate <= '$end' AND "
 	       .       "provisioningid = $provid";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$cachepts[$row['statdate']] = $row['value'];
 	if((count($cachepts) + 31) < $daycnt) {
 		$data = array('nodata' => i('(too much computational time required to generate this graph)'));
@@ -1348,7 +1348,7 @@
 				}
 			}
 			$qh = doQuery($query, 101);
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				$unixstart = datetimeToUnix($row["start"]);
 				$unixend = datetimeToUnix($row["end"]);
 				for($binstart = $daystart, $binend = $daystart + 3600, $binindex = 0;
diff --git a/web/.ht-inc/userpreferences.php b/web/.ht-inc/userpreferences.php
index 3838c99..fcdc6f7 100644
--- a/web/.ht-inc/userpreferences.php
+++ b/web/.ht-inc/userpreferences.php
@@ -490,7 +490,7 @@
 		       . "WHERE u.id = '{$user['id']}' AND "
 		       .       "l.userid = u.id";
 		$qh = doQuery($query, 101);
-		if(! ($row = mysql_fetch_assoc($qh)))
+		if(! ($row = mysqli_fetch_assoc($qh)))
 			abort();
 		$passhash = sha1("{$data['newpassword']}{$row['salt']}");
 		$query = "UPDATE localauth "
@@ -564,7 +564,7 @@
 	if($pubkeyauth == 2 && preg_match('|^[-a-zA-Z0-9\+/ @=\.\n\r]*$|', $pubkeys)) {
 		if(get_magic_quotes_gpc())
 			$pubkeys = stripslashes($pubkeys);
-		$_pubkeys = mysql_real_escape_string($pubkeys);
+		$_pubkeys = vcl_mysql_escape_string($pubkeys);
 		$query = "UPDATE user SET sshpublickeys = '$_pubkeys' WHERE id = {$user['id']}";
 		doQuery($query);
 		$_SESSION['user']['sshpublickeys'] = htmlspecialchars($pubkeys);
diff --git a/web/.ht-inc/utils.php b/web/.ht-inc/utils.php
index feaabef..2dad962 100644
--- a/web/.ht-inc/utils.php
+++ b/web/.ht-inc/utils.php
@@ -125,7 +125,12 @@
 	$days = array(i('Sunday'), i('Monday'), i('Tuesday'), i('Wednesday'), i('Thursday'), i('Friday'), i('Saturday'));
 	$phpVerArr = explode('.', phpversion());
 	$phpVer = $phpVerArr[0];
-	$uniqid = uniqid($_SERVER['HTTP_HOST'] . "-" . getmypid() . "-");
+	
+	$host = $_SERVER['HTTP_HOST'];
+	if(strpos($host, ':')) {
+		$host = substr($host, 0, strpos($host, ':'));
+	}
+	$uniqid = uniqid($host . "-" . getmypid() . "-");
 
 	$passwdArray = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
 	                     'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
@@ -264,7 +269,7 @@
 	# set up $affilValFunc, $addUserFunc, $updateUserFunc for any shibonly affiliations
 	$query = "SELECT id FROM affiliation WHERE shibonly = 1";
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$id = $row['id'];
 		if(! array_key_exists($id, $affilValFunc)) {
 			if(ALLOWADDSHIBUSERS)
@@ -448,7 +453,7 @@
 						exit;
 					}
 					$search = ldap_search($ds,
-					                      $auth['binddn'], 
+					                      $auth['binddn'],
 					                      "{$auth['lookupuserfield']}={$user['unityid']}",
 					                      array('dn'), 0, 3, 15);
 					if($search) {
@@ -498,7 +503,7 @@
 			elseif($authMechs[$authtype]['type'] == 'redirect') {
 				$affilid = $authMechs[$authtype]['affiliationid'];
 				if(!(isset($apiValidateFunc) && is_array($apiValidateFunc) &&
-				   array_key_exists($affilid, $apiValidateFunc) && 
+				   array_key_exists($affilid, $apiValidateFunc) &&
 				   $apiValidateFunc[$affilid]($xmluser, $xmlpass))) {
 					printXMLRPCerror(3);    # access denied
 					dbDisconnect();
@@ -635,13 +640,13 @@
 		$fh = fopen($idfile, 'r');
 		$id = fread($fh, 50);
 		fclose($fh);
-		$_id = mysql_real_escape_string($id);
-	
+		$_id = vcl_mysql_escape_string($id);
+
 		$query = "SELECT id "
 		       . "FROM cryptkey  "
 		       . "WHERE id = '$_id'";
 		$qh = doQuery($query);
-		if($row = mysql_fetch_assoc($qh))
+		if($row = mysqli_fetch_assoc($qh))
 			return;
 	}
 
@@ -732,7 +737,7 @@
 		       .       "end > NOW()";
 		$qh = doQuery($query);
 		$ids = array();
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$ids[] = $row['id'];
 		if(empty($ids)) {
 			dbDisconnect();
@@ -745,7 +750,7 @@
 		doQuery($query, 101, 'vcl', 1);
 		dbDisconnect();
 		return;
-	}  
+	}
 	$inmaintenance = 0;
 	$skin = '';
 	foreach($files as $file) {
@@ -1002,7 +1007,7 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function abort($errcode, $query="") {
-	global $mysql_link_vcl, $mysql_link_acct, $ERRORS, $user, $mode;
+	global $mysqli_link_vcl, $mysqli_link_acct, $ERRORS, $user, $mode;
 	global $ENABLE_ITECSAUTH, $requestInfo, $aborting;
 	if(! isset($aborting))
 		$aborting = 1;
@@ -1012,11 +1017,11 @@
 		xmlRPCabort($errcode, $query);
 	if(ONLINEDEBUG && checkUserHasPerm('View Debug Information')) {
 		if($errcode >= 100 && $errcode < 400) {
-			print "<font color=red>" . mysql_error($mysql_link_vcl) . "</font><br>\n";
-			error_log(mysql_error($mysql_link_vcl));
+			print "<font color=red>" . mysqli_error($mysqli_link_vcl) . "</font><br>\n";
+			error_log(mysqli_error($mysqli_link_vcl));
 			if($ENABLE_ITECSAUTH) {
-				print "<font color=red>" . mysql_error($mysql_link_acct) . "</font><br>\n";
-				error_log(mysql_error($mysql_link_acct));
+				print "<font color=red>" . mysqli_error($mysqli_link_acct) . "</font><br>\n";
+				error_log(mysqli_error($mysqli_link_acct));
 			}
 			print "$query<br>\n";
 			error_log($query);
@@ -1033,9 +1038,9 @@
 	else {
 		$message = "";
 		if($errcode >= 100 && $errcode < 400) {
-			$message .= mysql_error($mysql_link_vcl) . "\n";
+			$message .= mysqli_error($mysqli_link_vcl) . "\n";
 			if($ENABLE_ITECSAUTH)
-				$message .= mysql_error($mysql_link_acct) . "\n";
+				$message .= mysqli_error($mysqli_link_acct) . "\n";
 			$message .= $query . "\n";
 		}
 		$message .= "ERROR($errcode): " . $ERRORS["$errcode"] . "\n";
@@ -1104,7 +1109,7 @@
 	global $affilValFuncArgs, $affilValFunc;
 	if(empty($loginid))
 		return 0;
-	
+
 	$rc = getAffilidAndLogin($loginid, $affilid);
 	if($rc == -1)
 		return 0;
@@ -1112,25 +1117,25 @@
 	if(empty($affilid))
 		return 0;
 
-	$escloginid = mysql_real_escape_string($loginid);
+	$escloginid = vcl_mysql_escape_string($loginid);
 	$query = "SELECT id "
 	       . "FROM user "
 	       . "WHERE unityid = '$escloginid' AND "
 	       .       "affiliationid = $affilid";
 	$qh = doQuery($query, 101);
-	if(mysql_num_rows($qh))
+	if(mysqli_num_rows($qh))
 		return 1;
 
 	if($rc == 0 &&
-	   ALLOWADDSHIBUSERS == 1 && 
+	   ALLOWADDSHIBUSERS == 1 &&
 	   strpos($loginid, '@')) {
 		$query = "SELECT shibonly "
 		       . "FROM affiliation "
 		       . "WHERE id = " . DEFAULT_AFFILID;
-		$qh = doQuery($query); 
-		$row = mysql_fetch_assoc($qh);
+		$qh = doQuery($query);
+		$row = mysqli_fetch_assoc($qh);
 		if($row['shibonly'] == 1)
-			return 0;           
+			return 0;
 	}
 
 	$valfunc = $affilValFunc[$affilid];
@@ -1184,11 +1189,12 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \fn mysql_connect_plus($host, $user, $pwd)
+/// \fn mysql_connect_plus($host, $user, $pwd, $db)
 ///
 /// \param $host - mysql host
 /// \param $user - userid to use for connection
 /// \param $pwd - password to use for connection
+/// \param $db - database to use after connecting
 ///
 /// \return mysql resource identifier, 0 if failure to connect
 ///
@@ -1197,12 +1203,12 @@
 /// and returns the identifier
 ///
 ////////////////////////////////////////////////////////////////////////////////
-function mysql_connect_plus($host, $user, $pwd) {
+function mysql_connect_plus($host, $user, $pwd, $db) {
 	$timeout = 5;             /* timeout in seconds */
 
 	if($fp = @fsockopen($host, 3306, $errno, $errstr, $timeout)) {
 		fclose($fp);
-		return $link = mysql_connect($host, $user, $pwd);
+		return $link = mysqli_connect($host, $user, $pwd, $db);
 	} else {
 		#print "ERROR: socket timeout<BR>\n";
 		return 0;
@@ -1214,29 +1220,25 @@
 /// \fn dbConnect()
 ///
 /// \brief opens connections to database, the resource identifiers are\n
-/// \b $mysql_link_vcl - for vcl database\n
-/// \b $mysql_link_acct - for accounts database\n
+/// \b $mysqli_link_vcl - for vcl database\n
+/// \b $mysqli_link_acct - for accounts database\n
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function dbConnect() {
-	global $vclhost, $vcldb, $vclusername, $vclpassword, $mysql_link_vcl;
-	global $accthost, $acctusername, $acctpassword, $mysql_link_acct;
+	global $vclhost, $vcldb, $vclusername, $vclpassword, $mysqli_link_vcl;
+	global $accthost, $acctusername, $acctpassword, $mysqli_link_acct;
 	global $ENABLE_ITECSAUTH;
 
 	if($ENABLE_ITECSAUTH) {
 		// open a connection to mysql server for accounts
-		if($mysql_link_acct = mysql_connect_plus($accthost, $acctusername, $acctpassword))
-			mysql_select_db("accounts", $mysql_link_acct);
-		else
+		if(! ($mysqli_link_acct = mysql_connect_plus($accthost, $acctusername, $acctpassword, 'accounts')))
 			$ENABLE_ITECSAUTH = 0;
 	}
 
 	// open a connection to mysql server for vcl
-	if(! $mysql_link_vcl = mysql_connect_plus($vclhost, $vclusername, $vclpassword)) {
+	if(! $mysqli_link_vcl = mysql_connect_plus($vclhost, $vclusername, $vclpassword, $vcldb)) {
 		die("Error connecting to $vclhost.<br>\n");
 	}
-	// select the vcl database
-	mysql_select_db($vcldb, $mysql_link_vcl) or abort(104);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1247,10 +1249,10 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function dbDisconnect() {
-	global $mysql_link_vcl, $mysql_link_acct, $ENABLE_ITECSAUTH;
-	mysql_close($mysql_link_vcl);
+	global $mysqli_link_vcl, $mysqli_link_acct, $ENABLE_ITECSAUTH;
+	mysqli_close($mysqli_link_vcl);
 	if($ENABLE_ITECSAUTH)
-		mysql_close($mysql_link_acct);
+		mysqli_close($mysqli_link_acct);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1268,9 +1270,9 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function doQuery($query, $errcode=101, $db="vcl", $nolog=0) {
-	global $mysql_link_vcl, $mysql_link_acct, $user, $mode, $ENABLE_ITECSAUTH;
+	global $mysqli_link_vcl, $mysqli_link_acct, $user, $mode, $ENABLE_ITECSAUTH;
 	if($db == "vcl") {
-		if(QUERYLOGGING != 0 && (! $nolog) && 
+		if(QUERYLOGGING != 0 && (! $nolog) &&
 		   preg_match('/^(UPDATE|INSERT|DELETE)/', $query) &&
 		   strpos($query, 'UPDATE continuations SET expiretime = ') === FALSE) {
 			$logquery = str_replace("'", "\'", $query);
@@ -1289,10 +1291,10 @@
 			   .        "NOW(), "
 			   .        "'$mode', "
 			   .        "'$logquery')";
-			mysql_query($q, $mysql_link_vcl);
+			mysqli_query($mysqli_link_vcl, $q);
 		}
-		for($i = 0; ! ($qh = mysql_query($query, $mysql_link_vcl)) && $i < 3; $i++) {
-			if(mysql_errno() == '1213') # DEADLOCK, sleep and retry
+		for($i = 0; ! ($qh = mysqli_query($mysqli_link_vcl, $query)) && $i < 3; $i++) {
+			if(mysqli_errno() == '1213') # DEADLOCK, sleep and retry
 				usleep(50);
 			else
 				abort($errcode, $query);
@@ -1300,7 +1302,7 @@
 	}
 	elseif($db == "accounts") {
 		if($ENABLE_ITECSAUTH)
-			$qh = mysql_query($query, $mysql_link_acct) or abort($errcode, $query);
+			$qh = mysqli_query($mysqli_link_acct, $query) or abort($errcode, $query);
 		else
 			$qh = NULL;
 	}
@@ -1311,14 +1313,31 @@
 ///
 /// \fn dbLastInsertID()
 ///
-/// \return last insert id for $mysql_link_vcl
+/// \return last insert id for $mysqli_link_vcl
 ///
-/// \brief calls mysql_insert_id for $mysql_link_vcl
+/// \brief calls mysqli_insert_id for $mysqli_link_vcl
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function dbLastInsertID() {
-	global $mysql_link_vcl;
-	return mysql_insert_id($mysql_link_vcl);
+	global $mysqli_link_vcl;
+	return mysqli_insert_id($mysqli_link_vcl);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn vcl_mysql_escape_string($string) {
+///
+/// \param $string - string to be escaped
+///
+/// \return escaped string
+///
+/// \brief wrapper for mysqli_real_escape_string so that $mysqli_link_vcl global
+/// variable doesn't have to be included in every function needing to call it
+///
+////////////////////////////////////////////////////////////////////////////////
+function vcl_mysql_escape_string($string) {
+	global $mysqli_link_vcl;
+	return mysqli_real_escape_string($mysqli_link_vcl, $string);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1334,7 +1353,7 @@
 	$query = "SELECT id, name, prettyname, type, installtype FROM OS ORDER BY prettyname";
 	$qh = doQuery($query, "115");
 	$oslist = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$oslist[$row['id']] = $row;
 	return $oslist;
 }
@@ -1373,7 +1392,7 @@
 ///                  checked out\n
 /// \b maxinitialtime - maximum time (in minutes) to be shown when requesting
 ///                     a reservation that the image can reserved for\n
-/// \b imagemetaid - NULL or corresponding id from imagemeta table and the 
+/// \b imagemetaid - NULL or corresponding id from imagemeta table and the
 /// following additional information:\n
 /// \b checkuser - whether or not vcld should check for a logged in user\n
 /// \b sysprep - whether or not to use sysprep on creation of the image\n
@@ -1406,7 +1425,7 @@
 	       .        "id "
 	       . "FROM imagemeta";
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$allmetadata[$row['id']] = $row;
 
 	# get all image revision data
@@ -1430,7 +1449,7 @@
 		$query .=   "i.deleted = 0 AND ";
 	$query .=      "u.affiliationid = a.id";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$id = $row['imageid'];
 		unset($row['imageid']);
 		$allrevisiondata[$id][$row['id']] = $row;
@@ -1485,7 +1504,7 @@
 		$query .= "AND i.deleted = 0 ";
    $query .= "ORDER BY i.prettyname";
 	$qh = doQuery($query, 120);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if(is_null($row['maxconcurrent']))
 			$row['maxconcurrent'] = 0;
 		$imagelist[$includedeleted][$row["id"]] = $row;
@@ -1512,7 +1531,7 @@
 				        . "FROM subimages "
 				        . "WHERE imagemetaid = $metaid";
 					$qh2 = doQuery($query2, 101);
-					while($row2 = mysql_fetch_assoc($qh2))
+					while($row2 = mysqli_fetch_assoc($qh2))
 						$imagelist[$includedeleted][$row["id"]]["subimages"][] =  $row2["imageid"];
 				}
 			}
@@ -1562,7 +1581,7 @@
 	$fixeddata = array();
 	$query = "SELECT name, value FROM variable WHERE name LIKE 'fixedIPsp%'";
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$spid = str_replace('fixedIPsp', '', $row['name']);
 		$fixeddata[$spid] = Spyc::YAMLLoad($row['value']);
 	}
@@ -1598,7 +1617,7 @@
 		$query .= "ORDER BY name";
 	$qh = doQuery($query, 101);
 	$profiles = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$profiles[$row['id']] = $row;
 		if(isset($fixeddata[$row['id']])) {
 			$profiles[$row['id']]['netmask'] = $fixeddata[$row['id']]['netmask'];
@@ -1647,7 +1666,7 @@
 	       .       "s.id IN ($inids)";
 	$qh = doQuery($query, 101);
 	$profiles = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$profiles[$row['id']] = $row['image'];
 	$_SESSION['usersessiondata'][$key] = $profiles;
 	return $profiles;
@@ -1696,7 +1715,7 @@
 	$query .= " ORDER BY revision";
 	$qh = doQuery($query, 101);
 	$return = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$return[$row['id']] = $row;
 	return $return;
 }
@@ -1723,7 +1742,7 @@
 	       . "FROM image "
 	       . "WHERE id = $imageid";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_assoc($qh))
+	if($row = mysqli_fetch_assoc($qh))
 		return $row;
 	else
 		return array('description' => '', 'usage' => '');
@@ -1807,7 +1826,7 @@
 		       .          "disabled";
 
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			if($row['disabled'] &&
 			   isset($allmethods[$row['imageid']][$row['imagerevisionid']][$row['connectmethodid']]))
 				unset($allmethods[$row['imageid']][$row['imagerevisionid']][$row['connectmethodid']]);
@@ -1844,7 +1863,7 @@
 	if(! preg_match('/^en/', $locale)) {
 		$query = "DESC connectmethod";
 		$qh = doQuery($query, 101);
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			if($row['Field'] == "description_$locale")
 				$descfield = "description_$locale";
 			if($row['Field'] == "connecttext_$locale")
@@ -1858,7 +1877,7 @@
 	       .        "protocol "
 	       . "FROM connectmethodport";
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$row['key'] = "#Port-{$row['protocol']}-{$row['port']}#";
 		$cmports[$row['connectmethodid']][] = $row;
 	}
@@ -1883,7 +1902,7 @@
 	       .          "c.`$descfield`";
 	$methods = array();
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if($row['disabled']) {
 		  if(isset($methods[$row['id']]))
 			unset($methods[$row['id']]);
@@ -1910,7 +1929,7 @@
 	$query = "SELECT id, name FROM imagetype ORDER BY name";
 	$qh = doQuery($query);
 	$data = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$data[$row['id']] = $row['name'];
 	return $data;
 }
@@ -1935,14 +1954,14 @@
 	$query = "DESC imagemeta";
 	$qh = doQuery($query, 101);
 	$defaults = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$defaults[$row['Field']] = $row['Default'];
 	# get imagemeta data
 	$query = "SELECT * FROM imagemeta WHERE id = $imagemetaid";
 	$qh = doQuery($query, 101);
-	$row = mysql_fetch_assoc($qh);
+	$row = mysqli_fetch_assoc($qh);
 	$alldefaults = 1;
-	if(mysql_num_rows($qh) == 0)
+	if(mysqli_num_rows($qh) == 0)
 		# it is possible that the imagemeta record could have been deleted before
 		#   this was submitted
 		return 1;
@@ -1990,10 +2009,10 @@
 			return '';
 	$query = "SELECT id, "
 	       .        "imageid "
-	       . "FROM imagerevision  " 
+	       . "FROM imagerevision  "
 	       . "WHERE production = 1";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$alldata[$row['imageid']] = $row['id'];
 	return $alldata[$imageid];
 }
@@ -2094,7 +2113,7 @@
 	else
 		$query .=   "u.usergroupid = $groupid";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		array_push($startnodes, $row["privnodeid"]);
 	}
 	# build data array from userprivtype and userpriv tables to reduce queries
@@ -2109,7 +2128,7 @@
 	       .       "u.userid = $userid AND "
 	       .       "t.name IN ('block','cascade',$inlist)";
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$privdataset['user'][$row['privnodeid']][] = $row['name'];
 	$query = "SELECT t.name, "
 	       .        "u.usergroupid, "
@@ -2128,7 +2147,7 @@
 	       . "ORDER BY u.privnodeid, "
 	       .          "u.usergroupid";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$privdataset['usergroup'][$row['privnodeid']][] = array('name' => $row['name'], 'groupid' => $row['usergroupid']);
 
 	# travel up tree looking at privileges granted at parent nodes
@@ -2190,7 +2209,7 @@
 
 	$resources = array();
 	foreach(array_keys($resourcegroups) as $type) {
-		$resources[$type] = 
+		$resources[$type] =
 		   getResourcesFromGroups($resourcegroups[$type], $type, $includedeleted);
 	}
 	if(! $bygroup)
@@ -2220,7 +2239,7 @@
 /// \brief adds resource privileges to $nodeprivs for the parents of $nodeid
 ///
 ////////////////////////////////////////////////////////////////////////////////
-function getUserResourcesUp(&$nodeprivs, $nodeid, $userid, 
+function getUserResourcesUp(&$nodeprivs, $nodeid, $userid,
                             $resourceprivs, $privdataset) {
 	# build list of parent nodes
 	# starting at top, get images available at that node and user privs there and
@@ -2257,7 +2276,7 @@
 /// of $nodeid
 ///
 ////////////////////////////////////////////////////////////////////////////////
-function getUserResourcesDown(&$nodeprivs, $nodeid, $userid, 
+function getUserResourcesDown(&$nodeprivs, $nodeid, $userid,
                               $resourceprivs, $privdataset) {
 	# FIXME can we check for cascading and if not there, don't descend?
 	$children = getChildNodes($nodeid);
@@ -2283,11 +2302,11 @@
 ///
 /// \return modifies $nodeprivs, but doesn't return anything
 ///
-/// \brief for $id, gets privileges and cascaded privileges the user and any 
+/// \brief for $id, gets privileges and cascaded privileges the user and any
 /// groups the user is and adds them to $nodeprivs
 ///
 ////////////////////////////////////////////////////////////////////////////////
-function addNodeUserResourcePrivs(&$nodeprivs, $id, $lastid, $userid, 
+function addNodeUserResourcePrivs(&$nodeprivs, $id, $lastid, $userid,
                                   $resourceprivs, $privdataset) {
 	$nodeprivs[$id]["user"] = array("cascade" => 0);
 	foreach($resourceprivs as $priv) {
@@ -2358,9 +2377,9 @@
 			if($noprivs)
 				$nodeprivs[$id][$groupid]["cascade"] = 0;
 		}
-		// if group not blocking at this node, and group had cascade at previous 
+		// if group not blocking at this node, and group had cascade at previous
 		# node
-		if($lastid && ! $nodeprivs[$id][$groupid]["block"] && 
+		if($lastid && ! $nodeprivs[$id][$groupid]["block"] &&
 		   isset($nodeprivs[$lastid][$groupid]) &&
 		   $nodeprivs[$lastid][$groupid]["cascade"]) {
 			# set cascade = 1
@@ -2468,7 +2487,7 @@
 		if(! $includedeleted && $type == 'managementnode')
 			$query .= " AND stateid != (SELECT id FROM state WHERE name = 'deleted') ";
 		$qh = doQuery($query, 101);
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			if(! isset($resources[$type][$row["id"]]))
 				$resources[$type][$row["id"]] = $row[$field];
 		}
@@ -2502,7 +2521,7 @@
 	       . "WHERE g.resourcetypeid = t.id AND "
 	       .       "g.ownerusergroupid IN ($groupids)";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if(! isset($resourcegroups[$row["type"]][$row["id"]]))
 			$resourcegroups[$row["type"]][$row["id"]] = $row["name"];
 	}
@@ -2563,7 +2582,7 @@
 		$query .= "AND test = 0 ";*/
 	$query .= "ORDER BY t.$field";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$return[$row["id"]] = $row["name"];
 	}
 	return $return;
@@ -2644,7 +2663,7 @@
 	else
 		$groupid = getResourceGroupID($group);
 	foreach($adds as $type) {
-		$type = mysql_real_escape_string($type);
+		$type = vcl_mysql_escape_string($type);
 		$query = "INSERT IGNORE INTO resourcepriv ("
 		       .        "resourcegroupid, "
 		       .        "privnodeid, "
@@ -2656,7 +2675,7 @@
 		doQuery($query, 377);
 	}
 	foreach($removes as $type) {
-		$type = mysql_real_escape_string($type);
+		$type = vcl_mysql_escape_string($type);
 		$query = "DELETE FROM resourcepriv "
 		       . "WHERE resourcegroupid = $groupid AND "
 		       .       "privnodeid = $node AND "
@@ -2725,7 +2744,7 @@
 	$cryptdata = $iv . $cryptdata;
 	return trim(base64_encode($cryptdata));
 }
- 
+
 ////////////////////////////////////////////////////////////////////////////////
 ///
 /// \fn decryptData($data, $cryptkey, $algo, $option, $keylength)
@@ -2799,7 +2818,7 @@
 	       . "WHERE cryptkeyid = $cryptkeyid AND "
 	       .       "secretid = $secretid";
 	$qh = doQuery($query);
-	if(! ($row = mysql_fetch_assoc($qh)))
+	if(! ($row = mysqli_fetch_assoc($qh)))
 		return NULL;
 	$secret = decryptSecretKey($row['cryptsecret']);
 	if($secret === NULL)
@@ -2828,7 +2847,7 @@
 		       . "FROM cryptkey "
 		       . "WHERE id = $cryptkey";
 		$qh = doQuery($query);
-		if(! ($row = mysql_fetch_assoc($qh)))
+		if(! ($row = mysqli_fetch_assoc($qh)))
 			return NULL;
 		$cryptkey = $row['pubkey'];
 		if($row['algorithmoption'] == 'OAEP' || 1) # OAEP only currently supported option
@@ -2896,7 +2915,7 @@
 function getSecretKeyID($table, $field, $recordid) {
 	$query = "SELECT $field FROM $table WHERE id = $recordid";
 	$qh = doQuery($query);
-	if(($row = mysql_fetch_row($qh)) && $row[0] != 0)
+	if(($row = mysqli_fetch_row($qh)) && $row[0] != 0)
 		return $row[0];
 
 	# generate secret key
@@ -2935,7 +2954,7 @@
 		return NULL;
 	$query = "SELECT secretid FROM cryptsecret WHERE id = $id";
 	$qh = doQuery($query);
-	if(! ($row = mysql_fetch_assoc($qh)))
+	if(! ($row = mysqli_fetch_assoc($qh)))
 		return NULL;
 	# encrypt with all other public keys and write to cryptsecret
 	encryptWebSecretKeys($key, $row['secretid'], $cryptkeyid);
@@ -2988,13 +3007,13 @@
 	$fh = fopen($idfile, 'r');
 	$id = fread($fh, 50);
 	fclose($fh);
-	$_id = mysql_real_escape_string($id);
+	$_id = vcl_mysql_escape_string($id);
 
 	$query = "SELECT id "
 	       . "FROM cryptkey  "
 	       . "WHERE id = '$_id'";
 	$qh = doQuery($query);
-	if($row = mysql_fetch_assoc($qh))
+	if($row = mysqli_fetch_assoc($qh))
 		return $row['id'];
 
 	if($create) {
@@ -3026,7 +3045,7 @@
 	       .       "hosttype = 'web'";
 	$qh = doQuery($query);
 	$values = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$cryptsecret = encryptSecretKey($secret, $row['pubkey']);
 		if($cryptsecret === NULL)
 			continue;
@@ -3073,7 +3092,7 @@
 	       .       "cs.secretid IS NULL AND "
 	       .       "ck.id != $mycryptkeyid";
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$secret = decryptSecretKey($row['mycryptsecret']);
 		$encsecret = encryptSecretKey($secret, $row['cryptkey']);
 		$values[] = "({$row['cryptkeyid']}, {$row['secretid']}, '$encsecret', '"
@@ -3116,7 +3135,7 @@
 	       . "WHERE rs.requestid = $requestid AND "
 	       .       "ad.secretid IS NOT NULL";
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$secretids[$row['managementnodeid']][$row['secretid']] = 1;
 	# determine any secretids needed from vmprofile
 	$query = "SELECT vp.secretid, "
@@ -3128,7 +3147,7 @@
 	       . "WHERE rs.requestid = $requestid AND "
 	       .       "vp.secretid IS NOT NULL";
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$secretids[$row['managementnodeid']][$row['secretid']] = 1;
 
 	$mycryptkeyid = getCryptKeyID();
@@ -3185,7 +3204,7 @@
 		       .       "s.id in ($allsecretids) AND "
 		       .       "cs.secretid IS NULL";
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			$secret = decryptSecretKey($row['mycryptsecret']);
 			$encsecret = encryptSecretKey($secret, $row['cryptkey']);
 			$values[] = "({$row['cryptkeyid']}, {$row['secretid']}, '$encsecret', '"
@@ -3349,7 +3368,7 @@
 		$query .= "AND ug.affiliationid = $affiliationid ";
 	$query .= "ORDER BY name";
 	$qh = doQuery($query, 280);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if(! empty($row["owner"]) && ! empty($row['affiliation']))
 			$row['owner'] = "{$row['owner']}@{$row['affiliation']}";
 		if($user['showallgroups'] || $affiliationid == 0)
@@ -3392,13 +3411,13 @@
 		       . "FROM `usergroup` u, "
 		       .      "`usergroupmembers` m "
 		       . "WHERE u.editusergroupid = m.usergroupid AND "
-		       .       "(u.ownerid = $id OR m.userid = $id) AND " 
+		       .       "(u.ownerid = $id OR m.userid = $id) AND "
 		       .       "u.affiliationid = {$user['affiliationid']} "
 		       . "ORDER BY name";
 	}
 	$qh = doQuery($query, 101);
 	$groups = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$groups[$row['id']] = $row['name'];
 	}
 	return $groups;
@@ -3438,7 +3457,7 @@
 	$query .= "ORDER BY ug.name, "
 	       .           "ugpt.name";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$data[] = $row;
 	return $data;
 }
@@ -3460,7 +3479,7 @@
 	$data = array();
 	$query = "SELECT id, name, help FROM usergroupprivtype ORDER BY name";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$data[$row['id']] = $row;
 	return $data;
 }
@@ -3505,7 +3524,7 @@
 
 	$query .= "ORDER BY t.name, g.name";
 	$qh = doQuery($query, 281);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if(empty($type))
 			$return[$row["id"]]["name"] = $row["type"] . "/" . $row["name"];
 		else
@@ -3549,7 +3568,7 @@
 		       .       "gm.resourceid = r.id AND "
 		       .       "r.resourcetypeid = t.id";
 		$qh = doQuery($query, 282);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$return[$type][$row["id"]][] = $row["groupid"];
 	}
 	return $return;
@@ -3653,7 +3672,7 @@
 	       .          "rgm.resourcegroupid, "
 	       .          $orders;
 	$qh = doQuery($query, 282);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if(isset($row['deleted']) && $row['deleted'] == 1)
 			continue;
 		if(isset($row['deleted2']) && $row['deleted2'] == 1)
@@ -3690,7 +3709,7 @@
 	       .       "u.affiliationid = a.id "
 	       . "ORDER BY u.unityid";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$return[$row["id"]] = $row['user'];
 	}
 	return $return;
@@ -3714,7 +3733,7 @@
 		return;
 
 	$query = "INSERT INTO usergroupmembers "
-	       .        "(userid, " 
+	       .        "(userid, "
 	       .        "usergroupid) "
 	       . "VALUES "
 	       .        "($userid, "
@@ -3767,8 +3786,8 @@
 	       . "WHERE unityid = '$loginid' AND "
 	       .       "affiliationid = $affilid";
 	$qh = doQuery($query, 140);
-	if(mysql_num_rows($qh)) {
-		$row = mysql_fetch_row($qh);
+	if(mysqli_num_rows($qh)) {
+		$row = mysqli_fetch_row($qh);
 		return $row[0];
 	}
 	if($noadd)
@@ -3795,7 +3814,7 @@
 	       . "ORDER BY id DESC "
 	       . "LIMIT 1";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_assoc($qh))
+	if($row = mysqli_fetch_assoc($qh))
 		return $row['imageid'];
 	return NULL;
 }
@@ -3814,7 +3833,7 @@
 	$query = "SELECT id, name FROM affiliation ORDER BY name";
 	$qh = doQuery($query, 101);
 	$return = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$return[$row['id']] = $row['name'];
 	return $return;
 }
@@ -3838,8 +3857,8 @@
 		return $cache['unityids'][$userid];
 	$query = "SELECT unityid FROM user WHERE id = $userid";
 	$qh = doQuery($query, 101);
-	if(mysql_num_rows($qh)) {
-		$row = mysql_fetch_row($qh);
+	if(mysqli_num_rows($qh)) {
+		$row = mysqli_fetch_row($qh);
 		$cache['unityids'][$userid] = $row[0];
 		return $row[0];
 	}
@@ -3858,11 +3877,11 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function getAffiliationID($affil) {
-	$affil = mysql_real_escape_string($affil);
+	$affil = vcl_mysql_escape_string($affil);
 	$query = "SELECT id FROM affiliation WHERE name = '$affil'";
 	$qh = doQuery($query, 101);
-	if(mysql_num_rows($qh)) {
-		$row = mysql_fetch_row($qh);
+	if(mysqli_num_rows($qh)) {
+		$row = mysqli_fetch_row($qh);
 		return $row[0];
 	}
 	return NULL;
@@ -3882,8 +3901,8 @@
 function getAffiliationName($affilid) {
 	$query = "SELECT name FROM affiliation WHERE id = $affilid";
 	$qh = doQuery($query, 101);
-	if(mysql_num_rows($qh)) {
-		$row = mysql_fetch_row($qh);
+	if(mysqli_num_rows($qh)) {
+		$row = mysqli_fetch_row($qh);
 		return $row[0];
 	}
 	return NULL;
@@ -3907,7 +3926,7 @@
 	if($affilid)
 		$query .= " WHERE id = $affilid";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$return[$row['id']] = $row['dataUpdateText'];
 	return $return;
 }
@@ -3935,7 +3954,7 @@
 	  	       .       "a2.name = 'Global'";
 	}
 	$qh = doQuery($query);
-	if(($row = mysql_fetch_assoc($qh)) && ! empty($row['theme']))
+	if(($row = mysqli_fetch_assoc($qh)) && ! empty($row['theme']))
 		return $row['theme'];
 	else
 		return DEFAULTTHEME;
@@ -3966,7 +3985,7 @@
 	   strncmp("{$_POST[$vartag]}", "0", 1) == 0 &&
 	   $type == ARG_NUMERIC &&
 		strncmp("{$_POST[$vartag]}", "0x0", 3) != 0) ||
-	   (array_key_exists($vartag, $_GET) && 
+	   (array_key_exists($vartag, $_GET) &&
 	   ! is_array($_GET[$vartag]) &&
 	   strncmp("{$_GET[$vartag]}", "0", 1) == 0 &&
 	   $type == ARG_NUMERIC &&
@@ -4165,7 +4184,7 @@
 			if(! is_string($value))
 				$return[$index] = $defaultvalue;
 			elseif($addslashes)
-				$return[$index] = mysql_real_escape_string($value);
+				$return[$index] = vcl_mysql_escape_string($value);
 		}
 		return $return;
 	}
@@ -4174,7 +4193,7 @@
 		if(strlen($return) == 0)
 			$return = $defaultvalue;
 		elseif($addslashes)
-			$return = mysql_real_escape_string($return);
+			$return = vcl_mysql_escape_string($return);
 	}
 
 	return $return;
@@ -4267,7 +4286,7 @@
 		$query .= "u.unityid = '$id' AND af.id = $affilid";
 
 	$qh = doQuery($query, "105");
-	if($user = mysql_fetch_assoc($qh)) {
+	if($user = mysqli_fetch_assoc($qh)) {
 		$user['sshpublickeys'] = htmlspecialchars($user['sshpublickeys']);
 		if((datetimeToUnix($user["lastupdated"]) > time() - SECINDAY) ||
 		   $user['unityid'] == 'vclreload' ||
@@ -4343,7 +4362,7 @@
 	}
 	$qh = doQuery($query, "101");
 	$groups = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$groups[$row["usergroupid"]] = $row["name"];
 	}
 	if($includeowned) {
@@ -4362,7 +4381,7 @@
 			       . "WHERE ownerid = $userid";
 		}
 		$qh = doQuery($query, "101");
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			$groups[$row["usergroupid"]] = $row["name"];
 		}
 	}
@@ -4398,7 +4417,7 @@
 	       . "ORDER BY t.name";
 	$perms = array();
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$perms[$row['id']] = $row['name'];
 	return $perms;
 }
@@ -4468,7 +4487,7 @@
 		       . "FROM user "
 		       . "WHERE id = $id";
 		$qh = doQuery($query, 101);
-		if($row = mysql_fetch_assoc($qh)) {
+		if($row = mysqli_fetch_assoc($qh)) {
 			$id = $row['unityid'];
 			$type = 'loginid';
 			$affilid = $row['affiliationid'];
@@ -4530,9 +4549,9 @@
 ////////////////////////////////////////////////////////////////////////////////
 function updateUserPrefs($userid, $preferredname, $width, $height, $bpp, $audio,
                          $mapdrives, $mapprinters, $mapserial, $rdpport) {
-	global $mysql_link_vcl;
-	$preferredname = mysql_real_escape_string($preferredname);
-	$audio = mysql_real_escape_string($audio);
+	global $mysqli_link_vcl;
+	$preferredname = vcl_mysql_escape_string($preferredname);
+	$audio = vcl_mysql_escape_string($audio);
 	if($rdpport == 3389)
 		$rdpport = 'NULL';
 	$query = "UPDATE user SET "
@@ -4547,7 +4566,7 @@
 	       .        "rdpport = $rdpport "
 	       . "WHERE id = $userid";
 	doQuery($query, 270);
-	return mysql_affected_rows($mysql_link_vcl);
+	return mysqli_affected_rows($mysqli_link_vcl);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -4556,7 +4575,7 @@
 ///
 /// \param $userid - an id from the user table
 ///
-/// \return an array of privileges types that the user has somewhere in the 
+/// \return an array of privileges types that the user has somewhere in the
 /// privilege tree
 ///
 /// \brief get the privilege types that the user has somewhere in the
@@ -4578,7 +4597,7 @@
 	       .                         "WHERE ownerid = $userid))";
 	$qh = doQuery($query, 107);
 	$privileges = array();
-	while($row = mysql_fetch_row($qh))
+	while($row = mysqli_fetch_row($qh))
 		$privileges[] = $row[0];
 	if(in_array("mgmtNodeAdmin", $privileges))
 		$privileges[] = 'managementnodeAdmin';
@@ -4613,7 +4632,7 @@
 	       .       "r.groupid IN ($inids)";
 	$ids = array();
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$ids[] = $row['id'];
 	return $ids;
 }
@@ -4734,7 +4753,7 @@
 			$query .=   "AND rq.id != $requestid ";
 		$query .= "LIMIT 1";
 		$qh = doQuery($query, 101);
-		if(mysql_num_rows($qh)) {
+		if(mysqli_num_rows($qh)) {
 			return debugIsAvailable(-3, 2, $start, $end, $imagerevisionid);
 		}
 
@@ -4744,7 +4763,7 @@
 		       . "WHERE IPaddress = '$ip' AND "
 		       .       "stateid != 1";
 		$qh = doQuery($query, 101);
-		if(mysql_num_rows($qh)) {
+		if(mysqli_num_rows($qh)) {
 			return debugIsAvailable(-4, 16, $start, $end, $imagerevisionid);
 		}
 	}
@@ -4761,7 +4780,7 @@
 
 	foreach($requestInfo["images"] as $key => $imageid) {
 		# check for max concurrent usage of image
-		if(! $skipconcurrentcheck && 
+		if(! $skipconcurrentcheck &&
 		   $images[$imageid]['maxconcurrent'] != NULL) {
 			if($userid == 0)
 				$usersgroups = $user['groups'];
@@ -4785,7 +4804,7 @@
 			       .       "rq.stateid NOT IN (1,5,11,12,16,17) AND "
 			       .       "rq.userid != $reloadid";
 			$qh = doQuery($query, 101);
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				$compids[] = $row['computerid'];
 				if($row['reqid'] == $requestid)
 					$decforedit = 1;
@@ -4807,7 +4826,7 @@
 			       .       "bt.skip != 1 AND "
 			       .       "br.status != 'deleted'";
 			$qh = doQuery($query);
-			if(! $row = mysql_fetch_assoc($qh)) {
+			if(! $row = mysqli_fetch_assoc($qh)) {
 				cleanSemaphore();
 				return debugIsAvailable(0, 3, $start, $end, $imagerevisionid);
 			}
@@ -4877,7 +4896,7 @@
 			       . "FROM computer "
 			       . "WHERE id = $compid";
 			$qh = doQuery($query, 128);
-			$row = mysql_fetch_row($qh);
+			$row = mysqli_fetch_row($qh);
 			if(! in_array($row[0], $scheduleids)) {
 				cleanSemaphore();
 				return debugIsAvailable(0, 7, $start, $end, $imagerevisionid, $computerids, $currentids, $blockids);
@@ -4893,7 +4912,7 @@
 			       . "LEFT JOIN OS ON (i.OSid = OS.id) "
 			       . "WHERE i.id = $imageid";
 			$qh = doQuery($query, 101);
-			if(! ($row = mysql_fetch_assoc($qh))) {
+			if(! ($row = mysqli_fetch_assoc($qh))) {
 				cleanSemaphore();
 				return debugIsAvailable(0, 8, $start, $end, $imagerevisionid, $computerids, $currentids, $blockids);
 			}
@@ -4952,7 +4971,7 @@
 			       .          "network";
 
 			$qh = doQuery($query, 129);
-			while($row = mysql_fetch_assoc($qh)) {
+			while($row = mysqli_fetch_assoc($qh)) {
 				array_push($computerids, $row['id']);
 				if($row['currentimageid'] == $imageid &&
 				   $row['imagerevisionid'] == $requestInfo['imagerevisions'][$key]) {
@@ -4981,7 +5000,7 @@
 		       .       "rq.stateid NOT IN (5, 12, 19) AND " # failed, complete, reload
 		       .       "(rq.stateid != 14 OR rq.laststateid != 19)"; # pending/reload
 		$qh = doQuery($query, 130);
-		while($row = mysql_fetch_row($qh)) {
+		while($row = mysqli_fetch_row($qh)) {
 			array_push($usedComputerids, $row[0]);
 		}
 
@@ -5056,7 +5075,7 @@
 			       .          "c.network";
 			$qh = doQuery($query, 101);
 			$newcompids = array();
-			while($row = mysql_fetch_assoc($qh))
+			while($row = mysqli_fetch_assoc($qh))
 				$newcompids[] = $row['id'];
 			$computerids = $newcompids;
 		}
@@ -5078,7 +5097,7 @@
 			       .       "(type != 'virtualmachine' OR "
 			       .       "vmhostid IS NOT NULL)";
 			$qh = doQuery($query);
-			if(mysql_num_rows($qh)) {
+			if(mysqli_num_rows($qh)) {
 				if($now)
 					return debugIsAvailable(-4, 18, $start, $end, $imagerevisionid, $computerids, $currentids, $blockids, array(), $virtual);
 				$requestInfo['ipwarning'] = 1;
@@ -5090,14 +5109,14 @@
 			if($requestid)
 				$query .= " AND id != $compid"; # TODO test this
 			$qh = doQuery($query);
-			$cnt = mysql_num_rows($qh);
+			$cnt = mysqli_num_rows($qh);
 			if($cnt > 1) {
 				if($now)
 					return debugIsAvailable(-4, 22, $start, $end, $imagerevisionid, $computerids, $currentids, $blockids, array(), $virtual);
 				$requestInfo['ipwarning'] = 1;
 			}
 			elseif($cnt == 1) {
-				$row = mysql_fetch_assoc($qh);
+				$row = mysqli_fetch_assoc($qh);
 				$computerids = array($row['id']);
 				$blockids = array();
 			}
@@ -5302,7 +5321,7 @@
 
 	$scheduleids = array();
 	$qh = doQuery($query, 127);
-	while($row = mysql_fetch_row($qh)) {
+	while($row = mysqli_fetch_row($qh)) {
 		array_push($scheduleids, $row[0]);
 	}
 	return $scheduleids;
@@ -5322,7 +5341,7 @@
 function getImagePlatform($imageid) {
 	$query = "SELECT platformid FROM image WHERE id = $imageid";
 	$qh = doQuery($query, 125);
-	if(! $row = mysql_fetch_assoc($qh))
+	if(! $row = mysqli_fetch_assoc($qh))
 		return NULL;
 	return $row['platformid'];
 }
@@ -5350,7 +5369,7 @@
 	       .       "(('$startdt' > (start - INTERVAL 30 MINUTE)) AND ('$startdt' < end))) AND "
 	       .       "end > NOW()";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_row($qh))
+	if($row = mysqli_fetch_row($qh))
 		return true;
 	return false;
 }
@@ -5453,7 +5472,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 function getSemaphore($imageid, $imagerevisionid, $mgmtnodeid, $compid, $start,
                       $end, $requestid=0) {
-	global $mysql_link_vcl, $uniqid;
+	global $mysqli_link_vcl, $uniqid;
 	$query = "INSERT INTO semaphore "
 	       . "SELECT c.id, "
 	       .        "$imageid, "
@@ -5467,7 +5486,7 @@
 	       .       "(s.expires IS NULL OR s.expires < NOW()) "
 	       . "LIMIT 1";
 	doQuery($query);
-	$rc = mysql_affected_rows($mysql_link_vcl);
+	$rc = mysqli_affected_rows($mysqli_link_vcl);
 
 	# check to see if another process allocated this one
 	if($rc) {
@@ -5483,7 +5502,7 @@
 		if($requestid)
 			$query .= " AND rq.id != $requestid";
 		$qh = doQuery($query);
-		$rc2 = mysql_num_rows($qh);
+		$rc2 = mysqli_num_rows($qh);
 		if($rc2) {
 			$query = "DELETE FROM semaphore "
 			       . "WHERE computerid = $compid AND "
@@ -5561,7 +5580,7 @@
 	       .       "l.wasavailable = 1 AND "
 	       .       "l.ending != 'failed'";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$comps[] = $row['computerid'];
 	return $comps;
 }
@@ -5576,7 +5595,7 @@
 ///
 /// \return an array of resource ids of type $resourcetype2
 ///
-/// \brief gets a list of resources of type $resourcetype2 that $resourcesubid 
+/// \brief gets a list of resources of type $resourcetype2 that $resourcesubid
 /// of type $resourcetype1 maps to based on the resourcemap table
 ///
 ////////////////////////////////////////////////////////////////////////////////
@@ -5592,7 +5611,7 @@
 	       . "WHERE subid = $resourcesubid AND "
 	       .       "resourcetypeid = $resourcetype1";
 	$qh = doQuery($query, 101);
-	$row = mysql_fetch_row($qh);
+	$row = mysqli_fetch_row($qh);
 	$resourceid = $row[0];
 
 	# get groups $resourceid is in
@@ -5601,7 +5620,7 @@
 	       . "FROM resourcegroupmembers "
 	       . "WHERE resourceid = $resourceid";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_row($qh)) {
+	while($row = mysqli_fetch_row($qh)) {
 		array_push($resourcegroupids, $row[0]);
 	}
 
@@ -5619,7 +5638,7 @@
 	       .       "resourcetypeid1 = $resourcetype1 AND "
 	       .       "resourcetypeid2 = $resourcetype2";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_row($qh)) {
+	while($row = mysqli_fetch_row($qh)) {
 		array_push($type2groupids, $row[0]);
 	}
 
@@ -5631,7 +5650,7 @@
 	       .       "resourcetypeid2 = $resourcetype1 AND "
 	       .       "resourcetypeid1 = $resourcetype2";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_row($qh)) {
+	while($row = mysqli_fetch_row($qh)) {
 		array_push($type2groupids, $row[0]);
 	}
 
@@ -5646,7 +5665,7 @@
 	       . "WHERE m.resourcegroupid IN ($inlist) AND "
 	       .       "m.resourceid = r.id";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_row($qh)) {
+	while($row = mysqli_fetch_row($qh)) {
 		array_push($mappedresources, $row[0]);
 	}
 	return $mappedresources;
@@ -5733,7 +5752,7 @@
 	       .       "r.imageid != $imageid) AND "
 	       .       "r.status = 'accepted'";
 	$qh = doQuery($query, 101);
-	return(mysql_num_rows($qh));
+	return(mysqli_num_rows($qh));
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -5784,7 +5803,7 @@
 	       . "ORDER BY u.overlapResCount DESC "
 	       . "LIMIT 1";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_assoc($qh))
+	if($row = mysqli_fetch_assoc($qh))
 		return $row['overlapResCount'];
 	else
 		return 1;
@@ -5806,7 +5825,7 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function addRequest($forimaging=0, $revisionid=array(), $checkuser=1) {
-	global $requestInfo, $user, $uniqid, $mysql_link_vcl;
+	global $requestInfo, $user, $uniqid, $mysqli_link_vcl;
 	$startstamp = unixToDatetime($requestInfo["start"]);
 	$endstamp = unixToDatetime($requestInfo["end"]);
 	$now = time();
@@ -5823,7 +5842,7 @@
 	addLogEntry($nowfuture, $start, $endstamp, 1, $requestInfo["imageid"]);
 
 	$qh = doQuery("SELECT LAST_INSERT_ID() FROM log", 131);
-	if(! $row = mysql_fetch_row($qh)) {
+	if(! $row = mysqli_fetch_row($qh)) {
 		abort(132);
 	}
 	$logid = $row[0];
@@ -5852,7 +5871,7 @@
 	$qh = doQuery($query, 136);
 
 	$qh = doQuery("SELECT LAST_INSERT_ID() FROM request", 134);
-	if(! $row = mysql_fetch_row($qh)) {
+	if(! $row = mysqli_fetch_row($qh)) {
 		abort(135);
 	}
 	$requestid = $row[0];
@@ -5894,12 +5913,12 @@
 	       .        "computerid, "
 	       .        "imageid, "
 	       .        "imagerevisionid, "
-	       .        "managementnodeid " 
+	       .        "managementnodeid "
 	       . "FROM semaphore "
 	       . "WHERE expires > NOW() AND "
 	       .       "procid = '$uniqid'";
 	doQuery($query);
-	$cnt = mysql_affected_rows($mysql_link_vcl);
+	$cnt = mysqli_affected_rows($mysqli_link_vcl);
 	if($cnt == 0) {
 		# reached this point SEMTIMEOUT seconds after getting semaphore, clean up and abort
 		$query = "DELETE FROM request WHERE id = $requestid";
@@ -6036,7 +6055,7 @@
 	       . "GROUP BY rs.managementnodeid "
 	       . "ORDER BY count";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$mgmtnodecnt[$row["mnid"]] = $row["count"];
 	}
 	uasort($mgmtnodecnt, "sortKeepIndex");
@@ -6113,11 +6132,11 @@
 	       . "FROM request "
 	       . "WHERE id = $id";
 	$qh = doQuery($query, 165);
-	if(! ($data = mysql_fetch_assoc($qh))) {
+	if(! ($data = mysqli_fetch_assoc($qh))) {
 		if($returnNULL)
 			return NULL;
 		# FIXME handle XMLRPC cases
-		if(! $printedHTMLheader) 
+		if(! $printedHTMLheader)
 			print $HTMLheader;
 		print "<h1>" . i("OOPS! - Reservation Has Expired") . "</h1>\n";
 		$h = i("The selected reservation is no longer available. Go to <a>Reservations</a> to request a new reservation or select another one that is available.");
@@ -6163,7 +6182,7 @@
 	$data["reservations"] = array();
 	$data['passwds'] = array();
 	$resids = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		array_push($data["reservations"], $row);
 		$resids[] = $row['reservationid'];
 		$data['passwds'][$row['reservationid']][$data['userid']] = $row['password'];
@@ -6177,7 +6196,7 @@
 	       . "FROM serverrequest "
 	       . "WHERE requestid = $id";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_assoc($qh)) {
+	if($row = mysqli_fetch_assoc($qh)) {
 		$data['serverrequest'] = 1;
 		$data['servername'] = $row['name'];
 		$data['admingroupid'] = $row['admingroupid'];
@@ -6191,7 +6210,7 @@
 		       . "FROM reservationaccounts "
 		       . "WHERE reservationid IN ($inids)";
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$data['passwds'][$row['reservationid']][$row['userid']] = $row['password'];
 	}
 	else
@@ -6204,7 +6223,7 @@
 /// \fn updateRequest($requestid, $nowfuture)
 ///
 /// \param $requestid - the id of the request to be updated
-/// \param $nowfuture (optional) - "now" or "future"; whether the 
+/// \param $nowfuture (optional) - "now" or "future"; whether the
 ///
 /// \brief updates an entry to the request and reservation tables
 ///
@@ -6216,7 +6235,7 @@
 
 	$query = "SELECT logid FROM request WHERE id = $requestid";
 	$qh = doQuery($query, 146);
-	if(! $row = mysql_fetch_row($qh)) {
+	if(! $row = mysqli_fetch_row($qh)) {
 		abort(148);
 	}
 	$logid = $row[0];
@@ -6256,7 +6275,7 @@
 		                    # could be updated, which would end up setting both
 		                    # rows to the same computer
 		doQuery($query, 147);
-		addChangeLogEntry($logid, NULL, $endstamp, $startstamp, $computerid, NULL, 
+		addChangeLogEntry($logid, NULL, $endstamp, $startstamp, $computerid, NULL,
 		                  1);
 		$query = "UPDATE sublog "
 		       . "SET computerid = $computerid "
@@ -6343,7 +6362,7 @@
 	if($request['serverrequest']) {
 		$query = "SELECT id FROM serverrequest WHERE requestid = {$request['id']}";
 		$qh = doQuery($query);
-		if($row = mysql_fetch_assoc($qh)) {
+		if($row = mysqli_fetch_assoc($qh)) {
 			$query = "DELETE FROM serverrequest WHERE requestid = {$request['id']}";
 			doQuery($query, 152);
 			deleteVariable("fixedIPsr{$row['id']}");
@@ -6394,7 +6413,7 @@
 		       . "ORDER BY reservations "
 		       . "LIMIT 1";
 		$qh = doQuery($query, 101);
-		if($row = mysql_fetch_assoc($qh))
+		if($row = mysqli_fetch_assoc($qh))
 			$compid = $row["computerid"];
 		else
 			return -1;
@@ -6418,7 +6437,7 @@
 	if($count)
 		$query .= " LIMIT $count";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$resInfo[$row["id"]] = $row;
 	}
 	if(! count($resInfo))
@@ -6430,7 +6449,7 @@
 	# a reservation is reassigned to meets the same restrictions
 	foreach($resInfo as $res) {
 		// pass forimaging = 1 so that isAvailable only looks at one computer
-		$rc = isAvailable($images, $res["imageid"], $res['imagerevisionid'], 
+		$rc = isAvailable($images, $res["imageid"], $res['imagerevisionid'],
 		      datetimeToUnix($res["start"]), datetimeToUnix($res["end"]), 0,
 		      0, $res["userid"], 0, 1);
 		if($rc < 1) {
@@ -6442,7 +6461,7 @@
 		return 0;
 	foreach($resInfo as $res) {
 		$rc = isAvailable($images, $res["imageid"], $res['imagerevisionid'],
-		      datetimeToUnix($res["start"]), datetimeToUnix($res["end"]), 1, 
+		      datetimeToUnix($res["start"]), datetimeToUnix($res["end"]), 1,
 		      0, $res["userid"], 0, 1);
 		if($rc > 0) {
 			$newcompid = array_shift($requestInfo["computers"]);
@@ -6500,7 +6519,7 @@
 	       . "WHERE v.computerid = $compid AND "
 	       .       "vm.vmhostid = v.id";
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$rc = moveReservationsOffComputer($row['id']);
 		if($rc != 0)
 			# lock computer so that reservations on other VMs on this host do not get moved to it
@@ -6535,7 +6554,7 @@
 	       . "ORDER BY rq.end DESC "
 	       . "LIMIT 1";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_assoc($qh))
+	if($row = mysqli_fetch_assoc($qh))
 		$end = $row['end'];
 	$query = "SELECT UNIX_TIMESTAMP(t.end) as end "
 	       . "FROM blockComputers c, "
@@ -6546,7 +6565,7 @@
 	       . "ORDER BY t.end DESC "
 	       . "LIMIT 1";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_assoc($qh))
+	if($row = mysqli_fetch_assoc($qh))
 		if($row['end'] > $end)
 			$end = $row['end'];
 	return $end;
@@ -6572,7 +6591,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 function getCompFinalVMReservationTime($hostid, $addsemaphores=0,
                                        $notomaintenance=0) {
-	global $uniqid, $mysql_link_vcl;
+	global $uniqid, $mysqli_link_vcl;
 	if($addsemaphores) {
 		$query = "SELECT vm.id "
 		       . "FROM computer vm, "
@@ -6581,7 +6600,7 @@
 		       .       "vm.vmhostid = v.id";
 		$qh = doQuery($query);
 		$compids = array();
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$compids[] = $row['id'];
 		if(empty($compids))
 			return 0;
@@ -6604,7 +6623,7 @@
 		       .       "(s.expires IS NULL OR s.expires < NOW()) "
 		       . "GROUP BY c.id";
 		doQuery($query);
-		$cnt = mysql_affected_rows($mysql_link_vcl);
+		$cnt = mysqli_affected_rows($mysqli_link_vcl);
 		if($cnt != count($compids))
 			return -1;
 	}
@@ -6626,7 +6645,7 @@
 	       . "ORDER BY rq.end DESC "
 	       . "LIMIT 1";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_assoc($qh))
+	if($row = mysqli_fetch_assoc($qh))
 		$end = $row['end'];
 	$query = "SELECT UNIX_TIMESTAMP(t.end) as end "
 	       . "FROM blockComputers c, "
@@ -6641,7 +6660,7 @@
 	       . "ORDER BY t.end DESC "
 	       . "LIMIT 1";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_assoc($qh))
+	if($row = mysqli_fetch_assoc($qh))
 		if($row['end'] > $end)
 			$end = $row['end'];
 	return $end;
@@ -6671,7 +6690,7 @@
 	       . "ORDER BY rq.start "
 	       . "LIMIT 1";
 	$qh = doQuery($query);
-	if($row = mysql_fetch_assoc($qh))
+	if($row = mysqli_fetch_assoc($qh))
 		return datetimeToUnix($row['start']);
 	return 0;
 }
@@ -6856,7 +6875,7 @@
 	$data = array();
 	$foundids = array();
 	$lastreqid = 0;
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if($row['id'] != $lastreqid) {
 			$lastreqid = $row['id'];
 			$count++;
@@ -6894,7 +6913,7 @@
 			}
 			else {
 				$data[$count]['serverowner'] = 0;
-				if(! empty($row['serveradmingroupid']) && 
+				if(! empty($row['serveradmingroupid']) &&
 				   array_key_exists($row['serveradmingroupid'], $user['groups']))
 					$data[$count]['serveradmin'] = 1;
 				else
@@ -6983,7 +7002,7 @@
 	$tmp = explode(' ', $datetime);
 	list($year, $month, $day) = explode('-', $tmp[0]);
 	list($hour, $min, $sec) = explode(':', $tmp[1]);
-	return mktime($hour, $min, $sec, $month, $day, $year, -1);
+	return mktime($hour, $min, $sec, $month, $day, $year);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -7170,7 +7189,7 @@
 function getDepartmentName($id) {
 	$query = "SELECT name FROM department WHERE id = '$id'";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_row($qh)) {
+	if($row = mysqli_fetch_row($qh)) {
 		return $row[0];
 	}
 	else {
@@ -7182,7 +7201,7 @@
 ///
 /// \fn getImageId($image)
 ///
-/// \param $image - name of an image (must match name (not prettyname) in the 
+/// \param $image - name of an image (must match name (not prettyname) in the
 /// image table)
 ///
 /// \return the id of matching $image in the image table or 0 if lookup fails
@@ -7192,7 +7211,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 function getImageId($image) {
 	$qh = doQuery("SELECT id FROM image WHERE name = '$image'", 170);
-	if($row = mysql_fetch_row($qh)) {
+	if($row = mysqli_fetch_row($qh)) {
 		return $row[0];
 	}
 	return 0;
@@ -7211,7 +7230,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 function getOSId($os) {
 	$qh = doQuery("SELECT id FROM OS WHERE name = '$os'", 175);
-	if($row = mysql_fetch_row($qh)) {
+	if($row = mysqli_fetch_row($qh)) {
 		return $row[0];
 	}
 	return 0;
@@ -7229,7 +7248,7 @@
 function getStates() {
 	$qh = doQuery("SELECT id, name FROM state", 176);
 	$states = array();
-	while($row = mysql_fetch_row($qh)) {
+	while($row = mysqli_fetch_row($qh)) {
 		$states[$row[0]] = $row[1];
 	}
 	return $states;
@@ -7247,7 +7266,7 @@
 function getPlatforms() {
 	$qh = doQuery("SELECT id, name FROM platform", 178);
 	$platforms = array();
-	while($row = mysql_fetch_row($qh)) {
+	while($row = mysqli_fetch_row($qh)) {
 		$platforms[$row[0]] = $row[1];
 	}
 	return $platforms;
@@ -7275,7 +7294,7 @@
 	       . "ORDER BY p.prettyname";
 	$qh = doQuery($query, 101);
 	$provisioning = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$provisioning[$row['id']] = $row;
 	return $provisioning;
 }
@@ -7299,7 +7318,7 @@
 function getProvisioningTypes() {
 	$query = "SELECT id, prettyname FROM provisioning WHERE name = 'none'";
 	$qh = doQuery($query);
-	$none = mysql_fetch_assoc($qh);
+	$none = mysqli_fetch_assoc($qh);
 	$query = "SELECT p.id, "
 	       .        "p.prettyname, "
 	       .        "o.name AS `type` "
@@ -7313,7 +7332,7 @@
 	$types = array('blade' => array($none['id'] => $none['prettyname']),
 	               'lab' => array(),
 	               'virtualmachine' => array());
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if($row['type'] == 'kickstart' || $row['type'] == 'partimage')
 			$types['blade'][$row['id']] = $row['prettyname'];
 		elseif($row['type'] == 'none')
@@ -7358,7 +7377,7 @@
 	       . "ORDER BY s.name";
 	$qh = doQuery($query, 179);
 	$schedules = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$schedules[$row["id"]] = $row;
 		$schedules[$row["id"]]["times"] = array();
 	}
@@ -7369,7 +7388,7 @@
 	       . "ORDER BY scheduleid, "
 	       .          "start";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		array_push($schedules[$row["scheduleid"]]["times"],
 		           array("start" => $row["start"], "end" => $row["end"]));
 	}
@@ -7493,7 +7512,7 @@
 	}
 	$qh = doQuery($query, 101);
 	$return = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if(is_null($row['natpublicIPaddress'])) {
 			$row['nathostenabled'] = 0;
 			$row['natpublicIPaddress'] = '';
@@ -7519,7 +7538,7 @@
 			$return[$mn_id]['timeservers'] = $timeservers;
 		}
 	}
-	
+
 	return $return;
 }
 
@@ -7551,7 +7570,7 @@
 	       .       "c.id in ($inlist)";
 	$qh = doQuery($query);
 	$compgroups = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$compgroups[] = $row['resourcegroupid'];
 	$mngrps = array();
 	foreach($compgroups as $grpid) {
@@ -7644,7 +7663,7 @@
 	       . "WHERE perlpackage LIKE 'VCL::Module::Predictive::%'";
 	$qh = doQuery($query, 101);
 	$modules = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$modules[$row['id']] = $row;
 	return $modules;
 }
@@ -7660,7 +7679,7 @@
 /// \return array of free/used timeslotes
 ///
 /// \brief generates an array of availability for computers where index is a
-/// computerid with a value that is an array whose indexes are unix timestamps 
+/// computerid with a value that is an array whose indexes are unix timestamps
 /// that increment by 15 minutes with a value that is an array with 2 indexes:
 /// 'scheduleclosed' and 'available' that tell if the computer's schedule is
 /// closed at that moment and if the computer is available at that moment\n
@@ -7716,7 +7735,7 @@
 		       .  "AND platformid IN ($platinlist)";
 	}
 	$qh = doQuery($query, 155);
-	while($row = mysql_fetch_row($qh)) {
+	while($row = mysqli_fetch_row($qh)) {
 		array_push($computerids, $row[0]);
 		$times[$row[0]] = array();
 		$scheduleids[$row[0]] = $row[1];
@@ -7764,7 +7783,7 @@
 	$qh = doQuery($query, 156);
 
 	$id = "";
-	while($row = mysql_fetch_row($qh)) {
+	while($row = mysqli_fetch_row($qh)) {
 		if($row[3] == $requestid) {
 			continue;
 		}
@@ -7855,7 +7874,7 @@
 				continue;
 			}
 			//if between a start and end time
-			if($current >= $times[$id][$count]["start"] && 
+			if($current >= $times[$id][$count]["start"] &&
 			   $current <  $times[$id][$count]["end"]) {
 				if($first) {
 					# set the previous 15 minute block to show as busy to allow for load time
@@ -7874,7 +7893,7 @@
 				continue;
 			}
 			//if after previous end but before this start
-			if($current >= $times[$id][$count - 1]["end"] && 
+			if($current >= $times[$id][$count - 1]["end"] &&
 			   $current <  $times[$id][$count]["start"]) {
 				$reserveInfo[$id][$current]["available"] = 1;
 				continue;
@@ -7928,8 +7947,7 @@
 	              0,
 	              $timeval["mon"],
 	              $timeval["mday"],
-	              $timeval["year"],
-	              -1);
+	              $timeval["year"]);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -8010,11 +8028,11 @@
 		$usercomputerids = array_keys($resources["computer"]);
 		# get list of computers' platformids
 		$qh = doQuery("SELECT platformid FROM image WHERE id = $imageid", 110);
-		$row = mysql_fetch_row($qh);
+		$row = mysqli_fetch_row($qh);
 		$platformid = $row[0];
 		$computer_platformids = array();
 		$qh = doQuery("SELECT id, platformid FROM computer", 111);
-		while($row = mysql_fetch_row($qh)) {
+		while($row = mysqli_fetch_row($qh)) {
 			$computer_platformids[$row[0]] = $row[1];
 		}
 		$mappedcomputers = getMappedResources($imageid, "image", "computer");
@@ -8304,7 +8322,7 @@
 /// \param $ip - (optional, default='') desired IP address
 /// \param $mac - (optional, default='') desired MAC address
 ///
-/// \return an array where each key is a unix timestamp for the start time of 
+/// \return an array where each key is a unix timestamp for the start time of
 /// the available slot and each element is an array with these items:\n
 /// \b start - start of slot in datetime format\n
 /// \b startts - start of slot in unix timestamp format\n
@@ -8399,7 +8417,7 @@
 	       .          "(c.procspeed * c.procnumber), "
 	       .          "network";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$row['duration'] = $reqduration;
 		$row['startts'] = $start;
 		$row['start'] = $startdt;
@@ -8453,7 +8471,7 @@
 		       . "GROUP BY rq1.id ";
 		$query .= "ORDER BY rs1.computerid, rq1.start, rq1.end";
 		$qh = doQuery($query, 101);
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			$row['startts'] = datetimeToUnix($row['start']);
 			if($row['startts'] % 900) {
 				$row['startts'] = $row['startts'] - ($row['startts'] % 900) + 900;
@@ -8512,7 +8530,7 @@
 	$query .=      "(c.type != 'virtualmachine' OR c.vmhostid IS NOT NULL) "
 	       . "GROUP BY rs.computerid";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if($row['endts'] % 900) {
 			$row['endts'] = $row['endts'] - ($row['endts'] % 900);
 			$row['duration'] -= 900;
@@ -8568,7 +8586,7 @@
 	if($extendonly)
 		$query .= " HAVING start = '$startdt'";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if($usedaysahead && $row['startts'] > $daysahead)
 			continue;
 		if($row['startts'] % 900) {
@@ -8605,7 +8623,7 @@
 		       .    "br.imageid != $imageid) AND ";
 	$query .=      "bc.computerid IN ($newincompids)";
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if(isset($slots[$row['compid']]))
 			fATremoveOverlaps($slots, $row['compid'], $row['start'], $row['end'], 0);
 	}
@@ -8634,7 +8652,7 @@
 		elseif(! empty($mac))
 			$query .=   "s.fixedIP = '$mac'";
 		$qh = doQuery($query);
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			if(isset($slots[$row['compid']]))
 				fATremoveOverlaps($slots, $row['compid'], $row['start'], $row['end'], 0);
 		}
@@ -8648,7 +8666,7 @@
 	       . "WHERE start < '$maxenddt' AND "
 	       .       "end > '$minstartdt'";
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		foreach(array_keys($slots) AS $compid)
 			fATremoveOverlaps($slots, $compid, $row['start'], $row['end'],
 			                  $row['allowreservations']);
@@ -8804,7 +8822,7 @@
 	if($extendonly)
 		$query .= " AND rq.id != $reqid";
 	$qh = doQuery($query);
-	if(mysql_num_rows($qh) >= $maxoverlap)
+	if(mysqli_num_rows($qh) >= $maxoverlap)
 		return 1;
 	return 0;
 }
@@ -8957,7 +8975,7 @@
 		$query .= "AND c.id = $compid ";
 	$query .= "ORDER BY c.hostname";
 	$qh = doQuery($query, 180);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if(is_null($row['nathostid'])) {
 			$row['natenabled'] = 0;
 			$row['nathost'] = '';
@@ -8993,7 +9011,7 @@
 	if(isset($_SESSION['usersessiondata'][$key]))
 		return $_SESSION['usersessiondata'][$key];
 	$computers = getComputers();
-	$resources = getUserResources(array("computerAdmin"), 
+	$resources = getUserResources(array("computerAdmin"),
 	                              array("administer", "manageGroup"), 0, 1);
 	$return = array("platforms" => array(),
 	                "schedules" => array());
@@ -9026,7 +9044,7 @@
 /// they occur\n
 /// \b nextstates - array where each key is a computerloadstate id and its value
 /// is that state's following state; the last state has a NULL value\n
-/// \b totaltime - estimated time (in seconds) it takes for all states to 
+/// \b totaltime - estimated time (in seconds) it takes for all states to
 /// complete\n
 /// \b data - array where each key is is a computerloadstate id and each value
 /// is an array with these elements:\n
@@ -9048,13 +9066,13 @@
 	#   need this information
 	$query = "SELECT id FROM computerloadstate WHERE loadstatename = 'repeat'";
 	$qh = doQuery($query, 101);
-	if(! $row = mysql_fetch_assoc($qh))
+	if(! $row = mysqli_fetch_assoc($qh))
 		return array();
 	$loadstates['repeatid'] = $row['id'];
 
 	$query = "SELECT `type` FROM computer WHERE id = $compid";
 	$qh = doQuery($query, 101);
-	if(! $row = mysql_fetch_assoc($qh))
+	if(! $row = mysqli_fetch_assoc($qh))
 		return array();
 
 	$type = $row['type'];
@@ -9073,7 +9091,7 @@
 	        . "(SELECT nextstateid FROM computerloadflow WHERE `type` = '$type' "
 	        . "AND nextstateid IS NOT NULL)";
 	$qh = doQuery($query2, 101);
-	if(! $row = mysql_fetch_assoc($qh))
+	if(! $row = mysqli_fetch_assoc($qh))
 		return array();
 	$loadstates['data'][$row['stateid']] = $row;
 	$loadstates['stateids'] = array($row['stateid']);
@@ -9083,7 +9101,7 @@
 		$query2 = $query . "AND cf.computerloadstateid = {$row['nextstateid']} "
 		        . "AND `type` = '$type'";
 		$qh = doQuery($query2, 101);
-		if(! $row = mysql_fetch_assoc($qh)) {
+		if(! $row = mysqli_fetch_assoc($qh)) {
 			$_SESSION['compstateflow'][$key] = $loadstates;
 			return $loadstates;
 		}
@@ -9128,7 +9146,7 @@
 	       .       "rs.requestid = rq.id "
 	       . "LIMIT 1";
 	$qh = doQuery($query, 101);
-	if(! $row = mysql_fetch_assoc($qh))
+	if(! $row = mysqli_fetch_assoc($qh))
 		abort(113);
 	if($row['start'] < $row['reqtime']) {
 		# now
@@ -9151,7 +9169,7 @@
 	$qh = doQuery($query, 101);
 	$last = array();
 	$data = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$data[$row['id']] = $row;
 		if(empty($last)) {
 			if($future)
@@ -9191,7 +9209,7 @@
 	       .        "start > (NOW() - INTERVAL 12 MONTH) AND "
 	       .        "UNIX_TIMESTAMP(loaded) - UNIX_TIMESTAMP(start) < 1800";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_assoc($qh)) {
+	if($row = mysqli_fetch_assoc($qh)) {
 		if(! empty($row['avgloadtime']))
 			return (int)$row['avgloadtime'];
 		else
@@ -9217,7 +9235,7 @@
 		       . "FROM sublog "
 		       . "WHERE computerid = $compid";
 		$qh = doQuery($query, 101);
-		if($row = mysql_fetch_row($qh))
+		if($row = mysqli_fetch_row($qh))
 			$computers[$compid]["counts"] = $row[0];
 		else
 			$computers[$compid]["counts"] = 0;
@@ -9344,7 +9362,7 @@
 	       .       "c2.id NOT IN ($alloccompids) "
 	       . "ORDER BY s.name";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$data['compids'][] = $row['computerid'];
 		$data[$row['computerid']] = $row;
 	}
@@ -9375,7 +9393,7 @@
 	       .       "t.start < '$enddt' AND "
 	       .       "c.blockTimeid = t.id";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		array_push($compids, $row['computerid']);
 	}
 	return $compids;
@@ -9411,7 +9429,7 @@
 	if($id)
 		$query .= " WHERE n.id = $id";
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$nathosts[$row['id']] = $row;
 	if($sort)
 		uasort($nathosts, "sortKeepIndex");
@@ -9440,8 +9458,8 @@
 function getNATports($resid) {
 	$ports = array();
 	$query = "SELECT n.publicport, "
-	       .        "n.connectmethodportid, " 
-	       .        "c.port AS privateport, " 
+	       .        "n.connectmethodportid, "
+	       .        "c.port AS privateport, "
 	       .        "c.protocol, "
 	       .        "c.connectmethodid "
 	       . "FROM natport n, "
@@ -9449,7 +9467,7 @@
 	       . "WHERE n.connectmethodportid = c.id AND "
 	       .       "n.reservationid = $resid";
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$ports[$row['connectmethodid']]["#Port-{$row['protocol']}-{$row['privateport']}#"] = $row;
 	return $ports;
 }
@@ -9499,7 +9517,7 @@
 
 	$qh = doQuery($query);
 	$addomainlist = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$addomainlist[$row['id']] = $row;
 	return $addomainlist;
 }
@@ -9562,7 +9580,7 @@
 		$query .= " AND t.end > '" . unixToDatetime($start) . "'";
 	$query .= " ORDER BY t.start, t.end";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$return[$row['timeid']] = $row;
 		$return[$row['timeid']]['unixstart'] = datetimeToUnix($row['start']);
 		$return[$row['timeid']]['unixend'] = datetimeToUnix($row['end']);
@@ -9571,7 +9589,7 @@
 		        . "FROM blockComputers "
 		        . "WHERE blockTimeid = {$row['timeid']}";
 		$qh2 = doQuery($query2, 101);
-		while($row2 = mysql_fetch_assoc($qh2))
+		while($row2 = mysqli_fetch_assoc($qh2))
 			array_push($return[$row['timeid']]['computerids'], $row2['computerid']);
 	}
 	return $return;
@@ -9625,7 +9643,7 @@
 	       .       "bt.end > '$nowdt' AND "
 	       .       "br.imageid = $imageid";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_assoc($qh))
+	if($row = mysqli_fetch_assoc($qh))
 		return 1;
 	return 0;
 }
@@ -9648,7 +9666,7 @@
 /// \param $extra - (optional) any extra attributes that need to be set
 ///
 /// \brief prints out a select input part of a form\n
-/// it is assumed that if $selectedid is left off, we assume $dataArr has no 
+/// it is assumed that if $selectedid is left off, we assume $dataArr has no
 /// index '-1'\n
 /// each OPTION's value is the index of that element of the array
 ///
@@ -9707,7 +9725,7 @@
 /// multiple tag set
 ///
 /// \brief generates HTML for select input
-/// it is assumed that if $selectedid is left off, we assume $dataArr has no 
+/// it is assumed that if $selectedid is left off, we assume $dataArr has no
 /// index '-1'\n
 /// each OPTION's value is the index of that element of the array
 ///
@@ -9941,12 +9959,12 @@
 ///
 /// \fn requestIsReady($request)
 ///
-/// \param $request - a request element from the array returned by 
+/// \param $request - a request element from the array returned by
 /// getUserRequests
 ///
 /// \return 1 if request is ready for a user to connect, 0 if not
 ///
-/// \brief checks to see if a request is 
+/// \brief checks to see if a request is
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function requestIsReady($request) {
@@ -9954,7 +9972,7 @@
 		if($res["computerstateid"] != 3 && $res["computerstateid"] != 8)
 			return 0;
 	}
-	if(($request["currstateid"] == 14 &&      // request current state pending 
+	if(($request["currstateid"] == 14 &&      // request current state pending
 	   $request["laststateid"] == 3 &&        //   and last state reserved and
 	   $request["computerstateid"] == 3) ||   //   computer reserved
 	   ($request["currstateid"] == 8 &&       // request current state inuse
@@ -10171,7 +10189,7 @@
 ///
 /// \return 1 if schedule is closed at $timestamp, 0 if it is open
 ///
-/// \brief checks to see if the computer's schedule is open or closed at 
+/// \brief checks to see if the computer's schedule is open or closed at
 /// $timestamp
 ///
 ////////////////////////////////////////////////////////////////////////////////
@@ -10228,7 +10246,7 @@
 	       .       "u.courseroll = 0";
 	$qh = doQuery($query, 305);
 	$oldusergroups = array();
-	while($row = mysql_fetch_row($qh)) {
+	while($row = mysqli_fetch_row($qh)) {
 		array_push($oldusergroups, $row[0]);
 	}
 	if(count(array_diff($oldusergroups, $newusergroups)) ||
@@ -10276,7 +10294,7 @@
 	       . "WHERE name = '$name' AND "
 	       .       "affiliationid = $affilid";
 	$qh = doQuery($query, 300);
-	if($row = mysql_fetch_row($qh))
+	if($row = mysqli_fetch_row($qh))
 		return $row[0];
 	elseif($noadd)
 		return NULL;
@@ -10292,7 +10310,7 @@
 	       .        "0)";
 	doQuery($query, 301);
 	$qh = doQuery("SELECT LAST_INSERT_ID() FROM usergroup", 302);
-	if(! $row = mysql_fetch_row($qh)) {
+	if(! $row = mysqli_fetch_row($qh)) {
 		abort(303);
 	}
 	return $row[0];
@@ -10303,7 +10321,7 @@
 /// \fn getUserGroupName($id, $incAffil)
 ///
 /// \param $id - id of a user group
-/// \param $incAffil - 0 or 1 (optional, defaults to 0); include @ and 
+/// \param $incAffil - 0 or 1 (optional, defaults to 0); include @ and
 /// affiliation at the end
 ///
 /// \return name for $id from usergroup table or 0 if name not found
@@ -10325,7 +10343,7 @@
 		       . "WHERE id = $id";
 	}
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_row($qh))
+	if($row = mysqli_fetch_row($qh))
 		return $row[0];
 	return 0;
 }
@@ -10402,7 +10420,7 @@
 	$query .= "ORDER BY m.start";
 	$qh = doQuery($query, 101);
 	$data = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$data[$row['id']] = $row;
 	$_SESSION['usersessiondata'][$key] = $data;
 	return $data;
@@ -10437,7 +10455,7 @@
 	       . "ORDER BY start";
 	$qh = doQuery($query, 101);
 	$data = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$data[] = $row;
 	$_SESSION['usersessiondata'][$key] = $data;
 	return $data;
@@ -10454,7 +10472,7 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function unset_by_val($needle, &$haystack) {
-	while(($gotcha = array_search($needle,$haystack)) > -1) { 
+	while(($gotcha = array_search($needle,$haystack)) > -1) {
 		unset($haystack[$gotcha]);
 	}
 }
@@ -10468,13 +10486,16 @@
 ////////////////////////////////////////////////////////////////////////////////
 function sendRDPfile() {
 	global $user;
-	# for more info on this file, see 
+	# for more info on this file, see
 	# http://dev.remotenetworktechnology.com/ts/rdpfile.htm
 	$requestid = getContinuationVar("requestid");
 	$resid = getContinuationVar("resid");
+
+	$cmid = getContinuationVar('cmid');
+
 	$request = getRequestInfo("$requestid");
 	if($request['stateid'] == 11 || $request['stateid'] == 12 ||
-	   ($request['stateid'] == 14 && 
+	   ($request['stateid'] == 14 &&
 	   ($request['laststateid'] == 11 || $request['laststateid'] == 12))) {
 		$cont = addContinuationsEntry('viewRequests');
 		header("Location: " . BASEURL . SCRIPT . "?continuation=$cont");
@@ -10494,20 +10515,19 @@
 	                                          $res['imagerevisionid']);
 	$natports = getNATports($resid);
 	$port = '';
-	foreach($connectData as $cmid => $method) {
-		if(preg_match('/remote desktop/i', $method['description']) ||
-		   preg_match('/RDP/i', $method['description'])) {
-			# assume index 0 of ports for nat
-			if(! empty($natports) && array_key_exists($method['ports'][0]['key'], $natports[$cmid]))
-				$port = ':' . $natports[$cmid][$method['ports'][0]['key']]['publicport'];
-			else {
-				if($method['ports'][0]['key'] == '#Port-TCP-3389#' &&
-				   $user['rdpport'] != 3389)
-					$port = ':' . $user['rdpport'];
-				else
-					$port = ':' . $method['ports'][0]['port'];
-			}
-			break;
+
+	$method = $connectData[$cmid];
+	if(preg_match('/remote desktop/i', $method['description']) ||
+	   preg_match('/RDP/i', $method['description'])) {
+		# assume index 0 of ports for nat
+		if(! empty($natports) && array_key_exists($method['ports'][0]['key'], $natports[$cmid]))
+			$port = ':' . $natports[$cmid][$method['ports'][0]['key']]['publicport'];
+		else {
+			if($method['ports'][0]['key'] == '#Port-TCP-3389#' &&
+			   $user['rdpport'] != 3389)
+				$port = ':' . $user['rdpport'];
+			else
+				$port = ':' . $method['ports'][0]['port'];
 		}
 	}
 
@@ -10542,15 +10562,15 @@
 	print "desktopwidth:i:$width\r\n";
 	print "desktopheight:i:$height\r\n";
 	print "session bpp:i:$bpp\r\n";
-	
+
 	print "winposstr:s:0,1,0,0,5000,4000\r\n";
-	# 0: 
+	# 0:
 	# 1:    use coordinates for the window position, as opposed to 3 - maximized
 	# 0:    left position in client coordinates
 	# 0:    top position in client coordinates
 	# 5000: width in pixels - set large to avoid scrollbars
 	# 4000: height in pixels - set large to avoid scrollbars
-	
+
 	print "full address:s:$ipaddress$port\r\n";
 	print "compression:i:1\r\n";
 	print "keyboardhook:i:2\r\n";
@@ -10567,6 +10587,8 @@
 		$userid = $user["unityid"];
 	if($request['reservations'][0]['domainDNSName'] != '' && ! strlen($passwd))
 		$userid .= "@" . $request['reservations'][0]['domainDNSName'];
+	elseif($request['reservations'][0]['OStype'] == 'windows')
+		$userid = ".\\$userid";
 	print "username:s:$userid\r\n";
 	print "clear password:s:$passwd\r\n";
 	print "domain:s:\r\n";
@@ -10634,16 +10656,16 @@
 /// available; \b NOTE: pass -1 instead of NULL if you don't want this field
 /// to be updated
 ///
-/// \brief adds an entry to the changelog table and updates information in 
+/// \brief adds an entry to the changelog table and updates information in
 /// the log table
 ///
 ////////////////////////////////////////////////////////////////////////////////
-function addChangeLogEntry($logid, $remoteIP, $end=NULL, $start=NULL, 
+function addChangeLogEntry($logid, $remoteIP, $end=NULL, $start=NULL,
                            $computerid=NULL, $ending=NULL, $wasavailable=-1) {
 	if($logid == 0) {
 		return;
 	}
-	$query = "SELECT computerid, " 
+	$query = "SELECT computerid, "
 	       .        "start, "
 	       .        "initialend, "
 	       .        "remoteIP, "
@@ -10652,13 +10674,13 @@
 	       . "FROM log "
 	       . "WHERE id = $logid";
 	$qh = doQuery($query, 265);
-	if(! $log = mysql_fetch_assoc($qh)) {
+	if(! $log = mysqli_fetch_assoc($qh)) {
 		abort(30);
 	}
 	$log["computerid"] = array();
 	$query = "SELECT computerid FROM sublog WHERE logid = $logid";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		array_push($log["computerid"], $row["computerid"]);
 	}
 	$changed = 0;
@@ -10760,7 +10782,7 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function addChangeLogEntryOther($logid, $data) {
-	$data = mysql_real_escape_string($data);
+	$data = vcl_mysql_escape_string($data);
 	$query = "INSERT INTO changelog "
 	       .        "(logid, "
 	       .        "timestamp, "
@@ -10796,7 +10818,7 @@
 	       . "FROM computer "
 	       . "WHERE id = $computerid";
 	$qh = doQuery($query, 101);
-	$row = mysql_fetch_assoc($qh);
+	$row = mysqli_fetch_assoc($qh);
 	$predictiveid = $row['predictivemoduleid'];
 	$query = "SELECT c.type, "
 	       .        "v.computerid AS hostid "
@@ -10804,7 +10826,7 @@
 	       . "LEFT JOIN vmhost v ON (c.vmhostid = v.id) "
 	       . "WHERE c.id = $computerid";
 	$qh = doQuery($query, 101);
-	$row = mysql_fetch_assoc($qh);
+	$row = mysqli_fetch_assoc($qh);
 	if($row['type'] == 'virtualmachine')
 		$hostcomputerid = $row['hostid'];
 	else
@@ -10856,7 +10878,7 @@
 	if($subtype == "users" || $subtype == "both") {
 		$query = "SELECT id, name FROM userprivtype WHERE name NOT IN ('configAdmin', 'serverProfileAdmin')";
 		$qh = doQuery($query, 365);
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			if($row["name"] == "block" || $row["name"] == "cascade")
 				continue;
 			$types["users"][$row["id"]] = $row["name"];
@@ -10865,7 +10887,7 @@
 	if($subtype == "resources" || $subtype == "both") {
 		$query = "SELECT id, name FROM resourcetype";
 		$qh = doQuery($query, 366);
-		while($row = mysql_fetch_assoc($qh))
+		while($row = mysqli_fetch_assoc($qh))
 			$types["resources"][$row["id"]] = $row["name"];
 	}
 	return $types;
@@ -10885,7 +10907,7 @@
 function getUserPrivTypeID($type) {
 	$query = "SELECT id FROM userprivtype WHERE name = '$type'";
 	$qh = doQuery($query, 370);
-	if($row = mysql_fetch_row($qh))
+	if($row = mysqli_fetch_row($qh))
 		return $row[0];
 	else
 		return NULL;
@@ -10934,8 +10956,8 @@
 ///
 /// \param $max - max allowed length in minutes
 ///
-/// \return array of lengths up to $max starting with 30 minutes, 1 hour, 
-/// 2 hours, then increasing by 2 hours up to 47 hours, then 2 days, then 
+/// \return array of lengths up to $max starting with 30 minutes, 1 hour,
+/// 2 hours, then increasing by 2 hours up to 47 hours, then 2 days, then
 /// increasing by 1 day; indexes are the duration in minutes
 ///
 /// \brief generates an array of reservation lengths
@@ -11057,8 +11079,8 @@
 ////////////////////////////////////////////////////////////////////////////////
 function getResourceGroupID($groupname) {
 	list($type, $name) = explode('/', $groupname);
-	$type = mysql_real_escape_string($type);
-	$name = mysql_real_escape_string($name);
+	$type = vcl_mysql_escape_string($type);
+	$name = vcl_mysql_escape_string($name);
 	$query = "SELECT g.id "
 	       . "FROM resourcegroup g, "
 	       .      "resourcetype t "
@@ -11066,7 +11088,7 @@
 	       .       "t.name = '$type' AND "
 	       .       "g.resourcetypeid = t.id";
 	$qh = doQuery($query, 371);
-	if($row = mysql_fetch_row($qh))
+	if($row = mysqli_fetch_row($qh))
 		return $row[0];
 	else
 		return NULL;
@@ -11089,7 +11111,7 @@
 	       . "FROM resourcegroup "
 	       . "WHERE id = $groupid";
 	$qh = doQuery($query);
-	if($row = mysql_fetch_assoc($qh))
+	if($row = mysqli_fetch_assoc($qh))
 		return $row['name'];
 	else
 		return NULL;
@@ -11107,12 +11129,12 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function getResourceTypeID($name) {
-	$name = mysql_real_escape_string($name);
+	$name = vcl_mysql_escape_string($name);
 	$query = "SELECT id "
 	       . "FROM resourcetype "
 	       . "WHERE name = '$name'";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_row($qh))
+	if($row = mysqli_fetch_row($qh))
 		return $row[0];
 	else
 		return NULL;
@@ -11131,7 +11153,7 @@
 function getResourcePrivs() {
 	$query = "show columns from resourcepriv where field = 'type'";
 	$qh = doQuery($query, 101);
-	$row = mysql_fetch_assoc($qh);
+	$row = mysqli_fetch_assoc($qh);
 	preg_match("/^enum\(([a-zA-Z0-9,']+)\)$/", $row['Type'], $matches);
 	$tmp = str_replace("'", '', $matches[1]);
 	return explode(',', $tmp);
@@ -11151,7 +11173,7 @@
 	$query = "SELECT id, prettyname FROM configtype ORDER BY name";
 	$qh = doQuery($query);
 	$types = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$types[$row['id']] = $row['prettyname'];
 	return $types;
 }
@@ -11170,7 +11192,7 @@
 	$query = "SELECT id, name FROM datatype ORDER BY name";
 	$qh = doQuery($query);
 	$types = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$types[$row['id']] = $row['name'];
 	return $types;
 }
@@ -11195,7 +11217,7 @@
 	$query .= "ORDER BY prettyname";
 	$qh = doQuery($query);
 	$types = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$types[$row['id']] = $row['prettyname'];
 	return $types;
 }
@@ -11240,7 +11262,7 @@
 	       .      "user u, "
 	       .      "affiliation ua, "
 	       .      "configtype ct, "
-	       .      "configmaptype cmt, " 
+	       .      "configmaptype cmt, "
 	       .      "affiliation a, "
 	       .      "configstage cs "
 	       . "WHERE cm.configid = c.id AND "
@@ -11261,7 +11283,7 @@
 	$qh = doQuery($query);
 	$configs = array();
 	$configids = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$row['configmapid'] = $row['id'];
 		if(is_null($row['subimageid']))
 			$configids[] = $row['configid'];
@@ -11345,7 +11367,7 @@
 	       .      "user u, "
 	       .      "affiliation ua, "
 	       .      "configtype ct, "
-	       .      "configmaptype cmt, " 
+	       .      "configmaptype cmt, "
 	       .      "affiliation a, "
 	       .      "configstage cs "
 	       . "WHERE cm.configid = c.id AND "
@@ -11372,7 +11394,7 @@
 	$qh = doQuery($query);
 	$configs = array();
 	$configids = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$row['configmapid'] = $row['id'];
 		if(is_null($row['subimageid']))
 			$configids[] = $row['configid'];
@@ -11442,7 +11464,7 @@
 	       . "ORDER BY cv.configid";
 	$data = array();
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$row['required'] = (int)$row['required'];
 		$row['ask'] = (int)$row['ask'];
 		#$row['defaultvalue'] = htmlspecialchars($row['defaultvalue']);
@@ -11515,7 +11537,7 @@
 	$qh = doQuery($query);
 	$clusters = array();
 	$subimageids = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$children = getConfigClustersRec($row['configsubimageid'], $flat);
 		if(! empty($children)) {
 			if($flat)
@@ -11578,7 +11600,7 @@
 	       .        "a.name = 'Global')";
 	$qh = doQuery($query);
 	$clusters = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if($rec < 20)
 			$children = getConfigClustersRec($row['configsubimageid'], $flat, ++$rec);
 		if($rec < 20 && ! empty($children)) {
@@ -11606,7 +11628,7 @@
 	$query = "SELECT id, name FROM OStype ORDER BY name";
 	$qh = doQuery($query);
 	$types = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$types[$row['id']] = $row['name'];
 	return $types;
 }
@@ -11639,7 +11661,7 @@
 	       .       "c.id IN ($inlist)";
 	$configs = array();
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$configs[$row['id']] = $row['name'];
 	return $configs;
 }
@@ -11662,7 +11684,7 @@
 	if(isset($cache['nodes'][$nodeid]))
 		return $cache['nodes'][$nodeid];
 	$qh = doQuery("SELECT id, parent, name FROM privnode", 330);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$cache['nodes'][$row['id']] = $row;
 	if(isset($cache['nodes'][$nodeid]))
 		return $cache['nodes'][$nodeid];
@@ -11749,7 +11771,7 @@
 ///
 /// \return -1, 0, 1 if numerical parts of $a <, =, or > $b
 ///
-/// \brief compares $a and $b to determine which one should be ordered first; 
+/// \brief compares $a and $b to determine which one should be ordered first;
 /// has some understand of numerical order in strings
 ///
 ////////////////////////////////////////////////////////////////////////////////
@@ -11809,8 +11831,8 @@
 /// \param $resource2inlist - (optional) comma delimited list of resource groups
 /// to limit query to
 ///
-/// \return an array of $resourcetype1 group to $resourcetype2 group mappings 
-/// where each index is a group id from $resourcetype1 and each value is an 
+/// \return an array of $resourcetype1 group to $resourcetype2 group mappings
+/// where each index is a group id from $resourcetype1 and each value is an
 /// array of $resourcetype2 group ids
 ///
 /// \brief builds an array of $resourcetype2 group ids for each $resourcetype1
@@ -11839,7 +11861,7 @@
 	if(! empty($resource2inlist))
 		$query .= "AND resourcegroupid2 IN ($resource2inlist) ";
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if($resourcetype1 == $row['resourcetypeid1']) {
 			if(array_key_exists($row["resourcegroupid1"], $return))
 				array_push($return[$row["resourcegroupid1"]], $row["resourcegroupid2"]);
@@ -11891,7 +11913,7 @@
 	       . "ORDER BY c.description";
 	$methods = array();
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$methods[$row['id']] = $row;
 	$_SESSION['usersessiondata'][$key] = $methods;
 	return $methods;
@@ -11929,7 +11951,7 @@
 	       . "ORDER BY start "
 	       . "LIMIT 1";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_assoc($qh)) {
+	if($row = mysqli_fetch_assoc($qh)) {
 		$end = datetimeToUnix($request["end"]);
 		$start = datetimeToUnix($row["start"]);
 		return ($start - $end) / 60;
@@ -11974,8 +11996,8 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function cleanSemaphore() {
-	global $mysql_link_vcl, $uniqid;
-	if(! is_resource($mysql_link_vcl) || ! get_resource_type($mysql_link_vcl) == 'mysql link')
+	global $mysqli_link_vcl, $uniqid;
+	if(! is_resource($mysqli_link_vcl) || ! get_resource_type($mysqli_link_vcl) == 'mysql link')
 		return;
 	$query = "DELETE FROM semaphore "
 	       . "WHERE procid = '$uniqid'";
@@ -12024,7 +12046,7 @@
 /// \param $id (optional) - a profile id; if specified, only data about this
 /// profile will be returned
 ///
-/// \return an array of profiles where each key is the profile id and each 
+/// \return an array of profiles where each key is the profile id and each
 /// element is an array with these keys:\n
 /// \b profilename - name of profile\n
 /// \b name - name of profile (so array can be passed to printSelectInput)\n
@@ -12083,7 +12105,7 @@
 		$query .= " AND vp.id = $id";
 	$qh = doQuery($query, 101);
 	$ret = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$ret[$row['id']] = $row;
 	return $ret;
 }
@@ -12103,7 +12125,7 @@
 function getENUMvalues($table, $field) {
 	$query = "DESC $table";
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if($row['Field'] == "$field") {
 			$data = preg_replace(array('/^enum\(/', "/'/", '/\)$/'), array('', '', ''), $row['Type']);
 			$types = explode(',', $data);
@@ -12117,7 +12139,7 @@
 /// \fn addContinuationsEntry($nextmode, $data, $duration, $deleteFromSelf,
 ///                           $multicall, $repeatProtect)
 ///
-/// \param $nextmode - next mode to go in to 
+/// \param $nextmode - next mode to go in to
 /// \param $data (optional, default=array())- array of data to make available
 /// in $nextmode
 /// \param $duration (optional, default=SECINWEEK)- how long this continuation
@@ -12152,7 +12174,7 @@
 		$contid = md5($mode . $nextmode . $serdata . $user['id'] . $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']);
 	else
 		$contid = md5($mode . $nextmode . $serdata . $user['id'] . $_SERVER['REMOTE_ADDR']);
-	$serdata = mysql_real_escape_string($serdata);
+	$serdata = vcl_mysql_escape_string($serdata);
 	$expiretime = unixToDatetime(time() + $duration);
 	$query = "SELECT id, "
 	       .        "parentid "
@@ -12160,7 +12182,7 @@
 	       . "WHERE id = '$contid' AND "
 	       .       "userid = {$user['id']}";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_assoc($qh)) {
+	if($row = mysqli_fetch_assoc($qh)) {
 		# update expiretime
 		$query = "UPDATE continuations "
 		       . "SET expiretime = '$expiretime' "
@@ -12183,7 +12205,7 @@
 			       . "WHERE id = '$continuationid' AND "
 			       .       "userid = {$user['id']}";
 			$qh = doQuery($query, 101);
-			if(! $row = mysql_fetch_assoc($qh))
+			if(! $row = mysqli_fetch_assoc($qh))
 				abort(108);
 			$deletefromid = $row['deletefromid'];
 		}
@@ -12267,7 +12289,7 @@
 	$qh = doQuery($query, 101);
 
 	# return error if it is not there
-	if(! ($row = mysql_fetch_assoc($qh)))
+	if(! ($row = mysqli_fetch_assoc($qh)))
 		return array('error' => 'continuation does not exist');
 
 	# return error if it is expired
@@ -12373,7 +12395,7 @@
 	       . "FROM shibauth "
 	       . "WHERE id = $id";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_assoc($qh)) {
+	if($row = mysqli_fetch_assoc($qh)) {
 		$data = unserialize($row['data']);
 		unset($row['data']);
 		$data2 = array_merge($row, $data);
@@ -12412,7 +12434,7 @@
 	$query .= "FROM variable "
 	       .  "WHERE name = '$key'";
 	$qh = doQuery($query);
-	if($row = mysql_fetch_assoc($qh)) {
+	if($row = mysqli_fetch_assoc($qh)) {
 		if($incparams) {
 			switch($row['serialization']) {
 				case 'yaml':
@@ -12451,7 +12473,7 @@
 ///
 /// \return array of values from variable table
 ///
-/// \brief gets data from the variable table for $pattern matches 'name' from 
+/// \brief gets data from the variable table for $pattern matches 'name' from
 /// table
 ///
 ////////////////////////////////////////////////////////////////////////////////
@@ -12463,7 +12485,7 @@
 	       . "WHERE name REGEXP '$pattern'";
 	$qh = doQuery($query);
 	$ret = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		switch($row['serialization']) {
 			case 'none':
 				$ret[$row['name']] = $row['value'];
@@ -12499,7 +12521,7 @@
 	$update = 0;
 	$query = "SELECT serialization FROM variable WHERE name = '$key'";
 	$qh = doQuery($query);
-	if($row = mysql_fetch_assoc($qh)) {
+	if($row = mysqli_fetch_assoc($qh)) {
 		if($serialization == '')
 			$serialization = $row['serialization'];
 		$update = 1;
@@ -12509,19 +12531,19 @@
 	$_SESSION['variables'][$key] = $data;
 	switch($serialization) {
 		case 'none':
-			$qdata = mysql_real_escape_string($data);
+			$qdata = vcl_mysql_escape_string($data);
 			break;
 		case 'yaml':
 			$yaml = Spyc::YAMLDump($data);
-			$qdata = mysql_real_escape_string($yaml);
+			$qdata = vcl_mysql_escape_string($yaml);
 			break;
 		case 'phpserialize':
-			$qdata = mysql_real_escape_string(serialize($data));
+			$qdata = vcl_mysql_escape_string(serialize($data));
 			break;
 	}
 	if($update)
 		$query = "UPDATE variable "
-		       . "SET value = '$qdata', " 
+		       . "SET value = '$qdata', "
 		       .     "serialization = '$serialization', "
 		       .     "setby = 'webcode', "
 		       .     "timestamp = NOW() "
@@ -12727,15 +12749,15 @@
 		$keyid = $user['id'];
 	if(function_exists($function)) {
 		if(! defined('XMLRPCLOGGING') || XMLRPCLOGGING != 0) {
-			$saveargs = mysql_real_escape_string(serialize($args));
+			$saveargs = vcl_mysql_escape_string(serialize($args));
 			$query = "INSERT INTO xmlrpcLog "
-			       .        "(xmlrpcKeyid, " 
+			       .        "(xmlrpcKeyid, "
 			       .        "timestamp, "
 			       .        "IPaddress, "
 			       .        "method, "
 			       .        "apiversion, "
 			       .        "comments) "
-			       . "VALUES " 
+			       . "VALUES "
 			       .        "($keyid, "
 			       .        "NOW(), "
 			       .        "'$remoteIP', "
@@ -12768,13 +12790,13 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function xmlRPCabort($errcode, $query='') {
-	global $mysql_link_vcl, $mysql_link_acct, $ERRORS, $user, $mode;
+	global $mysqli_link_vcl, $mysqli_link_acct, $ERRORS, $user, $mode;
 	global $XMLRPCERRORS;
 	if(ONLINEDEBUG && checkUserHasPerm('View Debug Information')) {
 		$msg = '';
 		if($errcode >= 100 && $errcode < 400) {
-			$msg .= "ERROR (" . mysql_errno($mysql_link_vcl) . ") - ";
-			$msg .= mysql_error($mysql_link_vcl) . " $query ";
+			$msg .= "ERROR (" . mysqli_errno($mysqli_link_vcl) . ") - ";
+			$msg .= mysqli_error($mysqli_link_vcl) . " $query ";
 		}
 		$msg .= $ERRORS["$errcode"];
 		$XMLRPCERRORS[100] = $msg;
@@ -12783,8 +12805,8 @@
 	else {
 		$message = "";
 		if($errcode >= 100 && $errcode < 400) {
-			$message .= mysql_error($mysql_link_vcl) . "\n";
-			$message .= mysql_error($mysql_link_acct) . "\n";
+			$message .= mysqli_error($mysqli_link_vcl) . "\n";
+			$message .= mysqli_error($mysqli_link_acct) . "\n";
 			$message .= $query . "\n";
 		}
 		$message .= "ERROR($errcode): " . $ERRORS["$errcode"] . "\n";
@@ -12934,7 +12956,7 @@
 			             'errormsg' => 'existing user group with submitted name and affiliation');
 		}
 		elseif($exists && $doesexist) {
-			$esc_name = mysql_real_escape_string($items['name']);
+			$esc_name = vcl_mysql_escape_string($items['name']);
 			$items['id'] = getUserGroupID($esc_name, $affilid);
 		}
 	}
@@ -13022,7 +13044,7 @@
 			 // Always use "." for floats.
 			 return floatval(str_replace(",", ".", strval($a)));
 		}
- 
+
 		if (is_string($a)) {
 			 static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
 			return '"' . str_replace($jsonReplaces[0], $jsonReplaces[1], $a) . '"';
@@ -14363,7 +14385,7 @@
 		setcookie("VCLLOCALE", $_COOKIE['VCLLOCALE'], (time() + (86400 * 31)), "/", COOKIEDOMAIN);
 		$locale = $_COOKIE['VCLLOCALE'];
 	}
-	
+
 	#putenv('LC_ALL=' . $locale);
 	# use UTF8 encoding for any locales other than English (we may just be able
 	#   to always use UTF8)
diff --git a/web/.ht-inc/vm.php b/web/.ht-inc/vm.php
index 5375cdf..90c96a5 100644
--- a/web/.ht-inc/vm.php
+++ b/web/.ht-inc/vm.php
@@ -47,7 +47,7 @@
 	print "</div>\n";
 
 	$newmsg = "To create a new Virtual Host, change the state of a computer to<br>\n"
-	        . "'vmhostinuse' under Manage Computers-&gt;Computer Utilities.<br><br>\n";
+	        . "'vmhostinuse' under Manage Computers-&gt;Edit Computer Profiles.<br><br>\n";
 	$vmhosts = getVMHostData();
 	$resources = getUserResources(array("computerAdmin"), array("administer"));
 	foreach($vmhosts as $key => $value) {
@@ -380,7 +380,7 @@
 	$currvms = array();
 	$noaccess = array();
 	$freevms = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if($row['vmhostid'] == $vmhostid) {
 			$ids[$row['id']] = $row['hostname'];
 			if(array_key_exists($row['id'], $computers))
@@ -423,7 +423,7 @@
 		       .       "rq.laststateid = 18) AND "
 		       .       "rq.start > NOW()";
 		$qh = doQuery($query, 101);
-		while($row = mysql_fetch_assoc($qh)) {
+		while($row = mysqli_fetch_assoc($qh)) {
 			$movevms[] = array('id' => $row['id'],
 			                 'time' => strtolower($row['start']) . ' ' . date('T'),
 			                 'hostname' => $currvms[$row['computerid']]['name']);
@@ -480,7 +480,7 @@
 		$query .= " AND vh.id = $id";
 	$qh = doQuery($query, 101);
 	$ret = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$ret[$row['id']] = $row;
 		foreach($profiles[$row['vmprofileid']] AS $key => $value) {
 			if(is_null($value))
@@ -524,7 +524,7 @@
 	       . "WHERE id in ($vmlistids)";
 	$qh = doQuery($query, 101);
 	$vmdata = array();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if(! array_key_exists($row['id'], $resources['computer'])) {
 			$fails[] = array('id' => $row['id'], 'name' => $row['hostname'], 'reason' => 'noaccess');
 			unset_by_val($row['id'], $vmids);
@@ -537,7 +537,7 @@
 	$query = "SELECT id FROM vmhost";
 	$vmhosts = array();
 	$qh = doQuery($query, 101);
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$vmhosts[$row['id']] = 1;
 
 	# check to see if there any submitted vms have a hostid of an existing vm host
@@ -616,7 +616,7 @@
 		       . "ORDER BY end DESC "
 		       . "LIMIT 1";
 		$qh = doQuery($query, 101);
-		if($row = mysql_fetch_assoc($qh)) {
+		if($row = mysqli_fetch_assoc($qh)) {
 			$checks[] = array('id' => $compid,
 			                  'hostname' => $compdata[$compid]['hostname'],
 			                  'end' => strtolower($row['end']) . ' ' . date('T'),
@@ -840,11 +840,11 @@
 	else {
 		if(get_magic_quotes_gpc())
 			$newvalue = stripslashes($newvalue);
-		$newvalue2 = mysql_real_escape_string($newvalue);
+		$newvalue2 = vcl_mysql_escape_string($newvalue);
 		$newvalue2 = "'$newvalue2'";
 	}
 
-	$item = mysql_real_escape_string($item);
+	$item = vcl_mysql_escape_string($item);
 	$profile = getVMProfiles($profileid);
 	if($item == 'password') {
 		$pwdlen = strlen($newvalue);
@@ -878,7 +878,7 @@
 			       . "WHERE cryptkeyid = $cryptkeyid AND "
 			       .       "secretid = $secretid";
 			$qh = doQuery($query);
-			if(! ($row = mysql_fetch_assoc($qh))) {
+			if(! ($row = mysqli_fetch_assoc($qh))) {
 				# generate a new secret
 				$newsecretid = getSecretKeyID('vmprofile', 'secretid', 0);
 				$delids = array($secretid);
@@ -895,7 +895,7 @@
 				       . "WHERE cs.secretid = $secretid AND "
 				       .       "ck.hosttype = 'managementnode'";
 				$qh = doQuery($query);
-				while($row = mysql_fetch_assoc($qh))
+				while($row = mysqli_fetch_assoc($qh))
 					$secretidset[$row['mnid']][$newsecretid] = 1;
 				$values = getMNcryptkeyUpdates($secretidset, $cryptkeyid);
 				addCryptSecretKeyUpdates($values);
@@ -946,11 +946,11 @@
 	$newprofile = processInputVar('newname', ARG_STRING);
 	if(get_magic_quotes_gpc()) {
 		$newprofile = stripslashes($newprofile);
-		$newprofile = mysql_real_escape_string($newprofile);
+		$newprofile = vcl_mysql_escape_string($newprofile);
 	}
 	$query = "SELECT id FROM vmprofile WHERE profilename = '$newprofile'";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_assoc($qh)) {
+	if($row = mysqli_fetch_assoc($qh)) {
 		sendJSON(array('failed' => 'exists'));
 		return;
 	}
@@ -994,7 +994,7 @@
 	       .       "s.name IN ('vmhostinuse', 'tovmhostinuse') AND " 
 	       .       "vh.vmprofileid = $profileid";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_assoc($qh)) {
+	if($row = mysqli_fetch_assoc($qh)) {
 		sendJSON(array('failed' => 'inuse'));
 		return;
 	}
diff --git a/web/.ht-inc/xmlrpcWrappers.php b/web/.ht-inc/xmlrpcWrappers.php
index 0ec5c74..33b1587 100644
--- a/web/.ht-inc/xmlrpcWrappers.php
+++ b/web/.ht-inc/xmlrpcWrappers.php
@@ -430,7 +430,7 @@
 			$admingroup = stripslashes($admingroup);
 		if(preg_match('/@/', $admingroup)) {
 			$tmp = explode('@', $admingroup);
-			$escadmingroup = mysql_real_escape_string($tmp[0]);
+			$escadmingroup = vcl_mysql_escape_string($tmp[0]);
 			$affilid = getAffiliationID($tmp[1]);
 			if(is_null($affilid)) {
 				return array('status' => 'error',
@@ -439,7 +439,7 @@
 			}
 		}
 		else {
-			$escadmingroup = mysql_real_escape_string($admingroup);
+			$escadmingroup = vcl_mysql_escape_string($admingroup);
 			$affilid = DEFAULT_AFFILID;
 		}
 		$admingroupid = getUserGroupID($escadmingroup, $affilid, 1);
@@ -457,7 +457,7 @@
 			$logingroup = stripslashes($logingroup);
 		if(preg_match('/@/', $logingroup)) {
 			$tmp = explode('@', $logingroup);
-			$esclogingroup = mysql_real_escape_string($tmp[0]);
+			$esclogingroup = vcl_mysql_escape_string($tmp[0]);
 			$affilid = getAffiliationID($tmp[1]);
 			if(is_null($affilid)) {
 				return array('status' => 'error',
@@ -466,7 +466,7 @@
 			}
 		}
 		else {
-			$esclogingroup = mysql_real_escape_string($logingroup);
+			$esclogingroup = vcl_mysql_escape_string($logingroup);
 			$affilid = DEFAULT_AFFILID;
 		}
 		$logingroupid = getUserGroupID($esclogingroup, $affilid, 1);
@@ -514,7 +514,7 @@
 		                         . "spaces, dashes(-), underscores(_), and periods(.) "
 		                         . "and be up to 255 characters long");
 	}
-	$name = mysql_real_escape_string($name);
+	$name = vcl_mysql_escape_string($name);
 
 	# validate $start
 	if($start != 'now' && ! is_numeric($start)) {
@@ -574,7 +574,7 @@
 	if($userdata != '') {
 		if(get_magic_quotes_gpc())
 			$userdata = stripslashes($userdata);
-		$esc_userdata = mysql_real_escape_string($userdata);
+		$esc_userdata = vcl_mysql_escape_string($userdata);
 		$query = "INSERT INTO variable "
 		       .        "(name, "
 		       .        "serialization, "
@@ -1334,7 +1334,7 @@
 	}
 	$query = "SELECT id FROM request WHERE id = $requestid";
 	$qh = doQuery($query, 101);
-	if(! mysql_num_rows($qh)) {
+	if(! mysqli_num_rows($qh)) {
 		return array('status' => 'error',
 		             'errorcode' => 52,
 		             'errormsg' => 'specified request does not exist');
@@ -1772,13 +1772,13 @@
 		in_array("nodeAdmin", $user["privileges"])) {
 		if(get_magic_quotes_gpc())
 			$nodeName = stripslashes($nodeName);
-		$nodeName = mysql_real_escape_string($nodeName);
+		$nodeName = vcl_mysql_escape_string($nodeName);
 		// does a node with this name already exist?
 		$query = "SELECT id "
 		       . "FROM privnode "
 		       . "WHERE name = '$nodeName' AND parent = $parentNode";
 		$qh = doQuery($query, 335);
-		if(mysql_num_rows($qh))
+		if(mysqli_num_rows($qh))
 			return array('status' => 'success', 'exists' => TRUE);
 		else
 			return array('status' => 'success', 'exists' => FALSE);
@@ -1836,7 +1836,7 @@
 			       . "FROM privnode "
 			       . "WHERE name = '$nodeName' AND parent = $parentNode";
 			$qh = doQuery($query);
-			if(mysql_num_rows($qh)) {
+			if(mysqli_num_rows($qh)) {
 				return array('status' => 'error',
 				             'errorcode' => 82,
 				             'errormsg' => 'A node of that name already exists under ' . $nodeInfo['name']);
@@ -1847,7 +1847,7 @@
 			       .        "($parentNode, '$nodeName')";
 			doQuery($query);
 			$qh = doQuery("SELECT LAST_INSERT_ID() FROM privnode", 101);
-			if(! $row = mysql_fetch_row($qh)) {
+			if(! $row = mysqli_fetch_row($qh)) {
 				return array('status' => 'error',
 				             'errorcode' => 85,
 				             'errormsg' => 'Could not add node to database');
@@ -2470,7 +2470,7 @@
 	       . "LEFT JOIN affiliation euga ON (eug.affiliationid = euga.id) "
 	       . "WHERE ug.id = {$rc['id']}";
 	$qh = doQuery($query, 101);
-	if(! $row = mysql_fetch_assoc($qh)) {
+	if(! $row = mysqli_fetch_assoc($qh)) {
 		return array('status' => 'error',
 		             'errorcode' => 18,
 		             'errormsg' => 'user group with submitted name and affiliation does not exist');
@@ -2607,7 +2607,7 @@
                              $newOwner='', $newManagingGroup='',
                              $newInitialMaxTime='', $newTotalMaxTime='',
                              $newMaxExtendTime='') {
-	global $user, $mysql_link_vcl;
+	global $user, $mysqli_link_vcl;
 	if(! in_array('groupAdmin', $user['privileges'])) {
 		return array('status' => 'error',
 		             'errorcode' => 16,
@@ -2650,7 +2650,7 @@
 	       . "FROM usergroup "
 	       . "WHERE id = {$rc['id']}";
 	$qh = doQuery($query, 101);
-	if(! $row = mysql_fetch_assoc($qh)) {
+	if(! $row = mysqli_fetch_assoc($qh)) {
 		return array('status' => 'error',
 		             'errorcode' => 18,
 		             'errormsg' => 'user group with submitted name and affiliation does not exist');
@@ -2675,7 +2675,7 @@
 			if(get_magic_quotes_gpc())
 				$newName = stripslashes($newName);
 			$validate['name'] = $newName;
-			$tmp = mysql_real_escape_string($newName);
+			$tmp = vcl_mysql_escape_string($newName);
 			$updates[] = "name = '$tmp'";
 		}
 		if(! empty($newAffiliation))
@@ -2694,7 +2694,7 @@
 
 	if($row['custom']) {
 		if(! empty($newOwner)) {
-			$newownerid = getUserlistID(mysql_real_escape_string($newOwner));
+			$newownerid = getUserlistID(vcl_mysql_escape_string($newOwner));
 			$updates[] = "ownerid = $newownerid";
 		}
 		if(! empty($newManagingGroup))
@@ -2732,7 +2732,7 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function XMLRPCremoveUserGroup($name, $affiliation) {
-	global $user, $mysql_link_vcl;
+	global $user, $mysqli_link_vcl;
 	if(! in_array('groupAdmin', $user['privileges'])) {
 		return array('status' => 'error',
 		             'errorcode' => 16,
@@ -2750,7 +2750,7 @@
 	       . "FROM usergroup "
 	       . "WHERE id = {$rc['id']}";
 	$qh = doQuery($query, 101);
-	if(! $row = mysql_fetch_assoc($qh)) {
+	if(! $row = mysqli_fetch_assoc($qh)) {
 		return array('status' => 'error',
 		             'errorcode' => 18,
 		             'errormsg' => 'user group with submitted name and affiliation does not exist');
@@ -2775,7 +2775,7 @@
 	       . "WHERE id = {$rc['id']}";
 	doQuery($query, 101);
 	# validate something deleted
-	if(mysql_affected_rows($mysql_link_vcl) == 0) {
+	if(mysqli_affected_rows($mysqli_link_vcl) == 0) {
 		return array('status' => 'error',
 		             'errorcode' => 30,
 		             'errormsg' => 'failure while deleting group from database');
@@ -2849,7 +2849,7 @@
 	       . "FROM usergroup "
 	       . "WHERE id = {$rc['id']}";
 	$qh = doQuery($query, 101);
-	if(! $row = mysql_fetch_assoc($qh)) {
+	if(! $row = mysqli_fetch_assoc($qh)) {
 		return array('status' => 'error',
 		             'errorcode' => 18,
 		             'errormsg' => 'user group with submitted name and affiliation does not exist');
@@ -2875,7 +2875,7 @@
 	       .       "u.affiliationid = a.id";
 	$qh = doQuery($query, 101);
 	$members = array();
-	while($row = mysql_fetch_assoc($qh))
+	while($row = mysqli_fetch_assoc($qh))
 		$members[] = $row['member'];
 	return array('status' => 'success',
 	             'members' => $members);
@@ -2924,7 +2924,7 @@
 	       . "FROM usergroup "
 	       . "WHERE id = {$rc['id']}";
 	$qh = doQuery($query, 101);
-	if(! $row = mysql_fetch_assoc($qh)) {
+	if(! $row = mysqli_fetch_assoc($qh)) {
 		return array('status' => 'error',
 		             'errorcode' => 18,
 		             'errormsg' => 'user group with submitted name and affiliation does not exist');
@@ -2942,7 +2942,7 @@
 			continue;
 		if(get_magic_quotes_gpc())
 			$_user = stripslashes($_user);
-		$esc_user = mysql_real_escape_string($_user);
+		$esc_user = vcl_mysql_escape_string($_user);
 		if(validateUserid($_user) == 1)
 			addUserGroupMember($esc_user, $rc['id']);
 		else
@@ -3006,7 +3006,7 @@
 	       . "FROM usergroup "
 	       . "WHERE id = {$rc['id']}";
 	$qh = doQuery($query, 101);
-	if(! $row = mysql_fetch_assoc($qh)) {
+	if(! $row = mysqli_fetch_assoc($qh)) {
 		return array('status' => 'error',
 		             'errorcode' => 18,
 		             'errormsg' => 'user group with submitted name and affiliation does not exist');
@@ -3024,7 +3024,7 @@
 			continue;
 		if(get_magic_quotes_gpc())
 			$_user = stripslashes($_user);
-		$esc_user = mysql_real_escape_string($_user);
+		$esc_user = vcl_mysql_escape_string($_user);
 		# check that affiliation of user can be determined because getUserlistID
 		#   will abort if it cannot find it
 		$affilok = 0;
@@ -3135,7 +3135,7 @@
 			             'errorcode' => 87,
 			             'errormsg' => 'Name must be between 3 and 30 characters and can only contain letters, numbers, spaces, and these characters: - . _');
 		}
-		$name = mysql_real_escape_string($name);
+		$name = vcl_mysql_escape_string($name);
 		$data = array('type' => 'resource',
 		              'ownergroup' => $rc['managingGroupID'],
 		              'resourcetypeid' => $typeid,
@@ -3476,7 +3476,7 @@
 	       . "WHERE bt.blockRequestid = br.id AND "
 	       .       "bt.id = $blockTimesid";
 	$qh = doQuery($query, 101);
-	if(! $rqdata = mysql_fetch_assoc($qh)) {
+	if(! $rqdata = mysqli_fetch_assoc($qh)) {
 		return array('status' => 'error',
 		             'errorcode' => 8,
 		             'errormsg' => 'unknown blockTimesid');
@@ -3526,8 +3526,8 @@
 		$blockCompVals = array();
 		$checkstartbase = $unixstart - $imgLoadTime - 300;
 		$reloadstartbase = unixToDatetime($checkstartbase);
-		$rows = mysql_num_rows($qh);
-		while($row = mysql_fetch_assoc($qh)) {
+		$rows = mysqli_num_rows($qh);
+		while($row = mysqli_fetch_assoc($qh)) {
 			if(array_key_exists($row['reqid'], $donereqids))
 				continue;
 			$donereqids[$row['reqid']] = 1;
@@ -3594,7 +3594,7 @@
 	       . "FROM blockComputers "
 	       . "WHERE blockTimeid = $blockTimesid";
 	$qh = doQuery($query, 101);
-	if(! $row = mysql_fetch_assoc($qh)) {
+	if(! $row = mysqli_fetch_assoc($qh)) {
 		return array('status' => 'error',
 		             'errorcode' => 15,
 		             'errormsg' => 'failure to communicate with database');
@@ -3772,7 +3772,7 @@
 	       .       "r.subid = i.id AND "
 	       .       "r.resourcetypeid = 13";
 	$qh = doQuery($query);
-	if(mysql_num_rows($qh) != 1) {
+	if(mysqli_num_rows($qh) != 1) {
 		return array('status' => 'error',
 		             'errorcode' => 91,
 		             'errormsg' => 'Invalid resourceid submitted');
@@ -3823,7 +3823,7 @@
 	# check for existance of $reservationid
 	$query = "SELECT id FROM reservation WHERE id = $reservationid";
 	$qh = doQuery($query);
-	if(! ($row = mysql_fetch_assoc($qh))) {
+	if(! ($row = mysqli_fetch_assoc($qh))) {
 		return array('status' => 'error',
 		             'errorcode' => 101,
 		             'errormsg' => 'Specified reservation does not exist');
@@ -3839,7 +3839,7 @@
 	       . "WHERE rs.id = $reservationid AND "
 	       .       "ad.secretid IS NOT NULL";
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$secretids[] = $row['secretid'];
 		$mnid = $row['managementnodeid'];
 	}
@@ -3853,7 +3853,7 @@
 	       . "WHERE rs.id = $reservationid AND "
 	       .       "vp.secretid IS NOT NULL";
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		$secretids[] = $row['secretid'];
 		$mnid = $row['managementnodeid'];
 	}
@@ -3884,7 +3884,7 @@
 	       .       "ck.hosttype = 'managementnode' AND "
 	       .       "cs.id IS NULL";
 	$qh = doQuery($query);
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		if($row['mycryptsecret'] == NULL) {
 			$fails[] = $row['secretid'];
 			continue;
@@ -3952,7 +3952,7 @@
 	       .       "o.userid = {$user['id']}";
 	$qh = doQuery($query);
 	//if nothing returned, oneclick does not exist
-	if(! $row = mysql_fetch_assoc($qh)) {
+	if(! $row = mysqli_fetch_assoc($qh)) {
 		return array('status' => 'error',
 		             'errorcode' => 95,
 		             'errormsg' => "The OneClick with ID $oneclickid does not exist.");
@@ -4027,7 +4027,7 @@
 	$result['status'] = 'success';
 	$result['oneclicks'] = array();
 	#$allstates = getStates();
-	while($row = mysql_fetch_assoc($qh)) {
+	while($row = mysqli_fetch_assoc($qh)) {
 		/*if($row['currstateid'] == 14)
 			$state = $allstates[$row['laststateid']];
 		elseif(! is_null($row['currstateid']))
@@ -4208,7 +4208,7 @@
 	       .       "userid = {$user['id']}";
 	$qh = doQuery($query, 101);
 	//if nothing returned, oneclick does not exist or belongs to another user
-	if(! $row = mysql_fetch_assoc($qh)) {
+	if(! $row = mysqli_fetch_assoc($qh)) {
 		return array('status' => 'error',
 		             'errorcode' => 95,
 		             'errormsg' => "The OneClick with ID $oneclickid does not exist.");
@@ -4262,7 +4262,7 @@
 	       .       "userid = {$user['id']}";
 	$qh = doQuery($query, 101);
 	//if nothing returned, oneclick does not exist or belongs to another user
-	if(! $row = mysql_fetch_assoc($qh)) {
+	if(! $row = mysqli_fetch_assoc($qh)) {
 		return array('status' => 'error',
 		             'errorcode' => 95,
 		             'errormsg' => "The OneClick with ID $oneclickid does not exist.");
diff --git a/web/index.php b/web/index.php
index bbdca0a..6ac26f6 100644
--- a/web/index.php
+++ b/web/index.php
@@ -26,8 +26,8 @@
 }
 
 $user = '';
-$mysql_link_vcl = '';
-$mysql_link_acct = '';
+$mysqli_link_vcl = '';
+$mysqli_link_acct = '';
 $mode = '';
 $oldmode = '';
 $submitErr = '';
diff --git a/web/shibauth/index.php b/web/shibauth/index.php
index 0ab553d..64c33c5 100644
--- a/web/shibauth/index.php
+++ b/web/shibauth/index.php
@@ -43,7 +43,7 @@
 				 .       "a.shibname = '{$tmp[1]}' AND "
 				 .       "u.affiliationid = a.id";
 		$qh = doQuery($query, 101);
-		if($row = mysql_fetch_assoc($qh)) {
+		if($row = mysqli_fetch_assoc($qh)) {
 			$_SERVER['sn'] = $row['lastname'];
 			$_SERVER['givenName'] = $row['firstname'];
 		}
@@ -103,11 +103,11 @@
 $tmp = explode(';', $_SERVER['eppn']);
 $tmp = explode('@', $tmp[0]);
 $username = strtolower($tmp[0]);
-$tmp1 = mysql_escape_string(strtolower($tmp[1]));
+$tmp1 = vcl_mysql_escape_string(strtolower($tmp[1]));
 $query = "SELECT name, shibonly FROM affiliation WHERE shibname = '$tmp1'";
 $qh = doQuery($query, 101);
 # if shib affiliation not already in VCL, create affiliation
-if(! ($row = mysql_fetch_assoc($qh))) {
+if(! ($row = mysqli_fetch_assoc($qh))) {
 	$affil = strtolower($tmp[1]);
 	$tmp = explode('.', $affil);
 	array_pop($tmp);
@@ -120,7 +120,7 @@
 	       . "ORDER BY name DESC "
 	       . "LIMIT 1";
 	$qh = doQuery($query, 101);
-	if($row = mysql_fetch_assoc($qh)) {
+	if($row = mysqli_fetch_assoc($qh)) {
 		if(preg_match("/$affilname([0-9]+)/", $row['name'], $matches)) {
 			$cnt = $matches[1];
 			$cnt++;
@@ -160,7 +160,7 @@
 	       .        "shibonly) "
 	       . "VALUES "
 	       .        "('$newaffilname', "
-	       .        "'" . mysql_escape_string($affil) . "', "
+	       .        "'" . vcl_mysql_escape_string($affil) . "', "
 	       .        "1)";
 	doQuery($query, 101, 'vcl', 1);
 	unset($row);
@@ -210,12 +210,12 @@
                   'unscoped-affiliation' => $_SERVER['unscoped-affiliation'],
                   'affiliation' => $_SERVER['affiliation'],
 );
-$serdata = mysql_escape_string(serialize($shibdata));
+$serdata = vcl_mysql_escape_string(serialize($shibdata));
 $query = "SELECT id "
        . "FROM shibauth "
        . "WHERE sessid = '{$_SERVER['Shib-Session-ID']}'";
 $qh = doQuery($query, 101);
-if($row = mysql_fetch_assoc($qh)) {
+if($row = mysqli_fetch_assoc($qh)) {
 	$shibauthid = $row['id'];
 }
 else {
@@ -233,7 +233,7 @@
 	       .        "'$serdata')";
 	doQuery($query, 101);
 	$qh = doQuery("SELECT LAST_INSERT_ID() FROM shibauth", 101);
-	if(! $row = mysql_fetch_row($qh)) {
+	if(! $row = mysqli_fetch_row($qh)) {
 		# todo
 	}
 	$shibauthid = $row[0];
diff --git a/web/testsetup.php b/web/testsetup.php
index ba3e5ae..8f384d2 100644
--- a/web/testsetup.php
+++ b/web/testsetup.php
@@ -79,14 +79,18 @@
 
 $includesecrets = 1;
 $includeconf = 1;
+$host = $_SERVER['HTTP_HOST'];
+if (strpos($host, ':')) {
+	$host = substr($host, 0, strpos($host, ':'));
+}
 
-if(! ip2long(getHostbyname($_SERVER['HTTP_HOST']))) {
+if(! ip2long(getHostbyname($host))) {
 	print $header;
 	# php version
 	print "PHP version: " . phpversion() . "<br><br>\n";
-	title("Trying to resolve my hostname ({$_SERVER['HTTP_HOST']})");
+	title("Trying to resolve my hostname ($host)");
 	print "<ul>\n";
-	fail("unable to resolve my hostname; ensure {$_SERVER['HTTP_HOST']} is in DNS or create an entry for it in /etc/hosts");
+	fail("unable to resolve my hostname; ensure $host is in DNS or create an entry for it in /etc/hosts");
 	print "</ul>\n";
 	$includesecrets = 0;
 	$includeconf = 0;
@@ -160,8 +164,7 @@
 
 # conf.php tests
 $createcryptkey = 0;
-if($includeconf && include('.ht-inc/conf.php')) {
-	$host = $_SERVER['HTTP_HOST'];
+if($includeconf && include('.ht-inc/conf.php')) {	
 	if(! defined('COOKIEDOMAIN')) {
 		print $header;
 		# php version