[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 3 4 /** 5 6 * Permet une gestion individuelle des imprimantes 7 * @Version $Id: view_printers.php 8562 2015-03-15 13:37:26Z plouf $ 8 9 * @Projet LCS / SambaEdu 10 11 * @auteurs Patrice Andre <h.barca@free.fr> 12 * @auteurs Carip-Academie de Lyon 13 14 * @Licence Distribue selon les termes de la licence GPL 15 16 * @note 17 18 */ 19 20 /** 21 22 * @Repertoire: printers/ 23 * file: view_printers.php 24 25 */ 26 27 28 29 30 // Affiche les parametres de chaque imprimante 31 include "entete.inc.php"; 32 include "printers.inc.php"; 33 include "ihm.inc.php"; // pour is_admin() 34 //include "ldap.inc.php"; 35 36 require_once ("lang.inc.php"); 37 bindtextdomain('se3-printers',"/var/www/se3/locale"); 38 textdomain ('se3-printers'); 39 40 //aide 41 $_SESSION["pageaide"]="Imprimantes"; 42 43 if (is_admin("printers_is_admin",$login)=="Y") { 44 if ($_POST['one_printer'] != ""){ 45 $one_printer= $_POST['one_printer']; 46 } elseif($_GET['one_printer'] != ""){ 47 $one_printer= $_GET['one_printer']; 48 } else { 49 $one_printer= '*'; 50 } 51 52 $num = $_POST['num']; 53 $status = $_POST['status']; 54 $queue = $_POST['queue']; 55 $period = $_POST['period']; 56 $pages = $_POST['pages']; 57 $printer = $_POST['printer']; 58 $quota = $_POST['quota']; 59 $valids = $_POST['valids']; 60 $validq = $_POST['validq']; 61 62 $all_printers=search_printers ("printer-name=".$one_printer); 63 $nb_printers=count($all_printers); 64 65 if (isset($quota)) { 66 if ($quota == "Valider") { 67 $period_sec=$period*86400; 68 } else { 69 $pages=$period_sec=0; 70 } 71 exec("/usr/sbin/lpadmin -p $printer -o job-page-limit=$pages -o job-quota-period=$period_sec"); 72 } 73 if (isset($valids)){ 74 if(file_exists("/usr/bin/enable")){ 75 $able=$status; 76 } else { 77 $able="cups".$status; 78 } 79 exec ("/usr/bin/$able {$all_printers[$num]['printer-name']}"); 80 } elseif (isset($validq)) { 81 if(file_exists("/usr/bin/accept")){ 82 $able=$queue; 83 } else { 84 $able="cups".$queue; 85 } 86 exec ("/usr/sbin/$able {$all_printers[$num]['printer-name']}"); 87 } 88 89 // Bug Lenny 90 if (isset($_GET['disable_lenny_bug'])) { 91 system ("sudo /usr/share/se3/scripts/disable_lenny_bug.sh"); 92 } 93 94 //Recuperation des champs Printers,QuotaPeriod,PageLimit de /etc/cups/printers.conf 95 $result1=exec("/usr/bin/sudo /usr/share/se3/scripts/printless.sh /etc/cups/printers.conf | grep \"<*[^/ ]Printer\" | sed s/^.*Printer' '/\"\"/g",$nom_imprim); 96 $result2=exec("/usr/bin/sudo /usr/share/se3/scripts/printless.sh /etc/cups/printers.conf | grep PageLimit | cut -c 11-",$nb_p); 97 $result3=exec("/usr/bin/sudo /usr/share/se3/scripts/printless.sh /etc/cups/printers.conf | grep QuotaPeriod | cut -c 13-",$nb_s); 98 //L'ordre de listage des imprimantes dans printers.conf ne correspond pas necessairement a celui de ldap 99 // d'ou la necessite de lister celui de printers.conf conformement a celui de ldap de facon a ce que les quotas 100 // correspondent aux bonnes imprimantes 101 $n=count($nom_imprim); 102 for ($i=0;$i<$nb_printers;$i++) { 103 $j=0; 104 while ( ( $all_printers[$i]['printer-name'].">" != $nom_imprim[$j]) && ($j <= $n) ) { 105 $j++; 106 } 107 $nb_pages[$i]=$nb_p[$j]; 108 $nb_sec[$i]=$nb_s[$j]; 109 } 110 //Affichage du navigateur d'imprimantes si non $one_printer : 111 if ($one_printer == "*") { 112 echo "<H1>".gettext("Gestion des imprimantes")."</H1>"; 113 if (count($all_printers)) { 114 if($_GET['lieu']==1) { usort($all_printers, "cmp_location"); } else {usort($all_printers, "cmp_printer"); } 115 } 116 // Test serveur cups 117 $status=exec("LC_ALL=C /usr/bin/lpstat -r"); 118 echo "\n<br>\n<CENTER>\n"; 119 echo "<TABLE border=1 width=\"60%\">\n"; 120 121 echo "<tr class=menuheader style=\"height: 30\">\n"; 122 echo "<td colspan=\"5\" valign=\"middle\" align=\"center\">"; 123 echo "Serveur d'impression "; 124 if ($status=="scheduler is running") { 125 echo "<u onmouseover=\"return escape".gettext("('<b>Etat : Serveur cups en marche')")."\">"; 126 echo "<IMG style=\"border: 0px solid;\" SRC=\"../elements/images/enabled.png\" >"; 127 echo "</u>\n"; 128 } else { 129 echo "<u onmouseover=\"return escape".gettext("('<b>Etat : Serveur cups stoppé')")."\">"; 130 echo "<IMG style=\"border: 0px solid;\" SRC=\"../elements/images/disabled.png\" >"; 131 echo "</u>\n"; 132 } 133 echo "</td>"; 134 echo "</tr>"; 135 echo "<tr class=menuheader style=\"height: 30\">\n"; 136 137 echo "<td align=\"center\"></td>\n"; 138 echo "<td align=\"center\"><a href=view_printers.php>Imprimantes</a></td>\n"; 139 echo "<td align=\"center\">Information</td>\n"; 140 echo "<td align=\"center\"><a href=view_printers.php?lieu=1>Lieu</a></td>\n"; 141 echo "<td align=\"center\">Parc</td>\n"; 142 echo "</tr>"; 143 144 for ($loop=0; $loop<$nb_printers; $loop++) { 145 $printer=$all_printers[$loop]['printer-name']; 146 147 echo "<TR>"; 148 echo "<td align=\"center\"><img style=\"border: 0px solid ;\" src=\"../elements/images/printer.png\" title=\"Imprimante\" alt=\"Imprimante\">"; 149 echo "</TD><TD>"; 150 if($nb_printers<6) { 151 echo "<A HREF=\"#tag[$loop]\">$printer</A>"; 152 } else { 153 echo "<A href='view_printers.php?one_printer=$printer'>$printer</A>"; 154 } 155 echo "</TD><TD>"; 156 echo $all_printers[$loop]['printer-info']; 157 echo "</TD><TD>"; 158 echo $all_printers[$loop]['printer-location']; 159 echo "</TD><TD>"; 160 $list_parcs=search_machines("objectclass=groupOfNames","parcs"); 161 $pass=0; 162 if ( count($list_parcs)>0) { 163 sort($list_parcs); 164 for ($loopp=0; $loopp < count($list_parcs); $loopp++) { 165 $parc=$list_parcs[$loopp]["cn"]; 166 $imp=gof_members($parc,"parcs",1); 167 if (count($imp)>0) { 168 for ($loopmp=0; $loopmp < count($imp);$loopmp++) { 169 $comp=trim($imp[$loopmp]); 170 $printer=trim($printer); 171 if ("$comp" == "$printer") { 172 echo "<A href=../parcs/show_parc.php?parc=".$list_parcs[$loopp]["cn"].">"; 173 echo $list_parcs[$loopp]["cn"]; 174 echo "</A>"; 175 echo "<br>"; 176 $pass=1; 177 } 178 } 179 } 180 } 181 } 182 if($pass==0) { echo "Sans parc"; } 183 echo "</TD></TR>"; 184 185 } 186 echo "</TABLE><br>\n"; 187 } 188 189 // Si trop d'imprimante (>6) on ne les affiche plus 190 if (($nb_printers>5) && ($_GET['action'] != "all")) { 191 echo "<br><hr><center>"; 192 echo "<A href='view_printers.php?action=all'>".gettext("Détail de toutes les imprimantes")."</A> "; 193 echo " <u onmouseover=\"return escape".gettext("('Permet de voir le détail de toutes les imprimantes. Cela peut être très long à afficher si vous en avez beaucoup.')")."\"><img name=\"action_image2\" src=\"../elements/images/system-help.png\"></u> "; 194 echo "</center>"; 195 196 include "pdp.inc.php"; 197 exit; 198 } 199 if($_GET['action']=="all") { 200 echo "<HR>\n"; 201 } 202 for ($loop=0; $loop<$nb_printers; $loop++) { 203 $printer=$all_printers[$loop]['printer-name']; 204 205 if((one_printer!="") && ($_GET['action'] !="all")) { 206 echo "<H1>".gettext("Liste des imprimantes")."</H1>"; 207 } 208 // echo $printer; 209 echo "<TABLE width=\"90%\"><TR><TD width=\"80%\">"; 210 echo "<FONT SIZE=5><A NAME=\"tag[$loop]\"><B>$printer</B></A></FONT>\n"; 211 echo "</TD>\n"; 212 // Ajout pour pouvoir modifier 213 echo "<TD>"; 214 echo "<FORM ACTION=\"config_printer.php\" METHOD=\"post\">\n"; 215 echo "<INPUT TYPE=\"hidden\" VALUE=\"$printer\" NAME=\"nom_imprimante\">\n"; 216 echo "<INPUT TYPE=\"hidden\" VALUE=\"".$all_printers[$loop]['printer-uri']."\" NAME=\"uri_printer\">\n"; 217 echo "<INPUT TYPE=\"hidden\" VALUE=\"".$all_printers[$loop]['printer-location']."\" NAME=\"lieu_printer\">\n"; 218 echo "<INPUT TYPE=\"hidden\" VALUE=\"".$all_printers[$loop]['printer-info']."\" NAME=\"info_printer\">\n"; 219 echo "<INPUT TYPE=\"hidden\" VALUE=\"".$all_printers[$loop]['printer-more-info']."\" NAME=\"dev_mode\">\n"; 220 221 echo "<INPUT TYPE=\"hidden\" VALUE=\"".$all_printers[$loop]['nprinthardwarequeuename']."\" NAME=\"driver_printer\">\n"; 222 if (is_admin("se3_is_admin",$login)=="Y") { 223 echo "<INPUT TYPE=\"submit\" VALUE=\"".gettext("Modifier")."\" NAME=\"modifs\">\n"; 224 } 225 echo "</FORM>\n"; 226 echo "</TD>\n"; 227 228 echo "</TR>\n</TABLE>\n"; 229 $URI=preg_replace("/:[^:]*@/", ":*******@", $all_printers[$loop]['printer-uri']); 230 echo "<BR><BR>\n"; 231 echo "<TABLE BORDER=0>\n"; 232 echo "<TR><TD BGCOLOR=\"cornflowerblue\"><B>URI:</B></TD><TD WIDTH=300 BGCOLOR=\"cornflowerblue\">$URI</TD></TR>\n"; 233 echo "<TR><TD BGCOLOR=\"cornflowerblue\"><B>".gettext("Emplacement:")."</B></TD><TD WIDTH=300 BGCOLOR=\"cornflowerblue\">{$all_printers[$loop]['printer-location']}</TD></TR>\n"; 234 echo "<TR><TD BGCOLOR=\"cornflowerblue\"><B>".gettext("Description:")."</B></TD><TD WIDTH=300 BGCOLOR=\"cornflowerblue\">{$all_printers[$loop]['printer-info']}</TD></TR>\n"; 235 echo "<TR><TD BGCOLOR=\"cornflowerblue\"><B>".gettext("Travaux en cours:")."</B></TD>\n"; 236 $sys= exec("LC_ALL=C /usr/bin/lpstat -o $printer"); 237 if ($sys != "") { 238 echo "<TD BGCOLOR=\"cornflowerblue\"><BLINK>".gettext("OUI")."</BLINK></TD></TR>\n"; 239 } else { 240 echo "<TD BGCOLOR=\"cornflowerblue\">".gettext("NON")."</TD></TR>\n"; 241 } 242 echo "<TR><TD BGCOLOR=\"lightsteelblue\"><B>".gettext("Etat:")."</B></TD>\n"; 243 $sys= exec("LC_ALL=C /usr/bin/lpstat -p $printer | grep enabled"); 244 if ($sys != "") { 245 echo "<TD BGCOLOR=\"lightsteelblue\"><FONT COLOR=\"green\">".gettext("Active")."</FONT></TD>\n"; 246 $status="disable"; 247 } else { 248 echo "<TD BGCOLOR=\"lightsteelblue\"><FONT COLOR=\"red\">".gettext("Inactive")."</FONT></TD>\n"; 249 $status="enable"; 250 } 251 echo "<TD BGCOLOR=\"lightsteelblue\">\n"; 252 echo "<FORM ACTION=\"view_printers.php\" METHOD=\"post\">\n"; 253 echo "<INPUT TYPE=\"hidden\" VALUE=\"$loop\" NAME=\"num\">\n"; 254 echo "<INPUT TYPE=\"hidden\" VALUE=\"$status\" NAME=\"status\">\n"; 255 echo "<INPUT TYPE=\"hidden\" VALUE=\"$one_printer\" NAME=\"one_printer\">\n"; 256 echo "<INPUT TYPE=\"submit\" VALUE=\"".gettext("Basculer")."\" NAME=\"valids\">\n"; 257 echo "</FORM></TD>\n"; 258 echo "<TD VALIGN=\"top\" BGCOLOR=\"lightsteelblue\">".gettext("Activer/Désactiver l'imprimante")."</TD></TR>\n"; 259 echo "<TR><TD BGCOLOR=\"lightsteelblue\"><B>".gettext("Travaux d'impression:")."</B></TD>\n"; 260 $sys= exec("LC_ALL=C /usr/bin/lpstat -a $printer | grep not"); 261 if ($sys != "") { 262 echo "<TD BGCOLOR=\"lightsteelblue\"><FONT COLOR=\"red\">".gettext("Rejette")."</FONT></TD>\n"; 263 $queue="accept"; 264 } else { 265 echo "<TD BGCOLOR=\"lightsteelblue\"><FONT COLOR=\"green\">".gettext("Accepte")."</FONT></TD>\n"; 266 $queue="reject"; 267 } 268 echo "<TD BGCOLOR=\"lightsteelblue\">\n"; 269 echo "<FORM ACTION=\"view_printers.php\" METHOD=\"post\">\n"; 270 echo "<INPUT TYPE=\"hidden\" VALUE=\"$loop\" NAME=\"num\">\n"; 271 echo "<INPUT TYPE=\"hidden\" VALUE=\"$queue\" NAME=\"queue\">\n"; 272 echo "<INPUT TYPE=\"hidden\" VALUE=\"$one_printer\" NAME=\"one_printer\">\n"; 273 echo "<INPUT TYPE=\"submit\" VALUE=\"".gettext("Basculer")."\" NAME=\"validq\">\n"; 274 echo "</FORM></TD>\n"; 275 echo "<TD VALIGN=\"top\" BGCOLOR=\"lightsteelblue\">".gettext("Accepter/Rejeter les travaux")."</TD></TR>\n"; 276 echo "</TABLE>\n"; 277 echo "<BR>"; 278 //Affiche le bouton pour basculer sur la page travaux d'impression 279 echo "<FORM ACTION=\"printer_jobs.php\" METHOD=\"post\">\n"; 280 echo "<INPUT TYPE=\"hidden\" VALUE=\"$printer\" NAME=\"printer\">\n"; 281 // AJOUT: boireaus pour permettre un retour apres consultation des travaux 282 echo "<INPUT TYPE=\"hidden\" VALUE=\"tag[$loop]\" NAME=\"tag\">\n"; 283 echo "<INPUT TYPE=\"submit\" VALUE=\"".gettext("Travaux")."\" NAME=\"travaux\">\n"; 284 echo " ".gettext("Voir les travaux"); 285 echo "</FORM>\n"; 286 287 //Affichage du formulaire de quota 288 $nb_jours[$loop]=round(($nb_sec[$loop])/86400); 289 echo "<FORM ACTION=\"view_printers.php\" METHOD=\"post\">\n"; 290 echo "<INPUT TYPE=\"hidden\" VALUE=\"$printer\" NAME=\"printer\">\n"; 291 echo "<INPUT TYPE=\"hidden\" VALUE=\"$loop\" NAME=\"num\">\n"; 292 echo gettext("Définir un quota:"); 293 echo " ".gettext("Nombre de pages: "); 294 echo "<INPUT TYPE=\"texte\" VALUE=\"$nb_pages[$loop]\" NAME=\"pages\" SIZE=\"6\">\n"; 295 echo " ".gettext("tous les: "); 296 echo "<INPUT TYPE=\"texte\" VALUE=\"$nb_jours[$loop]\" NAME=\"period\" SIZE=\"5\">\n"; 297 echo " ".gettext("jours")." "; 298 echo "<INPUT TYPE=\"hidden\" VALUE=\"$one_printer\" NAME=\"one_printer\">\n"; 299 echo "<INPUT TYPE=\"submit\" VALUE=\"".gettext("Valider")."\" NAME=\"quota\">\n"; 300 echo " "; 301 echo "<INPUT TYPE=\"submit\" VALUE=\"".gettext("Aucun")."\" NAME=\"quota\">\n"; 302 echo "</FORM>\n"; 303 system("sudo /usr/share/se3/scripts/lenny_bug.sh $printer", $ret); 304 if ($ret == "1") { 305 echo "<h2>Cette imprimante ne semble pas partagée avec le bon nom, si c'est le cas, cliquez <a href=view_printers.php?disable_lenny_bug>ici</a> pour la réactiver</h2>"; 306 } 307 echo "<HR>\n"; 308 309 } 310 } 311 312 include "pdp.inc.php"; 313 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |