on your server. It will attempt to read sub-directories too. It will do its best to choose relevant titles for each download - if you need to change titles or add extra information you will have to edit the downloads afterwards.',"wp-download_monitor"); ?>

No folder selected
',"wp-download_monitor"); $tags = $_POST['tags']; //save to db if ( empty($errors ) ) { if (!function_exists('php4_scandir') && !function_exists('scandir')) { function php4_scandir($dir,$listDirectories=true) { $dirArray = array(); if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if($listDirectories == false) { if(is_dir($file)) { continue; } } array_push($dirArray,basename($file)); } closedir($handle); } return $dirArray; } } global $found_downloads, $extensions; $extensions = array(); if ($exe) $extensions = explode(',',$exe); global $found_downloads; $found_downloads = array(); function find_downloads($dir) { global $found_downloads, $extensions; $root_dir = ''; if( file_exists($root_dir . $dir) ) { if (function_exists('scandir')) { $files = scandir($root_dir . $dir); } else { $files = php4_scandir($root_dir . $dir); } if( count($files) > 2 ) { // All dirs foreach( $files as $file ) { if( file_exists($root_dir . $dir . $file) && $file != '.' && $file != '..' && is_dir($root_dir . $dir . $file) ) { find_downloads(htmlentities($dir . $file .'/')); } } // All files foreach( $files as $file ) { if( file_exists($root_dir . $dir . $file) && $file != '.' && $file != '..' && !is_dir($root_dir . $dir . $file) ) { $ext = preg_replace('/^.*\./', '', $file); if ($ext!='php' && (in_array($ext, $extensions) || sizeof($extensions)==0)) { $info = pathinfo($file); $found_downloads[] = array( 'path' => htmlentities($dir . $file), 'title' => trim(ucwords(htmlentities(str_replace('_',' ',str_replace('.'.$info['extension'],'',$file))))) ); } } } } } } $dir = urldecode($filename); $dir = str_replace(get_bloginfo('wpurl').'/', ABSPATH, $dir); find_downloads($dir); if (sizeof($found_downloads)>0) { $count = 0; $found_download_ids = array(); foreach ($found_downloads as $adownload) { $query_add = sprintf("INSERT INTO %s (title, filename, dlversion, postDate, hits, user, members, mirrors, file_description) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s')", $wpdb->escape( $wp_dlm_db ), $wpdb->escape( $adownload['title'] ), $wpdb->escape( $adownload['path'] ), "", $wpdb->escape( $_POST['postDate'] ), "0", $wpdb->escape( $_POST['user'] ), $wpdb->escape( $members ), "", "" ); $result = $wpdb->query($query_add); if ($result) { $download_insert_id = $wpdb->insert_id; $found_download_ids[] = $download_insert_id; // Loop Categories $cats = $download_taxonomies->categories; $values = array(); if (!empty($cats)) { foreach ( $cats as $c ) { $this_cat_value = (isset($_POST[ 'category_'.$c->id ])) ? 1 : 0; if ($this_cat_value) $values[] = '("'.$wpdb->escape( $c->id ).'", '.$download_insert_id.')'; } } if (sizeof($values)>0) $wpdb->query("INSERT INTO $wp_dlm_db_relationships (taxonomy_id, download_id) VALUES ".implode(',', $values).""); // Tags $values = array(); if ($tags) { // Break 'em up $thetags = explode(',', $tags); $thetags = array_map('trim', $thetags); if (sizeof($thetags)>0) { foreach ($thetags as $tag) { if ($tag) { // Exists? $tag_id = $wpdb->get_var("SELECT id FROM $wp_dlm_db_taxonomies WHERE taxonomy='tag' AND name='".$wpdb->escape($tag)."';"); // Insert if (!$tag_id) { $wpdb->query("INSERT INTO $wp_dlm_db_taxonomies (name, parent, taxonomy) VALUES ('".$wpdb->escape($tag)."', 0, 'tag');"); $tag_id = $wpdb->insert_id; } if ($tag_id) $values[] = '("'.$wpdb->escape( $tag_id ).'", '.$download_insert_id.')'; } } } } if (sizeof($values)>0) $wpdb->query("INSERT INTO $wp_dlm_db_relationships (taxonomy_id, download_id) VALUES ".implode(',', $values).""); // Thumbnail if (isset($thumbnail)) { $wpdb->query("INSERT INTO $wp_dlm_db_meta (meta_name, meta_value, download_id) VALUES ('thumbnail', '".$wpdb->escape( $thumbnail )."', '".$download_insert_id."')"); } // Force Download if (isset($forcedownload)) { $wpdb->query("INSERT INTO $wp_dlm_db_meta (meta_name, meta_value, download_id) VALUES ('force', '".$wpdb->escape( $forcedownload )."', '".$download_insert_id."')"); } $count ++; } } // Process and save meta/custom fields $index = 1; $values = array(); if (isset($_POST['meta'])) foreach ($_POST['meta'] as $meta) { if (trim($meta['key'])) { if ($found_download_ids) foreach($found_download_ids as $download_id) { $values[] = '("'.$wpdb->escape(strtolower((str_replace(' ','-',trim(stripslashes($meta['key'])))))).'", "'.$wpdb->escape($meta['value']).'", '.$download_id.')'; $index ++; } } } if (sizeof($values)>0) $wpdb->query("INSERT INTO $wp_dlm_db_meta (meta_name, meta_value, download_id) VALUES ".implode(',', $values).""); wp_dlm_clear_cached_stuff(); // Message echo '

'.$count.' '.__("Downloads added Successfully","wp-download_monitor").'

'; exit; } else echo '

'.__("No files found","wp-download_monitor").'

'; } else echo $errors; } ?>
:
:
    get_parent_cats(); if (!empty($cats)) { foreach ( $cats as $c ) { echo '
  • '; // Do Children if (!function_exists('cat_form_output_children')) { function cat_form_output_children($child) { global $download_taxonomies; if ($child) { echo '
  • '; echo '
      '; $download_taxonomies->do_something_to_cat_children($child->id, 'cat_form_output_children', 'cat_form_output_no_children'); echo '
    '; echo '
  • '; } } function cat_form_output_no_children() { echo '
  • '; } } echo '
      '; $download_taxonomies->do_something_to_cat_children($c->id, 'cat_form_output_children', 'cat_form_output_no_children'); echo '
    '; echo ''; } } ?>
:
/>
/>

Some Name will become some-name.',"wp-download_monitor"); ?>

'; } } $index ++; } if ($_POST['addmeta']) { echo ''; } } ?>
" type="submit" style="margin-bottom: 6px !important;" />

" />

" /> user_login.'" />'; ?>
'; } ?>