Changeset 821968
- Timestamp:
- 12/14/2013 05:21:33 PM (12 years ago)
- Location:
- dbc-backup-2/trunk
- Files:
-
- 4 edited
-
dbcbackup-options.php (modified) (6 diffs)
-
dbcbackup.php (modified) (3 diffs)
-
inc/functions.php (modified) (19 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dbc-backup-2/trunk/dbcbackup-options.php
r721073 r821968 2 2 /* 3 3 Plugin Options for DBC Backup 2 4 4 5 */ 6 5 7 if ( ! defined( 'ABSPATH' ) ) exit; 6 8 if(!defined('WP_ADMIN') OR !current_user_can('manage_options')) wp_die(__('You do not have sufficient permissions to access this page.')); 7 9 8 // dbcbackup_locale(); 9 $cfg = get_option('dbcbackup_options'); 10 if($_POST['quickdo'] == 'dbc_logerase') 11 { 12 check_admin_referer('dbc_quickdo'); 13 $cfg['logs'] = array(); 14 update_option('dbcbackup_options', $cfg); 15 } 16 elseif($_POST['quickdo'] == 'dbc_backupnow') 17 { 18 check_admin_referer('dbc_quickdo'); 19 $cfg['logs'] = dbcbackup_run('backupnow'); 20 } 21 elseif($_POST['do'] == 'dbc_setup') 22 { 23 check_admin_referer('dbc_options'); 24 $temp['export_dir'] = rtrim(stripslashes_deep(trim($_POST['export_dir'])), '/'); 25 $temp['compression'] = stripslashes_deep(trim($_POST['compression'])); 26 $temp['gzip_lvl'] = intval($_POST['gzip_lvl']); 27 $temp['period'] = intval($_POST['severy']) * intval($_POST['speriod']); 28 $temp['active'] = (bool)$_POST['active']; 29 $temp['rotate'] = intval($_POST['rotate']); 30 $temp['logs'] = $cfg['logs']; 31 32 $timenow = time(); 33 $year = date('Y', $timenow); 34 $month = date('n', $timenow); 35 $day = date('j', $timenow); 36 $hours = intval($_POST['hours']); 37 $minutes = intval($_POST['minutes']); 38 $seconds = intval($_POST['seconds']); 39 $temp['schedule'] = mktime($hours, $minutes, $seconds, $month, $day, $year); 40 update_option('dbcbackup_options', $temp); 41 42 if($cfg['active'] AND !$temp['active']) $clear = true; 43 if(!$cfg['active'] AND $temp['active']) $schedule = true; 44 if($cfg['active'] AND $temp['active'] AND (array($hours, $minutes, $seconds) != explode('-', date('G-i-s', $cfg['schedule'])) OR $temp['period'] != $cfg['period']) ) 45 { 46 $clear = true; 47 $schedule = true; 48 } 49 if($clear) wp_clear_scheduled_hook('dbc_backup'); 50 if($schedule) wp_schedule_event($temp['schedule'], 'dbc_backup', 'dbc_backup'); 51 $cfg = $temp; 52 ?><div id="message" class="updated fade"><p><?php _e('Options saved.') ?></p></div><?php 53 } 54 55 $is_safe_mode = ini_get('safe_mode') == '1' ? 1 : 0; 56 if(!empty($cfg['export_dir'])) 57 { 58 if(!is_dir($cfg['export_dir']) AND !$is_safe_mode) 59 { 60 @mkdir($cfg['export_dir'], 0777, true); 61 @chmod($cfg['export_dir'], 0777); 62 63 if(is_dir($cfg['export_dir'])) 64 { 65 $dbc_msg[] = sprintf(__("Folder <strong>%s</strong> was created.", 'dbcbackup'), $cfg['export_dir']); 66 } 67 else 68 { 69 $dbc_msg[] = $is_safe_mode ? __('PHP Safe Mode Is On', 'dbcbackup') : sprintf(__("Folder <strong>%s</strong> wasn't created, check permissions.", 'dbcbackup'), $cfg['export_dir']); 70 } 71 } 72 else 73 { 74 $dbc_msg[] = sprintf(__("Folder <strong>%s</strong> exists.", 'dbcbackup'), $cfg['export_dir']); 75 } 76 77 if(is_dir($cfg['export_dir'])) 78 { 79 $condoms = array('.htaccess', 'index.html'); 80 foreach($condoms as $condom) 81 { 82 if(!file_exists($cfg['export_dir'].'/'.$condom)) 83 { 84 if($file = @fopen($cfg['export_dir'].'/'.$condom, 'w')) 85 { 86 $cofipr = ($condom == 'index.html')? '' : "Order allow,deny\ndeny from all"; 87 fwrite($file, $cofipr); 88 fclose($file); 89 $dbc_msg[] = sprintf(__("File <strong>%s</strong> was created.", 'dbcbackup'), $condom); 90 } 91 else 92 { 93 $dbc_msg[] = sprintf(__("File <strong>%s</strong> wasn't created, check permissions.", 'dbcbackup'), $condom); 94 } 95 } 96 else 97 { 98 $dbc_msg[] = sprintf(__("File <strong>%s</strong> exists.", 'dbcbackup'), $condom); 99 } 100 } 101 } 102 } 103 else 104 { 105 $dbc_msg[] = __('Specify the folder where the backups will be stored', 'dbcbackup'); 106 } 107 108 /** 109 * 110 * DBC Backup 111 * Options Panel 112 **/ 10 //admin page functions 11 require_once ('inc/admin-functions.php'); 12 13 14 15 /* ------------------------------------------------------------------------ * 16 * This is the layout for the Admin Page 17 * since v2 18 * thanks to Frank Bueltge for his Admin Page template 19 * http://bueltge.de/ 20 * ------------------------------------------------------------------------ */ 21 113 22 ?> 114 23 <div class="wrap"> … … 116 25 <h2><?php _e('DBC Backup Options', 'dbcbackup'); ?></h2> 117 26 <div class="metabox-holder has-right-sidebar"> 118 <div id="message" class="updated fade"><p><?php echo implode('<br />', $dbc_msg); ?></p></div> 27 <?php 28 29 //$screen = get_current_screen(); 30 // print_r($screen->id); 31 // return $screen; 32 settings_errors();?> 33 119 34 <!-- SIDEBAR --> 120 35 <div class="inner-sidebar"> 121 36 <div class="postbox"> 37 <h3><span>Backup Settings Status</span></h3> 38 <div class="inside"> 39 <?php echo implode('<br />', $dbc_msg); ?> 40 </div> 41 </div> 122 42 <div class="postbox"> 123 43 <h3><span>Thanks from Damien</span></h3> 124 44 <div class="inside"> 125 <p>Thanks for installing this. <a target="_blank" href="http://damien.co/?utm_source=WordPress&utm_medium=dbc-backup-installed&utm_campaign=WordPress-Plugin">Damien</a></p>126 <p>Please add yourself to <a target="_blank" href="http://wordpress.damien.co/wordpress-mailing-list/?utm_source=WordPress&utm_medium=dbc-backup-installed &utm_campaign=WordPress-Plugin">my mailing list</a> to be the first to hear WordPress tips and updates for this plugin.</p>45 <?php echo 'Thank you for using version ' . DBCBACKUP2_VERSION; ?>. <a target="_blank" href="http://damien.co/?utm_source=WordPress&utm_medium=dbc-backup-installed-2.3&utm_campaign=WordPress-Plugin">Damien</a></p> 46 <p>Please add yourself to <a target="_blank" href="http://wordpress.damien.co/wordpress-mailing-list/?utm_source=WordPress&utm_medium=dbc-backup-installed-2.3&utm_campaign=WordPress-Plugin">my mailing list</a> to be the first to hear WordPress tips and updates for this plugin.</p> 127 47 <p>Let me and your friends know you installed this:</p> 128 48 <a href="https://twitter.com/share" class="twitter-share-button" data-text="I just installed DBC Backup 2 for WordPress" data-url="http://damiens.ws/MLLV3H" data-counturl="http://wordpress.damien.co/dbc-backup-2" data-count="horizontal" data-via="damiensaunders">Tweet</a><script type="text/javascript" src="https://platform.twitter.com/widgets.js"></script> … … 135 55 <div class="inside"> 136 56 <ul> 137 <li><a target="_blank" href="http://wordpress.damien.co/dbc-backup-2/?utm_source=WordPress&utm_medium=dbc-backup-installed &utm_campaign=WordPress-Plugin">Help & FAQ's</a></li>138 <li><a target="_blank" href="http://wordpress.damien.co/?utm_source=WordPress&utm_medium=dbc-backup-installed &utm_campaign=WordPress-Plugin">More WordPress Tips & Ideas</a></li>57 <li><a target="_blank" href="http://wordpress.damien.co/dbc-backup-2/?utm_source=WordPress&utm_medium=dbc-backup-installed-2.3&utm_campaign=WordPress-Plugin">Help & FAQ's</a></li> 58 <li><a target="_blank" href="http://wordpress.damien.co/?utm_source=WordPress&utm_medium=dbc-backup-installed-2.3&utm_campaign=WordPress-Plugin">More WordPress Tips & Ideas</a></li> 139 59 </ul> 140 60 </div> … … 145 65 <ul> 146 66 <li><a target="_blank" href="http://wordpress.damien.co/isotope/?utm_source=WordPress&utm_medium=dbc-sitewide-installed&utm_campaign=WordPress-Plugin">Isotope</a> - does amazing visual things for your website.</li> 147 <li><a target="_blank" href="http://whitetshirtdigital.com/shop/?utm_source=WordPress&utm_medium=dbc-backup-installed &utm_campaign=WordPress-Plugin">Learn more about digital marketing or WordPress</a> with Damien.</li>67 <li><a target="_blank" href="http://whitetshirtdigital.com/shop/?utm_source=WordPress&utm_medium=dbc-backup-installed-2.3&utm_campaign=WordPress-Plugin">Learn more about digital marketing or WordPress</a> with Damien.</li> 148 68 </ul> 149 69 </div> … … 247 167 </select></label> 248 168 <?php endforeach;?></p> 249 <?php _e('Active:', 'dbcbackup'); ?> <input style="display:inline" type="checkbox" name="active" value="1" <?php echo ($cfg['active'] ? 'checked="checked"' : ''); ?> /></p>169 <?php _e('Active:', 'dbcbackup'); ?> <input type="checkbox" name="active" value="1" <?php echo ($cfg['active'] ? 'checked="checked"' : ''); ?> /></p> 250 170 <?php if($next_scheduled = wp_next_scheduled('dbc_backup')): 251 171 _e('Next Schedule is on: ', 'dbcbackup'); echo date('Y-m-d H:i:s', $next_scheduled); ?> | <?php … … 268 188 <option value="<?php echo $i; ?>" <?php echo ($cfg['rotate'] == $i ? 'selected' : ''); ?>><?php echo $display; ?></option> 269 189 <?php endfor; ?> 270 </select></label><br /><?php _e(' The deletion of the old backups occurs during new backup generation.', 'dbcbackup'); ?></td>190 </select></label><br /><?php _e('Deletion of old backups occurs the next time a backup is run.', 'dbcbackup'); ?></td> 271 191 </tr> 272 192 <tr> -
dbc-backup-2/trunk/dbcbackup.php
r721073 r821968 4 4 Plugin URI: http://wordpress.damien.co/plugins?utm_source=WordPress&utm_medium=dbc-backup&utm_campaign=WordPress-Plugin&utm_keyword=source 5 5 Description: Safe & easy backup for your WordPress database. Just schedule and forget. 6 Version: 2. 26 Version: 2.3.23 7 7 Author: Damien Saunders 8 Author URI: http://damien.co/?utm_source=WordPress&utm_medium=dbc-backup &utm_campaign=WordPress-Plugin&utm_keyword=source8 Author URI: http://damien.co/?utm_source=WordPress&utm_medium=dbc-backup-2-2.3.23&utm_campaign=WordPress-Plugin&utm_keyword=source 9 9 License: GPLv2 or later 10 10 */ 11 11 12 /** 13 * You shouldn't be here. 14 */ 12 15 if ( ! defined( 'ABSPATH' ) ) exit; 13 /* 14 * Save User Options to WPDB 15 */ 16 add_action('activate_dbcbackup/dbcbackup.php', 'dbcbackup_install'); 17 function dbcbackup_install() 18 { 19 $options = array('export_dir' => '', 'compression' => 'none', 'gzip_lvl' => 0, 'period' => 86400, 'schedule' => time(), 'active' => 0, 'rotate' => -1); 20 add_option('dbcbackup_options', $options, '', 'no'); 16 17 /** 18 * Globals 19 */ 20 define ("DBCBACKUP2_VERSION", "2.3.23"); 21 define ("PLUGIN_NAME", "dbc-backup-2"); 22 $plugin = plugin_basename(__FILE__); 23 global $damien_dbc_option; 24 global $plugin; 25 26 // @todo implement this default location and make it work for 1st time users. 27 define ("DBCBACKUP2_LOCATION", "../wp-content/backup"); 28 29 /** 30 * Gets the stored presets from the database so we can use them in the Admin page 31 * since v2.1 32 * @return mixed 33 */ 34 function dbc_get_global_options(){ 35 $damien_dbc_option = get_option('dbcbackup_options'); 36 return $dbc_option; 21 37 } 22 38 23 /* 24 * Uninstall function 25 */ 26 function dbcbackup_uninstall() 27 { 28 wp_clear_scheduled_hook('dbc_backup'); 29 delete_option('dbcbackup_options'); 39 40 /** 41 * Here we add the plugin default settings 42 * Since v2.3 we set the default directory to wp-content/backup 43 * 44 */ 45 function damien_dbc_set_default_options() { 46 if (get_option('dbcbackup_options') === false){ 47 $new_options['compression'] = "none"; 48 $new_options['gzip_lvl'] = 0; 49 $new_options['period'] = 86400; 50 $new_options['schedule'] = time(); 51 $new_options['active'] = 0; 52 $new_options['rotate'] =-1; 53 $new_options['version'] = DBCBACKUP2_VERSION; 54 $new_options['export_dir'] = ""; 55 add_option('dbcbackup_options', $new_options); 56 } 30 57 } 31 register_deactivation_hook(__FILE__, 'dbcbackup_uninstall');58 add_action('admin_init', 'damien_dbc_set_default_options'); 32 59 33 add_action('dbc_backup', 'dbcbackup_run'); 34 function dbcbackup_run($mode = 'auto') 35 { 36 if(defined('DBC_BACKUP_RETURN')) return; 37 $cfg = get_option('dbcbackup_options'); 38 if(!$cfg['active'] AND $mode == 'auto') return; 39 if(empty($cfg['export_dir'])) return; 40 if($mode == 'auto') dbcbackup_locale(); 41 42 require_once ('inc/functions.php'); 43 define('DBC_COMPRESSION', $cfg['compression']); 44 define('DBC_GZIP_LVL', $cfg['gzip_lvl']); 45 define('DBC_BACKUP_RETURN', true); 46 47 $timenow = time(); 48 $mtime = explode(' ', microtime()); 49 $time_start = $mtime[1] + $mtime[0]; 50 $key = substr(md5(md5(DB_NAME.'|'.microtime())), 0, 6); 51 $date = date('m.d.y-H.i.s', $timenow); 52 list($file, $fp) = dbcbackup_open($cfg['export_dir'].'/Backup_'.$date.'_'.$key); 53 54 if($file) 55 { 56 $removed = dbcbackup_rotate($cfg, $timenow); 57 @set_time_limit(0); 58 $sql = mysql_query("SHOW TABLE STATUS FROM ".DB_NAME); 59 dbcbackup_write($file, dbcbackup_header()); 60 while ($row = mysql_fetch_array($sql)) 61 { 62 dbcbackup_structure($row['Name'], $file); 63 dbcbackup_data($row['Name'], $file); 64 } 65 dbcbackup_close($file); 66 $result = __('Successful', 'dbcbackup'); 67 } 68 else 69 { 70 $result = sprintf(__("Failed To Open: %s.", 'dbcbackup'), $fp); 71 } 72 $mtime = explode(' ', microtime()); 73 $time_end = $mtime[1] + $mtime[0]; 74 $time_total = $time_end - $time_start; 75 $cfg['logs'][] = array ('file' => $fp, 'size' => @filesize($fp), 'started' => $timenow, 'took' => $time_total, 'status' => $result, 'removed' => $removed); 76 update_option('dbcbackup_options', $cfg); 77 return ($mode == 'auto' ? true : $cfg['logs']); 78 } 79 /* 80 * i18n -- I need to local at the POT stuff for v2.2 60 61 62 63 64 /** 65 * INCLUDED FILES 66 * since v2.3 67 * @return array|bool 81 68 */ 82 function dbcbackup_locale() 69 // backup files 70 require_once ('inc/backup_run.php'); 71 //functions for the admin page are called at the top of the options.php 72 //require_once ('inc/admin-functions.php'); 73 //functions 74 require_once ('inc/functions.php'); 75 76 77 78 79 /** 80 * i18n -- I need to look at the POT stuff for v2.2 81 * 82 */function dbcbackup_locale() 83 83 { 84 84 load_plugin_textdomain('dbcbackup', 'wp-content/plugins/dbc-backup-2'); 85 85 } 86 86 87 /* 88 * 2.1 Add Menu - moved to Tools 87 /** 88 * Add Menu 89 * since v0 90 * v2.1 moved to Tools menu 91 * @todo v2.3 added helptab - work in progress 89 92 */ 93 function dbcbackup_menu() 94 { 95 global $dbc_backup_admin; 96 $dbc_backup_admin = add_management_page('DBC Backup', 'DBC Backup', 'manage_options', 'dbc_backup_admin', 'damien_dbc_inc_my_page'); 97 include dirname(__FILE__).'/inc/help_tab.php'; 98 // Adds my_help_tab when my_admin_page loads 99 add_action('load-'.$dbc_backup_admin, 'damien_dbc_admin_add_help_tab'); 100 101 } 90 102 add_action('admin_menu', 'dbcbackup_menu'); 91 function dbcbackup_menu() 103 104 /** 105 * 106 */ 107 function damien_dbc_inc_my_page() 92 108 { 93 if(function_exists('add_management_page')) 94 { 95 add_management_page('DBC Backup', 'DBC Backup', 'manage_options', dirname(__FILE__).'/dbcbackup-options.php'); 96 } 109 include dirname(__FILE__).'/dbcbackup-options.php'; 97 110 } 98 111 99 /* 112 113 114 115 /** 100 116 * Add WP-Cron Job 117 * since v0 118 * @return array 101 119 */ 102 add_filter('cron_schedules', 'dbcbackup_interval'); 103 function dbcbackup_interval() { 120 function dbcbackup_interval() { 104 121 $cfg = get_option('dbcbackup_options'); 105 122 $cfg['period'] = ($cfg['period'] == 0) ? 86400 : $cfg['period']; 106 123 return array('dbc_backup' => array('interval' => $cfg['period'], 'display' => __('DBC Backup Interval', 'dbc_backup'))); 107 124 } 125 add_filter('cron_schedules', 'dbcbackup_interval'); 108 126 109 /* 110 * 2.1 Add settings link on Installed Plugin page 127 128 /** 129 * Add settings link on Installed Plugin page 130 * since v2.1 131 * @param $links 132 * @return mixed 111 133 */ 112 function dbc_backup_settings_link($links) { 134 function dbc_backup_settings_link($links) { 113 135 $settings_link = '<a href="tools.php?page=dbc-backup-2/dbcbackup-options.php">Settings</a>'; 114 136 array_unshift($links, $settings_link); … … 120 142 121 143 122 /* 144 145 /* ------------------------------------------------------------------------ * 146 * Boring stuff 147 * ------------------------------------------------------------------------ */ 148 149 150 151 /** 123 152 * RSS feed 124 153 */ 154 125 155 function dbc_backup_rss_display() 126 156 { … … 140 170 } 141 171 172 173 /* ------------------------------------------------------------------------ * 174 * If you delete the plugin - I'll feel sad 175 * ------------------------------------------------------------------------ */ 176 177 178 179 /** 180 * Uninstall function 181 * Ill be sorry to see you leave 182 * since v2.1 183 */ 184 function dbcbackup_uninstall() 185 { 186 wp_clear_scheduled_hook('dbc_backup'); 187 delete_option('dbcbackup_options'); 188 } 189 register_deactivation_hook(__FILE__, 'dbcbackup_uninstall'); 190 191 192 142 193 ?> -
dbc-backup-2/trunk/inc/functions.php
r570332 r821968 1 1 <?php 2 2 3 function dbcbackup_structure($table, $fp) 3 /** 4 * @param $table 5 * @param $fp 6 * 7 * @return bool 8 */ 9 function dbcbackup_structure($table, $fp) 4 10 { 5 11 $is_safe_mode = ini_get('safe_mode') == '1' ? 1 : 0; … … 7 13 $res =''; 8 14 $res .= "\n"; 9 $res .= "--\n"; 10 $res .= "-- Table structure of table ".dbcbackup_backquote($table)."\n"; 11 $res .= "--\n"; 15 $res .= "# Table structure of table ".dbcbackup_backquote($table)."\n"; 16 $res .= "# ------------------------------------------------------- \n"; 12 17 $res .= "\n"; 13 18 … … 19 24 unset($row); 20 25 $create_table = preg_replace('/^CREATE TABLE/', 'CREATE TABLE IF NOT EXISTS', $create_table); 21 $create_table = preg_replace("/ENGINE\s?=/", "TYPE=", $create_table); 26 //@todo delete the next line if this works 27 //$create_table = preg_replace("/ENGINE\s?=/", "TYPE=", $create_table); 22 28 $create_table .= ";\n"; 23 29 $res .= $create_table; … … 25 31 $status = true; 26 32 } 27 else 33 else 28 34 { 29 35 $tmp = mysql_error(); … … 38 44 /* ------------------ */ 39 45 40 function dbcbackup_data($table, $fp) 46 /** 47 * @param $table 48 * @param $fp 49 * @return bool 50 */function dbcbackup_data($table, $fp) 41 51 { 42 52 $is_safe_mode = ini_get('safe_mode') == '1' ? 1 : 0; … … 44 54 $res =''; 45 55 $res .= "\n"; 46 $res .= "--\n"; 47 $res .= "-- Dumping data for table ".dbcbackup_backquote($table)."\n"; 48 $res .= "--\n"; 56 $res .= "# Dumping data for table ".dbcbackup_backquote($table)."\n"; 57 $res .= "# ----------------------------------------------------- \n"; 49 58 $res .= "\n"; 50 59 dbcbackup_write($fp, $res); 51 60 52 61 if($sql = mysql_query("SELECT * FROM ".dbcbackup_backquote($table))) 53 62 { … … 60 69 while ($row = mysql_fetch_array($sql)) 61 70 { 62 $res = "INSERT INTO ".dbcbackup_backquote($table)." VALUES ("; 71 $res = "INSERT INTO ".dbcbackup_backquote($table)." VALUES ("; 63 72 $fieldcounter = -1; 64 73 $firstfield = 1; 65 74 while (++$fieldcounter < $numfields) 66 { 75 { 76 //tmp array and array dereferencing here 77 $fields_tmp = array(1,2,3); 78 67 79 if (!$firstfield){ 68 80 $res .= ', '; … … 75 87 && ! $fields_meta[$fieldcounter]->blob) { 76 88 $res .= $row[$fieldcounter]; 77 } elseif (stristr($field _flags[$j], 'BINARY')89 } elseif (stristr($fields_tmp[1], 'BINARY') 78 90 && isset($GLOBALS['hexforbinary']) 79 91 && $fields_meta[$fieldcounter]->type != 'datetime' … … 93 105 } // end if 94 106 } 95 $res .= ");\n"; 96 dbcbackup_write($fp, $res); 107 $res .= ");\n"; 108 dbcbackup_write($fp, $res); 97 109 } 98 110 //$res = "UNLOCK TABLES;\n"; … … 112 124 113 125 114 function dbcbackup_backquote($a_name) 126 /** 127 * @param $a_name 128 * @return array|string 129 */function dbcbackup_backquote($a_name) 115 130 { 116 131 //Add backqouotes to tables and db-names in SQL queries. Taken from phpMyAdmin. 117 if (!empty($a_name) && $a_name != '*') 118 { 119 if (is_array($a_name)) 132 if (!empty($a_name) && $a_name != '*') 133 { 134 if (is_array($a_name)) 120 135 { 121 136 $result = array(); 122 137 reset($a_name); 123 while(list($key, $val) = each($a_name)) 138 while(list($key, $val) = each($a_name)) 124 139 { 125 140 $result[$key] = '`' . $val . '`'; 126 141 } 127 142 return $result; 128 } 129 else 143 } 144 else 130 145 { 131 146 return '`' . $a_name . '`'; 132 147 } 133 } 134 else 148 } 149 else 135 150 { 136 151 return $a_name; … … 140 155 /* ------------------ */ 141 156 157 /** 158 * This is the header of the SQL file 159 * @return string 160 */ 142 161 function dbcbackup_header() 143 162 { 144 $header = "-- Database Cron Backup \n"; 145 $header .= "-- Version 1.0 for Wordpress 2.5+ \n"; 146 $header .= "-- Copyright Chris T aka Tefra http://www.t3-design.com \n"; 147 $header .= "-- Generated: ".date('l dS \of F Y h:i A', time() + (get_option('gmt_offset') * 3600))." \n"; 148 $header .= "-- MySQL Server: ".mysql_get_host_info()."\n"; 149 $header .= "-- MySQL Server version: ".mysql_get_server_info()."\n"; 150 $header .= "-- Database: ".dbcbackup_backquote(DB_NAME)."\n"; 151 $header .= "-- -------------------------------------------------------- \n"; 163 //@todo tidy this up 164 $link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD); 165 $header = "# ####################################################### \n"; 166 $header .= "# \n"; 167 $header .= "# DBC Backup 2\n"; 168 $header .= "# Version 2.3 for Wordpress 3.6 \n"; 169 $header .= "# Plugin by Damien Saunders http://wordpress.damien.co \n"; 170 $header .= "# Generated: ".date('l dS \of F Y h:i A', time() + (get_option('gmt_offset') * 3600))." \n"; 171 $header .= "# MySQL Server: ".mysqli_get_host_info($link)."\n"; 172 $header .= "# MySQL Server version: ".mysqli_get_server_info($link)."\n"; 173 $header .= "# Database: ".dbcbackup_backquote(DB_NAME)."\n"; 174 $header .= "# \n"; 175 $header .= "# ####################################################### \n"; 152 176 return $header; 153 177 } … … 155 179 /* ------------------ */ 156 180 157 function dbcbackup_fields($result) { 181 /** 182 * @param $result 183 * @return array 184 */function dbcbackup_fields($result) { 158 185 $fields = array(); 159 186 $num_fields = mysql_num_fields($result); 160 for ($i = 0; $i < $num_fields; $i++) 187 for ($i = 0; $i < $num_fields; $i++) 161 188 { 162 189 $fields[] = mysql_fetch_field($result, $i); … … 167 194 /* ------------------ */ 168 195 169 function dbcbackup_addslashes($a_string = '', $is_like = false, $crlf = false, $php_code = false) 196 /** 197 * @param string $a_string 198 * @param bool $is_like 199 * @param bool $crlf 200 * @param bool $php_code 201 * @return mixed 202 */function dbcbackup_addslashes($a_string = '', $is_like = false, $crlf = false, $php_code = false) 170 203 { //Taken from phpMyAdmin. 171 204 if ($is_like) { … … 189 222 /* ------------------ */ 190 223 224 /** 225 * PHP file write and compression settings 226 * @param $fp 227 * @param string $mode 228 * @return array 229 */ 191 230 function dbcbackup_open($fp, $mode='write') 192 231 { … … 219 258 /* ------------------ */ 220 259 221 function dbcbackup_read($fp) 260 /** 261 * @param $fp 262 * @return string 263 */function dbcbackup_read($fp) 222 264 { 223 265 switch(DBC_COMPRESSION) … … 240 282 /* ------------------ */ 241 283 242 function dbcbackup_write($fp, $code) 284 /** 285 * @param $fp 286 * @param $code 287 */function dbcbackup_write($fp, $code) 243 288 { 244 289 switch(DBC_COMPRESSION) … … 261 306 /* ------------------ */ 262 307 263 function dbcbackup_close($fp) 308 /** 309 * @param $fp 310 */function dbcbackup_close($fp) 264 311 { 265 312 switch(DBC_COMPRESSION) … … 282 329 /* ------------------ */ 283 330 284 function dbcbackup_rotate($cfg, $timenow) 331 /** 332 * @param $cfg 333 * @param $timenow 334 * @return int 335 */function dbcbackup_rotate($cfg, $timenow) 285 336 { 286 337 $removed = 0; … … 315 366 return $removed; 316 367 } 317 318 ?> -
dbc-backup-2/trunk/readme.txt
r721073 r821968 1 === Plugin Name===1 === DBC Backup 2 === 2 2 Contributors: damiensaunders 3 3 Donate link: 4 4 Tags: Database, Cron, Backup, Schedule, SQL, data, extract 5 Requires at least: 3. 06 Tested up to: 3. 67 Stable tag: 2.1.2 #stable tag not the same as the SVN commit tag5 Requires at least: 3.6 6 Tested up to: 3.8 7 Stable tag: 2.1.2 8 8 9 9 DBC Backup 2 is a safe & simple way to schedule regular WordPress database backups using the wp-cron batch jobs. … … 23 23 24 24 = Additional Info = 25 The plugin will try to auto create the export directory 25 The plugin will try to auto create the export directory. 26 27 This plugin creates it's own sql file and does not use mysqldump like most other plugins. 26 28 27 29 During backup, a log is created that includes, the generation date, file, filesize, status and the duration of the generation. … … 44 46 == Changelog == 45 47 48 = Version 2.3 = 49 - Major update, new layout 50 - FIXED - issue with SQL file that prevented it from being imported 51 - FIXED - a lot of the PHP error notices which annoy many developers 52 - FIXED - now use mysqli.query as mysql_query is deprecated 53 46 54 = Version 2.2 = 47 - Killed a few bugs. Getting this ready for the next WordPress 3.6 55 - Killed a few bugs. Getting this ready for the next WordPress 3.6 48 56 49 57 = Version 2.1.1 =
Note: See TracChangeset
for help on using the changeset viewer.