コード例 #1
0
ファイル: blfs-chapter26.php プロジェクト: JamesLinus/BLFS
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;
}
コード例 #2
0
ファイル: thumb.php プロジェクト: JeffLuckett/quickref
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;
}
コード例 #3
0
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;
}
コード例 #4
0
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;
}
コード例 #5
0
$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) {
        ?>
コード例 #6
0
ファイル: blfs-include.php プロジェクト: renodr/blfs-currency
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}";
}
コード例 #7
0
ファイル: blfs-chapter20.php プロジェクト: JamesLinus/BLFS
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
    // Occasionally there are dashes (e.g. 201-1)
    $max = find_max($lines, "/{$package}/", "/^.* {$package}-([\\d\\.]*\\d)\\.tar.*\$/");
    return $max;
}
コード例 #8
0
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;
            }
            $frames[$i] = $file_path;
        }
        if (!$err) {
            for ($i = 1; $i < $highest_frame; $i++) {
                $s = (string) $i;
                if ($options['zeropadding']) {
                    $s = str_pad($s, $options['zeropadding'], '0', STR_PAD_LEFT);
                }
            }
            // ffmpeg needs at least one file starting with zero, having zeropadding digits
            $options['files'] = $frames;
            $result = $options;
        }
    }
    return $result;
}
コード例 #9
0

<?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.";
}
コード例 #10
0
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.*\$/");
    }
    if ($book_index == "cracklib") {
        return find_max($lines, "/\\d\\.\\d+\\.\\d+/", "/^.*(\\d\\.\\d+\\.\\d+).*\$/");
    }
    if ($book_index == "nettle") {
        return find_max($lines, "/nettle/", "/^.*nettle-([\\.\\d]+\\d).tar.*\$/");
    }
    if ($book_index == "gnupg") {
        return find_max($lines, "/gnupg-2/", "/^.*gnupg-([\\.\\d]+).tar.*\$/");
    }
    if ($book_index == "nss") {
        $ver = find_max($lines, "/NSS_/", "/^.*NSS_(\\d[_\\d]+)_RTM.*\$/");
        return preg_replace("/_/", ".", $ver);
        // Change underscors to dots
    }
    if ($book_index == "sudo") {
        return find_max($lines, "/sudo-\\d[\\.\\d]+/", "/^.*sudo-(\\d\\.[\\d\\.]+p?\\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;
}
コード例 #11
0
ファイル: blfs-chapter05.php プロジェクト: JamesLinus/BLFS
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;
}
コード例 #12
0
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.*$/');
    }
    // libtirpc  (sourceforge is inconsistent here)
    if ($book_index == "libtirpc") {
        return find_max($lines, '/^\\s*0\\.[\\d\\.]+\\s*$/', '/^\\s*(0\\.[\\d\\.]+)\\s*$/');
    }
    if ($book_index == "geoclue1") {
        return find_max($lines, "/geoclue/", "/^.*geoclue-([\\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;
}
コード例 #13
0
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;
            }
            return $ver;
            // Return first match of regex
        }
        return 0;
        // This is an error
    }
    if (preg_match("/inkscape/", "{$dirpath}")) {
        return find_max($lines, "/\\d\\./", "/^.* (\\d[\\d\\.]+\\d)\$/");
    }
    if (preg_match("/abiword/", "{$dirpath}")) {
        return find_max($lines, "/^\\d/", "/^([\\d\\.]+).*\$/");
    }
    if ($package == "balsa") {
        return find_max($lines, "/^.*balsa-/", "/^.*balsa-([\\d\\.]+).*\$/");
    }
    if ($package == "gparted") {
        return find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]+).*\$/");
    }
    if ($package == "rox-filer") {
        return find_max($lines, "/^\\s*\\d/", "/^\\s*(\\d\\.[\\d\\.]+).*\$/");
    }
    if ($package == "tigervnc") {
        return find_max($lines, "/^\\s*\\d\\./", "/^\\s*(\\d\\.[\\d\\.]+).*\$/");
    }
    if ($package == "xdg-utils") {
        return find_max($lines, "/{$package}/", "/^{$package}-(\\d\\.[\\d\\.rc-]+).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)\\.ta.*\$/");
    return $max;
}
コード例 #14
0
ファイル: imdb.php プロジェクト: MaxD2/ParseMX-Library
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
コード例 #15
0
ファイル: blfs-chapter14.php プロジェクト: JamesLinus/BLFS
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.*$/');
    }
    if ($book_index == "whois") {
        return find_max($lines, '/whois_/', '/^.*whois_([\\d\\.]+).tar.*$/');
    }
    if ($book_index == "wireshark") {
        return find_even_max($lines, '/wireshark/', '/^.*wireshark-([\\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;
}
コード例 #16
0
ファイル: blfs-chapter30.php プロジェクト: JamesLinus/BLFS
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 == "GConf" || $book_index == "gcr" || $book_index == "gvfs" || $book_index == "yelp-xsl" || $book_index == "gnome-desktop" || $book_index == "gnome-keyring" || $book_index == "gnome-video-effects" || $book_index == "gtksourceview" || $book_index == "libgtop" || $book_index == "libpeas" || $book_index == "libwnck" || $book_index == "totem-pl-parser" || $book_index == "vte" || $book_index == "dconf" || $book_index == "gnome-icon-theme" || $book_index == "gnome-icon-theme-symbolic" || $book_index == "gnome-themes-standard" || $book_index == "notification-daemon" || $book_index == "yelp" || $book_index == "libgnome-keyring") {
            $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 == "libpeas" )
            //  $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 == "polkit-gnome") {
        return find_max($lines, "/\\d\$/", "/^.* ([\\d\\.]+)\$/");
    }
    // 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;
}
コード例 #17
0
ファイル: blfs-chapter06.php プロジェクト: JamesLinus/BLFS
function get_packages($package, $dirpath)
{
    global $exceptions;
    global $regex;
    global $book_index;
    global $url_fix;
    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 == "joe") {
        $dir = find_max($lines, '/^.*joe-[\\d\\.]+.*$/', '/^.*(joe-[\\d\\.]+).tar.*$/');
        $lines = http_get_file("{$dirpath}/{$dir}");
    }
    // vim language pack
    if ($book_index == "vim1") {
        return find_max($lines, '/^.*vim-[\\d\\.]+-lang.*$/', '/^.*vim-([\\d\\.]+)-lang.*$/');
    }
    if ($book_index == "nano") {
        return find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]+).tar.*\$/");
    }
    // zsh docs
    if ($book_index == "zsh1") {
        return find_max($lines, '/doc/', '/^.*zsh-([\\d\\.]+)-doc.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;
}
コード例 #18
0
ファイル: blfs-chapter10.php プロジェクト: JamesLinus/BLFS
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)) {
        // babl and similar
        if ($book_index == "babl" || $book_index == "gegl" || $book_index == "libart_lgpl") {
            // 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[\\d\\.]+)/");
            $dirpath .= "/{$dir}/";
        }
        // Get listing
        //if ( $book_index == "tiff" ) { $dirpath .= "/"; }
        $lines = http_get_file("{$dirpath}/");
    } else {
        // glib type packages
        if ($book_index == "librsvg") {
            // Parent listing
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up one
            $lines = http_get_file($dirpath);
            $dir = find_even_max($lines, '/^\\s+[\\d\\.]+\\//', '/^\\s+([\\d\\.]+)\\/.*$/');
            $dirpath .= "/{$dir}/";
        }
        // Customize http directories as needed
        $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 == "freetype" || $book_index == "freetype-doc") {
        $dir = find_max($lines, '/\\d\\./', '/^\\s*([\\d\\.]+)\\s*$/');
        $lines = http_get_file("{$dirpath}/{$dir}");
    }
    if ($book_index == "libjpeg-turbo") {
        return find_max($lines, '/\\d\\./', '/^\\s*([\\d\\.]+)\\s*$/');
    }
    if ($book_index == "openjpeg") {
        return find_max($lines, '/^\\s*1[\\d\\.]/', '/^.*(1\\.[\\d\\.]+).*$/');
    }
    // imlib
    if ($book_index == "imlib2") {
        $dir = find_max($lines, '/^\\s*[\\d\\.]+\\s*$/', '/^\\s*([\\d\\.]+)\\s*$/');
        $lines = http_get_file("{$dirpath}/{$dir}");
        return find_max($lines, "/imlib/", "/^.*{$package}-([\\d\\.]*\\d).tar.*\$/");
    }
    // lcms (actually lcms 1.xx)
    if ($book_index == "lcms") {
        return find_max($lines, '/1\\.[\\d\\.]+/', '/^\\s*(1[\\d\\.]+)\\s*$/');
    }
    if ($book_index == "opencv") {
        return find_max($lines, '/\\d\\.[\\d\\.]+/', '/^\\s*(\\d\\.[\\d\\.]+)\\s*$/');
    }
    // lcms2
    if ($book_index == "lcms2") {
        return find_max($lines, '/2\\.[\\d\\.]+/', '/^\\s*(2[\\d\\.]+)\\s*$/');
    }
    // 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.*\$/", TRUE);
    return $max;
}
コード例 #19
0
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 {
        // glib type packages
        if ($book_index == "gtk-doc") {
            // Parent listing
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            $lines = http_get_file($dirpath);
            $dir = find_max($lines, '/^\\s+[\\d\\.]+\\//', '/^\\s+([\\d\\.]+)\\/.*$/');
            $dirpath .= "/{$dir}/";
        }
        // babl and similar
        if ($book_index == "rarian") {
            // 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, '/^\\s+[\\d\\.]+\\//', '/^\\s+([\\d\\.]+)\\/.*$/');
            $dirpath .= "/{$dir}/";
        }
        // Customize http directories as needed
        $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 == "hd2u") {
        return find_max($lines, '/hd2u/', '/^.*hd2u-([\\d\\.]+).tgz.*$/');
    }
    if ($book_index == "ImageMagick") {
        return find_max($lines, '/ImageMagick/', '/^.*ImageMagick-([\\d\\.-]+).tar.*$/');
    }
    if ($book_index == "js") {
        return find_max($lines, '/js/', '/^.*js(\\d[\\d\\.-]+\\d).tar.*$/');
    }
    if ($book_index == "lsof_") {
        return find_max($lines, '/lsof_/', '/^.*lsof_([\\d\\.]+).tar.*$/');
    }
    if ($book_index == "qtchooser") {
        return find_max($lines, '/qtchooser/', '/^.*qtchooser-([\\d\\.]+)-.*.tar.gz.*$/');
    }
    if ($book_index == "tree") {
        return find_max($lines, '/tree/', '/^.*tree-([\\d\\.]+).tgz.*$/');
    }
    if ($book_index == "tidy-cvs_") {
        return find_max($lines, '/tidy-cvs/', '/^.*_(\\d+).tar.*$/');
    }
    if ($book_index == "rep-gtk_") {
        return find_max($lines, '/rep-gtk/', '/^.*[_-]([\\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;
}
コード例 #20
0
ファイル: blfs-chapter24.php プロジェクト: JamesLinus/BLFS
function get_packages($package, $dirpath)
{
    global $regex;
    global $book_index;
    global $url_fix;
    global $current;
    global $freedesk;
    global $xorg_drv;
    global $proto;
    global $apps;
    global $libs;
    global $fonts;
    global $drivers;
    if (isset($current) && $book_index != "{$current}") {
        return 0;
    }
    if ($dirpath == "") {
        return "";
    }
    // 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)) {
        // MesaLib
        if ($book_index == "mesa") {
            // 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
            $lines = http_get_file("{$dirpath}/");
            // The directory is not always the same as the package
            $max = find_max($lines, "/\\d\$/", "/^.* (\\d+[\\d\\.]+)\$/");
            $split = explode(".", $max);
            if (count($split) < 3) {
                $max .= ".0";
            }
            return $max;
        }
        if ($dirpath == $xorg_drv) {
            if (count($drivers) == 0) {
                $drivers = http_get_file("{$dirpath}/");
            }
            $lines = $drivers;
        } else {
            // Get listing
            $lines = http_get_file("{$dirpath}/");
        }
    } else {
        // Customize http directories as needed
        if ($dirpath == "{$freedesk}/proto") {
            if (count($proto) == 0) {
                $proto = http_get_file($dirpath);
            }
            $lines = $proto;
        } else {
            if ($dirpath == "{$freedesk}/lib") {
                if (count($libs) == 0) {
                    $libs = http_get_file($dirpath);
                }
                $lines = $libs;
            } else {
                if ($dirpath == "{$freedesk}/app") {
                    if (count($apps) == 0) {
                        $apps = http_get_file($dirpath);
                    }
                    $lines = $apps;
                } else {
                    if ($dirpath == "{$freedesk}/font") {
                        if (count($fonts) == 0) {
                            $fonts = http_get_file($dirpath);
                        }
                        $lines = $fonts;
                    } 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;
            }
            //if ( $book_index == "exiv" ) $ver = "2-$ver";
            return $ver;
            // Return first match of regex
        }
        return 0;
        // This is an error
    }
    if ($book_index == "xterm") {
        return find_max($lines, '/xterm-\\d+.tgz$/', '/^.*xterm-(\\d+).tgz$/');
    }
    // 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.*\$/", TRUE);
    return $max;
}
コード例 #21
0
function get_packages($package, $dirpath)
{
    global $regex;
    global $book_index;
    global $url_fix;
    global $current;
    if (isset($current) && $book_index != "{$current}") {
        return 0;
    }
    if ($package == "x") {
        return 'daily';
    }
    // Daily snapshot for x264
    // 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 == "audiofile" || $package == "esound" || $package == "opal") {
            // Default ftp enties for this chapter
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 1
            exec("echo 'ls -1;bye' | ncftp {$dirpath}/", $dirs);
            $dir = find_max($dirs, "/^\\d/", "/^([\\d\\.]+).*\$/");
            $dirpath .= "/{$dir}/";
        }
        // Get listing
        exec("echo 'ls -1;bye' | ncftp {$dirpath}/", $lines);
    } else {
        if ($package == "libdvdcss" || $package == "libdvdnav" || $package == "libdvdread") {
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 1
            $lines = http_get_file($dirpath . "/");
            return find_max($lines, "/^\\d\\./", ":^(\\d[\\d\\.]+)/.*\$:", TRUE);
        }
        // Directories are in the form of mmddyy :(
        if ($package == "libmpeg3") {
            $a = array();
            $dirs = http_get_file($dirpath);
            foreach ($dirs as $d) {
                // Isolate the version and put in an array
                $slice = preg_replace("/^\\s*(\\d{2})(\\d{2})(\\d{2})\\s*\$/", "\$3\$2\$1", $d);
                if ("x{$slice}" == "x{$d}") {
                    continue;
                }
                array_push($a, $slice);
            }
            rsort($a, SORT_NATURAL);
            // Max version is at the top
            $dir = $a[0];
            $lines = http_get_file("{$dirpath}/{$dir}");
            return find_max($lines, "/libmpeg3/", "/^.*libmpeg3-(\\d[\\d\\.]+)-src.*\$/");
        }
        $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 == "faad2") {
        return find_max($lines, "/faad2-\\d/", "/^.*faad2-([\\d\\.]+).*\$/");
    }
    if ($package == "gst-plugins-bad") {
        return find_max($lines, "/^.*bad-/", "/^.*bad-(0.10[\\d\\.]+).tar.*\$/");
    }
    if ($package == "gst-plugins-ugly") {
        return find_max($lines, "/^.*ugly-/", "/^.*ugly-(0.10[\\d\\.]+).tar.*\$/");
    }
    if ($package == "gst-ffmpeg") {
        return find_even_max($lines, "/^.*ffmpeg/", "/^.*ffmpeg-([\\d\\.]+).tar.*\$/");
    }
    if (preg_match("/gst.*1/", $package)) {
        $package = preg_replace("/(.*)1/", "\$1", $package);
        return find_even_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]+).tar.*\$/");
    }
    if ($package == "gst-libav") {
        return find_even_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]+).tar.*\$/");
    }
    if ($package == "libmad") {
        return find_max($lines, "/^.*libmad-/", "/^.*libmad-([\\d\\.]+[a-m]{0,1}).tar.*\$/");
    }
    if ($package == "libmusicbrainz") {
        return find_max($lines, "/^.*libmusicbrainz-/", "/^.*libmusicbrainz-(2[\\d\\.]+).tar.*\$/");
    }
    if ($package == "libmusicbrainz1") {
        return find_max($lines, "/^.*libmusicbrainz-/", "/^.*libmusicbrainz-(3[\\d\\.]+).tar.*\$/");
    }
    // Very sensitive to upstream format that appears to be script based
    if ($package == "libvpx") {
        return find_max($lines, "/v\\d/", "/^.*sv([\\d\\.]+)v.*\$/");
    }
    if ($package == "soundtouch") {
        return find_max($lines, "/soundtouch/", "/^.*soundtouch-([\\d\\.]+).*\$/");
    }
    if ($package == "speex" || $package == "speexdsp") {
        return find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.rc]+).tar.*\$/");
    }
    if ($package == "taglib") {
        return find_max($lines, "/TagLib/", "/^.*TagLib ([\\d\\.]+).*\$/");
    }
    if ($package == "xvidcore") {
        return find_max($lines, "/xvidcore_/", "/^.*xvidcore_([\\d\\.]+).orig.*\$/");
    }
    if ($package == "libcdio-paranoia") {
        return find_max($lines, "/paranoia/", "/^.*paranoia-([\\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;
}
コード例 #22
0
ファイル: blfs-chapter09.php プロジェクト: JamesLinus/BLFS
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" || $book_index == "glibmm" || $book_index == "gmime" || $book_index == "json-glib" || $book_index == "libglade" || $book_index == "libgsf" || $book_index == "libIDL" || $book_index == "libsigc++" || $book_index == "libcroco" || $book_index == "ptlib" || $book_index == "gobject-introspection") {
            // Parent listing
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            $lines = http_get_file("{$dirpath}/");
            //if ( $book_index == "libsigc++" )
            //  $dir = find_max(      $lines, '/^[\d\.]+$/', '/^([\d\.]+)$/' );
            //else
            $dir = find_even_max($lines, '/^[\\d\\.]+$/', '/^([\\d\\.]+)$/');
            $dirpath .= "/{$dir}/";
        }
        // Get listing
        $lines = http_get_file("{$dirpath}/");
    } else {
        // glib type packages
        if ($book_index == "glib" || $book_index == "glibmm" || $book_index == "gmime" || $book_index == "json-glib" || $book_index == "libglade" || $book_index == "libgsf" || $book_index == "libIDL" || $book_index == "libsigc++" || $book_index == "libcroco" || $book_index == "ptlib" || $book_index == "gobject-introspection") {
            // 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 == "libsigc++" )
            //   $dir = find_max(      $lines1, '/^\s+[\d\.]+\/.*$/', '/^\s+([\d\.]+)\/.*$/' );
            //else
            $dir = find_even_max($lines1, '/^\\s+[\\d\\.]+\\/.*$/', '/^\\s+([\\d\\.]+)\\/.*$/');
            $dirpath .= "/{$dir}";
        }
        // Customize http directories as needed
        if ($book_index != "json-c") {
            $lines = http_get_file("{$dirpath}/");
            if (!is_array($lines)) {
                return $lines;
            }
        }
        if ($book_index == "nspr") {
            // Get the max directory and return numerical value
            $lines = http_get_file($dirpath);
            $dir = find_max($lines, "/v\\d/", "/^.*v([\\d\\.]+).*/");
            return $dir;
        }
    }
    // 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 == "boost") {
        $dir = find_max($lines, '/\\d\\.\\d\\d/', '/^\\s*([\\d\\.]+)\\s*$/');
        $lines = http_get_file("{$dirpath}/{$dir}");
        return find_max($lines, '/^.*boost_[\\d_]+.tar.*$/', '/^.*boost_([\\d_]+).tar.*$/');
    }
    if ($book_index == "enchant") {
        $dir = find_max($lines, '/^\\s*[\\d\\.]+\\/.*$/', '/^\\s*([\\d\\.]+)\\/.*$/');
        $lines = http_get_file("{$dirpath}/{$dir}");
    }
    if ($book_index == "icu4c") {
        $dir = find_max($lines, '/\\d+\\.\\d/', '/^(\\d+\\.\\d+)\\/.*$/');
        $lines = http_get_file("{$dirpath}/{$dir}");
        return find_max($lines, '/icu4c/', '/^.*icu4c-([\\d_]+)-src.*$/');
    }
    if ($book_index == "json-c") {
        exec("curl -L -s {$dirpath}", $data);
        // wget doesn't seem to work here
        $xml_parser = xml_parser_create();
        xml_parse_into_struct($xml_parser, $data[1], $values);
        $lines = array();
        foreach ($values as $v) {
            if ($v['tag'] == "KEY") {
                array_push($lines, $v['value']);
            }
        }
        return find_max($lines, '/^.*json-c.*.tar.*$/', '/^.*json-c-([\\d\\.]+).tar.*$/');
    }
    if ($book_index == "libdbusmenu-qt") {
        return find_max($lines, '/^.*libdbusmenu-qt [\\d\\.]+.*$/', '/^.*libdbusmenu-qt ([\\d\\.]+).*$/');
    }
    if ($book_index == "libsigc++") {
        return find_max($lines, '/^.*libsigc.*[\\d\\.]+.*$/', '/^.*libsigc\\+\\+-([\\d\\.]+).tar.*$/');
    }
    if ($book_index == "libusb") {
        return find_max($lines, '/^.*libusb-[\\d\\.]+.*$/', '/^.*libusb-([\\d\\.]+)$/');
    }
    if ($book_index == "libusb-compat") {
        return find_max($lines, '/^.*compat-[\\d\\.]+$/', '/^.*compat-([\\d\\.]+)$/');
    }
    if ($book_index == "libxkbcommon") {
        return find_max($lines, '/\\d\\./', '/^.*(0\\.[\\d\\.]+)\\..*$/');
    }
    if ($book_index == "libxml2") {
        return find_max($lines, '/libxml2/', '/^.*libxml2-([\\d\\.-]+).tar.*$/');
    }
    if ($book_index == "xmlts") {
        return find_max($lines, '/^.*Conformance Test Suite [\\d]+.*$/', '/^.*Conformance Test Suite ([\\d]+).*$/');
    }
    if ($book_index == "libpaper") {
        return find_max($lines, '/libpaper/', '/.*libpaper_([\\d\\.]+\\+nmu\\d).tar.*$/');
    }
    if ($book_index == "libatomic_ops") {
        return find_max($lines, '/tar/', '/.*ops-([\\d\\.]+).tar.*$/');
    }
    if ($book_index == "openobex") {
        return find_max($lines, '/\\d\\./', '/^\\s*([\\d\\.]+)\\s*$/');
    }
    if ($book_index == "qjson") {
        return find_max($lines, '/\\d\\./', '/^\\s*([\\d\\.]+)\\s*$/');
    }
    if ($book_index == "slib") {
        return find_max($lines, '/slib/', '/^.*slib-(\\d[a-z]\\d+).tar.*$/');
    }
    if ($book_index == "wv") {
        return find_max($lines, '/.*/', '/^([\\d\\.]+).*$/');
    }
    if ($book_index == "grantlee") {
        return find_max($lines, "/{$package}/", "/^.*{$package}-(0[\\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;
}
コード例 #23
0
ファイル: parsemx.php プロジェクト: MaxD2/ParseMX-Library
/**
 * Uzip ZIP file to spefied path. If it is external one, it is downloaded
 * @param $file
 * @param bool $path
 * @return bool - unzip result
 */
function unzip($file, $path = ".")
{
    $external = strpos($file, '//');
    if ($external) {
        $file = http_get_file($file);
        if (!$file) {
            return re(false);
        }
    }
    $zip = new ZipArchive();
    if ($zip->open($file) === TRUE) {
        $zip->extractTo($path);
        $zip->close();
        if ($external) {
            @unlink($file);
        }
        re(true);
        return true;
    }
    return re(false);
}
コード例 #24
0
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 == "atk" || $book_index == "atkmm" || $book_index == "at-spi2-core" || $book_index == "at-spi2-atk" || $book_index == "cogl" || $book_index == "clutter" || $book_index == "clutter-gtk" || $book_index == "gdk-pixbuf" || $book_index == "gtk+1" || $book_index == "gtk-engines" || $book_index == "libglade" || $book_index == "pango" || $book_index == "pangomm" || $book_index == "gtkmm1" || $book_index == "goffice1" || $book_index == "gtk-vnc") {
            // Parent listing
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            $dirlines = http_get_file("{$dirpath}/");
            if ($book_index == "gdk-pixbuf" || $book_index == "gtk-vnc") {
                $dir = find_max($dirlines, '/\\d$/', '/^.* ([\\d\\.]+)$/');
            } else {
                $dir = find_even_max($dirlines, '/\\d$/', '/^.* ([\\d\\.]+)$/');
            }
            $dirpath .= "/{$dir}/";
        }
        if ($book_index == "goffice" || $book_index == "gtk+" || $book_index == "gtkmm") {
            $dirpath .= "/";
        }
        if ($book_index == "libnotify" || $book_index == "libxklavier") {
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            $dirlines = http_get_file("{$dirpath}/");
            $dir = find_max($dirlines, '/\\d$/', '/^.* ([\\d\\.]+)$/');
            $dirpath .= "/{$dir}/";
        }
        if ($book_index == "firefox") {
            // Customize http directories as needed
            $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
        }
        // Get listing
        $lines = http_get_file("{$dirpath}/");
    } else {
        if ($book_index == "qt-everywhere-opensource-src") {
            // Customize http directories as needed
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 1
            $position = strrpos($dirpath, "/");
            $dirlines = http_get_file($dirpath);
            $dir = find_max($dirlines, '/^[\\d\\.]+.*$/', '/^([\\d\\.]+).*$/');
            $dirpath .= "/{$dir}";
        }
        if ($book_index == "qt-everywhere-opensource-src1") {
            // Customize http directories as needed
            $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
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 3
            $dirlines = http_get_file($dirpath);
            $dir = find_max($dirlines, '/^[\\d\\.]+.*$/', '/^([\\d\\.]+).*$/');
            $dirpath .= "/{$dir}";
            $dirlines = http_get_file("{$dirpath}");
            $dir = find_max($dirlines, '/^[\\d\\.]+.*$/', '/^([\\d\\.]+).*$/');
            $dirpath .= "/{$dir}/single";
        }
        if ($book_index == "fltk") {
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 1
        }
        $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 == "goffice1") {
        $package = "goffice";
    }
    if ($book_index == "gtk+" || $book_index == "gtk+1") {
        return find_max($lines, '/gtk/', '/^.*gtk.-([\\d\\.]*\\d)\\.tar.*$/');
    }
    if ($book_index == "gtkmm1") {
        $package = "gtkmm";
    }
    if ($book_index == "imlib2") {
        return find_max($lines, '/\\d\\.[\\d\\.]+\\d/', '/^.* (\\d\\.[\\d\\.]+\\d).*$/');
    }
    if ($book_index == "webkitgtk") {
        return find_even_max($lines, '/webkitgtk-2.4/', '/^.*-(\\d[\\d\\.]+\\d).tar.*$/');
    }
    if ($book_index == "webkitgtk1") {
        return find_even_max($lines, '/webkitgtk/', '/^.*webkitgtk-(\\d[\\d\\.]+\\d).tar.*$/');
    }
    if ($book_index == "cairo" || $book_index == "cairomm") {
        return find_even_max($lines, "/{$package}/", "/^{$package}-(\\d[\\d\\.]+\\d).tar.*\$/");
    }
    if ($book_index == "firefox") {
        return find_max($lines, "/^\\d/", "/^(\\d{2}.\\d+)\$/");
    }
    if ($book_index == "qt-everywhere-opensource-src1") {
        return find_max($lines, "/src.*tar.xz/", "/^.*src-([\\d\\.]+).tar.*\$/");
    }
    if ($book_index == "fltk") {
        return find_max($lines, "/1\\./", "/^\\s+(1\\.[\\d\\.]+).*\$/");
    }
    // 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;
}
コード例 #25
0
function get_packages($package, $dirpath)
{
    global $exceptions;
    global $regex;
    global $book_index;
    global $url_fix;
    global $current;
    if (isset($current) && $book_index != "{$current}") {
        return 0;
    }
    if ($book_index == "mplayer") {
        return "daily";
    }
    // 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 == "cdparanoia-III") {
        return find_max($lines, "/^.*cdparanoia-III-/", "/^.*cdparanoia-III-([\\d\\.]+).src.tgz.*\$/");
    }
    if ($package == "amarok") {
        return find_max($lines, "/\\d\\./", "/^.*;([\\d\\.]+)\\/.*\$/");
    }
    if ($package == "xine-ui") {
        return find_max($lines, "/\\d\\./", "/^\\s*([\\d\\.]+)\$/");
    }
    if ($package == "dvd+rw-tools") {
        return find_max($lines, "/dvd\\+/", "/^.*dvd\\+rw-tools-([\\d\\.]+).tar.*\$/");
    }
    if ($package == "vlc") {
        return find_max($lines, "/\\d\\.[\\d\\.]+\\//", "/^([\\d\\.]+)\\/.*\$/");
    }
    // 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;
}
コード例 #26
0
ファイル: blfs-chapter34.php プロジェクト: JamesLinus/BLFS
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)) {
        // All ftp enties for this chapter N/A for this chapter
    } else {
        if ($book_index != "midori_" && $book_index != "lxmenu-data" && $book_index != "menu-cache" && $book_index != "pcmanfm" && $book_index != "libfm" && $book_index != "libfm1" && $book_index != "lxpanel" && $book_index != "lxappearance" && $book_index != "lxpolkit" && $book_index != "lxsession" && $book_index != "lxde-common" && $book_index != "gpicview" && $book_index != "lxinput" && $book_index != "lxrandr" && $book_index != "lxshortcut" && $book_index != "lxtask" && $book_index != "lxterminal" && $book_index != "lxappearance-obconf" && $book_index != "lxde-icon-theme") {
            // Most http enties for this chapter
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 1
            $dirs = http_get_file("{$dirpath}/");
            if (preg_match("/xf/", $package)) {
                $dir = find_even_max($dirs, "/^\\d/", "/^([\\d\\.]+)\\/.*\$/");
            } else {
                $dir = find_max($dirs, "/^\\d/", "/^([\\d\\.]+)\\/.*\$/");
            }
            $dirpath .= "/{$dir}";
            $lines = http_get_file("{$dirpath}/");
            if (!is_array($lines)) {
                return $lines;
            }
        } else {
            if ($book_index == "menu-cache") {
                $lines1 = http_get_file("{$dirpath}");
                $dir = find_max($lines1, "/ 1\\./", "/^.* (1[\\d\\.]+).*\$/");
                $dirpath .= "/{$dir}";
            }
            if ($book_index == "lxsession") {
                $lines1 = http_get_file("{$dirpath}");
                $dir = find_max($lines1, "/LXSession \\d/", "/^.*(LXSession [\\d\\.x]+).*\$/");
                $d = preg_replace("/ /", "%20", $dir);
                // Fix embedded blank
                $dirpath .= "/{$d}";
            }
            if ($book_index == "lxde-common") {
                $lines1 = http_get_file("{$dirpath}");
                $dir = find_max($lines1, "/LXDE[ -]Common/i", "/^.*(LX.* [\\d\\.x]+).*\$/i");
                $d = preg_replace("/ /", "%20", $dir);
                // Fix embedded blank
                $dirpath .= "/{$d}";
            }
            if ($book_index == "lxinput") {
                $lines1 = http_get_file("{$dirpath}");
                $dir = find_max($lines1, "/LXInput/i", "/^.*(LX.* [\\d\\.x]+).*\$/i");
                $d = preg_replace("/ /", "%20", $dir);
                // Fix embedded blank
                $dirpath .= "/{$d}";
            }
            if ($book_index == "gpicview") {
                $lines1 = http_get_file("{$dirpath}");
                $dir = find_max($lines1, "/GpicView \\d/i", "/^.*(Gpic.* [\\d\\.]+).*\$/i");
                $d = preg_replace("/ /", "%20", $dir);
                // Fix embedded blank
                $dirpath .= "/{$d}";
            }
            if ($book_index == "lxrandr") {
                $lines1 = http_get_file("{$dirpath}");
                $dir = find_max($lines1, "/LXRandR \\d/i", "/^.*(LX.* [\\d\\.x]+).*\$/i");
                $d = preg_replace("/ /", "%20", $dir);
                // Fix embedded blank
                $dirpath .= "/{$d}";
            }
            if ($book_index == "lxshortcut") {
                $lines1 = http_get_file("{$dirpath}");
                $dir = find_max($lines1, "/LXShortcut \\d/i", "/^.*(LX.* [\\d\\.]+).*\$/i");
                $d = preg_replace("/ /", "%20", $dir);
                // Fix embedded blank
                $dirpath .= "/{$d}";
            }
            if ($book_index == "lxtask") {
                $lines1 = http_get_file("{$dirpath}");
                $dir = find_max($lines1, "/LXTask \\d/i", "/^.*(LX.* [\\d\\.x]+).*\$/i");
                $d = preg_replace("/ /", "%20", $dir);
                // Fix embedded blank
                $dirpath .= "/{$d}";
            }
            if ($book_index == "lxterminal") {
                $lines1 = http_get_file("{$dirpath}");
                $dir = find_max($lines1, "/LXTerminal \\d/i", "/^.*(LX.* [\\d\\.]+).*\$/i");
                $d = preg_replace("/ /", "%20", $dir);
                // Fix embedded blank
                $dirpath .= "/{$d}";
            }
            if ($book_index == "lxpanel") {
                $lines1 = http_get_file("{$dirpath}");
                $dir = find_max($lines1, "/LXPanel 0/", "/^.*(LXPanel [\\d\\.x]+).*\$/");
                $d = preg_replace("/ /", "%20", $dir);
                // Fix embedded blank
                $dirpath .= "/{$d}";
            }
            $lines = http_get_file("{$dirpath}");
        }
    }
    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 == "lxmenu-data") {
        $ver = find_max($lines, "/{$package}/", "/^.*{$package} ([\\d\\.]*\\d).*\$/");
        return $ver;
    }
    if ($book_index == "lxde-icon-theme") {
        return find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]*\\d).*\$/");
    }
    // Most packages are in the form $package-n.n.n
    // Occasionally there are dashes (e.g. 201-1)
    return find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]*\\d)\\.tar.*\$/");
}
コード例 #27
0
function get_packages($package, $dirpath)
{
    global $regex;
    global $book_index;
    global $url_fix;
    global $current;
    if (isset($current) && $book_index != "{$current}") {
        return 0;
    }
    // These are constant - have not changed in 10 years
    if ($package == "docbk") {
        return "31";
    }
    if ($package == "docbook") {
        return "4.5";
    }
    if ($package == "openjade") {
        return "1.3.2";
    }
    if ($package == "docbook-dsssl") {
        return "1.79";
    }
    if ($package == "docbook-dsssl-doc") {
        return "1.79";
    }
    // 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 == "texlive") {
            $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, "/20\\d\\d/", "/^.*(20\\d\\d).*\$/");
            $lines = http_get_file("{$dirpath}/{$dir}/");
            $ver = find_max($lines, "/texlive-/", "/^.*texlive-(\\d+).*\$/");
            return $ver == "0" ? "pending" : $ver;
        }
        // Get listing
        $lines = http_get_file("{$dirpath}/");
    } else {
        if ($book_index == "gnu-gs-fonts-other") {
            $dirs = http_get_file($dirpath);
            $dir = find_max($dirs, "/misc.*GPL/", "/^\\s*([\\d\\.]+.*)\$/");
            $dir = preg_replace("/ /", '%20', $dir);
            $dir = preg_replace("/\\(/", '%28', $dir);
            $dir = preg_replace("/\\)/", '%29', $dir);
            $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;
            }
            return $ver;
            // Return first match of regex
        }
        return 0;
        // This is an error
    }
    if ($package == "cups") {
        return find_max($lines, "/^.*cups-/", "/^.*cups-([\\d\\.]+)-source.*\$/");
    }
    if ($package == "sgml-common") {
        return find_max($lines, "/sgml-common/", "/^.*sgml-common-([\\d\\.]+).tgz.*\$/");
    }
    if ($package == "docbook-xml") {
        return find_max($lines, "/4\\.\\d/", "/^.*(4\\.\\d),.*\$/");
    }
    if ($package == "docbook-xsl") {
        return find_max($lines, "/\\.\\d+/", "/^\\s*([\\d\\.]+)\$/");
    }
    if ($package == "psutils") {
        return find_max($lines, "/{$package}/", "/^.*{$package}-(p[\\d\\.]+).tar.*\$/");
    }
    if ($package == "fop") {
        return find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]+)-src.tar.*\$/");
    }
    if ($package == "texlive") {
        return find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]+)-source.tar.*\$/");
    }
    if ($package == "mupdf") {
        return find_max($lines, "/mupdf/", "/^.*{$package}-([\\d\\.]+)-source.tar.*\$/");
    }
    if ($package == "biblatex-biber") {
        return find_max($lines, "/{$package}/", "/^.*{$package}-([\\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;
}
コード例 #28
0
ファイル: blfs-chapter12.php プロジェクト: JamesLinus/BLFS
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 == "gtk-doc") {
            // 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}";
        }
        // babl and similar
        if ($book_index == "rarian") {
            // 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[\\d\\.]+)/");
            $dirpath .= "/{$dir}";
        }
        // Get listing
        $lines = http_get_file("{$dirpath}/");
    } else {
        // Customize http directories as needed
        $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 == "apache-ant") {
        return find_max($lines, '/apache-ant/', '/^.*apache-ant-([\\d\\.]+)-src.tar.*$/');
    }
    if ($book_index == "at") {
        return find_max($lines, '/orig/', '/^.*at_([\\d\\.]+).orig.tar.*$/');
    }
    if ($book_index == "dbus") {
        return find_even_max($lines, '/dbus/', '/^.*dbus-(\\d[\\d\\.]*\\d).tar.*$/');
    }
    if ($book_index == "colord") {
        return find_even_max($lines, '/colord/', '/^.*colord-(\\d[\\d\\.]*\\d).tar.*$/');
    }
    if ($book_index == "fcron") {
        return find_max($lines, '/fcron/', '/^.*fcron-(\\d[\\d\\.]*\\d).src.tar.*$/');
    }
    if ($book_index == "raptor2") {
        return find_max($lines, '/raptor/', '/^.*raptor2-([\\d\\.]*\\d).tar.*$/');
    }
    if ($book_index == "heirloom") {
        return find_max($lines, '/\\d{6}/', '/^.*(\\d{6})\\h*$/');
    }
    if ($book_index == "udisks1") {
        return find_max($lines, '/udisks/', '/^.*udisks-(\\d[\\d\\.]*\\d).tar.*$/');
    }
    if ($book_index == "p7zip") {
        return find_max($lines, '/\\d\\./', '/^\\s*([\\d\\.]+)\\s*$/');
    }
    if ($book_index == "unzip" || $book_index == "zip") {
        return find_max($lines, "/{$book_index}/", "/^.* {$book_index}(\\d\\d).tgz.*\$/");
    }
    // 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.*\$/", TRUE);
    return $max;
}
コード例 #29
0
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;
    }
    # ftp.kde.org seems to be down
    if (preg_match("/ftp:..ftp.kde.org/", $dirpath)) {
        $dirpath = preg_replace("/ftp:..ftp.kde.org.pub.kde/", "http://download.kde.org", $dirpath);
    }
    // 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 == "automoc4") {
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 1
        }
        if ($book_index == "kactivities") {
            return "check manually";
        }
        if ($book_index == "phonon-backend-vlc" || $book_index == "phonon" || $book_index == "phonon-backend-gstreamer") {
            $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 .= "/$book_index";
        }
        // Get listing
        $lines = http_get_file("{$dirpath}/");
    } else {
        if ($book_index == "kfilemetadata") {
            return "check manually";
        }
        if (preg_match('/baloo/', $book_index)) {
            return "check manually";
        }
        # Copy from ftp above for now
        if ($book_index == "automoc4") {
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 1
            $lines = http_get_file("{$dirpath}");
            return find_max($lines, "/\\d\\./", "/^.*;([\\d\\.]+)\\/.*\$/");
        }
        if ($book_index == "akonadi" || $book_index == "qimageblitz" || $book_index == "polkit-qt-1" || $book_index == "polkit-kde-agent-1" || $book_index == "attica") {
            $lines = http_get_file("{$dirpath}");
            return find_max($lines, "/{$book_index}/", "/^.*{$book_index}-([\\d\\.]+).tar.*\$/");
        }
        if ($book_index == "kactivities") {
            return "check manually";
        }
        if ($book_index == "phonon-backend-vlc" || $book_index == "phonon" || $book_index == "phonon-backend-gstreamer") {
            $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
            $lines = http_get_file("{$dirpath}");
            return find_max($lines, "/\\d\\./", "/^.*;([\\d\\.]+)\\/.*\$/");
        }
        if (!is_array($kde_lines)) {
            // All http for kde
            /*
            $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 = "http://download.kde.org/stable/applications/";
            $lines = http_get_file($dirpath);
            $kde_ver = find_max($lines, "/1\\d\\./", "/^.*;(1[\\d\\.]+\\d)\\/.*\$/");
            $kde_lines = http_get_file("{$dirpath}{$kde_ver}/src/");
        }
        return find_max($kde_lines, "/{$package}/", "/^.*{$package}-([\\d\\.]*\\d)\\.tar.*\$/");
        //if ( ! is_array( $lines ) ) return $lines;
    }
    // End fetch
    // automoc4 and similar
    if ($book_index == "automoc4" || $book_index == "phonon" || $book_index == "phonon-backend-gstreamer" || $book_index == "phonon-backend-vlc") {
        return find_max($lines, "/\\d\\./", "/^.* (\\d\\.[\\d\\.]+).*\$/");
    }
    // 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;
}
コード例 #30
0
ファイル: blfs-chapter31.php プロジェクト: JamesLinus/BLFS
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 == 'network-manager-applet') {
            $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\\.]+)\$/");
            // Not even
            $dirpath .= "/{$dir}/";
        } else {
            // All other ftp enties for this chapter
            $dirpath = rtrim($dirpath, "/");
            // Trim any trailing slash
            $position = strrpos($dirpath, "/");
            $dirpath = substr($dirpath, 0, $position);
            // Up 1
            $dirs = http_get_file("{$dirpath}/");
            $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
    }
    // 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;
}