class Message private Id private Exists private To private From public

 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
class Message
{
private $Id;
private $Exists;
private $To;
private $From;
public $Title;
public $Date;
public $Text;
function __construct($To, $From, $Title, $Text)
{
$this->Exists = FALSE;
$this->To = $To;
$this->From = $From;
$this->Title = $Title;
$this->Text = $Text;
}
function Exists()
{
return $this->Exists;
}
function Send()
{
global $Language;
global $DatabaseConnection;
if(Database::GetCount('id', 'messages', array(array('to' => array('=', $this->To, null)))) < 30)
{
$Date = time();
if($DatabaseConnection->Query("INSERT INTO messages(`id`,`to`,`from`,`title`,`date`,`text`,`new`) VALUES(NULL, '".$this->To."', '".$this->From."', '".$this->Title."', '".$Date."', '".$this->Text."', 1)"))
{
$this->Id = $DatabaseConnection->lastInsertId('id');
$this->Exists = TRUE;
$this->Date = $Date;
}
} else {
echo "<hr><b>$Language[123]</b><hr>";
return FALSE;
}
}
}