SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Phpadmentor doubt

    Hi.
    Im new to sitepoint and im wondering if anyone knows how to put banners on phpadmentor opening in another page.

    Thanks

  2. #2
    SitePoint Wizard silver trophybronze trophy Nadia P's Avatar
    Join Date
    Oct 2004
    Location
    NSW Australia
    Posts
    3,564
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi and welcome to Sitepoint. I"ve not used phpadmentor so can't help there, but may be you could ask your question in the PHP section of the forum, I'm sure that people there may be familiar with this.

    Nadia

  3. #3
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    I think this is more of a basic HTML question, I guess you mean that when the user clicks the link it opens a new browser window rather than opening in the same page....


    If so you can simply use <a href="link_here.com" target="blank" />
    However I seem to recall that the target attribute is deprecated or is on it's wa. In that case you would need some javascript to do the direction.

    PS Welcome to the forums
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  4. #4
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks
    But when I generate the html code it gives me this "echo(PhpAdMentor_GetAd("7", 2, 14) );"
    Meaby I have to change something on the phpadmentor_config.php but don&#180;t know what.

  5. #5
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,254
    Mentioned
    113 Post(s)
    Tagged
    1 Thread(s)
    Moved to a more appropriate forum...
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style

  6. #6
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks


    Meaby someone can give me an help on the code:

    Code:
    <?
    $sPhpAdMentor_InstallPath = "http://www.aspcode.net/phpadmentor/";
    $sPhpAdMentor_DBHost = "localhost";
    $sPhpAdMentor_DBUser = "youruserid";
    $sPhpAdMentor_DBPassword = "yourpassword";
    $sPhpAdMentor_DBDatabase = "phpadmentor";
    
    $sPhpAdMentor_DefaultBanner = "http://www.aspcode.net/images/aspcode46860.gif";
    $sPhpAdMentor_DefaultClick = "http://www.aspcode.net/";
    
    
    //$PhpAdMentor_admin_user = "stefan";
    //$PhpAdMentor_admin_pass = "stefan";
    
    $sPhpAdMentor_MaxInt = 2147483647;
    $sPhpAdMentor_MaxDate = "2020-10-10";
    
    function PhpAdMentor_MaxIntToNull( $val )
    {
    global $sPhpAdMentor_MaxInt;
    if ( $val == $sPhpAdMentor_MaxInt )
        return "";
    return $val;
    }
    
    //Do not modify functions below...
    function PhpAdMentor_GetDatabaseConn()
    {
        global $sPhpAdMentor_DBHost;
        global $sPhpAdMentor_DBUser;
        global  $sPhpAdMentor_DBPassword;
        global $sPhpAdMentor_DBDatabase;
        $conn = mysql_connect($sPhpAdMentor_DBHost, $sPhpAdMentor_DBUser, $sPhpAdMentor_DBPassword);
        mysql_select_db($sPhpAdMentor_DBDatabase, $conn);
        return $conn;
    }
    
    function PhpAdMentor_UpdateStats( $connadmentor, $id, $addclicksno, $addimpressionsno )
    {
        global $sPhpAdMentor_DBDatabase;
    
    
        $sSQL = "select count(*) as antal from $sPhpAdMentor_DBDatabase.stats where bannerid=$id and datum=curdate()";
        $oRS = mysql_query( $sSQL, $connadmentor );
    
        $row = mysql_fetch_array($oRS);
        if ( $row["antal"] != 0 )
            {
            //Already exists
            $sSQL = "update $sPhpAdMentor_DBDatabase.stats set ";
            if (  $addclicksno )
                $sSQL = $sSQL . "clicks=clicks+1";
            if (  $addimpressionsno )
                $sSQL = $sSQL . "impressions=impressions+1";
            $sSQL = $sSQL . " where datum=Now() and bannerid=$id ";
            }
        else
            {
            $sSQL = "insert into $sPhpAdMentor_DBDatabase.stats( bannerid,datum,clicks,impressions ) values($id, Now() ";
            if (  $addclicksno )
                $sSQL = $sSQL . ",1";
            else
                $sSQL = $sSQL . ",0";
            if (  $addimpressionsno )
                $sSQL = $sSQL . ",1";
            else
                $sSQL = $sSQL . ",0";
            $sSQL = $sSQL . ")";
            }
        mysql_query( $sSQL, $connadmentor );
    
        $sSQL = "update $sPhpAdMentor_DBDatabase.banner set showcount=showcount+";
        if (  $addimpressionsno )
            $sSQL = $sSQL . "1";
        else
            $sSQL = $sSQL . "0";
        $sSQL = $sSQL . ",clickcount=clickcount+";
    
        if (  $addclicksno )
            $sSQL = $sSQL . "1";
        else
            $sSQL = $sSQL . "0";
        $sSQL = $sSQL . " where bannerid=$id";
        mysql_query( $sSQL, $connadmentor );
    }
    
    
    
    function AdSQL_AddAndWhere( $sWhere, $sWhat )
    {
        $sRet = "";
        if ( $sWhere == "" )
            $sRet = " WHERE ";
        else
            $sRet = $sWhere .  " AND ";
    
        $sRet = $sRet . " " . $sWhat;
        return $sRet;
    }
    function PhpAdMentor_GetBanner($bid, $gifurl, $xsize, $ysize )
    {
            global $sPhpAdMentor_InstallPath;
            if ($xsize != 0 )
                $xsizestring = "width='$xsize'";
            if ($ysize != 0 )
                $ysizestring = "height='$ysize'";
    
            $sClickUrl = $sPhpAdMentor_InstallPath . "click.php?mgr=aspcode.net&id=" . $bid;
            return "<a href='$sClickUrl'><img border='0' src='$gifurl' $xsizestring $ysizestring></a>";
    }
    
    function PhpAdMentor_GetHTMLBanner( $htmlcode )
    {
    //Replace with special tags...
    $htmlcode = stripslashes($htmlcode);
    
    srand ((double) microtime() * 1000000);
    
    $lastrandom ="";
    
    $nOffset = 0;
    while ( $posstart = strpos($htmlcode, "<ADM_RANDOM", $nOffset ) )
        {
    //                echo($posstart);
        //Found one, now we need to find end tag
        $posend = strpos( $htmlcode, ">", $posstart+1 );
        if ( !$posend )
            break;
    //                echo($posend);
        $len = $posend-$posstart;
        $wholetag = substr($htmlcode, $posstart, $len+1  );
        if ($wholetag == "<ADM_RANDOM-LAST>" )
            {
            $left = substr($htmlcode,0,$posstart);
            $right =substr($htmlcode,$posend+1);
            $htmlcode =$left . $lastrandom . $right;
            }
        else
            {
            $vArr = split( "-", $htmlcode );
            $leftnum = $vArr[1];
            $rightnum = $vArr[2];
            $lastrandom = rand(  $leftnum, $rightnum );
            $left = substr($htmlcode,0,$posstart);
            $right =substr($htmlcode,$posend+1);
            $htmlcode =$left . $lastrandom . $right;
            }
        }
    return $htmlcode;
    }
    
    
    function PhpAdMentor_GetAd( $sZones, $nAdPos, $nBannerId = 0, $conn=0 )
    {
        global $sPhpAdMentor_DBHost;
        global $sPhpAdMentor_DBUser;
        global  $sPhpAdMentor_DBPassword;
        global $sPhpAdMentor_DBDatabase;
        global $sPhpAdMentor_DefaultBanner;
        global $sPhpAdMentor_InstallPath;
    
        $sSQL = "";
        $sWhere = "";
    
        if ( $conn== 0)
            $connadmentor = mysql_pconnect($sPhpAdMentor_DBHost, $sPhpAdMentor_DBUser, $sPhpAdMentor_DBPassword);
        else
            $connadmentor = $conn;
    
        $sSQL =     "select distinct banner.bannerid as bannerid, gifurl, ishtml, htmlcode ";
        $sSQL = $sSQL . " from $sPhpAdMentor_DBDatabase.banner ";
    
        if (  $nBannerId != 0 )
            $sWhere = AdSQL_AddAndWhere( $sWhere, "banner.bannerid=" . $nBannerId );
        else
            {
            if( $sZones != "" )
                {
                $sSQL = $sSQL . ",$sPhpAdMentor_DBDatabase.banzone ";
                $sWhere = AdSQL_AddAndWhere( $sWhere, "banner.bannerid=banzone.bannerid" );
                $sWhere = AdSQL_AddAndWhere( $sWhere, "banzone.zoneid in ( " . $sZones . ")" );
                }
            if ( $nAdPos != 0 )
                {
                $sWhere = AdSQL_AddAndWhere( $sWhere, "banner.farmid=" . $nAdPos );
                }
    
            $sWhere = AdSQL_AddAndWhere( $sWhere, "weight > 0 and showcount < maximpressions AND validtodate >= now() AND validfromdate <= now()" );
            $sWhere = AdSQL_AddAndWhere( $sWhere, " (( ishtml=1 ) OR ( clickcount < maxclicks ) )"  );
            }
    
        $sSQL = $sSQL . $sWhere;
        $sSQL = $sSQL . " ORDER BY weight * RAND() limit 0,1";
    
        $oRS = mysql_query( $sSQL, $connadmentor );
        if ( mysql_num_rows($oRS) == 0 )
            {
            //default
            $sClickUrl = $sPhpAdMentor_InstallPath . "click.php?mgr=aspcode.net&id=-1";
            return "<a href='$sClickUrl'><img border='0' src='$sPhpAdMentor_DefaultBanner'></a>";
            }
        else
            {
            $row = mysql_fetch_array($oRS);
            //Simply generate the banner html
            if ($row["ishtml"] == 1 )
                {
                $htmlcode = PhpAdMentor_GetHTMLBanner($row["htmlcode"]);
                PhpAdMentor_UpdateStats( $connadmentor, $row["bannerid"], false,true );
                return $htmlcode;
                }
    
            $htmlcode = PhpAdMentor_GetBanner( $row["bannerid"], $row["gifurl"], $row["xsize"], $row["ysize"]  );
            PhpAdMentor_UpdateStats( $connadmentor, $row["bannerid"], false,true );
            return $htmlcode;
            }
    }
    
    
    
    
    
    
    ?>
    This is the phpadmentor_config.php file , can anyone tell me how to put the banners opening in another page?

    Thanks

  7. #7
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    I've not looked at the entire script, but I think I may have found the bit you need to edit:

    PHP Code:
    function PhpAdMentor_GetBanner($bid$gifurl$xsize$ysize )
    {
            global 
    $sPhpAdMentor_InstallPath;
            if (
    $xsize != )
                
    $xsizestring "width='$xsize'";
            if (
    $ysize != )
                
    $ysizestring "height='$ysize'";

            
    $sClickUrl $sPhpAdMentor_InstallPath "click.php?mgr=aspcode.net&id=" $bid;
            return 
    "<a href='$sClickUrl' target='_blank'><img border='0' src='$gifurl$xsizestring $ysizestring></a>";

    If you replace the existing PhpAdMentor_GetBanner function with the one above, it should open the ads in a new window instead of the current window.
    It uses the target attribute, which isn't valid in XHTML. So if you're writing XHTML, you may want to replace the target='_blank' with an onclick handler instead. But my guess is that this'll be fine

  8. #8
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks works perfect !!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •