Forum Moderators: coopster
<?php
$string = "This is a strpos() test";
$pos = strpos($string, "This");
if ($pos === false) {
print "Not found\n";
} else {
print "Found!\n";
}
?>
if(file_exists("yourfile.php")){
$YourString = file_get_contents("yourfile.php");
$pos = strpos($YourString, "This");
if($pos === false){
//redirect as instance not found
header("location: sorry.html");//<--use the header function to redirect
exit;//<--use the exit to kill the script, good practise after a header() call
}
else{
echo "Woo! We matched the value we wanted!\n\r";
exit;//<--stops repetition of html sometimes, though completely optional
}
}
else{
echo "Sorry, no file found..";
exit;
}
if(file_exists("http://localhost/test/wp-content/themes/resep/footer.php")){
$YourString = file_get_contents("http://localhost/test/wp-content/themes/resep/footer.php");
$pos = strpos($YourString, "teststring");
if ($pos === false) {
header("location: http://localhost/test/sorry.html");
} else {
print "Found!\n";
}
} <div class="clear"></div>
</div>
</div>
<?php include (TEMPLATEPATH . '/bottom.php'); ?>
<div id="footer">
<div class="fleft">
Design: <a href="http://mmohut.com/">MMORPG</a> <br/>
Copyright © <?php echo date('Y');?> <?php bloginfo('name');?><br/>
</div>
<div class="fright">
<a href="<?php bloginfo('rss2_url'); ?>">Subscribe to Posts</a> <br/> <a href="<?php bloginfo('comments_rss2_url'); ?>">Subscribe to Comments</a>
</div>
<div class="clear"></div>
</div>
teststring
</body>
</html>
Warning: file_get_contents(footer.php) [function.file-get-contents]: failed to open stream: No such file or directory in C:\xampp\htdocs\test\wp-content\themes\resep\header.php on line 45 <div class="clear"></div>
</div>
</div>
<?php include (TEMPLATEPATH . '/bottom.php'); ?>
<div id="footer">
<div class="fleft">
Design: <a href="http://mmohut.com/">MMORPG</a> <br/>
Copyright © <?php echo date('Y');?> <?php bloginfo('name');?><br/>
<?php $foot = get_option('rsp_foot'); echo stripslashes($foot); ?>
</div>
<div class="fright">
<a href="http://mmohut.com/social-games">Facebook Games</a> | <a href="http://www.hostv.com/">VPS Hosting</a> | <a href="http://www.cirtexhosting.com/">Website hosting</a> <br/>
<a href="<?php bloginfo('rss2_url'); ?>">Subscribe to Posts</a> <br/> <a href="<?php bloginfo('comments_rss2_url'); ?>">Subscribe to Comments</a>
</div>
<div class="clear"></div>
</div>
<?php wp_footer(); ?>
</body>
</html> [edited by: Jim123 at 11:02 pm (utc) on Oct 19, 2010]
<?php define('SECURITY', 1); ?>
<?php
if (defined('SECURITY')) {
}
else { ?>
<meta http-equiv="refresh" content="0;URL=http://www.google.com" />
<?php } ?> <?php define('SECURITY', 1); ?> and the other code in a file that loads before the footer.php? <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>. Can be done differently.