PluginProbe
Form Maker by 10Web – Mobile-Friendly Drag & Drop Contact Form Builder / 1.13.7
Form Maker by 10Web – Mobile-Friendly Drag & Drop Contact Form Builder v1.13.7
1.15.47 1.15.46 1.15.45 1.15.44 1.15.43 1.13.45 1.13.46 1.13.47 1.13.48 1.13.49 1.13.5 1.13.50 1.13.51 1.13.52 1.13.53 1.13.54 1.13.55 1.13.56 1.13.57 1.13.58 1.13.59 1.13.60 1.13.7 1.13.8 1.13.9 All 351 releases
form-maker / admin / controllers / FormMakerSQLMapping.php

FormMakerSQLMapping.php in Form Maker by 10Web – Mobile-Friendly Drag & Drop Contact Form Builder 1.13.7, at admin/controllers/FormMakerSQLMapping.php

177 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class FMControllerFormMakerSQLMapping
5 */
6 class FMControllerFormMakerSQLMapping extends FMAdminController {
7 /**
8 * @var $model
9 */
10 private $model;
11 /**
12 * @var $view
13 */
14 private $view;
15
16 /**
17 * FMControllerFormMakerSQLMapping constructor.
18 */
19 public function __construct() {
20 // Load FMModelFormMakerSQLMapping class.
21 require_once WDFMInstance(self::PLUGIN)->plugin_dir . "/admin/models/FMSqlMapping.php";
22 $this->model = new FMModelFormMakerSQLMapping();
23 // Load FMViewFormMakerSQLMapping class.
24 require_once WDFMInstance(self::PLUGIN)->plugin_dir . "/admin/views/FMSqlMapping.php";
25 $this->view = new FMViewFormMakerSQLMapping();
26 }
27
28 /**
29 * Execute.
30 */
31 public function execute() {
32 $id = WDW_FM_Library(self::PLUGIN)->get('id', '');
33 $form_id = WDW_FM_Library(self::PLUGIN)->get('form_id', '');
34 $task = WDW_FM_Library(self::PLUGIN)->get('task', '');
35 if ( $task && method_exists($this, $task) ) {
36 $this->$task($form_id);
37 }
38 else {
39 if ( $id ) {
40 $this->edit_query($id, $form_id);
41 }
42 else {
43 $this->add_query($form_id);
44 }
45 }
46 }
47
48 /**
49 * Add query.
50 *
51 * @param int $form_id
52 */
53 public function add_query( $form_id = 0 ) {
54 // Get labels by form id.
55 $label = $this->model->get_labels($form_id);
56 // Set params for view.
57 $params = array();
58 $params['label'] = $label;
59 $params['form_id'] = $form_id;
60 $this->view->add_query($params);
61 }
62
63 /**
64 * Edit query.
65 *
66 * @param int $id
67 * @param int $form_id
68 */
69 public function edit_query( $id = 0, $form_id = 0 ) {
70 // Get labels by form id.
71 $label = $this->model->get_labels($form_id);
72 // Get query by id.
73 $query_obj = $this->model->get_query($id);
74 $temp = explode('***wdfcon_typewdf***', $query_obj->details);
75 $con_type = $temp[0];
76 $temp = explode('***wdfcon_methodwdf***', $temp[1]);
77 $con_method = $temp[0];
78 $temp = explode('***wdftablewdf***', $temp[1]);
79 $table_cur = $temp[0];
80 $temp = explode('***wdfhostwdf***', $temp[1]);
81 $host = $temp[0];
82 $temp = explode('***wdfportwdf***', $temp[1]);
83 $port = $temp[0];
84 if ($port) {
85 $host .= ':' . $port;
86 }
87 $temp = explode('***wdfusernamewdf***', $temp[1]);
88 $username = $temp[0];
89 $temp = explode('***wdfpasswordwdf***', $temp[1]);
90 $password = $temp[0];
91 $temp = explode('***wdfdatabasewdf***', $temp[1]);
92 $database = $temp[0];
93 $details = $temp[1];
94 $tables = $this->model->get_tables_saved($con_type, $username, $password, $database, $host);
95 $table_struct = $this->model->get_table_struct_saved($con_type, $username, $password, $database, $host, $table_cur, $con_method);
96 // Set params for view.
97 $params = array();
98 $params['id'] = $id;
99 $params['form_id'] = $form_id;
100 $params['label'] = $label;
101 $params['query_obj'] = $query_obj;
102 $params['tables'] = $tables;
103 $params['table_struct'] = $table_struct;
104 $this->view->edit_query($params);
105 }
106
107 /**
108 * DB tables.
109 *
110 * @param int $form_id
111 */
112 public function db_tables( $form_id = 0 ) {
113 // Get all tables.
114 $tables = $this->model->get_tables();
115 // Set params for view.
116 $params = array();
117 $params['tables'] = $tables;
118 $params['form_id'] = $form_id;
119 $this->view->db_tables($params);
120 }
121
122 /**
123 * DB table struct.
124 *
125 * @param int $form_id
126 */
127 public function db_table_struct( $form_id = 0 ) {
128 $con_method = WDW_FM_Library(self::PLUGIN)->get('con_method', '');
129 // Get labels by form id.
130 $label = $this->model->get_labels($form_id);
131 // Get table struct.
132 $table_struct = $this->model->get_table_struct();
133 // Set params for view.
134 $params = array();
135 $params['form_id'] = $form_id;
136 $params['label'] = $label;
137 $params['table_struct'] = $table_struct;
138 $params['con_method'] = $con_method;
139 $this->view->db_table_struct($params);
140 }
141
142 /**
143 * Save query.
144 */
145 public function save_query() {
146 global $wpdb;
147 $form_id = ((isset($_GET['form_id'])) ? (int) $_GET['form_id'] : 0);
148 $query = ((isset($_POST['query'])) ? stripslashes(wp_specialchars_decode($_POST['query'])) : "");
149 $details = ((isset($_POST['details'])) ? esc_html($_POST['details']) : "");
150 $save = $wpdb->insert($wpdb->prefix . 'formmaker_query', array(
151 'form_id' => $form_id,
152 'query' => $query,
153 'details' => $details,
154 ), array(
155 '%d',
156 '%s',
157 '%s',
158 ));
159 }
160
161 /**
162 * Update query.
163 */
164 public function update_query() {
165 global $wpdb;
166 $id = ((isset($_GET['id'])) ? (int) $_GET['id'] : 0);
167 $form_id = ((isset($_GET['form_id'])) ? (int) $_GET['form_id'] : 0);
168 $query = ((isset($_POST['query'])) ? stripslashes(wp_specialchars_decode($_POST['query'])) : "");
169 $details = ((isset($_POST['details'])) ? esc_html($_POST['details']) : "");
170 $save = $wpdb->update($wpdb->prefix . 'formmaker_query', array(
171 'form_id' => $form_id,
172 'query' => $query,
173 'details' => $details,
174 ), array( 'id' => $id ));
175 }
176 }
177