back-up your database just in case.
Version: 3.0.5
Author: Mike Jolley
Author URI: http://blue-anvil.com
*/
/* Copyright 2006 Michael Jolley (email : jolley.small.at.googlemail.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
################################################################################
// Vars and version
################################################################################
$dlm_build="B20090325";
$wp_dlm_root = get_bloginfo('wpurl')."/wp-content/plugins/download-monitor/";
global $table_prefix;
$wp_dlm_db = $table_prefix."DLM_DOWNLOADS";
$wp_dlm_db_cats = $table_prefix."DLM_CATS";
$wp_dlm_db_formats = $table_prefix."DLM_FORMATS";
$wp_dlm_db_stats = $table_prefix."DLM_STATS";
$wp_dlm_db_log = $table_prefix."DLM_LOG";
$wp_dlm_db_meta = $table_prefix."DLM_META";
$def_format = get_option('wp_dlm_default_format');
$dlm_url = get_option('wp_dlm_url');
$downloadtype = get_option('wp_dlm_type');
if (empty($dlm_url))
$downloadurl = $wp_dlm_root.'download.php?id=';
else
$downloadurl = get_bloginfo('wpurl').'/'.$dlm_url;
load_plugin_textdomain('wp-download_monitor', 'wp-content/plugins/download-monitor/', 'download-monitor/');
################################################################################
// ADD MEDIA BUTTONS AND FORMS
################################################################################
function wp_dlm_add_media_button() {
echo '';
}
################################################################################
// HANDLE UPDATES
################################################################################
function wp_dlm_update() {
global $dlm_build;
add_option('wp_dlm_build', $dlm_build, 'Version of DLM plugin', 'no');
if ( get_option('wp_dlm_build') != $dlm_build ) {
// Init again
wp_dlm_init();
// Show update message
//echo '
';
//_e('
The plugin has recently been updated - You may need to re-save your permalinks settings (Options/settings -> Permalinks) for the changes to occur in your blog.
If you encounter any errors, such as not being able to save a file to the database, try using the Recreate Download Database option.
',"wp-download_monitor");
// Update the build
update_option('wp_dlm_build', $dlm_build);
}
}
################################################################################
// Set up menus within the wordpress admin sections
################################################################################
function wp_dlm_menu() {
global $wp_dlm_root;
// Add a new top-level menu:
add_menu_page(__('Downloads','wp-download_monitor'), __('Downloads','wp-download_monitor'), 6, __FILE__ , 'wp_dlm_admin', $wp_dlm_root.'/img/menu_icon.png');
// Add submenus to the custom top-level menu:
add_submenu_page(__FILE__, __('Edit','wp-download_monitor'), __('Edit','wp-download_monitor') , 6, __FILE__ , 'wp_dlm_admin');
add_submenu_page(__FILE__, __('Add New','wp-download_monitor') , __('Add New','wp-download_monitor') , 6, 'dlm_addnew', 'dlm_addnew');
add_submenu_page(__FILE__, __('Add Existing','wp-download_monitor') , __('Add Existing','wp-download_monitor') , 6, 'dlm_addexisting', 'dlm_addexisting');
add_submenu_page(__FILE__, __('Configuration','wp-download_monitor') , __('Configuration','wp-download_monitor') , 6, 'dlm_config', 'wp_dlm_config');
add_submenu_page(__FILE__, __('Log','wp-download_monitor') , __('Log','wp-download_monitor') , 6, 'dlm_log', 'wp_dlm_log');
}
add_action('admin_menu', 'wp_dlm_menu');
################################################################################
// ADMIN HEADER
################################################################################
function wp_dlm_head() {
global $wp_db_version, $wp_dlm_root;
// Provide css based on wordpress version.
if ($wp_db_version < 9872) {
// 2.5 + 2.6 with new interface
echo '';
} else {
// 2.7
echo '';
}
if ($_GET['activate'] && $_GET['activate']==true) {
wp_dlm_init();
}
if (
$_REQUEST['page']=='dlm_addnew' ||
$_REQUEST['page']=='dlm_addexisting' ||
$_REQUEST['page']=='download-monitor/wp-download_monitor.php' ||
$_REQUEST['page']=='download-monitor/wp-download_monitor.php'
) {
?>
supports_collation()) {
if(!empty($wpdb->charset)) $collate = "DEFAULT CHARACTER SET $wpdb->charset";
if(!empty($wpdb->collate)) $collate .= " COLLATE $wpdb->collate";
}
// Create tables
$sql = "CREATE TABLE IF NOT EXISTS ".$wp_dlm_db." (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`title` VARCHAR (200) NOT NULL ,
`filename` LONGTEXT NOT NULL ,
`file_description` LONGTEXT NULL ,
`dlversion` VARCHAR (200) NOT NULL ,
`postDate` DATETIME NOT NULL ,
`hits` INT (12) UNSIGNED NOT NULL ,
`user` VARCHAR (200) NOT NULL ,
`category_id` INT (12) NULL,
`members` INT (1) NULL,
`mirrors` LONGTEXT NULL,
PRIMARY KEY ( `id` )) $collate;";
$result = $wpdb->query($sql);
$sql = "CREATE TABLE IF NOT EXISTS ".$wp_dlm_db_cats." (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` LONGTEXT NOT NULL ,
`parent` INT (12) UNSIGNED NOT NULL,
PRIMARY KEY ( `id` )) $collate;";
$result = $wpdb->query($sql);
$sql = "CREATE TABLE IF NOT EXISTS ".$wp_dlm_db_formats." (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR (250) NOT NULL ,
`format` LONGTEXT NOT NULL,
PRIMARY KEY ( `id` )) $collate;";
$result = $wpdb->query($sql);
$sql = "CREATE TABLE IF NOT EXISTS ".$wp_dlm_db_stats." (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`download_id` INT UNSIGNED NOT NULL,
`date` DATE NOT NULL ,
`hits` INT (12) UNSIGNED NOT NULL,
PRIMARY KEY ( `id` )) $collate;";
$result = $wpdb->query($sql);
$sql = "CREATE TABLE IF NOT EXISTS ".$wp_dlm_db_log." (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`download_id` INT UNSIGNED NOT NULL,
`user_id` INT UNSIGNED NOT NULL,
`date` DATETIME NULL ,
`ip_address` VARCHAR (200) NULL ,
PRIMARY KEY ( `id` )) $collate;";
$result = $wpdb->query($sql);
$sql = "CREATE TABLE IF NOT EXISTS ".$wp_dlm_db_meta." (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`meta_name` LONGTEXT NOT NULL ,
`meta_value` LONGTEXT NOT NULL ,
`download_id` INT (12) UNSIGNED NOT NULL,
PRIMARY KEY ( `id` )) $collate;";
$result = $wpdb->query($sql);
$q = $wpdb->get_results("select * from $wp_dlm_db;");
if ( empty( $q ) ) {
$wpdb->query("TRUNCATE table $wp_dlm_db");
}
return;
}
################################################################################
// Reinstall function
################################################################################
function wp_dlm_reinstall() {
global $wpdb, $wp_dlm_db, $wp_dlm_db_cats;
// GET OLD DATA
$wpdb->show_errors;
$query = sprintf("SELECT * from %s;",
$wpdb->escape( $wp_dlm_db ));
$result_d = $wpdb->get_results($query);
if($result_d && $wpdb->num_rows>0) {
$values="";
foreach($result_d as $d) {
$id=$d->id;
$title=$d->title;
$filename=$d->filename;
$dlversion=$d->dlversion;
$postDate=$d->postDate;
$hits=$d->hits;
$user=$d->user;
$members=$d->members;
$category_id=$d->category_id;
$mirrors=$d->mirrors;
$file_description=$d->file_description;
$values.='("'.$id.'","'.$title.'","'.$filename.'","'.$dlversion.'","'.$postDate.'","'.$hits.'","'.$user.'","'.$members.'","'.$category_id.'","'.$mirrors.'","'.$file_description.'"),';
}
$values = substr_replace($values,"",-1);
}
$query = sprintf("SELECT * from %s;",
$wpdb->escape( $wp_dlm_db_cats ));
$result_cats = $wpdb->get_results($query);
if($result_cats && $wpdb->num_rows>0) {
$values2="";
foreach($result_cats as $d) {
$id=$d->id;
$name=$d->name;
$parent=$d->parent;
$values2.='("'.$id.'","'.$name.'","'.$parent.'"),';
}
$values2 = substr_replace($values2,"",-1);
}
// DROP TABLES
$sql = 'DROP TABLE IF EXISTS `'.$wp_dlm_db.'`';
$wpdb->query($sql);
$sql = 'DROP TABLE IF EXISTS `'.$wp_dlm_db_cats.'`';
$wpdb->query($sql);
wp_dlm_init();
// Change Collation (we forgot to do this in older versions)
if($wpdb->supports_collation()) {
if(!empty($wpdb->charset)) $char_set = $wpdb->charset;
if(!empty($wpdb->collate)) $collate = 'collate '.$wpdb->collate;
}
if ($char_set) {
global $wp_dlm_db_formats,$wp_dlm_db_stats,$wp_dlm_db_log,$wp_dlm_db_meta;
$wpdb->query('ALTER TABLE '.$wp_dlm_db_formats.' convert to character set '.$char_set.' '.$collate.';');
$wpdb->query('ALTER TABLE '.$wp_dlm_db_stats.' convert to character set '.$char_set.' '.$collate.';');
$wpdb->query('ALTER TABLE '.$wp_dlm_db_log.' convert to character set '.$char_set.' '.$collate.';');
$wpdb->query('ALTER TABLE '.$wp_dlm_db_meta.' convert to character set '.$char_set.' '.$collate.';');
}
// ADD OLD DATA
if (!empty($values)) {
$query_ins = sprintf("INSERT INTO %s (id, title, filename, dlversion, postDate, hits, user, members, category_id, mirrors, file_description) VALUES %s;",
$wpdb->escape( $wp_dlm_db ),
$values);
$wpdb->query($query_ins);
}
if (!empty($values2)) {
$query_ins = sprintf("INSERT INTO %s (id, name, parent) VALUES %s;",
$wpdb->escape( $wp_dlm_db_cats ),
$values2);
$wpdb->query($query_ins);
}
}
################################################################################
// MAGIC QUOTES - WORDPRESS DOES THIS BUT ADDS THE SLASHES BACK - I DONT WANT THEM!
################################################################################
function wp_dlm_magic() {
function stripit($in) {
if (!is_array($in)) $out = stripslashes($in); else $out = $in;
return $out;
}
//if (get_magic_quotes_gpc() || get_magic_quotes_runtime() ){
$_GET = array_map('stripit', $_GET);
$_POST = array_map('stripit', $_POST);
$_REQUEST = array_map('stripit', $_REQUEST);
//}
return;
}
################################################################################
// INSERT BUTTON ON POST SCREEN
################################################################################
function wp_dlm_ins_button() {
//set globals
global $table_prefix,$wpdb,$wp_dlm_db,$wp_dlm_db_cats;
if( strpos($_SERVER['REQUEST_URI'], 'post.php')
|| strstr($_SERVER['PHP_SELF'], 'page-new.php')
|| strstr($_SERVER['PHP_SELF'], 'page.php')
|| strstr($_SERVER['PHP_SELF'], 'post-new.php') )
{
// select all downloads
$query_select = sprintf("SELECT * FROM %s ORDER BY id;",
$wpdb->escape($wp_dlm_db));
$downloads = $wpdb->get_results($query_select);
$js .= '';
if (!empty($downloads)) {
$js .= '';
// select all cats
$query_select_cats = sprintf("SELECT * FROM %s WHERE parent=0 ORDER BY id;",
$wpdb->escape( $wp_dlm_db_cats ));
$cats = $wpdb->get_results($query_select_cats);
if (!empty($cats)) {
$js .= '';
}
?>
escape($wp_dlm_db_formats),
$wpdb->escape($id));
$format = $wpdb->get_row($query_select);
return $format->format;
}
################################################################################
// SHORTCODES
################################################################################
function wp_dlm_shortcode_download( $atts ) {
extract(shortcode_atts(array(
'id' => '0',
'format' => '0',
'autop' => false
), $atts));
global $wpdb,$wp_dlm_root,$wp_dlm_db,$wp_dlm_db_formats,$wp_dlm_db_cats, $def_format, $dlm_url, $downloadurl, $downloadtype, $wp_dlm_db_meta;
if ($id>0) {
// Handle Formats
if (!$format && $def_format>0) {
$format = wp_dlm_get_custom_format($def_format);
} elseif ($format>0 && is_numeric($format) ) {
$format = wp_dlm_get_custom_format($format);
} else {
// Format is set!
$format = html_entity_decode($format);
}
if (empty($format) || $format=='0') {
$format = '{title} ({hits})';
}
// Get download info
$d = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wp_dlm_db WHERE id = %s" , $id ) );
if ($d) {
switch ($downloadtype) {
case ("Title") :
$downloadlink = urlencode($d->title);
break;
case ("Filename") :
$downloadlink = $d->filename;
$links = explode("/",$downloadlink);
$downloadlink = end($links);
break;
default :
$downloadlink = $d->id;
break;
}
$format = str_replace('\\"',"'",$format);
$fpatts = array('{url}', '{version}', '{title}', '{size}', '{hits}', '{image_url}', '{description}', '{description-autop}', '{category}');
$fsubs = array( $downloadurl.$downloadlink , $d->dlversion , $d->title , wp_dlm_get_size($d->filename) , $d->hits , get_option('wp_dlm_image_url') , $d->file_description , wpautop($d->file_description) );
// Category
if ($d->category_id>0) {
$c = $wpdb->get_row("SELECT name FROM $wp_dlm_db_cats where id=".$d->category_id." LIMIT 1;");
$fsubs[] = $c->name;
preg_match("/{category,\s*\"([^\"]*?)\",\s*\"([^\"]*?)\"}/", $format, $match);
$fpatts[] = $match[0];
$fsubs[] = $match[1].$c->name.$match[2];
} else {
$fsubs[] = "";
preg_match("/{category,\s*\"([^\"]*?)\",\s*\"([^\"]*?)\"}/", $format, $match);
$fpatts[] = $match[0];
$fsubs[] = "";
}
// Hits (special) {hits, none, one, many)
preg_match("/{hits,\s*\"([^\"]*?)\",\s*\"([^\"]*?)\",\s*\"([^\"]*?)\"}/", $format, $match);
$fpatts[] = $match[0];
if ( $d->hits == 1 )
{
$text = str_replace('%',$d->hits,$match[2]);
$fsubs[] = $text;
}
elseif ( $d->hits > 1 )
{
$text = str_replace('%',$d->hits,$match[3]);
$fsubs[] = $text;
}
else
{
$text = str_replace('%',$d->hits,$match[1]);
$fsubs[] = $text;
}
// Version
preg_match("/{version,\s*\"([^\"]*?)\",\s*\"([^\"]*?)\"}/", $format, $match);
$fpatts[] = $match[0];
if ($d->dlversion) $fsubs[] = $match[1].$d->dlversion.$match[2]; else $fsubs[] = "";
// Date
preg_match("/{date,\s*\"([^\"]*?)\"}/", $format, $match);
$fpatts[] = $match[0];
if ($d->postDate) $fsubs[] = date_i18n($match[1],strtotime($d->postDate)); else $fsubs[] = "";
// Other
preg_match("/{description,\s*\"([^\"]*?)\",\s*\"([^\"]*?)\"}/", $format, $match);
$fpatts[] = $match[0];
if ($d->file_description) $fsubs[] = $match[1].$d->file_description.$match[2]; else $fsubs[] = "";
preg_match("/{description-autop,\s*\"([^\"]*?)\",\s*\"([^\"]*?)\"}/", $format, $match);
$fpatts[] = $match[0];
if ($d->file_description) $fsubs[] = $match[1].wpautop($d->file_description).$match[2]; else $fsubs[] = "";
// meta
if (preg_match("/{meta-([^,]*?)}/", $format, $match)) {
$meta_data = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wp_dlm_db_meta WHERE download_id = %s" , $id ) );
foreach($meta_data as $meta) {
$fpatts[] = "{meta-".$meta->meta_name."}";
$fsubs[] = $meta->meta_value;
$fpatts[] = "{meta-autop-".$meta->meta_name."}";
$fsubs[] = wpautop($meta->meta_value);
}
}
$output = str_replace( $fpatts , $fsubs , $format );
} else $output = '[Download not found]';
} else $output = '[Download id not defined]';
if ($autop) return wpautop($output);
return $output;
}
add_shortcode('download', 'wp_dlm_shortcode_download');
################################################################################
// LEGACY TAGS SUPPORT
################################################################################
function wp_dlm_parse_downloads($data) {
if (substr_count($data,"[download#")) {
preg_match_all("/\[download#([0-9]+)#format=([0-9]+)\]/", $data, $matches, PREG_SET_ORDER);
if ( sizeof( $matches ) > 0 ) foreach ($matches as $val) {
$code = '[download id="'.$val[1].'" format="'.$val[2].'"]';
$data = str_replace( $val[0] , $code , $data );
} // End foreach
// Handle Non-formatted downloads
preg_match_all("/\[download#([0-9]+)/", $data, $matches, PREG_SET_ORDER);
$patts = array();
$subs = array();
if ( sizeof( $matches ) > 0 ) foreach ($matches as $val) {
$patts[] = "[download#" . $val[1] . "]";
$subs[] = '[download id="'.$val[1].'"]';
// No hit counter
$format = '{title}';
$patts[] = "[download#" . $val[1] . "#nohits]";
$subs[] = '[download id="'.$val[1].'" format="'.htmlspecialchars($format).'"]';
// URL only
$format = '{url}';
$patts[] = "[download#" . $val[1] . "#url]";
$subs[] = '[download id="'.$val[1].'" format="'.htmlspecialchars($format).'"]';
// Description only
$format = '{description}';
$patts[] = "[download#" . $val[1] . "#description]";
$subs[] = '[download id="'.$val[1].'" format="'.htmlspecialchars($format).'"]';
// Description (autop) only
$format = '{description-autop}';
$patts[] = "[download#" . $val[1] . "#description_autop]";
$subs[] = '[download id="'.$val[1].'" format="'.htmlspecialchars($format).'"]';
// Hits only
$format = '{hits}';;
$patts[] = "[download#" . $val[1] . "#hits]";
$subs[] = '[download id="'.$val[1].'" format="'.htmlspecialchars($format).'"]';
// Image link
$format = '';
$patts[] = "[download#" . $val[1] . "#image]";
$subs[] = '[download id="'.$val[1].'" format="'.htmlspecialchars($format).'"]';
// Regular download link WITH filesize
$format = '{title} ({hits}) - {size}';
$patts[] = "[download#" . $val[1] . "#size]";
$subs[] = '[download id="'.$val[1].'" format="'.htmlspecialchars($format).'"]';
// No hit counter + filesize
$format = '{title} ({size})';
$patts[] = "[download#" . $val[1] . "#size#nohits]";
$subs[] = '[download id="'.$val[1].'" format="'.htmlspecialchars($format).'"]';
} // End foreach
$data = str_replace($patts, $subs, $data);
} // End if [download# found
global $wpdb, $wp_dlm_db, $wp_dlm_db_meta, $wp_dlm_db_cats, $downloadurl, $downloadtype;
// Handle CATEGORIES
if (substr_count($data,"[download_cat#")) {
$patts = array();
$subs = array();
preg_match_all("/\[download_cat#([0-9]+)#format=([0-9]+)\]/", $data, $result, PREG_SET_ORDER);
if ($result) foreach ($result as $val) {
$format = wp_dlm_get_custom_format($val[2]);
if ($format) {
$format = str_replace('\\"',"'",$format);
// Traverse through categories to get sub-cats
$the_cats = array();
$the_cats[] = $val[1];
$the_cats = wp_dlm_get_sub_cats($the_cats);
// Get downloads for category and sub-categories
$query = "SELECT * FROM $wp_dlm_db WHERE category_id IN (".implode(',',$the_cats).") ORDER BY 'title'";
$downloads = $wpdb->get_results($query);
// GENERATE LIST
$links = '
';
$patts[] = "[download_cat#" . $val[1] . "#format=" . $val[2] . "]";
$subs[] = $links;
} // End if format
} // End foreach
$data = str_replace($patts, $subs, $data);
$patts = array();
$subs = array();
preg_match_all("|\[download_cat#([0-9]+)\]|U",$data,$result,PREG_SET_ORDER);
if ($result) foreach ($result as $val) {
// Traverse through categories to get sub-cats
$the_cats = array();
$the_cats[] = $val[1];
$the_cats = wp_dlm_get_sub_cats($the_cats);
// Get downloads for category and sub-categories
$query ="SELECT * FROM $wp_dlm_db WHERE category_id IN (".implode(',',$the_cats).") ORDER BY 'title'";
$downloads = $wpdb->get_results($query);
// GENERATE LIST
$links = '
';
if (!empty($downloads)) {
foreach($downloads as $d) {
switch ($downloadtype) {
case ("Title") :
$downloadlink = urlencode($d->title);
break;
case ("Filename") :
$downloadlink = $d->filename;
$link = explode("/",$downloadlink);
$downloadlink = urlencode(end($link));
break;
default :
$downloadlink = $d->id;
break;
}
if (!empty($d->dlversion))
$links.= '
Need help? FAQ, Usage instructions and other notes can be found on the plugin page here.',"wp-download_monitor"); ?>
The Wordpress Download monitor plugin was created by Mike Jolley. The development
of this plugin took a lot of time and effort, so please don\'t forget to donate if you found this plugin useful to ensure continued development.',"wp-download_monitor"); ?>
';
}
################################################################################
// Configuration page
################################################################################
function wp_dlm_config() {
//set globals
global $wpdb,$wp_dlm_root,$wp_dlm_db,$wp_dlm_db_cats,$wp_dlm_db_formats,$dlm_url,$downloadtype;
// turn off magic quotes
wp_dlm_magic();
wp_dlm_update();
?>
';
_e('
Download URL updated - You need to re-save your permalinks settings (Options/settings -> Permalinks) for
the changes to occur in your blog.
If your .htaccess file cannot be written to by WordPress, add the following to your
.htaccess file above the "# BEGIN WordPress" line:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^download/([^/]+)$ wp-content/plugins/download-monitor/download.php?id=$1 [L]
replacing "download/" with your custom url.
',"wp-download_monitor");
echo '
';
} else {
echo '
';
_e('
Download URL updated - You need to re-save your permalinks settings (Options/settings -> Permalinks) for
the changes to occur in your blog.
If your .htaccess file cannot be written to by WordPress, remove the following from your
.htaccess file if it exists above the "# BEGIN WordPress" line:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^download/([^/]+)$ wp-content/plugins/download-monitor/download.php?id=$1 [L]
replacing "download/" with your previous custom url.
You can categorise downloads using these categories. You can then show groups of downloads using the category tags or a dedicated download page (see documentation). Please note, deleting a category also deletes it\'s child categories.',"wp-download_monitor"); ?>
This allows you to define formats in which to output your downloads however you want.',"wp-download_monitor"); ?>
Set a custom url for your downloads, e.g. download/. You can also choose how to link to the download in it\'s url, e.g. selecting "filename" would make the link appear as http://yoursite.com/download/filename.zip.
Leave this option blank to use the default download path (wp-content/plugins/download-monitor/download.php?id=)
If you fill in this option ensure the custom directory does not exist on the server nor does it match a page or post\'s url as this can cause problems redirecting to download.php.
',"wp-download_monitor"); ?>
This will delete the old download monitor tables and recreate them. You should only do this as a last resort if experiencing database errors after updating the plugin. Download monitor will attempt to re-add any downloads currently in the database.',"wp-download_monitor"); ?>
WARNING: THIS MAY DELETE DOWNLOAD DATA IN THE DATABASE; BACKUP YOUR DATABASE FIRST!',"wp-download_monitor"); ?>
';
}
################################################################################
// let_to_num used for file sizes
################################################################################
function let_to_num($v){ //This function transforms the php.ini notation for numbers (like '2M') to an integer (2*1024*1024 in this case)
$l = substr($v, -1);
$ret = substr($v, 0, -1);
switch(strtoupper($l)){
case 'P':
$ret *= 1024;
case 'T':
$ret *= 1024;
case 'G':
$ret *= 1024;
case 'M':
$ret *= 1024;
case 'K':
$ret *= 1024;
break;
}
return $ret;
}
################################################################################
// Add Download Page
################################################################################
function dlm_addnew() {
//set globals
global $wpdb,$wp_dlm_root,$wp_dlm_db,$wp_dlm_db_cats,$wp_dlm_db_formats,$wp_dlm_db_meta;
// turn off magic quotes
wp_dlm_magic();
wp_dlm_update();
?>
Required field: Title omitted
',"wp-download_monitor");
if (empty( $_POST['dlhits'] )) $_POST['dlhits'] = 0;
if (!is_numeric($_POST['dlhits'] )) $errors.=__('