Jump to content

stu2000

Members
  • Content count

    460
  • Joined

  • Last visited


Reputation Activity

  1. Like
    stu2000 got a reaction from Patty in [CONTRIBUTION] Admin Change Customer Passwords   
    If anyone is interested, here is my change_password.php file with a few cosmetic changes and the ability now to automatically email the customer with the new password (please note I have removed (commented out) the auto password generation)
     
     

    <?php /* $Id: change_password.php,v 3.0 11/23/2007 kymstion osCommerce, Open Source E-Commerce Solutions [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url] Copyright © 2007 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); // Include the password functions require(DIR_WS_FUNCTIONS . 'password_funcs.php'); // Include the language definitions require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHANGE_PASSWORD); // // POST target -- the POST form has been sent to change a password // If a password change has been submitted, check the results for errors $pass = 0; if ($_POST['customer_id'] != '') { $customer_id = (int)$_POST['customer_id']; if ($_POST['new_password'] == '' && $_POST['repeat_password'] == '') { // Use generated password $pass = 1; $new_password = $_POST['auto_password']; } elseif ($_POST['new_password'] == $_POST['repeat_password']) { // Use custom password $pass = 1; $new_password = $_POST['new_password']; } elseif (empty($_POST['new_password'])) { // Missing password $pass = 2; } elseif (empty($_POST['repeat_password'])) { // Missing repeat password $pass = 2; } elseif ($_POST['new_password'] != $_POST['repeat_password']) { // Mismatched passwords $pass = 3; } // If all is well, make the changes to the database if ($pass == 1) { mysql_query("UPDATE " . TABLE_CUSTOMERS . " SET customers_password='" . tep_encrypt_password ($new_password) . "' WHERE customers_id='" . $customer_id . "'"); // Get the customer's information for the success message $customer_name_query = mysql_query("SELECT customers_firstname, customers_lastname, customers_email_address FROM " . TABLE_CUSTOMERS . " WHERE customers_id='" . $customer_id . "'"); $customer_name = mysql_fetch_array ($customer_name_query); define('EMAIL_PASSWORD_REMINDER_SUBJECT', STORE_NAME . ' - New Password Generated'); define('EMAIL_PASSWORD_REMINDER_BODY', 'A new password was requested for your account at ' . STORE_NAME . '.' . "\n\n" . 'Your new password to \'' . STORE_NAME . '\' is: ' . '%s' . "\n\n" . 'If you did not authorise this, please contact us immediately.' . "\n\n" . STORE_OWNER . "\n" . STORE_OWNER_EMAIL_ADDRESS ); tep_mail($customer_name['customers_firstname'] . " " . $customer_name['customers_lastname'], $customer_name['customers_email_address'], EMAIL_PASSWORD_REMINDER_SUBJECT, nl2br(sprintf(EMAIL_PASSWORD_REMINDER_BODY, $new_password)), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); } } // End POST section // // GET target -- a GET form has been sent // Build a SQL string from the Search or Customer variables $search_string = ''; if (isset ($HTTP_GET_VARS['search']) && strlen ($HTTP_GET_VARS['search']) > 1) { $keywords = tep_db_input (tep_db_prepare_input ($HTTP_GET_VARS['search'])); $search_string = "where customers_lastname like '%" . $keywords . "%' or customers_firstname like '%" . $keywords . "%' or customers_email_address like '%" . $keywords . "%'"; } elseif (isset ($HTTP_GET_VARS['customer'])) { $customer_id = (int)$HTTP_GET_VARS['customer']; $search_string = "WHERE customers_id='" . $customer_id . "'"; } // End GET section // // Variable fields to insert into the page // Build an array of customers for the select pulldown $customer_data_query = mysql_query("SELECT customers_id, customers_firstname, customers_lastname, customers_email_address FROM " . TABLE_CUSTOMERS . " " . $search_string . " ORDER BY customers_lastname, customers_firstname "); $customers_array = array(); while ($customer_data = mysql_fetch_array ($customer_data_query) ) { $customers_array[] = array('id' => $customer_data['customers_id'], 'text' => $customer_data['customers_firstname'] . ' ' . $customer_data['customers_lastname'] . ' (' . $customer_data['customers_email_address'] . ')' ); } // Set the correct message to display for password change or errors $message = ''; switch ($pass) { case 1: $message = '<b><font color=#009900>'; $message .= CUSTOMER_PASSWORD . $customer_name['customers_firstname'] . ' ' . $customer_name['customers_lastname']; $message .= PASSWORD_UPDATED . ' <font color=red>' . $new_password . '</font><br>An Email has been sent to ' . $customer_name['customers_firstname'] . ' ' . $customer_name['customers_lastname'] . ' to verify this change.<br>'; $message .= '</b></font><br>' . tep_black_line(); break; case 2: $message = '<b><font color=#ff0000>'. PLEASE_NEW_PASSWORD . PLEASE_REPEAT . '</b></font>'; break; case 3: $message = '<b><font color=#ff0000>'. ERROR_NEW_PASSWORD . PLEASE_REPEAT . '</b></font>'; break; case 0: default: $message = ' '; break; } // Set up the search form $search_form = tep_draw_input_field ('search'); $search_form .= tep_draw_hidden_field ('selected_box', 'customers'); $search_form .= tep_hide_session_id(); // Generate a random password and add it to the form $auto_password = tep_create_random_value (ENTRY_PASSWORD_MIN_LENGTH); $auto_form = tep_draw_hidden_field ('auto_password', $auto_password) . $auto_password; ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="2" cellpadding="2"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table></td> <!-- body_text //--> <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> </tr> </table></td> </tr> <?php if ($message != ' ') { ?> <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 class="main"><?php echo $message; ?></td> </tr> </table></td> </tr> <?php } ?> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td><?php echo tep_draw_form ('search', FILENAME_CHANGE_PASSWORD, '', 'get'); ?> <table border="0" width="600px" cellspacing="0" cellpadding="2"> <tr> <td width="170"><?php echo tep_draw_separator('pixel_trans.gif', '170', '1'); ?></td> <td width="150"><?php echo tep_draw_separator('pixel_trans.gif', '150', '1'); ?></td> <td width="280"><?php echo tep_draw_separator('pixel_trans.gif', '280', '1'); ?></td> </tr> <tr> <td class="main" colspan="3"><?php echo TEXT_SEARCH_INSTRUCTION; ?><br></td> </tr> <tr> <td width="170" class="main"><b><?php echo SEARCH; ?></b></td> <td width="150" class="main"><?php echo $search_form; ?></td> <td width="280" class="main"><?php echo tep_image_submit ('button_search.gif', IMAGE_SEARCH); ?></td> </tr> </form></table></td> </tr> <tr> <td><?php echo tep_draw_form ('password', FILENAME_CHANGE_PASSWORD, 'selected_box=customers', 'POST'); ?> <table border=0 width="600px" cellspacing="0" cellpadding="2"> <tr> <td width="170" class="main"><b><font color=red>OR</font><br><br><?php echo SELECT_CUSTOMER; ?></b><br><br></td> <td width="450" class="main"><br><br><?php echo tep_draw_pull_down_menu('customer_id', $customers_array);; ?><br><br></td> </tr> <tr> <td class="main"><b><?php echo NEW_PASSWORD; ?></b></td> <td class="main"><?php echo tep_draw_password_field('new_password'); ?></td> </tr> <tr> <td class="main"><b><?php echo REPEAT_NEW_PASSWORD; ?></b></td> <td class="main"><?php echo tep_draw_password_field('repeat_password'); ?></td> </tr> <!-- <tr> <td class="main"><b><?php echo AUTO_PASSWORD; ?></b></td> <td class="main"><?php echo $auto_form; ?></td> </tr> --> <tr> <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '170', '1'); ?></td> <td><?php echo tep_image_submit ('button_change_password.gif', IMAGE_CHANGE_PASSWORD); ?></td> </tr> </form></table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> </table></td> <!-- body_text_eof //--> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> <br> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
     
    A big thank you to Jim Keebaugh, for his help in completing this modification :)
  2. Like
    stu2000 got a reaction from The Imagineer in [CONTRIBUTION] Multiple Categories per product quick entry   
    Multiple Categories per product quick entry (Download here)
     
    This is a cool contribution by the authors Pavel Rojkov, Snowbird and CommLog.
     
    The installation instructions can be somewhat confusing, therefore I have updated the instructions and included the code snippets below, just so you can see what the changes should look like.
     
    All credits goto the original code writers.
     

    case 'insert_product': case 'update_product': // copy image only if modified $products_image = new upload('products_image'); $products_image->set_destination(DIR_FS_CATALOG_IMAGES); if ($products_image->parse() && $products_image->save()) { $products_image_name = $products_image->filename; } else { $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : ''); } if (isset($HTTP_POST_VARS['edit_x']) || isset($HTTP_POST_VARS['edit_y'])) {
     

    'manufacturers_id' => tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id'])); if (isset($products_image_name) && tep_not_null($products_image_name) && ($products_image_name != 'none')) { $sql_data_array['products_image'] = tep_db_prepare_input($products_image_name); } if ($action == 'insert_product') {
     
     

    if ($action == 'insert_product') { $insert_sql_data = array('products_date_added' => 'now()'); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); tep_db_perform(TABLE_PRODUCTS, $sql_data_array); $products_id = tep_db_insert_id(); } elseif ($action == 'update_product') { $update_sql_data = array('products_last_modified' => 'now()'); $sql_data_array = array_merge($sql_data_array, $update_sql_data); tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'"); #delete categories saved in the tables tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '". $products_id . "'"); } # create loop here to insert rows for multiple categories $selected_catids = $HTTP_POST_VARS['categories_ids']; if (!$selected_catids) $selected_catids[0] = 0; foreach ($selected_catids as $current_category_id) { tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . $products_id . "', '" . $current_category_id . "')"); } $languages = tep_get_languages(); for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $language_id = $languages[$i]['id'];
     

    $manufacturers_array = array(array('id' => '', 'text' => TEXT_NONE)); $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name"); while ($manufacturers = tep_db_fetch_array($manufacturers_query)) { $manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'], 'text' => $manufacturers['manufacturers_name']); } # get selected categories $categories_query_selected = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $HTTP_GET_VARS['pID'] . "'"); $categories_array_selected = array(array('id' => '')); while ($categories = tep_db_fetch_array($categories_query_selected)) { $categories_array_selected[] = array('id' => $categories['categories_id']); } $categories_array = array(array('id' => '', 'text' => TEXT_NONE)); #Categories list displays only for one languge (Default is English) $language_id = 1; $categories_array = tep_get_category_tree(); // added by R Calder $form_action = ($HTTP_GET_VARS['pID']) ? 'update_product' : 'insert_product'; $tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));
     

    //--></script> <?php echo tep_draw_form('new_product', FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $HTTP_GET_VARS['pID'] . '&action='. $form_action, 'post', 'enctype="multipart/form-data"'); ?> <table border="0" width="100%" cellspacing="0" cellpadding="2">
  3. Like
    stu2000 got a reaction from The Imagineer in [CONTRIBUTION] Multiple Categories per product quick entry   
    Once this contribution is installed, simply goto your admin control panel and add a product, when you come to adding the product to a category, to select multiple categories, simply hold down the <CONTROL> Key on your keyboard and select the categories you want the product to appear in.
×