Skip to main content

Random/weighted banners, quotes & more

This script will display banners (with or without links), quotes, or anything else you want to randomly select with each individual page load.   The item will be randomly selected, but the frequency of selection can be weighted based on a value you specify.   For example, giving an item a weight of 2 will cause that item to be selected twice as often as an item with a weight of 1.   Use only integers 1 or greater for weight values.

You can specify the item as html code in the script, or have each item be stored in an external file (also as html code).   The switch at the top of the script makes the selection of in-script or external files.   The example below shows the in-script method.

- - Start Script Here - -
<?php
$externalFile 
"N";  // Y means the item array contains file names
// add to the weight and item arrays below
$weight[0] = 1$item[0] = "<a href='link0.htm'><img src='image0.gif'></a>";$weight[1] = 1$item[1] = "<a href='link1.htm'><img src='image1.gif'></a>";$weight[2] = 1$item[2] = "<a href='link2.htm'><img src='image2.gif'></a>";// end of arraysfor ( $a=0$a<count($weight); $a++ )
for ( 
$b=1$b<=$weight[$a]; $b++ ) $pick[] = $a;$selected $item[$pick[rand(0,count($pick)-1)]];
if (
$externalFile == "Y"$selected file_get_contents($selected);
echo 
$selected;?>

- - End Script Here - -

If you wish each item to be stored in an external file, then you set $externalFile = "Y"; and change the array values to file names as in the example below:
$weight[0] = 1; $item[0] = "file0.txt";

Visitor Counter
This simple script creates an image that can be used on any page to display a visitor counter.  A session variable is used to ensure that the counter only advances once per browser session (the most accurate way to count website visitors).  If you want to see how it works, the counter is shown here:

counter

In your html, put an <img> tag for the image, such as the one below. Do not put width or height parameters in the img tag as this will distort the generated image.

<img src="counter.php" alt="counter" style="border: inset 3px;">
Name the script below counter.php.

- - Start Script Here - -
<?php
$filename 
'counter.dat';session_start();
if (!isset(
$_SESSION['visitor_counter']) AND is_writable($filename)) {
  
$count file_get_contents($filename);
  if (
is_numeric($count)) {
    
$count++;
    
$handle fopen($filename,"w");
    
fwrite($handle,"$count");
    
fclose($handle);
    
$_SESSION['visitor_counter'] = $count;
  }
} else {
  
$count $_SESSION['visitor_counter'];
}
$width = (strlen($count)*8)+8;$im = @imagecreate($width18);$background_color imagecolorallocate($im,255,255,255);$text_color imagecolorallocate($im,0,0,0);imagestring($im,4,4,2,$count,$text_color);imagepng($im);imagedestroy($im);?>

- - End Script Here - -

The count value is stored in a file counter.dat.  Create a starter counter.dat file with notepad with a good starting value (say 50 - give yourself a few starter hits).  You can cheat any time just by changing the value in counter.dat with notepad.

Put your web page, counter.php and counter.dat in the same directory.



If you want an invisible counter (cannot be seen on the page), you can simply use the following <img> tag in the html page:

<img src="counter.php" width=1 height=1>



If you would like a comma in the number if the number is more than 3 digits, then add this line just before the $width calculation:

if (strlen($count)>3) $count = substr($count,0,strlen($count)-3) . "," . substr($count,strlen($count)-3,3);



If you are using a PHP page and want to include the counter in a text line rather than display it as an image, as is done at the bottom of this page, you can simply replace the bottom half of the script (everything after the if/else test) with this one line:

echo "You are visitor $count since January, 2004";



Note - If the user's browser is blocking cookies, then the counter will count each page hit rather than browser sessions.

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