obey-robots.txt
View Thread
Post your improvements and modifications to header.php here.
Did you implemented this?
Yes Yes 100%[1 Vote]
No No 0%[0 Votes]
Total Votes : 1
 Print Thread
header.php Use googleapis as a CDN
Fusioneer
I modified header.php to load jquery.js from googleapis.
This has two advantages.
- You use googleapis as a CDN (Content Delivery Network), reducing your own serverload and loading time of jquery.
- You load the minified version to further improve loading time.

If for some reason the file could not be loaded a fail safe/fall back has been build in.

Original header.php
Download source  GeSHi: PHP
  1. <?php
  2. /*-------------------------------------------------------+
  3. | PHP-Fusion Content Management System
  4. | Copyright (C) 2002 - 2011 Nick Jones
  5. | http://www.php-fusion.co.uk/
  6. +--------------------------------------------------------+
  7. | Filename: header.php
  8. | Author: Nick Jones (Digitanium)
  9. +--------------------------------------------------------+
  10. | This program is released as free software under the
  11. | Affero GPL license. You can redistribute it and/or
  12. | modify it under the terms of this license which you
  13. | can read by viewing the included agpl.txt or online
  14. | at www.gnu.org/licenses/agpl.html. Removal of this
  15. | copyright header is strictly prohibited without
  16. | written permission from the original author(s).
  17. +--------------------------------------------------------*/
  18. if (!defined("IN_FUSION")) { die("Access Denied"); }
  19.  
  20. require_once INCLUDES."output_handling_include.php";
  21. require_once INCLUDES."header_includes.php";
  22. require_once THEME."theme.php";
  23. require_once THEMES."templates/render_functions.php";
  24.  
  25. if ($settings['maintenance'] == "1" && ((iMEMBER && $settings['maintenance_level'] == "1"
  26. && $userdata['user_id'] != "1") || ($settings['maintenance_level'] > $userdata['user_level'])
  27. )) {
  28. redirect(BASEDIR."maintenance.php");
  29. }
  30. if (iMEMBER) {
  31. $result = dbquery(
  32. "UPDATE ".DB_USERS." SET user_lastvisit='".time()."', user_ip='".USER_IP."', user_ip_type='".USER_IP_TYPE."'
  33. WHERE user_id='".$userdata['user_id']."'"
  34. );
  35. }
  36.  
  37. echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n";
  38. echo "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='".$locale['xml_lang']."' lang='".$locale['xml_lang']."'>\n";
  39. echo "<head>\n<title>".$settings['sitename']."</title>\n";
  40. echo "<meta http-equiv='Content-Type' content='text/html; charset=".$locale['charset']."' />\n";
  41. echo "<meta name='description' content='".$settings['description']."' />\n";
  42. echo "<meta name='keywords' content='".$settings['keywords']."' />\n";
  43. echo "<link rel='stylesheet' href='".THEME."styles.css' type='text/css' media='screen' />\n";
  44. if (file_exists(IMAGES."favicon.ico")) { echo "<link rel='shortcut icon' href='".IMAGES."favicon.ico' type='image/x-icon' />\n"; }
  45. if (function_exists("get_head_tags")) { echo get_head_tags(); }
  46. echo "<script type='text/javascript' src='".INCLUDES."jquery/jquery.js'></script>\n";
  47. echo "<script type='text/javascript' src='".INCLUDES."jscript.js'></script>\n";
  48. echo "</head>\n<body>\n";
  49.  
  50. require_once THEMES."templates/panels.php";
  51. ?>
Parsed in 0.052 seconds, using GeSHi 1.0.8.10


Now replace line 46 with:
Download source  GeSHi: PHP
  1. if (FALSE === file_get_contents("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js",NULL,NULL,0,1)) {echo "<script type='text/javascript' src='".INCLUDES."jquery/jquery.js'></script>\n";} else {echo "<script type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'></script>\n";}
  2.  
Parsed in 0.017 seconds, using GeSHi 1.0.8.10


So complete it woul like like this.
Download source  GeSHi: PHP
  1. <?php
  2. /*-------------------------------------------------------+
  3. | PHP-Fusion Content Management System
  4. | Copyright (C) 2002 - 2011 Nick Jones
  5. | http://www.php-fusion.co.uk/
  6. +--------------------------------------------------------+
  7. | Filename: header.php
  8. | Author: Nick Jones (Digitanium)
  9. +--------------------------------------------------------+
  10. | This program is released as free software under the
  11. | Affero GPL license. You can redistribute it and/or
  12. | modify it under the terms of this license which you
  13. | can read by viewing the included agpl.txt or online
  14. | at www.gnu.org/licenses/agpl.html. Removal of this
  15. | copyright header is strictly prohibited without
  16. | written permission from the original author(s).
  17. +--------------------------------------------------------*/
  18. if (!defined("IN_FUSION")) { die("Access Denied"); }
  19.  
  20. require_once INCLUDES."output_handling_include.php";
  21. require_once INCLUDES."header_includes.php";
  22. require_once THEME."theme.php";
  23. require_once THEMES."templates/render_functions.php";
  24.  
  25. if ($settings['maintenance'] == "1" && ((iMEMBER && $settings['maintenance_level'] == "1"
  26. && $userdata['user_id'] != "1") || ($settings['maintenance_level'] > $userdata['user_level'])
  27. )) {
  28. redirect(BASEDIR."maintenance.php");
  29. }
  30. if (iMEMBER) {
  31. $result = dbquery(
  32. "UPDATE ".DB_USERS." SET user_lastvisit='".time()."', user_ip='".USER_IP."', user_ip_type='".USER_IP_TYPE."'
  33. WHERE user_id='".$userdata['user_id']."'"
  34. );
  35. }
  36.  
  37. echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n";
  38. echo "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='".$locale['xml_lang']."' lang='".$locale['xml_lang']."'>\n";
  39. echo "<head>\n<title>".$settings['sitename']."</title>\n";
  40. echo "<meta http-equiv='Content-Type' content='text/html; charset=".$locale['charset']."' />\n";
  41. echo "<meta name='description' content='".$settings['description']."' />\n";
  42. echo "<meta name='keywords' content='".$settings['keywords']."' />\n";
  43. echo "<link rel='stylesheet' href='".THEME."styles.css' type='text/css' media='screen' />\n";
  44. if (file_exists(IMAGES."favicon.ico")) { echo "<link rel='shortcut icon' href='".IMAGES."favicon.ico' type='image/x-icon' />\n"; }
  45. if (function_exists("get_head_tags")) { echo get_head_tags(); }
  46. if (FALSE === file_get_contents("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js",NULL,NULL,0,1)) {echo "<script type='text/javascript' src='".INCLUDES."jquery/jquery.js'></script>\n";} else {echo "<script type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'></script>\n";}
  47. echo "<script type='text/javascript' src='".INCLUDES."jscript.js'></script>\n";
  48. echo "</head>\n<body>\n";
  49.  
  50. require_once THEMES."templates/panels.php";
  51. ?>
Parsed in 0.020 seconds, using GeSHi 1.0.8.10

Warning about ParkingCrew.com! Case: ParkingCrew.com acquires NameDrive.com but earnings are not transferred despite assurances and promises. Inquiries about this are ignored! It's just a con compagny. Don't do business with them!
 
Jump to Forum
New Thread Post Reply
Use BBcode or HTML to refer to; 'header.php Use googleapis as a CDN'
BBcode:
HTML: