<?

/**
 *
 * INDEXU
 * Copyright(C), Nicecoder, 2000-2006, All Rights Reserved.
 *
 * INDEXU(tm) is protected by Indonesia and International copyright laws.
 * Unauthorized use or distribution of INDEXU(tm) is strictly prohibited,
 * violators will be prosecuted. To obtain a license for using INDEXU(tm),
 * please register at Nicecoder home page at http://www.nicecoder.com
 *
 * Author:
 *    Dody Rachmat Wicaksono (dody@nicecoder.com)
 *    M. Zuber (zubby@nicecoder.com)
 *
 */
  
  include "../application.php";
  include "2co.inc.php";
  
  ignore_user_abort(true);
  set_time_limit(300);

  define('2CO_RETURN', 1);
  
  $referers = array("www.2checkout.com", "www.2checkout.com", "2checkout.com");
  $valid_referer = FALSE;
  if ($_SERVER['HTTP_REFERER']) {
    while (list(, $host) = @each($referers)) {
      if (eregi($host, $_SERVER['HTTP_REFERER'])) {
        $valid_referer = TRUE;
      }
    }
  }
  else {
    $valid_referer = TRUE;
  }

  if (!$valid_referer) {
    exit;
  }

  if ($_POST['credit_card_processed'] != 'Y') {
    Redirect(urldecode($_POST['cancel_return']) . '?err=1', FALSE);
    exit;
  }

  if ($_POST['secret'] != $co_secret) {
    exit;
  }

  if (ereg('2co.check-upgrade.php', $_POST['notify_url'])) {
    include "2co.check-upgrade.php";
    Redirect(urldecode($_POST['return']), FALSE);
    exit;
  }
  elseif (ereg('2co.check-invoice.php', $_POST['notify_url'])) {
    include "2co.check-invoice.php";
    Redirect(urldecode($_POST['return']), FALSE);
    exit;
  }

?>
