Changeset 1786

Show
Ignore:
Timestamp:
10/12/04 15:52:29 (4 years ago)
Author:
donncha
Message:

Added enclosure support.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/edit-form-advanced.php

    r1762 r1786  
    2121$form_prevstatus = '<input type="hidden" name="prev_status" value="'.$post_status.'" />'; 
    2222 
    23     $form_trackback = '<p><label for="trackback"><a href="http://wordpress.org/docs/reference/post/#trackback" title="' . __('Help on trackbacks') . '">' . __('<strong>TrackBack</strong> a <abbr title="Universal Resource Identifier">URI</abbr></a>') . '</label> ' . __('(Separate multiple <abbr title="Universal Resource Identifier">URI</abbr>s with spaces.)') . '<br /> 
    24     <input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" value="'. str_replace("\n", ' ', $to_ping) .'" /></p>'; 
    25     if ('' != $pinged) { 
    26         $pings .= '<p>'. __('Already pinged:') . '</p><ul>'; 
    27         $already_pinged = explode("\n", trim($pinged)); 
    28         foreach ($already_pinged as $pinged_url) { 
    29             $pings .= "\n\t<li>$pinged_url</li>"; 
    30         } 
    31         $pings .= '</ul>'; 
     23$form_trackback = '<p><label for="trackback"><a href="http://wordpress.org/docs/reference/post/#trackback" title="' . __('Help on trackbacks') . '">' . __('<strong>TrackBack</strong> a <abbr title="Universal Resource Identifier">URI</abbr></a>') . '</label> ' . __('(Separate multiple <abbr title="Universal Resource Identifier">URI</abbr>s with spaces.)') . '<br /> 
     24<input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" value="'. str_replace("\n", ' ', $to_ping) .'" /></p>'; 
     25if ('' != $pinged) { 
     26    $pings .= '<p>'. __('Already pinged:') . '</p><ul>'; 
     27    $already_pinged = explode("\n", trim($pinged)); 
     28    foreach ($already_pinged as $pinged_url) { 
     29        $pings .= "\n\t<li>$pinged_url</li>"; 
    3230    } 
     31    $pings .= '</ul>'; 
     32} 
    3333 
    3434$saveasdraft = '<input name="save" type="submit" id="save" tabindex="6" value="' . __('Save and Continue Editing') . '" />'; 
     35 
     36$form_enclosure = '<p><label for="enclosure"><a href="http://www.thetwowayweb.com/payloadsforrss" title="' . __('Help on enclosures') . '">' . __('<strong>Enclosures</strong></a>') . '</label> ' . __('(Separate multiple <abbr title="Universal Resource Identifier">URI</abbr>s with spaces.)') . '<br /> 
     37<input type="text" name="enclosure_url" style="width: 415px" id="enclosure" tabindex="8" value="'. str_replace("\n", ' ', $enclosure_url) .'" /></p>'; 
    3538 
    3639if (empty($post_status)) $post_status = 'draft'; 
     
    122125<input onclick='ReloadTextDiv();' name="use_instant_preview" type="checkbox" id="use_instant_preview" value="1" checked /> <label for='use_instant_preview'>Use Instant Preview</label> <br /> 
    123126</fieldset> 
    124 <fieldset id="previewdiv"> 
    125 <legend><a href="http://wordpress.org/docs/reference/post/#post" title="Help with post field">Preview</a></legend> 
    126 <div><p id="TextDisplay"></p></div> 
    127 </fieldset> 
    128  
    129127<?php 
    130128?> 
     
    138136<?php echo $form_prevstatus ?> 
    139137<?php echo $form_trackback; ?> 
    140  
    141138 
    142139<p class="submit"><?php echo $saveasdraft; ?> <input type="submit" name="submit" value="<?php _e('Save') ?>" style="font-weight: bold;" tabindex="6" />  
     
    152149    <input name="referredby" type="hidden" id="referredby" value="<?php echo htmlspecialchars($_SERVER['HTTP_REFERER']); ?>" /> 
    153150</p> 
     151<fieldset id="previewdiv"> 
     152<legend><a href="http://wordpress.org/docs/reference/post/#post" title="Help with post field">Preview</a></legend> 
     153<div><p id="TextDisplay"></p></div> 
     154</fieldset> 
     155<?php echo $form_enclosure; ?> 
     156 
    154157<?php 
    155158if ('' != $pinged) { 
  • trunk/wp-admin/post.php

    r1782 r1786  
    2121} 
    2222 
    23 $wpvarstoreset = array('action', 'safe_mode', 'withcomments', 'posts', 'poststart', 'postend', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder'); 
     23$wpvarstoreset = array('action', 'safe_mode', 'withcomments', 'posts', 'poststart', 'postend', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder', 'enclosure_url' ); 
    2424 
    2525for ($i=0; $i<count($wpvarstoreset); $i += 1) { 
     
    3939 
    4040switch($action) { 
    41  
    42  
    4341case 'post': 
    44  
    4542        $standalone = 1; 
    4643        require_once('admin-header.php'); 
     
    412409        sleep($sleep_after_edit); 
    413410    } 
     411 
     412        // Enclosures 
     413        $enclosures = split( "   ", $enclosure_url ); 
     414        if( is_array( $enclosures ) ) { 
     415            while( list( $key, $url ) = each( $enclosures ) ) { 
     416                if( $url != '' ) { 
     417                    // READ INFO FROM REMOTE HOST 
     418                    $file = str_replace( "http://", "", $url ); 
     419                    $host = substr( $file, 0, strpos( $file, "/" ) ); 
     420                    $file = substr( $file, strpos( $file, "/" ) ); 
     421                    $headers = "HEAD $file HTTP/1.1\r\nHOST: $host\r\n\r\n"; 
     422                    $port    = 80; 
     423                    $timeout = 3; 
     424                    // Open a socket connection to the host 
     425                    $fp = fsockopen($host, $port, &$err_num, &$err_msg, $timeout); 
     426                    if( $fp ) { 
     427                        // Send request for the page 
     428                        fputs($fp, $headers ); 
     429 
     430                        // Get the response 
     431                        $response = ''; 
     432                        while (!feof($fp)) 
     433                            $response .= fgets($fp, 2048); 
     434                    } else { 
     435                        $response = ''; 
     436                    } 
     437                    if( $response != '' ) { 
     438                        $len = substr( $response, strpos( $response, "Content-Length:" ) + 16 ); 
     439                        $len = substr( $len, 0, strpos( $len, "\n" ) ); 
     440                        $type = substr( $response, strpos( $response, "Content-Type:" ) + 14 ); 
     441                        $type = substr( $type, 0, strpos( $type, "\n" ) + 1 ); 
     442                        $meta_value = "$url\n$len\n$type\n"; 
     443                        $query = "INSERT INTO `".$wpdb->postmeta."` ( `meta_id` , `post_id` , `meta_key` , `meta_value` ) 
     444                                  VALUES ( NULL, '$post_ID', 'enclosure' , '".$meta_value."')"; 
     445                        $wpdb->query( $query ); 
     446                    } 
     447                } 
     448            }  
     449        } 
    414450 
    415451    // are we going from draft/private to published? 
     
    775811 
    776812<?php 
    777 $bookmarklet_height= 420; 
     813$bookmarklet_height= (get_settings('use_trackback')) ? 460 : 420; 
    778814 
    779815if ($is_NS4 || $is_gecko) { 
  • trunk/wp-rss2.php

    r1575 r1786  
    4242<?php endif; ?> 
    4343        <wfw:commentRSS><?php echo comments_rss(); ?></wfw:commentRSS> 
     44<?php  
     45$custom_fields = get_post_custom(); 
     46if( is_array( $custom_fields ) ) { 
     47    while( list( $key, $val ) = each( $custom_fields ) ) {  
     48        if( $key == 'enclosure' ) { 
     49            $enclosure = $val[ 0 ]; 
     50            $enclosure = split( "\n", $enclosure ); 
     51            print "<enclosure url='".trim( $enclosure[ 0 ] )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>\n"; 
     52        } 
     53    } 
     54} 
     55?> 
    4456    </item> 
    4557    <?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>