<?php // ۞// text { encoding:utf-8 ; bom:no ; linebreaks:unix ; tabs:4sp ; }
if (isset($my['version'])) { return; }  else  {  $my['version'] = '0.7';   }
if  (
realpath ($_SERVER['SCRIPT_FILENAME'])    ==    realpath (__FILE__))  {
                                        die ( 
'to err is human, human!' ); }
/*
    Ad-Loader    v0.7

    See notes at the bottom for "How to create an Ad Module".

    ;o)

    (c) copyright corz.org 2011->tomorrow!

*/


/*
prefs.. */

//// Uncomment if you haven't already set these variables (in page/init)
////
//// campaign name    (must match entry in ad-loader.ini or be "all")
//// see the bottom of this script for more details.
////
//if (!isset($ad_loader['campaign'])) { $ad_loader['campaign'] = 'all'; }
////
//// ini file where you store your ad modules..
////
//$ad_loader['settings_file'] = dirname(__FILE__).'/ad-loader.ini';
////
//// where the image resources are kept (the path from site root)..
////
//$ad_loader['image_folder'] = '/img/resources/';
////

/* end prefs.
*/



// my_function..
function do_my_ads($shuffle=false) {
  global 
$ad_loader$site_config;

    
// assign default values..
    
$ad_loader['url'] = 'http://'.$site_config['host'].'/';
    
$ad_loader['text'] = 'AD text goes here!';
    
$ad_loader['title'] = $ad_loader['image'] = '';

    
// grab the settings from the ini file..
    
$master_ini_array parse_ini_file($ad_loader['settings_file'], true);
    
// randomize the entries..
    
if ($shuffle) { kshuffle($master_ini_array); }

    
$ad_count 0;

    foreach (
$master_ini_array as $product_name => $campaign_data) {

        if (
array_key_exists('campaign'$campaign_data)) { $ad_loader['my_campaign'] = $campaign_data['campaign']; }

        if (!
stristr($_SERVER['PHP_SELF'], $product_name)) {

            if (
$product_name == $ad_loader['campaign']
              or 
$ad_loader['campaign'] == $ad_loader['my_campaign']
                or 
$ad_loader['campaign'] == 'all') {

                
// set the URL and title for the ad..
                
if (array_key_exists('url'$campaign_data))        { $ad_loader['url'] = $campaign_data['url']; }
                if (
array_key_exists('title'$campaign_data))        { $ad_loader['title'] = $campaign_data['title']; }
                if (
array_key_exists('image'$campaign_data))        { $ad_loader['image'] = $campaign_data['image']; }
                if (
array_key_exists('text'$campaign_data))        { $ad_loader['text'] = $campaign_data['text']; }

                
// multiple text strings, choose a random one..
                
if (stristr($ad_loader['text'], "|")) { //redundant
                    
$ad_strings explode('|'$ad_loader['text']);
                    
$ad_loader['text'] = $ad_strings[rand(0,(count($ad_strings)-1))];
                }

                
// we will URL-encode the name parts (not slashes, though)
                
$ad_loader['image'] = urlencode($ad_loader['image']);
                
$ad_loader['image'] = str_replace('%2F''/'$ad_loader['image']);


                
// spit out the ad..
                //
                
echo '
<div class="my-promo-plate">
    <a target="_blank" rel="noopener noreferrer" href="'
,$ad_loader['url'],'" title="',$ad_loader['title'],'">
        <img class="promo-img" width="64" id="res_image_'
,$product_name,'" src="',$ad_loader['image_folder'],$ad_loader['image'],
                                                                            
'" alt="image for ',$ad_loader['campaign'],'" />
        <div class="my-ad-message">'
,$ad_loader['text'],'</div>
    </a>
</div>'
;

                
$ad_count++;
                if (
$ad_count >= $site_config['show_ads']) { break; }

            }
        }
    }
}

/*

DELETE:
https://www.googleapis.com/adsensehost/v4.1/accounts/SOMETHINGTHEFUCKINHERE/adclients/ca-pub-7123663696036963/adunits/9994046867

*/






function do_google_ad($ad_type) {

    switch (
$ad_type) {

        case 
"big-rec-1":

            if (
$_SERVER['HTTP_HOST'] == $GLOBALS['site_config']['dev_mirror']) {
                echo 
'<div class="dummy-ad" style="width:336px;height:280px;">Google Ad Here</div>';
            } else {
                echo 
'<script nonce="'.$_SERVER['CSP_NONCE'].'" async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- corz.org webmaster  rectangle -->
<ins class="adsbygoogle"
     style="display:inline-block;width:336px;height:280px;background-color:'
,$GLOBALS['site_scheme']['bg_color'],'"
     data-ad-client="ca-pub-7123663696036963"
     data-ad-slot="4453380472"></ins>
<script nonce="'
.$_SERVER['CSP_NONCE'].'">
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<noscript><!-- google stuff --></noscript>'
;
            }
            break;

        case 
"banner-1":
            if (
$_SERVER['HTTP_HOST'] == $GLOBALS['site_config']['dev_mirror']) {
                
//echo '<iframe src="',$GLOBALS['site_config']['url'],'/dummy-ad.html" name="google_ads_frame1" id="google_ads_frame1" title="Dummy Ad!"></iframe>';
                
echo '<div id="ad-banner" class="dummy-ad" style="width:120px;height:240px;">Google Ad Here</div>';
            } else {

                echo 
'<div id="ad-banner"><script nonce="'.$_SERVER['CSP_NONCE'].'" async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- corz.org webmaster  banner -->
<ins class="adsbygoogle"
     style="display:inline-block;width:120px;height:240px;background-color:'
,$GLOBALS['site_scheme']['bg_color'],'"
     data-ad-client="ca-pub-7123663696036963"
     data-ad-slot="8275005566"></ins>
<script nonce="'
.$_SERVER['CSP_NONCE'].'">
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<noscript><!-- google stuff --></noscript></div>'
;
            }

            
// no break;
            // we print out both and use JavaScript to switch them on viewport scroll

        
case "wide-skyscraper":

            if (
$_SERVER['HTTP_HOST'] == $GLOBALS['site_config']['dev_mirror']) {
                echo 
'<div id="ad-skyscraper" class="dummy-ad" style="width:160px;height:600px;">Google Ad Here</div>';
            } else {
                echo 
'<div id="ad-skyscraper"><script nonce="'.$_SERVER['CSP_NONCE'].'" async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- corz.org webmaster wide skyscraper -->
<ins class="adsbygoogle"
     style="display:inline-block;width:160px;height:600px;background-color:'
,$GLOBALS['site_scheme']['bg_color'],'"
     data-ad-client="ca-pub-7123663696036963"
     data-ad-slot="8517313669"></ins>
<script nonce="'
.$_SERVER['CSP_NONCE'].'">
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<noscript><!-- google stuff --></noscript></div>'
;
            }
    }
}



// shuffle, but keep the key names..
// slightly long-winded but nice.
function kshuffle(&$array) {
    if(!
is_array($array) or empty($array)) {
        return 
false;
    }
    
$tmp = array();
    foreach(
$array as $key => $value) {
        
$tmp[] = array('k' => $key'v' => $value);
    }
    
shuffle($tmp);
    
$array = array();
    foreach(
$tmp as $entry) {
        
$array[$entry['k']] = $entry['v'];
    }
    return 
true;
}






/*

    How to create an Ad Module.    (old version)

    NOTE: Overlays have been deprecated in favour of using CSS to dim inactive ads.


    *   Create an images for the Ad
        (usually 64px (or larger) PNG with alpha transparency)

        This can be your main product logo.
        Larger images will be scaled down to 64px on the page.


    *   Add an entry in ad-loader.ini, e.g..


            ; the ini[section] is the name of the product..
            [checksum]

            ; The URI of the landing page..
            url = "https://corz.org/windows/software/checksum/"

            ; This is the ToolTip which pops up when the user hovers a pointer over the ad..
            title = "Drag and drop hashing for windows.."


            ; This is the image that will be used for the ad (placed below the text)
            ; The directory for the images is set in ad-loader.php (for all images in one dir)
            ; or you can set it to blank and enter the full site path to the image resource.
            image = "checksum_resource_01_icon_[120px].png"

            ; Text of the Ad.
            ; If you create multiple text entries, a random one will be picked each time the ad is generated..
            text = "Give your data some peace of mind..|Peace of mind with a click..|Is that file still 100% ?"


            ; You can specify a "section campaign" in the individual product. When set,
            ; this enables ad-loader to generate section-specific ads.
            campaign = "windows"


            NOTE:    The [section] name must not contain spaces or punctuation
                    (basically anything that would mess up an id="" attribute)

                    It also makes sense to use a string that would be found in
                    the product's URL, so ad-loader can auto-skip ads on pages
                    about that product.

                    For example, the above module will NOT load for this page:

                        https://corz.org/windows/software/checksum/index.php


    *    Enable site ads, and set the campaign (in the calling page)

            <?php

            $site_config['show_ads'] = 3;    //    longer pages have higher values, can show more ads - I never go above 3, personally.

            // switch on the ads..
            $site_config['do_my_ads'] = true;

            // enabling (individual) promotions..
            $ad_loader['campaign'] = 'LoopDropZ';

            // or load all available ads.. (except auto-skipped ads)
            //$ad_loader['campaign'] = 'all';

            This is generally done on a site-wide basis, only disabling on
            special pages, like your front page, etc.


            How "campaigns" work:

                Ad-Loader chooses which ads to display based on the current "campaign".

                This is generally set to "all", allowing Ad-Loader to select from any ad.

                It can also be set to a product name, which is whatever is in the
                [section] title of the ini entry, e.g. "checksum", so only the checksum
                ad would appear.

                It can also be set to a "section", which will match anying you have set in
                a particular ad's campaign = "something" setting.

                It's usually best to set campaign to "all" on a global basis. Then, in your
                header/footer, you can check for the current PATH/QUERY and switch the
                campaign to, for example, "windows". In that part of the site, only ads
                with their sub-capaign set to "windws" will be shown, targeting your ads
                for the windows-specific audience.

                 Lots of ads can have the same campaign set, e.g. "windows", and Ad-Loader
                 will pick a selection from them.


        *    Call the Ad Function..

            Anywhere you want an ad block to appear, do this:

                do_my_ads();






*/



?>
back to the source menu
test

Welcome to corz.org!

I'm always messing around with the back-end.. See a bug? Wait a minute and try again. Still see a bug? Mail Me!