Presentation is loading. Please wait.

Presentation is loading. Please wait.

Page with Hit Counter. PHP Page with Counter Read file with count print out count <?php /* open file for reading, read and print count */ $filename=

Similar presentations


Presentation on theme: "Page with Hit Counter. PHP Page with Counter Read file with count print out count <?php /* open file for reading, read and print count */ $filename="— Presentation transcript:

1 Page with Hit Counter

2 PHP Page with Counter

3 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);

4 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); ?>

5 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

6 Permissions seen in WinSCP

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

8 WinSCP Right Click/Properties

9 Can change permissions here, but group is grayed out

10 http://www.chiark.greenend.org.uk/~sgtatham/putty/dow nload.html

11 PuTTY Interface

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

13 Use chgrp command to change the file’s group

14 Alternate way to change permissions

15 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


Download ppt "Page with Hit Counter. PHP Page with Counter Read file with count print out count <?php /* open file for reading, read and print count */ $filename="

Similar presentations


Ads by Google