page with hit counter

Post on 05-Jan-2016

30 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

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

TRANSCRIPT

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= "HitCounter.txt"; $filePointer = fopen($filename, "r") or

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

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

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

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

Permissions seen in WinSCP

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.

WinSCP Right Click/Properties

Can change permissions here, but group is grayed out

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

PuTTY Interface

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

Use chgrp command to change the file’s group

Alternate way to change permissions

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

top related