diff serve.php @ 0:d8a3998dac8e ad

ajout module ad
author pierre
date Fri, 20 Feb 2009 14:04:09 +0000
parents
children 948362c2a207
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/serve.php	Fri Feb 20 14:04:09 2009 +0000
@@ -0,0 +1,43 @@
+<?php
+// $Id: serve.php,v 1.1.2.2.2.1 2009/02/16 17:06:47 jeremy Exp $
+
+/**
+ * @file
+ * Serve advertisements.
+ *
+ * Copyright (c) 2005-2009.
+ *   Jeremy Andrews <jeremy@tag1consulting.com>.
+ */
+
+// Provide adserve functions to external plugins.
+require_once('adserve.inc');
+
+if (isset($_GET['o'])) {
+  $output = preg_replace('/[^a-zA-Z0-9_-]/', '', $_GET['o']);
+  if ($output == 'image') {
+    require_once('imageserve.inc');
+    adserve_counter_image();
+    exit(0);
+  }
+  else if ($output) {
+    // TODO: Document how this hook allows external modules to use serve.php
+    $files = array(
+      "$output.inc", // search for file in main ad directory
+      "$output/$output.inc", // search for file in subdirectory
+      "../$output/$output.inc", // search for file in higher subdirectory
+    );
+    foreach ($files as $file) {
+      $function = $output .'_serve';
+      if (file_exists($file)) {
+        require_once("$file");
+        if (function_exists($function)) {
+          $function();
+          exit(0);
+        }
+      }
+    }
+  }
+}
+
+// Default action.
+adserve_ad();