How to forbid to the user to save a picture?

The politics of browsers is those, that to any user to give an easy approach as to a source code html pages and to pictures on pages. Usually all this is done{made} through the contextual menu. Means it is necessary to search for ways that users could not cause this menu.


With issue the opportunity to operate the menu has appeared. Now in a tag <IMG> it is possible to use event oncontextmenu which each time when the contextual menu is going to is processed to appear on a page. If to intercept this event and to return false the contextual menu will not appear. Therefore if to use



<img src = "images/picture.jpg" oncontextmenu = " return false ">


The user never will see that of the contextual menu for the given element of page.


Those who does not use Internet Explorer 5.0 can do this cunning with help Cascading Style Sheets (CSS):



<img src = "images/clear.gif" width=200 height=142

style = " background:url (images/picture.jpg) ">


Here the tag <IMG> for display of transparent picture GIF with the same sizes chtoi a real picture is used. And then, by means of style as a background the necessary image is established. The given reception works in Internet Explorer 4.0.


However, this shift will not work in the Navigator, and mentioned below will be:



<div style = " background:url (images/picture.jpg) no-repeat; width:200;

height:142 ">

<img src = "images/clear.gif" width=200 height=142>

</div>


This code actually makes too most - atop of a real picture the transparent image is located, and the picture is done{made} by a background of a tag <DIV>.


Also remember, that the user very much will want to receive a picture he can always see a source code of a page and calculate an exact way of a picture. So shipko be not under a delusion, the given shifts raschitany on inexperienced users:)




Bases OOP

Object-oriented programs are more simple and are transportable, it is easier to modify and accompany with them, than their "traditional" colleagues. Besides it is similar, the idea objective orientirovannosti at its{her} competent use allows the program to be even more protected from a various sort of mistakes, than it was conceived by the programmer at the moment of job above her. However it is given nothing by gift:

Ideas OOP are rather difficult for perception{recognition} " from zero ", therefore till now very much a plenty of programs (various systems Unix, Apache, Perl, and itself PHP) are still written on old kind "objective - nondirectional" Si.


PHP until recently provided only some support OOP. However, after output{exit} PHP5 support OOP in PHP became practically full.


Strategy OOP is the best way for describing as displacement of priorities during programming from functionality of the application to structures of the data. It allows the programmer to model real objects and situations in created applications. Technology OOP possesses three main advantages:


* She is simple for understanding: OOP allows to think categories of daily objects;

* Is raised{increased} it is reliable and simple for support - correct designing provides simplicity of expansion and updating of object-oriented programs. The modular structure allows to make independent changes to different parts of the program, reducing to a minimum risk of mistakes of programming;

* Accelerates a cycle of development - modul`nost` here again plays the important role as various components of object-oriented programs can be used easily in other programs that reduces redundancy of a code and reduces risk of entering of mistakes at copying.


Specificity OOP appreciablly raises efficiency of work of programmers and allows them to create more powerful, scaled and effective applications.


Object-oriented programming is based on:


* Inkapsuljacii;

* Polymorphism;

* Inheritance.


Inkapsuljacija


Inkapsuljacija is the mechanism uniting the data and processing them a code as a unit.


Many advantages OOP are caused by one of his{its} fundamental principles - inkapsuljaciej. Inkapsuljaciej inclusion of various fine elements in larger object therefore the programmer works directly with this object is called. It results in simplification of the program as minor details are excluded from it{her}.


Inkapsuljaciju it is possible to compare to job of the automobile from the point of view of the typical driver. Many drivers do not understand in detail the internal device of the machine, but thus operate her{it} how has been conceived. Let they do not know, how the engine is arranged, the brake or steering management, - exists the special interface which automates and simplifies these complex{difficult} operations. Said also concerns to inkapsuljacii and OOP - many details of " the internal device " disappear from the user that allows him to concentrate on the decision of specific targets. In OOP this opportunity is provided with classes, objects and various means of expression of hierarchical communications{connections} between them.


Polymorphism


Polymorphism allows to use the same names for similar, but technically different problems{tasks}. The main thing in polymorphism is that he allows to manipulate objects by creation of standard interfaces for similar actions. Polymorphism considerably facilitates a spelling of complex{difficult} programs.


Inheritance


Inheritance allows one object to get properties of other object, do not confuse to copying objects. At copying the exact copy of object is created, and at inheritance the exact copy is supplemented with unique properties which are characteristic only for derivative object.


Classes and objects in PHP


The class is a base concept of object-oriented programming (OOP). If to say easier the class is an original type of a variable.


The copy of a class is an object. The object is a data set (properties) and functions (methods) for their processing. The data and methods are called as members of a class. In general, object is all that supports inkapsuljaciju.


Inside object the data and a code (members of a class) can be either are open, or no. The open data and members of a class are accessible to other parts of the program which are not a part of object. And the closed data and members of a class are accessible only inside this object.


The description of classes in PHP begin a syntactic word class:


class Imja_klassa {

// The description of members of a class - the data and methods for their processing

}


For the announcement of object it is necessary to use the operator new:


Object = new Imja_klassa;


The data are described with the help of a syntactic word var. The method is described the same as also ordinary function. The method also can pass parameters.


Example of a class on PHP:



<? php

// We create new class Coor:

class Coor {

// Given (properties):

var $name;

var $addr;


// Methods:

function Name () {

echo " <h3> John </h3> ";

}


}


// We create object of class Coor:

$object = new Coor;

?>


Access to klasam and to objects in PHP


We have considered, how classes are described and objects are created. Now it is necessary for us to get access to members of a class, for this purpose in PHP the operator-> is intended. We shall result an example:



<? php

// We create new class Coor:

class Coor {

// Given (properties):

var $name;


// Methods:

function Getname () {

echo " <h3> John </h3> ";

}


}


// We create object of class Coor:

$object = new Coor;

// We get access to members of a class:

$object-> name = "Alex";

echo $object-> name;

// Deduces 'Alex'

// And now we shall get access to a method of a class (actually, to function inside a class):

$object-> Getname ();

// Deduces 'John' capital letters

?>


To get access to members of a class inside a class, it is necessary to use the index $this, kotory always concerns to the current object. Modified method Getname ():



function Getname () {

echo $this-> name;

}


In the same way, it is possible to write method Setname ():


function Setname ($name) {

$this-> name = $name;

}


Now for change of a name it is possible to use method Setname ():



$object-> Setname ("Peter");

$object-> Getname ();


Here full listing of a code:



<? php

// We create new class Coor:

class Coor {

// Given (properties):

var $name;


// Methods:

function Getname () {

echo $this-> name;

}


function Setname ($name) {

$this-> name = $name;

}


}


// We create object of class Coor:

$object = new Coor;

// Now for change of a name we use method Setname ():

$object-> Setname ("Nick");

// And for access, as before, Getname ():

$object-> Getname ();

// The script deduces 'Nick'

?>


The index $this can be used also for access to methods, and not just for a data access:



function Setname ($name) {

$this-> name = $name;

$this-> Getname ();

}


Initialization of objects


Sometimes there is a necessity to execute initialization of object - to appropriate{give} to his{its} properties initial values. We shall assume, classname Coor and he contains two svojstva:imja the person and city of his{its} residing. It is possible to write a method (function) which will carry out initialization of object, for example Init ():



<? php

// We create new class Coor:

class Coor {

// Given (properties):

var $name;

var $city;


// Inicializirujuhhij a method:

function Init ($name) {

$this-> name = $name;

$this-> city = "London";

}


}


// We create object of class Coor:

$object = new Coor;

// For initialization of object at once we cause a method:

$object-> Init ();

?>


The main thing to not forget to call function right after creations of object, or to call any method between creation (the operator new) object and his{its} initialization (call Init).


That PHP knew, that the certain method needs to be caused automatically at creation of object, he needs to give a name same, as well as at a class (Coor):



function Coor ($name)

$this-> name = $name;

$this-> city = "London";

}


The method, inicializirujuhhij object, is called as the designer. However, PHP has no destruktorov as resources I am released{exempted} automatically at end of job of scripts.


Inheritance and polymorphism of classes in PHP


Inheritance of classes in PHP


Inheritance is not simply creation of an exact copy of a class, and expansion of already existing class that the descendant could carry out any new, characteristic only to him functions. We shall consider a concrete example on PHP:



<? php

class Parent {

function parent_funct () {echo " <h1> It is parental function </h1> ";}

function test () {echo " <h1> It is a parental class </h1> ";}

}


class Child extends Parent {

function child_funct () {echo " <h2> It is affiliated function </h2> ";}

function test () {echo " <h2> It is an affiliated class </h2> ";}

}


$object = new Parent;

$object = new Child;


$object-> parent_funct (); // Deduces ' It is parental function '

$object-> child_funct (); // Deduces ' It is affiliated function '

$object-> test (); // Deduces ' It is an affiliated class '

?>


The keyword extends (see) speaks an example that affiliated class Child inherits all methods and properties of class Parent. A parental class usually name a base class or a super class, and affiliated class Child - a derivative or a subclass.


Polymorphism of classes in PHP


Polymorphism are properties of a base class to use functions of derivative classes. The practical example showing property of a class - polymorphism:



<? php

class Base {

function funct () {

echo " <h2> Function of a base class </h2> ";

}

function base_funct () {

$this-> funct ();

}

}


class Derivative extends Base {

function funct () {

echo " <h3> Function of a derivative class </h3> ";

}

}


$b = new Base ();

$d = new Derivative ();


$b-> base_funct ();

$d-> funct ();

$d-> base_funct ();

// The script deduces:


// Function of a base class

// Function of a derivative class

// Function of a derivative class

?>


In the considered example function base_funct () class Base has been rewritten by the same function of class Derivative. The function redefined thus, is called virtual.