本文整理汇总了PHP中find_max函数的典型用法代码示例。如果您正苦于以下问题:PHP find_max函数的具体用法?PHP find_max怎么用?PHP find_max使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了find_max函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_packages
function get_packages($package, $dirpath)
{
global $regex;
global $book_index;
global $url_fix;
global $current;
if (isset($current) && $book_index != "{$current}") {
return 0;
}
// Fix up directory path
foreach ($url_fix as $u) {
$replace = $u['replace'];
$match = $u['match'];
if (isset($u['pkg'])) {
if ($package == $u['pkg']) {
$dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
break;
}
} else {
if (preg_match("/{$match}/", $dirpath)) {
$dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
break;
}
}
}
// Check for ftp
if (preg_match("/^ftp/", $dirpath)) {
// Get listing
$lines = http_get_file("{$dirpath}/");
} else {
$lines = http_get_file($dirpath);
if (!is_array($lines)) {
return $lines;
}
}
// End fetch
if (isset($regex[$package])) {
// Custom search for latest package name
foreach ($lines as $l) {
if (preg_match('/^\\h*$/', $l)) {
continue;
}
$ver = preg_replace($regex[$package], "\$1", $l);
if ($ver == $l) {
continue;
}
return $ver;
// Return first match of regex
}
return 0;
// This is an error
}
if ($package == 'sawfish') {
return find_max($lines, "/sawfish/", "/^.*sawfish_([\\d\\.]*\\d)\\.tar.*\$/");
}
// Most packages are in the form $package-n.n.n
// Occasionally there are dashes (e.g. 201-1)
$max = find_max($lines, "/{$package}/", "/^.*{$package}-?([\\d\\.]*\\d)\\.tar.*\$/");
return $max;
}
示例2: get_packages
function get_packages($package, $dirpath)
{
global $regex;
global $book_index;
global $url_fix;
global $current;
global $kde_ver;
global $kde_lines;
if (isset($current) && $book_index != "{$current}") {
return 0;
}
// Fix up directory path
foreach ($url_fix as $u) {
$replace = $u['replace'];
$match = $u['match'];
if (isset($u['pkg'])) {
if ($package == $u['pkg']) {
$dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
break;
}
} else {
if (preg_match("/{$match}/", $dirpath)) {
$dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
break;
}
}
}
// Check for ftp
if (preg_match("/^ftp/", $dirpath)) {
// No ftp for kde apps
// Get listing
$lines = http_get_file("{$dirpath}/");
} else {
if ($package == "konsole" || $package == "kdeplasma-addons" || $package == "kate" || $package == "gwenview") {
return "check manually";
}
if (!is_array($kde_lines)) {
$dirpath = "http://download.kde.org/stable/applications/";
$lines = http_get_file($dirpath);
$kde_ver = find_max($lines, "/4\\./", "/^.*;(1[\\d\\.]+\\d)\\/.*\$/");
$kde_lines = http_get_file("{$dirpath}/{$kde_ver}/src");
}
if (!is_array($kde_lines)) {
return $lines;
}
return find_max($kde_lines, "/{$package}/", "/^.*{$package}-([\\d\\.]*\\d)\\.tar.*\$/");
}
// End fetch
// Most packages are in the form $package-n.n.n
// Occasionally there are dashes (e.g. 201-1)
$max = find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]*\\d)\\.tar.*\$/");
return $max;
}
示例3: get_packages
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") {
//.........这里部分代码省略.........
示例4: get_packages
function get_packages($package, $dirpath)
{
global $regex;
global $book_index;
global $url_fix;
global $current;
if (isset($current) && $book_index != "{$current}") {
return 0;
}
// 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\\.]+)\$/");
}
//.........这里部分代码省略.........
示例5: get_packages
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;
}
示例6: get_packages
function get_packages($package, $dirpath)
{
global $regex;
global $book_index;
global $url_fix;
global $current;
if (isset($current) && $book_index != "{$current}") {
return 0;
}
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.*\$/");
}
//.........这里部分代码省略.........
示例7: tal
?>
</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;
示例8: get_packages
function get_packages($package, $dirpath)
{
global $regex;
global $book_index;
global $url_fix;
global $current;
if (isset($current) && $book_index != "{$current}") {
return 0;
}
// Fix up directory path
foreach ($url_fix as $u) {
$replace = $u['replace'];
$match = $u['match'];
if (isset($u['pkg'])) {
if ($package == $u['pkg']) {
$dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
break;
}
} else {
if (preg_match("/{$match}/", $dirpath)) {
$dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
break;
}
}
}
// Check for ftp
if (preg_match("/^ftp/", $dirpath)) {
if ($package == '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;
}
示例9: get_packages
function get_packages($package, $dirpath)
{
global $regex;
global $book_index;
global $url_fix;
global $current;
global $libreoffice;
if (isset($current) && $book_index != "{$current}") {
return 0;
}
// Fix up directory path
foreach ($url_fix as $u) {
$replace = $u['replace'];
$match = $u['match'];
if (isset($u['pkg'])) {
if ($package == $u['pkg']) {
$dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
break;
}
} else {
if (preg_match("/{$match}/", $dirpath)) {
$dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
break;
}
}
}
// Check for ftp
if (preg_match("/^ftp/", $dirpath)) {
if ($package == "seamonkey" || $package == "firefox" || $package == "thunderbird") {
$dirpath = rtrim($dirpath, "/");
// Trim any trailing slash
$position = strrpos($dirpath, "/");
$dirpath = substr($dirpath, 0, $position);
// Up 1
$position = strrpos($dirpath, "/");
$dirpath = substr($dirpath, 0, $position);
// Up 2
$dirpath .= "/";
$dirs = http_get_file($dirpath);
if ($package == "seamonkey") {
return find_max($dirs, "/\\d\\./", "/^.* (\\d\\.[\\.\\d]+)\$/");
} else {
return find_max($dirs, "/\\d\\./", "/^.*(\\d{2}[\\.\\d]+)\$/");
}
}
// Get listing
$lines = http_get_file("{$dirpath}/");
} else {
if (preg_match("/abiword/", $dirpath)) {
$dirpath = rtrim($dirpath, "/");
// Trim any trailing slash
$position = strrpos($dirpath, "/");
$dirpath = substr($dirpath, 0, $position);
// Up 1
$position = strrpos($dirpath, "/");
$dirpath = substr($dirpath, 0, $position);
// Up 2
}
if ($book_index == "gnucash-docs") {
$dirs = http_get_file($dirpath);
$dir = find_max($dirs, "/^\\s+\\d\\./", "/^\\s+(\\d\\.[\\d\\.]+)\$/");
$dirpath .= "/{$dir}/";
}
if ($book_index == "xchat") {
$dirs = http_get_file($dirpath);
$dir = find_max($dirs, "/^\\s*\\d\\./", ":^\\s*(\\d\\.[\\d\\.]+)/.*\$:");
$dirpath .= "/{$dir}/";
}
if (preg_match("/^libre/", "{$package}")) {
if (count($libreoffice) == 0) {
$dirs = http_get_file($dirpath);
$dir = find_max($dirs, "/\\d\\./", "/^.*;([\\d\\.]+)\\/.*\$/");
$dirpath = "http://download.documentfoundation.org/libreoffice/src/{$dir}";
$libreoffice = http_get_file($dirpath);
}
return find_max($libreoffice, "/{$package}/", "/^.*{$package}-([\\d\\.]*\\d)\\.tar.*\$/");
}
if ($package == "gimp") {
$dirpath = rtrim($dirpath, "/");
// Trim any trailing slash
$dirs = http_get_file("{$dirpath}/");
$dir = find_max($dirs, "/v\\d\\./", "/^.*(v\\d\\.[\\d\\.]+).*\$/");
$dirpath .= "/{$dir}/";
}
$lines = http_get_file($dirpath);
if (!is_array($lines)) {
return $lines;
}
}
// End fetch
if (isset($regex[$package])) {
// Custom search for latest package name
foreach ($lines as $l) {
if (preg_match('/^\\h*$/', $l)) {
continue;
}
$ver = preg_replace($regex[$package], "\$1", $l);
if ($ver == $l) {
continue;
}
//.........这里部分代码省略.........
示例10: get_packages
function get_packages($package, $dirpath)
{
global $regex;
global $book_index;
global $url_fix;
global $current;
if (isset($current) && $book_index != "{$current}") {
return 0;
}
// Fix up directory path
foreach ($url_fix as $u) {
$replace = $u['replace'];
$match = $u['match'];
if (isset($u['pkg'])) {
if ($package == $u['pkg']) {
$dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
break;
}
} else {
if (preg_match("/{$match}/", $dirpath)) {
$dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
break;
}
}
}
// Check for ftp
if (preg_match("/^ftp/", $dirpath)) {
if ($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.*$/');
}
//.........这里部分代码省略.........
示例11: get_packages
function get_packages($package, $dirpath)
{
global $regex;
global $book_index;
global $url_fix;
global $current;
global $kde_ver;
if (isset($current) && $book_index != "{$current}") {
return 0;
}
// Fix up directory path
foreach ($url_fix as $u) {
$replace = $u['replace'];
$match = $u['match'];
if (isset($u['pkg'])) {
if ($package == $u['pkg']) {
$dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
break;
}
} else {
if (preg_match("/{$match}/", $dirpath)) {
$dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
break;
}
}
}
// Check for ftp
if (preg_match("/^ftp/", $dirpath)) {
if ($book_index == "polkit-gnome") {
$dirpath = rtrim($dirpath, "/");
// Trim any trailing slash
$position = strrpos($dirpath, "/");
$dirpath = substr($dirpath, 0, $position);
// Up 1
}
if ($book_index == "libsecret") {
$dirpath = rtrim($dirpath, "/");
// Trim any trailing slash
$position = strrpos($dirpath, "/");
$dirpath = substr($dirpath, 0, $position);
// Up 1
$dirs = http_get_file("{$dirpath}/");
$dir = find_max($dirs, "/\\d\$/", "/^.* ([\\d\\.]+)\$/");
$dirpath .= "/{$dir}/";
}
// gsettings-desktop-schemas and similar
if ($book_index == "gsettings-desktop-schemas" || $book_index == "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;
}
示例12: get_packages
function get_packages($package, $dirpath)
{
global $regex;
global $book_index;
global $url_fix;
global $current;
global $kde_ver;
if (isset($current) && $book_index != "{$current}") {
return 0;
}
// Fix up directory path
foreach ($url_fix as $u) {
$replace = $u['replace'];
$match = $u['match'];
if (isset($u['pkg'])) {
if ($package == $u['pkg']) {
$dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
break;
}
} else {
if (preg_match("/{$match}/", $dirpath)) {
$dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
break;
}
}
}
// Check for ftp
if (preg_match("/^ftp/", $dirpath)) {
if ($book_index == "polkit-gnome") {
$dirpath = rtrim($dirpath, "/");
// Trim any trailing slash
$position = strrpos($dirpath, "/");
$dirpath = substr($dirpath, 0, $position);
// Up 1
}
if ($book_index == "libsecret") {
$dirpath = rtrim($dirpath, "/");
// Trim any trailing slash
$position = strrpos($dirpath, "/");
$dirpath = substr($dirpath, 0, $position);
// Up 1
$dirs = http_get_file("{$dirpath}/");
$dir = find_max($dirs, "/\\d\$/", "/^.* ([\\d\\.]+)\$/");
$dirpath .= "/{$dir}/";
}
// gsettings-desktop-schemas and similar
if ($book_index == "gsettings-desktop-schemas" || $book_index == "libsecret" || $book_index == "totem-pl-parser" || $book_index == "vte" || $book_index == "yelp-xsl" || $book_index == "GConf" || $book_index == "gcr" || $book_index == "geocode-glib" || $book_index == "gjs" || $book_index == "gnome-desktop" || $book_index == "gnome-menus" || $book_index == "gnome-video-effects" || $book_index == "grilo" || $book_index == "gtkhtml" || $book_index == "gtksourceview" || $book_index == "libchamplain" || $book_index == "libgee" || $book_index == "libgtop" || $book_index == "libgweather" || $book_index == "libpeas" || $book_index == "rest" || $book_index == "libwnck" || $book_index == "gnome-online-accounts" || $book_index == "libgdata" || $book_index == "evolution-data-server" || $book_index == "caribou" || $book_index == "dconf" || $book_index == "gnome-backgrounds" || $book_index == "adwaita-icon-theme" || $book_index == "gnome-themes-standard" || $book_index == "gvfs" || $book_index == "nautilus" || $book_index == "zenity" || $book_index == "gnome-bluetooth" || $book_index == "gnome-keyring" || $book_index == "gnome-settings-daemon" || $book_index == "gnome-control-center" || $book_index == "mutter" || $book_index == "gnome-shell" || $book_index == "gnome-shell-extensions" || $book_index == "gnome-session" || $book_index == "gdm" || $book_index == "gnome-user-docs" || $book_index == "yelp") {
$dirpath = rtrim($dirpath, "/");
// Trim any trailing slash
$position = strrpos($dirpath, "/");
$dirpath = substr($dirpath, 0, $position);
// Up 1
$dirs = http_get_file("{$dirpath}/");
if ($book_index == "gjs" || $book_index == "gnome-menus" || $book_index == "rest") {
$dir = find_max($dirs, "/\\d\$/", "/^.* ([\\d\\.]+)\$/");
} else {
$dir = find_even_max($dirs, "/\\d\$/", "/^.* ([\\d\\.]+)\$/");
}
$dirpath .= "/{$dir}/";
}
// Get listing
$lines = http_get_file("{$dirpath}/");
} else {
$lines = http_get_file($dirpath);
if (!is_array($lines)) {
return $lines;
}
}
// End fetch
if (isset($regex[$package])) {
// Custom search for latest package name
foreach ($lines as $l) {
if (preg_match('/^\\h*$/', $l)) {
continue;
}
$ver = preg_replace($regex[$package], "\$1", $l);
if ($ver == $l) {
continue;
}
return $ver;
// Return first match of regex
}
return 0;
// This is an error
}
if ($book_index == "telepathy-glib" || $book_index == "telepathy-mission-control") {
return find_even_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]*\\d)\\.tar.*\$/");
}
// Most packages are in the form $package-n.n.n
// Occasionally there are dashes (e.g. 201-1)
$max = find_max($lines, "/{$package}/", "/^.*{$package}-([\\d\\.]*\\d)\\.tar.*\$/");
return $max;
}
示例13: get_packages
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
//.........这里部分代码省略.........
示例14: get_packages
function get_packages($package, $dirpath)
{
global $regex;
global $book_index;
global $url_fix;
global $current;
if (isset($current) && $book_index != "{$current}") {
return 0;
}
// Fix up directory path
foreach ($url_fix as $u) {
$replace = $u['replace'];
$match = $u['match'];
if (isset($u['pkg'])) {
if ($package == $u['pkg']) {
$dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
break;
}
} else {
if (preg_match("/{$match}/", $dirpath)) {
$dirpath = preg_replace("/{$match}/", "{$replace}", $dirpath);
break;
}
}
}
// Check for ftp
if (preg_match("/^ftp/", $dirpath)) {
// 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;
//.........这里部分代码省略.........
示例15: find_max
// 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);