• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

SSI and .php file

Hi:

In my website there is an .htaccess file which contains the following lines :

php_flag register_globals off
AddHandler server-parsed .htm
AddHandler server-parsed .html

In order to enable SSI banner, I added an aditional line : AddHandler server-parsed .php

After that, the main page index.php file doesn't open. It asked to download a file which contain the following codes :

--------------------------------
<?
session_start();
$catname = "";
$catid = "";
$val_string = "";

if (isset($_REQUEST["catid"])) {
      $catid = round($_REQUEST["catid"]);
}
if (isset($_REQUEST["setlang"])) {
      $_SESSION["la"] = $_REQUEST["setlang"];
      
}

include_once("admin/inc.php");
include_once("functions.php");
if ($catid) {
      $sql = "select catname from $cat_tbl where catid = $catid";
      $row = mysql_fetch_array(q($sql));
      $catname = " :: " . $row["catname"];
}
else
{
      $fp = 1;      
}
include_once("header_inc.php");

if (!$special_mode) {
      include("navigation.php");
      if (isset($menu_ordinary)) { print $menu_ordinary; }
}

if (!empty($catid)) {
      // Write out the link bar
      writeLinkedTitle($catid);
}
// Security check
if (file_exists("install.php"))
{
      print "<p><center><b><font color='red'>SECURITY WARNING</font></b><br />You have not followed our instructions to       delete install.php
      immediately after install. Leaving this file here is a <u>major</u> security problem and opens your site up
      to wild hacking.</center></p>";      
}
print '<table border="0" width="100%" cellspacing="0" cellpadding="10" valign="top"><tr><td width="100%">';           

// If we are on the frontpage, write out welcome message along with flags
if ($catid==0 AND !$special_mode)
{
      echo "<h2>$name_of_site</h2>";
      echo formatString($welcome_message, array("$name_of_site"));
      include "templates/flags_frontpage.html";
?>
<table border="0" width="100%" bgcolor="#A9B8D1" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%" height="1"><img border="0" src="layout_images/spacerbig.gif" width="1" height="1" alt='' /></td>
  </tr>
</table>

<?
}

// If we have featured ads
if (!empty($set_special) AND !isset($_REQUEST["catid"]))
      print "<table border='0' width='100%'><tr><td valign='top' width='80%'>";
      
// Print out categories
include("catcol.php");      

// This is the column containing special ads
if (!empty($set_special) AND !isset($_REQUEST["catid"])) {
      print "</td><td valign='top' width='20%'>";
      include "special.php";
      print "</td></tr></table>";
}


// Print out ad-listings
include("links.php");


// Counter (if activated from admin area)
$frontpage=1;

if (isset($set_count_dynamic))
{
      $str = "";
      if (isset($validation))
      {
            if ($validation<>"")
                  $str = " where valid=1";
      }
      $row = mysql_fetch_array(mysql_query("select count(ad_username) from $ads_tbl $str"));
      $upd_ads = $row["count(ad_username)"];
      
      $row = mysql_fetch_array(mysql_query("select count(email) from $usr_tbl"));
      $upd_users = $row["count(email)"];
      
      $row = mysql_fetch_array(mysql_query("select sum(sitehits) from $ads_tbl $str"));
      $upd_sitehits = $row["sum(sitehits)"];

      if (!$upd_sitehits)
            $upd_sitehits = 0;
      
      $la_s_bar = formatString($la_s_bar, array("$upd_users","$upd_ads","$upd_sitehits"));
      $show_bar = 1;
}

print "</td></tr></table>\n";
print "<!-- ## INDEX.PHP END ## -->";

include_once("footer_inc.php");
?>
-------------------------

Now my question is where I am making mistake ?

rsdn
0
Sohel Rana
Asked:
Sohel Rana
  • 2
  • 2
2 Solutions
 
jdpipeCommented:
Hi there rsdn,

I'm not sure what level you're at with this stuff, however here are my comments. What you've got there is a PHP file. PHP is a scripting language, rather like SSI. Your new Apache directive has told Apache that it should handle your PHP files using Apache's SSI handler. This means that Apache will process all the SSI commands from your PHP file that it recognises, but the PHP commands will now not be processed.

From your comment, it sounds like you want to insert some additional stuff at the top of that index.php page. If that's what you want to do, I'd suggest editing the index.php file and adding some print("<h1>my heading</h1>"); lines, something like that. Use the PHP language to add the stuff you want.

I believe it may be possible to use multiple handlers on a page using Apache, but it's probably not going to be necessary for what you're trying to do.

Hope that helps
JP
0
 
Sohel RanaAuthor Commented:
Hi JP:

Thanks for your comment. I am not good in php, so sorry for asking you additional question. Rightnow, I place the code inside header.html file :

---------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>%SITENAME% %PAGE%</title>
<link rel="stylesheet" href="style.css" type="text/css" />

<center>
<!--#include virtual="/SSI/asianclassified.htm" -->
</center>


<script language="JavaScript">
<!--
function openPage(URL) { aWindow=window.open(URL,"Large","toolbar=no,width=500,height=500,status=no,scrollbars=yes,resize=no,menubars=no");
}
-->
</script>
</head>


<body bgcolor="#FFFFFF">

--------------------------------

Can you tell me where I need to change in header.html ? Or I need to place this code inside index.php file? I place this code to header.html because I need to show the banner in all pages, rather than main or index.php page.

rsdn
0
 
jdpipeCommented:
1. copy header.html to header.php
2. in header.php, change %SITENAME% to <?php print($SITENAME) ?>
3. in header.php change %PAGE% to <?php print($PAGE) ?>
4. in file index.php, add require("header.php"); at the start, just after the first <?php

JP
0
 
Marcus BointonCommented:
The equivalent to this: <!--#include virtual="/SSI/asianclassified.htm" --> in PHP is:

virtual('/SSI/asianclassified.htm');

This is the usual technique for combining PHP and SSI - doing both in the same file is pretty hopeless (I don't think you can have multiple handlers for the same file type), but you can at least call one from the other using virtual() and #include virtual. You need to use virtual and not include or require as it spawns a new apache sub-request, and that sub request can use a different handler.

Your HTML is pretty invalid which won't help - you've got content outside your body tag.

0
 
Sohel RanaAuthor Commented:
Thanks everyone for your input.

rsdn
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now