PHP 8.3 code fixes
This commit is contained in:
parent
e593a25368
commit
ae6269ac58
121
distroquery.php
121
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 "<h1>" . _r("Available repositories") . ":</h1>";
|
||||
$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 " > <a href=\"" . $url_prefix . "\">Repositories</a>";
|
||||
|
||||
$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 "<h5>ERROR: " . $j["error"] . "</h5>";
|
||||
} else {
|
||||
|
||||
@ -148,10 +161,15 @@ $url_prefix = home_url() . "/rpms/";
|
||||
//
|
||||
echo " > <a href=\"" . $url_prefix . "\">" . _r("Repositories") . "</a>";
|
||||
|
||||
$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 "<h3>" . _r("ERROR") . ": " . $j["error"] . "</h3>";
|
||||
} else {
|
||||
echo " > <a href=\"" . $url_prefix . "/" . $repo . "\">$repo</a> > " . $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 " <a href=\"" . $provider_url . "\">[" . $cnt . "]</a>";
|
||||
if (isset($buildrequire["providers"]["archs"][$arch])) {
|
||||
foreach ($buildrequire["providers"]["archs"][$arch] as $provider) {
|
||||
$cnt++;
|
||||
$provider_url = $url_prefix . $provider["repository"] . "/" . $provider["name"] . "/" . $arch;
|
||||
echo " <a href=\"" . $provider_url . "\">[" . $cnt . "]</a>";
|
||||
}
|
||||
}
|
||||
if ($cnt == 0) echo " (" . _r("unresolved") . ")";
|
||||
echo "<br/>";
|
||||
@ -243,9 +263,14 @@ $url_prefix = home_url() . "/rpms/";
|
||||
//
|
||||
echo " > <a href=\"" . $url_prefix . "\">" . _r("Repositories") . "</a>";
|
||||
|
||||
$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 "<h3>" . _r("ERROR") . ": " . $j["error"] . "</h3>";
|
||||
} else {
|
||||
echo " > <a href=\"" . $url_prefix . "/" . $repo . "\">$repo</a> > " . $package . " (" . $arch . ")";
|
||||
@ -287,42 +312,52 @@ $url_prefix = home_url() . "/rpms/";
|
||||
_r("Brothers") . "</th><th>" . _r("Provides") . "</th><th>" .
|
||||
_r("Obsoletes") . "</th><th>" . _r("Requires") . "</th></tr>";
|
||||
echo "<tr><td>";
|
||||
foreach ($j["brothers"] as $brother) {
|
||||
$brother_url = $url_prefix . $repo . "/" . $brother . "/" . $arch;
|
||||
echo "<a href=\"". $brother_url . "\">". $brother . "</a><br/>";
|
||||
}
|
||||
echo "</td><td>";
|
||||
foreach ($j["provides"] as $provide) {
|
||||
echo $provide["name"];
|
||||
if ($provide["flags"] != "") echo " " . $provide["flags"] . " " . $provide["version"];
|
||||
echo "<br/>";
|
||||
}
|
||||
echo "</td><td>";
|
||||
foreach ($j["obsoletes"] as $obsolete) {
|
||||
echo $obsolete["name"];
|
||||
if ($obsolete["flags"] != "") echo " " . $obsolete["flags"] . " " . $obsolete["version"];
|
||||
echo "<br/>";
|
||||
}
|
||||
echo "</td><td>";
|
||||
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 " <a href=\"" . $provider_url . "\">[" . $cnt . "]</a>";
|
||||
if (isset($j["brothers"])) {
|
||||
foreach ($j["brothers"] as $brother) {
|
||||
$brother_url = $url_prefix . $repo . "/" . $brother . "/" . $arch;
|
||||
echo "<a href=\"". $brother_url . "\">". $brother . "</a><br/>";
|
||||
}
|
||||
if ($cnt == 0) echo " <font color=red>(" . _r("unresolved") . ")</font>";
|
||||
}
|
||||
echo "</td><td>";
|
||||
if (isset($j["provides"])) {
|
||||
foreach ($j["provides"] as $provide) {
|
||||
echo $provide["name"];
|
||||
if ($provide["flags"] != "") echo " " . $provide["flags"] . " " . $provide["version"];
|
||||
echo "<br/>";
|
||||
}
|
||||
}
|
||||
echo "</td><td>";
|
||||
if (isset($j["obsoletes"])) {
|
||||
foreach ($j["obsoletes"] as $obsolete) {
|
||||
echo $obsolete["name"];
|
||||
if ($obsolete["flags"] != "") echo " " . $obsolete["flags"] . " " . $obsolete["version"];
|
||||
echo "<br/>";
|
||||
}
|
||||
}
|
||||
echo "</td><td>";
|
||||
if (isset($j["requires"])) {
|
||||
foreach ($j["requires"] as $require) {
|
||||
echo $require["name"];
|
||||
if ($require["flags"] != "") echo " " . $require["flags"] . " " . $require["version"];
|
||||
|
||||
echo "<br/>";
|
||||
$cnt = 0;
|
||||
if (isset($require["providers"])) {
|
||||
foreach ($require["providers"] as $provider) {
|
||||
$cnt++;
|
||||
$provider_url = $url_prefix . $provider["repository"] . "/" . $provider["name"] . "/" . $arch;
|
||||
echo " <a href=\"" . $provider_url . "\">[" . $cnt . "]</a>";
|
||||
}
|
||||
}
|
||||
if ($cnt == 0) echo " <font color=red>(" . _r("unresolved") . ")</font>";
|
||||
echo "<br/>";
|
||||
}
|
||||
}
|
||||
echo "</td></tr></table>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php finish: ?>
|
||||
</span></div><!-- end of #content-full -->
|
||||
|
||||
<?php get_footer(); ?>
|
||||
|
@ -35,7 +35,7 @@ function add_custom_scripts() {
|
||||
if($_SERVER['HTTPS']=='on') {
|
||||
$protocol='https:';
|
||||
}
|
||||
$output .= "<script type=\"text/javascript\" src=\"" . get_stylesheet_directory_uri() . "/scripts/jquery.cookiebar.js\"></script>\n";
|
||||
//$output .= "<script type=\"text/javascript\" src=\"" . get_stylesheet_directory_uri() . "/scripts/jquery.cookiebar.js\"></script>\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 .= "<br><br>";
|
||||
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]");
|
||||
|
@ -48,6 +48,8 @@ button, input, select, textarea {
|
||||
|
||||
.featured-title {
|
||||
color: #59b237;
|
||||
margin-top:28px;
|
||||
font-size:40px;
|
||||
}
|
||||
|
||||
.featured-subtitle {
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
if (!is_user_logged_in()) {
|
||||
wp_redirect( wp_login_url( "http://".$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI] ));
|
||||
wp_redirect( wp_login_url( "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"] ));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user