* @auteurs Carip-Academie de Lyon * @Licence Distribue selon les termes de la licence GPL * @note */ /** * @Repertoire: printers/ * file: view_printers.php */ // Affiche les parametres de chaque imprimante include "entete.inc.php"; include "printers.inc.php"; include "ihm.inc.php"; // pour is_admin() //include "ldap.inc.php"; require_once ("lang.inc.php"); bindtextdomain('se3-printers',"/var/www/se3/locale"); textdomain ('se3-printers'); //aide $_SESSION["pageaide"]="Imprimantes"; if (is_admin("printers_is_admin",$login)=="Y") { if ($_POST['one_printer'] != ""){ $one_printer= $_POST['one_printer']; } elseif($_GET['one_printer'] != ""){ $one_printer= $_GET['one_printer']; } else { $one_printer= '*'; } $num = $_POST['num']; $status = $_POST['status']; $queue = $_POST['queue']; $period = $_POST['period']; $pages = $_POST['pages']; $printer = $_POST['printer']; $quota = $_POST['quota']; $valids = $_POST['valids']; $validq = $_POST['validq']; $all_printers=search_printers ("printer-name=".$one_printer); $nb_printers=count($all_printers); if (isset($quota)) { if ($quota == "Valider") { $period_sec=$period*86400; } else { $pages=$period_sec=0; } exec("/usr/sbin/lpadmin -p $printer -o job-page-limit=$pages -o job-quota-period=$period_sec"); } if (isset($valids)){ if(file_exists("/usr/bin/enable")){ $able=$status; } else { $able="cups".$status; } exec ("/usr/bin/$able {$all_printers[$num]['printer-name']}"); } elseif (isset($validq)) { if(file_exists("/usr/bin/accept")){ $able=$queue; } else { $able="cups".$queue; } exec ("/usr/sbin/$able {$all_printers[$num]['printer-name']}"); } // Bug Lenny if (isset($_GET['disable_lenny_bug'])) { system ("sudo /usr/share/se3/scripts/disable_lenny_bug.sh"); } //Recuperation des champs Printers,QuotaPeriod,PageLimit de /etc/cups/printers.conf $result1=exec("/usr/bin/sudo /usr/share/se3/scripts/printless.sh /etc/cups/printers.conf | grep \"<*[^/ ]Printer\" | sed s/^.*Printer' '/\"\"/g",$nom_imprim); $result2=exec("/usr/bin/sudo /usr/share/se3/scripts/printless.sh /etc/cups/printers.conf | grep PageLimit | cut -c 11-",$nb_p); $result3=exec("/usr/bin/sudo /usr/share/se3/scripts/printless.sh /etc/cups/printers.conf | grep QuotaPeriod | cut -c 13-",$nb_s); //L'ordre de listage des imprimantes dans printers.conf ne correspond pas necessairement a celui de ldap // d'ou la necessite de lister celui de printers.conf conformement a celui de ldap de facon a ce que les quotas // correspondent aux bonnes imprimantes $n=count($nom_imprim); for ($i=0;$i<$nb_printers;$i++) { $j=0; while ( ( $all_printers[$i]['printer-name'].">" != $nom_imprim[$j]) && ($j <= $n) ) { $j++; } $nb_pages[$i]=$nb_p[$j]; $nb_sec[$i]=$nb_s[$j]; } //Affichage du navigateur d'imprimantes si non $one_printer : if ($one_printer == "*") { echo "

".gettext("Gestion des imprimantes")."

"; if (count($all_printers)) { if($_GET['lieu']==1) { usort($all_printers, "cmp_location"); } else {usort($all_printers, "cmp_printer"); } } // Test serveur cups $status=exec("LC_ALL=C /usr/bin/lpstat -r"); echo "\n
\n
\n"; echo "\n"; echo "\n"; echo ""; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; for ($loop=0; $loop<$nb_printers; $loop++) { $printer=$all_printers[$loop]['printer-name']; echo ""; echo ""; } echo "
\"Imprimante\""; echo ""; if($nb_printers<6) { echo "$printer"; } else { echo "$printer"; } echo ""; echo $all_printers[$loop]['printer-info']; echo ""; echo $all_printers[$loop]['printer-location']; echo ""; $list_parcs=search_machines("objectclass=groupOfNames","parcs"); $pass=0; if ( count($list_parcs)>0) { sort($list_parcs); for ($loopp=0; $loopp < count($list_parcs); $loopp++) { $parc=$list_parcs[$loopp]["cn"]; $imp=gof_members($parc,"parcs",1); if (count($imp)>0) { for ($loopmp=0; $loopmp < count($imp);$loopmp++) { $comp=trim($imp[$loopmp]); $printer=trim($printer); if ("$comp" == "$printer") { echo ""; echo $list_parcs[$loopp]["cn"]; echo ""; echo "
"; $pass=1; } } } } } if($pass==0) { echo "Sans parc"; } echo "

\n"; } // Si trop d'imprimante (>6) on ne les affiche plus if (($nb_printers>5) && ($_GET['action'] != "all")) { echo "

"; echo "".gettext("Détail de toutes les imprimantes")." "; echo " "; echo "
"; include "pdp.inc.php"; exit; } if($_GET['action']=="all") { echo "
\n"; } for ($loop=0; $loop<$nb_printers; $loop++) { $printer=$all_printers[$loop]['printer-name']; if((one_printer!="") && ($_GET['action'] !="all")) { echo "

".gettext("Liste des imprimantes")."

"; } // echo $printer; echo "\n"; // Ajout pour pouvoir modifier echo "\n"; echo "\n
"; echo "$printer\n"; echo ""; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if (is_admin("se3_is_admin",$login)=="Y") { echo "\n"; } echo "
\n"; echo "
\n"; $URI=preg_replace("/:[^:]*@/", ":*******@", $all_printers[$loop]['printer-uri']); echo "

\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $sys= exec("LC_ALL=C /usr/bin/lpstat -o $printer"); if ($sys != "") { echo "\n"; } else { echo "\n"; } echo "\n"; $sys= exec("LC_ALL=C /usr/bin/lpstat -p $printer | grep enabled"); if ($sys != "") { echo "\n"; $status="disable"; } else { echo "\n"; $status="enable"; } echo "\n"; echo "\n"; echo "\n"; $sys= exec("LC_ALL=C /usr/bin/lpstat -a $printer | grep not"); if ($sys != "") { echo "\n"; $queue="accept"; } else { echo "\n"; $queue="reject"; } echo "\n"; echo "\n"; echo "
URI:$URI
".gettext("Emplacement:")."{$all_printers[$loop]['printer-location']}
".gettext("Description:")."{$all_printers[$loop]['printer-info']}
".gettext("Travaux en cours:")."".gettext("OUI")."
".gettext("NON")."
".gettext("Etat:")."".gettext("Active")."".gettext("Inactive")."\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
".gettext("Activer/Désactiver l'imprimante")."
".gettext("Travaux d'impression:")."".gettext("Rejette")."".gettext("Accepte")."\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
".gettext("Accepter/Rejeter les travaux")."
\n"; echo "
"; //Affiche le bouton pour basculer sur la page travaux d'impression echo "
\n"; echo "\n"; // AJOUT: boireaus pour permettre un retour apres consultation des travaux echo "\n"; echo "\n"; echo " ".gettext("Voir les travaux"); echo "
\n"; //Affichage du formulaire de quota $nb_jours[$loop]=round(($nb_sec[$loop])/86400); echo "
\n"; echo "\n"; echo "\n"; echo gettext("Définir un quota:"); echo " ".gettext("Nombre de pages: "); echo "\n"; echo " ".gettext("tous les: "); echo "\n"; echo " ".gettext("jours")."    "; echo "\n"; echo "\n"; echo "  "; echo "\n"; echo "
\n"; system("sudo /usr/share/se3/scripts/lenny_bug.sh $printer", $ret); if ($ret == "1") { echo "

Cette imprimante ne semble pas partagée avec le bon nom, si c'est le cas, cliquez ici pour la réactiver

"; } echo "
\n"; } } include "pdp.inc.php"; ?>