Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7557899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:15:11+00:00 2026-05-30T12:15:11+00:00

I am using this simple PHP script which fetches the shared resources, in this

  • 0

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;
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:15:12+00:00Added an answer on May 30, 2026 at 12:15 pm

    I knew there was a reason, although it does run rather slow.

    tinyMCE into 2 locations e.g:

    Localhost

    • /www/javascript/resources/tiny_mce

    Shared subdomain

    • /var/www/domain.co.uk/subdomains/shared/public/javascript/resources/tiny_mce

    .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”

    <?php
    $request = $_SERVER['REQUEST_URI'];
    $request = substr($request, strpos($request, 'javascript/resources/')+21);
    
    $domain = 'shared.domain.co.uk';
    if(strpos($_SERVER['HTTP_HOST'], 'sandbox.') !== false) {
        $domain = 'sandbox.domain.co.uk';
    } elseif(strpos($_SERVER['HTTP_HOST'], 'localhost') !== false || strpos($_SERVER['HTTP_HOST'], '127.0.0.1') !== false) {
        $domain = 'localhost';
    } 
    
    $url = 'http://'.$domain.'/javascript/resources/' . $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;
    ?>
    

    Then a .htaccess script to rewrite anything after “resources” in: domain.co.uk/webapp/shared/javascript/resources

    RewriteEngine On
    
    RewriteRule (.*) index.php?%{QUERY_STRING}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After loading a PHP template (using jQuery's load function), this simple script won't make
im using a simple test script from http://www.tuxradar.com/practicalphp/8/11/0 like this <?php $fp = fopen(foo.txt,
I have an AJAX request (using JQuery) that calls a PHP script which does
I'm looking for a simple script in which I can do something like this
I have had problems with a simple php script in which I can upload
Ho to make this simple xml with php using DOM? Full code will be
Can anybody help me with this simple code?? #include <iostream> using namespace std; void
I am currently submitting a simple PHP form via JavaScript using document.add_driver.submit(); This method
I created a simple Import script that takes a CSV processes it in PHP
I built a simple script in PHP which has two functions: Give uploaded file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.