PageRenderTime 46ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 1ms

/184.168.182.1/wp-content/plugins/cyan-backup/includes/page-options.php

https://gitlab.com/endomorphosis/falkenstein
PHP | 832 lines | 729 code | 93 blank | 10 comment | 115 complexity | 495bcd5d34c6ebc7eaf9446697c14ae3 MD5 | raw file
  1. <?php
  2. if( !is_admin() )
  3. wp_die(__('Access denied!', $this->textdomain));
  4. include_once('class-cyan-utilities.php');
  5. $CYANUtil = new CYAN_Utilities;
  6. $nonce_field = 'option_update';
  7. $option = (array)get_option($this->option_name);
  8. $archive_path = $this->get_archive_path($option);
  9. $excluded_dir = $this->get_excluded_dir($option, array());
  10. $content_dir = $this->chg_directory_separator(WP_CONTENT_DIR . "/", FALSE);
  11. $abspath = $this->chg_directory_separator(ABSPATH, FALSE);
  12. $admin_dir = $this->chg_directory_separator($abspath . 'wp-admim/', FALSE);
  13. // Create the .htaccess or WebConfig files
  14. if (isset($_POST['CreateWebConfig']) || isset($_POST['Createhtaccess'])) {
  15. if ( $this->wp_version_check('2.5') && function_exists('check_admin_referer') )
  16. check_admin_referer($nonce_field, self::NONCE_NAME);
  17. if( isset($_POST['CreateWebConfig']) )
  18. {
  19. if( $abspath == $archive_path || $admin_dir == $archive_path) {
  20. $CYANUtil->record_notes( "<strong>". __('Archive path set to WordPress root or admin folder, Web.Config not written!', $this->textdomain)."</strong>", 2);
  21. } else {
  22. $access_filename = $archive_path . 'Web.config';
  23. if( !file_exists( $access_filename ) )
  24. {
  25. $access_file = fopen( $access_filename, 'w' );
  26. fwrite( $access_file, '<?xml version="1.0" encoding="utf-8" ?>' . "\n");
  27. fwrite( $access_file, '<configuration>' . "\n");
  28. fwrite( $access_file, ' <system.webServer>' . "\n");
  29. fwrite( $access_file, ' <security>' . "\n");
  30. fwrite( $access_file, ' <authorization>' . "\n");
  31. fwrite( $access_file, ' <remove users="*" roles="" verbs="" />' . "\n");
  32. fwrite( $access_file, ' <add accessType="Allow" roles="Administrators" />' . "\n");
  33. fwrite( $access_file, ' </authorization>' . "\n");
  34. fwrite( $access_file, ' </security>' . "\n");
  35. fwrite( $access_file, ' </system.webServer>' . "\n");
  36. fwrite( $access_file, '</configuration>' . "\n");
  37. fclose( $access_file );
  38. $CYANUtil->record_notes( __('Web.Config written!', $this->textdomain), 0);
  39. }
  40. else
  41. {
  42. $CYANUtil->record_notes( __('Web.Config already exists, please edit it manually!', $this->textdomain), 1);
  43. }
  44. }
  45. }
  46. if( isset($_POST['Createhtaccess']) )
  47. {
  48. if( $abspath == $archive_path || $admin_dir == $archive_path ) {
  49. $CYANUtil->record_notes( __('Archive path set to WordPress root or admin folder, .htaccess not written!', $this->textdomain), 2);
  50. } else {
  51. $access_filename = $archive_path . '.htaccess';
  52. if( !file_exists( $access_filename ) )
  53. {
  54. $access_file = fopen( $access_filename, 'w' );
  55. fwrite( $access_file, '<FilesMatch ".*">' . "\n" );
  56. fwrite( $access_file, ' Order Allow,Deny' . "\n" );
  57. fwrite( $access_file, ' Deny from all' . "\n" );
  58. fwrite( $access_file, '</FilesMatch>' . "\n" );
  59. fclose( $access_file );
  60. $CYANUtil->record_notes( __('.htaccess written!', $this->textdomain), 0);
  61. }
  62. else
  63. {
  64. $CYANUtil->record_notes( __('.htaccess already exists, please edit it manually!', $this->textdomain), 1);
  65. }
  66. }
  67. }
  68. }
  69. // option update
  70. if (isset($_POST['options_update'])) {
  71. if( $this->wp_version_check('2.5') && function_exists('check_admin_referer') )
  72. check_admin_referer($nonce_field, self::NONCE_NAME);
  73. if( isset( $_POST['clear_backup'] ) ) {
  74. @unlink( $archive_path . 'backup.active' );
  75. @unlink( $archive_path . 'status.log' );
  76. $CYANUtil->record_notes( __('Active backup state cleared!', $this->textdomain), 0);
  77. }
  78. if( isset( $_POST['clear_files'] ) ) {
  79. $archive_pre = basename(ABSPATH);
  80. $current_files = scandir($archive_path);
  81. foreach( $current_files as $this_file ) {
  82. $this_file_ext = strtolower(substr( $this_file, -4 ));
  83. if( substr( $this_file, 0, strlen( $archive_pre ) ) == $archive_pre && $this_file_ext != ".zip" && $this_file_ext != ".log" ) {
  84. $CYANUtil->recursive_remove( $archive_path . $this_file );
  85. $CYANUtil->record_notes( sprintf( __('%s deleted from the archive directory.', $this->textdomain), $this_file ), 0);
  86. }
  87. }
  88. }
  89. if( isset( $_POST['forcessl'] ) ) {
  90. $options['forcessl'] = $_POST['forcessl'];
  91. }
  92. if( isset( $_POST['disableziparchive'] ) ) {
  93. $options['disableziparchive'] = $_POST['disableziparchive'];
  94. }
  95. if( isset( $_POST['artificialdelay'] ) ) {
  96. $options['artificialdelay'] = $_POST['artificialdelay'];
  97. }
  98. $postdata = $this->get_real_post_data();
  99. if ( isset($postdata['archive_path']) ) {
  100. $dir = trim($postdata['archive_path']);
  101. if ( ($realpath = realpath($dir)) !== FALSE) {
  102. $realpath = $this->chg_directory_separator($realpath, FALSE);
  103. if ( is_dir($realpath) )
  104. $realpath = $this->trailingslashit($realpath, FALSE);
  105. if( $realpath == $abspath || $realpath == $admin_dir ) {
  106. $CYANUtil->record_notes( __('Archive path set to WordPress root or admin folder, this is not a valid option!', $this->textdomain), 2);
  107. } else {
  108. $options['archive_path'] = $realpath;
  109. if( substr( $realpath, 0, strlen( $abspath) ) == $abspath ) {
  110. $test_name = $realpath . "test.zip";
  111. $test_text = "This is a test file\n";
  112. $test_file = fopen( $test_name, 'w' );
  113. if( $test_file ) {
  114. fwrite($test_file, $test_text);
  115. fclose($test_file);
  116. $test_url = $this->wp_site_url( substr( $realpath, strlen( $abspath ) ) . 'test.zip' );
  117. $test_read = @file_get_contents($test_url);
  118. @unlink( $test_name );
  119. if( $test_read == $test_text ) {
  120. $CYANUtil->record_notes( sprintf(__('Archive directory ("%s") is a subdirectory in the WordPress root and is accessible via the web, this is an insecure configuration!', $this->textdomain), $realpath), 1);
  121. }
  122. } else {
  123. $CYANUtil->record_notes( sprintf(__('Archive directory ("%s") is not writeable!', $this->textdomain), $realpath), 2);
  124. }
  125. }
  126. }
  127. } else {
  128. $CYANUtil->record_notes( sprintf(__('Archive directory ("%s") does not exist!', $this->textdomain), $realpath), 2);
  129. }
  130. }
  131. if ( isset($postdata['excluded']) ) {
  132. $excluded = $excluded_dir = array();
  133. $check_archive_excluded = FALSE;
  134. $archive_path_found = FALSE;
  135. if( substr( $archive_path, 0, strlen( $abspath) ) == $abspath ) { $check_archive_excluded = TRUE; }
  136. foreach ( explode("\n", $postdata['excluded']) as $dir ) {
  137. $dir = trim($dir);
  138. if ( !empty($dir) ) {
  139. if ( ($realpath = realpath($dir)) !== FALSE) {
  140. $realpath = $this->chg_directory_separator($realpath, FALSE);
  141. $dir = str_replace($abspath, '', $realpath);
  142. if ( is_dir($realpath) )
  143. $dir = $this->trailingslashit($dir, FALSE);
  144. $excluded[] = $dir;
  145. $excluded_dir[] = str_replace($abspath, '', $dir);
  146. $realpath = $this->trailingslashit($realpath, FALSE);
  147. if( $check_archive_excluded && $realpath == $archive_path ) { $archive_path_found = TRUE; }
  148. } else {
  149. $CYANUtil->record_notes(sprintf(__('Excluded directory ("%s") is not found, removed from exclusions.', $this->textdomain), $dir), 1);
  150. }
  151. }
  152. }
  153. if( $check_archive_excluded == TRUE && $archive_path_found == FALSE ) {
  154. $archive_dir = str_replace($abspath, '', $archive_path);
  155. $excluded[] = $archive_dir;
  156. $excluded_dir[] = $archive_dir;
  157. $CYANUtil->record_notes( __('Archive path is in the WordPress directory tree but was not found in the exclusions, it has automatically been added.', $this->textdomain), 0);
  158. }
  159. $options['excluded'] = $excluded;
  160. }
  161. if( isset( $_POST['emaillog'] ) ) {
  162. $options['emaillog'] = $_POST['emaillog'];
  163. }
  164. if( isset( $_POST['sendto'] ) ) {
  165. $options['sendto'] = $_POST['sendto'];
  166. }
  167. if ( isset($_POST['schedule']) ) {
  168. if( is_array( $_POST['schedule'] ) ) {
  169. $options['schedule'] = $_POST['schedule'];
  170. $options['schedule']['tod'] = $options['schedule']['hours'] . ':' . $options['schedule']['minutes'] . $options['schedule']['ampm'];
  171. }
  172. }
  173. if ( isset($_POST['remote']) ) {
  174. if( is_array( $_POST['remote'] ) ) {
  175. $options['remote'] = $_POST['remote'];
  176. if( !function_exists( 'mcrypt_encrypt' ) ) {
  177. $CYANUtil->record_notes( __('mcrypt library is not installed so passwords cannot be encrypted before being stored in the database. Your remote storage password will be stored in clear text! Please install mcrypt and re-save your configuration.', $this->textdomain), 1);
  178. }
  179. // Encrpyt the password for storage in the database.
  180. $options['remote']['password'] = $this->encrypt_password( $options['remote']['password'] );
  181. }
  182. }
  183. // Remove the backup schedule if we've change it recurrence.
  184. if( wp_next_scheduled('cyan_backup_hook') && ( $options['schedule']['type'] != $option['schedule']['type'] || $options['schedule']['interval'] != $option['schedule']['interval'] || $options['schedule']['tod'] != $option['schedule']['tod'] || $options['schedule']['dom'] != $option['schedule']['dom'] || $options['schedule']['dow'] != $option['schedule']['dow'] ) ) {
  185. wp_unschedule_event(wp_next_scheduled('cyan_backup_hook'), 'cyan_backup_hook');
  186. }
  187. // Add the backup schedule if it doesn't exist and is enabled.
  188. if( !wp_next_scheduled('cyan_backup_hook') && $options['schedule']['enabled'] ) {
  189. $next_backup_time = $this->calculate_initial_backup( $options['schedule'] );
  190. if( $next_backup_time > time() ) {
  191. wp_schedule_single_event($next_backup_time, 'cyan_backup_hook');
  192. $options['next_backup_time'] = $next_backup_time;
  193. } else {
  194. $CYANUtil->record_notes( __('Schedule not set, failed to determine the next scheduled time to backup!', $this->textdomain), 2);
  195. }
  196. }
  197. // Remove the backup schedule if it does exist and is disabled.
  198. if( wp_next_scheduled('cyan_backup_hook') && !$options['schedule']['enabled'] ) {
  199. wp_unschedule_event(wp_next_scheduled('cyan_backup_hook'), 'cyan_backup_hook');
  200. }
  201. if ( isset($_POST['prune']) ) {
  202. if( is_array( $_POST['prune'] ) ) {
  203. $options['prune'] = $_POST['prune'];
  204. }
  205. }
  206. update_option($this->option_name, $options);
  207. $option = $options;
  208. $archive_path = $this->get_archive_path($option);
  209. $excluded_dir = $this->get_excluded_dir($option, array());
  210. // Done!
  211. $CYANUtil->record_notes(__('Configuration saved!', $this->textdomain), 0);
  212. }
  213. // Decrypt the password for use on the form.
  214. $decrypted_pw = $this->decrypt_password( $option['remote']['password'] );
  215. $option['remote']['password'] = $decrypted_pw;
  216. $schedule_types = array( 'Once', 'Hourly', 'Daily', 'Weekly', 'Monthly' );
  217. if( self::DEBUG_MODE == TRUE ) {
  218. $schedule_types[] = 'debug';
  219. }
  220. $display_settings = array();
  221. $display_type_settings = array(
  222. 'Once' => array(
  223. 'schedule_debug' => 'display: none;',
  224. 'schedule_once' => '',
  225. 'schedule_before' => 'display: none;',
  226. 'schedule_interval' => 'display: none;',
  227. 'schedule_hours_label' => 'display: none;',
  228. 'schedule_days' => 'display: none;',
  229. 'schedule_weeks' => 'display: none;',
  230. 'schedule_months' => 'display: none;',
  231. 'schedule_on' => '',
  232. 'schedule_dow' => '',
  233. 'schedule_the' => '',
  234. 'schedule_dom' => '',
  235. 'schedule_at' => '',
  236. 'schedule_hours' => '',
  237. 'schedule_minutes' => '',
  238. 'schedule_ampm' => ''
  239. ),
  240. 'Hourly' => array(
  241. 'schedule_debug' => 'display: none;',
  242. 'schedule_once' => 'display: none;',
  243. 'schedule_before' => '',
  244. 'schedule_interval' => '',
  245. 'schedule_hours_label' => '',
  246. 'schedule_days' => 'display: none;',
  247. 'schedule_weeks' => 'display: none;',
  248. 'schedule_months' => 'display: none;',
  249. 'schedule_on' => 'display: none;',
  250. 'schedule_dow' => 'display: none;',
  251. 'schedule_the' => 'display: none;',
  252. 'schedule_dom' => 'display: none;',
  253. 'schedule_at' => '',
  254. 'schedule_hours' => 'display: none;',
  255. 'schedule_minutes' => '',
  256. 'schedule_ampm' => 'display: none;'
  257. ),
  258. 'Daily' => array(
  259. 'schedule_debug' => 'display: none;',
  260. 'schedule_once' => 'display: none;',
  261. 'schedule_before' => '',
  262. 'schedule_interval' => '',
  263. 'schedule_hours_label' => 'display: none;',
  264. 'schedule_days' => '',
  265. 'schedule_weeks' => 'display: none;',
  266. 'schedule_months' => 'display: none;',
  267. 'schedule_on' => 'display: none;',
  268. 'schedule_dow' => 'display: none;',
  269. 'schedule_the' => 'display: none;',
  270. 'schedule_dom' => 'display: none;',
  271. 'schedule_at' => '',
  272. 'schedule_hours' => '',
  273. 'schedule_minutes' => '',
  274. 'schedule_ampm' => ''
  275. ),
  276. 'Weekly' => array(
  277. 'schedule_debug' => 'display: none;',
  278. 'schedule_once' => 'display: none;',
  279. 'schedule_before' => '',
  280. 'schedule_interval' => '',
  281. 'schedule_hours_label' => 'display: none;',
  282. 'schedule_days' => 'display: none;',
  283. 'schedule_weeks' => '',
  284. 'schedule_months' => 'display: none;',
  285. 'schedule_on' => '',
  286. 'schedule_dow' => '',
  287. 'schedule_the' => 'display: none;',
  288. 'schedule_dom' => 'display: none;',
  289. 'schedule_at' => '',
  290. 'schedule_hours' => '',
  291. 'schedule_minutes' => '',
  292. 'schedule_ampm' => ''
  293. ),
  294. 'Monthly' => array(
  295. 'schedule_debug' => 'display: none;',
  296. 'schedule_once' => 'display: none;',
  297. 'schedule_before' => '',
  298. 'schedule_interval' => '',
  299. 'schedule_hours_label' => 'display: none;',
  300. 'schedule_days' => 'display: none;',
  301. 'schedule_weeks' => 'display: none;',
  302. 'schedule_months' => '',
  303. 'schedule_on' => '',
  304. 'schedule_dow' => 'display: none;',
  305. 'schedule_the' => '',
  306. 'schedule_dom' => '',
  307. 'schedule_at' => '',
  308. 'schedule_hours' => '',
  309. 'schedule_minutes' => '',
  310. 'schedule_ampm' => ''
  311. )
  312. );
  313. if( self::DEBUG_MODE == TRUE ) {
  314. $display_type_settings['debug'] = array(
  315. 'schedule_debug' => '',
  316. 'schedule_once' => 'display: none;',
  317. 'schedule_before' => 'display: none;',
  318. 'schedule_interval' => 'display: none;',
  319. 'schedule_hours_label' => 'display: none;',
  320. 'schedule_days' => 'display: none;',
  321. 'schedule_weeks' => 'display: none;',
  322. 'schedule_months' => 'display: none;',
  323. 'schedule_on' => 'display: none;',
  324. 'schedule_dow' => 'display: none;',
  325. 'schedule_the' => 'display: none;',
  326. 'schedule_dom' => 'display: none;',
  327. 'schedule_at' => 'display: none;',
  328. 'schedule_hours' => 'display: none;',
  329. 'schedule_minutes' => 'display: none;',
  330. 'schedule_ampm' => 'display: none;'
  331. );
  332. }
  333. echo '<script type="text/javascript">//<![CDATA[' . "\n";
  334. echo 'function set_schedule_display() {' . "\n";
  335. echo ' var display_type_settings = new Array() ' . "\n\n";
  336. foreach( $display_type_settings as $key => $value ) {
  337. echo ' display_type_settings[\'' . $key . '\'] = new Array();' . "\n";
  338. }
  339. foreach( $display_type_settings as $key => $value ) {
  340. foreach( $value as $subkey => $subvalue ) {
  341. echo ' display_type_settings[\'' . $key . '\'][\'' . $subkey . '\'] = \'';
  342. if( $subvalue == "display: none;" ) { echo '0'; } else { echo '1'; }
  343. echo '\';' . "\n";
  344. }
  345. }
  346. echo "\n";
  347. echo ' var type = jQuery("#schedule_type").val();' . "\n";
  348. echo "\n";
  349. echo ' for( var i in display_type_settings[type] ) {' . "\n";
  350. echo ' if( display_type_settings[type][i] == 0 ) { jQuery("#" + i).css( "display", "none" ); } else { jQuery("#" + i).css( "display", "" ); }' . "\n";
  351. echo ' }' . "\n";
  352. echo '}' . "\n";
  353. echo "\n";
  354. echo 'jQuery(document).ready(function() {' . "\n";
  355. echo ' jQuery("#clear_files").change(function(){' . "\n";
  356. echo "\n";
  357. echo ' if(!this.checked)' . "\n";
  358. echo ' return;' . "\n";
  359. echo "\n";
  360. echo " var agree = confirm('" . __('Are you sure you want to delete all temporary files in the archive directory?', $this->textdomain) . "')\n";
  361. echo "\n";
  362. echo ' if(!agree)' . "\n";
  363. echo ' jQuery("#clear_files").attr("checked", false);' . "\n";
  364. echo "\n";
  365. echo ' });' . "\n";
  366. echo "\n";
  367. echo ' jQuery("#clear_backup").change(function(){' . "\n";
  368. echo "\n";
  369. echo ' if(!this.checked)' . "\n";
  370. echo ' return;' . "\n";
  371. echo "\n";
  372. echo " var agree = confirm('" . __('Are you sure you want to clear the active state?', $this->textdomain) . "')\n";
  373. echo "\n";
  374. echo ' if(!agree)' . "\n";
  375. echo ' jQuery("#clear_backup").attr("checked", false);' . "\n";
  376. echo "\n";
  377. echo ' });' . "\n";
  378. echo "\n";
  379. echo ' jQuery("#tabs").tabs();' . "\n";
  380. echo "\n";
  381. echo '});' . "\n";
  382. echo '//]]></script>' . "\n";
  383. // Find the next scheduled backup in WP Cron.
  384. $next_schedule = wp_next_scheduled('cyan_backup_hook');
  385. $current_time = time();
  386. // If the next scheduled backup is over an hour in the past, it's probably broken, let the user know.
  387. if( $next_schedule < $current_time - 3600 ) {
  388. $CYANUtil->record_notes( __('The next scheduled backup job is in the past, WP Cron may be broken. If it does not execute shortly, you may want to disable and then re-enable scheduled backup jobs to re-create the WP Cron entry.', $this->textdomain), 1 );
  389. }
  390. echo $CYANUtil->output_notes();
  391. $CYANUtil->clear_notes();
  392. ?>
  393. <div class="wrap">
  394. <div id="icon-options-general" class="icon32"><br /></div>
  395. <h2><?php _e('CYAN Backup Options', $this->textdomain);?></h2>
  396. <form method="post" id="option_update" action="<?php echo $this->admin_action;?>-options">
  397. <div id="tabs">
  398. <ul>
  399. <li><a href="#fragment-1"><span><?php _e('Directory Options', $this->textdomain);?></span></a></li>
  400. <li><a href="#fragment-2"><span><?php _e('Log Options', $this->textdomain);?></span></a></li>
  401. <li><a href="#fragment-3"><span><?php _e('Schedule Options', $this->textdomain);?></span></a></li>
  402. <li><a href="#fragment-4"><span><?php _e('Storage Maintenance', $this->textdomain);?></span></a></li>
  403. <li><a href="#fragment-5"><span><?php _e('Remote Storage', $this->textdomain);?></span></a></li>
  404. <li><a href="#fragment-6"><span><?php _e('Clear Active Backup', $this->textdomain);?></span></a></li>
  405. </ul>
  406. <div id="fragment-1">
  407. <?php if ($this->wp_version_check('2.5') && function_exists('wp_nonce_field') )
  408. echo wp_nonce_field($nonce_field, self::NONCE_NAME, true, false);
  409. ?>
  410. <table class="optiontable form-table" style="margin-top:0;">
  411. <tbody>
  412. <tr>
  413. <th><?php _e('Force SSL', $this->textdomain);?></th>
  414. <td>
  415. <input type=checkbox id="forcessl" name="forcessl"<?php if( $option['forcessl'] == 'on' ) { echo ' CHECKED'; }?>>
  416. </td>
  417. </tr>
  418. <tr>
  419. <th><?php _e('Artificial Delay', $this->textdomain);?></th>
  420. <td>
  421. <input type=checkbox id="artificialdelay" name="artificialdelay"<?php if( $option['artificialdelay'] == 'on' ) { echo ' CHECKED'; }?>>
  422. </td>
  423. </tr>
  424. <?php if( class_exists('ZipArchive') ) {?>
  425. <tr>
  426. <th><?php _e('Disable ZipArchive', $this->textdomain);?></th>
  427. <td>
  428. <input type=checkbox id="disableziparchive" name="disableziparchive"<?php if( $option['disableziparchive'] == 'on' ) { echo ' CHECKED'; }?>>
  429. </td>
  430. </tr>
  431. <?php }?>
  432. <tr>
  433. <th><?php _e('Archive path', $this->textdomain);?></th>
  434. <td>
  435. <input type="text" name="archive_path" id="archive_path" size="100" value="<?php echo htmlentities($archive_path);?>" /><br><br>
  436. <input class="button" id="Createhtaccess" name="Createhtaccess" type="submit" value="<?php _e('Create .htaccess File', $this->textdomain);?>">&nbsp;
  437. <input class="button" id="CreateWebConfig" name="CreateWebConfig" type="submit" value="<?php _e('Create WebConfig File', $this->textdomain);?>">
  438. </td>
  439. </tr>
  440. <tr>
  441. <th><?php _e('Excluded dir', $this->textdomain);?></th>
  442. <td><textarea name="excluded" id="excluded" rows="5" cols="100">
  443. <?php
  444. foreach ($excluded_dir as $dir) {
  445. echo htmlentities($this->chg_directory_separator($abspath.$dir,FALSE)) . "\n";
  446. }
  447. ?></textarea><br><br>
  448. <input class="button" id="AddArchiveDir" name="AddArchiveDir" type="button" value="<?php _e('Add Archive Dir', $this->textdomain);?>" onClick="excluded.value = jQuery.trim( excluded.value ) + '\n<?php echo addslashes( $archive_path ); ?>';">&nbsp;
  449. <input class="button" id="AddWPContentDir" name="AddWPContentDir" type="button" value="<?php _e('Add WP-Content Dir', $this->textdomain);?>" onClick="excluded.value = jQuery.trim( excluded.value ) + '\n<?php echo addslashes( $content_dir ); ?>';">&nbsp;
  450. <input class="button" id="AddWPContentDir" name="AddWPUpgradeDir" type="button" value="<?php _e('Add WP-Upgrade Dir', $this->textdomain);?>" onClick="excluded.value = jQuery.trim( excluded.value ) + '\n<?php echo addslashes( $this->chg_directory_separator( $content_dir . "upgrade/", FALSE ) ); ?>';">&nbsp;
  451. <input class="button" id="AddWPAdminDir" name="AddWPAdminDir" type="button" value="<?php _e('Add WP-Admin Dir', $this->textdomain);?>" onClick="excluded.value = jQuery.trim( excluded.value ) + '\n<?php echo addslashes( $admin_dir ); ?>';">&nbsp;
  452. <input class="button" id="AddWPIncludesDir" name="AddWPIncludesDir" type="button" value="<?php _e('Add WP-Includes Dir', $this->textdomain);?>" onClick="excluded.value = jQuery.trim( excluded.value ) + '\n<?php echo addslashes($this->chg_directory_separator($abspath . "wp-includes/", FALSE) )?>';">&nbsp;
  453. </td>
  454. </tr>
  455. </tbody>
  456. </table>
  457. </div>
  458. <div id="fragment-2">
  459. <table class="optiontable form-table" style="margin-top:0;">
  460. <tbody>
  461. <tr>
  462. <th><?php _e('E-Mail the log file', $this->textdomain);?></th>
  463. <td>
  464. <input type=checkbox id="emaillog_enabled" name="emaillog"<?php if( $option['emaillog'] == 'on' ) { echo ' CHECKED'; }?>>
  465. </td>
  466. </tr>
  467. <tr>
  468. <th><?php _e('Send to addresses', $this->textdomain);?></th>
  469. <td>
  470. <input type="input" size="60" id="emaillog_sendto" name="sendto" value="<?php echo $option['sendto'];?>"><br>
  471. <br>
  472. <?php _e('This is a comma separated list of e-mail addresses to send the log file to, if blank it will be sent to the WordPress admin user.', $this->textdomain);?>
  473. </td>
  474. </tr>
  475. </tbody>
  476. </table>
  477. </div>
  478. <div id="fragment-3">
  479. <table style=\"margin-top:0; width: auto;\">
  480. <tbody>
  481. <tr>
  482. <td class="description" style="width: auto; text-align: right; vertical-align: top;"><span class="description"><?php _e('Current server time', $this->textdomain);?></span>:</td><td style="width: auto; text-align: left; vertical-align: top;"><code>
  483. <?php
  484. echo date( get_option('date_format'), $current_time ) . ' @ ' . date( get_option('time_format'), $current_time );
  485. ?></code>
  486. </td>
  487. </tr>
  488. <?php if( $option['schedule']['enabled'] == 'on' ) { ?>
  489. <tr>
  490. <td style="width: auto; text-align: right; vertical-align: top;"><span class="description"><?php _e('Next backup scheduled for', $this->textdomain);?></span>:</td><td style="width: auto; text-align: left; vertical-align: top;"><code>
  491. <?php
  492. if( $next_schedule ) {
  493. echo date( get_option('date_format'), $next_schedule ) . ' @ ' . date( get_option('time_format'), $next_schedule );
  494. }
  495. else {
  496. _e('None', $this->textdomain );
  497. }
  498. ?></code>
  499. </td>
  500. </tr>
  501. <?php }?>
  502. </tbody>
  503. </table>
  504. <table class="optiontable form-table" style="margin-top:0;">
  505. <tbody>
  506. <tr>
  507. <th><?php _e('Enable', $this->textdomain);?></th>
  508. <td><input type=checkbox id="schedule_enabled" name="schedule[enabled]"<?php if( $option['schedule']['enabled'] == 'on' ) { echo ' CHECKED'; }?>></td>
  509. </tr>
  510. <tr>
  511. <th><?php _e('Type', $this->textdomain);?></th>
  512. <td>
  513. <select id="schedule_type" onChange="set_schedule_display();" name="schedule[type]">
  514. <?php
  515. foreach( $schedule_types as $type ) {
  516. echo "\t\t\t\t\t\t<option value=\"" . $type . '"';
  517. if( $option['schedule']['type'] == $type ) { echo ' SELECTED'; $display_settings = $display_type_settings[$type]; }
  518. echo '>' . __($type, $this->textdomain) . '</option>';
  519. }
  520. ?>
  521. </select>
  522. </td>
  523. </tr>
  524. <tr>
  525. <th><?php _e('Schedule', $this->textdomain);?></th>
  526. <td>
  527. <?php
  528. if( self::DEBUG_MODE == TRUE ) {
  529. echo "\t\t\t\t\t\t" . '<span id="schedule_debug" style="' . $display_settings['schedule_debug'] . '">' . __('Every minute, for debugging only', $this->textdomain) . '</span>';
  530. }
  531. ?>
  532. <span id="schedule_once" style="<?php echo $display_settings['schedule_once'];?>"><?php _e('Only once', $this->textdomain);?></span>
  533. <span id="schedule_before" style="<?php echo $display_settings['schedule_before'];?>"><?php _e('Run backup every', $this->textdomain);?> </span>
  534. <?php
  535. echo "\t\t\t\t\t\t<select id=" . '"schedule_interval" name="schedule[interval]">';
  536. for( $i = 1; $i < 32; $i++ )
  537. {
  538. echo '<option value="' . $i . '"';
  539. if( $i == (int)$option['schedule']['interval'] ) { echo ' SELECTED'; }
  540. echo '>' . $i . '</option>';
  541. }
  542. echo "</select>\n";
  543. ?>
  544. <span id="schedule_hours_label" style="<?php echo $display_settings['schedule_hours_label'];?>"> <?php _e('hour(s)', $this->textdomain);?></span><span id="schedule_days" style="<?php echo $display_settings['schedule_days'];?>"> <?php _e('day(s)', $this->textdomain);?></span><span id="schedule_weeks" style="<?php echo $display_settings['schedule_weeks'];?>"> <?php _e('week(s)', $this->textdomain);?></span><span id="schedule_months" style="<?php echo $display_settings['schedule_months'];?>"> <?php _e('month(s)', $this->textdomain);?></span>
  545. <span id="schedule_on" style="<?php echo $display_settings['schedule_on'];?>"> <?php _e('on', $this->textdomain);?></span>
  546. <select id="schedule_dow" name="schedule[dow]" style="<?php echo $display_settings['schedule_dow'];?>">
  547. <option value=""></option>
  548. <?php
  549. $weekdays = array( 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' );
  550. foreach( $weekdays as $day ) {
  551. echo "\t\t\t\t\t\t\t\t" . '<option value="' . $day . '"';
  552. if( $option['schedule']['dow'] == $day ) { echo' SELECTED'; }
  553. echo '>' . __($day, $this->textdomain) . '</option>';
  554. }
  555. ?>
  556. </select>
  557. <span id="schedule_the" style="<?php echo $display_settings['schedule_the'];?>"> <?php _e('the', $this->textdomain);?></span>
  558. <select id="schedule_dom" name="schedule[dom]" style="<?php echo $display_settings['schedule_dom'];?>">
  559. <option value=""></option>
  560. <?php
  561. for( $i = 1; $i < 28; $i++ ) {
  562. echo "\t\t\t\t\t\t\t\t" . '<option value="' . $i . '"';
  563. if( $option['schedule']['dom'] == $i ) { echo' SELECTED'; }
  564. echo '>' . $i . '</option>';
  565. }
  566. ?>
  567. </select>
  568. <span id="schedule_at" style="<?php echo $display_settings['schedule_at'];?>"> <?php _e('at', $this->textdomain);?></span>
  569. <?php
  570. echo "\t\t\t\t\t\t<select id=" . '"schedule_hours" name="schedule[hours]"><option value=""></option>';
  571. for( $i = 1; $i < 13; $i++ )
  572. {
  573. echo '<option value="' . $i . '"';
  574. if( $i == (int)$option['schedule']['hours'] ) { echo ' SELECTED'; }
  575. echo '>' . $i . '</option>';
  576. }
  577. echo "</select>\n";
  578. echo "\t\t\t\t\t\t<select id=" . '"schedule_minutes" name="schedule[minutes]"><option value=""></option>';
  579. for( $i = 0; $i < 60; $i++ )
  580. {
  581. echo '<option value="' . $i . '"';
  582. if( $i == (int)$option['schedule']['minutes'] ) { echo ' SELECTED'; }
  583. echo '>:';
  584. if( $i < 10 ) { echo '0'; }
  585. echo $i . '</option>';
  586. }
  587. echo "</select>\n";
  588. ?>
  589. <select id="schedule_ampm" name="schedule[ampm]"><option value="am"<?php if( $option['schedule']['ampm'] == 'am' ) { echo ' SELECTED'; } ?>>am</option><option value="pm"<?php if( $option['schedule']['ampm'] == 'pm' ) { echo ' SELECTED'; } ?>>pm</option></select>.
  590. </td>
  591. </tr>
  592. </tbody>
  593. </table>
  594. </div>
  595. <div id="fragment-4">
  596. <table class="optiontable form-table" style="margin-top:0;">
  597. <tbody>
  598. <tr>
  599. <th><?php _e('Enable backup pruning', $this->textdomain);?></th>
  600. <td><input type="checkbox" name="prune[enabled]"<?php if( $option['prune']['enabled'] == 'on' ) { echo' CHECKED'; }?>></td>
  601. </tr>
  602. <tr>
  603. <th><?php _e('Number of backups to keep', $this->textdomain);?></th>
  604. <td><input type="text" name="prune[number]" size="5" value="<?php echo $option['prune']['number'];?>"></td>
  605. </tr>
  606. </tbody>
  607. </table>
  608. </div>
  609. <div id="fragment-5">
  610. <table class="optiontable form-table" style="margin-top:0;">
  611. <tbody>
  612. <tr>
  613. <th><?php _e('Enable remote storage', $this->textdomain);?></th>
  614. <td><input type="checkbox" name="remote[enabled]"<?php if( $option['remote']['enabled'] == 'on' ) { echo' CHECKED'; }?>></td>
  615. </tr>
  616. <tr>
  617. <th><?php _e('Protocol', $this->textdomain);?></th>
  618. <td>
  619. <?php
  620. echo "\t\t\t\t\t\t<select id=" . '"remote_protocol" name="remote[protocol]"><option value=""></option>';
  621. $wrappers = stream_get_wrappers();
  622. // 'dropbox' => __('DropBox', $this->textdomain),
  623. if( in_array( 'ftp', $wrappers ) ) { $remoteprotocols['ftpwrappers'] = __('FTP Wrappers', $this->textdomain); }
  624. if( function_exists( 'ftp_connect' ) ) { $remoteprotocols['ftplibrary'] = __('FTP Library', $this->textdomain); }
  625. if( in_array( 'ftps', $wrappers ) ) { $remoteprotocols['ftpswrappers'] = __('FTPS Wrappers', $this->textdomain); }
  626. if( function_exists( 'ftp_ssl_connect' ) ) { $remoteprotocols['ftpslibrary'] = __('FTPS Library', $this->textdomain); }
  627. if( in_array( 'ssh2', $wrappers ) ) { $remoteprotocols['sftpwrappers'] = __('SFTP Wrappers', $this->textdomain); }
  628. if( function_exists( 'ssh2_connect' ) ) { $remoteprotocols['sftplibrary'] = __('SFTP Library', $this->textdomain); }
  629. $remoteprotocols['sftpphpseclib'] = __('SFTP phpseclib', $this->textdomain);
  630. foreach( $remoteprotocols as $key => $protocol )
  631. {
  632. echo '<option value="' . $key . '"';
  633. if( $key == $option['remote']['protocol'] ) { echo ' SELECTED'; }
  634. echo '>'. $protocol . '</option>';
  635. }
  636. echo "</select>\n";
  637. ?>
  638. </td>
  639. </tr>
  640. <tr>
  641. <th><?php _e('Host', $this->textdomain);?></th>
  642. <td><input type="text" size="40" name="remote[host]" value="<?php echo $option['remote']['host'];?>"></td>
  643. </tr>
  644. <tr>
  645. <th><?php _e('Username', $this->textdomain);?></th>
  646. <td><input type="text" size="20" name="remote[username]" value="<?php echo $option['remote']['username'];?>"></td>
  647. </tr>
  648. <tr>
  649. <th><?php _e('Password', $this->textdomain);?></th>
  650. <td><input type="password" size="20" name="remote[password]" value="<?php echo $option['remote']['password'];?>"></td>
  651. </tr>
  652. <tr>
  653. <th><?php _e('Remote path', $this->textdomain);?></th>
  654. <td>
  655. <input type="text" size="40" name="remote[path]" value="<?php echo $option['remote']['path'];?>"><br>
  656. <br>
  657. <?php _e( "You many use the follow place holders: %m = month (01-12), %d = day (01-31), %Y = year (XXXX), %M = month (Jan...Dec), %F = month (January...December)" );?>
  658. </td>
  659. </tr>
  660. <tr>
  661. <th><?php _e('Include log file', $this->textdomain);?></th>
  662. <td><input type="checkbox" name="remote[sendlog]"<?php if( $option['remote']['sendlog'] == 'on' ) { echo' CHECKED'; }?>></td>
  663. </tr>
  664. <tr>
  665. <th><?php _e('Delete local copy during scheduled backup', $this->textdomain);?></th>
  666. <td><input type="checkbox" name="remote[deletelocalschedule]"<?php if( $option['remote']['deletelocalschedule'] == 'on' ) { echo' CHECKED'; }?>></td>
  667. </tr>
  668. <tr>
  669. <th><?php _e('Delete local copy during manual backup', $this->textdomain);?></th>
  670. <td><input type="checkbox" name="remote[deletelocalmanual]"<?php if( $option['remote']['deletelocalmanual'] == 'on' ) { echo' CHECKED'; }?>></td>
  671. </tr>
  672. </tbody>
  673. </table>
  674. </div>
  675. <div id="fragment-6">
  676. <table class="optiontable form-table" style="margin-top:0;">
  677. <tbody>
  678. <tr>
  679. <th><?php _e('Clear active backup status', $this->textdomain);?></th>
  680. <td><input type="checkbox" id="clear_backup" name="clear_backup"><br><br><?php _e('WARNING: Only check this if a backup has hung and you can no longer execute backups.', $this->textdomain);?></td>
  681. </tr>
  682. <tr>
  683. <th><?php _e('Delete temporary files and directories', $this->textdomain);?></th>
  684. <td><input type="checkbox" id="clear_files" name="clear_files"><br><br><?php echo sprintf(__('WARNING: Only check this if no backup is running. This will delete any file in the archive path that starts with "%s" but is not a zip/log file.', $this->textdomain), basename(ABSPATH) );?></td>
  685. </tr>
  686. </tbody>
  687. </table>
  688. </div>
  689. </div>
  690. <p style="margin-top:1em;"><input type="submit" name="options_update" class="button-primary" value="<?php _e('Update Options', $this->textdomain);?>" class="button" /></p>
  691. </form>
  692. </div>