Required field: Title omitted
',"wp-download_monitor"); if (empty( $_POST['dlhits'] )) $_POST['dlhits'] = 0; if (!is_numeric($_POST['dlhits'] )) $errors.=__('
Invalid hits entered
',"wp-download_monitor"); $tags = $_POST['tags']; $thumbnail = $_POST['thumbnail']; if ($thumbnail) { if( !strstr($thumbnail, '://' ) ) { $pageURL = ""; $pageURL = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"]; } else { $pageURL .= $_SERVER["SERVER_NAME"]; } if (!strstr(get_bloginfo('url'),'www.')) $pageURL = str_replace('www.','', $pageURL ); if ( ! isset($_SERVER['DOCUMENT_ROOT'] ) ) $_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF']) ) ); $dir_path = $_SERVER['DOCUMENT_ROOT']; $thumbnail = str_replace( $dir_path, $pageURL, $thumbnail ); } } //attempt to upload file if ( empty($errors ) ) { $time = current_time('mysql'); $overrides = array('test_form'=>false); add_filter('upload_dir', 'dlm_upload_dir'); $file = wp_handle_upload($_FILES['upload'], $overrides, $time); remove_filter('upload_dir', 'dlm_upload_dir'); if ( !isset($file['error']) ) { $full_path = $file['url']; $info = $file['url']; $filename = $file['url']; } else $errors = '
'.$file['error'].'
'; if ( !empty($errors ) ) { // No File Was uploaded if ( empty( $_POST['filename'] ) && !isset($_FILES['upload']) ) $errors = '
'.__('No file selected',"wp-download_monitor").'
'; elseif (!empty($_POST['filename'])) $errors = ''; } } //attempt to upload thumbnail if ( empty($errors ) ) { $time = current_time('mysql'); $overrides = array('test_form'=>false); add_filter('upload_dir', 'dlm_upload_thumbnail_dir'); $file = wp_handle_upload($_FILES['thumbnail_upload'], $overrides, $time); remove_filter('upload_dir', 'dlm_upload_thumbnail_dir'); if ( !isset($file['error']) ) { $thumbnail = $file['url']; } } //save to db if ( empty($errors ) ) { // Add download $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( $_POST['title'] ), $wpdb->escape( $filename ), mysql_real_escape_string( $_POST['dlversion'] ), $wpdb->escape( $_POST['postDate'] ), mysql_real_escape_string( $_POST['dlhits'] ), $wpdb->escape( $_POST['user'] ), $wpdb->escape( $members ), $wpdb->escape($mirrors), $wpdb->escape($file_description) ); $result = $wpdb->query($query_add); if ($result) { $download_insert_id = $wpdb->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); $thetags = array_map('strtolower', $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 ($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 $wpdb->query("INSERT INTO $wp_dlm_db_meta (meta_name, meta_value, download_id) VALUES ('force', '".$wpdb->escape( $forcedownload )."', '".$download_insert_id."')"); // Process and save meta/custom fields $index = 1; $values = array(); if (isset($_POST['meta']) && is_array($_POST['meta'])) foreach ($_POST['meta'] as $meta) { if (trim($meta['key'])) { $values[] = '("'.$wpdb->escape(strtolower((str_replace(' ','-',trim(stripslashes($meta['key'])))))).'", "'.$wpdb->escape($meta['value']).'", '.$download_insert_id.')'; $index ++; } } if (sizeof($values)>0) $wpdb->query("INSERT INTO $wp_dlm_db_meta (meta_name, meta_value, download_id) VALUES ".implode(',', $values).""); if (empty($info)) echo '

'.__("Download added Successfully","wp-download_monitor").'

'; else echo '

'.__("Download added Successfully","wp-download_monitor").' - '.$info.'

'; do_action('download_added', $download_insert_id); // Redirect echo ''; exit; } else _e('
Error saving to database
',"wp-download_monitor"); } else echo $errors; } $max_upload_size_text = ''; if (function_exists('ini_get')) { $max_upload_size = min(dlm_let_to_num(ini_get('post_max_size')), dlm_let_to_num(ini_get('upload_max_filesize'))); $max_upload_size_text = __(' (defined in php.ini)',"wp-download_monitor"); } if (!$max_upload_size || $max_upload_size==0) { $max_upload_size = 8388608; $max_upload_size_text = ''; } ?>
:
:
:
:


= .



    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 (isset($_POST['addmeta'])) { echo ''; } } ?>
" type="submit" style="margin-bottom: 6px !important;" />

" />

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