Your browser must have JavaScript enabled in order to view this page.
 >  >
 
Welcome Guest#216 Login/register    Go to Bottom
Go to Top

Source for file DpUser.php

Documentation is available at DpUser.php

  1. <?php
  2. /**
  3.  * A user object, the object representing a real user
  4.  *
  5.  * DutchPIPE version 0.4; PHP version 5
  6.  *
  7.  * LICENSE: This source file is subject to version 1.0 of the DutchPIPE license.
  8.  * If you did not receive a copy of the DutchPIPE license, you can obtain one at
  9.  * http://dutchpipe.org/license/1_0.txt or by sending a note to
  10.  * license@dutchpipe.org, in which case you will be mailed a copy immediately.
  11.  *
  12.  * @package    DutchPIPE
  13.  * @subpackage dpuniverse_std
  14.  * @author     Lennert Stock <ls@dutchpipe.org>
  15.  * @copyright  2006, 2007 Lennert Stock
  16.  * @license    http://dutchpipe.org/license/1_0.txt  DutchPIPE License
  17.  * @version    Subversion: $Id: DpUser.php 311 2007-09-03 12:48:09Z ls $
  18.  * @link       http://dutchpipe.org/manual/package/DutchPIPE
  19.  * @see        DpLiving
  20.  */
  21.  
  22. /**
  23.  * Builts upon the standard DpLiving class
  24.  */
  25. inherit(DPUNIVERSE_STD_PATH 'DpLiving.php');
  26.  
  27. /**
  28.  * Gets title type constants
  29.  */
  30. inherit(DPUNIVERSE_INCLUDE_PATH 'title_types.php');
  31.  
  32. /**
  33.  * A user object, the object representing a real user
  34.  *
  35.  * Currently the only differerence with a NPC (which shares the same DpLiving
  36.  * class) is the passing of the user's last HTTP request's server, request and
  37.  * cookie variables, and the tell method (NPCs don't have a browser).
  38.  * See the DpLiving class for most functionality.
  39.  *
  40.  * Creates the following DutchPIPE properties:<br />
  41.  *
  42.  * - boolean <b>isUser</b> - Set to TRUE
  43.  * - boolean <b>isRegistered</b> - TRUE if this is a registered user, FALSE
  44.  *   otherwise
  45.  * - boolean <b>isAdmin</b> - TRUE if this user is an administrator, FALSE
  46.  *   otherwise
  47.  * - boolean <b>noCookies</b> - TRUE if the user's browser didn't accept our
  48.  *   cookie
  49.  * - boolean <b>isKnownBot</b> - TRUE if this is a known search engine bot,
  50.  *   FALSE otherwise
  51.  * - boolean <b>isAjaxCapable</b> - TRUE if the user's browser is AJAX-capable,
  52.  *   FALSE otherwise
  53.  * - string <b>age</b> - Descriptive age of the user
  54.  * - string <b>inactive</b> - Descriptive inactive time of the user, empty
  55.  *   string for active
  56.  * - boolean <b>isInactive</b> - TRUE if the user in inactive, FALSE otherwise
  57.  * - integer <b>avatarNr</b> - Avatar image number, 0 for custom avatar
  58.  * - string <b>avatarCustom</b> - File name of custom avatar, if any
  59.  * - status <b>browseAvatarCustom</b> - TRUE if the user is browsing on his
  60.  *   computer for an image to upload (which causes scripts to halt), unset
  61.  *   otherwise
  62.  * - mixed <b>status</b> - FALSE for no special status, otherwise a descriptive
  63.  *   string, 'away'
  64.  * - string <b>inputMode</b> - Input field mode, "say" or "cmd"
  65.  * - string <b>inputEnabled</b> - Is input field visibile? Either "on" or "off"
  66.  * - string <b>inputPersistent</b> - Input field options
  67.  *
  68.  * @package    DutchPIPE
  69.  * @subpackage dpuniverse_std
  70.  * @author     Lennert Stock <ls@dutchpipe.org>
  71.  * @copyright  2006, 2007 Lennert Stock
  72.  * @license    http://dutchpipe.org/license/1_0.txt  DutchPIPE License
  73.  * @version    Release: 0.2.1
  74.  * @link       http://dutchpipe.org/manual/package/DutchPIPE
  75.  */
  76. class DpUser extends DpLiving
  77. {
  78.     /**
  79.      * Variables set by the web server of related to dpclient.php's environment
  80.      *
  81.      * This environment is the execution environment of the current dpclient.php
  82.      * script.
  83.      *
  84.      * @var         array 
  85.      */
  86.     public $_SERVER;
  87.  
  88.     /**
  89.      * Variables which are currently registered to a script's session
  90.      *
  91.      * @var         array 
  92.      */
  93.     public $_SESSION;
  94.  
  95.     /**
  96.      * Variables provided via HTTP cookies
  97.      *
  98.      * @var         array 
  99.      */
  100.     public $_COOKIE;
  101.  
  102.     /**
  103.      * Variables provided via URL query string
  104.      *
  105.      * @var         array 
  106.      */
  107.     public $_GET;
  108.  
  109.     /**
  110.      * Variables provided via HTTP POST
  111.      *
  112.      * @var         array 
  113.      */
  114.     public $_POST;
  115.  
  116.     /**
  117.      * Variables provided via HTTP post file uploads
  118.      *
  119.      * @var         array 
  120.      */
  121.     public $_FILES;
  122.  
  123.     /**
  124.      * Counter for AJAX events, increased with each event
  125.      *
  126.      * @var         string 
  127.      */
  128.     private $mEventCount 0;
  129.  
  130.     /**
  131.      * Status of last connection, for example 'busy', used to detect change
  132.      *
  133.      * @var         string 
  134.      */
  135.     private $mLastStatus FALSE;
  136.  
  137.     /**
  138.      * Events this user will be alerted of, such as people entering the site
  139.      *
  140.      * @var         array 
  141.      */
  142.     public $mAlertEvents = array();
  143.  
  144.     /**
  145.      * History of input field actions, can be accesed by up and down arrow keys
  146.      *
  147.      * @var         array 
  148.      */
  149.     public $mActionHistory = array();
  150.  
  151.     /**
  152.      * Initializes the user
  153.      */
  154.     function createDpLiving()
  155.     {
  156.         $this->addId(dp_text('user'));
  157.         $this->isUser new_dp_property(TRUE);
  158.         $this->isRegistered new_dp_property(FALSE);
  159.         $this->isAdmin new_dp_property(FALSE);
  160.         $this->noCookies new_dp_property(FALSE);
  161.         $this->isKnownBot new_dp_property(FALSE);
  162.         $this->isAjaxCapable new_dp_property(FALSE);
  163.         $this->age new_dp_property(0FALSE);
  164.         $this->inactive new_dp_property(FALSEFALSE'getInactive');
  165.         $this->isInactive new_dp_property(FALSEFALSE'isInactive');
  166.         $this->inputMode 'say';
  167.         $this->inputEnabled new_dp_property('off');
  168.         $this->inputPersistent new_dp_property('page');
  169.         $this->avatarCustom new_dp_property(FALSE);
  170.  
  171.         $avatar_nr get_current_dpuniverse()->getRandAvatarNr();
  172.         $this->avatarNr new_dp_property($avatar_nr);
  173.         $this->setTitle(dp_text('User'));
  174.         $this->titleType DPUNIVERSE_TITLE_TYPE_NAME;
  175.         $this->titleImg DPUNIVERSE_AVATAR_STD_URL 'user' $avatar_nr
  176.             . '.gif';
  177.         $this->status new_dp_property(FALSENULL'getStatus');
  178.         $this->body '<img src="' DPUNIVERSE_AVATAR_STD_URL 'user'
  179.             . $avatar_nr '_body.gif" border="0" alt="" align="left" '
  180.             . 'style="margin-right: 15px" />' dp_text('A user.''<br />';
  181.  
  182.         /* Actions for everybody */
  183.         $this->addAction(dp_text("who's here?")dp_text('who')'actionWho'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  184.         $this->addAction(dp_text("change avatar")dp_text('avatar')'actionAvatar'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  185.         $this->addAction(array(dp_text('tools')dp_text('options'))explode('#'dp_text('options#settings#config'))'actionSettings'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  186.         $this->addAction(array(dp_text('tools')dp_text('my home'))dp_text('myhome')'actionMyhome'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_REGISTEREDDP_ACTION_SCOPE_SELF);
  187.         $this->addAction(array(dp_text('tools')dp_text('set my home'))dp_text('myhome set')'actionMyhome'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_REGISTEREDDP_ACTION_SCOPE_SELF);
  188.         $this->addAction(array(dp_text('tools')dp_text('login/register'))dp_text('login')'actionLoginOut'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_GUESTDP_ACTION_SCOPE_SELF);
  189.         $this->addAction(array(dp_text('tools')dp_text('logout'))dp_text('logout')'actionLoginOut'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_REGISTEREDDP_ACTION_SCOPE_SELF);
  190.         $this->addAction(array(dp_text('tools')dp_text('advanced')array($this'getModeChecked'))dp_text('mode')'actionMode'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  191.         $this->addAction(array(dp_text('tools')dp_text('advanced')dp_text('show page links'))dp_text('links')'actionLinks'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  192.         $this->addAction(array(dp_text('tools')dp_text('advanced')dp_text('show source'))dp_text('source')'actionSource'DP_ACTION_OPERANT_MENUDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  193.  
  194.         /* Actions for admin only */
  195.         $this->addAction(array(dp_text('admin')dp_text('goto...'))dp_text('goto')'actionGoto'DP_ACTION_OPERANT_COMPLETEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_ADMINDP_ACTION_SCOPE_SELF);
  196.         $this->addAction(array(dp_text('admin')dp_text('reset'))dp_text('reset')'actionReset'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_ADMINDP_ACTION_SCOPE_SELF);
  197.         $this->addAction(array(dp_text('admin')dp_text('svars'))dp_text('svars')'actionSvars'DP_ACTION_OPERANT_MENUDP_ACTION_TARGET_SELF DP_ACTION_TARGET_LIVINGDP_ACTION_AUTHORIZED_ADMINDP_ACTION_SCOPE_SELF);
  198.         $this->addAction(array(dp_text('admin')dp_text('force...'))dp_text('force')'actionForce'array($this'actionMoveOperant')DP_ACTION_TARGET_LIVINGDP_ACTION_AUTHORIZED_ADMINDP_ACTION_SCOPE_SELF);
  199.         $this->addAction(array(dp_text('admin')dp_text('move...'))dp_text('move')'actionMove'array($this'actionMoveOperant')DP_ACTION_TARGET_SELF DP_ACTION_TARGET_LIVING DP_ACTION_TARGET_OBJINV DP_ACTION_TARGET_OBJENVDP_ACTION_AUTHORIZED_ADMINDP_ACTION_SCOPE_SELF);
  200.         $this->addAction(array(dp_text('admin')dp_text('object list'))dp_text('oblist')'actionOblist'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_ADMINDP_ACTION_SCOPE_SELF);
  201.  
  202.         /* Last action in menu */
  203.  
  204.         $this->addValidClientCall('setAvatar');
  205.         $this->addValidClientCall('setSettings');
  206.         if (DPUNIVERSE_AVATAR_CUSTOM_ENABLED && function_exists('gd_info')) {
  207.             $this->addValidClientCall('setBrowseAvatarCustom');
  208.             $this->addValidClientCall('uploadAvatarCustom');
  209.             $this->addValidClientCall('removeAvatarCustom');
  210.         }
  211.     }
  212.  
  213.     /**
  214.      * Gets the user's age in a string
  215.      *
  216.      * Returns the user's age in a format like "1 day, 6 hours and 14 minutes".
  217.      *
  218.      * @return  string  user's age
  219.      * @see     getInactive, isInactive, getStatus, DpLiving::getSessionAge()
  220.      */
  221.     protected function getAge()
  222.     {
  223.         if (!$this->isRegistered{
  224.             return FALSE;
  225.         }
  226.  
  227.         $result dp_db_query('SELECT userAge FROM Users WHERE '
  228.             . 'userUsernameLower='
  229.             . dp_db_quote(dp_strtolower($this->title)'text'));
  230.  
  231.         $age !$result || !dp_db_num_rows($result)
  232.             ? dp_db_fetch_one($result00);
  233.  
  234.         dp_db_free($result);
  235.  
  236.         return get_age2string($age (time($this->creationTime));
  237.  
  238.     }
  239.  
  240.     /**
  241.      * Gets inactive time of the user in a string
  242.      *
  243.      * Returns how long the user is inactive in a format like "2 hours and 14
  244.      * minutes".
  245.      *
  246.      * @return  string  user's inactivity
  247.      * @see     getAge, isInactive, getStatus, DpLiving::getSessionAge()
  248.      */
  249.     function getInactive()
  250.     {
  251.         $inactive_time time((!isset($this->lastActionTime)
  252.             ? $this->creationTime $this->lastActionTime);
  253.  
  254.         if ($inactive_time 300{
  255.             return '';
  256.         }
  257.  
  258.         return get_age2string($inactive_time);
  259.     }
  260.  
  261.     /**
  262.      * Is this user inactive?
  263.      *
  264.      * Inactive is defined as a user who hasn't shown activity in the last 5
  265.      * minutes.
  266.      *
  267.      * @return  status  TRUE if the user is inactive, FALSE if active
  268.      * @see     getAge, getInactive, getStatus, DpLiving::getSessionAge()
  269.      */
  270.     function isInactive()
  271.     {
  272.         $inactive_time time((!isset($this->lastActionTime)
  273.             ? $this->creationTime $this->lastActionTime);
  274.  
  275.         return $inactive_time >= 300;
  276.     }
  277.  
  278.     /**
  279.      * Gets a descriptive user status string
  280.      *
  281.      * If the user has a special status like inactive, returns a string like
  282.      * "away", to use in user titles and such. If there is no special status,
  283.      * returns an empty string.
  284.      *
  285.      * @return  string  status description
  286.      * @see     getAge, getInactive, isInactive, DpLiving::getSessionAge()
  287.      */
  288.     function getStatus()
  289.     {
  290.         if ($this->isInactive{
  291.             return dp_text('away');
  292.         }
  293.  
  294.         return FALSE;
  295.     }
  296.  
  297.     /**
  298.      * Calls itself every "heartbeat"
  299.      *
  300.      * Redefine this method to make timed stuff happen.
  301.      */
  302.     function timeoutHeartBeat()
  303.     {
  304.         DpLiving::timeoutHeartBeat();
  305.  
  306.         if ($this->status === $this->mLastStatus{
  307.             return;
  308.         }
  309.  
  310.         $this->mLastStatus $this->status;
  311.  
  312.         $this->tell(array('abstract' => '<changeDpElement id="'
  313.             . $this->getUniqueId('"><b>'
  314.             . $this->getAppearance(1FALSE'</b></changeDpElement>',
  315.             'graphical' => '<changeDpElement id="'
  316.             . $this->getUniqueId('"><b>'
  317.             . $this->getAppearance(1FALSE$this'graphical')
  318.             . '</b></changeDpElement>'));
  319.         $this->getEnvironment()->tell(array(
  320.             'abstract' => '<changeDpElement id="' $this->getUniqueId('">'
  321.             . $this->getAppearance(1FALSE'</changeDpElement>',
  322.             'graphical' => '<changeDpElement id="'
  323.             . $this->getUniqueId('">'
  324.             . $this->getAppearance(1FALSE$this'graphical')
  325.             . '</changeDpElement>')$this);
  326.     }
  327.  
  328.     /**
  329.      * Sets various PHP global variables passed on from the DutchPIPE server
  330.      *
  331.      * Called each time a user's browser does a normal page or AJAX request.
  332.      * Several variables are passed which represent their corresponding PHP
  333.      * global arrays: $_SERVER, $_COOKIE, etc.
  334.      *
  335.      * @param   array   &$rServerVars  User server variables
  336.      * @param   array   &$rSessionVars User session variables
  337.      * @param   array   &$rCookieVars  User cookie variables
  338.      * @param   array   &$rGetVars     User get variables
  339.      * @param   array   &$rPostVars    User post variables
  340.      * @param   array   &$rFilesVars   User files variables
  341.      */
  342.     function setVars(&$rServerVars&$rSessionVars&$rCookieVars&$rGetVars,
  343.             &$rPostVars&$rFilesVars)
  344.     {
  345.         $this->_SERVER = $rServerVars;
  346.         $this->_SESSION = $rSessionVars;
  347.         $this->_COOKIE = $rCookieVars;
  348.         $this->_GET = $rGetVars;
  349.         $this->_POST = $rPostVars;
  350.         $this->_FILES = $rFilesVars;
  351.     }
  352.  
  353.     /**
  354.      * Sends something to dpclient-js.php running on the user's browser
  355.      *
  356.      * Sends the given data to the user's browser. It's up the user's DutchPIPE
  357.      * Javascript client, dpclient-js.php by default, what to do with the
  358.      * received content. dpclient-js.php can be send data like
  359.      * '<message>hello world</message>' and '<window>hello world</window>',
  360.      * to show something in the message area and pop up a window respectively.
  361.      *
  362.      * Can be binded to an environment. This is useful for locations producing
  363.      * messages: the user could be moving to another location before the client
  364.      * catches the new message with AJAX, in which case the user should not get
  365.      * the message.
  366.      *
  367.      * @param      string    $data         message string
  368.      * @param      object    &$binded_env  optional binded environment
  369.      */
  370.     function tell($data&$binded_env NULL)
  371.     {
  372.         if ((FALSE === is_string($data|| === dp_strlen($data)) &&
  373.                 (FALSE === is_array($data)) || === count($data)) {
  374.             return;
  375.         }
  376.  
  377.         if (FALSE === is_null($binded_env)
  378.                 && (FALSE === ($env $this->getEnvironment())
  379.                 || $env !== $binded_env)) {
  380.             echo dp_text("Message skipped, no longer in page\n");
  381.             return;
  382.         }
  383.  
  384.         // If this user is the same user doing the current HTTP request, tell
  385.         // straight away. Otherwise, store the message for the next time we get
  386.         // a HTTP request from the user.
  387.         if (TRUE === get_current_dpuniverse()->isNoDirectTell()
  388.                 || $this !== get_current_dpuser()) {
  389.             //echo sprintf(dp_text("Storing %s: %s\n"), $this->title,
  390.             //    (dp_strlen($data) > 512 ? dp_substr($data, 0, 512) : $data));
  391.             get_current_dpuniverse()->storeTell($this$data$binded_env);
  392.             return;
  393.         }
  394.         if (is_array($data)) {
  395.             $data $data[$this->displayMode];
  396.         }
  397.  
  398.         // Gets the message type from $data which holds a string with the format
  399.         // <type>tellstuff</type>. If no type was given in the $data string, we
  400.         // consider it type 'message':
  401.         list($mtype_start$data$mtype_end$this->_tellParseTag($data);
  402.  
  403.         $this->_tellDoTell($mtype_start$data$mtype_end);
  404.     }
  405.  
  406.     private function _tellParseTag($data)
  407.     {
  408.          if (dp_strlen($data>=&& dp_substr($data01== '<'
  409.                 && FALSE !== ($pos dp_strpos($data'>'))) {
  410.             $mtype_start dp_substr($data1$pos 1);
  411.             $endpos dp_strrpos($data'<');
  412.             $mtype_end dp_substr($data$endpos 2-1);
  413.  
  414.             $data "<![CDATA[" dp_substr($datadp_strlen($mtype_start2,
  415.                 $endpos dp_strlen($mtype_start2']]>';
  416.         else {
  417.             $mtype_start $mtype_end 'message';
  418.             $data "<![CDATA[$data]]>";
  419.         }
  420.  
  421.         return array($mtype_start$data$mtype_end);
  422.     }
  423.  
  424.     private function _tellDoTell($mtype_start$data$mtype_end)
  425.     {
  426.         $universe get_current_dpuniverse();
  427.  
  428.         if (isset($this->_GET['ajax'])) {
  429.             if ($mtype_end === 'message' && $data === '<![CDATA[empty]]>'{
  430.                 $mtype_start $mtype_end '';
  431.                 $data '1';
  432.             }
  433.         }
  434.         if ($data !== '1' || !$universe->isToldSomething()) {
  435.             if ($mtype_start !== ''{
  436.                 $data "<$mtype_start>$data</$mtype_end>";
  437.             }
  438.             /*
  439.             if ($data !== '1') {
  440.                 echo sprintf(dp_text("Telling %s: %s\n"), $this->title,
  441.                     (dp_strlen($data) > 236 ? dp_substr($data, 0, 236)
  442.                     : $data));
  443.             }
  444.             */
  445.             if ($mtype_end === '' || $mtype_end === 'header'
  446.                     || $mtype_end === 'cookie' || $mtype_end === 'location'{
  447.                 $universe->tellCurrentDpUserRequest($data);
  448.             else {
  449.                 $universe->tellCurrentDpUserRequest('<event count="'
  450.                     . $this->mEventCount++ . '" time="' time('">' $data
  451.                     . '</event>');
  452.             }
  453.         }
  454.     }
  455.  
  456.     /**
  457.      * Reports an event
  458.      *
  459.      * Called when certain events occur, given with $name.
  460.      *
  461.      * @param      object    $name       Name of event
  462.      * @param      mixed     $args       One or more arguments, depends on event
  463.      * @since      DutchPIPE 0.2.0
  464.      */
  465.     function eventDpLiving($name)
  466.     {
  467.         if (EVENT_DESTROYING_OBJ !== $name{
  468.             return;
  469.         }
  470.  
  471.         if (TRUE === $this->isRegistered{
  472.             $result dp_db_query('SELECT userAge FROM Users WHERE '
  473.                 . 'userUsernameLower='
  474.                 . dp_db_quote(dp_strtolower($this->title)'text'));
  475.             $age !$result || !dp_db_num_rows($result0
  476.                 : dp_db_fetch_one($result00);
  477.             dp_db_free($result);
  478.  
  479.             $new_age $age (time($this->creationTime);
  480.             dp_db_exec('UPDATE Users set userAge=' dp_db_quote($new_age)
  481.                 . ' WHERE userUsernameLower='
  482.                 . dp_db_quote(dp_strtolower($this->title)'text'));
  483.         elseif ($this->avatarCustom{
  484.                 . $this->avatarCustom);
  485.         }
  486.  
  487.     }
  488.  
  489.     /**
  490.      * Experimental, ignore.
  491.      *
  492.      * @access     private
  493.      * @since      DutchPIPE 0.2.0
  494.      */
  495.  
  496.     function isDraggable(&$by_who)
  497.     {
  498.         if ($by_who === $this{
  499.             return TRUE;
  500.         }
  501.  
  502.         return DpLiving::isDraggable($by_who);
  503.     }
  504.  
  505.     /**
  506.      * Tries to perform the action given by the user object
  507.      *
  508.      * Handles input area input mode and history. Uses DpLiving::performAction()
  509.      * for the real stuff. See DpLiving::performAction() for more information.
  510.      *
  511.      * @param   string  $action     the action given by the user object
  512.      * @return  boolean TRUE for success, FALSE for unsuccessful action
  513.      * @see     DpLiving::performAction()
  514.      */
  515.     final public function performAction($action)
  516.     {
  517.         $action $orig_action trim($action);
  518.         if (!isset($this->_GET['menuaction']&& 'say' === $this->inputMode
  519.                 && dp_strlen($action)) {
  520.             if (dp_strlen($action&& '/' === dp_substr($action01)) {
  521.                 $action $orig_action dp_substr($action1);
  522.             else {
  523.                 $action sprintf(dp_text('say %s')$action);
  524.             }
  525.         }
  526.         $rval DpLiving::performAction($action);
  527.  
  528.         if ('' !== $action && isset($this->_GET['cmdline'])
  529.              && (!($sz count($this->mActionHistory))
  530.              || $this->mActionHistory[$sz 1!== $action)) {
  531.             $this->mActionHistory[$orig_action;
  532.             if (count($this->mActionHistory20{
  533.                 array_shift($this->mActionHistory);
  534.             }
  535.         }
  536.  
  537.         return $rval;
  538.     }
  539.  
  540.     /**
  541.      * Shows this user a window with help information
  542.      *
  543.      * @param   string  $verb       the action, "help"
  544.      * @param   string  $noun       empty string
  545.      * @return  boolean TRUE
  546.      */
  547.     function actionHelp($verb$noun)
  548.     {
  549.         $tmp dp_file_get_contents(DPUNIVERSE_STD_PATH
  550.             . ('say' === $this->inputMode 'help.html' 'commands.html'));
  551.  
  552.         $this->tell("<window><div id=\"helptext\">" $tmp
  553.             . "<br clear=\"all\" /></div></window>");
  554.         return TRUE;
  555.     }
  556.  
  557.     /**
  558.      * Shows this user source code of environment or of another object
  559.      *
  560.      * @param   string  $verb       the action, "source"
  561.      * @param   string  $noun       what to show source of, could be empty
  562.      * @return  boolean TRUE for action completed, FALSE otherwise
  563.      */
  564.     function actionSource($verb$noun)
  565.     {
  566.         if (!dp_strlen($noun)) {
  567.             $what $this->getEnvironment();
  568.         else {
  569.             if (FALSE === ($what $this->isPresent($noun))
  570.                     && FALSE === ($what =
  571.                     $this->getEnvironment()->isPresent($noun))) {
  572.                 $this->tell(sprintf(dp_text("Can't find: %s<br />")$noun));
  573.                 return TRUE;
  574.             }
  575.         }
  576.  
  577.         if (FALSE === ($what $this->getEnvironment())) {
  578.             return FALSE;
  579.         }
  580.         /* Without the \n and &nbsp; to &#160 conversion, highlight_file gave
  581.          invalid XHTML */
  582.         $this->tell("<window styleclass=\"dpwindow_src\">\n"
  583.             . str_replace('&nbsp;''&#160;'@highlight_file(DPUNIVERSE_PATH
  584.             . $what->locationTRUE"\n</window>"));
  585.         return TRUE;
  586.     }
  587.  
  588.     /**
  589.      * Shows this living a list of links in its environment or in another object
  590.      *
  591.      * @param   string  $verb       the action, "links"
  592.      * @param   string  $noun       what to take, could be empty
  593.      * @return  boolean TRUE for action completed, FALSE otherwise
  594.      */
  595.     function actionLinks($verb$noun)
  596.     {
  597.         if (!dp_strlen($noun)) {
  598.             $what $this->getEnvironment();
  599.         else {
  600.             if (FALSE === ($what $this->isPresent($noun))
  601.                     && FALSE === ($what =
  602.                     $this->getEnvironment()->isPresent($noun))) {
  603.                 $this->tell(sprintf(dp_text("Can't find: %s<br />")$noun));
  604.                 return TRUE;
  605.             }
  606.         }
  607.  
  608.         if (FALSE === method_exists($what'getExits')
  609.                 || === count($links $what->getExits())) {
  610.             $tell '<b>' sprintf(dp_text('No links found in %s'),
  611.                 $what->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))
  612.                 . '</b><br />';
  613.         else {
  614.             $tell '<b>' sprintf(dp_text('Links found in: %s'),
  615.                 $what->title'</b><br /><br />';
  616.             foreach ($links as $linktitle => $linkdata{
  617.                 if ($linktitle === DPUNIVERSE_NAVLOGO{
  618.                     $linkcommand dp_text('home');
  619.                 else {
  620.                     $linkcommand explode(' '$linktitle);
  621.                     $linkcommand dp_strtolower($linktitle);
  622.                 }
  623.                 $tell .= "<a href=\"" DPSERVER_CLIENT_URL
  624.                 . "?location={$linkdata[0]}\">$linkcommand</a><br />";
  625.             }
  626.         }
  627.         $this->tell('<window>' $tell '</window>');
  628.         return TRUE;
  629.     }
  630.  
  631.     /**
  632.      * Shows this user a list of users on the site
  633.      *
  634.      * @param   string  $verb       the action, "who"
  635.      * @param   string  $noun       empty string
  636.      * @return  boolean TRUE
  637.      */
  638.     function actionWho($verb$noun)
  639.     {
  640.         $users get_current_dpuniverse()->getUsers();
  641.         if (=== count($users)) {
  642.            $this->tell('<window><b>' dp_text('No one is on this site.')
  643.             . '</b></window>');
  644.             return TRUE;
  645.         }
  646.  
  647.         $tell '<b>' dp_text('People currently on this site:')
  648.             . '</b><br />';
  649.         $tell .= '<table cellpadding="0" cellspacing="0" border="0" style="'
  650.             . 'margin-top: 5px">';
  651.         foreach ($users as &$user{
  652.             $env $user->getEnvironment();
  653.             $loc $env->location;
  654.             if (!== dp_strpos($loc'http://')) {
  655.                 $loc DPSERVER_CLIENT_URL '?location=' $loc;
  656.             }
  657.             $env FALSE === $env '-' '<a href="' $loc '">'
  658.                 . $env->title '</a>';
  659.  
  660.             $status !isset($user->status|| FALSE === $user->status ''
  661.                 : ' (' $user->status ')';
  662.  
  663.             $tell .= '<tr><td>' $user->title $status
  664.                 . '</td><td style="padding-left: 10px">' $env '</td></tr>';
  665.         }
  666.         $tell .= '</table>';
  667.         $this->tell("<window>$tell</window>");
  668.         return TRUE;
  669.     }
  670.  
  671.     /**
  672.      * Shows this user a window with avatar settings
  673.      *
  674.      * @param   string  $verb       the action, "avatar"
  675.      * @param   string  $noun       empty string
  676.      * @return  boolean TRUE for action completed, FALSE otherwise
  677.      * @see     setAvatar, setBrowseAvatarCustom, uploadAvatarCustom,
  678.      *           removeAvatarCustom
  679.      * @since   DutchPIPE 0.4.1
  680.      */
  681.     function actionAvatar($verb$noun)
  682.     {
  683.         if (DPUNIVERSE_AVATAR_CUSTOM_ENABLED && function_exists('gd_info')) {
  684.             $this->tell('<script src="' DPUNIVERSE_WWW_URL
  685.                 . 'ajaxfileupload.js">&nbsp;</script>');
  686.         }
  687.         $this->tell('<script>' (!DPUNIVERSE_AVATAR_CUSTOM_ENABLED
  688.             || !function_exists('gd_info''' '
  689. function set_browse_avatar_custom()
  690. {
  691.     jQuery.ajax({
  692.         url: "' DPSERVER_CLIENT_URL '",
  693.         data: "location="+encodeURIComponent(\''
  694.             . $this->getEnvironment()->location
  695.             . '\')+"&rand="+Math.round(Math.random()*9999)
  696.             + "&call_object="+encodeURIComponent("' $this->getUniqueId('")
  697.             + "&method=setBrowseAvatarCustom",
  698.         success: handle_response
  699.     });
  700.  
  701.     return false;
  702. }
  703. function upload_avatar_custom()
  704. {
  705.     jQuery("#dpuploading").show();
  706.     jQuery.ajaxFileUpload
  707.     (
  708.         {
  709.             url: "' DPSERVER_CLIENT_URL '?location="+encodeURIComponent(\''
  710.                 . $this->getEnvironment()->location
  711.                 . '\')+"&rand="+Math.round(Math.random()*9999)
  712.                 + "&call_object="+encodeURIComponent("' $this->getUniqueId()
  713.                 . '") + "&method=uploadAvatarCustom"
  714.                 + "&ie6="+(jQuery.browser.msie
  715.                 && 6 == parseInt(jQuery.browser.version) ? "yes" : "no"),
  716.             secureuri: false,
  717.             fileElementId: "dpuploadimg",
  718.             dataType: "xml",
  719.             timeout: 10000,
  720.             success: function(resp) { handle_response(resp); },
  721.             error: function (data, status, e) { jQuery("#dpuploading").hide(); }
  722.         }
  723.     )
  724.  
  725.     return false;
  726. }
  727. function remove_avatar_custom()
  728. {
  729.     jQuery.ajax({
  730.         url: "' DPSERVER_CLIENT_URL '",
  731.         data: "location="+encodeURIComponent(\''
  732.             . $this->getEnvironment()->location
  733.             . '\')+"&rand="+Math.round(Math.random()*9999)
  734.             + "&call_object="+encodeURIComponent("' $this->getUniqueId('")
  735.             + "&method=removeAvatarCustom",
  736.         success: handle_response
  737.     });
  738.  
  739.     return false;
  740. }
  741. ''
  742. function set_avatar(avatar_nr)
  743. {
  744.     jQuery.ajax({
  745.         url: "' DPSERVER_CLIENT_URL '",
  746.         data: "location="+encodeURIComponent(\''
  747.             . $this->getEnvironment()->location
  748.             . '\')+"&rand="+Math.round(Math.random()*9999)
  749.             + "&call_object="+encodeURIComponent("' $this->getUniqueId('")
  750.             + "&method=setAvatar"
  751.             + "&avatar_nr="+avatar_nr,
  752.         success: handle_response
  753.     });
  754.  
  755.     return false;
  756. }
  757. </script>');
  758.         $nr_of_avatars get_current_dpuniverse()->getNrOfAvatars();
  759.         $cur_avatar_nr = (int)$this->avatarNr;
  760.  
  761.         $avatar_settings =
  762.             '<table cellpadding="0" cellspacing="0" border="0"><tr>';
  763.  
  764.         $i DPUNIVERSE_AVATAR_CUSTOM_ENABLED && function_exists('gd_info'&&
  765.             $this->avatarCustom 1;
  766.         for ($done 0$i <= $nr_of_avatars$i++{
  767.             $done++;
  768.             $avatar_settings .= '<td align="center" valign="bottom" '
  769.                 . 'style="text-align: center">'
  770.                 . $this->_getAvatarSettingsHtml($i'</td>';
  771.             if ($done == 0{
  772.                 $avatar_settings .= '</tr>';
  773.                 if ($i $nr_of_avatars{
  774.                     $avatar_settings .= '<tr>';
  775.                 }
  776.             }
  777.         }
  778.         $avatar_settings .= '</tr></table>';
  779.         $this->tell('<window>'
  780.             . ('http://dutchpipe.org' !== DPSERVER_HOST_URL
  781.             && 'http://dev.dutchpipe.org' !== DPSERVER_HOST_URL
  782.             ? dp_text('Choose your avatar:')
  783.             : dp_text('Choose your avatar (kindly provided by <a href="http://www.messdudes.com/" target="_blank">Mess Dudes</a>):'))
  784.             . '<br />
  785. <div style="width: 100%; height: 170px; overflow: auto; margin-top: 7px">'
  786.             . $avatar_settings '</div>' (!DPUNIVERSE_AVATAR_CUSTOM_ENABLED
  787.             || !function_exists('gd_info'''
  788.             : '<p style="margin-top: 15px; margin-bottom: 5px">'
  789.             . dp_text('Upload your own avatar:''</p>
  790. <form id="dpupload" action="" method="POST" enctype="multipart/form-data"
  791. style="display: block; margin: 0">
  792. <div style="float: left; height: 28px"><input id="dpuploadimg" type="file"
  793. name="dpuploadimg" class="dpupload_button"
  794. onmousedown="return set_browse_avatar_custom()" />&nbsp;<button
  795. id="buttonUpload" onclick="return upload_avatar_custom()"
  796. class="dpupload_button">' dp_text('Upload''</button>'
  797.             . (!$this->avatarCustom '' '&nbsp;<button id="buttonUpload"
  798. onclick="return remove_avatar_custom()"
  799. class="dpupload_button">' dp_text('Delete''</button>')
  800.             . '</div><img id="dpuploading" src="' DPUNIVERSE_IMAGE_URL
  801.             . 'loading.gif" style="float: left; position: relative; top: -5px;
  802. left: 5px; display: none">
  803. </form><div id="dpupload_msg" style="display: none; margin: 0"></div>')
  804. '</window>');
  805.  
  806.         return TRUE;
  807.     }
  808.  
  809.     /**
  810.      * Gets the HTML for a single avatar in the avatar configuration window
  811.      *
  812.      * @param   int     $avatarNr     default avatar number, 0 for custom avatar
  813.      * @return  string  HTML for the given avatar
  814.      * @access  private
  815.      * @see     actionAvatar
  816.      * @since   DutchPIPE 0.4.1
  817.      */
  818.     private function _getAvatarSettingsHtml($avatarNr)
  819.     {
  820.         $alt dp_text('Click to select');
  821.         $img_src $avatarNr DPUNIVERSE_AVATAR_STD_URL 'user'
  822.             . $avatarNr '.gif' (!$this->isRegistered
  823.             ? DPUNIVERSE_AVATAR_CUSTOM_GUEST_URL
  824.             : DPUNIVERSE_AVATAR_CUSTOM_REG_URL$this->avatarCustom;
  825.         $margin '20px';
  826.  
  827.         return '<img src="' $img_src '" '
  828.             . 'border="0" class="dpimage" alt="' $alt '" title="' $alt
  829.             . '" style="margin-bottom: 12px; margin-left: ' $margin
  830.             . '; margin-right: ' $margin '" onClick="set_avatar('
  831.             . $avatarNr ')"  />';
  832.     }
  833.  
  834.     /**
  835.      * Switches to another avatar when clicking on one using actionAvatar()
  836.      *
  837.      * Sets the avatarNr property to the given stock avatar number, or to 0 in
  838.      * case a custom avatar is used. Updates database for registered users.
  839.      * Sends messages.
  840.      *
  841.      * @see     actionAvatar, uploadAvatarCustom, removeAvatarCustom
  842.      * @since   DutchPIPE 0.4.1
  843.      */
  844.     function setAvatar()
  845.     {
  846.         if (!isset($this->_GET['avatar_nr']|| === dp_strlen($avatar_nr
  847.                 = $this->_GET['avatar_nr'])) {
  848.             $this->tell(dp_text('Error receiving settings.<br />'));
  849.         }
  850.  
  851.         $this->avatarNr $avatar_nr;
  852.         $this->titleImg $avatar_nr DPUNIVERSE_AVATAR_STD_URL 'user'
  853.             . $avatar_nr '.gif' (!$this->isRegistered
  854.             ? DPUNIVERSE_AVATAR_CUSTOM_GUEST_URL
  855.             : DPUNIVERSE_AVATAR_CUSTOM_REG_URL$this->avatarCustom;
  856.  
  857.         // TODO: Should get real width/height for non GD users:
  858.         $this->titleImgWidth NULL;
  859.         $this->titleImgHeight NULL;
  860.  
  861.         $this->body '<img src="' ($avatar_nr DPUNIVERSE_AVATAR_STD_URL
  862.             . 'user' $avatar_nr '_body.gif' (!$this->isRegistered
  863.             ? DPUNIVERSE_AVATAR_CUSTOM_GUEST_URL
  864.             : DPUNIVERSE_AVATAR_CUSTOM_REG_URL$this->avatarCustom)
  865.             . '" border="0" alt="" align="left" style="margin-right: 15px" />'
  866.             . dp_text('A user.''<br />';
  867.  
  868.         if ($this->isRegistered{
  869.             dp_db_exec('UPDATE Users set '
  870.                 . 'userAvatarNr=' dp_db_quote($avatar_nr'integer')
  871.                 . ' WHERE userUsernameLower='
  872.                 . dp_db_quote(dp_strtolower($this->title)'text'));
  873.         }
  874.  
  875.         if (FALSE !== ($body $this->getEnvironment()->
  876.                 getAppearanceInventory(0TRUENULL$this->displayMode))) {
  877.             $this->tell($body);
  878.         }
  879.         $this->getEnvironment()->tell(array(
  880.             'abstract' =>
  881.                 '<changeDpElement id="' $this->getUniqueId('">'
  882.                 . $this->getAppearance(1FALSE'</changeDpElement>',
  883.             'graphical' =>
  884.                 '<changeDpElement id="' $this->getUniqueId('">'
  885.                 . $this->getAppearance(1FALSE$this'graphical')
  886.                 . '</changeDpElement>'
  887.             )$this);
  888.     }
  889.  
  890.     /**
  891.      * Sets this user as busy browing for a file
  892.      *
  893.      * Sets the browseAvatarCustom property to TRUE, or unsets it otherwise.
  894.      * Called from the JavaScript client when the user clicks on "Browse..." to
  895.      * look for a file to upload. This causes browsers to halt execution of
  896.      * scripts while the file dialog is visible. DpCurrentRequest uses this
  897.      * property to users are not thrown out while browsing for a file.
  898.      *
  899.      * @param   boolean $browseAvatarCustom TRUE to start browsing, FALSE to end
  900.      * @see     actionAvatar, uploadAvatarCustom
  901.      * @since   DutchPIPE 0.4.1
  902.      */
  903.     function setBrowseAvatarCustom($browseAvatarCustom TRUE)
  904.     {
  905.         echo "setBrowseAvatarCustom($browseAvatarCustom) called\n";
  906.         if (!DPUNIVERSE_AVATAR_CUSTOM_ENABLED || !function_exists('gd_info')) {
  907.             return;
  908.         }
  909.  
  910.         if (TRUE !== $browseAvatarCustom{
  911.             if (isset($this->browseAvatarCustom)) {
  912.                 unset($this->browseAvatarCustom);
  913.             }
  914.         else {
  915.             if (!isset($this->browseAvatarCustom)) {
  916.                 $this->browseAvatarCustom new_dp_property();
  917.             }
  918.             $this->setDpProperty('browseAvatarCustom'$browseAvatarCustom);
  919.         }
  920.         echo "browseAvatarCustom: $this->browseAvatarCustom\n";
  921.     }
  922.  
  923.     /**
  924.      * Attempts to upload a file to be used as our avatar image
  925.      *
  926.      * @see     actionAvatar, setBrowseAvatarCustom, removeAvatarCustom
  927.      * @since   DutchPIPE 0.4.1
  928.      */
  929.     function uploadAvatarCustom()
  930.     {
  931.         if (!DPUNIVERSE_AVATAR_CUSTOM_ENABLED || !function_exists('gd_info')) {
  932.             return;
  933.         }
  934.  
  935.         $prevAvatar $this->avatarCustom;
  936.         $msg $err FALSE;
  937.  
  938.         // Check if there are files uploaded
  939.         if (!isset($this->_FILES['dpuploadimg'])
  940.                 || !empty($this->_FILES['dpuploadimg']['error'])
  941.                 || empty($this->_FILES['dpuploadimg']['tmp_name'])) {
  942.             $msg empty($this->_FILES['dpuploadimg']['error'])
  943.                 ?  dp_text('Failed to upload image.')
  944.                 : (empty($this->_FILES['dpuploadimg']['tmp_name'])
  945.                 ? dp_text('No image was given to upload.')
  946.                 : $this->_FILES['dpuploadimg']['error']);
  947.             $err TRUE;
  948.         elseif ($this->_FILES['dpuploadimg']['size']
  949.                 > DPSERVER_OBJECT_IMAGE_CUSTOM_MAX_SIZE{
  950.             $msg sprintf(dp_text('The image was too large. The maximum file size is %d kilobytes.'),
  951.                 floor(DPSERVER_OBJECT_IMAGE_CUSTOM_MAX_SIZE 1024));
  952.             $err TRUE;
  953.         else {
  954.             $name $this->_FILES['dpuploadimg']['name'];
  955.             $pos dp_strrpos($name'.');
  956.             if (FALSE !== $pos && $pos dp_strlen($name1{
  957.                 $type dp_strtolower(dp_substr($name$pos 1));
  958.             }
  959.  
  960.             // Make a unique filename for the avatar
  961.             $attempts 5;
  962.             while ($attempts--{
  963.                 $new_fn make_random_id(36);
  964.                 $new_fn dp_substr($new_fnmt_rand(0dp_strlen($new_fn6),
  965.                     5'.' $type;
  966.                 $new_path (!$this->isRegistered
  967.                     ? DPUNIVERSE_AVATAR_CUSTOM_GUEST_PATH
  968.                     : DPUNIVERSE_AVATAR_CUSTOM_REG_PATH$new_fn;
  969.                 if (!file_exists($new_path)) {
  970.                     break;
  971.                 }
  972.                 if (!$attempts{
  973.                     $msg dp_text('Failed to upload image.');
  974.                     $err TRUE;
  975.                 }
  976.             }
  977.  
  978.             $tmp_name $this->_FILES['dpuploadimg']['tmp_name'];
  979.  
  980.             if (TRUE !== ($rval dp_upload_image($this$tmp_name,
  981.                     $new_path))) {
  982.                 $msg $rval;
  983.                 $err TRUE;
  984.             else {
  985.                 //$msg = "<p style=\"margin-bottom: 10px\">File Name: {$name}, "
  986.                 //    . " File Size: " . @filesize($tmp_name) . '</p>';
  987.  
  988.                 dp_db_exec('UPDATE Users set '
  989.                     . 'userAvatarCustom=' dp_db_quote($new_fn'text')
  990.                     . ',userAvatarNr=' dp_db_quote(0'integer')
  991.                     . ' WHERE userUsernameLower='
  992.                     . dp_db_quote(dp_strtolower($this->title)'text'));
  993.  
  994.                 if ($this->avatarCustom{
  995.                     unlink((!$this->isRegistered
  996.                         ? DPUNIVERSE_AVATAR_CUSTOM_GUEST_PATH
  997.                         : DPUNIVERSE_AVATAR_CUSTOM_REG_PATH)
  998.                         . $this->avatarCustom);
  999.                 }
  1000.  
  1001.                 $this->avatarCustom $new_fn;
  1002.                 $this->avatarNr 0;
  1003.                 $this->titleImg (!$this->isRegistered
  1004.                     ? DPUNIVERSE_AVATAR_CUSTOM_GUEST_URL
  1005.                     : DPUNIVERSE_AVATAR_CUSTOM_REG_URL$new_fn;
  1006.                 $this->body '<img src="' (!$this->isRegistered
  1007.                     ? DPUNIVERSE_AVATAR_CUSTOM_GUEST_URL
  1008.                     : DPUNIVERSE_AVATAR_CUSTOM_REG_URL$new_fn
  1009.                     . '" border="0" alt="" align="left" '
  1010.                     . 'style="margin-right: 15px" />'
  1011.                     . dp_text('A user.''<br />';
  1012.             }
  1013.         }
  1014.  
  1015.         if (FALSE !== $msg{
  1016.             if (TRUE === $err{
  1017.                 $msg sprintf(
  1018.                     dp_text('Error: %s<br />'),
  1019.                     $msg);
  1020.             }
  1021.             $msg '<br clear="all" />' $msg;
  1022.         }
  1023.  
  1024.         /* In uploadAvatarCustomMessages messagea are sent to the user in XML
  1025.          * format. These are retreived in the target iframe the AJAX form posts
  1026.          * to. Internet Explorer 6 can't handle XML documents, and a small delay
  1027.          * is needed so the messages are retreived by dpclient-js.php using AJAX
  1028.          * instead, where Internet Explorer 6 can handle the XML.
  1029.          *
  1030.          */
  1031.  
  1032.         if (isset($this->_GET['ie6']&& 'yes' === $this->_GET['ie6']{
  1033.             $this->setTimeout('_uploadAvatarCustomMessages'1$msg$err);
  1034.         else {
  1035.             $this->_uploadAvatarCustomMessages($msg$err);
  1036.         }
  1037.     }
  1038.  
  1039.     /**
  1040.      * Finishes uploading, removes loading indicator, sends messages
  1041.      *
  1042.      * @param   mixed   $msg  message string, FALSE for no message (the default)
  1043.      * @param   boolean $err  TRUE for upload error, else FALSE (the default)
  1044.      * @access  private
  1045.      * @see     actionAvatar, setBrowseAvatarCustom, uploadAvatarCustom,
  1046.      *           removeAvatarCustom
  1047.      * @since   DutchPIPE 0.4.1
  1048.      */
  1049.     function _uploadAvatarCustomMessages($msg FALSE$err FALSE)
  1050.     {
  1051.         $this->tell('<script>jQuery("#dpuploading").hide();</script>');
  1052.         if (!$err{
  1053.             if (FALSE === ($body $this->getEnvironment()->
  1054.                     getAppearanceInventory(0TRUE$this,
  1055.                     $this->displayMode))) {
  1056.                 $body '';
  1057.             }
  1058.             $this->tell($body);
  1059.             $this->getEnvironment()->tell(array('abstract' =>
  1060.                 '<changeDpElement id="'
  1061.                 . $this->getUniqueId('">'
  1062.                 . $this->getAppearance(1FALSE'</changeDpElement>',
  1063.                 'graphical' => '<changeDpElement id="'
  1064.                 . $this->getUniqueId('">'
  1065.                 . $this->getAppearance(1FALSE$this'graphical')
  1066.                 . '</changeDpElement>')$this);
  1067.             $this->performAction(('say' === $this->inputMode '/' '')
  1068.                 . dp_text('avatar'));
  1069.         }
  1070.         if ($msg && dp_strlen($msg)) {
  1071.             $this->tell('<div id="dpupload_msg">' $msg '</div>');
  1072.         }
  1073.     }
  1074.  
  1075.     /**
  1076.      * Removes the custom avatar
  1077.      *
  1078.      * @access  private
  1079.      * @see     actionAvatar, uploadAvatarCustom
  1080.      * @since   DutchPIPE 0.4.1
  1081.      */
  1082.     function removeAvatarCustom()
  1083.     {
  1084.         $avatar_nr $this->avatarNr 1;
  1085.         $this->avatarCustom FALSE;
  1086.         $this->titleImg DPUNIVERSE_AVATAR_STD_URL 'user' $avatar_nr
  1087.             . '.gif';
  1088.  
  1089.         $this->titleImgWidth $this->titleImgHeight NULL;
  1090.  
  1091.         $this->body '<img src="' DPUNIVERSE_AVATAR_STD_URL 'user'
  1092.             . $avatar_nr '_body.gif" border="0" alt="" align="left" '
  1093.             . 'style="margin-right: 15px" />' dp_text('A user.''<br />';
  1094.  
  1095.         if ($this->isRegistered{
  1096.             dp_db_exec('UPDATE Users set '
  1097.                 . 'userAvatarNr=' dp_db_quote($avatar_nr'integer')
  1098.                 . ',userAvatarCustom = NULL'
  1099.                 . ' WHERE userUsernameLower='
  1100.                 . dp_db_quote(dp_strtolower($this->title)'text'));
  1101.         }
  1102.  
  1103.         if (FALSE !== ($body $this->getEnvironment()->
  1104.                 getAppearanceInventory(0TRUENULL$this->displayMode))) {
  1105.             $this->tell($body);
  1106.         }
  1107.         $this->getEnvironment()->tell(array(
  1108.             'abstract' => '<changeDpElement id="' $this->getUniqueId('">'
  1109.                 . $this->getAppearance(1FALSE'</changeDpElement>',
  1110.             'graphical' => '<changeDpElement id="'
  1111.                 . $this->getUniqueId('">'
  1112.                 . $this->getAppearance(1FALSE$this'graphical')
  1113.                 . '</changeDpElement>'
  1114.             )$this);
  1115.         $this->performAction(('say' === $this->inputMode '/' '')
  1116.             . dp_text('avatar'));
  1117.     }
  1118.  
  1119.     /**
  1120.      * Shows this user a window with settings
  1121.      *
  1122.      * @param   string  $verb       the action, "settings"
  1123.      * @param   string  $noun       empty string
  1124.      * @return  boolean TRUE for action completed, FALSE otherwise
  1125.      * @see     setSettings
  1126.      */
  1127.     function actionSettings($verb$noun)
  1128.     {
  1129.         $this->tell('<script>
  1130. function send_settings(avatar_nr)
  1131. {
  1132.     jQuery.ajax({
  1133.         url: "' DPSERVER_CLIENT_URL '",
  1134.         data: "location='
  1135.             . $this->getEnvironment()->location
  1136.             . '&rand="+Math.round(Math.random()*9999)
  1137.             + "&call_object="+encodeURIComponent("' $this->getUniqueId('")
  1138.             + "&method=setSettings"
  1139.             + "&display_mode="+(_gel("display_mode1").checked
  1140.                 ? _gel("display_mode1").value : _gel("display_mode2").value)
  1141.             + "&people_entering="+(_gel("people_entering").checked ? "1" : "0")
  1142.             + "&people_leaving="+(_gel("people_leaving").checked ? "1" : "0")
  1143.             + "&bots_entering="+(_gel("bots_entering").checked ? "1" : "0"),
  1144.         success: handle_response
  1145.     });
  1146.  
  1147.     return false;
  1148. }
  1149. </script>');
  1150.         $this->tell('<window>'
  1151. dp_text('People and items on the page are displayed in:''<br />
  1152. <input type="radio" id="display_mode1" name="display_mode" value="graphical"' ($this->displayMode == 'graphical' ' checked="checked"' ''' onClick="send_settings()" style="cursor: pointer" />' dp_text('Graphical mode''<br />
  1153. <input type="radio" id="display_mode2" name="display_mode" value="abstract"' ($this->displayMode == 'abstract' ' checked="checked"' ''' onClick="send_settings()" style="cursor: pointer" />' dp_text('Abstract mode''<br /><br />'
  1154. dp_text('Alert me of the following events:''<br />
  1155. <input type="checkbox" id="people_entering" name="people_entering" value="1"' (isset($this->mAlertEvents['people_entering']' checked="checked"' ''' onClick="send_settings()" style="cursor: pointer" />' dp_text('People entering this site''<br />
  1156. <input type="checkbox" id="people_leaving" name="people_leaving" value="1"' (isset($this->mAlertEvents['people_leaving']' checked="checked"' ''' onClick="send_settings()" style="cursor: pointer" />' dp_text('People leaving this site''<br />
  1157. <input type="checkbox" id="bots_entering" name="bots_entering" value="1"' (isset($this->mAlertEvents['bots_entering']?  ' checked="checked"' ''' onClick="send_settings()" style="cursor: pointer" />' dp_text('Search engines indexing pages''<br />
  1158. </window>');
  1159.  
  1160.         return TRUE;
  1161.     }
  1162.  
  1163.     /**
  1164.      * Applies settings from the settings menu obtained with actionSettings()
  1165.      *
  1166.      * Called from the Javascript that goes with the menu that pops up after the
  1167.      * settings action has been performed. Applies avatar and dispay mode
  1168.      * settings, based on the DpUser::_GET variable in this user.
  1169.      *
  1170.      * @see     actionSettings
  1171.      */
  1172.     function setSettings()
  1173.     {
  1174.         if (!isset($this->_GET['display_mode'])
  1175.                 || === dp_strlen($display_mode
  1176.                 = $this->_GET['display_mode'])) {
  1177.             $this->tell(dp_text('Error receiving settings.<br />'));
  1178.         }
  1179.  
  1180.         $this->displayMode $display_mode;
  1181.  
  1182.         if (isset($this->_GET['people_entering']&& $this->_GET['people_entering'== '1'{
  1183.             $this->mAlertEvents['people_entering'TRUE;
  1184.             get_current_dpuniverse()->addAlertEvent('people_entering'$this);
  1185.         elseif (isset($this->mAlertEvents['people_entering'])) {
  1186.             unset($this->mAlertEvents['people_entering']);
  1187.             get_current_dpuniverse()->removeAlertEvent('people_entering'$this);
  1188.         }
  1189.  
  1190.         if (isset($this->_GET['people_leaving']&& $this->_GET['people_leaving'== '1'{
  1191.             $this->mAlertEvents['people_leaving'TRUE;
  1192.             get_current_dpuniverse()->addAlertEvent('people_leaving'$this);
  1193.         elseif (isset($this->mAlertEvents['people_leaving'])) {
  1194.             unset($this->mAlertEvents['people_leaving']);
  1195.             get_current_dpuniverse()->removeAlertEvent('people_leaving'$this);
  1196.         }
  1197.  
  1198.         if (isset($this->_GET['bots_entering']&& $this->_GET['bots_entering'== '1'{
  1199.             $this->mAlertEvents['bots_entering'TRUE;
  1200.             get_current_dpuniverse()->addAlertEvent('bots_entering'$this);
  1201.         elseif (isset($this->mAlertEvents['bots_entering'])) {
  1202.             unset($this->mAlertEvents['bots_entering']);
  1203.             get_current_dpuniverse()->removeAlertEvent('bots_entering'$this);
  1204.         }
  1205.  
  1206.         if ($this->isRegistered{
  1207.             dp_db_exec('UPDATE Users set '
  1208.                 . 'userDisplayMode=' dp_db_quote($display_mode'text')
  1209.                 . ',userEventPeopleEntering='
  1210.                 . dp_db_quote((!isset($this->mAlertEvents['people_entering'])
  1211.                 ? '0' '1')'text')
  1212.                 . ',userEventPeopleLeaving='
  1213.                 . dp_db_quote((!isset($this->mAlertEvents['people_leaving'])
  1214.                 ? '0' '1')'text')
  1215.                 . ',userEventBotsEntering='
  1216.                 . dp_db_quote((!isset($this->mAlertEvents['bots_entering'])
  1217.                 ? '0' '1')'text')
  1218.                 . ' WHERE userUsernameLower='
  1219.                 . dp_db_quote(dp_strtolower($this->title)'text'));
  1220.         }
  1221.  
  1222.         if (FALSE !== ($body $this->getEnvironment()->
  1223.                 getAppearanceInventory(0TRUENULL$display_mode))) {
  1224.             $this->tell($body);
  1225.         }
  1226.     }
  1227.  
  1228.     /**
  1229.      * Shows this administrator various PHP/server information about a user
  1230.      *
  1231.      * @param   string  $verb       the action, "svars"
  1232.      * @param   string  $noun       who to show info of, could be empty
  1233.      * @return  boolean TRUE for action completed, FALSE otherwise
  1234.      */
  1235.     function actionSvars($verb$noun)
  1236.     {
  1237.         if (!dp_strlen($noun)) {
  1238.             $ob =$this;
  1239.         else {
  1240.             if (FALSE === ($env $this->getEnvironment())) {
  1241.                 return FALSE;
  1242.             }
  1243.             if (FALSE === ($ob $this->isPresent($noun))) {
  1244.                 if (FALSE === ($ob $env->isPresent($noun))) {
  1245.                     if (FALSE ===
  1246.                             ($ob get_current_dpuniverse()->findUser($noun))) {
  1247.                         $this->setActionFailure(sprintf(
  1248.                             dp_text('Target %s not found.<br />')$noun));
  1249.                         return FALSE;
  1250.                     }
  1251.                 }
  1252.             }
  1253.         }
  1254.         $this->tell('<window><b>' sprintf(dp_text('Server variables of %s:'),
  1255.             $ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))
  1256.             . '</b><br /><pre>' print_r($ob->_SERVERTRUE'</pre>'
  1257.             . '<b>' sprintf(dp_text('Properties of %s:'),
  1258.             $ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))
  1259.             . '</b><pre>' htmlentities(print_r($ob->getProperties()TRUE))
  1260.             . '</pre></window>');
  1261.         return TRUE;
  1262.     }
  1263.  
  1264.     /**
  1265.      * Destroys an object
  1266.      *
  1267.      * @param   string  $verb       the action, "destroy"
  1268.      * @param   string  $noun       the object to destroy, for example "rose"
  1269.      * @return  boolean TRUE for action completed, FALSE otherwise
  1270.      * @since   DutchPIPE 0.4.0
  1271.      */
  1272.     function actionDestroy($verb$noun)
  1273.     {
  1274.         if (FALSE === ($env $this->getEnvironment()) ||
  1275.                 ($noun && !($dest_ob $env->isPresent($noun)))) {
  1276.             $this->setActionFailure(sprintf(dp_text("Couldn't find: %s<br />"),
  1277.                 $noun));
  1278.             return FALSE;
  1279.         }
  1280.         if (!isset($dest_ob)) {
  1281.             $this->setActionFailure(dp_text('Destroy what?<br />'));
  1282.             return FALSE;
  1283.         }
  1284.         $this->tell(sprintf(
  1285.             dp_text('You destroy %s.<br />'),
  1286.             $dest_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)));
  1287.         $env->tell(ucfirst(sprintf(
  1288.             dp_text('%s destroys %s.<br />'),
  1289.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE),
  1290.             $dest_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))),
  1291.             $this$dest_ob);
  1292.         $dest_ob->tell(ucfirst(sprintf(
  1293.             dp_text('%s destroys you.<br />'),
  1294.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))));
  1295.         $dest_ob->removeDpObject();
  1296.  
  1297.         return TRUE;
  1298.     }
  1299.  
  1300.     /**
  1301.      * Shows a list of all objects in this DutchPIPE universe in a window
  1302.      *
  1303.      * @param   string  $verb       the action, "oblist"
  1304.      * @param   string  $noun       empty string
  1305.      * @return  boolean TRUE for action completed, FALSE otherwise
  1306.      * @see     DpUniverse::gteObjectList()
  1307.      * @since   DutchPIPE 0.4.0
  1308.      */
  1309.     function actionOblist($verb$noun)
  1310.     {
  1311.         $this->tell('<stylesheet href="' DPUNIVERSE_WWW_URL
  1312.             . 'oblist.css"></stylesheet>');
  1313.         $this->tell('<window styleclass="dpwindow_oblist" delay="100">'
  1314.             . '<div class="dpoblist_div">'
  1315.             . get_current_dpuniverse()->getObjectList()
  1316.             . '</div><a href="javascript:send_action2server(\'oblist\')">Reload'
  1317.             . '</a></window>');
  1318.         $this->tell('<script type="text/javascript" ' .
  1319.             'src="' DPUNIVERSE_WWW_URL 'sorttable.js"></script>');
  1320.         $this->tell("<script>\nsetTimeout('sorttable.init()', 200);\n"
  1321.             . "</script>");
  1322.         return TRUE;
  1323.     }
  1324.  
  1325.     /**
  1326.      * Go to a given location
  1327.      *
  1328.      * @param   string  $verb       the action, "goto"
  1329.      * @param   string  $noun       the location, for example "/page/about.php"
  1330.      * @return  boolean TRUE for action completed, FALSE otherwise
  1331.      */
  1332.     function actionGoto($verb$noun)
  1333.     {
  1334.         if (!dp_strlen($noun)) {
  1335.             $this->setActionFailure(dp_text('Goto where?<br />'));
  1336.             return FALSE;
  1337.         }
  1338.  
  1339.         $this->tell("<location>$noun</location>");
  1340.         return TRUE;
  1341.     }
  1342.  
  1343.     /**
  1344.      * Makes this administrator force another user to perform an action
  1345.      *
  1346.      * @param   string  $verb       the action, "force"
  1347.      * @param   string  $noun       who and what to force
  1348.      * @return  boolean TRUE for action completed, FALSE otherwise
  1349.      */
  1350.     function actionForce($verb$noun)
  1351.     {
  1352.         if (!dp_strlen($noun trim($noun))
  1353.                 || FALSE === ($pos dp_strpos($noun' '))) {
  1354.             $this->setActionFailure(
  1355.                 dp_text('Syntax: force <i>who what</i>.<br />'));
  1356.             return FALSE;
  1357.         }
  1358.  
  1359.         $noun str_replace('&quot;''"'$noun);
  1360.  
  1361.         if (dp_substr($noun01== '"'{
  1362.             $noun trim(dp_substr($noun1));
  1363.             if (FALSE !== ($pos2 dp_strpos($noun'"'))) {
  1364.                 $who dp_substr($noun0$pos2);
  1365.                 $what dp_substr($noun$pos2 1);
  1366.             }
  1367.         }
  1368.         if (!isset($who)) {
  1369.             $who dp_substr($noun0$pos);
  1370.             $what dp_substr($noun$pos 1);
  1371.         }
  1372.  
  1373.         if (FALSE === ($who_ob $this->isPresent($who))) {
  1374.             if (FALSE !== ($env $this->getEnvironment())) {
  1375.                 $who_ob $env->isPresent($who);
  1376.             }
  1377.         }
  1378.         if (FALSE === $who_ob{
  1379.             $this->setActionFailure(sprintf(
  1380.                 dp_text('Target %s not found.<br />')$who));
  1381.             return FALSE;
  1382.         }
  1383.  
  1384.         $this->tell(sprintf(
  1385.             dp_text('You give %s the old "Jedi mind-trick" stink eye.<br />'),
  1386.             $who_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)));
  1387.         $env->tell(ucfirst(sprintf(
  1388.             dp_text('%s gives %s the old "Jedi mind-trick" stink eye.<br />'),
  1389.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE),
  1390.             $who_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))),
  1391.             $this$who_ob);
  1392.         $who_ob->tell(ucfirst(sprintf(
  1393.             dp_text('%s gives you the old "Jedi mind-trick" stink eye.<br />'),
  1394.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))));
  1395.  
  1396.         $who_ob->performAction($what);
  1397.         return TRUE;
  1398.     }
  1399.  
  1400.     /**
  1401.      * Completes the move action performed by clicking on an object
  1402.      *
  1403.      * @param   string  $verb       the action, "move"
  1404.      * @return  string  a string such as "beer "
  1405.      * @see     actionMove()
  1406.      */
  1407.     function actionMoveOperant($verb&$menuobj)
  1408.     {
  1409.         $title dp_strtolower($menuobj->title);
  1410.  
  1411.         return (FALSE === dp_strpos($title' '$title '"' $title '"')
  1412.             . ' ';
  1413.     }
  1414.  
  1415.     /**
  1416.      * Makes this administrator move an object to another environment
  1417.      *
  1418.      * @param   string  $verb       the action, "move"
  1419.      * @param   string  $noun       what and where to move
  1420.      * @return  boolean TRUE for action completed, FALSE otherwise
  1421.      */
  1422.     function actionMove($verb$noun)
  1423.     {
  1424.         if (!dp_strlen($noun trim($noun))
  1425.                 || FALSE === ($pos dp_strpos($noun' '))) {
  1426.             $this->setActionFailure(
  1427.                 dp_text('Syntax: move <i>what where</i>.<br />'));
  1428.             return FALSE;
  1429.         }
  1430.  
  1431.         $noun str_replace('&quot;''"'$noun);
  1432.  
  1433.         if (dp_substr($noun01== '"'{
  1434.             $noun trim(dp_substr($noun1));
  1435.             if (FALSE !== ($pos2 dp_strpos($noun'"'))) {
  1436.                 $what dp_substr($noun0$pos2);
  1437.             }
  1438.         }
  1439.         if (!isset($what)) {
  1440.             $what dp_substr($noun0$pos);
  1441.         }
  1442.  
  1443.         if (FALSE === ($what_ob $this->isPresent($what))) {
  1444.             if (FALSE !== ($env $this->getEnvironment())) {
  1445.                 $what_ob $env->isPresent($what);
  1446.             }
  1447.             if (FALSE === $what_ob{
  1448.                 $what_ob get_current_dpuniverse()->findUser($what);
  1449.             }
  1450.         }
  1451.         if (FALSE === $what_ob{
  1452.             $this->setActionFailure(sprintf(
  1453.                 dp_text('Object to move %s not found.<br />')$what));
  1454.             return FALSE;
  1455.         }
  1456.  
  1457.         $pos !isset($pos2$pos $pos2 2;
  1458.         if (dp_strlen($where trim(dp_substr($noun$pos))))  {
  1459.             if (dp_substr($where01== '"'{
  1460.                 $where trim(dp_substr($where1));
  1461.                 if ($pos dp_strpos($where'"')) {
  1462.                     $where dp_substr($where0$pos);
  1463.                 }
  1464.             }
  1465.         }
  1466.  
  1467.         if (!dp_strlen($where))  {
  1468.             $this->setActionFailure(
  1469.                 dp_text('Syntax: move <i>what where</i>.<br />'));
  1470.             return FALSE;
  1471.         }
  1472.  
  1473.         $env $this->getEnvironment();
  1474.         if ('!' === $where{
  1475.             $where_ob $this->getEnvironment();
  1476.             if (FALSE === $where_ob{
  1477.                 $this->setActionFailure(sprintf(
  1478.                     dp_text("Can't move object %s to this location: you have no environment.<br />"),
  1479.                     $what));
  1480.             }
  1481.         }
  1482.         elseif ('me' === $where{
  1483.             $where_ob $this;
  1484.         }
  1485.         elseif (FALSE === ($where_ob $this->isPresent($where))) {
  1486.             if (FALSE !== $env{
  1487.                 $where_ob $env->isPresent($where);
  1488.             }
  1489.             if (FALSE === $where_ob{
  1490.                 $where_ob get_current_dpuniverse()->findUser($where);
  1491.             }
  1492.         }
  1493.         if (FALSE === $where_ob{
  1494.             $this->setActionFailure(sprintf(
  1495.                 dp_text('Target %s not found.<br />')$where));
  1496.             return FALSE;
  1497.         }
  1498.  
  1499.         if ($this === $what_ob && $this === $where_ob{
  1500.             $this->setActionFailure(
  1501.                 dp_text('You cannot move yourself into yourself.<br />'));
  1502.             return FALSE;
  1503.         }
  1504.  
  1505.         $this->tell(sprintf(
  1506.             dp_text('You give %s the old "Jedi mind-trick" stink eye.<br />'),
  1507.             $what_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)));
  1508.         if (FALSE !== $env{
  1509.             $env->tell(ucfirst(sprintf(
  1510.                 dp_text('%s gives %s the old "Jedi mind-trick" stink eye.<br />'),
  1511.                 $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE),
  1512.                 $what_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))),
  1513.                 $this$what_ob);
  1514.             }
  1515.         $what_ob->tell(ucfirst(sprintf(
  1516.             dp_text('%s gives you the old "Jedi mind-trick" stink eye.<br />'),
  1517.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))));
  1518.  
  1519.         $what_ob->moveDpObject($where_ob);
  1520.         return TRUE;
  1521.     }
  1522.  
  1523.     /**
  1524.      * Resets the environment.
  1525.      *
  1526.      * @return  boolean TRUE
  1527.      */
  1528.     function actionReset()
  1529.     {
  1530.         $this->getEnvironment()->__reset();
  1531.         $this->tell('Resetted.<br />');
  1532.         return TRUE;
  1533.     }
  1534.  
  1535.     /**
  1536.      * Go to the login page, logout if logon on.
  1537.      *
  1538.      * @return  boolean TRUE
  1539.      */
  1540.     function actionLoginOut()
  1541.     {
  1542.         $this->tell('<location>/page/login.php'
  1543.             . ($this->isRegistered '&act=logout' '')
  1544.             . '</location>');
  1545.         return TRUE;
  1546.     }
  1547.  
  1548.     /**
  1549.      * Moves to or sets personal home location
  1550.      *
  1551.      * @param   string  $verb       the action, "myhome"
  1552.      * @param   string  $noun       empty to go home, "set" to set home
  1553.      * @return  boolean TRUE for action completed, FALSE otherwise
  1554.      */
  1555.     function actionMyhome($verb$noun)
  1556.     {
  1557.         if (is_null($noun)) {
  1558.             $result dp_db_query('
  1559.                 SELECT
  1560.                     userHomeLocation,userHomeSublocation
  1561.                 FROM
  1562.                     Users
  1563.                 WHERE
  1564.                     userUsernameLower='
  1565.                     . dp_db_quote(dp_strtolower($this->title)'text'));
  1566.  
  1567.             if (empty($result|| !($row dp_db_fetch_row($result))) {
  1568.                 dp_db_free($result);
  1569.                 return FALSE;
  1570.             }
  1571.  
  1572.             if (is_null($row[0])) {
  1573.                 $this->tell(dp_text('You have no home location set. Set your home location first.<br />'));
  1574.                 dp_db_free($result);
  1575.                 return TRUE;
  1576.             }
  1577.  
  1578.             dp_db_free($result);
  1579.             $this->tell('<location>' $row[0(is_null($row[1]''
  1580.                 : '&sublocation=' $row[1]'</location>');
  1581.             return TRUE;
  1582.         }
  1583.  
  1584.         if (dp_text("set"=== $noun{
  1585.             $env $this->getEnvironment();
  1586.             if (!$env || !dp_strlen($loc $env->location)) {
  1587.                 return FALSE;
  1588.             }
  1589.             $subloc $env->sublocation;
  1590.  
  1591.             dp_db_exec('UPDATE Users set userHomeLocation='
  1592.                 . dp_db_quote($loc'text'',userHomeSublocation='
  1593.                 . (is_null($subloc|| !dp_strlen($subloc'NULL'
  1594.                 : dp_db_quote($subloc'text')) ' WHERE userUsernameLower='
  1595.                 . dp_db_quote(dp_strtolower($this->title)'text'));
  1596.             $this->tell(dp_text('Your home location has been set to the current page.<br />'));
  1597.             return TRUE;
  1598.         }
  1599.  
  1600.         $this->actionFailure dp_text('Syntax: myhome [set]<br />');
  1601.         return FALSE;
  1602.     }
  1603.  
  1604.     /**
  1605.      * Sets the input field mode
  1606.      *
  1607.      * Without an argument, switches between the two modes "cmd" and "say".
  1608.      * Otherwise switches to the given mode (if it is valid). The input field
  1609.      * stays visible between page changes with mode "pin".
  1610.      *
  1611.      * @param   string  $verb       the action, "mode"
  1612.      * @param   string  $noun       empty or a mode
  1613.      * @return  boolean TRUE for action completed, FALSE otherwise
  1614.      */
  1615.     function actionMode($verb$noun)
  1616.     {
  1617.         if (is_null($noun)) {
  1618.             $this->inputMode 'cmd' !== $this->inputMode 'cmd' 'say';
  1619.         elseif (in_array($nounexplode('#'dp_text('cmd#command')))) {
  1620.             $this->inputMode 'cmd';
  1621.         elseif (in_array($nounexplode('#'dp_text('say')))) {
  1622.             $this->inputMode 'say';
  1623.         elseif (in_array($nounexplode('#'dp_text('once')))) {
  1624.             $ip 'once';
  1625.         elseif (in_array($nounexplode('#'dp_text('page')))) {
  1626.             $ip 'page';
  1627.         elseif (in_array($nounexplode('#'dp_text('always')))) {
  1628.             $ip 'always';
  1629.         else {
  1630.             $this->actionFailure dp_text('Invalid action mode (valid modes are: say and cmd).<br />');
  1631.             return FALSE;
  1632.         }
  1633.  
  1634.         if (isset($ip)) {
  1635.             $this->inputPersistent $ip;
  1636.             if ($this->isRegistered{
  1637.                 dp_db_exec('UPDATE Users SET '
  1638.                     . 'userInputPersistent=' dp_db_quote($ip'text')
  1639.                     . ' WHERE userUsernameLower='
  1640.                     . dp_db_quote(dp_strtolower($this->title)'text'));
  1641.             }
  1642.             return TRUE;
  1643.         }
  1644.  
  1645.         if ($this->isRegistered{
  1646.             dp_db_exec('UPDATE Users set userInputMode='
  1647.                 . dp_db_quote($this->inputMode'text')
  1648.                 . ' WHERE userUsernameLower='
  1649.                 . dp_db_quote(dp_strtolower($this->title)'text'));
  1650.         }
  1651.         $this->tell('cmd' === $this->inputMode
  1652.             ? dp_text('The input field is now in command mode. Enter <tt>help</tt> for more information.<br />')
  1653.             : dp_text('The input field is now in page chat mode. Enter <tt>/help</tt> for more information.<br />'));
  1654.         return TRUE;
  1655.     }
  1656.  
  1657.     function getModeChecked()
  1658.     {
  1659.         return ('cmd' !== $this->inputMode '' '<img src="'
  1660.             . DPUNIVERSE_IMAGE_URL 'checked.gif" width="7" '
  1661.             . 'height="7" border="0" alt="" title="" />#'
  1662.             . DPUNIVERSE_IMAGE_URL 'checked_over.gif#')
  1663.             . dp_text('command mode');
  1664.     }
  1665.  
  1666.     /**
  1667.      * Makes this user object tell something to another user object
  1668.      *
  1669.      * @param   string  $verb       the action, "tell"
  1670.      * @param   string  $noun       who and what to tell, could be empty
  1671.      * @return  boolean TRUE for action completed, FALSE otherwise
  1672.      */
  1673.     function actionTell($verb$noun)
  1674.     {
  1675.         if (FALSE === ($pos dp_strpos($noun' '))) {
  1676.             $this->tell('<script>
  1677. setTimeout("bind_input(); _gel(\'dptell\').focus();", 50);
  1678. </script>');
  1679.             $this->tell('<window styleclass="dpwindow_tell">
  1680. <b>' sprintf(dp_text('Private message to %s:')$noun'</b><br /><br />
  1681. <form onSubmit="send_action2server(\''
  1682.                 . addslashes($verb' ' addslashes($noun)
  1683.                 . ' \' + jQuery(\'#dptell\').val()); close_dpwindow(); '
  1684.                 . 'return false">
  1685. <input id="dptell" type="text" value="" size="50" maxlength="255"
  1686. class="dpcomm" /> <input type="submit" value=" &gt; " /></form>
  1687. </window>');
  1688.             return TRUE;
  1689.         }
  1690.  
  1691.         return DpLiving::actionTell($verb$noun);
  1692.     }
  1693.  
  1694.     /**
  1695.      * Makes this user shout something to everyone on the site
  1696.      *
  1697.      * @param   string  $verb       the action, "shout"
  1698.      * @param   string  $noun       what to shout, could be empty
  1699.      * @return  boolean TRUE for action completed, FALSE otherwise
  1700.      */
  1701.     function actionShout($verb$noun)
  1702.     {
  1703.         if (is_null($noun)) {
  1704.             $this->tell('<script>
  1705. setTimeout("bind_input(); _gel(\'dpshout\').focus();", 50);
  1706. </script>');
  1707.             $this->tell('<window styleclass="dpwindow_shout">
  1708. <b>' dp_text('Message to everybody on this site:''</b><br /><br />
  1709. <form onSubmit="send_action2server(\''
  1710.                 . addslashes($verb)
  1711.                 . ' \' + jQuery(\'#dpshout\').val()); close_dpwindow(); '
  1712.                 . 'return false">
  1713. <input id="dpshout" type="text" value="" size="50" maxlength="255"
  1714. class="dpcomm" /> <input type="submit" value=" &gt; " /></form>
  1715. </window>');
  1716.             return TRUE;
  1717.         }
  1718.  
  1719.         return DpLiving::actionShout($verb$noun);
  1720.     }
  1721.  
  1722.     /**
  1723.      * Makes this user communicate a custom message to its environment
  1724.      *
  1725.      * @param   string  $verb       the action, "emote"
  1726.      * @param   string  $noun       string to "emote"
  1727.      * @return  boolean TRUE for action completed, FALSE otherwise
  1728.      */
  1729.     function actionEmote($verb$noun)
  1730.     {
  1731.         if (is_null($noun)) {
  1732.             $this->tell('<script>
  1733. setTimeout("bind_input(); _gel(\'dpemote\').focus();", 50);
  1734. </script>');
  1735.             $this->tell('<window styleclass="dpwindow_emote">
  1736. <b>' dp_text('Emotion to everybody on this page:''</b><br /><br />'
  1737.                 . $this->title ' <form onSubmit="send_action2server(\''
  1738.                 . addslashes($verb)
  1739.                 . ' \' + jQuery(\'#dpemote\').val()); close_dpwindow(); '
  1740.                 . 'return false">
  1741. <input id="dpemote" type="text" value="" size="50" maxlength="255"
  1742. class="dpemote" /> <input type="submit" value=" &gt; " /></form>
  1743. </window>');
  1744.             return TRUE;
  1745.         }
  1746.  
  1747.         return DpLiving::actionEmote($verb$noun);
  1748.     }
  1749. }
  1750. ?>

Documentation generated on Mon, 03 Sep 2007 22:21:19 +0200 by phpDocumentor 1.3.0RC6

Click me!
Guest#216
 
 
 
  Go to Top
 
 
Input Field OptionsClose Input Field Go to Top
 
Legal Notices | Copyright © 2006, 2007 Lennert Stock. All rights reserved. Last update: Mon Sep 03 2007, 21:50 CET.