|
Weidenhammer
|
WebMail
|
All Recipes
|
The Weather Channel »

|
12/15/2011
Convert Image to Base 64 String To Embed in Email...
<cfoutput> <cfimage
<img src="data:image/png;base64,#ToBase64(myImage)#">
</cfoutput>
12/15/2011
Embedding documents into email using ColdFusion
11/22/2011
Coldfusion Code to use Paged Records Stored Proc
<!--- Function used to select all BarCodeLabel records by Vendor Number... ------------------------------------------------------------------> <cffunction name="getBarCodesByVendorNumberPAGED" access="public" output="yes" returntype="struct"> <cfargument name="BCL_VENDORNUMBER" required="yes"> <cfargument name="intCurrentPage" required="yes"> <cfargument name="intPageSize" required="yes"> <cfstoredproc procedure="dbo.sp_barCodeLabels_BCL_SELECTP_BY_VEND0R_NUM_PAGED" datasource="#request.DSN#"> <cfprocparam type="IN" dbvarname="@BCL_VendorNumber" value="#arguments.BCL_VENDORNUMBER#" cfsqltype="CF_SQL_VARCHAR"> <cfprocparam type="IN" dbvarname="@intPageSize" value="#arguments.intPageSize#" cfsqltype="cf_sql_integer"> <cfprocparam type="IN" dbvarname="@intCurrentPage" value="#arguments.intCurrentPage#" cfsqltype="cf_sql_integer"> <cfprocresult name="rsTotalRecords" resultset="1"> <cfprocresult name="rsTotalPages" resultset="2"> <cfprocresult name="rsBarCodeLabels_BCL" resultset="3"> <cfprocresult name="rsDistinctPOs_BCL" resultset="4"> </cfstoredproc> <cfset structResult = structNew()> <cfset structResult.intTotalRecords = rsTotalRecords.totalRecords> <cfset structResult.intTotalPages = rsTotalPages.totalPages> <cfset structResult.rsbarCodeLabels_BCL = rsbarCodeLabels_BCL> <cfset structResult.rsDistinctPOs_BCL = rsDistinctPOs_BCL> <cfreturn structResult> </cffunction>
11/22/2011
SQL Server - Getting paged records from Stored Procedure
USE [YOUR_DB_NAME] GO /****** Object: StoredProcedure [dbo].[sp_barCodeLabels_BCL_SELECTP_BY_VEND0R_NUM_PAGED] Script Date: 11/22/2011 23:06:01 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO /* AUTHOR: CodeBuilder_3434 DATE: 10/21/2011 01:36:17 PM - Getting paged records for BCL lable... */ ALTER PROC [dbo].[sp_barCodeLabels_BCL_SELECTP_BY_VEND0R_NUM_PAGED] @BCL_VendorNumber VARCHAR(7) = NULL, @intPageSize int = 10, @intCurrentPage int = 1 AS /* IF A PK WAS PROVIDED, SEARCH BY PK... */ Declare @intPageStart as int Declare @intPageEnd as int Declare @intTotalRecords as int Declare @intTotalPages as int set @intPageStart = (@intCurrentPage-1) * @intPageSize + 1 set @intPageEnd = @intCurrentPage * @intPageSize select @intTotalRecords = count(1) FROM barCodeLabels_BCL WHERE BCL_VendorNumber = @BCL_VendorNumber -- First result set: Total Records!!! select @intTotalRecords as totalRecords -- Note that if we don't cast as 'float' Ceiling does not work, since it -- defaults to integer devision!!! set @intTotalPages = Ceiling(cast(@intTotalRecords as float)/@intPageSize) -- Second result set: Total pages!!! select @intTotalPages as totalPages -- Third result set: selected records in current page... SELECT * FROM ( SELECT row_number() over (order by BCL_PO, BCL_SKU) as rowNum, BCL_VENDORNUMBER, BCL_PO, BCL_SKU, BCL_QTY, BCL_UNITOFMEASURE, BCL_ITEMDESC, BCL_NUMBEROFCARTONS, BCL_DATEIMPORTED FROM barCodeLabels_BCL WHERE BCL_VendorNumber = @BCL_VendorNumber ) as Sub WHERE Sub.rowNum between @intPageStart and @intPageEnd ORDER BY BCL_PO, BCL_SKU -- Fourth result set, all distinct POs SELECT DISTINCT BCL_PO FROM barCodeLabels_BCL WHERE BCL_VendorNumber = @BCL_VendorNumber
10/07/2011
IIS settings that control MAX upload size - Classic ASP Code
To resolve this problem, follow these steps:
07/26/2011
SQL Server - Getting Paged Records
--=============================================================================== -- Getting paged records... --=============================================================================== Declare @intPageSize as int Declare @intCurrentPage as int Declare @intPageStart as int Declare @intPageEnd as int Declare @intTotalRecords as int Declare @intTotalPages as int set @intPageSize = 50; set @intCurrentPage = 4 set @intPageStart = (@intCurrentPage-1) * @intPageSize + 1 set @intPageEnd = @intCurrentPage * @intPageSize select @intTotalRecords = count(1) from tblPage_PAG select @intTotalRecords as totalRecords -- Note that if we don't cast as 'float' Ceiling does not work, since it -- defaults to integer devision!!! set @intTotalPages = Ceiling(cast(@intTotalRecords as float)/@intPageSize) select @intTotalPages as totalPages select * from ( SELECT row_number() over (order by pag_id) as rowNum, PAG_ID, PAG_TITLE, PAG_CONTENT, PAG_MODIFICATIONDATE, PAG_MODIFICATIONUSR, PAG_ACTIVE, PAG_INCLUDE, PAG_PARENT, PAG_ORDER, PAG_SEO_URL FROM tblPage_PAG ) as Sub where Sub.rowNum between @intPageStart and @intPageEnd --===============================================================================
12/21/2010
Creating a simple plugin for Eclipse - Web Browser Window
Steps for creating the new ldpc statutes browser plugin: NOTE, THE INSTRUCTIONS BELOW ASSUME THAT THE USER WILL NOT MODIFY
3. Optionally, choose a different location, or just keep the 5. Screen #2, leave all things alone, press Next > 6. Screen #3, check the checkbox: "Create a plugin using one of the templates: 8. Java Package Name: com.ldpc.webbrowser [you will need to remove 'view' from this one if you want the new class and its activator class to be in the same package!!!] 9. Click on the Finish button... You will be given another screen where you need to enter the following: 10. replace the code within the ldpcBrowser.java class file located MAKE SURE TO RESOLVE ANY REFERENCING ISSUES RESULTING FROM ANY DEVIATIONS
/*--------------------------------------------------------------------------------------------*/ import org.eclipse.swt.widgets.Composite; import java.io.BufferedReader; public class ldpcBrowser extends ViewPart // I’m fairly certain that the first two variables are not needed, they are just left over from something else I tried // I think this is the only variable needed to load a page @Override } File file = new File("c://ldpcBrowserPath.txt"); try // repeat until all lines is read 11. if desired, update the icon image...modify the image being used by default 12. FINALLY, to use the new plugin, dbl-click on the plugin.xml file Select the newly created plugin from the list under: If all goes well, the plugin will be generated...under the selected folder C:Documents and Settingsvictor3434My DocumentsSOFTWAREPHP Toolseclipseplugins* Note that this particular plugin was designed to use an external file make sure to crate this file yourself in the specified location, or in
12/04/2010
codeBuilder against DB2 Database
<!--- Author: Victor Sanchez ---> <!--- Date: May 15, 2009 ---> <!--- Desc: Code builder to work against DB2 ---> <!--- Make sure this code only runs in development environment for security reasons... ---> <cfif FindNoCase("development.server.domainname", cgi.SERVER_NAME)> <!--- Get the list of available tables available to this datasource ---> <cfquery name="tablesQry" datasource="#Request.DSN#"> SELECT DISTINCT T.TABNAME AS TABLE_NAME FROM SYSCAT.Tables T JOIN SYSCAT.Columns C ON T.TABNAME = C.TABNAME WHERE T.TABSCHEMA = 'LAWINFO' ORDER BY TABLE_NAME </cfquery> <!--- Get metadata about a selected table... ---> <cffunction name="getTableInfo" access="public" returntype="query"> <cfargument name="table_name" required="yes" type="string"> <cfquery name="tableInfoQry" datasource="#Request.DSN#"> SELECT C.*, T.TABNAME AS TABLE_NAME, Upper(C.COLNAME) AS COLUMN_NAME, CASE C.NULLS WHEN 'Y' THEN 'no' WHEN 'N' THEN 'yes' END AS IS_REQUIRED, C.TYPENAME AS DATA_TYPE, C.LENGTH AS CHARACTER_MAXIMUM_LENGTH, C.COLNO FROM SYSCAT.Tables T JOIN SYSCAT.Columns C ON T.TABNAME = C.TABNAME WHERE T.TABNAME = '#arguments.table_name#' ORDER BY C.COLNO, C.NULLS ASC </cfquery> <!--- <cfdump var="#tableInfoQry#"> ---> <cfreturn tableInfoQry> </cffunction> <!--- Default parameters... ---> <cfparam name="form.txtTableName" default="tblSomeTableName_STN"> <cfparam name="form.txtSchemaName" default="LAWINFO"> <cfparam name="form.txtObjectName" default="#form.txtTablename#"> <cfparam name="form.txtTablePK" default="PK_ID"> <cfparam name="form.selCreateFiles" default="no"> <!--- Try to extract the name of the object based on the name of the table... ---> <cfset strTableName = form.txtTableName> <!--- <cfset strTableName = RemoveChars(Reverse(strTableName), 1, 4)> ---> <cfset strObjectName = form.txtObjectName> <cfset strTableTail = Right(form.txtTablename, 4)> <cfset strPageTitle = "<ColdFusion Object Code Builder>"> <html> <head> <title><cfoutput>#strPageTitle#</cfoutput></title> </head> <style type="text/css"> * { font-family: verdana; } body { background-color:#000033; color:whiteSmoke; font-weight:bold; font-size: 12px; overflow-x:hidden; overflow-y: scroll; margin:0px; } .pageTitle { font-size: 20px; color:#000066; width:100%; text-align:center; } .code { font-family: "Courier New"; width:1200px; height:600px; overflow:scroll; background-color:silver; font-size:10.5px; } .resetButtonInactive { background-color: #003300; color:gray; border:2px solid #003300; cursor:pointer; font-weight:bold; } .resetButtonActive { background-color: #005500; color:white; border:2px solid #005500; cursor:pointer; font-weight:bold; } .buildButtonInactive { background-color:#000066; color:gray; border:2px solid #000066; cursor:pointer; font-weight:bold; } .buildButtonActive { background-color:#000099; color:white; border:2px solid #000099; cursor:pointer; font-weight:bold; } .copyCodeButton { background-color:#aaaaaa; color:black; border:2px solid black; cursor:pointer; font-weight:bold; width:250px } .cssAssumptionNote { color:black; background-color: #CCCCCC; border:5px dashed #aaaaaa; font-size:14px; font-family:'Courier New'; width:800px; padding:5px; } </style> <body> <cfoutput> <div class="pageTitle" style="color:white;; position:relative; top:28px; left:5px">#strPageTitle#</div> <div id="idPageTitle" style="padding:10px; background-color:##000023;"> <div class="pageTitle">#strPageTitle#</div> </div> <center> <pre class="cssAssumptionNote"> <span style="color:firebrick">Assumption:</span> Table Names use the following naming convention: <span style="color:navy ">JSCT_</span><span style="color:blue ">CMSN</span><span style="color:navy ">_TBL</span> </pre> </center> <br> <cfform name="frmBuildObject" method="post" action="#cgi.PATH_INFO#"> <div style="display:inline">Schema name: </div> <cfinput type="text" name="txtSchemaName" value="#form.txtSchemaName#" onFocus="this.select()"> <div style="display:inline">Table Name: </div> <cfselect name="txtTableName" query="tablesQry" value="table_name" display="table_name" selected="#form.txtTablename#"/> <div style="display:inline">Object name: </div> <cfinput type="text" name="txtObjectName" value="#form.txtObjectName#" onFocus="this.select()"> <div style="display:inline">Table PK: </div> <cfinput type="text" name="txtTablePK" value="#form.txtTablePK#" onFocus="this.select()"> <div> <div style="display:inline">Create Files? </div> <cfselect name="selCreateFiles"> <option value="yes" <cfif form.selCreateFiles eq 'yes'>selected</cfif>>Yes</option> <option value="no" <cfif form.selCreateFiles eq 'no'>selected</cfif>>No</option> </cfselect> <cfinput type="button" name="btnBuildObject" value="Build Object" onClick="submitForm(this.form)" class="buildButtonInactive" onMouseOut="this.className='buildButtonInactive'" onMouseOver="this.className='buildButtonActive'" /> <cfinput type="button" name="btmReset" value="Reset" onClick="resetForm()" class="resetButtonInactive" onMouseOut="this.className='resetButtonInactive'" onMouseOver="this.className='resetButtonActive'" /> </div> </cfform> <script language="javascript"> function submitForm(objForm) { objForm.submit(); } function resetForm(objForm) { window.location = "#cgi.SCRIPT_NAME#"; } </script> </cfoutput> <!--- If the form was submitted, build the cfObject... ---> <cfif cgi.REQUEST_METHOD eq "POST"> <!--- Get META-DATA about the selected table... ---> <cfset tableMetaDataQry = getTableInfo(form.txtTableName)> <!--- Generate a list of column names for the selected table... ---> <cfset strColumnList = ""> <cfset strSaveRecordArguments = ""> <cfset strColumnListForInsert = ""> <cfset strInsertValues = ""> <cfset strUpdateValues = ""> <cfset strFakeData = ""> <cfset strFormFields = ""> <cfset strCFParams = ""> <cfset strDataFromDB = ""> <cfset strColumnListForCMSInsert = ""> <cfoutput query="tableMetaDataQry"> <!--- Format strColumnList... ---> <cfset strColumnList = strColumnList & chr(9) & chr(9) & chr(9) & tableMetaDataQry.column_name> <!--- Format strSaveRecordArguments... ---> <cfset strSaveRecordArguments = strSaveRecordArguments & chr(9) & chr(9) & "<cfargument name=""" & tableMetaDataQry.column_name & """ required=""" & Trim(tableMetaDataQry.is_required) & """>"> <!--- Format strColumnListForInsert... ---> <cfset strColumnListForInsert = strColumnListForInsert & chr(9) & chr(9) & chr(9) & chr(9) & chr(9) & tableMetaDataQry.column_name> <!--- Format strColumnListForCMSInsert... ---> <cfset strColumnListForCMSInsert = strColumnListForCMSInsert & chr(9) & chr(9) & "form." & tableMetaDataQry.column_name & ""> <!--- Format strFakeData ---> <cfset strFakeData = strFakeData & chr(9) & chr(9)> <!--- Format intMaxLength... ---> <cfset intMaxLength = tableMetaDataQry.CHARACTER_MAXIMUM_LENGTH> <cfif tableMetaDataQry.DATA_TYPE eq "TIMESTAMP"> <cfset intMaxLength = 26> </cfif> <cfif tableMetaDataQry.DATA_TYPE eq "DATE"> <cfset intMaxLength = 26> </cfif> <cfif tableMetaDataQry.DATA_TYPE eq "SMALLINT"> <cfset intMaxLength = 10> </cfif> <cfswitch expression="#tableMetaDataQry.data_type#"> <cfcase value="uniqueidentifier"> <cfset strSqlType = "cf_sql_varchar"> <cfset strFakeData = strFakeData & "''"> <cfset intMaxLength = 36> </cfcase> <cfcase value="bit"> <cfset strSqlType = "cf_sql_bit"> <cfset strFakeData = strFakeData & "0"> <cfset intMaxLength = 1> </cfcase> <cfcase value="nvarchar,varchar"> <cfset strSqlType = "cf_sql_varchar"> <cfset strFakeData = strFakeData & "'" & tableMetaDataQry.column_name & "'"> </cfcase> <cfcase value="ntext,text"> <cfset strSqlType = "cf_sql_varchar"> <!--- Don't need a maxlength for ntext/text.... ---> <cfset intMaxLength = ""> <cfset strFakeData = strFakeData & "'This field is probably a comments or description field...'"> </cfcase> <cfcase value="int,smallint"> <cfset strSqlType = "cf_sql_integer"> <cfset strFakeData = strFakeData & "34"> </cfcase> <cfcase value="numeric"> <cfset strSqlType = "cf_sql_numeric"> <cfset strFakeData = strFakeData & "3434"> </cfcase> <cfcase value="float"> <cfset strSqlType = "cf_sql_float"> <cfset strFakeData = strFakeData & "34.34"> </cfcase> <cfcase value="timestamp,datetime"> <cfset strSqlType = "cf_sql_timestamp"> <cfset strFakeData = strFakeData & "'" & DateFormat(Now(), 'MM/DD/YYYY') & " " & TimeFormat(Now(), 'hh:mm:ss tt') & "'"> </cfcase> <cfdefaultcase> <cfset strSqlType = "cf_sql_varchar"> <cfset strFakeData = strFakeData & "'" & tableMetaDataQry.column_name & "'"> </cfdefaultcase> </cfswitch> <cfset strMaxLength = ""> <cfset strFieldSize = ""> <cfif intMaxLength neq ""> <cfset strMaxLength = "maxlength=""" & intMaxLength & """ "> <cfset intFieldSize = intMaxLength> <cfif intFieldSize gt 75> <cfset intFieldSize = 75> </cfif> <cfset strFieldSize = "size=""" & intFieldSize & """ "> </cfif> <cfset strValue = "##Arguments." & tableMetaDataQry.column_name & "##"> <cfset strInsertValues = strInsertValues & chr(9) & chr(9) & chr(9) & chr(9) & chr(9) & "<cfqueryparam cfsqltype=""" & strSqlType & """ " & strMaxLength & "value=""" & strValue & """ null=""##NOT(Len(Arguments." & tableMetaDataQry.column_name & "))##"">"> <!--- Format strUpdateValues [Note: Does not include the table's Primary Key...]... ---> <cfif tableMetaDataQry.column_name neq form.txtTablePK> <cfset strUpdateValues = strUpdateValues & chr(9) & chr(9) & chr(9) & chr(9) & chr(9) & tableMetaDataQry.column_name & " = <cfqueryparam cfsqltype=""" & strSqlType & """ " & strMaxLength & "value=""" & strValue & """ null=""##NOT(Len(Arguments." & tableMetaDataQry.column_name & "))##"">"> </cfif> <cfset strRequiredField = ""> <cfset strRequiredIndicator = ""> <cfif Trim(tableMetaDataQry.is_required) eq "yes"> <cfset strRequiredField = " required=""yes"" message=""" & tableMetaDataQry.column_name & " is a required field"" "> <cfset strRequiredIndicator = "<span class='cssRequiredField'>*</span>"> </cfif> <!--- Format strFormFields ---> <cfif tableMetaDataQry.data_type eq "bit"> <cfset strFormFields = strFormFields & " <tr> <td align=""right""> <div class=""cssFormLabel"">#strRequiredIndicator##tableMetaDataQry.column_name#? </div> </td> <td align=""left""> <cfselect name=""#tableMetaDataQry.column_name#""> <option value=""1"" <cfif form.#tableMetaDataQry.column_name# eq 1>selected</cfif>>Yes</option> <option value=""0"" <cfif form.#tableMetaDataQry.column_name# eq 0>selected</cfif>>No</option> </cfselect> </td> </tr> "> <cfelseif tableMetaDataQry.data_type eq "ntext"> <cfset strFormFields = strFormFields & " <tr> <td align=""right""> <div class=""cssFormLabel"">#strRequiredIndicator##tableMetaDataQry.column_name#? </div> </td> <td align=""left""> <cftextarea class=""cssTextArea"" name=""#tableMetaDataQry.column_name#""><cfoutput>##form.#tableMetaDataQry.column_name###</cfoutput></cftextarea> </td> </tr> "> <cfelseif tableMetaDataQry.column_name eq form.txtTablePK> <!--- Do nothing, this field will be added as a hidden field...see code below... ---> <cfelse> <cfset strFormFields = strFormFields & " <tr> <td align=""right""> <div class=""cssFormLabel"">#strRequiredIndicator##tableMetaDataQry.column_name#: </div> </td> <td align=""left""> <cfinput type=""text"" name=""#tableMetaDataQry.column_name#"" value=""##form.#tableMetaDataQry.column_name###"" #strMaxLength# #strFieldSize# #strRequiredField#> </td> </tr> "> </cfif> <!--- Format strCFParams ---> <cfif tableMetaDataQry.data_type neq "bit"> <cfset strCFParams = strCFParams & "<cfparam name=""form.#tableMetaDataQry.column_name#"" default="""">"> <cfelse> <cfset strCFParams = strCFParams & "<cfparam name=""form.#tableMetaDataQry.column_name#"" default=""0"">"> </cfif> <!--- Format strDataFromDB ---> <cfset strDataFromDB = strDataFromDB & chr(9) & "<cfset form.#tableMetaDataQry.column_name# = #strObjectName#Qry.#tableMetaDataQry.column_name#>"> <!--- Add line breaks to these lists so as long as it is not the last column in the table...---> <cfif tableMetaDataQry.RecordCount neq tableMetaDataQry.CurrentRow> <cfset strColumnList = strColumnList & "," & chr(13)> <cfset strSaveRecordArguments = strSaveRecordArguments & chr(13)> <cfset strColumnListForInsert = strColumnListForInsert & "," & chr(13)> <cfset strColumnListForCMSInsert = strColumnListForCMSInsert & "," & chr(13)> <cfset strInsertValues = strInsertValues & "," & chr(13)> <cfif tableMetaDataQry.column_name neq form.txtTablePK> <cfset strUpdateValues = strUpdateValues & "," & chr(13)> </cfif> <cfset strFakeData = strFakeData & "," & chr(13)> <cfset strCFParams = strCFParams & chr(13)> <cfset strDataFromDB = strDataFromDB & chr(13)> </cfif> </cfoutput> <cfset strCode = " <!--- Data Access Layer For: #form.txtTableName# ----------------------------------------------------------------------------------------------> <cfcomponent> <!--- Function used to retrieve all records -----------------------------------------------------------------------------------------------> <cffunction name=""getAll"" access=""public"" returntype=""query""> <cfquery name=""allRecordsQry"" datasource=""##Request.DSN##""> SELECT " & strColumnList & " FROM #form.txtSchemaName#.#form.txtTableName# ORDER BY #form.txtTablePK# </cfquery> <cfreturn allRecordsQry> </cffunction> <!--- Function used to retrieve a specific record -----------------------------------------------------------------------------------------> <cffunction name=""getByID"" access=""public"" returntype=""query""> <cfargument name=""#form.txtTablePK#"" required=""yes""> <cfquery name=""recordQry"" datasource=""##Request.DSN##""> SELECT " & strColumnList & " FROM #form.txtSchemaName#.#form.txtTableName# WHERE #form.txtTablePK# = <cfqueryparam cfsqltype=""cf_sql_varchar"" maxlength=""36"" value=""##Arguments.#form.txtTablePK###""> </cfquery> <cfreturn recordQry> </cffunction> <!--- Function used to delete a specific record--------------------------------------------------------------------------------------------> <cffunction name=""delete"" access=""public"" returntype=""void""> <cfargument name=""#form.txtTablePK#"" required=""yes""> <cfquery name=""recordQry"" datasource=""##Request.DSN##""> DELETE FROM #form.txtSchemaName#.#form.txtTableName# WHERE #form.txtTablePK# = <cfqueryparam cfsqltype=""cf_sql_int"" maxlength=""10"" value=""##Arguments.#form.txtTablePK###""> </cfquery> </cffunction> <!--- Function used to INSRT or SAVE a specific record-------------------------------------------------------------------------------------> <cffunction name=""save"" access=""public"" returntype=""string""> " & strSaveRecordArguments & " <!--- First, determine if the record needs to be inserted or merely updated... ---> <cfset blnNeedToInsert = FALSE> <cfif LEN(TRIM(Arguments.#form.txtTablePK#)) EQ 0> <cfset blnNeedToInsert = TRUE> </cfif> <cfif blnNeedToInsert> <!--- We need to INSERT a brand new record... ---> <cfquery name=""recordQry"" datasource=""##Request.DSN##""> INSERT INTO #form.txtSchemaName#.#form.txtTableName# ( " & strColumnListForInsert & " ) VALUES ( " & strInsertValues & " ) </cfquery> <cfquery name=""lastIDQry"" datasource=""#Request.DSN#""> SELECT IDENTITY_VAL_LOCAL() AS last_id FROM SYSIBM.SYSDUMMY1 </cfquery> <cfset Arguments.#form.txtTablePK# = lastIDQry.last_id> <cfelse> <!--- We need to UPDATE an existing record... ---> <cfquery name=""recordQry"" datasource=""##Request.DSN##""> UPDATE #form.txtSchemaName#.#form.txtTableName# SET " & strUpdateValues & " WHERE #form.txtTablePK# = <cfqueryparam cfsqltype=""cf_sql_varchar"" maxlength=""36"" value=""##Arguments.#form.txtTablePK###""> </cfquery> </cfif> <!--- Return the ID of the affected record... ---> <cfreturn Arguments.#form.txtTablePK#> </cffunction> </cfcomponent> "> <cfset strCFMLForm = " <!--- If the user is trying to UPDATE an existing record...get info from the database... ---> <cfif StructKeyExists(URL, ""#form.txtTablePK#"")> <cfset #strObjectName#Qry = #strObjectName#Obj.getByID(URL.#form.txtTablePK#)> </cfif> <style type=""text/css""> input { font-size: 12px; } select { font-size: 12px; } .cssFormLabel { color: black; background-color: ##dddddd; line-height: 20px; font-familly: verdana; font-weight: bold; font-size: 10px; } .cssAdminFormContainerTable { background-color: ##eeeeee; width: 1000px; } .cssSaveButton { width: 150px; } .cssTimestamp { color: navy; font-family:verdana; font-weight:bold; font-size:12px; } .cssRequiredField { color: red; font-size: 12px; font-family: verdana; } .cssTextArea { width: 500px; height: 100px; } </style> <!--- Make sure these parameters exist... ---> " & strCFParams & " <!--- If the user is updating this form, set the form values from the DB query... ---> <cfif StructKeyExists(URL, ""#form.txtTablePK#"") AND #strObjectName#Qry.RecordCount eq 1> " & strDataFromDB & " </cfif> <!--- Display save timestamp if the user just saved the file... ---> <cfif StructKeyExists(url, ""savetime"")> <br /> <div class=""cssTimestamp""><cfoutput>##DateFormat(url.savetime, 'MM/DD/YYYY')## ##TimeFormat(url.savetime, 'hh:mm:ss tt')##</cfoutput></div> </cfif> <cfform name=""frm#strObjectName#"" action=""index.cfm?act=#strObjectName#&subact=act_save"" method=""POST"" onsubmit=""return validateForm(_CF_this);""> <cfinput type=""hidden"" name=""#form.txtTablePK#"" value=""##form.#form.txtTablePK###""> <br> <table class=""cssAdminFormContainerTable""> <tr> <td> <table> " & strFormFields & " <tr> <td align=""right""> <div class=""cssFormLabel""> </div> </td> <td align=""right""> <cfinput type=""image"" src=""resources/images/btnSave.png"" name=""btnSubmit"" style=""border:none; cursor:pointer"" title=""Save""> </td> </tr> </table> </td> </tr> </table> <script language=""Javascript""> /* Validate form before submitting... */ function validateForm(objForm) { /* Return true or false depending on success of the validation results... */ return true; } </script> </cfform> "> <cfset strCFMLDelete = " <!--- Delete the requested record... ---> <cfif StructKeyExists(URL, ""#form.txtTablePK#"")> <cfset #strObjectName#Obj.delete(URL.#form.txtTablePK#)> </cfif> <!--- Send user back to the list of records... ---> <cflocation addtoken=""no"" url=""index.cfm?act=#LCase(strObjectName)#""> "> <cfset strCFMLSave = " <!--- Insert or Update the requested record... ---> <cfif StructKeyExists(FORM, ""#form.txtTablePK#"")> <!--- INSERTING A NEW RECORD... ---> <cfset FORM.#form.txtTablePK# = #strObjectName#Obj.save ( " & strColumnListForCMSInsert & " )> </cfif> <!--- Send user back to updated record... ---> <cflocation addtoken=""no"" url=""index.cfm?act=#LCase(strObjectName)#&subact=dsp_form&#form.txtTablePK#=##FORM.#form.txtTablePK###&savetime=##Now()##""> "> <cfset strCFMLList = " <cfset #strObjectName#Qry = #strObjectName#Obj.getAll()> <style type=""text/css""> .cssFormLabel { color: black; background-color: ##dddddd; line-height: 20px; font-familly: verdana; font-weight: bold; font-size: 10px; } .cssAdminFormContainerTable { background-color: ##eeeeee; width: 1000px; } .cssSaveButton { width: 150px; } .cssOnMouseOverBG { background-color:whiteSmoke; cursor:pointer; } </style> <cfif #strObjectName#Qry.RecordCount gt 0> <table style=""width: 1000px""> <tr> <td> <div class=""cssFormLabel""> Name </div> </td> <td> <div class=""cssFormLabel""> Action </div> </td> </tr> <cfoutput query=""#strObjectName#Qry""> <tr onMouseover=""this.className='cssOnMouseOverBG'"" onMouseout=""this.className=''""> <td> ###strObjectName#Qry.#Right(txtTableName, 3)#_Name## </td> <td> <a href=""index.cfm?act=#LCase(strObjectName)#&subact=dsp_form&#form.txtTablePK#=###strObjectName#Qry.#form.txtTablePK###"">Edit</a> | <a href=""index.cfm?act=#LCase(strObjectName)#&subact=act_delete&#form.txtTablePK#=###strObjectName#Qry.#form.txtTablePK###"">Delete</a> </td> </tr> </cfoutput> </table> </cfif> "> <cfset strCFMLObject = " <link href='/resource/css/cms_admin.css' type='text/css' rel='stylesheet' /> <script language='javascript' src='/resource/scripts/cms_scripts.js'></script> <!--- Instantiate all objects to be used in the admin here... ---> <cfset #strObjectName#Obj = CreateObject(""component"", ""objects.#strObjectName#"")> <h3>#strObjectName#</h3> <table> <tr> <td> <a href=""index.cfm?act=#LCase(strObjectName)#&subact=dsp_list"">List</a> | <a href=""index.cfm?act=#LCase(strObjectName)#&subact=dsp_form"">New</a> </td> </tr> </table> <cfparam name=""url.subact"" default=""dsp_list""> <!--- Include the requested template based on the url.subact if any... ---> <cfinclude template=""##url.subact##.cfm""> "> <cfoutput> <cfset strCurrentPath = GetDirectoryFromPath(ExpandPath("*.*"))> <!--- Write the output to a local file... ---> <!--- <cffile action="write" file="#strCurrentPath#theForm.cfm" output="#strCFMLForm#"> ---> <!--- Open the file you just wrote... ---> <!--- <cfinclude template="theForm.cfm"> ---> <!--- Remove the form we just created, we no longer need it!!! ---> <!--- <cffile action="delete" file="#strCurrentPath#theForm.cfm"> ---> <!--- OBJECT CODE................................................................................................................. ---> <hr> <div style="color:orange; "> Object Code </div> <hr> <!--- Code definition for the object... ---> <div style="cursor:pointer; color:firebrick" onClick="expandCollapse(this, '#strObjectName#.cfc','txtObjectCode');"> [+] #strObjectName#.cfc </div> <br> <textarea id="txtObjectCode" class="code" style="display:none; " onDblClick="this.select()"> #strCode# </textarea> <!--- CMS ADMIN CODE.............................................................................................................. ---> <hr> <div style="color:orange; "> CMS code </div> <hr> <!--- Code definition for CMS Admin dsp_object.cfm... ---> <div style="cursor:pointer; color:##009900" onClick="expandCollapse(this, 'dsp_#LCase(strObjectName)#.cfm','idCMSObject');"> [+] dsp_#LCase(strObjectName)#.cfm </div> <br> <textarea id="idCMSObject" class="code" style="display: none;" onDblClick="this.select()"> #strCFMLObject# </textarea> <!--- Code definition for CMS Admin act_list.cfm... ---> <div style="cursor:pointer; color:##009900" onClick="expandCollapse(this, 'dsp_list.cfm','idCMSList');"> [+] dsp_list.cfm </div> <br> <textarea id="idCMSList" class="code" style="display: none;" onDblClick="this.select()"> #strCFMLList# </textarea> <!--- Code definition for CMS Admin dsp_form... ---> <div style="cursor:pointer; color:##009900" onClick="expandCollapse(this, 'dsp_form.cfm','txtFormCode');"> [+] dsp_form.cfm </div> <br> <textarea id="txtFormCode" class="code" style="display: none;" onDblClick="this.select()"> #strCFMLForm# </textarea> <!--- Code definition for CMS Admin act_delete... ---> <div style="cursor:pointer; color:##009900" onClick="expandCollapse(this, 'act_save.cfm','idCMSSave');"> [+] act_save.cfm </div> <br> <textarea id="idCMSSave" class="code" style="display: none;" onDblClick="this.select()"> #strCFMLSave# </textarea> <!--- Code definition for CMS Admin act_delete... ---> <div style="cursor:pointer; color:##009900" onClick="expandCollapse(this, 'act_delete.cfm','idCMSDelete');"> [+] act_delete.cfm </div> <br> <textarea id="idCMSDelete" class="code" style="display: none;" onDblClick="this.select()"> #strCFMLDelete# </textarea> <hr> </cfoutput> <!--- Generated the files in a temporary directory if the user requested this... ---> <cfif form.selCreateFiles eq 'yes'> <!--- Created the temporary directory in which the place the files... ---> <cfset strCodeDirectory = "#strCurrentPath#codeBuilderFiles_3434"> <cftry> <cfdirectory action="create" directory="#strCodeDirectory#"> <cfcatch type="any"> <cfif FindNoCase("already exists on your file system.", cfcatch.Detail)> <!--- Do nothing, the directory already existed... ---> <cfelse> <cfdump var="#cfcatch.Message#"> </cfif> </cfcatch> </cftry> <!--- Remove all files form the directory... ---> <cfdirectory action="list" name="sourceDirQry" directory="#strCodeDirectory#"> <cfloop query="sourceDirQry"> <cffile action="delete" file="#sourceDirQry.directory##sourceDirQry.name#"> </cfloop> <!--- Generate the files... ---> <cffile action="write" file="#strCodeDirectory##strObjectName#.cfc" output="#strCode#"> <cffile action="write" file="#strCodeDirectory#dsp_#LCase(strObjectName)#.cfm" output="#strCFMLObject#"> <cffile action="write" file="#strCodeDirectory#dsp_list.cfm" output="#strCFMLList#"> <cffile action="write" file="#strCodeDirectory#dsp_form.cfm" output="#strCFMLForm#"> <cffile action="write" file="#strCodeDirectory#act_save.cfm" output="#strCFMLSave#"> <cffile action="write" file="#strCodeDirectory#act_delete.cfm" output="#strCFMLDelete#"> </cfif> </cfif> <script language="javascript"> /* This function only works in IE!!! */ function copyToClipboard(strContentID) { window.clipboardData.setData("Text", document.getElementById(strContentID).value); document.getElementById(strContentID).select(); } // Function used to expand and collapse content... function expandCollapse(objMenu, strMenuString, divID) { objDiv = document.getElementById(divID); if(objDiv.style.display == 'none') { objDiv.style.display = 'block'; objMenu.innerHTML = '[-] ' + strMenuString; } else { objDiv.style.display = 'none'; objMenu.innerHTML = '[+] ' + strMenuString; } } </script> </body> </html> <!--- DEVELOPER NOTE: If you want to see debugging information, just add a 'debug' to the list of URL parameters... ---> <cfif StructKeyExists(url, "debug")> <cfsetting showdebugoutput="yes"> <cfelse> <cfsetting showdebugoutput="no"> </cfif> <cfelse> CF Code Builder </cfif>
12/03/2010
Forced File Download
<!--- Function used to perform a forced-download from the server... --------------------------------------------------------------> <cffunction name="downloadFile" access="public" returntype="void"> <cfargument name="fileFullPath" required="yes" type="string"> <cfargument name="description" required="no" type="string" default=""> <!--- Remove the full path from the file name for display purposes... ---> <cfset variables.filename = GetFileFromPath(fileFullPath)> <!--- Determine the file's mime-type... ---> <cfswitch expression="#LCase(ListLast(variables.filename, "."))#"> <cfcase value="avi"> <cfset variables.contentType = "video/x-msvideo" /> </cfcase> <cfcase value="doc"> <cfset variables.contentType = "application/msword" /> </cfcase> <cfcase value="exe"> <cfset variables.contentType = "application/octet-stream" /> </cfcase> <cfcase value="gif"> <cfset variables.contentType = "image/gif" /> </cfcase> <cfcase value="jpg,jpeg"> <cfset variables.contentType = "image/jpg" /> </cfcase> <cfcase value="mp3"> <cfset variables.contentType = "audio/mpeg" /> </cfcase> <cfcase value="mov"> <cfset variables.contentType = "video/quicktime" /> </cfcase> <cfcase value="mpe,mpg,mpeg"> <cfset variables.contentType = "video/mpeg" /> </cfcase> <cfcase value="pdf"> <cfset variables.contentType = "application/pdf" /> </cfcase> <cfcase value="png"> <cfset variables.contentType = "image/png" /> </cfcase> <cfcase value="ppt"> <cfset variables.contentType = "application/vnd.ms-powerpoint" /> </cfcase> <cfcase value="wav"> <cfset variables.contentType = "audio/x-wav" /> </cfcase> <cfcase value="xls"> <cfset variables.contentType = "application/vnd.ms-excel" /> </cfcase> <cfcase value="zip"> <cfset variables.contentType = "application/zip" /> </cfcase> <cfdefaultcase> <cfset variables.contentType = "application/unknown" /> </cfdefaultcase> </cfswitch> <!--- Perform forced-download... ---> <cfheader name="Content-Disposition" value="attachment;filename=#variables.filename#"> <cfheader name="Content-Description" value="#arguments.description#"> <cfcontent type="#variables.contentType#" file="#arguments.fileFullPath#"> <cfabort> </cffunction>
12/03/2010
Gracefully truncate a block of text to a particular size.
<!--- Function used to gracefully truncate a long string...ads "..." at the end when the string is truncated to fit within the intMaxChars argument... ---> <cffunction name="displayMaxChars" returntype="string" access="public"> <cfargument name="strInput" type="string"> <cfargument name="intMaxChars" default="200"> <cfset strShorterString = strInput> <!--- If input string is too long, add word by word until we have the max allowed string.. ---> <cfif Len(strShorterString) gt arguments.intMaxChars> <cfset strShorterString = ""> <cfset arrWords = ListToArray(arguments.strInput, " ")> <cfloop from="1" to="#ArrayLen(arrWords)#" index="k"> <cfset strShorterString = strShorterString & arrWords[k] & " " > <!--- Check to see if we can break out of the loop yet... ---> <cfif Len(strShorterString) + 3 gt arguments.intMaxChars> <cfset strShorterString = Trim(strShorterString) & "..."> <cfbreak> </cfif> </cfloop> </cfif> <cfreturn strShorterString> </cffunction>
12/03/2010
File Upload Function
<!--- Function used to upload files... -------------------------------------------------------------------------------------------> <cffunction name="uploadFile" access="public" returntype="struct"> <cfargument name="dataFileToUpload" required="yes" type="string"> <cfargument name="destination" required="yes" type="string"> <cfargument name="nameConflict" required="no" type="string" default=""><!--- error,makeunique,overwrite,skip ---> <cfargument name="accept" required="no" type="string" default=""><!---Limits the mime-types to accept. Example: accept = "image/jpg, application/msword" ---> <!--- Perform file upload... ---> <cffile action="upload" filefield="#arguments.dataFileToUpload#" destination="#arguments.destination#" nameconflict="#arguments.nameConflict#" accept="#arguments.accept#"> <!--- Returns status of what happened... ---> <cfreturn cffile> </cffunction>
12/03/2010
Remove extra whitespace sent to browser - Use in requestEnd within Application.cfc
<!--- Function used to remove any white space outside of tags, needed to cleanup RSS Feed XML... ---------------------------------> <cffunction name="removeExtraWhiteSpace" access="public" returntype="void"> <!--- Code below was borrowed from a CF posting: http://www.coldfusionjedi.com/index.cfm/2008/1/28/Chasing-down-a-whitespace-issue --------------------------------------------> <cfscript> pageContent = getPageContext().getOut().getString().trim(); getPageContext().getOut().clearBuffer(); pageContent = REreplace(pageContent, ">s+<", ">" & chr(13) & chr(10) & "<", "all");//strip whitespace between tags pageContent = REreplace(pageContent, "[nrf]+", chr(13) & chr(10), "all");//condense excessive new lines into one new line pageContent = REreplace(pageContent, "t+", " ", "all");//condense excessive tabs into a single space writeoutput(pageContent.trim()); getPageContext().getOut().flush(); </cfscript> </cffunction>
12/03/2010
Mobile device detection - HTTP_USER_AGENT analysis
<!--- Function used to attempt to detect mobile devices... ----------------------------------------------------------------------> <cffunction name="runDeviceDetection" access="public" output="yes" returntype="void"> <!--- Code borrowed and reformatted from : http://detectmobilebrowser.com/... ---> <cfset blnIsMobile = false> <cfset strMobilePattern = ""> <cfset strMobilePattern = strMobilePattern & "android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|ip(hone|od)|iris|kindle|lge |maemo|"> <cfset strMobilePattern = strMobilePattern & "midp|mmp|mobile|o2|opera m(ob|in)i|palm( os)?|p(ixi|re)/|plucker|pocket|psp|smartphone|symbian|"> <cfset strMobilePattern = strMobilePattern & "treo|up.(browser|link)|vodafone|wap|windows ce; (iemobile|ppc)|xiino|XV6875 Opera"> <cfset strMobilePattern2 = ""> <cfset strMobilePattern2 = strMobilePattern2 & "1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|"> <cfset strMobilePattern2 = strMobilePattern2 & "an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|"> <cfset strMobilePattern2 = strMobilePattern2 & "br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|"> <cfset strMobilePattern2 = strMobilePattern2 & "dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|"> <cfset strMobilePattern2 = strMobilePattern2 & "fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|"> <cfset strMobilePattern2 = strMobilePattern2 & "hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|"> <cfset strMobilePattern2 = strMobilePattern2 & "ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|"> <cfset strMobilePattern2 = strMobilePattern2 & "lg( g|/(k|l|u)|50|54|e-|e/|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|"> <cfset strMobilePattern2 = strMobilePattern2 & "me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|"> <cfset strMobilePattern2 = strMobilePattern2 & "n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|"> <cfset strMobilePattern2 = strMobilePattern2 & "p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|"> <cfset strMobilePattern2 = strMobilePattern2 & "qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|"> <cfset strMobilePattern2 = strMobilePattern2 & "h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|"> <cfset strMobilePattern2 = strMobilePattern2 & "so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|"> <cfset strMobilePattern2 = strMobilePattern2 & "to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|"> <cfset strMobilePattern2 = strMobilePattern2 & "voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(-|2|g)|"> <cfset strMobilePattern2 = strMobilePattern2 & "yas-|your|zeto|zte-"> <cfif reFindNoCase(strMobilePattern, CGI.HTTP_USER_AGENT) OR REFindNoCase(strMobilePattern2, Left(CGI.HTTP_USER_AGENT, 4))> <cfset blnIsMobile = true> </cfif> <cfreturn blnIsMobile> </cffunction>
06/07/2010
Generating Custom Captcha Images With ColdFusion 8
<!--- Author: Victor Sanchez Purpose: To generate captcha images... ---> <cfoutput> <cfset captchaImgPathRelative = '/cfdocs/legis/utilities/vsanchez/cheese.png'> <cfset captchaImgPathFull = ExpandPath(captchaImgPathRelative)> <cfset INT_TOTAL_CHARS = 8> <cfset INT_FONT_SIZE = 40> <cfset STR_DIFFICULTY = "low"><!--- high, medium, low ---> <cfset INT_CAPTCHA_WIDTH = INT_TOTAL_CHARS * (INT_FONT_SIZE + 10)> <cfset INT_CAPTCHA_WIDTH = 360> <cfset INT_CAPTCHA_HEIGHT = (INT_FONT_SIZE + 30)> <cfset INT_CAPTCHA_HEIGHT = 249> <cfset randomString = ""> <cfloop from="1" to="#INT_TOTAL_CHARS#" index="k"> <cfset charType = RandRange(0,999) MOD 3> <cfif charType eq 1> <!--- Use capital letter... ---> <cfset nextChar = chr(RandRange(65,90))> <cfelseif charType eq 2> <!--- Use lower case letter ---> <cfset nextChar = chr(RandRange(97,122))> <cfelse> <!--- Use a decimal number ---> <cfset nextChar = chr(RandRange(48,57))> </cfif> <cfset randomString = randomString & nextChar> </cfloop> <div> Captcha Generator... </div> <div style="display: none"> <cfimage format="PNG" action = "captcha" text = "#randomString#" width = "#INT_CAPTCHA_WIDTH#" height = "#INT_CAPTCHA_HEIGHT#" destination = "#captchaImgPathFull#" difficulty = "#STR_DIFFICULTY#" overwrite = "yes" fonts = "Arial,Courier New,Times New Roman" fontSize = "#INT_FONT_SIZE#"> </div> <cfset joe = imageNew(captchaImgPathFull)> <!--- <cfset imageRotate(joe,10,10,90,"bicubic")> ---> <!--- <img src="#captchaImgPathRelative#" style="border: 2px solid black"> ---> <cfset objImage = ImageRead( "./cheese.png" ) /> <!--- Read in the Kinky Solutions watermark. ---> <cfset objWatermark = ImageNew("./nuclearPantsLogo.png") /> <cfset objWatermark = ImageNew("./captchaBG.png") /> <!--- Turn on antialiasing on the existing image for the pasting to render nicely. ---> <cfset ImageSetAntialiasing(objImage,"on") /> <!--- When we paste the watermark onto the photo, we don't want it to be fully visible. Therefore, let's set the drawing transparency to 50% before we paste. ---> <cfset ImageSetDrawingTransparency(objImage,75) /> <!--- Paste the watermark on to the image. We are going to paste this into the bottom, right corner. ---> <cfset ImagePaste(objImage,objWatermark,(objImage.GetWidth() - objWatermark.GetWidth())/2,(objImage.GetHeight() - objWatermark.GetHeight())/2) /> <!--- Write it to the browser. ---> <cfimage action="writetobrowser" source="#objImage#" style="border: 2px solid black"/> <div> <!--- This example shows how to create a text string image. ---> <!--- Use the ImageNew function to create a 200x100-pixel image. ---> <cfset myImage=ImageNew("",INT_CAPTCHA_WIDTH + 4,100, "rgb", "black")> <!--- Set the drawing color to green. ---> <cfset ImageSetDrawingColor(myImage,"red")> <cfset textProperties = StructNew()> <cfset textProperties.font = "Arial"> <cfset textProperties.size = "20"> <cfset textProperties.style = "font-weight: bold"> <cfset textProperties.strikethrough = "no"> <cfset textProperties.underline = "no"> <!--- Specify the text string and the start point for the text. ---> <cfset ImageDrawText(myImage,"It's not easy being yellow.",20,50, textProperties)> <!--- Display the image in a browser. ---> <cfimage source="#myImage#" action="writeToBrowser"> </div> </cfoutput>
06/07/2010
Stripping Out Comment Lines From SQL Code
<cfsavecontent variable="sql"> /*Assuming a page size of 25, WE ARE GETTING RECORDS 3001 TO 3025 FROM A TOTAL OF 76,359 RECORDS?*/ SELECT ROW_NUM, LTRM_SESS_YR,LTRM_SESS_IND, LTRM_ROLL_CL_BODY, LTRM_ROLL_CL_NBR FROM ( SELECT ROWNUMBER() OVER(ORDER BY LTRM_SESS_YR,LTRM_SESS_IND, LTRM_ROLL_CL_BODY, LTRM_ROLL_CL_NBR DESC) AS ROW_NUM, INNER_TABLE.* FROM ( SELECT LTRM_SESS_YR,LTRM_SESS_IND, LTRM_ROLL_CL_BODY, LTRM_ROLL_CL_NBR FROM LEGTRK.LTRM_ROLL_CL_MASTER_TBL ORDER BY LTRM_SESS_YR,LTRM_SESS_IND, LTRM_ROLL_CL_BODY, LTRM_ROLL_CL_NBR DESC ) AS INNER_TABLE ) AS OUTER_TABLE WHERE OUTER_TABLE.ROW_NUM > 76300 FETCH FIRST 25 ROWS ONLY /*Assuming a page size of 25, WE ARE GETTING RECORDS 3001 TO 3025 FROM A TOTAL OF 76,359 RECORDS?*/ </cfsavecontent> <!--- <cfset sql = REReplace(sql, "/*([^*/]*)*/", "<span style='color: green'>« 1 »</span>", "all")> ---> <cfset sql = Trim(REReplace(sql, "/*([^*/]*)*/", "", "all"))> <cfoutput> <pre>#sql#</pre> </cfoutput>
06/07/2010
Programmatically Downloading Remote Images
<cfoutput> <cfset resizeType = "bilinear"> <!--- Get image from original location and save it locally ---> <cfhttp method="get" url="http://www.nuclearpants.com/resources/images/nuclearPantsLogo.png"></cfhttp> <cfset sourceImage="http://www.nuclearpants.com/resources/images/nuclearPantsLogo.png"> <cfset imageName = GetFileFromPath(sourceImage)> <cfset strPhotosFolder = "/cfdocs/legis/utilities/vsanchez/"> <cfhttp url="#sourceImage#" method="get" path="#ExpandPath(strPhotosFolder)#" file="#imageName#"></cfhttp> <cfset sourceImage = expandPath(strPhotosFolder & imageName)> <cfset img = imageRead(sourceImage)> <cfset newImage = duplicate(img)> <cfset imageScaleToFit(newImage, 110, 164, resizeType)> <cfset filename = strPhotosFolder & "small_" & getFileFromPath(sourceImage)> <cfset imageWrite(newImage,expandPath(filename),1)> <!--- Delete large image... ---> <!--- <cffile action="delete" file="#ExpandPath(strPhotosFolder)##imageName#"> ---> <div> <img src="#imageName#"> </div> <div> <img src="#filename#"> </div> </cfoutput>
06/07/2010
Google Sitemap Generator - Reads In A File Of URLs
<style> .pageTitle { font-size:16px; font-weight:bold; color:navy; border-bottom:2px solid navy; padding-bottom:2px; margin-bottom:10px; margin-top:20px; } </style> <div class="pageTitle"> Google XML Sitemap Generator </div> <!--- NOTE: The example below 'manually' creates the array of links ---> <cfset arrSitemapLinks = ArrayNew(1)> <!--- Add a single link to the sitemap... ---> <cfset tempStruct = StructNew()> <cfset tempStruct.loc = "http://www.nuclearpants.com"> <cfset tempStruct.lastmod = "2009-01-01"> <cfset tempStruct.changefreq = "daily"> <cfset tempStruct.priority = "1.0"> <cfset arrSitemapLinks[ArrayLen(arrSitemapLinks)+1] = tempStruct> <!--- Add a single link to the sitemap... ---> <cfset tempStruct = StructNew()> <cfset tempStruct.loc = "http://www.nuclearpants.com/VideoGalleries/videoGalleries.php"> <cfset tempStruct.lastmod = "2009-01-01"> <cfset tempStruct.changefreq = "hourly"> <cfset tempStruct.priority = "1.0"> <cfset arrSitemapLinks[ArrayLen(arrSitemapLinks)+1] = tempStruct> <cfoutput> <cfsavecontent variable="strSitemap"> <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <cfloop from="1" to="#ArrayLen(arrSitemapLinks)#" index="k"><url> <loc>#arrSitemapLinks[k].loc#</loc> <lastmod>#arrSitemapLinks[k].lastmod#</lastmod> <changefreq>#arrSitemapLinks[k].changefreq#</changefreq> <priority>#arrSitemapLinks[k].priority#</priority> </url> </cfloop></urlset> </cfsavecontent> <cfset strSitemapXML4Display = Replace(strSitemap, "<", "<", "all")> <cfset strSitemapXML4Display = Replace(strSitemapXML4Display, ">", ">", "all")> <div> Manually created sitemap: </div> <pre style="border:1px dotted black; background-color:##CCCCCC; padding:2px">#strSitemapXML4Display#</pre> <!--- Now, let's generate a sitemap based on a list of URLs in the local file: sitemap3434.txt --------------------------------------> <!--- Now, let's generate a sitemap based on a list of URLs in the local file: sitemap3434.txt --------------------------------------> <!--- Now, let's generate a sitemap based on a list of URLs in the local file: sitemap3434.txt --------------------------------------> <cfset arrSitemapLinks = ArrayNew(1)> <cfset strStoredQueriesDirFullPath = ExpandPath("/cfdocs/legis/utilities/vsanchez/SOLUTIONS/googleSitemaps/")> <cfset fileToReadFullPath = "#strStoredQueriesDirFullPath#sitemap3434.txt"> <cfset objInputFile = FileOpen(fileToReadFullPath, "read")> <cfloop condition="NOT FileisEOF(objInputFile)"> <!--- Read-in one line at a time... ---> <cfset strLine = FileReadLine(objInputFile)> <!--- Add a single link to the sitemap... ---> <cfset tempStruct = StructNew()> <cfset tempStruct.loc = strLine> <cfset tempStruct.lastmod = DateFormat(Now(), 'yyyy-mm-dd')> <cfset tempStruct.changefreq = "daily"> <cfset tempStruct.priority = "1.0"> <cfset arrSitemapLinks[ArrayLen(arrSitemapLinks)+1] = tempStruct> </cfloop> <!--- Close the input file... ---> <cfset FileClose(objInputFile)> <cfsavecontent variable="strSitemap"> <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <cfloop from="1" to="#ArrayLen(arrSitemapLinks)#" index="k"><url> <loc>#arrSitemapLinks[k].loc#</loc> <lastmod>#arrSitemapLinks[k].lastmod#</lastmod> <changefreq>#arrSitemapLinks[k].changefreq#</changefreq> <priority>#arrSitemapLinks[k].priority#</priority> </url> </cfloop></urlset> </cfsavecontent> <cfset strSitemapXML4Display = Replace(strSitemap, "<", "<", "all")> <cfset strSitemapXML4Display = Replace(strSitemapXML4Display, ">", ">", "all")> <div> Sitemap created from file containing a URL list </div> <pre style="border:1px dotted black; background-color:lavender; padding:2px">#strSitemapXML4Display#</pre> </cfoutput> |