page == 1) { $title = $this->data['titre']; // $height = 20; $max_length = 55; if(strlen($title ) > $max_length){ $first = substr($title, 0, $max_length); $last = substr($title, $max_length); $title = trim($first).'
'.trim($last); } $this->SetTextColor(0, 0, 0); // Logo $image_file = 'https://www.terrenourriciere.org/pram/logo_pram.jpg'; // $this->Image($image_file, 165, 5, 30, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false); $header = ''; $header .= ''; $header .= ''; $header .= ''; $header .= ''; $header .= '
'; $header .= 'Retour d\'expérience
'; $header .= ''.$title.''; $header .= '
'; $header .= 'Logo PRAM'; // $header .= 'Logo PRAM'; $header .= '
'; $this->writeHTML($header, true, false, true, false, ''); } } // Page footer public function Footer() { $this->SetFont('opensans', '', 8); // Position at 15 mm from bottom $this->SetY(-15); // Set font // $this->SetFont('times', 'I', 8); $footer = "
  
"; $footer .= '

Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages().'

'; $footer .= "
"; $footer .= '

Retour d\'expérience - PRAM Occitanie

'; $footer .= "
"; // $footer .= ''; $footer .= "
"; $this->writeHTML($footer, true, false, true, false, ''); } } // create new PDF document $unicode = true; $format = "UTF-8"; // $format = "utf8"; $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, $unicode, $format, false); $db = new PDO( 'mysql:host=pramockspip.mysql.db;dbname=pramockspip', 'pramockspip', '6Q9zBUZMAAEy', array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8") ); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdf->site_info = []; $sql = 'SELECT * FROM pram_meta WHERE nom IN ("adresse_site", "nom_site")'; $req = $db->query($sql); $errordb=$db->errorInfo(); if($errordb[2]!='') exit('Erreur SQL !
'.$sql.'
'.$errordb[2]); while($result = $req->fetch(PDO::FETCH_ASSOC)){ $pdf->site_info[$result['nom']] = $result['valeur']; } // echo "
"; var_dump($pdf->site_info); echo "
"; $pdf->data = []; if(isset($_GET['article'])){ $sql = 'SELECT * FROM pram_articles WHERE id_article='.intval($_GET['article']); $req = $db->query($sql); $errordb=$db->errorInfo(); if($errordb[2]!='') exit('Erreur SQL !
'.$sql.'
'.$errordb[2]); $pdf->data = $req->fetch(PDO::FETCH_ASSOC); $sql = 'SELECT * FROM pram_documents_liens LEFT JOIN pram_documents ON pram_documents.id_document = pram_documents_liens.id_document WHERE id_objet='.$pdf->data['id_article']; $req = $db->query($sql); $errordb=$db->errorInfo(); if($errordb[2]!='') exit('Erreur SQL !
'.$sql.'
'.$errordb[2]); while($result = $req->fetch(PDO::FETCH_ASSOC)){ $pdf->data['documents'][$result['id_document']] = $result; } if($pdf->data['porteur'] != ''){ $id_porteur = explode('|', $pdf->data["porteur"])[1]; $sql = 'SELECT pram_articles.id_article, pram_articles.titre, pram_documents_liens.id_document, pram_documents.fichier FROM pram_articles LEFT JOIN pram_documents_liens ON pram_articles.id_article = pram_documents_liens.id_objet LEFT JOIN pram_documents ON pram_documents_liens.id_document = pram_documents.id_document WHERE pram_articles.id_article='.intval($id_porteur); $req = $db->query($sql); $errordb=$db->errorInfo(); if($errordb[2]!='') exit('Erreur SQL !
'.$sql.'
'.$errordb[2]); $pdf->data['porteur'] = $req->fetch(PDO::FETCH_ASSOC); // echo "
"; var_dump($pdf->data['porteur']); echo "
"; } }else{ die("Aucun article trouvé"); } $url = $pdf->site_info['adresse_site']."/spip.php?page=fiche-pdf&projet=".$pdf->data['id_article']."&var_mode=recalcul"; $content = ''; $fp = @fopen($url,"r"); //lecture du fichier if($fp != ''){ while (!feof($fp)) { //on parcoure toutes les lignes $content .= fgets($fp, 4096); // lecture du contenu de la ligne } fclose($fp); } // $url = "https://".$_SERVER['SERVER_ADDR']."/spip.php?page=fiche-pdf&projet=".$pdf->data['id_article']."&var_mode=recalcul"; $host = "Host: ".$_SERVER['SERVER_NAME']; // echo "
"; var_dump($host); echo "
"; // echo "
"; var_dump($url); echo "
"; // $c = curl_init(); // $headers = array($host); // curl_setopt($c, CURLOPT_HTTPHEADER, $headers); // curl_setopt($c, CURLOPT_URL, $url); // curl_setopt($c, CURLOPT_RETURNTRANSFER, true); // curl_setopt($c, CURLOPT_TIMEOUT, 1); // curl_setopt($c, CURLOPT_USERAGENT, 'Mozilla/5.001 (windows; U; NT4.0; en-US; rv:1.0) Gecko/25250101'); // curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 5); // $content = curl_exec($c); // $context = stream_context_create(array('http' => array('header'=>'Connection: close\r\n'))); // $content = file_get_contents($url, false, $context); // echo "
"; var_dump(array($head, $errStr, $errNum, $ci)); echo "
"; // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('PRAM'); $pdf->SetTitle($pdf->data['titre']); $pdf->SetSubject('Retour d\'expérience'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); // set header and footer fonts $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(10, 25, 10); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // add a page $pdf->AddPage(); // exit($content); // $tbl = $tbl_content; $pdf->writeHTML($content, true, false, true, false, ''); // --------------------------------------------------------- //Close and output PDF document $pdf->Output('Titre'.'.pdf', 'I'); die(); //============================================================+ // END OF FILE //============================================================+ ?>