Размер файла: 11.04Kb
<? /* ============================================= Движок: SHCMS Engine ============================================= Название файла: Почта ============================================= Official website: http://shcms.ru ============================================= */ define ( 'SHCMS' , true ); include_once '../system/inc/basic_settings.php' ; if ( $_GET [ 'id' ]){ $id = $_GET [ 'id' ];} $users_mail = mysql_fetch_array ( mysql_query ( "SELECT * FROM `users` WHERE `id` = '$id'" )); registrat (); if ( $user_id == $users_mail [ 'id' ]) { $shcmsengine [ 'title' ] = 'Вы не можете писать себе' ; include_once '../template/head.php' ; errors ( "Вы не можете писать себе" ); header ( "Refresh: 1; url=?act=mail" ); include_once '../template/foot.php' ; exit ; } switch ( $act ): case '' : $shcmsengine [ 'title' ] = 'Почта' ; include_once '../template/head.php' ; $allmail = mysql_result ( mysql_query ( "SELECT COUNT(DISTINCT(`posted`)) FROM `mails` WHERE `user_id` = '$user_id'" ), 0 ); $newmail = new Navigation ( $allmail , 10 , true ); $mail = mysql_query ( "SELECT DISTINCT(`posted`) FROM `mails` WHERE `user_id` = '$user_id' ORDER BY `id` DESC " . $newmail -> limit (). "" ); echo '<div class="maintitle mainrazd">Все ваши контакты</div><div class="maintext">' ; if (! mysql_num_rows ( $mail )) { echo '<div class="posts">У вас нет контактов</div>' ; } else { while ( $mails = mysql_fetch_array ( $mail )) { $profile_users = mysql_fetch_array ( mysql_query ( "SELECT * FROM `users` WHERE `id` = " . $mails [ 'posted' ]. " LIMIT 1" )); echo '<div class="posts"> ' ; if ( $profile_users [ 'pol' ] == 1 ){ echo ' <img src="/template/icon/users/1.png"/>' ; } else { echo ' <img src="/template/icon/users/2.png"/>' ; } echo ' <a href="' . DIR_SHCMS . 'change_view.php?id=' . $profile_users [ 'id' ]. '">' . $profile_users [ 'login' ]. '</a>' ; echo '<span class="maintime"><a href="mails.php?act=message&id=' . $mails [ 'posted' ]. '">Написать</a></span>' ; echo '</div>' ; } echo '<div class="pages">' ; echo $newmail -> pagination (); echo '</div>' ; } echo '</div>' ; $mail_proch = mysql_result ( mysql_query ( "SELECT COUNT(*) FROM `mails` WHERE `user_id` = '$user_id' AND `read` = 'yes'" ), 0 ); $mail_noproch = mysql_result ( mysql_query ( "SELECT COUNT(*) FROM `mails` WHERE `user_id` = '$user_id' AND `read` = 'no'" ), 0 ); $mail_read = mysql_result ( mysql_query ( "SELECT COUNT(*) FROM `mails` WHERE `posted` = '$user_id'" ), 0 ); echo '<div class="maintitle mainrazd">Действие</div><div class="maintext">' ; echo '<div class="posts"><img src="../template/icon/mail/pr.png"> <a href="?act=written">Прочитанные письма</a> (' . $mail_proch . ')</div>' ; echo '<div class="posts"><img src="../template/icon/mail/ne.png"> <a href="?act=mail">Непрочитанные письма</a> (' . $mail_noproch . ')</div>' ; echo '<div class="posts"><img src="../template/icon/mail/ot.png"> <a href="?act=read">Отправленные письма</a> (' . $mail_read . ')</div>' ; echo '</div>' ; break ; case 'message' : $shcmsengine [ 'title' ] = 'Переписка с ' . $users_mail [ 'login' ]. '' ; include_once '../template/head.php' ; if ( $_POST [ 'submit' ]) { $submit = $_POST [ 'submit' ]; } if ( isset ( $submit )) { if ( $_POST [ 'text' ]) { $text = $_POST [ 'text' ]; } if ( empty ( $text )) { errors ( 'Введите пожалуйста текст сообщения' ); include_once '../template/foot.php' ; exit ; } if ( strlen ( $text ) < 4 or strlen ( $text ) > 10000 ) { errors ( 'Сообщение должно быть не меньше 4 и не больше 10000' ); include_once '../template/foot.php' ; exit ; } if ( $settings_shcms [ 'antimat' ] == true ) { $text = $system_function -> antimat ( $text ); } $message = mysql_query ( "INSERT INTO `mails` (`user_id`,`read`,`text`,`posted`,`time`) VALUES ('" . $users_mail [ 'id' ]. "','no','$text','$user_id','" . time (). "')" ); if ( $message == true ) { messag ( "Сообщение успешно отправлено" ); header ( "Refresh: 1; url=?act=message&id=$id" ); include_once '../template/foot.php' ; exit ; } else { errors ( "Возникла ошибка при отправки письма" ); header ( "Refresh: 1; url=?" ); include_once '../template/foot.php' ; exit ; } } echo '<div class="maintext">' ; $form = new form ( "?act=message&id=$id" ); $form -> textarea ( '<strong>Текст сообщения:</strong>' , 'text' , '' , true ); $form -> submit ( 'Отправить' , 'submit' ); $form -> submit ( 'Обновить' , 'resfresh' ); $form -> finish (); echo '</div>' ; $allfield = mysql_result ( mysql_query ( "SELECT COUNT(*) FROM `mails` WHERE ((`mails`.`user_id`='$id' AND `mails`.`posted`='$user_id') OR (`mails`.`user_id`='$user_id' AND `mails`.`posted`='$id'))" ), 0 ); $newlist = new Navigation ( $allfield , 10 , true ); $mails = mysql_query ( "SELECT * FROM `mails` WHERE ((`mails`.`user_id`='$id' AND `mails`.`posted`='$user_id') OR (`mails`.`user_id`='$user_id' AND `mails`.`posted`='$id')) ORDER BY `id` DESC " . $newlist -> limit (). "" ); while ( $mail = mysql_fetch_array ( $mails )) { if ( $user_id == $mail [ 'user_id' ]) { mysql_query ( "UPDATE `mails` SET `read` = 'yes' WHERE `posted` = '$id'" ); } $mysql_users = mysql_fetch_array ( mysql_query ( "SELECT * FROM `users` WHERE `id` = '$mail[user_id]'" )); echo '<div class="maintitle">' ; if ( $mail [ 'read' ] == 'no' ) { users_profile ( $mail [ 'user_id' ]); echo '<font color="red"> <small>Не прочитано</small></font>' ; } else { users_profile ( $mail [ 'user_id' ]); } echo '<span class="mainforum">' . $timedate -> times ( $mail [ 'time' ]). '</span></div><div class="maintext">' ; echo processing ( $mail [ 'text' ]) ; echo '<div class="mainforum"><a href="?act=delete&id_mail=' . $mail [ 'id' ]. '&id=' . $id . '"><img src="../template/icon/delete.png"></a></div>' ; echo '</div>' ; } echo '<div class="pages">' ; echo $newlist -> pagination ( 'act=message&id=' . $id . '' ); echo '</div>' ; break ; case 'delete' : $shcmsengine [ 'title' ] = 'Удаление сообщений' ; include_once '../template/head.php' ; if ( $_GET [ 'id_mail' ]){ $id_mail = $_GET [ 'id_mail' ];} if ( $id == false ) { errors ( 'Выбранный вами пост не существует' ); header ( "Refresh: 1; url=?act=message&id=$id" ); include_once '../template/foot.php' ; } $delete_mail = mysql_query ( "DELETE FROM `mails` WHERE `id` = '$id_mail'" ); if ( $delete_mail == true ) { messag ( 'Пост успешно удален' ); header ( "Refresh: 1; url=?act=message&id=$id" ); include_once '../template/foot.php' ; } else { errors ( 'Пост не удален' ); header ( "Refresh: 1; url=?act=message&id=$id" ); include_once '../template/foot.php' ; } break ; case 'mail' : $countmail = mysql_result ( mysql_query ( "SELECT COUNT(*) FROM `mails` WHERE `user_id` = '" . $user_id . "' AND `read` = 'no'" ), 0 ); if ( $countmail == NULL ){ $shcmsengine [ 'title' ] = 'Новых сообщений нет' ; } else { $shcmsengine [ 'title' ] = 'Новых сообщений (' . $countmail . ')' ; } include_once '../template/head.php' ; $allfield = mysql_result ( mysql_query ( "SELECT COUNT(*) FROM `mails` WHERE `user_id` = '" . $user_id . "' AND `read` = 'no'" ), 0 ); $newlist = new Navigation ( $allfield , 10 , true ); $mail = mysql_query ( "SELECT DISTINCT(`posted`) FROM `mails` WHERE `user_id` = '$user_id' AND `read` = 'no' ORDER BY `id` DESC " . $newlist -> limit (). "" ); $mails = mysql_fetch_array ( $mail ); if ( $mails == NULL ) { echo '<div class="posts"> ' ; echo SHCMS_core :: img_shcms ( '../template/icon/empty.png' ). 'Новых сообщений у вас нет!</div>' ; } else { do { $mail_users = mysql_fetch_array ( mysql_query ( "SELECT * FROM `users` WHERE `id` = '$mails[posted]'" )); echo '<div class="mysql_no"> <a href="?act=message&id=' . $mails [ 'posted' ]. '">' . $mail_users [ 'login' ]. '</a> (' . mysql_result ( mysql_query ( "SELECT COUNT(*) FROM `mails` WHERE `user_id` = '$user_id' AND `read` = 'no' AND `posted` = '$mails[posted]'" ), 0 ). ')</div>' ; } while ( $mails = mysql_fetch_array ( $mail )); echo '<div class="pages">' ; echo $newlist -> pagination ( 'act=mail' ); echo '</div>' ; } break ; /* case'prosm': $mail = mysql_fetch_array(mysql_query("SELECT * FROM `mails` WHERE `id` = '$id'")); $user_mail = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '$mail[posted]'")); $shcmsengine['title'] = 'Переписка с пользователем '.$user_mail['login'].''; include_once'../template/head.php'; if($user_id == $mail['user_id']) { mysql_query("UPDATE `mails` SET `read` = 'yes' WHERE `id` = '$id'"); } echo '<div class="posts"><strong>Написал: </strong>'; echo ''.users_list($mail['posted']).'<br/>'; echo '<strong>Отправлено: </strong>'.$timedate->times($mail['time']).'<br/>'; echo '<strong>Ответить: </strong><a href="'.DIR_SHCMS.'mails.php?act=message&id='.$mail['posted'].'">Написать письмо</a>'; echo '</div><div class="posts">'; echo processing($mail['text']).'</div>'; */ break ; case 'written' : $shcmsengine [ 'title' ] = 'Прочитанные письма' ; include_once '../template/head.php' ; $mail = mysql_query ( "SELECT * FROM `mails` WHERE `user_id` = '$user_id' AND `read` = 'yes'" ); while ( $mails = mysql_fetch_array ( $mail )) { $mail_users = mysql_fetch_array ( mysql_query ( "SELECT * FROM `users` WHERE `id` = '$mails[posted]'" )); echo '<div class="mysql_yes"><a href="?act=prosm&id=' . $mails [ 'id' ]. '">' . $mail_users [ 'login' ]. '</a> <div class="maintime">' . $timedate -> times ( $mails [ 'time' ]). '</div></div>' ; } break ; case 'read' : $shcmsengine [ 'title' ] = 'Отправленные письма' ; include_once '../template/head.php' ; $mail = mysql_query ( "SELECT * FROM `mails` WHERE `posted` = '$user_id' ORDER BY `id` DESC" ); while ( $mails = mysql_fetch_array ( $mail )) { $mail_users = mysql_fetch_array ( mysql_query ( "SELECT * FROM `users` WHERE `id` = '$mails[user_id]'" )); echo '<div class="mysql_yes"><a href="?act=prosm&id=' . $mails [ 'id' ]. '">' . $mail_users [ 'login' ]. '</a> <div class="maintime">' . $timedate -> times ( $mails [ 'time' ]). '</div></div>' ; } break ; endswitch ; include_once '../template/foot.php' ; ?>