| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined( 'ABSPATH')) exit; |
| 4 |
|
| 5 |
/** |
| 6 |
* |
| 7 |
*/ |
| 8 |
class WPFormsDB_Form_Details |
| 9 |
{ |
| 10 |
private $form_id; |
| 11 |
private $form_post_id; |
| 12 |
|
| 13 |
|
| 14 |
public function __construct() |
| 15 |
{ |
| 16 |
$this->form_post_id = (int) $_GET['fid']; |
| 17 |
$this->form_id = (int) $_GET['ufid']; |
| 18 |
|
| 19 |
$this->form_details_page(); |
| 20 |
} |
| 21 |
|
| 22 |
public function form_details_page(){ |
| 23 |
global $wpdb; |
| 24 |
$cfdb = apply_filters( 'WPFormsDB_database', $wpdb ); |
| 25 |
$table_name = $cfdb->prefix.'wpforms_db'; |
| 26 |
$upload_dir = wp_upload_dir(); |
| 27 |
$WPFormsDB_dir_url = $upload_dir['baseurl'].'/WPFormsDB_uploads'; |
| 28 |
|
| 29 |
if ( is_numeric($this->form_post_id) && is_numeric($this->form_id) ) { |
| 30 |
|
| 31 |
$result = $cfdb->get_row( "SELECT * FROM $table_name WHERE form_post_id = $this->form_post_id AND form_id = $this->form_id LIMIT 1", OBJECT ); |
| 32 |
} |
| 33 |
|
| 34 |
if ( empty($result) ) { |
| 35 |
wp_die( esc_html__( 'Not valid contact form', 'database-for-wpforms' )); |
| 36 |
} |
| 37 |
?> |
| 38 |
<div class="wrap"> |
| 39 |
<div id="welcome-panel" class="cfdb7-panel"> |
| 40 |
<div class="cfdb7-panel-content"> |
| 41 |
<div class="welcome-panel-column-container"> |
| 42 |
<?php do_action('WPFormsDB_before_formdetails_title',$this->form_post_id ); ?> |
| 43 |
<h3><?php echo esc_html( get_the_title( $this->form_post_id ) ); ?></h3> |
| 44 |
<?php do_action('WPFormsDB_after_formdetails_title', $this->form_post_id ); ?> |
| 45 |
<p></span><?php echo esc_html( $result->form_date ); ?></p> |
| 46 |
<?php $form_data = unserialize( $result->form_value, ['allowed_classes' => false] ); |
| 47 |
|
| 48 |
foreach ($form_data as $key => $data): |
| 49 |
|
| 50 |
if ( $key == 'WPFormsDB_status' ) continue; |
| 51 |
|
| 52 |
if ( strpos($key, 'WPFormsDB_file') !== false ){ |
| 53 |
|
| 54 |
$key_val = str_replace('WPFormsDB_file', '', $key); |
| 55 |
$key_val = str_replace('your-', '', $key_val); |
| 56 |
$key_val = ucfirst( $key_val ); |
| 57 |
echo '<p><b>'.esc_html( $key_val ).'</b>: <a href="'. esc_url( $WPFormsDB_dir_url.'/'.$data ).'">' |
| 58 |
. esc_html( $data ).'</a></p>'; |
| 59 |
}else{ |
| 60 |
|
| 61 |
|
| 62 |
if ( is_array($data) ) { |
| 63 |
|
| 64 |
$key_val = str_replace('your-', '', $key); |
| 65 |
$key_val = ucfirst( $key_val ); |
| 66 |
$arr_str_data = implode(', ',$data); |
| 67 |
$arr_str_data = nl2br( $arr_str_data ); |
| 68 |
echo '<p><b>'.esc_html( $key_val ).'</b>: '. esc_html($arr_str_data) .'</p>'; |
| 69 |
|
| 70 |
}else{ |
| 71 |
|
| 72 |
$key_val = str_replace('your-', '', $key); |
| 73 |
$key_val = ucfirst( $key_val ); |
| 74 |
$data = nl2br( $data ); |
| 75 |
echo '<p><b>'.esc_html( $key_val ).'</b>: '.wp_kses($data, ['br' => []]).'</p>'; |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
endforeach; |
| 80 |
|
| 81 |
$form_data['WPFormsDB_status'] = 'read'; |
| 82 |
$form_data = serialize( $form_data ); |
| 83 |
$form_id = $result->form_id; |
| 84 |
|
| 85 |
$sql = $cfdb->prepare( |
| 86 |
"UPDATE {$table_name} SET form_value = %s WHERE form_id = %d", |
| 87 |
$form_data, |
| 88 |
$form_id |
| 89 |
); |
| 90 |
$cfdb->query( $sql ); |
| 91 |
?> |
| 92 |
</div> |
| 93 |
</div> |
| 94 |
</div> |
| 95 |
</div> |
| 96 |
<?php |
| 97 |
do_action('WPFormsDB_after_formdetails', $this->form_post_id ); |
| 98 |
} |
| 99 |
|
| 100 |
} |
| 101 |
|