'Nazionalità',34=>'Tipologia',119=>'Birreria',118=>'Formato'); $confezioni=array(25=>'l.', 26=>'cl.'); $doc=(int)$_GET['doc']; if ($doc==0) die('errato avvio del programma'); $conn=mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die(mysql_error()); mysql_select_db(DB_NAME) or die(mysql_error()); mysql_query("SET CHARACTER SET utf8"); mysql_query("SET NAMES utf8"); $rs=mysql_query("select post_content, post_title, guid from wp_posts where id=$doc and post_status='publish'") or die(mysql_error()); if (mysql_num_rows($rs)==0){ die('Il documento richiesto non esiste'); } $x=mysql_fetch_assoc($rs); $sql="SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON (tt.term_id = t.term_id) INNER JOIN wp_term_relationships AS tr ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE tr.object_id IN ($doc) ORDER BY t.name ASC;"; $rs=mysql_query($sql) or die(mysql_error()); $cats=array('Tipologia'=>'','Nazionalità'=>'','Birreria'=>'','Equilibrio dolce-amaro'=>'','Grado alcolico'=>'','Formato'=>'','Capacità'=>''); $myCats=array(); while($y=mysql_fetch_assoc($rs)): $cats[$disp[$y['parent']]]=$y['name']; $cats[$disp[$y['parent']] . '_slug']=$y['slug']; $myCats[]=$y; endwhile; $myUi=''; foreach($myCats as $cat): foreach($confezioni as $k=>$ui): if ($cat['term_id']==$k): $myUi=$ui; break; endif; endforeach; endforeach; $sql="select * from wp_postmeta where 1 and post_id=$doc and meta_key in ( 'capacita', 'temperatura_di_servizio', 'grado_alcolico', 'equilibrio_dolce_amaro')"; $rs=mysql_query($sql) or die(mysql_error()); while($y=mysql_fetch_assoc($rs)): $dati[$y['meta_key']]=$y['meta_value']; endwhile; $dati['capacita']=unserialize($dati['capacita']); //xdump($dati, true); $eda=(int)$dati['equilibrio_dolce_amaro']; if ($eda!=0): $cats['Equilibrio dolce-amaro']=""; endif; $cats['Grado alcolico']=$dati['grado_alcolico'] . '°'; $tmp=''; foreach($dati['capacita'] as $v): $tmp.=$v. ' ' . $myUi .'
'; endforeach; $cats['Capacità']=$tmp; $caratt=''; foreach($cats as $car=>$descr): if (strpos($car, 'slug')==0): $caratt .= ""; endif; endforeach; $caratt.='
$car$descr
'; $qry="select guid from wp_posts p where post_type='attachment' and ID in ( select meta_value ID from wp_postmeta where post_id=$doc and meta_key like 'img_%' and meta_value<>'' )"; //$rs=mysql_query("select * from wp_posts where post_parent=$doc and post_type='attachment' and post_status='inherit'") or die(mysql_error()); $rs=mysql_query($qry) or die(mysql_error()); $imgs=array(); while($y=mysql_fetch_assoc($rs)): $imgs[]=$y; endwhile; //xdump($imgs, true); $testo=$x['post_content'] . '
' .$caratt; $titolo=$x['post_title']; if ($testo!=''){ $doc=new Doc(); $res=''; $guid=''; $birreria="Birreria
"; $nazione="Nazione
"; $res=$doc->html2pdf($testo, $titolo, $guid, $imgs, $birreria, $nazione); $doc->render(); //header("Location: $res"); } function xdump($a, $die=false){ print '' . print_r($a, true) . ''; if ($die) die; } ?>