functions.php: distromatic_func: redirect request to old distromatic packages interface to the new distroquery API interface
This commit is contained in:
parent
06122a2040
commit
32ec9403e2
@ -43,7 +43,7 @@ $url_prefix = home_url() . "/rpms/";
|
||||
$arch=get_query_var('arch');
|
||||
|
||||
$get_args = array(
|
||||
'timeout' => 15,
|
||||
'timeout' => 20,
|
||||
'sslverify' => false
|
||||
);
|
||||
|
||||
|
@ -347,8 +347,45 @@ function openmamba_distromatic_func() {
|
||||
$outputlang = "en_US.UTF-8";
|
||||
|
||||
if (preg_match('/^[a-zA-Z0-9._\=\-\+\/\.\&\:]*$/', $urlargs)) {
|
||||
$ret = "<span id=\"distromatic\">" . __("Loading, please wait...", "responsive") . "</span><br>";
|
||||
$ret .= "<script>$(document).ready(function(){ $('#distromatic').load('/distribution/distromatic.naked.html?" . $urlargs . "'); })</script>";
|
||||
|
||||
// Set title for obsolete packages pages
|
||||
$arch = "";
|
||||
parse_str($urlargs, $args);
|
||||
if (array_key_exists('arch', $args)) {
|
||||
if (preg_match('/^[a-zA-Z0-9._]*$/', $args['arch'])) {
|
||||
$arch = urlencode($args['arch']);
|
||||
}
|
||||
}
|
||||
if (array_key_exists('tag', $args)) {
|
||||
if (preg_match('/^[a-zA-Z0-9._-]*$/', $args['tag'])) {
|
||||
$repo = urlencode($args['tag']);
|
||||
}
|
||||
}
|
||||
if (array_key_exists('pkg', $args)) {
|
||||
if ($args['pkg'] != '_index') {
|
||||
if (preg_match('/^[a-zA-Z0-9._+-]*$/', $args['pkg'])) {
|
||||
$pkgarr = explode('.', urlencode($args['pkg']));
|
||||
$pkg = $pkgarr[0];
|
||||
if (sizeof($pkgarr) > 1 && $pkgarr[1] != "source") {
|
||||
$arch = $pkgarr[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($repo != "base" && substr($repo, 0, 6) != "devel-") {
|
||||
// Old repos -> old interface
|
||||
$ret = "<span id=\"distromatic\">" . __("Loading, please wait...", "responsive") . "</span><br>";
|
||||
$ret .= "<script>$(document).ready(function(){ $('#distromatic').load('/distribution/distromatic.naked.html?" . $urlargs . "'); })</script>";
|
||||
} else {
|
||||
// Current repos -> redirect to new interface
|
||||
$ret = "<span id=\"distromatic\">" . __("Redirecting to new interface, please wait...", "responsive") . "</span><br>";
|
||||
$redirect_url = "https://openmamba.org/en/rpms/" . $repo . "/";
|
||||
if ($pkg != "") $redirect_url .= $pkg . "/";
|
||||
if ($arch != "") $redirect_url .= $arch . "/";
|
||||
$ret .= "<script>$(document).ready(function(){ window.location.replace('" . $redirect_url . "'); })</script>";
|
||||
}
|
||||
} else {
|
||||
$ret = "<span id=\"distromatic\">" . __("Invalid request.", "responsive") . "</span><br>";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user