Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-12-2012, 05:06 PM   PM User | #1
doubledee
Regular Coder

 
doubledee's Avatar
 
Join Date: Mar 2011
Location: Arizona
Posts: 617
Thanks: 19
Thanked 0 Times in 0 Posts
doubledee has a little shameless behaviour in the past
Where to store Admin E-mail

I'm in the process of streamlining my Error-Handling code, and I would like to put things like the Admin's E-mail in one location, so that I don't have to track it down in multiple places/scripts.

If I place it in a PHP Constant, would that cause any security issues?

Furthermore, where would be the best place to store things like E-mail Headers and so on?

For example...
PHP Code:
    $headers  "From: Admin <admin@MySite.com>\r\n";
    
$headers .= "MIME-Version: 1.0\r\n";
    
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"
Thanks,


Debbie
doubledee is offline   Reply With Quote
Old 11-12-2012, 06:25 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,650
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
It depends on what you are referring to as security. Using a defined constant will potentially create a privacy leak between scripts as it will be globally readable in any scope. That's only a problem if you say its a problem; given constant's readonly nature, I'd say there's no problem with that. You wouldn't want to create a defined constant for authentication information if you allow third party addons, but I don't see an issue with an email address (unless you're concerned about spam).

Email headers should be dynamically and conditionally created within the script handling all the emails. These aren't configuration based data, they are manipulation based on data, so creating a global location for them doesn't make any sense.
Fou-Lu is offline   Reply With Quote
Old 11-12-2012, 07:04 PM   PM User | #3
doubledee
Regular Coder

 
doubledee's Avatar
 
Join Date: Mar 2011
Location: Arizona
Posts: 617
Thanks: 19
Thanked 0 Times in 0 Posts
doubledee has a little shameless behaviour in the past
Quote:
Originally Posted by Fou-Lu View Post
It depends on what you are referring to as security. Using a defined constant will potentially create a privacy leak between scripts as it will be globally readable in any scope. That's only a problem if you say its a problem; given constant's readonly nature, I'd say there's no problem with that. You wouldn't want to create a defined constant for authentication information if you allow third party addons, but I don't see an issue with an email address (unless you're concerned about spam).

Email headers should be dynamically and conditionally created within the script handling all the emails. These aren't configuration based data, they are manipulation based on data, so creating a global location for them doesn't make any sense.
Right now I have a script called "results.php" which is where I display my Error-Messages and where I log and send out e-mail notifications to the Admin.

I tweaked my code a bit and added these variables to my script to make it slightly easier to modify...

PHP Code:
    // ************************
    // Initialize Variables.    *
    // ************************
    
$emailTo 'JoeTheAdmin@mail.com';

    
$headers  "From: Admin <admin@MySite.com>\r\n";
    
$headers .= "MIME-Version: 1.0\r\n";
    
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"

I guess I was wondering if those should be assigned to Constants, and maybe go into a global "config" file instead?!

Or are they okay like they are? (Of course, if I need to refer to the Admin E-mail in other scripts, then I'd have a maintenance issue...)


Debbie
doubledee is offline   Reply With Quote
Old 11-12-2012, 11:25 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,650
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
If its configurable data, put it into a configuration file. An email that can change IMO warrants placing into configuration data.
Whether its a constant or a variable is up to you.
Fou-Lu is offline   Reply With Quote
Old 11-13-2012, 11:55 AM   PM User | #5
alemcherry
New Coder

 
Join Date: Apr 2010
Posts: 55
Thanks: 0
Thanked 4 Times in 4 Posts
alemcherry is an unknown quantity at this point
Global config file is a good place. If you believe this is something that need to be editable and chnagable by the user, a config table and an option to edit the same from admin interface would be better. However, that is not needed in most custom made scripts. If this is a product that would installed by many people, making it editable would be good.
__________________
Hosting Reviews and Discounts: Bluehost Coupon and Hostmonster Coupon
alemcherry is offline   Reply With Quote
Old 11-13-2012, 12:04 PM   PM User | #6
minder
Banned

 
Join Date: Oct 2012
Posts: 81
Thanks: 0
Thanked 4 Times in 4 Posts
minder can only hope to improve
I store all config. parameters (email address, compnay name, home page url etc etc etc) in a database table and in the Admin account's menu somewhere I will have a "Configure Site" menu option which presents all the config params in a html form from which the admin user can edit them.
minder is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:46 AM.


Advertisement
Log in to turn off these ads.