protected virtual XVar prepareButtons() { dynamic editable = null; if (XVar.Pack(this.pdfMode)) { return(null); } prepareNextPrevButtons(); if (this.mode == Constants.VIEW_DASHBOARD) { if (getLayoutVersion() == Constants.BOOTSTRAP_LAYOUT) { this.xt.assign(new XVar("groupbutton_class"), new XVar("rnr-invisible-button")); } return(null); } if (this.mode == Constants.VIEW_SIMPLE) { if (XVar.Pack(this.pSet.hasListPage())) { this.xt.assign(new XVar("back_button"), new XVar(true)); this.xt.assign(new XVar("backbutton_attrs"), (XVar)(MVCFunctions.Concat("id=\"backButton", this.id, "\""))); this.xt.assign(new XVar("mbackbutton_attrs"), (XVar)(MVCFunctions.Concat("id=\"extraBackButton", this.id, "\""))); } else { if (XVar.Pack(isShowMenu())) { this.xt.assign(new XVar("back_button"), new XVar(true)); this.xt.assign(new XVar("backbutton_attrs"), (XVar)(MVCFunctions.Concat("id=\"backToMenuButton", this.id, "\""))); } } } if (this.mode == Constants.VIEW_POPUP) { this.xt.assign(new XVar("close_button"), new XVar(true)); this.xt.assign(new XVar("closebutton_attrs"), (XVar)(MVCFunctions.Concat("id=\"closeButton", this.id, "\""))); } editable = new XVar(false); if (XVar.Pack(editAvailable())) { dynamic data = XVar.Array(); data = XVar.Clone(getCurrentRecordInternal()); editable = XVar.Clone(CommonFunctions.CheckSecurity((XVar)(data[this.pSet.getTableOwnerID()]), new XVar("Edit"))); if (XVar.Pack(GlobalVars.globalEvents.exists(new XVar("IsRecordEditable"), (XVar)(this.tName)))) { editable = XVar.Clone(GlobalVars.globalEvents.IsRecordEditable((XVar)(getCurrentRecordInternal()), (XVar)(editable), (XVar)(this.tName))); } if (XVar.Pack(editable)) { this.xt.assign(new XVar("edit_page_button"), new XVar(true)); this.xt.assign(new XVar("edit_page_button_attrs"), (XVar)(MVCFunctions.Concat("id=\"editPageButton", this.id, "\""))); this.xt.assign(new XVar("header_edit_page_button_attrs"), (XVar)(MVCFunctions.Concat("id=\"headerEditPageButton", this.id, "\""))); } } this.xt.assign(new XVar("view_menu_button"), (XVar)((XVar)(editable) || (XVar)(this.viewPdfEnabled))); return(null); }
public XVar detreccount() { try { dynamic dInd = null, dSTable = null, dTable = null, mKeys = null, mSTable = null, mTable = null, output = null, pageObject = null, pageType = null, respObj = null, var_params = XVar.Array(); XTempl xt; MVCFunctions.Header("Expires", "Thu, 01 Jan 1970 00:00:01 GMT"); mSTable = XVar.Clone(MVCFunctions.postvalue(new XVar("mSTable"))); if (XVar.Pack(!(XVar)(CommonFunctions.checkTableName((XVar)(mSTable))))) { respObj = XVar.Clone(new XVar("success", false, "error", "Wrong master short table name")); MVCFunctions.Echo(MVCFunctions.my_json_encode((XVar)(respObj))); return(MVCFunctions.GetBuferContentAndClearBufer()); } Assembly.GetExecutingAssembly().GetType(MVCFunctions.Concat("runnerDotNet.", MVCFunctions.Concat("", mSTable, ""), "_Variables")).InvokeMember("Apply", BindingFlags.InvokeMethod, null, null, null); dSTable = XVar.Clone(MVCFunctions.postvalue(new XVar("dSTable"))); if (XVar.Pack(!(XVar)(CommonFunctions.checkTableName((XVar)(dSTable))))) { respObj = XVar.Clone(new XVar("success", false, "error", "Wrong detail short table name")); MVCFunctions.Echo(MVCFunctions.my_json_encode((XVar)(respObj))); return(MVCFunctions.GetBuferContentAndClearBufer()); } Assembly.GetExecutingAssembly().GetType(MVCFunctions.Concat("runnerDotNet.", MVCFunctions.Concat("", dSTable, ""), "_Variables")).InvokeMember("Apply", BindingFlags.InvokeMethod, null, null, null); if ((XVar)(!(XVar)(CommonFunctions.isLogged())) || (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Search"))))) { respObj = XVar.Clone(new XVar("success", false, "error", "")); MVCFunctions.Echo(MVCFunctions.my_json_encode((XVar)(respObj))); return(MVCFunctions.GetBuferContentAndClearBufer()); } mKeys = XVar.Clone(MVCFunctions.my_json_decode((XVar)(MVCFunctions.postvalue(new XVar("mKeys"))))); mTable = XVar.Clone(MVCFunctions.postvalue(new XVar("mTable"))); dTable = XVar.Clone(MVCFunctions.postvalue(new XVar("dTable"))); pageType = XVar.Clone(MVCFunctions.postvalue(new XVar("pageType"))); xt = XVar.UnPackXTempl(new XTempl()); var_params = XVar.Clone(new XVar("pageType", pageType)); var_params.InitAndSetArrayItem(xt, "xt"); var_params.InitAndSetArrayItem(mTable, "tName"); var_params.InitAndSetArrayItem(false, "needSearchClauseObj"); pageObject = XVar.Clone(new RunnerPage((XVar)(var_params))); dInd = new XVar(0); for (; dInd < MVCFunctions.count(pageObject.allDetailsTablesArr); dInd++) { if (pageObject.allDetailsTablesArr[dInd]["dDataSourceTable"] == dTable) { break; } } output = XVar.Clone(pageObject.countDetailsRecsNoSubQ((XVar)(dInd), (XVar)(mKeys))); respObj = XVar.Clone(new XVar("success", true, "recsCount", output)); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(respObj))); return(MVCFunctions.GetBuferContentAndClearBufer()); } catch (RunnerRedirectException ex) { return(Redirect(ex.Message)); } }
public ActionResult detailspreview() { try { dynamic masterKeys = XVar.Array(), mastertable = null, mode = null, pageObject = null, query = null, recordsCounter = null, returnJSON = XVar.Array(), rowcount = null, sessionPrefix = null, var_params = XVar.Array(), whereClauses = XVar.Array(); ProjectSettings pSet; XTempl xt; dbo__ABCVotes_Variables.Apply(); MVCFunctions.Header("Expires", "Thu, 01 Jan 1970 00:00:01 GMT"); mode = XVar.Clone(MVCFunctions.postvalue(new XVar("mode"))); if (XVar.Pack(!(XVar)(CommonFunctions.isLogged()))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } if (XVar.Pack(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Search"))))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } GlobalVars.cipherer = XVar.Clone(new RunnerCipherer((XVar)(GlobalVars.strTableName))); xt = XVar.UnPackXTempl(new XTempl()); { TLayout t_layout = null; t_layout = new TLayout(new XVar("detailspreview"), new XVar("AvenueAvenue"), new XVar("MobileAvenue")); t_layout.version = 2; t_layout.blocks["bare"] = XVar.Array(); t_layout.containers["dcount"] = XVar.Array(); t_layout.containers["dcount"].Add(new XVar("name", "detailspreviewheader", "block", "", "substyle", 1)); t_layout.containers["dcount"].Add(new XVar("name", "detailspreviewdetailsfount", "block", "", "substyle", 1)); t_layout.containers["dcount"].Add(new XVar("name", "detailspreviewdispfirst", "block", "display_first", "substyle", 1)); t_layout.skins["dcount"] = "empty"; t_layout.blocks["bare"].Add("dcount"); t_layout.containers["detailspreviewgrid"] = XVar.Array(); t_layout.containers["detailspreviewgrid"].Add(new XVar("name", "detailspreviewfields", "block", "details_data", "substyle", 1)); t_layout.skins["detailspreviewgrid"] = "grid"; t_layout.blocks["bare"].Add("detailspreviewgrid"); GlobalVars.page_layouts["dbo__ABCVotes_detailspreview"] = t_layout; t_layout.skinsparams = XVar.Array(); t_layout.skinsparams["empty"] = XVar.Array(); t_layout.skinsparams["empty"]["button"] = "button2"; t_layout.skinsparams["menu"] = XVar.Array(); t_layout.skinsparams["menu"]["button"] = "button1"; t_layout.skinsparams["hmenu"] = XVar.Array(); t_layout.skinsparams["hmenu"]["button"] = "button1"; t_layout.skinsparams["undermenu"] = XVar.Array(); t_layout.skinsparams["undermenu"]["button"] = "button1"; t_layout.skinsparams["fields"] = XVar.Array(); t_layout.skinsparams["fields"]["button"] = "button1"; t_layout.skinsparams["form"] = XVar.Array(); t_layout.skinsparams["form"]["button"] = "button1"; t_layout.skinsparams["1"] = XVar.Array(); t_layout.skinsparams["1"]["button"] = "button1"; t_layout.skinsparams["2"] = XVar.Array(); t_layout.skinsparams["2"]["button"] = "button1"; t_layout.skinsparams["3"] = XVar.Array(); t_layout.skinsparams["3"]["button"] = "button1"; } recordsCounter = new XVar(0); mastertable = XVar.Clone(MVCFunctions.postvalue(new XVar("mastertable"))); masterKeys = XVar.Clone(MVCFunctions.my_json_decode((XVar)(MVCFunctions.postvalue(new XVar("masterKeys"))))); sessionPrefix = new XVar("_detailsPreview"); if (mastertable != XVar.Pack("")) { dynamic i = null; XSession.Session[MVCFunctions.Concat(sessionPrefix, "_mastertable")] = mastertable; i = new XVar(1); if ((XVar)(MVCFunctions.is_array((XVar)(masterKeys))) && (XVar)(0 < MVCFunctions.count(masterKeys))) { while (XVar.Pack(masterKeys.KeyExists(MVCFunctions.Concat("masterkey", i)))) { XSession.Session[MVCFunctions.Concat(sessionPrefix, "_masterkey", i)] = masterKeys[MVCFunctions.Concat("masterkey", i)]; i++; } } if (XVar.Pack(XSession.Session.KeyExists(MVCFunctions.Concat(sessionPrefix, "_masterkey", i)))) { XSession.Session.Remove(MVCFunctions.Concat(sessionPrefix, "_masterkey", i)); } } else { mastertable = XVar.Clone(XSession.Session[MVCFunctions.Concat(sessionPrefix, "_mastertable")]); } var_params = XVar.Clone(XVar.Array()); var_params.InitAndSetArrayItem(1, "id"); var_params.InitAndSetArrayItem(xt, "xt"); var_params.InitAndSetArrayItem(GlobalVars.strTableName, "tName"); var_params.InitAndSetArrayItem("detailspreview", "pageType"); GlobalVars.pageObject = XVar.Clone(new DetailsPreview((XVar)(var_params))); pSet = XVar.UnPackProjectSettings(new ProjectSettings((XVar)(GlobalVars.strTableName), new XVar(Constants.PAGE_LIST))); whereClauses = XVar.Clone(XVar.Array()); if (mastertable == "dbo._ABCReports") { dynamic formattedValue = null; formattedValue = XVar.Clone(CommonFunctions.make_db_value(new XVar("record"), (XVar)(XSession.Session[MVCFunctions.Concat(sessionPrefix, "_masterkey1")]))); if (formattedValue == "null") { whereClauses.InitAndSetArrayItem(MVCFunctions.Concat(GlobalVars.pageObject.getFieldSQLDecrypt(new XVar("record")), " is null"), null); } else { whereClauses.InitAndSetArrayItem(MVCFunctions.Concat(GlobalVars.pageObject.getFieldSQLDecrypt(new XVar("record")), "=", formattedValue), null); } } if (mastertable == "ABC_Voting_Submitted") { dynamic formattedValue = null; formattedValue = XVar.Clone(CommonFunctions.make_db_value(new XVar("record"), (XVar)(XSession.Session[MVCFunctions.Concat(sessionPrefix, "_masterkey1")]))); if (formattedValue == "null") { whereClauses.InitAndSetArrayItem(MVCFunctions.Concat(GlobalVars.pageObject.getFieldSQLDecrypt(new XVar("record")), " is null"), null); } else { whereClauses.InitAndSetArrayItem(MVCFunctions.Concat(GlobalVars.pageObject.getFieldSQLDecrypt(new XVar("record")), "=", formattedValue), null); } } if (mastertable == "ABC_Voting_Recirculated") { dynamic formattedValue = null; formattedValue = XVar.Clone(CommonFunctions.make_db_value(new XVar("record"), (XVar)(XSession.Session[MVCFunctions.Concat(sessionPrefix, "_masterkey1")]))); if (formattedValue == "null") { whereClauses.InitAndSetArrayItem(MVCFunctions.Concat(GlobalVars.pageObject.getFieldSQLDecrypt(new XVar("record")), " is null"), null); } else { whereClauses.InitAndSetArrayItem(MVCFunctions.Concat(GlobalVars.pageObject.getFieldSQLDecrypt(new XVar("record")), "=", formattedValue), null); } } if (mastertable == "ABC_Voting_My_Voting") { dynamic formattedValue = null; formattedValue = XVar.Clone(CommonFunctions.make_db_value(new XVar("record"), (XVar)(XSession.Session[MVCFunctions.Concat(sessionPrefix, "_masterkey1")]))); if (formattedValue == "null") { whereClauses.InitAndSetArrayItem(MVCFunctions.Concat(GlobalVars.pageObject.getFieldSQLDecrypt(new XVar("record")), " is null"), null); } else { whereClauses.InitAndSetArrayItem(MVCFunctions.Concat(GlobalVars.pageObject.getFieldSQLDecrypt(new XVar("record")), "=", formattedValue), null); } } if (mastertable == "dbo.vwABCReportsVoteCount") { dynamic formattedValue = null; formattedValue = XVar.Clone(CommonFunctions.make_db_value(new XVar("record"), (XVar)(XSession.Session[MVCFunctions.Concat(sessionPrefix, "_masterkey1")]))); if (formattedValue == "null") { whereClauses.InitAndSetArrayItem(MVCFunctions.Concat(GlobalVars.pageObject.getFieldSQLDecrypt(new XVar("record")), " is null"), null); } else { whereClauses.InitAndSetArrayItem(MVCFunctions.Concat(GlobalVars.pageObject.getFieldSQLDecrypt(new XVar("record")), "=", formattedValue), null); } } whereClauses.InitAndSetArrayItem(CommonFunctions.SecuritySQL(new XVar("Search"), (XVar)(GlobalVars.strTableName)), null); query = XVar.Clone(pSet.getSQLQuery()); GlobalVars.strSQL = XVar.Clone(query.buildSQL_default((XVar)(whereClauses))); rowcount = XVar.Clone(GlobalVars.pageObject.connection.getFetchedRowsNumber((XVar)(GlobalVars.strSQL))); GlobalVars.strSQL = MVCFunctions.Concat(GlobalVars.strSQL, GlobalVars.pageObject.getOrderByClause()); xt.assign(new XVar("row_count"), (XVar)(rowcount)); if (XVar.Pack(rowcount)) { dynamic b = null, data = XVar.Array(), display_count = null, format = null, keylink = null, qResult = null, row = XVar.Array(), rowinfo = XVar.Array(), rowinfo2 = XVar.Array(), value = null, var_class = null, viewContainer = null; xt.assign(new XVar("details_data"), new XVar(true)); display_count = new XVar(10); if (mode == "inline") { display_count *= 2; } if (display_count + 2 < rowcount) { xt.assign(new XVar("display_first"), new XVar(true)); xt.assign(new XVar("display_count"), (XVar)(display_count)); } else { display_count = XVar.Clone(rowcount); } rowinfo = XVar.Clone(XVar.Array()); viewContainer = XVar.Clone(new ViewControlsContainer((XVar)(pSet), new XVar(Constants.PAGE_LIST))); viewContainer.isDetailsPreview = new XVar(true); b = new XVar(true); qResult = XVar.Clone(GlobalVars.pageObject.connection.query((XVar)(GlobalVars.strSQL))); data = XVar.Clone(GlobalVars.cipherer.DecryptFetchedArray((XVar)(qResult.fetchAssoc()))); while ((XVar)(data) && (XVar)(recordsCounter < display_count)) { recordsCounter++; row = XVar.Clone(XVar.Array()); keylink = new XVar(""); keylink = MVCFunctions.Concat(keylink, "&key1=", MVCFunctions.runner_htmlspecialchars((XVar)(MVCFunctions.RawUrlEncode((XVar)(data["id"]))))); keylink = MVCFunctions.Concat(keylink, "&key2=", MVCFunctions.runner_htmlspecialchars((XVar)(MVCFunctions.RawUrlEncode((XVar)(data["record"]))))); viewContainer.recId = XVar.Clone(recordsCounter); value = XVar.Clone(viewContainer.showDBValue(new XVar("committee_member"), (XVar)(data), (XVar)(keylink))); row.InitAndSetArrayItem(value, "committee_member_value"); format = XVar.Clone(pSet.getViewFormat(new XVar("committee_member"))); var_class = new XVar("rnr-field-text"); if (format == Constants.FORMAT_FILE) { var_class = new XVar(" rnr-field-file"); } if (format == Constants.FORMAT_AUDIO) { var_class = new XVar(" rnr-field-audio"); } if (format == Constants.FORMAT_CHECKBOX) { var_class = new XVar(" rnr-field-checkbox"); } if ((XVar)(format == Constants.FORMAT_NUMBER) || (XVar)(CommonFunctions.IsNumberType((XVar)(pSet.getFieldType(new XVar("committee_member")))))) { var_class = new XVar(" rnr-field-number"); } row.InitAndSetArrayItem(var_class, "committee_member_class"); viewContainer.recId = XVar.Clone(recordsCounter); value = XVar.Clone(viewContainer.showDBValue(new XVar("date_voted"), (XVar)(data), (XVar)(keylink))); row.InitAndSetArrayItem(value, "date_voted_value"); format = XVar.Clone(pSet.getViewFormat(new XVar("date_voted"))); var_class = new XVar("rnr-field-text"); if (format == Constants.FORMAT_FILE) { var_class = new XVar(" rnr-field-file"); } if (format == Constants.FORMAT_AUDIO) { var_class = new XVar(" rnr-field-audio"); } if (format == Constants.FORMAT_CHECKBOX) { var_class = new XVar(" rnr-field-checkbox"); } if ((XVar)(format == Constants.FORMAT_NUMBER) || (XVar)(CommonFunctions.IsNumberType((XVar)(pSet.getFieldType(new XVar("date_voted")))))) { var_class = new XVar(" rnr-field-number"); } row.InitAndSetArrayItem(var_class, "date_voted_class"); viewContainer.recId = XVar.Clone(recordsCounter); value = XVar.Clone(viewContainer.showDBValue(new XVar("vote"), (XVar)(data), (XVar)(keylink))); row.InitAndSetArrayItem(value, "vote_value"); format = XVar.Clone(pSet.getViewFormat(new XVar("vote"))); var_class = new XVar("rnr-field-text"); if (format == Constants.FORMAT_FILE) { var_class = new XVar(" rnr-field-file"); } if (format == Constants.FORMAT_AUDIO) { var_class = new XVar(" rnr-field-audio"); } if (format == Constants.FORMAT_CHECKBOX) { var_class = new XVar(" rnr-field-checkbox"); } if ((XVar)(format == Constants.FORMAT_NUMBER) || (XVar)(CommonFunctions.IsNumberType((XVar)(pSet.getFieldType(new XVar("vote")))))) { var_class = new XVar(" rnr-field-number"); } row.InitAndSetArrayItem(var_class, "vote_class"); viewContainer.recId = XVar.Clone(recordsCounter); value = XVar.Clone(viewContainer.showDBValue(new XVar("comment"), (XVar)(data), (XVar)(keylink))); row.InitAndSetArrayItem(value, "comment_value"); format = XVar.Clone(pSet.getViewFormat(new XVar("comment"))); var_class = new XVar("rnr-field-text"); if (format == Constants.FORMAT_FILE) { var_class = new XVar(" rnr-field-file"); } if (format == Constants.FORMAT_AUDIO) { var_class = new XVar(" rnr-field-audio"); } if (format == Constants.FORMAT_CHECKBOX) { var_class = new XVar(" rnr-field-checkbox"); } if ((XVar)(format == Constants.FORMAT_NUMBER) || (XVar)(CommonFunctions.IsNumberType((XVar)(pSet.getFieldType(new XVar("comment")))))) { var_class = new XVar(" rnr-field-number"); } row.InitAndSetArrayItem(var_class, "comment_class"); rowinfo.InitAndSetArrayItem(row, null); if (XVar.Pack(b)) { rowinfo2.InitAndSetArrayItem(row, null); b = new XVar(false); } data = XVar.Clone(GlobalVars.cipherer.DecryptFetchedArray((XVar)(qResult.fetchAssoc()))); } xt.assign_loopsection(new XVar("details_row"), (XVar)(rowinfo)); xt.assign_loopsection(new XVar("details_row_header"), (XVar)(rowinfo2)); } returnJSON = XVar.Clone(new XVar("success", true)); xt.load_template((XVar)(MVCFunctions.GetTemplateName(new XVar("dbo__ABCVotes"), new XVar("detailspreview")))); returnJSON.InitAndSetArrayItem(xt.fetch_loaded(), "body"); if (mode != "inline") { dynamic layout = null; returnJSON.InitAndSetArrayItem(MVCFunctions.postvalue(new XVar("counter")), "counter"); layout = XVar.Clone(CommonFunctions.GetPageLayout((XVar)(MVCFunctions.GoodFieldName((XVar)(GlobalVars.strTableName))), new XVar("detailspreview"))); if (XVar.Pack(layout)) { foreach (KeyValuePair <XVar, dynamic> css in layout.getCSSFiles((XVar)(CommonFunctions.isRTL()), (XVar)((XVar)(CommonFunctions.mobileDeviceDetected()) && (XVar)(layout.version != Constants.BOOTSTRAP_LAYOUT))).GetEnumerator()) { returnJSON.InitAndSetArrayItem(css.Value, "CSSFiles", null); } } } MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(returnJSON))); MVCFunctions.Echo(new XVar("")); return(MVCFunctions.GetBuferContentAndClearBufer()); } catch (RunnerRedirectException ex) { return(Redirect(ex.Message)); } }
public XVar rte() { try { dynamic _connection = null, cfield = null, data = XVar.Array(), field = null, id = null, nHeight = null, nWidth = null, onsubmit = null, ptype = null, table = null; ProjectSettings pSet; table = XVar.Clone(MVCFunctions.postvalue(new XVar("table"))); if (XVar.Pack(!(XVar)(CommonFunctions.checkTableName((XVar)(table))))) { MVCFunctions.Echo(new XVar(0)); return(MVCFunctions.GetBuferContentAndClearBufer()); } Assembly.GetExecutingAssembly().GetType(MVCFunctions.Concat("runnerDotNet.", MVCFunctions.Concat("", table, ""), "_Variables")).InvokeMember("Apply", BindingFlags.InvokeMethod, null, null, null); if ((XVar)((XVar)(!(XVar)(CommonFunctions.isLogged())) || (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Search"))))) && (XVar)(MVCFunctions.postvalue("action") != "add")) { return(MVCFunctions.GetBuferContentAndClearBufer()); } ptype = XVar.Clone(MVCFunctions.postvalue(new XVar("ptype"))); field = XVar.Clone(MVCFunctions.postvalue(new XVar("field"))); pSet = XVar.UnPackProjectSettings(new ProjectSettings((XVar)(GlobalVars.strTableName), (XVar)(ptype))); if ((XVar)(!(XVar)(pSet.checkFieldPermissions((XVar)(field)))) && (XVar)(MVCFunctions.postvalue("action") != "add")) { return(MVCFunctions.GetBuferContentAndClearBufer()); } _connection = XVar.Clone(GlobalVars.cman.byTable((XVar)(GlobalVars.strTableName))); data = new XVar(false); if (MVCFunctions.postvalue("action") != "add") { dynamic keys = XVar.Array(), keysArr = XVar.Array(), qResult = null, sql = null, where = null; keysArr = XVar.Clone(pSet.getTableKeys()); keys = XVar.Clone(XVar.Array()); foreach (KeyValuePair <XVar, dynamic> k in keysArr.GetEnumerator()) { keys.InitAndSetArrayItem(MVCFunctions.postvalue((XVar)(MVCFunctions.Concat("key", k.Key + 1))), k.Value); } where = XVar.Clone(CommonFunctions.KeyWhere((XVar)(keys))); if (pSet.getAdvancedSecurityType() == Constants.ADVSECURITY_VIEW_OWN) { where = XVar.Clone(CommonFunctions.whereAdd((XVar)(where), (XVar)(CommonFunctions.SecuritySQL(new XVar("Search"), (XVar)(GlobalVars.strTableName))))); } sql = XVar.Clone(GlobalVars.gQuery.gSQLWhere((XVar)(where))); qResult = XVar.Clone(_connection.query((XVar)(sql))); if (XVar.Pack(!(XVar)(qResult))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } data = XVar.Clone(qResult.fetchAssoc()); } else { data = XVar.Clone(XVar.Array()); data.InitAndSetArrayItem(XSession.Session[MVCFunctions.Concat(GlobalVars.strTableName, "_", field, "_rte")], field); } nWidth = XVar.Clone(pSet.getNCols((XVar)(field))); nHeight = XVar.Clone(pSet.getNRows((XVar)(field))); id = XVar.Clone(MVCFunctions.postvalue(new XVar("id"))); cfield = XVar.Clone(MVCFunctions.Concat("value_", MVCFunctions.GoodFieldName((XVar)(field)), "_", (XVar.Pack(!XVar.Equals(XVar.Pack(id), XVar.Pack(""))) ? XVar.Pack(id) : XVar.Pack("1")))); if (MVCFunctions.postvalue("browser") == "ie") { onsubmit = new XVar("onsubmit=\"updateRTEs();\""); } else { onsubmit = XVar.Clone(MVCFunctions.Concat("onsubmit=\"updateRTEs();return this.elements['", cfield, "'].value;\"")); } MVCFunctions.Echo(MVCFunctions.Concat("<html><body style=\"margin:0;\"><form name=\"rteform\" ", onsubmit, ">")); MVCFunctions.Echo(MVCFunctions.Concat("<script type=\"text/javascript\" src=\"", MVCFunctions.GetRootPathForResources(new XVar("include/rte/richtext.js")), "\"></script>\r\n")); MVCFunctions.Echo("<script language=\"JavaScript\" type=\"text/javascript\">"); MVCFunctions.Echo("initRTE('include/rte/images/', 'include/rte/', '');\r\n"); MVCFunctions.Echo(MVCFunctions.Concat("{var rte = new richTextEditor('", cfield, "');")); MVCFunctions.Echo(MVCFunctions.Concat("rte.width= ", nWidth, ";")); MVCFunctions.Echo(MVCFunctions.Concat("rte.height= ", nHeight, ";")); MVCFunctions.Echo("rte.html = '"); if ((XVar)(data) && (XVar)(data[field] != null)) { MVCFunctions.Echo(CommonFunctions.jsreplace((XVar)(data[field]))); } MVCFunctions.Echo("';"); MVCFunctions.Echo("rte.build();}"); MVCFunctions.Echo("</script>"); MVCFunctions.Echo("</form></body></html>"); return(MVCFunctions.GetBuferContentAndClearBufer()); } catch (RunnerRedirectException ex) { return(Redirect(ex.Message)); } }
public XVar lookupsuggest() { try { dynamic LookupSQL = null, LookupSQLTable = null, LookupType = null, contextParams = XVar.Array(), data = XVar.Array(), displayFieldIndex = null, displayFieldName = null, field = null, isExistParent = null, likeConditionField = null, likeField = null, likeWheres = XVar.Array(), linkAndDisplaySame = null, linkFieldIndex = null, linkFieldName = null, lookupCipherer = null, lookupConnection = null, lookupField = null, lookupIndices = XVar.Array(), lookupOrderBy = null, lookupPSet = null, lookupQueryObj = null, lookupTable = null, lwDisplayField = null, masterTable = null, pageType = null, parentCtrlsData = XVar.Array(), qResult = null, respObj = null, searchByLinkField = null, strLookupWhere = null, strUniqueOrderBy = null, table = null, value = null, values = XVar.Array(), var_response = XVar.Array(); MVCFunctions.Header("Expires", "Thu, 01 Jan 1970 00:00:01 GMT"); table = XVar.Clone(MVCFunctions.postvalue(new XVar("table"))); if (XVar.Pack(!(XVar)(CommonFunctions.checkTableName((XVar)(table))))) { MVCFunctions.Echo(new XVar(0)); return(MVCFunctions.GetBuferContentAndClearBufer()); } Assembly.GetExecutingAssembly().GetType(MVCFunctions.Concat("runnerDotNet.", MVCFunctions.Concat("", table, ""), "_Variables")).InvokeMember("Apply", BindingFlags.InvokeMethod, null, null, null); pageType = XVar.Clone(MVCFunctions.postvalue(new XVar("pageType"))); GlobalVars.strTableName = XVar.Clone(CommonFunctions.GetTableByShort((XVar)(table))); GlobalVars.cipherer = XVar.Clone(new RunnerCipherer((XVar)(GlobalVars.strTableName))); GlobalVars.gSettings = XVar.Clone(new ProjectSettings((XVar)(GlobalVars.strTableName), (XVar)(pageType))); field = XVar.Clone(MVCFunctions.postvalue(new XVar("searchField"))); if (GlobalVars.gSettings.getEntityType() == Constants.titDASHBOARD) { dynamic dashFields = XVar.Array(); dashFields = XVar.Clone(GlobalVars.gSettings.getDashboardSearchFields()); table = XVar.Clone(MVCFunctions.GoodFieldName((XVar)(dashFields[field][0]["table"]))); GlobalVars.strTableName = XVar.Clone(CommonFunctions.GetTableByShort((XVar)(table))); field = XVar.Clone(MVCFunctions.GoodFieldName((XVar)(dashFields[field][0]["field"]))); if (XVar.Pack(!(XVar)(CommonFunctions.checkTableName((XVar)(table))))) { MVCFunctions.Echo(new XVar(0)); return(MVCFunctions.GetBuferContentAndClearBufer()); } Assembly.GetExecutingAssembly().GetType(MVCFunctions.Concat("runnerDotNet.", MVCFunctions.Concat("", table, ""), "_Variables")).InvokeMember("Apply", BindingFlags.InvokeMethod, null, null, null); GlobalVars.cipherer = XVar.Clone(new RunnerCipherer((XVar)(GlobalVars.strTableName))); GlobalVars.gSettings = XVar.Clone(new ProjectSettings((XVar)(GlobalVars.strTableName), (XVar)(pageType))); } masterTable = XVar.Clone(MVCFunctions.postvalue(new XVar("masterTable"))); if ((XVar)(masterTable != XVar.Pack("")) && (XVar)(XSession.Session.KeyExists(MVCFunctions.Concat(masterTable, "_masterRecordData")))) { contextParams.InitAndSetArrayItem(XSession.Session[MVCFunctions.Concat(masterTable, "_masterRecordData")], "masterData"); } contextParams.InitAndSetArrayItem(MVCFunctions.my_json_decode((XVar)(MVCFunctions.postvalue(new XVar("data")))), "data"); RunnerContext.push((XVar)(new RunnerContextItem((XVar)(pageType), (XVar)(contextParams)))); if (GlobalVars.strTableName != "dbo._ABCSecurity") { if (XVar.Pack(!(XVar)(CommonFunctions.isLogged()))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } if ((XVar)((XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Edit")))) && (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Add"))))) && (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Search"))))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } } else { dynamic checkResult = null; checkResult = new XVar(true); if (field == "username") { checkResult = new XVar(false); } if (field == "password") { checkResult = new XVar(false); } if (XVar.Pack(checkResult)) { if (XVar.Pack(!(XVar)(CommonFunctions.isLogged()))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } if ((XVar)((XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Edit")))) && (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Add"))))) && (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Search"))))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } } } isExistParent = XVar.Clone(MVCFunctions.postvalue(new XVar("isExistParent"))); searchByLinkField = XVar.Clone(MVCFunctions.postvalue(new XVar("searchByLinkField"))); parentCtrlsData = XVar.Clone(MVCFunctions.my_json_decode((XVar)(MVCFunctions.postvalue(new XVar("parentCtrlsData"))))); value = XVar.Clone(MVCFunctions.postvalue(new XVar("searchFor"))); values = XVar.Clone((XVar.Pack(MVCFunctions.postvalue(new XVar("multiselection"))) ? XVar.Pack(CommonFunctions.splitvalues((XVar)(value))) : XVar.Pack(new XVar(0, value)))); lookupField = new XVar(""); foreach (KeyValuePair <XVar, dynamic> f in GlobalVars.gSettings.getFieldsList().GetEnumerator()) { if ((XVar)(MVCFunctions.GoodFieldName((XVar)(f.Value)) == field) && (XVar)(GlobalVars.gSettings.getEditFormat((XVar)(f.Value)) == Constants.EDIT_FORMAT_LOOKUP_WIZARD)) { LookupType = XVar.Clone(GlobalVars.gSettings.getLookupType((XVar)(f.Value))); if ((XVar)(LookupType == Constants.LT_LOOKUPTABLE) || (XVar)(LookupType == Constants.LT_QUERY)) { lookupField = XVar.Clone(f.Value); break; } } } if (XVar.Pack(!(XVar)(lookupField))) { respObj = XVar.Clone(new XVar("success", false, "data", XVar.Array())); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(respObj))); MVCFunctions.Echo(new XVar("")); return(MVCFunctions.GetBuferContentAndClearBufer()); } lookupTable = XVar.Clone(GlobalVars.gSettings.getLookupTable((XVar)(lookupField))); linkFieldName = XVar.Clone(GlobalVars.gSettings.getLinkField((XVar)(lookupField))); displayFieldName = XVar.Clone(GlobalVars.gSettings.getDisplayField((XVar)(lookupField))); linkAndDisplaySame = XVar.Clone(displayFieldName == linkFieldName); if (LookupType == Constants.LT_QUERY) { lookupConnection = XVar.Clone(GlobalVars.cman.byTable((XVar)(lookupTable))); } else { dynamic connId = null; connId = XVar.Clone(GlobalVars.gSettings.getNotProjectLookupTableConnId((XVar)(lookupField))); lookupConnection = XVar.Clone((XVar.Pack(MVCFunctions.strlen((XVar)(connId))) ? XVar.Pack(GlobalVars.cman.byId((XVar)(connId))) : XVar.Pack(GlobalVars.cman.getDefault()))); } lookupOrderBy = XVar.Clone(GlobalVars.gSettings.getLookupOrderBy((XVar)(lookupField))); if (lookupConnection.dbType == Constants.nDATABASE_MSSQLServer) { strUniqueOrderBy = XVar.Clone(lookupOrderBy); } if (LookupType == Constants.LT_QUERY) { lookupPSet = XVar.Clone(new ProjectSettings((XVar)(lookupTable), (XVar)(pageType))); lookupCipherer = XVar.Clone(new RunnerCipherer((XVar)(lookupTable))); lookupQueryObj = XVar.Clone(lookupPSet.getSQLQuery()); if (XVar.Pack(GlobalVars.gSettings.getCustomDisplay((XVar)(lookupField)))) { lookupQueryObj.AddCustomExpression((XVar)(displayFieldName), (XVar)(lookupPSet), (XVar)(GlobalVars.strTableName), (XVar)(lookupField)); } lookupQueryObj.ReplaceFieldsWithDummies((XVar)(lookupPSet.getBinaryFieldsIndices())); } else { dynamic lwLinkField = null; LookupSQLTable = new XVar("SELECT "); lwLinkField = XVar.Clone(lookupConnection.addFieldWrappers((XVar)(GlobalVars.gSettings.getLinkField((XVar)(lookupField))))); if (XVar.Pack(GlobalVars.gSettings.isLookupUnique((XVar)(lookupField)))) { LookupSQLTable = MVCFunctions.Concat(LookupSQLTable, "DISTINCT "); } LookupSQLTable = MVCFunctions.Concat(LookupSQLTable, GlobalVars.cipherer.GetLookupFieldName((XVar)(lwLinkField), (XVar)(lookupField), new XVar(null), new XVar(true))); if (lookupConnection.dbType == Constants.nDATABASE_MSSQLServer) { if ((XVar)(strUniqueOrderBy) && (XVar)(GlobalVars.gSettings.isLookupUnique((XVar)(lookupField)))) { LookupSQLTable = MVCFunctions.Concat(LookupSQLTable, ",", lookupConnection.addFieldWrappers((XVar)(strUniqueOrderBy))); } } lwDisplayField = XVar.Clone(RunnerPage.sqlFormattedDisplayField((XVar)(lookupField), (XVar)(lookupConnection), (XVar)(GlobalVars.gSettings))); if (XVar.Pack(!(XVar)(linkAndDisplaySame))) { LookupSQLTable = MVCFunctions.Concat(LookupSQLTable, ",", (XVar.Pack(lwDisplayField == lwLinkField) ? XVar.Pack(GlobalVars.cipherer.GetFieldName((XVar)(lwDisplayField), (XVar)(lookupField), new XVar(true))) : XVar.Pack(lwDisplayField))); } LookupSQLTable = MVCFunctions.Concat(LookupSQLTable, " FROM ", lookupConnection.addTableWrappers((XVar)(lookupTable)), " "); } strLookupWhere = XVar.Clone(CommonFunctions.prepareLookupWhere((XVar)(lookupField), (XVar)(GlobalVars.gSettings))); if (LookupType == Constants.LT_QUERY) { dynamic secOpt = null; secOpt = XVar.Clone(lookupPSet.getAdvancedSecurityType()); if (secOpt == Constants.ADVSECURITY_VIEW_OWN) { strLookupWhere = XVar.Clone(CommonFunctions.whereAdd((XVar)(strLookupWhere), (XVar)(CommonFunctions.SecuritySQL(new XVar("Search"), (XVar)(lookupTable))))); } } if (XVar.Pack(strLookupWhere)) { strLookupWhere = XVar.Clone(MVCFunctions.Concat(" (", strLookupWhere, ") AND ")); } if (LookupType == Constants.LT_QUERY) { if (XVar.Pack(GlobalVars.gSettings.getCustomDisplay((XVar)(lookupField)))) { likeField = XVar.Clone((XVar.Pack(searchByLinkField) ? XVar.Pack(linkFieldName) : XVar.Pack(displayFieldName))); } else { likeField = XVar.Clone(RunnerPage._getFieldSQLDecrypt((XVar)((XVar.Pack(searchByLinkField) ? XVar.Pack(linkFieldName) : XVar.Pack(displayFieldName))), (XVar)(lookupConnection), (XVar)(lookupPSet), (XVar)(GlobalVars.cipherer))); } } else { likeField = XVar.Clone(GlobalVars.cipherer.GetFieldName((XVar)(lwDisplayField), (XVar)(lookupField))); } if (XVar.Pack(searchByLinkField)) { likeConditionField = XVar.Clone((XVar.Pack(LookupType == Constants.LT_QUERY) ? XVar.Pack(linkFieldName) : XVar.Pack(lookupField))); } else { likeConditionField = XVar.Clone((XVar.Pack(LookupType == Constants.LT_QUERY) ? XVar.Pack(displayFieldName) : XVar.Pack(lookupField))); } likeWheres = XVar.Clone(XVar.Array()); foreach (KeyValuePair <XVar, dynamic> fieldValue in values.GetEnumerator()) { if (LookupType == Constants.LT_QUERY) { likeWheres.InitAndSetArrayItem(MVCFunctions.Concat(likeField, lookupCipherer.GetLikeClause((XVar)(likeConditionField), (XVar)(fieldValue.Value))), null); } else { likeWheres.InitAndSetArrayItem(MVCFunctions.Concat(likeField, GlobalVars.cipherer.GetLikeClause((XVar)(likeConditionField), (XVar)(fieldValue.Value))), null); } } strLookupWhere = MVCFunctions.Concat(strLookupWhere, MVCFunctions.implode(new XVar(" OR "), (XVar)(likeWheres))); if ((XVar)(isExistParent) && (XVar)(GlobalVars.gSettings.useCategory((XVar)(lookupField)))) { dynamic parentWhereParts = XVar.Array(); parentWhereParts = XVar.Clone(XVar.Array()); foreach (KeyValuePair <XVar, dynamic> cData in GlobalVars.gSettings.getParentFieldsData((XVar)(lookupField)).GetEnumerator()) { dynamic arLookupWhere = XVar.Array(), category = null, lookupCategory = XVar.Array(); arLookupWhere = XVar.Clone(XVar.Array()); category = XVar.Clone(parentCtrlsData[cData.Value["main"]]); lookupCategory = XVar.Clone((XVar.Pack(category == XVar.Pack("")) ? XVar.Pack(XVar.Array()) : XVar.Pack(CommonFunctions.splitvalues((XVar)(category))))); foreach (KeyValuePair <XVar, dynamic> arLookupCategory in lookupCategory.GetEnumerator()) { dynamic catField = null, cvalue = null; cvalue = XVar.Clone(CommonFunctions.make_db_value((XVar)(cData.Value["main"]), (XVar)(arLookupCategory.Value))); if (XVar.Pack(lookupPSet)) { catField = XVar.Clone(RunnerPage._getFieldSQLDecrypt((XVar)(cData.Value["lookup"]), (XVar)(lookupConnection), (XVar)(lookupPSet), (XVar)(GlobalVars.cipherer))); } else { catField = XVar.Clone(lookupConnection.addFieldWrappers((XVar)(cData.Value["lookup"]))); } arLookupWhere.InitAndSetArrayItem(MVCFunctions.Concat(catField, "=", cvalue), null); } if (XVar.Pack(MVCFunctions.count(arLookupWhere))) { parentWhereParts.InitAndSetArrayItem(MVCFunctions.Concat("(", MVCFunctions.implode(new XVar(" OR "), (XVar)(arLookupWhere)), ")"), null); } } if (MVCFunctions.count(parentWhereParts) == MVCFunctions.count(GlobalVars.gSettings.getParentFieldsData((XVar)(lookupField)))) { strLookupWhere = XVar.Clone(CommonFunctions.whereAdd((XVar)(strLookupWhere), (XVar)(MVCFunctions.Concat("(", MVCFunctions.implode(new XVar(" AND "), (XVar)(parentWhereParts)), ")")))); } else { respObj = XVar.Clone(new XVar("success", false, "data", XVar.Array())); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(respObj))); MVCFunctions.Echo(new XVar("")); return(MVCFunctions.GetBuferContentAndClearBufer()); } } if (XVar.Pack(MVCFunctions.strlen((XVar)(lookupOrderBy)))) { lookupOrderBy = XVar.Clone(lookupConnection.addFieldWrappers((XVar)(lookupOrderBy))); if (XVar.Pack(GlobalVars.gSettings.isLookupDesc((XVar)(lookupField)))) { lookupOrderBy = MVCFunctions.Concat(lookupOrderBy, " DESC"); } } if (LookupType == Constants.LT_QUERY) { LookupSQL = XVar.Clone(lookupQueryObj.buildSQL_default((XVar)(strLookupWhere))); if (XVar.Pack(MVCFunctions.strlen((XVar)(lookupOrderBy)))) { LookupSQL = MVCFunctions.Concat(LookupSQL, " ORDER BY ", lookupOrderBy); } } else { LookupSQL = XVar.Clone(MVCFunctions.Concat(LookupSQLTable, " where ", strLookupWhere)); if ((XVar)(!(XVar)(GlobalVars.gSettings.isLookupUnique((XVar)(lookupField)))) || (XVar)(Constants.nDATABASE_Access != lookupConnection.dbType)) { if (XVar.Pack(lookupOrderBy)) { LookupSQL = MVCFunctions.Concat(LookupSQL, " ORDER BY ", lookupOrderBy); } } } lookupIndices = XVar.Clone(CommonFunctions.GetLookupFieldsIndexes((XVar)(GlobalVars.gSettings), (XVar)(lookupField))); linkFieldIndex = XVar.Clone(lookupIndices["linkFieldIndex"]); displayFieldIndex = XVar.Clone(lookupIndices["displayFieldIndex"]); var_response = XVar.Clone(XVar.Array()); qResult = XVar.Clone(lookupConnection.query((XVar)(LookupSQL))); while (XVar.Pack(data = XVar.Clone(qResult.fetchNumeric()))) { if ((XVar)(LookupType == Constants.LT_QUERY) && (XVar)(GlobalVars.gSettings.isLookupUnique((XVar)(lookupField)))) { dynamic uniqueArray = XVar.Array(); if (XVar.Pack(!(XVar)(uniqueArray as object != null))) { uniqueArray = XVar.Clone(XVar.Array()); } if (XVar.Pack(MVCFunctions.in_array((XVar)(data[displayFieldIndex]), (XVar)(uniqueArray)))) { continue; } uniqueArray.InitAndSetArrayItem(data[displayFieldIndex], null); } data.InitAndSetArrayItem(GlobalVars.cipherer.DecryptField((XVar)(lookupField), (XVar)(data[linkFieldIndex])), linkFieldIndex); if (LookupType == Constants.LT_QUERY) { data.InitAndSetArrayItem(GlobalVars.cipherer.DecryptField((XVar)(displayFieldName), (XVar)(data[displayFieldIndex])), displayFieldIndex); } var_response.InitAndSetArrayItem(data[linkFieldIndex], null); var_response.InitAndSetArrayItem(data[displayFieldIndex], null); } respObj = XVar.Clone(new XVar("success", true, "data", MVCFunctions.array_slice((XVar)(var_response), new XVar(0), new XVar(40)))); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(respObj))); MVCFunctions.Echo(new XVar("")); return(MVCFunctions.GetBuferContentAndClearBufer()); } catch (RunnerRedirectException ex) { return(Redirect(ex.Message)); } }
public XVar download() { try { dynamic _connection = null, absFileName = null, ctype = null, data = XVar.Array(), ext = null, field = null, fieldsArr = XVar.Array(), filename = null, keys = XVar.Array(), keysArr = XVar.Array(), qResult = null, sql = null, strfilesize = null, table = null, where = null; table = XVar.Clone(MVCFunctions.postvalue(new XVar("table"))); GlobalVars.strTableName = XVar.Clone(CommonFunctions.GetTableByShort((XVar)(table))); if (XVar.Pack(!(XVar)(CommonFunctions.checkTableName((XVar)(table))))) { MVCFunctions.Echo(new XVar(0)); return(MVCFunctions.GetBuferContentAndClearBufer()); } Assembly.GetExecutingAssembly().GetType(MVCFunctions.Concat("runnerDotNet.", MVCFunctions.Concat("", table, ""), "_Variables")).InvokeMember("Apply", BindingFlags.InvokeMethod, null, null, null); if ((XVar)(!(XVar)(CommonFunctions.isLogged())) || (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Search"))))) { MVCFunctions.HeaderRedirect(new XVar("login")); return(MVCFunctions.GetBuferContentAndClearBufer()); } field = XVar.Clone(MVCFunctions.postvalue(new XVar("field"))); if (XVar.Pack(!(XVar)(GlobalVars.gSettings.checkFieldPermissions((XVar)(field))))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } fieldsArr = XVar.Clone(GlobalVars.gSettings.getFieldsList()); foreach (KeyValuePair <XVar, dynamic> f in fieldsArr.GetEnumerator()) { dynamic fViewFormat = null; fViewFormat = XVar.Clone(GlobalVars.gSettings.getViewFormat((XVar)(f.Value))); if ((XVar)(field == f.Value) && (XVar)((XVar)((XVar)(fViewFormat != Constants.FORMAT_FILE) && (XVar)(fViewFormat != Constants.FORMAT_AUDIO)) && (XVar)(fViewFormat != Constants.FORMAT_VIDEO))) { MVCFunctions.Echo(new XVar(0)); return(MVCFunctions.GetBuferContentAndClearBufer()); } } _connection = XVar.Clone(GlobalVars.cman.byTable((XVar)(GlobalVars.strTableName))); keysArr = XVar.Clone(GlobalVars.gSettings.getTableKeys()); keys = XVar.Clone(XVar.Array()); foreach (KeyValuePair <XVar, dynamic> k in keysArr.GetEnumerator()) { keys.InitAndSetArrayItem(MVCFunctions.postvalue((XVar)(MVCFunctions.Concat("key", k.Key + 1))), k.Value); } where = XVar.Clone(CommonFunctions.KeyWhere((XVar)(keys))); if (GlobalVars.gSettings.getAdvancedSecurityType() == Constants.ADVSECURITY_VIEW_OWN) { where = XVar.Clone(CommonFunctions.whereAdd((XVar)(where), (XVar)(CommonFunctions.SecuritySQL(new XVar("Search"), (XVar)(GlobalVars.strTableName))))); } sql = XVar.Clone(GlobalVars.gQuery.gSQLWhere((XVar)(where))); qResult = XVar.Clone(_connection.query((XVar)(sql))); if (XVar.Pack(!(XVar)(qResult))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } data = XVar.Clone(qResult.fetchAssoc()); if (XVar.Pack(!(XVar)(data))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } filename = XVar.Clone(data[field]); ext = XVar.Clone(MVCFunctions.substr((XVar)(filename), (XVar)(MVCFunctions.strlen((XVar)(filename)) - 4))); ctype = XVar.Clone(CommonFunctions.getContentTypeByExtension((XVar)(ext))); if (XVar.Pack(GlobalVars.gSettings.isAbsolute((XVar)(field)))) { absFileName = XVar.Clone(MVCFunctions.Concat(GlobalVars.gSettings.getUploadFolder((XVar)(field)), filename)); } else { absFileName = XVar.Clone(MVCFunctions.getabspath((XVar)(MVCFunctions.Concat(GlobalVars.gSettings.getUploadFolder((XVar)(field)), filename)))); } if (XVar.Pack(!(XVar)(MVCFunctions.file_exists((XVar)(absFileName))))) { MVCFunctions.returnError404(); MVCFunctions.Echo(new XVar("")); return(MVCFunctions.GetBuferContentAndClearBufer()); } strfilesize = XVar.Clone(MVCFunctions.filesize((XVar)(absFileName))); if (XVar.Equals(XVar.Pack(strfilesize), XVar.Pack(false))) { MVCFunctions.returnError404(); MVCFunctions.Echo(new XVar("")); return(MVCFunctions.GetBuferContentAndClearBufer()); } MVCFunctions.Header((XVar)(MVCFunctions.Concat("Content-Type: ", ctype))); MVCFunctions.Header((XVar)(MVCFunctions.Concat("Content-Disposition: attachment;Filename=\"", filename, "\""))); MVCFunctions.Header("Cache-Control", "private"); MVCFunctions.SendContentLength((XVar)(strfilesize)); MVCFunctions.printfile((XVar)(absFileName)); return(MVCFunctions.GetBuferContentAndClearBufer()); } catch (RunnerRedirectException ex) { return(Redirect(ex.Message)); } }
public XVar fulltext() { try { dynamic _connection = null, cViewControl = null, container = null, data = XVar.Array(), field = null, fieldValue = null, htmlEncodedValue = null, keys = XVar.Array(), keysArr = XVar.Array(), lookup = null, lookupInRegisterPage = null, mainField = null, mainTable = null, mode = null, pageName = null, pageType = null, qResult = null, returnJSON = null, searchClauseObj = null, sessionPrefix = null, sql = null, table = null, where = null; ProjectSettings pSet; mode = XVar.Clone(MVCFunctions.postvalue(new XVar("mode"))); table = XVar.Clone(MVCFunctions.postvalue(new XVar("table"))); field = XVar.Clone(MVCFunctions.postvalue(new XVar("field"))); pageType = XVar.Clone(MVCFunctions.postvalue(new XVar("pagetype"))); pageName = XVar.Clone(MVCFunctions.postvalue(new XVar("page"))); mainTable = XVar.Clone(MVCFunctions.postvalue(new XVar("maintable"))); mainField = XVar.Clone(MVCFunctions.postvalue(new XVar("mainfield"))); lookup = new XVar(false); if ((XVar)(mainTable) && (XVar)(mainField)) { lookup = new XVar(true); } if (XVar.Pack(!(XVar)(CommonFunctions.checkTableName((XVar)(table))))) { MVCFunctions.Echo(new XVar(0)); return(MVCFunctions.GetBuferContentAndClearBufer()); } Assembly.GetExecutingAssembly().GetType(MVCFunctions.Concat("runnerDotNet.", MVCFunctions.Concat("", table, ""), "_Variables")).InvokeMember("Apply", BindingFlags.InvokeMethod, null, null, null); pSet = XVar.UnPackProjectSettings(new ProjectSettings((XVar)(CommonFunctions.GetTableByShort((XVar)(table))), (XVar)(pageType), (XVar)(pageName))); GlobalVars.cipherer = XVar.Clone(new RunnerCipherer((XVar)(CommonFunctions.GetTableByShort((XVar)(table))), (XVar)(pSet))); _connection = XVar.Clone(GlobalVars.cman.byTable((XVar)(GlobalVars.strTableName))); lookupInRegisterPage = new XVar(false); if (XVar.Pack(!(XVar)(MVCFunctions.in_array((XVar)(field), (XVar)(pSet.getListFields()))))) { lookupInRegisterPage = new XVar(false); } if ((XVar)((XVar)(!(XVar)(CommonFunctions.isLogged())) || (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Search"))))) && (XVar)(!(XVar)(lookupInRegisterPage))) { returnJSON = XVar.Clone(new XVar("success", false, "error", "")); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(returnJSON))); return(MVCFunctions.GetBuferContentAndClearBufer()); } if (XVar.Pack(!(XVar)(pSet.checkFieldPermissions((XVar)(field))))) { returnJSON = XVar.Clone(new XVar("success", false, "error", "Error: You have not permission for read this text")); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(returnJSON))); return(MVCFunctions.GetBuferContentAndClearBufer()); } if (XVar.Pack(!(XVar)(GlobalVars.gQuery.HasGroupBy()))) { GlobalVars.gQuery.RemoveAllFieldsExcept((XVar)(pSet.getFieldIndex((XVar)(field)))); } keysArr = XVar.Clone(pSet.getTableKeys()); keys = XVar.Clone(XVar.Array()); foreach (KeyValuePair <XVar, dynamic> k in keysArr.GetEnumerator()) { keys.InitAndSetArrayItem(MVCFunctions.postvalue((XVar)(MVCFunctions.Concat("key", k.Key + 1))), k.Value); } where = XVar.Clone(CommonFunctions.KeyWhere((XVar)(keys))); if (pSet.getAdvancedSecurityType() == Constants.ADVSECURITY_VIEW_OWN) { where = XVar.Clone(CommonFunctions.whereAdd((XVar)(where), (XVar)(CommonFunctions.SecuritySQL(new XVar("Search"), (XVar)(GlobalVars.strTableName))))); } sql = XVar.Clone(GlobalVars.gQuery.gSQLWhere((XVar)(where))); qResult = XVar.Clone(_connection.query((XVar)(sql))); if ((XVar)(!(XVar)(qResult)) || (XVar)(!(XVar)(data = XVar.Clone(GlobalVars.cipherer.DecryptFetchedArray((XVar)(qResult.fetchAssoc())))))) { returnJSON = XVar.Clone(new XVar("success", false, "error", "Error: Wrong SQL query")); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(returnJSON))); return(MVCFunctions.GetBuferContentAndClearBufer()); } fieldValue = XVar.Clone(data[field]); sessionPrefix = XVar.Clone(pSet.getOriginalTableName()); if (mode == Constants.LIST_DASHBOARD) { sessionPrefix = XVar.Clone(MVCFunctions.Concat("Dashboard_", pSet.getOriginalTableName())); } if (XVar.Pack(lookup)) { sessionPrefix = XVar.Clone(MVCFunctions.Concat(pSet.getOriginalTableName(), "_lookup_", mainTable, "_", mainField)); } searchClauseObj = XVar.Clone(SearchClause.UnserializeObject((XVar)(XSession.Session[MVCFunctions.Concat(sessionPrefix, "_advsearch")]))); container = XVar.Clone(new ViewControlsContainer((XVar)(pSet), new XVar(Constants.PAGE_LIST), new XVar(null))); cViewControl = XVar.Clone(container.getControl((XVar)(field))); if ((XVar)(cViewControl.localControlsContainer) && (XVar)(!(XVar)(cViewControl.linkAndDisplaySame))) { cViewControl.localControlsContainer.fullText = new XVar(true); } else { cViewControl.container.fullText = new XVar(true); } if (XVar.Pack(searchClauseObj)) { dynamic useViewControl = null; if ((XVar)(searchClauseObj.bIsUsedSrch) || (XVar)(useViewControl)) { cViewControl.searchClauseObj = XVar.Clone(searchClauseObj); cViewControl.searchHighlight = new XVar(true); } } htmlEncodedValue = XVar.Clone(cViewControl.showDBValue((XVar)(data), new XVar(""))); returnJSON = XVar.Clone(new XVar("success", true, "textCont", htmlEncodedValue)); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(returnJSON))); return(MVCFunctions.GetBuferContentAndClearBufer()); } catch (RunnerRedirectException ex) { return(Redirect(ex.Message)); } }
public XVar searchsuggest() { try { dynamic _connection = null, allSearchFields = null, dashSearchFields = XVar.Array(), dashSettings = null, detailKeys = XVar.Array(), forDashboardSimpleSearch = null, numberOfSuggests = null, pSetList = null, pageType = null, result = XVar.Array(), returnJSON = XVar.Array(), searchClauseObj = null, searchField = null, searchFor = null, searchOpt = null, table = null, whereClauses = XVar.Array(); ProjectSettings pSet; CommonFunctions.add_nocache_headers(); table = XVar.Clone(MVCFunctions.postvalue(new XVar("table"))); GlobalVars.strTableName = XVar.Clone(CommonFunctions.GetTableByShort((XVar)(table))); if (XVar.Pack(!(XVar)(CommonFunctions.checkTableName((XVar)(table))))) { MVCFunctions.Echo(new XVar(0)); return(MVCFunctions.GetBuferContentAndClearBufer()); } Assembly.GetExecutingAssembly().GetType(MVCFunctions.Concat("runnerDotNet.", MVCFunctions.Concat("", table, ""), "_Variables")).InvokeMember("Apply", BindingFlags.InvokeMethod, null, null, null); if (XVar.Pack(!(XVar)(CommonFunctions.isLogged()))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } if (XVar.Pack(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Search"))))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } searchFor = XVar.Clone(MVCFunctions.trim((XVar)(MVCFunctions.postvalue(new XVar("searchFor"))))); if (searchFor == XVar.Pack("")) { MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(new XVar("success", true, "result", "")))); return(MVCFunctions.GetBuferContentAndClearBufer()); } searchOpt = XVar.Clone((XVar.Pack(MVCFunctions.postvalue(new XVar("start"))) ? XVar.Pack("Starts with") : XVar.Pack("Contains"))); searchField = XVar.Clone(MVCFunctions.GoodFieldName((XVar)(MVCFunctions.postvalue(new XVar("searchField"))))); numberOfSuggests = XVar.Clone(CommonFunctions.GetGlobalData(new XVar("searchSuggestsNumber"), new XVar(10))); whereClauses = XVar.Clone(XVar.Array()); pageType = XVar.Clone(MVCFunctions.postvalue(new XVar("pageType"))); if (XVar.Pack(!(XVar)(pageType))) { pageType = new XVar(Constants.PAGE_LIST); } forDashboardSimpleSearch = XVar.Clone((XVar)(!(XVar)(searchField)) && (XVar)(pageType == Constants.PAGE_DASHBOARD)); if (XVar.Pack(forDashboardSimpleSearch)) { dynamic dashGoogleLikeFields = XVar.Array(), sfdata = XVar.Array(); dashSettings = XVar.Clone(new ProjectSettings((XVar)(GlobalVars.strTableName), new XVar(Constants.PAGE_DASHBOARD))); dashGoogleLikeFields = XVar.Clone(dashSettings.getGoogleLikeFields()); dashSearchFields = XVar.Clone(dashSettings.getDashboardSearchFields()); sfdata = XVar.Clone(XVar.Array()); foreach (KeyValuePair <XVar, dynamic> g in dashGoogleLikeFields.GetEnumerator()) { foreach (KeyValuePair <XVar, dynamic> data in dashSearchFields[g.Value].GetEnumerator()) { sfdata.InitAndSetArrayItem(data.Value["field"], data.Value["table"], null); } } foreach (KeyValuePair <XVar, dynamic> fields in sfdata.GetEnumerator()) { dynamic _result = XVar.Array(); if (numberOfSuggests <= MVCFunctions.count(result)) { break; } if (XVar.Pack(!(XVar)(MVCFunctions.count(result)))) { result = XVar.Clone(XVar.Array()); } _result = XVar.Clone(CommonFunctions.getListOfSuggests((XVar)(fields.Value), (XVar)(fields.Key), (XVar)(whereClauses), (XVar)(numberOfSuggests - MVCFunctions.count(result)), (XVar)(searchOpt), (XVar)(searchFor))); foreach (KeyValuePair <XVar, dynamic> _data in _result.GetEnumerator()) { dynamic found = null; found = new XVar(false); foreach (KeyValuePair <XVar, dynamic> data in result.GetEnumerator()) { if (data.Value["realValue"] == _data.Value["realValue"]) { found = new XVar(true); break; } } if (XVar.Pack(!(XVar)(found))) { result.InitAndSetArrayItem(_data.Value, null); } } } MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(new XVar("success", true, "result", result)))); MVCFunctions.Echo(new XVar("")); return(MVCFunctions.GetBuferContentAndClearBufer()); } if (pageType == Constants.PAGE_DASHBOARD) { dynamic sfData = XVar.Array(); dashSettings = XVar.Clone(new ProjectSettings((XVar)(GlobalVars.strTableName), new XVar(Constants.PAGE_DASHBOARD))); dashSearchFields = XVar.Clone(dashSettings.getDashboardSearchFields()); sfData = XVar.Clone(dashSearchFields[searchField][0]); searchField = XVar.Clone(MVCFunctions.GoodFieldName((XVar)(sfData["field"]))); table = XVar.Clone(MVCFunctions.GoodFieldName((XVar)(sfData["table"]))); if (XVar.Pack(!(XVar)(CommonFunctions.checkTableName((XVar)(table))))) { MVCFunctions.Echo(new XVar(0)); return(MVCFunctions.GetBuferContentAndClearBufer()); } GlobalVars.strTableName = XVar.Clone(CommonFunctions.GetTableByShort((XVar)(table))); Assembly.GetExecutingAssembly().GetType(MVCFunctions.Concat("runnerDotNet.", MVCFunctions.Concat("", table, ""), "_Variables")).InvokeMember("Apply", BindingFlags.InvokeMethod, null, null, null); foreach (KeyValuePair <XVar, dynamic> elem in dashSettings.getDashboardElements().GetEnumerator()) { if (elem.Value["table"] == GlobalVars.strTableName) { pageType = new XVar(Constants.PAGE_LIST); if (elem.Value["type"] == Constants.DASHBOARD_CHART) { pageType = new XVar(Constants.PAGE_CHART); } else { if (elem.Value["type"] == Constants.DASHBOARD_REPORT) { pageType = new XVar(Constants.PAGE_REPORT); } } break; } } } pSetList = XVar.Clone(new ProjectSettings((XVar)(GlobalVars.strTableName), (XVar)(pageType))); if (searchField == XVar.Pack("")) { allSearchFields = XVar.Clone(pSetList.getGoogleLikeFields()); } else { allSearchFields = XVar.Clone(pSetList.getAllSearchFields()); } pSet = XVar.UnPackProjectSettings(new ProjectSettings((XVar)(GlobalVars.strTableName), new XVar(Constants.PAGE_SEARCH))); GlobalVars.cipherer = XVar.Clone(new RunnerCipherer((XVar)(GlobalVars.strTableName))); _connection = XVar.Clone(GlobalVars.cman.byTable((XVar)(GlobalVars.strTableName))); detailKeys = XVar.Clone(XVar.Array()); if (XSession.Session[MVCFunctions.Concat(GlobalVars.strTableName, "_mastertable")] != "") { dynamic i = null, j = null, masterTablesInfoArr = XVar.Array(), masterWhere = null, mastervalue = null; masterWhere = new XVar(""); masterTablesInfoArr = XVar.Clone(pSet.getMasterTablesArr((XVar)(GlobalVars.strTableName))); i = new XVar(0); for (; i < MVCFunctions.count(masterTablesInfoArr); i++) { if (XSession.Session[MVCFunctions.Concat(GlobalVars.strTableName, "_mastertable")] != masterTablesInfoArr[i]["mDataSourceTable"]) { continue; } detailKeys = XVar.Clone(masterTablesInfoArr[i]["detailKeys"]); j = new XVar(0); for (; j < MVCFunctions.count(detailKeys); j++) { mastervalue = XVar.Clone(GlobalVars.cipherer.MakeDBValue((XVar)(detailKeys[j]), (XVar)(XSession.Session[MVCFunctions.Concat(GlobalVars.strTableName, "_masterkey", j + 1)]), new XVar(""), new XVar(true))); if (mastervalue == "null") { masterWhere = MVCFunctions.Concat(masterWhere, RunnerPage._getFieldSQL((XVar)(detailKeys[j]), (XVar)(_connection), (XVar)(pSet)), " is NULL "); } else { masterWhere = MVCFunctions.Concat(masterWhere, RunnerPage._getFieldSQLDecrypt((XVar)(detailKeys[j]), (XVar)(_connection), (XVar)(pSet), (XVar)(GlobalVars.cipherer)), "=", mastervalue); } } break; } whereClauses.InitAndSetArrayItem(masterWhere, null); } searchClauseObj = XVar.Clone(SearchClause.getSearchObject((XVar)(GlobalVars.strTableName), new XVar(""), (XVar)(GlobalVars.strTableName), (XVar)(GlobalVars.cipherer))); searchClauseObj.processFiltersWhere((XVar)(_connection)); foreach (KeyValuePair <XVar, dynamic> filteredField in searchClauseObj.filteredFields.GetEnumerator()) { whereClauses.InitAndSetArrayItem(filteredField.Value["where"], null); } result = XVar.Clone(CommonFunctions.getListOfSuggests((XVar)(allSearchFields), (XVar)(GlobalVars.strTableName), (XVar)(whereClauses), (XVar)(numberOfSuggests), (XVar)(searchOpt), (XVar)(searchFor), (XVar)(searchField), (XVar)(detailKeys))); returnJSON = XVar.Clone(XVar.Array()); returnJSON.InitAndSetArrayItem(true, "success"); returnJSON.InitAndSetArrayItem(result, "result"); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(returnJSON))); MVCFunctions.Echo(new XVar("")); return(MVCFunctions.GetBuferContentAndClearBufer()); } catch (RunnerRedirectException ex) { return(Redirect(ex.Message)); } }
public XVar searchsuggest() { try { dynamic _connection = null, allSearchFields = XVar.Array(), controls = null, detailKeys = XVar.Array(), numberOfSuggests = null, query = null, result = XVar.Array(), returnJSON = XVar.Array(), searchClauseObj = null, searchField = null, searchFor = null, searchOpt = null, table = null, var_response = XVar.Array(), whereClauses = XVar.Array(); ProjectSettings pSet; CommonFunctions.add_nocache_headers(); table = XVar.Clone(MVCFunctions.postvalue(new XVar("table"))); GlobalVars.strTableName = XVar.Clone(CommonFunctions.GetTableByShort((XVar)(table))); if (XVar.Pack(!(XVar)(CommonFunctions.checkTableName((XVar)(table))))) { MVCFunctions.Echo(new XVar(0)); return(MVCFunctions.GetBuferContentAndClearBufer()); } Assembly.GetExecutingAssembly().GetType(MVCFunctions.Concat("runnerDotNet.", MVCFunctions.Concat("", table, ""), "_Variables")).InvokeMember("Apply", BindingFlags.InvokeMethod, null, null, null); if (XVar.Pack(!(XVar)(CommonFunctions.isLogged()))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } if (XVar.Pack(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Search"))))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } searchFor = XVar.Clone(MVCFunctions.trim((XVar)(MVCFunctions.postvalue(new XVar("searchFor"))))); if (searchFor == XVar.Pack("")) { MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(new XVar("success", true, "result", "")))); return(MVCFunctions.GetBuferContentAndClearBufer()); } _connection = XVar.Clone(GlobalVars.cman.byTable((XVar)(GlobalVars.strTableName))); var_response = XVar.Clone(XVar.Array()); searchOpt = XVar.Clone((XVar.Pack(MVCFunctions.postvalue(new XVar("start"))) ? XVar.Pack("Starts with") : XVar.Pack("Contains"))); searchField = XVar.Clone(MVCFunctions.GoodFieldName((XVar)(MVCFunctions.postvalue(new XVar("searchField"))))); numberOfSuggests = XVar.Clone(CommonFunctions.GetGlobalData(new XVar("searchSuggestsNumber"), new XVar(10))); pSet = XVar.UnPackProjectSettings(new ProjectSettings((XVar)(GlobalVars.strTableName), new XVar(Constants.PAGE_SEARCH))); query = XVar.Clone(pSet.getSQLQuery()); if (searchField == XVar.Pack("")) { allSearchFields = XVar.Clone(pSet.getGoogleLikeFields()); } else { allSearchFields = XVar.Clone(pSet.getAllSearchFields()); } detailKeys = XVar.Clone(XVar.Array()); whereClauses = XVar.Clone(XVar.Array()); whereClauses.InitAndSetArrayItem(CommonFunctions.SecuritySQL(new XVar("Search"), (XVar)(GlobalVars.strTableName)), null); GlobalVars.cipherer = XVar.Clone(new RunnerCipherer((XVar)(GlobalVars.strTableName))); controls = XVar.Clone(new EditControlsContainer(new XVar(null), (XVar)(pSet), new XVar(Constants.PAGE_LIST), (XVar)(GlobalVars.cipherer))); if (XSession.Session[MVCFunctions.Concat(GlobalVars.strTableName, "_mastertable")] != "") { dynamic i = null, j = null, masterTablesInfoArr = XVar.Array(), masterWhere = null, mastervalue = null; masterWhere = new XVar(""); masterTablesInfoArr = XVar.Clone(pSet.getMasterTablesArr((XVar)(GlobalVars.strTableName))); i = new XVar(0); for (; i < MVCFunctions.count(masterTablesInfoArr); i++) { if (XSession.Session[MVCFunctions.Concat(GlobalVars.strTableName, "_mastertable")] != masterTablesInfoArr[i]["mDataSourceTable"]) { continue; } detailKeys = XVar.Clone(masterTablesInfoArr[i]["detailKeys"]); j = new XVar(0); for (; j < MVCFunctions.count(detailKeys); j++) { mastervalue = XVar.Clone(GlobalVars.cipherer.MakeDBValue((XVar)(detailKeys[j]), (XVar)(XSession.Session[MVCFunctions.Concat(GlobalVars.strTableName, "_masterkey", j + 1)]), new XVar(""), new XVar(true))); if (mastervalue == "null") { masterWhere = MVCFunctions.Concat(masterWhere, RunnerPage._getFieldSQL((XVar)(detailKeys[j]), (XVar)(_connection), (XVar)(pSet)), " is NULL "); } else { masterWhere = MVCFunctions.Concat(masterWhere, RunnerPage._getFieldSQLDecrypt((XVar)(detailKeys[j]), (XVar)(_connection), (XVar)(pSet), (XVar)(GlobalVars.cipherer)), "=", mastervalue); } } break; } whereClauses.InitAndSetArrayItem(masterWhere, null); } searchClauseObj = XVar.Clone(SearchClause.getSearchObject((XVar)(GlobalVars.strTableName), new XVar(""), (XVar)(GlobalVars.strTableName), (XVar)(GlobalVars.cipherer))); searchClauseObj.processFiltersWhere((XVar)(_connection)); foreach (KeyValuePair <XVar, dynamic> filteredField in searchClauseObj.filteredFields.GetEnumerator()) { whereClauses.InitAndSetArrayItem(filteredField.Value["where"], null); } result = XVar.Clone(XVar.Array()); foreach (KeyValuePair <XVar, dynamic> f in allSearchFields.GetEnumerator()) { dynamic clausesData = XVar.Array(), distinct = null, fType = null, fieldControl = null, having = null, isAggregateField = null, qResult = null, row = XVar.Array(), sql = XVar.Array(), subQuery = null, val = null, where = null; fType = XVar.Clone(pSet.getFieldType((XVar)(f.Value))); if ((XVar)((XVar)((XVar)(!(XVar)(CommonFunctions.IsCharType((XVar)(fType)))) && (XVar)(!(XVar)(CommonFunctions.IsNumberType((XVar)(fType))))) && (XVar)(!(XVar)(CommonFunctions.IsGuid((XVar)(fType))))) || (XVar)(MVCFunctions.in_array((XVar)(f.Value), (XVar)(detailKeys)))) { continue; } if ((XVar)(_connection.dbType == Constants.nDATABASE_Oracle) && (XVar)(CommonFunctions.IsTextType((XVar)(fType)))) { continue; } if ((XVar)((XVar)(searchField != XVar.Pack("")) && (XVar)(searchField != MVCFunctions.GoodFieldName((XVar)(f.Value)))) || (XVar)(!(XVar)(pSet.checkFieldPermissions((XVar)(f.Value))))) { continue; } fieldControl = XVar.Clone(controls.getControl((XVar)(f.Value))); isAggregateField = XVar.Clone(pSet.isAggregateField((XVar)(f.Value))); where = XVar.Clone(fieldControl.getSuggestWhere((XVar)(searchOpt), (XVar)(searchFor), (XVar)(isAggregateField))); having = XVar.Clone(fieldControl.getSuggestHaving((XVar)(searchOpt), (XVar)(searchFor), (XVar)(isAggregateField))); if ((XVar)(!(XVar)(MVCFunctions.strlen((XVar)(where)))) && (XVar)(!(XVar)(MVCFunctions.strlen((XVar)(having))))) { continue; } distinct = new XVar("DISTINCT"); if ((XVar)(_connection.dbType == Constants.nDATABASE_MSSQLServer) || (XVar)(_connection.dbType == Constants.nDATABASE_Access)) { if (XVar.Pack(CommonFunctions.IsTextType((XVar)(fType)))) { distinct = new XVar(""); } } sql = XVar.Clone(query.getSqlComponents()); clausesData = XVar.Clone(fieldControl.getSelectColumnsAndJoinFromPart((XVar)(searchFor), (XVar)(searchOpt), new XVar(true))); if (0 == MVCFunctions.strlen((XVar)(clausesData["joinFromPart"]))) { subQuery = XVar.Clone(SQLQuery.buildSQL((XVar)(sql), (XVar)(whereClauses), (XVar)(XVar.Array()), (XVar)(new XVar(0, where)), (XVar)(new XVar(0, having)))); GlobalVars.strSQL = XVar.Clone(MVCFunctions.Concat("SELECT ", distinct, " st.", _connection.addFieldWrappers((XVar)(f.Value)), " from (", subQuery, ") st")); } else { sql["from"] = MVCFunctions.Concat(sql["from"], clausesData["joinFromPart"]); sql.InitAndSetArrayItem(MVCFunctions.Concat("SELECT ", distinct, " ", clausesData["selectColumns"], " as ", _connection.addFieldWrappers(new XVar("_srchfld_"))), "head"); subQuery = XVar.Clone(SQLQuery.buildSQL((XVar)(sql), (XVar)(whereClauses), (XVar)(XVar.Array()), (XVar)(new XVar(0, where)), (XVar)(new XVar(0, having)))); GlobalVars.strSQL = XVar.Clone(MVCFunctions.Concat("SELECT ", _connection.addFieldWrappers(new XVar("_srchfld_")), " from (", subQuery, ") st")); } qResult = XVar.Clone(_connection.queryPage((XVar)(GlobalVars.strSQL), new XVar(1), (XVar)(numberOfSuggests), new XVar(true))); while ((XVar)(row = XVar.Clone(qResult.fetchNumeric())) && (XVar)(MVCFunctions.count(var_response) < numberOfSuggests)) { val = XVar.Clone(GlobalVars.cipherer.DecryptField((XVar)(f.Value), (XVar)(row[0]))); if (XVar.Pack(CommonFunctions.IsGuid((XVar)(fType)))) { val = XVar.Clone(MVCFunctions.substr((XVar)(val), new XVar(1), new XVar(-1))); } fieldControl.suggestValue((XVar)(MVCFunctions.Concat("_", val)), (XVar)(searchFor), (XVar)(var_response), (XVar)(row)); } } _connection.close(); MVCFunctions.ksort(ref var_response, new XVar(Constants.SORT_STRING)); foreach (KeyValuePair <XVar, dynamic> realValue in var_response.GetEnumerator()) { dynamic pos = null, strRealValue = null, strValue = null; if (numberOfSuggests < MVCFunctions.count(result)) { break; } strValue = XVar.Clone((XVar.Pack(realValue.Key[0] == "_") ? XVar.Pack(MVCFunctions.substr((XVar)(realValue.Key), new XVar(1))) : XVar.Pack(realValue.Key))); strRealValue = XVar.Clone((XVar.Pack(realValue.Value[0] == "_") ? XVar.Pack(MVCFunctions.substr((XVar)(realValue.Value), new XVar(1))) : XVar.Pack(realValue.Value))); pos = XVar.Clone(CommonFunctions.my_stripos((XVar)(strValue), (XVar)(searchFor), new XVar(0))); if (XVar.Equals(XVar.Pack(pos), XVar.Pack(false))) { result.InitAndSetArrayItem(new XVar("value", MVCFunctions.runner_htmlspecialchars((XVar)(strValue)), "realValue", strRealValue), null); } else { dynamic highlightedValue = null; highlightedValue = XVar.Clone(MVCFunctions.Concat(MVCFunctions.runner_htmlspecialchars((XVar)(MVCFunctions.substr((XVar)(strValue), new XVar(0), (XVar)(pos)))), "<b>", MVCFunctions.runner_htmlspecialchars((XVar)(MVCFunctions.substr((XVar)(strValue), (XVar)(pos), (XVar)(MVCFunctions.strlen((XVar)(searchFor)))))), "</b>", MVCFunctions.runner_htmlspecialchars((XVar)(MVCFunctions.substr((XVar)(strValue), (XVar)(pos + MVCFunctions.strlen((XVar)(searchFor)))))))); result.InitAndSetArrayItem(new XVar("value", highlightedValue, "realValue", strRealValue), null); } } returnJSON = XVar.Clone(XVar.Array()); returnJSON.InitAndSetArrayItem(true, "success"); returnJSON.InitAndSetArrayItem(result, "result"); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(returnJSON))); MVCFunctions.Echo(new XVar("")); return(MVCFunctions.GetBuferContentAndClearBufer()); } catch (RunnerRedirectException ex) { return(Redirect(ex.Message)); } }
public XVar checkduplicates() { try { dynamic _connection = null, data = XVar.Array(), denyChecking = null, fieldControlType = null, fieldName = null, fieldSQL = null, hasDuplicates = null, pageType = null, qResult = null, regEmailMode = null, regUsernameMode = null, returnJSON = null, sql = null, tableName = null, value = null, where = null; ProjectSettings pSet; tableName = XVar.Clone(MVCFunctions.postvalue(new XVar("tableName"))); pageType = XVar.Clone(MVCFunctions.postvalue(new XVar("pageType"))); fieldName = XVar.Clone(MVCFunctions.postvalue(new XVar("fieldName"))); fieldControlType = XVar.Clone(MVCFunctions.postvalue(new XVar("fieldControlType"))); value = XVar.Clone(MVCFunctions.postvalue(new XVar("value"))); if (XVar.Pack(!(XVar)(CommonFunctions.checkTableName((XVar)(tableName))))) { MVCFunctions.Echo(new XVar(0)); return(MVCFunctions.GetBuferContentAndClearBufer()); } Assembly.GetExecutingAssembly().GetType(MVCFunctions.Concat("runnerDotNet.", MVCFunctions.Concat("", tableName, ""), "_Variables")).InvokeMember("Apply", BindingFlags.InvokeMethod, null, null, null); if ((XVar)(pageType != Constants.PAGE_REGISTER) && (XVar)((XVar)(!(XVar)(CommonFunctions.isLogged())) || (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Search")))))) { returnJSON = XVar.Clone(new XVar("success", false, "error", MVCFunctions.Concat("Error: You have not permissions to read the ", tableName, " table's data"))); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(returnJSON))); return(MVCFunctions.GetBuferContentAndClearBufer()); } _connection = XVar.Clone(GlobalVars.cman.byTable((XVar)(GlobalVars.strTableName))); pSet = XVar.UnPackProjectSettings(new ProjectSettings((XVar)(GlobalVars.strTableName), (XVar)(pageType))); denyChecking = XVar.Clone(pSet.allowDuplicateValues((XVar)(fieldName))); regEmailMode = new XVar(false); regUsernameMode = new XVar(false); if (XVar.Pack(denyChecking)) { returnJSON = XVar.Clone(new XVar("success", false, "error", "Duplicated values are allowed")); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(returnJSON))); return(MVCFunctions.GetBuferContentAndClearBufer()); } GlobalVars.cipherer = XVar.Clone(new RunnerCipherer((XVar)(GlobalVars.strTableName), (XVar)(pSet))); if (XVar.Pack(GlobalVars.cipherer.isFieldEncrypted((XVar)(fieldName)))) { value = XVar.Clone(GlobalVars.cipherer.MakeDBValue((XVar)(fieldName), (XVar)(value), (XVar)(fieldControlType), new XVar(true))); } else { value = XVar.Clone(CommonFunctions.make_db_value((XVar)(fieldName), (XVar)(value), (XVar)(fieldControlType), new XVar(""), (XVar)(GlobalVars.strTableName))); } if (value == "null") { fieldSQL = XVar.Clone(RunnerPage._getFieldSQL((XVar)(fieldName), (XVar)(_connection), (XVar)(pSet))); } else { fieldSQL = XVar.Clone(RunnerPage._getFieldSQLDecrypt((XVar)(fieldName), (XVar)(_connection), (XVar)(pSet), (XVar)(GlobalVars.cipherer))); } where = XVar.Clone(MVCFunctions.Concat(fieldSQL, (XVar.Pack(value == "null") ? XVar.Pack(" is ") : XVar.Pack("=")), value)); if (XVar.Pack(regEmailMode)) { where = XVar.Clone(_connection.comparisonSQL((XVar)(fieldSQL), (XVar)(value), new XVar(true))); } if (XVar.Pack(regUsernameMode)) { where = XVar.Clone(_connection.comparisonSQL((XVar)(fieldSQL), (XVar)(value), (XVar)(pSet.isCaseInsensitiveUsername()))); } sql = XVar.Clone(MVCFunctions.Concat("SELECT count(*) from ", _connection.addTableWrappers((XVar)(pSet.getOriginalTableName())), " where ", where)); qResult = XVar.Clone(_connection.query((XVar)(sql))); if ((XVar)(!(XVar)(qResult)) || (XVar)(!(XVar)(data = XVar.Clone(qResult.fetchNumeric())))) { returnJSON = XVar.Clone(new XVar("success", false, "error", "Error: Wrong SQL query")); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(returnJSON))); return(MVCFunctions.GetBuferContentAndClearBufer()); } hasDuplicates = XVar.Clone((XVar.Pack(data[0]) ? XVar.Pack(true) : XVar.Pack(false))); returnJSON = XVar.Clone(new XVar("success", true, "hasDuplicates", hasDuplicates, "error", "")); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(returnJSON))); return(MVCFunctions.GetBuferContentAndClearBufer()); } catch (RunnerRedirectException ex) { return(Redirect(ex.Message)); } }
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)); } }
public XVar autocomplete() { try { dynamic contextParams = XVar.Array(), control = null, editControls = null, field = null, isExistParent = null, masterTable = null, mode = null, pageType = null, parentCtrlsData = null, respObj = null, shortTableName = null; ProjectSettings pSet; MVCFunctions.Header("Expires", "Thu, 01 Jan 1970 00:00:01 GMT"); shortTableName = XVar.Clone(MVCFunctions.postvalue(new XVar("shortTName"))); Assembly.GetExecutingAssembly().GetType(MVCFunctions.Concat("runnerDotNet.", MVCFunctions.Concat("", shortTableName, ""), "_Variables")).InvokeMember("Apply", BindingFlags.InvokeMethod, null, null, null); field = XVar.Clone(MVCFunctions.postvalue(new XVar("field"))); if (GlobalVars.strTableName != "dbo._ABCSecurity") { if (XVar.Pack(!(XVar)(CommonFunctions.isLogged()))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } if ((XVar)((XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Edit")))) && (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Add"))))) && (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Search"))))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } } else { dynamic checkField = null; checkField = new XVar(true); if (field == "username") { checkField = new XVar(false); } if (field == "password") { checkField = new XVar(false); } if (XVar.Pack(checkField)) { if (XVar.Pack(!(XVar)(CommonFunctions.isLogged()))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } if ((XVar)((XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Edit")))) && (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Add"))))) && (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Search"))))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } } } pageType = XVar.Clone(MVCFunctions.postvalue(new XVar("pageType"))); GlobalVars.cipherer = XVar.Clone(new RunnerCipherer((XVar)(GlobalVars.strTableName))); pSet = XVar.UnPackProjectSettings(new ProjectSettings((XVar)(GlobalVars.strTableName), (XVar)(pageType))); editControls = XVar.Clone(new EditControlsContainer(new XVar(null), (XVar)(pSet), (XVar)(pageType), (XVar)(GlobalVars.cipherer))); control = XVar.Clone(editControls.getControl((XVar)(field))); contextParams = XVar.Clone(XVar.Array()); contextParams.InitAndSetArrayItem(MVCFunctions.my_json_decode((XVar)(MVCFunctions.postvalue(new XVar("data")))), "data"); masterTable = XVar.Clone(MVCFunctions.postvalue(new XVar("masterTable"))); if ((XVar)(masterTable != XVar.Pack("")) && (XVar)(XSession.Session.KeyExists(MVCFunctions.Concat(masterTable, "_masterRecordData")))) { dynamic masterControlsData = XVar.Array(), masterData = XVar.Array(); masterData = XVar.Clone(XSession.Session[MVCFunctions.Concat(masterTable, "_masterRecordData")]); masterControlsData = XVar.Clone(MVCFunctions.my_json_decode((XVar)(MVCFunctions.postvalue(new XVar("masterData"))))); foreach (KeyValuePair <XVar, dynamic> mValue in masterControlsData.GetEnumerator()) { masterData.InitAndSetArrayItem(mValue.Value, mValue.Key); } contextParams.InitAndSetArrayItem(masterData, "masterData"); } RunnerContext.push((XVar)(new RunnerContextItem(new XVar(Constants.CONTEXT_ROW), (XVar)(contextParams)))); parentCtrlsData = XVar.Clone(MVCFunctions.my_json_decode((XVar)(MVCFunctions.postvalue(new XVar("parentCtrlsData"))))); isExistParent = XVar.Clone(MVCFunctions.postvalue(new XVar("isExistParent"))); mode = XVar.Clone(MVCFunctions.intval((XVar)(MVCFunctions.postvalue(new XVar("mode"))))); respObj = XVar.Clone(new XVar("success", true, "data", control.getLookupContentToReload((XVar)(XVar.Equals(XVar.Pack(isExistParent), XVar.Pack("1"))), (XVar)(mode), (XVar)(parentCtrlsData)))); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(respObj))); RunnerContext.pop(); MVCFunctions.Echo(new XVar("")); return(MVCFunctions.GetBuferContentAndClearBufer()); } catch (RunnerRedirectException ex) { return(Redirect(ex.Message)); } }