inversesoft123 Posted January 8, 2009 Share Posted January 8, 2009 Anybody please help me out ... I am having admob advertise code with me I wanna use it into PHProxy but when I insert it gives Header already sent error.. Can any 1 guide me how to ad+ external PHP code into PHProxy I am attaching screenshot where I wanted to add code.. The code I am trying to insert is.. code1: <?php /* editable area */ $mob_mode = 'live'; // change mode from "test" to "live" when you are done testing $mob_alternate_link = ''; // use this to set a default link to appear if AdMob does not return an ad. /* end editable area */ //used for ad targeting $mob_contents = ''; $mob_ua = urlencode(getenv("HTTP_USER_AGENT")); $mob_ip = urlencode($_SERVER['REMOTE_ADDR']); $mob_m = ''; if ($mob_mode=='test') $mob_m = "&m"; $mob_url = 'http://ads.admob.com/ad_source.php?s=xxxxxxxxxx&u='.$mob_ua.'&i='.$mob_ip.$mob_m; @$mob_ad_serve = fopen($mob_url,'r'); if ($mob_ad_serve) { while (!feof($mob_ad_serve)) $mob_contents .= fread($mob_ad_serve,1024); fclose($mob_ad_serve); } $mob_link = explode("><",$mob_contents); $mob_ad_text = $mob_link[0]; $mob_ad_link = $mob_link[1]; if (isset($mob_ad_link) && ($mob_ad_link !='')) { //display AdMob Ad echo '<a href="'. $mob_ad_link .'">'. $mob_ad_text . '</a>'; } else { //no AdMob ad, display alternate echo $mob_alternate_link; } echo "<br/>\n"; ?> and Code2: <?php // change to "live" to disable demo mode and show real ads define("MOJIVA_MODE", "live"); function mojiva_ad($mojiva_params = array()) { // prepare url parameters of request $mojiva_get = 'site='.urlencode('252'); $mojiva_get .= '&ip='.urlencode($_SERVER['REMOTE_ADDR']); $mojiva_get .= '&ua='.urlencode($_SERVER['HTTP_USER_AGENT']); $mojiva_get .= '&url='.urlencode(sprintf("http%s://%s%s", (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == TRUE ? "s": ""), $_SERVER["HTTP_HOST"], $_SERVER["REQUEST_URI"])); $mojiva_get .= '&zone='.urlencode('277'); $mojiva_get .= '&adstype=3'; // type of ads (1 - text only, 2 - images only, 3 - text + images) $mojiva_get .= '&key=1'; $mojiva_get .= '&count=1'; // quantity of ads $mojiva_get .= '&keywords='; // keywords to search ad delimited by commas (not necessary) $mojiva_get .= '&whitelabel=0'; // filter by whitelabel(0 - all, 1 - only whitelabel, 2 - only non-whitelabel $mojiva_get .= '&premium=0'; // filter by premium status (0 - non-premium, 1 - premium only, 2 - both $mojiva_get .= '¶mBORDER='.urlencode('#000000'); // ads border color $mojiva_get .= '¶mHEADER='.urlencode('#cccccc'); // header color $mojiva_get .= '¶mBG='.urlencode('#eeeeee'); // background color $mojiva_get .= '¶mTEXT='.urlencode('#000000'); // text color $mojiva_get .= '¶mLINK='.urlencode('#ff0000'); // url color if(MOJIVA_MODE == "test") $mojiva_get .= '&test=1'; // send request $mojiva_request = @fsockopen('ads.mojiva.com', 80, $errno, $errstr, 1); if ($mojiva_request) { stream_set_timeout($mojiva_request, 1000); fwrite($mojiva_request, "GET /ad?".$mojiva_get." HTTP/1.0\r\n"); fwrite($mojiva_request, "Host: ads.mojiva.com\r\n"); fwrite($mojiva_request, "Connection: Close\r\n\r\n"); $mojiva_info = stream_get_meta_data($mojiva_request); $mojiva_timeout = $mojiva_info['timed_out']; $mojiva_contents = ""; $mojiva_body = false; $mojiva_head = ""; while (!feof($mojiva_request) && !$mojiva_timeout) { $mojiva_line = fgets($mojiva_request); if(!$mojiva_body && $mojiva_line == "\r\n") $mojiva_body = true; if(!$mojiva_body) $mojiva_head .= $mojiva_line; if($mojiva_body && !empty($mojiva_line)) $mojiva_contents .= $mojiva_line; $mojiva_info = stream_get_meta_data($mojiva_request); $mojiva_timeout = $mojiva_info['timed_out']; } fclose($mojiva_request); if (!preg_match('/^HTTP\/1\.\d 200 OK/', $mojiva_head)) $mojiva_timeout = true; if($mojiva_timeout) return ""; return $mojiva_contents; } } ?> <?php // copy this snippet elsewhere on your page for display more of ads echo mojiva_ad($mojiva_params); echo '<br/>'; Please Guide me regarding above 2 separate codes that what should I do if I don't want error Headers Already Sent in PHProxy.. thx Link to comment https://forums.phpfreaks.com/topic/140034-how-to-add-php-code-in-phproxy/ Share on other sites More sharing options...
corbin Posted January 8, 2009 Share Posted January 8, 2009 Look at the "Headers Already Sent" sticky in the PHP Help forum ;p. Link to comment https://forums.phpfreaks.com/topic/140034-how-to-add-php-code-in-phproxy/#findComment-732880 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.