Файл: _core/_class/send.php
Строк: 67
<?php
# mark core v1.0
# author Drk in
# date 24.10.19
# class send
class send {
public static function mail($user,$mess) # mail send system
{
# mess
$mess_cut = system::num($mess,33);
# contact
$contact_user = DB :: $dbh -> queryFetch("SELECT id FROM mail_con WHERE user = ? AND data = ?;", array(0,$user));
$contact_data = DB :: $dbh -> queryFetch("SELECT id FROM mail_con WHERE user = ? AND data = ?;", array($user,0));
# contact user
if (empty($contact_user)):
DB :: $dbh -> query("INSERT INTO mail_con SET user = ?,data = ?",array(0,$user));
$my_contact = DB :: $dbh -> lastInsertId();
else:
$my_contact = $contact_user['id'];
endif;
# contact date
if (empty($contact_data)):
DB :: $dbh -> query("INSERT INTO mail_con SET user = ?, data = ?",array($user,0));
$data_contact = DB :: $dbh -> lastInsertId();
else:
$data_contact = $contact_data['id'];
endif;
# update
DB :: $dbh -> query("UPDATE mail_con SET cn = cn + 1, time = ?, mess = ? WHERE id = ?",array(time(),$mess_cut,$my_contact));
cache_mail_con::save($my_contact);
DB :: $dbh -> query("UPDATE mail_con SET cn = cn + 1, cn_new = cn_new + 1, time = ?, mess = ? WHERE id = ?",array(time(),$mess_cut,$data_contact));
cache_mail_con::save($data_contact);
# send message
DB :: $dbh -> query("INSERT INTO mail (user,data,mess,time,`read`) VALUES (?, ?, ?, ?, ?);",array(0,$user,$mess,time(),1));
$id_db = DB :: $dbh -> lastInsertId();
cache_mail::save($id_db);
# user
DB :: $dbh -> query("UPDATE user SET cn_mail = ? WHERE id = ?",array(1,$user));
cache_user::save($user);
}
public static function journal($user,$mess,$price,$sn = 0) # journal send
{
DB :: $dbh -> query("INSERT INTO journal (user,mess,price,time,sn) VALUES (?, ?, ?, ?, ?);",array($user,$mess,$price,time(),$sn));
$id = DB :: $dbh -> lastInsertId();
cache_journal::save($id);
}
public static function admin_log($user,$mess,$type) # admin log send
{
DB :: $dbh -> query("INSERT INTO admin_log (user,mess,type,time) VALUES (?, ?, ?, ?);",array($user,$mess,$type,time()));
$id = DB :: $dbh -> lastInsertId();
cache_admin_log::save($id);
}
}
?>