| 1 | <?php |
|---|
| 2 | // $Id: pmlite.php,v 1.4 2005/08/03 12:39:11 onokazu Exp $ |
|---|
| 3 | // ------------------------------------------------------------------------ // |
|---|
| 4 | // XOOPS - PHP Content Management System // |
|---|
| 5 | // Copyright (c) 2000 XOOPS.org // |
|---|
| 6 | // <http://www.xoops.org/> // |
|---|
| 7 | // ------------------------------------------------------------------------ // |
|---|
| 8 | // This program is free software; you can redistribute it and/or modify // |
|---|
| 9 | // it under the terms of the GNU General Public License as published by // |
|---|
| 10 | // the Free Software Foundation; either version 2 of the License, or // |
|---|
| 11 | // (at your option) any later version. // |
|---|
| 12 | // // |
|---|
| 13 | // You may not change or alter any portion of this comment or credits // |
|---|
| 14 | // of supporting developers from this source code or any supporting // |
|---|
| 15 | // source code which is considered copyrighted (c) material of the // |
|---|
| 16 | // original comment or credit authors. // |
|---|
| 17 | // // |
|---|
| 18 | // This program is distributed in the hope that it will be useful, // |
|---|
| 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|---|
| 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|---|
| 21 | // GNU General Public License for more details. // |
|---|
| 22 | // // |
|---|
| 23 | // You should have received a copy of the GNU General Public License // |
|---|
| 24 | // along with this program; if not, write to the Free Software // |
|---|
| 25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|---|
| 26 | // ------------------------------------------------------------------------ // |
|---|
| 27 | |
|---|
| 28 | $xoopsOption['pagetype'] = "pmsg"; |
|---|
| 29 | |
|---|
| 30 | include "mainfile.php"; |
|---|
| 31 | $reply = !empty($_GET['reply']) ? 1 : 0; |
|---|
| 32 | $send = !empty($_GET['send']) ? 1 : 0; |
|---|
| 33 | $send2 = !empty($_GET['send2']) ? 1 : 0; |
|---|
| 34 | $to_userid = !empty($_GET['to_userid']) ? intval($_GET['to_userid']) : 0; |
|---|
| 35 | $msg_id = !empty($_GET['msg_id']) ? intval($_GET['msg_id']) : 0; |
|---|
| 36 | if ( empty($_GET['refresh'] ) && isset($_POST['op']) && $_POST['op'] != "submit" ) { |
|---|
| 37 | $jump = "pmlite.php?refresh=".time().""; |
|---|
| 38 | if ( $send == 1 ) { |
|---|
| 39 | $jump .= "&send=".$send.""; |
|---|
| 40 | } elseif ( $send2 == 1 ) { |
|---|
| 41 | $jump .= "&send2=".$send2."&to_userid=".$to_userid.""; |
|---|
| 42 | } elseif ( $reply == 1 ) { |
|---|
| 43 | $jump .= "&reply=".$reply."&msg_id=".$msg_id.""; |
|---|
| 44 | } else { |
|---|
| 45 | } |
|---|
| 46 | echo "<html><head><meta http-equiv='Refresh' content='0; url=".$jump."' /></head><body></body></html>"; |
|---|
| 47 | exit(); |
|---|
| 48 | } |
|---|
| 49 | xoops_header(); |
|---|
| 50 | if ($xoopsUser) { |
|---|
| 51 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 52 | if (isset($_POST['op']) && $_POST['op'] == "submit" && XoopsMultiTokenHandler::quickValidate('pm')) { |
|---|
| 53 | $res = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("users")." WHERE uid=".intval($_POST['to_userid']).""); |
|---|
| 54 | list($count) = $xoopsDB->fetchRow($res); |
|---|
| 55 | if ($count != 1) { |
|---|
| 56 | echo "<br /><br /><div><h4>"._PM_USERNOEXIST."<br />"; |
|---|
| 57 | echo _PM_PLZTRYAGAIN."</h4><br />"; |
|---|
| 58 | echo "[ <a href='javascript:history.go(-1)'>"._PM_GOBACK."</a> ]</div>"; |
|---|
| 59 | } else { |
|---|
| 60 | $pm_handler =& xoops_gethandler('privmessage'); |
|---|
| 61 | $pm =& $pm_handler->create(); |
|---|
| 62 | $pm->setVar("subject", $_POST['subject']); |
|---|
| 63 | $pm->setVar("msg_text", $_POST['message']); |
|---|
| 64 | $pm->setVar("to_userid", $_POST['to_userid']); |
|---|
| 65 | $pm->setVar("from_userid", $xoopsUser->getVar("uid")); |
|---|
| 66 | if (!$pm_handler->insert($pm)) { |
|---|
| 67 | echo $pm->getHtmlErrors(); |
|---|
| 68 | echo "<br /><a href='javascript:history.go(-1)'>"._PM_GOBACK."</a>"; |
|---|
| 69 | } else { |
|---|
| 70 | echo "<br /><br /><div style='text-align:center;'><h4>"._PM_MESSAGEPOSTED."</h4><br /><a href=\"javascript:window.opener.location='".XOOPS_URL."/viewpmsg.php';window.close();\">"._PM_CLICKHERE."</a><br /><br /><a href=\"javascript:window.close();\">"._PM_ORCLOSEWINDOW."</a></div>"; |
|---|
| 71 | } |
|---|
| 72 | } |
|---|
| 73 | } elseif ($reply == 1 || $send == 1 || $send2 == 1) { |
|---|
| 74 | $token=&XoopsMultiTokenHandler::quickCreate('pm'); |
|---|
| 75 | |
|---|
| 76 | include_once XOOPS_ROOT_PATH."/include/xoopscodes.php"; |
|---|
| 77 | if ($reply == 1) { |
|---|
| 78 | $pm_handler =& xoops_gethandler('privmessage'); |
|---|
| 79 | $pm =& $pm_handler->get($msg_id); |
|---|
| 80 | if ($pm->getVar("to_userid") == $xoopsUser->getVar('uid')) { |
|---|
| 81 | $pm_uname = XoopsUser::getUnameFromId($pm->getVar("from_userid")); |
|---|
| 82 | $message = "[quote]\n"; |
|---|
| 83 | $message .= sprintf(_PM_USERWROTE,$pm_uname); |
|---|
| 84 | $message .= "\n".$pm->getVar("msg_text", "E")."\n[/quote]"; |
|---|
| 85 | } else { |
|---|
| 86 | unset($pm); |
|---|
| 87 | $reply = $send2 = 0; |
|---|
| 88 | } |
|---|
| 89 | } |
|---|
| 90 | echo "<form action='pmlite.php' method='post' name='coolsus'>\n"; |
|---|
| 91 | echo $token->getHtml(); |
|---|
| 92 | echo "<table width='300' align='center' class='outer'><tr><td class='head' width='25%'>"._PM_TO."</td>"; |
|---|
| 93 | if ( $reply == 1 ) { |
|---|
| 94 | echo "<td class='even'><input type='hidden' name='to_userid' value='".$pm->getVar("from_userid")."' />".$pm_uname."</td>"; |
|---|
| 95 | } elseif ( $send2 == 1 ) { |
|---|
| 96 | $to_username = XoopsUser::getUnameFromId($to_userid); |
|---|
| 97 | echo "<td class='even'><input type='hidden' name='to_userid' value='".$to_userid."' />".$to_username."</td>"; |
|---|
| 98 | } else { |
|---|
| 99 | echo "<td class='even'><select name='to_userid'>"; |
|---|
| 100 | $result = $xoopsDB->query("SELECT uid, uname FROM ".$xoopsDB->prefix("users")." WHERE level > 0 ORDER BY uname"); |
|---|
| 101 | while ( list($ftouid, $ftouname) = $xoopsDB->fetchRow($result) ) { |
|---|
| 102 | echo "<option value='".$ftouid."'>".$myts->makeTboxData4Show($ftouname)."</option>"; |
|---|
| 103 | } |
|---|
| 104 | echo "</select></td>"; |
|---|
| 105 | } |
|---|
| 106 | echo "</tr>"; |
|---|
| 107 | echo "<tr><td class='head' width='25%'>"._PM_SUBJECTC."</td>"; |
|---|
| 108 | if ( $reply == 1 ) { |
|---|
| 109 | $subject = $pm->getVar('subject', 'E'); |
|---|
| 110 | if (!preg_match("/^Re:/i",$subject)) { |
|---|
| 111 | $subject = 'Re: '.$subject; |
|---|
| 112 | } |
|---|
| 113 | echo "<td class='even'><input type='text' name='subject' value='".$subject."' size='30' maxlength='100' /></td>"; |
|---|
| 114 | } else { |
|---|
| 115 | echo "<td class='even'><input type='text' name='subject' size='30' maxlength='100' /></td>"; |
|---|
| 116 | } |
|---|
| 117 | echo "</tr>"; |
|---|
| 118 | echo "<tr valign='top'><td class='head' width='25%'>"._PM_MESSAGEC."</td>"; |
|---|
| 119 | echo "<td class='even'>"; |
|---|
| 120 | xoopsCodeTarea("message",37,8); |
|---|
| 121 | xoopsSmilies("message"); |
|---|
| 122 | echo "</td>"; |
|---|
| 123 | echo "</tr>"; |
|---|
| 124 | echo "<tr><td class='head'> </td><td class='even'> |
|---|
| 125 | <input type='hidden' name='op' value='submit' /> |
|---|
| 126 | <input type='submit' class='formButton' name='submit' value='"._PM_SUBMIT."' /> |
|---|
| 127 | <input type='reset' class='formButton' value='"._PM_CLEAR."' /> |
|---|
| 128 | <input type='button' class='formButton' name='cancel' value='"._PM_CANCELSEND."' onclick='javascript:window.close();' /> |
|---|
| 129 | </td></tr></table>\n"; |
|---|
| 130 | echo "</form>\n"; |
|---|
| 131 | } |
|---|
| 132 | } else { |
|---|
| 133 | echo _PM_SORRY."<br /><br /><a href='".XOOPS_URL."/register.php'>"._PM_REGISTERNOW."</a>."; |
|---|
| 134 | } |
|---|
| 135 | |
|---|
| 136 | xoops_footer(); |
|---|
| 137 | |
|---|
| 138 | ?> |
|---|