VNC Helper for Windows 11
Need to make a Window 11 system understand how to launch VNC for a url like: vnc://[ip]:[port] URL? Pass it to this like: https://geeklabs.com/vnc.php?url=vnc://127.0.0.1:5900
TightVNC from: https://www.tightvnc.com/ is a bit cruder that RemoteRipple. you trigger it to launch from the system with IP address and port as displayed in a web UI.
“VNC Helper” creats a config file that TightVNC can use. Your web browser should ask you if you want to open or download the file when you click that button. Click Open with TightVNC or any other VNC Viewer that will work with that simple file format. Suggested to check the box for “Always open files of this type”.
MS-Edge browser and Chrome: open the download file list and choose to open the file created and downloaded. While viewing that download list: right click on the file that downloaded and choose: “Always open Files of this type” and it will autoload / start TightVNC or other properly associated VNC viewer when you click that button and it downloads.
<?php
// Minimal VNC url to .vnc parser example
// Please add your own input detainting and other sanity checks.
$url = $_REQUEST['url'] ;
$parts = preg_split("/\:/", $url);
if($parts[0] == 'vnc') {
$ip = $parts[1] ;
$port = $parts[2] ;
$strip = array('/\//');
$ip = preg_replace($strip, '', $ip);
} else {
print "needs: ?url=vnc://ip:port" ; die ;
} ;
if($port> 1000 or empty($port)) {
$port = "5900" ;
} ;
if(!empty($ip)) {
$file = "[connection]\nhost=$ip\nport=$port\n" ;
if (strlen($file) < 100 ) { die ; } ; //minimal sanity/safety check
$ctype = "application/vnc";
$filename = "$ip.$port.vnc" ;
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
header("Content-Type: $ctype");
header("Content-Disposition: attachment; filename=\"" . $filename . "\";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . strlen($file));
print "$file\n" ;
exit;
} ;
