Example #1
0
function com_uninstall()
{
    global $aecConfig;
    $db = JFactory::getDBO();
    $user = JFactory::getUser();
    if ($aecConfig->cfg['delete_tables'] && $aecConfig->cfg['delete_tables_sure']) {
        $app = JFactory::getApplication();
        $tables = $db->getTableList();
        $tfound = false;
        foreach ($tables as $tname) {
            if (strpos($tname, $app->getCfg('dbprefix') . 'acctexp_') === 0) {
                $db->setQuery("DROP TABLE IF EXISTS {$tname}");
                $db->query();
                $tfound = true;
            }
        }
        if ($tfound) {
            echo "Component successfully uninstalled, all tables have been deleted";
        } else {
            echo "Component successfully uninstalled. The component tables are still in the database and will be preserved for the next install or upgrade of the component.";
        }
    } else {
        $user = JFactory::getUser();
        $short = "AEC uninstall";
        $event = "AEC has been removed";
        $tags = "uninstall,system";
        $eventlog = new eventLog();
        $params = array("userid" => $user->id);
        $eventlog->issue($short, $tags, $event, 2, $params);
        echo "Component successfully uninstalled. The component tables are still in the database and will be preserved for the next install or upgrade of the component.";
    }
    return true;
}
Example #2
0
/**
 * @param string $short
 * @param string $tags
 */
function aecQuickLog($short, $tags, $text, $level = 128)
{
    $eventlog = new eventLog();
    if (empty($text)) {
        $eventlog->issue($short, $tags, "[[EMPTY]]", $level);
    } elseif (is_array($text) || is_object($text)) {
        // Due to some weird error, json_encode sometimes throws a notice - even on a proper array or object
        $eventlog->issue($short, $tags, @json_encode($text), $level);
    } elseif (is_string($text) || is_bool($text) || is_float($text)) {
        $eventlog->issue($short, $tags, $text, $level);
    } elseif (is_numeric($text)) {
        $eventlog->issue($short, $tags, $text, $level);
    } else {
        $eventlog->issue($short, $tags, "[[UNSUPPORTED TYPE]]", $level);
    }
}
Example #3
0
 /**
  * @param Invoice $objInvoice
  */
 public function entryFromInvoice($objInvoice, $response, $pp)
 {
     $user = new cmsUser();
     $user->load($objInvoice->userid);
     $plan = new SubscriptionPlan();
     $plan->load($objInvoice->usage);
     if ($pp->id) {
         $this->proc_id = $pp->id;
         $this->proc_name = $pp->processor_name;
     }
     $this->user_id = $user->id;
     $this->user_name = $user->username;
     if ($plan->id) {
         $this->plan_id = $plan->id;
         $this->plan_name = $plan->name;
     }
     $this->transaction_date = date('Y-m-d H:i:s', (int) gmdate('U'));
     $this->amount = $objInvoice->amount;
     $this->invoice_number = $objInvoice->invoice_number;
     $this->response = $response;
     $this->cleanup();
     $short = 'history entry';
     $event = 'Processor (' . $pp->processor_name . ') notification for ' . $objInvoice->invoice_number;
     $tags = 'history,processor,payment';
     $params = array('invoice_number' => $objInvoice->invoice_number);
     $eventlog = new eventLog();
     $eventlog->issue($short, $tags, $event, 2, $params);
     $this->check();
     $this->store();
 }
Example #4
0
 public function logErrors($errors, $eucaInstall, $eucaInstalldb)
 {
     $errors = array_merge($errors, $eucaInstall->getErrors(), $eucaInstalldb->getErrors());
     $tags = array();
     if (empty($errors)) {
         return;
     }
     foreach ($errors as $error) {
         $eventlog = new eventLog();
         $eventlog->issue('', $tags, $error);
     }
 }
Example #5
0
 public function invoiceCreationAction($objInvoice)
 {
     if ($this->settings['email_info']) {
         $metaUser = new metaUser($objInvoice->userid);
         $request = new stdClass();
         $request->metaUser =& $metaUser;
         $request->invoice =& $objInvoice;
         $request->plan =& $objInvoice->getObjUsage();
         $message = AECToolbox::rewriteEngineRQ($this->settings['text'], $request);
         $subject = AECToolbox::rewriteEngineRQ($this->settings['subject'], $request);
         if (!empty($message)) {
             $recipients = AECToolbox::rewriteEngineRQ($this->settings['recipient'], $request);
             $recips = explode(',', $recipients);
             $recipients2 = array();
             foreach ($recips as $k => $email) {
                 $recipients2[$k] = trim($email);
             }
             $recipients = $recipients2;
             $bccipients = AECToolbox::rewriteEngineRQ($this->settings['bcc'], $request);
             $bccips = explode(',', $bccipients);
             $bccipients2 = array();
             foreach ($bccips as $k => $email) {
                 $bccipients2[$k] = trim($email);
             }
             $bccipients = $bccipients2;
             if (!empty($bccipients2)) {
                 $bcc = $bccipients;
             } else {
                 $bcc = null;
             }
             xJ::sendMail($this->settings['sender'], $this->settings['sender_name'], $recipients, $subject, $message, $this->settings['text_html'], null, $bcc);
         }
     }
     if ($this->settings['waitingplan']) {
         $db = JFactory::getDBO();
         $metaUser = new metaUser($objInvoice->userid);
         if (!$metaUser->hasSubscription || in_array($metaUser->objSubscription->status, array('Expired', 'Closed'))) {
             if (!$metaUser->hasSubscription) {
                 $payment_plan = new SubscriptionPlan();
                 $payment_plan->load($this->settings['waitingplan']);
                 $metaUser->establishFocus($payment_plan, 'offline_payment3', false);
             }
             $metaUser->objSubscription->applyUsage($this->settings['waitingplan'], 'none', 0);
             $short = 'waiting plan';
             $event = 'Offline Payment waiting plan assigned for ' . $objInvoice->invoice_number;
             $tags = 'processor,waitingplan';
             $params = array('invoice_number' => $objInvoice->invoice_number);
             $eventlog = new eventLog();
             $eventlog->issue($short, $tags, $event, 2, $params);
         }
     }
 }
Example #6
0
 public function Action()
 {
     if (empty($_POST['query'])) {
         return null;
     }
     $db = JFactory::getDBO();
     $query = trim(aecGetParam('query', 0));
     if (strpos($query, 'supercommand:') !== false) {
         $supercommand = new aecSuperCommand();
         if ($supercommand->parseString($query)) {
             if (strpos($query, '!') === 0) {
                 $armed = true;
             } else {
                 $armed = false;
             }
             $return = $supercommand->query($armed);
             if ($return > 1) {
                 $multiple = true;
             } else {
                 $multiple = false;
             }
             if ($return != false && !$armed) {
                 $r = '<p>This supercommand would affect ' . $return . " user" . ($multiple ? "s" : "") . ". Add a ! in front of supercommand to carry out the command.</p>";
             } elseif ($return != false) {
                 $r = '<p>If you\'re so clever, you tell us what <strong>colour</strong> it should be!? (Everything went fine. Really! It affected ' . $return . " user" . ($multiple ? "s" : "") . ")</p>";
             } else {
                 $r = '<p>Something went wrong. No users found.</p>';
             }
             return $r;
         }
         return "I think you ought to know I'm feeling very depressed. (Something was wrong with your query.)";
     }
     if (strpos($query, 'jsonserialencode') === 0) {
         $s = trim(substr($query, 16));
         if (!empty($s)) {
             $return = base64_encode(serialize(jsoonHandler::decode($s)));
             return '<p>' . $return . '</p>';
         }
     }
     if (strpos($query, 'serialdecodejson') === 0) {
         $s = trim(substr($query, 16));
         if (!empty($s)) {
             $return = jsoonHandler::encode(unserialize(base64_decode($s)));
             return '<p>' . $return . '</p>';
         }
     }
     if (strpos($query, 'serialdecode') === 0) {
         $s = trim(substr($query, 12));
         if (!empty($s)) {
             $return = unserialize(base64_decode($s));
             return '<p>' . obsafe_print_r($return, true, true) . '</p>';
         }
     }
     if (strpos($query, 'unserialize') === 0) {
         $s = trim(substr($query, 11));
         if (!empty($s)) {
             $return = unserialize($s);
             return '<p>' . obsafe_print_r($return, true, true) . '</p>';
         }
     }
     $maybe = array('?', '??', '???', '????', 'what to do', 'need strategy', 'help', 'help me', 'huh?', 'AAAAH!');
     if (in_array($query, $maybe)) {
         include_once JPATH_SITE . '/components/com_acctexp/lib/eucalib/eucalib.add.php';
         $ed = rand(1, 4);
         $edf = ${'edition_0' . $ed};
         $maxed = count(${'edition_0' . $ed});
         return $edf['quote_' . str_pad(rand(1, $maxed + 1), 2, '0')];
     }
     if (strpos($query, 'logthis:') === 0) {
         $eventlog = new eventLog();
         $eventlog->issue('debug', 'debug', 'debug entry: ' . str_replace('logthis:', '', $query), 128);
         return 'alright, logged.';
     }
 }
Example #7
0
 public function save($coupon_code)
 {
     $new = 0;
     $type = $_POST['type'];
     $_POST['coupon_code'] = aecGetParam('coupon_code', 0, true, array('word', 'string', 'clear_nonalnum'));
     if ($_POST['coupon_code'] == '') {
         $this->setMessage(JText::_('AEC_MSG_NO_COUPON_CODE'));
         return;
     }
     $cph = new couponHandler();
     if (!empty($_POST['id'])) {
         $cph->coupon = new Coupon($_POST['oldtype']);
         $cph->coupon->load($_POST['id']);
         if ($cph->coupon->id) {
             $cph->status = true;
         }
     } else {
         $cph->load($_POST['coupon_code']);
     }
     if (!$cph->status) {
         $cph->coupon = new Coupon($type);
         $cph->coupon->createNew($_POST['coupon_code']);
         $cph->status = true;
         $new = 1;
     }
     if ($cph->status) {
         if (!$new) {
             if ($cph->coupon->type != $_POST['type']) {
                 $cph->switchType();
             }
         }
         unset($_POST['type']);
         unset($_POST['oldtype']);
         unset($_POST['id']);
         $post = AECToolbox::cleanPOST($_POST, false);
         $cph->coupon->savePOSTsettings($post);
         $cph->coupon->storeload();
     } else {
         $short = 'coupon store failure';
         $event = 'When trying to store coupon';
         $tags = 'coupon,loading,error';
         $params = array();
         $eventlog = new eventLog();
         $eventlog->issue($short, $tags, $event, 128, $params);
     }
     $this->setMessage(JText::_('AEC_MSG_SUCESSFULLY_SAVED'));
 }
 public function relayAction(&$metaUser, $exchange = null, $invoice = null, $objplan = null, $stage = 'action', &$add, &$params)
 {
     if ($stage == 'action') {
         if (isset($this->settings['_aec_action'])) {
             if (!$this->settings['_aec_action']) {
                 return null;
             }
         }
         if (isset($this->settings['_aec_only_first_bill']) && !empty($invoice)) {
             if ($this->settings['_aec_only_first_bill'] && $invoice->counter > 1) {
                 return null;
             }
         }
     }
     if (!$this->checkPermission($metaUser, $invoice)) {
         return null;
     }
     // Exchange Settings
     if (is_array($exchange) && !empty($exchange)) {
         $this->exchangeSettings($exchange);
     }
     $request = new stdClass();
     $request->action = $stage;
     $request->parent =& $this;
     $request->metaUser =& $metaUser;
     $request->invoice =& $invoice;
     $request->plan =& $objplan;
     if (empty($params)) {
         $miparams = $metaUser->meta->getMIParams($this->id, $objplan->id);
         $params =& $miparams;
     }
     $request->params =& $params;
     if ($add !== false) {
         $request->add =& $add;
     } else {
         $request->add = null;
     }
     // Call Action
     if (method_exists($this->mi_class, $stage)) {
         $return = $this->mi_class->{$stage}($request);
     } elseif (method_exists($this->mi_class, 'relayAction')) {
         switch ($stage) {
             case 'action':
                 $request->area = '';
                 break;
             case 'pre_expiration_action':
                 $request->area = '_pre_exp';
                 break;
             case 'expiration_action':
                 $request->area = '_exp';
                 break;
             default:
                 $request->area = $stage;
                 break;
         }
         $return = $this->mi_class->relayAction($request);
     } else {
         return null;
     }
     // Gather Errors and Warnings
     $errors = $this->getErrors();
     $warnings = $this->getWarnings();
     if ($errors !== false || $warnings !== false) {
         $level = 2;
         $error = 'The MI "' . $this->name . '" (' . $this->class_name . ') encountered problems.';
         if ($warnings !== false) {
             $error .= ' ' . $warnings;
             $level = 32;
         }
         if ($errors !== false) {
             $error .= ' ' . $errors;
             $level = 128;
         }
         if (!empty($request->invoice->invoice_number)) {
             $pparams = array('invoice_number' => $request->invoice->invoice_number);
         } else {
             $pparams = array();
         }
         $eventlog = new eventLog();
         $eventlog->issue('MI application problems', 'mi, problems, ' . $this->class_name, $error, $level, $pparams);
     }
     // If returning fatal error, issue additional entry
     if ($return === false) {
         $error = 'The MI "' . $this->name . '" (' . $this->class_name . ') could not be carried out due to errors, plan application was halted';
         $err = $this->_db->getErrorMsg();
         if (!empty($err)) {
             $error .= ' Last Database Error: ' . $err;
         }
         if (!empty($request->invoice->invoice_number)) {
             $pparams = array('invoice_number' => $request->invoice->invoice_number);
         } else {
             $pparams = array();
         }
         $eventlog = new eventLog();
         $eventlog->issue('MI application failed', 'mi, failure, ' . $this->class_name, $error, 128, $pparams);
     }
     return $return;
 }
Example #9
0
 public function pay($multiplicator = 1, $noclear = false)
 {
     $metaUser = false;
     $new_plan = false;
     $plans = array();
     if (!empty($this->userid)) {
         $metaUser = new metaUser($this->userid);
     }
     if (!empty($this->params['target_user'])) {
         $targetUser = new metaUser($this->params['target_user']);
     } else {
         $targetUser =& $metaUser;
     }
     if (!empty($this->params['aec_pickup'])) {
         if (is_array($this->params['aec_pickup'])) {
             foreach ($this->params['aec_pickup'] as $key) {
                 if (isset($this->params[$key])) {
                     unset($this->params[$key]);
                 }
             }
         }
         unset($this->params['aec_pickup']);
     }
     $override_permissioncheck = $this->isRecurring() && $this->counter > 1;
     if (!empty($this->usage)) {
         $usage = explode('.', $this->usage);
         // Update old notation
         if (!isset($usage[1])) {
             $temp = $usage[0];
             $usage[0] = 'p';
             $usage[1] = $temp;
         }
         switch (strtolower($usage[0])) {
             case 'c':
             case 'cart':
                 if (empty($this->params['cart']->content)) {
                     $this->params['cart'] = new aecCart();
                     $this->params['cart']->load($usage[1]);
                     if (!empty($this->params['cart']->content)) {
                         foreach ($this->params['cart']->content as $c) {
                             $new_plan = new SubscriptionPlan();
                             $new_plan->load($c['id']);
                             for ($i = 0; $i < $c['quantity']; $i++) {
                                 $plans[] = $new_plan;
                             }
                         }
                     }
                     $this->params['cart']->clear();
                     $this->storeload();
                     // Load and delete original entry
                     $cart = new aecCart();
                     $cart->load($usage[1]);
                     if ($cart->id) {
                         $cart->delete();
                     }
                 } else {
                     foreach ($this->params['cart']->content as $c) {
                         $new_plan = new SubscriptionPlan();
                         $new_plan->load($c['id']);
                         if (!$override_permissioncheck) {
                             if ($new_plan->checkPermission($metaUser) === false) {
                                 return false;
                             }
                         }
                         for ($i = 0; $i < $c['quantity']; $i++) {
                             $plans[] = $new_plan;
                         }
                     }
                 }
                 break;
             case 'p':
             case 'plan':
             default:
                 $new_plan = new SubscriptionPlan();
                 $new_plan->load($this->usage);
                 if (!$override_permissioncheck) {
                     if ($new_plan->checkPermission($metaUser) === false) {
                         return false;
                     }
                 }
                 $plans[] = $new_plan;
                 break;
         }
     }
     if (is_object($metaUser)) {
         if (!empty($this->params['userMIParams'])) {
             foreach ($this->params['userMIParams'] as $plan => $mis) {
                 foreach ($mis as $mi_id => $content) {
                     $metaUser->meta->setMIParams($mi_id, $plan, $content);
                     if ($metaUser->userid !== $targetUser->userid) {
                         $targetUser->meta->setMIParams($mi_id, $plan, $content);
                     }
                 }
             }
             $metaUser->meta->storeload();
             if ($metaUser->userid !== $targetUser->userid) {
                 $targetUser->meta->storeload();
             }
         }
     }
     foreach ($plans as $plan) {
         if (is_object($targetUser) && is_object($plan)) {
             if ($targetUser->userid) {
                 if (!empty($this->subscr_id)) {
                     $targetUser->establishFocus($plan, $this->method, false, $this->subscr_id);
                 } else {
                     $targetUser->establishFocus($plan, $this->method);
                 }
                 $this->subscr_id = $targetUser->focusSubscription->id;
                 // Apply the Plan
                 $application = $targetUser->focusSubscription->applyUsage($plan->id, $this->method, 0, $multiplicator, $this);
             } else {
                 $application = $plan->applyPlan(0, $this->method, 0, $multiplicator, $this);
             }
         }
     }
     $micro_integrations = false;
     if (!empty($this->conditions)) {
         if (strpos($this->conditions, 'mi_attendevents')) {
             $start_position = strpos($this->conditions, '<registration_id>') + strlen('<registration_id>');
             $end_position = strpos($this->conditions, '</registration_id>');
             $micro_integration['name'] = 'mi_attendevents';
             $micro_integration['parameters'] = array('registration_id' => substr($this->conditions, $start_position, $end_position - $start_position));
             $micro_integrations = array();
             $micro_integrations[] = $micro_integration;
         }
     }
     // Reload the meta- & targetUser since they have been updated
     if (!empty($this->userid)) {
         $metaUser = new metaUser($this->userid);
     }
     if (!empty($this->params['target_user'])) {
         $targetUser = new metaUser($this->params['target_user']);
     } else {
         $targetUser =& $metaUser;
     }
     if (!empty($micro_integrations)) {
         if (is_array($micro_integrations)) {
             foreach ($micro_integrations as $micro_int) {
                 $mi = new microIntegration();
                 if (isset($micro_integration['parameters'])) {
                     $exchange = $micro_integration['parameters'];
                 } else {
                     $exchange = null;
                 }
                 if (isset($micro_int['name'])) {
                     if ($mi->callDry($micro_int['name'])) {
                         if (is_object($targetUser)) {
                             $mi->action($targetUser, $exchange, $this, $new_plan);
                         } else {
                             $mi->action($targetUser, $exchange, $this, $new_plan);
                         }
                     }
                 } elseif (isset($micro_int['id'])) {
                     if ($mi->mi_exists($micro_int['id'])) {
                         $mi->load($micro_int['id']);
                         if ($mi->callIntegration()) {
                             if (is_object($metaUser)) {
                                 $mi->action($targetUser, $exchange, $this, $new_plan);
                             } else {
                                 $mi->action($targetUser, $exchange, $this, $new_plan);
                             }
                         }
                     }
                 }
                 unset($mi);
             }
         }
     }
     if ($this->coupons) {
         foreach ($this->coupons as $coupon_code) {
             $cph = new couponHandler();
             $cph->load($coupon_code);
             $cph->triggerMIs($targetUser, $this, $plans[0]);
         }
     }
     // We need to at least warn the admin if there is an invoice with nothing to do
     if (empty($this->usage) && empty($this->conditions) && empty($this->coupons)) {
         $short = 'Nothing to do';
         $event = JText::_('AEC_MSG_PROC_INVOICE_ACTION_EV_VALID_APPFAIL');
         $tags = 'invoice,application,payment,action_failed';
         $params = array('invoice_number' => $this->invoice_number);
         $eventlog = new eventLog();
         $eventlog->issue($short, $tags, $event, 32, $params);
     }
     if (!$noclear) {
         $this->setTransactionDate();
     }
     return true;
 }
Example #10
0
 static function getObjectProperty($object, $key, $test = false)
 {
     if (!is_array($key)) {
         if (strpos($key, '.') !== false) {
             $key = explode('.', $key);
         }
     }
     if (!is_array($key)) {
         if (isset($object->{$key})) {
             if ($test) {
                 return true;
             } else {
                 return $object->{$key};
             }
         } elseif ($test) {
             return false;
         } else {
             return null;
         }
     } else {
         $return = $object;
         $err = 'AECjson cmd:data Syntax Error';
         $erp = 'aecjson,data,syntax,error';
         $erx = 'Syntax Parser cannot parse next property: ';
         if (empty($key)) {
             $erx .= 'No Key Found';
             $eventlog = new eventLog();
             $eventlog->issue($err, $erp, $erx, 128, array());
             return false;
         }
         foreach ($key as $k) {
             // and use {}/variable variables instead
             $subject =& $return;
             if (is_object($subject)) {
                 if (property_exists($subject, $k)) {
                     if ($test) {
                         return true;
                     } else {
                         $return =& $subject->{$k};
                     }
                 } elseif ($test) {
                     return false;
                 } else {
                     $props = array_keys(get_object_vars($subject));
                     $event = $erx . $k . ' does not exist! Possible object values are: ' . implode(';', $props);
                     $eventlog = new eventLog();
                     $eventlog->issue($err, $erp, $event, 128, array());
                 }
             } elseif (is_array($subject)) {
                 if (isset($subject[$k])) {
                     if ($test) {
                         return true;
                     } else {
                         $return =& $subject[$k];
                     }
                 } elseif ($test) {
                     return false;
                 } else {
                     $props = array_keys($subject);
                     $event = $erx . $k . ' does not exist! Possible array values are: ' . implode(';', $props);
                     $eventlog = new eventLog();
                     $eventlog->issue($err, $erp, $event, 128, array());
                 }
             } elseif ($test) {
                 return false;
             } else {
                 $event = $erx . $k . '; neither property nor array field';
                 $eventlog = new eventLog();
                 $eventlog->issue($err, $erp, $event, 128, array());
                 return false;
             }
         }
         return $return;
     }
 }
Example #11
0
 public function fileEventlog()
 {
     // Make sure we have all the language stuff loaded
     $langlist = array('com_acctexp.admin' => JPATH_ADMINISTRATOR);
     xJLanguageHandler::loadList($langlist);
     $short = JText::_('AEC_LOG_SH_HEARTBEAT');
     $event = array(JText::_('AEC_LOG_LO_HEARTBEAT') . ' ');
     $tags = array('heartbeat');
     $level = 2;
     if ($this->result['expired']) {
         if ($this->result['expired'] > 1) {
             $event[] = 'Expires ' . $this->result['expired'] . ' subscriptions';
         } else {
             $event[] = 'Expires 1 subscription';
         }
         $tags[] = 'expiration';
     }
     if ($this->result['fallback']) {
         if ($this->result['fallback'] > 1) {
             $event[] = $this->result['fallback'] . ' subscriptions assigned to a fallback subscription plan';
         } else {
             $event[] = '1 subscription assigned to a fallback subscription plan';
         }
         $tags[] = 'fallback';
     }
     if ($this->result['fail_expired']) {
         if ($this->result['fail_expired'] > 1) {
             $event[] = 'Failed to expire ' . $this->result['fail_expired'] . ' subscriptions';
         } else {
             $event[] = 'Failed to expire 1 subscription';
         }
         $event[] = '- please check your subscriptions for problems';
         $tags[] = 'error';
         $level = 128;
     }
     if ($this->result['pre_exp_actions']) {
         $event[] = $this->result['pre_exp_actions'] . ' Pre-expiration action';
         $event[] = $this->result['pre_exp_actions'] > 1 ? 's' : '';
         $event[] = ' for ' . $this->result['pre_expired'] . ' subscription';
         $event[] = $this->result['pre_expired'] > 1 ? 's' : '';
         $tags[] = 'pre-expiration';
     }
     if ($this->result['skipped']) {
         if ($this->result['fail_expired'] > 1) {
             $event[] = 'Skipped ' . $this->result['fail_expired'] . ' subscriptions';
         } else {
             $event[] = 'Skipped 1 subscription';
         }
     }
     if (count($event) === 0) {
         $event[] = JText::_('AEC_LOG_AD_HEARTBEAT_DO_NOTHING');
     }
     $eventlog = new eventLog();
     $eventlog->issue($short, implode(',', $tags), implode(" ", $event), $level);
 }
Example #12
0
function processNotification($option, $processor)
{
    global $aecConfig;
    // Legacy naming support
    switch ($processor) {
        case 'vklix':
            $processor = 'viaklix';
            break;
        case 'auth':
            $processor = 'authorize';
            break;
        case '2co':
            $processor = '2checkout';
            break;
        case 'eps':
            $processor = 'epsnetpay';
            break;
    }
    if (!empty($aecConfig->cfg['debug_processor_notifications'])) {
        aecDebug("ResponseFunction:processNotification");
        aecDebug($_GET);
        aecDebug($_POST);
        aecDebug($_REQUEST);
        aecDebug(file_get_contents("php://input"));
    }
    $response = array();
    $response['fullresponse'] = aecPostParamClear($_POST);
    // parse processor notification
    $pp = new PaymentProcessor();
    if ($pp->loadName($processor)) {
        $pp->init();
        $response = array_merge($response, $pp->parseNotification($response['fullresponse']));
    } else {
        $eventlog = new eventLog();
        $eventlog->issue('processor loading failure', 'processor,loading,error', 'When receiving payment notification, tried to load processor: ' . $processor, 128);
        return;
    }
    // Get Invoice record
    if (!empty($response['invoice'])) {
        $id = aecInvoiceHelper::InvoiceIDfromNumber($response['invoice']);
    } else {
        $id = false;
        $response['invoice'] = 'empty';
    }
    if (!$id) {
        $short = JText::_('AEC_MSG_PROC_INVOICE_FAILED_SH');
        $event = '';
        $tags = '';
        if (isset($response['null'])) {
            if (isset($response['explanation'])) {
                $short = JText::_('AEC_MSG_PROC_INVOICE_ACTION_SH');
                $event .= $response['explanation'];
            } else {
                $event .= JText::_('AEC_MSG_PROC_INVOICE_ACTION_EV_NULL');
            }
            $tags .= 'invoice,processor,payment,null';
        } else {
            $event = sprintf(JText::_('AEC_MSG_PROC_INVOICE_FAILED_EV'), $processor, $response['invoice']);
            $tags = 'invoice,processor,payment,error';
        }
        $params = array();
        $eventlog = new eventLog();
        if (isset($response['null'])) {
            if (isset($response['error'])) {
                $eventlog->issue($short, $tags, $response['error'], 128, $params);
            } else {
                $eventlog->issue($short, $tags, $event, 8, $params);
            }
        } else {
            $eventlog->issue($short, $tags, $event, 128, $params);
            $error = 'Invoice Number not found. Invoice number provided: "' . $response['invoice'] . '"';
            $pp->notificationError($response, $error);
        }
        return;
    } else {
        $iFactory = new InvoiceFactory(null, null, null, null, $response['invoice']);
        $iFactory->processorResponse($response);
    }
}
 public function doTheCurl($url, $content, $curlextra = null, $header = null)
 {
     global $aecConfig;
     if (!function_exists('curl_init')) {
         $short = 'cURL failure';
         $event = 'Trying to establish connection with ' . $url . ' failed - curl_init is not available - will try fsockopen instead. If Error persists and fsockopen works, please permanently switch to using that!';
         $tags = 'processor,payment,phperror';
         $params = array();
         $eventlog = new eventLog();
         $eventlog->issue($short, $tags, $event, 128, $params);
         return false;
     }
     if (empty($curlextra)) {
         $curlextra = array();
     }
     // Preparing cURL variables as array, to possibly overwrite them with custom settings by the processor
     $curl_calls = array();
     $curl_calls[CURLOPT_URL] = $url;
     $curl_calls[CURLOPT_RETURNTRANSFER] = true;
     if (empty($header)) {
         $curl_calls[CURLOPT_HTTPHEADER] = array('Content-Type: text/xml');
     } else {
         $curl_calls[CURLOPT_HTTPHEADER] = $header;
     }
     $curl_calls[CURLOPT_HEADER] = false;
     if (!empty($content)) {
         $curl_calls[CURLOPT_POST] = true;
         $curl_calls[CURLOPT_POSTFIELDS] = $content;
     }
     if (!empty($aecConfig->cfg['ssl_verifypeer'])) {
         $curl_calls[CURLOPT_SSL_VERIFYPEER] = $aecConfig->cfg['ssl_verifypeer'];
     } else {
         $curl_calls[CURLOPT_SSL_VERIFYPEER] = false;
     }
     if (!empty($aecConfig->cfg['ssl_verifyhost'])) {
         $curl_calls[CURLOPT_SSL_VERIFYHOST] = $aecConfig->cfg['ssl_verifyhost'];
     } else {
         $curl_calls[CURLOPT_SSL_VERIFYHOST] = false;
     }
     if (!empty($aecConfig->cfg['use_proxy']) && !empty($aecConfig->cfg['proxy'])) {
         $curl_calls[CURLOPT_HTTPPROXYTUNNEL] = true;
         $curl_calls[CURLOPT_PROXY] = $aecConfig->cfg['proxy'];
         if (!empty($aecConfig->cfg['proxy_port'])) {
             $curl_calls[CURLOPT_PROXYPORT] = $aecConfig->cfg['proxy_port'];
         }
         if (!empty($aecConfig->cfg['proxy_username']) && !empty($aecConfig->cfg['proxy_password'])) {
             $curl_calls[CURLOPT_PROXYUSERPWD] = $aecConfig->cfg['proxy_username'] . ":" . $aecConfig->cfg['proxy_password'];
         }
     }
     // Set or replace cURL params
     if (!empty($curlextra)) {
         foreach ($curlextra as $name => $value) {
             if ($value == '[[unset]]') {
                 if (isset($curl_calls[$name])) {
                     unset($curl_calls[$name]);
                 }
             } else {
                 $curl_calls[$name] = $value;
             }
         }
     }
     // Set cURL params
     $ch = curl_init();
     foreach ($curl_calls as $name => $value) {
         curl_setopt($ch, $name, $value);
     }
     $response = curl_exec($ch);
     if ($response === false) {
         $short = 'cURL failure';
         $event = 'Trying to establish connection with ' . $url . ' failed with Error #' . curl_errno($ch) . ' ( "' . curl_error($ch) . '" ) - will try fsockopen instead. If Error persists and fsockopen works, please permanently switch to using that!';
         $tags = 'processor,payment,phperror';
         $params = array();
         $eventlog = new eventLog();
         $eventlog->issue($short, $tags, $event, 128, $params);
     }
     curl_close($ch);
     return $response;
 }