Page with Hit Counter

15
Page with Hit Counter

description

Page with Hit Counter. PHP Page with Counter. Read file with count print out count.

Transcript of Page with Hit Counter

Page 1: Page with Hit Counter

Page with Hit Counter

Page 2: Page with Hit Counter

PHP Page with Counter

Page 3: Page with Hit Counter

Read file with count print out count

<?php /* open file for reading, read and print count */ $filename= "HitCounter.txt"; $filePointer = fopen($filename, "r") or

die("Problem opening $filename"); $theCount = fread($filePointer,

filesize($filename)); print ($theCount+1); fclose($filePointer);

Page 4: Page with Hit Counter

Write file with new count /* open file for writing, write new count the file must have the appropriate permissions

especially to be written to */ $filePointer = fopen($filename , "w") or die("Problem

opening $filename"); $theCount = $theCount + 1; $fout= fwrite($filePointer, $theCount); fclose($filePointer); ?>

Page 5: Page with Hit Counter

Permissions

• In order for the file to be able to be written to, we must change its permissions.

• You can view the permissions in WinSCP. • In Linux there are three basic kinds of

permission and three basic actors to whom permission may be given.

• The permissions are Read, Write and Execute• The actors are: You (the Owner), Group, World

Page 6: Page with Hit Counter

Permissions seen in WinSCP

Page 7: Page with Hit Counter

Limiting Access

• In order to limit access to the file, but still allow its effect, we are going to place the file into the group for web things, and then give that group write permissions.

• The permissions can be changed using WinSCP by right clicking on the remote file and choosing properties.

• But to change the group, we use another Putty.

Page 8: Page with Hit Counter

WinSCP Right Click/Properties

Page 9: Page with Hit Counter

Can change permissions here, but group is grayed out

Page 10: Page with Hit Counter

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Page 11: Page with Hit Counter

PuTTY Interface

Page 12: Page with Hit Counter

Enter username and password (not echoed). Then use cd (change directory command to get to folder

Page 13: Page with Hit Counter

Use chgrp command to change the file’s group

Page 14: Page with Hit Counter

Alternate way to change permissions

Page 15: Page with Hit Counter

Chmod 764 filename

• The first number gives permissions to Owner, the second to Group and the third to World.

• The permission come in the order Read, Write, eXecute.

• So 764 gives – 7 111 Read, Write, and Execute to Owner– 6 110 Read, Write to Group– 4 100 Read to World