PX : code

LPHPRng Sample by John Callaghan
Download this code


<? include("lprng.php3"); ?>

<form>
Print server: <input type=text name=lprnghost value="<? echo $lprnghost ?>">
</form>

<pre><?
if(strlen($lprnghost) == 0) exit;

echo "\n<b>LPQ Output</b>\n";

$lpqarray = lpq($lprnghost);

while(list($pserver, $parray) = @each($lpqarray))
    {
    while(list($printer, $line) = @each($parray))
        {
        printf("%s@%s:\n", $printer, $pserver);
        printf("    %s: %s\n", "comment", $line["comment"]);
        printf("    %s: %s\n", "destination", $line["destination"]);
        printf("    %s: %s\n", "subservers",
                               @implode($line["subservers"], " "));
        printf("    %s: %s\n", "server", $line["server"]);

        while(list($index, $jobline) = @each($line["jobs"]))
            {
            printf("    %s: %s\n", "job", implode($jobline, " "));
            printf("    %s: %ld\n", "time", lp_parsetime($jobline["time"]));
            }

        printf("\n");
        }
    }

echo "\n<b>Printcap Output</b>\n";

$lpcarray = lpc($lprnghost, "all", "printcap");
while(list($index, $lpcline) = @each($lpcarray))
    {
    echo $lpcline . "\n";
    }

echo "\n<b>Status Output</b>\n";

$lpcarray = lp_status($lprnghost, "all");
while(list($index, $lpcline) = @each($lpcarray))
    {
    echo implode($lpcline, " ") . "\n";
    }

echo "\n<b>Getprinters Output</b>\n";

$lpcarray = lp_getprinters($lprnghost);
while(list($index, $lpcline) = @each($lpcarray))
    {
    echo $lpcline . "\n";
    }

echo "\n<b>Getsubservers Output</b>\n";

$lpcarray = lp_getsubservers($lprnghost, "all");
while(list($printer, $lpcline) = @each($lpcarray))
    {
    echo "$printer: " . implode($lpcline, " ") . "\n";
    }

?></pre>

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.