Example #1
0
function parse_details($pbiorigin, $jail, $col, $showRemoval = false, $filter = true, $pbiarray)
{
    global $totalCols;
    global $inslist;
    global $SCERROR;
    global $sysType;
    global $allPBI;
    $jail = "#system";
    $jailUrl = "__system__";
    if (empty($inslist)) {
        $inslist = get_installed_list($jail);
    }
    // If provided the $pbiarray summary, we can skip the 2nd request for it
    if (!isset($pbiarray)) {
        $sccmd = array("{$jail} app-summary {$pbiorigin}");
        $response = send_sc_query($sccmd);
        $pbiarray = $response["{$jail} app-summary {$pbiorigin}"];
    }
    // Output format (4/7/15): [origin, name, version, iconpath, rating, type, comment, confdir, isInstalled, canRemove]
    $pbiname = $pbiarray[1];
    $pbiver = $pbiarray[2];
    $pbiicon = $pbiarray[3];
    $pbirating = $pbiarray[4];
    $pbitype = $pbiarray[5];
    $pbicomment = $pbiarray[6];
    $pbicomment = str_replace('"', '', $pbicomment);
    $pbicdir = $pbiarray[7];
    if (!isset($pbiarray[9])) {
        $isPBI = false;
        $pkgCmd = "pkg";
    } else {
        $isPBI = true;
        $pkgCmd = "pbi";
    }
    if ($isPBI) {
        $pbiinstalled = $pbiarray[8];
        $pbicanremove = $pbiarray[9];
    } else {
        $pbiinstalled = $pbiarray[4];
        $pbicanremove = $pbiarray[5];
    }
    if ($pbiorigin == "ports-mgmt/pkg") {
        $pbicanremove = false;
    }
    // If no match, return false
    if (empty($pbiname) or $pbiname == "{$SCERROR}") {
        return 1;
    }
    if ($allPBI == "false") {
        // Not on a desktop, filter out Graphical types
        if ($sysType != "DESKTOP" and $filter) {
            if ($pbitype == "Graphical") {
                return 1;
            }
            if ($pbitype != "Server" and $viewType != "ALL") {
                return 1;
            }
        }
        // If on a desktop, only list graphical types for the main system
        if ($jail == "#system" and $sysType == "DESKTOP" and $filter) {
            if ($pbitype != "Graphical") {
                return 1;
            }
        }
        // In a jail, see what else to filter
        if ($jail != "#system" and $filter) {
            // In jails we only list Server types, unless user requested CLI also
            if ($pbitype != "Server" and $viewType != "ALL") {
                return 1;
            }
            // In a jail, filter out Graphical types
            if ($pbitype == "Graphical") {
                return 1;
            }
        }
    }
    if ($col == 1) {
        print "<tr>\n";
    }
    // Get our values from this line
    print "  <td>\n";
    if (strlen($pbiname) > 14) {
        $pbiname = substr($pbiname, 0, 14) . "..";
    }
    if (strlen($pbiver) > 14) {
        $pbiver = substr($pbiver, 0, 14) . "..";
    }
    $appbusy = false;
    $dStatus = getDispatcherStatus();
    foreach ($dStatus as $curStatus) {
        if (strpos($curStatus, "pbi {$pbiorigin}") !== false) {
            $appbusy = true;
            break;
        }
        if (strpos($curStatus, "pkg {$pbiorigin}") !== false) {
            $appbusy = true;
            break;
        }
    }
    if ($appbusy) {
        print "<div id='item-working'><img style=\"background-color: Transparent;background-repeat:no-repeat;border: none;float:right;\" height=22 width=22 src=\"images/working.gif\" title=\"Working...\"></div>";
    } else {
        // Get the divid for this entry
        $appdivid = "button-" . str_replace("/", "-", $pbiorigin);
        // Is this app installed?
        //if ( array_search($pbiorigin, $inslist) !== false ) {
        if ($pbiinstalled == "true") {
            if ($pbicanremove == "true") {
                print "<div id='" . $appdivid . "'><button title=\"Delete {$pbiname}\" style=\"background-color: Transparent;background-repeat:no-repeat;border: none;float:right;\" onclick=\"delConfirmTiny('" . $pbiname . "','" . $pbiorigin . "','" . $pkgCmd . "','" . $appdivid . "')\"><img src=\"/images/application-exit.png\" height=22 width=22></button></div>\n";
            }
        } else {
            print "<div id='" . $appdivid . "'><button title=\"Install {$pbiname}\" style=\"background-color: Transparent;background-repeat:no-repeat;border: none;float:right;\" onclick=\"addConfirmTiny('" . $pbiname . "','" . $pbiorigin . "','" . $pkgCmd . "','" . $appdivid . "')\"><img src=\"/images/install.png\" height=22 width=22></button>\n";
        }
    }
    print "    <a href=\"/?p=appinfo&app=" . rawurlencode($pbiorigin) . "&allPBI={$allPBI}\" title=\"{$pbicomment}\"><img border=0 align=\"center\" height=48 width=48 src=\"/images/pbiicon.php?i={$pbicdir}/icon.png\" style=\"float:left;\"></a>\n";
    print "    <a href=\"/?p=appinfo&app=" . rawurlencode($pbiorigin) . "&allPBI={$allPBI}\" style=\"margin-left:5px;\">{$pbiname}</a><br>\n";
    print "    <a href=\"/?p=appinfo&app=" . rawurlencode($pbiorigin) . "&allPBI={$allPBI}\" style=\"margin-left:5px;\">{$pbiver}</a><br>\n";
    if (!empty($pbirating) and $pbirating != $SCERROR) {
        if (strpos($pbirating, "5") === 0) {
            print "<img src=\"/images/rating-5.png\" height=16 width=80 title=\"{$pbirating}\">";
        }
        if (strpos($pbirating, "4") === 0) {
            print "<img src=\"/images/rating-4.png\" height=16 width=80 title=\"{$pbirating}\">";
        }
        if (strpos($pbirating, "3") === 0) {
            print "<img src=\"/images/rating-3.png\" height=16 width=80 title=\"{$pbirating}\">";
        }
        if (strpos($pbirating, "2") === 0) {
            print "<img src=\"/images/rating-2.png\" height=16 width=80 title=\"{$pbirating}\">";
        }
        if (strpos($pbirating, "1") === 0) {
            print "<img src=\"/images/rating-1.png\" height=16 width=80 title=\"{$pbirating}\">";
        }
    }
    print "  </td>\n";
    if ($col == $totalCols) {
        print "</tr>\n";
    }
    return 0;
}
Example #2
0
function parse_details($pbiorigin, $jail, $col, $showRemoval = false, $filter = true)
{
    global $sc;
    global $jailUrl;
    global $totalCols;
    global $inslist;
    global $SCERROR;
    global $sysType;
    global $allPBI;
    if (empty($jail)) {
        $jail = "#system";
    }
    if (empty($inslist)) {
        $inslist = get_installed_list($jail);
    }
    /*$cmd="pbi app $pbiorigin";
      exec("$sc ". escapeshellarg("$cmd name")
        . " " . escapeshellarg("pkg $jail local $pbiorigin version") 
        . " " . escapeshellarg("$cmd comment") 
        . " " . escapeshellarg("$cmd confdir")
        . " " . escapeshellarg("pkg $jail remote $pbiorigin name") 
        . " " . escapeshellarg("pkg $jail remote $pbiorigin version")
        . " " . escapeshellarg("pkg $jail remote $pbiorigin comment")
        . " " . escapeshellarg("$cmd type")
        . " " . escapeshellarg("$cmd rating")
        , $pbiarray);
    
      $pbiname = $pbiarray[0];
      $pbiver = $pbiarray[1];
      $pbicomment = $pbiarray[2];
      $pbicdir = $pbiarray[3];
      if ( empty($pbiname) or $pbiname == "$SCERROR" ) {
        $pbiname = $pbiarray[4];
        $isPBI=false;
        $pkgCmd="pkg";
      } else {
        $isPBI=true;
        $pkgCmd="pbi";
      }
      if ( empty($pbiver) or $pbiver == "$SCERROR" )
        $pbiver = $pbiarray[5];
      if ( empty($pbiver) or $pbiver == "$SCERROR" )
        $pbiver = "";
      if ( empty($pbicomment) or $pbicomment == "$SCERROR" )
        $pbicomment = $pbiarray[6];
      $pbitype = $pbiarray[7];
      $pbirating = $pbiarray[8];
      */
    exec("{$sc} " . escapeshellarg("{$jail} app-summary {$pbiorigin}"), $pbiarray);
    $pbiarray = explode("::::", $pbiarray[0]);
    //only one line output based on cmd above
    // Output format (4/7/15): [origin, name, version, iconpath, rating, type, comment, confdir, isInstalled, canRemove]
    $pbiname = $pbiarray[1];
    $pbiver = $pbiarray[2];
    $pbiicon = $pbiarray[3];
    $pbirating = $pbiarray[4];
    $pbitype = $pbiarray[5];
    $pbicomment = $pbiarray[6];
    $pbicdir = $pbiarray[7];
    $pbiinstalled = $pbiarray[8];
    $pbicanremove = $pbiarray[9];
    if (empty($pbitype)) {
        $isPBI = false;
        $pkgCmd = "pkg";
    } else {
        $isPBI = true;
        $pkgCmd = "pbi";
    }
    // If no match, return false
    if (empty($pbiname) or $pbiname == "{$SCERROR}") {
        return 1;
    }
    if ($allPBI == "false") {
        // Not on a desktop, filter out Graphical types
        if ($sysType != "DESKTOP" and $filter) {
            if ($pbitype == "Graphical") {
                return 1;
            }
            if ($pbitype != "Server" and $viewType != "ALL") {
                return 1;
            }
        }
        // If on a desktop, only list graphical types for the main system
        if ($jail == "#system" and $sysType == "DESKTOP" and $filter) {
            if ($pbitype != "Graphical") {
                return 1;
            }
        }
        // In a jail, see what else to filter
        if ($jail != "#system" and $filter) {
            // In jails we only list Server types, unless user requested CLI also
            if ($pbitype != "Server" and $viewType != "ALL") {
                return 1;
            }
            // In a jail, filter out Graphical types
            if ($pbitype == "Graphical") {
                return 1;
            }
        }
    }
    if ($col == 1) {
        print "<tr>\n";
    }
    // Get our values from this line
    print "  <td>\n";
    // Is this app installed?
    //if ( array_search($pbiorigin, $inslist) !== false ) {
    if ($pbiinstalled == "true") {
        //$output="";
        //exec("/usr/local/bin/syscache ".escapeshellarg("pkg $jail local $pbiorigin rdependencies"), $output);
        // Only display the removal option if the app isn't used as a dep on something else
        //if ( "$output[0]" == "$SCERROR" )
        if ($pbicanremove == "true") {
            print "    <button title=\"Delete {$pbiname}\" style=\"background-color: Transparent;background-repeat:no-repeat;border: none;float:right;\" onclick=\"delConfirm('" . $pbiname . "','" . rawurlencode($pbiorigin) . "','" . $pkgCmd . "','" . $jailUrl . "')\"><img src=\"/images/application-exit.png\" height=22 width=22></button>\n";
        }
    } else {
        global $pbiindexdir;
        if (file_exists("{$pbiindexdir}/{$pbiorigin}/LICENSE")) {
            // Read the license data
            $pbilic = file_get_contents("{$pbiindexdir}/{$pbiorigin}/LICENSE");
            print "    <button title=\"Install {$pbiname}\" style=\"background-color: Transparent;background-repeat:no-repeat;border: none;float:right;\" onclick=\"addConfirmLic('" . $pbiname . "','" . rawurlencode($pbiorigin) . "','" . $pkgCmd . "','" . $jailUrl . "','" . $pbilic . "')\"><img src=\"/images/install.png\" height=22 width=22></button>\n";
        } else {
            print "    <button title=\"Install {$pbiname}\" style=\"background-color: Transparent;background-repeat:no-repeat;border: none;float:right;\" onclick=\"addConfirm('" . $pbiname . "','" . rawurlencode($pbiorigin) . "','" . $pkgCmd . "','" . $jailUrl . "')\"><img src=\"/images/install.png\" height=22 width=22></button>\n";
        }
    }
    print "    <a href=\"/?p=appinfo&app=" . rawurlencode($pbiorigin) . "&jail={$jailUrl}&allPBI={$allPBI}\" title=\"{$pbicomment}\"><img border=0 align=\"center\" height=48 width=48 src=\"/images/pbiicon.php?i={$pbicdir}/icon.png\" style=\"float:left;\"></a>\n";
    print "    <a href=\"/?p=appinfo&app=" . rawurlencode($pbiorigin) . "&jail={$jailUrl}&allPBI={$allPBI}\" style=\"margin-left:5px;\">{$pbiname}</a><br>\n";
    print "    <a href=\"/?p=appinfo&app=" . rawurlencode($pbiorigin) . "&jail={$jailUrl}&allPBI={$allPBI}\" style=\"margin-left:5px;\">{$pbiver}</a><br>\n";
    if (!empty($pbirating) and $pbirating != $SCERROR) {
        if (strpos($pbirating, "5") === 0) {
            print "<img src=\"/images/rating-5.png\" height=16 width=80 title=\"{$pbirating}\">";
        }
        if (strpos($pbirating, "4") === 0) {
            print "<img src=\"/images/rating-4.png\" height=16 width=80 title=\"{$pbirating}\">";
        }
        if (strpos($pbirating, "3") === 0) {
            print "<img src=\"/images/rating-3.png\" height=16 width=80 title=\"{$pbirating}\">";
        }
        if (strpos($pbirating, "2") === 0) {
            print "<img src=\"/images/rating-2.png\" height=16 width=80 title=\"{$pbirating}\">";
        }
        if (strpos($pbirating, "1") === 0) {
            print "<img src=\"/images/rating-1.png\" height=16 width=80 title=\"{$pbirating}\">";
        }
    }
    print "  </td>\n";
    if ($col == $totalCols) {
        print "</tr>\n";
    }
    return 0;
}
Example #3
0
function parse_details($pbiorigin, $jail, $col, $showRemoval = false, $filter = true)
{
    global $sc;
    global $jailUrl;
    global $totalCols;
    global $inslist;
    global $SCERROR;
    global $sysType;
    global $allPBI;
    if (empty($jail)) {
        $jail = "#system";
    }
    if (empty($inslist)) {
        $inslist = get_installed_list($jail);
    }
    exec("{$sc} " . escapeshellarg("{$jail} app-summary {$pbiorigin}"), $pbiarray);
    $pbiarray = explode("::::", $pbiarray[0]);
    //only one line output based on cmd above
    // Output format (4/7/15): [origin, name, version, iconpath, rating, type, comment, confdir, isInstalled, canRemove]
    $pbiname = $pbiarray[1];
    $pbiver = $pbiarray[2];
    $pbiicon = $pbiarray[3];
    $pbirating = $pbiarray[4];
    $pbitype = $pbiarray[5];
    $pbicomment = $pbiarray[6];
    $pbicdir = $pbiarray[7];
    $pbiinstalled = $pbiarray[8];
    $pbicanremove = $pbiarray[9];
    if (empty($pbitype)) {
        $isPBI = false;
        $pkgCmd = "pkg";
    } else {
        $isPBI = true;
        $pkgCmd = "pbi";
    }
    // If no match, return false
    if (empty($pbiname) or $pbiname == "{$SCERROR}") {
        return 1;
    }
    if ($allPBI == "false") {
        // Not on a desktop, filter out Graphical types
        if ($sysType != "DESKTOP" and $filter) {
            if ($pbitype == "Graphical") {
                return 1;
            }
            if ($pbitype != "Server" and $viewType != "ALL") {
                return 1;
            }
        }
        // If on a desktop, only list graphical types for the main system
        if ($jail == "#system" and $sysType == "DESKTOP" and $filter) {
            if ($pbitype != "Graphical") {
                return 1;
            }
        }
        // In a jail, see what else to filter
        if ($jail != "#system" and $filter) {
            // In jails we only list Server types, unless user requested CLI also
            if ($pbitype != "Server" and $viewType != "ALL") {
                return 1;
            }
            // In a jail, filter out Graphical types
            if ($pbitype == "Graphical") {
                return 1;
            }
        }
    }
    if ($col == 1) {
        print "<tr>\n";
    }
    // Get our values from this line
    print "  <td>\n";
    if (strlen($pbiname) > 14) {
        $pbiname = substr($pbiname, 0, 14) . "..";
    }
    if (strlen($pbiver) > 14) {
        $pbiver = substr($pbiver, 0, 14) . "..";
    }
    $appbusy = false;
    $dStatus = getDispatcherStatus();
    foreach ($dStatus as $curStatus) {
        if (strpos($curStatus, "pbi {$pbiorigin}") !== false) {
            $appbusy = true;
            break;
        }
        if (strpos($curStatus, "pkg {$pbiorigin}") !== false) {
            $appbusy = true;
            break;
        }
    }
    if ($appbusy) {
        print "<img style=\"background-color: Transparent;background-repeat:no-repeat;border: none;float:right;\" height=22 width=22 src=\"images/working.gif\" title=\"Working...\">";
        echo "<script>setTimeout(function () { location.reload(1); }, 8000);</script>";
    } else {
        // Is this app installed?
        //if ( array_search($pbiorigin, $inslist) !== false ) {
        if ($pbiinstalled == "true") {
            if ($pbicanremove == "true") {
                print "    <button title=\"Delete {$pbiname}\" style=\"background-color: Transparent;background-repeat:no-repeat;border: none;float:right;\" onclick=\"delConfirm('" . $pbiname . "','" . rawurlencode($pbiorigin) . "','" . $pkgCmd . "','" . $jailUrl . "')\"><img src=\"/images/application-exit.png\" height=22 width=22></button>\n";
            }
        } else {
            print "    <button title=\"Install {$pbiname}\" style=\"background-color: Transparent;background-repeat:no-repeat;border: none;float:right;\" onclick=\"addConfirm('" . $pbiname . "','" . rawurlencode($pbiorigin) . "','" . $pkgCmd . "','" . $jailUrl . "')\"><img src=\"/images/install.png\" height=22 width=22></button>\n";
        }
    }
    print "    <a href=\"/?p=appinfo&app=" . rawurlencode($pbiorigin) . "&jail={$jailUrl}&allPBI={$allPBI}\" title=\"{$pbicomment}\"><img border=0 align=\"center\" height=48 width=48 src=\"/images/pbiicon.php?i={$pbicdir}/icon.png\" style=\"float:left;\"></a>\n";
    print "    <a href=\"/?p=appinfo&app=" . rawurlencode($pbiorigin) . "&jail={$jailUrl}&allPBI={$allPBI}\" style=\"margin-left:5px;\">{$pbiname}</a><br>\n";
    print "    <a href=\"/?p=appinfo&app=" . rawurlencode($pbiorigin) . "&jail={$jailUrl}&allPBI={$allPBI}\" style=\"margin-left:5px;\">{$pbiver}</a><br>\n";
    if (!empty($pbirating) and $pbirating != $SCERROR) {
        if (strpos($pbirating, "5") === 0) {
            print "<img src=\"/images/rating-5.png\" height=16 width=80 title=\"{$pbirating}\">";
        }
        if (strpos($pbirating, "4") === 0) {
            print "<img src=\"/images/rating-4.png\" height=16 width=80 title=\"{$pbirating}\">";
        }
        if (strpos($pbirating, "3") === 0) {
            print "<img src=\"/images/rating-3.png\" height=16 width=80 title=\"{$pbirating}\">";
        }
        if (strpos($pbirating, "2") === 0) {
            print "<img src=\"/images/rating-2.png\" height=16 width=80 title=\"{$pbirating}\">";
        }
        if (strpos($pbirating, "1") === 0) {
            print "<img src=\"/images/rating-1.png\" height=16 width=80 title=\"{$pbirating}\">";
        }
    }
    print "  </td>\n";
    if ($col == $totalCols) {
        print "</tr>\n";
    }
    return 0;
}