Example #1
0
        public static XVar readSelectedRecordsFromRequest(dynamic _param_table)
        {
            #region pass-by-value parameters
            dynamic table = XVar.Clone(_param_table);
            #endregion

            dynamic         keyFields = XVar.Array(), selected_recs = XVar.Array();
            ProjectSettings pSet;
            if (XVar.Pack(!(XVar)(MVCFunctions.postvalue("selection"))))
            {
                return(XVar.Array());
            }
            pSet          = XVar.UnPackProjectSettings(new ProjectSettings((XVar)(table)));
            keyFields     = XVar.Clone(pSet.getTableKeys());
            selected_recs = XVar.Clone(XVar.Array());
            foreach (KeyValuePair <XVar, dynamic> keyblock in MVCFunctions.EnumeratePOST("selection"))
            {
                dynamic arr = XVar.Array(), keys = XVar.Array();
                arr = XVar.Clone(MVCFunctions.explode(new XVar("&"), (XVar)(keyblock.Value)));
                if (MVCFunctions.count(arr) < MVCFunctions.count(keyFields))
                {
                    continue;
                }
                keys = XVar.Clone(XVar.Array());
                foreach (KeyValuePair <XVar, dynamic> value in arr.GetEnumerator())
                {
                    keys.InitAndSetArrayItem(MVCFunctions.urldecode((XVar)(value.Value)), keyFields[value.Key]);
                }
                selected_recs.InitAndSetArrayItem(keys, null);
            }
            return(selected_recs);
        }
Example #2
0
        public EditSelectedPage(dynamic var_params)
            : base((XVar)var_params)
        {
            if (skipEditSelectedPageCtor)
            {
                skipEditSelectedPageCtor = false;
                return;
            }
            dynamic keyFields = XVar.Array();

            keyFields = XVar.Clone(this.pSet.getTableKeys());
            foreach (KeyValuePair <XVar, dynamic> s in this.selection.GetEnumerator())
            {
                dynamic arr = XVar.Array(), parsed = XVar.Array();
                arr = XVar.Clone(MVCFunctions.explode(new XVar("&"), (XVar)(s.Value)));
                if (MVCFunctions.count(arr) != MVCFunctions.count(this.pSet.getTableKeys()))
                {
                    continue;
                }
                foreach (KeyValuePair <XVar, dynamic> v in arr.GetEnumerator())
                {
                    parsed.InitAndSetArrayItem(v.Value, keyFields[v.Key]);
                }
                this.parsedSelection.InitAndSetArrayItem(parsed, null);
            }
        }
Example #3
0
        protected virtual XVar getMultiselectLookupValues(dynamic _param_value)
        {
            #region pass-by-value parameters
            dynamic value = XVar.Clone(_param_value);
            #endregion

            dynamic LookupSQL = null, displayValue = null, i = null, lookupArr = XVar.Array(), lookupValues = XVar.Array(), lookuprow = XVar.Array(), qResult = null, var_in = null, withoutWhere = null;
            var_in = XVar.Clone(getDbPreparedValuesList((XVar)(value)));
            if (XVar.Pack(!(XVar)(MVCFunctions.strlen((XVar)(var_in)))))
            {
                return(new XVar(0, value));
            }
            if (XVar.Pack(MVCFunctions.count(this.resolvedLookupValues[value])))
            {
                return(this.resolvedLookupValues[value]);
            }
            withoutWhere = new XVar(false);
            i            = new XVar(0);
            for (; i < 2; i++)
            {
                LookupSQL = XVar.Clone(getMultiselectLookupResolvingSQL((XVar)(value), (XVar)(var_in), (XVar)(withoutWhere)));
                CommonFunctions.LogInfo((XVar)(LookupSQL));
                lookupArr = XVar.Clone(XVar.Array());
                qResult   = XVar.Clone(this.lookupConnection.query((XVar)(LookupSQL)));
                while (XVar.Pack(lookuprow = XVar.Clone(qResult.fetchNumeric())))
                {
                    displayValue = XVar.Clone(lookuprow[this.displayFieldIndex]);
                    lookupArr.InitAndSetArrayItem(displayValue, null);
                    this.resolvedLinkLookupValues.InitAndSetArrayItem(lookuprow[this.linkFieldIndex], value, displayValue);
                }
                if (MVCFunctions.count(lookupArr) == MVCFunctions.count(MVCFunctions.explode(new XVar(","), (XVar)(var_in))))
                {
                    break;
                }
                withoutWhere = new XVar(true);
            }
            lookupValues = XVar.Clone(XVar.Array());
            lookupArr    = XVar.Clone(MVCFunctions.array_unique((XVar)(lookupArr)));
            foreach (KeyValuePair <XVar, dynamic> lookupvalue in lookupArr.GetEnumerator())
            {
                lookupValues.InitAndSetArrayItem(getDecryptLookupValue((XVar)(lookupvalue.Value)), null);
            }
            if (XVar.Pack(MVCFunctions.count(lookupValues)))
            {
                this.resolvedLookupValues.InitAndSetArrayItem(lookupValues, value);
            }
            return(lookupValues);
        }
Example #4
0
        public virtual XVar modifyKeys()
        {
            dynamic keys = XVar.Array();

            keys = XVar.Clone(XVar.Array());
            if (XVar.Pack(MVCFunctions.count(this.keys)))
            {
                dynamic j = null, tKeysNamesArr = XVar.Array();
                tKeysNamesArr = XVar.Clone(GlobalVars.gSettings.getTableKeys());
                if (XVar.Pack(this.isManyKeys))
                {
                    foreach (KeyValuePair <XVar, dynamic> value in this.keys.GetEnumerator())
                    {
                        dynamic recKeyArr = XVar.Array();
                        keys.InitAndSetArrayItem(XVar.Array(), value.Key);
                        recKeyArr = XVar.Clone(MVCFunctions.explode(new XVar("&"), (XVar)(value.Value)));
                        j         = new XVar(0);
                        for (; j < MVCFunctions.count(tKeysNamesArr); j++)
                        {
                            if (XVar.Pack(recKeyArr.KeyExists(j)))
                            {
                                keys.InitAndSetArrayItem(MVCFunctions.urldecode((XVar)(recKeyArr[j])), value.Key, tKeysNamesArr[j]);
                            }
                        }
                    }
                }
                else
                {
                    if (XVar.Pack(MVCFunctions.count(this.keys)))
                    {
                        j = new XVar(0);
                        for (; j < MVCFunctions.count(tKeysNamesArr); j++)
                        {
                            keys.InitAndSetArrayItem(MVCFunctions.urldecode((XVar)(this.keys[j])), tKeysNamesArr[j]);
                        }
                    }
                }
            }
            this.keys = XVar.Clone(keys);
            return(null);
        }
Example #5
0
        public override XVar getPdfValue(dynamic data, dynamic _param_keylink = null)
        {
            #region default values
            if (_param_keylink as Object == null)
            {
                _param_keylink = new XVar("");
            }
            #endregion

            #region pass-by-value parameters
            dynamic keylink = XVar.Clone(_param_keylink);
            #endregion

            dynamic filesList = null, textVal = null;
            textVal = XVar.Clone(getTextValue((XVar)(data)));
            if (XVar.Pack(!(XVar)(MVCFunctions.strlen((XVar)(textVal)))))
            {
                return("\"\"");
            }
            filesList = XVar.Clone(MVCFunctions.explode(new XVar(", "), (XVar)(textVal)));
            return(MVCFunctions.my_json_encode((XVar)(new XVar("stack", filesList))));
        }
Example #6
0
        public virtual XVar getTableNameComponents(dynamic _param_name)
        {
            #region pass-by-value parameters
            dynamic name = XVar.Clone(_param_name);
            #endregion

            dynamic components = XVar.Array(), parts = XVar.Array(), strippedTableName = null;
            strippedTableName = XVar.Clone(MVCFunctions.str_replace((XVar)(new XVar(0, this.strLeftWrapper, 1, this.strRightWrapper)), new XVar(""), (XVar)(name)));
            parts             = XVar.Clone(MVCFunctions.explode(new XVar("."), (XVar)(strippedTableName)));
            components        = XVar.Clone(XVar.Array());
            components.InitAndSetArrayItem(name, "fullName");
            if ((XVar)((XVar)(MVCFunctions.count(parts) == 3) && (XVar)(crossDbSupported())) && (XVar)(schemaSupported()))
            {
                components.InitAndSetArrayItem(parts[0], "db");
                components.InitAndSetArrayItem(parts[1], "schema");
                components.InitAndSetArrayItem(parts[2], "table");
            }
            else
            {
                if ((XVar)(MVCFunctions.count(parts) == 2) && (XVar)((XVar)(crossDbSupported()) || (XVar)(schemaSupported())))
                {
                    if (XVar.Pack(schemaSupported()))
                    {
                        components.InitAndSetArrayItem(parts[0], "schema");
                    }
                    else
                    {
                        components.InitAndSetArrayItem(parts[0], "db");
                    }
                    components.InitAndSetArrayItem(parts[1], "table");
                }
                else
                {
                    components.InitAndSetArrayItem(name, "table");
                }
            }
            return(components);
        }
Example #7
0
        public virtual XVar addTableWrappers(dynamic _param_strName)
        {
            #region pass-by-value parameters
            dynamic strName = XVar.Clone(_param_strName);
            #endregion

            dynamic arr = XVar.Array(), ret = null;
            if (MVCFunctions.substr((XVar)(strName), new XVar(0), new XVar(1)) == this.strLeftWrapper)
            {
                return(strName);
            }
            arr = XVar.Clone(MVCFunctions.explode(new XVar("."), (XVar)(strName)));
            ret = new XVar("");
            foreach (KeyValuePair <XVar, dynamic> e in arr.GetEnumerator())
            {
                if (ret != XVar.Pack(""))
                {
                    ret = MVCFunctions.Concat(ret, ".");
                }
                ret = MVCFunctions.Concat(ret, this.strLeftWrapper, e.Value, this.strRightWrapper);
            }
            return(ret);
        }
Example #8
0
        protected virtual XVar getCommonFormatSettings(dynamic _param_viewFomat)
        {
            #region pass-by-value parameters
            dynamic viewFomat = XVar.Clone(_param_viewFomat);
            #endregion

            dynamic formatSettings = XVar.Array();
            formatSettings = XVar.Clone(XVar.Array());
            if (XVar.Equals(XVar.Pack(viewFomat), XVar.Pack(Constants.FORMAT_CURRENCY)))
            {
                formatSettings.InitAndSetArrayItem(GlobalVars.locale_info["LOCALE_ICURRDIGITS"], "decimalDigits");
                formatSettings.InitAndSetArrayItem(MVCFunctions.explode(new XVar(";"), (XVar)(GlobalVars.locale_info["LOCALE_SMONGROUPING"])), "grouping");
                formatSettings.InitAndSetArrayItem(GlobalVars.locale_info["LOCALE_SMONTHOUSANDSEP"], "thousandSep");
                formatSettings.InitAndSetArrayItem(GlobalVars.locale_info["LOCALE_SMONDECIMALSEP"], "decimalSep");
            }
            if (viewFomat == Constants.FORMAT_NUMBER)
            {
                formatSettings.InitAndSetArrayItem(this.pSet.isDecimalDigits((XVar)(this.fName)), "decimalDigits");
                formatSettings.InitAndSetArrayItem(MVCFunctions.explode(new XVar(";"), (XVar)(GlobalVars.locale_info["LOCALE_SGROUPING"])), "grouping");
                formatSettings.InitAndSetArrayItem(GlobalVars.locale_info["LOCALE_STHOUSAND"], "thousandSep");
                formatSettings.InitAndSetArrayItem(GlobalVars.locale_info["LOCALE_SDECIMAL"], "decimalSep");
            }
            return(formatSettings);
        }
Example #9
0
 public XVar combo()
 {
     try
     {
         dynamic contentType = null, library = null, queryString = null, start = null, var_end = null, yuiComponents = XVar.Array(), yuiFiles = XVar.Array();
         GlobalVars.cCharset = new XVar("utf-8");
         queryString         = XVar.Clone(MVCFunctions.GetQueryString());
         if ((XVar)(!(XVar)(queryString as object != null)) || (XVar)(MVCFunctions.strlen((XVar)(queryString)) == 0))
         {
             return(MVCFunctions.GetBuferContentAndClearBufer());
         }
         yuiFiles      = XVar.Clone(MVCFunctions.explode(new XVar("&"), (XVar)(queryString)));
         contentType   = XVar.Clone((XVar.Pack(MVCFunctions.strpos((XVar)(yuiFiles[0]), new XVar(".js"))) ? XVar.Pack("application/x-javascript") : XVar.Pack(" text/css")));
         yuiComponents = XVar.Clone(XVar.Array());
         if (contentType == "application/x-javascript")
         {
             foreach (KeyValuePair <XVar, dynamic> yuiFile in yuiFiles.GetEnumerator())
             {
                 dynamic parts = XVar.Array();
                 parts = XVar.Clone(MVCFunctions.explode(new XVar("/"), (XVar)(yuiFile.Value)));
                 if (MVCFunctions.count(parts) == 4)
                 {
                     if ((XVar)((XVar)(parts.KeyExists(0)) && (XVar)(parts.KeyExists(1))) && (XVar)(parts.KeyExists(2)))
                     {
                         yuiComponents.InitAndSetArrayItem(MVCFunctions.Concat(parts[2], "/", parts[2]), null);
                     }
                     else
                     {
                         MVCFunctions.Echo((XVar)(MVCFunctions.Concat("<!-- Unable to determine module name! ", MVCFunctions.runner_htmlspecialchars((XVar)(yuiFile.Value)), " -->")));
                         return(MVCFunctions.GetBuferContentAndClearBufer());
                     }
                 }
                 else
                 {
                     start = XVar.Clone(MVCFunctions.strpos((XVar)(yuiFile.Value), new XVar("/build/")));
                     if (XVar.Equals(XVar.Pack(start), XVar.Pack(false)))
                     {
                         MVCFunctions.Echo((XVar)(MVCFunctions.Concat("<!-- Unable to determine module name! ", MVCFunctions.runner_htmlspecialchars((XVar)(yuiFile.Value)), " -->")));
                         return(MVCFunctions.GetBuferContentAndClearBufer());
                     }
                     start  += MVCFunctions.strlen(new XVar("/build/"));
                     var_end = XVar.Clone(MVCFunctions.strpos((XVar)(yuiFile.Value), new XVar(".js")));
                     if (XVar.Equals(XVar.Pack(var_end), XVar.Pack(false)))
                     {
                         MVCFunctions.Echo((XVar)(MVCFunctions.Concat("<!-- Unable to determine module name! ", MVCFunctions.runner_htmlspecialchars((XVar)(yuiFile.Value)), " -->")));
                         return(MVCFunctions.GetBuferContentAndClearBufer());
                     }
                     yuiComponents.InitAndSetArrayItem(MVCFunctions.substr((XVar)(yuiFile.Value), (XVar)(start), (XVar)(var_end - start)), null);
                 }
             }
             library = XVar.Clone(MVCFunctions.myfile_get_contents((XVar)(MVCFunctions.getabspath(new XVar("include/yui/yui.lib"))), new XVar("r")));
         }
         else
         {
             foreach (KeyValuePair <XVar, dynamic> yuiFile in yuiFiles.GetEnumerator())
             {
                 start = XVar.Clone(MVCFunctions.strpos((XVar)(yuiFile.Value), new XVar("/build/")));
                 if (XVar.Equals(XVar.Pack(start), XVar.Pack(false)))
                 {
                     MVCFunctions.Echo((XVar)(MVCFunctions.Concat("<!-- Unable to determine module name! ", MVCFunctions.runner_htmlspecialchars((XVar)(yuiFile.Value)), " -->")));
                     return(MVCFunctions.GetBuferContentAndClearBufer());
                 }
                 start += MVCFunctions.strlen(new XVar("/build/"));
                 yuiComponents.InitAndSetArrayItem(MVCFunctions.substr((XVar)(yuiFile.Value), (XVar)(start)), null);
             }
             library = XVar.Clone(MVCFunctions.myfile_get_contents((XVar)(MVCFunctions.getabspath(new XVar("include/yui/yuicss.lib"))), new XVar("r")));
         }
         MVCFunctions.Header("Cache-Control", "max-age=315360000");
         MVCFunctions.Header("Expires", "Thu, 29 Oct 2020 20:00:00 GMT");
         MVCFunctions.Header((XVar)(MVCFunctions.Concat("Content-Type: ", contentType)));
         foreach (KeyValuePair <XVar, dynamic> y in yuiComponents.GetEnumerator())
         {
             start = XVar.Clone(MVCFunctions.strpos((XVar)(library), (XVar)(MVCFunctions.Concat("begincombofile ", y.Value))));
             if (XVar.Equals(XVar.Pack(start), XVar.Pack(false)))
             {
                 MVCFunctions.Echo((XVar)(MVCFunctions.Concat("Unknown file ", MVCFunctions.runner_htmlspecialchars((XVar)(y.Value)))));
                 return(MVCFunctions.GetBuferContentAndClearBufer());
             }
             start  += MVCFunctions.strlen((XVar)(MVCFunctions.Concat("begincombofile ", y.Value)));
             var_end = XVar.Clone(MVCFunctions.strpos((XVar)(library), new XVar("endcombofile"), (XVar)(start)));
             if (XVar.Equals(XVar.Pack(var_end), XVar.Pack(false)))
             {
                 MVCFunctions.Echo((XVar)(MVCFunctions.Concat("Unknown file ", MVCFunctions.runner_htmlspecialchars((XVar)(y.Value)))));
                 return(MVCFunctions.GetBuferContentAndClearBufer());
             }
             MVCFunctions.Echo(MVCFunctions.substr((XVar)(library), (XVar)(start), (XVar)(var_end - start)));
         }
         return(MVCFunctions.GetBuferContentAndClearBufer());
     }
     catch (RunnerRedirectException ex)
     { return(Redirect(ex.Message)); }
 }
Example #10
0
        public virtual XVar getOrderFields()
        {
            dynamic         columns = XVar.Array(), ret = XVar.Array(), saved = XVar.Array();
            ProjectSettings pSet;

            if (!XVar.Equals(XVar.Pack(this._cachedFields), XVar.Pack(null)))
            {
                return(this._cachedFields);
            }
            ret     = XVar.Clone(XVar.Array());
            columns = XVar.Clone(XVar.Array());
            pSet    = XVar.UnPackProjectSettings(this.pSet);
            saved   = XVar.Clone(XSession.Session[MVCFunctions.Concat(this.sessionPrefix, "_orderby")]);
            if (0 != MVCFunctions.strlen((XVar)(saved["orderby"])))
            {
                dynamic fields = XVar.Array();
                fields = XVar.Clone(MVCFunctions.explode(new XVar(";"), (XVar)(saved["orderby"])));
                foreach (KeyValuePair <XVar, dynamic> f in fields.GetEnumerator())
                {
                    dynamic dir = null, fieldName = null, goodField = null, index = null;
                    dir = XVar.Clone(MVCFunctions.substr((XVar)(f.Value), new XVar(0), new XVar(1)));
                    if ((XVar)(dir != "a") && (XVar)(dir != "d"))
                    {
                        continue;
                    }
                    goodField = XVar.Clone(MVCFunctions.substr((XVar)(f.Value), new XVar(1)));
                    fieldName = XVar.Clone(pSet.getFieldByGoodFieldName((XVar)(goodField)));
                    index     = XVar.Clone(pSet.getFieldIndex((XVar)(fieldName)) + 1);
                    if (XVar.Pack(!(XVar)(index)))
                    {
                        continue;
                    }
                    ret.InitAndSetArrayItem(new XVar("column", fieldName, "index", index, "expr", RunnerPage._getFieldSQLDecrypt((XVar)(fieldName), (XVar)(this.connection), (XVar)(this.pSet), (XVar)(this.cipherer)), "dir", (XVar.Pack(dir == "a") ? XVar.Pack("ASC") : XVar.Pack("DESC"))), null);
                    columns.InitAndSetArrayItem(true, fieldName);
                }
            }
            else
            {
                if (0 != MVCFunctions.strlen((XVar)(saved["sortby"])))
                {
                    dynamic sortbySettings = XVar.Array(), var_option = XVar.Array();
                    sortbySettings = getSortBySettings();
                    var_option     = XVar.Clone(sortbySettings[saved["sortby"] - 1]);
                    if (XVar.Pack(var_option))
                    {
                        foreach (KeyValuePair <XVar, dynamic> f in var_option["fields"].GetEnumerator())
                        {
                            ret.InitAndSetArrayItem(new XVar("column", f.Value["field"], "index", pSet.getFieldIndex((XVar)(f.Value["field"])) + 1, "expr", RunnerPage._getFieldSQLDecrypt((XVar)(f.Value["field"]), (XVar)(this.connection), (XVar)(this.pSet), (XVar)(this.cipherer)), "dir", (XVar.Pack(f.Value["desc"]) ? XVar.Pack("DESC") : XVar.Pack("ASC"))), null);
                            columns.InitAndSetArrayItem(true, f.Value);
                        }
                    }
                }
                else
                {
                    dynamic orderInfo = XVar.Array();
                    orderInfo = XVar.Clone(pSet.getOrderIndexes());
                    foreach (KeyValuePair <XVar, dynamic> o in orderInfo.GetEnumerator())
                    {
                        dynamic field = null;
                        field = XVar.Clone(pSet.GetFieldByIndex((XVar)(o.Value[0])));
                        ret.InitAndSetArrayItem(new XVar("column", field, "index", o.Value[0], "expr", o.Value[2], "dir", o.Value[1]), null);
                        columns.InitAndSetArrayItem(true, field);
                    }
                }
            }
            foreach (KeyValuePair <XVar, dynamic> k in pSet.getTableKeys().GetEnumerator())
            {
                if (XVar.Pack(columns.KeyExists(k.Value)))
                {
                    continue;
                }
                ret.InitAndSetArrayItem(new XVar("column", k.Value, "index", pSet.getFieldIndex((XVar)(k.Value)) + 1, "expr", RunnerPage._getFieldSQLDecrypt((XVar)(k.Value), (XVar)(this.connection), (XVar)(this.pSet), (XVar)(this.cipherer)), "dir", "ASC", "hidden", true), null);
            }
            this._cachedFields = XVar.Clone(ret);
            return(ret);
        }
Example #11
0
        public XVar mfhandler()
        {
            try
            {
                dynamic         _connection = null, field = null, fileName = null, formStamp = null, fsFileName = null, fsize = null, ftype = null, havePermission = null, iconShowed = null, isDBFile = null, isPDF = null, outputAsAttachment = null, pageType = null, pdf = null, requestAction = null, sessionFile = XVar.Array(), upload_handler = null, value = null, var_params = XVar.Array();
                ProjectSettings pSet;
                isPDF = new XVar(false);
                if (XVar.Pack(isPDF))
                {
                    GlobalVars.strTableName = XVar.Clone(var_params["table"]);
                    field              = XVar.Clone(var_params["field"]);
                    pageType           = XVar.Clone(var_params["pageType"]);
                    outputAsAttachment = new XVar(false);
                }
                else
                {
                    GlobalVars.strTableName = XVar.Clone(MVCFunctions.postvalue(new XVar("table")));
                    field              = XVar.Clone(MVCFunctions.postvalue(new XVar("field")));
                    pageType           = XVar.Clone(MVCFunctions.postvalue(new XVar("pageType")));
                    outputAsAttachment = XVar.Clone(MVCFunctions.postvalue(new XVar("nodisp")) != 1);
                }
                if (GlobalVars.strTableName == XVar.Pack(""))
                {
                    if (XVar.Pack(!(XVar)(isPDF)))
                    {
                        MVCFunctions.Echo("<p>No table name received</p>");
                    }
                    return(MVCFunctions.GetBuferContentAndClearBufer());
                }
                if (field == XVar.Pack(""))
                {
                    if (XVar.Pack(!(XVar)(isPDF)))
                    {
                        MVCFunctions.Echo("<p>No field name received</p>");
                    }
                    return(MVCFunctions.GetBuferContentAndClearBufer());
                }
                if (XVar.Pack(!(XVar)(CommonFunctions.GetTableURL((XVar)(GlobalVars.strTableName)))))
                {
                    MVCFunctions.Echo(new XVar(0));
                    return(MVCFunctions.GetBuferContentAndClearBufer());
                }
                if (XVar.Pack(isPDF))
                {
                    requestAction = new XVar("GET");
                }
                else
                {
                    requestAction = XVar.Clone(MVCFunctions.postvalue("_action"));
                }
                _connection = XVar.Clone(GlobalVars.cman.byTable((XVar)(GlobalVars.strTableName)));
                pSet        = XVar.UnPackProjectSettings(new ProjectSettings((XVar)(GlobalVars.strTableName), (XVar)(pageType)));
                if (XVar.Pack(!(XVar)(isPDF)))
                {
                    CommonFunctions.add_nocache_headers();
                }
                Assembly.GetExecutingAssembly().GetType(MVCFunctions.Concat("runnerDotNet.", MVCFunctions.Concat("", CommonFunctions.GetTableURL((XVar)(GlobalVars.strTableName)), ""),
                                                                            "_Variables")).InvokeMember("Apply", BindingFlags.InvokeMethod, null, null, null);
                if (requestAction == "POST")
                {
                    havePermission = XVar.Clone((XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Add"))) || (XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Edit"))));
                }
                else
                {
                    havePermission = XVar.Clone((XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Search"))) || (XVar)(MVCFunctions.postvalue(new XVar("fkey"))));
                }
                if ((XVar)((XVar)(!(XVar)(CommonFunctions.isLogged())) && (XVar)(pageType != Constants.PAGE_REGISTER)) || (XVar)(!(XVar)(havePermission)))
                {
                    MVCFunctions.HeaderRedirect(new XVar("login"), new XVar(""), new XVar("message=expired"));
                    return(MVCFunctions.GetBuferContentAndClearBufer());
                }
                upload_handler          = XVar.Clone(new UploadHandler((XVar)(CommonFunctions.getOptionsForMultiUpload((XVar)(pSet), (XVar)(field)))));
                upload_handler.pSet     = XVar.Clone(pSet);
                upload_handler.field    = XVar.Clone(field);
                upload_handler.table    = XVar.Clone(GlobalVars.strTableName);
                upload_handler.pageType = XVar.Clone(pageType);
                switch (((XVar)requestAction).ToString())
                {
                case "DELETE":
                    CommonFunctions.printMFHandlerHeaders();
                    formStamp = XVar.Clone(MVCFunctions.postvalue(new XVar("formStamp")));
                    if (formStamp != XVar.Pack(""))
                    {
                        upload_handler.formStamp = XVar.Clone(formStamp);
                        upload_handler.delete();
                    }
                    break;

                case "POST":
                    CommonFunctions.printMFHandlerHeaders();
                    formStamp = XVar.Clone(MVCFunctions.postvalue(new XVar("formStamp")));
                    if (formStamp != XVar.Pack(""))
                    {
                        upload_handler.formStamp = XVar.Clone(formStamp);
                        upload_handler.post();
                    }
                    break;

                case "GET":
                default:
                    if (XVar.Pack(isPDF))
                    {
                        isDBFile = XVar.Clone(var_params.KeyExists("filename"));
                        fileName = XVar.Clone((XVar.Pack(var_params.KeyExists("file")) ? XVar.Pack(var_params["file"]) : XVar.Pack(var_params["filename"])));
                    }
                    else
                    {
                        isDBFile  = XVar.Clone(MVCFunctions.postvalue(new XVar("filename")) != "");
                        fileName  = XVar.Clone((XVar.Pack(MVCFunctions.postvalue(new XVar("file")) != "") ? XVar.Pack(MVCFunctions.postvalue(new XVar("file"))) : XVar.Pack(MVCFunctions.postvalue(new XVar("filename")))));
                        formStamp = XVar.Clone(MVCFunctions.postvalue(new XVar("fkey")));
                    }
                    if (fileName == XVar.Pack(""))
                    {
                        MVCFunctions.Echo(new XVar(""));
                        return(MVCFunctions.GetBuferContentAndClearBufer());
                    }
                    sessionFile = new XVar(null);
                    fsFileName  = new XVar("");
                    if ((XVar)(!(XVar)(isDBFile)) && (XVar)(formStamp != XVar.Pack("")))
                    {
                        sessionFile = XVar.Clone(XSession.Session[MVCFunctions.Concat("mupload_", formStamp)][fileName]["file"]);
                    }
                    else
                    {
                        dynamic i = null, keys = XVar.Array(), qResult = null, queryObj = null, strWhereClause = null, tKeys = XVar.Array();
                        keys  = XVar.Clone(XVar.Array());
                        tKeys = XVar.Clone(pSet.getTableKeys());
                        i     = new XVar(0);
                        for (; i < MVCFunctions.count(tKeys); i++)
                        {
                            if (XVar.Pack(isPDF))
                            {
                                keys.InitAndSetArrayItem(var_params[MVCFunctions.Concat("key", i + 1)], tKeys[i]);
                            }
                            else
                            {
                                keys.InitAndSetArrayItem(MVCFunctions.postvalue((XVar)(MVCFunctions.Concat("key", i + 1))), tKeys[i]);
                            }
                        }
                        strWhereClause = XVar.Clone(CommonFunctions.KeyWhere((XVar)(keys)));
                        if (pSet.getAdvancedSecurityType() != Constants.ADVSECURITY_ALL)
                        {
                            strWhereClause = XVar.Clone(CommonFunctions.whereAdd((XVar)(strWhereClause), (XVar)(CommonFunctions.SecuritySQL(new XVar("Search")))));
                        }
                        queryObj = XVar.Clone(pSet.getSQLQuery().CloneObject());
                        if (XVar.Pack(!(XVar)(queryObj.HasGroupBy())))
                        {
                            queryObj.RemoveAllFieldsExcept((XVar)(pSet.getFieldIndex((XVar)(field))));
                        }
                        qResult = XVar.Clone(_connection.query((XVar)(queryObj.gSQLWhere((XVar)(strWhereClause)))));
                        if (XVar.Pack(isDBFile))
                        {
                            if (XVar.Pack(qResult))
                            {
                                dynamic data = XVar.Array();
                                data = XVar.Clone(qResult.fetchAssoc());
                                if (XVar.Pack(data))
                                {
                                    value = XVar.Clone(_connection.stripSlashesBinary((XVar)(data[field])));
                                }
                            }
                        }
                        else
                        {
                            dynamic row = XVar.Array();
                            GlobalVars.cipherer = XVar.Clone(new RunnerCipherer((XVar)(GlobalVars.strTableName), (XVar)(pSet)));
                            row = XVar.Clone(GlobalVars.cipherer.DecryptFetchedArray((XVar)(qResult.fetchAssoc())));
                            if (XVar.Pack(row))
                            {
                                dynamic filesArray = XVar.Array();
                                filesArray = XVar.Clone(MVCFunctions.my_json_decode((XVar)(row[field])));
                                if ((XVar)(!(XVar)(MVCFunctions.is_array((XVar)(filesArray)))) || (XVar)(MVCFunctions.count(filesArray) == 0))
                                {
                                    if (row[field] == "")
                                    {
                                        filesArray = XVar.Clone(XVar.Array());
                                    }
                                    else
                                    {
                                        dynamic uploadedFile = XVar.Array();
                                        uploadedFile = XVar.Clone(upload_handler.get_file_object((XVar)(row[field])));
                                        if (XVar.Pack(uploadedFile == null))
                                        {
                                            filesArray = XVar.Clone(XVar.Array());
                                        }
                                        else
                                        {
                                            filesArray = XVar.Clone(new XVar(0, MVCFunctions.my_json_decode((XVar)(MVCFunctions.my_json_encode((XVar)(uploadedFile))))));
                                        }
                                    }
                                }
                                foreach (KeyValuePair <XVar, dynamic> uploadedFile in filesArray.GetEnumerator())
                                {
                                    if (uploadedFile.Value["usrName"] == fileName)
                                    {
                                        sessionFile = XVar.Clone(uploadedFile.Value);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    iconShowed = new XVar(false);
                    if (XVar.Pack(isDBFile))
                    {
                        ftype = new XVar("");
                        if (pSet.getViewFormat((XVar)(field)) == Constants.FORMAT_DATABASE_IMAGE)
                        {
                            if (XVar.Pack(!(XVar)(value)))
                            {
                                value = XVar.Clone(MVCFunctions.myfile_get_contents(new XVar("images/no_image.gif")));
                            }
                            ftype = XVar.Clone(MVCFunctions.SupposeImageType((XVar)(value)));
                        }
                        if (XVar.Pack(!(XVar)(ftype)))
                        {
                            ftype = XVar.Clone(CommonFunctions.getContentTypeByExtension((XVar)(MVCFunctions.substr((XVar)(fileName), (XVar)(MVCFunctions.strrpos((XVar)(fileName), new XVar(".")))))));
                        }
                        fsize = XVar.Clone(MVCFunctions.strlen_bin((XVar)(value)));
                    }
                    else
                    {
                        if (sessionFile != null)
                        {
                            dynamic isSRC = null, isThumbnail = null;
                            isThumbnail = new XVar(false);
                            isSRC       = new XVar(false);
                            if (XVar.Pack(isPDF))
                            {
                                isThumbnail = XVar.Clone(var_params.KeyExists("thumbnail"));
                                isSRC       = XVar.Clone(var_params.KeyExists("src"));
                            }
                            else
                            {
                                isThumbnail = XVar.Clone(MVCFunctions.postvalue(new XVar("thumbnail")) != "");
                                isSRC       = XVar.Clone(MVCFunctions.postvalue(new XVar("src")) == 1);
                            }
                            if (MVCFunctions.postvalue(new XVar("icon")) != "")
                            {
                                fsFileName = XVar.Clone(MVCFunctions.Concat("images/icons/", CommonFunctions.getIconByFileType((XVar)(sessionFile["type"]), (XVar)(sessionFile["name"]))));
                                fsize      = XVar.Clone(MVCFunctions.filesize((XVar)(MVCFunctions.getabspath((XVar)(fsFileName)))));
                                ftype      = new XVar("image/png");
                            }
                            else
                            {
                                if ((XVar)((XVar)(isThumbnail) && (XVar)(sessionFile["thumbnail"])) && (XVar)(MVCFunctions.GDExist()))
                                {
                                    fsFileName = XVar.Clone(sessionFile["thumbnail"]);
                                    fsize      = XVar.Clone(sessionFile["thumbnail_size"]);
                                    ftype      = XVar.Clone(sessionFile["thumbnail_type"]);
                                }
                                else
                                {
                                    if ((XVar)((XVar)(false) && (XVar)((XVar)(pageType == Constants.PAGE_EDIT) || (XVar)(pageType == Constants.PAGE_ADD))) && (XVar)(isSRC))
                                    {
                                        iconShowed = new XVar(true);
                                        fsFileName = XVar.Clone(MVCFunctions.Concat("images/icons/", CommonFunctions.getIconByFileType((XVar)(sessionFile["type"]), (XVar)(sessionFile["name"]))));
                                        fsize      = XVar.Clone(MVCFunctions.filesize((XVar)(MVCFunctions.getabspath((XVar)(fsFileName)))));
                                        ftype      = new XVar("image/png");
                                    }
                                    else
                                    {
                                        fsFileName = XVar.Clone(sessionFile["name"]);
                                        fsize      = XVar.Clone(sessionFile["size"]);
                                        ftype      = XVar.Clone(sessionFile["type"]);
                                    }
                                }
                            }
                        }
                    }
                    if ((XVar)((XVar)(isDBFile) && (XVar)(value)) || (XVar)(fsFileName != XVar.Pack("")))
                    {
                        dynamic norange = null;
                        if (XVar.Pack(!(XVar)(isDBFile)))
                        {
                            if ((XVar)((XVar)(!(XVar)(pSet.isAbsolute((XVar)(field)))) && (XVar)(!(XVar)(MVCFunctions.isAbsolutePath((XVar)(fsFileName))))) || (XVar)(iconShowed))
                            {
                                fsFileName = XVar.Clone(MVCFunctions.getabspath((XVar)(fsFileName)));
                            }
                            if (XVar.Pack(!(XVar)(MVCFunctions.myfile_exists((XVar)(fsFileName)))))
                            {
                                fsFileName = XVar.Clone(MVCFunctions.getabspath(new XVar("images/no_image.gif")));
                                fsize      = XVar.Clone(MVCFunctions.filesize((XVar)(fsFileName)));
                                ftype      = new XVar("image/gif");
                            }
                        }
                        if (XVar.Pack(isPDF))
                        {
                            dynamic file = null;
                            if (XVar.Pack(isDBFile))
                            {
                                file = XVar.Clone(value);
                            }
                            else
                            {
                                file = XVar.Clone(MVCFunctions.myfile_get_contents((XVar)(fsFileName)));
                            }
                            return(MVCFunctions.GetBuferContentAndClearBufer());
                        }
                        norange = XVar.Clone(MVCFunctions.postvalue(new XVar("norange")) == 1);
                        if (MVCFunctions.postvalue(new XVar("norange")) == 1)
                        {
                            MVCFunctions.Header("Accept-Ranges", "none");
                            MVCFunctions.Header("Cache-Control", "private");
                            MVCFunctions.Header((XVar)(MVCFunctions.Concat("Content-Type: ", ftype)));
                            MVCFunctions.Header("Access-Control-Allow-Methods", "HEAD, GET, POST");
                            if (XVar.Pack(outputAsAttachment))
                            {
                                MVCFunctions.Header((XVar)(MVCFunctions.Concat("Content-Disposition: attachment;Filename=\"", fileName, "\"")));
                            }
                            MVCFunctions.SendContentLength((XVar)(fsize));
                            if (MVCFunctions.GetServerVariable("REQUEST_METHOD") == "HEAD")
                            {
                                MVCFunctions.Echo(new XVar(""));
                                return(MVCFunctions.GetBuferContentAndClearBufer());
                            }
                            if (XVar.Pack(isDBFile))
                            {
                                MVCFunctions.echoBinary((XVar)(value));
                            }
                            else
                            {
                                MVCFunctions.printfile((XVar)(fsFileName));
                            }
                        }
                        else
                        {
                            dynamic httpRange = null, printContentLength = null, range = null, range_orig = null, seek_end = null, seek_start = null, size_unit = null, tmparr = XVar.Array();
                            size_unit  = new XVar("");
                            range_orig = new XVar("");
                            httpRange  = XVar.Clone(MVCFunctions.GetHttpRange());
                            if (XVar.Pack(MVCFunctions.preg_match(new XVar("/^bytes=((\\d*-\\d*,? ?)+)$/"), (XVar)(httpRange))))
                            {
                                tmparr     = XVar.Clone(MVCFunctions.explode(new XVar("="), (XVar)(httpRange)));
                                size_unit  = XVar.Clone(tmparr[0]);
                                range_orig = XVar.Clone(tmparr[1]);
                            }
                            if (size_unit == "bytes")
                            {
                                if (!XVar.Equals(XVar.Pack(MVCFunctions.strpos((XVar)(range_orig), new XVar(","))), XVar.Pack(false)))
                                {
                                    dynamic extra_ranges = null;
                                    tmparr       = XVar.Clone(MVCFunctions.explode(new XVar(","), (XVar)(range_orig)));
                                    range        = XVar.Clone(tmparr[0]);
                                    extra_ranges = XVar.Clone(tmparr[1]);
                                }
                                else
                                {
                                    range = XVar.Clone(range_orig);
                                }
                            }
                            else
                            {
                                range = new XVar("-");
                            }
                            tmparr     = XVar.Clone(MVCFunctions.explode(new XVar("-"), (XVar)(range)));
                            seek_start = XVar.Clone(tmparr[0]);
                            seek_end   = XVar.Clone(tmparr[1]);
                            seek_end   = XVar.Clone((XVar.Pack(MVCFunctions.strlen((XVar)(seek_end)) == 0) ? XVar.Pack(fsize - 1) : XVar.Pack(MVCFunctions.min((XVar)(MVCFunctions.abs((XVar)(MVCFunctions.intval((XVar)(seek_end))))), (XVar)(fsize - 1)))));
                            seek_start = XVar.Clone((XVar.Pack((XVar)(MVCFunctions.strlen((XVar)(seek_start)) == 0) || (XVar)(seek_end < MVCFunctions.abs((XVar)(MVCFunctions.intval((XVar)(seek_start)))))) ? XVar.Pack(0) : XVar.Pack(MVCFunctions.max((XVar)(MVCFunctions.abs((XVar)(MVCFunctions.intval((XVar)(seek_start))))), new XVar(0)))));
                            if ((XVar)(XVar.Pack(0) < seek_start) || (XVar)(seek_end < fsize - 1))
                            {
                                MVCFunctions.Header(new XVar("HTTP/1.1 206 Partial Content"));
                            }
                            MVCFunctions.Header("Accept-Ranges", "bytes");
                            MVCFunctions.Header((XVar)(MVCFunctions.Concat("Content-Range: bytes ", seek_start, "-", seek_end, "/", fsize)));
                            if (XVar.Pack(outputAsAttachment))
                            {
                                MVCFunctions.Header((XVar)(MVCFunctions.Concat("Content-Disposition: attachment;Filename=\"", fileName, "\"")));
                            }
                            printContentLength = new XVar(true);
                            if (XVar.Pack(printContentLength))
                            {
                                MVCFunctions.Header((XVar)(MVCFunctions.Concat("Content-Length: ", (seek_end - seek_start) + 1)));
                            }
                            MVCFunctions.Header("Cache-Control", "cache, must-revalidate");
                            MVCFunctions.Header("Pragma", "public");
                            MVCFunctions.Header((XVar)(MVCFunctions.Concat("Content-Type: ", ftype)));
                            if (MVCFunctions.GetServerVariable("REQUEST_METHOD") == "HEAD")
                            {
                                MVCFunctions.Echo(new XVar(""));
                                return(MVCFunctions.GetBuferContentAndClearBufer());
                            }
                            if (XVar.Pack(isDBFile))
                            {
                                MVCFunctions.echoBinaryPartial((XVar)(value), (XVar)(seek_start), (XVar)(seek_end));
                            }
                            else
                            {
                                MVCFunctions.printfileByRange((XVar)(fsFileName), (XVar)(seek_start), (XVar)(seek_end));
                            }
                        }
                    }
                    break;
                }
                MVCFunctions.Echo(new XVar(""));
                return(MVCFunctions.GetBuferContentAndClearBufer());
            }
            catch (RunnerRedirectException ex)
            { return(Redirect(ex.Message)); }
        }