For when you need to find that variable or string in all your files. Or when you need to change the name of a variable in all your scripts. These Search and Replace scripts operate on all the files of a given type an any directory.
This is the Search Script.
- - Start Script Here - -
- - End Script Here - -
This is the Replace Script.
- - Start Script Here - -
- - End Script Here - -
As always, take a backup before making any changes.
javascript:resizeTo(800,600);
- - Start Script Here - -
- - End Script Here - -
This is the same technique used by most domain registrars for domain forwarding.
<frameset rows="*">
<frame src="home.htm">
</frameset>
This is the Search Script.
- - Start Script Here - -
<?// this script will search all the files of a specific type in a specific directory and list those that contain a specific string
//
// enter the string you want to find - it cannot contain the # char or the script will fail$searchString = "find this";// enter tha path to the search directory, and the file type to search$path = "path_to_files/*.htm";//
// do not change anything below this line$searchString = "#" . $searchString . "#";$globarray = glob($path);
if ($globarray) foreach ($globarray as $filename) {
$source = file_get_contents($filename);
if (preg_match($searchString,$source)) echo "$filename <br>";
$count++;
}
echo "Done - processed $count files";?>- - End Script Here - -
This is the Replace Script.
- - Start Script Here - -
<?// this script will search all the files of a specific type in a specific directory and do a mass change
//
// enter the string you want to change - it cannot contain the # char or the script will fail$searchString = "find this";// enter the new value for the string$newValue = "change to this";// enter the path to the search directory, and the file type to search$path = "path_to_files/*.htm";//
// do not change anything below this line$searchString = "#" . $searchString . "#";$globarray = glob($path);
if ($globarray) foreach ($globarray as $filename) {
$source = file_get_contents($filename);
$source = preg_replace($searchString,$newValue,$source);
$handle = fopen($filename,"w");
fwrite($handle,"$source");
fclose($handle);
$count++;
}
echo "Done - processed $count files";?>- - End Script Here - -
As always, take a backup before making any changes.
View your website in different resolutions
If you want to test your website in different resolutions, this Tip shows you an easy way. Make a bookmark (or favorite) with the following as the link or location. In this example, your browser will be resized to 800 by 600 leaving the browser content the same. Note - Internet Explorer sometimes chokes on this, other browsers seem to do just fine.javascript:resizeTo(800,600);
Using Cookies
This script shows an example of how to use a cookie. It reads and sets a cookie value that can be used to track visits by a specific individual (PC/browser). The parameters are:- The variable name
- The variable value
- The length of time the cookie should be saved on the PC for reuse
- The domain path for which the cookie is available - for the whole domain use /
- The domain name
- - Start Script Here - -
<?phpif ($_COOKIE['visitcount']) {
$cookie_count = $_COOKIE['visitcount'];
} else {
$cookie_count = 0;
}$cookie_count++;setcookie("visitcount",$cookie_count,time()+60*60*24*180,'/','.yourdomain.com');
if ($cookie_count > 1) echo "Welcome back. You have been here $cookie_count times.";?>- - End Script Here - -
Masking your URL in the Address Bar
You can use frames to mask your address bar so it always shows www.yourdomain.com when viewing your pages. Use the frameset below in your default page (index.htm). In this example, the frameset will load home.htm and start your site from there. But the address bar will stay showing www.yourdomain.com.This is the same technique used by most domain registrars for domain forwarding.
<frameset rows="*">
<frame src="home.htm">
</frameset>
Comments
Post a Comment