doupacan2098 2013-01-24 21:33
浏览 36
已采纳

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

I know this going to be very easy question for people with good PHP knowledge.

I have a WordPress website self hosted. I designed it for mobile devices and I would like to install Millennial Media advertisements in it. Millennial Media does not really provide detailed instructions and web resources strangely are not available!

I have knowledge in HTML,CSS and JavaScript but very poor in PHP :( . any way I can do some changes PHP to achieve what I want, but I can't write them from zero and integrate them by my self.

Ok long story short This the code provided by 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 ----------*/
?>

I want the Advertisement to appear in the footer area ( I will edit the footer.php in twenty eleven theme ) but I want to know where shall I put these pieces of codes in wordpress files or shall I create a new ones and what to name them?

would some please help me with this issue and provide me with the file's names that required to be edited and how would they look like in the end ?

Thanks

  • 写回答

1条回答 默认 最新

  • douci2516 2013-01-24 21:38
    关注

    Anywhere in your page, where you want the ad to appear, let's say inside a <div>, use:

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

    This will make output of that file appear where include is.

    EDIT: Complete rewrite:

    This is content of footer.php. I just installed wordpress for you, took 3 minutes. I edited footer.php including <?php include('ads.php'); ?> (see below), which appeared in footer, as expected

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

    Now if you got a file from the ad company, change ads.php above to this file name. If you got a code pasted in (i don't know, an e-mail, website) - create a file ads.php and paste whatever you got from them. Place that file in twentyeleven subfolder. My file looks like this:

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

    and on the page it is like so: 1 http://www.spzozwolsztyn.internetdsl.pl/wpress.jpg

    If you got tired of them remove include line from footer.php.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分