PHP Links to Local File on MAC & PC
<p><strong>complete</strong> Novice to PHP and HTML so this could be a schoolboy error. I'm trying to set up a small Intranet site for my work. I want to be able to display links to Local Files Eg Comapny Handbooks, Procedures etc. My main issue is that it needs to be both PC and MAC user friendly (Mac users mainly use Firefox, PC's use IE).I have a PHP script on each page that I can get to work individually for a Mac or a PC but can't get it working simultaneously. Eg I'd like my code to look up the users OS and the run the part of the script relevant to displaying the Local File link for that OS. I believe the critical part of the script is the 'file///' If it's 'file///' it works on a PC in IE &amp; Firefox but it needs to be 'File' (without three /'s) to work on a Mac? but I may be wrong in that analogy. Current code as follows;</p>

<pre><code>&lt;?php

//determine OS of user MAC or PC
$user_agent = getenv("HTTP_USER_AGENT"); 
if (strpos($user_agent, "Win") !== FALSE) 
$os = "Windows"; 
else if((strpos($user_agent, "Mac") !== FALSE) || (strpos($user_agent, "PPC") !== FALSE))
$os = "Mac";

if ($os == "Windows") 
{
//path to S:\One reality\Personnel\Culture &amp; Values
$uncpath = "//servername/shared/one reality/personnel/culture &amp; values/";

//get all files with a .pdf extension.
$files = glob($uncpath . "*.pdf");

//print each file name
foreach ($files as $file)

{
    echo "&lt;a target=_blank href='file:///$file'&gt;".preg_replace("/\\.[^.\\s]{3,4}$/", "",basename($file))."&lt;/a&gt;&lt;br&gt;&lt;br&gt;"; 
}
}
elseif ($os == "Mac")
{
//path to S:\One reality\Personnel\Culture &amp; Values
$uncpath = "//servername/shared/one reality/personnel/culture &amp; values/";

//get all files with a .pdf extension.
$files = glob($uncpath . "*.pdf");

//print each file name
foreach ($files as $file)
{
    echo "&lt;a target=_blank href='file:$file'&gt;".preg_replace("/\\.[^.\\s]{3,4}$/", "",basename($file))."&lt;/a&gt;&lt;br&gt;&lt;br&gt;"; 
}
}

?&gt;
</code></pre>

<p>The above code runs fine on a PC and opens a new TAB as a pdf but on a Mac the code does not get round to running the Mac specific 'file:' without the three slashes and as a result does not know how to display the Local file link. PS I know about allowing local file links in Firefox and that is in place so it's basically a coding issue. I suspect its something wrong within my IF $os = statement.  </p>

<p>I'm preapred to scrap this approach and start again if you think I've gone down the wrong route.  </p>
