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


PHP http_get_file函数代码示例

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


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

示例1: get_packages

function get_packages($package, $dirpath)
{
    global $regex;
    global $book_index;
    global $url_fix;
    global $current;
    if (isset($current) && $book_index != "{$current}") {
        return 0;
    }
    // Fix up directory path
    foreach ($url_fix as $u) {
        $replace = $u['replace'];
        $match = $u['match'];
        if (isset($u['pkg'])) {
            if ($package == $u['pkg']) {
                $dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
                break;
            }
        } else {
            if (preg_match("/{$match}/", $dirpath)) {
                $dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
                break;
            }
        }
    }
    // Check for ftp
    if (preg_match("/^ftp/", $dirpath)) {
        // Get listing
        $lines = http_get_file("{$dirpath}/");
    } else {
        $lines = http_get_file($dirpath);
        if (!is_array($lines)) {
            return $lines;
        }
    }
    // End fetch
    if (isset($regex[$package])) {
        // Custom search for latest package name
        foreach ($lines as $l) {
            if (preg_match('/^\\h*$/', $l)) {
                continue;
            }
            $ver = preg_replace($regex[$package], "\$1", $l);
            if ($ver == $l) {
                continue;
            }
            return $ver;
            // Return first match of regex
        }
        return 0;
        // This is an error
    }
    if ($package == 'sawfish') {
        return find_max($lines, "/sawfish/", "/^.*sawfish_([\\d\\.]*\\d)\\.tar.*\$/");
    }
    // Most packages are in the form $package-n.n.n
    // Occasionally there are dashes (e.g. 201-1)
    $max = find_max($lines, "/{$package}/", "/^.*{$package}-?([\\d\\.]*\\d)\\.tar.*\$/");
    return $max;
}
开发者ID:JamesLinus,项目名称:BLFS,代码行数:60,代码来源:blfs-chapter26.php

示例2: thumb

function thumb($id, $content)
{
    //Getting the image url from custom field
    $img = get_post_meta($id, 'image', $single = true);
    //If there is no image specified in custom fields, get image from the content.
    if ($img == NULL || $img == '') {
        //Extracting the content of the post to do a pattern match
        //A simple regular expression to identify image urls.
        $searchimages = '~http://[^>]*.(jpg|jpeg|gif|png|PNG)~';
        preg_match($searchimages, $content, $pics);
        $iNumberOfPics = count($pics[0]);
        if ($iNumberOfPics > 0) {
            $img = $pics[0];
            if (!image_domain($img)) {
                $img = http_get_file($img, $id);
            }
            add_post_meta($id, 'image', $img, true) or update_post_meta($id, 'image', $img);
        }
    }
    if ($img == NULL || $img == '') {
        if (!get_option('upload_url_path')) {
            $img = WP_CONTENT_URL . '/uploads/swift_default.jpg';
        } else {
            $img = get_option('upload_url_path') . '/swift_default.jpg';
        }
        add_post_meta($id, 'image', $img, true) or update_post_meta($id, 'image', $img);
    }
    return $img;
}
开发者ID:JeffLuckett,项目名称:quickref,代码行数:29,代码来源:thumb.php

示例3: get_packages

function get_packages($package, $dirpath)
{
    global $regex;
    global $book_index;
    global $url_fix;
    global $current;
    global $kde_ver;
    global $kde_lines;
    if (isset($current) && $book_index != "{$current}") {
        return 0;
    }
    // Fix up directory path
    foreach ($url_fix as $u) {
        $replace = $u['replace'];
        $match = $u['match'];
        if (isset($u['pkg'])) {
            if ($package == $u['pkg']) {
                $dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
                break;
            }
        } else {
            if (preg_match("/{$match}/", $dirpath)) {
                $dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
                break;
            }
        }
    }
    // Check for ftp
    if (preg_match("/^ftp/", $dirpath)) {
        // No ftp for kde apps
        // Get listing
        $lines = http_get_file("{$dirpath}/");
    } else {
        if ($package == "konsole" || $package == "kdeplasma-addons" || $package == "kate" || $package == "gwenview") {
            return "check manually";
        }
        if (!is_array($kde_lines)) {
            $dirpath = "http://download.kde.org/stable/applications/";
            $lines = http_get_file($dirpath);
            $kde_ver = find_max($lines, "/4\\./", "/^.*;(1[\\d\\.]+\\d)\\/.*\$/");
            $kde_lines = http_get_file("{$dirpath}/{$kde_ver}/src");
        }
        if (!is_array($kde_lines)) {
            return $lines;
        }
        return find_max($kde_lines, "/{$package}/", "/^.*{$package}-([\\d\\.]*\\d)\\.tar.*\$/");
    }
    // End fetch
    // Most packages are in the form $package-n.n.n
    // Occasionally there are dashes (e.g. 201-1)
    $max = find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]*\\d)\\.tar.*\$/");
    return $max;
}
开发者ID:renodr,项目名称:blfs-currency,代码行数:53,代码来源:blfs-chapter29.php

示例4: get_packages

function get_packages($package, $dirpath)
{
    global $regex;
    global $book_index;
    global $url_fix;
    global $current;
    global $kde_ver;
    if (isset($current) && $book_index != "{$current}") {
        return 0;
    }
    // Fix up directory path
    foreach ($url_fix as $u) {
        $replace = $u['replace'];
        $match = $u['match'];
        if (isset($u['pkg'])) {
            if ($package == $u['pkg']) {
                $dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
                break;
            }
        } else {
            if (preg_match("/{$match}/", $dirpath)) {
                $dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
                break;
            }
        }
    }
    // Check for ftp
    if (preg_match("/^ftp/", $dirpath)) {
        if ($book_index == "polkit-gnome") {
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 1
        }
        if ($book_index == "libsecret") {
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 1
            $dirs = http_get_file("{$dirpath}/");
            $dir = find_max($dirs, "/\\d\$/", "/^.* ([\\d\\.]+)\$/");
            $dirpath .= "/{$dir}/";
        }
        // gsettings-desktop-schemas and similar
        if ($book_index == "gsettings-desktop-schemas" || $book_index == "libsecret" || $book_index == "totem-pl-parser" || $book_index == "vte" || $book_index == "yelp-xsl" || $book_index == "GConf" || $book_index == "gcr" || $book_index == "geocode-glib" || $book_index == "gjs" || $book_index == "gnome-desktop" || $book_index == "gnome-menus" || $book_index == "gnome-video-effects" || $book_index == "grilo" || $book_index == "gtkhtml" || $book_index == "gtksourceview" || $book_index == "libchamplain" || $book_index == "libgee" || $book_index == "libgtop" || $book_index == "libgweather" || $book_index == "libpeas" || $book_index == "rest" || $book_index == "libwnck" || $book_index == "gnome-online-accounts" || $book_index == "libgdata" || $book_index == "evolution-data-server" || $book_index == "caribou" || $book_index == "dconf" || $book_index == "gnome-backgrounds" || $book_index == "adwaita-icon-theme" || $book_index == "gnome-themes-standard" || $book_index == "gvfs" || $book_index == "nautilus" || $book_index == "zenity" || $book_index == "gnome-bluetooth" || $book_index == "gnome-keyring" || $book_index == "gnome-settings-daemon" || $book_index == "gnome-control-center" || $book_index == "mutter" || $book_index == "gnome-shell" || $book_index == "gnome-shell-extensions" || $book_index == "gnome-session" || $book_index == "gdm" || $book_index == "gnome-user-docs" || $book_index == "yelp") {
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 1
            $dirs = http_get_file("{$dirpath}/");
            if ($book_index == "gjs" || $book_index == "gnome-menus" || $book_index == "rest") {
                $dir = find_max($dirs, "/\\d\$/", "/^.* ([\\d\\.]+)\$/");
            } else {
                $dir = find_even_max($dirs, "/\\d\$/", "/^.* ([\\d\\.]+)\$/");
            }
            $dirpath .= "/{$dir}/";
        }
        // Get listing
        $lines = http_get_file("{$dirpath}/");
    } else {
        $lines = http_get_file($dirpath);
        if (!is_array($lines)) {
            return $lines;
        }
    }
    // End fetch
    if (isset($regex[$package])) {
        // Custom search for latest package name
        foreach ($lines as $l) {
            if (preg_match('/^\\h*$/', $l)) {
                continue;
            }
            $ver = preg_replace($regex[$package], "\$1", $l);
            if ($ver == $l) {
                continue;
            }
            return $ver;
            // Return first match of regex
        }
        return 0;
        // This is an error
    }
    if ($book_index == "telepathy-glib" || $book_index == "telepathy-mission-control") {
        return find_even_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]*\\d)\\.tar.*\$/");
    }
    // Most packages are in the form $package-n.n.n
    // Occasionally there are dashes (e.g. 201-1)
    $max = find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]*\\d)\\.tar.*\$/");
    return $max;
}
开发者ID:renodr,项目名称:blfs-currency,代码行数:93,代码来源:blfs-chapter30.php

示例5: http_get_file

$download_ok = false;
$done_zip = false;
if (isset($_POST['install'])) {
    //download latest
    if (isset($_POST['ver']) && in_array($_POST['ver'], array('1', '2'))) {
        $download_ok = http_get_file($versions[$_POST['ver']]['url'], 'latest.zip');
    } elseif ($_POST['ver'] == '0') {
        //use local file
        $download_ok = file_exists('latest.zip');
        if (!$download_ok) {
            echo '<br/> File dosen\'t exists, try downloading the latest version.';
        }
    } else {
        //use get latest stable url for remote
        $uri = Get_latest_version_url($versions[$_POST['ver']]['lang_code']);
        $download_ok = http_get_file($uri, 'latest.zip');
    }
    //unzip
    if ($download_ok) {
        $done_zip = extract_zip('latest.zip', $_POST['folder']);
    } else {
        echo '<br/> File dosen\'t exists, try downloading the latest version.';
        die;
    }
    //create database
    if (isset($_POST['mk_db']) && $_POST['mk_db'] == 'mkdb') {
        create_db($_POST['db_user'], $_POST['db_pass'], $_POST['server'], $_POST['db_name']);
    }
    //redirect to installer
    if ($done_zip) {
        ?>
开发者ID:inkm,项目名称:Wamp-WordPress-installer,代码行数:31,代码来源:installer.php

示例6: max_parent

function max_parent($dirpath, $prefix)
{
    // First, remove a directory
    $dirpath = rtrim($dirpath, "/");
    // Trim any trailing slash
    $position = strrpos($dirpath, "/");
    $dirpath = substr($dirpath, 0, $position);
    $lines = http_get_file($dirpath);
    $regex_match = "#{$prefix}[\\d\\.]+/#";
    $regex_replace = "#^.*({$prefix}[\\d\\.]+)/.*\$#";
    $max = find_max($lines, $regex_match, $regex_replace);
    return "{$dirpath}/{$max}";
}
开发者ID:renodr,项目名称:blfs-currency,代码行数:13,代码来源:blfs-include.php

示例7: get_packages

function get_packages($package, $dirpath)
{
    global $regex;
    global $book_index;
    global $url_fix;
    global $current;
    if (isset($current) && $book_index != "{$current}") {
        return 0;
    }
    // Fix up directory path
    foreach ($url_fix as $u) {
        $replace = $u['replace'];
        $match = $u['match'];
        if (isset($u['pkg'])) {
            if ($package == $u['pkg']) {
                $dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
                break;
            }
        } else {
            if (preg_match("/{$match}/", $dirpath)) {
                $dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
                break;
            }
        }
    }
    // Check for ftp
    if (preg_match("/^ftp/", $dirpath)) {
        // bind
        if ($book_index == "bind") {
            // Get the max directory and adjust the directory path
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 1
            $lines1 = http_get_file("{$dirpath}/");
            $dir = find_max($lines1, "/\\.[\\d\\.P-]+\\s*\$/", "/^.* (\\d\\.[\\d\\.P-]+)\$/");
            $dirpath .= "/{$dir}";
            $lines2 = http_get_file("{$dirpath}/");
            return find_max($lines2, "/bind-9/", "/^.*bind-(\\d+[\\d\\.P-]+).tar.*\$/");
        }
        // Get listing
        $lines = http_get_file("{$dirpath}/");
    } else {
        // Customize http directories as needed
        if ($book_index == "dovecot") {
            // Get the max directory and adjust the directory path
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 1
            $lines1 = http_get_file("{$dirpath}/");
            $dir = find_max($lines1, "/^\\s*\\d+/", "/^\\s*(\\d+[\\d\\.]+)\\/.*\$/");
            $dirpath .= "/{$dir}/";
        }
        $lines = http_get_file($dirpath);
        if (!is_array($lines)) {
            return $lines;
        }
    }
    // End fetch
    if (isset($regex[$package])) {
        // Custom search for latest package name
        foreach ($lines as $l) {
            if (preg_match('/^\\h*$/', $l)) {
                continue;
            }
            $ver = preg_replace($regex[$package], "\$1", $l);
            if ($ver == $l) {
                continue;
            }
            if ($package == "sqlite-autoconf") {
                $ver = preg_replace("/\\./", "0", $ver);
            }
            return $ver;
            // Return first match of regex
        }
        return 0;
        // This is an error
    }
    if ($book_index == "qpopper") {
        return find_max($lines, '/qpopper[\\d\\.]+.tar.*$/', '/^.* qpopper([\\d\\.]+).tar.*$/');
    }
    if ($book_index == "sendmail.") {
        return find_max($lines, '/sendmail\\.[\\d\\.]+.tar.*$/', '/^.* sendmail\\.([\\d\\.]+).tar.*$/');
    }
    if ($book_index == "openldap") {
        return find_max($lines, '/openldap-[\\d\\.]+.tgz.*$/', '/^.* openldap-([\\d\\.]+).tgz.*$/');
    }
    if ($book_index == "proftpd") {
        return find_max($lines, '/proftpd-[a-m\\d\\.]+.tar.*$/', '/^.* proftpd-([a-m\\d\\.]+).tar.*$/');
    }
    if ($book_index == "dovecot") {
        return find_max($lines, '/dovecot-/', '/^.*dovecot-([\\d\\.]+).tar.*$/');
    }
    if ($book_index == "postgresql") {
        return find_max($lines, '/v\\d/', '/^.*v([\\d\\.]+)\\/.*$/');
    }
    // Most packages are in the form $package-n.n.n
//.........这里部分代码省略.........
开发者ID:JamesLinus,项目名称:BLFS,代码行数:101,代码来源:blfs-chapter20.php

示例8: cache_sequence

function cache_sequence($url, $fps, $clip_fps, $start, $duration, $dir_path, $options = array())
{
    // TODO: support $speed != 1
    $result = FALSE;
    $url = end_with_slash($url);
    $cache_path = url_file_path($url, $dir_path);
    if (empty($options['zeropadding'])) {
        $options['zeropadding'] = 0;
    }
    if (empty($options['duration'])) {
        $options['duration'] = str_repeat('9', max(1, $options['zeropadding'])) / $clip_fps;
    }
    if (empty($options['zeropadding'])) {
        $options['zeropadding'] = strlen(floor($options['duration'] * $clip_fps));
    }
    if (empty($options['pattern'])) {
        $options['pattern'] = '%.jpg';
    }
    if (!isset($options['begin'])) {
        $options['begin'] = 1;
    }
    if (empty($options['increment'])) {
        $options['increment'] = 1;
    }
    if (empty($options['dimensions'])) {
        $options['dimensions'] = get_file_info('dimensions', $cache_path);
    }
    $one = floatval(1);
    $clip_frame_seconds = $one / $clip_fps;
    $frame_seconds = $one / $fps;
    if ($duration == -1) {
        $duration = $options['duration'];
    }
    $stop = $start + $duration;
    $stop = min($stop, $options['duration']);
    $frames = array();
    for ($i = $start; !floatgtre($i, $stop); $i += $clip_frame_seconds) {
        $frame = floor($i * $clip_fps);
        $frame_key = 'frame' . $frame;
        if (!isset($frames[$frame_key])) {
            $frames[$frame_key] = $frame;
        }
    }
    if ($frames) {
        $highest_frame = 0;
        $build_dir = $cache_path;
        if ($options['dimensions']) {
            $build_dir = frame_file_path($cache_path, $options['dimensions'], $clip_fps);
        }
        asort($frames);
        $frames = array_values($frames);
        $z = sizeof($frames);
        $highest_frame = $frames[$z - 1];
        $err = FALSE;
        for ($i = 0; $i < $z; $i++) {
            $frame = $frames[$i];
            $frame *= $options['increment'];
            $frame += $options['begin'];
            $s = (string) $frame;
            if ($options['zeropadding']) {
                $s = str_pad($s, $options['zeropadding'], '0', STR_PAD_LEFT);
            }
            $file_name = str_replace('%', $s, $options['pattern']);
            $file_url = $url . $file_name;
            $file_path = $build_dir . $file_name;
            $download = TRUE;
            if ($build_dir != $cache_path) {
                if (file_exists($file_path) && filesize($file_path)) {
                    $download = FALSE;
                }
            }
            if ($download) {
                $mime = http_get_file($file_url, $file_path);
                if (!$mime) {
                    $err = 'Could not download: ' . $file_url . ' ' . $file_path;
                } else {
                    if ($build_dir == $cache_path) {
                        $data = @getimagesize($file_path);
                        if ($data && $data[0] && $data[1]) {
                            $options['dimensions'] = $data[0] . 'x' . $data[1];
                            set_file_info($cache_path, 'dimensions', $options['dimensions']);
                            set_file_info($cache_path, 'duration', $options['duration']);
                            set_file_info($cache_path, 'Content-Type', 'video/sequence');
                            $build_dir = frame_file_path($cache_path, $options['dimensions'], $clip_fps);
                            if (!safe_path($build_dir)) {
                                $err = 'Could not get safe path: ' . $build_dir;
                            } elseif (!@rename($file_path, $build_dir . $file_name)) {
                                $err = 'Could not rename: ' . $file_path . ' ' . $build_dir . $file_name;
                            } else {
                                $file_path = $build_dir . $file_name;
                            }
                        } else {
                            $err = 'Could not get image size: ' . $file_path;
                        }
                    }
                }
            }
            if ($err) {
                break;
            }
//.........这里部分代码省略.........
开发者ID:ronniebrito,项目名称:moodle_moviemasher,代码行数:101,代码来源:cacheutils.php

示例9: http_get_file



<?php 
//$content = file_get_contents('http://joomla.joelrowley.com/simpledownload.txt');if ($content !== false) {$myFile = "simpledownload.txt";$fh = fopen($myFile, 'w') or die("can't open file");fwrite($fh, $content);fclose($fh);} else {print "Error occurred.";}
?>

<?php 
function http_get_file($url)
{
    $url_stuff = parse_url($url);
    $port = isset($url_stuff['port']) ? $url_stuff['port'] : 80;
    $fp = fsockopen($url_stuff['host'], $port);
    $query = 'GET ' . $url_stuff['path'] . " HTTP/1.0\n";
    $query .= 'Host: ' . $url_stuff['host'];
    $query .= "\n\n";
    fwrite($fp, $query);
    while ($line = fread($fp, 1024)) {
        $buffer .= $line;
    }
    preg_match('/Content-Length: ([0-9]+)/', $buffer, $parts);
    return substr($buffer, -$parts[1]);
}
$content = http_get_file("http://joomla.joelrowley.com/simpledownload.txt");
if ($content !== false) {
    $myFile = "simpledownload.txt";
    $fh = fopen($myFile, 'w') or die("can't open file");
    fwrite($fh, $content);
    fclose($fh);
} else {
    print "Error occurred.";
}
开发者ID:hjoelr,项目名称:com_simpledownload,代码行数:29,代码来源:remote-update.php

示例10: get_packages

function get_packages($package, $dirpath)
{
    global $regex;
    global $book_index;
    global $url_fix;
    global $current;
    if (isset($current) && $book_index != "{$current}") {
        return 0;
    }
    // Fix up directory path
    foreach ($url_fix as $u) {
        $replace = $u['replace'];
        $match = $u['match'];
        if (isset($u['pkg'])) {
            if ($package == $u['pkg']) {
                $dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
                break;
            }
        } else {
            if (preg_match("/{$match}/", $dirpath)) {
                $dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
                break;
            }
        }
    }
    // Check for ftp
    if (preg_match("/^ftp/", $dirpath)) {
        if ($package == 'gnutls') {
            $lines1 = http_get_file($dirpath);
            $dir = find_max($lines1, "/v\\d\\.\\d/", "/.*(v\\d[\\d\\.-]*\\d).*\$/");
            $dirpath .= "{$dir}/";
        }
        $lines = http_get_file("{$dirpath}/");
        if (!is_array($lines)) {
            return $lines;
        }
    } else {
        // Customize http directories as needed
        if ($package == 'cracklib') {
            $dirpath = "http://sourceforge.net/projects/cracklib/files/{$package}";
        }
        // Need to get max directory from here
        if ($package == 'cracklib-words') {
            $dirpath = "http://sourceforge.net/projects/cracklib/files/{$package}";
            $lines = http_get_file($dirpath);
            $max = find_max($lines, "/\\d{4}-\\d{2}-\\d{2}/", "/^.*(\\d{4}-\\d{2}-\\d{2}).*\$/");
            if ($max == 0) {
                return -6;
            }
            $dirpath .= "/{$max}";
            $lines = http_get_file($dirpath);
            return find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.-]*\\d)\\.gz.*\$/");
        }
        if ($book_index == "krb5") {
            // Remove last two dirs from $path
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
        }
        $lines = http_get_file($dirpath);
        if (!is_array($lines)) {
            return $lines;
        }
    }
    // End fetch
    if (isset($regex[$package])) {
        // Custom search for latest package name
        foreach ($lines as $l) {
            $ver = preg_replace($regex[$package], "\$1", $l);
            if ($ver == $l) {
                continue;
            }
            //if ( $package == 'krb' ) $ver = "5-$ver";
            return $ver;
            // Return first match of regex
        }
        return 0;
        // This is an error
    }
    if ($package == "acl" || $package == "attr") {
        return find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.-]*\\d)\\.src.tar.*\$/");
    }
    if ($package == "libcap2_") {
        return find_max($lines, "/{$package}/", "/^.*{$package}([\\d\\.-]*\\d)\\.orig.tar.*\$/");
    }
    if ($book_index == "Linux-PAM1") {
        return find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]*\\d)-docs.tar.*\$/");
    }
    if ($book_index == "openssh") {
        return find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.p]*\\d).tar.*\$/");
    }
    if ($book_index == "openssl") {
        return find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.p]*\\d.?).tar.*\$/");
    }
    if ($book_index == "p11-kit") {
        return find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]*\\d).tar.*\$/");
    }
    if ($book_index == "shadow_") {
        return find_max($lines, "/{$package}/", "/^.*{$package}([\\d\\.]*\\d).orig.tar.*\$/");
//.........这里部分代码省略.........
开发者ID:renodr,项目名称:blfs-currency,代码行数:101,代码来源:blfs-chapter04.php

示例11: get_packages

function get_packages($package, $dirpath)
{
    global $regex;
    global $book_index;
    global $url_fix;
    global $current;
    if (isset($current) && $book_index != "{$current}") {
        return 0;
    }
    // Fix up directory path
    foreach ($url_fix as $u) {
        $replace = $u['replace'];
        $match = $u['match'];
        if (isset($u['pkg'])) {
            if ($package == $u['pkg']) {
                $dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
                break;
            }
        } else {
            if (preg_match("/{$match}/", $dirpath)) {
                $dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
                break;
            }
        }
    }
    if (preg_match("/ftp/", $dirpath)) {
        $dirpath .= "/";
    }
    $lines = http_get_file("{$dirpath}");
    if (!is_array($lines)) {
        return $lines;
    }
    if (isset($regex[$package])) {
        // Custom search for latest package name
        foreach ($lines as $l) {
            $ver = preg_replace($regex[$package], "\$1", $l);
            if ($ver == $l) {
                continue;
            }
            if ($package == 'krb') {
                $ver = "5-{$ver}";
            }
            return $ver;
            // Return first match of regex
        }
        return 0;
        // This is an error
    }
    if ($book_index == "LVM2.") {
        return find_max($lines, "/{$package}/", "/^.*{$package}([\\d\\.]*\\d).tgz.*\$/");
    }
    if ($book_index == "gptfdisk") {
        $dir = find_max($lines, '/\\d\\./', '/^\\s*([\\d\\.]+)\\s*$/');
        $lines = http_get_file("{$dirpath}/{$dir}");
    }
    if ($book_index == "mdadm") {
        $max = find_max($lines, '/mdadm-[\\d\\.]+/', '/^.*mdadm-([\\d\\.]+).tar.*$/');
        return $max;
    }
    if ($book_index == "reiserfsprogs") {
        $max = find_max($lines, '/^v[\\d\\.]+.*$/', '/^v([\\d\\.]+).*$/');
        return $max;
    }
    // Most packages are in the form $package-n.n.n
    // Occasionally there are dashes (e.g. 201-1)
    $max = find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]*\\d)\\.tar.*\$/");
    return $max;
}
开发者ID:JamesLinus,项目名称:BLFS,代码行数:68,代码来源:blfs-chapter05.php

示例12: get_packages

function get_packages($package, $dirpath)
{
    global $regex;
    global $book_index;
    global $url_fix;
    global $current;
    if (isset($current) && $book_index != "{$current}") {
        return 0;
    }
    // Fix up directory path
    foreach ($url_fix as $u) {
        $replace = $u['replace'];
        $match = $u['match'];
        if (isset($u['pkg'])) {
            if ($package == $u['pkg']) {
                $dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
                break;
            }
        } else {
            if (preg_match("/{$match}/", $dirpath)) {
                $dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
                break;
            }
        }
    }
    // Check for ftp
    if (preg_match("/^ftp/", $dirpath)) {
        // glib type packages
        if ($book_index == "glib-networking" || $book_index == "libsoup") {
            // Parent listing
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            $lines = http_get_file("{$dirpath}/");
            $dir = find_even_max($lines, '/^[\\d\\.]+$/', '/^([\\d\\.]+)$/');
            $dirpath .= "/{$dir}/";
        }
        // lynx - really has odd name format
        if ($book_index == "lynx") {
            $lines = http_get_file($dirpath);
            $dir = find_max($lines, "/lynx/", "/^.*(lynx\\d[\\d\\.]+).*\$/");
            $dirpath .= "/{$dir}/";
            $lines = http_get_file("{$dirpath}");
            $max = find_max($lines, "/rel/", "/^.*lynx(\\d[\\d\\.]+rel\\.\\d).tar.*\$/");
            return $max;
        }
        // Get listing
        $lines = http_get_file("{$dirpath}/");
    } else {
        // Customize http directories as needed
        if ($book_index == "glib-networking" || $book_index == "libsoup" || $book_index == "geoclue1") {
            // Parent listing
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            $lines1 = http_get_file($dirpath);
            if ($book_index == "geoclue1") {
                $dir = find_max($lines1, '/^\\s*[\\d\\.]+\\/.*$/', '/^\\s*([\\d\\.]+).*$/');
            } else {
                $dir = find_even_max($lines1, '/^\\s*[\\d\\.]+\\/.*$/', '/^\\s*([\\d\\.]+).*$/');
            }
            $dirpath .= "/{$dir}/";
        }
        $lines = http_get_file($dirpath);
        if (!is_array($lines)) {
            return $lines;
        }
    }
    // End fetch
    if (isset($regex[$package])) {
        // Custom search for latest package name
        foreach ($lines as $l) {
            if (preg_match('/^\\h*$/', $l)) {
                continue;
            }
            $ver = preg_replace($regex[$package], "\$1", $l);
            if ($ver == $l) {
                continue;
            }
            //if ( $book_index == "exiv" ) $ver = "2-$ver";
            return $ver;
            // Return first match of regex
        }
        return 0;
        // This is an error
    }
    if ($book_index == "libndp") {
        return find_max($lines, '/v\\d/', '/^.*v([\\d\\.]+)$/');
    }
    if ($book_index == "heirloom-mailx_") {
        return find_max($lines, '/orig/', '/^.*_([\\d\\.]+)\\.orig.*$/');
    }
    if ($book_index == "libpcap") {
        return find_max($lines, '/libpcap-[\\d\\.]+/', '/^.*libpcap-([\\d\\.]+).tar.*$/');
    }
    if ($book_index == "mutt") {
        return find_max($lines, '/mutt-/', '/^.*mutt-([\\d\\.]+).tar.*$/');
    }
//.........这里部分代码省略.........
开发者ID:renodr,项目名称:blfs-currency,代码行数:101,代码来源:blfs-chapter17.php

示例13: get_packages

function get_packages($package, $dirpath)
{
    global $regex;
    global $book_index;
    global $url_fix;
    global $current;
    global $libreoffice;
    if (isset($current) && $book_index != "{$current}") {
        return 0;
    }
    // Fix up directory path
    foreach ($url_fix as $u) {
        $replace = $u['replace'];
        $match = $u['match'];
        if (isset($u['pkg'])) {
            if ($package == $u['pkg']) {
                $dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
                break;
            }
        } else {
            if (preg_match("/{$match}/", $dirpath)) {
                $dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
                break;
            }
        }
    }
    // Check for ftp
    if (preg_match("/^ftp/", $dirpath)) {
        if ($package == "seamonkey" || $package == "firefox" || $package == "thunderbird") {
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 1
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 2
            $dirpath .= "/";
            $dirs = http_get_file($dirpath);
            if ($package == "seamonkey") {
                return find_max($dirs, "/\\d\\./", "/^.* (\\d\\.[\\.\\d]+)\$/");
            } else {
                return find_max($dirs, "/\\d\\./", "/^.*(\\d{2}[\\.\\d]+)\$/");
            }
        }
        // Get listing
        $lines = http_get_file("{$dirpath}/");
    } else {
        if (preg_match("/abiword/", $dirpath)) {
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 1
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 2
        }
        if ($book_index == "gnucash-docs") {
            $dirs = http_get_file($dirpath);
            $dir = find_max($dirs, "/^\\s+\\d\\./", "/^\\s+(\\d\\.[\\d\\.]+)\$/");
            $dirpath .= "/{$dir}/";
        }
        if ($book_index == "xchat") {
            $dirs = http_get_file($dirpath);
            $dir = find_max($dirs, "/^\\s*\\d\\./", ":^\\s*(\\d\\.[\\d\\.]+)/.*\$:");
            $dirpath .= "/{$dir}/";
        }
        if (preg_match("/^libre/", "{$package}")) {
            if (count($libreoffice) == 0) {
                $dirs = http_get_file($dirpath);
                $dir = find_max($dirs, "/\\d\\./", "/^.*;([\\d\\.]+)\\/.*\$/");
                $dirpath = "http://download.documentfoundation.org/libreoffice/src/{$dir}";
                $libreoffice = http_get_file($dirpath);
            }
            return find_max($libreoffice, "/{$package}/", "/^.*{$package}-([\\d\\.]*\\d)\\.tar.*\$/");
        }
        if ($package == "gimp") {
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $dirs = http_get_file("{$dirpath}/");
            $dir = find_max($dirs, "/v\\d\\./", "/^.*(v\\d\\.[\\d\\.]+).*\$/");
            $dirpath .= "/{$dir}/";
        }
        $lines = http_get_file($dirpath);
        if (!is_array($lines)) {
            return $lines;
        }
    }
    // End fetch
    if (isset($regex[$package])) {
        // Custom search for latest package name
        foreach ($lines as $l) {
            if (preg_match('/^\\h*$/', $l)) {
                continue;
            }
            $ver = preg_replace($regex[$package], "\$1", $l);
            if ($ver == $l) {
                continue;
            }
//.........这里部分代码省略.........
开发者ID:renodr,项目名称:blfs-currency,代码行数:101,代码来源:blfs-chapter36.php

示例14: begin_debug

begin_debug();
// By default, localhost root/root MySQL user is used. Set $q_server, $q_user, $q_password to override
$q_database = 'imdb_sample';
q("CREATE TABLE IF NOT EXISTS films (title VARCHAR(250), year SMALLINT, cover VARCHAR(250))");
$http_cache = true;
http_get('http://www.imdb.com/chart/top/');
foreach (tags_html('.titleColumn') as $film) {
    set_source($film);
    $year = inside('(', ')', tag_text('.secondaryInfo'));
    if ($year < 2015) {
        continue;
    }
    http_get(tag_link('a'));
    // Open film link
    $title = q_escape(replace('(*)', '', tag_text('h1')));
    // Take title and remove year like (2015) from it
    if (q("SELECT * FROM films WHERE title={$title}")) {
        continue;
    }
    // If film already in DB, skip
    http_get(tag_link('.poster'));
    // Open poster link
    $cover = q_escape(http_get_file(tag_image('#primary-img'), 'covers/'));
    // Download primary image from slideshow
    q("INSERT INTO films SET title={$title}, year={$year}, cover={$cover}");
}
// Lets output the films from our DB
foreach (qq("SELECT * FROM films") as $film) {
    echo "<h1><img src='{$film['cover']}' /> {$film['title']} <i>({$film['year']})</i></h1>";
}
// THE END
开发者ID:MaxD2,项目名称:ParseMX-Library,代码行数:31,代码来源:imdb.php

示例15: get_packages

function get_packages($package, $dirpath)
{
    global $regex;
    global $book_index;
    global $url_fix;
    global $current;
    if (isset($current) && $book_index != "{$current}") {
        return 0;
    }
    // Fix up directory path
    foreach ($url_fix as $u) {
        $replace = $u['replace'];
        $match = $u['match'];
        if (isset($u['pkg'])) {
            if ($package == $u['pkg']) {
                $dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
                break;
            }
        } else {
            if (preg_match("/{$match}/", $dirpath)) {
                $dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
                break;
            }
        }
    }
    // Check for ftp
    if (preg_match("/^ftp/", $dirpath)) {
        if ($book_index == "bind") {
            // Get the max directory and adjust the directory path
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 1
            $lines1 = http_get_file("{$dirpath}/");
            $dir = find_max($lines1, "/\\d\$/", "/^.* ([\\d\\.P\\-]+)\$/");
            $dirpath .= "/{$dir}/";
            $lines2 = http_get_file($dirpath);
            return find_max($lines2, "/bind-/", "/^.*bind-(\\d+[\\d\\.P\\-]+).tar.*\$/");
        }
        if ($book_index == "dhcp") {
            // Get the max directory and adjust the directory path
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            $lines = http_get_file("{$dirpath}/");
            $dir = find_max($lines, "/\\d\$/", "/^.* (\\d\\.[\\d\\.P\\-]+)\$/");
            $dirpath .= "/{$dir}/";
        }
        // Get listing
        $lines = http_get_file("{$dirpath}/");
    } else {
        if ($book_index == "NetworkManager") {
            // Get the max directory and adjust the directory path
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $lines1 = http_get_file($dirpath);
            $dir = find_max($lines1, "/\\d[\\d\\.]+/", "/^\\s*(\\d[\\d\\.]+).*\$/");
            $dirpath .= "/{$dir}/";
        }
        $lines = http_get_file($dirpath);
        if (!is_array($lines)) {
            return $lines;
        }
    }
    // End fetch
    if (isset($regex[$package])) {
        // Custom search for latest package name
        foreach ($lines as $l) {
            if (preg_match('/^\\h*$/', $l)) {
                continue;
            }
            $ver = preg_replace($regex[$package], "\$1", $l);
            if ($ver == $l) {
                continue;
            }
            if ($book_index == "exiv") {
                $ver = "2-{$ver}";
            }
            return $ver;
            // Return first match of regex
        }
        return 0;
        // This is an error
    }
    if ($book_index == "dhcp") {
        return find_max($lines, '/dhcp/', '/^.*dhcp-([\\d\\.P-]+).tar.*$/');
    }
    if ($book_index == "ncftp") {
        return find_max($lines, '/ncftp/', '/^.*ncftp-([\\d\\.]+)-src.tar.*$/');
    }
    if ($book_index == "net-tools-CVS") {
        return find_max($lines, '/net-tools/', '/^.*_(\\d+).tar.*$/');
    }
    if ($book_index == "ntp") {
        $dir = max_parent($dirpath, "ntp-");
        $lines = http_get_file("{$dir}");
        return find_max($lines, '/ntp-.*tar/', '/^ntp-([\\d\\.p]+).tar.*$/');
    }
//.........这里部分代码省略.........
开发者ID:JamesLinus,项目名称:BLFS,代码行数:101,代码来源:blfs-chapter14.php


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