<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
  

  if (!defined('START_SESSION')) { define('START_SESSION', true); }
   // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
 $dirsToCheck = array('/hsphere/local/home/jeannesuggs/dancespotlight.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."); }
//Get the current CMS users details
  $CMS_USER = getCurrentUserFromCMS(); 
  
  //redirect the browser if no user is currently logged into the back end
  if (!@$CMS_USER['num']){ 
    redirectBrowserToUrl("http://www.dancespotlight.com/cmsAdmin/admin.php?redirectUrl=" . $_SERVER['REQUEST_URI']);
    exit;
  }
?>
<?php
  // load record from 'common_information'
  list($common_informationRecords, $common_informationMetaData) = getRecords(array(
    'tableName'   => 'common_information',
    'where'       => '', // load first record
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $common_informationRecord = @$common_informationRecords[0]; // get first record

// load records from 'home_page_background_images'
  list($home_page_background_imagesRecords, $home_page_background_imagesMetaData) = getRecords(array(
    'tableName'   => 'home_page_background_images',
    'loadUploads' => true,
    'allowSearch' => false,
  ));
 // load records
  list($publcity_listingsRecords, $publcity_listingsMetaData) = getRecords(array(
    'tableName'   => 'publcity_listings',
	
  ));
   // load records
  list($media_typesRecords, $media_typesMetaData) = getRecords(array(
    'tableName'   => 'media_types',
	
  ));
  
     // load records
  list($specialty_groupRecords, $specialty_groupMetaData) = getRecords(array(
    'tableName'   => 'specialty_group',
	
  ));
  
   // load records
  list($sourceRecords, $sourceMetaData) = getRecords(array(
    'tableName'   => 'source',
	
  ));

?>
<?php
    $showSignupForm = true;

  // process form
  if (@$_REQUEST['save']) {

    // error checking
    $errorsAndAlerts = "";
    if (!@$_REQUEST['first_name'])                { $errorsAndAlerts .= "Please enter a first_name<br/>\n"; }
	if (!@$_REQUEST['last_name'])                { $errorsAndAlerts .= "Please enter a last_name<br/>\n"; }
	// if (!@$_REQUEST['media_type'])                { $errorsAndAlerts .= "Please select a specialty group<br/>\n"; }
 if (!@$_REQUEST['specialty_group'])                { $errorsAndAlerts .= "Please select a specialty group<br/>\n"; }
	if (!@$_REQUEST['source'])                { $errorsAndAlerts .= "Please select a specialty group<br/>\n"; }
	if (!@$_REQUEST['email_address'])                   { $errorsAndAlerts .= "Please enter an email address<br/>\n"; }
    else if(!isValidEmail(@$_REQUEST['email_address'])) { $errorsAndAlerts .= "Please enter a valid email (example: user@example.com)<br/>\n"; }
	
    // check for duplicate email
   $count = mysql_select_count_from('publicity_listings', "'".mysql_escape($_REQUEST['email_address'])."' IN (email_address)");
 if ($count > 0 ) { $errorsAndAlerts .= "That Email Address already exists. \n";
$showSignupForm = true; }

    // 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)

   
    if (!$errorsAndAlerts) {
      
      mysql_query("INSERT INTO `{$TABLE_PREFIX}publcity_listings` SET
                      
                     
					    source            = '".mysql_escape( $_REQUEST['source'] )."',
						specialty_group            = '".mysql_escape( $_REQUEST['specialty_group'] )."',
						media_type            = '".mysql_escape( $_REQUEST['media_type'] )."',
					  organization         = '".mysql_escape( $_REQUEST['organization'] )."',
					  department         = '".mysql_escape( $_REQUEST['department'] )."',
					   first_name         = '".mysql_escape( $_REQUEST['first_name'] )."',
					   last_name         = '".mysql_escape( $_REQUEST['last_name'] )."',
					 title         = '".mysql_escape( $_REQUEST['title'] )."',
					  email_address            = '".mysql_escape( $_REQUEST['email_address'] )."',
					   street_address         = '".mysql_escape( $_REQUEST['street_address'] )."',
					   city         = '".mysql_escape( $_REQUEST['city'] )."',
					   state         = '".mysql_escape( $_REQUEST['state'] )."',
					   zip         = '".mysql_escape( $_REQUEST['zip'] )."',
					   phone         = '".mysql_escape( $_REQUEST['phone'] )."',
					  cell         = '".mysql_escape( $_REQUEST['cell'] )."',
					   description         = '".mysql_escape( $_REQUEST['description'] )."',
					  createdDate      = NOW(),
                      updatedDate      = NOW(),
                      createdByUserNum = '0',
                      updatedByUserNum = '0'")
      or die("MySQL Error Creating Record:<br/>\n". htmlspecialchars(mysql_error()) . "\n");
      $userNum = mysql_insert_id();

    

      $_REQUEST        = array(); // clear form values
      $showSignupForm  = false;
    }
  }

?>
<?php header('Content-type: text/html; charset=utf-8'); ?>
<!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>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>
<script>
jQuery(document).ready(function($) {
if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
{
$("#footer").css("position", "static");
};
});
</script>
<style type="text/css">
table.email {
	border-width: 1px;
	border-spacing: 1px;
	border-style: solid;
	border-color: white;
	border-collapse: collapse;
}
table.email th {
	border-width: 1px;
	padding: 1px;
	border-style: solid;
	border-color: white;
}
table.email td {
	border-width: 1px;
	padding: 1px;
	border-style: solid;
	border-color: white;
}
</style>
<title>Dance Spotlight - Publicity List</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="robots" content="noindex,nofollow" />
<link rel="shortcut icon" href="images/favicon.ico">
<link href="css/multi-column.css" rel="stylesheet" type="text/css" />

<!--[if IE]>
<script type="text/javascript" src="js/css3-multi-column.js"></script> 
<![endif]-->
<link href="css/dsa.css" rel="stylesheet" type="text/css" />
<link href="css/ds5.css.php" rel="stylesheet" type="text/css" />
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
<!--[if gte IE 9]>
  <style type="text/css">
    .gradient {
       filter: none;
    }
  </style>
<![endif]-->
<?php
    function xp_detection ()
{

	if (isset ($_SERVER['HTTP_USER_AGENT']))
	{
		
		
			if (strpos ($_SERVER['HTTP_USER_AGENT'], 'Windows NT 5.1') && strpos ($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)
			return true;
			
			if (strpos ($_SERVER['HTTP_USER_AGENT'], 'Windows XP') && strpos ($_SERVER['HTTP_USER_AGENT'], 'MSIE'  ) !== false)
			return true;

		
	}

	return false;
}
    ?>
<style type="text/css">
html {
	height: 100%;
}
body {
	height: 100%;
	margin: 0;
	background-repeat: no-repeat;
	background-attachment: fixed;
}
</style>
</head>

<body class="gradient">
<?PHP
  function maxWords($textOrHtml, $maxWords) { 
// $text = strip_tags($textOrHtml, '<br /><br/><br><p>'); removed to show links
  $text = $textOrHtml;
  $words = preg_split("/\s+/", $text, $maxWords+1); 
  if (count($words) > $maxWords) { unset($words[$maxWords]); } 
  $output = join(' ', $words); 
 
  return $output; 
  } 
?>
<?PHP
function wordCount($textOrHtml) {
$text = strip_tags($textOrHtml, "<b></b><i></i>");
$words = preg_split("/\s+/", $text);

return count($words);
}
?>
<div id="header">
  <div class="wrap">
    <div class="logo">
      <?php if ($common_informationRecord['preferred_width'] && $common_informationRecord['preferred_height']):?>
      <a href="http://www.dancespotlight.com"><img class="logo1" src="<?php foreach ($common_informationRecord['logo_image_all'] as $index => $upload): ?><?php echo $upload['urlPath'] ?>" width="<?php echo $common_informationRecord['preferred_width'] ?>" height="<?php echo $common_informationRecord['preferred_height'] ?>"<?php endforeach;?> alt="Dance Spotlight Logo" /></a>
      <?php else :?>
      <a href="http://www.dancespotlight.com"><img class="logo1" src="<?php foreach ($common_informationRecord['logo_image_all'] as $index => $upload): ?><?php echo $upload['urlPath'] ?>" width="<?php echo $upload['thumbWidth2'] ?>" height="<?php echo $upload['thumbHeight2'] ?>"<?php endforeach;?> alt="Dance Spotlight Logo" /></a>
      <?php endif ?>
    </div>
    <ul id="navlist">
      <li><a href="index.php"><span class="menulink">Home</span></a></li>
      <li><a href="about.php"><span class="menulink">About Us</span></a></li>
      <li><a href="videos.php"><span class="menulink">Videos</span></a></li>
      <li><a href="../graham/index.php"><span class="menulink">Graham Project</span></a></li>
      <?php if($common_informationRecord['show_faq_link'] == "1") :?>
      <li><a href="faq.php"><span class="menulink">FAQ</span></a></li>
      <?php endif ?>
      <li><a href="contact.php"><span class="menulink">Contact Us</span></a></li>
    </ul>
    <p class="body-text-bold-white-italic-10 tag-line1 "><?php echo $common_informationRecord['home_page_tag_line'] ?></p>
  </div>
</div>
<div class="wrap">
  <div  span class="information-unit">
    <div align="center" >
      <h1 class="body-text-white-bold-11">ADD/MODIFY PUBLICITY RECORDS</h1>
      <span class="body-text-white-10">Enter as much information as you can.<br />
      A </span><span class="body-text-bold-red-11">*</span> <span class="body-text-white-10">indicates a required field.</span> 
      <!-- PUBLICITY RECORD FORM -->
      <?php if (@$errorsAndAlerts): ?>
      <div style="color: #C00; font-weight: bold; font-size: 14px; font-family: arial;"><br/>
        <?php echo $errorsAndAlerts; ?><br/>
      </div>
      <?php endif ?>
      <?php if ($showSignupForm): ?>
      <form method="post" action="?">
        <input type="hidden" name="save" value="1" />
        <table border="0" cellspacing="10" cellpadding="12">
          <tr>
            <td class=" body-text-bold-white-10" ><span class="body-text-bold-red-11">*</span> Who was responsible for obtaining this information?</td>
            <td><?php $Array3 = getListOptions('publcity_listings', 'source');

?>
              <select name="source">
                <option value="">Select a Source</option>
                <?php foreach($Array3 as $type => $code): ?>
                <option <?php selectedIf(@$_REQUEST['source'],$type); ?> value="<?php echo $type; ?>"><?php echo $code; ?></option>
                <?php endforeach; ?>
              </select></td>
          </tr>
          <tr>
            <td class=" body-text-bold-white-10" ><span class="body-text-bold-red-11">*</span> Select a Specialty Group</td>
            <td><?php $Array2 = getListOptions('publcity_listings', 'specialty_group');

?>
              <select name="specialty_group">
                <option value="">Select a Specialty Group</option>
                <?php foreach($Array2 as $type => $code): ?>
                <option <?php selectedIf(@$_REQUEST['specialty_group'],$type); ?> value="<?php echo $type; ?>"><?php echo $code; ?></option>
                <?php endforeach; ?>
              </select></td>
          </tr>
          <tr>
            <td class=" body-text-bold-white-10" >Select a Media Type</td>
            <td><?php $Array1 = getListOptions('publcity_listings', 'media_type');

?>
              <?php // showme ($Array1) ?>
              <select name="media_type">
                <option value="">Select a Media Type</option>
                <?php foreach($Array1 as $type => $code): ?>
                <option <?php selectedIf(@$_REQUEST['media_type'],$type); ?> value="<?php echo $type; ?>"><?php echo $code; ?></option>
                <?php endforeach; ?>
              </select></td>
          </tr>
          <tr>
            <td colspan="2"><hr  color="#b2b2b2" /></td>
          </tr>
          <tr>
            <td class=" body-text-bold-white-10">Organization</td>
            <td><input class="form" type="text" name="organization" value="<?php echo htmlspecialchars(@$_REQUEST['organization']); ?>" size="50" /></td>
          </tr>
          <tr>
            <td class=" body-text-bold-white-10">Department</td>
            <td><input class="form" type="text" name="department" value="<?php echo htmlspecialchars(@$_REQUEST['department']); ?>" size="50" /></td>
          </tr>
          <tr>
            <td class=" body-text-bold-white-10"><span class="body-text-bold-red-11">*</span> First Name</td>
            <td><input class="form" type="text" name="first_name" value="<?php echo htmlspecialchars(@$_REQUEST['first_name']); ?>" size="50" /></td>
          </tr>
          <tr>
            <td class=" body-text-bold-white-10"><span class="body-text-bold-red-11">*</span> Last Name</td>
            <td><input class="form" type="text" name="last_name" value="<?php echo htmlspecialchars(@$_REQUEST['last_name']); ?>" size="50" /></td>
          </tr>
          <tr>
            <td class=" body-text-bold-white-10">Title</td>
            <td><input class="form" type="text" name="title" value="<?php echo htmlspecialchars(@$_REQUEST['title']); ?>" size="50" /></td>
          </tr>
          <tr>
            <td colspan="2"><hr  color="#b2b2b2" /></td>
          </tr>
          <tr>
            <td class=" body-text-bold-white-10"><span class="body-text-bold-red-11">*</span> Email</td>
            <td><input class="form" type="text" name="email_address" value="<?php echo htmlspecialchars(@$_REQUEST['email_address']); ?>" size="50" /></td>
          </tr>
          
            <td class=" body-text-bold-white-10">Street Address</td>
            <td><input class="form" type="text" name="street_address" value="<?php echo htmlspecialchars(@$_REQUEST['street_address']); ?>" size="50" /></td>
          </tr>
          <tr>
            <td class=" body-text-bold-white-10">City</td>
            <td><input class="form" type="text" name="city" value="<?php echo htmlspecialchars(@$_REQUEST['city']); ?>" size="50" /></td>
          </tr>
          
            <td class=" body-text-bold-white-10">State</td>
            <td><input class="form" type="text" name="state" value="<?php echo htmlspecialchars(@$_REQUEST['state']); ?>" size="50" /></td>
          </tr>
          <tr>
            <td class=" body-text-bold-white-10">Zip Code</td>
            <td><input class="form" type="text" name="zip" value="<?php echo htmlspecialchars(@$_REQUEST['zip']); ?>" size="50" /></td>
          </tr>
          <tr>
            <td colspan="2"><hr  color="#b2b2b2" /></td>
          </tr>
          <tr>
            <td class=" body-text-bold-white-10">Land Phone</td>
            <td><input class="form" type="text" name="phone" value="<?php echo htmlspecialchars(@$_REQUEST['phone']); ?>" size="50" /></td>
          </tr>
          <tr>
            <td class=" body-text-bold-white-10">Cell Phone</td>
            <td><input class="form" type="text" name="cell" value="<?php echo htmlspecialchars(@$_REQUEST['cell']); ?>" size="50" /></td>
          </tr>
          <tr>
            <td colspan="2"><hr  color="#b2b2b2" /></td>
          </tr>
          <tr>
            <td class=" body-text-bold-white-10">Additional Information</td>
            <td><textarea cols="50" rows="5" class="form" name="description" value="<?php echo htmlspecialchars(@$_REQUEST['description']); ?>" />
              </textarea></td>
          </tr>
          <tr>
            <td colspan="2"><hr  color="#b2b2b2" /></td>
          </tr>
          <tr>
            <td colspan="2" align="center"><br/>
              <input class="button" type="submit" name="submit" value="Submit &gt;&gt;" /></td>
          </tr>
        </table>
      </form>
      <?php endif ?>
      <br />
      <br />
      <br />
      <br />
      <br />
      <br />
      <br />
      <br />
      <span class="body-text-white-small-8">
      <?php showExecuteSeconds() ?>
      seconds</span> </div>
  </div>
</div>
</body>
</html>
