<?php
include_once('captcha/captchac_lib.php');  
session_write_close ();

if (@$_REQUEST['submit']) {
  $errorsAndAlerts = "";
	if (!@$_REQUEST['Turing'])    {$errorsAndAlerts .= "To help prevent spam, you must enter characters in the image into the empty box below before submitting.<br/><br/>\n";}
	else  
	{
	 	$Turing_code = $_REQUEST["Turing"];   
		if ( CheckCaptcha($Turing_code) !=1 )  {  $errorsAndAlerts .= "The characters you entered do not match those displayed. Please try again.<br/><br/>\n";}
	
	}
}
?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/hsphere/local/home/c341633/qartguide.com/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
  
// membership v 1.03
list($common_informationRecords, $common_informationMetaData) = getRecords(array(
    'tableName'   => 'common_information',
    'where'       => whereRecordNumberInUrl(1),
    'limit'       => '1',
  ));
  $common_informationRecord = @$common_informationRecords[0]; // get first record
  
   list($horizontal_menu_entriesRecords, $horizontal_menu_entriesMetaData) = getRecords(array(
    'tableName'   => 'horizontal_menu_entries',
  ));

 list($vertical_menu_entriesRecords, $vertical_menu_entriesMetaData) = getRecords(array(
    'tableName'   => 'vertical_menu_entries',
  ));
  list($footer_menu_entriesRecords, $footer_menu_entriesMetaData) = getRecords(array(
    'tableName'   => 'footer_menu_entries',
  ));
  
  // load records
  list($subscriber_level_valuesRecords, $subscriber_level_valuesMetaData) = getRecords(array(
    'tableName'   => 'subscriber_level_values',
    'where'       => whereRecordNumberInUrl(1),
    'limit'       => '1',
  ));
  $subscriber_level_valuesRecord = @$subscriber_level_valuesRecords[0]; // get first record
 ?>
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php $records_allowed = $subscriber_level_valuesRecord['platinum_level_records']; ?>
 <?php if (!@$GLOBALS['WEBSITE_MEMBERSHIP_PLUGIN']) { die("You must activate the Website Membership plugin before you can access this page."); } ?>
<?php

  $showSignupForm = true;

  // error checking
  if (@$CURRENT_USER) {
    $errorsAndAlerts = "You are already signed up! <a class='special' href='{$GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL']}'>CLICK HERE</a> to continue, or <a class='special' href='?action=logoff'>LOG OUT</a>.";
    $showSignupForm = false;
  }

  // process form
  if (@$_REQUEST['save']) {

    // error checking

	if (!@$_REQUEST['first_name'])                { $errorsAndAlerts .= "You must enter your first name!<br/>\n"; }
	if (!@$_REQUEST['last_name'])                { $errorsAndAlerts .= "You must enter your last name!<br/>\n"; }
    if (!@$_REQUEST['email'])                   { $errorsAndAlerts .= "You must enter your email!<br/>\n"; }
    else if(!isValidEmail(@$_REQUEST['email'])) { $errorsAndAlerts .= "Please enter a valid email (example: user@example.com)<br/>\n"; }
    if (!@$_REQUEST['username'])                { $errorsAndAlerts .= "You must choose a username!<br/>\n"; }


    // check for duplicate usernames and emails
    if (!$errorsAndAlerts) {
      $count = mysql_select_count_from('accounts', "`username` = '".mysql_escape(@$_REQUEST['username'])."'");
      if ($count > 0 && @$_REQUEST['username']) { $errorsAndAlerts .= "That username is already in use, please choose another!<br/>\n"; }

      $count = mysql_select_count_from('accounts', "'".mysql_escape($_REQUEST['email'])."' IN (email, username)");
      if ($count > 0) { $errorsAndAlerts .= "That email is already in use, please choose another!<br/>\n"; }
    }

    // turn off strict mysql error checking for: STRICT_ALL_TABLES
    mysqlStrictMode(false); // disable Mysql strict errors for when a field isn't defined below (can be caused when fields are added later)

    // add user
    if (!$errorsAndAlerts) {
		
      // generate password
      $password     = substr(md5(uniqid(rand(), true)), 15); // example output: c5560251ef0b3eef9
      if (@$SETTINGS['advanced']['encryptPasswords']) { $passwordHash = getPasswordDigest($password); }
      else                                            { $passwordHash = $password; }
	  
      
 			@$_REQUEST['first_name']=ucwords(@$_REQUEST['first_name']);
			@$_REQUEST['middle_initial']=strtoupper(@$_REQUEST['middle_initial']);
			@$_REQUEST['last_name']=ucfirst(@$_REQUEST['last_name']);			
 			@$_REQUEST['city']=ucwords(@$_REQUEST['city']);
			@$_REQUEST['state']=strtoupper(@$_REQUEST['state']);
					
        mysql_query("INSERT INTO `{$TABLE_PREFIX}accounts` SET
		 			  organization         = '".mysql_escape( $_REQUEST['organization'] )."',
                      first_name         = '".mysql_escape( $_REQUEST['first_name'] )."',
					  middle_initial         = '".mysql_escape( $_REQUEST['middle_initial'] )."',
					  last_name         = '".mysql_escape( $_REQUEST['last_name'] )."',
					  email            = '".mysql_escape( $_REQUEST['email'] )."',	 
					  web_site         = '".mysql_escape( $_REQUEST['web_site'] )."',
					  facebook         = '".mysql_escape( $_REQUEST['facebook'] )."',
					  flickr         = '".mysql_escape( $_REQUEST['flickr'] )."',
					  linkedin         = '".mysql_escape( $_REQUEST['linkedin'] )."',
					  twitter         = '".mysql_escape( $_REQUEST['twitter'] )."',
					  blog         = '".mysql_escape( $_REQUEST['blog'] )."',
					  other_social_networking_site_name         = '".mysql_escape( $_REQUEST['other_social_networking_site_name'] )."',
					  other_social_networking_site_url         = '".mysql_escape( $_REQUEST['other_social_networking_site_url'] )."',
                      username         = '".mysql_escape( $_REQUEST['username'] )."',
					  password         = '".mysql_escape( $passwordHash )."',
					  street_address         = '".mysql_escape( $_REQUEST['street_address'] )."',
					  city         = '".mysql_escape( $_REQUEST['city'] )."',
					  state         = '".mysql_escape( $_REQUEST['state'] )."',
					  zip         = '".mysql_escape( $_REQUEST['zip'] )."',
					  day_phone         = '".mysql_escape( $_REQUEST['day_phone'] )."', 
					  evening_phone         = '".mysql_escape( $_REQUEST['evening_phone'] )."', 
					  cell_phone         = '".mysql_escape( $_REQUEST['cell_phone'] )."',
			          AllowedFolders = 'platinum',
					  hidden           = '0',
                      disabled         = '0',
					  approved         = '0',
                      isAdmin          = '0',
                      expiresDate      = (NOW() + INTERVAL 30 DAY),
					  no_renewal	= '0',
                      neverExpires     = '1',
                      createdDate      = NOW(),
                      updatedDate      = NOW(),
                      createdByUserNum = '0',
                      updatedByUserNum = '0'")
      or die("MySQL Error Creating Record:<br/>\n". htmlspecialchars(mysql_error()) . "\n");
	  
	  
      $userNum = mysql_insert_id();

	   // create accesslist entry
      // replace '_sample' with the table you want the user to access
      // replace '6' with the access level they should have: 0=none, 6=author, 9=editor
      // replace '1' with the max listings they are allowed
      mysql_query("INSERT INTO `{$TABLE_PREFIX}_accesslist`
                               (userNum,  tableName,        accessLevel, maxRecords, randomSaveId)
                        VALUES ($userNum, 'all',            '1',         NULL,       '1234567890'),
                                ($userNum, 'quick_start_guide_menu',        '9',         1,          '1234567890'),
								($userNum, 'master_subscription_pages',        '6',          '$records_allowed',          '1234567890'),
                               ($userNum, 'master_event_titles',        '6',         '$records_allowed',          '1234567890'),
							    ($userNum, 'master_event_sub_category_titles',        '6',         '$records_allowed',          '1234567890'),
							   ($userNum, 'custom_branding',        '6',        1,          '1234567890'),
							    ($userNum, 'email_signup',        '6',        NULL,          '1234567890'),
                               ($userNum, '_sample',        '6',         1,          '1234567890')") or die("MySQL Error Creating Access List:<br/>\n". htmlspecialchars(mysql_error()) . "\n");

    
      // send message
      $emailTemplate = "emails/user-new-signup.php";
      $emailHeaders  = emailTemplate_load(array(
                        'template'     => websiteLogin_pluginDir() . "/$emailTemplate",
                        'subject'      => '', // set in template
                        'from'         => '', // set in template
                        'to'           => $_REQUEST['email'],
                        'placeholders' => array(
                          'username' => array_key_exists('username', $_REQUEST) ? $_REQUEST['username'] : $_REQUEST['email'], // if using email as username then show that instead
                          'password' => $password,
                          'loginUrl' => "http://" . $_SERVER['HTTP_HOST'] . $GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL'],
                        ),
                      ));
      $mailErrors   = sendMessage($emailHeaders);
      if ($mailErrors) { die("Mail Error: $errors"); }

      // show thanks
      $errorsAndAlerts  = "Thanks, We've created an account for you and emailed you your password.<br/><br/>\n";
      $errorsAndAlerts .= "If you don't receive an email from us within a few minutes check your spam filter for messages from {$emailHeaders['from']}<br/><br/>\n";
      $errorsAndAlerts .= "<a href='{$GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL']}'>Click here to login</a>.";

      $_REQUEST        = array(); // clear form values
      $showSignupForm  = false;
    }
  }

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="content-type" content="text/html;charset=utf-8" />
	<link rel="shortcut icon"  href="favicon.ico" >
		<title>QART Guide - Platinum Subscription Signup</title>
        <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">

	       

    <link href="css/qart.css.php" rel="stylesheet" type="text/css" /> 
    <style type="text/css">
<!--
 body { color:#<?php echo $common_informationRecord['font_color'] ?>;
	 <?php if ($common_informationRecord['all_page_background_image']): ?>background-image: url(<?php foreach ($common_informationRecord['all_page_background_image'] as $upload): ?><?php echo $upload['urlPath'] ?><?php endforeach ?>);<?php endif ?> 
	 <?php if ($common_informationRecord['all_page_background_color']): ?>background-color:#<?php echo $common_informationRecord['all_page_background_color'] ?>;<?php endif ?> 
	background-repeat: <?php echo $common_informationRecord['repeat_all_page_background'] ?>;
}
-->
</style>
	</head>

	<body>
	
     
     <table width="70%"   border="0" align="center" cellpadding="0" ><tr><td> 
     
     <div align="center">
			<h1><?php foreach ($common_informationRecord['masthead_image'] as $upload): ?><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><?php endforeach ?>
<br />
			</h1>
			
		</div>
		<table width="70%"  align="center" border="0">
		  <tr>
          <td align="center" class="medium-bold">|</td>
           <?php foreach ($horizontal_menu_entriesRecords as $record): ?>
		    <td align="center" class="body-text"><a href="<?php if ($record['url']): ?><?php echo $record['url'] ?><?php else : ?>#<?php endif ?>"><?php echo $record['entry'] ?></a></td>
            <td align="center" class="medium-bold">|</td>
           	<?php endforeach ?>
	      </tr>
	   </table>
		<p></p>
        
       
        </td></tr>
      
      <tr>
        <td align="center">
        
        <table width="95%" border="0" align="center" cellpadding="0">
  
  <tr>
    <td width="40%" valign="top"><br />
      
      <table  border="0" align="right" cellpadding="15">
        <?php foreach ($vertical_menu_entriesRecords as $record): ?>
        <tr>
          
          <td width="225"  class=" bg">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="<?php if ($record['url']): ?><?php echo $record['url'] ?><?php else : ?>#<?php endif ?>"><?php echo $record['entry'] ?></a></td>
          </tr>
        
        <?php endforeach ?>
      </table></td>
    <td class="space" bgcolor="<?php echo $common_informationRecord['information_color'] ?>" align="left" valign="top" ><div align="left">
                          
                           <h3 class="body-text-pal" align="center">QART GUIDE PLATINUM SUBSCRIPTION <br />
              SIGNUP FORM</h3>
						   
						   <?php if (@$errorsAndAlerts): ?>
                            </div>
            <div class=" heading-text-bold" align="left">
                       
                      <?php echo $errorsAndAlerts; ?><br/>
            </div>
                      
                               
            <p>
              <?php else: ?>
              <span class=" medium">Please fill out the  form below and click on the submit button.<br /><br />
                          Your subscription request will be reviewed by our subscription committee and you'll receive a confirmation e-mail with your temporary password and login instructions.<br />
              </span><br />
              <span class="medium-bold">Got Questions? &nbsp; </span><a class="special" href="http://72.41.217.52/contact.php">CLICK HERE TO CONTACT US</a><br />
              <br />
              <!-- USER SIGNUP FORM -->
              <?php endif ?>                       
              
              <?php if ($showSignupForm): ?>
            </p>
                      <form method="post" action="?" >
                                                
                                                        <input type="hidden" name="save" value="1" />
                                                                  
                                                        <table border="0" cellspacing="0" cellpadding="5">
                                                          <tr>
                                                            <td class="medium-bold"><font color="red">*</font> = Required Field</td>
                                                            <td>&nbsp;</td>
                                                          </tr>
                                                                    
                                                         <tr>
                                                            <td width="486" class="medium-bold">Organization Name (Optional)&nbsp;</td>
        <td width="392"><input type="text" name="organization" value="<?php echo htmlspecialchars(@$_REQUEST['organization']); ?>" size="50" /></td>
       </tr>
                                                          <tr>
                                                            <td width="486" class="medium-bold">First Name <font color="red">*</font></td>
        <td width="392"><input type="text" name="first_name" value="<?php echo htmlspecialchars(@$_REQUEST['first_name']); ?>" size="50" /></td>
       </tr>
       <tr>
                                                            <td class="medium-bold">Middle Initial (Optional)&nbsp;</td>
        <td><input type="text" name="middle_initial" value="<?php echo htmlspecialchars(@$_REQUEST['middle_initial']); ?>" MAXLENGTH="1" size="3" /></td>
       </tr>
                                                          <tr>
                                                            <td class="medium-bold">Last Name <font color="red">*</font></td>
        <td><input type="text" name="last_name" value="<?php echo htmlspecialchars(@$_REQUEST['last_name']); ?>" size="50" /></td>
       </tr>
        <tr>
          <td class="medium-bold">Street Address <font color="red">*</font></td>
      <td><input type="text" name="street_address" value="<?php echo htmlspecialchars(@$_REQUEST['street_address']); ?>" size="50" /></td>
     </tr>
     <tr>
          <td class="medium-bold">City <font color="red">*</font></td>
      <td><input type="text" name="city" value="<?php echo htmlspecialchars(@$_REQUEST['city']); ?>" size="50" /></td>
     </tr>
     <tr>  
          <td class="medium-bold">State <font color="red">*</font></td>  
      <td><input type="text" name="state" value="<?php echo htmlspecialchars(@$_REQUEST['state']); ?>" MAXLENGTH="2" size="50" /></td>  
     </tr>
     <tr>
          <td class="medium-bold">Zip Code <font color="red">*</font></td>
      <td><input type="text" name="zip" value="<?php echo htmlspecialchars(@$_REQUEST['zip']); ?>" MAXLENGTH="10" size="50" /></td>
     </tr>
                                                         
                                                        
                                                          <tr>
                                                            <td class="medium-bold">Day Phone <font color="red">*</font></td>
                                                            <td><input type="text" name="day_phone" value="<?php echo htmlspecialchars(@$_REQUEST['day_phone']); ?>" size="50" /></td>
                                                          </tr>
                                                          <tr>
                                                            <td class="medium-bold">Evening Phone  (Optional)</td>
                                                            <td><input type="text" name="evening_phone" value="<?php echo htmlspecialchars(@$_REQUEST['evening_phone']); ?>" size="50" /></td>
                                                          </tr>
                                                          <tr>
                                                            <td class="medium-bold">Cell Phone (Optional)</td>
                                                            <td><input type="text" name="cell_phone" value="<?php echo htmlspecialchars(@$_REQUEST['cell_phone']); ?>" size="50" /></td>
                                                          </tr>
                                                          
                                                          <tr>
                                                            <td colspan="2" class="medium-bold">&nbsp;</td>
                                                          </tr>
                                                          
                                                          <tr>
                                                            <td class="medium-bold">Email <font color="red">*</font></td>
        <td><input type="text" name="email" value="<?php echo htmlspecialchars(@$_REQUEST['email']); ?>" size="50" /></td>
       </tr>
       <tr>
                                                            <td colspan="2" class="medium-bold">&nbsp;</td>
                                                          </tr>
                                                           
                                                          <tr>
                                                            <td class="medium-bold">Choose a temporary Username <font color="red">*</font></td>
        <td><input type="text" name="username" value="<?php echo htmlspecialchars(@$_REQUEST['username']); ?>" size="50" /></td>
       </tr>
        <tr>
                                                            <td colspan="2" class="medium-bold">&nbsp;</td>
                                                          </tr>
       <tr>
                                                            <td colspan="2" class="medium-bold">OPTIONAL INFORMATION</td>
                                                          </tr>
        <tr>
              <td class="medium-bold"><p>Web Site URL</p>
              </td>
                                                            <td><input type="text" name="web_site" value="<?php echo htmlspecialchars(@$_REQUEST['web_site']); ?>" size="50" /></td>
                                                          </tr>
                                                          <tr>
              <td class="medium-bold"><p>Blog</p>
              </td>
                                                            <td><input type="text" name="blog" value="<?php echo htmlspecialchars(@$_REQUEST['blog']); ?>" size="50" /></td>
                                                          </tr>
                                                          <tr>
              <td class="medium-bold"><p>Facebook URL</p>
              </td>
                                                            <td><input type="text" name="facebook" value="<?php echo htmlspecialchars(@$_REQUEST['facebook']); ?>" size="50" /></td>
                                                          </tr>
                                                          <tr>
              <td class="medium-bold"><p>Flickr URL</p>
              </td>
                                                            <td><input type="text" name="flickr" value="<?php echo htmlspecialchars(@$_REQUEST['flickr']); ?>" size="50" /></td>
                                                          </tr>
                                                          <tr>
              <td class="medium-bold"><p>Linkedin URL</p>
              </td>
                                                            <td><input type="text" name="linkedin" value="<?php echo htmlspecialchars(@$_REQUEST['linkedin']); ?>" size="50" /></td>
                                                          </tr>
                                                          <tr>
              <td class="medium-bold"><p>Twitter URL</p>
              </td>
                                                            <td><input type="text" name="twitter" value="<?php echo htmlspecialchars(@$_REQUEST['twitter']); ?>" size="50" /></td>
                                                          </tr>
                                                          <tr>
              <td class="medium-bold"><p>Other Social Networking Site Name</p>
              </td>
                                                            <td><input type="text" name="other_social_networking_site_name" value="<?php echo htmlspecialchars(@$_REQUEST['other_social_networking_site_name']); ?>" size="50" /></td>
                                                          </tr>
                                                          <tr>
              <td class="medium-bold"><p>Other Social Networking Site URL</p>
              </td>
                                                            <td><input type="text" name="other_social_networking_site_url" value="<?php echo htmlspecialchars(@$_REQUEST['other_social_networking_site_url']); ?>" size="50" /></td>
                                                          </tr>
                                                          
                                                            <tr>
                                                            <td  valign="top">&nbsp;</td>
                                                            <td>&nbsp;</td>
                                                          </tr>
                   
                   
                
                   <tr>
                     <td  valign="top"><span class="medium-bold">CAPTCHA Image Verification</span><br />
                     <span class="body-text">To help prevent spam, please type the characters in the image into the blank box before you click on submit.<br />
                     <br />
                     </span> <a href="/captcha/whatisturing.html" onclick="window.open('/captcha/whatisturing.html','_blank','width=300, height=300, left=' + (screen.width-450) + ', top=100');return false;">WHAT'S CAPTCHA?</a></td>
                     <td>
                     
                     <table cellpadding=5 cellspacing=0 bgcolor="#7C7164">


<tr>
<td style="padding: 5px;" width="300" height="100"><img src="/captcha/captchac_code.php" id="captcha"><br />
<a href="#" onclick=" document.getElementById('captcha').src = document.getElementById('captcha').src + '?' + (new Date()).getMilliseconds()">CLICK TO CHANGE THE CHARACTERS DISPLAYED</a><br /></td>
</tr>
<tr>
  <td style="padding: 5px;"><input type="text" name="Turing" value="" maxlength="100" size="20" />
    <br />
    <br />    </td>
</tr>
</table></td></tr>
                   
                   
                   
                                                                    
                                                          <tr>
                                                            <td colspan="2" align="center">
                                                              <br/><input class="button" type="submit" name="submit" value="Click to Submit &gt;&gt;" />                                                            </td>
       </tr>
                                                        </table>
                        
            </form>
                               
                                
                                  <br /> 
                                  <span class="medium">By submitting this form you agree to abide by all the terms and conditions of a subscription to QART Guide.</span><br />
                                  <a class="special" href="webterms.php">CLICK HERE TO READ OUR TERMS</a> 
                                  <!-- /USER SIGNUP FORM -->     
               <?php endif ?> </div></td>    </tr>
  
</table></td>
      </tr>
      <tr>
        <td align="center"><br /> <table width="50%"  align="center" border="0">
		  <tr>
          <td align="center" class="small">|</td>
           <?php foreach ($footer_menu_entriesRecords as $record): ?>
		   <td  width="12%" valign="top" align="center" class="small"><a href="<?php if ($record['url']): ?><?php echo $record['url'] ?><?php else : ?>#<?php endif ?>"><?php echo $record['entry'] ?></a></td>
            <td align="center" class="small">|</td> <?php endforeach ?>
            
            <td  ><div id="google_translate_element"></div><script>
function googleTranslateElementInit() {
  new google.translate.TranslateElement({
    pageLanguage: 'en'
  }, 'google_translate_element');
}
</script><script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script></td>
	      </tr>
	   </table></td>
      </tr>
    </table>
	</body>

</html>