XOOPS  2.6.0
misc.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
13 
24 include __DIR__ . DIRECTORY_SEPARATOR . 'mainfile.php';
25 
27 $xoops->logger()->quiet();
28 
31 
32 $action = Request::getCmd('action', '');
33 $type = Request::getCmd('type', '');
34 
35 if ($action == "showpopups") {
36  $xoops->simpleHeader(false);
37 
38  // show javascript close button?
39  $closebutton = 1;
40  switch ($type) {
41  case "friend":
42  $op = Request::getCmd('op', 'sendform');
43  $tpl = new XoopsTpl();
44  if (!$xoops->security()->check() || $op == "sendform") {
45  if ($xoops->isUser()) {
46  $yname = $xoops->user->getVar("uname", 'e');
47  $ymail = $xoops->user->getVar("email", 'e');
48  $fname = "";
49  $fmail = "";
50  } else {
51  $yname = "";
52  $ymail = "";
53  $fname = "";
54  $fmail = "";
55  }
56  $form = new Xoops\Form\ThemeForm(XoopsLocale::RECOMMEND_SITE_TO_FRIEND, 'form_id', 'misc.php', 'post', true);
57  $form->addElement(new Xoops\Form\Text(XoopsLocale::C_YOUR_NAME, 'yname', 6, 255, $yname), true);
58  $form->addElement(new Xoops\Form\Text(XoopsLocale::C_YOUR_EMAIL, 'ymail', 6, 255, $ymail), true);
59  $form->addElement(new Xoops\Form\Text(XoopsLocale::C_FRIEND_NAME, 'fname', 6, 255, $fname), true);
60  $form->addElement(new Xoops\Form\Text(XoopsLocale::C_FRIEND_EMAIL, 'fmail', 6, 255, $fmail), true);
61  $form->addElement(new Xoops\Form\Hidden('action', 'showpopups'));
62  $form->addElement(new Xoops\Form\Hidden('type', 'friend'));
63 
65  $button_tray->addElement(new Xoops\Form\Hidden('op', 'sendsite'));
66 
67  $button = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SEND, 'submit');
68  $button->setClass('btn btn-success');
69  $button_tray->addElement($button);
70 
71  $button_2 = new Xoops\Form\Button('', 'close', XoopsLocale::A_CLOSE, 'close');
72  $button_2->setClass('btn btn-warning');
73  $button_2->setExtra("onclick='javascript:window.close();'");
74  $button_tray->addElement($button_2);
75 
76  $form->addElement($button_tray);
77 
78  $tpl->assign('closebutton', 0);
79  $tpl->assign('form', $form->render());
80  } elseif ($op == "sendsite") {
81  $myts = MyTextsanitizer::getInstance();
82  if ($xoops->isUser()) {
83  $ymail = $xoops->user->getVar("email");
84  } else {
85  $ymail = isset($_POST['ymail']) ? $myts->stripSlashesGPC(trim($_POST['ymail'])) : '';
86  }
87  if (!isset($_POST['yname']) || trim($_POST['yname']) == "" || $ymail == ''
88  || !isset($_POST['fname']) || trim($_POST['fname']) == "" || !isset($_POST['fmail'])
89  || trim($_POST['fmail']) == '') {
90  $xoops->redirect($xoops_url . "/misc.php?action=showpopups&amp;type=friend&amp;op=sendform", 2, XoopsLocale::E_YOU_NEED_TO_ENTER_REQUIRED_INFO);
91  exit();
92  }
93  $yname = $myts->stripSlashesGPC(trim($_POST['yname']));
94  $fname = $myts->stripSlashesGPC(trim($_POST['fname']));
95  $fmail = $myts->stripSlashesGPC(trim($_POST['fmail']));
96  if (!$xoops->checkEmail($fmail) || !$xoops->checkEmail($ymail) || preg_match("/[\\0-\\31]/", $yname)) {
98  $xoops->redirect($xoops_url . "/misc.php?action=showpopups&amp;type=friend&amp;op=sendform", 2, $errormessage);
99  }
100  $xoopsMailer = $xoops->getMailer();
101  $xoopsMailer->setTemplate("tellfriend.tpl");
102  $xoopsMailer->assign("SITENAME", $xoops->getConfig('sitename'));
103  $xoopsMailer->assign("ADMINMAIL", $xoops->getConfig('adminmail'));
104  $xoopsMailer->assign("SITEURL", $xoops_url . "/");
105  $xoopsMailer->assign("YOUR_NAME", $yname);
106  $xoopsMailer->assign("FRIEND_NAME", $fname);
107  $xoopsMailer->setToEmails($fmail);
108  $xoopsMailer->setFromEmail($ymail);
109  $xoopsMailer->setFromName($yname);
110  $xoopsMailer->setSubject(sprintf(XoopsLocale::F_INTERESTING_SITE, $xoops->getConfig('sitename')));
111 
112  $tpl->assign('closebutton', 1);
113  if (!$xoopsMailer->send()) {
114  $tpl->assign('message', $xoopsMailer->getErrors());
115  } else {
116  $tpl->assign('message', XoopsLocale::S_REFERENCE_TO_SITE_SENT);
117  }
118  }
119  $tpl->display('module:system/system_misc_friend.tpl');
120  break;
121  case 'online':
122  $isadmin = $xoops->userIsAdmin;
123  $start = Request::getInt('start', 0);
124  $online_handler = $xoops->getHandlerOnline();
125  $online_total = $online_handler->getCount();
126  $limit = ($online_total > 20) ? 20 : $online_total;
127  $criteria = new CriteriaCompo();
128  $criteria->setLimit($limit);
129  $criteria->setStart($start);
130  $onlines = $online_handler->getAll($criteria, null, false, false);
131  $count = count($onlines);
132  $module_handler = $xoops->getHandlerModule();
133  $modules = $module_handler->getNameList(new Criteria('isactive', 1));
134  $onlineUsers = array();
135  for ($i = 0; $i < $count; ++$i) {
136  $onlineUsers[$i]['uid'] = $onlines[$i]['online_uid'];
137  $onlineUsers[$i]['ip'] = $onlines[$i]['online_ip'];
138  $onlineUsers[$i]['updated'] = $onlines[$i]['online_updated'];
139  $onlineUsers[$i]['module'] = ($onlines[$i]['online_module'] > 0) ? $modules[$onlines[$i]['online_module']] : '';
140  if ($onlines[$i]['online_uid'] != 0 && is_object($user = new XoopsUser($onlines[$i]['online_uid']))) {
141  $onlineUsers[$i]['name'] = $user->getVar('uname');
142  $response = $xoops->service("Avatar")->getAvatarUrl($user);
143  $avatar = $response->getValue();
144  $avatar = empty($avatar) ? $xoops_upload_url . '/blank.gif' : $avatar;
145  $onlineUsers[$i]['avatar'] = $avatar;
146  } else {
147  $onlineUsers[$i]['name'] = $xoops->getConfig('anonymous');
148  $onlineUsers[$i]['avatar'] = $xoops_upload_url . '/blank.gif';
149  }
150  }
151 
152  $tpl = new XoopsTpl();
153  if ($online_total > 20) {
154  $nav = new XoopsPageNav($online_total, 20, $start, 'start', 'action=showpopups&amp;type=online');
155  $tpl->assign('nav', $nav->renderNav());
156  }
157  $tpl->assign('onlineusers', $onlineUsers);
158  $tpl->assign('isadmin', $isadmin);
159  $tpl->assign('closebutton', $closebutton);
160  $tpl->display('module:system/system_misc_online.tpl');
161  break;
162  case 'ssllogin':
163  if ($xoops->getConfig('use_ssl') && isset($_POST[$xoops->getConfig('sslpost_name')]) && $xoops->isUser()) {
164  $xoops->loadLanguage('user');
165  echo sprintf(XoopsLocale::E_INCORRECT_LOGIN, $xoops->user->getVar('uname'));
166  echo '<div style="text-align:center;"><input class="formButton" value="' . XoopsLocale::A_CLOSE . '" type="button" onclick="window.opener.location.reload();window.close();" /></div>';
167  $closebutton = false;
168  }
169  break;
170  default:
171  break;
172  }
173  $xoops->simpleFooter();
174 }
$tpl
Definition: backend.php:39
const E_INCORRECT_LOGIN
Definition: en_US.php:332
const A_SEND
Definition: en_US.php:126
$i
Definition: dialog.php:68
const C_YOUR_NAME
Definition: en_US.php:199
$xoops
Definition: misc.php:26
const S_REFERENCE_TO_SITE_SENT
Definition: en_US.php:1030
static getInstance()
Definition: Xoops.php:160
const F_INTERESTING_SITE
Definition: en_US.php:416
const C_YOUR_EMAIL
Definition: en_US.php:198
const C_FRIEND_NAME
Definition: en_US.php:182
$xoops_url
Definition: misc.php:29
$user
Definition: checklogin.php:47
$action
Definition: misc.php:32
const E_YOU_NEED_TO_ENTER_REQUIRED_INFO
Definition: en_US.php:386
const EMAIL_PROVIDED_IS_INVALID
Definition: en_US.php:282
$form
Definition: xoops_code.php:21
exit
Definition: browse.php:104
$xoops_upload_url
Definition: misc.php:30
defined('DS') or define('DS' DIRECTORY_SEPARATOR
Definition: common.php:41
$button
Definition: xoops_code.php:29
const A_CLOSE
Definition: en_US.php:87
const C_FRIEND_EMAIL
Definition: en_US.php:181
static get($name)
$type
Definition: misc.php:33
$limit
Definition: findusers.php:202
$modules
Definition: userinfo.php:185
$button_tray
Definition: xoops_code.php:26
$avatar
Definition: userinfo.php:94
$criteria
$button_2
Definition: xoops_code.php:34
if($xoops->isUser()&&$isAdmin) $response
Definition: userinfo.php:83
$module_handler
Definition: main.php:55
const RECOMMEND_SITE_TO_FRIEND
Definition: en_US.php:945
$start
$myts
Definition: edituser.php:38
$op
const E_CHECK_EMAIL_AND_TRY_AGAIN
Definition: en_US.php:316