Exemple #1
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;
 }
Exemple #2
0
 public function Settings()
 {
     $db = JFactory::getDBO();
     $settings = array();
     if (!empty($_POST['type']) && !empty($_POST['id']) && empty($_POST['edit'])) {
         $db = JFactory::getDBO();
         $settings['edit'] = array('hidden', 1);
         $settings['type'] = array('hidden', $_POST['type']);
         $fixed = array();
         switch ($_POST['type']) {
             case 'metauser':
                 $fixed = array('userid');
                 $object = new metaUserDB();
                 $s = AECToolbox::searchUser($_POST['id']);
                 if (!empty($s)) {
                     $_POST['id'] = $object->getIDbyUserid($s[0]);
                 } else {
                     $_POST['id'] = $object->getIDbyUserid((int) $_POST['id']);
                 }
                 break;
             case 'processor':
                 if (!is_numeric($_POST['id'])) {
                     $query = 'SELECT `id`' . ' FROM #__acctexp_config_processors' . ' WHERE `name` = \'' . (int) $_POST['id'] . '\'';
                     $db->setQuery($query);
                     $_POST['id'] = $db->loadResult();
                 }
                 $object = new processor();
                 break;
             case 'invoice':
                 if (!is_numeric($_POST['id'])) {
                     $_POST['id'] = aecInvoiceHelper::InvoiceIDfromNumber($_POST['id']);
                 }
                 $object = new Invoice();
                 break;
         }
         $object->load($_POST['id']);
         $vars = get_object_vars($object);
         $encoded = $object->declareParamFields();
         foreach ($vars as $k => $v) {
             if (is_null($k)) {
                 $k = "";
             }
             if ($k == 'id') {
                 $settings['id'] = array('hidden', $v);
             } elseif (in_array($k, $fixed)) {
                 $settings[$k] = array('p', $k, $k, $v);
             } elseif (in_array($k, $encoded)) {
                 $v = jsoonHandler::encode($v);
                 if ($v === "null") {
                     $v = "";
                 }
                 $settings[$k] = array('inputD', $k, $k, $v);
             } elseif (strpos($k, '_') !== 0) {
                 $settings[$k] = array('inputD', $k, $k, $v);
             }
         }
     } else {
         $settings['type'] = array('list', 'Item Type', 'The type of Item you want to edit');
         $settings['id'] = array('inputC', 'Item ID', 'Identification for your Item');
         $types = array('metauser' => 'MetaUser Information', 'processor' => 'Payment Processor', 'invoice' => 'Invoice');
         $typelist = array();
         foreach ($types as $type => $typename) {
             $typelist[] = JHTML::_('select.option', $type, $typename);
         }
         $settings['lists']['type'] = JHTML::_('select.genericlist', $typelist, 'type', 'size="3"', 'value', 'text', array());
     }
     return $settings;
 }
Exemple #3
0
 public function Action()
 {
     if (empty($_POST['query'])) {
         return null;
     }
     $db = JFactory::getDBO();
     $query = trim(aecGetParam('query', 0));
     if (strpos($query, 'supercommand:') !== false) {
         $supercommand = new aecSuperCommand();
         if ($supercommand->parseString($query)) {
             if (strpos($query, '!') === 0) {
                 $armed = true;
             } else {
                 $armed = false;
             }
             $return = $supercommand->query($armed);
             if ($return > 1) {
                 $multiple = true;
             } else {
                 $multiple = false;
             }
             if ($return != false && !$armed) {
                 $r = '<p>This supercommand would affect ' . $return . " user" . ($multiple ? "s" : "") . ". Add a ! in front of supercommand to carry out the command.</p>";
             } elseif ($return != false) {
                 $r = '<p>If you\'re so clever, you tell us what <strong>colour</strong> it should be!? (Everything went fine. Really! It affected ' . $return . " user" . ($multiple ? "s" : "") . ")</p>";
             } else {
                 $r = '<p>Something went wrong. No users found.</p>';
             }
             return $r;
         }
         return "I think you ought to know I'm feeling very depressed. (Something was wrong with your query.)";
     }
     if (strpos($query, 'jsonserialencode') === 0) {
         $s = trim(substr($query, 16));
         if (!empty($s)) {
             $return = base64_encode(serialize(jsoonHandler::decode($s)));
             return '<p>' . $return . '</p>';
         }
     }
     if (strpos($query, 'serialdecodejson') === 0) {
         $s = trim(substr($query, 16));
         if (!empty($s)) {
             $return = jsoonHandler::encode(unserialize(base64_decode($s)));
             return '<p>' . $return . '</p>';
         }
     }
     if (strpos($query, 'serialdecode') === 0) {
         $s = trim(substr($query, 12));
         if (!empty($s)) {
             $return = unserialize(base64_decode($s));
             return '<p>' . obsafe_print_r($return, true, true) . '</p>';
         }
     }
     if (strpos($query, 'unserialize') === 0) {
         $s = trim(substr($query, 11));
         if (!empty($s)) {
             $return = unserialize($s);
             return '<p>' . obsafe_print_r($return, true, true) . '</p>';
         }
     }
     $maybe = array('?', '??', '???', '????', 'what to do', 'need strategy', 'help', 'help me', 'huh?', 'AAAAH!');
     if (in_array($query, $maybe)) {
         include_once JPATH_SITE . '/components/com_acctexp/lib/eucalib/eucalib.add.php';
         $ed = rand(1, 4);
         $edf = ${'edition_0' . $ed};
         $maxed = count(${'edition_0' . $ed});
         return $edf['quote_' . str_pad(rand(1, $maxed + 1), 2, '0')];
     }
     if (strpos($query, 'logthis:') === 0) {
         $eventlog = new eventLog();
         $eventlog->issue('debug', 'debug', 'debug entry: ' . str_replace('logthis:', '', $query), 128);
         return 'alright, logged.';
     }
 }