Still hating phtml

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jonlevine
    New Member
    • May 2002
    • 24

    Still hating phtml

    I am still looking for a solution to my problem of either making vbulletin output .pthml pages or getting my ad manager program to work on pages without a .phtml extension.

    To summarize, I use an ad manager program (banner ads and the like) which runs off php3. The software requires the pages that it run on end in .phtml. Unfortunately, vbulletin spits out pages with a .php extension, causing the ads not to be displayed on the forum pages. I am looking for some kind of work around to this issue. I've tried an .htaccess file (correctly, I believe) but to no avail. An 'include' was also suggested, but that didn't work either (possibly because I placed it in the wrong area of the code, but I am unsure). I've researched framing the whole site, so that the pages can run independantly of each other, but the site is already built (and ready to go live) and that would force me to scrap everything.

    Am I grasping at straws here or can this be solved? I'm at the end of my rope with this problem (literally, I'm tying the noose around my neck). Any and all help would be appreciated.
  • Mark Hensler
    Senior Member
    • Feb 2001
    • 570

    #2
    Why does this script require *.phtml files?
    I'm having a hard time understanding that.

    Comment

    • jonlevine
      New Member
      • May 2002
      • 24

      #3
      yes, it requires .phtml. it runs on php3, which i guess requires the extension to parse the code properly. for reference here is the code that needs to be inserted into the page with the .phtml extension.


      <?
      require("$DOCUMENT_ROOT/adserver/config.inc.php3");
      require("$DOCUMENT_ROOT/adserver/view.inc.php3");
      ?>
      <html>
      <head>
      </head>
      <?
      view("468x60","keyword");
      ?>
      </body>
      </html>

      Comment

      • okrogius
        Senior Member
        • Dec 2001
        • 1149

        #4
        Can you post a copy of the view.inc.php3?

        Comment

        • jonlevine
          New Member
          • May 2002
          • 24

          #5
          here's the view.inc.php3 code:

          [PHP]
          <?
          /* $Id: view.inc.php3,v 1.9 1999/09/13 18:27:25 tobias Exp $ */

          // Get a banner
          function get_banner($what,$clientID)
          {
          global $phpAds_db, $REMOTE_HOST, $phpAds_tbl_banners;
          if(is_string($what) AND !ereg("[0-9]x[0-9]",$what))
          {
          switch ($what)
          {
          // Get all HTML banners
          case "html":
          $select_html = "SELECT
          bannerID,
          banner,
          format,
          url
          FROM
          $phpAds_tbl_banners
          WHERE
          format = 'html'
          AND
          active = 'true'";

          if ($clientID!=0)
          $select_html .= " AND clientID = ".$clientID;
          $res = mysql_db_query($phpAds_db,$select_html) or mysql_die();
          //Not any of the special words (i.e. 'html'), So, must be a keyword
          default:
          $what_array = explode(",",$what);
          $select_html = "SELECT
          bannerID,
          banner,
          format,
          width,
          height,
          alt,
          bannertext,
          url
          FROM $phpAds_tbl_banners
          WHERE (";
          for($k=0;$k<count($what_array);$k++)
          $select_html .= "keyword LIKE '%".trim($what_array[$k])."%' OR ";

          $select_html .= "keyword = 'global') AND active = 'true'";

          /*
          The special 'global' keyword allows you to define a banner as global and
          show up under all keywords. I put this in so that if I didn't have any banners
          for a particular keyword, instead of being blank, it would show one of the global
          banners - Weston Bustraan <[email protected]>
          */

          if ($clientID!=0)
          $select_html .= " AND clientID = ".$clientID;
          $res = mysql_db_query($phpAds_db,$select_html) or mysql_die();
          } //swtich($what)
          }
          elseif (is_int( $what))
          {
          $select_int = "SELECT
          bannerID,
          banner,
          format,
          alt,
          width,
          height,
          bannertext,
          url
          FROM
          $phpAds_tbl_banners
          WHERE
          bannerID = ".$what."
          AND active = 'true'";
          if ($clientID!=0)
          $select_int .= " AND clientID = ".$clientID;
          $res = mysql_db_query($phpAds_db,$select_int) or die(mysql_error());
          }
          else
          {
          list($width, $height) = explode("x", $what);
          // Get all banners with the specified width/height
          $select_x = "SELECT
          bannerID,
          banner,
          format,
          alt,
          width,
          height,
          bannertext
          FROM
          $phpAds_tbl_banners
          WHERE
          width = ".$width."
          AND height = ".$height."
          AND active = 'true'";
          if ($clientID!=0)
          $select_x .= " AND clientID = ".$clientID;
          $res = mysql_db_query($phpAds_db,$select_x) or die(mysql_error());
          }

          $count = mysql_num_rows($res);

          // Select a random bannerID
          srand((double)microtime()*1000000);
          // Funny... rand() accepts a range n..m as parameter, when n is 0 then range goes
          // from 0 to m-1 instead of 0..m (as it does when n is eg 1). Is this the correct
          // behavious or am I missing something?

          if (mysql_num_rows($res)>1)
          {
          $rand = rand(1, mysql_num_rows($res));
          mysql_data_seek($res, $rand-1);
          }
          $row = mysql_fetch_array($res);
          return($row);
          }

          // Log an adview for the banner with $bannerID
          function log_adview($bannerID)
          {
          global $phpAds_log_adviews;

          if (!$phpAds_log_adviews)
          return(false);

          global $row, $phpAds_tbl_adviews;
          if (isset($GLOBALS["REMOTE_HOST"]) && !empty($GLOBALS["REMOTE_HOST"]))
          $host = $GLOBALS["REMOTE_HOST"];
          else
          if (isset($GLOBALS["REMOTE_ADDR"]) && !empty($GLOBALS["REMOTE_ADDR"]))
          $host = gethostbyaddr($GLOBALS["REMOTE_ADDR"]);
          $res = mysql_db_query($GLOBALS["phpAds_db"], "
          INSERT
          INTO $phpAds_tbl_adviews
          VALUES
          (
          '$bannerID',
          null,
          '$host'
          )
          ") or die(mysql_error());
          }

          // view a banner
          // $what can currently have one of the following formats:
          // - [INTEGER]: Display the banner with this bannerID
          // - "[WIDTH]x[HEIGHT]": Display a randomly selected banner with this width/height
          // - "html": Display a randomly selected HTML-banner
          function view($what, $clientID=0, $target = "", $withtext=0)
          {
          if (!is_int($clientID))
          {
          $target = $clientID;
          $clientID = 0;
          }
          global $phpAds_db, $REMOTE_HOST;
          mysql_pconnect($GLOBALS["phpAds_hostname"], $GLOBALS["phpAds_mysqluser"], $GLOBALS["phpAds_mysqlpassword"]);
          $row = get_banner($what,$clientID);

          if (!empty($row["bannerID"]))
          {
          if ($row["format"] == "html")
          {
          if(!empty($row["url"]))
          echo "<a href=\"$GLOBALS[phpAds_url_prefix]/click.php3?bannerID=$row[bannerID]\"$target>";
          echo $row["banner"];
          if(!empty($row["url"]))
          echo "</a>";
          }
          else
          {
          if (!empty($target))
          $target = " target=\"$target\"";
          echo "<a href=\"$GLOBALS[phpAds_url_prefix]/click.php3?bannerID=$row[bannerID]\"$target><img src=\"$GLOBALS[phpAds_url_prefix]/viewbanner.php3?bannerID=$row[bannerID]\" width=$row[width] height=$row[height] alt=\"$row[alt]\" border=0></a>";
          if (($withtext) && (! $row["bannertext"] == ""))
          echo "<BR>\n<a href=\"$GLOBALS[phpAds_url_prefix]/click.php3?bannerID=$row[bannerID]\"$target>".$row["bannertext"]."</a>";
          }
          log_adview($row["bannerID"]);
          }
          else
          {
          return(false);
          }
          return(true);
          }

          function view_t($what, $target = "")
          {
          view ($what, $target, 1);
          }

          ?>

          Comment

          • okrogius
            Senior Member
            • Dec 2001
            • 1149

            #6
            Your main problem here is that you're attempting to place dynamicaly generated code in a static html page.

            Try placing this in your phpinclude template:
            PHP Code:
            require("$DOCUMENT_ROOT/adserver/config.inc.php3"); 
            require(
            "$DOCUMENT_ROOT/adserver/view.inc.php3");
            $showads = eval("view('468x60','keyword');"); 
            Then try the $showads in your header template.

            Comment

            • Mark Hensler
              Senior Member
              • Feb 2001
              • 570

              #7
              PHP Code:
              require("$DOCUMENT_ROOT/adserver/config.inc.php3"); 
              require(
              "$DOCUMENT_ROOT/adserver/view.inc.php3");
              $showads = eval("return view('468x60','keyword');");
              // or
              //eval("\$showads=view('468x60','keyword');"); 
              eval() does not return a value unless return() is explicitly called.

              Comment

              • jonlevine
                New Member
                • May 2002
                • 24

                #8
                Codename and Mark,

                Thank you for taking the time to respond. I am a little confused though. I am unsure where to place the code that you re-wrote:

                PHP:--------------------------------------------------------------------------------
                require("$DOCUMENT_ROOT/adserver/config.inc.php3");
                require("$DOCUMENT_ROOT/adserver/view.inc.php3");
                $showads = eval("return view('468x60','keyword');");
                // or
                //eval("\$showads=view('468x60','keyword');");

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

                According to the Ad Manager docs these two lines:

                require("$DOCUMENT_ROOT/adserver/config.inc.php3");
                require("$DOCUMENT_ROOT/adserver/view.inc.php3");

                need to be at the very top of the page (above the <html> tag).

                Then :

                view('468x60','keyword');

                is placed where I want the ad to show up on the page.

                Does this still hold true for this new code? Meaning that I would now place:

                $showads = eval("return view('468x60','keyword');");

                where I want the ad to appear.

                As you both can probably tell, I'm rather new at php and I really do appreciate the help.

                Comment

                • jonlevine
                  New Member
                  • May 2002
                  • 24

                  #9
                  Getting closer

                  I placed the code into my phpinclude and the banner showed up!!!

                  The problem is, the banner it tucked up in the top right hand corner of my page. I tried placing the $showads where I want the banner to appear, but it just shows up as the number one (in the spot where I want the banner).

                  So then I tried moving the whole code where I want the banner to appear, but that didn't work.

                  Codename, you mentioned placing the $showads into my header template, but you didn't say where. Did you mean my headerinclude? I don't think you did (I tried it anyway though).

                  For reference, this page will show you what I'm talking about:



                  If you view the source code, you can see that it jams everything up at the very top of the page.

                  Thanks to the both of you, you are doing something that even vBulletins tech support said couldn't be done!
                  Last edited by jonlevine; Tue 21 May '02, 8:34pm.

                  Comment

                  • Mark Hensler
                    Senior Member
                    • Feb 2001
                    • 570

                    #10
                    Alright, view() seems to be printing rather than returning the string. We'll have to capture that...
                    PHP Code:
                    // put in phpinclude
                    require("$DOCUMENT_ROOT/adserver/config.inc.php3");
                    require(
                    "$DOCUMENT_ROOT/adserver/view.inc.php3");
                    ob_start();
                    view('468x60','keyword');
                    $showads ob_get_contents();
                    ob_end_clean(); 
                    Now just put $showads anywhere in your vB templates.

                    Comment

                    • jonlevine
                      New Member
                      • May 2002
                      • 24

                      #11
                      WHO'S THE MAN!!!!

                      Mark,

                      It worked!!!! I want to thank you and Codeman sooooo much for the help. I must have lost two night worth of sleep over this problem.

                      Thanks again!

                      Comment

                      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                      Working...