PDA


View Full Version : PHP in a custom template?


Gmrx
05-26-2005, 12:01 PM
Is it possible to use php in a custom page? I've got the template showing up alright, but my php code isn't showing.

Here's the custom template. The line in bold is what I can't get to work.

<table class="tborder" width="100%" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" align="center">
<tr>
<td colspan="2" class="tcat" width="100%">Image Hosting</td>
</tr>
<tr>
<td class="alt1">This service is provided free for all registered members of [removed].net. All we ask in return is that you please refrain from uploading images which are considered to be inappropriate or offensive in nature.
<p>
<? include ("http://[removed].net/upload.php"); ?></td>
</tr>
</table>
<br />





Which runs this:

<?
// CONFIG
$serverpath = "/home/[removed]/public_html/hostedimages/"; // Path to where images should be uploaded to on the server. INCLUDE TRAILING SLASH.
$urltoimages = "http://[removed].net/hostedimages/"; // Web address to where the images are accessible from. INCLUDE TRAILING SLASH.
// CONFIG END
$mode = $_GET['mode'];
if ($mode == "") { $mode = "form"; }

if ($mode == "form") {
echo "<form enctype='multipart/form-data' method='post' action='?mode=upload'>\n";
echo "<input type='file' name='file'>\n";
echo "<input type='submit' name='Submit' value='Go'>\n";
}

if ($mode == "upload") {
$file = $_FILES['file']['name'];
$allowedfiles[] = "gif";
$allowedfiles[] = "jpg";
$allowedfiles[] = "jpeg";
$allowedfiles[] = "png";
$allowedfiles[] = "GIF";
$allowedfiles[] = "JPG";
$allowedfiles[] = "JPEG";
$allowedfiles[] = "PNG";
$path = "$serverpath/$file";
foreach($allowedfiles as $allowedfile) {
if (substr($file, -3) == $allowedfile) {
move_uploaded_file($_FILES['file']['tmp_name'], "$path");
$done = "yes";
echo "<p><b>Your image has been successfully uploaded to our server and can be accessed using the URL provided below.</b></p>";
echo "<p><A href='$urltoimages/$file' target='_blank'><strong>$urltoimages/$file</strong></a></p>";
echo "<p><img src='$urltoimages/$file' border='0'>";
}

}

if ($done <> "yes") { print "<p><b>Error: Your image as not been uploaded because it is not a recognized image file. Please try again.</b></p>"; }
}
?>

Brian
05-26-2005, 12:37 PM
You cannot use PHP in templates with vB. If you're trying to add that as a module you will need to add the file to your modules directory and then add it through the admincp.

Gmrx
05-26-2005, 12:55 PM
I'm not trying to add it as a module, rather as a custom page. Is it possible to do that?

DJQuad
05-30-2005, 01:11 PM
I am as well. What are our options for using custom PHP scripts?

DJQuad
06-05-2005, 04:58 PM
Anyone?

Brian
06-05-2005, 04:59 PM
Either add it as a module, or if you're running v2.0 you can specify a PHP file to include.