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


Millennial Media PHP Setup ( Code Integration )

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

我有一个自托管的WordPress网站。我为移动设备设计了它,我想在其中安装千禧一代媒体广告。千禧一代媒体并没有真正提供详细的说明,奇怪的是网络资源不可用!

我有HTML,CSS和JavaScript的知识,但在PHP:(方面很差。无论如何,我可以做一些更改PHP来实现我想要的,但我不能从零开始编写它们并自己集成它们。

好的长话短说这是千禧媒体提供的代码:

<?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 ----------*/
?>

我希望广告出现在页脚区域(我将在二十一主题中编辑页脚.php)但是我想知道我应该将这些代码放在WordPress文件中的什么位置,还是应该创建一个新的代码以及命名它们?

请有人帮助我解决这个问题,并向我提供需要编辑的文件名称以及它们最终的外观?

谢谢

在网页中您希望广告展示的任何位置,假设在<div>内,请使用:

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

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

编辑:完全重写:

这是页脚的内容.php。我刚刚为您安装了wordpress,花了3分钟。我编辑了页脚.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

如果您厌倦了它们,请从页脚中删除包含行.php。