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