home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / CMS / xoops-2.0.18.1.exe / xoops-2.0.18.1 / htdocs / misc.php < prev    next >
Encoding:
PHP Script  |  2008-01-11  |  13.9 KB  |  263 lines

  1. <?php
  2. // $Id: misc.php 1241 2008-01-11 03:25:49Z phppp $
  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. include_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/misc.php';
  30. $action = isset($_GET['action']) ? trim($_GET['action']) : '';
  31. $action = isset($_POST['action']) ? trim($_POST['action']) : $action;
  32. $type = isset($_GET['type']) ? trim($_GET['type']) : '';
  33. $type = isset($_POST['type']) ? trim($_POST['type']) : $type;
  34.  
  35. if ( $action == "showpopups" ) {
  36.     xoops_header(false);
  37.     // show javascript close button?
  38.     $closebutton = 1;
  39.     switch ( $type ) {
  40.     case "smilies":
  41.         $target = isset($_GET['target']) ? trim($_GET['target']) : '';
  42.         if ($target == '' || !preg_match('/^[0-9a-z_]*$/i', $target)) {
  43.         } else {
  44.             echo "<script type=\"text/javascript\"><!--//
  45.             function doSmilie(addSmilie) {
  46.             var currentMessage = window.opener.xoopsGetElementById(\"".$target."\").value;
  47.             window.opener.xoopsGetElementById(\"".$target."\").value=currentMessage+addSmilie;
  48.             return;
  49.             }
  50.             //-->
  51.             </script>
  52.             ";
  53.             echo '</head><body>
  54.             <table width="100%" class="outer">
  55.             <tr><th colspan="3">'._MSC_SMILIES.'</th></tr>
  56.             <tr class="head"><td>'._MSC_CODE.'</td><td>'._MSC_EMOTION.'</td><td>'._IMAGE.'</td></tr>';
  57.             $myts =& MyTextsanitizer::getInstance();
  58.             if ($smiles = $myts->getSmileys()) {
  59.                 $rcolor = 'even';
  60.                 foreach ($smiles as $key => $smile) {
  61.                     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>";
  62.                     $rcolor = ($rcolor == 'even') ? 'odd' : 'even';
  63.                 }
  64.             } else {
  65.                 echo "Could not retrieve data from the database.";
  66.             }
  67.             echo '</table>'._MSC_CLICKASMILIE;
  68.         }
  69.         break;
  70.     case "avatars":
  71.         ?>
  72.         <script language='javascript'>
  73.         <!--//
  74.         function myimage_onclick(counter){
  75.             window.opener.xoopsGetElementById("user_avatar").options[counter].selected = true;
  76.             showAvatar();
  77.             window.opener.xoopsGetElementById("user_avatar").focus();
  78.             window.close();
  79.         }
  80.         function showAvatar() {
  81.             window.opener.xoopsGetElementById("avatar").src='<?php echo XOOPS_UPLOAD_URL;?>/' + window.opener.xoopsGetElementById("user_avatar").options[window.opener.xoopsGetElementById("user_avatar").selectedIndex].value;
  82.         }
  83.         //-->
  84.         </script>
  85.         </head><body>
  86.         <h4><?php echo _MSC_AVAVATARS;?></h4>
  87.         <form name='avatars' action='<?php echo $_SERVER['REQUEST_URI'];?>'>
  88.         <table width='100%'><tr>
  89.         <?php
  90.         $avatar_handler =& xoops_gethandler('avatar');
  91.         $avatarslist =& $avatar_handler->getList('S');
  92.         $cntavs = 0;
  93.         $counter = isset($_GET['start']) ? intval($_GET['start']) : 0;
  94.             foreach ($avatarslist as $file => $name) {
  95.             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>';
  96.             $counter++;
  97.             $cntavs++;
  98.             if ($cntavs > 8) {
  99.                 echo '</tr><tr>';
  100.                 $cntavs=0;
  101.             }
  102.         }
  103.         echo '</tr></table></form></div>';
  104.         break;
  105.     case "friend":
  106.         if ( !$GLOBALS['xoopsSecurity']->check() || !isset($_POST['op']) || $_POST['op'] == "sendform") {
  107.             if ( $xoopsUser ) {
  108.                 $yname = $xoopsUser->getVar("uname", 'e');
  109.                 $ymail = $xoopsUser->getVar("email", 'e');
  110.                 $fname = "";
  111.                 $fmail = "";
  112.             } else {
  113.                 $yname = "";
  114.                 $ymail = "";
  115.                 $fname = "";
  116.                 $fmail = "";
  117.             }
  118.             printCheckForm();
  119.             echo '</head><body>';
  120.             echo "<div class='errorMsg'>".implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())."</div>";
  121.             echo '
  122.             <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>';
  123.             echo "<tr><td class='head'>
  124.                 <input type='hidden' name='op' value='sendsite' />
  125.                 <input type='hidden' name='action' value='showpopups' />
  126.                 <input type='hidden' name='type' value='friend' />\n";
  127.             echo _MSC_YOURNAMEC."</td><td class='even'><input type='text' name='yname' value='$yname' id='yname' /></td></tr>
  128.                 <tr><td class='head'>"._MSC_YOUREMAILC."</td><td class='odd'><input type='text' name='ymail' value='".$ymail."' id='ymail' /></td></tr>
  129.                 <tr><td class='head'>"._MSC_FRIENDNAMEC."</td><td class='even'><input type='text' name='fname' value='$fname' id='fname' /></td></tr>
  130.                 <tr><td class='head'>"._MSC_FRIENDEMAILC."</td><td class='odd'><input type='text' name='fmail' value='$fmail' id='fmail' /></td></tr>
  131.                 <tr><td class='head'> </td><td class='even'><input type='submit' value='"._SEND."' /> <input value='"._CLOSE."' type='button' onclick='javascript:window.close();' />".$GLOBALS['xoopsSecurity']->getTokenHTML()."</td></tr>
  132.                 </table></form>\n";
  133.             $closebutton = 0;
  134.         } elseif ($_POST['op'] == "sendsite") {
  135.             $myts =& MyTextsanitizer::getInstance();
  136.             if ( $xoopsUser ) {
  137.                 $ymail = $xoopsUser->getVar("email");
  138.             } else {
  139.                 $ymail = isset($_POST['ymail']) ? $myts->stripSlashesGPC(trim($_POST['ymail'])) : '';
  140.             }
  141.             if ( !isset($_POST['yname']) || trim($_POST['yname']) == "" || $ymail == '' || !isset($_POST['fname']) || trim($_POST['fname']) == ""  || !isset($_POST['fmail']) || trim($_POST['fmail']) == '' ) {
  142.                 redirect_header(XOOPS_URL."/misc.php?action=showpopups&type=friend&op=sendform",2,_MSC_NEEDINFO);
  143.                 exit();
  144.             }
  145.             $yname = $myts->stripSlashesGPC(trim($_POST['yname']));
  146.             $fname = $myts->stripSlashesGPC(trim($_POST['fname']));
  147.             $fmail = $myts->stripSlashesGPC(trim($_POST['fmail']));
  148.             if (!checkEmail($fmail) || !checkEmail($ymail)  || preg_match( "/[\\0-\\31]/", $yname ) ) {
  149.                 $errormessage = _MSC_INVALIDEMAIL1."<br />"._MSC_INVALIDEMAIL2."";
  150.                 redirect_header(XOOPS_URL."/misc.php?action=showpopups&type=friend&op=sendform",2,$errormessage);
  151.                 exit();
  152.             }
  153.             $xoopsMailer =& getMailer();
  154.             $xoopsMailer->setTemplate("tellfriend.tpl");
  155.             $xoopsMailer->assign("SITENAME", $xoopsConfig['sitename']);
  156.             $xoopsMailer->assign("ADMINMAIL", $xoopsConfig['adminmail']);
  157.             $xoopsMailer->assign("SITEURL", XOOPS_URL."/");
  158.             $xoopsMailer->assign("YOUR_NAME", $yname);
  159.             $xoopsMailer->assign("FRIEND_NAME", $fname);
  160.             $xoopsMailer->setToEmails($fmail);
  161.             $xoopsMailer->setFromEmail($ymail);
  162.             $xoopsMailer->setFromName($yname);
  163.             $xoopsMailer->setSubject(sprintf(_MSC_INTSITE,$xoopsConfig['sitename']));
  164.             //OpenTable();
  165.             if ( !$xoopsMailer->send() ) {
  166.                 echo $xoopsMailer->getErrors();
  167.             } else {
  168.                 echo "<div><h4>"._MSC_REFERENCESENT."</h4></div>";
  169.             }
  170.             //CloseTable();
  171.         }
  172.         break;
  173.     case 'online':
  174.         $isadmin = $xoopsUserIsAdmin;
  175.         echo '<table  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 valign="middle" 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="" />' : ' ';
  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> </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 XOOPS_ROOT_PATH.'/class/pagenav.php';
  215.             $nav = new XoopsPageNav($online_total, 20, $start, 'start', 'action=showpopups&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 XOOPS_ROOT_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 echo _MSC_ENTERYNAME;?>" );
  245.                 xoopsGetElementById("yname").focus();
  246.                 return false;
  247.             } else if ( xoopsGetElementById("fname").value == "" ){
  248.                 alert( "<?php echo _MSC_ENTERFNAME;?>" );
  249.                 xoopsGetElementById("fname").focus();
  250.                 return false;
  251.             } else if ( xoopsGetElementById("fmail").value ==""){
  252.                 alert( "<?php echo _MSC_ENTERFMAIL;?>" );
  253.                 xoopsGetElementById("fmail").focus();
  254.                 return false;
  255.             } else {
  256.                 return true;
  257.             }
  258.         }
  259.         //-->
  260.     </script>
  261.     <?php
  262. }
  263. ?>