Use php.ini to replace html with anything
« 27 Request Methods for Apache rewritecond htaccessPenny Stocks »
By including a php file using php.ini, you can replace the headers in your html with dynamic headers.
Include a php file that contains a function to replace html with different html. You include a file from your php.ini like auto_prepend_file /home/askapache.com/config.php?
config.php example from: Effective way to update your blog’s header scripts
<?php
function Config($page) {
$googleAnalytics = '<!-- Google Analytics -->
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script type="text/javascript">_uacct = "UA-188760-13";urchinTracker();</script>
';
$quantcast = '<!-- Quantcast -->
<script type="text/javascript" src="http://edge.quantserve.com/quant.js"></script>
<script type="text/javascript">_qacct="p-0dzSWakPjpGqM";quantserve();</script>
<noscript><img src="http://pixel.quantserve.com/pixel/p-0dzSWakPjpGqM.gif" style="display: none" height="1" width="1" alt="Quantcast"/></noscript>
';
$mybloglog = '<!-- MyBlogLog -->
<script type="text/javascript" src="http://track.mybloglog.com/js/jsserv.php?mblID=2007020306380804"></script>
';
$pages = array(); // Add pages (relative to the public site root) that should be ignored
$ip = array(); // Add IP addresses that should be ignored, for instance you don't want to track yourself or your company's visit to your blog.
if (
strpos($page,'frameset') !== false ||
(!empty($ip) && in_array($_SERVER['REMOTE_ADDR'], $ip)) ||
(!empty($pages) && in_array((isset($_SERVER['PHP_SELF']) && !empty($_SERVER['PHP_SELF']))?$_SERVER['PHP_SELF']:$_SERVER['SCRIPT_NAME'], $pages))
)
{ return $page; }
$replace = array
(
'</head>',
'</HEAD>'
);
return str_replace($replace, "\n{$googleAnalytics}\n\n{$quantcast}\n\n{$mybloglog}\r</head>", $page);
}
ob_start("Config");
?>
Specifies the name of a file that is automatically parsed before the main file. The file is included as if it was called with the include() function, so include_path is used.
The special value none disables auto-prepending.
Specifies the name of a file that is automatically parsed after the main file. The file is included as if it was called with the include() function, so include_path is used.
The special value none disables auto-appending.
Note: If the script is terminated with exit(), auto-append will not occur.
« 27 Request Methods for Apache rewritecond htaccess
Penny Stocks »
Please consider donating to support active development of the free software and articles here.![]()
The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect. Tim Berners-Lee
No comments yet. Be the first!
It's very simple - you read the protocol and write the code. -Bill Joy
HTML | DCMI | GRDDL | XOXO | XDMP | XFN | DOM | XML | XHTML 1.1 Strict | CSS 2.1 | W3C | TLDP | WAI | DISA | ICSI | GIAC | SANS RR | GHOST | DEFCON | NIST | DHS CYBER | NIST | .:: Phrack Magazine ::.
↑ TOPExcept where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 License, just credit with a link.
This site is not supported or endorsed by The Apache Software Foundation (ASF). All software and documentation produced by The ASF is licensed. "Apache" is a trademark of The ASF. HTTPD based on NCSA HTTPd