当前位置: 首页>>代码示例>>PHP>>正文


PHP fetch_remote_file函数代码示例

本文整理汇总了PHP中fetch_remote_file函数的典型用法代码示例。如果您正苦于以下问题:PHP fetch_remote_file函数的具体用法?PHP fetch_remote_file怎么用?PHP fetch_remote_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了fetch_remote_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process_attachment

function process_attachment($post, $url)
{
    // if the URL is absolute, but does not contain address, then upload it assuming base_site_url
    //if ( preg_match( '|^/[\w\W]+$|', $url ) )
    //	$url = rtrim( $this->base_url, '/' ) . $url;
    global $url_remap;
    $upload = fetch_remote_file($url, $post);
    if (is_wp_error($upload)) {
        return $upload;
    }
    if ($info = wp_check_filetype($upload['file'])) {
        $post['post_mime_type'] = $info['type'];
    } else {
        return new WP_Error('attachment_processing_error', __('Invalid file type', 'wordpress-importer'));
    }
    $post['guid'] = $upload['url'];
    // as per wp-admin/includes/upload.php
    $post_id = wp_insert_attachment($post, $upload['file']);
    wp_update_attachment_metadata($post_id, wp_generate_attachment_metadata($post_id, $upload['file']));
    // remap resized image URLs, works by stripping the extension and remapping the URL stub.
    if (preg_match('!^image/!', $info['type'])) {
        $parts = pathinfo($url);
        $name = basename($parts['basename'], ".{$parts['extension']}");
        // PATHINFO_FILENAME in PHP 5.2
        $parts_new = pathinfo($upload['url']);
        $name_new = basename($parts_new['basename'], ".{$parts_new['extension']}");
        $url_remap[$parts['dirname'] . '/' . $name] = $parts_new['dirname'] . '/' . $name_new;
    }
    return $post_id;
}
开发者ID:centroculturalsp,项目名称:cultural,代码行数:30,代码来源:importimages.php

示例2: automedia_xxxymovies

function automedia_xxxymovies($message)
{
    global $mybb, $width, $height;
    $w = $width;
    $h = $height;
    /**
     *Example:
     *http://www.xxxymovies.com/164396/
    */
    $pattern = "<http://www.xxxymovies.com/([0-9]{1,12})/\" target>";
    if (preg_match($pattern, $message)) {
        preg_match_all($pattern, $message, $links);
        $link = $links[1];
        foreach ($link as $url) {
            $site = htmlspecialchars_uni("http://www.xxxymovies.com/" . $url . "/");
            $data = fetch_remote_file($site);
            if ($data) {
                $nrxxx = get_avmatch('~rel="video_src" href="([\\w\\.\\/:-_]+)"~i', $data);
                $vid = array($nrxxx);
            }
            $limit = 1;
            foreach ($vid as $id) {
                $n = htmlspecialchars_uni($id);
                $message = preg_replace("#(\\[automedia\\]|<a href=\"(http://)(?:www\\.)?xxxymovies\\.com/([0-9]{1,12})/(\\[/automedia\\]|\" target=\"_blank\">)(.*?)</a>)#i", "<div class=\"am_embed\"><embed src=\"{$n}\" loop=\"false\" width=\"{$w}\" height=\"{$h}\" allowfullscreen=\"true\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></div>", $message, $limit);
            }
        }
    }
    return $message;
}
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:29,代码来源:xxxymovies.php

示例3: task_versioncheck

/**
 * MyBB 1.8
 * Copyright 2014 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybb.com
 * License: http://www.mybb.com/about/license
 *
 */
function task_versioncheck($task)
{
    global $cache, $lang, $mybb;
    $current_version = rawurlencode($mybb->version_code);
    $updated_cache = array('last_check' => TIME_NOW);
    // Check for the latest version
    require_once MYBB_ROOT . 'inc/class_xml.php';
    $contents = fetch_remote_file("http://www.mybb.com/version_check.php");
    if (!$contents) {
        add_task_log($task, $lang->task_versioncheck_ran_errors);
        return false;
    }
    $pos = strpos($contents, "<");
    if ($pos > 1) {
        $contents = substr($contents, $pos);
    }
    $pos = strpos(strrev($contents), ">");
    if ($pos > 1) {
        $contents = substr($contents, 0, -1 * ($pos - 1));
    }
    $parser = new XMLParser($contents);
    $tree = $parser->get_tree();
    $latest_code = (int) $tree['mybb']['version_code']['value'];
    $latest_version = "<strong>" . htmlspecialchars_uni($tree['mybb']['latest_version']['value']) . "</strong> (" . $latest_code . ")";
    if ($latest_code > $mybb->version_code) {
        $latest_version = "<span style=\"color: #C00;\">" . $latest_version . "</span>";
        $version_warn = 1;
        $updated_cache['latest_version'] = $latest_version;
        $updated_cache['latest_version_code'] = $latest_code;
    } else {
        $latest_version = "<span style=\"color: green;\">" . $latest_version . "</span>";
    }
    // Check for the latest news
    require_once MYBB_ROOT . "inc/class_feedparser.php";
    $feed_parser = new FeedParser();
    $feed_parser->parse_feed("http://feeds.feedburner.com/MyBBDevelopmentBlog");
    $updated_cache['news'] = array();
    require_once MYBB_ROOT . '/inc/class_parser.php';
    $post_parser = new postParser();
    if ($feed_parser->error == '') {
        foreach ($feed_parser->items as $item) {
            if (isset($updated_cache['news'][2])) {
                break;
            }
            $description = $item['description'];
            $description = $post_parser->parse_message($description, array('allow_html' => true));
            $description = preg_replace('#<img(.*)/>#', '', $description);
            $updated_cache['news'][] = array('title' => htmlspecialchars_uni($item['title']), 'description' => $description, 'link' => htmlspecialchars_uni($item['link']), 'author' => htmlspecialchars_uni($item['author']), 'dateline' => $item['date_timestamp']);
        }
    }
    $cache->update("update_check", $updated_cache);
    add_task_log($task, $lang->task_versioncheck_ran);
}
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:61,代码来源:versioncheck.php

示例4: automedia_divshare

function automedia_divshare($message)
{
    global $mybb, $width, $height;
    $w = $width;
    $h = $height;
    /**
     *Example:
     *http://www.divshare.com/download/7714880-d76
     */
    if (preg_match('<a href=\\"(http://)(?:www\\.)?divshare\\.com/download/([^\\"]*)\\">isU', $message)) {
        $pattern = "<http://www.divshare.com/download/([-\\w]+)\" target>";
        preg_match_all($pattern, $message, $links);
        $link = $links[1];
        foreach ($link as $url) {
            $site = htmlspecialchars_uni("http://www.divshare.com/download/{$url}");
            //Find the video id
            $data = utf8_encode(fetch_remote_file($site));
            if ($data) {
                $nrdv = get_avmatch('/data=([-\\w =]*)&/isU', $data);
                $vid = array($nrdv);
                $nrdi = get_avmatch('/ class=\\"img_thumb\\" id=\\"([-\\w =]{6,40}?)\\" border=/isU', $data);
                $img = array($nrdi);
            }
            $limit = 1;
            if ($vid) {
                foreach ($vid as $video_id) {
                    if (!in_array("ajaxData_img_thumb", $img)) {
                        $message = preg_replace("#(\\[automedia\\]|<a href=\"(http://)?(?:www\\.)?divshare\\.com/download/([-\\w]{6,18}?)(\\[/automedia\\]|\" target=\"_blank\">)(.*?)</a>)#i", "<div class=\"am_embed\"><div id=\"kadoo_video_container_\$3\"><object height=\"{$h}\" width=\"{$w}\" id=\"video_detector_\$3\"><param value=\"http://divshare.com/flash/video_flash_detector.php?data={$video_id}&amp;autoplay=default&amp;id=\$3\" name=\"movie\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><param name=\"wmode\" value=\"opaque\"></param><embed wmode=\"opaque\" height=\"{$h}\" width=\"{$w}\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" src=\"http://divshare.com/flash/video_flash_detector.php?data={$video_id}&amp;autoplay=default&amp;id=\$3\"></embed></object></div>", $message, $limit);
                    }
                }
            }
            if ($img) {
                foreach ($img as $image_id) {
                    if ($image_id == "ajaxData_img_thumb") {
                        $message = preg_replace("#(\\[automedia\\]|<a href=\"(http://)?(?:www\\.)?divshare\\.com/download/([-\\w]{6,18}?)(\\[/automedia\\]|\" target=\"_blank\">)(.*?)</a>)#i", "<div class=\"am_embed\"><object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,18,0\" width=\"{$w}\" height=\"{$h}\" id=\"divslide\"><param name=\"movie\" value=\"http://www.divshare.com/flash/slide?myId=\$3\" /><param name=\"allowFullScreen\" value=\"true\" /><embed src=\"http://www.divshare.com/flash/slide?myId=\$3\" width=\"{$h}\" height=\"{$h}\" name=\"divslide\" allowfullscreen=\"true\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed></object></div>", $message, $limit);
                    }
                }
            }
        }
    }
    return $message;
}
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:42,代码来源:divshare.php

示例5: parse_feed

 /**
  * Parses a feed with the specified filename (or URL)
  *
  * @param string $feed The path or URL of the feed
  * @return boolean True if parsing was a success, false if failure
  */
 function parse_feed($feed)
 {
     // Include the XML parser
     require_once MYBB_ROOT . "inc/class_xml.php";
     // Load the feed we want to parse
     $contents = fetch_remote_file($feed);
     // This is to work around some dodgy bug we've detected with certain installations of PHP
     // where certain characters would magically appear between the fetch_remote_file call
     // and here which break the feed being imported.
     if (strpos($contents, "<") !== 0) {
         $contents = substr($contents, strpos($contents, "<"));
     }
     if (strrpos($contents, ">") + 1 !== strlen($contents)) {
         $contents = substr($contents, 0, strrpos($contents, ">") + 1);
     }
     // Could not load the feed, return an error
     if (!$contents) {
         $this->error = "invalid_file";
         return false;
     }
     // Parse the feed and get the tree
     $parser = new XMLParser($contents);
     $tree = $parser->get_tree();
     // If the feed is invalid, throw back an error
     if ($tree == false) {
         $this->error = "invalid_feed_xml";
         return false;
     }
     // Change array key names to lower case
     $tree = $this->keys_to_lowercase($tree);
     // This is an RSS feed, parse it
     if (array_key_exists("rss", $tree)) {
         $this->parse_rss($tree['rss']);
     } else {
         $this->error = "unknown_feed_type";
         return false;
     }
     return true;
 }
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:45,代码来源:class_feedparser.php

示例6: dt_geodir_insert_taxonomy

function dt_geodir_insert_taxonomy($post_type, $catname, $folder_name, $last_catid)
{
    $uploads = wp_upload_dir();
    // Array of key => value pairs
    $dummy_image_url = get_template_directory_uri() . "/assets/images";
    $uploaded = (array) fetch_remote_file("{$dummy_image_url}/cat_icon.png");
    $new_path = null;
    $new_url = null;
    if (empty($uploaded['error'])) {
        $new_path = $uploaded['file'];
        $new_url = $uploaded['url'];
    }
    $wp_filetype = wp_check_filetype(basename($new_path), null);
    $attachment = array('guid' => $uploads['baseurl'] . '/' . basename($new_path), 'post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($new_path)), 'post_content' => '', 'post_status' => 'inherit');
    $attach_id = wp_insert_attachment($attachment, $new_path);
    // you must first include the image.php file
    // for the function wp_generate_attachment_metadata() to work
    require_once ABSPATH . 'wp-admin/includes/image.php';
    $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
    wp_update_attachment_metadata($attach_id, $attach_data);
    if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, $post_type)) {
        update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), $post_type);
    }
}
开发者ID:mistergiri,项目名称:directory-starter,代码行数:24,代码来源:dummy.php

示例7: die

    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$page->add_breadcrumb_item($lang->mybb_credits, "index.php?module=home-credits");
$plugins->run_hooks("admin_home_credits_begin");
if (!$mybb->input['action']) {
    $page->output_header($lang->mybb_credits);
    $sub_tabs['credits'] = array('title' => $lang->mybb_credits, 'link' => "index.php?module=home-credits", 'description' => $lang->mybb_credits_description);
    $sub_tabs['credits_about'] = array('title' => $lang->about_the_team, 'link' => "http://www.mybb.com/about/team", 'link_target' => "_blank");
    $sub_tabs['check_for_updates'] = array('title' => $lang->check_for_updates, 'link' => "index.php?module=home-credits&amp;fetch_new=1");
    $plugins->run_hooks("admin_home_credits_start");
    $page->output_nav_tabs($sub_tabs, 'credits');
    $mybb_credits = $cache->read('mybb_credits');
    if ($mybb->get_input('fetch_new', MyBB::INPUT_INT) == 1 || $mybb->get_input('fetch_new', MyBB::INPUT_INT) == -2 || $mybb->get_input('fetch_new', MyBB::INPUT_INT) != -1 && (!is_array($mybb_credits) || $mybb_credits['last_check'] <= TIME_NOW - 60 * 60 * 24 * 14)) {
        $new_mybb_credits = array('last_check' => TIME_NOW);
        require_once MYBB_ROOT . "inc/class_xml.php";
        $contents = fetch_remote_file("http://www.mybb.com/mybb_team.xml");
        if (!$contents) {
            flash_message($lang->error_communication, 'error');
            if ($mybb->get_input('fetch_new', MyBB::INPUT_INT) == -2) {
                admin_redirect('index.php?module=tools-cache');
            }
            admin_redirect('index.php?module=home-credits&amp;fetch_new=-1');
        }
        $parser = new XMLParser($contents);
        $tree = $parser->get_tree();
        $mybbgroup = array();
        foreach ($tree['mybbgroup']['team'] as $team) {
            $members = array();
            foreach ($team['member'] as $member) {
                $members[] = array('name' => htmlspecialchars_uni($member['name']['value']), 'username' => htmlspecialchars_uni($member['username']['value']), 'profile' => htmlspecialchars_uni($member['profile']['value']), 'lead' => (bool) $member['attributes']['lead'] or false);
            }
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:31,代码来源:credits.php

示例8: die

if (!defined("IN_MYBB")) {
    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$page->add_breadcrumb_item($lang->version_check, "index.php?module=home-version_check");
$plugins->run_hooks("admin_home_version_check_begin");
if (!$mybb->input['action']) {
    $plugins->run_hooks("admin_home_version_check_start");
    $page->output_header($lang->version_check);
    $sub_tabs['version_check'] = array('title' => $lang->version_check, 'link' => "index.php?module=home-version_check", 'description' => $lang->version_check_description);
    $sub_tabs['download_mybb'] = array('title' => $lang->dl_the_latest_mybb, 'link' => "http://mybb.com/downloads", 'link_target' => '_blank');
    $sub_tabs['check_plugins'] = array('title' => $lang->check_plugin_versions, 'link' => "index.php?module=config-plugins&amp;action=check");
    $page->output_nav_tabs($sub_tabs, 'version_check');
    $current_version = rawurlencode($mybb->version_code);
    $updated_cache = array("last_check" => TIME_NOW);
    require_once MYBB_ROOT . "inc/class_xml.php";
    $contents = fetch_remote_file("http://www.mybb.com/version_check.php");
    if (!$contents) {
        $page->output_inline_error($lang->error_communication);
        $page->output_footer();
        exit;
    }
    // We do this because there is some weird symbols that show up in the xml file for unknown reasons
    $pos = strpos($contents, "<");
    if ($pos > 1) {
        $contents = substr($contents, $pos);
    }
    $pos = strpos(strrev($contents), ">");
    if ($pos > 1) {
        $contents = substr($contents, 0, -1 * ($pos - 1));
    }
    $parser = new XMLParser($contents);
开发者ID:ThinhNguyenVB,项目名称:Gradient-Studios-Website,代码行数:31,代码来源:version_check.php

示例9: update_core

 function update_core($step = '1', $v)
 {
     global $dbprefix, $SQL, $lang, $config;
     $ftp = $this->check_what_method();
     $v = $v['version_number'];
     //$this->f_method = 'zfile';  //standard
     if ($ftp && $this->is_ftp_supported) {
         $this->f_method = 'kftp';
         if (!empty($config['ftp_info'])) {
             $ftp_info = @unserialize($config['ftp_info']);
             $this->info = $ftp_info;
         } else {
             $this->f_method = 'zfile';
             //return to file
         }
     }
     $this->check_connect();
     switch ($step) {
         case '1':
             //....... download files
             # code...
             if (file_exists(PATH . $config['foldername'] . '/' . 'aupdatekleeja' . $v . '.tar')) {
                 return true;
             }
             $b_url = empty($_SERVER['SERVER_NAME']) ? $config['siteurl'] : $_SERVER['SERVER_NAME'];
             if (defined("DEV_STAGE")) {
                 $data = fetch_remote_file('http://localhost/saanina-kleeja/check_vers2/?i=' . urlencode($b_url));
             } else {
                 $data = fetch_remote_file('http://www.kleeja.com/check_vers2/?i=' . urlencode($b_url));
             }
             if ($data != false) {
                 //then ..write new file
                 $re = $this->f > _write(PATH . $config['foldername'] . '/' . 'aupdatekleeja' . $v . '.tar', $data);
                 if ($this->f->check()) {
                     $this->zipped_files = $this->f->push('aupdate' . $v);
                     return 'zipped';
                 }
                 return $re;
             } else {
                 return false;
             }
             break;
         case '2':
             //extract / untar
             return $this->untar(PATH . $config['foldername'] . '/' . 'aupdatekleeja' . $v . '.tar', PATH);
             break;
         case '3':
             //database
             include PATH . 'cache/sqlupdate_' . $v . '.php';
             if ($config['db_version'] >= DB_VERSION && !defined('DEV_STAGE')) {
                 $update_msgs_arr[] = '<span style="color:green;">' . $lang['INST_UPDATE_CUR_VER_IS_UP'] . '</span>';
             }
             //
             //is there any sqls
             //
             $SQL->show_errors = false;
             if (isset($update_sqls) && sizeof($update_sqls) > 0) {
                 $err = '';
                 foreach ($update_sqls as $name => $sql_content) {
                     $err = '';
                     $SQL->query($sql_content);
                     $err = $SQL->get_error();
                     if (strpos($err[1], 'Duplicate') !== false || $err[0] == '1062' || $err[0] == '1060') {
                         $sql = "UPDATE `{$dbprefix}config` SET `value` = '" . DB_VERSION . "' WHERE `name` = 'db_version'";
                         $SQL->query($sql);
                         $update_msgs_arr[] = '<span style="color:green;">' . $lang['INST_UPDATE_CUR_VER_IS_UP'] . '</span>';
                         $complete_upate = false;
                     }
                 }
                 return $update_msgs_arr;
             } else {
                 return false;
             }
             break;
         case '4':
             //functions
             include PATH . 'cache/sqlupdate_' . $v . '.php';
             if ($config['db_version'] >= DB_VERSION && !defined('DEV_STAGE')) {
                 return 'updated';
             }
             //
             //is there any functions
             //
             if (isset($update_functions) && sizeof($update_functions) > 0) {
                 foreach ($update_functions as $n) {
                     call_user_func($n);
                 }
                 return true;
             } else {
                 return false;
             }
             break;
         case '5':
             include PATH . 'cache/sqlupdate_' . $v . '.php';
             //
             //is there any notes
             //
             $NOTES_CUP = false;
             if (isset($update_notes) && sizeof($update_notes) > 0) {
                 $i = 1;
//.........这里部分代码省略.........
开发者ID:omtim,项目名称:kleeja,代码行数:101,代码来源:update.php

示例10: die

if (!defined("IN_MYBB")) {
    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
@set_time_limit(0);
$page->add_breadcrumb_item($lang->file_verification, "index.php?module=tools-file_verification");
$plugins->run_hooks("admin_tools_file_verification_begin");
if (!$mybb->input['action']) {
    $plugins->run_hooks("admin_tools_file_verification_check");
    if ($mybb->request_method == "post") {
        // User clicked no
        if ($mybb->input['no']) {
            admin_redirect("index.php?module=tools-system_health");
        }
        $page->add_breadcrumb_item($lang->checking, "index.php?module=tools-file_verification");
        $page->output_header($lang->file_verification . " - " . $lang->checking);
        $file = explode("\n", fetch_remote_file("http://www.mybb.com/checksums/release_mybb_{$mybb->version_code}.txt"));
        if (strstr($file[0], "<?xml") !== false || empty($file[0])) {
            $page->output_inline_error($lang->error_communication);
            $page->output_footer();
            exit;
        }
        // Parser-up our checksum file from the MyBB Server
        foreach ($file as $line) {
            $parts = explode(" ", $line, 2);
            if (empty($parts[0]) || empty($parts[1])) {
                continue;
            }
            if (substr($parts[1], 0, 7) == "./admin") {
                $parts[1] = "./{$mybb->config['admin_dir']}" . substr($parts[1], 7);
            }
            if (file_exists(MYBB_ROOT . "forums.php") && !file_exists(MYBB_ROOT . "portal.php")) {
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:31,代码来源:file_verification.php

示例11: geodir_default_taxonomies

/**
 * Default taxonomies
 *
 * Adds the default terms for taxonomies - placecategory. Modify at your own risk.
 * 
 * @since 1.0.0
 * @package GeoDirectory
 * @global object $wpdb WordPress Database object.
 * @global string $dummy_image_path The dummy image path.
 */
function geodir_default_taxonomies()
{
    global $wpdb, $dummy_image_path;
    $category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
    $last_catid = isset($last_catid) ? $last_catid : '';
    $last_term = get_term($last_catid, 'gd_placecategory');
    $uploads = wp_upload_dir();
    // Array of key => value pairs
    //print_r($uploads) ;
    for ($i = 0; $i < count($category_array); $i++) {
        $parent_catid = 0;
        if (is_array($category_array[$i])) {
            $cat_name_arr = $category_array[$i];
            for ($j = 0; $j < count($cat_name_arr); $j++) {
                $catname = $cat_name_arr[$j];
                if (!term_exists($catname, 'gd_placecategory')) {
                    $last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
                    if ($j == 0) {
                        $parent_catid = $last_catid;
                    }
                    if (geodir_dummy_folder_exists()) {
                        $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
                    } else {
                        $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
                    }
                    $catname = str_replace(' ', '_', $catname);
                    $uploaded = (array) fetch_remote_file("{$dummy_image_url}/" . $catname . ".png");
                    if (empty($uploaded['error'])) {
                        $new_path = $uploaded['file'];
                        $new_url = $uploaded['url'];
                    }
                    $wp_filetype = wp_check_filetype(basename($new_path), null);
                    $attachment = array('guid' => $uploads['baseurl'] . '/' . basename($new_path), 'post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($new_path)), 'post_content' => '', 'post_status' => 'inherit');
                    $attach_id = wp_insert_attachment($attachment, $new_path);
                    // you must first include the image.php file
                    // for the function wp_generate_attachment_metadata() to work
                    require_once ABSPATH . 'wp-admin/includes/image.php';
                    $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
                    wp_update_attachment_metadata($attach_id, $attach_data);
                    if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
                        update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
                    }
                }
            }
        } else {
            $catname = $category_array[$i];
            if (!term_exists($catname, 'gd_placecategory')) {
                $last_catid = wp_insert_term($catname, 'gd_placecategory');
                if (geodir_dummy_folder_exists()) {
                    $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
                } else {
                    $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
                }
                $catname = str_replace(' ', '_', $catname);
                $uploaded = (array) fetch_remote_file("{$dummy_image_url}/" . $catname . ".png");
                if (empty($uploaded['error'])) {
                    $new_path = $uploaded['file'];
                    $new_url = $uploaded['url'];
                }
                $wp_filetype = wp_check_filetype(basename($new_path), null);
                $attachment = array('guid' => $uploads['baseurl'] . '/' . basename($new_path), 'post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($new_path)), 'post_content' => '', 'post_status' => 'inherit');
                $attach_id = wp_insert_attachment($attachment, $new_path);
                // you must first include the image.php file
                // for the function wp_generate_attachment_metadata() to work
                require_once ABSPATH . 'wp-admin/includes/image.php';
                $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
                wp_update_attachment_metadata($attach_id, $attach_data);
                if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
                    update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
                }
            }
        }
    }
}
开发者ID:jefferose,项目名称:geodirectory,代码行数:84,代码来源:admin_functions.php

示例12: tt_update_avatar_url

function tt_update_avatar_url($avatar_url)
{
    global $mybb, $user, $db;
    $avatar_url = preg_replace("#script:#i", "", $avatar_url);
    $avatar_url = preg_replace("/^(https)/", 'http', $avatar_url);
    $ext = get_extension($avatar_url);
    // Copy the avatar to the local server (work around remote URL access disabled for getimagesize)
    $file = fetch_remote_file($avatar_url);
    if (!$file) {
        return false;
    } else {
        $tmp_name = $mybb->settings['avataruploadpath'] . "/remote_" . md5(random_str());
        $fp = @fopen($tmp_name, "wb");
        if (!$fp) {
            return false;
        } else {
            fwrite($fp, $file);
            fclose($fp);
            list($width, $height, $type) = @getimagesize($tmp_name);
            @unlink($tmp_name);
            if (!$type) {
                return false;
            }
        }
    }
    if ($width && $height && $mybb->settings['maxavatardims'] != "") {
        list($maxwidth, $maxheight) = explode("x", my_strtolower($mybb->settings['maxavatardims']));
        if ($maxwidth && $width > $maxwidth || $maxheight && $height > $maxheight) {
            return false;
        }
    }
    if ($width > 0 && $height > 0) {
        $avatar_dimensions = intval($width) . "|" . intval($height);
    }
    $updated_avatar = array("avatar" => $db->escape_string($avatar_url . '?dateline=' . TIME_NOW), "avatardimensions" => $avatar_dimensions, "avatartype" => "remote");
    return $updated_avatar;
}
开发者ID:dthiago,项目名称:tapatalk-mybb,代码行数:37,代码来源:sign_in.php

示例13: fetch_remote_file

/**
 * Get remote files
 *
 * @param string $url the file link
 * @param bool|string $save_in save file to this path, or false if not
 * @param int $timeout trying getting the file timeout
 * @param bool $head_only gets only the headers without the contents
 * @param int $max_redirects allowed number of redirects
 * @param bool $binary is the file content binary or not
 * @author punbb and kleeja team
 */
function fetch_remote_file($url, $save_in = false, $timeout = 20, $head_only = false, $max_redirects = 10, $binary = false)
{
    global $plugin;
    ($hook = $plugin->run_hook('kleeja_fetch_remote_file_func')) ? eval($hook) : null;
    //run hook
    #Quite unlikely that this will be allowed on a shared host, but it can't hurt
    if (function_exists('ini_set')) {
        @ini_set('default_socket_timeout', $timeout);
    }
    $allow_url_fopen = function_exists('ini_get') ? strtolower(@ini_get('allow_url_fopen')) : strtolower(@get_cfg_var('allow_url_fopen'));
    if (function_exists('curl_init') && !$save_in) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
        @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HEADER, true);
        curl_setopt($ch, CURLOPT_NOBODY, $head_only);
        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; Kleeja)');
        // Grab the page
        $data = @curl_exec($ch);
        $responce_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);
        // Process 301/302 redirect
        if ($data !== false && ($responce_code == '301' || $responce_code == '302') && $max_redirects > 0) {
            $headers = explode("\r\n", trim($data));
            foreach ($headers as $header) {
                if (substr($header, 0, 10) == 'Location: ') {
                    $responce = fetch_remote_file(substr($header, 10), $save_in, $timeout, $head_only, $max_redirects - 1);
                    if ($head_only) {
                        if ($responce != false) {
                            $headers[] = $responce;
                        }
                        return $headers;
                    } else {
                        return false;
                    }
                }
            }
        }
        #Ignore everything except a 200 response code
        if ($data !== false && $responce_code == '200') {
            if ($head_only) {
                return explode("\r\n", str_replace("\r\n\r\n", "\r\n", trim($data)));
            } else {
                preg_match('#HTTP/1.[01] 200 OK#', $data, $match, PREG_OFFSET_CAPTURE);
                $last_content = substr($data, $match[0][1]);
                $content_start = strpos($last_content, "\r\n\r\n");
                if ($content_start !== false) {
                    return substr($last_content, $content_start + 4);
                }
            }
        }
    } else {
        if (function_exists('fsockopen')) {
            $url_parsed = parse_url($url);
            $host = $url_parsed['host'];
            $port = empty($url_parsed['port']) || $url_parsed['port'] == 0 ? 80 : $url_parsed['port'];
            $path = $url_parsed['path'];
            if (isset($url_parsed["query"]) && $url_parsed["query"] != '') {
                $path .= '?' . $url_parsed['query'];
            }
            if (!($fp = @fsockopen($host, $port, $errno, $errstr, $timeout))) {
                return false;
            }
            #Send a standard HTTP 1.0 request for the page
            fwrite($fp, ($head_only ? 'HEAD' : 'GET') . " {$path} HTTP/1.0\r\n");
            fwrite($fp, "Host: {$host}\r\n");
            fwrite($fp, 'User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; Kleeja)' . "\r\n");
            fwrite($fp, 'Connection: Close' . "\r\n\r\n");
            stream_set_timeout($fp, $timeout);
            $stream_meta = stream_get_meta_data($fp);
            #let's open new file to save it in.
            if ($save_in) {
                $fp2 = @fopen($save_in, 'w' . ($binary ? '' : ''));
            }
            #Fetch the response 1024 bytes at a time and watch out for a timeout
            $in = false;
            $h = false;
            $s = '';
            while (!feof($fp) && !$stream_meta['timed_out']) {
                $s = fgets($fp, 1024);
                if ($save_in) {
                    if ($s == "\r\n") {
                        $h = true;
                        continue;
                    }
                    if ($h) {
                        @fwrite($fp2, $s);
//.........这里部分代码省略.........
开发者ID:omtim,项目名称:kleeja,代码行数:101,代码来源:functions_files.php

示例14: fetch_remote_file

	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

	<channel>';
//-----------------//-----------------//-----------------//-----------------//-----------------
$con = '/////////////////////////////////////صفحه ی اعلام نتایج ysc//////////////////////////////////////////////////' . PHP_EOL . fetch_remote_file('http://ysc.ac.ir/include_news_post.php?id+post=196', array('postid' => '196')) . PHP_EOL . '/////////////////////////////////////سایت کمیته//////////////////////////////////////////////////' . PHP_EOL . fetch_remote_file('http://inoi.ir') . PHP_EOL . '/////////////////////////////////////صفحه اصلی ysc//////////////////////////////////////////////////' . PHP_EOL . fetch_remote_file('http://ysc.ac.ir/');
$old = file_get_contents("ysc.txt");
$all = file_get_contents("all.txt");
if ($old != $con) {
    //یک بار دیگر چک می کنیم
    $con = '/////////////////////////////////////صفحه ی اعلام نتایج ysc//////////////////////////////////////////////////' . PHP_EOL . fetch_remote_file('http://ysc.ac.ir/include_news_post.php?id+post=196', array('postid' => '196')) . PHP_EOL . '/////////////////////////////////////سایت کمیته//////////////////////////////////////////////////' . PHP_EOL . fetch_remote_file('http://inoi.ir') . PHP_EOL . '/////////////////////////////////////صفحه اصلی ysc//////////////////////////////////////////////////' . PHP_EOL . fetch_remote_file('http://ysc.ac.ir/');
    if ($old != $con) {
        echo '	<item>
		<title>' . date("Y/m/d  H:i:s") . ' update</title>
	</item>' . $all;
        file_put_contents("all.txt", '	<item>
		<title>' . date("Y/m/d  H:i:s") . ' update</title>
	</item>' . $all);
        file_put_contents("ysc.txt", $con);
        file_put_contents('./changelog/' . date("YmdHis") . '.txt', $old);
    }
} else {
    echo $all;
}
echo '	</channel>
</rss>
开发者ID:ar-pa,项目名称:rss,代码行数:31,代码来源:index.php

示例15: processURL

 function processURL($url)
 {
     global $USER, $CONF;
     $ok = false;
     //generate a unique "upload id" - we use this to hold the image until
     //they've confirmed they want to submit
     $upload_id = md5(uniqid('upload'));
     $pendingfile = $this->_pendingJPEG($upload_id);
     function fetch_remote_file($url, $filename)
     {
         $data = file_get_contents($url);
         if (strlen($data) > 0) {
             file_put_contents($filename, $data);
             return true;
         }
         return false;
     }
     if (preg_match('/^http:\\/\\/[\\w\\.-]+\\/[\\w\\.\\/-]+\\.jpg$/', $url) || preg_match('/^http:\\/\\/www\\.picnik\\.com\\/file\\/\\d+$/', $url)) {
         if (fetch_remote_file($url, $pendingfile)) {
             if ($this->_isJpeg($pendingfile)) {
                 $ok = $this->_processFile($upload_id, $pendingfile);
             } else {
                 $this->error("We only accept JPEG images - your upload did not appear to be a valid JPEG file");
             }
         } else {
             //playing silly buggers?
             $this->error("There were problems processing your upload - please contact us");
         }
     } else {
         //playing silly buggers?
         $this->error("We where unable to fetch that image - please contact us");
     }
     return $ok;
 }
开发者ID:s-a-r-id,项目名称:geograph-project,代码行数:34,代码来源:uploadmanager.class.php


注:本文中的fetch_remote_file函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。