Tally List : mailing list management, archiving, and analysis
click for archive home
 
Archive of:
CFtipsPlus
Cold Fusion tips email (external)
 
home
24 hour view
quick stats
weekly updates
 
all tallylists
corporate solutions
archive your favorite
help / feedback


Search the Tallylist search by keyword:

About Cold Fusion Tips :
product's home
product's list home
 
  Archived TallyList / CFtipsPlus: 
Subject: Happy Easter | CFFILE Helper Tips | CFHttp in Use
Nathan Stanford (23p/+0r)     Posted: Saturday 14 Apr 2001
This post: 168 views, +0 rating

============== ColdFusion TIPS PLUS ColdFusion 01 Volume 01 Issue 15 =============================================================== http://www.cftipsplus.com ============== Issue 00054 ============== I. Comments: II. CFFILE Helper Tips By Sam Farmer sfarmer@intelixinc.com III. CFHttp in Use By Dain Anderson dain_anderson@yahoo.com www.comet.com

============== I. Comments:

Have a Happy Easter,

Keep Coding, Nathan Stanford President/CEO C.F. Concepts, Inc. www.cftipsplus.com

If you have suggestions for articles send them to us. If you would like to write for cftipsplus.com send us an email to:

admin@cftipsplus.com

IF YOU WANT TO BE AN AUTHOR SEND IN YOUR COLDFUSION TIPS.

Remember this is a great way to get your name know in the ColdFusion Community.

=============================================================== If you have any suggestions please email me at cftips@nsnd.com. ===============================================================

=============================================================== II. CFFILE Helper Tips By Sam Farmer sfarmer@intelixinc.com ===============================================================

One of the biggest issues with CFFILE comes when moving from a development machine to a production machine as file structures and, possibly, operating systems are likely to change. The following tips should help in this process.

Firstly, we want to find out which slash to use. This can be deduced from looking at the server.OS.Name variable.

<CFIF NOT CompareNoCase(Left(server.OS.Name,3),"WIN")> <!--- Windows ---> <CFSET variables.slash = "\"> <CFELSE> <!--- Unix ---> <CFSET variables.slash = "/"> </CFIF>

Secondly its useful to find out the path of current directory. We can find this out by combining the GetDirectoryFromPath and ExpandPath functions.

<CFSET variables.pathToUse = GetDirectoryFromPath(ExpandPath("*.*"))>

If we are uploading images there is a good chance we would want to put them in an images directory under the current directory like this:

<CFFILE ACTION="UPLOAD" FILEFIELD="fileUpload" DESTINATION="#variables.currentpath#images" NAMECONFLICT="ERROR">

When uploading other files like documents it is often a good idea to store them outside the web root so that they can only be accessed by using CFCONTENT. Often this will be in a directory below the web root.

Thirdly, we can use the following code to move up a specific number of directories.

<CFSET variables.directoriesUp = "2"> <CFIF variables.directoriesUp LT ListLen(variables.pathToUse,variables.slash)> <!--- Then we can move up ---> <CFLOOP FROM="1" TO="#variables.directoriesUp#" INDEX="ii"> <CFSET variables.chop = ListLast(variables.pathToUse,variables.slash)> <CFSET variables.pathToUse = Replace(variables.pathToUse,variables.chop & variables.slash,"")> </CFLOOP> <CFELSE> Too many directories too want to move up </CFIF>

Sam Farmer =============================================================== =============================================================== III. CFHttp in Use By Dain Anderson dain_anderson@yahoo.com www.comet.com ===============================================================

How to be #1 in your topic area at Experts-Exchange.com As a digest, I often visit http://www.experts-exchange.com to help others with ColdFusion. It doesn't put food on the table, but it's a lot of fun. However, I was beginning to feel like I could never get to any questions before someone else got a whack at it, so I decided to take a different approach.

I created a program that will alert me when new questions arrive to the ColdFusion topic area. The reason I built this program was because I started to feel that a lot of the answers to questions were half-assed and the questioners were awarding points without knowing any better. I basically wanted to let people know that there is help out there, and I wanted to set a precedence by truly helping people, not just saying, "No, you can't do that."

In all fairness to the other ColdFusion experts there, here is the program I use:

First off, you need to create an ultra-simple database with one table called "Qs", with one field called "Q" as a text field. I use Access for this, since it's very simple. Next, create a datasource called "ee" that stands for "Experts-Exchange".

You can use this code for any topic area -- just replace the BaseURL variable below to reflect the category you want.

<CFSETTING SHOWDEBUGOUTPUT="No">

<!--- Get the questions that already exist in the database; if the question exists, then it isn't new. Keep in mind that some questions will appear to be new that aren't -- this is due to questions being rejected and re-appearing in the main list. ---> <CFQUERY DATASOURCE="ee" NAME="getQs" BLOCKFACTOR="10"> SELECT Q FROM Qs </CFQUERY>

<!--- Refresh the page every minute ---> <CFHEADER NAME="Refresh" VALUE="60;URL=index.cfm">

<!--- Set the base URL for all links ---> <CFSET ListQuestionsURL = "http://www.experts-exchange.com/jsp/qList.jsp?ta=coldfusion&"> <CFSET ShowQuestionURL = "http://www.experts-exchange.com/jsp/qShow.jsp?ta=coldfusion&">

<BASE HREF="<CFOUTPUT>#ShowQuestionURL#</CFOUTPUT>" TARGET="_blank">

<!--- Grab the content ---> <CFLOCK NAME="#ListQuestionsURL#" THROWONTIMEOUT="Yes" TIMEOUT="100" TYPE="EXCLUSIVE">

<CFHTTP METHOD="GET" URL="#ListQuestionsURL#" TIMEOUT="50"> </CFLOCK>

<CFSCRIPT> QList = ValueList(getQs.Q); origPage = CFHTTP.FileContent; QList_New = ""; Exit = 0; Start = 1; Count = 1;

/* While there are still questions, loop */ while (Exit EQ 0) { /* Parse the question, based on the last starting point */ Q = REFindNoCase("qid=([^&]*)",origPage,Start,"TRUE"); /* If not 0, it found another question */ if (Q.pos[1]) { /* Get the full question number */ FullQ = Mid(origPage,Q.pos[1],Q.len[1]); /* If it's not in the database */ if (ListFindNoCase(QList, FullQ) EQ 0) { /* Add it to the list of new arrivals */ Qlist_New = ListAppend(QList_New, FullQ); } /* Output a link to the new question */ WriteOutput("<A HREF=""" & ShowQuestionURL & FullQ & """>" & FullQ & "</A><BR>"); /* Reset the start position to the current position plus the length of the text */ Start = Q.pos[1] + Q.len[1]; } else Exit = 1; } </CFSCRIPT>

<!--- Loop through the newly-found questions and insert them ---> <CFLOOP LIST="#QList_New#" INDEX="this"> <CFQUERY DATASOURCE="ee"> INSERT INTO Qs (Q) VALUES ('#this#') </CFQUERY> </CFLOOP>

<!--- If there are new questions found, alert the user ---> <CFIF LEN(QList_New)> <SCRIPT LANGUAGE="JavaScript"> var newWin = window.open('','','width=200,height=200') var content = "<HTML><HEAD><TITLE>New Qs</TITLE><HEAD>"; content += "<BODY ONLOAD='window.focus();'> New Questions added.

"; <CFLOOP LIST="#QList_New#" INDEX="this"> content += <CFOUTPUT> "<A HREF='#ShowQuestionURL##this#' TARGET='_blank'>#this#</A> <BR>"; </CFOUTPUT> </CFLOOP> content += "<P ALIGN='center'> <A HREF='JavaScript:window.close();'> Close Window</A>"; content += "</BODY><HTML>"; newWin.document.open(); newWin.document.write(content); newWin.document.close(); </SCRIPT> </CFIF>

==============

============== Publisher and Creator: Nathan Stanford, admin@cftipsplus.com C.F. Concepts, Inc. http://www.cftipsplus.com ============== Macromedia and ColdFusion are U.S. registered trademarks.

============== Copyright (c) 2000 - 2001 C.F. Concepts, Inc. CFTIPSPLUS.COM and NSND.COM Permission is granted to circulate this publication via MANUAL forwarding by email to friends provided that the text is forwarded in its entirety and no fee is charged. ===============================================================

============== To unsubscribe: unsubscribe-cftips@nsnd.com

To subscribe: subscribe-cftips@nsnd.com ==============

==^================================================================ EASY UNSUBSCRIBE click here: http://topica.com/u/?aVxjC7.aVG5kO Or send an email To: cftips-unsubscribe@topica.com This email was sent to: cftipsplus@tallylist.com

T O P I C A -- Learn More. Surf Less. Newsletters, Tips and Discussions on Topics You Choose. http://www.topica.com/partner/tag01 ==^================================================================


Similar Subject Line Posts (+/- two weeks of this post)
Happy Easter | CFFILE Helper Tips | CFHttp in Use  14 Apr 2001 (this post)   (168 v/ +0 r)
 

Send a reply to the CFtipsPlus list!
click to send a reply! NOTE: Many lists will reject your post unless you have already registered with them. Also - don't forget the right account to send from (for those with multiple emails!)

Feedback: If this post was exceptionally helpful, please help by giving this post a positive review.

 

TallyList : copyright Ububik - 2000