informatique:printer

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
informatique:printer [04/10/2019 14:25] ldalbegueinformatique:printer [01/07/2026 09:14] (Version actuelle) bchicard
Ligne 1: Ligne 1:
-==== Annuaire du GNI ====+~~NOCACHE~~
  
 <PHP> <PHP>
  
-// mydap version 4 +echo 
-// https://samjlevy.com/mydap/ +<style> 
- function mydap_start($username,$password,$host,$port=389) { +.pc-wrap font-familyArialsans-seriffont-size: 14pxcolor: #333max-width: 720px; } 
- global $mydap; +.pc-intro font-size: 13pxcolor: #666margin-bottom20pxborder-left: 3px solid #378ADDpadding6px 6px 14pxline-height1.6; }
- if(isset($mydap)) die('Error, LDAP connection already established'); +
-  +
- // Connect to AD +
- $mydap = ldap_connect($host,$port) or die('Error connecting to LDAP'); +
-  +
- ldap_set_option($mydap,LDAP_OPT_PROTOCOL_VERSION,3); +
- @ldap_bind($mydap,$username,$password) or die('Error binding to LDAP: '.ldap_error($mydap)); +
-  +
- return true; +
-+
-  +
-function mydap_end() { +
- global $mydap; +
- if(!isset($mydap)) die('Error, no LDAP connection established'); +
-  +
- // Close existing LDAP connection +
- ldap_unbind($mydap); +
-+
-  +
-function mydap_attributes($user_dn,$keep=false) { +
- global $mydap; +
- if(!isset($mydap)) die('Error, no LDAP connection established'); +
- if(empty($user_dn)) die('Error, no LDAP user specified'); +
-  +
- // Disable pagination setting, not needed for individual attribute queries +
- ldap_control_paged_result($mydap,1); +
-  +
- // Query user attributes +
- $results = (($keep) ? ldap_search($mydap,$user_dn,'cn=*',$keep) : ldap_search($mydap,$user_dn,'cn=*')) +
- or die('Error searching LDAP: '.ldap_error($mydap)); +
-  +
- $attributes = ldap_get_entries($mydap,$results); +
-  +
- // Return attributes list +
- if(isset($attributes[0])) return $attributes[0]; +
- else return array(); +
-+
-  +
-function mydap_members($object_dn,$object_class='g') { +
- global $mydap; +
- if(!isset($mydap)) die('Error, no LDAP connection established'); +
- if(empty($object_dn)) die('Error, no LDAP object specified'); +
-  +
- // Determine class of object we are dealing with +
-  +
- // Groups, use range to overcome LDAP attribute limit +
- if($object_class == 'g') { +
- $output = array(); +
- $range_size = 1500; +
- $range_start = 0; +
- $range_end = $range_size 1; +
- $range_stop = false; +
-  +
- do { +
- // Query Group members +
- $results = ldap_search($mydap,$object_dn,'cn=*',array("member;range=$range_start-$range_end")) or die('Error searching LDAP'.ldap_error($mydap)); +
- $members = ldap_get_entries($mydap,$results); +
-  +
- $member_base = false; +
-  +
- // Determine array key of the member results +
-  +
- // If array key matches the format of range=$range_start-* we are at the end of the results +
- if(isset($members[0]["member;range=$range_start-*"])) { +
- // Set flag to break the do loop +
- $range_stop = true; +
- // Establish the key of this last segment +
- $member_base = $members[0]["member;range=$range_start-*"]; +
-  +
- // Otherwise establish the key of this next segment +
- elseif(isset($members[0]["member;range=$range_start-$range_end"])) +
- $member_base = $members[0]["member;range=$range_start-$range_end"]; +
-  +
- if($member_base && isset($member_base['count']) && $member_base['count'] != 0) { +
- // Remove 'count' element from array +
- array_shift($member_base); +
-  +
- // Append this segment of members to output +
- $output = array_merge($output,$member_base); +
- } else $range_stop = true; +
-  +
- if(!$range_stop) { +
- // Advance range +
- $range_start = $range_end + 1; +
- $range_end = $range_end + $range_size; +
-+
- } while($range_stop == false); +
-  +
- // Containers and Organizational Units, use pagination to overcome SizeLimit +
- } elseif($object_class == 'c' || $object_class == "o") { +
-  +
- $pagesize = 1000; +
- $counter = ""; +
- do { +
- ldap_control_paged_result($mydap,$pagesize,true,$counter); +
-  +
- // Query Container or Organizational Unit members +
- $results = ldap_search($mydap,$object_dn,'objectClass=user',array('sn')) or die('Error searching LDAP'.ldap_error($mydap)); +
- $members = ldap_get_entries($mydap, $results); +
-  +
- // Remove 'count' element from array +
- array_shift($members); +
-  +
- // Pull the 'dn' from each result, append to output +
- foreach($members as $e) $output[] = $e['dn']; +
-  +
- ldap_control_paged_result_response($mydap,$results,$counter); +
- } while($counter !== null && $counter != ""); +
-  +
- // Invalid object_class specified +
- } else die("Invalid mydap_member object_class, must be c, g, or o"); +
-  +
- // Return alphabetized member list +
- sort($output); +
- return $output; +
-+
-  +
-// ================================================================================== +
-// Example Usage +
-// ================================================================================== +
-/*  +
-// Establish connection +
-mydap_start( +
- 'joe@ad.local', // Active Directory search user +
- 'password', // Active Directory search user password +
- 'ad.local', // Active Directory server +
- 389 // Port (optional) +
-); +
-  +
-// Query users using mydap_members(object_dn,object_class) +
-// The object_dn parameter should be the distinguishedName of the object +
-// The object_class parameter should be 'c' for Container, 'g' for Group, or 'o' for Organizational Unit +
-// If left blank object_class will assume Group +
-// Exthe default 'Users' object in AD is a Container +
-// The function returns an array of member distinguishedName'+
-$members = mydap_members('CN=Users,DC=ad,DC=local','c'); +
-if(!$members) die('No members found, make sure you are specifying the correct object_class'); +
-  +
-// Now collect attributes for each member pulled +
-// Specify user attributes we want to collect, to be used as the keep parameter of mydap_attributes +
-$keep = array('samaccountname','mail','employeeID'); +
-  +
-// Iterate each member to get attributes +
-$i = 1; // For counting our output +
-foreach($members as $m) { +
- // Query a user's attributes using mydap_attributes(member_dn,keep) +
- // The member_dn is the step $m of this foreach +
- $attr = mydap_attributes($m,$keep); +
-  +
- // Each attribute is returned as an array, the first key is [count], [0]+ will contain the actual value(s) +
- // You will want to make sure the key exists to account for situations in which the attribute is not returned (has no value) +
- $employeeID = isset($attr['employeeid'][0]) ? $attr['employeeid'][0] "[no employee ID]"; +
- $samaccountname = isset($attr['samaccountname'][0]) ? $attr['samaccountname'][0] : "[no account name]"; +
- $mail = isset($attr['mail'][0]) ? $attr['mail'][0] "[no email]"; +
-  +
- // Do what you will, such as store or display member information +
- echo "$i$samaccountname, $mail - $employeeID<br>"; +
-  +
- $i++; +
-} +
-  +
-// Here you could run another mydap_members() if needed, merge with previous results, etc. +
-  +
-// Close connection +
-mydap_end(); +
-*/  +
-// Here you can open a new connection with mydap_connect() if needed, such as to a different AD server+
  
-mydap_start( +.pc-hero { display: flex; align-items: center; gap: 16px; background: #E8F0FB; border: 1px solid #BFDBFE; border-radius: 12px; padding: 18px 22px; margin-bottom: 24px; } 
- 'olympe@gni.loc', // Active Directory search user +.pc-hero-icon { width: 50px; height: 50px; border-radius: 12px; background: #185FA5; display: flex; align-items: center; justify-content: center; flex-shrink: 0; } 
- '*GNI/2011', // Active Directory search user password +.pc-hero-icon svg { width: 24px; height: 24px; } 
- 'sc-srv-ad.gni.loc', // Active Directory server +.pc-hero-title { font-size: 17px; font-weight: 700; color: #185FA5; margin-bottom: 3px; } 
- 389 // Port (optional) +.pc-hero-sub { font-size: 12px; color: #4B7BAE}
-);+
  
-$members = mydap_members('OU=Personnel,OU=Users,OU=Current,OU=GNI,DC=gni,DC=loc','c')+.pc-block { margin-bottom: 22px} 
-if(!$members) die('No members found, make sure you are specifying the correct object_class'); +.pc-block-title { font-size: 13pxfont-weight700; text-transform: uppercase; letter-spacing: 0.8px; color: #1A4A7A; margin-bottom: 10px; } 
-echo 'Nbr de Personnes dans l\'annuaire count($members) '<br/>';+.pc-text { font-size: 13px; color: #444; line-height: 1.7; margin-bottom: 10px}
  
-// Now collect attributes for each member pulled +.pc-features { display: grid; grid-template-columns: repeat(auto-fitminmax(220px1fr)); gap: 10px} 
-// Specify user attributes we want to collectto be used as the keep parameter of mydap_attributes +.pc-feature background: #f8fafd; border: 0.5px solid #dde3ec; border-radius: 10px; padding: 12px 14px; display: flex; align-items: flex-start; gap: 10px; } 
-$keep = array('samaccountname','mail','cn','ipphone','mobile','telephonenumber','title','givenName','sn','pager','facsimile TelephoneNumber'); +.pc-feature svg { flex-shrink: 0; margin-top: 2px; } 
-foreach($members as $m) +.pc-feature-text { font-size: 12.5px; color: #444; line-height: 1.5}
- // Query a user's attributes using mydap_attributes(member_dn,keep) +
- // The member_dn is the step $m of this foreach +
- $attr = mydap_attributes($m,$keep);+
  
-  // Each attribute is returned as an array, the first key is [count], [0]+ will contain the actual value(s) +.pc-key-title { font-size13pxfont-weight700color#1a2d4amargin: 6px 8px} 
- // You will want to make sure the key exists to account for situations in which the attribute is not returned (has no value) +.pc-key-item { displayflexalign-itemsflex-startgap10pxmargin-bottom10pxfont-size13pxcolor#444line-height: 1.6; } 
-  +.pc-key-item svg { flex-shrink: 0; margin-top3px}
- $user['login'] = isset($attr['samaccountname'][0]) ? $attr['samaccountname'][0] ""; +
- $user['mail'] = isset($attr['mail'][0]) ? $attr['mail'][0] ""; +
- $user['nom'] = isset($attr['sn'][0]) ? $attr['sn'][0] ""; +
- $user['prenom'] = isset($attr['givenname'][0]) ? $attr['givenname'][0] : ""+
- $user['fullname'] = isset($attr['cn'][0]) ? $attr['cn'][0] ""; +
- $user['telip'] = isset($attr['ipphone'][0]) ? $attr['ipphone'][0] ""; +
- $user['telmob'] = isset($attr['mobile'][0]) ? $attr['mobile'][0] ""; +
- $user['telext'] = isset($attr['telephonenumber'][0]) ? $attr['telephonenumber'][0] ""; +
- $user['fonction'] = isset($attr['title'][0]) ? $attr['title'][0] ""; +
- $user['code'] = isset($attr['pager'][0]) ? $attr['pager'][0] ""+
- $user['badge'] = isset($attr['facsimile TelephoneNumber'][0]) ? $attr['facsimile TelephoneNumber'][0] "";+
  
-//Photo des users +.pc-btn { displayinline-flexalign-items: center; gap: 8px; font-weight: 600; padding: 10px 20px; border-radius: 8px; text-decoration: none; font-size: 13px; color: #fff !important; margin-top: 6px; margin-right: 10px; } 
-$file = 'https://gni.gretani.com/tools/thumb/'.$user['login'].'.jpg'+.pc-btn:hover { text-decoration: none !importantopacity: 0.9; } 
-$file_headers = @get_headers($file); +.pc-btn-primary { background: #185FA5; } 
-if($file_headers[0] == 'HTTP/1.1 404 Not Found') { +.pc-btn-secondary background: #7F77DD; } 
-    $user['photo'] = 'tools\thumb\personne.jpg'; +</style>';
-+
-else +
-    $user['photo'] = 'tools\\thumb\\'.$user['login'].'.jpg'; +
-}+
  
- $users[$user['login']] $user; +echo '<div class="pc-wrap">';
-}+
  
-// Trie par nom +echo '<div class="pc-hero"> 
-foreach ($users as $key => $row)  +    <div class="pc-hero-icon"> 
-{ +        <svg viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9V2h12v7"/><path d="M6 18H4a2 2 0 01-2-2v-5a2 2 0 012-2h16a2 2 0 012 2v5a2 2 0 01-2 2h-2"/><rect x="6" y="14" width="12" height="8"/></svg
- $rang[$key] $row['nom']; +    </div> 
-} +    <div> 
-array_multisort($rang, SORT_ASC, $users);+        <div class="pc-hero-title">PaperCut — Gestion des impressions</div> 
 +        <div class="pc-hero-sub">Système d\'accounting des impressions au GNI</div> 
 +    </div> 
 +</div>';
  
-// Génération du tableau de sortie +// ── Pourquoi PaperCut ────────────────────────────────────── 
-echo '<br>'; +echo '<div class="pc-block">'; 
-echo '<table border=1 align="center">'; +echo '<div class="pc-block-title">Pourquoi PaperCut ?</div>'
-echo '<tr align="center"><td align="center" colspan=2>Nom</td><td align="center"> Tel Interne </td><td align="center"> Tel Externe & Tel Mobile </td><td align="center">Fonction</td></tr>'<td align="center">Code</td></tr>'<td align="center">Badge</td></tr>';+echo '<p class="pc-text">PaperCut est une solution logicielle dédiée à la gestion et au suivi des impressions dans les environnements éducatifs et professionnels. Au Greta Nord-Isère, PaperCut nous permet de :</p>';
  
-foreach($users as $login => $user)  +echo '<div class="pc-features">'; 
-{ + 
- echo '<tr align="center"><td align="center"><img src='.$user['photo'].height="50"></td><td align="left"><a href="mailto:'.$user['mail'].'">'. '.$user['nom'].' '.$user['prenom'].'</a></td><td> '.$user['telip'].' </td><td> '.$user['telext'].'<br>'.$user['telmob'].' </td><td> '.$user['fonction'].</td><td> '.$user['code'].' </td><td> '.$user['badge'].' </td></tr>';+$features = [ 
 +    ['icon' => '<circle cx="12cy="12" r="10"/><path d="M12 8v4l3 3"/>', 'text' ='Contrôler les coûts en attribuant des quotas d\'impression à chaque utilisateur']
 +    ['icon' => '<path d="M3 3v18h18"/><path d="M18 9l-5 5-4-4-3 3"/>',    'text=> 'Réduire le gaspillage en encourageant une utilisation responsable des ressources']
 +    ['icon=> '<path d="M9 11l3 3L22 4"/><path d="M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"/>', 'text' => 'Suivre les impressions (N&B, couleur, recto-verso...) pour une gestion transparente'], 
 +    ['icon=> '<rect x="3" y="3" width="18" height="18" rx="2"/><path d="M9 9h6v6H9z"/>''text=> 'Simplifier l\'administration grâce à une interface intuitive pour tous']
 +]; 
 + 
 +foreach ($features as $f) { 
 +    echo "<div class='pc-feature'> 
 +        <svg viewBox='0 0 24 24width='16height='16' fill='none' stroke='#185FA5' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'>{$f['icon']}</svg> 
 +        <span class='pc-feature-text'>{$f['text']}</span> 
 +    </div>";
 } }
  
-echo '</table>';+echo '</div></div>'; 
 + 
 +// ── Fonctionnalités clés ────────────────────────────────── 
 +echo '<div class="pc-block">'; 
 +echo '<div class="pc-block-title">Fonctionnalités clés</div>'; 
 + 
 +echo '<div class="pc-key-item"> 
 +    <svg viewBox="0 0 24 24" width="17" height="17" fill="none" stroke="#1D9E75" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0110 0v4"/></svg> 
 +    <span><strong>Authentification sécurisée</strong> — Connexion via les identifiants GRETA pour accéder aux services d\'impression.</span> 
 +</div>'; 
 + 
 +echo '<div class="pc-key-item"> 
 +    <svg viewBox="0 0 24 24" width="17" height="17" fill="none" stroke="#1D9E75" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M3 3v18h18"/><rect x="7" y="13" width="3" height="5"/><rect x="12" y="9" width="3" height="9"/><rect x="17" y="5" width="3" height="13"/></svg> 
 +    <span><strong>Tableau de bord utilisateur</strong> — Visualisation du solde, de l\'historique et des options d\'impression.</span> 
 +</div>'; 
 + 
 +echo '<a class="pc-btn pc-btn-primary" href="https://print.gretani.com" target="_blank"> 
 +    <svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="#fff" stroke-width="2"><path d="M9 11l3 3L22 4"/><path d="M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"/></svg> 
 +    Accéder à mon tableau de bord 
 +</a>'; 
 + 
 +echo '</div>'; 
 + 
 +// ── Besoin d'aide ────────────────────────────────────────── 
 +echo '<div class="pc-block">'; 
 +echo '<div class="pc-block-title">Besoin d\'aide ?</div>'; 
 +echo '<p class="pc-text">Consultez le tutoriel officiel PaperCut pour apprendre à utiliser le système.</p>'; 
 + 
 +echo '<a class="pc-btn pc-btn-secondary" href="https://files.gretani.com/gni/tutos_applicatif/papercut/sharp-copieur.pdf" target="_blank"> 
 +    <svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="#fff" stroke-width="2"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8l-6-6z"/><path d="M14 2v6h6"/></svg> 
 +    Tutoriel PaperCut — Guide utilisateur 
 +</a>'; 
 + 
 +echo '</div>'; 
 + 
 +echo '</div>';
  
 </PHP> </PHP>

Warning: Trying to access array offset on value of type bool in /var/www/html/lib/tpl/bootstrap3/Template.php on line 590
  • informatique/printer.1570195536.txt.gz
  • Dernière modification : 04/10/2019 14:25
  • de ldalbegue