get_results("SHOW TABLES LIKE '%$table_name%'") ) return FALSE; else return TRUE; } function af_mysql_warning() { echo '
There was a problem retrieving your file from our database. Please try again later or contact the website admin.
".date('m/d/y H:i:s')." URI: http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."
"); } // Pull the list of file inodes $SQL = "SELECT id FROM ".$table_prefix."attached_files_data WHERE masterid = $file_id ORDER BY id"; if ( !$file_nodes = $wpdb->get_results($SQL) ) { die("Failure to retrive list of file inodes"); } // Send down the header to the client Header ( "Content-Type: " . $file_info->datatype ); Header ( "Content-Length: " . $file_info->file_size ); Header ( "Content-Disposition: attachment; filename=\"" . $file_info->file_name . "\"" ); // Loop thru and stream the nodes 1 by 1 foreach ( $file_nodes as $node ) { $SQL = "SELECT file_data FROM ".$table_prefix."attached_files_data WHERE id = ".$node->id; if ( !$node_data = $wpdb->get_var($SQL) ) { die("Failure to retrive file node data"); } echo $node_data; } // Record as hit in DB if ( $_GET['record'] != 'no' ) { $SQL = "UPDATE ".$table_prefix."attached_files_meta SET hit_count = hit_count + 1 WHERE file_id = '$file_id'"; $wpdb->query($SQL); } exit(); } /*------------------------------------------------------------- Name: af_display_attachments Purpose: Lists the file(s) attached to post after main content Receive: content Return: content -------------------------------------------------------------*/ function af_display_attachments($content) { global $wp_query, $wpdb, $table_prefix, $af_config; // Get current post ID $post = $wp_query->post; $id = $post->ID; if ( empty($id) AND isset($_GET['post']) ) $id = $_GET['post']; // Load current attachments $SQL = "SELECT * FROM ".$table_prefix."attached_files_meta WHERE post_id = $id ORDER BY file_name ASC"; $results = $wpdb->get_results($SQL); if ( count($results) > 0 ) { // Head of output $content .= ''.$file->file_name.' '.number_format(round(($file->file_size / 1000))).'K