PageRenderTime 45ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/Quản lý website xem phim online PHP/thudang/public_html/mnet/wp-content/plugins/wp-postviews/postviews-options.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 309 lines | 276 code | 7 blank | 26 comment | 12 complexity | 10a93040c80f4143230a2a590b6e8596 MD5 | raw file
  1. <?php
  2. /*
  3. +----------------------------------------------------------------+
  4. | |
  5. | WordPress Plugin: WP-PostViews |
  6. | Copyright (c) 2012 Lester "GaMerZ" Chan |
  7. | |
  8. | File Written By: |
  9. | - Lester "GaMerZ" Chan |
  10. | - http://lesterchan.net |
  11. | |
  12. | File Information: |
  13. | - Post Views Options Page |
  14. | - wp-content/plugins/wp-postviews/postviews-options.php |
  15. | |
  16. +----------------------------------------------------------------+
  17. */
  18. ### Variables Variables Variables
  19. $base_name = plugin_basename('wp-postviews/postviews-options.php');
  20. $base_page = 'admin.php?page='.$base_name;
  21. $id = (isset($_GET['id']) ? intval($_GET['id']) : 0);
  22. $mode = (isset($_GET['mode']) ? trim($_GET['mode']) : '');
  23. $views_settings = array('views_options', 'widget_views_most_viewed', 'widget_views');
  24. $views_postmetas = array('views');
  25. ### Form Processing
  26. // Update Options
  27. if(!empty($_POST['Submit'])) {
  28. $views_options = array();
  29. $views_options['count'] = intval($_POST['views_count']);
  30. $views_options['exclude_bots'] = intval($_POST['views_exclude_bots']);
  31. $views_options['display_home'] = intval($_POST['views_display_home']);
  32. $views_options['display_single'] = intval($_POST['views_display_single']);
  33. $views_options['display_page'] = intval($_POST['views_display_page']);
  34. $views_options['display_archive'] = intval($_POST['views_display_archive']);
  35. $views_options['display_search'] = intval($_POST['views_display_search']);
  36. $views_options['display_other'] = intval($_POST['views_display_other']);
  37. $views_options['template'] = trim($_POST['views_template_template']);
  38. $views_options['most_viewed_template'] = trim($_POST['views_template_most_viewed']);
  39. $update_views_queries = array();
  40. $update_views_text = array();
  41. $update_views_queries[] = update_option('views_options', $views_options);
  42. $update_views_text[] = __('Post Views Options', 'wp-postviews');
  43. $i=0;
  44. $text = '';
  45. foreach($update_views_queries as $update_views_query) {
  46. if($update_views_query) {
  47. $text .= '<font color="green">'.$update_views_text[$i].' '.__('Updated', 'wp-postviews').'</font><br />';
  48. }
  49. $i++;
  50. }
  51. if(empty($text)) {
  52. $text = '<font color="red">'.__('No Post Views Option Updated', 'wp-postviews').'</font>';
  53. }
  54. }
  55. // Decide What To Do
  56. if(!empty($_POST['do'])) {
  57. // Uninstall WP-PostViews
  58. switch($_POST['do']) {
  59. case __('UNINSTALL WP-PostViews', 'wp-postviews') :
  60. if(trim($_POST['uninstall_views_yes']) == 'yes') {
  61. echo '<div id="message" class="updated fade">';
  62. echo '<p>';
  63. foreach($views_settings as $setting) {
  64. $delete_setting = delete_option($setting);
  65. if($delete_setting) {
  66. echo '<font color="green">';
  67. printf(__('Setting Key \'%s\' has been deleted.', 'wp-postviews'), "<strong><em>{$setting}</em></strong>");
  68. echo '</font><br />';
  69. } else {
  70. echo '<font color="red">';
  71. printf(__('Error deleting Setting Key \'%s\'.', 'wp-postviews'), "<strong><em>{$setting}</em></strong>");
  72. echo '</font><br />';
  73. }
  74. }
  75. echo '</p>';
  76. echo '<p>';
  77. foreach($views_postmetas as $postmeta) {
  78. $remove_postmeta = $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key = '$postmeta'");
  79. if($remove_postmeta) {
  80. echo '<font color="green">';
  81. printf(__('Post Meta Key \'%s\' has been deleted.', 'wp-postviews'), "<strong><em>{$postmeta}</em></strong>");
  82. echo '</font><br />';
  83. } else {
  84. echo '<font color="red">';
  85. printf(__('Error deleting Post Meta Key \'%s\'.', 'wp-postviews'), "<strong><em>{$postmeta}</em></strong>");
  86. echo '</font><br />';
  87. }
  88. }
  89. echo '</p>';
  90. echo '</div>';
  91. $mode = 'end-UNINSTALL';
  92. }
  93. break;
  94. }
  95. }
  96. ### Determines Which Mode It Is
  97. switch($mode) {
  98. // Deactivating WP-PostViews
  99. case 'end-UNINSTALL':
  100. $deactivate_url = 'plugins.php?action=deactivate&amp;plugin=wp-postviews/wp-postviews.php';
  101. if(function_exists('wp_nonce_url')) {
  102. $deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_wp-postviews/wp-postviews.php');
  103. }
  104. echo '<div class="wrap">';
  105. echo '<h2>'.__('Uninstall WP-PostViews', 'wp-postviews').'</h2>';
  106. echo '<p><strong>'.sprintf(__('<a href="%s">Click Here</a> To Finish The Uninstallation And WP-PostViews Will Be Deactivated Automatically.', 'wp-postviews'), $deactivate_url).'</strong></p>';
  107. echo '</div>';
  108. break;
  109. // Main Page
  110. default:
  111. $views_options = get_option('views_options');
  112. ?>
  113. <script type="text/javascript">
  114. /* <![CDATA[*/
  115. function views_default_templates(template) {
  116. var default_template;
  117. switch(template) {
  118. case 'template':
  119. default_template = "<?php _e('%VIEW_COUNT% views', 'wp-postviews'); ?>";
  120. break;
  121. case 'most_viewed':
  122. default_template = "<li><a href=\"%POST_URL%\" title=\"%POST_TITLE%\">%POST_TITLE%</a> - %VIEW_COUNT% <?php _e('views', 'wp-postviews'); ?></li>";
  123. break;
  124. }
  125. jQuery("#views_template_" + template).val(default_template);
  126. }
  127. /* ]]> */
  128. </script>
  129. <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
  130. <form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>">
  131. <div class="wrap">
  132. <?php screen_icon(); ?>
  133. <h2><?php _e('Post Views Options', 'wp-postviews'); ?></h2>
  134. <table class="form-table">
  135. <tr>
  136. <td valign="top" width="30%"><strong><?php _e('Count Views From:', 'wp-postviews'); ?></strong></td>
  137. <td valign="top">
  138. <select name="views_count" size="1">
  139. <option value="0"<?php selected('0', $views_options['count']); ?>><?php _e('Everyone', 'wp-postviews'); ?></option>
  140. <option value="1"<?php selected('1', $views_options['count']); ?>><?php _e('Guests Only', 'wp-postviews'); ?></option>
  141. <option value="2"<?php selected('2', $views_options['count']); ?>><?php _e('Registered Users Only', 'wp-postviews'); ?></option>
  142. </select>
  143. </td>
  144. </tr>
  145. <tr>
  146. <td valign="top" width="30%"><strong><?php _e('Exclude Bot Views:', 'wp-postviews'); ?></strong></td>
  147. <td valign="top">
  148. <select name="views_exclude_bots" size="1">
  149. <option value="0"<?php selected('0', $views_options['exclude_bots']); ?>><?php _e('No', 'wp-postviews'); ?></option>
  150. <option value="1"<?php selected('1', $views_options['exclude_bots']); ?>><?php _e('Yes', 'wp-postviews'); ?></option>
  151. </select>
  152. </td>
  153. </tr>
  154. <tr>
  155. <td valign="top">
  156. <strong><?php _e('Views Template:', 'wp-postviews'); ?></strong><br /><br />
  157. <?php _e('Allowed Variables:', 'wp-postviews'); ?><br />
  158. - %VIEW_COUNT%<br /><br />
  159. <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template', 'wp-postviews'); ?>" onclick="views_default_templates('template');" class="button" />
  160. </td>
  161. <td valign="top">
  162. <input type="text" id="views_template_template" name="views_template_template" size="70" value="<?php echo htmlspecialchars(stripslashes($views_options['template'])); ?>" />
  163. </td>
  164. </tr>
  165. <tr>
  166. <td valign="top">
  167. <strong><?php _e('Most Viewed Template:', 'wp-postviews'); ?></strong><br /><br />
  168. <?php _e('Allowed Variables:', 'wp-postviews'); ?><br />
  169. - %VIEW_COUNT%<br />
  170. - %POST_TITLE%<br />
  171. - %POST_EXCERPT%<br />
  172. - %POST_CONTENT%<br />
  173. - %POST_URL%<br /><br />
  174. <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template', 'wp-postviews'); ?>" onclick="views_default_templates('most_viewed');" class="button" />
  175. </td>
  176. <td valign="top">
  177. <textarea cols="80" rows="15" id="views_template_most_viewed" name="views_template_most_viewed"><?php echo htmlspecialchars(stripslashes($views_options['most_viewed_template'])); ?></textarea>
  178. </td>
  179. </tr>
  180. </table>
  181. <h3><?php _e('Display Options', 'wp-postviews'); ?></h3>
  182. <p><?php _e('These options specify where the view counts should be displayed and to whom. By default view counts will be displayed to all visitors. Note that the theme files must contain a call to <code>the_views()</code> in order for any view count to be displayed.', 'wp-postviews'); ?></p>
  183. <table class="form-table">
  184. <tr>
  185. <td valign="top"><strong><?php _e('Home Page:', 'wp-postviews'); ?></strong></td>
  186. <td>
  187. <select name="views_display_home" size="1">
  188. <option value="0"<?php selected('0', $views_options['display_home']); ?>><?php _e('Display to everyone', 'wp-postviews'); ?></option>
  189. <option value="1"<?php selected('1', $views_options['display_home']); ?>><?php _e('Display to registered users only', 'wp-postviews'); ?></option>
  190. <option value="2"<?php selected('2', $views_options['display_home']); ?>><?php _e('Don\'t display on home page', 'wp-postviews'); ?></option>
  191. </select>
  192. </td>
  193. </tr>
  194. <tr>
  195. <td valign="top"><strong><?php _e('Singe Posts:', 'wp-postviews'); ?></strong></td>
  196. <td>
  197. <select name="views_display_single" size="1">
  198. <option value="0"<?php selected('0', $views_options['display_single']); ?>><?php _e('Display to everyone', 'wp-postviews'); ?></option>
  199. <option value="1"<?php selected('1', $views_options['display_single']); ?>><?php _e('Display to registered users only', 'wp-postviews'); ?></option>
  200. <option value="2"<?php selected('2', $views_options['display_single']); ?>><?php _e('Don\'t display on single posts', 'wp-postviews'); ?></option>
  201. </select>
  202. </td>
  203. </tr>
  204. <tr>
  205. <td valign="top"><strong><?php _e('Pages:', 'wp-postviews'); ?></strong></td>
  206. <td>
  207. <select name="views_display_page" size="1">
  208. <option value="0"<?php selected('0', $views_options['display_page']); ?>><?php _e('Display to everyone', 'wp-postviews'); ?></option>
  209. <option value="1"<?php selected('1', $views_options['display_page']); ?>><?php _e('Display to registered users only', 'wp-postviews'); ?></option>
  210. <option value="2"<?php selected('2', $views_options['display_page']); ?>><?php _e('Don\'t display on pages', 'wp-postviews'); ?></option>
  211. </select>
  212. </td>
  213. </tr>
  214. <tr>
  215. <td valign="top"><strong><?php _e('Archive Pages:', 'wp-postviews'); ?></strong></td>
  216. <td>
  217. <select name="views_display_archive" size="1">
  218. <option value="0"<?php selected('0', $views_options['display_archive']); ?>><?php _e('Display to everyone', 'wp-postviews'); ?></option>
  219. <option value="1"<?php selected('1', $views_options['display_archive']); ?>><?php _e('Display to registered users only', 'wp-postviews'); ?></option>
  220. <option value="2"<?php selected('2', $views_options['display_archive']); ?>><?php _e('Don\'t display on archive pages', 'wp-postviews'); ?></option>
  221. </select>
  222. </td>
  223. </tr>
  224. <tr>
  225. <td valign="top"><strong><?php _e('Search Pages:', 'wp-postviews'); ?></strong></td>
  226. <td>
  227. <select name="views_display_search" size="1">
  228. <option value="0"<?php selected('0', $views_options['display_search']); ?>><?php _e('Display to everyone', 'wp-postviews'); ?></option>
  229. <option value="1"<?php selected('1', $views_options['display_search']); ?>><?php _e('Display to registered users only', 'wp-postviews'); ?></option>
  230. <option value="2"<?php selected('2', $views_options['display_search']); ?>><?php _e('Don\'t display on search pages', 'wp-postviews'); ?></option>
  231. </select>
  232. </td>
  233. </tr>
  234. <tr>
  235. <td valign="top"><strong><?php _e('Other Pages:', 'wp-postviews'); ?></strong></td>
  236. <td>
  237. <select name="views_display_other" size="1">
  238. <option value="0"<?php selected('0', $views_options['display_other']); ?>><?php _e('Display to everyone', 'wp-postviews'); ?></option>
  239. <option value="1"<?php selected('1', $views_options['display_other']); ?>><?php _e('Display to registered users only', 'wp-postviews'); ?></option>
  240. <option value="2"<?php selected('2', $views_options['display_other']); ?>><?php _e('Don\'t display on other pages', 'wp-postviews'); ?></option>
  241. </select>
  242. </td>
  243. </tr>
  244. </table>
  245. <p class="submit">
  246. <input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes', 'wp-postviews'); ?>" />
  247. </p>
  248. </div>
  249. </form>
  250. <p>&nbsp;</p>
  251. <!-- Uninstall WP-PostViews -->
  252. <form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>">
  253. <div class="wrap">
  254. <h3><?php _e('Uninstall WP-PostViews', 'wp-postviews'); ?></h3>
  255. <p>
  256. <?php _e('Deactivating WP-PostViews plugin does not remove any data that may have been created, such as the views data. To completely remove this plugin, you can uninstall it here.', 'wp-postviews'); ?>
  257. </p>
  258. <p style="color: red">
  259. <strong><?php _e('WARNING:', 'wp-postviews'); ?></strong><br />
  260. <?php _e('Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to back up all the data first.', 'wp-postviews'); ?>
  261. </p>
  262. <p style="color: red">
  263. <strong><?php _e('The following WordPress Options/PostMetas will be DELETED:', 'wp-postviews'); ?></strong><br />
  264. </p>
  265. <table class="widefat">
  266. <thead>
  267. <tr>
  268. <th><?php _e('WordPress Options', 'wp-postviews'); ?></th>
  269. <th><?php _e('WordPress PostMetas', 'wp-postviews'); ?></th>
  270. </tr>
  271. </thead>
  272. <tr>
  273. <td valign="top">
  274. <ol>
  275. <?php
  276. foreach($views_settings as $settings) {
  277. echo '<li>'.$settings.'</li>'."\n";
  278. }
  279. ?>
  280. </ol>
  281. </td>
  282. <td valign="top" class="alternate">
  283. <ol>
  284. <?php
  285. foreach($views_postmetas as $postmeta) {
  286. echo '<li>'.$postmeta.'</li>'."\n";
  287. }
  288. ?>
  289. </ol>
  290. </td>
  291. </tr>
  292. </table>
  293. <p>&nbsp;</p>
  294. <p style="text-align: center;">
  295. <input type="checkbox" name="uninstall_views_yes" value="yes" />&nbsp;<?php _e('Yes', 'wp-postviews'); ?><br /><br />
  296. <input type="submit" name="do" value="<?php _e('UNINSTALL WP-PostViews', 'wp-postviews'); ?>" class="button" onclick="return confirm('<?php _e('You Are About To Uninstall WP-PostViews From WordPress.\nThis Action Is Not Reversible.\n\n Choose [Cancel] To Stop, [OK] To Uninstall.', 'wp-postviews'); ?>')" />
  297. </p>
  298. </div>
  299. </form>
  300. <?php
  301. } // End switch($mode)
  302. ?>