Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update index.php - json option #132

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions www/--/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
define('SCRIPT_BADGES', '/--/badges/');
define('SCRIPT_API', '/--/api/1/search/');
define('SCRIPT_STATUS', '/--/status/');
define('SCRIPT_JSON', '/--/json/');

$items = explode('/', $script);
if ($Debug) {
Expand All @@ -60,6 +61,7 @@
if (strpos($script, SCRIPT_API) === 0) $script = SCRIPT_API;
if (strpos($script, SCRIPT_BADGES) === 0) $script = SCRIPT_BADGES;
if (strpos($script, SCRIPT_STATUS) === 0) $script = SCRIPT_STATUS;
if (strpos($script, SCRIPT_JSON) === 0) $script = SCRIPT_JSON;

switch($script) {
case SCRIPT_BADGES:
Expand All @@ -83,7 +85,26 @@
}

break;
case SCRIPT_JSON:
require_once($_SERVER['DOCUMENT_ROOT'] . '/../classes/ports.php');

$category_port = pg_escape_string($url_parts['port']);

list($category, $port) = explode('/', $category_port);
$myPort = new Port($db);
$result = $myPort->Fetch($category, $port);
header('Content-Type: application/json');
if (!empty($result)) {
$response = get_object_vars($myPort)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a trailing ; here

echo json_encode($response);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line fails to get json back. If I dump $response, it looks like this:

array(73) {
  ["dbh"]=>
  resource(2) of type (pgsql link)
  ["id"]=>
  string(5) "20643"
  ["element_id"]=>
  string(6) "272629"
  ["category_id"]=>
  string(1) "8"
  ["short_description"]=>
  string(48) "Open source Remote Desktop Protocol (RDP) server"
  ["long_description"]=>
  string(481) "Based on the work of rdesktop, xrdp uses the remote desktop protocol to
present a GUI to the user.

The goal of this project is to provide a fully functional Linux terminal
server, capable of accepting connections from rdesktop and Microsoft's own
terminal server / remote desktop clients.

Unlike Windows NT/2000/2003 server, xrdp will not display a Windows desktop
but an X window desktop to the user.

Xrdp uses Xvnc or X11rdp to manage the X session.

WWW: http://www.xrdp.org/"
  ["version"]=>
  string(6) "0.9.12"
  ["revision"]=>
  string(1) "0"
  ["epoch"]=>
  string(1) "1"
  ["maintainer"]=>
  string(16) "[email protected]"
  ["homepage"]=>
  string(20) "http://www.xrdp.org/"
  ["master_sites"]=>
  string(68) "https://codeload.github.com/neutrinolabs/xrdp/tar.gz/v0.9.12?dummy=/"
  ["extract_suffix"]=>
  NULL
  ["package_exists"]=>
  NULL
  ["depends_build"]=>
  string(445) "/usr/local/bin/nasm:devel/nasm pkgconf>=1.3.0_1:devel/pkgconf autoconf>=2.69:devel/autoconf automake>=1.16.1:devel/automake libtoolize:devel/libtool /usr/local/libdata/pkgconfig/ice.pc:x11/libICE /usr/local/libdata/pkgconfig/pixman-1.pc:x11/pixman /usr/local/libdata/pkgconfig/sm.pc:x11/libSM /usr/local/libdata/pkgconfig/x11.pc:x11/libX11 /usr/local/libdata/pkgconfig/xfixes.pc:x11/libXfixes /usr/local/libdata/pkgconfig/xrandr.pc:x11/libXrandr"
  ["depends_run"]=>
  string(459) "xterm:x11/xterm /usr/local/lib/xorg/modules/libxorgxrdp.so:x11-drivers/xorgxrdp /usr/local/lib/pulse-13.0/modules/module-xrdp-sink.so:audio/pulseaudio-module-xrdp /usr/local/libdata/pkgconfig/ice.pc:x11/libICE /usr/local/libdata/pkgconfig/pixman-1.pc:x11/pixman /usr/local/libdata/pkgconfig/sm.pc:x11/libSM /usr/local/libdata/pkgconfig/x11.pc:x11/libX11 /usr/local/libdata/pkgconfig/xfixes.pc:x11/libXfixes /usr/local/libdata/pkgconfig/xrandr.pc:x11/libXrandr"
  ["depends_lib"]=>
  string(80) "libfdk-aac.so:audio/fdk-aac libopus.so:audio/opus libjpeg.so:graphics/jpeg-turbo"
  ["last_commit_id"]=>
  string(6) "781307"
  ["found_in_index"]=>
  NULL
  ["forbidden"]=>
  NULL
  ["broken"]=>
  NULL
  ["deprecated"]=>
  NULL
  ["ignore"]=>
  NULL
  ["date_added"]=>
  string(20) "04 May 2007 01:13:19"
  ["categories"]=>
  string(3) "net"
  ["master_port"]=>
  NULL
  ["latest_link"]=>
  NULL
  ["no_latest_link"]=>
  NULL
  ["no_package"]=>
  NULL
  ["package_name"]=>
  string(4) "xrdp"
  ["restricted"]=>
  NULL
  ["no_cdrom"]=>
  NULL
  ["expiration_date"]=>
  NULL
  ["is_interactive"]=>
  NULL
  ["only_for_archs"]=>
  NULL
  ["not_for_archs"]=>
  NULL
  ["status"]=>
  string(1) "A"
  ["showconfig"]=>
  string(484) "===> The following configuration options are available for xrdp-0.9.12,1:
     DEBUG=off: Build with debugging support
     FUSE=off: Enable drive redirection via FUSE (experimental)
     IPV6=on: IPv6 protocol support
====> Options available for the group AUDIO_CODEC
     FDKAAC=on: Enable Fraunhofer FDK AAC for audio redirection
     MP3LAME=off: Enable MP3 Lame for audio redirection
     OPUS=on: Enable Opus for audio redirection
===> Use 'make config' to modify these settings"
  ["license"]=>
  string(8) "APACHE20"
  ["fetch_depends"]=>
  NULL
  ["extract_depends"]=>
  NULL
  ["patch_depends"]=>
  NULL
  ["uses"]=>
  string(72) "autoreconf:build compiler:c11 jpeg localbase libtool pkgconfig  ssl xorg"
  ["pkgmessage"]=>
  NULL
  ["distinfo"]=>
  string(570) "TIMESTAMP = 1577722873
SHA256 (xrdp/neutrinolabs-xrdp-v0.9.12_GH0.tar.gz) = 74ca5ff341a4428dba2ab409752adda9cfb788c298d8e0388dd6a4221e70ebaa
SIZE (xrdp/neutrinolabs-xrdp-v0.9.12_GH0.tar.gz) = 679189
SHA256 (xrdp/neutrinolabs-librfxcodec-v0.1.5_GH0.tar.gz) = 5710a65a9f877aca5b5bca9f2fb83b5904b59d465ab5c10bcf4ffc2b3416d0c8
SIZE (xrdp/neutrinolabs-librfxcodec-v0.1.5_GH0.tar.gz) = 48387
SHA256 (xrdp/neutrinolabs-libpainter-v0.1.1_GH0.tar.gz) = 6caee8444fbd72677ac5e125c7ac99490688474975451668e751a9d9187ee5e6
SIZE (xrdp/neutrinolabs-libpainter-v0.1.1_GH0.tar.gz) = 13929"
  ["license_restricted"]=>
  NULL
  ["manual_package_build"]=>
  NULL
  ["license_perms"]=>
  NULL
  ["conflicts"]=>
  string(16) "xrdp-devel[0-9]*"
  ["conflicts_build"]=>
  NULL
  ["conflicts_install"]=>
  NULL
  ["conflicts_matches"]=>
  bool(false)
  ["generate_plist"]=>
  NULL
  ["category"]=>
  string(3) "net"
  ["port"]=>
  string(4) "xrdp"
  ["needs_refresh"]=>
  NULL
  ["updated"]=>
  NULL
  ["onwatchlist"]=>
  string(1) "0"
  ["vulnerable_current"]=>
  NULL
  ["vulnerable_past"]=>
  NULL
  ["pkg_plist_library_matches"]=>
  NULL
  ["update_description"]=>
  NULL
  ["message_id"]=>
  NULL
  ["encoding_losses"]=>
  NULL
  ["last_commit_date"]=>
  string(22) "2020-01-08 19:36:47+00"
  ["svn_revision"]=>
  string(6) "522457"
  ["LocalResult"]=>
  NULL
  ["committer"]=>
  NULL
  ["svn_hostname"]=>
  string(18) "svnweb.freebsd.org"
  ["path_to_repo"]=>
  string(6) "/ports"
  ["element_pathname"]=>
  string(20) "/ports/head/net/xrdp"
  ["quarterly_revision"]=>
  string(8) "0.9.12,1"
  ["category_looking_at"]=>
  NULL
}

exit;
} else {
$error = ["error" => "Port not found"];
echo json_encode($error);
exit;
}

break;
case SCRIPT_STATUS:
require_once($_SERVER['DOCUMENT_ROOT'] . '/../classes/system_status.php');

Expand Down