/** * Determines whether the requested action is in our list of supported actions. */ function isValidAction($requested_action) { $actions = getSupportedActions(); foreach ($actions as $action => $sub_actions) { if (in_array($requested_action, $sub_actions)) { return true; } } return false; }
/** * Determines whether the requested action is in our list of supported actions. */ function isValidAction($action) { $actions = getSupportedActions(); if (array_key_exists($action[0], $actions)) { $section = $actions[$action[0]]; if (in_array($action[1], $section)) { return true; } } return false; }
define('AD_UNIT_ID', 'INSERT_AD_UNIT_ID_HERE'); // Max results per page. define('AD_MAX_PAGE_SIZE', 50); // This is the maximum number of obtainable rows for paged reports. define('AD_ROW_LIMIT', 5000); // Include the dependencies and die if any is not met. try { require_once "AdSenseAuth.php"; require_once "BaseExample.php"; require_once "htmlHelper.php"; } catch (Exception $e) { die('Missing requirement: ' . $e->getMessage() . "\n"); } try { // Build the list of supported actions. $actions = getSupportedActions(); // Go through API authentication. $auth = new AdSenseAuth(); $auth->authenticate('sample_user'); // To get rid of the code in the URL after the authentication. if (isset($_GET['code'])) { header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); } // If the action is set dispatch the action if supported if (isset($_GET["action"])) { $action = $_GET["action"]; if (!in_array($action, $actions)) { die('Unsupported action:' . $action . "\n"); } // Render the required action. require_once 'examples/' . $action . '.php';