• I have write a small hacks for index.php file to display an interstitial advertising, however it did not work in the right way.
    – People need to click 2 times to go inside.
    – Feeds was not working any more.

    <?php
    session_start();
    
    if (!empty($_SESSION['count'])) {
       define('WP_USE_THEMES', true);
       require('./wp-blog-header.php');
    
    } else if(empty($_SESSION['count'])){
    	$_SESSION['count'] = 1;
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Refresh" content="7; url=index.php">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Advertising</title>
    </head>
    <body>
    Advertising goes here.
    Click <a href="index.php">here</a> to go inside or you will be redirected after 7 seconds.
    </body>
    </html>
    <?php } ?>

    Is there any better way to display an interstitial advertising as above ? Please help me, thank you very much

Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    As far as I can tell, that should work fine. It works for me on your ebooksportal site. I only had to click once.

    Of course, if they’re blocking cookies, then you have an issue since the session won’t be passed along. You can fix that by changing your link:

    Click <a href="index.php?<?php echo htmlspecialchars(SID); ?>">here</a> to go inside or you will be redirected after 7 seconds.

    PHP *should* do this automatically if necessary. However, you might try it and see if it helps anyway.

    Thread Starter mrblue

    (@mrblue)

    Thank you so much for your support. I forgot that issue.
    I don’t know why, but it still take me 2 times to go inside (test on both of I.E and FF)
    Is there any way for feed ? It did not working any more. Or do you know some javascript could implement this thing ? I really appreciate your help !

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Hmmm… You could examine the $_SERVER['REQUEST_URI'] and see if it contains “feed” in it anywhere. If so, pass along to the blog header.php as per usual.

    Like so:

    ...
    if (!empty($_SESSION['count']) || stristr($_SERVER['REQUEST_URI'], 'feed')) {
       define('WP_USE_THEMES', true);
       require('./wp-blog-header.php');
    }
    ...

    Thread Starter mrblue

    (@mrblue)

    Yeah, you are the genius, Otto, it worked like a charm.

    Did you get a problem that, after click on the link to go inside, then you click on the link to read more, it will return the advertising page ?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    I’m not getting that particular problem here. Although I could see it happening. The problem is basically that you’re replacing index.php and subverting the system. Index.php is expected to be the main page for everything, blocking it like this could cause all sorts of weirdness.

    Try changing your interstitial page to interstitial.php and adding DirectoryIndex interstitial.php to your .htaccess instead. That way, people going to your site with http://example.com/ will get the interstitial.php page instead. Then have the interstitial page forward the user to index.php.

    I *think* that will work. Maybe.

    Thread Starter mrblue

    (@mrblue)

    Yup, I totally agree with you this point. However, it will cause other issues, I guess, for instance images, which store on the server will not display.

    I think that the best way to solve this problem is to use javascript instead, however I am very new to that kind of language.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    It shouldn’t interfere with images with that trick. Not the DirectoryIndex one, anyway.

    Thread Starter mrblue

    (@mrblue)

    I really admire your knowledge and kindly mind. It worked very well after I tried, however the search function was not working any more.

    I think that the problem is in this line:
    <form method=”get” id=”searchform” action=”<?php bloginfo(‘home’); ?>/”>

    Is there any suggestion ?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Try changing the action to have a /index.php on the end of the URL. Like <?php bloginfo('home'); ?>/index.php or something.

    Thread Starter mrblue

    (@mrblue)

    Thank you so much for your help. I really appreciate and remember this kindly action. The search engine has worked again !

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Problem with Interstitial Ads in index.php’ is closed to new replies.