Forums / General Questions / Questions about integrating my own code

Questions about integrating my own code

Started by solo_400 on 16 Jul 2012, 11:20 AM · Views: 1,295

Results 1 to 18 of 18
16 Jul 2012, 11:20 AM
#1
solo_400 avatar

solo_400

Zen Follower

Join Date:
Aug 2009
Posts:
369
Plugin Contributions:
0

Questions about integrating my own code

I need a guideline on integrating my own code without security risk .

I develop my self a piece of code in order to send mail when a desired product is on sale . JQuery inserted on tpl_product_info that is calling php files places on includes ( same place where configure.php is placed , because I need to have access on database ) . The problem is .htaccess file that is blocking access to *.php .
Please provide a solution on placing the php files called by my custom jquery .

thx

16 Jul 2012, 12:18 PM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: Questions about integrating my own code

Lots of stock files deeper in /includes/ communicate with the database. Why do you think your file needs to be that high in the file structure? What methods are you using for db access, and when do they come into play?

16 Jul 2012, 12:35 PM
#3
solo_400 avatar

solo_400

Zen Follower

Join Date:
Aug 2009
Posts:
369
Plugin Contributions:
0

Re: Questions about integrating my own code

gjh42:

Lots of stock files deeper in /includes/ communicate with the database. Why do you think your file needs to be that high in the file structure? What methods are you using for db access, and when do they come into play?

  1. tpl_product_info calling a jquery file . 2.Inside jquery file I call /include/my.php file 3. my.php file include .configure.php in order to access the database .

configure.php is protected by .htaccess by standard zencart settings .

I have put the php files on /includes because I thought I need include configure.php in order to have db access info . Please give me other solutions .

16 Jul 2012, 4:32 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Questions about integrating my own code

Correct. For security reasons you cannot use webpages/jQuery/ajax/javascript/URLs to directly call PHP files located inside the /includes/ folder or its subfolders.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

16 Jul 2012, 6:10 PM
#5
solo_400 avatar

solo_400

Zen Follower

Join Date:
Aug 2009
Posts:
369
Plugin Contributions:
0

Re: Questions about integrating my own code

Thank you DrByte , can you please provide a possible solution ? I really need my code running .. what should I do ?

16 Jul 2012, 6:30 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Questions about integrating my own code

Put your file in another folder. PHP scripts can be run from the root folder without those security restrictions. That would be a suitable place.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

16 Jul 2012, 7:49 PM
#7
solo_400 avatar

solo_400

Zen Follower

Join Date:
Aug 2009
Posts:
369
Plugin Contributions:
0

Re: Questions about integrating my own code

DrByte:

Put your file in another folder. PHP scripts can be run from the root folder without those security restrictions. That would be a suitable place.

Regarding the user/password/table_name : It is possible reading from configure.php which is included in /include and protected by .htaccess ? I don't want to put this info in my php .

16 Jul 2012, 8:12 PM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Questions about integrating my own code

Right. So, include() the file when you need it.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

16 Jul 2012, 10:07 PM
#9
solo_400 avatar

solo_400

Zen Follower

Join Date:
Aug 2009
Posts:
369
Plugin Contributions:
0

Re: Questions about integrating my own code

DrByte:

Right. So, include() the file when you need it.

Thank you DOC , I think I did it !

I think is impossible load configure.php from root directory without adding "Allow from localhost_IP" in my includes/.htaccess .

<Files *.php>
Order Deny,Allow
Deny from all
Allow from localhost_IP
</Files>

Do you think could be a security problem ?

thx again

16 Jul 2012, 11:03 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Questions about integrating my own code

solo_400:

I think is impossible load configure.php from root directory without adding "Allow from localhost_IP" in my includes/.htaccess .

<Files *.php>
Order Deny,Allow
Deny from all
Allow from localhost_IP
</Files>

Do you think could be a security problem ?
I would not do that. There should NOT be any reason to edit the /includes/.htaccess file.

Your extra scripts really need to handle security properly. Or load application_top.php to invoke Zen Cart's security handling systems. Loading configure.php directly is not advisable. I didn't mention that earlier because it sounded like you didn't care and all you wanted was just a quick dirty way of doing things without care for the proper approach.

If you want to do it properly, use the same approach that Zen Cart uses: load a primary script from the main directory, and have it load the required additional assets after invoking application_top.php. In the case of ajax, there are many things that will be absent from your stateless connection, so you will have to write numerous additional custom scripts to handle those.

I don't understand why you're doing all this just to send an email, nor why you're sending emails from product pages anyway. But, since you haven't explained anything about the business problem you're trying to solve by this approach, all we can do is blindly guess.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

17 Jul 2012, 9:19 AM
#11
solo_400 avatar

solo_400

Zen Follower

Join Date:
Aug 2009
Posts:
369
Plugin Contributions:
0

Re: Questions about integrating my own code

"If you want to do it properly" .. My concern is security issue and is all around this .

This piece of code is not for sending email . Serve for having a check box on product_info page . By checking this you agree being notified by email ( crontab script ) when product will be on sale . I have a custom table on database where this info is being saved . Now this part is working properly but security is the most important here .

I have removed "Allow from localhost_IP" from configure.php and I loaded application_top.php on my php script. Seems everything working now .

17 Jul 2012, 2:08 PM
#12
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: Questions about integrating my own code

There is a built-in feature (sidebox) for "notify me of product updates" which you could simply change the text on and have the exact frontend function you want without further customization or fancy work. If you really needed it in the center column I expect it could be adapted. Then changing the internal function to send the notification on sale instead of update should not be difficult for you.

17 Jul 2012, 4:24 PM
#13
solo_400 avatar

solo_400

Zen Follower

Join Date:
Aug 2009
Posts:
369
Plugin Contributions:
0

Re: Questions about integrating my own code

gjh42:

There is a built-in feature (sidebox) for "notify me of product updates" which you could simply change the text on and have the exact frontend function you want without further customization or fancy work. If you really needed it in the center column I expect it could be adapted. Then changing the internal function to send the notification on sale instead of update should not be difficult for you.

Is available on 1.3.8 version ?

17 Jul 2012, 4:59 PM
#14
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: Questions about integrating my own code

It has been available since before v1.3.0... but if you're doing the work of custom coding, you really should upgrade your site to v1.5.0 before your obsolete v1.3.8 gets hacked.

17 Jul 2012, 6:04 PM
#15
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Questions about integrating my own code

solo_400:

Is available on 1.3.8 version ?

Are you SERIOUSLY using v1.3.8? Not only is it ancient, but it's also got serious security problems. Your FIRST step should be to upgrade. IMMEDIATELY.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

17 Jul 2012, 6:29 PM
#16
solo_400 avatar

solo_400

Zen Follower

Join Date:
Aug 2009
Posts:
369
Plugin Contributions:
0

Re: Questions about integrating my own code

If you know someone can do it , let's talk.

17 Jul 2012, 6:39 PM
#17
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Questions about integrating my own code

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Jul 2012, 4:00 PM
#18
solo_400 avatar

solo_400

Zen Follower

Join Date:
Aug 2009
Posts:
369
Plugin Contributions:
0

Re: Questions about integrating my own code

I have some modules , custom template , card payment , social integration .
Do you know people/company can do this work ?