千禧媒体PHP设置(代码集成)

时间:2013-01-24 21:33:19

标签: php wordpress millennial-media

我知道对于具有良好PHP知识的人来说,这将是一个非常简单的问题。

我自己托管了一个WordPress网站。我为移动设备设计了它,我想在其中安装Millennial Media广告。 Millennial Media并没有提供详细的说明,而且奇怪的网络资源也不可用!

我对HTML,CSS和JavaScript有所了解,但PHP非常差:(。 任何方式我可以做一些改变PHP来实现我想要的,但我不能从零写它们并将它们整合在我自己。

好的长话短说 这是Millennial Media提供的代码:

<?php 
/*--------------------------------------------------------------*/ 
/* Millennial Media PHP Ad Coding, v.7.4.20                     */ 
/* Copyright Millennial Media, Inc. 2006                        */ 
/*                                                              */ 
/* The following code requires PHP >= 4.3.0 and                 */ 
/* allow_url_fopen 1 set in php.ini file.                       */ 
/*                                                              */ 
/* NOTE:                                                        */ 
/* It is recommended that you lower the default_socket_timeout  */ 
/* value in the php.ini file to 5 seconds.                      */ 
/* This will prevent network connectivity from affecting        */ 
/* page loading.                                                */ 
/*--------------------------------------------------------------*/ 

/*------- Publisher Specific Section -------*/ 
$mm_placementid = 123456; 
$mm_adserver = "ads.mp.mydas.mobi"; 

/* The default response will be echo'd on the page     */
/* if no Ad is returned, so any valid WML/XHTML string */
/* is acceptable.                                      */
$mm_default_response = "";

/*------------------------------------------*/

/*----------- BEGIN AD INITIALIZATION ----------*/
/*----- PLEASE DO NOT EDIT BELOW THIS LINE -----*/
$mm_id = "NONE";
$mm_ua = "NONE";
@$mm_ip = $_SERVER['REMOTE_ADDR'];

if (isset($_SERVER['HTTP_USER_AGENT'] )){
     $mm_ua = $_SERVER['HTTP_USER_AGENT'];
}

if (isset($_SERVER['HTTP_X_UP_SUBNO'])) {
          $mm_id = $_SERVER['HTTP_X_UP_SUBNO'];
} elseif (isset($_SERVER['HTTP_XID'])) {
          $mm_id = $_SERVER['HTTP_XID'];
} elseif (isset($_SERVER['HTTP_CLIENTID'])) {
          $mm_id = $_SERVER['HTTP_CLIENTID'];
} else {
          $mm_id = $_SERVER['REMOTE_ADDR'];
}

$mm_url = "http://$mm_adserver/getAd.php5?apid=$mm_placementid&auid="
          . urlencode($mm_id) . "&uip=" . urlencode($mm_ip) . "&ua="
          . urlencode($mm_ua);
/*------------ END AD INITIALIZATION -----------*/
?>

<?php
/* Place this code block where you want the ad to appear */
/*------- Reusable Ad Call -------*/
@$mm_response = file_get_contents($mm_url);
echo $mm_response != FALSE ? $mm_response : $mm_default_response;
/*--------- End Ad Call ----------*/
?>

我希望广告出现在页脚区域(我将在二十一个主题中编辑footer.php) 但是我想知道在哪里可以将这些代码放在wordpress文件中,或者我应该创建一个新代码以及如何命名它们?

请一些人帮我解决这个问题并向我提供需要编辑的文件名称以及它们最终会是什么样子?

由于

1 个答案:

答案 0 :(得分:2)

在您的网页中,您希望展示广告的位置,让我们说在<div>内,请使用:

<div>
   <?php include('thatfiletheysentyou.php'); ?>
</div>

这将使该文件的输出显示在include的位置。

编辑:完成重写:

这是footer.php的内容。我刚刚为你安装了wordpress,花了3分钟。我编辑了footer.php,包括<?php include('ads.php'); ?>(见下文),它出现在页脚中,符合预期

<?php
/**
 * The template for displaying the footer.
 *
 * Contains the closing of the id=main div and all content after
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 * @since Twenty Eleven 1.0
 */
?>

    </div><!-- #main -->


    <footer id="colophon" role="contentinfo">

            <?php
                /* A sidebar in the footer? Yep. You can can customize
                 * your footer with three columns of widgets.
                 */
                if ( ! is_404() )
                    get_sidebar( 'footer' );
        ?>

        <div id="site-generator">
        <div>
         <?php include('ads.php'); ?>
        </div>
    <?php do_action( 'twentyeleven_credits' ); ?>
    <a href="<?php echo esc_url( __( 'http://wordpress.org/', 'twentyeleven' ) ); ?>" title="<?php esc_attr_e( 'Semantic Personal Publishing Platform', 'twentyeleven' ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentyeleven' ), 'WordPress' ); ?></a>
        </div>
</footer><!-- #colophon -->
</div><!-- #page -->

<?php wp_footer(); ?>

</body>
</html>

现在,如果您从广告公司获得了一个文件,请将上面的ads.php更改为此文件名。如果你有一个粘贴的代码(我不知道,一个电子邮件,网站) - 创建一个文件ads.php并粘贴你从中得到的任何东西。将该文件放在twentyeleven子文件夹中。我的文件看起来像这样:

<?php
  echo 'HEHEHE!';
  //instead of this just paste your code here
?>

在页面上就像这样: 1 http://www.spzozwolsztyn.internetdsl.pl/wpress.jpg

如果你厌倦了,请从footer.php中删除include line。