XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
misc.php
Go to the documentation of this file.
1 <?php
19 include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mainfile.php';
20 
21 xoops_loadLanguage('misc');
22 
23 $action = isset($_GET['action']) ? strip_tags(trim($_GET['action'])) : '';
24 $action = isset($_POST['action']) ? strip_tags(trim($_POST['action'])) : $action;
25 $type = isset($_GET['type']) ? strip_tags(trim($_GET['type'])) : '';
26 $type = isset($_POST['type']) ? strip_tags(trim($_POST['type'])) : $type;
27 if ($action == "showpopups") {
28  xoops_header(false);
29  // show javascript close button?
30  $closebutton = 1;
31  switch ($type) {
32  case "smilies":
33  $target = isset($_GET['target']) ? trim($_GET['target']) : '';
34  if ($target == '' || !preg_match('/^[0-9a-z_]*$/i', $target)) {
35  } else {
36  echo "<script type=\"text/javascript\"><!--//
37  function doSmilie(addSmilie) {
38  var textareaDom = window.opener.xoopsGetElementById(\"" . $target . "\");
39  xoopsInsertText(textareaDom, addSmilie);
40  textareaDom.focus();
41  return;
42  }
43  //-->
44  </script>
45  ";
46  echo '</head><body>
47  <table width="100%" class="outer">
48  <tr><th colspan="3">' . _MSC_SMILIES . '</th></tr>
49  <tr class="head"><td>' . _MSC_CODE . '</td><td>' . _MSC_EMOTION . '</td><td>' . _IMAGE . '</td></tr>';
50  $myts =& MyTextsanitizer::getInstance();
51  if ($smiles = $myts->getSmileys()) {
52  $rcolor = 'even';
53  foreach ($smiles as $key => $smile) {
54  echo "<tr class='$rcolor'><td>" . $smile['code'] . "</td><td>" . $smile['emotion'] . "</td><td><img onmouseover='style.cursor=\"hand\"' onclick='doSmilie(\" " . $smile['code'] . " \");' src='" . XOOPS_UPLOAD_URL . "/" . $smile['smile_url'] . "' alt='' /></td></tr>";
55  $rcolor = ($rcolor == 'even') ? 'odd' : 'even';
56  }
57  } else {
58  echo "Could not retrieve data from the database.";
59  }
60  echo '</table>' . _MSC_CLICKASMILIE;
61  }
62  break;
63  case "avatars":
64  ?>
65 <script language='javascript'>
66  <!--//
67  function myimage_onclick(counter){
68  window.opener.xoopsGetElementById("user_avatar").options[counter].selected = true;
69  showAvatar();
70  window.opener.xoopsGetElementById("user_avatar").focus();
71  window.close();
72  }
73  function showAvatar() {
74  window.opener.xoopsGetElementById("avatar").src='<?php
75  echo XOOPS_UPLOAD_URL;
76  ?>/' + window.opener.xoopsGetElementById("user_avatar").options[window.opener.xoopsGetElementById("user_avatar").selectedIndex].value;
77  }
78  //-->
79  </script>
80 </head>
81 <body>
82 <h4><?php
83  echo _MSC_AVAVATARS;
84  ?></h4>
85 <form name='avatars'>
86 <table width='100%'>
87  <tr>
88  <?php
89  $avatar_handler =& xoops_gethandler('avatar');
90  $avatarslist = $avatar_handler->getList('S');
91  $cntavs = 0;
92  $counter = isset($_GET['start']) ? intval($_GET['start']) : 0;
93  foreach ($avatarslist as $file => $name) {
94  echo '<td><img src="uploads/' . $file . '" alt="' . $name . '" style="padding:10px; vertical-align:top;" /><br />' . $name . '<br /><input name="myimage" type="button" value="' . _SELECT . '" onclick="myimage_onclick(' . $counter . ')" /></td>';
95  $counter++;
96  $cntavs++;
97  if ($cntavs > 8) {
98  echo '</tr><tr>';
99  $cntavs = 0;
100  }
101  }
102  echo '</tr></table></form></div>';
103  break;
104  case "friend":
105  if (!$GLOBALS['xoopsSecurity']->check() || ! isset($_POST['op']) || $_POST['op'] == "sendform") {
106  if ($xoopsUser) {
107  $yname = $xoopsUser->getVar("uname", 'e');
108  $ymail = $xoopsUser->getVar("email", 'e');
109  $fname = "";
110  $fmail = "";
111  } else {
112  $yname = "";
113  $ymail = "";
114  $fname = "";
115  $fmail = "";
116  }
117  printCheckForm();
118  echo '</head><body>';
119  echo "<div class='errorMsg'>" . implode('<br />', $GLOBALS['xoopsSecurity']->getErrors()) . "</div>";
120  echo '
121  <form action="' . XOOPS_URL . '/misc.php" method="post" onsubmit="return checkForm();"><table width="100%" class="outer" cellspacing="1"><tr><th colspan="2">' . _MSC_RECOMMENDSITE . '</th></tr>';
122  echo "<tr><td class='head'>
123  <input type='hidden' name='op' value='sendsite' />
124  <input type='hidden' name='action' value='showpopups' />
125  <input type='hidden' name='type' value='friend' />\n";
126  echo _MSC_YOURNAMEC . "</td><td class='even'><input type='text' name='yname' value='{$yname}' id='yname' /></td></tr>
127  <tr><td class='head'>" . _MSC_YOUREMAILC . "</td><td class='odd'><input type='text' name='ymail' value='{$ymail}' id='ymail' /></td></tr>
128  <tr><td class='head'>" . _MSC_FRIENDNAMEC . "</td><td class='even'><input type='text' name='fname' value='{$fname}' id='fname' /></td></tr>
129  <tr><td class='head'>" . _MSC_FRIENDEMAILC . "</td><td class='odd'><input type='text' name='fmail' value='{$fmail}' id='fmail' /></td></tr>
130  <tr><td class='head'>&nbsp;</td><td class='even'><input type='submit' value='" . _SEND . "' />&nbsp;<input value='" . _CLOSE . "' type='button' onclick='javascript:window.close();' />" . $GLOBALS['xoopsSecurity']->getTokenHTML() . "</td></tr>
131  </table></form>\n";
132  $closebutton = 0;
133  } else if ($_POST['op'] == "sendsite") {
134  $myts =& MyTextsanitizer::getInstance();
135  if ($xoopsUser) {
136  $ymail = $xoopsUser->getVar("email");
137  } else {
138  $ymail = isset($_POST['ymail']) ? $myts->stripSlashesGPC(trim($_POST['ymail'])) : '';
139  }
140  if (!isset($_POST['yname']) || trim($_POST['yname']) == "" || $ymail == '' || !isset($_POST['fname']) || trim($_POST['fname']) == "" || !isset($_POST['fmail']) || trim($_POST['fmail']) == '') {
141  redirect_header(XOOPS_URL . "/misc.php?action=showpopups&amp;type=friend&amp;op=sendform", 2, _MSC_NEEDINFO);
142  exit();
143  }
144  $yname = $myts->stripSlashesGPC(trim($_POST['yname']));
145  $fname = $myts->stripSlashesGPC(trim($_POST['fname']));
146  $fmail = $myts->stripSlashesGPC(trim($_POST['fmail']));
147  if (!checkEmail($fmail) || !checkEmail($ymail) || preg_match("/[\\0-\\31]/", $yname)) {
148  $errormessage = _MSC_INVALIDEMAIL1 . "<br />" . _MSC_INVALIDEMAIL2 . "";
149  redirect_header(XOOPS_URL . "/misc.php?action=showpopups&amp;type=friend&amp;op=sendform", 2, $errormessage);
150  exit();
151  }
152  $xoopsMailer =& xoops_getMailer();
153  $xoopsMailer->setTemplate("tellfriend.tpl");
154  $xoopsMailer->assign("SITENAME", $xoopsConfig['sitename']);
155  $xoopsMailer->assign("ADMINMAIL", $xoopsConfig['adminmail']);
156  $xoopsMailer->assign("SITEURL", XOOPS_URL . "/");
157  $xoopsMailer->assign("YOUR_NAME", $yname);
158  $xoopsMailer->assign("FRIEND_NAME", $fname);
159  $xoopsMailer->setToEmails($fmail);
160  $xoopsMailer->setFromEmail($ymail);
161  $xoopsMailer->setFromName($yname);
162  $xoopsMailer->setSubject(sprintf(_MSC_INTSITE, $xoopsConfig['sitename']));
163  //OpenTable();
164  if (!$xoopsMailer->send()) {
165  echo $xoopsMailer->getErrors();
166  } else {
167  echo "<div><h4>" . _MSC_REFERENCESENT . "</h4></div>";
168  }
169  //CloseTable();
170  }
171  break;
172  case 'online':
174  echo '</head><body>';
175  echo '<table style="width:100%;" cellspacing="1" class="outer"><tr><th colspan="3">' . _WHOSONLINE . '</th></tr>';
176  $start = isset($_GET['start']) ? intval($_GET['start']) : 0;
177  $online_handler =& xoops_gethandler('online');
178  $online_total = $online_handler->getCount();
179  $limit = ($online_total > 20) ? 20 : $online_total;
180  $criteria = new CriteriaCompo();
181  $criteria->setLimit($limit);
182  $criteria->setStart($start);
183  $onlines = $online_handler->getAll($criteria);
184  $count = count($onlines);
185  $module_handler =& xoops_gethandler('module');
186  $modules = $module_handler->getList(new Criteria('isactive', 1));
187  for ($i = 0; $i < $count; $i++) {
188  if ($onlines[$i]['online_uid'] == 0) {
189  $onlineUsers[$i]['user'] = '';
190  } else {
191  $onlineUsers[$i]['user'] = new XoopsUser($onlines[$i]['online_uid']);
192  }
193  $onlineUsers[$i]['ip'] = $onlines[$i]['online_ip'];
194  $onlineUsers[$i]['updated'] = $onlines[$i]['online_updated'];
195  $onlineUsers[$i]['module'] = ($onlines[$i]['online_module'] > 0) ? $modules[$onlines[$i]['online_module']] : '';
196  }
197  $class = 'even';
198  for ($i = 0; $i < $count; $i++) {
199  $class = ($class == 'odd') ? 'even' : 'odd';
200  echo '<tr style="vertical-align:middle; text-align: center;" class="' . $class . '">';
201  if (is_object($onlineUsers[$i]['user'])) {
202  $avatar = $onlineUsers[$i]['user']->getVar('user_avatar') ? '<img src="' . XOOPS_UPLOAD_URL . '/' . $onlineUsers[$i]['user']->getVar('user_avatar') . '" alt="" />' : '&nbsp;';
203  echo '<td>' . $avatar . "</td><td><a href=\"javascript:window.opener.location='" . XOOPS_URL . "/userinfo.php?uid=" . $onlineUsers[$i]['user']->getVar('uid') . "';window.close();\">" . $onlineUsers[$i]['user']->getVar('uname') . "</a>";
204  } else {
205  echo '<td>&nbsp;</td><td>' . $xoopsConfig['anonymous'];
206  }
207  if ($isadmin == 1) {
208  echo '<br />(' . $onlineUsers[$i]['ip'] . ')';
209  }
210  echo '</td><td>' . $onlineUsers[$i]['module'] . '</td></tr>';
211  }
212  echo '</table><br />';
213  if ($online_total > 20) {
214  include_once $GLOBALS['xoops']->path('class/pagenav.php');
215  $nav = new XoopsPageNav($online_total, 20, $start, 'start', 'action=showpopups&amp;type=online');
216  echo '<div style="text-align: right;">' . $nav->renderNav() . '</div>';
217  }
218  break;
219  case 'ssllogin':
220  if ($xoopsConfig['use_ssl'] && isset($_POST[$xoopsConfig['sslpost_name']]) && is_object($xoopsUser)) {
221  include_once $GLOBALS['xoops']->path('language/' . $xoopsConfig['language'] . '/user.php');
222  echo sprintf(_US_LOGGINGU, $xoopsUser->getVar('uname'));
223  echo '<div style="text-align:center;"><input class="formButton" value="' . _CLOSE . '" type="button" onclick="window.opener.location.reload();window.close();" /></div>';
224  $closebutton = false;
225  }
226  break;
227  default:
228  break;
229  }
230  if ($closebutton) {
231  echo '<div style="text-align:center;"><input class="formButton" value="' . _CLOSE . '" type="button" onclick="javascript:window.close();" /></div>';
232  }
233  xoops_footer();
234 }
235 
236 function printCheckForm()
237 {
238  ?>
239  <script language='javascript' type="text/javascript">
240  <!--//
241  function checkForm()
242  {
243  if ( xoopsGetElementById("yname").value == "" ){
244  alert( "<?php
245  echo _MSC_ENTERYNAME;
246  ?>" );
247  xoopsGetElementById("yname").focus();
248  return false;
249  } else if ( xoopsGetElementById("fname").value == "" ){
250  alert( "<?php
251  echo _MSC_ENTERFNAME;
252  ?>" );
253  xoopsGetElementById("fname").focus();
254  return false;
255  } else if ( xoopsGetElementById("fmail").value ==""){
256  alert( "<?php
257  echo _MSC_ENTERFMAIL;
258  ?>" );
259  xoopsGetElementById("fmail").focus();
260  return false;
261  } else {
262  return true;
263  }
264  }
265  //-->
266  </script>
267  <?php
268 }
269 ?>