廣告廣告
  加入我的最愛 設為首頁 風格修改
首頁 首尾
 手機版   訂閱   地圖  簡體 
您是第 2804 個閱讀者
 
發表文章 發表投票 回覆文章
  可列印版   加為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.113717 second(s),query:15 Gzip disabled
本站由 瀛睿律師事務所 擔任常年法律顧問 | 免責聲明 | 本網站已依台灣網站內容分級規定處理 | 連絡我們 | 訪客留言