Ejemplo n.º 1
0
 public function Settings()
 {
     $settings = array();
     $settings['activate'] = array('toggle');
     $settings['block'] = array('toggle');
     $settings['username'] = array('inputD');
     $settings['username_rand'] = array('inputC');
     $settings['password'] = array('inputD');
     $xsettings = array();
     if (defined('JPATH_MANIFESTS')) {
         $settings['set_fields'] = array('toggle');
         $db = JFactory::getDBO();
         $query = 'SELECT DISTINCT `profile_key`' . ' FROM #__user_profiles';
         $db->setQuery($query);
         $pkeys = xJ::getDBArray($db);
         if (!empty($pkeys)) {
             foreach ($pkeys as $k) {
                 $title = ucfirst(str_replace('profile.', '', $k));
                 $settings['jprofile_' . str_replace(".", "_", $k)] = array('inputE', $title, $title);
                 $expname = $title . " " . JText::_('MI_MI_JOOMLAUSER_EXPMARKER');
                 $xsettings['jprofile_' . str_replace(".", "_", $k) . '_exp'] = array('inputE', $expname, $expname);
             }
         }
     }
     $rewriteswitches = array('cms', 'user', 'expiration', 'subscription', 'plan', 'invoice');
     $settings = AECToolbox::rewriteEngineInfo($rewriteswitches, $settings);
     $settings['aectab_reg'] = array('tab', 'Expiration', 'Expiration');
     $settings['set_fields_exp'] = array('toggle');
     $settings = array_merge($settings, $xsettings);
     $settings = AECToolbox::rewriteEngineInfo($rewriteswitches, $settings);
     return $settings;
 }
Ejemplo n.º 2
0
 public function getUserPipelineEvents($userid)
 {
     $db = JFactory::getDBO();
     // Entries for this user only
     $query = 'SELECT `id`' . ' FROM #__acctexp_displaypipeline' . ' WHERE `userid` = \'' . $userid . '\' AND `only_user` = \'1\'';
     $db->setQuery($query);
     $events = xJ::getDBArray($db);
     // Entries for all users
     $query = 'SELECT `id`' . ' FROM #__acctexp_displaypipeline' . ' WHERE `only_user` = \'0\'';
     $db->setQuery($query);
     $events = array_merge($events, xJ::getDBArray($db));
     $return = '';
     if (empty($events)) {
         return $return;
     }
     foreach ($events as $eventid) {
         $displayPipeline = new displayPipeline();
         $displayPipeline->load($eventid);
         if ($displayPipeline->id) {
             // If expire & expired -> delete
             if ($displayPipeline->expire) {
                 $expstamp = strtotime($displayPipeline->expstamp);
                 if ($expstamp - (int) gmdate('U') < 0) {
                     $displayPipeline->delete();
                     continue;
                 }
             }
             // If displaymax exceeded -> delete
             $displayremain = $displayPipeline->displaymax - $displayPipeline->displaycount;
             if ($displayremain <= 0) {
                 $displayPipeline->delete();
                 continue;
             }
             // If this can only be displayed once per user, prevent it from being displayed again
             if ($displayPipeline->once_per_user) {
                 $params = $displayPipeline->params;
                 if (isset($displayPipeline->params['displayedto'])) {
                     $users = $displayPipeline->params['displayedto'];
                     if (in_array($userid, $users)) {
                         continue;
                     } else {
                         $users[] = $userid;
                         $displayPipeline->params['displayedto'] = $users;
                     }
                 }
             }
             // Ok, now append text
             $return .= stripslashes($displayPipeline->displaytext);
             // Update display if at least one display would remain
             if ($displayremain > 1) {
                 $displayPipeline->displaycount = $displayPipeline->displaycount + 1;
                 $displayPipeline->check();
                 $displayPipeline->store();
             } else {
                 $displayPipeline->delete();
             }
         }
     }
     return $return;
 }
Ejemplo n.º 3
0
 public function getListForSubject($subject)
 {
     $db = JFactory::getDBO();
     $query = 'SELECT `id`' . ' FROM #__acctexp_displaypipeline' . ' WHERE `subject` = \'' . $subject . '\'';
     $db->setQuery($query);
     $buckets = xJ::getDBArray($db);
     return $buckets;
 }
Ejemplo n.º 4
0
 public function issue($short, $tags, $text, $level = 2, $params = null, $force_notify = 0, $force_email = 0)
 {
     global $aecConfig;
     $app = JFactory::getApplication();
     $lang = JFactory::getLanguage();
     // Event, Notice, Warning, Error
     $legal_levels = array(2, 8, 32, 128);
     if (!in_array((int) $level, $legal_levels)) {
         $level = $legal_levels[0];
     }
     $this->datetime = date('Y-m-d H:i:s', (int) gmdate('U'));
     $this->short = $short;
     $this->tags = $tags;
     $this->event = $text;
     $this->level = (int) $level;
     // Create a notification link if this matches the desired level
     if ($this->level >= $aecConfig->cfg['error_notification_level']) {
         $this->notify = 1;
     } else {
         $this->notify = $force_notify ? 1 : 0;
     }
     // Mail out notification to all admins if this matches the desired level
     if ($this->level >= $aecConfig->cfg['email_notification_level'] || $force_email) {
         // check if Global Config `mailfrom` and `fromname` values exist
         if ($app->getCfg('mailfrom') != '' && $app->getCfg('fromname') != '') {
             $adminName2 = $app->getCfg('fromname');
             $adminEmail2 = $app->getCfg('mailfrom');
         } else {
             $rows = xJACLhandler::getSuperAdmins();
             $adminName2 = $rows[0]->name;
             $adminEmail2 = $rows[0]->email;
         }
         if (!$lang->hasKey("AEC_NOTICE_NUMBER_" . $this->level)) {
             $lang = JFactory::getLanguage();
             $lang->load('com_acctexp.admin', JPATH_ADMINISTRATOR);
         }
         // Send notification to all administrators
         $subject2 = sprintf(JText::_('AEC_ASEND_NOTICE'), JText::_("AEC_NOTICE_NUMBER_" . $this->level), $this->short, $app->getCfg('sitename'));
         $message2 = sprintf(JText::_('AEC_ASEND_NOTICE_MSG'), $this->event);
         $subject2 = html_entity_decode($subject2, ENT_QUOTES, 'UTF-8');
         $message2 = html_entity_decode($message2, ENT_QUOTES, 'UTF-8');
         // get email addresses of all admins and superadmins set to recieve system emails
         $admins = AECToolbox::getAdminEmailList();
         foreach ($admins as $adminemail) {
             if (!empty($adminemail)) {
                 xJ::sendMail($adminEmail2, $adminEmail2, $adminemail, $subject2, $message2);
             }
         }
     }
     if (!empty($params) && is_array($params)) {
         $this->params = $params;
     }
     $this->check();
     $this->store();
 }
Ejemplo n.º 5
0
 /**
  * Encode array and set Parameter field
  */
 public function setParams($input, $field = 'params')
 {
     if (!empty($field) && $input != 'null') {
         if (get_magic_quotes_gpc()) {
             $store = jsonDBTable::multistripslashes($input);
         } else {
             $store = $input;
         }
         $this->{$field} = xJ::escape($this->_db, jsoonHandler::encode($store));
     } else {
         $this->{$field} = null;
     }
     return true;
 }
Ejemplo n.º 6
0
 public function deleteOldEvents()
 {
     $db = JFactory::getDBO();
     // Load all events happening now or before now
     $query = 'SELECT `id`' . ' FROM #__acctexp_event' . ' WHERE `due_date` <= \'' . date('Y-m-d H:i:s', (int) gmdate('U')) . '\'' . ' AND `status` = \'waiting\'';
     $db->setQuery($query);
     $events = xJ::getDBArray($db);
     // Call each event individually
     foreach ($events as $evid) {
         $event = new aecEvent();
         $event->load($evid);
         $event->trigger();
     }
 }
Ejemplo n.º 7
0
 public function Action()
 {
     if (empty($_POST['type']) || empty($_POST['search'])) {
         return "<h3>Incomplete Query.</h3>";
     }
     $db = JFactory::getDBO();
     $types = array('config' => array('config', 'aecConfig'), 'processor' => array('config_processors', 'PaymentProcessor'), 'coupons' => array('coupons', 'Coupon'), 'displaypipeline' => array('displaypipeline', 'displayPipeline'), 'eventlog' => array('eventlog', 'eventLog'), 'invoice' => array('invoices', 'Invoice'), 'itemgroups' => array('itemgroups', 'ItemGroup'), 'history' => array('log_history', 'logHistory'), 'metauser' => array('metauser', 'metaUserDB'), 'mi' => array('microintegrations', 'microIntegration'), 'plans' => array('plans', 'SubscriptionPlan'), 'subscr' => array('subscr', 'Subscription'));
     $changes = 0;
     foreach ($_POST['type'] as $type) {
         $query = 'SELECT `id` FROM `#__acctexp_' . $types[$type][0] . '`';
         $db->setQuery($query);
         $ids = xJ::getDBArray($db);
         foreach ($ids as $id) {
             $objclass = $types[$type][1];
             $obj = new $objclass();
             $obj->load($id);
             if (!empty($_POST['armed']) && !empty($_POST['replace'])) {
                 if (AECToolbox::searchinObjectProperties($obj, $_POST['search'])) {
                     $mod = AECToolbox::searchreplaceinObjectProperties($obj, $_POST['search'], $_POST['replace']);
                     $mod->check();
                     $mod->store();
                     $changes++;
                 }
             } else {
                 if (AECToolbox::searchinObjectProperties($obj, $_POST['search'])) {
                     $changes++;
                 }
             }
         }
     }
     $return = '';
     $return .= "<h3>Query Result:</h3>";
     $return .= "<p>Searching for <strong>" . $_POST['search'] . "</strong></p>";
     $return .= "<p>Replacing it with <strong>" . $_POST['replace'] . "</strong></p>";
     $return .= "<p>Found <strong>" . $changes . "</strong> database entries.</p>";
     if ($_POST['armed']) {
         $return .= "<p>Modified <strong>" . $changes . "</strong> database entries.</p>";
     }
     return $return;
 }
Ejemplo n.º 8
0
 public function mailOut($request, $newcodes)
 {
     $codelist = "";
     if ($this->settings['text_html']) {
         foreach ($newcodes as $code) {
             $codelist .= "<p>" . $code . "</p>";
         }
     } else {
         $codelist = implode("\n", $newcodes);
     }
     $message = sprintf($this->settings['text'], $codelist);
     $message = AECToolbox::rewriteEngineRQ($message, $request);
     $subject = AECToolbox::rewriteEngineRQ($this->settings['subject'], $request);
     if (empty($message)) {
         return false;
     }
     $recipients = explode(',', $this->settings['recipient']);
     foreach ($recipients as $current => $email) {
         $recipients[$current] = AECToolbox::rewriteEngineRQ(trim($email), $request);
     }
     xJ::sendMail($this->settings['sender'], $this->settings['sender_name'], $recipients, $subject, $message, $this->settings['text_html']);
     return true;
 }
Ejemplo n.º 9
0
 public function sendEmailRegistered($renew, $adminonly = false, $invoice = null)
 {
     global $aecConfig;
     $app = JFactory::getApplication();
     $free = strcmp(strtolower($this->type), 'none') == 0 || strcmp(strtolower($this->type), 'free') == 0;
     $urow = new cmsUser();
     $urow->load($this->userid);
     $plan = new SubscriptionPlan();
     $plan->load($this->plan);
     $name = $urow->name;
     $email = $urow->email;
     $username = $urow->username;
     $pwd = $urow->password;
     $activationcode = $urow->activation;
     $message = sprintf(JText::_('ACCTEXP_MAILPARTICLE_GREETING'), $name);
     // Assemble E-Mail Subject & Message
     if ($renew) {
         $subject = sprintf(JText::_('ACCTEXP_SEND_MSG_RENEW'), $name, $app->getCfg('sitename'));
         $message .= sprintf(JText::_('ACCTEXP_MAILPARTICLE_THANKSREN'), $app->getCfg('sitename'));
         if ($plan->email_desc) {
             $message .= "\n\n" . $plan->email_desc . "\n\n";
         } else {
             $message .= " ";
         }
         if ($free) {
             $message .= sprintf(JText::_('ACCTEXP_MAILPARTICLE_LOGIN'), JURI::root());
         } else {
             $message .= JText::_('ACCTEXP_MAILPARTICLE_PAYREC') . " " . sprintf(JText::_('ACCTEXP_MAILPARTICLE_LOGIN'), JURI::root());
         }
     } else {
         $subject = sprintf(JText::_('ACCTEXP_SEND_MSG'), $name, $app->getCfg('sitename'));
         $message .= sprintf(JText::_('ACCTEXP_MAILPARTICLE_THANKSREG'), $app->getCfg('sitename'));
         if ($plan->email_desc) {
             $message .= "\n\n" . $plan->email_desc . "\n\n";
         } else {
             $message .= " ";
         }
         if ($free) {
             $message .= sprintf(JText::_('ACCTEXP_MAILPARTICLE_LOGIN'), JURI::root());
         } else {
             $message .= JText::_('ACCTEXP_MAILPARTICLE_PAYREC') . " " . sprintf(JText::_('ACCTEXP_MAILPARTICLE_LOGIN'), JURI::root());
         }
     }
     $message .= JText::_('ACCTEXP_MAILPARTICLE_FOOTER');
     $subject = html_entity_decode($subject, ENT_QUOTES, 'UTF-8');
     $message = html_entity_decode($message, ENT_QUOTES, 'UTF-8');
     // Send email to user
     if ($app->getCfg('mailfrom') != '' && $app->getCfg('fromname') != '') {
         $adminName2 = $app->getCfg('fromname');
         $adminEmail2 = $app->getCfg('mailfrom');
     } else {
         $rows = xJACLhandler::getSuperAdmins();
         $row2 = $rows[0];
         $adminName2 = $row2->name;
         $adminEmail2 = $row2->email;
     }
     if (!$adminonly) {
         xJ::sendMail($adminEmail2, $adminEmail2, $email, $subject, $message);
     }
     $aecUser = array();
     if (is_object($invoice)) {
         if (!empty($invoice->params['creator_ip'])) {
             $aecUser['ip'] = $invoice->params['creator_ip'];
             // user Hostname (if not deactivated)
             if ($aecConfig->cfg['gethostbyaddr']) {
                 $aecUser['isp'] = gethostbyaddr($invoice->params['creator_ip']);
             } else {
                 $aecUser['isp'] = 'deactivated';
             }
         }
     }
     if (empty($aecUser)) {
         $aecUser = AECToolbox::aecIP();
     }
     // Send notification to all administrators
     if ($renew) {
         $subject2 = sprintf(JText::_('ACCTEXP_SEND_MSG_RENEW'), $name, $app->getCfg('sitename'));
         $message2 = sprintf(JText::_('ACCTEXP_ASEND_MSG_RENEW'), $adminName2, $app->getCfg('sitename'), $name, $email, $username, $plan->id, $plan->name, $aecUser['ip'], $aecUser['isp']);
     } else {
         $subject2 = sprintf(JText::_('ACCTEXP_SEND_MSG'), $name, $app->getCfg('sitename'));
         $message2 = sprintf(JText::_('ACCTEXP_ASEND_MSG'), $adminName2, $app->getCfg('sitename'), $name, $email, $username, $plan->id, $plan->name, $aecUser['ip'], $aecUser['isp']);
     }
     $subject2 = html_entity_decode($subject2, ENT_QUOTES, 'UTF-8');
     $message2 = html_entity_decode($message2, ENT_QUOTES, 'UTF-8');
     $admins = AECToolbox::getAdminEmailList();
     foreach ($admins as $adminemail) {
         if (!empty($adminemail)) {
             xJ::sendMail($adminEmail2, $adminEmail2, $adminemail, $subject2, $message2);
         }
     }
 }
Ejemplo n.º 10
0
 public function request($type, $start, $end)
 {
     $tree = new stdClass();
     switch ($type) {
         case 'sales':
             $tree = array();
             if (empty($end)) {
                 $end = date('Y-m-d H:i:s', (int) gmdate('U'));
             }
             $query = 'SELECT `id`' . ' FROM #__acctexp_log_history' . ' WHERE transaction_date >= \'' . $start . '\'' . ' AND transaction_date <= \'' . $end . '\'' . ' ORDER BY transaction_date ASC';
             $this->db->setQuery($query);
             $entries = xJ::getDBArray($this->db);
             if (empty($entries)) {
                 echo json_encode($tree);
                 exit;
             }
             $historylist = array();
             $groups = array();
             foreach ($entries as $id) {
                 $entry = new logHistory();
                 $entry->load($id);
                 $entry->amount = AECToolbox::correctAmount($entry->amount);
                 $refund = false;
                 if (is_array($entry->response) && !empty($entry->response)) {
                     $filter = array('new_case', 'subscr_signup', 'paymentreview', 'subscr_eot', 'subscr_failed', 'subscr_cancel', 'Pending', 'Denied');
                     foreach ($entry->response as $v) {
                         if (in_array($v, $filter)) {
                             continue 2;
                         } elseif ($v == 'refund' || $v == 'Reversed' || $v == 'Refunded') {
                             $refund = true;
                         }
                     }
                 } else {
                     continue;
                 }
                 $pgroups = ItemGroupHandler::parentGroups($entry->plan_id);
                 if (empty($pgroups[0])) {
                     $pgroups[0] = 0;
                 }
                 if (!in_array($pgroups[0], $groups)) {
                     $groups[] = $pgroups[0];
                 }
                 $sale = new stdClass();
                 $sale->id = $id;
                 //$sale->invoice	= $entry->invoice_number;
                 $sale->date = $entry->transaction_date;
                 //$sale->datejs	= date( 'F d, Y H:i:s', strtotime( $entry->transaction_date ) );
                 $sale->plan = $entry->plan_id;
                 $sale->group = $pgroups[0];
                 $sale->amount = $refund ? -$entry->amount : $entry->amount;
                 $tree[] = $sale;
             }
             break;
     }
     echo json_encode($tree);
     exit;
 }
Ejemplo n.º 11
0
 public function deformatInvoiceNumber()
 {
     global $aecConfig;
     $query = 'SELECT invoice_number' . ' FROM #__acctexp_invoices' . ' WHERE id = \'' . xJ::escape($this->_db, $this->id) . '\'' . ' OR secondary_ident = \'' . xJ::escape($this->_db, $this->invoice_number) . '\'';
     $this->_db->setQuery($query);
     $this->invoice_number = $this->_db->loadResult();
 }
Ejemplo n.º 12
0
 public function Action()
 {
     if (empty($_POST['start_date'])) {
         return null;
     }
     $db = JFactory::getDBO();
     $start_timeframe = $_POST['start_date'] . ' 00:00:00';
     if (empty($end)) {
         $end = date('Y-m-d', (int) gmdate('U'));
     }
     $end_timeframe = $end . ' 23:59:59';
     $query = 'SELECT `id`' . ' FROM #__acctexp_log_history' . ' WHERE transaction_date >= \'' . $start_timeframe . '\'' . ' AND transaction_date <= \'' . $end_timeframe . '\'' . ' ORDER BY transaction_date ASC';
     $db->setQuery($query);
     $entries = xJ::getDBArray($db);
     if (empty($entries)) {
         return "nothing to list";
     }
     $historylist = array();
     $groups = array();
     foreach ($entries as $id) {
         $entry = new logHistory();
         $entry->load($id);
         $refund = false;
         if (is_array($entry->response)) {
             $filter = array('new_case', 'subscr_signup', 'paymentreview', 'subscr_eot', 'subscr_failed', 'subscr_cancel', 'Pending', 'Denied');
             $refund = false;
             foreach ($entry->response as $v) {
                 if (in_array($v, $filter)) {
                     continue 2;
                 } elseif ($v == 'refund' || $v == 'Reversed' || $v == 'Refunded') {
                     $refund = true;
                 }
             }
         }
         $date = date('Y-m-d', strtotime($entry->transaction_date));
         $pgroups = ItemGroupHandler::parentGroups($entry->plan_id);
         if (!in_array($pgroups[0], $groups)) {
             $groups[] = $pgroups[0];
         }
         if (!isset($historylist[$date])) {
             $historylist[$date] = array('amount' => null, 'groups' => null);
         }
         if ($refund) {
             $historylist[$date]['amount'] -= (double) $entry->amount;
             $historylist[$date]['groups'][$pgroups[0]]--;
         } else {
             $historylist[$date]['amount'] += (double) $entry->amount;
             $historylist[$date]['groups'][$pgroups[0]]++;
         }
     }
     foreach ($historylist as $date => $entry) {
         ksort($historylist[$date]['groups']);
     }
     $return = "";
     $return .= '<table style="background-color: fff; width: 30%; margin: 0 auto; text-align: center !important; font-size: 180%;">';
     $groupnames = array();
     foreach ($groups as $group) {
         $groupnames[$group] = ItemGroupHandler::groupName($group);
     }
     $closer = 0;
     $incomplete = false;
     foreach ($historylist as $date => $history) {
         if (date('D', strtotime($date)) == 'Mon') {
             $week = array();
         } elseif (!isset($week)) {
             $week = array();
             $incomplete = true;
         }
         $return .= '<tr style="border-bottom: 2px solid #999 !important; height: 2em;">';
         $return .= '<td title="Date" style="text-align: left !important; color: #aaa;">' . $date . '</td>';
         $return .= '<td style="width: 5em;">&nbsp;</td>';
         foreach ($groups as $group) {
             if (empty($history['groups'][$group])) {
                 $count = 0;
             } else {
                 $count = $history['groups'][$group];
             }
             $return .= '<td title="' . $groupnames[$group] . '" style="font-weight: bold; width: 5em;">' . $count . '</td>';
             if (isset($week)) {
                 $week['groups'][$group] += $count;
             }
         }
         if (isset($week)) {
             $week['amount'] += $history['amount'];
         }
         $return .= '<td style="width: 5em;">&nbsp;</td>';
         $return .= '<td title="Amount" style="text-align: right !important; color: #608919;">' . AECToolbox::correctAmount($history['amount']) . '</td>';
         $return .= '</tr>';
         $return .= '<tr style="height: 1px; background-color: #999;">';
         $return .= '<td colspan="' . (count($groups) + 4) . '"></td>';
         $return .= '</tr>';
         $closer = 0;
         if (date('D', strtotime($date)) == 'Sun') {
             $return .= '<tr ' . ($incomplete ? 'title="Incomplete!"' : '') . 'style="border-bottom: 2px solid #999 !important; height: 2em; background-color: #ddd;">';
             $return .= '<td style="text-align: left !important; color: #aaa;">' . ($incomplete ? '(Week)' : 'Week') . '</td>';
             $return .= '<td style="width: 5em;">&nbsp;</td>';
             foreach ($groups as $group) {
                 if (empty($week['groups'][$group])) {
                     $count = 0;
                 } else {
                     $count = $week['groups'][$group];
                 }
                 if ($incomplete) {
                     $return .= '<td title="' . $groupnames[$group] . '" style="font-weight: bold; width: 5em;">(' . $count . ')</td>';
                 } else {
                     $return .= '<td title="' . $groupnames[$group] . '" style="font-weight: bold; width: 5em;">' . $count . '</td>';
                 }
             }
             $return .= '<td style="width: 5em;">&nbsp;</td>';
             if ($incomplete) {
                 $return .= '<td title="Amount" style="text-align: right !important; color: #608919;">(' . AECToolbox::correctAmount($week['amount']) . ')</td>';
             } else {
                 $return .= '<td title="Amount" style="text-align: right !important; color: #608919;">' . AECToolbox::correctAmount($week['amount']) . '</td>';
             }
             $return .= '</tr>';
             $return .= '<tr style="height: 1px; background-color: #999;">';
             $return .= '<td colspan="' . (count($groups) + 4) . '"></td>';
             $return .= '</tr>';
             $closer = 1;
             $incomplete = false;
         }
     }
     if (!$closer) {
         $return .= '<tr style="border-bottom: 2px solid #999 !important; height: 2em; background-color: #ddd;">';
         $return .= '<td title="Date" style="text-align: left !important; color: #aaa;">(Week)</td>';
         $return .= '<td style="width: 5em;">&nbsp;</td>';
         foreach ($groups as $group) {
             if (empty($week['groups'][$group])) {
                 $count = 0;
             } else {
                 $count = $week['groups'][$group];
             }
             $return .= '<td title="' . $groupnames[$group] . '" style="font-weight: bold; width: 5em;">' . $count . '</td>';
         }
         $return .= '<td style="width: 5em;">&nbsp;</td>';
         $return .= '<td title="Amount" style="text-align: right !important; color: #608919;">' . AECToolbox::correctAmount($week['amount']) . '</td>';
         $return .= '</tr>';
         $return .= '<tr style="height: 1px; background-color: #999;">';
         $return .= '<td colspan="' . (count($groups) + 4) . '"></td>';
         $return .= '</tr>';
         $closer = 1;
     }
     $return .= '</table><br /><br />';
     return $return;
 }
Ejemplo n.º 13
0
 /**
  * Encode array to newline separated string
  * @return string
  */
 static function encode($array)
 {
     $db = JFactory::getDBO();
     $params = array();
     foreach ($array as $key => $value) {
         if (!is_null($key)) {
             if (is_array($value)) {
                 $temp = implode(';', $value);
                 $value = $temp;
             }
             if (get_magic_quotes_gpc()) {
                 $value = stripslashes($value);
             }
             $value = xJ::escape($db, $value);
             $params[] = $key . '=' . $value;
         }
     }
     return implode("\n", $params);
 }
Ejemplo n.º 14
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);
         }
     }
 }
Ejemplo n.º 15
0
 /**
  * @param string $type
  */
 static function getChildren($groups, $type)
 {
     if (empty($groups)) {
         return array();
     }
     $db = JFactory::getDBO();
     $where = array();
     if (is_array($groups) && !empty($groups)) {
         $where[] = '`group_id` IN (' . implode(',', $groups) . ')';
     } elseif (!empty($groups)) {
         $where[] = '`group_id` = ' . $groups . '';
     }
     if (!empty($type)) {
         $where[] = '`type` = \'' . $type . '\'';
     }
     $query = 'SELECT item_id' . ' FROM #__acctexp_itemxgroup';
     if (!empty($where)) {
         $query .= ' WHERE ( ' . implode(' AND ', $where) . ' )';
     }
     $db->setQuery($query);
     $result = xJ::getDBArray($db);
     if (!empty($result)) {
         foreach ($result as $k => $v) {
             if (empty($v)) {
                 unset($result[$k]);
             }
         }
         // Order results
         $query = 'SELECT id' . ' FROM #__acctexp_' . ($type == 'group' ? 'itemgroups' : 'plans') . ' WHERE id IN (' . implode(',', $result) . ')' . ' ORDER BY `ordering` ASC';
         $db->setQuery($query);
         return xJ::getDBArray($db);
     } else {
         return $result;
     }
 }
Ejemplo n.º 16
0
 public function getGroupsByUser($userId, $recursive = true)
 {
     $db = JFactory::getDBO();
     // Build the database query to get the rules for the asset.
     $query = $db->getQuery(true);
     $query->select($recursive ? 'b.id' : 'a.id');
     $query->from('#__user_usergroup_map AS map');
     $query->where('map.user_id = ' . (int) $userId);
     $query->leftJoin('#__usergroups AS a ON a.id = map.group_id');
     // If we want the rules cascading up to the global asset node we need a self-join.
     if ($recursive) {
         $query->leftJoin('#__usergroups AS b ON b.lft <= a.lft AND b.rgt >= a.rgt');
     }
     // Execute the query and load the rules from the result.
     $db->setQuery($query);
     $result = xJ::getDBArray($db);
     // Clean up any NULL or duplicate values, just in case
     JArrayHelper::toInteger($result);
     if (empty($result)) {
         $result = array('1');
     } else {
         $result = array_unique($result);
     }
     return $result;
 }
Ejemplo n.º 17
0
 public function loadUser()
 {
     $users = array();
     if (is_object($this->request->user)) {
         $db = JFactory::getDBO();
         if (isset($this->request->user->username)) {
             $query = 'SELECT `id`' . ' FROM #__users' . ' WHERE LOWER( `username` ) LIKE \'%' . xJ::escape($db, strtolower($this->request->user->username)) . '%\'';
             $db->setQuery($query);
             $users = xJ::getDBArray($db);
         }
         if (empty($users) && isset($this->request->user->name)) {
             $query = 'SELECT `id`' . ' FROM #__users' . ' WHERE LOWER( `name` ) LIKE \'%' . xJ::escape($db, strtolower($this->request->user->name)) . '%\'';
             $db->setQuery($query);
             $users = xJ::getDBArray($db);
         }
         if (empty($users) && isset($this->request->user->email)) {
             $query = 'SELECT `id`' . ' FROM #__users' . ' WHERE LOWER( `email` ) = \'' . xJ::escape($db, $this->request->user->email) . '\'';
             $db->setQuery($query);
             $users = xJ::getDBArray($db);
         }
         if (empty($users) && isset($this->request->user->userid)) {
             $query = 'SELECT `id`' . '  FROM #__users' . ' WHERE `id` = \'' . xJ::escape($db, $this->request->user->userid) . '\'';
             $db->setQuery($query);
             $users = xJ::getDBArray($db);
         }
         if (empty($users) && isset($this->request->user->invoice_number)) {
             $query = 'SELECT `userid`' . 'FROM #__acctexp_invoices' . ' WHERE LOWER( `invoice_number` ) = \'' . xJ::escape($db, $this->request->user->invoice_number) . '\'' . ' OR LOWER( `secondary_ident` ) = \'' . xJ::escape($db, $this->request->user->invoice_number) . '\'';
             $db->setQuery($query);
             $users = xJ::getDBArray($db);
         }
     } else {
         $users = AECToolbox::searchUser($this->request->user);
     }
     if (!count($users)) {
         $this->error = 'user not found';
     } elseif (count($users) > 1) {
         $this->error = 'multiple users found';
     } else {
         if (!empty($this->metaUser->userid)) {
             if ($this->metaUser->userid != $users[0]) {
                 $this->metaUser = new metaUser($users[0]);
             }
         } else {
             $this->metaUser = new metaUser($users[0]);
         }
     }
 }
Ejemplo n.º 18
0
    $db->setQuery($query);
    $plans = xJ::getDBArray($db);
    foreach ($plans as $planid) {
        $plan = new SubscriptionPlan();
        $plan->load($planid);
        if (!empty($plan->params['processors'])) {
            foreach ($plan->params['processors'] as $pi) {
                if (!in_array($pi, $allprocs)) {
                    $allprocs[] = $pi;
                }
            }
        }
    }
    $query = 'SELECT id FROM #__acctexp_config_processors';
    $db->setQuery($query);
    $procs = xJ::getDBArray($db);
    foreach ($procs as $procid) {
        // Check whether the processor has a plan it is applied to
        if (!in_array($procid, $allprocs)) {
            // Double check whether we have a history entry
            $query = 'SELECT id FROM #__acctexp_log_history WHERE `proc_id` = \'' . $procid . '\'';
            $db->setQuery($query);
            if (!$db->loadResult()) {
                $query = 'DELETE FROM #__acctexp_config_processors WHERE `id` = \'' . $procid . '\'';
                $db->setQuery($query);
                $db->query();
            }
        }
    }
}
$eucaInstalldb->addColifNotExists('hidden', "int(4) NOT NULL default '0'", 'microintegrations');
Ejemplo n.º 19
0
 public function Action()
 {
     if (empty($_POST['start_date'])) {
         return null;
     }
     $db = JFactory::getDBO();
     $query = 'SELECT `id`' . ' FROM #__acctexp_microintegrations' . ' WHERE `class_name` LIKE \'%mi_supporttimetracker%\'';
     $db->setQuery($query);
     $mis = xJ::getDBArray($db);
     $planlist = array();
     foreach ($mis as $mi) {
         $plans = MicroIntegrationHandler::getPlansbyMI($mi);
         $planlist = array_merge($planlist, $plans);
     }
     $planlist = array_unique($planlist);
     $userlist = array();
     foreach ($planlist as $planid) {
         $users = SubscriptionPlanHandler::getPlanUserlist($planid);
         $userlist = array_merge($userlist, $users);
     }
     $userlist = array_unique($userlist);
     $start_timeframe = strtotime($_POST['start_date'] . ' 00:00:00');
     if (!empty($_POST['end_date'])) {
         $end_timeframe = strtotime($_POST['end_date'] . ' 23:59:59');
     } else {
         $end_timeframe = (int) gmdate('U');
     }
     $unused = $used = 0;
     $minordebt = 0;
     $minordebtthresh = 0;
     $minordebtth = 0;
     $minordebtlist = array();
     $majordebt = 0;
     $majordebtlist = array();
     $historylist = array();
     foreach ($userlist as $userid) {
         $db->setQuery('SELECT a.id, a.name, a.username, b.custom_params' . ' FROM #__users AS a' . ' LEFT JOIN `#__acctexp_metauser` AS b ON a.id = b.userid' . ' WHERE a.id = ' . $userid . ' AND b.custom_params <> ""');
         $user = $db->loadObject();
         if (empty($user->id)) {
             continue;
         }
         $uparams = unserialize(base64_decode($user->custom_params));
         if (!empty($uparams['support_minutes_history'])) {
             if (is_array($uparams['support_minutes_history'])) {
                 foreach ($uparams['support_minutes_history'] as $history) {
                     if ($history['tstamp'] > $start_timeframe && $history['tstamp'] <= $end_timeframe) {
                         if (!empty($history['userid']) && $history['minutes_used']) {
                             $add = array();
                             $add['userid'] = $user->id;
                             $add['name'] = $user->name;
                             $add['username'] = $user->username;
                             $historylist[$history['userid']][] = array_merge($history, $add);
                         }
                     }
                 }
             }
         }
         if (!empty($uparams['support_minutes_used'])) {
             $utotal = $uparams['support_minutes'] - $uparams['support_minutes_used'];
         } else {
             $utotal = $uparams['support_minutes'];
         }
         if ($utotal < 0) {
             if ($utotal < -30) {
                 $majordebtlist[] = array('userid' => $user->id, 'username' => $user->username, 'debt' => $utotal);
                 $majordebt += $utotal;
             } elseif ($utotal < -14) {
                 $minordebtlist[] = array('userid' => $user->id, 'username' => $user->username, 'debt' => $utotal);
                 $minordebt += $utotal;
             } else {
                 $minordebtthresh++;
                 $minordebtth += $utotal;
                 $minordebt += $utotal;
             }
         }
         if (!empty($uparams['support_minutes'])) {
             $unused += $uparams['support_minutes'] - $uparams['support_minutes_used'];
         }
         if (!empty($uparams['support_minutes_used'])) {
             $used += $uparams['support_minutes_used'];
         }
     }
     $return = "";
     foreach ($historylist as $userid => $history_list) {
         if (empty($history_list)) {
             continue;
         }
         $total_minutes = 0;
         $metaUser = new metaUser($userid);
         $return .= '<h1>' . $metaUser->cmsUser->name . '</h1>';
         $return .= '<table class="adminlist">';
         $return .= '<tr><th>Date</th><th>Username</th><th>Time Used</th><th>Details</th></tr>';
         $history_list = $this->historySort($history_list);
         foreach ($history_list as $history) {
             $userlink = '<a href="';
             $userlink .= JURI::base() . 'index.php?option=com_acctexp&amp;task=edit&amp;entity=Membership&amp;userid=' . $history['userid'];
             $userlink .= '">';
             $userlink .= $history['name'] . ' (' . $history['username'] . ')';
             $userlink .= '</a>';
             $return .= '<tr>';
             $return .= '<td>' . date('Y-m-d H:i:s', $history['tstamp']) . '</td>';
             $return .= '<td>' . $userlink . '</td>';
             $return .= '<td>' . $history['minutes_used'] . '</td>';
             $return .= '<td>' . $history['details'] . '</td>';
             $return .= '</tr>';
             $total_minutes += $history['minutes_used'];
         }
         $return .= '<tr><td><strong>TOTAL</strong></td><td></td><td><strong>' . $total_minutes . '</strong> (' . round($total_minutes / 60, 2) . ' hours)</td><td></td></tr>';
         $return .= '</table><br /><br />';
     }
     $return .= '<p>Total used minutes: <strong>' . $used . '</strong> (' . round($used / 60, 2) . ' hours)</p>';
     $return .= '<p>Total unused minutes: ' . $unused . ' (' . round($unused / 60, 2) . ' hours)</p>';
     $return .= '<p>Total minor debt: ' . $minordebt . ' (' . round($minordebt / 60, 2) . ' hours)</p>';
     $minordebtlist = $this->debtSort($minordebtlist);
     foreach ($minordebtlist as $user) {
         $return .= '<a href="' . JURI::base() . 'index.php?option=com_acctexp&amp;task=edit&amp;entity=Membership&amp;userid=' . $user['userid'] . '">' . $user['username'] . ' (' . $user['debt'] . ' minutes)</a> ';
     }
     $return .= '<p>' . $minordebtthresh . ' Users below the -15 minute threshhold, total debt: ' . $minordebtth . ' (' . round($majordebt / 60, 2) . ' hours)</p>';
     $return .= '<p>Total major debt: ' . $majordebt . ' (' . round($majordebt / 60, 2) . ' hours)</p>';
     $majordebtlist = $this->debtSort($majordebtlist);
     foreach ($majordebtlist as $user) {
         $return .= '<a href="' . JURI::base() . 'index.php?option=com_acctexp&amp;task=edit&amp;entity=Membership&amp;userid=' . $user['userid'] . '">' . $user['username'] . ' (' . $user['debt'] . ' minutes)</a> ';
     }
     return $return;
 }
Ejemplo n.º 20
0
 static function getActiveListbyList($milist)
 {
     if (empty($milist)) {
         return array();
     }
     $db = JFactory::getDBO();
     $milist = array_unique($milist);
     $query = 'SELECT `id`' . ' FROM #__acctexp_microintegrations' . ' WHERE `id` IN (' . xJ::escape($db, implode(',', $milist)) . ')' . ' AND `active` = \'1\'' . ' ORDER BY `ordering` ASC';
     $db->setQuery($query);
     return xJ::getDBArray($db);
 }
Ejemplo n.º 21
0
 public function url($params, $profile = false)
 {
     if (empty($params['option'])) {
         $params = array_merge(array('option' => 'com_acctexp'), $params);
     }
     $params[xJ::token()] = '1';
     $p = array();
     foreach ($params as $k => $v) {
         $p[] = $k . '=' . $v;
     }
     if ($profile) {
         $secure = $this->cfg['ssl_profile'];
     } else {
         $secure = $this->cfg['ssl_signup'];
     }
     return AECToolbox::deadsureURL('index.php?' . implode("&", $p), $secure);
 }
Ejemplo n.º 22
0
 public function Action()
 {
     $db = JFactory::getDBO();
     $entries = 0;
     $planlist = array();
     $pplist = array();
     $processors = array('authorize_arb', 'google_checkout', 'hsbc', 'iats', 'paypal_wpp', 'sparkassen_internetkasse', 'usaepay');
     $query = 'SELECT `id`' . ' FROM #__acctexp_invoices' . ' WHERE `method` IN (' . implode(',', $processors) . ')';
     $db->setQuery($query);
     $invoices = xJ::getDBArray($db);
     foreach ($invoices as $id) {
         $invoice = new Invoice();
         $invoice->load($id);
         // Skip non-rebilled
         if (count($invoice->transactions) < 2) {
             continue;
         }
         foreach ($invoice->transactions as $tid => $transaction) {
             if (!$tid) {
                 // Skip first entry
                 continue;
             }
             if (!empty($_POST['safe'])) {
                 $query = 'SELECT `id`' . ' FROM #__acctexp_log_history' . ' WHERE transaction_date = \'' . $transaction->timestamp . '\'' . ' AND proc_name = \'' . $transaction->processor . '\'' . ' AND invoice_number = \'' . $invoice->invoice_number . '\'';
                 $db->setQuery($query);
                 $hasentry = $db->loadResult();
                 if ($hasentry) {
                     continue;
                 }
             }
             $entries++;
             if (!empty($_POST['create'])) {
                 $entry = new logHistory();
                 $user = new cmsUser();
                 $user->load($invoice->userid);
                 if (!isset($planlist[$invoice->usage])) {
                     $plan = new SubscriptionPlan();
                     $plan->load($invoice->usage);
                     $planlist[$invoice->usage] = $plan;
                 }
                 if (!isset($pplist[$invoice->method])) {
                     $pp = new SubscriptionPlan();
                     $pp->load($invoice->method);
                     $pplist[$invoice->method] = $pp;
                 }
                 if ($pplist[$invoice->method]->id) {
                     $entry->proc_id = $pplist[$invoice->method]->id;
                     $entry->proc_name = $pplist[$invoice->method]->processor_name;
                 }
                 $entry->user_id = $user->id;
                 $entry->user_name = $user->username;
                 if ($planlist[$invoice->usage]->id) {
                     $entry->plan_id = $planlist[$invoice->usage]->id;
                     $entry->plan_name = $planlist[$invoice->usage]->name;
                 }
                 $entry->transaction_date = $transaction->timestamp;
                 $entry->amount = $transaction->amount;
                 $entry->invoice_number = $invoice->invoice_number;
                 $entry->response = 'Created by the Rebuild Rebills Tool';
                 $entry->cleanup();
                 $entry->check();
                 $entry->store();
             }
         }
     }
     if (empty($entries)) {
         if ($_POST['create']) {
             return "No Invoices found to create History Entries from.";
         } else {
             return "No Invoices with data found.";
         }
     } else {
         if ($_POST['create']) {
             return $entries . " History Entries created.";
         } else {
             return "No History Entries created, found " . $entries . " that can be converted (select 'Create' from the settings above and carry out the query again)";
         }
     }
 }
Ejemplo n.º 23
0
 public function relayAction($request)
 {
     if ($request->action == 'action') {
         if (!empty($this->settings['text_first'])) {
             if (empty($request->metaUser->objSubscription->previous_plan)) {
                 $request->area = '_first';
             }
         }
     }
     if (!isset($this->settings['text' . $request->area]) || !isset($this->settings['subject' . $request->area])) {
         return null;
     }
     $message = AECToolbox::rewriteEngineRQ($this->settings['text' . $request->area], $request);
     $subject = AECToolbox::rewriteEngineRQ($this->settings['subject' . $request->area], $request);
     if (empty($message)) {
         return null;
     }
     $recipient = $cc = $bcc = null;
     $rec_groups = array("recipient", "cc", "bcc");
     foreach ($rec_groups as $setting) {
         if (empty($this->settings[$setting])) {
             continue;
         }
         $list = AECToolbox::rewriteEngineRQ($this->settings[$setting], $request);
         $recipient_array = explode(',', $list);
         if (!empty($recipient_array)) {
             ${$setting} = array();
             foreach ($recipient_array as $k => $email) {
                 if (!empty($email)) {
                     ${$setting}[] = trim($email);
                 }
             }
         }
     }
     xJ::sendMail($this->settings['sender'], $this->settings['sender_name'], $recipient, $subject, $message, $this->settings['text' . $request->area . '_html'], $cc, $bcc);
     return true;
 }
Ejemplo n.º 24
0
$properties['invoice_pages'] = (int) ($invoiceno / $pagesize);
$properties['invoice_page'] = $page;
$invoices = array();
foreach ($invoiceList as $invoiceid) {
    $invoices[$invoiceid] = array();
    $invoice = new Invoice();
    $invoice->load($invoiceid);
    $rowstyle = '';
    $actionsarray = array();
    if (!in_array($invoice->method, $excludedprocs)) {
        $actionsarray[] = array('task' => 'invoicePrint', 'add' => 'invoice=' . $invoice->invoice_number . '&tmpl=component', 'text' => JText::_('HISTORY_ACTION_PRINT'), 'insert' => ' target="_blank" ', 'class' => 'btn');
        $actionsarray[] = array('task' => 'invoicePDF', 'add' => 'invoice=' . $invoice->invoice_number, 'text' => 'PDF', 'insert' => '', 'class' => 'btn');
    }
    if ($invoice->transaction_date == '0000-00-00 00:00:00' || $invoice->subscr_id) {
        if ($invoice->transaction_date == '0000-00-00 00:00:00') {
            $actionsarray[] = array('task' => 'repeatPayment', 'add' => 'invoice=' . $invoice->invoice_number . '&' . xJ::token() . '=1', 'text' => JText::_('HISTORY_ACTION_REPEAT'), 'class' => 'btn btn-success');
            if (is_null($invoice->fixed) || !$invoice->fixed) {
                $actionsarray[] = array('task' => 'cancelPayment', 'add' => 'invoice=' . $invoice->invoice_number, 'text' => JText::_('HISTORY_ACTION_CANCEL'), 'class' => 'btn btn-danger');
            }
        }
        $rowstyle = 'invoice-unpaid';
    }
    if (!in_array($invoice->method, $pplist)) {
        $pplist[] = $invoice->method;
    }
    $invoice->formatInvoiceNumber();
    $invoices[$invoiceid]['object'] = $invoice;
    $invoices[$invoiceid]['invoice_number'] = $invoice->invoice_number;
    $invoices[$invoiceid]['amount'] = $invoice->amount;
    $invoices[$invoiceid]['currency_code'] = $invoice->currency;
    $invoices[$invoiceid]['actions'] = $actionsarray;
Ejemplo n.º 25
0
 public function Action()
 {
     $db = JFactory::getDBO();
     // Find all entries lacking an existing user account
     $tables = array('cart' => 'userid', 'couponsxuser' => 'userid', 'invoices' => 'userid', 'metauser' => 'userid', 'subscr' => 'userid', 'log_history' => 'user_id');
     $found = array('total' => 0);
     foreach ($tables as $table => $key) {
         $query = 'SELECT count(*)' . ' FROM #__acctexp_' . $table . ' AS a' . ' LEFT JOIN #__users AS b ON a.' . $key . ' = b.id' . ' WHERE b.id is null';
         $db->setQuery($query);
         $count = $db->loadResult();
         $found[$table] = $count;
         $found['total'] += $count;
     }
     if (!empty($_POST['delete'])) {
         $return = '<p>Deleted a total of ' . $found['total'] . ' entries.<p>' . '<ul>';
         foreach ($found as $table => $count) {
             if ($table != 'total' && $count) {
                 $query = 'SELECT a.id' . ' FROM #__acctexp_' . $table . ' AS a' . ' LEFT JOIN #__users AS b ON a.' . $tables[$table] . ' = b.id' . ' WHERE b.id is null';
                 $db->setQuery($query);
                 $ids = xJ::getDBArray($db);
                 $query = 'DELETE' . ' FROM #__acctexp_' . $table . ' WHERE id IN (' . implode(',', $ids) . ')';
                 $db->setQuery($query);
                 $db->query();
                 $return .= '<li>deleted ' . $count . ' entries in table ' . $table . '</li>';
             }
         }
         $query = 'SELECT count(*)' . ' FROM #__acctexp_eventlog' . ' WHERE tags = \'debug\'';
         $db->setQuery($query);
         $dcount = $db->loadResult();
         if ($dcount) {
             $query = 'DELETE' . ' FROM #__acctexp_eventlog' . ' WHERE tags = \'debug\'';
             $db->setQuery($query);
             $db->query();
             $return .= '<li>removed ' . $dcount . ' debug entries in the eventlog</li>';
         }
         if (!empty($_POST['alltemp'])) {
             $query = 'SELECT count(*)' . ' FROM #__acctexp_temptoken';
             $db->setQuery($query);
             $dcount = $db->loadResult();
             if ($dcount) {
                 $query = 'TRUNCATE TABLE#__acctexp_temptoken';
                 $db->setQuery($query);
                 $db->query();
                 $return .= '<li>removed ' . $dcount . ' temptokens (full cleanup)</li>';
             }
         } else {
             $query = 'SELECT count(*)' . ' FROM #__acctexp_temptoken' . ' WHERE created_date < \'' . date('Y-m-d H:i:s', (int) gmdate('U') - 3600) . '\'';
             $db->setQuery($query);
             $dcount = $db->loadResult();
             if ($dcount) {
                 $query = 'DELETE' . ' FROM #__acctexp_temptoken' . ' WHERE created_date < \'' . date('Y-m-d H:i:s', (int) gmdate('U') - 3600) . '\'';
                 $db->setQuery($query);
                 $db->query();
                 $return .= '<li>removed ' . $dcount . ' temptokens</li>';
             }
         }
         return $return;
     } else {
         $return = '<p>Found a total of ' . $found['total'] . ' entries.<p>' . '<ul>';
         foreach ($found as $table => $count) {
             if ($table != 'total') {
                 $return .= '<li>' . $count . ' entries in table ' . $table . '</li>';
             }
         }
         $query = 'SELECT count(*)' . ' FROM #__acctexp_eventlog' . ' WHERE tags = \'debug\'';
         $db->setQuery($query);
         $count = $db->loadResult();
         if ($count) {
             $return .= '<li>' . $count . ' debug entries in the eventlog</li>';
         }
         $query = 'SELECT count(*)' . ' FROM #__acctexp_temptoken' . ' WHERE created_date < \'' . date('Y-m-d H:i:s', (int) gmdate('U') - 3600) . '\'';
         $db->setQuery($query);
         $count = $db->loadResult();
         if ($count) {
             $return .= '<li>' . $count . ' temptokens older than an hour</li>';
         }
         return $return;
     }
 }
Ejemplo n.º 26
0
$result = $db->loadObject();
if (is_object($result)) {
    if (strcmp($result->Field, 'extra01') === 0) {
        $queri = array();
        $queri[] = "ALTER TABLE #__acctexp_subscr CHANGE `extra01` `recurring` int(1) NOT NULL default '0'";
        $queri[] = "ALTER TABLE #__acctexp_subscr DROP `extra02`";
        $queri[] = "ALTER TABLE #__acctexp_subscr DROP `extra03`";
        $queri[] = "ALTER TABLE #__acctexp_subscr DROP `extra04`";
        $eucaInstalldb->multiQueryExec($queri);
    }
}
$db->setQuery("SELECT count(*) FROM  #__acctexp_config_processors");
$oldplans = $db->loadResult() == 0 && in_array($app->getCfg('dbprefix') . 'acctexp_processors_plans', $tables);
if ($oldplans || in_array($app->getCfg('dbprefix') . 'acctexp_config_paypal', $tables)) {
    $db->setQuery("SELECT proc_id FROM #__acctexp_processors_plans");
    $db_processors = xJ::getDBArray($db);
    if (is_array($db_processors)) {
        $used_processors = array_unique($db_processors);
        $legacy_processors_db = array("", "paypal", "vklix", "authorize", "allopass", "2checkout", "epsnetpay", "paysignet", "worldpay", "alertpay");
        $legacy_processors_name = array("", "paypal", "viaklix", "authorize", "allopass", "2checkout", "epsnetpay", "paysignet", "worldpay", "alertpay");
        foreach ($used_processors as $i => $n) {
            $db->setQuery("SELECT * FROM #__acctexp_config_" . $legacy_processors_db[$n]);
            $old_cfg = $db->loadObject();
            $pp = new PaymentProcessor();
            $pp->loadName($legacy_processors_name[$n]);
            $pp->init();
            switch ($legacy_processors_name[$n]) {
                case 'paypal':
                    $pp->settings['business'] = $old_cfg->business;
                    $pp->settings['testmode'] = $old_cfg->testmode;
                    $pp->settings['tax'] = $old_cfg->tax;
Ejemplo n.º 27
0
 public function loadJSuser()
 {
     $db = JFactory::getDBO();
     $query = 'SELECT `id`' . ' FROM #__community_fields' . ' WHERE `type` != \'group\'';
     $db->setQuery($query);
     $ids = xJ::getDBArray($db);
     $query = 'SELECT `field_id`, `value`' . ' FROM #__community_fields_values' . ' WHERE `field_id` IN (' . implode(',', $ids) . ')' . ' AND `user_id` = \'' . (int) $this->userid . '\'';
     $db->setQuery($query);
     $fields = $db->loadObjectList();
     $this->jsUser = array();
     foreach ($ids as $fid) {
         foreach ($fields as $field) {
             if ($field->field_id == $fid) {
                 $this->jsUser[$fid] = $field->value;
             }
         }
         if (!isset($this->jsUser[$fid])) {
             $this->jsUser[$fid] = null;
         }
         $this->rewrite['user_js_' . $fid] = $this->jsUser[$fid];
     }
     if (!empty($this->jsUser)) {
         $this->hasJSprofile = true;
     }
 }
Ejemplo n.º 28
0
<?php

/**
 * @version $Id: upgrade_0_12_6_RC2m.inc.php
 * @package AEC - Account Control Expiration - Membership Manager
 * @subpackage Install Includes
 * @copyright 2006-2015 Copyright (C) David Deutsch
 * @author David Deutsch <*****@*****.**> & Team AEC - http://www.valanx.org
 * @license GNU/GPL v.3 http://www.gnu.org/licenses/gpl.html or, at your option, any later version
 */
// Dont allow direct linking
defined('_JEXEC') or die('Direct Access to this location is not allowed.');
$query = 'SELECT `id`' . ' FROM #__acctexp_metauser';
$db->setQuery($query);
$entries = xJ::getDBArray($db);
/*
 * This may seem odd, but due to unforseen consequences, json encoding and decoding
 * actually fixes some numeric properties so that we can switch them over to arrays,
 * which is done with get_object_vars as its the quickest AND, uhm, dirtiest method.
 * without the encoding and decoding, get_object_vars just purrs out an empty array.
 */
foreach ($entries as $eid) {
    $meta = new metaUserDB();
    $meta->load($eid);
    if (!empty($meta->params)) {
        if (is_object($meta->params)) {
            if (is_object($meta->params->mi)) {
                $new = get_object_vars(json_decode(json_encode($meta->params->mi)));
                $meta->params->mi = $new;
            }
        }
Ejemplo n.º 29
0
 static function saveUserRegistration($var, $internal = false, $overrideActivation = false, $overrideEmails = false, $overrideJS = false)
 {
     $db = JFactory::getDBO();
     global $task, $aecConfig;
     $app = JFactory::getApplication();
     ob_start();
     // Let CB/JUSER think that everything is going fine
     if (aecComponentHelper::detect_component('anyCB')) {
         if (aecComponentHelper::detect_component('CBE') || $overrideActivation) {
             global $ueConfig;
         }
         $savetask = $task;
         $_REQUEST['task'] = 'done';
         include_once JPATH_SITE . '/components/com_comprofiler/comprofiler.php';
         $task = $savetask;
         if ($overrideActivation) {
             $ueConfig['reg_confirmation'] = 0;
         }
         if ($overrideEmails) {
             $ueConfig['reg_welcome_sub'] = '';
             // Only disable "Pending Approval / Confirmation" emails if it makes sense
             if (!$ueConfig['reg_confirmation'] || !$ueConfig['reg_admin_approval']) {
                 $ueConfig['reg_pend_appr_sub'] = '';
             }
         }
     } elseif (aecComponentHelper::detect_component('JUSER')) {
         $savetask = $task;
         $task = 'blind';
         include_once JPATH_SITE . '/components/com_juser/juser.php';
         include_once JPATH_SITE . '/administrator/components/com_juser/juser.class.php';
         $task = $savetask;
     } elseif (aecComponentHelper::detect_component('JOMSOCIAL')) {
     }
     // For joomla and CB, we must filter out some internal variables before handing over the POST data
     $badbadvars = array('userid', 'method_name', 'usage', 'processor', 'recurring', 'currency', 'amount', 'invoice', 'id', 'gid');
     foreach ($badbadvars as $badvar) {
         if (isset($var[$badvar])) {
             unset($var[$badvar]);
         }
     }
     if (empty($var['name']) && !empty($var['jform'])) {
         // Must be K2
         $var['name'] = aecEscape($var['jform']['name'], array('string', 'clear_nonalnum'));
         unset($var['jform']);
     }
     $_POST = $var;
     $var['username'] = aecEscape($var['username'], array('string', 'badchars'));
     $savepwd = aecEscape($var['password'], array('string', 'badchars'));
     if (aecComponentHelper::detect_component('anyCB')) {
         // This is a CB registration, borrowing their code to save the user
         if ($internal && !aecComponentHelper::detect_component('CBE')) {
             include_once JPATH_SITE . '/components/com_acctexp/lib/codeofshame/cbregister.php';
             if (empty($_POST['firstname']) && !empty($_POST['name'])) {
                 $name = metaUser::_explodeName($_POST['name']);
                 $_POST['firstname'] = $name['first'];
                 if (empty($name['last'])) {
                     $_POST['lastname'] = $name['first'];
                 } else {
                     $_POST['lastname'] = $name['last'];
                 }
             }
             $_POST['password__verify'] = $_POST['password2'];
             unset($_POST['password2']);
             @saveRegistrationNOCHECKSLOL('com_acctexp');
         } else {
             @saveRegistration('com_acctexp');
             $cbreply = ob_get_contents();
             $indicator = '<script type="text/javascript">alert(\'';
             $alertstart = strpos($cbreply, $indicator);
             // Emergency fallback
             if ($alertstart !== false) {
                 ob_clean();
                 $alertend = strpos($cbreply, '\'); </script>', $alertstart);
                 $alert = substr($cbreply, $alertstart + strlen($indicator), $alertend - $alertstart - strlen($indicator));
                 if ($aecConfig->cfg['plans_first']) {
                     aecErrorAlert($alert, $action = 'window.history.go(-2);');
                 } else {
                     aecErrorAlert($alert, $action = 'window.history.go(-3);');
                 }
             }
         }
     } elseif (aecComponentHelper::detect_component('JUSER')) {
         // This is a JUSER registration, borrowing their code to save the user
         saveRegistration('com_acctexp');
         $query = 'SELECT `id`' . ' FROM #__users' . ' WHERE `username` = \'' . $var['username'] . '\'';
         $db->setQuery($query);
         $uid = $db->loadResult();
         JUser::saveUser_ext($uid);
         //synchronize dublicate user data
         $query = 'SELECT `id`' . ' FROM #__juser_integration' . ' WHERE `published` = \'1\'' . ' AND `export_status` = \'1\'';
         $db->setQuery($query);
         $components = $db->loadObjectList();
         if (!empty($components)) {
             foreach ($components as $component) {
                 $synchronize = require_integration($component->id);
                 $synchronize->synchronizeFrom($uid);
             }
         }
     } elseif (aecComponentHelper::detect_component('JOMSOCIAL') && !$overrideJS) {
     } else {
         $data = array('username' => $var['username'], 'password' => $var['password'], 'password2' => $var['password2'], 'email' => $var['email'], 'name' => $var['name']);
         if (isset($var['jform']['profile'])) {
             $data['profile'] = $var['jform']['profile'];
         }
         if (defined('JPATH_MANIFESTS')) {
             $params = JComponentHelper::getParams('com_users');
             // Initialise the table with JUser.
             JUser::getTable('User', 'JTable');
             $user = new JUser();
             // Prepare the data for the user object.
             $useractivation = $params->get('useractivation');
             // Check if the user needs to activate their account.
             if (($useractivation == 1 || $useractivation == 2) && !$overrideActivation) {
                 jimport('joomla.user.helper');
                 $data['activation'] = xJ::getHash();
                 $data['block'] = 1;
             }
             $usersConfig = JComponentHelper::getParams('com_users');
             $system = $usersConfig->get('new_usertype', 2);
             $data['groups'][] = $system;
             // Bind the data.
             if (!$user->bind($data)) {
                 JError::raiseWarning(500, JText::sprintf('COM_USERS_REGISTRATION_BIND_FAILED', $user->getError()));
                 return false;
             }
             // Load the users plugin group.
             JPluginHelper::importPlugin('users');
             // Store the data.
             if (!$user->save()) {
                 JError::raiseWarning(500, JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $user->getError()));
                 return false;
             }
         } else {
             // This is a joomla registration, borrowing their code to save the user
             // Check for request forgeries
             if (!$internal) {
                 JRequest::checkToken() or die('Invalid Token');
             }
             // Get required system objects
             $user = clone JFactory::getUser();
             //$pathway 	=& $app->getPathway();
             $config = JFactory::getConfig();
             $authorize = JFactory::getACL();
             $document = JFactory::getDocument();
             // If user registration is not allowed, show 403 not authorized.
             $usersConfig = JComponentHelper::getParams('com_users');
             if ($usersConfig->get('allowUserRegistration') == '0') {
                 JError::raiseError(403, JText::_('Access Forbidden'));
                 return;
             }
             // Initialize new usertype setting
             $newUsertype = $usersConfig->get('new_usertype');
             if (!$newUsertype) {
                 $newUsertype = 'Registered';
             }
             // Bind the post array to the user object
             if (!$user->bind($data)) {
                 JError::raiseError(500, $user->getError());
                 unset($_POST);
                 subscribe('com_acctexp');
                 return false;
             }
             // Set some initial user values
             $user->set('id', 0);
             $user->set('usertype', '');
             $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO'));
             $user->set('sendEmail', 0);
             $user->set('registerDate', date('Y-m-d H:i:s', (int) gmdate('U')));
             // If user activation is turned on, we need to set the activation information
             $useractivation = $usersConfig->get('useractivation');
             if ($useractivation == '1' && !$overrideActivation) {
                 jimport('joomla.user.helper');
                 $user->set('activation', md5(JUserHelper::genRandomPassword()));
                 $user->set('block', '1');
             }
             // If there was an error with registration, set the message and display form
             if (!$user->save()) {
                 JError::raiseWarning('', JText::_($user->getError()));
                 echo JText::_($user->getError());
                 return false;
             }
         }
         $row = $user;
         $name = $row->name;
         $email = $row->email;
         $username = $row->username;
         $subject = sprintf(JText::_('AEC_SEND_SUB'), $name, $app->getCfg('sitename'));
         $subject = html_entity_decode($subject, ENT_QUOTES, 'UTF-8');
         $usersConfig = JComponentHelper::getParams('com_users');
         $activation = $usersConfig->get('useractivation');
         if ($activation > 0 && !$overrideActivation) {
             $atext = JText::_('AEC_USEND_MSG_ACTIVATE');
             if (defined('JPATH_MANIFESTS')) {
                 $activation_link = JURI::root() . 'index.php?option=com_users&amp;task=registration.activate&amp;token=' . $row->activation;
                 if ($activation == 2) {
                     $atext = JText::_('COM_USERS_MSG_ADMIN_ACTIVATE');
                 }
             } else {
                 $activation_link = JURI::root() . 'index.php?option=com_user&amp;task=activate&amp;activation=' . $row->activation;
             }
             $message = sprintf($atext, $name, $app->getCfg('sitename'), $activation_link, JURI::root(), $username, $savepwd);
         } else {
             $message = sprintf(JText::_('AEC_USEND_MSG'), $name, $app->getCfg('sitename'), JURI::root());
         }
         $message = html_entity_decode($message, ENT_QUOTES, 'UTF-8');
         // check if Global Config `mailfrom` and `fromname` values exist
         if ($app->getCfg('mailfrom') != '' && $app->getCfg('fromname') != '') {
             $adminName2 = $app->getCfg('fromname');
             $adminEmail2 = $app->getCfg('mailfrom');
         } else {
             // use email address and name of first superadmin for use in email sent to user
             $rows = xJACLhandler::getSuperAdmins();
             $row2 = $rows[0];
             $adminName2 = $row2->name;
             $adminEmail2 = $row2->email;
         }
         // Send email to user
         if (!($aecConfig->cfg['nojoomlaregemails'] || $overrideEmails)) {
             xJ::sendMail($adminEmail2, $adminEmail2, $email, $subject, $message);
         }
         // Send notification to all administrators
         $aecUser = AECToolbox::aecIP();
         $subject2 = sprintf(JText::_('AEC_SEND_SUB'), $name, $app->getCfg('sitename'));
         $message2 = sprintf(JText::_('AEC_ASEND_MSG_NEW_REG'), $adminName2, $app->getCfg('sitename'), $row->name, $email, $username, $aecUser['ip'], $aecUser['isp']);
         $subject2 = html_entity_decode($subject2, ENT_QUOTES, 'UTF-8');
         $message2 = html_entity_decode($message2, ENT_QUOTES, 'UTF-8');
         // get email addresses of all admins and superadmins set to recieve system emails
         $admins = AECToolbox::getAdminEmailList();
         foreach ($admins as $adminemail) {
             if (!empty($adminemail)) {
                 xJ::sendMail($adminEmail2, $adminEmail2, $adminemail, $subject2, $message2);
             }
         }
     }
     ob_clean();
     // We need the new userid, so we're fetching it from the newly created entry here
     $query = 'SELECT `id`' . ' FROM #__users' . ' WHERE `username` = \'' . $var['username'] . '\'';
     $db->setQuery($query);
     return $db->loadResult();
 }
Ejemplo n.º 30
0
 public function listPlans()
 {
     $db = JFactory::getDBO();
     $db->setQuery('SELECT id' . ' FROM #__acctexp_plans');
     return xJ::getDBArray($db);
 }