Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Require a Log In?


NSmith632

Recommended Posts

There's a thread running on how not to require customers to create an account to buy something. I need the exact 180 degree opposite.

 

I'm setting up a commerce site for a wholesale printing company, and I need to restrict who can log on at all (so joe schmoe doesn't see the *nice* prices)...

 

I also require fixed quantity break pricing too (which I see there is a module for...) and where is the Add button on the customer screen in the Admin section? Can I add customers through a CSV or excel database somehow? I'm a little new to sql.

 

Any suggestions? :)

 

Thanks!

Link to comment
Share on other sites

I just cant remember the name of it but there is a contribution that does just that.

You have to be logged in to view prices

Wish i could help you more

Click contributions in my signature

 

The_Bear

Link to comment
Share on other sites

Quick update.

 

I'm having luck adding the login code to index.html so OSCommerce checks for a login everytime a page is loaded. This is the code it uses when an item is added to the cart and oscommerce attempts to load the cart.

 

Any projected pitfalls I may be missing this way?

Link to comment
Share on other sites

Ya,

 

But I'm putting together a site I don't want/need guests/unregistered to see or do anything at all, except stare at a login page.

 

It was pretty simple, actually.

 

I copied the code that checks to see if a person is logged in. This is the code executed while the shopping cart is pulled up after a product is added to it:

 

// if the customer is not logged on, redirect them to the login page
 if (!tep_session_is_registered('customer_id')) {
   $navigation->set_snapshot();
   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 }

 

I've gone through and begun adding this snippet after the

  require('includes/application_top.php');

line in every file a visitor could access. Come to think of it, what I should do is a search/replace for the app top and replace it with app top and the login code. Hmm...

 

Make sense?

Link to comment
Share on other sites

Just remember not to add this to the login.php file...

 

If it weren't for that, you could just put this code in application_top.php and be done.

 

Hth,

Matt

Link to comment
Share on other sites

Thanks everyone -- I was trying to make this way too complicated. :rolleyes:

 

To make it even easier, just add the following to application_top:

  $filename = explode("/", $PHP_SELF); 
 if (($filename[count($filename)-1] != "login.php") && (!tep_session_is_registered('customer_id'))) {
   $navigation->set_snapshot();
   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 }

 

It needs to be after the functions are included, so I just put it at the bottom of the file. I ran a quick test on this and it seems to work just fine, but please run your own tests before adding this to a live site. This code has great potential for locking everybody out of your site if something goes wrong. :(

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Sure will...but can't tonight. Maybe tomorrow...

 

Same Bat Station, Same Bat Time.

Hi Nick, it is oct 2 here in the Netherlands. Have you had time to share the files? I hope so, because I am very interested. Please mail me.

Link to comment
Share on other sites

Ive just tried the above and it works great!

 

Im wondering now, how to go about making the login page, with

only the login stuff, (no pictures, no prices)

I want to completely lock unregistered users out.

 

Could anyone tell me how I can do this?

 

cheers

Link to comment
Share on other sites

Sure will...but can't tonight. Maybe tomorrow...

 

Same Bat Station, Same Bat Time.

Hi Nick, it is oct 2 here in the Netherlands. Have you had time to share the files? I hope so, because I am very interested. Please mail me.

See above code snippet.

Link to comment
Share on other sites

My bad.... sorry should have explained a little better.

 

I meant that Id like to get rid of the Registration stuff off of the login.php.

At the moment the one page has login and registration sign up.

 

Id like login.php to only have the login box.

 

cheers

Link to comment
Share on other sites

In login.php (around line 140) find this code:

            <td width="50%" height="100%" valign="top"><table border="0" width="100%" height="100%" cellspacing="1" cellpadding="2" class="infoBox">
             <tr class="infoBoxContents">
               <td><table border="0" width="100%" height="100%" cellspacing="0" cellpadding="2">
                 <tr>
                   <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
                 </tr>
                 <tr>
                   <td class="main" valign="top"><?php echo TEXT_NEW_CUSTOMER . '<br><br>' . TEXT_NEW_CUSTOMER_INTRODUCTION; ?></td>
                 </tr>
                 <tr>
                   <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
                 </tr>
                 <tr>
                   <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
                     <tr>
                       <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                       <td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL') . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>
                       <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                     </tr>
                   </table></td>
                 </tr>
               </table></td>
             </tr>
           </table></td>

and either comment it out or delete it.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

  • 5 months later...

when i add this to application_top.php

 

$filename = explode("/", $PHP_SELF);

if (($filename[count($filename)-1] != "login.php") && (!tep_session_is_registered('customer_id'))) {

?  $navigation->set_snapshot();

?  tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));

}

 

the password forgotten function is also protectet

 

what can i do now? :(

Link to comment
Share on other sites

We just need to allow access to password_forgotten.php. Try this version:

  if ((basename($PHP_SELF) != "login.php") && (basename($PHP_SELF) != "password_forgotten.php") && (!tep_session_is_registered('customer_id'))) {
   $navigation->set_snapshot();
   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 }

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

  • 3 months later...

Hi kymation,

 

Thx four your code ;) but I have a problem wiht it because I installed STS and the dropdownmenu, include in it, is protected and ask me to indentify myself again. Moreover, I have the same problem when I moved hypertext link of the information box (Shipping & Returns, Privacy Notice, Conditions of Use, Contact Us) at the bottom of my website because when I click on those links, it ask me to sign in again. I think, that is necessary to modify your code to allow access at future modification.

 

Thx by advance :rolleyes:

 

Fab

Link to comment
Share on other sites

This sounds like a SSL problem. This code will redirect you to a login page that is SSL. If you log in and then go to a non-SSL page the session is lost. Check your entries in includes/configure.php for the SSL-related definitions. If you are still having problems, please post the top part of configure.php (without the database password.)

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Hi Jim,

 

It doesn't work but I'm not a coder. This is the code of my configure.php:

<?php
/*
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

// Define the webserver and path parameters
// * DIR_FS_* = Filesystem directories (local/physical)
// * DIR_WS_* = Webserver directories (virtual/URL)
 define('HTTP_SERVER', 'http://xx.xxx.xxx.x:xxxx'); 
 define('HTTPS_SERVER', 'https://xx.xxx.xxx.x:xxxx'); 
 define('ENABLE_SSL', true); // secure webserver for checkout procedure?
 define('HTTP_COOKIE_DOMAIN', '127.0.0.1');
 define('HTTPS_COOKIE_DOMAIN', '');
 define('HTTP_COOKIE_PATH', '/catalog/');
 define('HTTPS_COOKIE_PATH', '');
 define('DIR_WS_HTTP_CATALOG', '/catalog/');
 define('DIR_WS_HTTPS_CATALOG', '');
 define('DIR_WS_IMAGES', 'images/');
 define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');
 define('DIR_WS_INCLUDES', 'includes/');
 define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');
 define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
 define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
 define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
 define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');

 define('DIR_WS_DOWNLOAD_PUBLIC', 'pub/');
 define('DIR_FS_CATALOG', '/easyphp/www/catalog/');
 define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
 define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

// define our database connection
 define('DB_SERVER', 'localhost'); // eg, localhost - should not be empty for productive servers
 define('DB_SERVER_USERNAME', 'root');
 define('DB_SERVER_PASSWORD', 'xxxxx');
 define('DB_DATABASE', 'mabase');
 define('USE_PCONNECT', 'true'); // use persistent connections?
 define('STORE_SESSIONS', 'mysql'); // leave empty '' for default handler or set to 'mysql'

// eselect plus payement
 define('DIR_WS_MONERIS', DIR_WS_INCLUDES. 'moneris/');

// STS: ADD: Define Simple Template System files
 define('STS_START_CAPTURE', DIR_WS_INCLUDES . 'sts_start_capture.php');
 define('STS_STOP_CAPTURE', DIR_WS_INCLUDES . 'sts_stop_capture.php'); 
 define('STS_RESTART_CAPTURE', DIR_WS_INCLUDES . 'sts_restart_capture.php');
 define('STS_TEMPLATE_DIR', DIR_WS_INCLUDES . 'sts_templates/');
 define('STS_DEFAULT_TEMPLATE', DIR_WS_INCLUDES . 'sts_template.html'); 
 define('STS_DISPLAY_OUTPUT', DIR_WS_INCLUDES . 'sts_display_output.php');
 define('STS_USER_CODE', DIR_WS_INCLUDES . 'sts_user_code.php');
 define('STS_PRODUCT_INFO', DIR_WS_INCLUDES . 'sts_product_info.php');
// STS: EOADD

?>

 

Thk a lot for your help

 

Fabien

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...