Пример #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;
 }
Пример #2
0
 public function encoder($input)
 {
     $output = $input;
     if (is_object($input)) {
         $classname = get_class($input);
         // Preserve Class information
         if ($classname != 'stdClass') {
             $output->_jsoon = new stdClass();
             $output->_jsoon->classname = $classname;
             // If parameters are advertised by the Class, cache them
             $function = $classname . '::declareJSONcalltimeparams()';
             if (is_callable($function)) {
                 $calltimeparams = $function();
                 if (isset($calltimeparams['parameters'])) {
                     $output->_jsoon->parameter = $calltimeparams['parameters'];
                 }
             }
         }
         $properties = get_object_vars($input);
         foreach ($properties as $pkey => $pvalue) {
             $output->{$pkey} = jsoonHandler::encoder($pvalue);
         }
     } elseif (is_array($input)) {
         // Check for relational array
         if (array_keys($input) !== range(0, count($input) - 1)) {
             $output = new stdClass();
             $output->_jsoon = new stdClass();
             $output->_jsoon->relational_array = true;
             foreach ($input as $key => $value) {
                 $output->{$key} = jsoonHandler::encoder($value);
             }
         } else {
             $output = array();
             foreach ($input as $key => $value) {
                 $output[$key] = jsoonHandler::encoder($value);
             }
         }
     }
     return $output;
 }
Пример #3
0
 public function Action()
 {
     if (empty($_POST['edit'])) {
         return null;
     }
     $db = JFactory::getDBO();
     switch ($_POST['type']) {
         case 'metauser':
             $object = new metaUserDB();
             break;
         case 'processor':
             $object = new processor();
             break;
         case 'invoice':
             $object = new Invoice();
             break;
     }
     $object->load($_POST['id']);
     if ($object->id != $_POST['id']) {
         return "<h3>Error - could not find item.</h3>";
     }
     $vars = get_object_vars($object);
     $encoded = $object->declareParamFields();
     foreach ($vars as $k => $v) {
         if (in_array($k, $encoded)) {
             if (get_magic_quotes_gpc()) {
                 $object->{$k} = jsoonHandler::decode(stripslashes($_POST[$k]));
             } else {
                 $object->{$k} = jsoonHandler::decode($_POST[$k]);
             }
         } elseif (strpos($k, '_') !== 0) {
             $object->{$k} = $_POST[$k];
         }
     }
     $object->check();
     if ($object->store()) {
         return "<h3>Success! Item updated.</h3>";
     } else {
         return "<h3>Error - could not store item.</h3>";
     }
 }
Пример #4
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.';
     }
 }
Пример #5
0
 $dec = $fielddeclare;
 foreach ($fielddeclare as $fieldname) {
     // No need to update what is empty
     if (empty($object->{$fieldname})) {
         unset($dec[array_search($fieldname, $dec)]);
     }
 }
 if (count($dec) < 1) {
     continue;
 }
 $sets = array();
 foreach ($dec as $fieldname) {
     // Decode from jsonized fields
     if (strpos($object->{$fieldname}, "{") === 0 || strpos($object->{$fieldname}, "\n") === false) {
         $decode = stripslashes(str_replace(array('\\n', '\\t', '\\r'), array("\n", "\t", "\r"), trim($object->{$fieldname})));
         $temp = jsoonHandler::decode($decode);
     } elseif (strpos($object->{$fieldname}, "\n") !== false) {
         // Has stripslashes stuff built in
         $temp = parameterHandler::decode($object->{$fieldname});
     } else {
         continue;
     }
     // ... to serialized
     if (is_array($temp) || is_object($temp)) {
         $sets[] = '`' . $fieldname . '` = \'' . base64_encode(serialize($temp)) . '\'';
     }
 }
 if (!empty($sets)) {
     $query = 'UPDATE #__acctexp_' . $dbtable . ' SET ' . implode(', ', $sets) . '' . ' WHERE `id` = \'' . $id . '\'';
     $db->setQuery($query);
     if (!$db->query()) {
Пример #6
0
 * @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.');
$serialupdate = false;
$jsonconversion = false;
// Check whether the config is on 0.12.6 status
$query = 'SELECT `settings` FROM #__acctexp_config' . ' WHERE `id` = \'1\'';
$db->setQuery($query);
$res = $db->loadResult();
if ((strpos($res, '{') === 0 || strpos($res, "\n") !== false) && !empty($res)) {
    if (strpos($res, '{') === 0) {
        $res = stripslashes(str_replace(array('\\n', '\\t', '\\r'), array("\n", "\t", "\r"), trim($res)));
        $restings = jsoonHandler::decode($res);
        $jsonconversion = true;
    } else {
        // Has stripslashes stuff built in
        $restings = parameterHandler::decode($res);
        $serialupdate = true;
        if (isset($restings['milist'])) {
            $temp = explode(';', $restings['milist']);
            $restings['milist'] = $temp;
        }
        if (isset($restings['gwlist'])) {
            $temp = explode(';', $restings['gwlist']);
            $restings['gwlist'] = $temp;
        }
    }
    $entry = base64_encode(serialize($restings));
Пример #7
0
 public function explainTags($subject)
 {
     $regex = "#{aecjson}(.*?){/aecjson}#s";
     // find all instances of json code
     $matches = array();
     preg_match_all($regex, $subject, $matches, PREG_SET_ORDER);
     if (count($matches) < 1) {
         return $subject;
     }
     foreach ($matches as $match) {
         $json = jsoonHandler::decode($match[1]);
         $result = $this->explainJSONitem($json);
         $subject = str_replace($match, $result, $subject);
     }
     return $subject;
 }