Exemple #1
0
        private void addCookie(ArrayValue array,
                               string cookies,
                               int start,
                               int end,
                               bool isMagicQuotes)
        {
            int eqIndex = cookies.indexOf('=', start);

            string name  = "";
            string value = "";

            StringValue valueV;

            if (eqIndex < end)
            {
                name = cookies.substring(start, eqIndex);

                StringValue nameV = cleanCookieName(name);
                if (array.get(nameV) != UnsetValue.UNSET)
                {
                    return;
                }

                value  = cookies.substring(eqIndex + 1, end);
                value  = decodeValue(value);
                valueV = createString(value);

                if (isMagicQuotes) // php/0876
                {
                    valueV = StringModule.addslashes(valueV);
                }

                array.append(nameV, valueV);
            }
            else
            {
                name = cookies.substring(start, end);

                StringValue nameV = cleanCookieName(name);

                if (nameV.length() > 0 && nameV[0] == '$')
                {
                    array.append(nameV, getEmptyString());
                }
            }
        }
            void addValue(Value value)
            {
                ArrayValue array = null;

                if (!_isArray)
                {
                    _isArray = true;
                    Value oldValue = _value;
                    _value = new ArrayValueImpl();
                    array  = (ArrayValue)_value;
                    array.append(oldValue);
                }
                else
                {
                    array = (ArrayValue)_value;
                }

                array.append(value);
            }
 public void addTo(ArrayValue array)
 {
     for (int i = 0; i < _keys.length; i++)
     {
         if (_keys[i] != null)
         {
             array.append(_keys[i], _values[i]);
         }
         else
         {
             array.put(_values[i]);
         }
     }
 }
        public static void addFormValue(Env env,
                                        ArrayValue array,
                                        string key,
                                        Value formValue,
                                        string [] formValueList,
                                        bool addSlashesToValues,
                                        bool isReplaceSpacesWithUnderscores)
        {
            int p = -1;
            int q = -1;

            if (key != null)
            {
                p = key.indexOf('[');
                q = key.indexOf(']', p);
            }

            if (p >= 0 && p < q)
            {
                if (p == 0)
                {
                    // php/080e
                    return;
                }

                int keyStart = 0;
                int keyEnd   = p;

                while (p > 0 && p < q)
                {
                    string currentKey = key.substring(keyStart, keyEnd);

                    if (keyStart == 0)
                    {
                        // php/081p
                        currentKey = currentKey.replace('.', '_');
                    }

                    if (isReplaceSpacesWithUnderscores)
                    {
                        // php/080h
                        currentKey = currentKey.replace(' ', '_');

                        // php/080k
                        isReplaceSpacesWithUnderscores = false;
                    }

                    StringValue currentKeyValue = env.createString(currentKey);
                    Value       currentArray    = array.get(currentKeyValue);

                    if (!currentArray.isArray())
                    {
                        currentArray = new ArrayValueImpl();
                    }

                    if (currentKeyValue.length() == 0)
                    {
                        array.append(currentArray);
                    }
                    else
                    {
                        array.put(currentKeyValue, currentArray);
                    }

                    array = currentArray.toArrayValue(env);

                    keyStart = p + 1;
                    keyEnd   = q;

                    p = key.indexOf('[', q + 1);
                    q = key.indexOf(']', p + 1);
                }

                if (keyEnd > 0)
                {
                    key = key.substring(keyStart, keyEnd);
                }
                else
                {
                    key = key.substring(keyStart);
                }

                if (isReplaceSpacesWithUnderscores)
                {
                    // php/080h
                    key = key.replace(' ', '_');
                }

                if (key.length() == 0)
                {
                    if (formValueList != null)
                    {
                        for (int i = 0; i < formValueList.length; i++)
                        {
                            Value value;

                            if (formValueList[i] != null)
                            {
                                value = env.createString(formValueList[i]);
                            }
                            else
                            {
                                value = NullValue.NULL;
                            }

                            put(array, null, value, addSlashesToValues);
                        }
                    }
                    else
                    {
                        array.put(formValue);
                    }
                }
                else if ('0' <= key[0] && key[0] <= '9')
                {
                    put(array,
                        LongValue.create(StringValue.toLong(key)),
                        formValue,
                        addSlashesToValues);
                }
                else
                {
                    put(array, env.createString(key), formValue, addSlashesToValues);
                }
            }
            else
            {
                if (key != null)
                {
                    key = key.replace('.', '_');

                    if (isReplaceSpacesWithUnderscores)
                    {
                        // php/080h
                        key = key.replace(' ', '_');
                    }

                    put(array, env.createString(key), formValue, addSlashesToValues);
                }
                else
                {
                    put(array, null, formValue, addSlashesToValues);
                }
            }
        }
 /**
  * Adds a new value.
  */
 public override ArrayValue append(Value key, Value value)
 {
     return(_array.append(key, value));
 }