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>"; }
}
?>
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>"; }
}
?>