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

Copyright (c) 2003 osCommerce 

osCommRes, Services Oline 
http://www.oscommres.com 
Copyright (c) 2005 osCommRes 

Freeway eCommerce 
http://www.zac-ware.com/freeway 
Copyright (c) 2007 ZacWare 

Released under the GNU General Public License

  IMPORTANT NOTE:

  This script is not part of the official osC distribution
  but an add-on contributed to the osC community. Please
  read the README and  INSTALL documents that are provided
  with this file for further information and installation notes.

  loginbox.php -   Version 1.0
  This puts a login request in a box with a login button.
  If already logged in, will not show anything.

  Modified to utilize SSL to bypass Security Alert
*/
// Check to ensure this file is included in Freeway!
defined('_FEXEC') or die();
 require(DIR_WS_LANGUAGES . $language . '/loginbox.php');
 

// WebMakers.com Added: Do not show if on login or create account
if ( (!strstr($_SERVER['PHP_SELF'],'login.php')) and (!strstr($_SERVER['PHP_SELF'],'create_account.php')) and !tep_session_is_registered('customer_id') && !tep_session_is_registered('contractor_id'))  {
?>
<!-- loginbox //-->
<?php
    if (!tep_session_is_registered('customer_id')) {
?>
<tr>
	<td>
<?php

if(!defined('BOX_HEADING_LOGIN'))define('BOX_HEADING_LOGIN', 'Login');
  $info_box_contents = array();
  $info_box_contents[] = array('align' => 'left',
                                 'text'  =>  BOX_HEADING_LOGIN );
    new infoBoxHeading($info_box_contents, true, true);

    $loginboxcontent = "
            <form name=\"login\" method=\"post\" action=\"" . tep_href_link(FILENAME_LOGIN, 'action=process', 'SSL') . "\">
            <table border=\"0\" width=\"100%\" cellspacing=\"2\" cellpadding=\"2\">
              <tr>
                <td align=\"left\" class=\"smallText\">
                  &nbsp;" . BOX_LOGINBOX_EMAIL . "
                </td>
                <td align=\"left\" class=\"infoBoxNavigationContent\">
                  <input type=\"text\" name=\"email_address\" maxlength=\"96\" size=\"10\" value=\"\">
                </td>
              </tr>
              <tr>
                <td align=\"left\" class=\"smallText\">
                  &nbsp;" . BOX_LOGINBOX_PASSWORD . "
                </td>
                <td align=\"left\" class=\"infoBoxNavigationContent\">
                  <input type=\"password\" name=\"password\" maxlength=\"40\" size=\"10\" value=\"\"
				</td>
              </tr>
		   
              <tr>
                <td colspan=\"2\" class=\"infoBoxNavigationContent\" align=\"center\">
                  " . tep_template_image_submit('button_login.gif', IMAGE_BUTTON_LOGIN) . "
                </td>
              </tr>
            </table>
            </form>
              ";
		$info_box_contents = array();
		$info_box_contents[] = array('align' => 'center',
									 'text'  => $loginboxcontent
									);
		new $infobox_template($info_box_contents);
		
		
		$info_box_contents = array();
		$info_box_contents[] = array('align' => 'left',
		'text'  => tep_draw_separator('pixel_trans.gif', '100%', '1')
								  );
		new infoboxFooter($info_box_contents, true, true);
?>
	</td>
</tr>
<?php
  } else {
  // If you want to display anything when the user IS logged in, put it
  // in here...  Possibly a "You are logged in as :" box or something.


  }
?>
<!-- loginbox_eof //-->
<?php
// WebMakers.com Added: My Account Info Box
} else {
  if (tep_session_is_registered('customer_id')) {
?>
<!-- my_account_info //-->
<tr>
	<td>
<?php
	$template_html='<tr>
						<td width="{{INITIAL_WIDTH}}"></td><td class="{{CLASS}}">{{SPACER}}{{ICON}}</td><td class="{{CLASS}}"><a href={{LINK_1}}> {{NAME}}</a></td>
					</tr>
					<tr>
						<td height="5"></td>
					</tr>
					';
	$replace_array=array();
	$replace_array["INITIAL_WIDTH"]=$INITIAL_WIDTH;
	$replace_array["CLASS"]="infoBoxNavigation";
	$replace_array["SPACER"]=tep_draw_separator('pixel_trans.gif',10,1);
	$replace_array["ICON"]=$CONTENT_ICON;
	$replace_html=$template_html;
	
	reset($replace_array);
	while(list($key,)=each($replace_array)){
		$replace_html=str_replace("{{" . $key . "}}",$replace_array[$key],$replace_html);
	}
	
	$info_box_contents = array();
	$info_box_contents[] = array('align' => 'left',
								 'text'  =>  BOX_HEADING_LOGIN_BOX_MY_ACCOUNT);
	new infoBoxHeading($info_box_contents, true, true);
	$detail_info=array();
	$detail_info[]=array( tep_href_link(FILENAME_ACCOUNT, '', 'SSL'),LOGIN_BOX_MY_ACCOUNT);
	$detail_info[]=array(tep_href_link(FILENAME_ACCOUNT_EDIT, '', 'SSL'),LOGIN_BOX_ACCOUNT_EDIT);
	$detail_info[]=array(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL'),LOGIN_BOX_ACCOUNT_HISTORY);
	$detail_info[]=array(tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'),LOGIN_BOX_ADDRESS_BOOK);
	$detail_info[]=array(tep_href_link(FILENAME_ACCOUNT_NOTIFICATIONS, '', 'NONSSL'),LOGIN_BOX_PRODUCT_NOTIFICATIONS);
	$detail_info[]=array(tep_href_link(FILENAME_LOGOFF, '', 'NONSSL'),LOGIN_BOX_LOGOFF);

	$login_box_string='';
	for ($icnt=0,$n=count($detail_info);$icnt<$n;$icnt++){
		$replace_string=$replace_html;
		$replace_string=str_replace("{{LINK_1}}",$detail_info[$icnt][0],$replace_string);
		$replace_string=str_replace("{{NAME}}",$detail_info[$icnt][1],$replace_string);
		$login_box_string.=$replace_string;;
	}
	
	$info_box_contents = array();
	$info_box_contents[] = array('align' => 'left',
							   'text'  => '<table border="0" cellpadding="0" cellspacing="0" width="100%">' . $login_box_string . '</table>'
                              );
	new $infobox_template($info_box_contents);
	
	$info_box_contents = array();
	$info_box_contents[] = array('align' => 'left',
										  'text'  => tep_draw_separator('pixel_trans.gif', '100%', '1')
							  );
	new infoboxFooter($info_box_contents, true, true);
?>
            </td>
          </tr>
<!-- my_account_info_eof //-->

<?php
  }
}
?>
