public static PhpValue getIntItem(Context ctx, PhpValue obj, PhpValue key) { return(getItem(ctx, obj.ToClr(), key.ToInt())); }
public bool setAttribute(PDO_ATTR attribute, PhpValue value) { try { if ((int)attribute >= (int)PDO_ATTR.ATTR_DRIVER_SPECIFIC) { return(this.m_driver.TrySetAttribute(this.m_attributes, attribute, value)); } switch (attribute) { //readonly case PDO_ATTR.ATTR_SERVER_INFO: case PDO_ATTR.ATTR_SERVER_VERSION: case PDO_ATTR.ATTR_CLIENT_VERSION: case PDO_ATTR.ATTR_CONNECTION_STATUS: case PDO_ATTR.ATTR_DRIVER_NAME: return(false); //boolean case PDO_ATTR.ATTR_AUTOCOMMIT: case PDO_ATTR.ATTR_EMULATE_PREPARES: this.m_attributes[attribute] = value; return(true); //strict positif integers case PDO_ATTR.ATTR_PREFETCH: case PDO_ATTR.ATTR_TIMEOUT: this.m_attributes[attribute] = value; return(true); //remaining case PDO_ATTR.ATTR_ERRMODE: int errmodeValue = (int)value.ToLong(); if (Enum.IsDefined(typeof(PDO_ERRMODE), errmodeValue)) { this.m_attributes[attribute] = (PhpValue)errmodeValue; return(true); } return(false); case PDO_ATTR.ATTR_CASE: int caseValue = (int)value.ToLong(); if (Enum.IsDefined(typeof(PDO_CASE), caseValue)) { this.m_attributes[attribute] = (PhpValue)caseValue; return(true); } return(false); case PDO_ATTR.ATTR_CURSOR: int cursorValue = (int)value.ToLong(); if (Enum.IsDefined(typeof(PDO_CURSOR), cursorValue)) { this.m_attributes[attribute] = (PhpValue)cursorValue; return(true); } return(false); case PDO_ATTR.ATTR_DEFAULT_FETCH_MODE: int fetchValue = value.ToInt(); if (Enum.IsDefined(typeof(PDO_FETCH), fetchValue)) { this.m_attributes[attribute] = (PhpValue)fetchValue; return(true); } return(false); case PDO_ATTR.ATTR_FETCH_CATALOG_NAMES: case PDO_ATTR.ATTR_FETCH_TABLE_NAMES: case PDO_ATTR.ATTR_MAX_COLUMN_LEN: case PDO_ATTR.ATTR_ORACLE_NULLS: case PDO_ATTR.ATTR_PERSISTENT: case PDO_ATTR.ATTR_STATEMENT_CLASS: case PDO_ATTR.ATTR_STRINGIFY_FETCHES: throw new NotImplementedException(); //statement only case PDO_ATTR.ATTR_CURSOR_NAME: return(false); default: return(false); } } catch (System.Exception ex) { this.HandleError(ex); return(false); } }
static PhpValue GsrCore(Context ctx, IPhpConfigurationService config, string option, PhpValue value, IniAction action) { switch (option) { case "precision": // CONSIDER: this can be set in our Context.InvariantNumberFormatInfo ? AssertGet(option, action); return(15); // default Double precision in .NET case "register_globals": AssertGet(option, action); return(PhpValue.False); // always Off case "allow_url_fopen": return(GetSet(ref config.Core.AllowUrlFopen, true, value, action)); case "include_path": return(GetSet(ref config.Core.IncludePaths, ".", value, action)); case "allow_url_include": AssertGet(option, action); return(PhpValue.False); case "disable_functions": case "disable_classes": AssertGet(option, action); return(string.Empty); case "file_uploads": AssertGet(option, action); return(PhpValue.True); //case "max_file_uploads": // return 20; case "memory_limit": AssertGet(option, action); return(-1); // no memory limit case "post_max_size": case "upload_max_filesize": AssertGet(option, action); return(ctx.HttpPhpContext != null ? ctx.HttpPhpContext.MaxRequestSize : (16_000_000 /*cli mode, just return something*/)); case "docref_root": return(GetSet(ref config.Core.docref_root, "", value, action)); case "docref_ext": return(GetSet(ref config.Core.docref_ext, "", value, action)); case "open_basedir": AssertGet(option, action); return(string.Empty); case "max_execution_time": if (action == IniAction.Set) { var oldvalue = config.Core.ExecutionTimeout; ctx.ApplyExecutionTimeout(config.Core.ExecutionTimeout = Math.Max(0, value.ToInt())); return(oldvalue); } else { return(config.Core.ExecutionTimeout); } default: throw new ArgumentException(); } }
static PhpValue GsrCore(Context ctx, IPhpConfigurationService config, string option, PhpValue value, IniAction action) { switch (option.ToLowerInvariant()) { case "precision": // TODO: this can be set in .NET <see cref="Core.Convert.ToString(double, Context)"/> by specifying "G{precision}", consider performance AssertGet(option, action); return((PhpValue)15); // default Double precision in .NET case "register_globals": AssertGet(option, action); return(PhpValue.False); // always Off case "allow_url_fopen": return((PhpValue)GetSet(ref config.Core.AllowUrlFopen, true, value, action)); case "include_path": return((PhpValue)GetSet(ref config.Core.IncludePaths, ".", value, action)); case "allow_url_include": AssertGet(option, action); return(PhpValue.False); case "disable_functions": case "disable_classes": AssertGet(option, action); return((PhpValue)string.Empty); case "memory_limit": AssertGet(option, action); return((PhpValue)(-1)); // no memory limit case "post_max_size": case "upload_max_filesize": AssertGet(option, action); return(ctx.HttpPhpContext != null ? ctx.HttpPhpContext.MaxRequestSize : (8_000_000 /*cli mode, just return something*/)); case "docref_root": return((PhpValue)GetSet(ref config.Core.docref_root, "", value, action)); case "docref_ext": return((PhpValue)GetSet(ref config.Core.docref_ext, "", value, action)); case "open_basedir": Debug.Assert(action == IniAction.Get); return((PhpValue)string.Empty); case "max_execution_time": if (action == IniAction.Set) { var oldvalue = config.Core.ExecutionTimeout; ctx.ApplyExecutionTimeout(config.Core.ExecutionTimeout = Math.Max(0, value.ToInt())); return(oldvalue); } else { return(config.Core.ExecutionTimeout); } default: throw new ArgumentException(); } }