PageRenderTime 61ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/shop quần áo starloveshop.com/wp-content/plugins/popup-with-fancybox/pages/content-management-edit.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 233 lines | 205 code | 22 blank | 6 comment | 34 complexity | 5b5daa137933a468719157968ee8b9a2 MD5 | raw file
  1. <?php if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); } ?>
  2. <div class="wrap">
  3. <?php
  4. $did = isset($_GET['did']) ? $_GET['did'] : '0';
  5. // First check if ID exist with requested ID
  6. $sSql = $wpdb->prepare(
  7. "SELECT COUNT(*) AS `count` FROM ".Popupwfb_Table."
  8. WHERE `Popupwfb_id` = %d",
  9. array($did)
  10. );
  11. $result = '0';
  12. $result = $wpdb->get_var($sSql);
  13. if ($result != '1')
  14. {
  15. ?><div class="error fade"><p><strong><?php _e('Oops, selected details doesnt exist.', 'popupwfb'); ?></strong></p></div><?php
  16. }
  17. else
  18. {
  19. $Popupwfb_errors = array();
  20. $Popupwfb_success = '';
  21. $Popupwfb_error_found = FALSE;
  22. $sSql = $wpdb->prepare("
  23. SELECT *
  24. FROM `".Popupwfb_Table."`
  25. WHERE `Popupwfb_id` = %d
  26. LIMIT 1
  27. ",
  28. array($did)
  29. );
  30. $data = array();
  31. $data = $wpdb->get_row($sSql, ARRAY_A);
  32. // Preset the form fields
  33. $form = array(
  34. 'Popupwfb_width' => $data['Popupwfb_width'],
  35. 'Popupwfb_timeout' => $data['Popupwfb_timeout'],
  36. 'Popupwfb_title' => $data['Popupwfb_title'],
  37. 'Popupwfb_content' => $data['Popupwfb_content'],
  38. 'Popupwfb_group' => $data['Popupwfb_group'],
  39. 'Popupwfb_status' => $data['Popupwfb_status'],
  40. 'Popupwfb_expiration' => $data['Popupwfb_expiration'],
  41. 'Popupwfb_starttime' => $data['Popupwfb_starttime'],
  42. 'Popupwfb_extra1' => $data['Popupwfb_extra1'],
  43. 'Popupwfb_id' => $data['Popupwfb_id']
  44. );
  45. }
  46. // Form submitted, check the data
  47. if (isset($_POST['Popupwfb_form_submit']) && $_POST['Popupwfb_form_submit'] == 'yes')
  48. {
  49. // Just security thingy that wordpress offers us
  50. check_admin_referer('Popupwfb_form_edit');
  51. $form['Popupwfb_width'] = isset($_POST['Popupwfb_width']) ? $_POST['Popupwfb_width'] : '';
  52. if ($form['Popupwfb_width'] == '')
  53. {
  54. $Popupwfb_errors[] = __('Please enter the popup window width, only number.', 'popupwfb');
  55. $Popupwfb_error_found = TRUE;
  56. }
  57. $form['Popupwfb_timeout'] = isset($_POST['Popupwfb_timeout']) ? $_POST['Popupwfb_timeout'] : '';
  58. if ($form['Popupwfb_timeout'] == '')
  59. {
  60. $Popupwfb_errors[] = __('Please enter popup timeout, only number.', 'popupwfb');
  61. $Popupwfb_error_found = TRUE;
  62. }
  63. $form['Popupwfb_title'] = isset($_POST['Popupwfb_title']) ? $_POST['Popupwfb_title'] : '';
  64. if ($form['Popupwfb_title'] == '')
  65. {
  66. $Popupwfb_errors[] = __('Please enter popup title.', 'popupwfb');
  67. $Popupwfb_error_found = TRUE;
  68. }
  69. $form['Popupwfb_content'] = isset($_POST['Popupwfb_content']) ? $_POST['Popupwfb_content'] : '';
  70. if ($form['Popupwfb_content'] == '')
  71. {
  72. $Popupwfb_errors[] = __('Please enter popup message.', 'popupwfb');
  73. $Popupwfb_error_found = TRUE;
  74. }
  75. $form['Popupwfb_group'] = isset($_POST['Popupwfb_group']) ? $_POST['Popupwfb_group'] : '';
  76. if ($form['Popupwfb_group'] == '')
  77. {
  78. $Popupwfb_errors[] = __('Please select available group for your popup message.', 'popupwfb');
  79. $Popupwfb_error_found = TRUE;
  80. }
  81. $form['Popupwfb_status'] = isset($_POST['Popupwfb_status']) ? $_POST['Popupwfb_status'] : '';
  82. if ($form['Popupwfb_status'] == '')
  83. {
  84. $Popupwfb_errors[] = __('Please select popup status.', 'popupwfb');
  85. $Popupwfb_error_found = TRUE;
  86. }
  87. $form['Popupwfb_expiration'] = isset($_POST['Popupwfb_expiration']) ? $_POST['Popupwfb_expiration'] : '9999-12-31';
  88. $form['Popupwfb_starttime'] = isset($_POST['Popupwfb_starttime']) ? $_POST['Popupwfb_starttime'] : '0000-00-00';
  89. // No errors found, we can add this Group to the table
  90. if ($Popupwfb_error_found == FALSE)
  91. {
  92. $sSql = $wpdb->prepare(
  93. "UPDATE `".Popupwfb_Table."`
  94. SET `Popupwfb_width` = %s,
  95. `Popupwfb_timeout` = %s,
  96. `Popupwfb_title` = %s,
  97. `Popupwfb_content` = %s,
  98. `Popupwfb_group` = %s,
  99. `Popupwfb_status` = %s,
  100. `Popupwfb_expiration` = %s,
  101. `Popupwfb_starttime` = %s
  102. WHERE Popupwfb_id = %d
  103. LIMIT 1",
  104. array($form['Popupwfb_width'], $form['Popupwfb_timeout'], $form['Popupwfb_title'], $form['Popupwfb_content'], $form['Popupwfb_group'],
  105. $form['Popupwfb_status'], $form['Popupwfb_expiration'], $form['Popupwfb_starttime'], $did)
  106. );
  107. $wpdb->query($sSql);
  108. $Popupwfb_success = __('Details was successfully updated.', 'popupwfb');
  109. }
  110. }
  111. if ($Popupwfb_error_found == TRUE && isset($Popupwfb_errors[0]) == TRUE)
  112. {
  113. ?>
  114. <div class="error fade">
  115. <p><strong><?php echo $Popupwfb_errors[0]; ?></strong></p>
  116. </div>
  117. <?php
  118. }
  119. if ($Popupwfb_error_found == FALSE && strlen($Popupwfb_success) > 0)
  120. {
  121. ?>
  122. <div class="updated fade">
  123. <p><strong>
  124. <?php echo $Popupwfb_success; ?> <a href="<?php echo POPUPWFB_ADMIN_URL; ?>">
  125. <?php _e('Click here', 'popupwfb'); ?></a> <?php _e('to view the details', 'popupwfb'); ?>
  126. </strong></p>
  127. </div>
  128. <?php
  129. }
  130. ?>
  131. <script language="JavaScript" src="<?php echo POPUPWFB_PLUGIN_URL; ?>/pages/setting.js"></script>
  132. <div class="form-wrap">
  133. <div id="icon-edit" class="icon32 icon32-posts-post"><br></div>
  134. <h2><?php _e('Popup with fancybox', 'popupwfb'); ?></h2>
  135. <form name="Popupwfb_form" method="post" action="#" onsubmit="return _Popupwfb_submit()" >
  136. <h3><?php _e('Update details', 'popupwfb'); ?></h3>
  137. <label for="tag-a"><?php _e('Popup width', 'popupwfb'); ?></label>
  138. <input name="Popupwfb_width" type="text" id="Popupwfb_width" value="<?php echo $form['Popupwfb_width']; ?>" size="20" maxlength="4" />
  139. <p><?php _e('Enter your popup window width. (Ex: 500)', 'popupwfb'); ?></p>
  140. <label for="tag-a"><?php _e('Popup timeout', 'popupwfb'); ?></label>
  141. <input name="Popupwfb_timeout" type="text" id="Popupwfb_timeout" value="<?php echo $form['Popupwfb_timeout']; ?>" size="20" maxlength="5" />
  142. <p><?php _e('Enter your popup window timeout in millisecond. (Ex: 3000)', 'popupwfb'); ?></p>
  143. <label for="tag-a"><?php _e('Popup title', 'popupwfb'); ?></label>
  144. <input name="Popupwfb_title" type="text" id="Popupwfb_title" value="<?php echo esc_html(stripslashes($form['Popupwfb_title'])); ?>" size="50" maxlength="250" />
  145. <p><?php _e('Enter your popup title.', 'popupwfb'); ?></p>
  146. <label for="tag-a"><?php _e('Popup message', 'popupwfb'); ?></label>
  147. <?php wp_editor(stripslashes($form['Popupwfb_content']), "Popupwfb_content"); ?>
  148. <p><?php _e('Enter your popup message.', 'popupwfb'); ?></p>
  149. <label for="tag-a"><?php _e('Popup display', 'popupwfb'); ?></label>
  150. <select name="Popupwfb_status" id="Popupwfb_status">
  151. <option value='YES' <?php if($form['Popupwfb_status'] == 'YES') { echo "selected='selected'" ; } ?>>Yes</option>
  152. <option value='NO' <?php if($form['Popupwfb_status'] == 'NO') { echo "selected='selected'" ; } ?>>No</option>
  153. </select>
  154. <p><?php _e('Please select your popup display status. (Select NO if you want to hide the popup in front end)', 'popupwfb'); ?></p>
  155. <label for="tag-a"><?php _e('Popup group', 'popupwfb'); ?></label>
  156. <select name="Popupwfb_group" id="Popupwfb_group">
  157. <option value=''>Select</option>
  158. <?php
  159. $sSql = "SELECT distinct(Popupwfb_group) as Popupwfb_group FROM `".Popupwfb_Table."` order by Popupwfb_group";
  160. $myDistinctData = array();
  161. $arrDistinctDatas = array();
  162. $thisselected = "";
  163. $myDistinctData = $wpdb->get_results($sSql, ARRAY_A);
  164. $i = 1;
  165. foreach ($myDistinctData as $DistinctData)
  166. {
  167. $arrDistinctData[$i]["Popupwfb_group"] = strtoupper($DistinctData['Popupwfb_group']);
  168. $i = $i+1;
  169. }
  170. for($j=$i; $j<$i+10; $j++)
  171. {
  172. $arrDistinctData[$j]["Popupwfb_group"] = "GROUP" . $j;
  173. }
  174. //$arrDistinctDatas = array_unique($arrDistinctData, SORT_REGULAR);
  175. foreach ($arrDistinctData as $arrDistinct)
  176. {
  177. if(strtoupper($form['Popupwfb_group']) == strtoupper($arrDistinct["Popupwfb_group"]))
  178. {
  179. $thisselected = "selected='selected'" ;
  180. }
  181. ?>
  182. <option value='<?php echo strtoupper($arrDistinct["Popupwfb_group"]); ?>' <?php echo $thisselected; ?>>
  183. <?php echo strtoupper($arrDistinct["Popupwfb_group"]); ?>
  184. </option>
  185. <?php
  186. $thisselected = "";
  187. }
  188. ?>
  189. </select>
  190. <p><?php _e('Please select available group for your popup message.', 'popupwfb'); ?></p>
  191. <label for="tag-title"><?php _e('Start date', 'popupwfb'); ?></label>
  192. <input name="Popupwfb_starttime" type="text" id="Popupwfb_starttime" value="<?php echo substr($form['Popupwfb_starttime'],0,10); ?>" maxlength="10" />
  193. <p><?php _e('Please enter popup display start date in this format YYYY-MM-DD <br /> 0000-00-00 : Is equal to no min date.', 'popupwfb'); ?></p>
  194. <label for="tag-title"><?php _e('Expiration date', 'popupwfb'); ?></label>
  195. <input name="Popupwfb_expiration" type="text" id="Popupwfb_expiration" value="<?php echo substr($form['Popupwfb_expiration'],0,10); ?>" maxlength="10" />
  196. <p><?php _e('Please enter the expiration date in this format YYYY-MM-DD <br /> 9999-12-31 : Is equal to no expire.', 'popupwfb'); ?></p>
  197. <input name="Popupwfb_id" id="Popupwfb_id" type="hidden" value="<?php echo $form['Popupwfb_id']; ?>">
  198. <input type="hidden" name="Popupwfb_form_submit" value="yes"/>
  199. <p class="submit">
  200. <input name="publish" lang="publish" class="button add-new-h2" value="<?php _e('Submit', 'popupwfb'); ?>" type="submit" />
  201. <input name="publish" lang="publish" class="button add-new-h2" onclick="_Popupwfb_redirect()" value="<?php _e('Cancel', 'popupwfb'); ?>" type="button" />
  202. <input name="Help" lang="publish" class="button add-new-h2" onclick="_Popupwfb_help()" value="<?php _e('Help', 'popupwfb'); ?>" type="button" />
  203. </p>
  204. <?php wp_nonce_field('Popupwfb_form_edit'); ?>
  205. </form>
  206. </div>
  207. <p class="description">
  208. <?php _e('Check official website for more information', 'popupwfb'); ?>
  209. <a target="_blank" href="<?php echo Popupwfb_FAV; ?>"><?php _e('click here', 'popupwfb'); ?></a>
  210. </p>
  211. </div>