Extension:Script And Google AdSense
From MediaWiki.org
| WARNING: the code or configuration described here poses a major security risk.
Problem: Vulnerable to Cross-site scripting attacks, because it passes user input directly to the browser. This may lead to user accounts being hijacked, among other things. |
|
Release status: stable |
|
|---|---|
| Description | Add Google AdSense to individual pages or any other scripts. |
| Author(s) | Jung Lee aka Max Lee (zedomaxTalk) |
| Last Version | 0.1 |
| License | No license specified |
| Download | see below |
|
check usage (experimental) |
|
Contents |
[edit] What can this extension do?
This extension allow you to add Google AdSense ads or any other scripts.
[edit] Usage
Let's say you have this code from Google AdSense:
<script type="text/javascript"><!-- google_ad_client = "pub-3379402347635671"; //728x90, created 12/2/07 google_ad_slot = "6488952503"; google_ad_width = 728; google_ad_height = 90; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
- Replace <script type="text/javascript"> with <myscript>.
- Replace </script> with </myscript>.
- Replace <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> with <myscript src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></myscript>.
You should get something like this after the conversion:
<myscript><!-- google_ad_client = "pub-3379402347635671"; //728x90, created 12/2/07 google_ad_slot = "6488952503"; google_ad_width = 728; google_ad_height = 90; //--></myscript> <myscript src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </myscript>
See example on my QuarterWiki site QuickStartGuide.
[edit] Installation
To install this extension, add the following to LocalSettings.php:
require_once("$IP/extensions/myscript.php");
[edit] Code
<?php $wgExtensionCredits['parserhook'][] = array( 'name' => 'Script and Google AdSense Extension - 11/16/2007', 'author' => 'Max Lee http://zedomax.net', 'url' => 'http://zedomax.net', 'version' => 'v.0.1', 'description' => 'Add Google AdSense and other scripts for your pages', ); # MyScript extension # Usage: /* <myscript><!-- google_ad_client = "pub-3379402347635671"; //728x90, created 12/2/07 google_ad_slot = "6488952503"; google_ad_width = 728; google_ad_height = 90; //--></myscript> <myscript src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </myscript> */ # To install it put this file in the extensions directory # To activate the extension, include it from your LocalSettings.php # with: require("extensions/wikiscript.php"); $wgExtensionFunctions[] = "wfMyScript"; function wfMyScript() { global $wgParser; # registers the <myscript> extension with the WikiText parser $wgParser->setHook( "myscript", "renderMyScript" ); } # The callback function for converting the input text to HTML output function renderMyScript( $input, $argv ) { if ($argv["src"]=='') $output = '<script type="text/javascript">'; else $output = '<script src="'.$argv["src"].'" type="text/javascript">'; $output .= $input; $output .= '</script>'; return $output; }
[edit] Examples
Sites using this extension
[edit] See also
- meta:Google Ads Monobook Explains in detail how to install Adsense.
- Extension:AdSense experimental
- Extension:GoogleAdSense unknown status
- meta:User:Mike Dillon/AdSense "safer version" than Extension:AdSense
- http://lukej.net/mediawiki/index.php/AdSense
- Archived edsimpson.co.uk