public function getMIform($request, $checkout = true, $alwayspermit = false, $useredit = false) { global $aecConfig; $language_array = AECToolbox::getISO3166_1a2_codes(); $language_code_list = array(); foreach ($language_array as $language) { $language_code_list[] = JHTML::_('select.option', $language, JText::_('COUNTRYCODE_' . $language)); } $settings = array(); $lists = array(); $hasregistration = true; if (!empty($request->metaUser->cmsUser)) { if (count($request->metaUser->cmsUser) < 4) { $hasregistration = false; } } else { $hasregistration = false; } $settings['validation'] = array(); $settings['validation']['rules'] = array(); $settings['formatting'] = array(); if (!empty($this->settings['emulate_reg']) && (empty($request->metaUser->userid) && !$hasregistration || !$checkout)) { if (defined('JPATH_MANIFESTS')) { // Joomla 1.6+ Registration $lang = JFactory::getLanguage(); $lang->load('com_users', JPATH_SITE, 'en-GB', true); $lang->load('com_users', JPATH_SITE, $lang->get('tag'), true); $settings['name'] = array('inputC', JText::_('COM_USERS_PROFILE_NAME_LABEL'), 'name', ''); $settings['username'] = array('inputC', JText::_('COM_USERS_PROFILE_USERNAME_LABEL'), 'username', ''); $settings['email'] = array('inputC', JText::_('COM_USERS_PROFILE_EMAIL1_LABEL'), 'email', ''); $settings['email2'] = array('inputC', JText::_('COM_USERS_PROFILE_EMAIL2_LABEL'), 'email', ''); $settings['password'] = array('password', JText::_('COM_USERS_REGISTER_PASSWORD1_LABEL'), 'password', ''); $settings['password2'] = array('password', JText::_('COM_USERS_REGISTER_PASSWORD2_LABEL'), 'password2', ''); $settings['validation']['rules']['name'] = array('minlength' => 2, 'required' => true); $settings['validation']['rules']['username'] = array('minlength' => 3, 'alphanumericwhitespace' => true, 'required' => true, 'remote' => "index.php?option=com_acctexp&task=usernameexists"); $settings['validation']['rules']['email'] = array('nowhitespace' => true, 'email' => true, 'required' => true, 'remote' => "index.php?option=com_acctexp&task=emailexists"); $settings['validation']['rules']['email2'] = array('nowhitespace' => true, 'email' => true, 'required' => true, 'equalTo' => '#mi_' . $this->id . '_email'); $settings['validation']['rules']['password'] = array('minlength' => 6, 'maxlength' => 98, 'required' => true); $settings['validation']['rules']['password2'] = array('minlength' => 6, 'maxlength' => 98, 'required' => true, 'equalTo' => '#mi_' . $this->id . '_password'); } else { // Joomla 1.5 Registration $settings['name'] = array('inputC', JText::_('Name'), 'name', ''); $settings['username'] = array('inputC', JText::_('User name'), 'username', ''); $settings['email'] = array('inputC', JText::_('Email'), 'email', ''); $settings['password'] = array('password', JText::_('Password'), 'password', ''); $settings['password2'] = array('password', JText::_('Verify Password'), 'password2', ''); $settings['validation']['rules']['name'] = array('minlength' => 2, 'required' => true); $settings['validation']['rules']['username'] = array('minlength' => 3, 'required' => true, 'remote' => "index.php?option=com_acctexp&task=usernameexists"); $settings['validation']['rules']['email'] = array('email' => true, 'required' => true, 'remote' => "index.php?option=com_acctexp&task=emailexists"); $settings['validation']['rules']['password'] = array('minlength' => 2, 'required' => true); $settings['validation']['rules']['password2'] = array('minlength' => 2, 'required' => true, 'equalTo' => '#mi_' . $this->id . '_password'); } if (!$checkout) { foreach ($settings as $s => $v) { if ($s == 'validation' || strpos($s, 'password') !== false) { continue; } $v[3] = $request->metaUser->cmsUser->{str_replace("2", "", $s)}; $settings[$s] = $v; } } if ($aecConfig->cfg['use_recaptcha'] && !empty($aecConfig->cfg['recaptcha_publickey']) && $checkout) { require_once JPATH_SITE . '/components/com_acctexp/lib/recaptcha/recaptchalib.php'; $settings['recaptcha'] = array('passthrough', 'ReCAPTCHA', 'recaptcha', recaptcha_get_html($aecConfig->cfg['recaptcha_publickey'])); } } elseif (!empty($this->settings['emulate_reg']) && !empty($this->settings['display_emul'])) { $settings['name'] = array('passthrough', JText::_('Name'), 'name', '<p><strong>' . $request->metaUser->cmsUser->name . '</strong></p>'); $settings['username'] = array('passthrough', JText::_('User name'), 'username', '<p><strong>' . $request->metaUser->cmsUser->username . '</strong></p>'); $settings['email'] = array('passthrough', JText::_('Email'), 'email', '<p><strong>' . $request->metaUser->cmsUser->email . '</strong></p>'); } if (!empty($this->settings['settings'])) { for ($i = 0; $i < $this->settings['settings']; $i++) { $p = $i . '_'; if (!isset($this->settings[$p . 'short'])) { continue; } if (!empty($request->params[$this->settings[$p . 'short']])) { $content = $request->params[$this->settings[$p . 'short']]; } elseif (!empty($_POST['mi_' . $request->parent->id . '_' . $this->settings[$p . 'short']])) { $content = aecGetParam('mi_' . $request->parent->id . '_' . $this->settings[$p . 'short'], true, array('string', 'badchars')); } else { $content = AECToolbox::rewriteEngineRQ($this->settings[$p . 'default'], $request); } if (!empty($this->settings[$p . 'fixed']) && !$checkout && !$alwayspermit) { $settings[$this->settings[$p . 'name']] = array('passthrough', $this->settings[$p . 'name'], $this->settings[$p . 'short'], '<p><strong>' . $content . '</strong></p>'); continue; } if (!empty($this->settings[$p . 'short'])) { if ($this->settings[$p . 'type'] == 'list') { $extra = explode("\n", $this->settings[$p . 'list']); if (!count($extra)) { continue; } $fields = array(); foreach ($extra as $ex) { $fields[] = explode("|", $ex); } if ($this->settings[$p . 'ltype']) { $settings[$this->settings[$p . 'short'] . '_desc'] = array('p', $this->settings[$p . 'name']); $settings[$this->settings[$p . 'short']] = array('hidden', null, 'mi_' . $this->id . '_' . $this->settings[$p . 'short']); foreach ($fields as $id => $field) { if (!empty($field[1])) { $settings[$this->settings[$p . 'short'] . $id] = array('radio', 'mi_' . $this->id . '_' . $this->settings[$p . 'short'], trim($field[0]), true, trim($field[1])); } } continue; } else { $options = array(); foreach ($fields as $field) { if (!empty($field[1])) { $options[] = JHTML::_('select.option', trim($field[0]), trim($field[1])); } } $lists[$this->settings[$p . 'short']] = JHTML::_('select.genericlist', $options, $this->settings[$p . 'short'], 'size="1"', 'value', 'text', 0); } } if (!empty($this->settings[$p . 'mandatory'])) { $settings['validation']['rules'][$this->settings[$p . 'short']] = array('required' => true); } if ($this->settings[$p . 'type'] == 'list_language') { $lists[$this->settings[$p . 'short']] = JHTML::_('select.genericlist', $language_code_list, $this->settings[$p . 'short'], 'size="10"', 'value', 'text', $content); $this->settings[$p . 'type'] = 'list'; } if (!empty($this->settings[$p . 'formatting'])) { $settings['formatting'][] = array('id' => 'mi_' . $this->id . '_' . $this->settings[$p . 'short'], 'pattern' => $this->settings[$p . 'formatting']); } if ($this->settings[$p . 'type'] == 'checkbox') { $settings[$this->settings[$p . 'short']] = array($this->settings[$p . 'type'], $this->settings[$p . 'name'], $this->settings[$p . 'desc'], $content, $this->settings[$p . 'default']); } elseif ($this->settings[$p . 'type'] == 'list') { $settings[$this->settings[$p . 'short']] = array($this->settings[$p . 'type'], $this->settings[$p . 'name'], $this->settings[$p . 'name'], 'mi_' . $this->id . '_' . $this->settings[$p . 'short']); } else { $settings[$this->settings[$p . 'short']] = array($this->settings[$p . 'type'], $this->settings[$p . 'name'], $this->settings[$p . 'name'], $content); } if (!empty($this->settings[$p . 'validationtype'])) { $settings['validation']['rules'][$this->settings[$p . 'short']] = array(); foreach ($this->settings[$p . 'validationtype'] as $vtype) { $settings['validation']['rules'][$this->settings[$p . 'short']][$vtype] = true; } } } } } if ($useredit) { $unset = array('validation', 'username'); foreach ($unset as $k) { if (isset($settings[$k])) { unset($settings[$k]); } } $pref = 'mi_' . $this->id . '_'; foreach ($settings as $k => $v) { $settings[$pref . $k] = $v; unset($settings[$k]); } } if (!empty($lists)) { $settings['lists'] = $lists; } return $settings; }
function export($type, $cmd = null) { $db = JFactory::getDBO(); $cmd_save = strcmp('save', $cmd) === 0; $cmd_apply = strcmp('apply', $cmd) === 0; $cmd_load = strcmp('load', $cmd) === 0; $cmd_export = strcmp('export', $cmd) === 0; $use_original = 0; $system_values = array(); $filter_values = array(); $options_values = array(); $params_values = array(); if ($type == 'sales') { $getpost = array('system' => array('selected_export', 'delete', 'save', 'save_name'), 'filter' => array('date_start', 'date_end', 'method', 'planid', 'groupid', 'status', 'orderby'), 'options' => array('collate', 'breakdown', 'breakdown_custom'), 'params' => array('export_method')); $pf = 8; } else { $getpost = array('system' => array('selected_export', 'delete', 'save', 'save_name'), 'filter' => array('planid', 'groupid', 'status', 'orderby'), 'options' => array('rewrite_rule'), 'params' => array('export_method')); $pf = 5; } $postfields = 0; foreach ($getpost as $name => $array) { $field = $name . '_values'; foreach ($array as $vname) { $vvalue = aecGetParam($vname, ''); if (!empty($vvalue)) { ${$field}[$vname] = $vvalue; $postfields++; } } } if (!empty($params_values['export_method'])) { $is_test = $params_values['export_method'] == 'test'; } else { $is_test = false; } $lists = array(); $pname = ""; if (!empty($system_values['selected_export']) || $cmd_save || $cmd_apply || $is_test) { $row = new aecExport($type == 'sales'); if (isset($system_values['selected_export'])) { $row->load($system_values['selected_export']); $pname = $row->name; } else { $row->load(0); } if (!empty($system_values['delete'])) { // User wants to delete the entry $row->delete(); } elseif (($cmd_save || $cmd_apply) && (!empty($system_values['selected_export']) || !empty($system_values['save_name']))) { // User wants to save an entry if (!empty($system_values['save'])) { // But as a copy of another entry $row->load(0); } $row->saveComplex($system_values['save_name'], $filter_values, $options_values, $params_values); if (!empty($system_values['save'])) { $system_values['selected_export'] = $row->getMax(); } } elseif (($cmd_save || $cmd_apply) && (empty($system_values['selected_export']) && !empty($system_values['save_name']) && $system_values['save']) && !$is_test) { // User wants to save a new entry $row->saveComplex($system_values['save_name'], $filter_values, $options_values, $params_values); } elseif ($cmd_load || count($postfields) && $postfields <= $pf && ($cmd_export || $is_test)) { if ($row->id) { // User wants to load an entry $filter_values = $row->filter; $options_values = $row->options; $params_values = $row->params; $pname = $row->name; $use_original = 1; } } } // Always store the last ten calls, but only if something is happening if ($cmd_save || $cmd_apply || $cmd_export) { $autorow = new aecExport($type == 'sales'); $autorow->load(0); $autorow->saveComplex('Autosave', $filter_values, $options_values, $params_values, true); if (isset($row)) { if ($autorow->filter == $row->filter && $autorow->options == $row->options && $autorow->params == $row->params) { $use_original = 1; } } } $filters = array('planid', 'groupid', 'status'); foreach ($filters as $filter) { if (!isset($filter_values[$filter])) { $filter_values[$filter] = array(); continue; } if (!is_array($filter_values[$filter])) { if (!empty($filter_values[$filter])) { $filter_values[$filter] = array($filter_values[$filter]); } else { $filter_values[$filter] = array(); } } } if ($is_test) { $row->params['export_method'] = 'test'; } // Create Parameters $params[] = array('userinfobox', 5); if ($type == 'members') { $params[] = array('section_paper', 'Compose Export'); $params['params_remap'] = array('subarea_change', 'params'); $params[] = array('div', '<div class="alert alert-info">'); $params[] = array('p', '<p>Take users that fit these criteria:</p>'); $params['groupid'] = array('list', ''); $params['planid'] = array('list', ''); $params['status'] = array('list', ''); $params[] = array('div_end', ''); $params[] = array('div', '<div class="alert alert-warning">'); $params[] = array('p', '<p>Order them like this:</p>'); $params['orderby'] = array('list', ''); $params[] = array('div_end', ''); $params[] = array('div', '<div class="alert alert-success">'); $params[] = array('p', '<p>And use these details for each line of the export:</p>'); $params['rewrite_rule'] = array('inputD', '[[user_id]];[[user_username]];[[subscription_expiration_date]]'); $params[] = array('div_end', ''); $params[] = array('section_end', ''); } else { $monthago = (int) gmdate('U') - 60 * 60 * 24 * 31; $params[] = array('section_paper', 'Compose Export'); $params['params_remap'] = array('subarea_change', 'params'); $params[] = array('div', '<div class="alert alert-info">'); $params[] = array('p', '<p>Collect Sales Data from this range:</p>'); $params['date_start'] = array('list_date', date('Y-m-d', $monthago)); $params['date_end'] = array('list_date', date('Y-m-d')); $params['method'] = array('list', ''); $params['planid'] = array('list', ''); $params['groupid'] = array('list', ''); $params[] = array('div_end', ''); $params[] = array('div', '<div class="alert alert-warning">'); $params[] = array('p', '<p>Collate it like this:</p>'); $params['collate'] = array('list', 'day'); $params[] = array('div_end', ''); $params[] = array('div', '<div class="alert alert-success">'); $params[] = array('p', '<p>Break down the data in each line like so:</p>'); $params['breakdown'] = array('list', 'month'); $params['breakdown_custom'] = array('inputD', ''); $params[] = array('div_end', ''); $params[] = array('section_end', ''); } if ($type == 'members') { $params[] = array('userinfobox', 5); $params[] = array('section_paper'); $rewriteswitches = array('cms', 'user', 'subscription', 'plan', 'invoice'); $params = AECToolbox::rewriteEngineInfo($rewriteswitches, $params); $params[] = array('section_end', ''); $params[] = array('2div_end', ''); } $params[] = array('2div_end', ''); $params[] = array('userinfobox', 5); $params[] = array('section_paper', 'Save or Load Export Presets'); $params[] = array('div', '<div class="form-wide">'); $params['selected_export'] = array('list', ''); $params['delete'] = array('checkbox'); $params['save'] = array('checkbox'); $params['save_name'] = array('inputC', $pname); $params[] = array('div_end', ''); $params[] = array('div', '<div class="right-btns">'); $params[] = array('p', '<a class="btn btn-primary" onclick="javascript: submitbutton(\'loadExport' . $type . '\')" href="#">' . aecHTML::Icon('upload') . ' Load Preset</a>'); $params[] = array('p', '<a class="btn btn-success" onclick="javascript: submitbutton(\'applyExport' . $type . '\')" href="#">' . aecHTML::Icon('download') . ' Save Preset</a>'); $params[] = array('p', '<a class="btn danger" onclick="javascript: submitbutton(\'saveExport' . $type . '\')" href="#">' . aecHTML::Icon('download-alt') . ' Save Preset & Exit</a>'); $params[] = array('div_end', ''); $params[] = array('section_end', ''); $params[] = array('2div_end', ''); $params[] = array('userinfobox', 5); $params[] = array('section_paper', 'Export'); $params['export_method'] = array('list', ''); $params[] = array('p', '<div class="right-btns"><div class="btn-group">'); $params[] = array('p', '<a class="btn btn-info" id="testexport" href="#export-result">' . aecHTML::Icon('eye-open') . ' Test Export</a>'); $params[] = array('p', '<a class="btn btn-success" onclick="javascript: submitbutton(\'exportExport' . $type . '\')" href="#">' . aecHTML::Icon('file') . ' Export Now</a>'); $params[] = array('2div_end', ''); $params[] = array('section_end', ''); $params[] = array('2div_end', ''); $params[] = array('userinfobox', 5); $params[] = array('div', '<div class="aec-settings-container" id="export-result">'); $params[] = array('h4', '<h4>Preview</h4>'); $params[] = array('2div_end', ''); // Create a list of export options // First, only the non-autosaved entries $query = 'SELECT `id`, `name`, `created_date`, `lastused_date`' . ' FROM #__acctexp_export' . ($type == 'sales' ? '_sales' : '') . ' WHERE `system` = \''; $db->setQuery($query . '0\''); $user_exports = $db->loadObjectList(); // Then the autosaved entries $db->setQuery($query . '1\''); $system_exports = $db->loadObjectList(); $entries = count($user_exports) + count($system_exports); $m = 0; if ($entries > 0) { $listitems = array(); $listitems[] = JHTML::_('select.option', 0, " --- Your Exports --- "); $user = false; for ($i = 0; $i < $entries; $i++) { if ($i >= count($user_exports) && $user === false) { $user = $i; $listitems[] = JHTML::_('select.option', 0, " --- Autosaves --- "); } if ($user === false) { if (!empty($user_exports[$i]->name)) { $used_date = $user_exports[$i]->lastused_date == '0000-00-00 00:00:00' ? 'never' : $user_exports[$i]->lastused_date; $listitems[] = JHTML::_('select.option', $user_exports[$i]->id, substr($user_exports[$i]->name, 0, 64) . ' - ' . 'last used: ' . $used_date . ', created: ' . $user_exports[$i]->created_date); } else { $m--; } } else { $ix = $i - $user; $used_date = $system_exports[$ix]->lastused_date == '0000-00-00 00:00:00' ? 'never' : $system_exports[$ix]->lastused_date; $listitems[] = JHTML::_('select.option', $system_exports[$ix]->id, substr($system_exports[$ix]->name, 0, 64) . ' - ' . 'last used: ' . $used_date . ', created: ' . $system_exports[$ix]->created_date); } } } else { $listitems[] = JHTML::_('select.option', 0, " --- No saved Preset available --- "); $listitems[] = JHTML::_('select.option', 0, " --- Your Exports --- ", 'value', 'text', true); $listitems[] = JHTML::_('select.option', 0, " --- Autosaves --- ", 'value', 'text', true); } $lists['selected_export'] = JHTML::_('select.genericlist', $listitems, 'selected_export', 'size="' . max(10, min(20, $entries + $m + 2)) . '" class="col-sm-7"', 'value', 'text', arrayValueDefault($system_values, 'selected_export', '')); // Get list of plans for filter $query = 'SELECT `id`, `name`' . ' FROM #__acctexp_plans' . ' ORDER BY `ordering`'; $db->setQuery($query); $db_plans = $db->loadObjectList(); $lists['planid'] = '<select id="plan-filter-select" class="col-sm-3" name="planid[]" multiple="multiple" size="5">'; foreach ($db_plans as $plan) { $lists['planid'] .= '<option value="' . $plan->id . '"' . (in_array($plan->id, $filter_values['planid']) ? ' selected="selected"' : '') . '>' . $plan->name . '</option>'; } $lists['planid'] .= '</select>'; $grouplist = ItemGroupHandler::getTree(); $lists['groupid'] = '<select id="group-filter-select" class="col-sm-3" name="groupid[]" multiple="multiple" size="5">'; foreach ($grouplist as $glisti) { if (defined('JPATH_MANIFESTS')) { $lists['groupid'] .= '<option value="' . $glisti[0] . '"' . (in_array($glisti[0], $filter_values['groupid']) ? ' selected="selected"' : '') . '>' . str_replace(' ', ' ', $glisti[1]) . '</option>'; } else { $lists['groupid'] .= '<option value="' . $glisti[0] . '"' . (in_array($glisti[0], $filter_values['groupid']) ? ' selected="selected"' : '') . '>' . $glisti[1] . '</option>'; } } $lists['groupid'] .= '</select>'; if ($type == 'members') { $status = array('excluded' => JText::_('AEC_SEL_EXCLUDED'), 'pending' => JText::_('AEC_SEL_PENDING'), 'active' => JText::_('AEC_SEL_ACTIVE'), 'expired' => JText::_('AEC_SEL_EXPIRED'), 'closed' => JText::_('AEC_SEL_CLOSED'), 'cancelled' => JText::_('AEC_SEL_CANCELLED'), 'hold' => JText::_('AEC_SEL_HOLD'), 'notconfig' => JText::_('AEC_SEL_NOT_CONFIGURED')); $lists['status'] = '<select id="status-group-select" name="status[]" multiple="multiple" size="5">'; foreach ($status as $id => $txt) { $lists['status'] .= '<option value="' . $id . '"' . (in_array($id, $filter_values['status']) ? ' selected="selected"' : '') . '>' . $txt . '</option>'; } $lists['status'] .= '</select>'; // Ordering $sel = array(); $sel[] = JHTML::_('select.option', 'expiration ASC', JText::_('EXP_ASC')); $sel[] = JHTML::_('select.option', 'expiration DESC', JText::_('EXP_DESC')); $sel[] = JHTML::_('select.option', 'name ASC', JText::_('NAME_ASC')); $sel[] = JHTML::_('select.option', 'name DESC', JText::_('NAME_DESC')); $sel[] = JHTML::_('select.option', 'username ASC', JText::_('LOGIN_ASC')); $sel[] = JHTML::_('select.option', 'username DESC', JText::_('LOGIN_DESC')); $sel[] = JHTML::_('select.option', 'signup_date ASC', JText::_('SIGNUP_ASC')); $sel[] = JHTML::_('select.option', 'signup_date DESC', JText::_('SIGNUP_DESC')); $sel[] = JHTML::_('select.option', 'lastpay_date ASC', JText::_('LASTPAY_ASC')); $sel[] = JHTML::_('select.option', 'lastpay_date DESC', JText::_('LASTPAY_DESC')); $sel[] = JHTML::_('select.option', 'plan_name ASC', JText::_('PLAN_ASC')); $sel[] = JHTML::_('select.option', 'plan_name DESC', JText::_('PLAN_DESC')); $sel[] = JHTML::_('select.option', 'status ASC', JText::_('STATUS_ASC')); $sel[] = JHTML::_('select.option', 'status DESC', JText::_('STATUS_DESC')); $sel[] = JHTML::_('select.option', 'type ASC', JText::_('TYPE_ASC')); $sel[] = JHTML::_('select.option', 'type DESC', JText::_('TYPE_DESC')); $lists['orderby'] = JHTML::_('select.genericlist', $sel, 'orderby', 'class="inputbox" size="1"', 'value', 'text', arrayValueDefault($filter_values, 'orderby', '')); } else { $collate_selection = array(); $collate_selection[] = JHTML::_('select.option', 'day', JText::_('Day')); $collate_selection[] = JHTML::_('select.option', 'week', JText::_('Week')); $collate_selection[] = JHTML::_('select.option', 'month', JText::_('Month')); $collate_selection[] = JHTML::_('select.option', 'year', JText::_('Year')); $selected_collate = 0; if (!empty($options_values['collate'])) { $selected_collate = $options_values['collate']; } else { $selected_collate = 'day'; } $lists['collate'] = JHTML::_('select.genericlist', $collate_selection, 'collate', 'size="1"', 'value', 'text', $selected_collate); $breakdown_selection = array(); $breakdown_selection[] = JHTML::_('select.option', '0', JText::_('None')); $breakdown_selection[] = JHTML::_('select.option', 'plan', JText::_('Plan')); $breakdown_selection[] = JHTML::_('select.option', 'group', JText::_('Group')); $selected_breakdown = 0; if (!empty($options_values['breakdown'])) { $selected_breakdown = $options_values['breakdown']; } $lists['breakdown'] = JHTML::_('select.genericlist', $breakdown_selection, 'breakdown', 'size="1"', 'value', 'text', $selected_breakdown); $processors = PaymentProcessorHandler::getInstalledObjectList(); $proc_list = array(); $selected_proc = array(); foreach ($processors as $proc) { $pp = new PaymentProcessor(); $pp->loadName($proc->name); $pp->getInfo(); $proc_list[] = JHTML::_('select.option', $pp->id, $pp->info['longname']); if (!empty($filter_values['method'])) { foreach ($filter_values['method'] as $id) { if ($id == $pp->id) { $selected_proc[] = JHTML::_('select.option', $id, $pp->info['longname']); } } } } $lists['method'] = JHTML::_('select.genericlist', $proc_list, 'method[]', 'size="8" multiple="multiple"', 'value', 'text', $selected_proc); } // Export Method $list = xJUtility::getFileArray(JPATH_SITE . '/components/com_acctexp/lib/export', 'php', false, true); $sel = array(); foreach ($list as $ltype) { $ltype = str_replace('.php', '', $ltype); if ($ltype != 'test') { $sel[] = JHTML::_('select.option', $ltype, $ltype); } } if (empty($params_values['export_method'])) { $params_values['export_method'] = 'csv'; } $lists['export_method'] = JHTML::_('select.genericlist', $sel, 'export_method', 'class="inputbox" size="1"', 'value', 'text', $params_values['export_method']); $settings = new aecSettings('export', 'general'); // Repackage the objects as array foreach ($getpost as $name => $array) { $field = $name . '_values'; foreach ($array as $vname) { if (!empty(${$field}->{$name})) { $settingsparams[$name] = ${$field}->{$name}; } else { $settingsparams[$name] = ""; } } } if (empty($params_values['rewrite_rule'])) { //$params_values['rewrite_rule'] = '[[user_id]];[[user_username]];[[subscription_expiration_date]]'; } $settingsparams = array_merge($filter_values, $options_values, $params_values); $settings->fullSettingsArray($params, $settingsparams, $lists); // Call HTML Class $aecHTML = new aecHTML($settings->settings, $settings->lists); if ($cmd_export && !empty($params_values['export_method'])) { if ($use_original) { $row->useExport(); } else { $autorow->useExport(); } } if ($cmd_save) { aecRedirect('index.php?option=com_acctexp&task=showCentral'); } else { HTML_AcctExp::export($type, $aecHTML); } }
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.'; } }
/** * @param string $view */ function getView($view, $args = null) { global $aecConfig; $db = JFactory::getDBO(); $user = JFactory::getUser(); $metaUser = null; if ($user->id) { $userid = $user->id; $metaUser = new metaUser($user->id); } else { $userid = aecGetParam('userid', 0, true, array('word', 'int')); $metaUser = new metaUser($userid); } $app = JFactory::getApplication(); $option = 'com_acctexp'; $dbtmpl = new configTemplate(); $dbtmpl->loadDefault(); $tmpl = $dbtmpl->template; if (!empty($dbtmpl->settings)) { $tmpl->cfg = array_merge($aecConfig->cfg, $dbtmpl->settings); } else { $tmpl->cfg = $aecConfig->cfg; } $tmpl->option = 'com_acctexp'; $tmpl->metaUser = $metaUser; if (strpos(JPATH_BASE, '/administrator')) { if (defined('JPATH_MANIFESTS')) { $query = 'SELECT `template`' . ' FROM #__template_styles' . ' WHERE `home` = 1 AND `client_id` = 0'; $db->setQuery($query); $tmpl->system_template = $db->loadResult(); } else { $query = 'SELECT `template`' . ' FROM #__templates_menu' . ' WHERE `menu_id` = 0 AND `client_id` = 0'; $db->setQuery($query); $tmpl->system_template = $db->loadResult(); } } else { $tmpl->system_template = $app->getTemplate(); } $tmpl->template = $dbtmpl->name; $tmpl->view = $view; $tmpl->paths['base'] = JPATH_SITE . '/components/com_acctexp/tmpl'; $tmpl->paths = array('default' => $tmpl->paths['base'] . '/default', 'current' => $tmpl->paths['base'] . '/' . $tmpl->template, 'site' => JPATH_SITE . '/templates/' . $tmpl->system_template . '/html/com_acctexp'); $hphp = '/' . $view . '/html.php'; $tphp = '/' . $view . '/tmpl/' . $view . '.php'; if (!empty($args)) { foreach ($args as $n => $v) { ${$n} = $v; } } if (file_exists($tmpl->paths['site'] . $hphp)) { include $tmpl->paths['site'] . $hphp; } elseif (file_exists($tmpl->paths['current'] . $hphp)) { include $tmpl->paths['current'] . $hphp; } elseif (file_exists($tmpl->paths['default'] . $hphp)) { include $tmpl->paths['default'] . $hphp; } elseif (file_exists($tmpl->paths['site'] . $tphp)) { include $tmpl->paths['site'] . $tphp; } elseif (file_exists($tmpl->paths['current'] . $tphp)) { include $tmpl->paths['current'] . $tphp; } elseif (file_exists($tmpl->paths['default'] . $tphp)) { include $tmpl->paths['default'] . $tphp; } return true; }
<?php /** * @version $Id: eucalib.admin.proxy.php * @package AEC - Account Control Expiration - Membership Manager * @subpackage Admin Proxy to relay to subtask files * @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 * * _ _ _ * | (_) | * ___ _ _ ___ __ _| |_| |__ * / _ \ | | |/ __/ _` | | | '_ \ * | __/ |_| | (_| (_| | | | |_) | * \___|\__,_|\___\__,_|_|_|_.__/ v1.0 * * The Extremely Useful Component LIBrary will rock your socks. Seriously. Reuse it! */ defined('_JEXEC') or die('Restricted access'); $task = trim(aecGetParam($_REQUEST, 'task', null)); $returntask = trim(aecGetParam($_REQUEST, 'returntask', null)); resolveProxy($task, $returntask, true);
public function onAfterRoute() { if (strpos(JPATH_BASE, '/administrator')) { // Don't act when on backend return true; } $vars = $this->getVars(); // Make sure we need to make a call at all if (!($vars['j_reg'] || $vars['k2_regsv'] || $vars['ccb'] || $vars['joms'] || $vars['alpha'] || $vars['aec'])) { return true; } $vars = $this->getAdditionalVars($vars); if (($vars['isreg'] || $vars['cb_sregsv'] || $vars['k2_regsv'] || $vars['alpha_regsv']) && $vars['int_reg']) { // Joomla or CB registration... if ($vars['pfirst'] && !$vars['has_usage']) { // Plans first and not yet selected -> select! $this->deleteToken(); $app = JFactory::getApplication(); $app->redirect(AECToolbox::deadsureURL('index.php?option=com_acctexp&task=subscribe', false, true)); } elseif (!$vars['pfirst'] && $vars['joms_regs'] && !$vars['has_user'] && !$vars['has_usage']) { $this->redirectToken(); } elseif ($vars['has_user'] && $vars['joms_regs']) { $this->redirectToken(); } elseif ($vars['has_user'] && ($vars['alpha_regsv'] || $vars['joms_regsv'] || $vars['cb_sregsv'] || $vars['k2_regsv'])) { if ($vars['joms_regsv']) { $name = aecGetParam('jsname', "", true, array('string', 'clear_nonalnum')); $username = aecGetParam('jsusername', "", true, array('string', 'clear_nonalnumwhitespace')); $password = aecGetParam('jspassword', "", true, array('string')); $password2 = aecGetParam('jspassword2', "", true, array('string')); $email = aecGetParam('jsemail', "", true, array('string', 'clear_nonemail')); } else { $name = aecGetParam('name', "", true, array('string', 'clear_nonalnum')); $username = aecGetParam('username', "", true, array('string', 'clear_nonalnumwhitespace')); $password = aecGetParam('password', "", true, array('string')); $password2 = aecGetParam('password2', "", true, array('string')); if (empty($password2)) { $password2 = aecGetParam('password__verify', "", true, array('string')); } $email = aecGetParam('email', "", true, array('string', 'clear_nonemail')); if (empty($username)) { $name = aecEscape($_REQUEST['jform']['name'], array('string', 'clear_nonalnum')); $username = aecEscape($_REQUEST['jform']['username'], array('string', 'clear_nonalnum')); $password = aecEscape($_REQUEST['jform']['password1'], array('string', 'clear_nonalnum')); $password2 = aecEscape($_REQUEST['jform']['password2'], array('string', 'clear_nonalnum')); if (empty($password2)) { $password2 = aecEscape($_REQUEST['jform']['password__verify'], array('string', 'clear_nonalnum')); } $email = aecEscape($_REQUEST['jform']['email1'], array('string', 'clear_nonalnum')); } } if (!empty($username) && !empty($password) && !empty($email)) { $temptoken = new aecTempToken(); $temptoken->getComposite(); $skip = array('coupon_code', 'task', 'option'); foreach ($_POST as $k => $v) { if (!in_array($k, $skip)) { $temptoken->content[$k] = aecGetParam($k, "", true, array('string')); } } $temptoken->content['name'] = $name; $temptoken->content['username'] = $username; $temptoken->content['password'] = $password; $temptoken->content['password2'] = $password2; $temptoken->content['email'] = $email; if ($vars['k2_regsv']) { $temptoken->content['handler'] = 'k2'; } elseif ($vars['joms_regsv']) { $temptoken->content['handler'] = 'jomsocial'; } elseif ($vars['cb_sregsv']) { $temptoken->content['handler'] = 'cb'; } $temptoken->storeload(); if ($vars['cb_sregsv'] || $vars['k2_regsv']) { $this->redirectToken(); } } if ($vars['alpha_regsv']) { $this->redirectToken(); } } elseif ($vars['has_usage']) { $existing = $this->saveToToken($vars); if ($vars['joms_reg'] && !$existing) { // I have... seen things you people wouldn't believe // Logic on fire on the shore of JomSocial $uri = JFactory::getURI(); $app = JFactory::getApplication(); $app->redirect($uri->toString()); } } } elseif ($vars['has_usage'] && !$vars['checkout']) { $this->saveToToken($vars); } elseif ($vars['cbsreg']) { // Any kind of user profile edit = trigger MIs $row = new stdClass(); $row->username = $vars['username']; $mih = new microIntegrationHandler(); $mih->userchange($row, $_POST, 'registration'); } }
public function checkout($repeat = 0, $error = null, $coupon = null) { global $aecConfig; if (!$this->checkAuth()) { return false; } $this->puffer(); $this->touchInvoice(false, true); if ($this->invoice->method != $this->processor) { $this->invoice->method = $this->processor; $this->invoice->storeload(); } // Delete TempToken - the data is now safe with the invoice $temptoken = new aecTempToken(); $temptoken->getComposite(); if ($temptoken->id) { $temptoken->delete(); } if (!empty($coupon)) { $this->InvoiceAddCoupon($coupon); } $user_ident = aecGetParam('user_ident', 0, true, array('string', 'clear_nonemail')); if (!empty($user_ident) && !empty($this->invoice->id)) { if ($this->invoice->addTargetUser(strtolower($user_ident))) { $this->invoice->storeload(); } } $repeat = empty($repeat) ? 0 : $repeat; $exceptproc = array('none', 'free'); $recurring = false; if (!in_array(strtolower($this->processor), $exceptproc)) { if (is_object($this->pp)) { if (isset($this->invoice->params['userselect_recurring'])) { $recurring_choice = $this->invoice->params['userselect_recurring']; } else { $recurring_choice = null; } $recurring = $this->pp->is_recurring($recurring_choice); } } // If this is marked as supposedly free if (in_array(strtolower($this->processor), $exceptproc) && !empty($this->plan)) { // Double Check Amount for made_free $this->invoice->computeAmount($this); if (!empty($this->invoice->made_free) || $this->plan->params['full_free'] && empty($this->invoice->counter) && empty($this->plan->params['trial_period']) || $this->plan->params['full_free'] && $this->invoice->counter || $this->plan->params['trial_free'] && empty($this->invoice->counter)) { // Only allow clearing while recurring if everything is free if (!($recurring && (empty($this->plan->params['full_free']) || empty($this->plan->params['trial_free'])))) { // mark paid if ($this->invoice->pay() !== false) { return $this->thanks(false, true); } } } return getView('access_denied'); } elseif (in_array(strtolower($this->processor), $exceptproc)) { if (!empty($this->invoice->made_free)) { // mark paid if ($this->invoice->pay() !== false) { return $this->thanks(false, true); } } return getView('access_denied'); } elseif (strcmp(strtolower($this->processor), 'error') === 0) { // Nope, won't work buddy return getView('access_denied'); } if (!empty($this->pp)) { if ($this->pp->requireSSLcheckout() && empty($_SERVER['HTTPS']) && !$aecConfig->cfg['override_reqssl']) { aecRedirect(AECToolbox::deadsureURL("index.php?option=com_acctexp&task=repeatPayment&invoice=" . $this->invoice->invoice_number . "&first=" . ($repeat ? 0 : 1) . '&' . xJ::token() . '=1', true, true)); exit; } } $this->loadItems(); $this->loadItemTotal(); $exchange = $silent = null; $this->triggerMIs('invoice_items_checkout', $exchange, $this->items, $silent); // Either this is fully free, or the next term is free and this is non recurring if (!empty($this->items->grand_total) && !$recurring) { if ($this->items->grand_total->isFree() && !$recurring) { $this->invoice->pay(); return $this->thanks(false, true); } } return $this->InvoiceToCheckout($repeat, $error); }
public function validateNotification($response, $post, $invoice) { require_once dirname(__FILE__) . '/lib/cls.ideal.php'; $response = array(); $response['valid'] = false; $transaction_id = aecGetParam('transaction_id', '', true, array('word', 'string', 'clear_nonalnum')); if (strlen($transaction_id)) { $mollieIdeal = new iDEAL_Payment($this->settings['partner_id']); $mollieIdeal->checkPayment($transaction_id); if ($mollieIdeal->getPaidStatus()) { $response['valid'] = true; } else { // error handling $response['error'] = true; $response['errormsg'] = 'iDEAL_Payment::checkPayment failed'; $this->___logError("iDEAL_Payment::checkPayment failed", $mollieIdeal->getErrorCode(), $mollieIdeal->getErrorMessage()); } } return $response; }
function InvoiceRemoveCoupon($option) { $invoice = aecGetParam('invoice', 0, true, array('word', 'string', 'clear_nonalnum')); $coupon_code = aecGetParam('coupon_code', 0, true, array('word', 'string', 'clear_nonalnum')); $objinvoice = new Invoice(); $objinvoice->loadInvoiceNumber($invoice); $objinvoice->removeCoupon($coupon_code); $objinvoice->computeAmount(); repeatInvoice($option, $invoice, null, $objinvoice->userid); }
public function parseNotification($post) { $db = JFactory::getDBO(); $response = array(); $response['valid'] = false; $response['invoice'] = aecGetParam('Invoice'); $allowed = array('83.241.130.100', '83.241.130.101', '10.4.49.11', '192.168.100.222', '127.0.0.1', '217.151.207.84', '83.241.130.102'); if (in_array($_SERVER["REMOTE_ADDR"], $allowed)) { $requesturl = ($_SERVER["SERVER_PORT"] == "80" ? "http://" : "https://") . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; $strippedUrl = substr($requesturl, 0, strpos($requesturl, "&md5sum")); $md5 = strtolower(md5($this->settings['key1'] . $strippedUrl . $this->settings['key2'])); if (strpos(strtolower($requesturl), $md5) >= 7) { if (aecGetParam('action') == 'authenticate') { $response['pending'] = 1; $response['pending_reason'] = 'authentication'; } elseif (aecGetParam('action') == 'settle') { $response['valid'] = 1; } } } return $response; }
public function prefilter($items, $cart = false, $fullcart = false) { if (empty($this->coupons)) { return null; } foreach ($this->coupons as $ccid => $coupon_code) { if (!$this->loadCoupon($coupon_code)) { continue; } if ($this->cph->coupon->restrictions['usage_cart_full']) { if (!in_array($coupon_code, $this->fullcartlist)) { $this->fullcartlist[] = $coupon_code; if (!empty($cart)) { if (!$cart->hasCoupon($coupon_code)) { $cart->addCoupon($coupon_code); $cart->storeload(); $this->affectedCart = true; } } continue; } } if (empty($cart) && empty($fullcart)) { return null; } $plans = $cart->getItemIdArray(); if ($this->cph->coupon->restrictions['usage_plans_enabled']) { $allowed = array_intersect($plans, $this->cph->coupon->restrictions['usage_plans']); if (empty($allowed)) { $allowed = false; } } else { $allowed = $plans; } foreach ($cart->content as $iid => $c) { if ($cart->hasCoupon($coupon_code, $iid)) { continue 2; } } if (!is_array($allowed)) { continue; } $fname = 'cartcoupon_' . $ccid . '_item'; $pgsel = aecGetParam($fname, null, true, array('word', 'int')); if (count($allowed) == 1) { $min = array_shift(array_keys($allowed)); foreach ($items as $iid => $item) { if ($item['obj']->id == $allowed[$min]) { $pgsel = $iid; } } } if (!is_null($pgsel)) { $items[$pgsel] = $this->applyToItem($pgsel, $items[$pgsel], $coupon_code); if (!$cart->hasCoupon($coupon_code, $pgsel)) { $cart->addCoupon($coupon_code, $pgsel); $cart->storeload(); $this->affectedCart = true; } } else { $found = false; foreach ($cart->content as $cid => $content) { if ($cart->hasCoupon($coupon_code, $cid)) { $items[$cid] = $this->applyToItem($cid, $items[$cid], $coupon_code); $found = true; $this->noapplylist[] = $coupon_code; } } if (!$found) { $ex = array(); $ex['head'] = "Select Item for Coupon \"" . $coupon_code . "\""; $ex['desc'] = "The coupon you have entered can be applied to one of the following items:<br />"; $ex['rows'] = array(); foreach ($allowed as $cid => $objid) { if (empty($fullcart[$cid]['free'])) { $ex['rows'][] = array('radio', $fname, $cid, true, $fullcart[$cid]['name']); } } if (!empty($ex['rows'])) { $this->raiseException($ex); } } } } }
function aecPostParamClear($array, $safe = false, $safe_params = array('string', 'badchars')) { $cleararray = array(); foreach ($array as $key => $value) { $cleararray[$key] = aecGetParam($key, $safe, $safe_params); } return $cleararray; }