XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
pmlite.php
Go to the documentation of this file.
1 <?php
19 include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mainfile.php';
21 $xoopsPreload->triggerEvent('core.pmlite.start');
22 
23 xoops_loadLanguage('pmsg');
24 
25 
26 //------------------------------ mamba
27 include $GLOBALS['xoops']->path('class/xoopsformloader.php');
28 $icon='';
30 $subject_icons = XoopsLists::getSubjectsList();
31 //------------------------------- mamba
32 
33 $reply = !empty($_GET['reply']) ? 1 : 0;
34 $send = !empty($_GET['send']) ? 1 : 0;
35 $send2 = !empty($_GET['send2']) ? 1 : 0;
36 $to_userid = !empty($_GET['to_userid']) ? intval($_GET['to_userid']) : 0;
37 $msg_id = !empty($_GET['msg_id']) ? intval($_GET['msg_id']) : 0;
38 if (empty($_GET['refresh']) && isset($_POST['op']) && $_POST['op'] != "submit") {
39  $jump = "pmlite.php?refresh=" . time() . "";
40  if ($send == 1) {
41  $jump .= "&amp;send=" . $send . "";
42  } else if ($send2 == 1) {
43  $jump .= "&amp;send2=" . $send2 . "&amp;to_userid=" . $to_userid . "";
44  } else if ($reply == 1) {
45  $jump .= "&amp;reply=" . $reply . "&amp;msg_id=" . $msg_id . "";
46  } else {
47  }
48  echo "<html><head><meta http-equiv='Refresh' content='0; url=" . $jump . "' /></head><body></body></html>";
49  exit();
50 }
51 
52 xoops_header();
53 if (is_object($xoopsUser)) {
55  if (isset($_POST['op']) && $_POST['op'] == "submit") {
56  if (!$GLOBALS['xoopsSecurity']->check()) {
57  $security_error = true;
58  }
59  $res = $xoopsDB->query("SELECT COUNT(*) FROM " . $xoopsDB->prefix("users") . " WHERE uid=" . intval($_POST['to_userid']) . "");
60  list ($count) = $xoopsDB->fetchRow($res);
61  if ($count != 1) {
62  echo "<br /><br /><div><h4>" . _PM_USERNOEXIST . "<br />";
63  echo _PM_PLZTRYAGAIN . "</h4><br />";
64  if (isset($security_error) && $security_error == true) {
65  echo implode('<br />', $GLOBALS['xoopsSecurity']->getErrors());
66  }
67  echo "[ <a href='javascript:history.go(-1)' title=''>" . _PM_GOBACK . "</a> ]</div>";
68  } else {
69  $pm_handler =& xoops_gethandler('privmessage');
70  $pm =& $pm_handler->create();
71 //------------------ mamba
72 if (isset($_POST['icon'])) {
73  $pm->setVar("msg_image", $_POST['icon']);
74  }
75 //----------------- mamba
76  $pm->setVar("subject", $_POST['subject']);
77  $pm->setVar("msg_text", $_POST['message']);
78  $pm->setVar("to_userid", $_POST['to_userid']);
79  $pm->setVar("from_userid", $xoopsUser->getVar("uid"));
80  if (!$pm_handler->insert($pm)) {
81  echo $pm->getHtmlErrors();
82  echo "<br /><a href='javascript:history.go(-1)' title=''>" . _PM_GOBACK . "</a>";
83  } else {
84  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();\" title=\"\">" . _PM_CLICKHERE . "</a><br /><br /><a href=\"javascript:window.close();\" title=\"\">" . _PM_ORCLOSEWINDOW . "</a></div>";
85  }
86  }
87  } else if ($reply == 1 || $send == 1 || $send2 == 1) {
88  include_once $GLOBALS['xoops']->path('include/xoopscodes.php');
89  if ($reply == 1) {
90  $pm_handler =& xoops_gethandler('privmessage');
91  $pm =& $pm_handler->get($msg_id);
92  if ($pm->getVar("to_userid") == $xoopsUser->getVar('uid')) {
93  $pm_uname = XoopsUser::getUnameFromId($pm->getVar("from_userid"));
94  $message = "[quote]\n";
95  $message .= sprintf(_PM_USERWROTE, $pm_uname);
96  $message .= "\n" . $pm->getVar("msg_text", "E") . "\n[/quote]";
97  } else {
98  unset($pm);
99  $reply = $send2 = 0;
100  }
101  }
102  echo "<form action='pmlite.php' method='post' name='coolsus'>\n";
103  echo "<table style=' text-align:left;' class='outer'><tr><td class='head txtright' style='width:25%'>" . _PM_TO . "</td>";
104  if ($reply == 1) {
105  echo "<td class='even'><input type='hidden' name='to_userid' value='" . $pm->getVar("from_userid") . "' />" . $pm_uname . "</td>";
106  } else if ($send2 == 1) {
107  $to_username = XoopsUser::getUnameFromId($to_userid);
108  echo "<td class='even'><input type='hidden' name='to_userid' value='" . $to_userid . "' />" . $to_username . "</td>";
109  } else {
110  require_once $GLOBALS['xoops']->path('class/xoopsform/formelement.php');
111  require_once $GLOBALS['xoops']->path('class/xoopsform/formselect.php');
112  require_once $GLOBALS['xoops']->path('class/xoopsform/formlabel.php');
113  require_once $GLOBALS['xoops']->path('class/xoopsform/formselectuser.php');
114  $user_sel = new XoopsFormSelectUser("", "to_userid");
115  echo "<td class='even'>" . $user_sel->render();
116  echo "</td>";
117  }
118  echo "</tr>";
119  echo "<tr><td class='head txtright' style='width:25%;'>" . _PM_SUBJECTC . "</td>";
120  if ($reply == 1) {
121  $subject = $pm->getVar('subject', 'E');
122  //TODO Fix harcoded string
123  if (!preg_match("/^" . _RE . "/i", $subject)) {
124  $subject = _RE . ' ' . $subject;
125  }
126  echo "<td class='even'><input type='text' name='subject' value='" . $subject . "' size='30' maxlength='100' /></td>";
127  } else {
128  echo "<td class='even'><input type='text' name='subject' size='30' maxlength='100' /></td>";
129  }
130  echo "</tr>";
131 
132 //----------------------------- mamba
133  echo "<tr>";
134  echo "<td class='head txtright' style='width:25%;'>" . _MESSAGEICON. "</td>";
135  foreach ($subject_icons as $iconfile) {
136  $icons_radio->addOption($iconfile, '<img src="' . XOOPS_URL . '/images/subject/' . $iconfile . '" alt="" />');
137  }
138  echo "<td class='even'>" . $icons_radio->render();
139  echo "</td>";
140  echo "</tr>";
141 //------------------------------- mamba
142 
143  echo "<tr style='vertical-align:top;'><td style='width:25%;' class='head txtright'>" . _PM_MESSAGEC . "</td>";
144  echo "<td class='even'>";
145  xoopsCodeTarea("message", 37, 8);
146  xoopsSmilies("message");
147 
148  echo "</td>";
149  echo "</tr>";
150  echo "<tr><td class='head'>&nbsp;</td><td class='even'>
151  <input type='hidden' name='op' value='submit' />" . $GLOBALS['xoopsSecurity']->getTokenHTML() . "
152  <input type='submit' class='formButton' name='submit' value='" . _PM_SUBMIT . "' />&nbsp;
153  <input type='reset' class='formButton' value='" . _PM_CLEAR . "' />
154  &nbsp;<input type='button' class='formButton' name='cancel' value='" . _PM_CANCELSEND . "' onclick='javascript:window.close();' />
155  </td></tr></table>\n";
156  echo "</form>\n";
157  }
158 } else {
159  echo _PM_SORRY . "<br /><br /><a href='" . XOOPS_URL . "/register.php' title=''>" . _PM_REGISTERNOW . "</a>.";
160 }
161 
162 xoops_footer();
163 
164 ?>