I have a phpbb forum and I want to show the latest 3 post in my website. I can connect to the DB and retrieve what I want but not img from post. Post content is stored as Blob, when I do a post looks like:
"Hello this is a test post.
[img]http://www.petfinder.com/wp-content/uploads/2012/11/101418789-cat-panleukopenia-fact-sheet-632x475.jpg[/img]
End of the file."
In the forum you can see the text and the image. But when I show the post in my website it looks like:
(Hello this is a test post. [img:3vv18at0]http://www.petfinder.com/wp-content/uploads/2012/11/101418789-cat-panleukopenia-fact-sheet-632x475.jpg[/img:3vv18at0]End of the file.)
Show the entery post as text, I would like to see the post as in the forum, text and images in their places.
This is the code I am using:
<?php
$conexion = mysql_connect("localhost","MYUSER","MYPASS");
$nPost = "0,3";
//DB a la que me conecto
mysql_select_db("DATABASE", $conexion) OR die("No se puede establecer la conexión a MySQL");
$consulta1 = "SELECT * FROM phpbb_topics WHERE forum_id = '4' ORDER BY topic_id DESC LIMIT $nPost";
$resultado1 = mysql_query($consulta1);
$consulta2 = "SELECT * FROM phpbb_posts WHERE forum_id = '4' ORDER BY topic_id DESC LIMIT $nPost";
$resultado2 = mysql_query($consulta2);
while ($row = mysql_fetch_array($resultado1)) {
$datosPost = mysql_fetch_array($resultado2);
$id = "$row[topic_id]";
$titulo = "$row[topic_title]";
$respuestas = "$row[topic_replies]";
$by = "$row[topic_first_poster_name]";
$text = "$datosPost[post_text]";
///////////////////EDIT AND WORKING//////////////////
$b = preg_replace('#\[img:(.*?)\](.*?)\[/img:(.*?)\]#s', '<br><img src="$2"/><br> ', $text);
$c = preg_replace('#\((.*?)\)#s', '$1', $b);
$text = $c;
////////////////////////THANKS TO damienkeitel//////////////
echo"<a href='http://www.compraclientes.com/foro/viewtopic.php?f=4&t=$id'><div class='postEntry'><div class='postHeader'><div class='postTitle'>$titulo</div><div class='postOwner'>(By $by)</div> <div class='postReplies'>($respuestas Respuestas)</div></div><div class='postText'>($text)</div></div></a>";
}
mysql_close($conexion);
?>
Thank you very much
$a = "(Hello this is a test post. [img:3vv18at0]http://www.petfinder.com/wp-content/uploads/2012/11/101418789-cat-panleukopenia-fact-sheet-632x475.jpg[/img:3vv18at0]End of the file.)";
$b = preg_replace('#\[img:(.*?)\](.*?)\[/img:(.*?)\]#s', '<br><img src="$2"/><br> ', $a);
$c = preg_replace('#\((.*?)\)#s', '$1', $b);
echo $c;
http://www.damienkeitel.com/pr.php <-- demo
I believe one of my previous answers, slightly modified, can provide you with information you need.
Display the 5 most recent posts on an external page
The short answer to your question is this chunk of code. This will clean up various aspects of your data.
$topic_title = $posts_row['topic_title'];
$post_author = get_username_string('full', $posts_row['poster_id'], $posts_row['username'], $posts_row['user_colour']);
$post_date = $user->format_date($posts_row['post_time']);
$post_link = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=" . $posts_row['post_id'] . "#p" . $posts_row['post_id']);
$post_text = nl2br($posts_row['post_text']);
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
$bbcode->bbcode_second_pass($post_text, $posts_row['bbcode_uid'], $posts_row['bbcode_bitfield']);
$post_text = smiley_text($post_text);
As I mention in the previous answer, that code is based on Example 4 the PHPBB Wiki.
Related
I have 2 files, the first one:
gives me the list of products
The second one:
- information relating to the product, therefore as an information page
In the first file, I implement a <a> tag, to redirect to the second file
and the variable: $id_evidenza = $row_ListaEvidenze['ID_evidenza'];
<a href="edit_evidenza.php?id=<?php echo $id_evidenza; ?>&te=<?php echo $_GET['te']; ?>" title="Modifica">
<strong><?php echo outputDecode($row_ListaEvidenze['cod_evidenza']); ?></strong>
</a
make a select query, and take my variable:
$myid_processo = "-1";
if (isset($_GET['id'])) {
$myid_processo = $_GET['id'];
}
//42320819($database_riskmanagement,$riskmanagement);
$query_processo = sprintf("SELECT * FROM tev_Evidenze WHERE tev_Evidenze.id_struttura = ".$id_str." AND tev_Evidenze.ID_evidenza = %s", GetSQLValueString($myid_processo, "int"));
$processo = mysqli_query($riskmanagement, $query_processo) or die(mysqli_error($riskmanagement));
createLog($_COOKIE['cod_operatore'], $query_processo);
$row_processo = mysqli_fetch_assoc($processo);
$totalRows_processo = mysqli_num_rows($processo);
with a do / while loop, I show the results on screen and it's ok.
Now the problems begin, because right now from the page where there are the list of products, we are in the product info page, they asked me, to implement a navigation system, which gives the possibility that if I am inside the product A, going back and forth I can scroll through the other products, without going over the product list page, and so I did by implementing this navigation system:
if($_GET['te']==""){
$sel_tipo_acc = " (ev.id_tipo_accreditamento = 0)";
}else{
$sel_tipo_acc = " (ev.id_tipo_accreditamento = ".$_GET['te'].")";
}
$my_ric_att = searchControl(trim($_GET['ric_att']));
$txt_ric = "";
$txt_ric = "Risultati per ";
$r_sql = "SELECT * FROM tev_Evidenze AS ev LEFT JOIN tev_Fatt_crit AS fc
ON fc.ID_fatt_crit = ev.id_fatt_crit
WHERE ev.id_struttura = ".$_SESSION['str']." AND ".$sel_tipo_acc." AND ";
if ($_GET['facr'] != ""){
$r_sql .= " fc.ID_fatt_crit = ".$_GET['facr']." AND ";
}
$r_sql .= " ((ev.cod_evidenza LIKE '%" .$my_ric_att. "%') OR (ev.desc_evidenza LIKE '%" .$my_ric_att. "%')) ";
$txt_ric .= trim($_GET['ric_att']) ;
$r_sql .= " ORDER BY fc.ordine_fatt_crit, ev.cod_evidenza, ev.ordine_evidenza";
$txt_ric .= "<br>";
if($_GET['v']=="all"){
$paginazione = 1;
}else{
$paginazione = 1;
}
$maxRows_ListaEvidenze = $paginazione;
$pageNum_ListaEvidenze = 0;
if (isset($_GET['pageNum_ListaEvidenze'])) {
$pageNum_ListaEvidenze = $_GET['pageNum_ListaEvidenze'];
}
$startRow_ListaEvidenze = $pageNum_ListaEvidenze * $maxRows_ListaEvidenze;
//42320819($database_riskmanagement, $riskmanagement);
$query_ListaEvidenze = $r_sql;
$query_limit_ListaEvidenze = sprintf("%s LIMIT %d, %d", $query_ListaEvidenze, $startRow_ListaEvidenze, $maxRows_ListaEvidenze);
$ListaEvidenze = mysqli_query($riskmanagement, $query_limit_ListaEvidenze) or die(mysqli_error($riskmanagement));
createLog($_COOKIE['cod_operatore'], $v_sql);
$row_processo = mysqli_fetch_assoc($ListaEvidenze);
if (isset($_GET['totalRows_ListaEvidenze'])) {
$totalRows_ListaEvidenze = $_GET['totalRows_ListaEvidenze'];
} else {
$all_ListaEvidenze = mysqli_query($riskmanagement, $query_ListaEvidenze);
$totalRows_ListaEvidenze = mysqli_num_rows($all_ListaEvidenze);
}
$totalPages_ListaEvidenze = ceil($totalRows_ListaEvidenze/$maxRows_ListaEvidenze)-1;
$queryString_ListaEvidenze = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_ListaEvidenze") == false &&
stristr($param, "totalRows_ListaEvidenze") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_ListaEvidenze = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_ListaEvidenze = sprintf("&totalRows_ListaEvidenze=%d%s", $totalRows_ListaEvidenze, $queryString_ListaEvidenze);
I have the problem in my url, I can't get all the necessary parameters in $ _GET, that is, if for example I go from product A to that B, I get this:
pageNum_ListaEvidenze=5&totalRows_ListaEvidenze=76&id=340&te=5
pageNum_ListaEvidenze=6&totalRows_ListaEvidenze=76&id=340&te=5
where the only thing that changes is the number after: pageNum_ListaEvidenze=
displaying another record, but the id is always stopped at the first record, I have this problem from this snippet of code, which I posted before:
if (isset($_GET['pageNum_ListaEvidenze'])) {
$pageNum_ListaEvidenze = $_GET['pageNum_ListaEvidenze'];
}
how do i make everything dynamic in the url?
I really understand your issue , but here is a better solution that can make the life easy .
Let's suppose that currently , you are on the info page(Page B as you describe) that show the product information .
To swip for the next product , or previous , you can try to do this :
Normaly , one the info page , you are able to get the id of the current product
$currentProductID = $_GET['id'];
Think to create a method that give you the id of the next product , the query should be like :
SELECT id FROM `product` WHERE `id` > $currentProductID limit 1
This will return the id of the next product , and then redirect to the B page with this id returned using php redirection or by clicking on the tag etc .
To do that for the previous product , just inverse the query above
with <.
Hope that help you .
I have tried to get a cleaner URL by adding a .htaccess file to my directory. However I have stumbled upon a small problem which I haven't been able to figure out yet how to solve. I provide an opportunity for my members to post content on my website. When posting the content, the title is saved and modified to be used to get a cleaner URL. For example
/dir/post.php?id=362 with the title [Hello friends] becomes ->
/dir/Hello-friends
My problem is how can I prevent that the same URL gets produced over and over again. I want that the following URLs with the same title, to get something added to it, like a number. For example
/dir/Hello-friends (The first post)
/dir/Hello-friends-2 (The second post, but here a number is added).
This is my php code
$conn = new mysqli($servername, $username, $password, $dbname);
if (mysqli_connect_error()) {
die("Database connection failed: " . mysqli_connect_error());
}
function php_slug($string)
{
$slug = preg_replace('/[^a-z0-9-]+/', '-', trim(strtolower($string)));
return $slug;
}
$title = mysqli_real_escape_string($conn,$title1);
$text1 = mysqli_real_escape_string($conn,$text0);
$text2 = mysqli_real_escape_string($conn,$text00);
$text3 = mysqli_real_escape_string($conn,$text000);
$text4 = mysqli_real_escape_string($conn,$text0000);
$text5 = mysqli_real_escape_string($conn,$text00000);
$text6 = mysqli_real_escape_string($conn,$text000000);
$pid = $_POST['pid'];
$post_title = $title;
$post_title = htmlentities($title);
$sql_titel = "SELECT post_title FROM posts WHERE title = '$title'";
$result_titel = mysqli_query($con, $sql_titel);
$resultsFound = mysqli_num_rows($result_titel);
if ($resultsFound > 0) {
$resultsFound++;
$post_title .= '-'.$resultsFound;
}
$sql = "INSERT INTO posts (title, text1, text2, text3, text4, text5, text6, post_title, pid)
VALUES ('$title', '$text1', '$text2', '$text3', '$text4', '$text5', '$text6', '".php_slug($post_title)."', '$pid')";
if ($conn->query($sql) === TRUE) {
echo "<script>alert('controlling post...!')</script>";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}
If you want to add a random number:
if($_POST['submit']) {
$post_title = $title;
$post_title = htmlentities($title);
$sql_titel = "SELECT post_title FROM posts WHERE post_title = '$post_title'";
$result_titel = mysqli_query($con, $sql_titel);
if(mysqli_num_rows($result_titel) > 0) {
$post_title = $post_title . '-' . mt_rand(1, 1000);
}
}
A simple extension to your code is to use the number of rows returned, like this:
if($_POST['submit']) {
$post_title = htmlentities($title);
// !!! You should use parameterized queries here !!!
$sql_titel = "SELECT post_title FROM posts WHERE title = '$title'";
$result_titel = mysqli_query($con, $sql_titel);
// Using the number of rows returned as our collision ID:
$sameNameID = mysqli_num_rows($result_titel);
if ($sameNameID > 0) {
// Bump it up by 1 (so we essentially get 0,2,3,4,5..):
$sameNameID++;
// Add it to the post title:
$post_title .= '-'.$sameNameID;
}
}
Importantly, notice that it's checking the title field rather than post_title.
Also be aware that you're probably vulnerable to SQL injection. I.e. a random person on the internet could do whatever they want to your database. htmlentities does not protect you from injection. You should use PDO instead.
But having said that, you might want to take inspiration from websites like StackOverflow itself, where a number (the article ID) is always present in the URL.
In StackOverflow's case, it's the ID which actually routes the request - this makes it possible to change the question (or title, in your case) later. For example, all of these link to this question:
https://stackoverflow.com/questions/41537052/
https://stackoverflow.com/questions/41537052/prevent-the-same-url-occuring
https://stackoverflow.com/questions/41537052/prevent-the-same-url-occuring-renamed
I am trying to create an xml file for google live data feed in PHP language. But the problem is my xml file is not able to display the content properly. I guess my xml file is not valid. In Firefox, only two fields coming from mysql database is being displayed like below -
example.com
Google Merchant Feed
PM-3114-100 Smart Power Meter Single phase, 4 loops (60A)
Compact Single Phase Smart Power Meter, 4 loops, ModbusRTU protocol. 60A CT's.
050-063 62 ohm precision shunt resistor for 4-20ma transducer
62 Ω precision shunt resistor for use when monitoring 4-20mA transducers with Datascan 7000 modules. One required for each channel where 4-20ma transducers are required.
While in chrome and IE, there is no data is rendered but only the error is shown. In Chrome, I am getting the following error -
This page contains the following errors:
error on line 48 at column 9: Extra content at the end of the document
Below is a rendering of the page up to the first error.
Here is my PHP code to create xml file -
<?php
// Set the xml header
header("Content-type: text/xml");
require_once '../admin/includes/login.php';
$sql = "SELECT `p`.`products_id`, `p`.`products_name`, `p`.`products_url`, `p`.`products_short_desc`, `p`.`products_model`, `p`.`products_price`, `p`.`products_status`, `p`.`products_image`, `c`.`categories_name`, `b`.`brand_name` FROM `products` AS `p` LEFT JOIN `categories` AS `c` ON `p`.`categories_id` = `c`.`categories_id` LEFT JOIN `brands` AS `b` ON `p`.`brand_id` = `b`.`brand_id` LIMIT 1, 2";
$rs = mysqli_query($con, $sql);
// Echo out all the details
echo '<?xml version="1.0"?>
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<title>example.com</title>
<link>http://www.example.com/</link>
<description>Google Merchant Feed</description>';
// while loop, this will cycle through the products and echo out all the variables
while($row = mysqli_fetch_array($rs))
{
$sql2 = "SELECT `categories_id`,`products_url`,`products_name` FROM `products` WHERE `products_id` = " . $row['products_id'];
$rs2 = mysqli_query($con, $sql2);
$row2 = mysqli_fetch_assoc($rs2);
$categories_id = $row2['categories_id'];
$structure = structure($categories_id);
$structure = array_reverse($structure);
$structure[] = $categories_id;
$breadcrumb = '';
$sub_url = $base;
foreach($structure as $url) {
$sql3 = mysqli_query($con, "SELECT `categories_name`,`categories_url` FROM `categories` WHERE `categories_id` = $url");
$row3 = mysqli_fetch_assoc($sql3);
if($url==0) {
$breadcrumb .= '<a id="breadcrumb_home" href="'.$sub_url.$row3['categories_url'].'">HOME > </a>';
} else {
$breadcrumb .= '<a class="breadcrumb_link" href="'.$sub_url.$row3['categories_url'].'">'.$row3['categories_name'].' > </a>';
$sub_url = $sub_url.preg_replace("/_c[0-9_]+/", "", $row3['categories_url']).'/';
}
}
// collect all variables
$brand = $row['brand_name'];
$title = $row['products_name'];
$link = $sub_url . $row['products_url'];
$description = $row['products_short_desc'];
$id = $row['products_model'];
//$condition = $row['products_condition'];
$condition = "new";
$price = $row['products_price'];
if($row['products_status'] == 1){$availability = 'in stock';} else {$availability = 'out of stock';}
$products_image = $row['products_image'];
$image = 'http://www.example.com/images/products/page/' . $products_image;
$category = $row['categories_name'];
//$gtin = $row['GTIN'];
//$mpn = $row['MPN'];
$gtin = 8808992787426;
$mpn = "M2262D-PC";
// output all variables into the correct google tags
echo "<item>
<title>$title</title>
<link>$link</link>
<description><![CDATA[$description]]></description>
<g:google_product_category>$category</g:google_product_category>
<g:id>$id</g:id>
<g:condition>$condition</g:condition>
<g:price>$price GBP</g:price>
<g:availability>$availability</g:availability>
<g:image_link><![CDATA[$image]]></g:image_link>
<g:shipping>
<g:country>UK</g:country>
<g:service>Standard</g:service>
<g:price>5.95 GBP</g:price>
</g:shipping>
<g:gtin>$gtin</g:gtin>
<g:brand>$brand</g:brand>
<g:mpn>$mpn</g:mpn>
<g:product_type>$category</g:product_type>
</item>";
}
?>
I am investigating the problem at my best but not able to trace it. Please help me to find out the bug why the proper xml file is not creating and why the data is not being displayed in exact manner I want.
The XML you generate is invalid. You do not escape the variables, so they can break it. The closing tags for channel and rss are missing, too. Use an XML API like XMLWriter or DOM.
I want to replace the enters in the $content part to <br/> so it actually shows up as enter on my webs
$content = $_POST['thread_content'];
$title = $_POST['title'];
$date = date('d-m-Y H:i:s');
$str = $content.split("\n").join("<br />");
$co = db::escape($str);
$ti = db::escape($title);
$id = db::escape($_GET['id']);
$user = user::getVar("id");
db::query("INSERT INTO Topics (topic_subject, topic_date, topic_cat, topic_by) VALUES ('".$ti."', '".$date."', '".$id."', '".$user."')");
//ID IS ID VAN HET BOARD! NIET VAN TOPIC ID!
$result = db::query("SELECT * FROM Topics ORDER BY topic_id DESC LIMIT 0, 1");
while($row = mysql_fetch_array($result)) {
$topicid = $row["topic_id"];
db::query("INSERT INTO Posts (post_content, post_date, post_topic, post_by, post_title, post_board) VALUES ('".$co."', '".$date."', '".$topicid."', '".$user."', '".$ti."', '".$id."')");
header("Location: ?p=Topics&id=".$topicid);
}
?>
But the $str = $content.split("\n").join("<br/>"); Doesn't work as I want it to work. It doesnt output <br/> in the output string to the database. Any one can help me out with this?
nl2br is the function you are looking for.
$str = nl2br($content);
That's not how string splitting and joining work in PHP (you're probably thinking of Python).
The easiest way to do this specific task would be to use PHP's builtin nl2br function instead.
PHP_EOL is quite nice too, have a look.
i have this file C:\\xampp\htdocs\exact\sample_pie.php that contains a graph. here's the code:
<?php
include("phpgraphlib.php");
include("phpgraphlib_pie.php");
include("connection.php");
$graph=new PHPGraphLibPie(400,200);
$link = mysql_connect('localhost', 'root', '');
mysql_select_db('exact');
$querypa = "SELECT COUNT(nature) FROM approved WHERE nature='Parade'";
$resultpa = mysql_query($querypa);
$printpa = mysql_result($resultpa,0);
$querycs = "SELECT COUNT(nature) FROM approved WHERE nature='Community Service'";
$resultcs = mysql_query($querycs);
$printcs = mysql_result($resultcs,0);
$queryga = "SELECT COUNT(nature) FROM approved WHERE nature='General Assembly'";
$resultga = mysql_query($queryga);
$printga = mysql_result($resultga,0);
$querypl = "SELECT COUNT(nature) FROM approved WHERE nature='Play/Showcase/Socio-Cultural Show/Film Showing'";
$resultpl = mysql_query($querypl);
$printpl = mysql_result($resultpl,0);
$queryco = "SELECT COUNT(nature) FROM approved WHERE nature='Competition/Sportsfest'";
$resultco = mysql_query($queryco);
$printco = mysql_result($resultco,0);
$queryfr = "SELECT COUNT(nature) FROM approved WHERE nature='Fund Raising'";
$resultfr = mysql_query($queryfr);
$printfr = mysql_result($resultfr,0);
$queryse = "SELECT COUNT(nature) FROM approved WHERE nature='Seminar/Convention/Conference/Training'";
$resultse = mysql_query($queryse);
$printse = mysql_result($resultse,0);
$totalAct=$printpa+$printga+$printpl+$printcs+$printco+$printfr+$printse;
$avepa=($printpa/$totalAct)*100;
$avecs=($printcs/$totalAct)*100;
$avega=($printga/$totalAct)*100;
$avepl=($printpl/$totalAct)*100;
$aveco=($printco/$totalAct)*100;
$avefr=($printfr/$totalAct)*100;
$avese=($printse/$totalAct)*100;
$pa=number_format($avepa,2);
$cs=number_format($avecs,2);
$ga=number_format($avega,2);
$pl=number_format($avepl,2);
$co=number_format($aveco,2);
$fr=number_format($avefr,2);
$se=number_format($avese,2);
$data=array("Parade"=>$pa, "General Assembly"=>$ga, "Play/Showcase/Socio-Cultural Show/Film Showing"=>$pl, "Community Service"=>$cs, "Competition/Sportsfest"=>$co, "Fund Raising"=>$fr, "Seminar/Convention/Conference/Training"=>$se);
$graph->addData($data);
$graph->setTitle("Total Activities per Nature of Activity");
$graph->setPrecision(2);
$graph->setLabelTextColor("0,0,0");
$graph->setLegendTextColor("0,0,0");
$graph->setGradient("210,245,255","pastel_purple");
$graph->createGraph();
?>
how can i get the graph as a .jpg through php script? i tried this file_get_contents("C:\\xampp\htdocs\exact\sample_pie.php");
but it only outputs this:
$pa, "General Assembly"=>$ga, "Play/Showcase/Socio-Cultural Show/Film Showing"=>$pl, "Community Service"=>$cs, "Competition/Sportsfest"=>$co, "Fund Raising"=>$fr, "Seminar/Convention/Conference/Training"=>$se); $graph->addData($data); $graph->setTitle("Total Activities per Nature of Activity"); $graph->setPrecision(2); $graph->setLabelTextColor("0,0,0"); $graph->setLegendTextColor("0,0,0"); $graph->setGradient("210,245,255","pastel_purple"); $graph->createGraph(); ?>
please help me. thanks.
Using file_get_contents() like that is only going to retrieve the script itself. That text is what the file contains and that's what file_get_contents() does; exactly what it says on the tin.
Try looking at the documentation for PHPGraphLib or in the source code failing that. There should be some sort of save method you can call instead of createGraph() or maybe you can just pass a filename parameter to createGraph().
On a sidenote, I should mention that your script is a lot more complicated than it should be. Everything between mysql_select_db() and $graph->addData() could be rewritten into something like this:
$data = array(
'Parade' => 0,
'Community Service' => 0,
'General Assembly' => 0,
'Play/Showcase/Socio-Cultural Show/Film Showing' => 0,
'Competition/Sportsfest' => 0,
'Fund Raising' => 0,
'Seminar/Convention/Conference/Training' => 0
);
$sql = "SELECT nature, COUNT(*) AS cnt
FROM approved
WHERE nature IN ('" . implode("','", array_keys($data)) . "')
GROUP BY nature";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result))
{
$data[$row['nature']] = $row['cnt'];
}
$totalAct = array_sum($data);
foreach ($data as $nature => &$value)
{
$value = number_format(100 * $value / $totalAct, 2);
}
For the rest, consult the documentation of your graph library as Ollie Saunders suggested.
<img src="/exact/sample_pie.php" />
You may want to use header() to set the appropriate Content-type from within sample_pie.php.