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; }
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; }
function get_packages($package, $dirpath) { global $regex; global $book_index; global $url_fix; global $current; global $previous; 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 == "pygobject1" || $book_index == "pygobject" || $book_index == "pygtk" || $book_index == "pyatspi") { // 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 == "pygobject") { $dir = find_even_max($lines, '/^2[\\d\\.]+$/', '/^(2[\\d\\.]+)$/'); } else { $dir = find_even_max($lines, '/^[\\d\\.]+$/', '/^([\\d\\.]+)$/'); } $dirpath .= "/{$dir}/"; } // gcc and similar if ($book_index == "gcc") { // 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}/"); return find_max($lines, "/gcc-\\d/", "/^.*gcc-(\\d[\\d\\.]+).*\$/"); } // slang if ($book_index == "slang") { // Get the max directory and adjust the directory path $dirpath = rtrim($dirpath, "/"); // Trim any trailing slash $position = strrpos($dirpath, "/"); $dirpath = substr($dirpath, 0, $position) . "/latest"; } if ($book_index == "vala") { // 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_even_max($lines, "/\\d[\\d\\.]+/", "/^(\\d[\\d\\.]+).*/"); $dirpath .= "/{$dir}/"; } if ($book_index == "cvs") { // Get the max directory $dirpath = rtrim($dirpath, "/"); // Trim any trailing slash $position = strrpos($dirpath, "/"); $dirpath = substr($dirpath, 0, $position); $lines = http_get_file("{$dirpath}/"); return find_max($lines, "/\\d\\.[\\d\\.]+/", "/^.* (\\d\\.[\\d\\.]+)\$/"); } // Get listing $lines = http_get_file("{$dirpath}/"); } else { // glib type packages if ($book_index == "pygobject1" || $book_index == "pygobject" || $book_index == "pygtk" || $book_index == "pyatspi") { // 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 == "pygobject") { $dir = find_even_max($lines1, '/^\\s+2[\\d\\.]+.*$/', '/^\\s+(2[\\d\\.]+).*$/'); } else { $dir = find_even_max($lines1, '/^\\s+[\\d\\.]+.*$/', '/^\\s+([\\d\\.]+).*$/'); } $dirpath .= "/{$dir}/"; } // Customize http directories as needed if ($book_index == "cmake") { $dirpath = max_parent($dirpath, 'v'); $prev = $previous; // Special if there is no current version in $dirpath $lines = http_get_file($dirpath); $max = find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]*\\d)\\.tar.*\$/"); if ($max != 0) { return $max; } $position = strrpos($dirpath, "/"); $dirpath = substr($dirpath, 0, $position) . "/{$prev}"; } if ($package == "npapi-sdk") { # We have to process the stupid javascript to get this to work exec("lynx -dump {$dirpath}", $output); $max = find_max($output, "/npapi-sdk/", "/^.*npapi-sdk-([\\d\\.]*\\d)\\.tar.*\$/"); return $max; } $strip = "yes"; $lines = http_get_file($dirpath, $strip); 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 && !preg_match('/^\\d\\.[\\d\\.]+$/', $ver)) { continue; } if ($book_index == "exiv") { $ver = "2-{$ver}"; } return $ver; // Return first match of regex } return 0; // This is an error } if ($book_index == "doxygen") { return find_max($lines, '/doxygen/', '/^.*doxygen-([\\d\\.]+).src.tar.*$/'); } if ($book_index == "llvm") { return find_max($lines, "/^.*{$book_index}-.*.src.*\$/", "/^.*{$book_index}-([\\d\\.]+)\\.src.*\$/"); } if ($book_index == "elfutils") { return find_max($lines, "/^\\s*\\d[\\d\\.]+\\/.*\$/", "/^\\s*(\\d[\\d\\.]+)\\/.*\$/"); } if ($book_index == "nasm") { return find_max($lines, '/^\\d/', '/^(\\d[\\d\\.]+\\d)\\/.*$/'); } # if ( $book_index == "python" || $book_index == "python1" ) // python docs # { # return find_max( $lines, "/python-\d/", # "/^python-(\d[\d\.]*\d)-docs.*$/" ); # } if ($book_index == "cmake") { $max = find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]*\\d)\\.tar.*\$/"); if ($max == 0) { $max = find_max($lines, "/{$package}/", "/^.*{$package}-(\\d[\\d\\.]*\\d-rc\\d).*\$/"); } return $max != 0 ? $max : "pending"; } if ($book_index == "pygobject1" || $book_index == "pygobject ") { $package = "pygobject"; } if ($book_index == "librep") { return find_max($lines, "/librep/", "/^.*[_-](\\d[\\d\\.]*\\d)\\.tar.*\$/"); } if ($book_index == "apache-ant") { return find_max($lines, "/{$package}/", "/^.*{$package}-(\\d[\\d\\.]+\\d)-src.*\$/"); } if ($book_index == "tk") { $dir = find_max($lines, '/\\d\\.[\\d\\.]+\\d/', '/^\\s+(\\d\\.[\\d\\.]+\\d).*$/'); $lines = http_get_file("{$dirpath}/{$dir}"); return find_max($lines, "/{$package}/", "/^.*{$package}([\\d\\.]*\\d)-src.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; }
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; }
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; }
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; }
?> </tbody> </table> @endif <script type="text/javascript"> function tal(event){ //DIRECT HIRE PRODUCTION | SALES Monthly <?php foreach ($users as $user) { $maxpointDaily = find_max(max($pointDaily[$user->cont])); $maxpointMonthly = find_max(max($pointMonthly[$user->cont])); $maxdirectHire = find_max(max($directHire[$user->cont])); $maxdirectHireAnnual = find_max(max($directHireAnnual[$user->cont])); $maxtempGMP = find_max(max($gmp[$user->cont])); $maxgmpAnnual = find_max(max($gmpAnnual[$user->cont])); ?> var pointDaily = '#pointDaily' +<?php echo $user->id; ?> ; var pointMonthly = '#pointMonthly' +<?php echo $user->id; ?> ; var directHire = '#directHire' +<?php echo $user->id; ?> ; var directHireAnnual = '#directHireAnnual' +<?php echo $user->id;
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; }
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; }
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; }
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; }
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; }
function get_packages($package, $dirpath) { global $exceptions; global $regex; global $book_index; // Check for ftp if (preg_match("/^ftp/", $dirpath)) { $dirpath = substr($dirpath, 6); // Remove ftp:// $dirpath = rtrim($dirpath, "/"); // Trim any trailing slash $position = strpos($dirpath, "/"); // Divide at first slash $server = substr($dirpath, 0, $position); $path = substr($dirpath, $position); //echo "server=$server path=$path\n"; $conn = ftp_connect($server); if (!isset($conn)) { //echo "No connection\n"; return -7; } if (!ftp_login($conn, "anonymous", "")) { //echo "anonymous ftp login failed\n"; return -8; } // See if we need special handling if (isset($exceptions[$package])) { $specials = explode(":", $exceptions[$package]); foreach ($specials as $i) { list($op, $regexp) = explode("=", $i); switch ($op) { case "UPDIR": // Remove last dir from $path $position = strrpos($path, "/"); $path = substr($path, 0, $position); // Get dir listing $lines = ftp_rawlist($conn, $path); $max = find_max($lines, $regexp, $regexp); break; case "DOWNDIR": // Append found directory $path .= "/{$max}"; break; default: echo "Error in specials array for {$package}\n"; return 0; break; } } } //echo "start ftp_rawlist path=$path\n"; $lines = ftp_rawlist($conn, $path); //print_r($lines); ftp_close($conn); } 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); //print_r( $lines ); $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 == "krb") { // 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); //print_r( $lines ); if (!is_array($lines)) { return $lines; } } // End fetch if (isset($regex[$package])) { // Custom search for latest package name //print_r($lines); foreach ($lines as $l) { $ver = preg_replace($regex[$package], "\$1", $l); if ($ver == $l) { continue; } echo "ver={$ver} l={$l}\n"; if ($package == 'krb') { $ver = "5-{$ver}"; } return $ver; // Return first match of regex } return 0; // This is an error } /* if ( $package == "perl" ) // Custom for perl { $tmp = array(); foreach ( $lines as $l ) { if ( preg_match( "/sperl/", $l ) ) continue; // Don't want this $ver = preg_replace( "/^.*perl-([\d\.]+\d)\.tar.*$/", "$1", $l ); if ( $ver == $l ) continue; list( $s1, $s2, $rest ) = explode( ".", $ver ); if ( $s2 % 2 == 1 ) continue; // Remove odd minor versions array_push( $tmp, $l ); } $lines = $tmp; } */ // gnupg-1 if ($book_index == "gnupg") { return find_max($lines, "/{$package}-1/", "/^.*{$package}-([\\d\\.]*\\d)\\.tar.*\$/"); } // Use std for gnupg-2 if ($book_index == "gnupg1") { $package == "gnupg"; } if ($package == "acl" || $package == "attr") { return find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.-]*\\d)\\.src.tar.*\$/"); } if ($package == "libcap") { return find_max($lines, "/{$package}2_/", "/^.*{$package}(2_[\\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_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; }
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 $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 == "libwnck" || $book_index == "gtksourceview") { $dir = find_even_max($dirs, "/ 2\\./", "/^.* (2[\\d\\.]+)\$/"); } else { if ($book_index == "vte") { $dir = "0.28"; } else { if ($book_index == "libunique") { $dir = "1.1"; } else { $dir = find_even_max($dirs, "/^\\d/", "/^([\\d\\.]+).*\$/"); } } } $dirpath .= "/{$dir}/"; // Get listing $lines = http_get_file("{$dirpath}/"); } else { if ($book_index != "midori" && $book_index != "xfce4-xkb-plugin") { // 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) && $book_index != "xfburn") { $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 == "midori") { exec("curl -L -s -m30 {$dirpath}", $lines); } else { $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 == "lxpanel") { $ver = find_max($lines, "/LXPanel/", "/^.*LXPanel ([\\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.*\$/"); }
// find the max defference value of the tow item, the A's index < B's index // e.g. $a -> 99 - 1 = 98; $a = [1, 4, 2, 16, 99, 3, 11, 1]; function find_max($a) { $len = count($a); if ($len < 2) { return false; } $max_d = $a[1] - $a[0]; $i = 0; while ($i < $len - 1) { for ($j = $i; $j < $len - 1; $j++) { if ($a[$j] >= $a[$j + 1]) { $i = $j; break; } } for ($j = $i; $j < $len; $j++) { $delta = $a[$i] - $a[$j]; if ($delta > $max_d) { $max_d = $delta; } } $i += 1; } return $max_d; } echo find_max($a);
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.*\$/"); }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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}"; }
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; }
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; }
function get_packages($package, $dirpath) { global $exceptions; global $regex; if ($package == "vim") { $dirpath = "http://mirrors-usa.go-parts.com/pub/vim/unix"; } // Check for ftp if (preg_match("/^ftp/", $dirpath)) { $dirpath = substr($dirpath, 6); // Remove ftp:// $dirpath = rtrim($dirpath, "/"); // Trim any trailing slash $position = strpos($dirpath, "/"); // Divide at first slash $server = substr($dirpath, 0, $position); $path = substr($dirpath, $position); $conn = ftp_connect($server); ftp_login($conn, "anonymous", ""); // See if we need special handling if (isset($exceptions[$package])) { $specials = explode(":", $exceptions[$package]); foreach ($specials as $i) { list($op, $regexp) = explode("=", $i); switch ($op) { case "UPDIR": // Remove last dir from $path $position = strrpos($path, "/"); $path = substr($path, 0, $position); // Get dir listing $lines = ftp_rawlist($conn, $path); $max = find_max($lines, $regexp, $regexp); break; case "DOWNDIR": // Append found directory $path .= "/{$max}"; break; default: echo "Error in specials array for {$package}\n"; return -5; break; } } } $lines = ftp_rawlist($conn, $path); ftp_close($conn); } else { // Customize http directories as needed if ($package == "tzdata") { // Remove two directories $dirpath = rtrim($dirpath, "/"); // Trim any trailing slash $position = strrpos($dirpath, "/"); $dirpath = substr($dirpath, 0, $position); $position = strrpos($dirpath, "/"); $dirpath = substr($dirpath, 0, $position); //echo "$dirpath\n"; } if ($package == "mpc") { $dirpath = "http://www.multiprecision.org/index.php?prog=mpc&page=download"; } if ($package == "bzip2") { // Remove one directory $dirpath = rtrim($dirpath, "/"); // Trim any trailing slash $position = strrpos($dirpath, "/"); $dirpath = substr($dirpath, 0, $position); //echo "$dirpath\n"; } if ($package == "mpfr") { $dirpath = "http://mpfr.loria.fr/mpfr-current"; } if ($package == "expat") { $dirpath = "http://sourceforge.net/projects/expat/files"; } if ($package == "intltool") { $dirpath = "https://launchpad.net/intltool/trunk"; } if ($package == "procps-ng") { $dirpath = "http://sourceforge.net/projects/procps-ng/files"; } if ($package == "e2fsprogs") { $dirpath = "http://sourceforge.net/projects/e2fsprogs/files/e2fsprogs"; } if ($package == "expect" || $package == "flex" || $package == "psmisc") { $dirpath = "http://sourceforge.net/projects/{$package}/files"; } if ($package == "tcl-core") { $dirpath = "http://sourceforge.net/projects/tcl/files"; } if ($package == "gcc") { $dirpath = max_parent($dirpath, "gcc-"); } if ($package == "util-linux") { $dirpath = max_parent($dirpath, "v."); } $lines = http_get_file($dirpath); if (!is_array($lines)) { return -6; } } // 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; } return $ver; // Return first match of regex } return -7; // This is an error } if ($package == "shadow") { return find_max($lines, "/shadow-/", "/^.*shadow-([\\d\\.]*\\d).*\$/"); } if ($package == "perl") { $tmp = array(); foreach ($lines as $l) { if (preg_match("/sperl/", $l)) { continue; } // Don't want this $ver = preg_replace("/^.*perl-([\\d\\.]+\\d)\\.tar.*\$/", "\$1", $l); if ($ver == $l) { continue; } list($s1, $s2, $rest) = explode(".", $ver); if ($s2 % 2 == 1) { continue; } // Remove odd minor versions array_push($tmp, $l); } $lines = $tmp; } if ($package == "attr" || $package == "acl") { return find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.-]*\\d)\\.src.*\$/"); } if ($package == "e2fsprogs") { return find_max($lines, "/v\\d/", "/^.*v(\\d[\\d\\.]+\\d).*\$/"); } if ($package == "XML-Parser") { return find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\._]*\\d).tar.*\$/"); } if ($package == "gmp") { return find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\._]*\\d[a-z]?).tar.*\$/"); } if ($package == "grub") { return find_max($lines, "/grub/", "/^.*grub-(\\d\\..*).tar.xz.*\$/"); } // 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.*\$/"); }