本文整理汇总了PHP中wp_get_http_headers函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_http_headers函数的具体用法?PHP wp_get_http_headers怎么用?PHP wp_get_http_headers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_get_http_headers函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: do_enclose
/**
* Check content for video and audio links to add as enclosures.
*
* Will not add enclosures that have already been added. This is called as
* pingbacks and trackbacks.
*
* @package WordPress
* @since 1.5.0
*
* @uses $wpdb
*
* @param string $content Post Content
* @param int $post_ID Post ID
*/
function do_enclose($content, $post_ID)
{
global $wpdb;
include_once ABSPATH . WPINC . '/class-IXR.php';
$log = debug_fopen(ABSPATH . 'enclosures.log', 'a');
$post_links = array();
debug_fwrite($log, 'BEGIN ' . date('YmdHis', time()) . "\n");
$pung = get_enclosed($post_ID);
$ltrs = '\\w';
$gunk = '/#~:.?+=&%@!\\-';
$punc = '.:?\\-';
$any = $ltrs . $gunk . $punc;
preg_match_all("{\\b http : [{$any}] +? (?= [{$punc}] * [^{$any}] | \$)}x", $content, $post_links_temp);
debug_fwrite($log, 'Post contents:');
debug_fwrite($log, $content . "\n");
foreach ((array) $post_links_temp[0] as $link_test) {
if (!in_array($link_test, $pung)) {
// If we haven't pung it already
$test = parse_url($link_test);
if (isset($test['query'])) {
$post_links[] = $link_test;
} elseif ($test['path'] != '/' && $test['path'] != '') {
$post_links[] = $link_test;
}
}
}
foreach ((array) $post_links as $url) {
if ($url != '' && !$wpdb->get_var($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $url . '%'))) {
if ($headers = wp_get_http_headers($url)) {
$len = (int) $headers['content-length'];
$type = $wpdb->escape($headers['content-type']);
$allowed_types = array('video', 'audio');
if (in_array(substr($type, 0, strpos($type, "/")), $allowed_types)) {
$meta_value = "{$url}\n{$len}\n{$type}\n";
$wpdb->query($wpdb->prepare("INSERT INTO `{$wpdb->postmeta}` ( `post_id` , `meta_key` , `meta_value` )\n\t\t\t\t\tVALUES ( %d, 'enclosure' , %s)", $post_ID, $meta_value));
}
}
}
}
}
开发者ID:joelglennwright,项目名称:agencypress,代码行数:54,代码来源:functions.php
示例2: do_enclose
/**
* Check content for video and audio links to add as enclosures.
*
* Will not add enclosures that have already been added and will
* remove enclosures that are no longer in the post. This is called as
* pingbacks and trackbacks.
*
* @package WordPress
* @since 1.5.0
*
* @uses $wpdb
*
* @param string $content Post Content
* @param int $post_ID Post ID
*/
function do_enclose($content, $post_ID)
{
global $wpdb;
include_once ABSPATH . WPINC . '/class-IXR.php';
$log = debug_fopen(ABSPATH . 'enclosures.log', 'a');
$post_links = array();
debug_fwrite($log, 'BEGIN ' . date('YmdHis', time()) . "\n");
$pung = get_enclosed($post_ID);
$ltrs = '\\w';
$gunk = '/#~:.?+=&%@!\\-';
$punc = '.:?\\-';
$any = $ltrs . $gunk . $punc;
preg_match_all("{\\b http : [{$any}] +? (?= [{$punc}] * [^{$any}] | \$)}x", $content, $post_links_temp);
debug_fwrite($log, 'Post contents:');
debug_fwrite($log, $content . "\n");
foreach ($pung as $link_test) {
if (!in_array($link_test, $post_links_temp[0])) {
// link no longer in post
$mid = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $link_test . '%'));
do_action('delete_postmeta', $mid);
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->postmeta} WHERE meta_id IN(%s)", implode(',', $mid)));
do_action('deleted_postmeta', $mid);
}
}
foreach ((array) $post_links_temp[0] as $link_test) {
if (!in_array($link_test, $pung)) {
// If we haven't pung it already
$test = @parse_url($link_test);
if (false === $test) {
continue;
}
if (isset($test['query'])) {
$post_links[] = $link_test;
} elseif ($test['path'] != '/' && $test['path'] != '') {
$post_links[] = $link_test;
}
}
}
foreach ((array) $post_links as $url) {
if ($url != '' && !$wpdb->get_var($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $url . '%'))) {
if ($headers = wp_get_http_headers($url)) {
$len = (int) $headers['content-length'];
$type = $headers['content-type'];
$allowed_types = array('video', 'audio');
// Check to see if we can figure out the mime type from
// the extension
$url_parts = @parse_url($url);
if (false !== $url_parts) {
$extension = pathinfo($url_parts['path'], PATHINFO_EXTENSION);
if (!empty($extension)) {
foreach (get_allowed_mime_types() as $exts => $mime) {
if (preg_match('!^(' . $exts . ')$!i', $extension)) {
$type = $mime;
break;
}
}
}
}
if (in_array(substr($type, 0, strpos($type, "/")), $allowed_types)) {
$meta_value = "{$url}\n{$len}\n{$type}\n";
$wpdb->insert($wpdb->postmeta, array('post_id' => $post_ID, 'meta_key' => 'enclosure', 'meta_value' => $meta_value));
do_action('added_postmeta', $wpdb->insert_id, $post_ID, 'enclosure', $meta_value);
}
}
}
}
}
开发者ID:Ogwang,项目名称:sainp,代码行数:82,代码来源:functions.php
示例3: do_enclose
/**
* Check content for video and audio links to add as enclosures.
*
* Will not add enclosures that have already been added and will
* remove enclosures that are no longer in the post. This is called as
* pingbacks and trackbacks.
*
* @since 1.5.0
*
* @global wpdb $wpdb
*
* @param string $content Post Content.
* @param int $post_ID Post ID.
*/
function do_enclose($content, $post_ID)
{
global $wpdb;
//TODO: Tidy this ghetto code up and make the debug code optional
include_once ABSPATH . WPINC . '/class-IXR.php';
$post_links = array();
$pung = get_enclosed($post_ID);
$post_links_temp = wp_extract_urls($content);
foreach ($pung as $link_test) {
if (!in_array($link_test, $post_links_temp)) {
// link no longer in post
$mids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like($link_test) . '%'));
foreach ($mids as $mid) {
delete_metadata_by_mid('post', $mid);
}
}
}
foreach ((array) $post_links_temp as $link_test) {
if (!in_array($link_test, $pung)) {
// If we haven't pung it already
$test = @parse_url($link_test);
if (false === $test) {
continue;
}
if (isset($test['query'])) {
$post_links[] = $link_test;
} elseif (isset($test['path']) && $test['path'] != '/' && $test['path'] != '') {
$post_links[] = $link_test;
}
}
}
foreach ((array) $post_links as $url) {
if ($url != '' && !$wpdb->get_var($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like($url) . '%'))) {
if ($headers = wp_get_http_headers($url)) {
$len = isset($headers['content-length']) ? (int) $headers['content-length'] : 0;
$type = isset($headers['content-type']) ? $headers['content-type'] : '';
$allowed_types = array('video', 'audio');
// Check to see if we can figure out the mime type from
// the extension
$url_parts = @parse_url($url);
if (false !== $url_parts) {
$extension = pathinfo($url_parts['path'], PATHINFO_EXTENSION);
if (!empty($extension)) {
foreach (wp_get_mime_types() as $exts => $mime) {
if (preg_match('!^(' . $exts . ')$!i', $extension)) {
$type = $mime;
break;
}
}
}
}
if (in_array(substr($type, 0, strpos($type, "/")), $allowed_types)) {
add_post_meta($post_ID, 'enclosure', "{$url}\n{$len}\n{$mime}\n");
}
}
}
}
}
开发者ID:hpilevar,项目名称:WordPress,代码行数:72,代码来源:functions.php
示例4: wpfc_get_filesize
function wpfc_get_filesize($url, $timeout = 10)
{
$headers = wp_get_http_headers($url);
$duration = isset($headers['content-length']) ? (int) $headers['content-length'] : 0;
if ($duration) {
sscanf($duration, "%d:%d:%d", $hours, $minutes, $seconds);
$length = isset($seconds) ? $hours * 3600 + $minutes * 60 + $seconds : $hours * 60 + $minutes;
if (!$length) {
$length = (int) $duration;
}
return $length;
}
return 0;
}
开发者ID:mlloewen,项目名称:wp-muirlake,代码行数:14,代码来源:podcast-functions.php
示例5: test_wp_get_http_headers_deprecated_argument
/**
* Test to see if the deprecated argument is working
*/
public function test_wp_get_http_headers_deprecated_argument()
{
$this->setExpectedDeprecated('wp_get_http_headers');
wp_get_http_headers('does_not_matter', $deprecated = true);
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:8,代码来源:getHttpHeaders.php
示例6: the_enclosure_rss
function the_enclosure_rss($echo = true)
{
if (!empty($GLOBALS['post']->post_password)) {
// if there's a password
return _echo('', $echo);
}
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content', $content);
$content = wp_convert_rss_charset($content);
$post_links = array();
preg_match('#(http://[^/]*)#', XOOPS_URL, $my_host);
$my_host = $my_host[0];
preg_match_all("{href=([\"'])((http://|https://|/)[^\\1]*?)\\1}i", $content, $post_links_temp);
foreach ($post_links_temp[2] as $link_test) {
$link_test = wp_get_fullurl($link_test);
$test = parse_url($link_test);
if (isset($test['query'])) {
$post_links[] = $link_test;
} elseif ($test['path'] != '/' && $test['path'] != '') {
$post_links[] = $link_test;
}
}
$output = '';
foreach ($post_links as $url) {
if ($headers = wp_get_http_headers($url)) {
$len = (int) $headers['content-length'];
$type = addslashes($headers['content-type']);
$allowed_types = array('video', 'audio');
if (in_array(substr($type, 0, strpos($type, "/")), $allowed_types)) {
$output .= "<enclosure url='" . trim(htmlspecialchars($url)) . "' length='" . trim($len) . "' type='" . trim($type) . "'/>\n";
}
}
}
return _echo($output, $echo);
}
开发者ID:nobunobuta,项目名称:xoops_mod_WordPress,代码行数:35,代码来源:template-functions-post.php
示例7: do_enclose
/**
* Check content for video and audio links to add as enclosures.
*
* Will not add enclosures that have already been added and will
* remove enclosures that are no longer in the post. This is called as
* pingbacks and trackbacks.
*
* @package WordPress
* @since 1.5.0
*
* @uses $wpdb
*
* @param string $content Post Content
* @param int $post_ID Post ID
*/
function do_enclose( $content, $post_ID ) {
global $wpdb;
include_once( ABSPATH . WPINC . '/class-IXR.php' );
$log = debug_fopen( ABSPATH . 'enclosures.log', 'a' );
$post_links = array();
debug_fwrite( $log, 'BEGIN ' . date( 'YmdHis', time() ) . "\n" );
$pung = get_enclosed( $post_ID );
$ltrs = '\w';
$gunk = '/#~:.?+=&%@!\-';
$punc = '.:?\-';
$any = $ltrs . $gunk . $punc;
preg_match_all( "{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp );
debug_fwrite( $log, 'Post contents:' );
debug_fwrite( $log, $content . "\n" );
foreach ( $pung as $link_test ) {
if ( !in_array( $link_test, $post_links_temp[0] ) ) { // link no longer in post
$mid = $wpdb->get_col( $wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $link_test . '%') );
do_action( 'delete_postmeta', $mid );
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE post_id IN(%s)", implode( ',', $mid ) ) );
do_action( 'deleted_postmeta', $mid );
}
}
foreach ( (array) $post_links_temp[0] as $link_test ) {
if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already
$test = parse_url( $link_test );
if ( isset( $test['query'] ) )
$post_links[] = $link_test;
elseif ( $test['path'] != '/' && $test['path'] != '' )
$post_links[] = $link_test;
}
}
foreach ( (array) $post_links as $url ) {
if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $url . '%' ) ) ) {
if ( $headers = wp_get_http_headers( $url) ) {
$len = (int) $headers['content-length'];
$type = $headers['content-type'];
$allowed_types = array( 'video', 'audio' );
if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) {
$meta_value = "$url\n$len\n$type\n";
$wpdb->insert($wpdb->postmeta, array('post_id' => $post_ID, 'meta_key' => 'enclosure', 'meta_value' => $meta_value) );
do_action( 'added_postmeta', $wpdb->insert_id, $post_ID, 'enclosure', $meta_value );
}
}
}
}
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:69,代码来源:functions.php
示例8: do_enclose
/**
* Check content for video and audio links to add as enclosures.
*
* Will not add enclosures that have already been added and will
* remove enclosures that are no longer in the post. This is called as
* pingbacks and trackbacks.
*
* @package WordPress
* @since 1.5.0
*
* @uses $wpdb
*
* @param string $content Post Content
* @param int $post_ID Post ID
*/
function do_enclose( $content, $post_ID ) {
global $wpdb;
//TODO: Tidy this ghetto code up and make the debug code optional
include_once( ABSPATH . WPINC . '/class-IXR.php' );
$post_links = array();
$pung = get_enclosed( $post_ID );
$ltrs = '\w';
$gunk = '/#~:.?+=&%@!\-';
$punc = '.:?\-';
$any = $ltrs . $gunk . $punc;
preg_match_all( "{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp );
foreach ( $pung as $link_test ) {
if ( !in_array( $link_test, $post_links_temp[0] ) ) { // link no longer in post
$mids = $wpdb->get_col( $wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, like_escape( $link_test ) . '%') );
foreach ( $mids as $mid )
delete_metadata_by_mid( 'post', $mid );
}
}
foreach ( (array) $post_links_temp[0] as $link_test ) {
if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already
$test = @parse_url( $link_test );
if ( false === $test )
continue;
if ( isset( $test['query'] ) )
$post_links[] = $link_test;
elseif ( isset($test['path']) && ( $test['path'] != '/' ) && ($test['path'] != '' ) )
$post_links[] = $link_test;
}
}
foreach ( (array) $post_links as $url ) {
if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, like_escape( $url ) . '%' ) ) ) {
if ( $headers = wp_get_http_headers( $url) ) {
$len = isset( $headers['content-length'] ) ? (int) $headers['content-length'] : 0;
$type = isset( $headers['content-type'] ) ? $headers['content-type'] : '';
$allowed_types = array( 'video', 'audio' );
// Check to see if we can figure out the mime type from
// the extension
$url_parts = @parse_url( $url );
if ( false !== $url_parts ) {
$extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION );
if ( !empty( $extension ) ) {
foreach ( get_allowed_mime_types( ) as $exts => $mime ) {
if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) {
$type = $mime;
break;
}
}
}
}
if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) {
add_post_meta( $post_ID, 'enclosure', "$url\n$len\n$mime\n" );
}
}
}
}
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:82,代码来源:functions.php
示例9: wp_get_http_headers
function wp_get_http_headers( $url, $red = 1 ) {
global $wp_version;
@set_time_limit( 60 );
if ( $red > 5 )
return false;
$parts = parse_url( $url );
$file = $parts['path'] . ($parts['query'] ? '?'.$parts['query'] : '');
$host = $parts['host'];
if ( !isset( $parts['port'] ) )
$parts['port'] = 80;
$head = "HEAD $file HTTP/1.1\r\nHOST: $host\r\nUser-Agent: WordPress/" . $wp_version . "\r\n\r\n";
$fp = @fsockopen($host, $parts['port'], $err_num, $err_msg, 3);
if ( !$fp )
return false;
$response = '';
fputs( $fp, $head );
while ( !feof( $fp ) && strpos( $response, "\r\n\r\n" ) == false )
$response .= fgets( $fp, 2048 );
fclose( $fp );
preg_match_all('/(.*?): (.*)\r/', $response, $matches);
$count = count($matches[1]);
for ( $i = 0; $i < $count; $i++) {
$key = strtolower($matches[1][$i]);
$headers["$key"] = $matches[2][$i];
}
preg_match('/.*([0-9]{3}).*/', $response, $return);
$headers['response'] = $return[1]; // HTTP response code eg 204, 200, 404
$code = $headers['response'];
if ( ('302' == $code || '301' == $code) && isset($headers['location']) )
return wp_get_http_headers( $headers['location'], ++$red );
return $headers;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:40,代码来源:functions.php
示例10: do_enclose
function do_enclose( $content, $post_ID ) {
global $wp_version, $wpdb;
include_once (ABSPATH . WPINC . '/class-IXR.php');
$log = debug_fopen(ABSPATH . '/enclosures.log', 'a');
$post_links = array();
debug_fwrite($log, 'BEGIN '.date('YmdHis', time())."\n");
$pung = get_enclosed( $post_ID );
$ltrs = '\w';
$gunk = '/#~:.?+=&%@!\-';
$punc = '.:?\-';
$any = $ltrs . $gunk . $punc;
preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp);
debug_fwrite($log, 'Post contents:');
debug_fwrite($log, $content."\n");
foreach($post_links_temp[0] as $link_test) :
if ( !in_array($link_test, $pung) ) : // If we haven't pung it already
$test = parse_url($link_test);
if (isset($test['query']))
$post_links[] = $link_test;
elseif(($test['path'] != '/') && ($test['path'] != ''))
$post_links[] = $link_test;
endif;
endforeach;
foreach ($post_links as $url) :
if ( $url != '' && !$wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE post_id = '$post_ID' AND meta_key = 'enclosure' AND meta_value LIKE ('$url%')") ) {
if ( $headers = wp_get_http_headers( $url) ) {
$len = (int) $headers['content-length'];
$type = addslashes( $headers['content-type'] );
$allowed_types = array( 'video', 'audio' );
if( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) {
$meta_value = "$url\n$len\n$type\n";
$wpdb->query( "INSERT INTO `$wpdb->postmeta` ( `post_id` , `meta_key` , `meta_value` )
VALUES ( '$post_ID', 'enclosure' , '$meta_value')" );
}
}
}
endforeach;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:45,代码来源:functions.php
示例11: sp_UserAvatar
function sp_UserAvatar($args = '', $contextData = '')
{
global $spThisUser;
$defs = array('tagClass' => 'spAvatar', 'imgClass' => 'spAvatar', 'size' => '', 'link' => 'profile', 'context' => 'current', 'wp' => '', 'echo' => 1, 'get' => 0);
$a = wp_parse_args($args, $defs);
$a = apply_filters('sph_Avatar_args', $a);
extract($a, EXTR_SKIP);
# sanitize before use
$tagClass = esc_attr($tagClass);
$imgClass = esc_attr($imgClass);
$link = esc_attr($link);
$size = (int) $size;
$echo = (int) $echo;
$get = (int) $get;
$wp = esc_attr($wp);
# init some vars
$forceWidth = false;
# make sure we are displaying avatars
$spAvatars = sp_get_option('sfavatars');
if ($spAvatars['sfshowavatars'] == true) {
$avatarData = new stdClass();
$avatarData->object = false;
$avatarData->userId = 0;
# need user id OR email
$avatarData->email = '';
$avatarData->avatar = '';
$avatarData->admin = '';
# determine avatar size
$avatarData->size = !empty($size) ? $size : $spAvatars['sfavatarsize'];
# get the appropriate user id and email address
switch ($context) {
case 'current':
# we want the avatar for the current user
global $spThisUser;
$avatarData->userId = $spThisUser->ID;
$avatarData->email = !empty($avatarData->userId) ? $spThisUser->user_email : '';
break;
case 'user':
# determine if we have user object, id or email address
if (is_object($contextData)) {
# sp user object passed in
# can contain anything, but must contain id or email, avatar array and admin flag
$avatarData->object = true;
$avatarData->userId = $contextData->ID;
$avatarData->email = $contextData->user_email;
$avatarData->avatar = $contextData->avatar;
$avatarData->admin = $contextData->admin;
} else {
if (is_numeric($contextData)) {
# user id passed in
$user = get_userdata((int) $contextData);
} else {
# email address passed in
$user = get_user_by('email', sp_esc_str($contextData));
}
if ($user) {
$avatarData->userId = $user->ID;
$avatarData->email = $user->user_email;
}
}
break;
default:
# allow themes/plugins to add new avatar user types
$avatarData = apply_filters('sph_Avatar_' . $context, $avatarData, $a);
break;
}
# loop through prorities until we find an avatar to use
foreach ($spAvatars['sfavatarpriority'] as $priority) {
switch ($priority) {
case 0:
# Gravatars
if (function_exists('sp_get_gravatar_cache_url')) {
$avatarData->url = sp_get_gravatar_cache_url(strtolower($avatarData->email), $avatarData->size);
if (empty($avatarData->url)) {
$gravatar = false;
} else {
$gravatar = true;
$forceWidth = true;
# force width to request since we only cache one size
}
} else {
$rating = $spAvatars['sfgmaxrating'];
switch ($rating) {
case 1:
$grating = 'g';
break;
case 2:
$grating = 'pg';
break;
case 3:
$grating = 'r';
break;
case 4:
default:
$grating = 'x';
break;
}
$avatarData->url = 'http://www.gravatar.com/avatar/' . md5(strtolower($avatarData->email)) . "?d=404&size={$avatarData->size}&rating={$grating}";
# Is there an gravatar?
$headers = wp_get_http_headers($avatarData->url);
//.........这里部分代码省略.........
开发者ID:Bakerpedia,项目名称:Developement_WPengine,代码行数:101,代码来源:sp-common-view-functions.php
示例12: flv_add_meta
function flv_add_meta($post_id) {
global $wpdb, $flv_options, $flv_sitemap_options, $flv_metakey, $flv_metavalues;
// jump out of function if sitemap feature is not enabled
if (!$flv_options['sitemap']) {
return $post_id;
}
$content = $wpdb->get_var("SELECT post_content
FROM $wpdb->posts
WHERE ID = '$post_id'");
// parse post content for FLV embed tags
$content = preg_replace_callback( "/\[flv:(([^]]+))]/i", "flv_gen_meta", $content );
// process each metavalues
foreach ($flv_metavalues as $metavalue) {
// read flv custom fields from database for current post_id
$flvs = $wpdb->get_results("SELECT meta_value, meta_id
FROM $wpdb->postmeta
WHERE post_id = '$post_id'
AND meta_key = '$flv_metakey'");
// status flag for database operations
$update = 0;
$delete = 0;
$write = 1;
// if flv custom field already exist, test its content and update the value with new flv path when applicable
if (!empty($flvs)) {
$del_metaids = array(); // array that stores flv to be deleted
$input = explode("\n", $metavalue);
$movie = $input[0];
$file = basename($movie);
// check to see if existing flv custom field can be updated
foreach ($flvs as $flv) {
if (stristr($flv->meta_value, $file)) {
$metaid = $flv->meta_id;
$update = 1;
// check to see if existing meta is valid (i.e. flv url is not a dead link)
} else {
$input_meta = explode("\n", $flv->meta_value);
$url = $input_meta[0];
$headers = wp_get_http_headers($url);
$code = (int) $headers['response'];
// client error
if ($code >= 400 && $code < 500) {
$delete = 1;
array_push($del_metaids, $flv->meta_id);
}
}
}
}
// disable custom field writing for YouTube links
if (stristr($metavalue,"youtube.com")) {
$write = 0;
}
// update existing flv custom field
if ($update) {
$results= $wpdb->query("UPDATE $wpdb->postmeta
SET meta_value = '$metavalue'
WHERE post_id = '$post_id'
AND meta_id = '$metaid'
AND meta_key = '$flv_metakey'");
// or write flv custom field to database
} else if ($write) {
$results = $wpdb->query("INSERT INTO $wpdb->postmeta (post_id,meta_key,meta_value)
VALUES ('$post_id', '$flv_metakey', '$metavalue')");
}
// delete dead flv
if ($delete) {
foreach ($del_metaids as $del_metaid) {
$results= $wpdb->query("DELETE FROM $wpdb->postmeta
WHERE post_id = '$post_id'
AND meta_id = '$del_metaid'
AND meta_key = '$flv_metakey'");
}
}
}
// check if flv embed tags are found within current post
if (!empty($metavalue)) {
// rebuild video sitemap if allowed
if ($flv_sitemap_options['allow_auto']) {
// get post status...
$post_status = $wpdb->get_var("SELECT post_status
FROM $wpdb->posts
WHERE ID = '$post_id'");
// only rebuild if post is already published
if ($post_status == 'publish')
flv_sitemap_build();
//.........这里部分代码省略.........
开发者ID:ramo01,项目名称:1kapp,代码行数:101,代码来源:flv-embed.php
示例13: getHttpHeaders
/**
* Retrieves information about a given podcast through several different methods
* @param - the URL of the file
* @return an array containing file information
*/
function getHttpHeaders($url)
{
# Don't attempt to get enclosure information since we're accepting failure
if (get_option('pod_accept_fail') == 'yes') {
$headers = array('response' => 200, 'content-length' => '1048576', 'content-type' => $this->getMimeType($url));
return $headers;
}
$wp_head = wp_get_http_headers($url);
$headers = array('response' => '200', 'content-length' => $wp_head['content-length'], 'content-type' => $this->getMimeType($url));
# Try to get the headers locally if external URLs fail
if ($headers['response'] == '' || $headers['response'] == '404') {
$local_host = $_SERVER['SERVER_NAME'];
$file_parse_url = parse_url($url);
$file_host = $file_parse_url['host'];
$file_path = $_SERVER['DOCUMENT_ROOT'] . $file_parse_url['path'];
# Double check we have a local file
if ($local_host == $file_host) {
if (file_exists($file_path)) {
$headers['response'] = '200';
$headers['content-type'] = mime_content_type($file_path);
$headers['content-length'] = filesize($file_path);
} else {
$headers['response'] = '404';
}
}
}
return $headers;
}
开发者ID:howardlei82,项目名称:IGSM-Website,代码行数:33,代码来源:podcasting-metabox.php
示例14: powerpressadmin_podpress_do_import
function powerpressadmin_podpress_do_import()
{
$Import = !empty($_POST['Import']) ? $_POST['Import'] : array();
$PodPressData = powerpress_get_podpress_episodes(true);
while (list($post_id, $podpress_episode_feeds) = each($Import)) {
while (list($podpress_index, $feed_slug) = each($podpress_episode_feeds)) {
if ($feed_slug) {
$EpisodeData = $PodPressData[$post_id]['podpress_data'][$podpress_index];
if ($EpisodeData['size'] == '' || !is_numeric($EpisodeData['size'])) {
$headers = wp_get_http_headers($EpisodeData['url']);
if ($headers && $headers['content-length']) {
$EpisodeData['size'] = (int) $headers['content-length'];
}
}
$EnclosureData = trim($EpisodeData['url']) . "\n" . trim($EpisodeData['size']) . "\n" . trim($EpisodeData['type']);
$Serialized = array();
if (!empty($EpisodeData['duration'])) {
$Serialized['duration'] = $EpisodeData['duration'];
}
if (!empty($EpisodeData['image'])) {
$Serialized['image'] = $EpisodeData['image'];
}
if (count($Serialized) > 0) {
$EnclosureData .= "\n" . serialize($Serialized);
}
if ($feed_slug == 'podcast') {
add_post_meta($post_id, 'enclosure', $EnclosureData, true);
} else {
add_post_meta($post_id, '_' . $feed_slug . ':enclosure', $EnclosureData, true);
}
powerpressadmin_podpress_import_log($PodPressData[$post_id]['post_title'], $EpisodeData['url'], $feed_slug);
}
}
}
}
开发者ID:ryan2407,项目名称:Vision,代码行数:35,代码来源:powerpressadmin-podpress.php
注:本文中的wp_get_http_headers函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论