Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // -------------------------------------------------------------
- header('Content-Type: text/html; charset=utf-8');
- // -------------------------------------------------------------
- $time_stamp = time();
- $cache_time = (3600*24*3);
- $source_url = 'http://code.jquery.com/jquery-latest.min.js';
- $local_file = 'jquery-latest.min.js';
- // -------------------------------------------------------------
- function update_jquery($source_url, $local_file, $cache_time, $time_stamp) {
- $vstatus = false;
- $last_update = @filemtime($local_file);
- if (!$last_update || ($cache_time < ($time_stamp - $last_update))) {
- if (!file_exists($local_file)) {
- copy($source_url,$local_file);
- $vstatus = 'new';
- }
- else {
- $pattern = "@\!\s(.*?)\s\|@";
- $loc = file_get_contents($local_file);
- preg_match($pattern,$loc,$mloc);
- $ext = file_get_contents($source_url);
- preg_match($pattern,$ext,$mext);
- if ($mloc[1] == $mext[1]) {
- touch($local_file,$time_stamp);
- $vstatus = 'no_change';
- }
- else {
- copy($source_url,$local_file);
- $vstatus = 'update';
- }
- }
- }
- else {
- $vstatus = 'cached';
- }
- return $vstatus;
- }
- // -------------------------------------------------------------
- $jver_status = update_jquery($source_url, $local_file, $cache_time, $time_stamp);
- // -------------------------------------------------------------
- print "<p>Update Status: ".$jver_status."</p>\n";
- // -------------------------------------------------------------
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement