I am using this simple PHP script which fetches the shared resources, in this example tiny_mce. How can I extend this script so that it checks if a local copy exists first before fetching the file from the shared resource.
<?php
$request = $_SERVER['QUERY_STRING'];
$url = 'http://shared.domain.co.uk/javascript/' . $request;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
$headers = substr($data, 0, strpos($data, "\r\n\r\n"));
$headers = preg_split('/\n|\r\n?/', $headers);
foreach($headers as $header)
if(strpos($header, 'Content-') !== false)
header($header);
$data = substr($data,strpos($data, "\r\n\r\n")+4);
print $data;
?>
I knew there was a reason, although it does run rather slow.
tinyMCE into 2 locations e.g:
Localhost
Shared subdomain
.php
small php script to be included with each project that uses tinymce e.g: “domain.co.uk/webapp/shared/javascript/resources/tiny_mce/jquery.tinymce.js”
Then a .htaccess script to rewrite anything after “resources” in: domain.co.uk/webapp/shared/javascript/resources