From: paulr Date: Thu, 4 Aug 2011 15:38:20 +0000 (+1000) Subject: fixed the url parser so all urlhandlers have ^ tacked to the start X-Git-Url: http://git.pjr.cc/?p=glcas.git;a=commitdiff_plain;h=ce16a1b219c25bd3cb3b803b4fec36dd557ead1b fixed the url parser so all urlhandlers have ^ tacked to the start otherwise preg_match matches subtexts Added APT code - and it seems to work --- diff --git a/libglcas/urlparser.php b/libglcas/urlparser.php index ab7e69c..d85692d 100644 --- a/libglcas/urlparser.php +++ b/libglcas/urlparser.php @@ -34,7 +34,7 @@ class GLCASUrlParser { error_log("catchall set to $val"); } else if($key != "/") { // now the rest - if(preg_match("/$key/", $url)) { + if(preg_match("/^$key/", $url)) { error_log("matched $url to $key and $val"); return new $val($this->config); } diff --git a/plugins/admin.php b/plugins/admin.php index 609047f..2b1d1ef 100644 --- a/plugins/admin.php +++ b/plugins/admin.php @@ -30,6 +30,9 @@ class GLCASAdmin { GLCASpageBuilder($this,"doRepoNextForm"); return; break; + case "addrepoapt": + GLCASpageBuilder($this,"doAddRepoApt"); + return; case "addrepoyum": GLCASpageBuilder($this,"doAddRepoYum"); return; @@ -148,15 +151,27 @@ class GLCASAdmin { } else { //echo "Looks like an apt repo, but I cant find any known distro's
"; } + //$existing_repos["distros"] = "Ubuntu, Debian"; + //$existing_repos["versions"] = "8.04LTS, 9.10, 10.04LTS, 10.10, 11.04, 11.10"; + //$existing_repos["arch"] = "x86_64, i386"; + + + $distros = $glt["distros"]; + $version = $glt["versions"]; + $archs = $glt["arch"]; echo "
"; echo ""; + echo ""; + echo ""; + echo ""; echo ""; echo ""; - echo ""; echo ""; echo ""; - echo ""; + echo ""; + echo ""; echo "
Description
Provides
Short URL
URL Prefix (blank for none)
Expire time for Meta Data days
Expire time for Meta Data days
"; echo "
"; return true; @@ -179,12 +194,35 @@ class GLCASAdmin { echo "Short URL"; echo "URL Prefix (blank for none)"; echo "Do Initial Update (can take a while, but done in background)"; - echo "Expire time for Meta Data days"; + echo "Expire time for Meta Data days"; echo ""; echo ""; echo ""; } } + + function doAddRepoApt($url) + { + $repo = new GLCASRepo($this->config); + + $desc = $_REQUEST["desc"]; + $OS = $_REQUEST["distro"]; + $version = $_REQUEST["version"]; + $arch = $_REQUEST["arch"]; + $shorturl = $_REQUEST["shorturl"]; + $prefix = $_REQUEST["prefix"]; + $repurl = $_REQUEST["repourl"]; + $expiretime = $REQUEST["expiretime"]; + $init = false; + if(isset($_REQUEST["initial"])) $init = true; + + + + $repo->addRepo($desc, $OS, $version, $arch, "-", $shorturl, $prefix, $repurl, "APT", $init, $expiretime); + + global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL; + header("Location: $BASE_URL/admin/"); + } function doAddRepoYum($url) { diff --git a/plugins/repo.php b/plugins/repo.php index 27ae54c..55eaed3 100644 --- a/plugins/repo.php +++ b/plugins/repo.php @@ -746,7 +746,16 @@ class GLCASRepo { $content .= ""; $dh = opendir($dir); while(($file = readdir($dh))!==false) { - if($file != "." && $file != "..") $content .= ""; + if($file != "." && $file != "..") { + if(is_dir("$dir/$file")) { + $fsize = ""; + $icon = "/icons/folder.png"; + } else { + $fsize = filesize("$dir/$file"); + $icon = "/icons/text.png"; + } + $content .= ""; + } } $content .= "
$file
$file$fsize
"; @@ -781,7 +790,11 @@ class GLCASRepo { } } $existing_repos["nrepos"] = $repos; + + // TODO: these need to be "calculated" $existing_repos["distros"] = "Ubuntu, Debian"; + $existing_repos["versions"] = "8.04LTS, 9.10, 10.04LTS, 10.10, 11.04, 11.10"; + $existing_repos["arch"] = "x86_64, i386"; return $existing_repos;