Example #1
0
 function view()
 {
     $returnpage = JRequest::getVar("returnpage", "");
     $Itemid = JRequest::getVar("Itemid", "0");
     if ($returnpage != "" && $returnpage == "enroll") {
         $user = JFactory::getUser();
         if ($user->id != "0") {
             $app = JFactory::getAPPlication("site");
             $course_id = JRequest::getVar("course_id", "0");
             $link = "index.php?option=com_guru&view=guruPrograms&task=enroll&cid=" . intval($course_id) . "&Itemid=" . intval($Itemid);
             $app->redirect($link);
         }
     }
     JRequest::setVar('view', 'guruLogin');
     parent::display();
 }
Example #2
0
 function FEPluginHandler($pay_type, $item, $tax, $redir = 0, $profile)
 {
     $db = JFactory::getDBO();
     if (!isset($this->default_payment)) {
         $this->default_payment = NULL;
     }
     $result = array();
     $total = $tax['taxed'];
     $conf = $this->getInstance("adagencyconfig", "adagencyModel");
     $configs = $conf->getConfigs();
     $orderpack = JRequest::getInt('tid');
     $getPaymentType = JRequest::getVar('payment_type');
     if (count($this->payment_plugins) < 1) {
         return -1;
     }
     $plugin_exists = 0;
     if (!isset($this->payment_plugins[$pay_type])) {
         //if selected payment method is not available
         if (is_object($this->default_payment)) {
             //try selected, or default payment gateway
             foreach ($this->payment_plugins as $plug) {
                 //find selected plugin
                 if ($plug->filename == $getPaymentType . '.php') {
                     $plugin = $plug;
                     break;
                 }
             }
             if (!isset($plugin)) {
                 $plugin = $this->default_payment;
             }
             //try default payment gateway
         } elseif (!is_object($this->default_payment)) {
             //no default available
             if (!isset($plugin)) {
                 foreach ($this->payment_plugins as $plug) {
                     //select first gateway available
                     $plugin = $plug;
                     break;
                 }
             }
         } else {
             die(JText::_("DSPAYMENTCANTBEPROC"));
         }
     } else {
         //all os ok - use normal gateway
         $plugin = $this->payment_plugins[$pay_type];
     }
     $this->_id = $plugin->id;
     $plugin = $this->getPlugin();
     if ($plugin->reqhttps != 0 && (getenv('HTTPS') != 'on' && getenv('HTTPS') != '1')) {
         //plugin requires https connection to perform checkout
         return "https";
     }
     $my = JFactory::getUser();
     $order_date = date('Y-m-d');
     $db->setQuery("SELECT aid FROM #__ad_agency_advertis WHERE user_id = " . intval($my->id));
     $aid = $db->loadColumn();
     $aid = $aid["0"];
     $db->setQuery("SELECT * FROM #__ad_agency_order_type WHERE tid = " . intval($orderpack));
     $typerow = $db->loadObjectList();
     $type_row = @$typerow[0];
     $notes = trim(addslashes(@$type_row->description));
     $quantity = @$type_row->quantity;
     $type = @$type_row->type;
     $cost = @$type_row->cost;
     $tid = @$type_row->tid;
     $payment_type = JRequest::getVar('payment_type');
     if (isset($_SESSION['LCC']) && isset($_SESSION['LCC2'])) {
         $confirm_data = $_SESSION['LCC'] . ";" . $_SESSION['LCC2'];
         $_SESSION['LCC'] = NULL;
         $_SESSION['LCC2'] = NULL;
         unset($_SESSION['LCC']);
         unset($_SESSION['LCC2']);
     } else {
         $confirm_data = NULL;
     }
     $sql = "SELECT currencydef FROM #__ad_agency_settings LIMIT 1";
     $db->setQuery($sql);
     $currencydef = $db->loadColumn();
     $currencydef = trim($currencydef["0"], " ");
     $renew = JRequest::getVar("remove_action", "");
     $orderid = 0;
     if ($renew == "") {
         $promocode = @$_SESSION["promocode"];
         $new_cost = @$_SESSION["new_cost"];
         $sql = "update #__ad_agency_promocodes set `used`=(`used`+1) where `id`=" . intval($promocode);
         $db->setQuery($sql);
         $db->query();
         $order_cost = $cost;
         if (isset($new_cost) && trim($new_cost) != "") {
             $order_cost = $new_cost;
         }
         $orderid_from_request = JRequest::getVar("orderid", "0");
         if (intval($orderid_from_request) == 0) {
             $insersql = "INSERT INTO #__ad_agency_order (`oid`,`tid`,`aid`,`type`,`quantity`,`cost`,`order_date`,`payment_type`,`card_number`,`expiration`,`card_name`,`notes`,`status`,`pack_id`,`currency`, `promocodeid`) VALUES ('','" . intval($tid) . "','" . intval($aid) . "','" . trim($type) . "','" . intval($quantity) . "','" . trim($order_cost) . "','" . trim($order_date) . "','" . addslashes(trim($payment_type)) . "','" . trim($confirm_data) . "','','','" . addslashes(trim($notes)) . "','not_paid','0','" . trim($currencydef) . "', '" . intval($promocode) . "');";
             $db->setQuery($insersql);
             $db->query();
             $sql = "select max(oid) from #__ad_agency_order";
             $db->setQuery($sql);
             $db->query();
             $orderid = $db->loadColumn();
             $orderid = $orderid["0"];
         } else {
             $orderid = intval($orderid_from_request);
         }
     } elseif ($renew == "renew") {
         $orderid = intval(JRequest::getVar("orderid", "0"));
         // not redirect to pypal if package is free
         if ($cost == 0 || $cost == "0.0" || $cost == "0.00" || $cost == "0.000" || $cost == "0.0000") {
             $package_id = JRequest::getVar("otid", "0");
             $sql = "select * from #__ad_agency_order_type where `tid`=" . intval($package_id);
             $db->setQuery($sql);
             $db->query();
             $package_content = $db->loadAssocList();
             if (isset($package_content) && count($package_content) > 0) {
                 $campaign_id = JRequest::getVar("campaign_id", "0");
                 $cost = $package_content["0"]["cost"];
                 $quantity = $package_content["0"]["quantity"];
                 //$date_today = date("Y-m-d H:i:s");
                 $jnow = JFactory::getDate();
                 $date_today = $jnow->toSql();
                 $date_today_int = strtotime($date_today);
                 $validity = '0000-00-00 00:00:00';
                 if (trim($package_content["0"]["validity"]) != "") {
                     $pack_validity_str = trim($package_content["0"]["validity"]);
                     $pack_validity_array = explode("|", $pack_validity_str);
                     $validity_date = strtotime("+" . $pack_validity_array["0"] . " " . $pack_validity_array["1"], $date_today_int);
                     $validity = date("Y-m-d H:i:s", $validity_date);
                 }
                 $sql = "update #__ad_agency_campaign set `start_date` = '" . trim($date_today) . "', `quantity`='" . intval($quantity) . "', `validity`='" . trim($validity) . "', `cost`='" . trim($cost) . "' where id=" . intval($campaign_id);
                 $db->setQuery($sql);
                 $db->query();
                 $Itemid = JRequest::getInt('Itemid', '0');
                 $link = "index.php?option=com_adagency&controller=adagencyCampaigns" . $Itemid;
                 $app = JFactory::getAPPlication("site");
                 $app->redirect(JRoute::_($link), JText::_("ADAG_RENEWED_SUCCESSFUL"));
             }
         }
     }
     if (!isset($orderid) || $orderid == 0) {
         $sql = "SELECT oid FROM #__ad_agency_order ORDER BY oid DESC LIMIT 1";
         $db->setQuery($sql);
         $orderid = $db->loadColumn();
         $orderid = $orderid["0"];
     }
     $item = new stdClass();
     $item->oid = $orderid;
     @($item->product_name = $item->name = $type_row->description);
     //$notes;
     $item->amount = $cost;
     $item->quantity = 1;
     $item->tid = $tid;
     $items[] = $item;
     $tax = array();
     $tax['currency'] = $configs->currencydef;
     $tax['value'] = $cost;
     $tax['shipping'] = 0;
     $tax['taxed'] = $cost;
     $profile = null;
     $sql = "SELECT * FROM #__ad_agency_advertis WHERE user_id = " . intval($my->id);
     $db->setQuery($sql);
     $profile = $db->loadObject();
     if (is_null($profile)) {
         $profile = new stdClass();
     }
     $profile->_sid = $orderid;
     $profile->_user_id = $my->id;
     $profile->_user = $my;
     $redirect = 1;
     $result = "";
     $autorenew = JRequest::getVar("aurorenew", "0");
     if ($autorenew == 1) {
         if ($type_row->type == "fr") {
             // Flat Rate - based on time, days or months.
             $result = $plugin->instance->getFEDataRenew($items, $tax, $redirect, $profile, $plugin, $configs);
         } else {
             $result = $plugin->instance->getFEData($items, $tax, $redirect, $profile, $plugin, $configs);
         }
     } else {
         if (isset($_SESSION["new_cost"]) && trim($_SESSION["new_cost"]) == 0) {
             $this->goToSuccessURL($orderid);
         } else {
             $result = $plugin->instance->getFEData($items, $tax, $redirect, $profile, $plugin, $configs);
         }
     }
     return $result;
 }