Пример #1
0
 /**
  * Print generic footer
  *
  * @param $type display type (0=HTML, 1=Sylk,2=PDF,3=CSV)
  * @param $title title of file : used for PDF
  *
  * @return string to display
  **/
 static function showFooter($type, $title = "")
 {
     global $LANG;
     $out = "";
     switch ($type) {
         case PDF_OUTPUT_LANDSCAPE:
             //pdf
             global $PDF_HEADER, $PDF_ARRAY;
             $pdf = new Cezpdf('a4', 'landscape');
             $pdf->selectFont(GLPI_ROOT . "/lib/ezpdf/fonts/Helvetica.afm");
             $pdf->ezStartPageNumbers(750, 10, 10, 'left', "GLPI PDF export - " . convDate(date("Y-m-d")) . " - " . count($PDF_ARRAY) . " " . decodeFromUtf8($LANG['pager'][5], 'windows-1252') . " - {PAGENUM}/{TOTALPAGENUM}");
             $options = array('fontSize' => 8, 'colGap' => 2, 'maxWidth' => 800, 'titleFontSize' => 8);
             $pdf->ezTable($PDF_ARRAY, $PDF_HEADER, decodeFromUtf8($title, 'windows-1252'), $options);
             $pdf->ezStream();
             break;
         case PDF_OUTPUT_PORTRAIT:
             //pdf
             global $PDF_HEADER, $PDF_ARRAY;
             $pdf = new Cezpdf('a4', 'portrait');
             $pdf->selectFont(GLPI_ROOT . "/lib/ezpdf/fonts/Helvetica.afm");
             $pdf->ezStartPageNumbers(550, 10, 10, 'left', "GLPI PDF export - " . convDate(date("Y-m-d")) . " - " . count($PDF_ARRAY) . " " . decodeFromUtf8($LANG['pager'][5], 'windows-1252') . " - {PAGENUM}/{TOTALPAGENUM}");
             $options = array('fontSize' => 8, 'colGap' => 2, 'maxWidth' => 565, 'titleFontSize' => 8);
             $pdf->ezTable($PDF_ARRAY, $PDF_HEADER, decodeFromUtf8($title, 'windows-1252'), $options);
             $pdf->ezStream();
             break;
         case SYLK_OUTPUT:
             //sylk
             global $SYLK_HEADER, $SYLK_ARRAY, $SYLK_SIZE;
             // largeurs des colonnes
             foreach ($SYLK_SIZE as $num => $val) {
                 $out .= "F;W" . $num . " " . $num . " " . min(50, $val) . "\n";
             }
             $out .= "\n";
             // Header
             foreach ($SYLK_HEADER as $num => $val) {
                 $out .= "F;SDM4;FG0C;" . ($num == 1 ? "Y1;" : "") . "X{$num}\n";
                 $out .= "C;N;K\"" . sylk_clean($val) . "\"\n";
                 $out .= "\n";
             }
             // Datas
             foreach ($SYLK_ARRAY as $row => $tab) {
                 foreach ($tab as $num => $val) {
                     $out .= "F;P3;FG0L;" . ($num == 1 ? "Y" . $row . ";" : "") . "X{$num}\n";
                     $out .= "C;N;K\"" . sylk_clean($val) . "\"\n";
                 }
             }
             $out .= "E\n";
             break;
         case CSV_OUTPUT:
             //csv
             break;
         default:
             $out = "</table></div>\n";
     }
     return $out;
 }
Пример #2
0
 /**
  * Authentify a user by checking a specific mail server
  * @param $auth : identification object
  * @param $login : user login
  * @param $password : user password
  * @param $mail_method : mail_method array to use
  *
  * @return identification object
  **/
 static function mailAuth($auth, $login, $password, $mail_method)
 {
     if (isset($mail_method["connect_string"]) && !empty($mail_method["connect_string"])) {
         $auth->auth_succeded = $auth->connection_imap($mail_method["connect_string"], decodeFromUtf8($login), decodeFromUtf8($password));
         if ($auth->auth_succeded) {
             $auth->extauth = 1;
             $auth->user_present = $auth->user->getFromDBbyName(addslashes($login));
             $auth->user->getFromIMAP($mail_method, decodeFromUtf8($login));
             //Update the authentication method for the current user
             $auth->user->fields["authtype"] = Auth::MAIL;
             $auth->user->fields["auths_id"] = $mail_method["id"];
         }
     }
     return $auth;
 }