diff --git a/distroquery.php b/distroquery.php
index d769ffe..15b8207 100644
--- a/distroquery.php
+++ b/distroquery.php
@@ -17,6 +17,9 @@ if ( !defined( 'ABSPATH' ) ) {
exit;
}
+$api_url = "https://push.openmamba.org/openmamba/distroquery/api/v1/";
+#$api_url = "https://openmamba.org/distroquery/api/v1/";
+
function human_filesize($bytes, $dec = 2): string {
$size = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
$factor = floor((strlen($bytes) - 1) / 3);
@@ -47,7 +50,12 @@ $url_prefix = home_url() . "/rpms/";
echo " > " . _r("Repositories");
echo "
" . _r("Available repositories") . ":
";
- $request = wp_remote_get('https://push.openmamba.org/openmamba/distroquery/api/v1/repositories');
+ $request = wp_remote_get($api_url . "repositories");
+ if (is_wp_error($request)) {
+ echo "ERROR: " . $request->get_error_message();
+ goto finish;
+ }
+
$j = json_decode($request["body"], true);
foreach ($j as $repository) {
$repository_url = $url_prefix . $repository["tag"];
@@ -60,17 +68,22 @@ $url_prefix = home_url() . "/rpms/";
//
echo " > Repositories";
- $page = $_GET['page'];
- $q = $_GET['q'];
+ $page = isset($_GET['page'])?$_GET['page']:"";
+ $q = isset($_GET['q'])?$_GET['q']:"";
$query_append = "";
- if ($page != "") $query_append="&page=" . $page;
+ if ($page != "") $query_append .="&page=" . $page;
if ($q != "") $query_append .= "&q=" . urlencode($q);
- if ($query_append[0] == '&') $query_append[0] = "?";
+ if (strlen($query_append) > 0 && $query_append[0] == '&') $query_append[0] = "?";
+
+ $request = wp_remote_get($api_url . "repository/" . $repo . $query_append);
+ if (is_wp_error($request)) {
+ echo "ERROR: " . $request->get_error_message();
+ goto finish;
+ }
- $request = wp_remote_get('https://push.openmamba.org/openmamba/distroquery/api/v1/repository/' . $repo . $query_append);
$j = json_decode($request["body"], true);
- if ($j["error"] != "") {
+ if (isset($j["error"])) {
echo "ERROR: " . $j["error"] . "
";
} else {
@@ -148,10 +161,15 @@ $url_prefix = home_url() . "/rpms/";
//
echo " > " . _r("Repositories") . "";
- $request = wp_remote_get('https://push.openmamba.org/openmamba/distroquery/api/v1/package/'. $repo . "/" . $package);
+ $request = wp_remote_get($api_url . "package/" . $repo . "/" . $package);
+ if (is_wp_error($request)) {
+ echo "ERROR: " . $request->get_error_message();
+ goto finish;
+ }
+
$j = json_decode($request["body"], true);
- if ($j["error"] != "") {
+ if (isset($j["error"])) {
echo "" . _r("ERROR") . ": " . $j["error"] . "
";
} else {
echo " > $repo > " . $package;
@@ -209,10 +227,12 @@ $url_prefix = home_url() . "/rpms/";
echo $buildrequire["name"];
if ($buildrequire["flags"] != "") echo "[" . $buildrequire["flags"] . $buildrequire["version"] . "]";
$cnt = 0;
- foreach ($buildrequire["providers"]["archs"][$arch] as $provider) {
- $cnt++;
- $provider_url = $url_prefix . $provider["repository"] . "/" . $provider["name"] . "/" . $arch;
- echo " [" . $cnt . "]";
+ if (isset($buildrequire["providers"]["archs"][$arch])) {
+ foreach ($buildrequire["providers"]["archs"][$arch] as $provider) {
+ $cnt++;
+ $provider_url = $url_prefix . $provider["repository"] . "/" . $provider["name"] . "/" . $arch;
+ echo " [" . $cnt . "]";
+ }
}
if ($cnt == 0) echo " (" . _r("unresolved") . ")";
echo "
";
@@ -243,9 +263,14 @@ $url_prefix = home_url() . "/rpms/";
//
echo " > " . _r("Repositories") . "";
- $request = wp_remote_get('https://push.openmamba.org/openmamba/distroquery/api/v1/package/'. $repo . "/" . $package . "/" . $arch);
+ $request = wp_remote_get($api_url . "package/" . $repo . "/" . $package . "/" . $arch);
+ if (is_wp_error($request)) {
+ echo "ERROR: " . $request->get_error_message();
+ goto finish;
+ }
+
$j = json_decode($request["body"],true);
- if ($j["error"] != "") {
+ if (isset($j["error"])) {
echo "" . _r("ERROR") . ": " . $j["error"] . "
";
} else {
echo " > $repo > " . $package . " (" . $arch . ")";
@@ -287,42 +312,52 @@ $url_prefix = home_url() . "/rpms/";
_r("Brothers") . "" . _r("Provides") . " | " .
_r("Obsoletes") . " | " . _r("Requires") . " | ";
echo "";
- foreach ($j["brothers"] as $brother) {
- $brother_url = $url_prefix . $repo . "/" . $brother . "/" . $arch;
- echo "". $brother . " ";
- }
- echo " | ";
- foreach ($j["provides"] as $provide) {
- echo $provide["name"];
- if ($provide["flags"] != "") echo " " . $provide["flags"] . " " . $provide["version"];
- echo " ";
- }
- echo " | ";
- foreach ($j["obsoletes"] as $obsolete) {
- echo $obsolete["name"];
- if ($obsolete["flags"] != "") echo " " . $obsolete["flags"] . " " . $obsolete["version"];
- echo " ";
- }
- echo " | ";
- foreach ($j["requires"] as $require) {
- echo $require["name"];
- if ($require["flags"] != "") echo " " . $require["flags"] . " " . $require["version"];
-
- $cnt = 0;
- foreach ($require["providers"] as $provider) {
- $cnt++;
- $provider_url = $url_prefix . $provider["repository"] . "/" . $provider["name"] . "/" . $arch;
- echo " [" . $cnt . "]";
+ if (isset($j["brothers"])) {
+ foreach ($j["brothers"] as $brother) {
+ $brother_url = $url_prefix . $repo . "/" . $brother . "/" . $arch;
+ echo "". $brother . " ";
}
- if ($cnt == 0) echo " (" . _r("unresolved") . ")";
+ }
+ echo " | ";
+ if (isset($j["provides"])) {
+ foreach ($j["provides"] as $provide) {
+ echo $provide["name"];
+ if ($provide["flags"] != "") echo " " . $provide["flags"] . " " . $provide["version"];
+ echo " ";
+ }
+ }
+ echo " | ";
+ if (isset($j["obsoletes"])) {
+ foreach ($j["obsoletes"] as $obsolete) {
+ echo $obsolete["name"];
+ if ($obsolete["flags"] != "") echo " " . $obsolete["flags"] . " " . $obsolete["version"];
+ echo " ";
+ }
+ }
+ echo " | ";
+ if (isset($j["requires"])) {
+ foreach ($j["requires"] as $require) {
+ echo $require["name"];
+ if ($require["flags"] != "") echo " " . $require["flags"] . " " . $require["version"];
- echo " ";
+ $cnt = 0;
+ if (isset($require["providers"])) {
+ foreach ($require["providers"] as $provider) {
+ $cnt++;
+ $provider_url = $url_prefix . $provider["repository"] . "/" . $provider["name"] . "/" . $arch;
+ echo " [" . $cnt . "]";
+ }
+ }
+ if ($cnt == 0) echo " (" . _r("unresolved") . ")";
+ echo " ";
+ }
}
echo " |
";
}
}
?>
+
diff --git a/functions.php b/functions.php
index 8f85cba..186a1bf 100644
--- a/functions.php
+++ b/functions.php
@@ -35,7 +35,7 @@ function add_custom_scripts() {
if($_SERVER['HTTPS']=='on') {
$protocol='https:';
}
- $output .= "\n";
+ //$output .= "\n";
wp_register_script('jquery', get_stylesheet_directory_uri() . "/scripts/jquery.min.js", false, '1.11.3');
wp_enqueue_script('jquery');
$JQUERY_LOADED = true;
@@ -69,21 +69,21 @@ function set_title($title) {
$urlargs = substr($_SERVER['REQUEST_URI'], $urlargspos + 1);
parse_str($urlargs, $args);
$newtitle = $title;
- if ($args['arch']) {
+ if (array_key_exists('arch', $args)) {
if (preg_match('/^[a-zA-Z0-9._]*$/', $args['arch'])) {
$newtitle = urlencode($args['arch']) . " - " . $newtitle;
} else {
$newtitle = " Invalid request - " . $newtitle;
}
}
- if ($args['tag']) {
+ if (array_key_exists('tag', $args)) {
if (preg_match('/^[a-zA-Z0-9._-]*$/', $args['tag'])) {
$newtitle = urlencode($args['tag']) . " - " . $newtitle;
} else {
$newtitle = " Invalid request - " . $newtitle;
}
}
- if ($args['pkg']) {
+ if (array_key_exists('pkg', $args)) {
if ($args['pkg'] == '_index')
$newtitle = 'Index - ' . $newtitle;
else {
@@ -149,7 +149,7 @@ function openmamba_infofile($mediaprefix, $milestone, $fallbackmilestone, $mediu
$script_file = "$mediaprefix/$fallbackmilestone/$medium/info/$filename.$outputlang.html.inc";
}
$ret = '';
- if ($script_file) {
+ if (isset($script_file)) {
$file = fopen($script_file, "r");
while (!feof($file)) {
$b=fread($file,1024);
@@ -198,23 +198,23 @@ function openmamba_download_func( $atts ) {
$ret .= "
";
if ($a['multilang']) {
reset($archname);
- while (list(, $currarch) = each($archname)) {
+ foreach($archname as $ey => $currarch) {
if (strpos(";".$a['archs'].";",$currarch) == false) continue;
$ret .= openmamba_download_link($milestone,$medium,$currarch,$ext,$mlword,"en");
}
} else {
reset($archname);
$langs = array('it' => 'italiano','en' => 'english','es' => 'espaƱol');
- while (list(, $currarch) = each($archname)) {
+ foreach($archname as $ey => $currarch) {
if (strpos(";".$a['archs'].";",$currarch) == false) continue;
$ret .= openmamba_download_link($milestone,$medium,$currarch,$ext,$langs[$outputlang],$outputlang);
}
foreach ($langs as $l => $lang) {
if ($l == $outputlang) continue;
reset($archname);
- while (list(, $currarch) = each($archname)) {
+ foreach($archname as $ey => $currarch) {
if (strpos(";".$a['archs'].";",$currarch) == false) continue;
- $out .= openmamba_download_link($milestone,$medium,$currarch,$ext,$lang,$l);
+ $out = openmamba_download_link($milestone,$medium,$currarch,$ext,$lang,$l);
}
}
$ret .= do_shortcode("[expand title=\"". __("More languages...","responsive") . "\"]". $out ."[/expand]");
diff --git a/style.css b/style.css
index 4b46cd2..6bade8c 100644
--- a/style.css
+++ b/style.css
@@ -48,6 +48,8 @@ button, input, select, textarea {
.featured-title {
color: #59b237;
+ margin-top:28px;
+ font-size:40px;
}
.featured-subtitle {
diff --git a/webbuild-page.php b/webbuild-page.php
index cad67c0..c8e610e 100644
--- a/webbuild-page.php
+++ b/webbuild-page.php
@@ -1,7 +1,7 @@