<!DOCTYPE html>
<?php
class FileHandling {
public static $dir;
public static function SetDir($d){
FileHandling::$dir = $d;
}
public static function GetFileList($filtr) {
$fileNamesArray = glob($filtr);
return $fileNamesArray;
}
public static function GetTextFileContent($file) {
$myfile = fopen($file, "r") or die ("Unable to open file!");
$resultArray;
$resultArray['mail'] = fgets($myfile);
$resultArray['FIO'] = fgets($myfile);
$resultArray['Date'] = strtotime(fgets($myfile));
$resultArray['Date'] = date("d-m-Y",$resultArray['Date']);
$resultArray['address'] = fgets($myfile);
fclose($myfile);
$resultArray['address'] = str_replace("http://", "", $resultArray['address']);
$resultArray['address'] = str_replace("www.", "", $resultArray['address']);
$resultArray['address'] = "http://www.".$resultArray['address'];
return $resultArray;
}
function __construct() {
}
}
class Person {
private $email;
private $name;
private $date;
private $site;
public function __construct($email, $name, $date, $site) {
$this->email = $email;
$this->date = $date;
$this->name = $name;
$this->site = $site;
}
public function GetName() {
return $this->name;
}
public function GetMail() {
return "<a href=\"mailto:".$this->email."\"".">Отправить e-mail ".$this->name."</a>";
}
public function GetDate() {
$temp = strtotime($this->date);
$temp = date("F d, Y", $temp);
return $temp;
}
public function GetSite() {
return "<a href=\"".$this->site."\"></a>";
}
public function &getPersonData() {
$personArray;
$personArray['FIO'] = $this->name;
$personArray['Site'] = $this->site;
$personArray['mail'] = $this->email;
$personArray['Date'] = $this->date;
return $personArray;
}
}
?>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
FileHandling::SetDir(__DIR__);
$listOfFiles = FileHandling::GetFileList("*.txt");
$file = FileHandling::GetTextFileContent($listOfFiles[0]);
$kurenkov = new Person("vladimir.kurenkov@gmail.com", "Vladimir Kurenkov",
"10.03.2001", "http://www.vk.com");
echo $kurenkov->GetMail()."<br>";
echo $kurenkov->GetName()."<br>";
echo $kurenkov->GetDate()."<br>";
echo $kurenkov->GetSite()."<br>"; //смотри код страницы(!)
$personData = $kurenkov->getPersonData();
echo "<table>";
foreach ($personData as $key => $value) {
echo "<tr><td>".$value."<td></tr>";
}
echo "</table>";
?>
</body>
</html>