Jump to content


[Snippet] Email-protect v1.6 Final


  • You cannot reply to this topic
22 replies to this topic

#1 Ed Headset

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 194 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Etomite, PHP, Ajax.
    3D imaging

Posted 04 March 2008 - 12:08 PM

File Name: Email-protect v1.6 Final
File Submitter: Ed Headset
File Submitted: 4 Mar 2008
File Updated: 18 Mar 2008
File Category: Security

/* Email-protect version 1.6 FINAL
A Collection of E-mail protection types
© 2008 Eduard Frankes (www.vitusware.com)
*****************************
This snippet has been tested with
Etomite 0.6.1.4

Using IE 7.0 and FireFox 2.0.0.12
IT works on IIS 6.x
this also works on Apache (Thanks Chris D.)
**********

Last minute Note:
TXTLINK does work, But it shows the full HTML code in the browser
like: <a href="mailto:email@address.com">email@address.com</a>
the browser doesn't render it.

So you can use it to explain how a mailto: link works

*****************************
Changes made in version 1.6 FINAL:
Minor code change/bug fix:
The text version added 2 spaces behind the AT, corrected to 1 space.

Special thanks to:

Ralph A. Dahlgren for $savePath initial idea & code to check if image exist to speed up the process.
Chris D. for tips how to create folders.

*************************

Usage:

[[Email-protect?email=email@address.com&type=txt]] (Default)
creates: &# 101;&# 109;&# 97;&# 105;&# 108;&# 64;&# 97;&# 100;&# 100;&# 114;&# 101; etc.. (spaces are added in this example)
that is rendered in the browser to look like email@address.com ( this is the default )

that is rendered in the browser to look like email@address.com ( this is the default )

[[Email-protect?email=email@address.com&type=txtlink]]
Creates: <a href="mailto:email@address.com">email@address.com</a> visible in the browser as HTML code

[[Email-protect?email=email@address.com&type=img&size=#]]

Creates a picture with the address
only this option uses the size and savePath parameters
Size defaults to 4
Folder where images are written($SavePath) defaults to "assets/images/email-protected/"
If this folder doesn't exist, it will be created with full read/write rights.
Images in this folder will be deleted when they are 86400 seconds or older (24Hrs.)

Size is from 1 (very small) to 4 (normal size)
use size 5 to make it bold (at size 4 size)
Sizes 6 or higher will default to size 5

[[Email-protect?email=email@address.com&type=dot]]
Creates: email AT address DOT com

[[Email-protect?email=email@address.com&type=java]]
creates a click able link with Java script

[[Email-protect?email=email@address.com&type=none]]
Use no protection at all (obviously not the best to use ;) )

*/

// settings:
$savePath = "assets/images/email-protected/"; // This is the default path where the email images are written NOTE: must end with a slash "/"
$seconds_old = 86400; // 24 Hrs. This is the default max time images will be kept. (time in seconds)


Click here to download this file

Edited by Ed Headset, 18 March 2008 - 07:40 PM.


#2 cathode

    Loves Etomite Forums!

  • Staff
  • 648 posts
  • Gender:Male

Posted 04 March 2008 - 03:32 PM

This has a lot of promise... I was just yesterday doing this manually...

#3 Ed Headset

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 194 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Etomite, PHP, Ajax.
    3D imaging

Posted 04 March 2008 - 10:41 PM

View Postcathode, on Mar 4 2008, 04:32 PM, said:

This has a lot of promise... I was just yesterday doing this manually...
Thanks for the nice comment :)

#4 Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts
  • Gender:Male

Posted 05 March 2008 - 02:50 AM

If the errors are caused by the same problems I was having, Randy clarified the problem here.

#5 Ed Headset

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 194 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Etomite, PHP, Ajax.
    3D imaging

Posted 05 March 2008 - 10:55 AM

View PostCris D., on Mar 5 2008, 03:50 AM, said:

If the errors are caused by the same problems I was having, Randy clarified the problem here.

Thanks for the info, I'll see if I can use this information to get the image working.

I think I have an Idea to get things working :Thinking:

Edited by Ed Headset, 05 March 2008 - 11:00 AM.


#6 Ed Headset

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 194 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Etomite, PHP, Ajax.
    3D imaging

Posted 12 March 2008 - 08:24 PM

Updated to version 1.0. FINAL

Changes made from 0.5 Beta :

The image option now works. :rolleyes:
It saves an image to the assets/cache/ folder where it can be loaded from.
The name of the image file will reflect the email name given
like: email@address.com.gif
so this snippet can be used for several image email addresses on the same page
Note: The email images are not removed!!
But they will be overwritten if the same address is used again.

#7 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 12 March 2008 - 10:54 PM

I'm not sure I'm feeling all warm and fuzzy about having stuff stored in the assets/cache/ directory...

#8 Ed Headset

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 194 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Etomite, PHP, Ajax.
    3D imaging

Posted 13 March 2008 - 10:42 AM

View PostRalph, on Mar 12 2008, 11:54 PM, said:

I'm not sure I'm feeling all warm and fuzzy about having stuff stored in the assets/cache/ directory...
Thinking about this, I think you are right.
It's better to create an snippets/emailprotect kina folder ;)

The assets/case was used because I was sure the folder rights were correctly set, to be able to write the image for testing
it just stayed in, so to speak :blush:
I'll change it a.s.a.p

Just to check: a cmod 777 should be enough not ?
(I'm never used Cmod, because I'm developing on a windows platform ;))
I want this folder to be created automatically if it doesn't exist, with the correct file rights

I'm also looking for a function to be able to delete not used images if the snippet is running, to keep the amount of images in order.
But That's a bit tricky if more then one email image is used, so I'll better check on file date do delete the old ones.

Thanks for the heads up! :D

#9 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 13 March 2008 - 01:24 PM

@Ed...

I haven't had a chance to take a good look at the code as yet... I tried last night but got interrupted... Anywhere within the assets branch is fine as far as where to store the images... Because I haven't looked at the code I'm not sure if you are doing a check to see if the image already exists or whether you are deleting this image after use... I'll try to take a closer look at the code in the near future...

#10 Ed Headset

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 194 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Etomite, PHP, Ajax.
    3D imaging

Posted 14 March 2008 - 07:05 AM

View PostRalph, on Mar 13 2008, 02:24 PM, said:

I'm not sure if you are doing a check to see if the image already exists or whether you are deleting this image after use...
Ralph,

That's an easy answer: NO
There is no check to see if the image already exist, and images are not deleted after use.

Images are written with filename = Email address.
so they are unique, and are overwritten if already exist.

Some of these functions will be added in the next version, see message above ;)
Please let me know what your think about it.

Edited by Ed Headset, 14 March 2008 - 07:07 AM.


#11 Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts
  • Gender:Male

Posted 14 March 2008 - 01:43 PM

Hey Ed Headset,

Quote

I want this folder to be created automatically if it doesn't exist, with the correct file rights
Try PHP mkdir

Quote

I'm also looking for a function to be able to delete not used images if the snippet is running, to keep the amount of images in order.
for a function that deletes old files, you could use something like this function. Or read each file in the dir and if the filename does not match the current filename in the snippet, unlink it.

Most of the stuff you need is in PHP.net

#12 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 14 March 2008 - 01:56 PM

I have PM'd a slightly modified copy of this snippet to Ed for review... I only made two small changes at this time... I converted the snippet to use a $savePath variable instead of a hard-coded path, but did not code in the ability to send $savePath in the snippet call... I also added in a file_exists() check so that an existing image is not continually re-created... I'm not sure how you'd handle removing old emails as I'd rather have old ones kicking around rather than re-creating needlessly... I'd leave that as a manual task if I was concerned about the extra images...

Like I told Ed in my PM, I didn't pick the snippet to death - yet...

#13 Ed Headset

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 194 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Etomite, PHP, Ajax.
    3D imaging

Posted 14 March 2008 - 03:32 PM

View PostRalph, on Mar 14 2008, 02:56 PM, said:

I have PM'd a slightly modified copy of this snippet to Ed for review... I only made two small changes at this time... I converted the snippet to use a $savePath variable instead of a hard-coded path, but did not code in the ability to send $savePath in the snippet call... I also added in a file_exists() check so that an existing image is not continually re-created... I'm not sure how you'd handle removing old emails as I'd rather have old ones kicking around rather than re-creating needlessly... I'd leave that as a manual task if I was concerned about the extra images...

Like I told Ed in my PM, I didn't pick the snippet to death - yet...
@ everyone, snippet is updated with the latest additions ;)
Please note: Default image $savePath or given savePath as parameter must exist and have write access!!

Did anyone tested it in a Apache environment ?
I'm most curious to hear if this works there to :Nail Biting:


@Ralph:
Thanks for your help, I have added savePath as you can see.
and I also added savePath to the snippet call.
I also added the "Fileexist" but with an slight change in the code,
because $width & $height were not calculated if the image already existed,
resulting in the image not displaying correctly ;)
Thanks again. :Applause:


Next on my list:
creating the savePath automatically if not exits.
But this could be tricky You always have to use the same savePath for this, or you'll end up with hundreds of folders :o :)

Thanks for the tips Chris! ;)

Edited by Ed Headset, 14 March 2008 - 04:49 PM.


#14 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 14 March 2008 - 05:20 PM

My mod's definitely work under Apache...

#15 Ed Headset

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 194 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Etomite, PHP, Ajax.
    3D imaging

Posted 15 March 2008 - 07:16 AM

View PostRalph, on Mar 14 2008, 06:20 PM, said:

My mod's definitely work under Apache...
Yes I know, but does mine to ?? :Praying:

#16 Ed Headset

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 194 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Etomite, PHP, Ajax.
    3D imaging

Posted 15 March 2008 - 11:05 AM

Just has a PM from Chris D.

It does work with Apache :Whew:

Check it here: Here (Courtesy of Chris D. :Applause:)

Edited by Ed Headset, 15 March 2008 - 11:06 AM.


#17 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 15 March 2008 - 02:49 PM

You can pretty much rest assured that virtually any PHP will work on an Apache server... It is Windows servers that developers need to be concerned with...

#18 Ed Headset

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 194 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Etomite, PHP, Ajax.
    3D imaging

Posted 15 March 2008 - 02:53 PM

View PostRalph, on Mar 15 2008, 03:49 PM, said:

You can pretty much rest assured that virtually any PHP will work on an Apache server... It is Windows servers that developers need to be concerned with...

Thanks that's good to know :D

BTW just updated to version 1.5
Last changes:
If savePath doesn't exist it will be created with full write access.
Also if the images are 86400 seconds old or older (24Hrs.) they will be deleted from the folder.

Edited by Ed Headset, 15 March 2008 - 02:54 PM.


#19 cathode

    Loves Etomite Forums!

  • Staff
  • 648 posts
  • Gender:Male

Posted 15 March 2008 - 03:30 PM

I have a question, is there a way to config the image output colors?

#20 cathode

    Loves Etomite Forums!

  • Staff
  • 648 posts
  • Gender:Male

Posted 15 March 2008 - 03:36 PM

View Postcathode, on Mar 15 2008, 11:30 AM, said:

I have a question, is there a way to config the image output colors?
Nevermind, I think I found it! :D





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users