public XVar PrepareValue(XVar value, XVar type) { if (_connection.dbType == Constants.nDATABASE_Oracle) { if (CommonFunctions.IsBinaryType(type)) { return("EMPTY_BLOB()"); } } if (CommonFunctions.IsDateFieldType(type)) { return(_connection.addDateQuotes(value)); } if (CommonFunctions.NeedQuotes(type)) { return(_connection.prepareString(value)); } else { if (XVar.Pack(MVCFunctions.IsNumeric(value))) { return(MVCFunctions.str_replace(new XVar(","), new XVar("."), (XVar)(value))); } else { return(0); } } }
public static XVar PrepareSQL(dynamic _param_sql, params dynamic[] _param_args) { #region pass-by-value parameters dynamic sql = XVar.Clone(_param_sql); dynamic args = XVar.Clone(_param_args); #endregion dynamic context = null, offsetShift = null, replacements = XVar.Array(), tokens = XVar.Array(); args = XVar.Clone(CommonFunctions.func_get_args(_param_sql, _param_args)); GlobalVars.conn = XVar.Clone(CurrentConnection()); context = XVar.Clone(RunnerContext.current()); tokens = XVar.Clone(scanTokenString((XVar)(sql))); replacements = XVar.Clone(XVar.Array()); foreach (KeyValuePair <XVar, dynamic> match in tokens["matches"].GetEnumerator()) { dynamic offset = null, repl = XVar.Array(), token = null, val = null; offset = XVar.Clone(tokens["offsets"][match.Key]); token = XVar.Clone(tokens["tokens"][match.Key]); repl = XVar.Clone(new XVar("offset", offset, "len", MVCFunctions.strlen((XVar)(match.Value)))); val = new XVar(""); if ((XVar)(MVCFunctions.IsNumeric(token)) && (XVar)(token < MVCFunctions.count(args))) { val = XVar.Clone(args[(int)token]); } else { val = XVar.Clone(context.getValue((XVar)(token))); } if (XVar.Pack(GlobalVars.conn.positionQuoted((XVar)(sql), (XVar)(offset)))) { repl.InitAndSetArrayItem(GlobalVars.conn.addSlashes((XVar)(val)), "insert"); } else { if (XVar.Pack(MVCFunctions.IsNumeric(val))) { repl.InitAndSetArrayItem(prepareNumberValue((XVar)(val)), "insert"); } else { repl.InitAndSetArrayItem(val, "insert"); } } replacements.InitAndSetArrayItem(repl, null); } offsetShift = new XVar(0); foreach (KeyValuePair <XVar, dynamic> r in replacements.GetEnumerator()) { sql = XVar.Clone(MVCFunctions.substr_replace((XVar)(sql), (XVar)(r.Value["insert"]), (XVar)(r.Value["offset"] + offsetShift), (XVar)(r.Value["len"]))); offsetShift += MVCFunctions.strlen((XVar)(r.Value["insert"])) - r.Value["len"]; } return(sql); }
public static XVar prepareNumberValue(dynamic _param_value) { #region pass-by-value parameters dynamic value = XVar.Clone(_param_value); #endregion dynamic strvalue = null; strvalue = XVar.Clone(value); if (XVar.Pack(MVCFunctions.IsNumeric(strvalue))) { return(MVCFunctions.str_replace(new XVar(","), new XVar("."), (XVar)(strvalue))); } return(0); }
public override XVar SQLWhere(dynamic _param_SearchFor, dynamic _param_strSearchOption, dynamic _param_SearchFor2, dynamic _param_etype, dynamic _param_isSuggest) { #region pass-by-value parameters dynamic SearchFor = XVar.Clone(_param_SearchFor); dynamic strSearchOption = XVar.Clone(_param_strSearchOption); dynamic SearchFor2 = XVar.Clone(_param_SearchFor2); dynamic etype = XVar.Clone(_param_etype); dynamic isSuggest = XVar.Clone(_param_isSuggest); #endregion dynamic hasDigits = null, i = null; hasDigits = new XVar(false); i = new XVar(0); for (; i < MVCFunctions.strlen((XVar)(SearchFor)); i++) { if (XVar.Pack(MVCFunctions.IsNumeric(SearchFor[i]))) { hasDigits = new XVar(true); break; } } if (XVar.Pack(!(XVar)(hasDigits))) { i = new XVar(0); for (; i < MVCFunctions.strlen((XVar)(SearchFor2)); i++) { if (XVar.Pack(MVCFunctions.IsNumeric(SearchFor2[i]))) { hasDigits = new XVar(true); break; } } } if ((XVar)(!(XVar)(hasDigits)) || (XVar)(SearchFor == XVar.Pack(""))) { return(""); } SearchFor = XVar.Clone(CommonFunctions.prepare_for_db((XVar)(this.field), (XVar)(SearchFor), new XVar("time"))); SearchFor2 = XVar.Clone(CommonFunctions.prepare_for_db((XVar)(this.field), (XVar)(SearchFor2), new XVar("time"))); return(base.SQLWhere((XVar)(SearchFor), (XVar)(strSearchOption), (XVar)(SearchFor2), (XVar)(etype), (XVar)(isSuggest))); }
public virtual XVar value(dynamic _param_field) { #region pass-by-value parameters dynamic field = XVar.Clone(_param_field); #endregion if (XVar.Pack(!(XVar)(prepareRecord()))) { return(null); } if (XVar.Pack(MVCFunctions.IsNumeric(field))) { return(this.data[field]); } if (XVar.Pack(this.fieldMap.KeyExists(field))) { return(this.data[this.fieldMap[field]]); } if (XVar.Pack(this.upperMap.KeyExists(MVCFunctions.strtoupper((XVar)(field))))) { return(this.data[this.upperMap[MVCFunctions.strtoupper((XVar)(field))]]); } return(null); }
public virtual XVar validate(dynamic _param_uploadedFile, dynamic file, dynamic _param_error, dynamic _param_file_size, dynamic _param_index, dynamic _param_uploadDir) { #region pass-by-value parameters dynamic uploadedFile = XVar.Clone(_param_uploadedFile); dynamic var_error = XVar.Clone(_param_error); dynamic file_size = XVar.Clone(_param_file_size); dynamic index = XVar.Clone(_param_index); dynamic uploadDir = XVar.Clone(_param_uploadDir); #endregion if (XVar.Pack(var_error)) { file.InitAndSetArrayItem(codeToMessage((XVar)(var_error)), "error"); return(false); } if (XVar.Pack(!(XVar)(file["name"]))) { file.InitAndSetArrayItem("No se ha indicado el nombre de fichero", "error"); return(false); } if (XVar.Pack(!(XVar)(MVCFunctions.preg_match((XVar)(this.options["accept_file_types"]), (XVar)(file["name"]))))) { file.InitAndSetArrayItem("El tipo de fichero es erróneo", "error"); return(false); } if ((XVar)(this.options["max_file_size"]) && (XVar)((XVar)(this.options["max_file_size"] * 1024 < file_size) || (XVar)(this.options["max_file_size"] * 1024 < file["size"]))) { file.InitAndSetArrayItem(MVCFunctions.mysprintf(new XVar("El tamaño del fichero supera el límite de %s KBytes"), (XVar)(new XVar(0, this.options["max_file_size"]))), "error"); return(false); } if ((XVar)(this.options["min_file_size"]) && (XVar)(file_size < this.options["min_file_size"] * 1024)) { file.InitAndSetArrayItem(MVCFunctions.mysprintf(new XVar("El tamaño del fichero no puede ser menor de %s KBytes"), (XVar)(new XVar(0, this.options["min_file_size"]))), "error"); return(false); } if ((XVar)(MVCFunctions.IsNumeric(this.options["max_totalFile_size"])) && (XVar)(this.options["max_totalFile_size"] * 1024 < getUploadFilesSize() + file["size"])) { file.InitAndSetArrayItem(MVCFunctions.mysprintf(new XVar("El tamaño de los ficheros supera el límite de %s KBytes"), (XVar)(new XVar(0, this.options["max_totalFile_size"]))), "error"); return(false); } if ((XVar)(MVCFunctions.IsNumeric(this.options["max_number_of_files"])) && (XVar)((XVar)(this.options["max_number_of_files"] <= getUploadFilesCount()) && (XVar)(0 < this.options["max_number_of_files"]))) { if (1 < this.options["max_number_of_files"]) { file.InitAndSetArrayItem(MVCFunctions.mysprintf(new XVar("No puede enviar más de %s ficheros"), (XVar)(new XVar(0, this.options["max_number_of_files"]))), "error"); } else { file.InitAndSetArrayItem("Solo puede enviar un fichero", "error"); } return(false); } if (XVar.Pack(CommonFunctions.isImageType((XVar)(uploadedFile["type"])))) { dynamic image_size = XVar.Array(), img_height = null, img_width = null; image_size = XVar.Clone(MVCFunctions.runner_getimagesize((XVar)(uploadedFile["tmp_name"]), (XVar)(uploadedFile))); img_width = XVar.Clone(image_size[0]); img_height = XVar.Clone(image_size[1]); if (XVar.Pack(MVCFunctions.IsNumeric(img_width))) { if ((XVar)((XVar)((XVar)(this.options["max_width"]) && (XVar)(this.options["max_width"] < img_width)) || (XVar)((XVar)(this.options["max_height"]) && (XVar)(this.options["max_height"] < img_height))) && (XVar)(!(XVar)(this.options["resizeOnUpload"]))) { file.InitAndSetArrayItem("maxResolution", "error"); return(false); } if ((XVar)((XVar)(this.options["min_width"]) && (XVar)(img_width < this.options["min_width"])) || (XVar)((XVar)(this.options["min_height"]) && (XVar)(img_height < this.options["min_height"]))) { file.InitAndSetArrayItem("minResolution", "error"); return(false); } } } return(true); }
protected static XVar _prepareValue(dynamic _param_value, dynamic _param_type) { #region pass-by-value parameters dynamic value = XVar.Clone(_param_value); dynamic var_type = XVar.Clone(_param_type); #endregion if (XVar.Pack(value == null)) { return("NULL"); } if ((XVar)((XVar)(CurrentConnection().dbType == Constants.nDATABASE_Oracle) || (XVar)(CurrentConnection().dbType == Constants.nDATABASE_DB2)) || (XVar)(CurrentConnection().dbType == Constants.nDATABASE_Informix)) { if (XVar.Pack(CommonFunctions.IsBinaryType((XVar)(var_type)))) { if (CurrentConnection().dbType == Constants.nDATABASE_Oracle) { return("EMPTY_BLOB()"); } return("?"); } if ((XVar)(CurrentConnection().dbType == Constants.nDATABASE_Informix) && (XVar)(CommonFunctions.IsTextType((XVar)(var_type)))) { return("?"); } } if ((XVar)(CommonFunctions.IsNumberType((XVar)(var_type))) && (XVar)(!(XVar)(MVCFunctions.IsNumeric(value)))) { value = XVar.Clone(MVCFunctions.trim((XVar)(value))); value = XVar.Clone(MVCFunctions.str_replace(new XVar(","), new XVar("."), (XVar)(value))); if (XVar.Pack(!(XVar)(MVCFunctions.IsNumeric(value)))) { return("NULL"); } } if ((XVar)(CommonFunctions.IsDateFieldType((XVar)(var_type))) || (XVar)(CommonFunctions.IsTimeType((XVar)(var_type)))) { if (XVar.Pack(!(XVar)(value))) { return("NULL"); } if (XVar.Pack(MVCFunctions.IsNumeric(value))) { if (XVar.Pack(CommonFunctions.IsDateFieldType((XVar)(var_type)))) { value = XVar.Clone(MVCFunctions.Concat(MVCFunctions.getYMDdate((XVar)(value)), " ", MVCFunctions.getHISdate((XVar)(value)))); } else { if (XVar.Pack(CommonFunctions.IsTimeType((XVar)(var_type)))) { value = XVar.Clone(MVCFunctions.getHISdate((XVar)(value))); } } } return(CurrentConnection().addDateQuotes((XVar)(value))); } if (XVar.Pack(CommonFunctions.NeedQuotes((XVar)(var_type)))) { return(CurrentConnection().prepareString((XVar)(value))); } return(value); }
public virtual XVar validate(dynamic _param_uploadedFile, dynamic file, dynamic _param_error, dynamic _param_file_size, dynamic _param_index, dynamic _param_uploadDir) { #region pass-by-value parameters dynamic uploadedFile = XVar.Clone(_param_uploadedFile); dynamic var_error = XVar.Clone(_param_error); dynamic file_size = XVar.Clone(_param_file_size); dynamic index = XVar.Clone(_param_index); dynamic uploadDir = XVar.Clone(_param_uploadDir); #endregion if (XVar.Pack(var_error)) { file.InitAndSetArrayItem(codeToMessage((XVar)(var_error)), "error"); return(false); } if (XVar.Pack(!(XVar)(file["name"]))) { file.InitAndSetArrayItem("File name was not provided", "error"); return(false); } if (XVar.Pack(!(XVar)(MVCFunctions.preg_match((XVar)(this.options["accept_file_types"]), (XVar)(file["name"]))))) { file.InitAndSetArrayItem("File type is not acceptable", "error"); return(false); } if ((XVar)(this.options["max_file_size"]) && (XVar)((XVar)(this.options["max_file_size"] * 1024 < file_size) || (XVar)(this.options["max_file_size"] * 1024 < file["size"]))) { file.InitAndSetArrayItem(MVCFunctions.mysprintf(new XVar("File size exceeds limit of %s kbytes"), (XVar)(new XVar(0, this.options["max_file_size"]))), "error"); return(false); } if ((XVar)(this.options["min_file_size"]) && (XVar)(file_size < this.options["min_file_size"] * 1024)) { file.InitAndSetArrayItem(MVCFunctions.mysprintf(new XVar("File size must not be less than %s kbytes"), (XVar)(new XVar(0, this.options["min_file_size"]))), "error"); return(false); } if ((XVar)(MVCFunctions.IsNumeric(this.options["max_totalFile_size"])) && (XVar)(this.options["max_totalFile_size"] * 1024 < getUploadFilesSize() + file["size"])) { file.InitAndSetArrayItem(MVCFunctions.mysprintf(new XVar("Total files size exceeds limit of %s kbytes"), (XVar)(new XVar(0, this.options["max_totalFile_size"]))), "error"); return(false); } if ((XVar)(MVCFunctions.IsNumeric(this.options["max_number_of_files"])) && (XVar)((XVar)(this.options["max_number_of_files"] <= getUploadFilesCount()) && (XVar)(0 < this.options["max_number_of_files"]))) { if (1 < this.options["max_number_of_files"]) { file.InitAndSetArrayItem(MVCFunctions.mysprintf(new XVar("You can upload no more than %s files"), (XVar)(new XVar(0, this.options["max_number_of_files"]))), "error"); } else { file.InitAndSetArrayItem("You can upload only one file", "error"); } return(false); } if (XVar.Pack(CommonFunctions.isImageType((XVar)(uploadedFile["type"])))) { dynamic image_size = XVar.Array(), img_height = null, img_width = null; image_size = XVar.Clone(MVCFunctions.runner_getimagesize((XVar)(uploadedFile["tmp_name"]), (XVar)(uploadedFile))); img_width = XVar.Clone(image_size[0]); img_height = XVar.Clone(image_size[1]); if (XVar.Pack(MVCFunctions.IsNumeric(img_width))) { if ((XVar)((XVar)((XVar)(this.options["max_width"]) && (XVar)(this.options["max_width"] < img_width)) || (XVar)((XVar)(this.options["max_height"]) && (XVar)(this.options["max_height"] < img_height))) && (XVar)(!(XVar)(this.options["resizeOnUpload"]))) { file.InitAndSetArrayItem("maxResolution", "error"); return(false); } if ((XVar)((XVar)(this.options["min_width"]) && (XVar)(img_width < this.options["min_width"])) || (XVar)((XVar)(this.options["min_height"]) && (XVar)(img_height < this.options["min_height"]))) { file.InitAndSetArrayItem("minResolution", "error"); return(false); } } } return(true); }
protected virtual XVar getDbPreparedValuesList(dynamic _param_value) { #region pass-by-value parameters dynamic value = XVar.Clone(_param_value); #endregion dynamic listValues = XVar.Array(), numeric = null, values = XVar.Array(), var_type = null; if (XVar.Pack(!(XVar)(this.pSet.multiSelect((XVar)(this.field))))) { return(""); } values = XVar.Clone(CommonFunctions.splitvalues((XVar)(value))); var_type = XVar.Clone(this.pSet.getLWLinkFieldType((XVar)(this.field))); numeric = new XVar(true); if (XVar.Pack(!(XVar)(var_type))) { foreach (KeyValuePair <XVar, dynamic> val in values.GetEnumerator()) { if ((XVar)(MVCFunctions.strlen((XVar)(val.Value))) && (XVar)(!(XVar)(MVCFunctions.IsNumeric(val.Value)))) { numeric = new XVar(false); break; } } } else { numeric = XVar.Clone(!(XVar)(CommonFunctions.NeedQuotes((XVar)(var_type)))); } listValues = XVar.Clone(XVar.Array()); foreach (KeyValuePair <XVar, dynamic> val in values.GetEnumerator()) { if ((XVar)(numeric) && (XVar)(!(XVar)(MVCFunctions.strlen((XVar)(val.Value))))) { continue; } if (XVar.Pack(numeric)) { listValues.InitAndSetArrayItem(val.Value + 0, null); } else { dynamic fName = null; fName = XVar.Clone((XVar.Pack(this.nLookupType == Constants.LT_QUERY) ? XVar.Pack(this.linkFieldName) : XVar.Pack(this.field))); listValues.InitAndSetArrayItem(this.lookupConnection.prepareString((XVar)(this.cipherer.EncryptField((XVar)(fName), (XVar)(val.Value)))), null); } } return(MVCFunctions.implode(new XVar(","), (XVar)(listValues))); }