I have this code to display an uploaded image. Although I need it to display it with my theme around it. Here is how the directory with the theme works.
root-
images.php
header.php
footer.php
theme-
/skin/default/header.html
/skin/default/footer.html
Here is the code from images.php.
<?
define('IN_OUTPUT',1);
include "includes/inc.php";
/**
* get var from url or query
*/
if(!empty($input[t]))
{
$type='t';
$id=intval($input[t]);
}
elseif(!empty($input[i]))
{
$type='i';
$id=intval($input[i]);
}
elseif(!empty($input[m]))
{
$type='m';
$id=intval($input[m]);
}
else
{
$phpscriptname = substr($_SERVER["PHP_SELF"],strrpos($_SERVER["PHP_SELF"],"/")+1);
$path=$phpscriptname==basename(__FILE__)?$_SERVER["REQUEST_URI"]:$_SERVER["PHP_SELF"];
$last=strrpos($path,'/');
$type=substr($path,$last+1,1);
$id=intval(substr($path,$last+2));
}
$db->setQuery("select
i.id,i.file,i.name,i.gallery_id,gal.uid,i.size,i.width,i.height,i.bandwidth
,u.last_update,u.bandwidth as userbandwidth,g.bandwidth as maxbandwidth,i.lastview as lview,u.status
from images4g as i
left join gallery as gal on gal.gallery_id=i.gallery_id
left join users as u on u.id=gal.uid
left join groups as g on g.id=u.gid
where i.id='$id'");
$db->query();
$row=$db->loadRow();
processOutput($row,$type);
?>
- <?
-
- define('IN_OUTPUT',1);
- include "includes/inc.php";
- /**
- * get var from url or query
- */
- if(!empty($input[t]))
- {
- $type='t';
- $id=intval($input[t]);
- }
- elseif(!empty($input[i]))
- {
- $type='i';
- $id=intval($input[i]);
- }
- elseif(!empty($input[m]))
- {
- $type='m';
- $id=intval($input[m]);
- }
- else
- {
- $phpscriptname = substr($_SERVER["PHP_SELF"],strrpos($_SERVER["PHP_SELF"],"/")+1);
- $path=$phpscriptname==basename(__FILE__)?$_SERVER["REQUEST_URI"]:$_SERVER["PHP_SELF"];
- $last=strrpos($path,'/');
- $type=substr($path,$last+1,1);
- $id=intval(substr($path,$last+2));
- }
- $db->setQuery("select
- i.id,i.file,i.name,i.gallery_id,gal.uid,i.size,i.width,i.height,i.bandwidth
- ,u.last_update,u.bandwidth as userbandwidth,g.bandwidth as maxbandwidth,i.lastview as lview,u.status
- from images4g as i
- left join gallery as gal on gal.gallery_id=i.gallery_id
- left join users as u on u.id=gal.uid
- left join groups as g on g.id=u.gid
- where i.id='$id'");
- $db->query();
- $row=$db->loadRow();
- processOutput($row,$type);
- ?>
Now I tried adding these into there where in the header.php and footer.php files just pull the information from the theme files.
<?
define('IN_OUTPUT',1);
include "includes/inc.php";
include "header.php";
/**
* get var from url or query
*/
if(!empty($input[t]))
{
$type='t';
$id=intval($input[t]);
}
elseif(!empty($input[i]))
{
$type='i';
$id=intval($input[i]);
}
elseif(!empty($input[m]))
{
$type='m';
$id=intval($input[m]);
}
else
{
$phpscriptname = substr($_SERVER["PHP_SELF"],strrpos($_SERVER["PHP_SELF"],"/")+1);
$path=$phpscriptname==basename(__FILE__)?$_SERVER["REQUEST_URI"]:$_SERVER["PHP_SELF"];
$last=strrpos($path,'/');
$type=substr($path,$last+1,1);
$id=intval(substr($path,$last+2));
}
$db->setQuery("select
i.id,i.file,i.name,i.gallery_id,gal.uid,i.size,i.width,i.height,i.bandwidth
,u.last_update,u.bandwidth as userbandwidth,g.bandwidth as maxbandwidth,i.lastview as lview,u.status
from images4g as i
left join gallery as gal on gal.gallery_id=i.gallery_id
left join users as u on u.id=gal.uid
left join groups as g on g.id=u.gid
where i.id='$id'");
$db->query();
$row=$db->loadRow();
processOutput($row,$type);
include "footer.php";
?>
- <?
-
- define('IN_OUTPUT',1);
- include "includes/inc.php";
- include "header.php";
- /**
- * get var from url or query
- */
- if(!empty($input[t]))
- {
- $type='t';
- $id=intval($input[t]);
- }
- elseif(!empty($input[i]))
- {
- $type='i';
- $id=intval($input[i]);
- }
- elseif(!empty($input[m]))
- {
- $type='m';
- $id=intval($input[m]);
- }
- else
- {
- $phpscriptname = substr($_SERVER["PHP_SELF"],strrpos($_SERVER["PHP_SELF"],"/")+1);
- $path=$phpscriptname==basename(__FILE__)?$_SERVER["REQUEST_URI"]:$_SERVER["PHP_SELF"];
- $last=strrpos($path,'/');
- $type=substr($path,$last+1,1);
- $id=intval(substr($path,$last+2));
- }
- $db->setQuery("select
- i.id,i.file,i.name,i.gallery_id,gal.uid,i.size,i.width,i.height,i.bandwidth
- ,u.last_update,u.bandwidth as userbandwidth,g.bandwidth as maxbandwidth,i.lastview as lview,u.status
- from images4g as i
- left join gallery as gal on gal.gallery_id=i.gallery_id
- left join users as u on u.id=gal.uid
- left join groups as g on g.id=u.gid
- where i.id='$id'");
- $db->query();
- $row=$db->loadRow();
- processOutput($row,$type);
- include "footer.php";
- ?>
Only problem is that when I do that the image doesn't display. The header shows, the footer doesnt. The image is displayed at code as if you opened the image with notepad.