1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP in HTML with IIS Solution

Discussion in 'Co-op Advertising Network' started by ProductivePC, Jan 28, 2005.

  1. #1
    Currently, I have a .htm index page that uses a .htm header and a .htm footer file.
    www.worldfamousgiftbaskets.net

    I have followed the instructions to set up the ad network.

    I have used the .htaccess file in the main directory.
    (AddType application/x-httpd-php .php .htm .html .asp)
    I have set the ad_network_ads.txt chmods set to 777.
    I have all of the files in the root directory along with the index.htm file.
    My server runs php.

    However when I use the .shtml include option
    (<!--#include virtual="/ad_network.php" -->)
    I receive the following:

    ', $ads); if (count ($ads) < 401 || $ads[0] + 900 < time()) { $new_ad = file_get_contents ('http://ads.digitalpoint.com/network.php?s=' . $_SERVER['SERVER_NAME'] . '&color=FDF3F9'); $ads[] = $new_ad; $ads[0] = time(); if (count ($ads) > 401) unset ($ads[1]); if ($new_ad) { $file = fopen($ad_file, 'r+'); if (flock ($file, LOCK_EX)) { fwrite ($file, implode ('', $ads)); ftruncate ($file, ftell($file)); flock ($file, LOCK_UN); } fclose ($file); } $ad = end ($ads); } else { $ad = $ads[rand(1,count($ads) - 1)]; } $ad_network[] = $ad; while (count ($ad_network) < 5) { $ad_network[] = $ads[rand(1,count($ads) - 1)]; } } else { $ad_network[] = 'You must set the "ad_network_ads.txt" file to be writable.'; } if (substr (@$_SERVER['DOCUMENT_NAME'], -6) == '.shtml') { ini_set ('zlib.output_compression', 0); echo end ($ad_network); } ?>

    I am pretty sure that I am supposed to see an ad instead of that prior to validating... is that not correct? :p

    I have since removed the code from the page because of the error above.


    Can someone point me into the correct direction?

    Thanks,

    Wayne
     
    ProductivePC, Jan 28, 2005 IP
  2. UberSkilled

    UberSkilled Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If your server has PHP on it, have you tested the ad_network page in a php file?

    like using example.php and typing in it
    <?php
    echo "Ad is displayed below\n<br/>";
    include("ad_network.php");
    ?>


    :)



    /Whitey - UberSkilled.com Admin
     
    UberSkilled, Jan 30, 2005 IP
  3. ProductivePC

    ProductivePC Peon

    Messages:
    362
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes,
    I have the the php files working no problem however it is when I use the .htm files that I receive the code on the page.

    I have read about the passthru that shawn developed but I must say it is a little over my head. I tried to do everything that it said but I believe that my windows server does not allow the mod_rewrite command. Also I could not upload the .htaccess file. It would not accept it.

    I have .htm files set to use SSI in the control panel already however so I shouldn't need it anyway.

    If I can get this working on the .HTM pages, I then have to get it working on the .ASP pages which shouldn't be a problem.

    Any suggestions?
     
    ProductivePC, Jan 30, 2005 IP
  4. UberSkilled

    UberSkilled Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Eeesh.

    Windows Server?

    UberSkilled shudders in disgust.

    Well you probably need the .htaccess file so that the script will execute. Maybe contact your Server Admin and ask them if they can put it on there for you?


    /Whitey - UberSkilled.com Admin
     
    UberSkilled, Jan 30, 2005 IP
  5. ProductivePC

    ProductivePC Peon

    Messages:
    362
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes, I know... I wasn't too happy about the Windows Server myself but the original programmers we hired wanted to use ASP for the shopping cart and didn't know how to program ASP for linux not to mention that the shopping cart we got stuck with doesn't run properly on chilisoft.

    I have SSI enabled..... for .htm already in the control panel If I am not mistaken that is all that .htaccess file is doing, correct?

    However, whenever I go to point it to that php file all I get is code on the page.

    I created a page so people can see what is happening.
    The code on this page is

    
    <html>
    <head><title>php test inside htm</title></head>
    <body>
    <!--#include virtual="/ad_network.php" -->
    </body>
    </html>
    
    Code (markup):
    I have tried it with and without the slash

    The page is http://www.worldfamousgiftbaskets.net/test.htm
     
    ProductivePC, Jan 30, 2005 IP
  6. ProductivePC

    ProductivePC Peon

    Messages:
    362
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Okay. To anyone with on a Windows Server with Static .HTM pages.

    Requirements:
    - Windows Server
    - IIS
    - Some type of Control Panel that allows you to map file extensions OR
    - A nice hosting company that does not argue with you everytime you call or write for support.

    First of all according to the engineers at my hosting company a .htaccess file is only good for a unix or linux system and will not work on a windows server with IIS so if you are trying to get this to work and not understanding why.... that may be it.

    Next, if your hosting company offers a control panel such as plesk or cpanel or hsphere (yes some of those are for linux however they can integrate it from a linux box to control the windows machine like our server does) We use HSphere. You can map file extensions in this control panel to use .htm or .html files with either SSI, PHP, ASP, Etc etc etc. This will allow you to use the programming that normally comes with that language.

    For example, currently we have our .htm files mapped to SSI therefore we can use <!--#include file="header.htm"--> the Server Side Includes in order to use a common header and common footer for all of our webpages. We do not have to rename all of our pages to .shtml

    If you map your file extensions in your control panel so that your .htm pages are set to PHP then you will be able to use the
    <?php include("header.htm"); ?> PHP code and you will be able to use the following code:

    <?php
    ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
    include ('ad_network.php');
    echo $ad_network[0];
    ?>

    This should work for all of you Windows Server People with IIS out there with Control Panels. If you do not have a control panel, you can contact your hosting company and ask them to map your .htm or .html files over to PHP.
    Realize that if you are using SSI extensions on your .HTM or .HTML pages currently, that all of those Server Side Includes on every webpage will have to be changed over to the PHP includes.

    This is just a theory, at this point, that I was discussing with our hosting company engineers however I will be testing this tonight. If anyone sees any fault in anything written here prior to testing tonight please let me know what it is.

    I will write more on whether it was successful when I test it at about 3 in the morning tonight.

    Fun Fact:
    If you don't know what server you are on, you can go to the following website and find that out http://news.netcraft.com/ (and for those of you linux lovers out there that want a laugh and a half do a server search for www.linuxsucks.com and see what server they are running on. :p)

    Wayne
     
    ProductivePC, Jan 31, 2005 IP
  7. ProductivePC

    ProductivePC Peon

    Messages:
    362
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Okay, everyone. it is a success.
    Window Server people, what little of you are out there, The above works no problem.
    http://www.worldfamousgiftbasket.com/test.htm

    
    <html>
    <head><title>php test inside htm</title></head>
    <body>
    <?php
    	ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
    	include ('ad_network.php');
    	echo $ad_network[0];
    ?>
    </body>
    </html>
    
    Code (markup):
     
    ProductivePC, Jan 31, 2005 IP
  8. chachi

    chachi The other Jason

    Messages:
    1,600
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    0
    #8
    good job Wayne, and thanks for posting all of that here. I am sure there will be others that will run into the same issues you did. Most of the people here are not super IIS users as I am sure you discovered.
     
    chachi, Jan 31, 2005 IP
  9. ProductivePC

    ProductivePC Peon

    Messages:
    362
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #9
    How do I change the original subject of the first post.... so that it states something to the effect of Display PHP within HTML Solution instead of Need help with Network Setup Ad?
     
    ProductivePC, Jan 31, 2005 IP
  10. chachi

    chachi The other Jason

    Messages:
    1,600
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Did you try to edit the original post? I would include IIS in your title if you can change it. Most of the problems people seem to have with setting up the coop is with running php inside .html pages. But, your case is specific to IIS and I think it would be helpful to note that in the title
     
    chachi, Jan 31, 2005 IP
  11. ProductivePC

    ProductivePC Peon

    Messages:
    362
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #11
    It won't let me edit it... All it says is QUOTE and the arrow. There is no Edit Button.
     
    ProductivePC, Jan 31, 2005 IP
  12. ProductivePC

    ProductivePC Peon

    Messages:
    362
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Okay,

    I have the ads displaying on the .htm pages of the website.
    I had something extremely weird happen however the default page for root is index.htm

    I initially has .htm files mapped over to SSI. I removed this mapping and remapped .htm files over to PHP. Here is where the strange part comes in. www.worldfamousgiftbaskets.net was still using SSI while www.worldfamousgiftbaskets.net/index.htm was using PHP.

    Even though they were the same file. The outcome was www.worldfamousgiftbaskets.net would not show the Ads however www.worldfamousgiftbaskets.net/index.htm

    This problem was solved by turning off buffering for the site in IIS.

    Now the ads work great on .htm pages with nothing more than the PHP code.

    They are not pretty but they are there.
     
    ProductivePC, Jan 31, 2005 IP
  13. Netizen

    Netizen Peon

    Messages:
    148
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #13
    I am moving to a new IIS server that has custom MIME types. I only have control panel access. PHP is working with a .php extension; I want to parse html as php.

    I tried setting html as application/x-httpd-php but it did not work. I think that may be an apache MIME type (guessing).

    Anyone know what the php type would be for IIS? maybe text/php? text/server-parsed?

    When I set the custom MIME type, I get the warning "The MIME type you are specifying should not clash with the existing Mime Types." but I can't figure out how to list existing MIME types.
     
    Netizen, Aug 27, 2005 IP
  14. ProductivePC

    ProductivePC Peon

    Messages:
    362
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Are you on a shared server or on a dedicated server?

    If you are on a dedicated, you can go into IIS and tell it to route all .html files through the php parser. Otherwise you are stuck to your hosting provider doing this for you... good luck....

    If your control panel is Hsphere you can then route these yourself. If not, then again, you may have to utilize your hosting provider.

    The reason that your x-httpd-php doesn't work is because you are on a windows server. .htaccess is made for linux/unix systems. Windows does not read them.

    Get your hosting company to map .html files through the php parser they are using. This will solve your issue. You will now be able to use .php code within .html files such as the following example which I screwed up the URL above:
    http://www.worldfamousgiftbaskets.net/test.htm
     
    ProductivePC, Aug 28, 2005 IP
  15. Netizen

    Netizen Peon

    Messages:
    148
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Shared IIS 6 server with Ensim control panel. I guess I don't see what the custom MIME type setting actually does.

    It looks like the only way to change the server to parse html as php is to use the IIS management console, so I will have to get the hosting co. to do it.

    IIS really needs an equivalent to .htaccess. It would make life easier to end-users.
     
    Netizen, Aug 28, 2005 IP
  16. fluid

    fluid Active Member

    Messages:
    679
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    70
    #16
    And what if you're on a Windows Server trying to get a .shtml file execute a php/asp script?

    Content of ssitest.shtml file: <!--#include file="asptest.asp" -->

    Content of asptest.asp:
    <%
    response.write "This is a test"
    %>

    I get the ssitest.shtml file to include the contents of asptest.asp rather than execute the script.

    Any ideas?
     
    fluid, May 26, 2006 IP
  17. ProductivePC

    ProductivePC Peon

    Messages:
    362
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #17
    If you sign into your control panel, there should be instructions on how to implement shtml with SSI's.
     
    ProductivePC, May 26, 2006 IP
  18. fluid

    fluid Active Member

    Messages:
    679
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    70
    #18
    I am using Plesk 7.5 for Windows and i cant find any information for SSI. I contacted the hosting company and they said it is normal tht the contents will be included and not executed. I have achieved this on a Linux server but the Windows server just doesnt want to do it and the support on the hosting dont have a clue what im talking about.
     
    fluid, May 26, 2006 IP
  19. fluid

    fluid Active Member

    Messages:
    679
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    70
    #19
    Update

    I found this in the control panel :

    SSI support: Yes (use SSI for *.htm, *.html files[] )
    ... the [] represents a checkbox which is unticked.

    As i said before, if i include a .html file in the .shtml file, then it works fine but when i include a .asp file, it just renders the content as text rather than execute the script.
     
    fluid, May 26, 2006 IP
  20. fluid

    fluid Active Member

    Messages:
    679
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    70
    #20
    Right. I've got the answer from my hosting provider now.

    This works on linux server because PHP works there as apache's module, and not as CGI. So, when Apache trys to include file, it passes the file thru php module, which executes it. So, you get included parsed php file in result.

    However, on win server php is configured as CGI and IIS does this in another way. Even if something (like asp) is configured as ISAPI IIS doesn't cascade filters, just SSI filter opens raw file from disk and includes it to target file without any parsing (as SSI filter does not parse anything except SSI). So you get source code as result.
     
    fluid, May 30, 2006 IP