readGood('.$id.',"https://img.new-combats.com/i/misc/read.gif"); nobtext('.$id.');'; } } } public function lockMsg($id,$uid) { $msg = mysql_fetch_array(mysql_query('SELECT * FROM `telegram` WHERE `id`="'.$id.'" AND `uid`="'.$uid.'" LIMIT 1 FOR UPDATE')); if(isset($msg['id'])) { $lock = array(0=>1,1=>0); mysql_query('START TRANSACTION'); $upd = mysql_query('UPDATE `telegram` SET `read`="1",`lock`="'.$lock[$msg['lock']].'" WHERE `id` = "'.$id.'" AND `uid`="'.$uid.'" LIMIT 1'); mysql_query('COMMIT'); if($upd) { if($lock[$msg['lock']]==1) { echo ''; }else{ echo ''; } } } } public function deleteMsgAll($uid,$pg) { mysql_query('START TRANSACTION'); $upd = mysql_query('UPDATE `telegram` SET `delete`="1" WHERE `uid`="'.$uid.'" AND `read`="1" AND `lock`="0" AND `delete`="0"'); mysql_query('COMMIT'); if($upd) { echo ''; } } public function deleteMsg($id,$uid,$pg) { $msg = mysql_fetch_array(mysql_query('SELECT * FROM `telegram` WHERE `id`="'.$id.'" AND `uid`="'.$uid.'" LIMIT 1 FOR UPDATE')); if(isset($msg['id'])) { mysql_query('START TRANSACTION'); $upd = mysql_query('UPDATE `telegram` SET `delete`="1" WHERE `id` = "'.$id.'" AND `uid`="'.$uid.'" LIMIT 1'); mysql_query('COMMIT'); if($upd && $msg['delete']==0 && $msg['lock']==0) { echo ''; } } } private function addMsgTable($id,$from,$fromType,$ttl,$time,$lock,$read,$pg) { $i1 = ''; if($read==1) { $i1 = ''; } if($lock==1) { $i1 = ''; } if($fromType==1) { $from = ''.$from.''; }elseif($read==0) { $from = ''.$from.''; } echo '
'.$i1.'
'.$from.' '.substr($ttl,0,30).'... '.date('d.m.y H:i',$time).'
'; } public function seeMsg($uid,$page,$maxPages) { $page = ceil($page); echo '
От кого Заголовок сообщения Когда
Блокировка сообщений
Удалить все прочитанные сообщения
'; $i = mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `telegram` WHERE `uid`="'.$uid.'" AND `delete`="0"')); $pg = ceil($i[0]/$maxPages); if($page<0) { $page = 0; }elseif($page>$pg) { $page = $pg; } if($i[0]>0) { $sp = mysql_query('SELECT * FROM `telegram` WHERE `uid`="'.$uid.'" AND `delete`="0" ORDER BY `id` DESC LIMIT '.(($page-1)*$maxPages).' , '.$maxPages.''); while($pl = mysql_fetch_array($sp)) { $this->addMsgTable($pl['id'],$pl['from'],$pl['fromType'],$pl['text'],$pl['time'],$pl['lock'],$pl['read'],$page); } } if($i[0]==0) { echo '
Сообщений нет
'; }elseif($i[0]>$maxPages){ $pages = ''; $i = 1; while($i<=$pg) { $cls = ''; if($page==$i) { $cls = 'style="color:#6f0000; font-size:14px;"'; } $pages .= ' '.$i.''; $i++; } echo '
Страницы: '.$pages.'
'; } } public function __clone() { trigger_error('Дублирование не допускается.', E_USER_ERROR); } } ?>