jb-data.de/scripts/testp.php
2025-08-11 22:23:30 +02:00

62 lines
1.8 KiB
PHP

<?php
$_SESSION['m1']=3; $_SESSION['m2']=0;
// Melde alle PHP Fehler (siehe Changelog)
error_reporting(E_ALL);
ini_set('display_errors', 0);
if(isset($_POST['submit']))
{
print_r($_FILES);
exit;
if($_FILES["upload"]["type"] == "application/pdf")
{
move_uploaded_file($_FILES["upload"]["tmp_name"],"upload/" . $_FILES["upload"]["name"]);
require_once 'CloudPrint.php';
$gcp = new GoogleCloudPrint();
if($gcp->loginToGoogle("rennbahn2000@gmail.com", "maxdata-01"))
{
$printers = $gcp->getPrinters();
$printerid = "";
if(count($printers)==0)
{
$content = "Could not get printers";
}
else
{
$printerid = $printers[0]['id'];
$resarray = $gcp->sendPrintToPrinter($printerid, "Printing Doc using Google Cloud Printing", "upload/" . $_FILES["upload"]["name"], "application/pdf");
if($resarray['status']==true)
{
$content = "Document has been sent to printer and should print shortly.";
}
else
{
$content = "An error occured while printing the doc. Error code:".$resarray['errorcode']." Message:".$resarray['errormessage'];
}
}
}
else
{
$content = "Login failed please check login info.";
}
}
else
{
$content = "<b>ERROR:</b><br>Invalid file upload only PDF file.";
}
}
else
{
$content = '<form enctype="multipart/form-data" action="" method="post">
<input type="file" name="upload" />
<input type="submit" name="submit">
</form>';
}
$template->assign('content', 'tpl/i_info.tpl');
?>