function view_user()
 {
     global $conn, $lang, $config, $user;
     require_once $config['basepath'] . '/include/misc.inc.php';
     require_once $config['basepath'] . '/include/images.inc.php';
     $display = '';
     $user = intval($_GET['user']);
     if ($user != "") {
         $misc = new misc();
         $sql = "SELECT userdb_is_agent, userdb_is_admin FROM " . $config['table_prefix'] . "userdb WHERE userdb_id = " . $user . "";
         $recordSet = $conn->Execute($sql);
         if ($recordSet === false) {
             $misc->log_error($sql);
         }
         // get main listings data
         while (!$recordSet->EOF) {
             $is_agent = $misc->make_db_unsafe($recordSet->fields['userdb_is_agent']);
             $is_admin = $misc->make_db_unsafe($recordSet->fields['userdb_is_admin']);
             $recordSet->MoveNext();
         }
         // end while
         if ($is_agent == 'yes' || $is_admin == true && $config["show_listedby_admin"] == 1) {
             require_once dirname(__FILE__) . '/class/template/core.inc.php';
             $page = new page_user();
             require_once dirname(__FILE__) . '/images.inc.php';
             $image_handler = new image_handler();
             require_once dirname(__FILE__) . '/files.inc.php';
             $file_handler = new file_handler();
             $page->load_page($config['template_path'] . '/' . $config['agent_template']);
             //Replace Tags
             $page->page = str_replace('{user_last_name}', $this->get_user_last_name($user), $page->page);
             $page->page = str_replace('{user_first_name}', $this->get_user_first_name($user), $page->page);
             $page->page = str_replace('{user_images_thumbnails}', $image_handler->renderUserImages($user), $page->page);
             $page->page = str_replace('{user_display_info}', $this->renderUserInfo($user), $page->page);
             $page->page = str_replace('{user_contact_link}', $this->contact_agent_link($user), $page->page);
             $page->page = str_replace('{user_vcard_link}', $this->vcard_agent_link($user), $page->page);
             $page->page = str_replace('{user_listings_list}', $this->userListings($user), $page->page);
             $page->page = str_replace('{user_hit_count}', $this->userHitcount($user), $page->page);
             $page->page = str_replace('{user_id}', $user, $page->page);
             $page->page = str_replace('{user_listings_link}', $this->userListingsLink($user), $page->page);
             $page->page = str_replace('{files_user_horizontal}', $file_handler->render_templated_files($user, 'user', 'horizontal'), $page->page);
             $page->page = str_replace('{files_user_vertical}', $file_handler->render_templated_files($user, 'user', 'vertical'), $page->page);
             $page->page = str_replace('{user_files_select}', $file_handler->render_files_select($user, 'user'), $page->page);
             // Handle Caption Only
             $page->page = preg_replace_callback('/{user_field_([^{}]*?)_caption}/', create_function('$matches', 'global $config,$user,$lang;require_once($config[\'basepath\'].\'/include/user.inc.php\'); return user::renderSingleListingItem($user, $matches[1],\'caption\');'), $page->page);
             // Hanle VlaueOnly
             $page->page = preg_replace_callback('/{user_field_([^{}]*?)_value}/', create_function('$matches', 'global $config,$user,$lang;require_once($config[\'basepath\'].\'/include/user.inc.php\'); return user::renderSingleListingItem($user, $matches[1],\'value\');'), $page->page);
             // Handle Raw Value
             $page->page = preg_replace_callback('/{user_field_([^{}]*?)_rawvalue}/', create_function('$matches', 'global $config,$user,$lang;require_once($config[\'basepath\'].\'/include/user.inc.php\'); return user::renderSingleListingItem($user, $matches[1],\'rawvalue\');'), $page->page);
             // Handle Both Caption and Value
             $page->page = preg_replace_callback('/{user_field_([^{}]*?)}/', create_function('$matches', 'global $config,$user,$lang;require_once($config[\'basepath\'].\'/include/user.inc.php\'); return user::renderSingleListingItem($user, $matches[1]);'), $page->page);
             // Insert Agent Image
             $sql2 = "SELECT userimages_thumb_file_name FROM " . $config['table_prefix'] . "userimages WHERE userdb_id = {$user} ORDER BY userimages_rank";
             $recordSet2 = $conn->Execute($sql2);
             if ($recordSet2 === false) {
                 $misc->log_error($sql2);
             }
             $num_images = $recordSet2->RecordCount();
             if ($num_images == 0) {
                 if ($config['show_no_photo'] == 1) {
                     $agent_image = '<img src="images/nophoto.gif" alt="' . $lang['no_photo'] . '" />';
                     $raw_agent_image = 'images/nophoto.gif';
                 } else {
                     $agent_image = '';
                     $raw_agent_image = '';
                 }
                 $page->page = $page->parse_template_section($page->page, 'agent_image_thumb_1', $agent_image);
                 $page->page = $page->parse_template_section($page->page, 'raw_agent_image_thumb_1', $raw_agent_image);
             }
             $x = 1;
             while (!$recordSet2->EOF) {
                 $thumb_file_name = $misc->make_db_unsafe($recordSet2->fields['userimages_thumb_file_name']);
                 if ($thumb_file_name != "") {
                     // gotta grab the image size
                     $imagedata = GetImageSize("{$config['user_upload_path']}/{$thumb_file_name}");
                     $imagewidth = $imagedata[0];
                     $imageheight = $imagedata[1];
                     $shrinkage = $config['thumbnail_width'] / $imagewidth;
                     $displaywidth = $imagewidth * $shrinkage;
                     $displayheight = $imageheight * $shrinkage;
                     $agent_image = '<img src="' . $config['user_view_images_path'] . '/' . $thumb_file_name . '" height="' . $displayheight . '" width="' . $displaywidth . '" alt="' . $thumb_file_name . '" />';
                     $raw_agent_image = $config['user_view_images_path'] . '/' . $thumb_file_name;
                 }
                 // end if ($thumb_file_name != "")
                 // We have the image so insert it into the section.
                 $page->page = $page->parse_template_section($page->page, 'agent_image_thumb_' . $x, $agent_image);
                 $page->page = $page->parse_template_section($page->page, 'raw_agent_image_thumb_' . $x, $raw_agent_image);
                 $x++;
                 $recordSet2->MoveNext();
             }
             // end while
             $page->page = preg_replace('{agent_image_thumb_(.*?)}', '', $page->page);
             $page->page = preg_replace('{raw_agent_image_thumb_(.*?)}', '', $page->page);
             $display = $page->page;
         } else {
             $display = $lang['user_manager_invalid_user_id'];
         }
     }
     return $display;
 }