diff --git a/api/download.php b/api/download.php index ab29708..3e59cf5 100644 --- a/api/download.php +++ b/api/download.php @@ -9,8 +9,8 @@ // loop over all the versions for each theme and plugin foreach ( $package['versions'] as $version ) { // md5 timestamp of current and previous day and the file name - $tod_md5 = md5( $version['file_name'] . mktime( 0, 0, 0, date( "m" ), date( "d" ), date( "Y" ) ) ); - $yes_md5 = md5( $version['file_name'] . mktime( 0, 0, 0, date( "m" ), date( "d" ) - 1, date( "Y" ) ) ); + $tod_md5 = md5( $version['file_name'] . mktime( 0, 0, 0, date( "n" ), date( "j" ), date( "Y" ) ) ); + $yes_md5 = md5( $version['file_name'] . mktime( 0, 0, 0, date( "n" ), date( "j" ) - 1, date( "Y" ) ) ); // test if the either of the md5 hashes match what was passed if ( $_GET['key'] == $tod_md5 || $_GET['key'] == $yes_md5 ) { $download = $update_folder . $version['file_name']; @@ -29,4 +29,4 @@ } } } -?> \ No newline at end of file +?> diff --git a/api/index.php b/api/index.php index bc642f7..1aadda5 100644 --- a/api/index.php +++ b/api/index.php @@ -58,6 +58,7 @@ $data = new stdClass; $data->slug = $args->slug; + $data->name = $latest_package['name']; $data->version = $latest_package['version']; $data->last_updated = $latest_package['date']; $data->download_link = $latest_package['package']; diff --git a/api/packages.php b/api/packages.php index d43f425..ca2bc8a 100644 --- a/api/packages.php +++ b/api/packages.php @@ -6,7 +6,7 @@ 'version' => '1.0', //Current version available 'date' => '2010-04-10', //Date version was released //theme.zip is the same as file_name - 'package' => 'http://url_to_your_site/download.php?key=' . md5('theme.zip' . mktime(0,0,0,date("m"),date("d"),date("Y"))), + 'package' => 'http://url_to_your_site/download.php?key=' . md5('theme.zip' . mktime(0,0,0,date("n"),date("j"),date("Y"))), //file_name is the name of the file in the update folder. 'file_name' => 'theme.zip', //File name of theme zip file 'author' => 'Author Name', //Author of theme @@ -26,15 +26,16 @@ 'versions' => array( '1.0' => array( //Array name should be set to current version of update 'version' => '1.0', //Current version available + 'name' => 'Plugin name', //Plugin name 'date' => '2010-04-10', //Date version was released 'author' => 'Author Name', //Author name - can be linked using html - Author Name 'requires' => '2.8', // WP version required for plugin 'tested' => '3.0.1', // WP version tested with - 'homepage' => 'http://your_plugin_website', // Site devoted to your plugin if available + 'plugin_homepage' => 'http://your_plugin_website', // Site devoted to your plugin if available 'downloaded' => '1000', // Number of times downloaded 'external' => '', // Unused //plugin.zip is the same as file_name - 'package' => 'http://url_to_your_site/download.php?key=' . md5('plugin.zip' . mktime(0,0,0,date("m"),date("d"),date("Y"))), + 'package' => 'http://url_to_your_site/download.php?key=' . md5('plugin.zip' . mktime(0,0,0,date("n"),date("j"),date("Y"))), //file_name is the name of the file in the update folder. 'file_name' => 'plugin.zip', 'sections' => array( @@ -55,4 +56,4 @@ 'info' => array( 'url' => 'http://your_plugin_webiste' // Site devoted to your plugin if available ) -); \ No newline at end of file +); diff --git a/readme.md b/readme.md index 71c5657..2a02d41 100644 --- a/readme.md +++ b/readme.md @@ -1,56 +1 @@ -## Automatic Theme & Plugin Updater for Self-Hosted Themes/Plugins - -**Support This Developer: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SE9ZVJUS324UC** - -*Any amount is always appreciated* - - -## General Info - -For themes and plugins that can't be submitted to official WordPress repository, ie ... commercial themes/plugins/, non-gpl licensed, written for one client. - -### Folder structure -* api (Folder to upload to server where updates will be housed) - * .htaccess (set Options+Indexes to allow checking to work properly) - * index.php (holds code used to check request for new versions) - * packages.php (file containing all info about plugins and themes) - * download.php (validates md5 key of date and package zip file) - * update (folder to hold all zip file updates for url masking - protected by .htaccess to disallow file listings) - - -* update (default folder for holding theme and plugin zip files) - * .htaccess (prevents indexing and viewing of any zip files in directory) - - -* plugin (folder for adding plugin update checking) - * test-plugin-update (simple plugin folder to show how update functions work) - * test-plugin-update.php (example plugin that only checks for updates to server) - - -* theme (folder for theme update checking) - * update.php (file that can be included from functions.php of theme to check for updates) - ---------------- - -**Important:** - -*Change $api_url to your api server url in:* - - /plugin/test-plugin-update/test-plugin-update.php - /theme/update.php - -## Adding new versions - -Edit the packages.php under api folder on your server. Commented thoroughly throughout with sections that need to be changed to reflect themes/plugins that are to be updated. - -## Adding additional themes/plugins - -Simply create another $package array with the key of the new theme/plugin slug and add all the appropriate info. When releasing the theme/plugin make sure that functions and variables are prefixed to prevent errors and allow multiple themes/plugins to be updated. - -## Child theme support - -Child themes are now supported. If the theme being updated is meant to be a parent theme the standard theme/update.php from the theme file will work. If the theme is a child theme of another theme comment out the parent theme section and uncomment the child theme section on the theme/update.php - -## Securing Download location - -Downloads are now always secured by a md5 hash of the package file_name and timestamp of current date. When downloading file current timestamp and timestamp of previous day are compared to key received from update request, if either match zip file is passed, and file can be downloaded. \ No newline at end of file +TEST