"Fossies" - the Fresh Open Source Software Archive

Member "impresscms-1.4.2/htdocs/misc.php" (24 Dec 2020, 13277 Bytes) of package /linux/www/impresscms-1.4.2.tar.gz:


The requested HTML page contains a <FORM> tag that is unusable on "Fossies" in "automatic" (rendered) mode so that page is shown as HTML source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "misc.php" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes reports: 1.4.2_rc_vs_1.4.2 or 1.4.1_vs_1.4.2.

    1 <?php
    2 // $Id: misc.php 12399 2014-01-25 17:02:01Z skenow $
    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 /**
   29  *
   30  * @copyright   http://www.xoops.org/ The XOOPS Project
   31  * @copyright   http://www.impresscms.org/ The ImpressCMS Project
   32  * @license     http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License (GPL)
   33  * @package     core
   34  * @since       XOOPS
   35  * @author      http://www.xoops.org The XOOPS Project
   36  * @author      Sina Asghari (aka stranger) <pesian_stranger@users.sourceforge.net>
   37  * @version     $Id: misc.php 12399 2014-01-25 17:02:01Z skenow $
   38  * @version $Id: misc.php 12399 2014-01-25 17:02:01Z skenow $
   39  **/
   40 
   41 include 'mainfile.php';
   42 icms_loadLanguageFile('core', 'misc');
   43 /* set filter types, if not strings */
   44 $filter_post[] = array(
   45         'uid' => 'int',
   46         'start' => 'int',
   47 );
   48 
   49 $filter_get[] = array(
   50         'uid' => 'int',
   51         'start' => 'int',
   52 );
   53 
   54 /* set default values for variables */
   55 $action = $type = "";
   56 
   57 /* filter the user input */
   58 if (!empty($_GET)) {
   59     // in places where strict mode is not used for checkVarArray, make sure filter_ vars are not overwritten
   60     if (isset($_GET['filter_post'])) unset ($_GET['filter_post']);
   61     $clean_GET = icms_core_DataFilter::checkVarArray($_GET, $filter_get, FALSE);
   62     extract($clean_GET);
   63 }
   64 if (!empty($_POST)) {
   65     $clean_POST = icms_core_DataFilter::checkVarArray($_POST, $filter_post, FALSE);
   66     extract($clean_POST);
   67 }
   68 
   69 if ($action == 'showpopups') {
   70     xoops_header(false);
   71     // show javascript close button?
   72     $closebutton = 1;
   73     switch($type)
   74     {
   75         case 'smilies':
   76             if ($target == '' || !preg_match('/^[0-9a-z_]*$/i', $target)) {} else {
   77                 echo "<script type=\"text/javascript\"><!--//
   78                 function doSmilie(addSmilie) {
   79                 var currentMessage = window.opener.xoopsGetElementById(\"".$target."\").value;
   80                 window.opener.xoopsGetElementById(\"".$target."\").value=currentMessage+addSmilie;
   81                 return;
   82                 }
   83                 //-->
   84                 </script>
   85                 ";
   86                 echo '</head><body>
   87                 <table width="100%" class="outer">
   88                 <tr><th colspan="3">'._MSC_SMILIES.'</th></tr>
   89                 <tr class="head"><td>'._MSC_CODE.'</td><td>'._MSC_EMOTION.'</td><td>'._IMAGE.'</td></tr>';
   90                 $smiles = icms_core_DataFilter::getSmileys(1);
   91                 $count = count($smiles);
   92                 if ($count > 0)
   93                 {
   94                     $rcolor = 'even';
   95                     for ($i = 0; $i < $count; $i++)
   96                     {
   97                         echo "<tr class='$rcolor'><td>".$smiles[$i]['code']."</td>
   98                             <td>".$smiles[$i]['emotion']."</td>
   99                             <td><img onmouseover='style.cursor=\"pointer\"' onclick='doSmilie(\" "
  100                             . $smiles[$i]['code'] . " \");' src='"
  101                             . ICMS_UPLOAD_URL . "/" . $smiles[$i]['smile_url'] . "' alt='' /></td></tr>";
  102                         $rcolor = ($rcolor == 'even') ? 'odd' : 'even';
  103                     }
  104                 }
  105                 else {echo 'Could not retrieve data from the database.';}
  106                 echo '</table>'._MSC_CLICKASMILIE;
  107             }
  108             break;
  109         case 'avatars':
  110             ?>
  111             <script language='javascript'>
  112                 <!--//
  113                 function myimage_onclick(counter) {
  114                     window.opener.xoopsGetElementById("user_avatar").options[counter].selected = true;
  115                     showAvatar();
  116                     window.opener.xoopsGetElementById("user_avatar").focus();
  117                     window.close();
  118                 }
  119                 function showAvatar() {
  120                     window.opener.xoopsGetElementById("avatar").src='<?php echo ICMS_UPLOAD_URL;?>/'
  121                     + window.opener.xoopsGetElementById("user_avatar")
  122                     .options[window.opener.xoopsGetElementById("user_avatar").selectedIndex].value;
  123                 }
  124                 //-->
  125             </script>
  126             </head>
  127             <body>
  128             <h4><?php echo _MSC_AVAVATARS;?></h4>
  129             <table width='100%'>
  130                 <tr>
  131                 <?php
  132                 $avatar_handler = icms::handler('icms_data_avatar');
  133                 $avatarslist =& $avatar_handler->getList('S');
  134                 $cntavs = 0;
  135                 $counter = isset($start) ? (int) ($start) : 0;
  136                 foreach ($avatarslist as $file => $name)
  137                 {
  138                     echo '<td><img src="uploads/'.$file.'" alt="'.$name.'" style="padding:10px; vertical-align:top;" />
  139                         <br />'.$name.'<br />
  140                         <input name="myimage" type="button" value="'._SELECT.'" onclick="myimage_onclick('.$counter.')" />
  141                         </td>';
  142                     $counter++;
  143                     $cntavs++;
  144                     if ($cntavs > 8)
  145                     {
  146                         echo '</tr><tr>';
  147                         $cntavs=0;
  148                     }
  149                 }
  150                 echo '</tr></table></div>';
  151                 break;
  152             case 'friend':
  153                 if (!icms::$security->check() || !isset($op) || $op == 'sendform') {
  154                     if (icms::$user) {
  155                         $yname = icms::$user->getVar('uname', 'e');
  156                         $ymail = icms::$user->getVar('email', 'e');
  157                         $fname = '';
  158                         $fmail = '';
  159                     } else {
  160                         $yname = '';
  161                         $ymail = '';
  162                         $fname = '';
  163                         $fmail = '';
  164                     }
  165                     printCheckForm();
  166                     echo '</head><body>';
  167                     echo "<div class='errorMsg'>".implode('<br />', icms::$security->getErrors())."</div>";
  168                     echo '<form action="'.ICMS_URL.'/misc.php" method="post" onsubmit="return checkForm();"><table  width="100%" class="outer" cellspacing="1"><tr><th colspan="2">'._MSC_RECOMMENDSITE.'</th></tr>';
  169                     echo "<tr><td class='head'>
  170                                 <input type='hidden' name='op' value='sendsite' />
  171                                 <input type='hidden' name='action' value='showpopups' />
  172                                 <input type='hidden' name='type' value='friend' />\n";
  173                     echo _MSC_YOURNAMEC."</td>
  174                         <td class='even'><input type='text' name='yname' value='$yname' id='yname' /></td></tr>
  175                         <tr><td class='head'>"._MSC_YOUREMAILC."</td><td class='odd'>
  176                         <input type='text' name='ymail' value='".$ymail."' id='ymail' /></td></tr>
  177                         <tr><td class='head'>"._MSC_FRIENDNAMEC."</td>
  178                         <td class='even'><input type='text' name='fname' value='$fname' id='fname' /></td></tr>
  179                         <tr><td class='head'>"._MSC_FRIENDEMAILC."</td>
  180                         <td class='odd'><input type='text' name='fmail' value='$fmail' id='fmail' /></td></tr>
  181                         <tr><td class='head'>&nbsp;</td><td class='even'>
  182                         <input type='submit' value='"._SEND."' />&nbsp;
  183                         <input value='"._CLOSE."' type='button' onclick='javascript:window.close();' />"
  184                         . icms::$security->getTokenHTML()."</td></tr>
  185                         </table></form>\n";
  186                     $closebutton = 0;
  187                 } elseif ($op == 'sendsite') {
  188                     if (icms::$user) {
  189                         $ymail = icms::$user->getVar('email');
  190                     } else {
  191                         $ymail = isset($ymail) ? icms_core_DataFilter::stripSlashesGPC(trim($ymail)) : '';
  192                     }
  193                     if (!isset($yname) || trim($yname) == '' || $ymail == ''
  194                         || !isset($fname) || trim($fname) == ''
  195                         || !isset($fmail) || trim($fmail) == '') {
  196                         redirect_header(ICMS_URL.'/misc.php?action=showpopups&amp;type=friend&amp;op=sendform',2,_MSC_NEEDINFO);
  197                     }
  198                     $yname = icms_core_DataFilter::stripSlashesGPC(trim($_POST['yname']));
  199                     $fname = icms_core_DataFilter::stripSlashesGPC(trim($_POST['fname']));
  200                     $fmail = icms_core_DataFilter::stripSlashesGPC(trim($_POST['fmail']));
  201                     if (!icms_core_DataFilter::checkVar($fmail, 'email') || !icms_core_DataFilter::checkVar($ymail, 'email') || preg_match('/[\\0-\\31]/', $yname)) {
  202                         $errormessage = _MSC_INVALIDEMAIL1.'<br />'._MSC_INVALIDEMAIL2.'';
  203                         redirect_header(ICMS_URL.'/misc.php?action=showpopups&amp;type=friend&amp;op=sendform',2,$errormessage);
  204                     }
  205                     $xoopsMailer = new icms_messaging_Handler();
  206                     $xoopsMailer->setTemplate('tellfriend.tpl');
  207                     $xoopsMailer->assign('SITENAME', $icmsConfig['sitename']);
  208                     $xoopsMailer->assign('ADMINMAIL', $icmsConfig['adminmail']);
  209                     $xoopsMailer->assign('SITEURL', ICMS_URL.'/');
  210                     $xoopsMailer->assign('YOUR_NAME', $yname);
  211                     $xoopsMailer->assign('FRIEND_NAME', $fname);
  212                     $xoopsMailer->setToEmails($fmail);
  213                     $xoopsMailer->setFromEmail($ymail);
  214                     $xoopsMailer->setFromName($yname);
  215                     $xoopsMailer->setSubject(sprintf(_MSC_INTSITE,$icmsConfig['sitename']));
  216                     //OpenTable();
  217                     if (!$xoopsMailer->send()) {echo $xoopsMailer->getErrors();}
  218                     else {echo '<div><h4>'._MSC_REFERENCESENT.'</h4></div>';}
  219                     //CloseTable();
  220                 }
  221                 break;
  222             case 'online':
  223                 echo '<table  width="100%" cellspacing="1" class="outer"><tr><th colspan="3">'._WHOSONLINE.'</th></tr>';
  224                 $online_handler = icms::handler('icms_core_Online');
  225                 $online_total =& $online_handler->getCount();
  226                 $limit = ($online_total > 20) ? 20 : $online_total;
  227                 $criteria = new icms_db_criteria_Compo();
  228                 $criteria->setLimit($limit);
  229                 $criteria->setStart($start);
  230                 $onlines =& $online_handler->getAll($criteria);
  231                 $count = count($onlines);
  232                 $module_handler = icms::handler('icms_module');
  233                 $modules =& $module_handler->getList(new icms_db_criteria_Item('isactive', 1));
  234                 for ($i = 0; $i < $count; $i++) {
  235                     if ($onlines[$i]['online_uid'] == 0) {
  236                         $onlineUsers[$i]['user'] = '';
  237                     } else {
  238                         $onlineUsers[$i]['user'] = new icms_member_user_Object($onlines[$i]['online_uid']);
  239                     }
  240                     $onlineUsers[$i]['ip'] = $onlines[$i]['online_ip'];
  241                     $onlineUsers[$i]['updated'] = $onlines[$i]['online_updated'];
  242                     $onlineUsers[$i]['module'] = ($onlines[$i]['online_module'] > 0) ? $modules[$onlines[$i]['online_module']] : '';
  243                 }
  244                 $class = 'even';
  245                 for ($i = 0; $i < $count; $i++) {
  246                     $class = ($class == 'odd') ? 'even' : 'odd';
  247                     echo '<tr valign="middle" align="center" class="'.$class.'">';
  248                     if (is_object($onlineUsers[$i]['user'])) {
  249                         $avatar = $onlineUsers[$i]['user']->getVar('user_avatar')
  250                             ? '<img src="'.ICMS_UPLOAD_URL.'/'.$onlineUsers[$i]['user']->getVar('user_avatar').'" alt="" />' : '&nbsp;';
  251                         echo '<td>'.$avatar."</td><td>
  252                             <a href=\"javascript:window.opener.location='".ICMS_URL."/userinfo.php?uid="
  253                             . $onlineUsers[$i]['user']->getVar('uid')."';window.close();\">"
  254                             . $onlineUsers[$i]['user']->getVar('uname')."</a>";
  255                     } else {
  256                         echo '<td>&nbsp;</td><td>'.$icmsConfig['anonymous'];
  257                     }
  258                     if (icms::$user->isAdmin()) {
  259                         echo '<br />('.$onlineUsers[$i]['ip'].')';
  260                     }
  261                     echo '</td><td>'.$onlineUsers[$i]['module'].'</td></tr>';
  262                 }
  263                 echo '</table><br />';
  264                 if ($online_total > 20) {
  265                     $nav = new icms_view_PageNav($online_total, 20, $start, 'start', 'action=showpopups&amp;type=online');
  266                     echo '<div style="text-align: right;">'.$nav->renderNav().'</div>';
  267                 }
  268                 break;
  269             case 'ssllogin':
  270                 if ($icmsConfig['use_ssl'] && isset($_POST[$icmsConfig['sslpost_name']]) && is_object(icms::$user)) {
  271                     icms_loadLanguageFile('core', 'user');
  272                     echo sprintf(_US_LOGGINGU, icms::$user->getVar('uname'));
  273                     echo '<div style="text-align:center;">
  274                         <input class="formButton" value="'._CLOSE.'" type="button" onclick="window.opener.location.reload();window.close();" />
  275                         </div>';
  276                     $closebutton = false;
  277                 }
  278                 break;
  279             default:
  280                 break;
  281                 }
  282                 if ($closebutton) {
  283                     echo '<div style="text-align:center;">
  284                         <input class="formButton" value="'._CLOSE.'" type="button" onclick="javascript:window.close();" />
  285                         </div>';
  286                 }
  287                 xoops_footer();
  288             }
  289 
  290             function printCheckForm() {
  291                 ?>
  292                     <script language='javascript'>
  293                     <!--//
  294                     function checkForm() {
  295                         if (xoopsGetElementById("yname").value == "") {
  296                             alert("<?php echo _MSC_ENTERYNAME;?>");
  297                             xoopsGetElementById("yname").focus();
  298                             return false;
  299                         } elseif (xoopsGetElementById("fname").value == "") {
  300                             alert("<?php echo _MSC_ENTERFNAME;?>");
  301                             xoopsGetElementById("fname").focus();
  302                             return false;
  303                         } elseif (xoopsGetElementById("fmail").value =="") {
  304                             alert("<?php echo _MSC_ENTERFMAIL;?>");
  305                             xoopsGetElementById("fmail").focus();
  306                             return false;
  307                         } else {
  308                             return true;
  309                         }
  310                     }
  311                     //-->
  312                     </script>
  313                 <?php
  314             }