DOCTYPE html -- To change this license header choose License Headers i

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<meta charset="windows-1251">
<title></title>
</head>
<body>
<?php
class DirectoryWork{
public $dir;
public function __construct($dir){
$this->dir = $dir;
}
public function GetFileList($filtr){
$fileList = array();
$fileList = glob($this->dir.$filtr);
return $fileList;
}
public function GetTextFileContent($file){
$userContent = array();
$handle = @fopen($file, "r");
$userContent[] = fgets($handle);
return $userContent;
}
}
class Person{
private $email;
private $name;
private $date;
private $site;
public function __construct($email, $name, $date, $site){
$this->email = $email;
$this->name = $name;
$this->date = $date;
$this->site = $site;
}
public function GetNormalMail(){
return $this->email;
}
public function GetNormalName(){
return $this->name;
}
public function GetNormalDate(){
return $this->date;
}
public function GetNormalSite(){
return $this->site;
}
public function GetMail(){
$newMail = $this->ConversEmail();
return $newMail;
}
public function GetName(){
return $this->name;
}
public function GetDate(){
$newDate = $this->ConversDate();
return $newDate;
}
public function GetSite(){
$newSite = $this->ConversSite();
return $newSite;
}
private function ConversEmail()
{
if (substr($this->email, 0, 4) == "www.")
return "<a href=\"mailto:".substr($this->email, 4)."\">Отправить e-mail ".$this->name."</a>";
else if (substr($this->email, 0, 11) == "http://www.")
return "<a href=\"mailto:".substr($this->email, 11)."\">Отправить e-mail ".$this->name."</a>";
else if (substr($this->email, 0, 7) == "http://")
return "<a href=\"mailto:".substr($this->email, 7)."\">Отправить e-mail ".$this->name."</a>";
else
return "<a href=\"mailto:".$this->email."\">Отправить e-mail ".$this->name."</a>";
}
private function ConversDate(){
return date("F j, Y", $this->date);
}
private function ConversSite(){
if (substr($this->site, 0, 4) == "www.")
return "<a href=\"http://".$this->site."\"></a>";
else if (substr($this->site, 0, 11) == "http://www.")
return "<a href=\"http://www.".substr($this->site, 11)."\"></a>";
else if (substr($this->site, 0, 7) == "http://")
return "<a href=\"http://www.".substr($this->site, 7)."\"></a>";
else
return "<a href=\"http://www.".$this->site."\"></a>";
}
public function &GetPersonData(){
$user = array();
$user['mail'] = $this->email;
$user['FIO'] = $this->name;
$user['date'] = $this->date;
$user['site'] = $this->site;
return $user;
}
}
class DataBase{
private static $number = 1;
private $link;
public function __construct($nameDataBase, $host, $admin, $password){
$this->link = mysql_connect("$host", "$admin", "$password");
mysql_select_db($nameDataBase);
}
public function INSERT_ONE_PERSON($person){
$number2 = self::$number;
$mail = $person->GetMail();
$res = mysql_query("INSERT INTO `persons`(`id`, `mail`, `FIO`, `date`, `site`) VALUES ($number2,
$mail, $person->GetFIO(), $person->GetDate(), $person->GetSite())");
self::$number++;
}
public function INSERT_PERSONS($persons){
foreach($persons as $key->$value){
$person = $persons[$key];
INSERT_ONE_PERSON($person);
}
}
}
$db = new DataBase('newdatabase', 'localhost', 'root', '');
$person = new person("wew@mail.ru", "WE", "29.12.1995", "fghrr.com");
$db->INSERT_ONE_PERSON($person);
$res = mysql_query("SELECT * FROM `persons` WHERE `id` = 1");
while($row = mysql_fetch_assoc($res))
var_dump($row);
?>
</body>
</html>