[ PHPXref.com ] [ Generated: Sun Jul 20 19:31:32 2008 ] [ phpAdsNew 2.0.8 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> adframe.php (source)

   1  <?php // $Revision: 2.0.2.9 $
   2  
   3  /************************************************************************/
   4  /* phpAdsNew 2                                                          */
   5  /* ===========                                                          */
   6  /*                                                                      */
   7  /* Copyright (c) 2000-2006 by the phpAdsNew developers                  */
   8  /* For more information visit: http://www.phpadsnew.com                 */
   9  /*                                                                      */
  10  /* This program is free software. You can redistribute it and/or modify */
  11  /* it under the terms of the GNU General Public License as published by */
  12  /* the Free Software Foundation; either version 2 of the License.       */
  13  /************************************************************************/
  14  
  15  
  16  
  17  // Figure out our location
  18  define ('phpAds_path', '.');
  19  
  20  
  21  // Set invocation type
  22  define ('phpAds_invocationType', 'adframe');
  23  
  24  
  25  
  26  /*********************************************************/
  27  /* Include required files                                */
  28  /*********************************************************/
  29  
  30  require    (phpAds_path."/config.inc.php"); 
  31  require (phpAds_path."/libraries/lib-io.inc.php");
  32  require (phpAds_path."/libraries/lib-db.inc.php");
  33  
  34  if (($phpAds_config['log_adviews'] && !$phpAds_config['log_beacon']) || $phpAds_config['acl'])
  35  {
  36      require (phpAds_path."/libraries/lib-remotehost.inc.php");
  37      
  38      if ($phpAds_config['log_adviews'] && !$phpAds_config['log_beacon'])
  39          require (phpAds_path."/libraries/lib-log.inc.php");
  40      
  41      if ($phpAds_config['acl'])
  42          require (phpAds_path."/libraries/lib-limitations.inc.php");
  43  }
  44  
  45  require    (phpAds_path."/libraries/lib-view-main.inc.php");
  46  require (phpAds_path."/libraries/lib-cache.inc.php");
  47  
  48  
  49  
  50  /*********************************************************/
  51  /* Register input variables                              */
  52  /*********************************************************/
  53  
  54  phpAds_registerGlobal ('what', 'clientid', 'clientID', 'context',
  55                         'target', 'source', 'withtext', 'withText',
  56                         'refresh', 'resize', 'rewrite');
  57  
  58  
  59  
  60  /*********************************************************/
  61  /* Main code                                             */
  62  /*********************************************************/
  63  
  64  if (isset($clientID) && !isset($clientid))    $clientid = $clientID;
  65  if (isset($withText) && !isset($withtext))  $withtext = $withText;
  66  
  67  if (!isset($what))         $what = '';
  68  if (!isset($clientid))     $clientid = 0;
  69  if (!isset($target))     $target = '_blank';
  70  if (!isset($source))     $source = '';
  71  if (!isset($withtext))     $withtext = '';
  72  if (!isset($context))     $context = '';
  73  if (!isset($rewrite))    $rewrite = 1;
  74  
  75  // Remove referer, to be sure it doesn't cause problems with limitations
  76  if (isset($HTTP_SERVER_VARS['HTTP_REFERER'])) unset($HTTP_SERVER_VARS['HTTP_REFERER']);
  77  if (isset($HTTP_REFERER)) unset($HTTP_REFERER);
  78  
  79  
  80  // Get the banner
  81  $banner = view_raw ($what, $clientid, $target, $source, $withtext, $context);
  82  
  83  if (!is_array($banner))
  84  {
  85      // No banner returned, set some default values and prevent resizing
  86      $banner = array('html' => '', 'alt' => '');
  87      unset($resize);
  88  }
  89  
  90  // Rewrite targets in HTML code to make sure they are 
  91  // local to the parent and not local to the iframe
  92  if (isset($rewrite) && $rewrite == 1)
  93  {
  94      $banner['html'] = preg_replace('#target\s*=\s*([\'"])_parent\1#i', "target='_top'", $banner['html']);
  95      $banner['html'] = preg_replace('#target\s*=\s*([\'"])_self\1#i', "target='_parent'", $banner['html']);
  96  }
  97  
  98  
  99  // Build HTML
 100  echo "<html>\n";
 101  echo "<head>\n";
 102  echo "<title>".($banner['alt'] ? $banner['alt'] : 'Advertisement')."</title>\n";
 103  
 104  // Add refresh meta tag if $refresh is set and numeric
 105  if (isset($refresh) && !preg_match('/[^\d]/', $refresh))
 106      echo "<meta http-equiv='refresh' content='".$refresh."'>\n";
 107  
 108  if (isset($resize) && $resize == 1)
 109  {
 110      echo "<script language='JavaScript'>\n";
 111      echo "<!--\n";
 112      echo "\tfunction phpads_adjustframe(frame) {\n";
 113      echo "\t\tif (document.all) {\n";
 114      echo "\t\t\tparent.document.all[frame.name].width = ".$banner['width'].";\n";
 115      echo "\t\t\tparent.document.all[frame.name].height = ".$banner['height'].";\n";
 116        echo "\t\t}\n";
 117        echo "\t\telse if (document.getElementById) {\n";
 118      echo "\t\t\tparent.document.getElementById(frame.name).width = ".$banner['width'].";\n";
 119      echo "\t\t\tparent.document.getElementById(frame.name).height = ".$banner['height'].";\n";
 120        echo "\t\t}\n";
 121      echo "\t}\n";
 122      echo "// -->\n";
 123      echo "</script>\n";
 124  }
 125  
 126  echo "</head>\n";
 127  
 128  if (isset($resize) && $resize == 1)
 129      echo "<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0' style='background-color:transparent' onload=\"phpads_adjustframe(window);\">\n";
 130  else
 131      echo "<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0' style='background-color:transparent'>\n";
 132  
 133  echo $banner['html'];
 134  echo "\n</body>\n";
 135  
 136  echo "</html>\n";
 137  
 138  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]