コード例 #1
0
/**
 * Wrapper function for the direct download of a map (wraps so as to download the map 'for where a member is at' [unless a direct realm given]).
 *
 * @param  MEMBER		The member to get the map of
 * @param  ?integer	The realm they are wanting to get (NULL: where they are at)
 */
function download_map_wrap($member_id, $realm)
{
    list($_realm, $x, $y) = get_loc_details($member_id);
    if (is_null($realm)) {
        $realm = $_realm;
    }
    download_map($realm, $x, $y);
}
コード例 #2
0
} else {
    br(2);
}
div_start('show_heading');
stock_item_heading($_POST['stock_id']);
br();
div_end();
set_global_stock_item($_POST['stock_id']);
div_start('reorders');
start_table(TABLESTYLE, "width=30%");
$th = array(_("Location"), _("Quantity On Hand"), _("Re-Order Level"));
table_header($th);
$j = 1;
$k = 0;
//row colour counter
$result = get_loc_details($_POST['stock_id']);
if (@$_GET['popup']) {
    hidden('_tabs_sel', get_post('_tabs_sel'));
    hidden('popup', @$_GET['popup']);
}
while ($myrow = db_fetch($result)) {
    alt_table_row_color($k);
    if (isset($_POST['UpdateData']) && check_num($myrow["loc_code"])) {
        $myrow["reorder_level"] = input_num($myrow["loc_code"]);
        set_reorder_level($_POST['stock_id'], $myrow["loc_code"], input_num($myrow["loc_code"]));
        display_notification(_("Reorder levels has been updated."));
    }
    $qoh = get_qoh_on_date($_POST['stock_id'], $myrow["loc_code"]);
    label_cell($myrow["location_name"]);
    $_POST[$myrow["loc_code"]] = qty_format($myrow["reorder_level"], $_POST['stock_id'], $dec);
    qty_cell($qoh, false, $dec);
コード例 #3
0
ファイル: stock_status.php プロジェクト: ravenii/guardocs
start_form(false, true);
if (!isset($_POST['stock_id'])) {
    $_POST['stock_id'] = get_global_stock_item();
}
echo "<center> " . tr("Item:") . " ";
stock_items_list('stock_id', $_POST['stock_id'], false, true);
echo "<br>";
echo "<hr>";
set_global_stock_item($_POST['stock_id']);
$mb_flag = get_mb_flag($_POST['stock_id']);
$kitset_or_service = false;
if (is_service($mb_flag)) {
    display_note(tr("This is a service and cannot have a stock holding, only the total quantity on outstanding sales orders is shown."));
    $kitset_or_service = true;
}
$loc_details = get_loc_details($_POST['stock_id']);
start_table($table_style);
if ($kitset_or_service == true) {
    $th = array(tr("Location"), tr("Demand"));
} else {
    $th = array(tr("Location"), tr("Quantity On Hand"), tr("Re-Order Level"), tr("Demand"), tr("Available"), tr("On Order"));
}
table_header($th);
$j = 1;
$k = 0;
//row colour counter
while ($myrow = db_fetch($loc_details)) {
    alt_table_row_color($k);
    $sql = "SELECT Sum(sales_order_details.quantity-sales_order_details.qty_sent) AS DEM\n\t\tFROM sales_order_details, sales_orders\n\t\tWHERE sales_orders.order_no = sales_order_details.order_no\n\t\tAND sales_orders.from_stk_loc='" . $myrow["loc_code"] . "'\n\t\tAND sales_order_details.qty_sent < sales_order_details.quantity\n\t\tAND sales_order_details.stk_code='" . $_POST['stock_id'] . "'";
    $demand_result = db_query($sql, "Could not retreive demand for item");
    if (db_num_rows($demand_result) == 1) {
コード例 #4
0
ファイル: ocworld_action.php プロジェクト: erico-deh/ocPortal
/**
 * Wrapper to edit an item copy. Does not return.
 *
 * @param  MEMBER		The member performing the action
 * @param  string		The name of the item
 * @param  integer	The cost of the item copy
 * @param  BINARY		Whether the item is finite.
 * @param  integer	The X ordinate of the item copy
 * @param  integer	The Y ordinate of the item copy
 * @param  AUTO_LINK	The realm of the item copy
 * @param  MEMBER		The owner of the item copy source
 */
function edit_item_wrap_copy($member_id, $name, $cost, $not_infinite, $new_x, $new_y, $new_realm, $user)
{
    if (!($cost > 0)) {
        $cost = 0;
    }
    if (!has_specific_permission($member_id, 'administer_ocworld') && $GLOBALS['SITE_DB']->query_value('w_items', 'copy_owner', array('name' => $name)) != $member_id) {
        ocw_refresh_with_message(do_lang_tempcode('ACCESS_DENIED__I_ERROR', $GLOBALS['FORUM_DRIVER']->get_username(get_member())), 'warn');
    }
    // Get $realm,$x,$y from $member_id
    list($realm, $x, $y) = get_loc_details($member_id);
    if (!has_specific_permission($member_id, 'administer_ocworld') && $GLOBALS['SITE_DB']->query_value('w_realms', 'owner', array('id' => $new_realm)) != $member_id && $GLOBALS['SITE_DB']->query_value('w_realms', 'r_private', array('id' => $new_realm)) == 1) {
        ocw_refresh_with_message(do_lang_tempcode('W_NO_ACCESS_MOVE'), 'warn');
    }
    if ($x != $new_x || $y != $new_y || $realm != $new_realm) {
        // Check we don't have a copy of this item at new dest already
        $t = $GLOBALS['SITE_DB']->query_value_null_ok('w_items', 'name', array('location_x' => $new_x, 'location_y' => $new_y, 'location_realm' => $new_realm, 'copy_owner' => $user, 'name' => $name));
        if (!is_null($t)) {
            ocw_refresh_with_message(do_lang_tempcode('W_COPY_SOURCE_ALREADY'), 'warn');
        }
    }
    // Fix infinity source thing... we can never make a non-infinite source into an infinite source
    $old_not_infinite = $GLOBALS['SITE_DB']->query_value_null_ok('w_items', 'not_infinite', array('location_x' => $x, 'location_y' => $y, 'location_realm' => $realm, 'copy_owner' => $user, 'name' => $name));
    if (is_null($old_not_infinite)) {
        warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
    }
    if ($old_not_infinite == 1) {
        $not_infinite = 1;
    } elseif ($not_infinite != 1) {
        $not_infinite = 0;
    }
    edit_item_copy($user, $name, $not_infinite, $cost, $new_x, $new_y, $new_realm, $x, $y, $realm);
    ocw_refresh_with_message(do_lang_tempcode('SUCCESS'));
}
コード例 #5
0
ファイル: ocworld.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     require_code('ocworld');
     require_code('ocworld_screens');
     // Decide what functions to execute for this command
     $command = either_param('type', 'room');
     $param = either_param('param', '');
     $dest_member_id = either_param_integer('user', -1);
     $member_id = get_member();
     if (is_guest($member_id)) {
         ocw_refresh_with_message(do_lang_tempcode('W_NOT_LOGGED_IN'), 'warn');
         return new ocp_tempcode();
     }
     $item = either_param('item', '');
     // Create the member if they aren't already in the system
     $member_rows = $GLOBALS['SITE_DB']->query_select('w_members', array('*'), array('id' => $member_id), '', 1);
     if (!array_key_exists(0, $member_rows)) {
         $member_rows[0] = array('id' => $member_id, 'location_realm' => 0, 'location_x' => 0, 'location_y' => 0, 'banned' => 0, 'health' => 10, 'trolled' => 0, 'lastactive' => time());
         $GLOBALS['SITE_DB']->query_insert('w_members', $member_rows[0]);
     }
     $member_row = $member_rows[0];
     // Check for banning
     if ($member_row['banned'] == 1) {
         ocw_refresh_with_message(do_lang_tempcode('W_YOU_BANNED'), 'warn');
     }
     // Check for death
     if ($member_row['health'] < 1) {
         take_items($member_id);
         $GLOBALS['SITE_DB']->query_update('w_members', array('location_realm' => 0, 'location_x' => 0, 'location_y' => 0, 'banned' => 0, 'health' => 10), array('id' => $member_id), '', 1);
         ocw_refresh_with_message(do_lang_tempcode('W_YOU_DIED'), 'warn');
     }
     // Mark as active
     $GLOBALS['SITE_DB']->query_update('w_members', array('lastactive' => time()), array('id' => $member_id), '', 1);
     destick($member_id);
     // Check to see if the user is locked into answering a trolls questions
     if ($member_row['trolled'] != 0) {
         $realm = $member_row['location_realm'];
         // Get the questions that were asked
         $i = 0;
         $trolled = $member_row['trolled'];
         $q = array();
         $a = array();
         while (($trolled & 255 << $i * 8) != 0) {
             $q_num = $trolled >> $i * 8 & 255;
             $q[$i + 1] = $GLOBALS['SITE_DB']->query_value('w_realms', 'q' . strval($q_num), array('id' => $realm));
             $a[$i + 1] = $GLOBALS['SITE_DB']->query_value('w_realms', 'a' . strval($q_num), array('id' => $realm));
             $i++;
         }
         $num_questions = $i;
         // Are we marking or answering?
         if (post_param('a1', '!!') != '!!') {
             // Mark them
             $pass = 0;
             for ($i = 1; $i <= $num_questions; $i++) {
                 $given = strtolower(post_param('a' . strval($i)));
                 $stored = strtolower($a[$i]);
                 if ($given == $stored) {
                     $pass++;
                 } elseif (strstr(':' . $stored . ':', ':' . $given . ':') !== false) {
                     $pass++;
                 }
             }
             // Regardless they have had their chance: no more questions
             $GLOBALS['SITE_DB']->query_update('w_members', array('trolled' => 0), array('id' => $member_id), '', 1);
             if ($pass == 0) {
                 $pen_id = mt_rand(0, 2);
                 if ($pen_id == 0) {
                     $joke = mt_rand(1, 10);
                     $penalty = do_lang_tempcode('W_JOKE_' . strval($joke));
                     hurt($member_id);
                 }
                 if ($pen_id == 1) {
                     $penalty = do_lang('W_PENALTY_STOLEN');
                     steal($member_id, -$realm - 1);
                 }
                 if ($pen_id == 2) {
                     $penalty = do_lang('W_PENALTY_SENT_LOBBY');
                     basic_enter_room($member_id, $realm, 0, 0);
                 }
                 ocw_refresh_with_message(do_lang_tempcode('W_TROLL_YOU', escape_html($penalty)), 'warn');
             } else {
                 ocw_refresh_with_message(do_lang_tempcode('W_TROLL_THANKYOU', integer_format($pass)));
             }
         } else {
             $troll_name = $GLOBALS['SITE_DB']->query_value('w_realms', 'troll_name', array('id' => $realm));
             $title = get_page_title('W_TROLL_Q', true, array(escape_html($troll_name)));
             $questions = new ocp_tempcode();
             for ($i = 1; $i <= $num_questions; $i++) {
                 $questions->attach(do_template('W_TROLL_QUESTION', array('_GUID' => 'b09eb44e4264a9dca5bdf651ca9a48d4', 'Q' => $q[$i], 'I' => strval($i))));
             }
             return do_template('W_TROLL', array('_GUID' => 'e108ccaebc5b1adfa9db6b5b23e93602', 'TITLE' => $title, 'TROLL' => $troll_name, 'QUESTIONS' => $questions));
         }
     }
     // There is a chance the troll on this realm will pick this 'turn' to move
     if (mt_rand(0, 6) == 1) {
         $realm = $member_row['location_realm'];
         $troll_id = -$realm - 1;
         $troll_loc = get_loc_details($troll_id, true);
         if (!is_null($troll_loc)) {
             list(, $troll_x, $troll_y) = $troll_loc;
             $dx = -1;
             $dy = -1;
             do {
                 $dx = mt_rand(-1, 1);
                 $dy = mt_rand(-1, 1);
             } while (!room_exists($troll_x + $dx, $troll_y + $dy, $realm));
             $GLOBALS['SITE_DB']->query_update('w_members', array('location_x' => $troll_x + $dx, 'location_y' => $troll_y + $dy), array('id' => $troll_id), '', 1);
         }
     }
     require_code('uploads');
     // What command are we being asked to do?
     if ($command == 'confirm') {
         $url = build_url(array('page' => 'ocworld'), '_SELF');
         $command2 = either_param('btype', '');
         $item = either_param('item', '');
         $user = either_param_integer('user', -1);
         $param = either_param('param', '');
         return do_template('W_CONFIRM_SCREEN', array('_GUID' => '365870cb4c6cb4282ff6c7a11f4f8a5b', 'TITLE' => get_page_title('W_CONFIRM_TITLE'), 'URL' => $url, 'COMMAND' => $command2, 'ITEM' => $item, 'USER' => strval($user), 'PARAM' => $param));
     }
     if ($command == 'reallocate') {
         if (!has_specific_permission(get_member(), 'administer_ocworld')) {
             ocw_refresh_with_message(do_lang_tempcode('W_ONLY_STAFF_REALLOC'), 'warn');
         }
         $out = new ocp_tempcode();
         $rows = $GLOBALS['SITE_DB']->query_select('items', array('*'), array('copy_owner' => NULL));
         foreach ($rows as $myrow) {
             $owner = $GLOBALS['SITE_DB']->query_value('w_itemdef', 'owner', array('name' => $myrow['name']));
             if (!is_null($owner)) {
                 $GLOBALS['SITE_DB']->query_update('w_items', array('copy_owner' => $owner), array('name' => $myrow['name'], 'copy_owner' => NULL));
                 $out->attach(paragraph(do_lang_tempcode('W_REALLOCATING', escape_html($myrow['name']), 'tfgdfgd4rf')));
             }
         }
         return do_template('W_REALLOCATE', array('_GUID' => '8fa4b9205310d6bc2fc28348a52898d5', 'TITLE' => get_page_title('W_REALLOCATE'), 'OUT' => $out));
     }
     if ($command == 'portal') {
         portal($member_id, intval($param));
     }
     if ($command == 'realms') {
         realms();
         return new ocp_tempcode();
     }
     if ($command == 'up') {
         $tpl = try_to_enter_room($member_id, 0, -1, '');
         if (!is_null($tpl)) {
             return $tpl;
         }
         ocw_refresh_with_message(new ocp_tempcode());
     }
     if ($command == 'down') {
         $tpl = try_to_enter_room($member_id, 0, 1, '');
         if (!is_null($tpl)) {
             return $tpl;
         }
         ocw_refresh_with_message(new ocp_tempcode());
     }
     if ($command == 'right') {
         $tpl = try_to_enter_room($member_id, 1, 0, '');
         if (!is_null($tpl)) {
             return $tpl;
         }
         ocw_refresh_with_message(new ocp_tempcode());
     }
     if ($command == 'left') {
         $tpl = try_to_enter_room($member_id, -1, 0, '');
         if (!is_null($tpl)) {
             return $tpl;
         }
         ocw_refresh_with_message(new ocp_tempcode());
     }
     if ($command == 'answered') {
         $tpl = try_to_enter_room($member_id, post_param_integer('dx'), post_param_integer('dy'), $param);
         if (!is_null($tpl)) {
             return $tpl;
         }
     }
     if ($command == 'drop') {
         drop_wrap($member_id, $item);
     }
     if ($command == 'give') {
         give($member_id, $dest_member_id, $item);
     }
     if ($command == 'pickpocket') {
         pickpocket($member_id, $dest_member_id);
     }
     if ($command == 'use') {
         useitem($member_id, $item);
     }
     if ($command == 'take') {
         take($member_id, $item, $dest_member_id);
     }
     if ($command == 'buy') {
         buy($member_id, $item, $dest_member_id);
     }
     if ($command == 'inventory') {
         $tpl = output_inventory_screen($dest_member_id);
         return $tpl;
     }
     if ($command == 'findperson') {
         findperson($param == '' ? strval($dest_member_id) : $param);
     }
     if ($command == 'message') {
         message($member_id, post_param('post'), post_param_integer('tuser'));
     }
     if ($command == 'emergency') {
         basic_enter_room($member_id, 0, 0, 0);
     }
     if ($command == 'delete-message-by-person') {
         if (!has_specific_permission($member_id, 'administer_ocworld') && $member_id != $dest_member_id) {
             ocw_refresh_with_message(do_lang_tempcode('ACCESS_DENIED__I_ERROR', $GLOBALS['FORUM_DRIVER']->get_username(get_member())), 'warn');
         }
         delete_message($member_id, $dest_member_id, addslashes($param));
     }
     // Management
     if ($command == 'additem') {
         require_code('ocworld_action');
         $name = post_param('name', '');
         if ($name == '') {
             $tpl = do_template('W_ITEM_SCREEN', array('_GUID' => '0246f7037a360996bdfb4f1dcf96bcfc', 'PRICE' => integer_format(get_price('mud_item')), 'TEXT' => paragraph(do_lang_tempcode('W_ADD_ITEM_TEXT')), 'TITLE' => get_page_title('W_ADD_ITEM_TITLE'), 'PAGE_TYPE' => 'additem', 'ITEM' => '', 'DESCRIPTION' => '', 'BRIBABLE' => '0', 'HEALTHY' => '0', 'PICTURE_URL' => '', 'MAX_PER_PLAYER' => '10', 'REPLICATEABLE' => '1'));
             return $tpl;
         }
         $urls = get_url('url', 'pic', 'uploads/ocworld', 0, OCP_UPLOAD_IMAGE);
         add_item_wrap($member_id, $name, post_param_integer('cost', 0), post_param_integer('not_infinite', 0), post_param_integer('bribable', 0), post_param_integer('healthy', 0), $urls[0], post_param_integer('max_per_player', -1), post_param_integer('replicateable', 0), post_param('description'));
     }
     if ($command == 'additemcopy') {
         require_code('ocworld_action');
         $name = post_param('name', '');
         if ($name == '') {
             $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'w_itemdef WHERE replicateable=1 OR owner=' . strval((int) get_member()) . ' ORDER BY name');
             $items = '';
             foreach ($rows as $myrow) {
                 $items .= "<option value=\"" . escape_html($myrow['name']) . "\">" . escape_html($myrow['name']) . "</option>";
             }
             if ($items == '') {
                 ocw_refresh_with_message(do_lang_tempcode('W_NO_ITEMS_YET'), 'warn');
             }
             if ($GLOBALS['XSS_DETECT']) {
                 ocp_mark_as_escaped($items);
             }
             $tpl = do_template('W_ITEMCOPY_SCREEN', array('_GUID' => '15799930bca51eafdee3c0a8e197866a', 'PRICE' => integer_format(get_price('mud_item_copy')), 'TEXT' => paragraph(do_lang_tempcode('W_ADD_ITEM_COPY_TEXT')), 'TITLE' => get_page_title('W_ADD_ITEM_COPY_TITLE'), 'PAGE_TYPE' => 'additemcopy', 'NOT_INFINITE' => '1', 'ITEMS' => $items, 'COST' => ''));
             return $tpl;
         }
         add_item_wrap_copy($member_id, $name, post_param_integer('cost'), post_param_integer('not_infinite', 0));
     }
     if ($command == 'addroom') {
         require_code('ocworld_action');
         $name = post_param('name', '');
         if ($name == '') {
             list($realm, $x, $y) = get_loc_details($member_id);
             $tpl = do_template('W_ROOM_SCREEN', array('_GUID' => '5357a6cf8648c952cf29c2b7234cfa6c', 'PRICE' => integer_format(get_price('mud_room')), 'TEXT' => paragraph(do_lang_tempcode('W_ADD_ROOM_TEXT')), 'ROOM_TEXT' => '', 'TITLE' => get_page_title('W_ADD_ROOM_TITLE'), 'PAGE_TYPE' => 'addroom', 'NAME' => '', 'PASSWORD_QUESTION' => '', 'PASSWORD_ANSWER' => '', 'PASSWORD_FAIL_MESSAGE' => '', 'REQUIRED_ITEM' => '', 'LOCKED_UP' => '0', 'LOCKED_DOWN' => '0', 'LOCKED_LEFT' => '0', 'LOCKED_RIGHT' => '0', 'ALLOW_PORTAL' => '1', 'PICTURE_URL' => ''));
             return $tpl;
         }
         $urls = get_url('url', 'pic', 'uploads/ocworld', 0, OCP_UPLOAD_IMAGE);
         add_room_wrap($member_id, post_param_integer('position'), $name, post_param('text'), post_param('password_question'), post_param('password_answer'), post_param('password_fail_message'), post_param('required_item'), post_param_integer('locked_up', 0), post_param_integer('locked_down', 0), post_param_integer('locked_right', 0), post_param_integer('locked_left', 0), $urls[0], post_param_integer('allow_portal', 0));
     }
     if ($command == 'addrealm') {
         require_code('ocworld_action');
         $name = post_param('name', '');
         if ($name == '') {
             $fortnights = (time() - $GLOBALS['FORUM_DRIVER']->get_member_join_timestamp(get_member())) / (60 * 60 * 24 * 7 * 2);
             $made = $GLOBALS['SITE_DB']->query_value('w_realms', 'COUNT(*)', array('owner' => get_member()));
             $left = round($fortnights - $made);
             $_qa = new ocp_tempcode();
             for ($i = 1; $i <= 30; $i++) {
                 $_qa->attach(do_template('W_REALM_SCREEN_QUESTION', array('_GUID' => '5fa7725f11b0df7e58ff83f2f1751515', 'I' => strval($i), 'Q' => '', 'A' => '')));
             }
             $tpl = do_template('W_REALM_SCREEN', array('_GUID' => '7ae26fe1766aed02233e1be84772759b', 'PRICE' => integer_format(get_price('mud_realm')), 'TEXT' => paragraph(do_lang_tempcode('W_ADD_REALM_TEXT', integer_format($left))), 'TITLE' => get_page_title('W_ADD_REALM_TITLE'), 'PAGE_TYPE' => 'addrealm', 'QA' => $_qa, 'NAME' => '', 'TROLL_NAME' => '', 'PRIVATE' => '0'));
             return $tpl;
         }
         $i = 1;
         $qa = array();
         while (strlen(post_param('question' . strval($i), '')) > 0) {
             $qa[$i] = array();
             $qa[$i]['q'] = post_param('question' . strval($i));
             $qa[$i]['a'] = post_param('answer' . strval($i));
             $i++;
         }
         $urls1 = get_url('jail_pic_url', 'jail_pic', 'uploads/ocworld', 0, OCP_UPLOAD_IMAGE);
         $urls2 = get_url('jail_house_pic_url', 'jail_house_pic', 'uploads/ocworld', 0, OCP_UPLOAD_IMAGE);
         $urls3 = get_url('lobby_pic_url', 'lobby_pic', 'uploads/ocworld', 0, OCP_UPLOAD_IMAGE);
         add_realm_wrap($member_id, $name, post_param('troll_name'), post_param('jail_name'), post_param('jail_text'), $urls1[0], post_param('jail_house_name'), post_param('jail_house_text'), $urls2[0], post_param('lobby_name'), post_param('lobby_text'), $urls3[0], $qa, post_param_integer('private', 0));
     }
     if ($command == 'addportal') {
         require_code('ocworld_action');
         $name = post_param('name', '');
         if ($name == '') {
             $tpl = do_template('W_PORTAL_SCREEN', array('_GUID' => '69e74a964f69721d0381a920c4a25ce5', 'PRICE' => integer_format(get_price('mud_portal')), 'TEXT' => paragraph(do_lang_tempcode('W_ADD_PORTAL_TEXT')), 'TITLE' => get_page_title('W_ADD_PORTAL_TITLE'), 'PORTAL_TEXT' => '', 'PAGE_TYPE' => 'addportal', 'NAME' => '', 'END_LOCATION_REALM' => '', 'END_LOCATION_X' => '', 'END_LOCATION_Y' => ''));
             return $tpl;
         }
         add_portal_wrap($member_id, $name, post_param('text'), post_param_integer('end_location_realm', -1), post_param_integer('end_location_x', -1), post_param_integer('end_location_y', -1));
     }
     if ($command == 'deleteitem') {
         require_code('ocworld_action');
         delete_item_wrap($item);
     }
     if ($command == 'deleteroom') {
         require_code('ocworld_action');
         delete_room_wrap($member_id);
     }
     if ($command == 'deleterealm') {
         require_code('ocworld_action');
         delete_realm_wrap($member_id);
     }
     if ($command == 'deleteportal') {
         require_code('ocworld_action');
         delete_portal_wrap($member_id, intval($param));
     }
     // Admin commands
     if (has_specific_permission($member_id, 'administer_ocworld')) {
         if ($command == 'mergeitems') {
             merge_items($item, either_param('item2'));
         }
         if ($command == 'teleport-person') {
             $ast = strpos($param, ':');
             $b = strpos($param, ':', $ast + 1);
             $realm = substr($param, 0, $ast);
             $x = intval(substr($param, $ast + 1, $b - $ast - 1));
             $y = intval(substr($param, $b + 1));
             basic_enter_room($dest_member_id, $realm, $x, $y);
         }
         if ($command == 'imprison-person') {
             imprison($dest_member_id);
         }
         if ($command == 'hurt-person') {
             hurt($dest_member_id);
         }
         if ($command == 'dehurt-person') {
             dehurt($dest_member_id);
         }
         if ($command == 'ban-person') {
             ban_member($dest_member_id);
         }
         if ($command == 'unban-person') {
             unban_member($dest_member_id);
         }
         if ($command == 'take-from-person') {
             steal($member_id, $dest_member_id);
         }
     }
     if ($command == 'edititem') {
         require_code('ocworld_action');
         $name = post_param('name', '');
         if ($name == '') {
             $rows = $GLOBALS['SITE_DB']->query_select('w_itemdef', array('*'), array('name' => either_param('item')), '', 1);
             if (!array_key_exists(0, $rows)) {
                 ocw_refresh_with_message(do_lang_tempcode('MISSING_RESOURCE'), 'warn');
             }
             $row = $rows[0];
             $tpl = do_template('W_ITEM_SCREEN', array('_GUID' => '1f581864bd2f0cbe05742e03ab6c2a53', 'TITLE' => get_page_title('W_EDIT_ITEM_TITLE'), 'PAGE_TYPE' => 'edititem', 'ITEM' => either_param('item'), 'DESCRIPTION' => $row['description'], 'BRIBABLE' => strval($row['bribable']), 'HEALTHY' => strval($row['healthy']), 'PICTURE_URL' => $row['picture_url'], 'OWNER' => is_null($row['owner']) ? '' : strval($row['owner']), 'MAX_PER_PLAYER' => strval($row['max_per_player']), 'REPLICATEABLE' => strval($row['replicateable'])));
             return $tpl;
         }
         $urls = get_url('url', 'pic', 'uploads/ocworld', 0, OCP_UPLOAD_IMAGE);
         edit_item_wrap($member_id, $item, $name, post_param_integer('bribable', 0), post_param_integer('healthy', 0), $urls[0], grab_new_owner('new_owner'), post_param_integer('max_per_player', -1), post_param_integer('replicateable', 0), post_param('description'));
     }
     if ($command == 'edititemcopy') {
         require_code('ocworld_action');
         $cost = post_param_integer('cost', -1);
         if ($cost == -1) {
             $user = get_param_integer('user');
             list($realm, $x, $y) = get_loc_details($member_id);
             $cost = $GLOBALS['SITE_DB']->query_value('w_items', 'cost', array('copy_owner' => $user, 'location_x' => $x, 'location_y' => $y, 'location_realm' => $realm, 'name' => get_param('item')));
             $not_infinite = $GLOBALS['SITE_DB']->query_value('w_items', 'not_infinite', array('copy_owner' => $user, 'location_x' => $x, 'location_y' => $y, 'location_realm' => $realm, 'name' => get_param('item')));
             $tpl = do_template('W_ITEMCOPY_SCREEN', array('_GUID' => 'a8d28f6516408dba96a8b57ddcd7cee6', 'TITLE' => get_page_title('W_EDIT_ITEM_COPY_TITLE'), 'PAGE_TYPE' => 'edititemcopy', 'NOT_INFINITE' => strval($not_infinite), 'X' => strval($x), 'Y' => strval($y), 'REALM' => strval($realm), 'ITEM' => get_param('item'), 'OWNER' => strval($user), 'COST' => strval($cost)));
             return $tpl;
         }
         edit_item_wrap_copy($member_id, $item, $cost, post_param_integer('not_infinite', 0), post_param_integer('new_x'), post_param_integer('new_y'), post_param_integer('new_realm'), grab_new_owner('new_owner'));
     }
     if ($command == 'editroom') {
         require_code('ocworld_action');
         $name = post_param('name', '');
         if ($name == '') {
             list($location_realm, $x, $y) = get_loc_details($member_id);
             $rows = $GLOBALS['SITE_DB']->query_select('w_rooms', array('*'), array('location_x' => $x, 'location_y' => $y, 'location_realm' => $location_realm), '', 1);
             if (!array_key_exists(0, $rows)) {
                 ocw_refresh_with_message(do_lang_tempcode('MISSING_RESOURCE'), 'warn');
             }
             $row = $rows[0];
             $tpl = do_template('W_ROOM_SCREEN', array('_GUID' => 'a4c5f8ae962cdbaa304135cf07c583a0', 'TITLE' => get_page_title('W_EDIT_ROOM_TITLE'), 'PAGE_TYPE' => 'editroom', 'X' => strval($x), 'Y' => strval($y), 'REALM' => strval($location_realm), 'NAME' => $row['name'], 'ROOM_TEXT' => $row['r_text'], 'PASSWORD_QUESTION' => $row['password_question'], 'PASSWORD_ANSWER' => $row['password_answer'], 'PASSWORD_FAIL_MESSAGE' => $row['password_fail_message'], 'REQUIRED_ITEM' => $row['required_item'], 'LOCKED_UP' => strval($row['locked_up']), 'LOCKED_DOWN' => strval($row['locked_down']), 'LOCKED_LEFT' => strval($row['locked_left']), 'LOCKED_RIGHT' => strval($row['locked_right']), 'ALLOW_PORTAL' => strval($row['allow_portal']), 'PICTURE_URL' => $row['picture_url'], 'OWNER' => is_null($row['owner']) ? '' : strval($row['owner'])));
             return $tpl;
         }
         $urls = get_url('url', 'pic', 'uploads/ocworld', 0, OCP_UPLOAD_IMAGE);
         edit_room_wrap($member_id, $name, post_param('text'), post_param('password_question'), post_param('password_answer'), post_param('password_fail_message'), post_param('required_item'), post_param_integer('locked_up', 0), post_param_integer('locked_down', 0), post_param_integer('locked_right', 0), post_param_integer('locked_left', 0), $urls[0], post_param_integer('allow_portal', 0), grab_new_owner('new_owner'), post_param_integer('new_x'), post_param_integer('new_y'), post_param_integer('new_realm'));
     }
     if ($command == 'editrealm') {
         require_code('ocworld_action');
         $name = post_param('name', '');
         if ($name == '') {
             list($realm, , ) = get_loc_details($member_id);
             $rows = $GLOBALS['SITE_DB']->query_select('w_realms', array('*'), array('id' => $realm), '', 1);
             if (!array_key_exists(0, $rows)) {
                 ocw_refresh_with_message(do_lang_tempcode('MISSING_RESOURCE'), 'warn');
             }
             $row = $rows[0];
             $qatc = new ocp_tempcode();
             for ($i = 1; $i <= 30; $i++) {
                 $qatc->attach(do_template('W_REALM_SCREEN_QUESTION', array('_GUID' => '0510427a3895969dede2bd13db7d46a6', 'I' => strval($i), 'Q' => $row['q' . strval($i)], 'A' => $row['a' . strval($i)])));
             }
             $tpl = do_template('W_REALM_SCREEN', array('_GUID' => 'f2503e0be6e45a296baa8625cafb4d72', 'TITLE' => get_page_title('W_EDIT_REALM_TITLE'), 'PAGE_TYPE' => 'editrealm', 'OWNER' => is_null($row['owner']) ? '' : strval($row['owner']), 'QA' => $qatc, 'NAME' => $row['name'], 'TROLL_NAME' => $row['troll_name'], 'PRIVATE' => strval($row['r_private'])));
             return $tpl;
         }
         for ($i = 1; $i <= 30; $i++) {
             $qa[$i]['q'] = post_param('question' . strval($i));
             $qa[$i]['a'] = post_param('answer' . strval($i));
         }
         edit_realm_wrap($member_id, $name, post_param('troll_name'), $qa, post_param_integer('private', 0), grab_new_owner('new_owner'));
     }
     if ($command == 'editportal') {
         require_code('ocworld_action');
         $name = post_param('name', '');
         if ($name == '') {
             list($realm, $x, $y) = get_loc_details($member_id);
             $end_realm = get_param_integer('param');
             $rows = $GLOBALS['SITE_DB']->query_select('w_portals', array('*'), array('start_location_x' => $x, 'start_location_y' => $y, 'start_location_realm' => $realm, 'end_location_realm' => $end_realm), '', 1);
             if (!array_key_exists(0, $rows)) {
                 ocw_refresh_with_message(do_lang_tempcode('MISSING_RESOURCE'), 'warn');
             }
             $row = $rows[0];
             $tpl = do_template('W_PORTAL_SCREEN', array('_GUID' => 'cad0e01c1c4c410e67b775c3ff6eeb3a', 'TITLE' => get_page_title('W_EDIT_PORTAL_TITLE'), 'PAGE_TYPE' => 'editportal', 'X' => strval($x), 'Y' => strval($y), 'REALM' => strval($realm), 'PARAM' => $param, 'NAME' => $row['name'], 'PORTAL_TEXT' => $row['p_text'], 'END_LOCATION_REALM' => strval($end_realm), 'END_LOCATION_X' => strval($row['end_location_x']), 'END_LOCATION_Y' => strval($row['end_location_y']), 'OWNER' => is_null($row['owner']) ? '' : strval($row['owner'])));
             return $tpl;
         }
         edit_portal_wrap($member_id, intval($param), $name, post_param('text'), post_param_integer('end_location_realm'), post_param_integer('end_location_x'), post_param_integer('end_location_y'), grab_new_owner('new_owner'), post_param_integer('new_x'), post_param_integer('new_y'), post_param_integer('new_realm'));
     }
     if ($command == 'room') {
         return output_room_screen($member_id);
     }
     ocw_refresh_with_message(do_lang('SUCCESS'));
     return new ocp_tempcode();
 }
コード例 #6
0
ファイル: ocworld.php プロジェクト: erico-deh/ocPortal
/**
 * Wrapper actualiser for a member to pick up an item from the room they are in.
 *
 * @param  MEMBER		The member picking up the item
 * @param  string		The name of the item
 * @param  MEMBER		The owner of the item copy
 */
function basic_pickup($member_id, $item_name, $copy_owner)
{
    add_item_person($member_id, $item_name);
    list($realm, $x, $y) = get_loc_details($member_id);
    take_an_item_from_room($realm, $x, $y, $item_name, $copy_owner);
}
コード例 #7
0
/**
 * Output a room screen.
 *
 * @param  MEMBER		The member who is in the room
 * @return tempcode	Interface
 */
function output_room_screen($member_id)
{
    $title = get_page_title('OCWORLD');
    /*$test_tpl=internalise_own_screen($title); Would require lots of work to make sure all links point right
    	if (is_object($test_tpl)) return $test_tpl;*/
    destick($member_id);
    require_lang('chat');
    require_lang('menus');
    require_javascript('javascript_editing');
    list($realm, $x, $y) = get_loc_details($member_id);
    $rooms = $GLOBALS['SITE_DB']->query_select('w_rooms', array('*'), array('location_x' => $x, 'location_y' => $y, 'location_realm' => $realm), '', 1);
    $room = $rooms[0];
    $room_name = $room['name'];
    $room_text = comcode_to_tempcode($room['r_text'], $room['owner']);
    $pic_url = str_replace(' ', '%20', $room['picture_url']);
    if (url_is_local($pic_url) && $pic_url != '') {
        $pic_url = get_custom_base_url() . '/' . $pic_url;
    }
    $up_room = $GLOBALS['SITE_DB']->query_value_null_ok('w_rooms', 'name', array('location_x' => $x, 'location_y' => $y - 1, 'location_realm' => $realm));
    $locked_up = $room['locked_up'];
    if ($locked_up == 1 || is_null($up_room)) {
        $up_room = '';
    }
    $down_room = $GLOBALS['SITE_DB']->query_value_null_ok('w_rooms', 'name', array('location_x' => $x, 'location_y' => $y + 1, 'location_realm' => $realm));
    $locked_down = $room['locked_down'];
    if ($locked_down == 1 || is_null($down_room)) {
        $down_room = '';
    }
    $right_room = $GLOBALS['SITE_DB']->query_value_null_ok('w_rooms', 'name', array('location_x' => $x + 1, 'location_y' => $y, 'location_realm' => $realm));
    $locked_right = $room['locked_right'];
    if ($locked_right == 1 || is_null($right_room)) {
        $right_room = '';
    }
    $left_room = $GLOBALS['SITE_DB']->query_value_null_ok('w_rooms', 'name', array('location_x' => $x - 1, 'location_y' => $y, 'location_realm' => $realm));
    $locked_left = $room['locked_left'];
    if ($locked_left == 1 || is_null($left_room)) {
        $left_room = '';
    }
    $realm_name = $GLOBALS['SITE_DB']->query_value('w_realms', 'name', array('id' => $realm));
    $has_up_room = !is_null($up_room) && $up_room != '' && $locked_up == 0;
    $has_left_room = !is_null($left_room) && $left_room != '' && $locked_left == 0;
    $has_right_room = !is_null($right_room) && $right_room != '' && $locked_right == 0;
    $has_down_room = !is_null($down_room) && $down_room != '' && $locked_down == 0;
    $rows = $GLOBALS['SITE_DB']->query_select('w_portals', array('name', 'end_location_realm', 'owner'), array('start_location_x' => $x, 'start_location_y' => $y, 'start_location_realm' => $realm), 'ORDER BY name');
    $portals = new ocp_tempcode();
    foreach ($rows as $myrow) {
        $dest_realm = $myrow['end_location_realm'];
        $editable = has_specific_permission($member_id, 'administer_ocworld') || $myrow['owner'] == $member_id;
        $portals->attach(do_template('W_MAIN_PORTAL', array('_GUID' => 'f5582c18b71be98d74dfb8d2b777afc0', 'NAME' => $myrow['name'], 'EDITABLE' => $editable, 'DEST_REALM' => strval($dest_realm))));
    }
    $width = '';
    if ($pic_url != '') {
        $ext = strtolower(substr($pic_url, strlen($pic_url) - 4));
        $mypic = false;
        if ($ext == 'jpeg' || $ext == '.jpg') {
            $mypic = @imagecreatefromjpeg($pic_url);
        }
        if ($ext == '.png') {
            $mypic = @imagecreatefrompng($pic_url);
        }
        if (function_exists('imagecreatefromgif') && $ext == '.gif') {
            $mypic = @imagecreatefromgif($pic_url);
        }
        if ($mypic === false || imagesx($mypic) > 430) {
            $width = 'width: 430px';
        }
    }
    $other_person = post_param_integer('tuser', -1);
    $rows = $GLOBALS['SITE_DB']->query_select('w_members', array('*'), array('location_x' => $x, 'location_y' => $y, 'location_realm' => $realm), 'ORDER BY lastactive DESC');
    $people_here = new ocp_tempcode();
    foreach ($rows as $myrow) {
        $this_member_name = $GLOBALS['FORUM_DRIVER']->get_username($myrow['id']);
        if (is_null($this_member_name)) {
            $this_member_name = do_lang('UNKNOWN');
        }
        $people_here->attach(do_template('W_MAIN_PERSON_HERE', array('_GUID' => 'd799e4343da8daa27459b097bc3b2e89', 'THIS_MEMBER_NAME' => $this_member_name, 'ID' => strval($myrow['id']), 'SELECTED' => false)));
    }
    $rows = $GLOBALS['SITE_DB']->query_select('w_members', array('*'), array('location_x' => $x, 'location_y' => $y, 'location_realm' => $realm), 'ORDER BY lastactive DESC', 15);
    $members = new ocp_tempcode();
    foreach ($rows as $myrow) {
        $id = $myrow['id'];
        $health = $myrow['health'];
        $aux = new ocp_tempcode();
        if ($id >= 0) {
            $name = $GLOBALS['FORUM_DRIVER']->get_username($id);
            if (is_null($name)) {
                $name = do_lang('UNKNOWN');
            }
            if ($myrow['banned'] == 1) {
                $aux = do_lang_tempcode('W_IS_BANNED');
            } elseif ($myrow['health'] < 1) {
                $aux = do_lang_tempcode('W_DEAD');
            }
        } else {
            $name = $GLOBALS['SITE_DB']->query_value('w_realms', 'troll_name', array('id' => -$id - 1));
            $aux = do_lang_tempcode('W_IS_TROLL');
        }
        if ($id == $member_id) {
            $style = 'ocw_self_member';
        } else {
            $style = 'ocw_other_member';
        }
        if ($id < 0) {
            $member_url = '';
        } else {
            $member_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($id, false, true);
        }
        $members->attach(do_template('W_MAIN_MEMBER', array('_GUID' => '83d9f930b68d4988b009b3c06ef783e9', 'HEALTH' => integer_format($health), 'ID' => strval($id), 'MEMBER_URL' => $member_url, 'STYLE' => $style, 'NAME' => $name, 'AUX' => $aux)));
    }
    $rows = $GLOBALS['SITE_DB']->query_select('w_items', array('*'), array('location_x' => $x, 'location_y' => $y, 'location_realm' => $realm, 'cost' => 0));
    $items = new ocp_tempcode();
    foreach ($rows as $myrow) {
        $rows2 = $GLOBALS['SITE_DB']->query_select('w_itemdef', array('*'), array('name' => $myrow['name']), '', 1);
        $myrow2 = $rows2[0];
        $aux = new ocp_tempcode();
        if ($myrow2['healthy'] == 1 && $myrow2['bribable'] == 1) {
            $aux = do_lang_tempcode('W_IS_HEALTH_AND_BRIBABLE');
        } elseif ($myrow2['healthy'] == 1) {
            $aux = do_lang_tempcode('W_IS_HEALTHY');
        } elseif ($myrow2['bribable'] == 1) {
            $aux = do_lang_tempcode('W_IS_BRIBABLE');
        }
        $edit_item_copy_access = has_specific_permission($member_id, 'administer_ocworld') || $myrow['copy_owner'] == $member_id;
        $count = $myrow['not_infinite'] == 1 ? make_string_tempcode(integer_format($myrow['i_count'])) : do_lang_tempcode('W_INFINITE');
        $picture_url = $myrow2['picture_url'];
        if (url_is_local($picture_url) && $picture_url != '') {
            $picture_url = get_custom_base_url() . '/' . str_replace(' ', '%20', $picture_url);
        }
        $items->attach(do_template('W_MAIN_ITEM', array('ACTION' => do_lang_tempcode('W_TAKE'), 'EDIT_ACCESS' => $edit_item_copy_access, 'USER' => strval($myrow['copy_owner']), 'DESCRIPTION' => $myrow2['description'], 'PICTURE_URL' => $picture_url, 'AUX' => $aux, 'NAME' => $myrow['name'], 'COUNT' => $count)));
    }
    $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'w_items WHERE location_x=' . strval((int) $x) . ' AND location_y=' . strval((int) $y) . ' AND location_realm=' . strval((int) $realm) . ' AND cost>0');
    $items_sale = new ocp_tempcode();
    foreach ($rows as $myrow) {
        $rows2 = $GLOBALS['SITE_DB']->query_select('w_itemdef', array('*'), array('name' => $myrow['name']), '', 1);
        $myrow2 = $rows2[0];
        $seller = $GLOBALS['FORUM_DRIVER']->get_username($myrow['copy_owner']);
        if (is_null($seller)) {
            $seller = do_lang('UNKNOWN');
        }
        $aux = new ocp_tempcode();
        if ($myrow2['healthy'] == 1 && $myrow2['bribable'] == 1) {
            $aux = do_lang_tempcode('W_IS_HEALTH_AND_BRIBABLE');
        } elseif ($myrow2['healthy'] == 1) {
            $aux = do_lang_tempcode('W_IS_HEALTHY');
        } elseif ($myrow2['bribable'] == 1) {
            $aux = do_lang_tempcode('W_IS_BRIBABLE');
        }
        $edit_item_copy_access = has_specific_permission($member_id, 'administer_ocworld') || $myrow['copy_owner'] == $member_id;
        $count = $myrow['not_infinite'] == 1 ? make_string_tempcode(integer_format($myrow['i_count'])) : do_lang_tempcode('W_INFINITE');
        $items_sale->attach(do_template('W_MAIN_ITEM', array('_GUID' => 'ab12f8373378abe5852f1d8ee0a05f27', 'ACTION' => do_lang_tempcode('W_BUY'), 'SELLER' => $seller, 'EDIT_ACCESS' => $edit_item_copy_access, 'USER' => strval($myrow['copy_owner']), 'DESCRIPTION' => $myrow2['description'], 'PICTURE_URL' => $myrow2['picture_url'], 'AUX' => $aux, 'NAME' => $myrow['name'], 'COUNT' => $count, 'COST' => integer_format($myrow['cost']))));
    }
    $hide_actions = array_key_exists('hideActions', $_COOKIE) && $_COOKIE['hideActions'] == 1 ? 'display: block;' : 'display: none;';
    $hide_additions = array_key_exists('hideAdditions', $_COOKIE) && $_COOKIE['hideAdditions'] == 1 ? 'display: block;' : 'display: none;';
    $hide_modifications = array_key_exists('hideModifications', $_COOKIE) && $_COOKIE['hideModifications'] == 1 ? 'display: block;' : 'display: none;';
    // PEOPLE HERE
    $other_person = post_param_integer('user', -1);
    $rows = $GLOBALS['SITE_DB']->query_select('w_members', array('*'), array('location_x' => $x, 'location_y' => $y, 'location_realm' => $realm), 'ORDER BY lastactive DESC');
    $people_here = new ocp_tempcode();
    foreach ($rows as $myrow) {
        if ($myrow['id'] >= 0) {
            $this_member_name = $GLOBALS['FORUM_DRIVER']->get_username($myrow['id']);
            if (is_null($this_member_name)) {
                $this_member_name = do_lang('UNKNOWN');
            }
        } else {
            $this_member_name = $GLOBALS['SITE_DB']->query_value('w_realms', 'troll_name', array('id' => -$myrow['id'] - 1));
        }
        $selected = $myrow['id'] == $other_person && !is_null($other_person) || $myrow['id'] == $other_person;
        $people_here->attach(do_template('W_MAIN_PERSON_HERE', array('_GUID' => '4fd3908b7b47338a4f47710c85a060ac', 'THIS_MEMBER_NAME' => $this_member_name, 'ID' => strval($myrow['id']), 'SELECTED' => $selected)));
    }
    if (has_specific_permission($member_id, 'administer_ocworld')) {
        $people_here->attach(do_template('W_MAIN_PEOPLE_SEP'));
        $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'w_members WHERE location_x<>' . strval((int) $x) . ' AND location_y<>' . strval((int) $y) . ' AND location_realm<>' . strval((int) $realm) . ' ORDER BY lastactive DESC', 30);
        foreach ($rows as $myrow) {
            if ($myrow['id'] >= 0) {
                $this_member_name = $GLOBALS['FORUM_DRIVER']->get_username($myrow['id']);
                if (is_null($this_member_name)) {
                    $this_member_name = do_lang('UNKNOWN');
                }
            } else {
                $this_member_name = $GLOBALS['SITE_DB']->query_value('w_realms', 'troll_name', array('id' => -$myrow['id'] - 1));
            }
            $people_here->attach(do_template('W_MAIN_PERSON_HERE', array('_GUID' => '16291e73031cc0254fa6d974d984d353', 'THIS_MEMBER_NAME' => $this_member_name, 'ID' => strval($myrow['id']), 'SELECTED' => false)));
        }
    }
    $people_here = do_template('W_MAIN_PEOPLE_HERE', array('_GUID' => 'c179c25a84cb2919b9bf59f42a77d1dc', 'CONTENT' => $people_here));
    // ITEMS HELD
    $item = post_param('item', '');
    $rows = $GLOBALS['SITE_DB']->query_select('w_inventory', array('*'), array('item_owner' => $member_id));
    $items_held = new ocp_tempcode();
    foreach ($rows as $myrow) {
        $items_held->attach(do_template('W_MAIN_ITEM_OWNED', array('_GUID' => '85b1de9cf8c11b535b28bf033fa11dc9', 'SELECTED' => false, 'NAME' => $myrow['item_name'])));
    }
    $items_held = do_template('W_MAIN_ITEMS_HELD', array('_GUID' => 'bbbc447a1d2ac0aed85ef57ecae79415', 'CONTENT' => $items_held));
    // ITEMS OWNED
    $item = post_param('item', '');
    $rows = $GLOBALS['SITE_DB']->query_select('w_itemdef', array('*'), array('owner' => $member_id));
    $_items_owned = new ocp_tempcode();
    foreach ($rows as $myrow) {
        $selected = $myrow['name'] == $item;
        $tpl = do_template('W_MAIN_ITEM_OWNED', array('_GUID' => 'dfa2971a5196b3c60d9bbd5240b0d269', 'SELECTED' => $selected, 'NAME' => $myrow['name']));
        $_items_owned->attach($tpl);
    }
    if (has_specific_permission($member_id, 'administer_ocworld')) {
        $_items_owned->attach(do_template('W_MAIN_ITEM_OWNED_SEP'));
        $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'w_itemdef WHERE owner<>' . strval((int) $member_id) . ' ORDER BY name');
        foreach ($rows as $myrow) {
            $selected = $myrow['name'] == $item;
            $tpl = do_template('W_MAIN_ITEM_OWNED', array('_GUID' => '84ccf58b51c77257b6a8a76feae19812', 'SELECTED' => $selected, 'NAME' => $myrow['name']));
            $_items_owned->attach($tpl);
        }
    }
    $items_owned = do_template('W_MAIN_ITEMS_OWNED', array('_GUID' => '6738150dc18abd7695623f98133c60fe', 'NAME' => 'item', 'CONTENT' => $_items_owned));
    $items_owned_2 = do_template('W_MAIN_ITEMS_OWNED', array('_GUID' => '471f3536533e534fe29ac910cb854c04', 'NAME' => 'item2', 'CONTENT' => $_items_owned));
    $is_room_owner = !is_null($member_id) || $GLOBALS['SITE_DB']->query_value('w_rooms', 'owner', array('location_x' => $x, 'location_y' => $y, 'location_realm' => $realm)) == $member_id;
    $is_realm_owner = has_specific_permission($member_id, 'administer_ocworld') || $GLOBALS['SITE_DB']->query_value('w_realms', 'owner', array('id' => $realm)) == $member_id;
    $may_do_stuff = !(!has_specific_permission($member_id, 'administer_ocworld') && $GLOBALS['SITE_DB']->query_value('w_realms', 'owner', array('id' => $realm)) != $member_id && $GLOBALS['SITE_DB']->query_value('w_realms', 'r_private', array('id' => $realm)) == 1);
    $may_add_portal = $GLOBALS['SITE_DB']->query_value('w_rooms', 'allow_portal', array('location_x' => $x, 'location_y' => $y, 'location_realm' => $realm)) == 1;
    $is_staff = has_specific_permission($member_id, 'administer_ocworld');
    return do_template('W_MAIN_SCREEN', array('TITLE' => $title, 'REALM_NAME' => $realm_name, 'ROOM_NAME' => $room_name, 'REALM' => strval($realm), 'X' => strval($x), 'Y' => strval($y), 'ROOM_TEXT' => $room_text, 'HAS_UP_ROOM' => $has_up_room, 'HAS_DOWN_ROOM' => $has_down_room, 'HAS_LEFT_ROOM' => $has_left_room, 'HAS_RIGHT_ROOM' => $has_right_room, 'PORTALS' => $portals, 'PIC_URL' => $pic_url, 'MEMBERS' => $members, 'ITEMS' => $items, 'ITEMS_SALE' => $items_sale, 'PEOPLE' => $people_here, 'IS_STAFF' => $is_staff, 'HIDE_MODIFICATIONS' => $hide_modifications, 'HIDE_ADDITIONS' => $hide_additions, 'HIDE_ACTIONS' => $hide_actions, 'MAY_DO_STUFF' => $may_do_stuff, 'MAY_ADD_PORTAL' => $may_add_portal, 'ITEMS_OWNED' => $items_owned, 'ITEMS_OWNED_2' => $items_owned_2, 'ITEMS_HELD' => $items_held, 'WIDTH' => $width, 'IS_ROOM_OWNER' => $is_room_owner, 'IS_REALM_OWNER' => $is_realm_owner, 'EMOTICON_CHOOSER' => $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser(), 'UP_ROOM' => $up_room, 'DOWN_ROOM' => $down_room, 'LEFT_ROOM' => $left_room, 'RIGHT_ROOM' => $right_room));
}