<?php

formbuilder_admin_nav('edit form');
?>
<form name="form1" method="post" class="formBuilderForm" action="<?php 
echo FB_ADMIN_PLUGIN_PATH;
?>
&fbaction=editForm&fbid=<?php 
echo $form_id;
?>
">

	<h3 class="info-box-title"><?php 
_e('Form Details', 'formbuilder');
?>
</h3>
	<fieldset class="options">
		<p><?php 
_e('You may use these controls to modify a form on your blog.', 'formbuilder');
?>
</p>

		<table width="100%" cellspacing="2" cellpadding="5" class="widefat">
			<tr valign="top">
				<td>
					<h4><?php 
_e('Form Controls', 'formbuilder');
?>
:</h4>
	
					<script type="text/javascript">
<?php

formbuilder_admin_nav('forms');
$_GET += array('pageNumber' => '');
?>
<fieldset class="options metabox-holder">

	<div class="info-box-formbuilder postbox">
		<h3 class="info-box-title hndle"><?php 
_e('Current Forms', 'formbuilder');
?>
</h3>
		<div class="inside">
		<style>
			.formSearch {
			 	display: block;
			 	width: 200px;
			 	float: right;
			 	text-align: right;
			 	padding: 6px;
			}
			.formSearch input {
				width: 120px;
			}
			.formSearch input.searchButton {
				width: auto;
			}
		</style>
		<?php 
if (isset($_GET['formSearch']) && $_GET['formSearch'] != "") {
    $formSearch = preg_replace("#[^a-z0-9 _-]#i", "", $_GET['formSearch']);
<?php

formbuilder_admin_nav('import form');
?>

<form name="formImport" method="POST" action="<?php 
echo FB_ADMIN_PLUGIN_PATH;
?>
&fbaction=importForm">
	<h3 class="info-box-title"><?php 
_e('Form Import', 'formbuilder');
?>
</h3>
	<p><?php 
_e('Enter the exported form data here and press Save.', 'formbuilder');
?>
</p>
	<textarea style="width: 700px; height: 500px;" name="formData"><?php 
echo $formData;
?>
</textarea>
	<br/><input type="submit" name="submit" value="Save" />
</form>
<?php

formbuilder_admin_nav('edit response');
?>
		<form name="form1" method="post" class="formBuilderForm formBuilderAdminForm" action="<?php 
echo FB_ADMIN_PLUGIN_PATH;
?>
&fbaction=editResponse&fbid=<?php 
echo $response_id;
?>
">
			<h3 class="info-box-title"><?php 
_e('Current Autoresponses', 'formbuilder');
?>
</h3>
			<fieldset class="options">
				<p><?php 
_e('You may use these controls to modify an autoresponse on your blog.  When linked to a form, the autoresponse you create here will be emailed to the first email address listed on the form in question.  In other words, you must specify at least one field on the form as requiring an email address.', 'formbuilder');
?>
</p>

				<table width="100%" cellspacing="2" cellpadding="5" class="widefat">
					<tr valign="top">
						<td>
						<h4><?php 
_e('Autoresponse Controls', 'formbuilder');
?>
:</h4>

						<?php 
foreach ($fields as $field) {
        function list_results()
        {
            global $wpdb;
            global $current_user;
            get_currentuserinfo();
            $formFilterID = '';
            $sql_where = array('1=1');
            ?>
		<?php 
            formbuilder_admin_nav('formResults');
            ?>
		<fieldset class="options metabox-holder">
			<div class="info-box-formbuilder postbox">
			
				<style>
					.formHeadBox {
						float: right;
						margin-top: 2px;
						padding-left: 14px;
					}
					em {
						color: #FF0000;
					}
				</style>
				
				<?php 
            // Process form search query if necessary.
            if (isset($_GET['formSearchQuery']) and $_GET['formSearchQuery'] != "") {
                $searchQuery = $_GET['formSearchQuery'];
                $searchQuery = str_replace("\\'", "", $searchQuery);
                $searchQuery = str_replace("'", "", $searchQuery);
                $sql_where[] = "xmldata LIKE '%{$searchQuery}%'";
            } else {
                $searchQuery = '';
            }
            ?>
				<div class='formHeadBox'>
					<form name='formSearchBox' method='get' action=''>
						<?php 
            if (isset($_GET['page'])) {
                ?>
<input type="hidden" name="page" value="<?php 
                echo $_GET['page'];
                ?>
" /><?php 
            }
            ?>
						<?php 
            if (isset($_GET['fbaction'])) {
                ?>
<input type="hidden" name="fbaction" value="<?php 
                echo $_GET['fbaction'];
                ?>
" /><?php 
            }
            ?>
						<?php 
            if (isset($_GET['pageNumber'])) {
                ?>
<input type="hidden" name="pageNumber" value="<?php 
                echo $_GET['pageNumber'];
                ?>
" /><?php 
            }
            ?>
						<?php 
            if (isset($_GET['formFilterID'])) {
                ?>
<input type="hidden" name="formFilterID" value="<?php 
                echo $_GET['formFilterID'];
                ?>
" /><?php 
            }
            ?>
						<input type="text" name="formSearchQuery" value="<?php 
            echo $searchQuery;
            ?>
" helptext="Search..." />
						<input type="submit" name="submit" value="Find" />
					</form>
				</div>
				
				<?php 
            $sql = "SELECT * FROM " . FORMBUILDER_TABLE_FORMS . " ORDER BY name ASC;";
            $results = $wpdb->get_results($sql, ARRAY_A);
            $forms = array();
            $allFormIDs = array();
            foreach ($results as $formData) {
                $forms[$formData['id']] = $formData;
                $allFormIDs[] = $formData['id'];
            }
            if (isset($_GET['formFilterID'])) {
                if (is_numeric($_GET['formFilterID']) and isset($forms[$_GET['formFilterID']])) {
                    $sql_where[] = "form_id = " . $_GET['formFilterID'];
                    $formFilterID = "&form_id=" . $_GET['formFilterID'];
                }
                if ($_GET['formFilterID'] == 'orphaned') {
                    $sql_where[] = "form_id NOT IN (" . implode(',', $allFormIDs) . ")";
                    $formFilterID = "&form_id=orphaned";
                }
            }
            ?>
				<div class='formHeadBox'>
					<form name='formFilterBox' method='get' action=''>
						<select name='formFilterID'>
							<option value=''><?php 
            if ($formFilterID) {
                ?>
Show all forms...<?php 
            } else {
                ?>
Filter by form...<?php 
            }
            ?>
</option>
							<?php 
            foreach ($forms as $formData) {
                $selected = '';
                if (isset($_GET['formFilterID']) and $formData['id'] == $_GET['formFilterID']) {
                    $selected = "selected='selected'";
                }
                $name = $formData['name'];
                if (strlen($name) > 20) {
                    $name = substr($name, 0, 20) . '...';
                }
                echo "\n<option value='{$formData['id']}' {$selected}>" . $name . "</option>";
            }
            ?>
							<option value='orphaned' <?php 
            if (isset($_GET['formFilterID']) and $_GET['formFilterID'] == 'orphaned') {
                ?>
selected='selected'<?php 
            }
            ?>
>Show Orphaned Forms</option>
						</select>
						<?php 
            if (isset($_GET['page'])) {
                ?>
<input type="hidden" name="page" value="<?php 
                echo $_GET['page'];
                ?>
" /><?php 
            }
            ?>
						<?php 
            if (isset($_GET['fbaction'])) {
                ?>
<input type="hidden" name="fbaction" value="<?php 
                echo $_GET['fbaction'];
                ?>
" /><?php 
            }
            ?>
						<?php 
            if (isset($_GET['pageNumber'])) {
                ?>
<input type="hidden" name="pageNumber" value="<?php 
                echo $_GET['pageNumber'];
                ?>
" /><?php 
            }
            ?>
						<?php 
            if (isset($_GET['formSearchQuery'])) {
                ?>
<input type="hidden" name="formSearchQuery" value="<?php 
                echo $_GET['formSearchQuery'];
                ?>
" /><?php 
            }
            ?>
						<input type="submit" name="submit" value="Go" />
					</form>
				</div>
		
				<h3 class="info-box-title hndle"><?php 
            _e('Recent Form Results:', 'formbuilder');
            ?>
</h3>
		
		<?php 
            if (isset($_POST['formResultSelected']) and isset($_POST['formResultSelectedAction'])) {
                switch ($_POST['formResultSelectedAction']) {
                    case 'Delete':
                        if (is_array($_POST['formResultSelected'])) {
                            $selected = $_POST['formResultSelected'];
                            foreach ($selected as $formResultID) {
                                if (is_numeric($formResultID) and preg_match('/^[0-9]+$/isu', $formResultID)) {
                                    $sql = "DELETE FROM " . FORMBUILDER_TABLE_RESULTS . " WHERE id = '" . $formResultID . "' LIMIT 1;";
                                    $result = $wpdb->query($sql);
                                } else {
                                    echo "Invalid form result ID detected: {$formResultID}<br/>\n";
                                }
                            }
                        }
                        break;
                    case 'Export':
                        if (is_array($_POST['formResultSelected'])) {
                            $selected = $_POST['formResultSelected'];
                            foreach ($selected as $formResultID) {
                                if (is_numeric($formResultID) and preg_match('/^[0-9]+$/isu', $formResultID)) {
                                    $export_ids[] = $formResultID;
                                } else {
                                    echo "Invalid form result ID detected: {$formResultID}<br/>\n";
                                }
                            }
                            $export_ids_string = implode(",", $export_ids);
                            $hash = md5($export_ids_string);
                            update_option('formbuilder_db_export_ids', $export_ids_string);
                            $url = FORMBUILDER_PLUGIN_URL . "php/formbuilder_export_results.php?h={$hash}";
                            echo "<meta HTTP-EQUIV='REFRESH' content='2; url=" . $url . "'><p>Your export should start automatically in a few seconds.  <a href='{$url}'>Click here if it does not.</a></p>";
                            return;
                        }
                        break;
                    case 'Resend':
                        if (is_array($_POST['formResultSelected'])) {
                            $selected = $_POST['formResultSelected'];
                            foreach ($selected as $formResultID) {
                                if (is_numeric($formResultID) and preg_match('/^[0-9]+$/isu', $formResultID)) {
                                    $resend_ids[] = $formResultID;
                                } else {
                                    echo "Invalid form result ID detected: {$formResultID}<br/>\n";
                                }
                            }
                            $resend_ids_string = implode(",", $resend_ids);
                            $name = 'Name:' . $current_user->user_login;
                            $timestamp = 'Time:' . time();
                            $resend_ids_string = "{$name},{$timestamp},{$resend_ids_string}";
                            $hash = md5($resend_ids_string);
                            update_option('formbuilder_db_resend_ids', $resend_ids_string);
                            $url = FB_ADMIN_PLUGIN_PATH . "&fbaction=formResults&fbxmlaction=mass-resend&h={$hash}";
                            echo "<meta HTTP-EQUIV='REFRESH' content='30; url=" . $url . "'><p>Preparing to resend.  <a href='{$url}'>Click here to proceed manually.</a></p>";
                            return;
                        }
                        break;
                    default:
                        break;
                }
            }
            // Check to see if we should display multiple pages.
            if (isset($_GET['pageNumber']) and preg_match("#^[0-9]+\$#isU", $_GET['pageNumber'])) {
                $result_page = $_GET['pageNumber'];
            } else {
                $result_page = 1;
            }
            // Turn the sql_where array into an actual sql statement.
            $sql_where = implode(" AND ", $sql_where);
            $sql = "SELECT id FROM " . FORMBUILDER_TABLE_RESULTS . " WHERE {$sql_where};";
            //		echo "\n<br/>$sql";
            $result = $wpdb->get_col($sql, ARRAY_A);
            $total_rows = count($result);
            $paged_nav = fb_get_paged_nav($total_rows, $this->result_limit, false);
            ?>
					<script type="text/javascript">
					function checkAll()
					{
						var inputs = document.getElementsByTagName('input');
						var checkboxes = [];
						for (var i = 0; i < inputs.length; i++) 
						{
							if (inputs[i].type == 'checkbox' && inputs[i].value != 'all results') 
							{
								if(inputs[i].checked == true)
								{
									inputs[i].checked = false;
								}
								else
								{
									inputs[i].checked = true;
								}
							}
						}
					}
					</script>
						<?php 
            // Iterate through the results and display them line by line.
            echo "<form action='' method='POST' name='formResultsList'><table class='widefat'>";
            echo "<tr class='fbexporttable'>" . "<td><a href='javascript:;' onclick='checkAll()' title='" . __('Click to toggle all ON or OFF.', 'formbuilder') . "'>" . __('toggle', 'formbuilder') . "</a></td>" . "<td><strong>" . __("Date:", 'formbuilder') . "</strong></td>" . "<td>" . "<span class='fbexport'>" . "<a href='" . FB_ADMIN_PLUGIN_PATH . "&fbaction=formResults&fbxmlaction=massdelete{$formFilterID}'><strong>" . __("Mass Delete", 'formbuilder') . "</strong></a>" . "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href='" . FB_ADMIN_PLUGIN_PATH . "&fbaction=formResults&fbxmlaction=showexport{$formFilterID}'><strong>" . __("Full Export", 'formbuilder') . "</strong></a>" . "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;" . __('Page:', 'formbuilder') . " {$paged_nav}" . "</span>" . "<strong>" . __("Message:", 'formbuilder') . "</strong>" . "</td>" . "</tr>";
            // Calculate time offset
            $currentTime = current_time('timestamp');
            $offset = time() - $currentTime;
            for ($i = 0; $i < $this->result_limit; $i++) {
                $sql_offset = $this->result_limit * ($result_page - 1);
                $sql = "SELECT * FROM " . FORMBUILDER_TABLE_RESULTS . " \n\t\t\t\t\t\t\tWHERE {$sql_where} \n\t\t\t\t\t\t\tORDER BY timestamp \n\t\t\t\t\t\t\tDESC LIMIT {$sql_offset}," . $this->result_limit . ";";
                //echo "\n<br/>" . $sql;
                $result = $wpdb->get_row($sql, ARRAY_A, $i);
                if ($result == false) {
                    break;
                }
                $form_data = $this->xmltoarray($result['xmldata']);
                $message = "";
                foreach ($form_data['form'] as $key => $value) {
                    if ($key != 'FormRecipient') {
                        $message .= strtoupper($key) . ": " . $value . "\n";
                    }
                }
                // Highlight any/all search query results.
                if ($searchQuery) {
                    $message = str_ireplace($searchQuery, "<em>{$searchQuery}</em>", $message);
                }
                $searchQueryVar = "";
                if (strlen($message) > 80) {
                    if ($searchQuery) {
                        $p1 = strpos($message, '<em>');
                        if ($p1 !== false) {
                            $message = "..." . substr($message, $p1 - 20, 85) . "...";
                            $searchQueryVar = "&searchQuery={$searchQuery}";
                        } else {
                            $message = substr($message, 0, 80) . "...";
                        }
                    } else {
                        $message = substr($message, 0, 80) . "...";
                    }
                }
                $messageDate = date("F j, Y, g:i a", $result['timestamp'] - $offset);
                echo "<tr class='hoverlite'>" . "<td><input type='checkbox' class='fb_stored_messages' name='formResultSelected[]' value='" . $result['id'] . "'/></td>" . "<td><a href='" . FB_ADMIN_PLUGIN_PATH . "&fbaction=formResults&fbxmlaction=showemail&fbxmlid=" . $result['id'] . $searchQueryVar . "'>" . $messageDate . "</a></td>" . "<td>" . $message . "</td>" . "</tr>";
            }
            $curpos = $sql_offset + $this->result_limit;
            echo "<tr><td colspan=3 align='left'>" . __('With Selected:', 'formbuilder') . " <select name='formResultSelectedAction'>" . "<option value=''></option>" . "<option value='Export'>" . __('Export', 'formbuilder') . "</option>" . "<option value='Delete'>" . __('Delete', 'formbuilder') . "</option>" . "<option value='Resend'>" . __('Resend', 'formbuilder') . "</option>" . "</select>" . " <input type='submit' value='" . __('Go', 'formbuilder') . "' />" . "<font style='float: right;'>" . __('Page:', 'formbuilder') . " {$paged_nav}</font></td></tr>";
            echo "</table></form>";
            ?>
			</div>
		</fieldset>		
		<?php 
        }
<?php

formbuilder_admin_nav('export form');
?>

<h3 class="info-box-title"><?php 
_e('Form Export', 'formbuilder');
?>
</h3>
<p><?php 
_e('The following text contains the data required to move this form to another site.  To move it, copy the entire text and paste it into the Import Form box on your secondary site.', 'formbuilder');
?>
</p>
<textarea style="width: 700px; height: 500px;"><?php 
echo $formData;
?>
</textarea>
<?php

formbuilder_admin_nav('strings');
?>
<fieldset class="options metabox-holder">

	<div class="info-box-formbuilder postbox">
		<h3 class="info-box-title hndle"><?php 
_e('Translatable Strings', 'formbuilder');
?>
</h3>
		<div class="inside">
		<p><?php 
_e('In some cases it can be useful to have text strings that appear on the site show up in another language without having to translate the entire WordPress interface.  This page allows you to translate or change all text that isn\'t form specific displayed to the visitor when filling out forms on the site.', 'formbuilder');
?>
</p>
		
		<form action="" method="POST">
		<table class="widefat">
			<tr valign="top">
				<th><?php 
_e('Text String', 'formbuilder');
?>
</th>
				<th><?php 
_e('Translated String', 'formbuilder');
?>
</th>
			</tr>
			
			<tr valign="top">
<?php

formbuilder_admin_nav('settings');
?>
<fieldset class="options metabox-holder">

	<div id="formbuilder-admin-left">

		<div class="info-box-formbuilder postbox">
			<?php 
$fb_permissions = get_option('formbuilder_permissions');
if (isset($_POST['permissions_save']) or isset($_POST['formbuilder_permissions'])) {
    $p = $_POST['formbuilder_permissions'];
    foreach ($fb_permissions as $level => $cap_a) {
        foreach ($cap_a as $cap => $value) {
            if (isset($p[$level][$cap]) and $p[$level][$cap] == 'yes') {
                $fb_permissions[$level][$cap] = 'yes';
            } else {
                $fb_permissions[$level][$cap] = 'no';
            }
        }
    }
    $fb_permissions['level_10']['manage'] = 'yes';
    update_option('formbuilder_permissions', $fb_permissions);
    formbuilder_admin_alert(__('Saved new permissions settings.'));
}
?>
			<h3 class='info-box-title hndle'><?php 
_e('Permissions Configuration:', 'formbuilder');
?>
 </h3>
        function list_results()
        {
            global $wpdb;
            global $current_user;
            get_currentuserinfo();
            ?>
		<?php 
            formbuilder_admin_nav('formResults');
            ?>
		<fieldset class="options metabox-holder">
			<div class="info-box-formbuilder postbox">
				<h3 class="info-box-title hndle"><?php 
            _e('Recent Form Results:', 'formbuilder');
            ?>
</h3>
		
		<?php 
            if (isset($_POST['formResultSelected']) and isset($_POST['formResultSelectedAction'])) {
                switch ($_POST['formResultSelectedAction']) {
                    case 'Delete':
                        if (is_array($_POST['formResultSelected'])) {
                            $selected = $_POST['formResultSelected'];
                            foreach ($selected as $formResultID) {
                                if (is_numeric($formResultID) and preg_match('/^[0-9]+$/isu', $formResultID)) {
                                    $sql = "DELETE FROM " . FORMBUILDER_TABLE_RESULTS . " WHERE id = '" . $formResultID . "' LIMIT 1;";
                                    $result = $wpdb->query($sql);
                                } else {
                                    echo "Invalid form result ID detected: {$formResultID}<br/>\n";
                                }
                            }
                        }
                        break;
                    case 'Export':
                        if (is_array($_POST['formResultSelected'])) {
                            $selected = $_POST['formResultSelected'];
                            foreach ($selected as $formResultID) {
                                if (is_numeric($formResultID) and preg_match('/^[0-9]+$/isu', $formResultID)) {
                                    $export_ids[] = $formResultID;
                                } else {
                                    echo "Invalid form result ID detected: {$formResultID}<br/>\n";
                                }
                            }
                            $export_ids_string = implode(",", $export_ids);
                            $hash = md5($export_ids_string);
                            update_option('formbuilder_db_export_ids', $export_ids_string);
                            $url = FORMBUILDER_PLUGIN_URL . "php/formbuilder_export_results.php?h={$hash}";
                            echo "<meta HTTP-EQUIV='REFRESH' content='2; url=" . $url . "'><p>Your export should start automatically in a few seconds.  <a href='{$url}'>Click here if it does not.</a></p>";
                            return;
                        }
                        break;
                    case 'Resend':
                        if (is_array($_POST['formResultSelected'])) {
                            $selected = $_POST['formResultSelected'];
                            foreach ($selected as $formResultID) {
                                if (is_numeric($formResultID) and preg_match('/^[0-9]+$/isu', $formResultID)) {
                                    $resend_ids[] = $formResultID;
                                } else {
                                    echo "Invalid form result ID detected: {$formResultID}<br/>\n";
                                }
                            }
                            $resend_ids_string = implode(",", $resend_ids);
                            $name = 'Name:' . $current_user->user_login;
                            $timestamp = 'Time:' . time();
                            $resend_ids_string = "{$name},{$timestamp},{$resend_ids_string}";
                            $hash = md5($resend_ids_string);
                            update_option('formbuilder_db_resend_ids', $resend_ids_string);
                            $url = FB_ADMIN_PLUGIN_PATH . "&fbaction=formResults&fbxmlaction=mass-resend&h={$hash}";
                            echo "<meta HTTP-EQUIV='REFRESH' content='30; url=" . $url . "'><p>Preparing to resend.  <a href='{$url}'>Click here to proceed manually.</a></p>";
                            return;
                        }
                        break;
                    default:
                        break;
                }
            }
            // Check to see if we should display multiple pages.
            if (isset($_GET['pageNumber']) and eregi("^[0-9]+\$", $_GET['pageNumber'])) {
                $result_page = $_GET['pageNumber'];
            } else {
                $result_page = 1;
            }
            $sql = "SELECT id FROM " . FORMBUILDER_TABLE_RESULTS . ";";
            $result = $wpdb->get_col($sql, ARRAY_A);
            $total_rows = count($result);
            $paged_nav = fb_get_paged_nav($total_rows, $this->result_limit, false);
            ?>
					<script type="text/javascript">
					function checkAll()
					{
						var inputs = document.getElementsByTagName('input');
						var checkboxes = [];
						for (var i = 0; i < inputs.length; i++) 
						{
							if (inputs[i].type == 'checkbox' && inputs[i].value != 'all results') 
							{
								if(inputs[i].checked == true)
								{
									inputs[i].checked = false;
								}
								else
								{
									inputs[i].checked = true;
								}
							}
						}
					}
					</script>
						<?php 
            // Iterate through the results and display them line by line.
            echo "<form action='' method='POST' name='formResultsList'><table class='widefat'>";
            echo "<tr class='fbexporttable'>" . "<td><a href='javascript:;' onclick='checkAll()' title='" . __('Click to toggle all ON or OFF.', 'formbuilder') . "'>" . __('toggle', 'formbuilder') . "</a></td>" . "<td><strong>" . __("Date:", 'formbuilder') . "</strong></td>" . "<td>" . "<span class='fbexport'>" . "<a href='" . FB_ADMIN_PLUGIN_PATH . "&fbaction=formResults&fbxmlaction=massdelete'><strong>" . __("Mass Delete", 'formbuilder') . "</strong></a>" . "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href='" . FB_ADMIN_PLUGIN_PATH . "&fbaction=formResults&fbxmlaction=showexport'><strong>" . __("Full Export", 'formbuilder') . "</strong></a>" . "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;" . __('Page:', 'formbuilder') . " {$paged_nav}" . "</span>" . "<strong>" . __("Message:", 'formbuilder') . "</strong>" . "</td>" . "</tr>";
            for ($i = 0; $i < $this->result_limit; $i++) {
                $sql_offset = $this->result_limit * ($result_page - 1);
                $sql = "SELECT * FROM " . FORMBUILDER_TABLE_RESULTS . " ORDER BY timestamp DESC LIMIT {$sql_offset}," . $this->result_limit . ";";
                $result = $wpdb->get_row($sql, ARRAY_A, $i);
                if ($result == false) {
                    break;
                }
                $form_data = $this->xmltoarray($result['xmldata']);
                $message = "";
                foreach ($form_data['form'] as $key => $value) {
                    if ($key != 'FormRecipient') {
                        $message .= strtoupper($key) . ": " . $value . "\n";
                    }
                }
                if (strlen($message) > 80) {
                    $message = substr($message, 0, 80) . "...";
                }
                echo "<tr class='hoverlite'>" . "<td><input type='checkbox' class='fb_stored_messages' name='formResultSelected[]' value='" . $result['id'] . "'/></td>" . "<td><a href='" . FB_ADMIN_PLUGIN_PATH . "&fbaction=formResults" . "&fbxmlaction=showemail&fbxmlid=" . $result['id'] . "'>" . date("F j, Y, g:i a", $result['timestamp']) . "</a></td>" . "<td>" . $message . "</td>" . "</tr>";
            }
            $curpos = $sql_offset + $this->result_limit;
            echo "<tr><td colspan=3 align='left'>" . __('With Selected:', 'formbuilder') . " <select name='formResultSelectedAction'>" . "<option value=''></option>" . "<option value='Export'>" . __('Export', 'formbuilder') . "</option>" . "<option value='Delete'>" . __('Delete', 'formbuilder') . "</option>" . "<option value='Resend'>" . __('Resend', 'formbuilder') . "</option>" . "</select>" . " <input type='submit' value='" . __('Go', 'formbuilder') . "' />" . "<font style='float: right;'>" . __('Page:', 'formbuilder') . " {$paged_nav}</font></td></tr>";
            echo "</table></form>";
            ?>
			</div>
		</fieldset>		
		<?php 
        }