What is Activity Tracking in Server?

1. generally there are two type of resources

1. serverfull

2. serveless

serverfull resources acquires complete tracking of user and they reponse 

over the server few or more resources cannot be shared in if resources is accessed from server protocol medium.

php

Tracking : Enable or disable

1 => Enabled  do not track : disabled 0

0 => Disabled do not track : enabled 1



Serverless Resources acquires InComplete Tracking of the user and they can response over the server without direct intervention of server.

They are not tracked by any server in this case In serverless resources 

can access any type of data from any source.

html

Tracking :disable

Explanation :

$_SERVER : Complete Array of Server Configuration and Setting

$_SERVER Stores the meta_data for the server configuration and its Environment,etc



How to check Tracking Enabled or disabled

$_SERVER['HTTP_DNT']

Any Request : HTTP/1.1 GET 200 OK

DNT : Response


How to Get Query String from Server

$_SERVER['QUERY_STRING']


How to get Remote Ip of Client?

$_SERVER['REMOTE_ADDR']


How to get Complete Url

$_SERVER['REQUEST_URI']


How to get Current File Name

$_SERVER['PHP_SELF']

$_SERVER['SCRIPT_NAME']


How to Server Request Method Type

$_SERVER['REQUEST_METHOD']


How to get Server Protocol

$_SERVER['SERVER_PROTOCOL']


How to get Server Host

$_SERVER['HTTP_HOST']


How to get Root of project

$_SERVER['DOCUMENT_ROOT']


How to get Port No

$_SERVER['SERVER_PORT']


Working with Session Super Global Varible.

$_SESSION: Is a super global varible which can be accessed 


$_FILES : This super global Variable is used to handle File uploading 

in Server

Files can be of Any Type

1. Binary 

2. Non Binary File


Example of Binary

Media Files mp3,mp4,pdf,zipped,or any other MIME Type

Example of Non Binary

All text format Files are Non Binary Files

.tmp

.log

.txt

.dat

.doc

.csv

.html Non Binary

.xml Non Binary


uploading Means :

Read from One source and write One Another Source

Read from One Destination and Write to Another Destination.


Copy and Move

Copy : first create the File

   Read the from 1 File

   write Another 2-File

   Memory Release of File Pointer

   

In C Langauge

File* fp1;

File* fp2;

fp1=&File;

fp2=&File;

fp1=fopen("c:/something.txt",r);

fp2=fopen("d:/something.txt",w);

while($ch=fread(fp1)!=EOL){

fwrite(fp2,$ch)

}

fclose(fp1);

fclose(fp2);


Move :

Copy : first create the File

   Read the from 1 File

   write Another 2-File

   Memory Release of File-2 Pointer

   fseek(-1)

   

Steps How to upload files on server

Internal Working:

When ever we try to upload any file the a upload request is generated and

file pointer is intialised

Who Intialised the File Pointer : 

Inbuilt Server is Responsible for Intialising the File Pointer

1. Apache 

2. PHP Cli Server


By default file pointer has source Address of tmp folder location in server

folder of Any server

Apache : tmp Root

php Inbuilt Server  : php tmp folder


What is this tmp folder

it is default folder where every file handling is performed by server

like storing file based session by file name sess_....

2. using any file with .tmp extension


such path is defined inside php.ini file

Now the file which is to be uploaded from browser required key parameters

1. file_uploads=on in ini setting of server

2. Path should be available to tmp folder

   upload_tmp_dir=

 define the path 

 

Note : in ini files ; means disable to enable directive remove ;

in httpd.conf # means disabled to enable #remove hash



3. file uploading in browser is now ready 

steps for code

----------------

<form method="post" enctype="multipart/form-data">

<input type="file" name="xyz..">

<input type="submit">


Server Side Code

print_r($_FILES);

It is two dimensional

name key : name of file

tmp_name : file address of tmp folder

error : it show the error if happend during upload

size: it give the total memory reserved by tmp file

type : mime Type



Validating File Uploads

------------------------

Loop Hole : error is used to detect Error but this error is related to processing or Illegal Error But not valid or used defined error.

$filename = $_FILES['keyname']['name'];

$error = $_FILES['keyname']['error'];  #Processing Error