ColdFusion: compare local files with remote FTP files

Written on 10 October 2011, 04:59pm

Tagged with: ,

What do you do when you discover that the production version of an application is not the same as the development version? (ignore the bigger problems of application development workflow)
You identify the files in question, yes. And what do you identity them when the application contains thousands of source files?
Of course, you make a script.


<cfsetting requesttimeout="300" showdebugoutput="no" />
<cfset initialDir = ExpandPath( '../' )> 
<!--- script is in a sub-folder of the app --->
<cfset total = 0> <!--- total changed files --->
<cfset subTotal = 0> <!--- actual changed files, see below --->
<cfset localRoot = "C:\your\local\app\root" />
<cfset remoteRoot = "/your/remote/root" />
<cfset tmpFile = "/this/is/just/a/temp/file" />

<cfset tick = GetTickCount()>


<!--- get list of ALL local files, recursively --->
<cfdirectory action="list" 
    directory="#initialDir#" 
    name="localQuery" 
    recurse="true"/>

<!--- make the FTP connection --->
<cfftp connection = "ftpConnection" 
    username = "*********"
    password = "*********"
    server = "********"    
    port="****"
    action = "open" 
    stopOnError = "Yes"> 
<cfif cfftp.succeeded EQ false>
    ERROR - FTP open connection failed!
    <cfabort>
</cfif>

<!--- call the recursive function for the first time --->
<cfset compareFiles(remoteRoot) />

<!--- close the FTP connection --->
<cfftp connection = "ftpConnection"
    action = "close"
    stopOnError = "Yes">
<cfif cfftp.succeeded EQ false>
    ERROR - FTP close connection failed!<cfabort>
</cfif>

<cfset tock = GetTickCount()>
<cfset time = round((tock-tick)/1000)>
<cfoutput><hr />#subTotal#/#total# files, #time# seconds</cfoutput>

This is the skeleton. The business logic happens in the function below:
(more…)

Another 6 Oracle goodies

Written on 25 July 2011, 12:16pm

Tagged with: ,

Continuing the Oracle Cheat Sheet 🙂

1. Create an Oracle user


create user xxx identified by yyy;
grant connect, resource, unlimited tablespace to xxx [identified by yyy];
grant create session to xxx;

2. Extend tablespace


ALTER DATABASE
DATAFILE  'C:\ORACLEXE\ORADATA\XE\SYSTEM.DBF'
RESIZE 1000M;

link

3. Invoking UNIX commands from SQL*Plus

You can invoke a UNIX command from SQL*Plus by using “HOST COMMAND”:

host ls -la *.sql 

lists all SQL files in the current directory
(more…)

CF 8 bug: ColdFusion injecting cfscript in HTML head

Written on 20 July 2011, 02:13pm

Tagged with: , ,

I recently encountered the following ColdFusion problem:
I had a HTML page where the head node contained an attribute: <head lang="fr">
The same page was also using some cfform tags.
On the CF 8 server, ColdFusion automatically injects two <script> statements immediately after <head, but ignoring any other attribute. So, in our case, the resulting HTML code was:

<head <script type="text/javascript" src="/CFIDE/scripts/cfform.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/masks.js"></script>
lang="fr">

Useless to say, this was breaking a lot of things in the design and the validation of the page.
(more…)