Thanks, Denny...

I read recently that dashes "-" in filenames were more
search engine friendly than underscores.  If I were to want to
disallow underscores and allow dashes, how would the regex change?

And, any thoughts on the dashes vs underscore issue?

Thanks,

Rick

> -----Original Message-----
> From: denstar [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 12, 2008 9:01 PM
> To: CF-Talk
> Subject: Re: Creating a .cfm file on the fly
> 
> Here's a function that uses a regex to say, "only good chars through", sorta:
> 
>       <cffunction name="safeString" access="public" hint="strips unsafe
> chars" returntype="string" output="false">
>               <cfargument name="stringToClean" required="true" type="string">
>               <cfreturn 
> rereplacenocase(stringToClean,'[^a-z|A-Z|0-9|_]','','all')>
>       </cffunction>
> 
> Basically, the allowed ones are the ones there-- A-Z (upper or lower
> case), 0-9, and underscores.
> 
> Any others get stripped out.
> 
> HIH,
>   Denny
> 
> -PS I use this in my existing CMS type of deal-- I'd recommend using
> more of a CMS approach (not writing .CFM files, and instead modeling
> what you want), or even better, if you like to generate stuff: pipe it
> all out to HTML files-- super performant-er!  =]
> 
> 
> On Wed, Mar 12, 2008 at 6:35 PM, Rick Faircloth
> <[EMAIL PROTECTED]> wrote:
> > Casey...
> >
> >  Do the "replace's" that you use below take care of *all*
> >  unwanted filename characters?  I'm thinking about implementing a
> >  page-creation tool, also,
> >  and didn't think about the problems that could be created
> >  with bad filenames a user might create.
> >
> >  Bruce...
> >
> >  I tinkered with page creation, too, and used a template
> >  for the basis of a new page, then used <cffile action = "append"...
> >  to add the HTML to the template.  I also updated a menu.cfm file using
> >  append to add the new page name to the menu and cfincluded the menu.cfm
> >  in the new page.
> >
> >  So basically, I just used cffile to copy the existing template
> >  to the requested filename, then used cffile append to the HTML
> >  and also used cffile append to update any cfincluded files,
> >  like the menu.cfm I mentioned.
> >
> >  I'm also planning to use the CF8 FCKEditor (modified to be able to
> >  add photos, etc.) to allow the user to create the main content for the 
> > page.
> >
> >  Pretty straightforward.
> >
> >  Rick
> >
> >
> >
> >
> >  > -----Original Message-----
> >  > From: Casey Dougall [mailto:[EMAIL PROTECTED]
> >  > Sent: Wednesday, March 12, 2008 8:16 PM
> >  > To: CF-Talk
> >  > Subject: Re: Creating a .cfm file on the fly
> >  >
> >  > On 3/12/08, Bruce Sorge <[EMAIL PROTECTED]> wrote:
> >  > >
> >  > > I have a client who wants me to make a change to a form he has.
> >  > > Currently he has a page that creates a new project that uses a WYSIWYG
> >  > > editor and put everything into a database table. What he wants instead
> >  > > is for the user to add a page name field in addition to the fields he
> >  > > already has, and when the user submits the form, he wants a .cfm page
> >  > > created with the value from the page name field being the file name. Of
> >  > > course I need to put the site's header and footer on there as well. So
> >  > > is there a way that I can create a template, and then when the form is
> >  > > submitted, using CFFILE or something like that to take that template 
> > and
> >  > > make a new page with it? Does this even make sense?
> >  > >
> >  > > Thanks,
> >  > >
> >  > > Bruce
> >  >
> >  >
> >  >
> >  > Yeah, I do something like this, you may know some regex that could 
> > eliminate
> >  > half of this junk at the beginning.
> >  >
> >  > <cfset FixedPageName =replace(FORM.PageName," ","-","all")>
> >  > <cfset FixedPageName =replace(FixedPageName,":","","all")>
> >  > <cfset FixedPageName =replace(FixedPageName,"?","","all")>
> >  > <cfset FixedPageName =replace(FixedPageName,"$","S","all")>
> >  > <cfset FixedPageName =replace(FixedPageName,"&","-and-","all")>
> >  > <cfset FixedPageName =replace(FixedPageName,"'","","all")>
> >  > <cfset FixedPageName =replace(FixedPageName,".","","all")>
> >  > <cfset FixedPageName = LCase(FixedPageName)>
> >  > <cfset
> >  > 
> > FORM.FixedPageName=replace(FixedPageName,"#FixedPageName#","#FixedPageName#.cfm","all")>
> >  >
> >  > <CFPARAM name="SavePath" default="#ExpandPath("../../Folder")#">
> >  >
> >  >   <CFSET sFileOutput = "">
> >  >       <CFFILE Action="Write" File="#SavePath#\#FORM.FixedPageName#"
> >  > Output="#sFileOutput#">
> >  >
> >  >
> >  >
> >
> >
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:301129
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to