| 1: | <?php
|
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: |
|
| 17: |
|
| 18: | use Xmf\Request;
|
| 19: |
|
| 20: | include __DIR__ . '/mainfile.php';
|
| 21: |
|
| 22: | xoops_loadLanguage('misc');
|
| 23: | xoops_loadLanguage('user');
|
| 24: |
|
| 25: | $action = Request::getCmd('action', '');
|
| 26: | $type = Request::getCmd('type', '');
|
| 27: |
|
| 28: | if ($action !== 'showpopups') {
|
| 29: | header('HTTP/1.0 404 Not Found');
|
| 30: | exit();
|
| 31: | }
|
| 32: | xoops_header(false);
|
| 33: |
|
| 34: | $closebutton = 1;
|
| 35: | switch ($type) {
|
| 36: | case 'smilies':
|
| 37: | $target = Request::getString('target', '');
|
| 38: | if ($target !== '' && preg_match('/^[0-9a-z_]*$/i', $target)) {
|
| 39: | $variables = array();
|
| 40: | $javaScript = <<<EOSMJS
|
| 41: | <script type="text/javascript">
|
| 42: | function doSmilie(addSmilie) {
|
| 43: | var textareaDom = window.opener.xoopsGetElementById("{$target}");
|
| 44: | xoopsInsertText(textareaDom, addSmilie);
|
| 45: | textareaDom.focus();
|
| 46: | }
|
| 47: | </script>
|
| 48: | EOSMJS;
|
| 49: | $variables['headContents'] = $javaScript;
|
| 50: | $variables['closeHead'] = true;
|
| 51: | $variables['lang_smiles'] = _MSC_SMILIES;
|
| 52: | $variables['lang_code'] = _MSC_CODE;
|
| 53: | $variables['lang_emotion'] = _MSC_EMOTION;
|
| 54: | $variables['lang_image'] = _IMAGE;
|
| 55: | $variables['lang_clicksmile'] = _MSC_CLICKASMILIE;
|
| 56: | $variables['lang_close'] = _CLOSE;
|
| 57: | $variables['upload_url'] = XOOPS_UPLOAD_URL .'/';
|
| 58: | $myts = \MyTextSanitizer::getInstance();
|
| 59: | if ($smiles = $myts->getSmileys(false)) {
|
| 60: | $variables['smilies'] = $smiles;
|
| 61: | } else {
|
| 62: | $variables['smilies'] = array();
|
| 63: | trigger_error('Could not retrieve smilies from the database.', E_USER_NOTICE);
|
| 64: | }
|
| 65: | xoops_misc_popup_body('db:system_misc_smilies.tpl', $variables);
|
| 66: | }
|
| 67: | break;
|
| 68: | case 'avatars':
|
| 69: |
|
| 70: | $avatarHandler = xoops_getHandler('avatar');
|
| 71: | $avatarsList = $avatarHandler->getList('S', true);
|
| 72: |
|
| 73: | $upload_url = XOOPS_UPLOAD_URL . '/';
|
| 74: | $javaScript = <<<EOAVJS
|
| 75: | <script language='javascript'>
|
| 76: | function myimage_onclick(counter) {
|
| 77: | window.opener.xoopsGetElementById("user_avatar").options[counter].selected = true;
|
| 78: | showAvatar();
|
| 79: | window.opener.xoopsGetElementById("user_avatar").focus();
|
| 80: | window.close();
|
| 81: | }
|
| 82: | function showAvatar() {
|
| 83: | window.opener.xoopsGetElementById("avatar").src="{$upload_url}" + window.opener.xoopsGetElementById("user_avatar").options[window.opener.xoopsGetElementById("user_avatar").selectedIndex].value;
|
| 84: | }
|
| 85: | </script>
|
| 86: | EOAVJS;
|
| 87: | $variables['headContents'] = $javaScript;
|
| 88: | $variables['closeHead'] = true;
|
| 89: | $variables['lang_avavatars'] = _MSC_AVAVATARS;
|
| 90: | $variables['lang_select'] = _SELECT;
|
| 91: | $variables['lang_close'] = _CLOSE;
|
| 92: | $variables['avatars'] = $avatarsList;
|
| 93: | $variables['upload_url'] = $upload_url;
|
| 94: | xoops_misc_popup_body('db:system_misc_avatars.tpl', $variables);
|
| 95: | break;
|
| 96: | case 'friend':
|
| 97: | include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
|
| 98: |
|
| 99: | $variables['headContents'] = '';
|
| 100: | $variables['closeHead'] = true;
|
| 101: | $variables['lang_recommend'] = _MSC_RECOMMENDSITE;
|
| 102: | $variables['lang_yourname'] = _MSC_YOURNAMEC;
|
| 103: | $variables['lang_youremail'] = _MSC_YOUREMAILC;
|
| 104: | $variables['lang_friendname'] = _MSC_FRIENDNAMEC;
|
| 105: | $variables['lang_friendemail'] = _MSC_FRIENDEMAILC;
|
| 106: | $variables['lang_send'] = _SEND;
|
| 107: | $variables['lang_close'] = _CLOSE;
|
| 108: |
|
| 109: | $error = false;
|
| 110: | $errorMessage = '';
|
| 111: |
|
| 112: | $method = Request::getMethod();
|
| 113: | if ('POST' === $method) {
|
| 114: | $yname = Request::getString('yname', '', 'POST');
|
| 115: | $ymail = Request::getString('ymail', '', 'POST');
|
| 116: | $fname = Request::getString('fname', '', 'POST');
|
| 117: | $fmail = Request::getString('fmail', '', 'POST');
|
| 118: |
|
| 119: | if (!$GLOBALS['xoopsSecurity']->check()) {
|
| 120: | $error = true;
|
| 121: | $temp = $GLOBALS['xoopsSecurity']->getErrors();
|
| 122: | $errorMessage = (is_array($temp)) ? implode('<br>', $temp) : $temp;
|
| 123: | }
|
| 124: | if (!$error && false === filter_var($ymail, FILTER_VALIDATE_EMAIL)) {
|
| 125: | $error = true;
|
| 126: | $errorMessage = _MSC_INVALIDEMAIL1;
|
| 127: | }
|
| 128: | if (!$error && false === filter_var($fmail, FILTER_VALIDATE_EMAIL)) {
|
| 129: | $error = true;
|
| 130: | $errorMessage = _MSC_INVALIDEMAIL1;
|
| 131: | }
|
| 132: | if (!$error && '' === $yname) {
|
| 133: | $error = true;
|
| 134: | $errorMessage = _MSC_ENTERYNAME;
|
| 135: | }
|
| 136: | if (!$error && '' === $fname) {
|
| 137: | $error = true;
|
| 138: | $errorMessage = _MSC_ENTERFNAME;
|
| 139: | }
|
| 140: | if ($error) {
|
| 141: | $variables['errorMessage'] = $errorMessage;
|
| 142: | }
|
| 143: | }
|
| 144: | if ('POST' === $method && false === $error) {
|
| 145: |
|
| 146: | $xoopsMailer = xoops_getMailer();
|
| 147: | $xoopsMailer->setTemplate('tellfriend.tpl');
|
| 148: | $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']);
|
| 149: | $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']);
|
| 150: | $xoopsMailer->assign('SITEURL', XOOPS_URL . '/');
|
| 151: | $xoopsMailer->assign('YOUR_NAME', $yname);
|
| 152: | $xoopsMailer->assign('FRIEND_NAME', $fname);
|
| 153: | $xoopsMailer->setToEmails($fmail);
|
| 154: | $xoopsMailer->setFromEmail($ymail);
|
| 155: | $xoopsMailer->setFromName($yname);
|
| 156: | $xoopsMailer->setSubject(sprintf(_MSC_INTSITE, $xoopsConfig['sitename']));
|
| 157: |
|
| 158: | if (!$xoopsMailer->send()) {
|
| 159: | $error = true;
|
| 160: | $errorMessage = $xoopsMailer->getErrors();
|
| 161: | $variables['errorMessage'] = $errorMessage;
|
| 162: | } else {
|
| 163: | $variables['successMessage'] = _MSC_REFERENCESENT;
|
| 164: | }
|
| 165: | } else {
|
| 166: |
|
| 167: | $ynameDefault = '';
|
| 168: | $ymailDefault = '';
|
| 169: | if (is_object($xoopsUser)) {
|
| 170: | $ynameDefault = $xoopsUser->getVar('uname', 'e');
|
| 171: | $ymailDefault = $xoopsUser->getVar('email', 'e');
|
| 172: | }
|
| 173: | $yname = Request::getString('yname', $ynameDefault);
|
| 174: | $ymail = Request::getString('ymail', $ymailDefault);
|
| 175: | $fname = Request::getString('fname', '');
|
| 176: | $fmail = Request::getString('fmail', '');
|
| 177: | }
|
| 178: | $form = new XoopsThemeForm(_MSC_RECOMMENDSITE, 'recommendus', XOOPS_URL . '/misc.php', 'post', true);
|
| 179: | $ynameElelment = new XoopsFormText(_MSC_YOURNAMEC, 'yname', 32, 64, $yname);
|
| 180: | $form->addElement($ynameElelment, true);
|
| 181: | $ymailElelment = new XoopsFormText(_MSC_YOUREMAILC, 'ymail', 48, 96, $ymail);
|
| 182: | $form->addElement($ymailElelment, true);
|
| 183: | if ('' !== $ymail && false === filter_var($ymail, FILTER_VALIDATE_EMAIL)) {
|
| 184: | $ynameElelment->setDescription(_MSC_INVALIDEMAIL1);
|
| 185: | }
|
| 186: | $fnameElement = new XoopsFormText(_MSC_FRIENDNAMEC, 'fname', 32, 64, $fname);
|
| 187: | $form->addElement($fnameElement, true);
|
| 188: | $fmailElelment = new XoopsFormText(_MSC_FRIENDEMAILC, 'fmail', 48, 96, $fmail);
|
| 189: | if ('' !== $fmail && false === filter_var($fmail, FILTER_VALIDATE_EMAIL)) {
|
| 190: | $fmailElelment->setDescription(_MSC_INVALIDEMAIL1);
|
| 191: | }
|
| 192: | $form->addElement($fmailElelment, true);
|
| 193: | $form->addElement(new XoopsFormHidden('action', $action));
|
| 194: | $form->addElement(new XoopsFormHidden('type', $type));
|
| 195: | $form->addElement(new XoopsFormButton('', 'submit', _SEND, 'submit'));
|
| 196: |
|
| 197: | xoops_misc_popup_body('db:system_misc_friend.tpl', $variables, true, true, $form);
|
| 198: | break;
|
| 199: | case 'online':
|
| 200: | include_once $GLOBALS['xoops']->path('class/pagenav.php');
|
| 201: |
|
| 202: | $isadmin = false;
|
| 203: | $timezone = $xoopsConfig['default_TZ'];
|
| 204: | if (is_object($xoopsUser)) {
|
| 205: | $isadmin = $xoopsUser->isAdmin();
|
| 206: | $timezone = $xoopsUser->timezone();
|
| 207: | }
|
| 208: |
|
| 209: | $variables['headContents'] = '';
|
| 210: | $variables['closeHead'] = true;
|
| 211: | $variables['isadmin'] = $isadmin;
|
| 212: | $variables['lang_whoisonline'] = _WHOSONLINE;
|
| 213: | $variables['lang_close'] = _CLOSE;
|
| 214: | $variables['lang_avatar'] = _US_AVATAR;
|
| 215: | $variables['anonymous'] = $xoopsConfig['anonymous'];
|
| 216: | $variables['upload_url'] = XOOPS_UPLOAD_URL .'/';
|
| 217: |
|
| 218: | $start = Request::getInt('start', 0);
|
| 219: | $limit = 20;
|
| 220: |
|
| 221: |
|
| 222: | $module_handler = xoops_getHandler('module');
|
| 223: | $modules = $module_handler->getObjects(new Criteria('isactive', 1), true);
|
| 224: |
|
| 225: |
|
| 226: | $onlineHandler = xoops_getHandler('online');
|
| 227: | $onlineTotal = $onlineHandler->getCount();
|
| 228: | $criteria = new CriteriaCompo();
|
| 229: | $criteria->setStart($start);
|
| 230: | $criteria->setLimit($limit);
|
| 231: | $onlines = $onlineHandler->getAll($criteria);
|
| 232: |
|
| 233: | $onlineUserInfo = array();
|
| 234: | foreach ($onlines as $online) {
|
| 235: | $info = array();
|
| 236: | if (0 == $online['online_uid']) {
|
| 237: | $info['uid'] = $online['online_uid'];
|
| 238: | $info['uname'] = $xoopsConfig['anonymous'];;
|
| 239: | $info['name'] = '';
|
| 240: | $info['xoopsuser'] = false;
|
| 241: | $info['avatar'] = 'avatars/blank.gif';
|
| 242: | } else {
|
| 243: |
|
| 244: | $onlineUser = new XoopsUser($online['online_uid']);
|
| 245: | $info['xoopsuser'] = $onlineUser;
|
| 246: | $info['uid'] = $online['online_uid'];
|
| 247: | $info['uname'] = $online['online_uname'];
|
| 248: | $info['name'] = $onlineUser->name();
|
| 249: | $info['avatar'] = $onlineUser->user_avatar();
|
| 250: | }
|
| 251: | $info['updated'] = formatTimestamp($online['online_updated'], 'm', $timezone);
|
| 252: | $info['ip'] = $online['online_ip'];
|
| 253: | $info['mid'] = $online['online_module'];
|
| 254: | if (0 === $online['online_module'] || !isset($modules[$online['online_module']])) {
|
| 255: | $info['module_name'] = '';
|
| 256: | $info['dirname'] = '';
|
| 257: | } else {
|
| 258: |
|
| 259: | $mod = $modules[$online['online_module']];
|
| 260: | $info['module_name'] = $mod->name();
|
| 261: | $info['dirname'] = $mod->dirname();
|
| 262: | }
|
| 263: | $onlineUserInfo[] = $info;
|
| 264: | }
|
| 265: | $variables['onlineUserInfo'] = $onlineUserInfo;
|
| 266: |
|
| 267: | $nav = new XoopsPageNav($onlineTotal, $limit, $start, 'start', 'action=showpopups&type=online');
|
| 268: | $variables['pageNav'] = $nav->renderNav();
|
| 269: |
|
| 270: | xoops_misc_popup_body('db:system_misc_online.tpl', $variables, true, true);
|
| 271: | break;
|
| 272: | case 'ssllogin':
|
| 273: | if ($xoopsConfig['use_ssl'] && isset($_POST[$xoopsConfig['sslpost_name']]) && is_object($xoopsUser)) {
|
| 274: | include_once $GLOBALS['xoops']->path('language/' . $xoopsConfig['language'] . '/user.php');
|
| 275: | echo sprintf(_US_LOGGINGU, $xoopsUser->getVar('uname'));
|
| 276: | echo '<div style="text-align:center;"><input class="formButton" value="' . _CLOSE . '" type="button" onclick="window.opener.location.reload();window.close();" /></div>';
|
| 277: | $closebutton = false;
|
| 278: | }
|
| 279: | break;
|
| 280: | default:
|
| 281: | break;
|
| 282: | }
|
| 283: | $closebutton=false;
|
| 284: | if ($closebutton) {
|
| 285: | echo '<div style="text-align:center;"><input class="formButton" value="' . _CLOSE . '" type="button" onclick="window.close();" /></div>';
|
| 286: | }
|
| 287: | xoops_footer();
|
| 288: |
|
| 289: | |
| 290: | |
| 291: | |
| 292: | |
| 293: | |
| 294: | |
| 295: | |
| 296: | |
| 297: |
|
| 298: | function xoops_misc_popup_body($template, $variables, $closehead = true, $closebutton = true, $xoopsForm = null)
|
| 299: | {
|
| 300: | global $xoopsConfig;
|
| 301: |
|
| 302: | $themeSet = $xoopsConfig['theme_set'];
|
| 303: | $themePath = XOOPS_THEME_PATH . '/' . $themeSet . '/';
|
| 304: | $themeUrl = XOOPS_THEME_URL . '/' . $themeSet . '/';
|
| 305: | include_once XOOPS_ROOT_PATH . '/class/template.php';
|
| 306: | $headTpl = new \XoopsTpl();
|
| 307: |
|
| 308: | $headTpl->assign(array(
|
| 309: | 'closeHead' => (bool) $closehead,
|
| 310: | 'closeButton' => (bool) $closebutton,
|
| 311: | 'themeUrl' => $themeUrl,
|
| 312: | 'themePath' => $themePath,
|
| 313: | 'xoops_langcode' => _LANGCODE,
|
| 314: | 'xoops_charset' => _CHARSET,
|
| 315: | 'xoops_sitename' => $xoopsConfig['sitename'],
|
| 316: | 'xoops_url' => XOOPS_URL,
|
| 317: | ));
|
| 318: |
|
| 319: | $headTpl->assign($variables);
|
| 320: | if ($xoopsForm instanceof XoopsForm) {
|
| 321: | $xoopsForm->assign($headTpl);
|
| 322: | }
|
| 323: |
|
| 324: | $output = $headTpl->fetch($template);
|
| 325: | echo $output;
|
| 326: | }
|
| 327: | |