[ Index ]
 

Code source de XOOPS 2.0.17.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/htdocs/ -> misc.php (source)

   1  <?php
   2  // $Id: misc.php 506 2006-05-26 23:10:37Z skalpa $

   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              if ($getsmiles = $xoopsDB->query("SELECT * FROM ".$xoopsDB->prefix("smiles"))) {
  58                  $rcolor = 'even';
  59                  while ( $smile = $xoopsDB->fetchArray($getsmiles) ) {
  60                      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>";
  61                      $rcolor = ($rcolor == 'even') ? 'odd' : 'even';
  62                  }
  63              } else {
  64                  echo "Could not retrieve data from the database.";
  65              }
  66              echo '</table>'._MSC_CLICKASMILIE;
  67          }
  68          break;
  69      case "avatars":
  70          ?>
  71          <script language='javascript'>
  72          <!--//
  73          function myimage_onclick(counter){
  74              window.opener.xoopsGetElementById("user_avatar").options[counter].selected = true;
  75              showAvatar();
  76              window.opener.xoopsGetElementById("user_avatar").focus();
  77              window.close();
  78          }
  79          function showAvatar() {
  80              window.opener.xoopsGetElementById("avatar").src='<?php echo XOOPS_UPLOAD_URL;?>/' + window.opener.xoopsGetElementById("user_avatar").options[window.opener.xoopsGetElementById("user_avatar").selectedIndex].value;
  81          }
  82          //-->

  83          </script>
  84          </head><body>
  85          <h4><?php echo _MSC_AVAVATARS;?></h4>
  86          <form name='avatars' action='<?php echo $_SERVER['REQUEST_URI'];?>'>
  87          <table width='100%'><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          } elseif ($_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 =& 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':
 173          $isadmin = $xoopsUserIsAdmin;
 174          echo '<table  width="100%" cellspacing="1" class="outer"><tr><th colspan="3">'._WHOSONLINE.'</th></tr>';
 175          $start = isset($_GET['start']) ? intval($_GET['start']) : 0;
 176          $online_handler =& xoops_gethandler('online');
 177          $online_total =& $online_handler->getCount();
 178          $limit = ($online_total > 20) ? 20 : $online_total;
 179          $criteria = new CriteriaCompo();
 180          $criteria->setLimit($limit);
 181          $criteria->setStart($start);
 182          $onlines =& $online_handler->getAll($criteria);
 183          $count = count($onlines);
 184          $module_handler =& xoops_gethandler('module');
 185          $modules =& $module_handler->getList(new Criteria('isactive', 1));
 186          for ($i = 0; $i < $count; $i++) {
 187              if ($onlines[$i]['online_uid'] == 0) {
 188                  $onlineUsers[$i]['user'] = '';
 189              } else {
 190                  $onlineUsers[$i]['user'] =& new XoopsUser($onlines[$i]['online_uid']);
 191              }
 192              $onlineUsers[$i]['ip'] = $onlines[$i]['online_ip'];
 193              $onlineUsers[$i]['updated'] = $onlines[$i]['online_updated'];
 194              $onlineUsers[$i]['module'] = ($onlines[$i]['online_module'] > 0) ? $modules[$onlines[$i]['online_module']] : '';
 195          }
 196          $class = 'even';
 197          for ($i = 0; $i < $count; $i++) {
 198              $class = ($class == 'odd') ? 'even' : 'odd';
 199              echo '<tr valign="middle" align="center" class="'.$class.'">';
 200              if (is_object($onlineUsers[$i]['user'])) {
 201                  $avatar = $onlineUsers[$i]['user']->getVar('user_avatar') ? '<img src="'.XOOPS_UPLOAD_URL.'/'.$onlineUsers[$i]['user']->getVar('user_avatar').'" alt="" />' : '&nbsp;';
 202                  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>";
 203              } else {
 204                  echo '<td>&nbsp;</td><td>'.$xoopsConfig['anonymous'];
 205              }
 206              if ($isadmin == 1) {
 207                  echo '<br />('.$onlineUsers[$i]['ip'].')';
 208              }
 209              echo '</td><td>'.$onlineUsers[$i]['module'].'</td></tr>';
 210          }
 211          echo '</table><br />';
 212          if ($online_total > 20) {
 213              include_once  XOOPS_ROOT_PATH.'/class/pagenav.php';
 214              $nav = new XoopsPageNav($online_total, 20, $start, 'start', 'action=showpopups&amp;type=online');
 215              echo '<div style="text-align: right;">'.$nav->renderNav().'</div>';
 216          }
 217          break;
 218      case 'ssllogin':
 219          if ($xoopsConfig['use_ssl'] && isset($_POST[$xoopsConfig['sslpost_name']]) && is_object($xoopsUser)) {
 220              include_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/user.php';
 221              echo sprintf(_US_LOGGINGU, $xoopsUser->getVar('uname'));
 222              echo '<div style="text-align:center;"><input class="formButton" value="'._CLOSE.'" type="button" onclick="window.opener.location.reload();window.close();" /></div>';
 223              $closebutton = false;
 224          }
 225          break;
 226      default:
 227          break;
 228      }
 229      if ($closebutton) {
 230          echo '<div style="text-align:center;"><input class="formButton" value="'._CLOSE.'" type="button" onclick="javascript:window.close();" /></div>';
 231      }
 232      xoops_footer();
 233  }
 234  
 235  function printCheckForm()
 236  {
 237      ?>
 238      <script language='javascript'>
 239          <!--//
 240          function checkForm()
 241          {
 242              if ( xoopsGetElementById("yname").value == "" ){
 243                  alert( "<?php echo _MSC_ENTERYNAME;?>" );
 244                  xoopsGetElementById("yname").focus();
 245                  return false;
 246              } else if ( xoopsGetElementById("fname").value == "" ){
 247                  alert( "<?php echo _MSC_ENTERFNAME;?>" );
 248                  xoopsGetElementById("fname").focus();
 249                  return false;
 250              } else if ( xoopsGetElementById("fmail").value ==""){
 251                  alert( "<?php echo _MSC_ENTERFMAIL;?>" );
 252                  xoopsGetElementById("fmail").focus();
 253                  return false;
 254              } else {
 255                  return true;
 256              }
 257          }
 258          //-->

 259      </script>
 260      <?php
 261  }
 262  ?>


Généré le : Sun Nov 25 11:44:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics