广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 2803 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为IE收藏   收藏主题   上一主题 | 下一主题   
eddyt7878
数位造型
个人文章 个人相簿 个人日记 个人地图
路人甲
级别: 路人甲 该用户目前不上站
推文 x0 鲜花 x1
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片
推文 x0
[PHP][求助] 请问一下我的部落格要如何再加入一段php码
我的部落格式使用bo-blog,h网址是http://qoo320....t.us,我想再部落格中出售我的文字连结,但是广告网站都要我加入一段text ad code 在我的网页里面,Copy and paste this code inside your PHP code,内容是一段<?php 开头 的语法。
php好难喔。我到底要如何加入这段语法ㄋ。

复制程式
Install PHP Routine

    * Copy and paste this code inside your PHP code
    * Done



Important note

    * This ad slot is set for site wide links, so you will need to place the code in your website so that it will appear on all pages of your website.
    * Advertisers monitor the visitors that they get from text links by looking at their web analytics reports. To ensure you earn the most income, please place the ad code above the fold the layout of your website; that will allow them to receive clicks.
    * When you have placed the code in your website and it has been successfully installed, you will receive an email from us and we will start selling and listing your website in our inventory. Thanks for your attention.

view plaincopy to clipboardprint?

   1. <?php   
   2. function ask2link_ad_helper($url)  
   3. {  
   4.   $content = '';  
   5.   $done=false;  
   6.   if (ini_get('allow_url_fopen') == '1') {  
   7.     if ($fp = @fopen($url, 'r')) {  
   8.       while ($line = @fread($fp, 1024)) {  
   9.         $content .= $line;  
  10.     $done=true;  
  11.       }  
  12.     }  
  13.   }   
  14.   if (!$done) {  
  15.     // get the host name and url path  
  16.     $parsedUrl = parse_url($url);  
  17.     $host = $parsedUrl['host'];  
  18.     if (isset($parsedUrl['path'])) {  
  19.       $path = $parsedUrl['path'];  
  20.     }  
  21.       
  22.     $timeout = 10;  
  23.     // connect to the remote server   
  24.     $fp = @fsockopen($host, '80', $errno, $errstr, $timeout );   
  25.       
  26.     if( !$fp ) {   
  27.       // echo "Cannot retrieve $url";  
  28.     } else {  
  29.       // send the necessary headers to get the file   
  30.       @fputs($fp, "GET $path HTTP/1.0\r\n" .  
  31.         "Host: $host\r\n\r\n");   
  32.         
  33.       // retrieve the response from the remote server   
  34.       while ( $line = @fread( $fp, 4096 ) ) {   
  35.         $content .= $line;  
  36.       }         
  37.       @fclose( $fp );        
  38.       // strip the headers  
  39.       $pos      = strpos($content, "\r\n\r\n");  
  40.       $content = substr($content, $pos + 4);  
  41.     }  
  42.   }  
  43.       
  44.   // return the file content   
  45.   return $content;  
  46. }  
  47.   
  48. function ask2link_ad($url) {  
  49.   $h = urlencode($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);  
  50.   $content=ask2link_ad_helper($url."?x-h=".$h);  
  51.   if (!preg_match('/\<Error/',$content)) {  
  52.     echo $content;  
  53.   }    
  54. }  
  55.   
  56. echo ask2link_ad('http://s3.amazonaws.com/mf1/ad/3144377774c076d5439b1246379080/ad_content');  
  57.   
  58. ?>  

<?php 
function ask2link_ad_helper($url)
{
  $content = '';
  $done=false;
  if (ini_get('allow_url_fopen') == '1') {
    if ($fp = @fopen($url, 'r')) {
      while ($line = @fread($fp, 1024)) {
        $content .= $line;
       $done=true;
      }
    }
  } 
  if (!$done) {
    // get the host name and url path
    $parsedUrl = parse_url($url);
    $host = $parsedUrl['host'];
    if (isset($parsedUrl['path'])) {
      $path = $parsedUrl['path'];
    }
    
    $timeout = 10;
    // connect to the remote server 
    $fp = @fsockopen($host, '80', $errno, $errstr, $timeout ); 
    
    if( !$fp ) { 
      // echo "Cannot retrieve $url";
    } else {
      // send the necessary headers to get the file 
      @fputs($fp, "GET $path HTTP/1.0\r\n" .
           "Host: $host\r\n\r\n"); 
      
      // retrieve the response from the remote server 
      while ( $line = @fread( $fp, 4096 ) ) { 
        $content .= $line;
      }       
      @fclose( $fp );      
      // strip the headers
      $pos      = strpos($content, "\r\n\r\n");
      $content = substr($content, $pos + 4);
    }
  }
    
  // return the file content 
  return $content;
}

function ask2link_ad($url) {
  $h = urlencode($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
  $content=ask2link_ad_helper($url."?x-h=".$h);
  if (!preg_match('/\<Error/',$content)) {
    echo $content;
  }  
}

echo ask2link_ad('http://s3.amazonaws.com/mf1/ad/3144377774c076d5439b1246379080/ad_content');

?>




献花 x0 回到顶端 [楼 主] From:台湾中华电信HINET | Posted:2009-07-01 03:40 |

首页  发表文章 发表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.012782 second(s),query:15 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言