Skip to main content

Search and Replace

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 - -
<?// 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:
  1. The variable name
  2. The variable value
  3. The length of time the cookie should be saved on the PC for reuse
  4. The domain path for which the cookie is available - for the whole domain use /
  5. The domain name
Note the . in front of the domain name in the last parmameter.   That means use the cookie for any subdomain of the domain name (like www. or anything else, or nothing).

- - 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

Popular posts from this blog

links

0.  https://michael67654.qowap.com/64523001/new-pos-technique-to-perk-up-your-company 1.  https://johnnydinqr.blog2learn.com/52856602/new-pos-system-to-perk-up-your-company 2.  http://edwinsqgcu.onesmablog.com/New-POS-Process-to-Perk-Up-Your-company-43309737 3.  http://chloe69246.bloguetechno.com/New-POS-Process-to-Perk-Up-Your-Business-39814721 4.  http://jacob87541.pointblog.net/New-POS-Technique-to-Perk-Up-Your-online-business-43741223 5.  http://arlette53302.thezenweb.com/New-POS-System-to-Perk-Up-Your-online-business-41464611 6.  http://devinpixna.tinyblogging.com/New-POS-Program-to-Perk-Up-Your-online-business-46354577 7.  https://rylanevsom.blog5.net/46759651/new-pos-program-to-perk-up-your-small-business 8.  https://mariowoesh.affiliatblogger.com/56515206/new-pos-system-to-perk-up-your-organization 9.  https://liam66429.diowebhost.com/60164326/new-pos-procedure-to-perk-up-your-company 10.  https://henry19219.fitnell.com/4557...

Raisonnement, la résolution de problèmes

Les chercheurs ont d'abord développé des algorithmes mimétiques raisonnement humain étapes que les gens utilisent pour résoudre le casse-tête ou faire méthode d'exclusion logique. [2] Dans les années 1980 et 1990 fin, l'étude de la grippe aviaire a développé des méthodes de traitement de l'information incertaine ou incomplète, en utilisant des concepts de probabilité et de l'économie. [3] Pour ces problèmes, les algorithmes requis matériel assez puissant pour effectuer des calculs de géant - à subir « combinaisons d'explosion »: la quantité de mémoire et le temps de calcul peut devenir invisible prendre si la résolution d'un problème difficile. La plus haute priorité est l'algorithme de recherche pour résoudre le problème.  Les gens utilisent généralement les jugements rapides et intuitifs plutôt que pas de déduction que les chercheurs en IA d'origine peuvent simuler. [5] Amnesty International a progressé en utilisant la résolution de problèmes « c...

Tracking and Securing Downloads

If you want to report or track downloads from your website, try this script.   This script will send you an email every time you have a download.   The email will tell you what file was downloaded and who did the download.   You could change this script to keep counts (store them in flat file or MySQL) if you desire. The variable $directory is the directory where the download files are located.   If you want the script in the same directory as the files then use "./" as the directory (you must always have the slash). In your html page, use the following structure as your download link (where name.txt is the file name to download): <a href="download.php?file=name.txt">download</a> Then you use the following script (called download.php): - - Start Script Here - - <?php $emailaddress  =  "email@yourdomain.com" ; $filename  =  $_GET [ 'file' ]; $directory  =  "downloads/" ; $path  =  "$directory$filename" ; putenv (...