Fifth pass at adding key files

This commit is contained in:
dsainty
2024-06-17 22:42:14 +10:00
parent 67ccdbcc34
commit 9797a6824a
535 changed files with 95045 additions and 0 deletions

54
site/coaches/_notes.txt Normal file
View File

@ -0,0 +1,54 @@
Advanced search options will be:
******************* EDUCATION ******************
Undergrad degree [ ] Undergrad sci degree or ex sci [ ]
Graduate degree [ ] Graduate science or ex sci degree [ ]
***************** CERTIFICATIONS ****************
F.I.S.T certified [ ] Serrotta certified [ ]
USAT level 1 [ ] USAT level 2 [ ] USAT level 3 [ ]
USA Cycling level 1 [ ] USA Cycling level 2 [ ]
USA Swimming level 1 [ ] USA Swimming level 2 [ ]
**************** SERVICES OFFERED ***************
Regular group swim workouts on pool deck [ ]
One-on-one swim instruction on pool deck [ ]
Local fitting [ ]
Regular track workouts in person [ ]
Online coaching [ ]
***************** LOCATION ****************
What we have before, plus:
Outside the United states [ ]
--<<< OTHER FIELDS FOR COACHES AND COACHES TO FILL OUT WOULD BE >>>--
Street address
Street address two
City
State
Zip
Phone
Fax/alt phone
Email
Website
--<< TEXT AREA >>--
More Info
Rates &amp; Fees
Camps

568
site/coaches/add.php Normal file
View File

@ -0,0 +1,568 @@
<?PHP
include("config.php");
if(!is_logged_in($user)){
header('Location: '.$site_url);
exit();
}
$useruid = base64_decode($_SESSION['user_id']);
// set the page title
$pagetitle = "Add a Coach";
// set meta tags
$meta_keywords = "add coach";
$meta_description = "Do you want to include a coach in our online triathlon coach database? Then use this form to send us your information, and we will add it to our website.";
?>
<? include("include_common_head.php"); ?>
<?
if($_POST[add_coach] == true){
include("add_X.php");
}
?>
<body class="listings">
<? include($common_path . "/ads/ad_wallpaper.html"); ?>
<div class="container">
<? include($common_path . "/templates/include_header.php"); ?>
<div class="main">
<div class="contentwrapper clearfix">
<? include("include_breadcrumb.php"); ?>
<section class="section listings section-has-widgets section-static remove-sidebar">
<div class="sidebar-b">
<? include("include_sidebar.php"); ?>
</div>
<div class="content content-has-widgets">
<div class="grid">
<div class="clearfix">
<?
if( $insert_success == true || $_GET[confirmed] == "yes" ) { ?>
<h1 class="content-title"><strong>Thank you</strong></h1>
<p class="cont">Thank you. Your coach information should be added within 24 hours. You will now be redirected back to the add page.</p>
<META HTTP-EQUIV=Refresh CONTENT="4; URL=add.php">
<?
unset($insert_success);
unset($confirm_coach);
?>
<? } else if( $confirm_coach == true ) { ?>
<h1 class="content-title"><strong>Add a Coach: Step 2 of 2</strong></h1>
<? }else if( ($confirm_coach != true) || ($_POST[add_coach] != true) ){ ?>
<h1 class="content-title"><strong>Add a Coach: Step 1 of 2</strong></h1>
<? if (!$errmsg) { ?>
<p class="cont">If you would like to add a coach to our website, simply fill out the form below. Be sure to fill out every field. After filling out each field, click submit. <span style="color: red;">You will then be prompted to confirm your information before the information is sent to us.</span></p>
<? } else { ?>
<p class="cont"><span style="color: red;"><? echo $errmsg; ?></span></p>
<? } ?>
<? }
// begin insert form
if( (($_POST[add_coach] != true) || ($errmsg) || (($confirm_coach != true) && ($_POST[insert_coach] != true))) && $_GET[confirmed] != "yes") {
?>
<form enctype="multipart/form-data" action="add.php" method="post">
<div class="dtable form">
<div class="drow">
<div class="dcell name">Name</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes($_POST[name]); ?>" type="text" name="name" class="txt lngtext" maxlength="80">
</div>
</div>
<div class="drow">
<div class="dcell name">Street Address</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($_POST[address])); ?>" type="text" name="address" class="txt lngtext">
</div>
</div>
<div class="drow">
<div class="dcell name">Street Address Two (optional)</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($_POST[address_two])); ?>" type="text" name="address_two" class="txt lngtext">
</div>
</div>
<div class="drow">
<div class="dcell name">City</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($_POST[city])); ?>" type="text" name="city" class="txt shotext">
</div>
</div>
<div class="drow">
<div class="dcell name">State</div>
<div class="dcell divider"></div>
<div class="dcell value">
<SELECT name="state">
<OPTION value="0">Choose a State/Province/Country</OPTION>
<? //use loop for dropdown box of states
foreach($state_list as $key=>$value){
if(strcmp($_POST[state], $value) == 0){
$str = " selected=\"selected\"";
}
echo "<option value=\"$value\"$str>$value</option>";
$str = "";
}
?>
</SELECT>
</div>
</div>
<div class="drow">
<div class="dcell name">Zip/Postal Code</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($_POST[zip])); ?>" type="text" name="zip" class="txt shotext">
</div>
</div>
<div class="drow">
<div class="dcell name">Phone</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($_POST[phone])); ?>" type="text" name="phone" class="txt shotext">
</div>
</div>
<div class="drow">
<div class="dcell name">Fax / Alternate Phone</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($_POST[fax])); ?>" type="text" name="fax" class="txt shotext">
</div>
</div>
<div class="drow">
<div class="dcell name">E-mail</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($_POST[email])); ?>" type="text" name="email" class="txt midtext">
</div>
</div>
<div class="drow">
<div class="dcell name">Website</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo $_POST[website]; ?>" type="text" name="website" class="txt lngtext" placeholder="http://">
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<h3>Info</h3>
</div>
</div>
<div class="drow">
<div class="dcell name">Certifications</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table cellpadding=0 cellspacing=0 width="100%"><?
$explosion = array("");
if (!is_array($_POST[certifications])){ $explosion = explode(",", $_POST[certifications]); } else { $explosion = $_POST[certifications]; }
$fetch = mysql_query("SELECT * FROM ".$prefix."CoachesCertifications ORDER BY coach_certification_id ASC") OR die(mysql_error());
$i = 0;
$grouping = 1;
echo("<tr>");
echo("<input type=\"hidden\" name=\"certifications[]\" value=\"0\" >");
while ($list = mysql_fetch_array($fetch)) {
if(($grouping != $list[coach_certification_group]) OR !($i%3)) {
if (!($i%3)) echo ("<td width=\"33%\">&nbsp;</td>");
echo "</tr><tr>";
$grouping = $list[coach_certification_group];
$i = 0;
}
echo("<td width=\"33%\"><input type=\"checkbox\" name=\"certifications[]\" value=\"$list[coach_certification_id]\" ");
if (in_array($list['coach_certification_id'], $explosion)){ echo "checked "; }
echo(">$list[coach_certification_name]</td>\n");
$i++;
}
while ($i<3) {
echo ("<td width=\"33%\">&nbsp;</td>\n");
$i++;
}
echo("</tr>");
?>
</table>
</div>
</div>
<div class="drow">
<div class="dcell name">Services</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table cellpadding=0 cellspacing=0 width="100%"><?
$explosion = array("");
if (!is_array($_POST[services])){ $explosion = explode(",", $_POST[services]); } else { $explosion = $_POST[services]; }
$results = mysql_query("SELECT * FROM ".$prefix."CoachesServices ORDER BY coach_service_id ASC");
$i = 0;
echo("<tr>");
echo("<input type=\"hidden\" name=\"services[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
if(!($i%1)) echo "</tr><tr>";
echo("<td width=\"100%\"><input type=\"checkbox\" name=\"services[]\" value=\"$row[coach_service_id]\" ");
if (in_array($row[coach_service_id], $explosion)){ echo "checked "; }
echo(">$row[coach_service_name]</td>\n");
$i++;
}
echo("</tr>");
?>
</table>
</div>
</div>
<div class="drow">
<div class="dcell name">Education</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table cellpadding=0 cellspacing=0 width="100%"><?
$explosion = array("");
if (!is_array($_POST[degrees])){ $explosion = explode(",", $_POST[degrees]); } else { $explosion = $_POST[degrees]; }
$results = mysql_query("SELECT * FROM ".$prefix."CoachesDegrees ORDER BY coach_degree_id ASC");
$i = 0;
echo("<tr>");
echo("<input type=\"hidden\" name=\"degrees[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
if(!($i%2)) echo "</tr><tr>";
echo("<td width=\"50%\"><input type=\"checkbox\" name=\"degrees[]\" value=\"$row[coach_degree_id]\" ");
if (in_array($row[coach_degree_id], $explosion)){ echo "checked "; }
echo(">$row[coach_degree_name]</td>\n");
$i++;
}
echo("</tr>");
?>
</table>
</div>
</div>
<div class="drow">
<div class="dcell name">General Info</div>
<div class="dcell divider"></div>
<div class="dcell value">
<textarea name="info" class="txt lngtext" rows="7" placeholder="Please write some information about your coaching business."><? if($_POST[info]){ echo strip_tags(stripslashes($_POST[info])); } ?></textarea>
</div>
</div>
<div class="drow">
<div class="dcell name">Rates &amp; Fees</div>
<div class="dcell divider"></div>
<div class="dcell value">
<textarea name="cost" rows="7" class="txt lngtext" placeholder="Please describe your rates and fees."><? if($_POST[cost]){ echo strip_tags(stripslashes($_POST[cost])); } ?></textarea>
</div>
</div>
<div class="drow">
<div class="dcell name">Camps</div>
<div class="dcell divider"></div>
<div class="dcell value">
<textarea name="camps" rows="7" class="txt lngtext" placeholder="Please describe any training camps your put on."><? if($_POST[camps]){ echo strip_tags(stripslashes($_POST[camps])); } ?></textarea>
</div>
</div>
<div class="drow actions">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<input type="submit" value="Submit" class="btn">
<input type="hidden" name="add_coach" value="true">
</div>
</div>
</div>
</form>
<? }
// end insert form
// begin confirmation form
if($confirm_coach == true){
?>
Please confirm your information. If everything is correct, click the submit button. Otherwise, you may click the edit button to change your information before submitting.</div>
<br />
<div class="dtable form">
<div class="drow">
<div class="dcell name">Name</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes($_POST[name]); ?>
</div>
</div>
<? // check the db for similar matches
$name_tag = strtolower(str_replace(" ","", $_POST['name']));
$name_superstart = substr($name_tag, 0, 4);
$name_superend = substr($name_tag, -4, 4);
$name_supermid = substr($name_tag, ((strlen($name_tag))/2 - 2), 4);
//echo $name_supermid;
$match_sql = "SELECT coach_id, coach_name, coach_name_tag, coach_city, coach_state FROM ".$prefix."Coaches WHERE coach_valid = 1 AND (coach_name_tag LIKE '%".$name_superstart."%' OR coach_name_tag LIKE '%".$name_superend."%' OR coach_name_tag LIKE '%".$name_supermid."%')";
//echo $match_sql;
$match_fetch = mysql_query($match_sql) OR die(mysql_error());
$i = false;
while ($match_row = mysql_fetch_array($match_fetch)) {
similar_text($match_row['coach_name'], $_POST['name'], $percent);
if ($percent >= 50) {
if ($i == false) {
echo ("<tr><td align=\"right\">Duplicate Alert:</td><td>");
}
if ($i == true) {echo ("<br />");}
echo ("<a href=\"".$site_url."/individual.php?coach_id=".$match_row['coach_id']."\">".$match_row['coach_name']." (".$match_row['coach_city'].", ".$match_row['coach_state'].")</a> (Similarity: ".(round($percent, 0))."%)");
$i = true;
}
}
if ($i == true) { echo("</td></tr>"); }
?>
<div class="drow">
<div class="dcell name">Street Address</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[address])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Street Address Two</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[address_two])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">City</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[city])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">State</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[state])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Zip/Postal Code</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[zip])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Phone</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[phone])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Fax</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[fax])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">E-mail</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[email])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Website</div>
<div class="dcell divider"></div>
<div class="dcell value">
<a href="<? echo $_POST[website]; ?>" target="_blank"><? echo $_POST[website]; ?></a>
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<h3>Info</h3>
</div>
</div>
<div class="drow">
<div class="dcell name">Certifications</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
$explosion = implode(",", $_POST[certifications]);
$sql = ("SELECT * FROM ".$prefix."CoachesCertifications WHERE coach_certification_id IN ($explosion) ORDER BY coach_certification_name ASC");
//echo $sql;
$results = mysql_query($sql) or die(mysql_error());
$certification_list = "";
while ($row = mysql_fetch_array($results)) {
$certification_list = $certification_list."$row[coach_certification_name], ";
}
$certification_list = rtrim($certification_list, ', ');
echo $certification_list;
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Services</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
$explosion = implode(",", $_POST[services]);
$sql = ("SELECT * FROM ".$prefix."CoachesServices WHERE coach_service_id IN ($explosion) ORDER BY coach_service_name ASC");
//echo $sql;
$results = mysql_query($sql) or die(mysql_error());
$service_list = "";
while ($row = mysql_fetch_array($results)) {
$service_list = $service_list."$row[coach_service_name], ";
}
$service_list = rtrim($service_list, ', ');
echo $service_list;
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Education</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
$explosion = implode(",", $_POST[degrees]);
$sql = ("SELECT * FROM ".$prefix."CoachesDegrees WHERE coach_degree_id IN ($explosion) ORDER BY coach_degree_name ASC");
//echo $sql;
$results = mysql_query($sql) or die(mysql_error());
$degree_list = "";
while ($row = mysql_fetch_array($results)) {
$degree_list = $degree_list."$row[coach_degree_name], ";
}
$degree_list = rtrim($degree_list, ', ');
echo $degree_list;
?>
</div>
</div>
<div class="drow">
<div class="dcell name">General Info</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo strip_tags(stripslashes($_POST[info])) ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Rates &amp; Fees</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo strip_tags(stripslashes($_POST[cost])) ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Camps</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo strip_tags(stripslashes($_POST[camps])) ?>
</div>
</div>
<div class="drow actions">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<form action="add.php" method="post">
<input type="hidden" name="name" value="<? echo stripslashes(htmlspecialchars($_POST[name])); ?>">
<input type="hidden" name="address" value="<? echo stripslashes(htmlspecialchars($_POST[address])); ?>">
<input type="hidden" name="address_two" value="<? echo stripslashes(htmlspecialchars($_POST[address_two])); ?>">
<input type="hidden" name="city" value="<? echo stripslashes(htmlspecialchars($_POST[city])); ?>">
<input type="hidden" name="state" value="<? echo $_POST[state]; ?>">
<input type="hidden" name="zip" value="<? echo $_POST[zip]; ?>">
<input type="hidden" name="phone" value="<? echo $_POST[phone]; ?>">
<input type="hidden" name="fax" value="<? echo $_POST[fax]; ?>">
<input type="hidden" name="email" value="<? echo $_POST[email]; ?>">
<input type="hidden" name="website" value="<? echo $_POST[website]; ?>">
<input type="hidden" name="certifications" value="<? echo(implode(',', $_POST[certifications])); ?>">
<input type="hidden" name="services" value="<? echo(implode(',', $_POST[services])); ?>">
<input type="hidden" name="degrees" value="<? echo(implode(',', $_POST[degrees])); ?>">
<input type="hidden" name="cost" value="<? echo stripslashes(htmlspecialchars($_POST[cost])); ?>">
<input type="hidden" name="info" value="<? echo stripslashes(htmlspecialchars($_POST[info])); ?>">
<input type="hidden" name="camps" value="<? echo stripslashes(htmlspecialchars($_POST[camps])); ?>">
<input type="hidden" name="add_coach" value="true">
<input type="hidden" name="insert_coach" value="true">
<input type="hidden" name="submitted_by" value="<? echo $useruid; ?>" >
<input type="submit" name="submit" value="Submit Info" class="btn float-left" style="margin-right: 5px;"/>
</form>
<form action="add.php" method="post">
<input type="hidden" name="name" value="<? echo stripslashes(htmlspecialchars($_POST[name])); ?>">
<input type="hidden" name="address" value="<? echo stripslashes(htmlspecialchars($_POST[address])); ?>">
<input type="hidden" name="address_two" value="<? echo stripslashes(htmlspecialchars($_POST[address_two])); ?>">
<input type="hidden" name="city" value="<? echo stripslashes(htmlspecialchars($_POST[city])); ?>">
<input type="hidden" name="state" value="<? echo $_POST[state]; ?>">
<input type="hidden" name="zip" value="<? echo $_POST[zip]; ?>">
<input type="hidden" name="phone" value="<? echo $_POST[phone]; ?>">
<input type="hidden" name="fax" value="<? echo $_POST[fax]; ?>">
<input type="hidden" name="email" value="<? echo $_POST[email]; ?>">
<input type="hidden" name="website" value="<? echo $_POST[website]; ?>">
<input type="hidden" name="certifications" value="<? echo(implode(',', $_POST[certifications])); ?>">
<input type="hidden" name="services" value="<? echo(implode(',', $_POST[services])); ?>">
<input type="hidden" name="degrees" value="<? echo(implode(',', $_POST[degrees])); ?>">
<input type="hidden" name="cost" value="<? echo stripslashes(htmlspecialchars($_POST[cost])); ?>">
<input type="hidden" name="info" value="<? echo stripslashes(htmlspecialchars($_POST[info])); ?>">
<input type="hidden" name="camps" value="<? echo stripslashes(htmlspecialchars($_POST[camps])); ?>">
<input type="hidden" name="confirm_coach" value="0">
<input type="submit" name="submit" value="Edit Information" class="btn float-left" />
</form>
</div>
</div>
</div>
<?
}
//end confirmation form
?>
</div><!-- end col-2/3 -->
</div><!-- end grid -->
</div><!-- end content -->
</section>
</div><!-- end contentwrapper -->
</div> <!-- end main -->
<? include($common_path . "/templates/include_footer.php") ?>
</div> <!-- container -->
</body>
<? include($common_path . "/templates/include_global_js.php") ?>
</html>

115
site/coaches/add_X.php Normal file
View File

@ -0,0 +1,115 @@
<?PHP
if (!$_POST){ header('Location: '.$site_url); }
/*
FIELD NAMES:
coach_id
coach_name
coach_name_tag
coach_address
coach_address_two
coach_city
coach_state
coach_state_tag
coach_zip
coach_phone
coach_fax
coach_email
coach_website
coach_certifications
coach_services
coach_degrees
coach_cost
coach_info
coach_camps
coach_submitted_by
coach_valid
coach_user_tags
*/
/* Need to ltrim and rtrim commas before insertion */
//Insert into database
//$pass = 'abc123';
$errmsg = NULL;
$insert_success = NULL;
//Check for blank fields
if ((!$_POST[name])) $errmsg = $errmsg."Shop name, ";
if (!$_POST[city]) $errmsg = $errmsg."City, ";
if (!$_POST[state]) $errmsg = $errmsg."State, ";
if (!$_POST[address]) $errmsg = $errmsg."Address, ";
if (!$_POST[phone]) $errmsg = $errmsg."Phone, ";
if (!$_POST[email]) $errmsg = $errmsg."Email, ";
if (!$_POST[website]) $errmsg = $errmsg."Website, ";
if (strlen($_POST[cost]) < 4) $errmsg = $errmsg."Rates &amp; Fees, ";
if (strlen($_POST[info]) < 4) $errmsg = $errmsg."General Info, ";
if (strlen($_POST[camps]) < 4) $errmsg = $errmsg."Camps, ";
if (isset($errmsg)) {
$errmsg = "The following fields cannot be left blank: ".$errmsg."<br />";
$errmsg = rtrim($errmsg, ", ");
}
$start_url = "(http(s)?\:\/\/)?"; // start url
$dots = "([\w_-]{2,}\.)+"; // one or more parts containing a '.' at the end
$last_part = "([\w_-]{2,})"; // last part doesn't contain a dot
$user = "((\/)(\~)[\w_=-]+)?((\/)[\w_=-]+)*"; // maybe subdirectories - possibly with user ~
$end = "((\/)|(\/)[\w_-]+\.[\w]{2,})?"; // maybe a slash at the end or slash+file+extension
$qstring1 = "((\?[\w_-]+\=([^\#]+)){0,1}"; // querystring - first argument (?a=b)
$qstring2 = "(\&[\w_-]+\=([^\#]+))*)?"; // querystring - following arguments (&c=d)
$bkmrk = "(#[\w_-]+)?"; // bookmark
$exp = "/^".$start_url.$dots.$last_part.$user.$end.$qstring1.$qstring2.$bkmrk."$/i";
if( !preg_match($exp, $_POST[website]) ) {
// Contains invalid characters.
$errmsg = $errmsg."Invalid Web Address<br />";
}
if( preg_match('/[^a-zA-Z0-9\. ]/', $_POST[name]) ) {
// Contains invalid characters.
$errmsg = $errmsg."Please use only letters and numbers in the name<br />";
}
// begin error message check
if(!$errmsg){
$name = trim($_POST[name]);
$name_tag = strtolower(str_replace(" ","", $name));
//if(strlen($name_tag) > 12){ //Shorten it
$name_tag = substr($name_tag, 0, 12);
//} // need to update a typo here in other dbs
$address = mysql_escape_string(trim($_POST[address]));
if (isset($_POST['address_two'])) { $address_two = mysql_escape_string(trim($_POST[address_two])); } else { $address_two = NULL; }
$city = mysql_escape_string(trim($_POST[city]));
$state = $_POST[state];
$state_tag = strtolower(str_replace(" ","", $state));
$zip = mysql_escape_string(trim($_POST[zip]));
$phone = trim($_POST[phone]);
$fax = trim($_POST[fax]);
$email = mysql_escape_string(trim($_POST[email]));
$website = mysql_escape_string(trim($_POST[website]));
$certifications = $_POST[certifications];
$services = $_POST[services];
$degrees = $_POST[degrees];
$cost = mysql_escape_string(nl2br(substr(trim($_POST[cost]), 0, 4096)));
$info = mysql_escape_string(nl2br(substr(trim($_POST[info]), 0, 4096)));
$camps = mysql_escape_string(nl2br(substr(trim($_POST[camps]), 0, 4096)));
$submitted_by = $_POST[submitted_by];
// begin boolean check to see if we should insert the coach into the dbase
if($_POST[insert_coach] == true){
$sql = "INSERT INTO ".$prefix."Coaches (coach_name, coach_name_tag, coach_address, coach_address_two, coach_city, coach_state, coach_state_tag, coach_zip, coach_phone, coach_fax, coach_email, coach_website, coach_certifications, coach_services, coach_degrees, coach_cost, coach_info, coach_camps, coach_submitted_by, coach_valid) VALUES ('$name', '$name_tag', '$address', '$address_two', '$city', '$state', '$state_tag', '$zip', '$phone', '$fax', '$email', '$website', ',$certifications,', ',$services,', ',$degrees,', '$cost', '$info', '$camps', $submitted_by, 0)";
//echo("shop entered!");
//echo($sql);
mysql_query($sql) OR die(mysql_error());
//exit();
$insert_success = true;
}else{
//echo("shop NOT entered.");
$confirm_coach = true;
}
// end insert check
}
// end error message check
?>

View File

@ -0,0 +1,19 @@
<?php
require_once("rating/classes/include.all.php");
// Check that the data was sent
if (sizeof($_POST) == 0
|| $_POST['parent'] == null
|| strlen(trim($_POST['parent'])) == 0
|| $_POST['item'] == null
|| strlen(trim($_POST['item'])) == 0
|| $_POST['rating'] == null
|| strlen(trim($_POST['rating'])) == 0
|| $_POST['classes'] == null
|| strlen(trim($_POST['classes'])) == 0)
{
die("You shouldn't be attempting to access this file in this manner.");
}
echo Rating::RateItem($_POST['parent'], $_POST['item'], $_POST['rating'], $_POST['classes']);
?>

View File

@ -0,0 +1,35 @@
<?PHP
if (eregi("comments_add.php", $_SERVER['SCRIPT_NAME'])) {
Header("Location: ".$site_url."/index.php"); die();
}
?>
<form action="comments_add_X.php" method="post">
<input type="hidden" name="coach_id" value="<? echo $row[coach_id]; ?>" />
<input type="hidden" name="editor_id" value="<? echo $useruid; ?>" />
<input type="hidden" name="add_this_review" value="1" />
<div class="row required clear content-title-no" style="background-color: #cecece; padding-left: 2px;">
<a name="comment"></a>
<strong>Add A Comment </strong>
</div>
<div class="row required clear" style="background-color: #cecece;">
<label for="Review_Subject" class="name">Subject: </label>
<div class="value">
<input type="text" id="Review_Subject" name="Review_Subject" value="" class="text" />
</div>
</div>
<div class="row required clear" style="background-color: #cecece;">
<label for="Review_Contents" class="name">Your Review: </label>
<div class="value">
<textarea id="Review_Contents" name="Review_Contents" rows="3" cols="42"></textarea>
</div>
<div class="formsubmit" style="background-color: #cecece;">
<input type="submit" name="add_review" value="Add Review" class="nobutton" />
</div>
</div>
</form>

View File

@ -0,0 +1,33 @@
<?PHP
// do I need to do additional security checks to make sure the script is being called appropriately?
include("config.php");
if (!$_POST){ header('Location: '.$site_url); }
// error checking
if (isset($_POST[Review_Subject]) && isset($_POST[Review_Contents])) {
if ($_SERVER['HTTP_X_FORWARD_FOR']) {
$ip = $_SERVER['HTTP_X_FORWARD_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$tsNow = time();
$coach_id = $_POST[coach_id];
$editor_id = $_POST[editor_id];
$subject = mysql_escape_string(trim($_POST[Review_Subject]));
$message = mysql_escape_string(nl2br(htmlspecialchars(substr(trim($_POST[Review_Contents]), 0, 4096))));
// build the SQL query to delete the edits that are bad
$sql = "INSERT INTO ".$prefix."CoachesComment (coach_id_fk, comment_time, user_id_fk, comment_subject, comment_message, comment_ip, comment_valid) VALUES ($coach_id, '$tsNow', '$editor_id', '$subject', '$message', '$ip', 0)";
//echo $sql;
mysql_query($sql) or die(mysql_error());
}
header('Location: '.$site_url.'/individual.php?coach_id='.$coach_id.'&review_add=ok');
exit();
?>

View File

@ -0,0 +1,19 @@
<?PHP
if (eregi("comments_show.php", $_SERVER['SCRIPT_NAME'])) {
Header("Location: index.php"); die();
}
//$sqlComments = "SELECT * FROM gforum_TriathlonsComment WHERE triathlon_id_fk = $row[uid] AND comment_valid = 1 ORDER BY comment_time DESC";
//$objComments = mysql_query($sqlComments) OR die(mysql_error());
$fb_xid = intval(mysql_escape_string($_GET[uid]));
?>
<a name="comment"></a>
<? /*<div class="fb-comments" data-href="<? echo(curPageURL()); ?>" data-num-posts="5" data-width="500"></div>*/ ?>
<? /**<fb:comments href="<? echo(curPageURL()); ?>" num_posts="5" width="500"></fb:comments>**/ ?>
<fb:comments href="<? echo(curPageURL()); ?>" num_posts="5" width="622"></fb:comments>

View File

@ -0,0 +1,88 @@
<?PHP include("config.php");
if(is_logged_in($user)){
$username = base64_decode($_SESSION['user']);
if($username != "Slowman" && $username != "Rappstar" && $username != "Herbert") {
header('Location: '.$site_url);
exit();
}
} else {
header('Location: '.$site_url);
exit();
}
// Query to fetch non-validated races:
$results = mysql_query("SELECT * FROM ".$prefix."CoachesComment WHERE comment_valid = 0 ORDER BY comment_time DESC") OR die(mysql_error());
// check to see if set is empty
$none = FALSE;
if (mysql_num_rows($results) == 0) { $none = TRUE; }
// set the page title
$pagetitle = "Admin: Comment Validation";
// set meta tags
$meta_keywords = "";
$meta_description = "";
?>
<? include("include_common_head.php"); ?>
<? include("include_common_content.php"); ?>
<!-- Start outer -->
<div id="outer">
<!-- BODY -->
<div class="content">
<!-- LEFT COLUMN -->
<!-- End left column -->
<!-- Content col -->
<h1 class="content-title"><strong>Unvalidated Comments</strong></h1>
<form method="post" action="comments_validate_X.php" enctype="multipart/form-data">
<div class="indent">
<?
if($none == TRUE){
echo "There are no comments waiting to be validated.";
}
?>
<table border="0" cellspacing="1" cellpadding="1" width="100%">
<?
$x = 0;
while($arrComments = mysql_fetch_array($results)){
$x++;
if($x % 2 == 0){ $bg = '#cecece'; }else{ $bg = '#ececec'; }
$arrCommenters = mysql_fetch_array(mysql_query("SELECT user_username FROM ".$prefix."User WHERE user_id = ".$arrComments[user_id_fk]." LIMIT 1"));
$arrClubs = mysql_fetch_array(mysql_query("SELECT coach_name FROM ".$prefix."Coaches WHERE coach_id = ".$arrComments[coach_id_fk]." LIMIT 1"));
$commenter_user_username = $arrCommenters[user_username];
$coach_name = $arrClubs[coach_name];
?>
<tr bgcolor="<? echo "$bg"; ?>"><td><span class="sub-hdr" style="margin-left: 5px;"><strong><? echo $arrComments[comment_subject]; ?></strong></span><div class="indent">Reviewed by: <? echo "<a href=\"http://forum.slowtwitch.com/gforum.cgi?username=".$commenter_user_username.";\" target=\"_blank\">".$commenter_user_username."</a>"; echo " on ".date("F j, Y g:i A", $arrComments[comment_time]); echo " about <a href=\"".$site_url."/individual.php?coach_id=".$arrComments[coach_id_fk]."\">".$coach_name."</a>";?></div><div class="indent" style="background-color: #eeeef9; border: 1px solid black; margin-top: 2px; margin-right: 5px; margin-bottom: 5px; padding: 5px; ">
<? echo stripslashes(stripslashes($arrComments[comment_message])); ?>
</div><div class="indent"><input type="checkbox" value="<? echo($arrComments[comment_id]); ?>" name="validate[]"> Validate this comment. <input type="checkbox" value="<? echo($arrComments[comment_id]); ?>" name="delete[]"> Delete this comment.<br /></div></td></tr>
<?
}
?>
</table>
<br />
<input type="submit" value="Process Selected Comments">
</div>
</form>
<!-- End content col -->
</div>
<!-- End BODY -->
</div>
<!-- End Outer -->
<? include("include_common_footer.php"); ?>

View File

@ -0,0 +1,37 @@
<?PHP
// do I need to do additional security checks to make sure the script is being called appropriately?
include("config.php");
if (!$_POST){ header('Location: '.$site_url); }
// error checking
if(!isset($_POST)) exit();
if (isset($_POST[delete])) {
// convert the array to a SQL friendly format
$deleteList = "(".implode(",", $_POST[delete]).")";
// build the SQL query to delete the edits that are bad
$sql = "DELETE FROM ".$prefix."CoachesComment WHERE comment_id IN $deleteList";
mysql_query($sql) or die(mysql_error());
}
if (isset($_POST[validate])) {
// convert the array to a SQL friendly format
$comment_idlist = "(".implode(",", $_POST[validate]).")";
// build the SQL query
$sql = "UPDATE ".$prefix."CoachesComment
SET comment_valid = 1
WHERE comment_id IN $comment_idlist;";
mysql_query($sql) or die(mysql_error());
}
header('Location: '.$site_url.'/comments_validate.php');
?>

148
site/coaches/config.php Normal file
View File

@ -0,0 +1,148 @@
<?
###########################################
#-----------Users login system------------#
###########################################
/*=========================================\
Author : Mohammed Ahmed(M@@king) \\
Version : 1.0 \\
Date Created: Aug 20 2005 \\
---------------------------- \\
Last Update: August 22 2005 \\
---------------------------- \\
Country : Palestine \\
City : Gaza \\
E-mail : m@maaking.com \\
MSN : m@maaking.com \\
AOL-IM : maa2pal \\
WWW : http://www.maaking.com \\
Mobile/SMS : 00972-599-622235 \\
\\
===========================================\
------------------------------------------*/
// NEED TO CHECK AGAINST SERVER VERSION
//skip the config file if somebody call it from the browser.
session_start();
if (eregi("config.php", $_SERVER['SCRIPT_NAME'])) {
Header("Location: index.php"); die();
}
$main_table = "Coaches";
$field_lead = "coach_";
$site_url = "/coaches";
include("../local/settings.php");
$st_id = 22;
//added new code to fix compatibility issues.
//09-Nov-2005
$phpver = phpversion();
if ($phpver < '4.1.0') {
$_GET = $HTTP_GET_VARS;
$_POST = $HTTP_POST_VARS;
$_SERVER = $HTTP_SERVER_VARS;
}
if ($phpver >= '4.0.4pl1' && strstr($_SERVER["HTTP_USER_AGENT"],'compatible')) {
if (extension_loaded('zlib')) {
ob_end_clean();
ob_start('ob_gzhandler');
}
} else if ($phpver > '4.0') {
if (strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip')) {
if (extension_loaded('zlib')) {
$do_gzip_compress = TRUE;
ob_start(array('ob_gzhandler',5));
ob_implicit_flush(0);
header('Content-Encoding: gzip');
}
}
}
$phpver = explode(".", $phpver);
$phpver = "$phpver[0]$phpver[1]";
if ($phpver >= 41) {
$PHP_SELF = $_SERVER['PHP_SELF'];
}
if (!ini_get("register_globals")) {
#import_request_variables('GPC');
}
function curPageURL() {
$isHTTPS = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on");
$port = (isset($_SERVER["SERVER_PORT"]) && ((!$isHTTPS && $_SERVER["SERVER_PORT"] != "80") || ($isHTTPS && $_SERVER["SERVER_PORT"] != "443")));
$port = ($port) ? ':'.$_SERVER["SERVER_PORT"] : '';
$url = ($isHTTPS ? 'https://' : 'http://').$_SERVER["SERVER_NAME"].$port.$_SERVER["REQUEST_URI"];
return $url;
}
$statecount = mysql_num_rows(mysql_query("SELECT * FROM gforum_Coaches WHERE coach_valid = 1"));
//Array of states for use in the form
$state_list = array('AL'=>"Alabama",
'AK'=>"Alaska",
'AB'=>'Alberta',
'AZ'=>"Arizona",
'AR'=>"Arkansas",
'BC'=>'British Columbia',
'CB'=>"Caribbean",
'CA'=>"California",
'CM'=>"Central America",
'CO'=>"Colorado",
'CT'=>"Connecticut",
'DE'=>"Delaware",
'DC'=>"District of Columbia",
'FL'=>"Florida",
'GA'=>"Georgia",
'HI'=>"Hawaii",
'ID'=>"Idaho",
'IL'=>"Illinois",
'IN'=>"Indiana",
'IA'=>"Iowa",
'KS'=>"Kansas",
'KY'=>"Kentucky",
'LA'=>"Louisiana",
'ME'=>"Maine",
'MB'=>'Manitoba',
'MD'=>"Maryland",
'MA'=>"Massachusetts",
'MX'=>"Mexico",
'MI'=>"Michigan",
'MN'=>"Minnesota",
'MS'=>"Mississippi",
'MO'=>"Missouri",
'MT'=>"Montana",
'NE'=>"Nebraska",
'NV'=>"Nevada",
'NB'=>'New Brunswick',
'NL'=>'Newfoundland',
'NH'=>"New Hampshire",
'NJ'=>"New Jersey",
'NM'=>"New Mexico",
'NY'=>"New York",
'NC'=>"North Carolina",
'ND'=>"North Dakota",
'NS'=>'Nova Scotia',
'OH'=>"Ohio",
'OK'=>"Oklahoma",
'ON'=>'Ontario',
'OR'=>"Oregon",
'PA'=>"Pennsylvania",
'PE'=>'Prince Edward Island',
'QC'=>'Quebec',
'RI'=>"Rhode Island",
'SK'=>'Saskatchewan',
'SC'=>"South Carolina",
'SD'=>"South Dakota",
'TN'=>"Tennessee",
'TX'=>"Texas",
'UT'=>"Utah",
'VT'=>"Vermont",
'VA'=>"Virginia",
'WA'=>"Washington",
'WV'=>"West Virginia",
'WI'=>"Wisconsin",
'WY'=>"Wyoming",
// New Foreign "States",
'OA'=>"Outside N. America");
?>

29
site/coaches/delete_X.php Normal file
View File

@ -0,0 +1,29 @@
<?PHP
include("config.php");
if (!$_POST){ header('Location: '.$site_url); }
$sql = "DELETE FROM gforum_Coaches WHERE coach_id = '$_POST[coach_id]'";
mysql_query($sql) or die(mysql_error());
$sql = "DELETE FROM gforum_CoachesEdits WHERE coach_id_fk = '$_POST[coach_id]'";
mysql_query($sql) or die(mysql_error());
$sql = "DELETE FROM gforum_CoachesEditors WHERE coach_id_fk = '$_POST[coach_id]'";
mysql_query($sql) or die(mysql_error());
$sql = "DELETE FROM gforum_CoachesComment WHERE coach_id_fk = '$_POST[coach_id]'";
mysql_query($sql) or die(mysql_error());
$sql = "DELETE FROM gforum_CoachesRating WHERE coach_id_fk = '$_POST[coach_id]'";
mysql_query($sql) or die(mysql_error());
header('Location: '.$site_url);
?>

View File

@ -0,0 +1,12 @@
<div class="breadcrumb">
<a href="<? echo $main_site_url ?>">Home</a> &gt;
<a href="<? echo $main_site_url . "/local/" ?>">Local Listings</a> &gt;
<? if ( $regionname or $statename or $row[coach_name]) { ?>
<a href="<? echo $site_url ?>">Triathlon Coaches</a>
<? } else { ?>
<span class="lasttitle">Triathlon Coaches</span>
<? } ?>
<? if ( $regionname ) { echo "&gt; " . $regionname; } ?>
<? if ( $statename ) { echo "&gt; " . $statename . " State"; } ?>
<? if ($row[coach_name]) { echo "&gt; " . $row[coach_name]; } ?>
</div>

View File

@ -0,0 +1,107 @@
<?PHP
if(is_logged_in($user)){
$tagtext = "I got fit here";
$actionlink = "individual.php?coach_id=$row[coach_id]&".get_sid();
}else{
$tagtext = "Log in to tag this coach";
$actionlink = "$forum_url/forum/?do=login&from=coaches";
$tagstatus = "no";
}
if(is_logged_in($user)){
//Get user's uid
//$testresults = mysql_query("SELECT user_id FROM ".$prefix."User WHERE user_username=\"$username\"") or die(mysql_error());
//$testrow = mysql_fetch_array($testresults);
//$useruid = $testrow[user_id];
$useruid = base64_decode($_SESSION['user_id']);
// is the current user the owner of the coach?
$coach_submitted_by = FALSE;
if($useruid == $row[coach_submitted_by]){
$coach_submitted_by = TRUE;
}
$tagresults = mysql_query("SELECT coach_user_tags FROM ".$prefix."Coaches WHERE coach_id=$row[coach_id]");
$tagrow = mysql_fetch_array($tagresults);
$tags = explode(",", $tagrow[coach_user_tags]);
$profileresults = mysql_query("SELECT user_coachtags FROM ".$prefix."User WHERE user_id='$useruid'") or die(mysql_error());
$profilerow = mysql_fetch_array($profileresults);
$profiletags = explode(",", $profilerow[user_coachtags]);
if($_POST[status] == "tag"){
//tag the coach
if(array_search($useruid, $tags) == FALSE){
array_push($tags, $useruid);
}
$tags = implode(",", $tags);
mysql_query("UPDATE ".$prefix."Coaches SET coach_user_tags='$tags' WHERE coach_id=$row[coach_id]") or die(mysql_error());
$tags = explode(",", $tags);
if(array_search($row[coach_id], $profiletags) == FALSE){
array_push($profiletags, $row[coach_id]);
}
$profiletags = implode(",", $profiletags);
mysql_query("UPDATE ".$prefix."User SET user_coachtags='$profiletags' WHERE user_id='$useruid'") or die(mysql_error());
}else if($_POST[status] == "untag"){
//untag the coach
$key = array_search($useruid, $tags);
unset($tags[$key]);
$tags = implode(",", $tags);
mysql_query("UPDATE ".$prefix."Coaches SET coach_user_tags='$tags' WHERE coach_id=$row[coach_id]") or die(mysql_error());
$tags = explode(",", $tags);
$key = array_search($row[coach_id], $profiletags);
unset($profiletags[$key]);
$profiletags = implode(",", $profiletags);
mysql_query("UPDATE ".$prefix."User SET user_coachtags='$profiletags' WHERE user_id=$useruid");
}
//Is the coach tagged already?
if(array_search($useruid, $tags) !== FALSE){ $tagged = TRUE; }else{ $tagged = FALSE; }
if($tagged){ $tagstatus = "untag"; $tagtext = "Untag this coach";}else{ $tagstatus = "tag"; $tagtext = "I'm coached";}
}
?>
<div>
<form action="<? echo $actionlink; ?>" method="post" style="display: inline;">
<input type="hidden" value="<? echo $tagstatus; ?>" name="status" />
</form>
<form method="post" action="<? echo "individual.php?coach_id=$row[coach_id]#tagged"; ?>" style="display: inline;">
<input type="submit" value="Who's coached?" class="btn" />
<? if (is_logged_in($user)) { ?>
<input type="submit" value="<? echo $tagtext; ?>" class="btn" />
<? } else { ?>
<a href="<? echo $actionlink ?>" class="btn"><? echo $tagtext; ?></a>
<? } ?>
</form>
<? if(is_logged_in($user)){ ?>
<form method="post" action="<? echo "individual.php?coach_id=$row[coach_id]#comment"; ?>" style="display: inline;">
<input type="submit" value="Comment on this coach" class="btn" />
</form>
<form method="post" action="<? echo "wiki_edit.php?coach_id=$row[coach_id]"; ?>" style="display: inline;">
<input type="submit" value="Edit this coach (wiki)" class="btn" />
</form>
<?
if(is_admin($user)) {
?>
<form method="post" action="delete_X.php" style="display: inline;">
<input type="hidden" name="coach_id" value="<? echo($row[coach_id]); ?>" />
<input type="submit" value="Delete this coach" class="btn" onclick="return confirm('Are you sure you want to DELETE this coach?');" />
</form>
<?
//Get user's username
$testresults = mysql_query("SELECT user_username FROM ".$prefix."User WHERE user_id='$row[coach_submitted_by]'") or die(mysql_error());
$testrow = mysql_fetch_array($testresults);
$username = $testrow[user_username];
echo("<br /><br /><strong>Entered By: </strong> <a href='http://forum.slowtwitch.com/gforum.cgi?username=$username;'>$username</a>");
}
}
?>
</div>

View File

@ -0,0 +1,40 @@
<? $xmlURL = "http://www.slowtwitch.com/googlemaps/coaches_xml.php" ?>
<body id="home" <? if (eregi("index.php", $_SERVER['SCRIPT_NAME'])) { echo ("onload=\"initializeAllMap('$xmlURL')\""); } ?>>
<? include("/var/home/slowtwitch/slowtwitch.com/www/db_templates/fb_sdk.html"); ?>
<div id="accessibility"><a href="#content">Skip to Content</a></div>
<hr class="hide" />
<div id="wrapper">
<div id="header">
<div id="ad_728x90"><!-- BEGIN ADVERTPRO CODE BLOCK -->
<? include "../db_templates/ad_728x90.html"; ?>
<!-- END ADVERTPRO CODE BLOCK --></div>
<div id="logo"><h1><a href="http://www.slowtwitch.com">&lt;:: Welcome to Slowtwitch.com ::&gt;</a></h1></div>
</div>
<? include "../db_templates/common_nav.html"; ?>
<hr class="hide" />
<div id="ocwrapper" class="clear">
<div id="icwrapper" class="clear">
<div id="leftsidebar">
<?
include("include_status.php");
?>
<?
include("include_navigation.php");
?>
</div>
<div id="contentwrapper" class="shadowleft">
<div class="shadowtop"><div class="shadowtopleft"></div><div class="shadowtopright"></div></div>
<div class="shadowright">
<div id="content">
<div class="clear"></div>

View File

@ -0,0 +1 @@
<?PHP include("../db_templates/include_common_footer.php"); ?>

View File

@ -0,0 +1,19 @@
<?PHP
if (eregi("include", $_SERVER['SCRIPT_NAME'])) {
Header("Location: ".$site_url."/index.php"); die();
}
?>
<!DOCTYPE html >
<html lang="en">
<head>
<base href="<? echo $site_url ?>/" />
<title>Slowtwitch.com Coach Database: <? echo $pagetitle; ?></title>
<? include($common_path . "/templates/include_global_head.php"); ?>
<? include($common_path . "/templates/google_analytics.html"); ?>
<? include($common_path . "/templates/fb_sdk.html"); ?>
<!-- begin script to create random number for ads -->
<script language="Javascript">
<!--
sgi_ord=Math.random()*10000000000000000;
//-->
</script>

View File

@ -0,0 +1,71 @@
<?PHP
$outsideflag = "Europe";
$sqlregionlist = "SELECT gtr.regionlong AS regionlong, gtr.regionid AS regionid, gtr.regionname AS regionname, gts.statetag AS statetag, gts.statelong AS statelong, COUNT(gf.coach_id) AS numclubs
FROM ".$prefix."CoachesStates AS gts
LEFT JOIN ".$prefix."Coaches AS gf
ON gts.statetag = gf.coach_state_tag AND gf.coach_valid = 1
LEFT JOIN ".$prefix."CoachesRegions AS gtr
ON gts.regionid = gtr.regionid
GROUP BY gtr.regionlong, gts.statetag ORDER BY gtr.regionlong ASC";
//echo $sqlregionlist;
$resultregionlist = mysql_query($sqlregionlist);
?>
<div class="widget">
<h2>Browse Coaches</h2>
<div class="region-list">
<?
$currentregion = '';
$regioncount = '';
$tempstring = '';
$currenttag = '';
$showhide = '';
$region_dropdown = '';
$state_string = '';
while($rowregionlist = mysql_fetch_array($resultregionlist)){
$selected_region = '';
$selected_state = '';
if ($currentregion != $rowregionlist[regionlong]) {
if ($selected_item == $currentrid) {
$selected_region = ' selected="seleted"';
}
if ($currentregion != '') {
if ($currentregion == $outsideflag) { echo ("<br /><strong>Outside N. America</strong><br />"); }
$region_dropdown .= "<option value=\"$site_url/regionlist.php?region=$currentrid\"$selected_region>$currentregion ($regioncount)</option>$state_string";
echo ("<div class='list-item'><a href='$site_url/regionlist.php?region=$currentrid'>" . $currentregion . " (" . $regioncount . ")</a><span>+</span><div class='sublist' id='". $currenttag . "'>");
echo $tempstring;
echo ('</div></div>');
}
$currentregion = $rowregionlist[regionlong];
$currentrid = $rowregionlist[regionid];
$currenttag = $rowregionlist[regionname];
$regioncount = 0;
$tempstring = '';
$state_string = '';
}
if ($selected_item == $rowregionlist[statetag]) {
$selected_state = ' selected="selected"';
}
$state_string .= "<option value=\"$site_url/statelist.php?state=$rowregionlist[statetag]\"$selected_state>&nbsp;&nbsp;&nbsp;$rowregionlist[statelong] ($rowregionlist[numclubs])</option>";
$tempstring = $tempstring. "<a href='$site_url/statelist.php?state=$rowregionlist[statetag]".get_sid()."' class='lhdr' title='$rowregionlist[statelong]'>$rowregionlist[statelong] ($rowregionlist[numclubs])</a>\n";
$regioncount += $rowregionlist[numclubs];
}
echo ("<div class='list-item'><a href='$site_url/regionlist.php?region=$currentrid'>".$currentregion." (".$regioncount.")</a><span>+</span><div class='sublist' id='".$currenttag."'>");
echo $tempstring;
echo ('</div></div>');
if ( $selected_item == 'top') { $selected_region = ' selected="selected"'; }
$region_dropdown .= "<option value=\"" . $site_url . '/top.php' . "\"$selected_region>Top Ranked</option>";
?>
<div class="advsearch">
<a href="<? echo $site_url . '/search.php' ?>">Search Coaches</a> <span class="sprite-magnify">&nbsp;</span>
</div>
</div>
</div>

View File

@ -0,0 +1,14 @@
<?
$selected_local = 'coaches';
include($common_path . "/templates/include_local_listing.php");
?>
<div class="widget-divider"></div>
<? include("include_status.php"); ?>
<? include("include_navigation.php"); ?>
<div class="widget-divider"></div>
<div class="advert hide-on-mobile">
<? include($common_path . "/ads/ad_300x600.html"); ?>
</div>

View File

@ -0,0 +1,12 @@
<?PHP ?>
<?
if(is_admin()){
echo("<br /><br /><strong style=\"text-decoration: underline;\">Admin:</strong>");
$unvalid_count = mysql_num_rows(mysql_query("SELECT * FROM ".$prefix.$main_table." WHERE ".$field_lead."valid = 0"));
echo("<br /><a href='validate.php'><strong>Validate Entries (".$unvalid_count.")</strong></a>");
$unvalid_count = mysql_num_rows(mysql_query("SELECT * FROM ".$prefix.$main_table."Edits"));
echo("<br /><a href='wiki_validate.php'><strong>Validate Edits (".$unvalid_count.")</strong></a>");
$unvalid_count = mysql_num_rows(mysql_query("SELECT * FROM ".$prefix.$main_table."Comment WHERE comment_valid = 0"));
echo("<br /><a href='comments_validate.php'><strong>Validate Comments (".$unvalid_count.")</strong></a>");
}
?>

View File

@ -0,0 +1,27 @@
<div class="list-block grid">
<div class="col-1-1 clearfix">
<h3 class="float-left"><a href="<? echo "individual.php?coach_id=$row[coach_id]"; ?>"><? echo $row[coach_name]; ?></a> <? if ($row[coach_certifications]) {
$temp_arr = explode(",", $row[coach_certifications]);
if (in_array($st_id, $temp_arr)) {echo "<img src='images/st_cert_16.gif' alt='Slowtwitch Certified Coach'></h3>"; } else { echo "</h3>";}
}
?>
</div>
<? if ($rating_text) { ?>
<p>(Avg. rating <? echo($row[score]); ?> based on <? echo(int_to_words($row[respondents])); if($row[respondents] == 1) { echo(" respondent"); } else { echo(" respondents"); } ?>)</p>
<? } ?>
<div class="col-1-2">
<?
echo ("$row[coach_address]");
if ($row[coach_address_two]) { echo ("<br />$row[coach_address_two]"); }
echo("<br />$row[coach_city], $row[coach_state] $row[coach_zip]");
?>
<br />Phone: <? echo $row[coach_phone] ?>
<br />Fax: <? echo $row[coach_fax] ?>
</div>
<div class="col-1-2">
Email: <? echo "<a href='mailto:$row[coach_email]'>$row[coach_email]</a>"; ?><br/>
Website: <? echo "<a href='$row[coach_website]' target='_blank'>$row[coach_website]</a>"; ?><br/>
<? if ($row[coach_cart] == 1) { echo ("**eCommerce Shopping Cart**<br />"); } ?>
<a href="<? echo "individual.php?coach_id=$row[coach_id]"; ?>">More info &gt;</a>
</div>
</div>

120
site/coaches/index.php Normal file
View File

@ -0,0 +1,120 @@
<?PHP include("config.php");
// set the page title
$pagetitle = "Triathlon Coaches";
// set meta tags
$meta_keywords = "triathlon, trifind, duathlon";
$meta_description = "Are you trying to find triathlon coaches in near your area? You can browse all triathlon coaches organized by states, to find which ones you want to use.";
?>
<? include("include_common_head.php"); ?>
<body class="listings">
<? include($common_path . "/ads/ad_wallpaper.html"); ?>
<div class="container">
<? include($common_path . "/templates/include_header.php"); ?>
<div class="main">
<div class="contentwrapper clearfix">
<? include("include_breadcrumb.php"); ?>
<section class="section listings section-has-widgets section-static remove-sidebar">
<div class="sidebar-b">
<? include("include_sidebar.php"); ?>
</div>
<div class="content content-has-widgets">
<div class="grid">
<div class="clearfix">
<h1 class="float-left">Triathlon Coaches</h1>
<? if (is_logged_in($user)) { ?>
<a href="<? echo $site_url . '/add.php' ?>" class="btn btn-white float-right">Add Coach</a>
<? } ?>
<hr class="line" />
<? include("../runshops/include_region_list.php"); ?>
<div class="map-container">
<div id="map" class="map" data-name="coach" data-json="<? echo $main_site_url ?>/googlemaps/json/coach.json"></div><!--xml relative path from js folder -->
</div>
<?
$num = mysql_num_rows(mysql_query("SELECT coach_id FROM ".$prefix."Coaches WHERE coach_valid=1"));
?>
<h3>Welcome to Slowtwitch.com's North American Triathlon Coach Database</h3>
<p><? echo($num) ?> coaches and counting. This collection of coaches is the most complete and comprehensive
selection of triathlon coaches in North America.</p>
<h3>Searching the database</h3>
<p>
Our Advanced Search is very potent, and will help you drill down to that set
of coaches conforming to a specific purpose you have in mind.
</p>
<h3>Browsing the database</h3>
<p>
You do not need to log in to do this. You'll find a list of coaches in
your region by clicking the regional links on the left. Click the (+) sign
and the region will expand to expose the individual states. Click on the
state to show that list of coaches in it. If you want to see coaches in
multiple states, but not those states we've aggregated into the regions you
see at left, you may do this via our Advanced Search.
</p>
<h3>Showing solidarity with your coach</h3>
<p>
When you see your personal coach listed here, you may click the "I AM COACHED" button. Your User Name will be added to the coaches's list of clients,
just like your User Name appends to those races you choose when you build
your Slowtwitch Personal Race Calendar. Likewise, your Forum User Profile
will show that this is your coach of choice.
</p>
<div class="advert float-left">
<? include($common_path . "/ads/ad_300x250_roadblocks.html"); ?>
</div>
<h3>How to enter a coach</h3>
<p>
You must be a registered user to add a coach to the database. There is
one common type of registration on Slowtwitch, and if you are registered to
post on our Reader Forum you are one of
<?
$num_users = mysql_num_rows(mysql_query("SELECT user_id FROM ".$prefix."User WHERE 1=1"));
echo number_format($num_users);
?>
who have made a registration,
and this means you're able to add coaches to our database.
<br /><br />
If you're not registered, the login prompt is to the left of the page, near
the top. The registration process is straightforward, easy, and free. It
will require you to receive an email and click on a link to complete your
registration. All this should take you only a minute or two. Then...
<br /><br />
1. Click the ADD A COACH button to begin adding to the database.
<br /><br />
2. Once you SUBMIT your coach, you'll also need to CONFIRM your submission
via a link at the bottom of the page.
<br /><br />
3. Once you successfully add your coach, it will not immediately be visible
to you. We must validate the addition on our end before anyone can see it.
We do this so that spammers won't use the coach registration as a way to spam
our database.
</p>
<h3>How to edit published information about a coach</h3>
<p>Any registered user may edit information for a listing. We will review the full contents of each update before confirming any changes that are made. A list of all editors who have made changes is visible at the bottom of each listing. If an entry has been updated, but those changes have not yet been confirmed, this is evident via a note on the individual page for that particular entry. This is to prevent conflicting updates from occuring simultaneously. If you wish to update an entry with pending changes, please wait until we have had a chance to review those changes first. Someone may have already changed the information you were going to change yourself. </p>
<h3>How to comment on a coach</h3>
<p>Any registered user may make a comment on a coach listing. These comments are subject to validation by an administrator before being published.</p>
<h3>Global coach map</h3>
<p>The map below shows the location of all registered Slowtwitch coaches around the globe. You can drag the map, zoom-in, zoom-out, and use any other of the standard Google Maps features. Anywhere you see a red icon, you can click to see the name of that coach and a street address.</p>
</div><!-- end col-2/3 -->
</div><!-- end grid -->
</div><!-- end content -->
</section>
</div><!-- end contentwrapper -->
</div> <!-- end main -->
<? include($common_path . "/templates/include_footer.php") ?>
</div> <!-- container -->
</body>
<? include($common_path . "/templates/include_global_js.php") ?>
</html>

245
site/coaches/individual.php Normal file
View File

@ -0,0 +1,245 @@
<?PHP
include("config.php");
require_once("rating/classes/include.all.php");
$coach_idhere = intval(mysql_escape_string($_GET[coach_id]));
$results = mysql_query("SELECT * FROM ".$prefix."Coaches WHERE coach_id='".$coach_idhere."' LIMIT 1");
$row = mysql_fetch_array($results);
if (!$row){header('Location: '.$site_url.'/?error=invalid_id');}
if($row[coach_valid] == 0) {
if(!is_admin($user)){
header('Location: '.$site_url);
exit();
}
}
// set the page title
$pagetitle = $row[coach_name];
// set meta tags
$meta_keywords = "triathlon, ".$row[coach_name].", ".$row[coach_state]." bike fit";
$meta_description = "Considering getting fit by ".$row[coach_name]."? Here is all of the information about this triathlon coach.";
?>
<? include("include_common_head.php"); ?>
<body class="listings">
<? include($common_path . "/ads/ad_wallpaper.html"); ?>
<div class="container">
<? include($common_path . "/templates/include_header.php"); ?>
<div class="main">
<div class="contentwrapper clearfix">
<? include("include_breadcrumb.php"); ?>
<section class="section listings section-has-widgets section-static remove-sidebar">
<div class="sidebar-b">
<? $selected_item = strtolower($row[coach_state]); ?>
<? include("include_sidebar.php"); ?>
</div>
<div class="content content-has-widgets">
<div class="grid">
<div class="clearfix">
<h1 class="float-left">Triathlon Coaches</h1>
<? if ($user) { ?>
<form method="post" action="wiki_edit.php?retailer_id=<? echo $row[coach_id] ?>">
<input type="submit" value="Edit (wiki)" class="nobutton btn btn-white float-right">
</form>
<? } ?>
<a href="" class="btn btn-white float-right">Back</a>
<hr class="line" />
<? include("../runshops/include_region_list.php"); ?>
<? if($_GET[review_add] == 'ok') { ?>
<p class="success"><strong>Commenter:</strong> your comments have been submitted and will be validated within 24 hours.</p>
<? } ?>
<? if($_GET[wiki_change] == 'success') { ?>
<p class="success"><strong>Editor:</strong> your changes have been submitted and will be validated within 24 hours.</p>
<? } ?>
<? $wikiFetchSQL = "SELECT edit_id FROM ".$prefix."CoachesEdits WHERE coach_id_fk = '".intval(mysql_escape_string($_GET[coach_id]))."'";
$boolEdits = mysql_num_rows(mysql_query($wikiFetchSQL));
if($boolEdits !== 0 && $_GET[wiki_change] != 'success') { ?>
<p class="error"><strong>Group Edits:</strong> there are group edits waiting to be validated.</p>
<? } ?>
<div class="details grid">
<div class="col-9-12">
<h2><? echo stripslashes(stripslashes($row[coach_name])) ; echo " "; ?>
<? if ($row[coach_certifications]) {
$temp_arr = explode(",", $row[coach_certifications]);
if (in_array($st_id, $temp_arr)) {echo "<img src='images/st_cert_22.gif' alt='Slowtwitch Certified Coach'></h2><strong>Slowtwitch Certified Coach</strong>"; } else { echo "</h2>";}
}
?>
</div>
<div class="col-3-12 right">
<? if(is_logged_in($user)) { ?><a href="#comment">Comment</a><? }?>
</div>
<div class="clearfix"></div>
<div class="col-6-12 address">
<? echo stripslashes(htmlspecialchars($row[coach_address])); ?><br />
<? if ( $row[coach_address_two] ) { echo stripslashes(htmlspecialchars($row[coach_address_two]) . "<br />"); } ?>
<? echo stripslashes(htmlspecialchars($row[coach_city])); ?>, <? echo stripslashes(htmlspecialchars($row[coach_state])); ?> <? echo stripslashes(htmlspecialchars($row[coach_zip])); ?><br />
Phone: <? echo stripslashes(htmlspecialchars($row[coach_phone])); ?><br />
Fax: <? echo stripslashes(htmlspecialchars($row[coach_fax])); ?>
</div>
<div class="col-6-12 contact">
Email: <a href="mailto:<? echo $row[coach_email]; ?>"><? echo stripslashes(htmlspecialchars($row[coach_email])); ?></a><br />
<span class="briefy-b">Website: <a href="<? echo $row[coach_website]; ?>" target="_blank"><? echo stripslashes(htmlspecialchars($row[coach_website])); ?></a></span>
</div>
<div class="clearfix"></div>
<br />
<div class="col-1-1">
<? include("include_buttons.php"); ?>
</div>
<div class="col-1-1 detail-block">
<h3>Info</h3>
<div class="highlight-block">
<strong>Education: </strong>
<?
$row[coach_degrees] = ltrim(rtrim($row[coach_degrees], ", "), ", ");
if ($row[coach_degrees]) {
$sql = ("SELECT * FROM ".$prefix."CoachesDegrees WHERE coach_degree_id IN ($row[coach_degrees]) ORDER BY coach_degree_name ASC") OR die(mysql_error());
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$degree_list = "";
while ($list = mysql_fetch_array($fetch)) {
$degree_list = $degree_list."$list[coach_degree_name], ";
}
$degree_list = rtrim($degree_list, ', ');
}
if ($degree_list) {echo $degree_list;} else {echo "None";}
?><br />
<strong>Certifications: </strong>
<?
$row[coach_certifications] = ltrim(rtrim($row[coach_certifications], ", "), ", ");
if ($row[coach_certifications]) {
$sql = ("SELECT * FROM ".$prefix."CoachesCertifications WHERE coach_certification_id IN ($row[coach_certifications]) ORDER BY coach_certification_name ASC");
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$certification_list = "";
while ($list = mysql_fetch_array($fetch)) {
$certification_list = $certification_list."$list[coach_certification_name], ";
}
$certification_list = rtrim($certification_list, ', ');
}
if ($certification_list) {echo $certification_list;} else {echo "None";}
?><br />
<strong>Services: </strong>
<?
$row[coach_services] = ltrim(rtrim($row[coach_services], ", "), ", ");
if ($row[coach_services]) {
$sql = ("SELECT * FROM ".$prefix."CoachesServices WHERE coach_service_id IN ($row[coach_services]) ORDER BY coach_service_name ASC");
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$service_list = "";
while ($list = mysql_fetch_array($fetch)) {
$service_list = $service_list."$list[coach_service_name], ";
}
$service_list = rtrim($service_list, ', ');
}
if ($service_list) {echo $service_list;} else {echo "None";}
?>
</div>
</div>
<div class="col-1-1 detail-block">
<h3>General Info</h3>
<div class="highlight-block">
<strong>General Info: </strong><? echo stripslashes(stripslashes($row[coach_info])) ?><br />
<strong>Rates &amp; Fees: </strong><? echo stripslashes(stripslashes($row[coach_cost])); ?><br />
<strong>Training Camps Offered: </strong><? echo stripslashes(stripslashes($row[coach_camps])); ?>
</div>
</div>
<div class="col-1-1">
<div id="map" class="map map-single" data-name="single" data-category="coach" data-lat="<? echo $row[coach_lat] ?>" data-lng="<? echo $row[coach_lng] ?>">
</div>
<div class="map-description">
<small>
Map location is based off of a geocode of the addressed entered using Google's Google Maps API. If your address does not geocode properly, you can either update the address (we will attempt to re-geocode after any updates to your entry) <strong>or</strong> you can use Google's geocoding tool found here: <a href="http://gmaps-samples.googlecode.com/svn/trunk/geocoder/singlegeocode.html">http://gmaps-samples.googlecode.com/svn/trunk/geocoder/singlegeocode.html</a> to obtain a lat/long for your location and enter that. To use the utility, type in an address that is close to your location and then drag-and-drop the marker to obtain the desired lat/long. If you choose to enter a lat/long, you <strong>must</strong> check the box on the edit page that says, "override geocode with entered lat/long."
</small>
</div>
</div>
<div class="col-1-1 detail-block">
<h3>Who's coached?</h3>
<div class="highlight-block">
<?
$testresults = mysql_query("SELECT coach_user_tags FROM ".$prefix."Coaches WHERE coach_id=$row[coach_id]");
$testrow = mysql_fetch_array($testresults);
$tags = explode(",", $testrow[coach_user_tags]);
$numcount = count($tags) - 1;
if($numcount == 0){ $phrase = "No users have tagged this coach yet."; }
else if($numcount == 1){ $phrase = "There is 1 user who has tagged this coach:"; }
else{ $phrase = "There are $numcount users who have tagged this coach: "; }
?>
<a name="tagged"></a><? echo $phrase; ?>
<?
//List users
$i = 0;
foreach($tags as $value){
if($i > 0){
$tempresults = mysql_query("SELECT user_username FROM ".$prefix."User WHERE user_id='$value'") or die (mysql_error());
$temprow = mysql_fetch_array($tempresults);
if($i > 1){ echo ", "; }
// TODO: SLOWTWITCH EDIT
//echo "<a href=\"profiles/$temprow[user_username].html\">$temprow[user_username]</a>";
// replace the link above with the link below for integration into gforum
echo "<a href=\"http://forum.slowtwitch.com/gforum.cgi?username=$temprow[user_username]&session=".$_SESSION['session_id']."&from=coaches\">$temprow[user_username]</a>";
// TODO: SLOWTWITCH EDIT END
}
$i++;
}
?>
</div>
</div>
</div>
<div class="col-1-1 detail-block">
<?
$testresults = mysql_query("SELECT * FROM ".$prefix."CoachesEditors WHERE coach_id_fk=$row[coach_id] ORDER BY edit_timestamp DESC");
$numcount = mysql_num_rows($testresults);
if($numcount == 0){ $phrase = "No updates have been made this coach yet."; }
else if($numcount == 1){ $phrase = "There has been 1 update to this coach:"; }
else{ $phrase = "There have been $numcount updates to this coach: "; }
echo "<br />";
?>
<h3><a name="editors"></a><? echo $phrase; ?></h3>
<div class="highlight-block">
<?
//List users
$i = 0;
while($row=mysql_fetch_array($testresults)){
if($i >= 0) {
$tempresults = mysql_query("SELECT user_username FROM ".$prefix."User WHERE user_id='$row[user_id_fk]'") or die (mysql_error());
$temprow = mysql_fetch_array($tempresults);
if ($i >= 1) { echo "<br />"; }
echo "<a href=\"http://forum.slowtwitch.com/gforum.cgi?username=$temprow[user_username]&session=".$_SESSION['session_id']."&from=coach\">$temprow[user_username]</a> at ".date("F j, Y g:i A", $row[edit_timestamp]);
}
$i++;
}
if($numcount <= 0) { echo "No users"; }
?>
</div>
</div>
</div>
<div class="content-divider-bottom"></div>
<? include ('comments_show.php'); ?>
</div><!-- end col-2/3 -->
</div><!-- end grid -->
</div><!-- end content -->
</section>
</div><!-- end contentwrapper -->
</div> <!-- end main -->
<? include($common_path . "/templates/include_footer.php") ?>
</div> <!-- container -->
</body>
<? include($common_path . "/templates/include_global_js.php") ?>
</html>

7
site/coaches/logout.php Normal file
View File

@ -0,0 +1,7 @@
<?PHP
include("config.php");
session_unset();
session_destroy();
$_SESSION = array();
header("Location: http://forum.slowtwitch.com/gforum.cgi?do=logout&from=coaches");
?>

View File

@ -0,0 +1,339 @@
<?PHP
###########################################
#-----------Users login system------------#
###########################################
/*=========================================\
Author : Mohammed Ahmed(M@@king) \\
Version : 1.0 \\
Date Created: Aug 20 2005 \\
---------------------------- \\
Last Update: August 22 2005 \\
---------------------------- \\
Country : Palestine \\
City : Gaza \\
E-mail : m@maaking.com \\
MSN : m@maaking.com \\
AOL-IM : maa2pal \\
WWW : http://www.maaking.com \\
Mobile/SMS : 00972-599-622235 \\
\\
===========================================\
------------------------------------------*/
if (eregi("mysql.class.php", $_SERVER['SCRIPT_NAME'])) {
Header("Location: index.php"); die();
}
//db class
if(!defined("SQL_LAYER"))
{
define("SQL_LAYER","mysql");
class sql_db
{
var $db_connect_id;
var $query_result;
var $row = array();
var $rowset = array();
var $num_queries = 0;
//
// Constructor
//
function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
{
$this->persistency = $persistency;
$this->user = $sqluser;
$this->password = $sqlpassword;
$this->server = $sqlserver;
$this->dbname = $database;
if($this->persistency)
{
$this->db_connect_id = @mysql_pconnect($this->server, $this->user, $this->password);
}
else
{
$this->db_connect_id = @mysql_connect($this->server, $this->user, $this->password);
}
if($this->db_connect_id)
{
if($database != "")
{
$this->dbname = $database;
$dbselect = @mysql_select_db($this->dbname);
if(!$dbselect)
{
@mysql_close($this->db_connect_id);
$this->db_connect_id = $dbselect;
}
}
return $this->db_connect_id;
}
else
{
return false;
}
}
//
// Other base methods
//
function sql_close()
{
if($this->db_connect_id)
{
if($this->query_result)
{
@mysql_free_result($this->query_result);
}
$result = @mysql_close($this->db_connect_id);
return $result;
}
else
{
return false;
}
}
//
// Base query method
//
function sql_query($query = "", $transaction = FALSE)
{
// Remove any pre-existing queries
unset($this->query_result);
if($query != "")
{
$this->query_result = @mysql_query($query, $this->db_connect_id);
}
if($this->query_result)
{
unset($this->row[$this->query_result]);
unset($this->rowset[$this->query_result]);
return $this->query_result;
}
else
{
return ( $transaction == END_TRANSACTION ) ? true : false;
}
}
//
// Other query methods
//
function sql_numrows($query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$result = @mysql_num_rows($query_id);
return $result;
}
else
{
return false;
}
}
function sql_affectedrows()
{
if($this->db_connect_id)
{
$result = @mysql_affected_rows($this->db_connect_id);
return $result;
}
else
{
return false;
}
}
function sql_numfields($query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$result = @mysql_num_fields($query_id);
return $result;
}
else
{
return false;
}
}
function sql_fieldname($offset, $query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$result = @mysql_field_name($query_id, $offset);
return $result;
}
else
{
return false;
}
}
function sql_fieldtype($offset, $query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$result = @mysql_field_type($query_id, $offset);
return $result;
}
else
{
return false;
}
}
function sql_fetchrow($query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$this->row[$query_id] = @mysql_fetch_array($query_id);
return $this->row[$query_id];
}
else
{
return false;
}
}
function sql_fetchrowset($query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
unset($this->rowset[$query_id]);
unset($this->row[$query_id]);
while($this->rowset[$query_id] = @mysql_fetch_array($query_id))
{
$result[] = $this->rowset[$query_id];
}
return $result;
}
else
{
return false;
}
}
function sql_fetchfield($field, $rownum = -1, $query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
if($rownum > -1)
{
$result = @mysql_result($query_id, $rownum, $field);
}
else
{
if(empty($this->row[$query_id]) && empty($this->rowset[$query_id]))
{
if($this->sql_fetchrow())
{
$result = $this->row[$query_id][$field];
}
}
else
{
if($this->rowset[$query_id])
{
$result = $this->rowset[$query_id][$field];
}
else if($this->row[$query_id])
{
$result = $this->row[$query_id][$field];
}
}
}
return $result;
}
else
{
return false;
}
}
function sql_rowseek($rownum, $query_id = 0){
if(!$query_id)
{
$query_id = $this->query_result;
}
if($query_id)
{
$result = @mysql_data_seek($query_id, $rownum);
return $result;
}
else
{
return false;
}
}
function sql_nextid(){
if($this->db_connect_id)
{
$result = @mysql_insert_id($this->db_connect_id);
return $result;
}
else
{
return false;
}
}
function sql_freeresult($query_id = 0){
if(!$query_id)
{
$query_id = $this->query_result;
}
if ( $query_id )
{
unset($this->row[$query_id]);
unset($this->rowset[$query_id]);
@mysql_free_result($query_id);
return true;
}
else
{
return false;
}
}
function sql_error($query_id = 0)
{
$result["message"] = @mysql_error($this->db_connect_id);
$result["code"] = @mysql_errno($this->db_connect_id);
return $result;
}
} // class sql_db
} // if ... define
?>

View File

@ -0,0 +1,406 @@
<?php
//////////////////////////////////////////////////////////////////////////////
// Database Class
//============================================================================
// Dependencies:
//----------------------------------------------------------------------------
// None
//============================================================================
// Modification History:
//----------------------------------------------------------------------------
// 2006-11-04: Created
//////////////////////////////////////////////////////////////////////////////
class Database extends Error
{
## CONSTANT VARIABLES
const DB_TYPES = 'mysql,mysqli'; // NO SPACES!
## END CONSTANT VARIABLES
## PUBLIC VARIABLES
## END PUBLIC VARIABLES
## PRIVATE VARIABLES
private static $host;
private static $port;
private static $database;
private static $username;
private static $password;
private static $type;
private static $connection;
private static $savedQueries;
private static $savedResults;
## END PRIVATE VARIABLES
## CONSTRUCTOR
## END CONSTRUCTOR
## DECONSTRUCTOR
## END DECONSTRUCTOR
## PUBLIC METHODS
// Initialize the Variables
// Does not return anything, but acts like a constructor for Static classes
public static function Initialize($varType, $varHost, $varPort, $varDatabase, $varUsername, $varPassword)
{
Error::Initialize();
if (!self::ValidDatabaseTypes($varType))
{
Error::LogError("Database Type Invalid", "Database Type must be one of: " . self::DB_TYPES);
}
self::$host = $varHost;
self::$port = $varPort;
self::$type = strtolower($varType);
self::$database = $varDatabase;
self::$password = $varPassword;
self::$username = $varUsername;
self::$savedQueries = array();
self::$savedResults = array();
self::$connection = self::ConnectToDatabase();
self::SelectTheDatabase();
}
// DeInitialize the Variables
// Does not return anything, but acts like a destructor for Static classes
public static function DeInitialize()
{
// Remove Saved Queries
for ($saved = 0; $saved < sizeof(self::$savedQueries); $saved++)
{
unset(self::$savedQueries[$saved]);
}
// Remove Saved Results
for ($saved = 0; $saved < sizeof(self::$savedResults); $saved++)
{
unset(self::$savedResults[$saved]);
}
// Close the Database Connection
switch (self::$type)
{
case "mysql":
@mysql_close(self::$connection) or Error::LogError("MySQL Failed to Close", mysql_error(self::$connection));
break;
case "mysqli":
@mysqli_close(self::$connection) or Error::LogError("MySQL Failed to Close", mysqli_error(self::$connection));
break;
}
// Destroy Variables
self::$host = null;
self::$port = null;
self::$type = null;
self::$database = null;
self::$password = null;
self::$username = null;
self::$connection = null;
self::$savedQueries = null;
self::$savedResults = null;
Error::DeInitialize();
}
// Database Types
// Returns an array of database types
public static function DatabaseTypes()
{
return split(",", self::DB_TYPES);
}
// Build Order By
// Returns the SQL Syntax for ORDER BY
public static function BuildOrderBy($varColumnName, $varDirection)
{
$orderby = "";
if (self::$connection)
{
switch (self::$type)
{
case "mysql":
case "mysqli":
$orderby = "ORDER BY `{$varColumnName}` {$varDirection}";
break;
}
}
return $orderby;
}
// Build Limit
// Returns the SQL Syntax for LIMIT
public static function BuildLimit($varStartingRow, $varNumberOfRows)
{
$limit = "";
if (self::$connection)
{
switch (self::$type)
{
case "mysql":
case "mysqli":
$limit = "LIMIT {$varStartingRow}, {$varNumberOfRows}";
break;
}
}
return $limit;
}
// Execute SQL Query
// Returns the result of the query, which is typically a resource id
public static function ExecuteQuery($sql, $name)
{
if (self::$connection)
{
if (strlen(trim($name)) != 0)
{
switch (self::$type)
{
case "mysql":
if (!array_key_exists($name, self::$savedQueries))
{
self::$savedQueries[$name] = @mysql_query($sql, self::$connection) or Error::LogError("Query Failed", mysql_error(self::$connection));
}
break;
case "mysqli":
if (!array_key_exists($name, self::$savedQueries))
{
self::$savedQueries[$name] = @mysqli_query(self::$connection, $sql) or Error::LogError("Query Failed", mysqli_error(self::$connection));
}
break;
}
return self::$savedQueries[$name];
}
else
{
Error::LogError("Execute Query Name Missing", "The name parameter was empty, please provide a name for the query.");
}
}
return null;
}
// Fetch Results
// Returns an array of the query results
public static function FetchResults($name)
{
$results = array();
if (self::$connection)
{
if (strlen(trim($name)) != 0 && (array_key_exists($name, self::$savedQueries) || array_key_exists($name, self::$savedResults)))
{
if (array_key_exists($name, self::$savedQueries))
{
switch (self::$type)
{
case "mysql":
$row = 0;
while ($currentResult = @mysql_fetch_assoc(self::$savedQueries[$name]))
{
$col = 0;
foreach ($currentResult as $key => $value)
{
$results[$row][$col] = $value;
$results[$row][$key] = $value;
$col++;
}
$row++;
}
break;
case "mysqli":
$row = 0;
while ($currentResult = @mysqli_fetch_assoc(self::$savedQueries[$name]))
{
$col = 0;
foreach ($currentResult as $key => $value)
{
$results[$row][$col] = $value;
$results[$row][$key] = $value;
$col++;
}
$row++;
}
break;
}
self::$savedResults[$name] = $results;
}
else
{
$results = self::$savedResults[$name];
}
}
else
{
if (strlen(trim($name)) == 0)
{
Error::LogError("Fetch Results Name Missing", "The name parameter was empty, the name is required so it knows which results to return.");
}
else
{
Error::LogError("Fetch Results Name ('{$name}') Not Found", "The name provided did not have any query results associated with it.");
}
}
}
return $results;
}
// Free SQL Query Results
// Returns nothing
public static function FreeResults($name)
{
if (self::$connection)
{
if (strlen(trim($name)) != 0 && array_key_exists($name, self::$savedQueries))
{
switch (self::$type)
{
case "mysql":
@mysql_free_result(self::$savedQueries[$name]) or Error::LogError("Free Results Error", mysql_error(self::$connection));
unset(self::$savedQueries[$name]);
break;
case "mysqli":
@mysqli_free_result(self::$savedQueries[$name]) or Error::LogError("Free Results Error", mysqli_error(self::$connection));
unset(self::$savedQueries[$name]);
break;
}
}
else
{
if (strlen(trim($name)) == 0)
{
Error::LogError("Free Results Name Missing", "The name parameter was empty, the name is required so it knows which results to free up from memory.");
}
else
{
Error::LogWarning("Free Results Name ('{$name}') Not Found", "The name provided did not have any query results associated with it.");
}
}
}
}
// Remove Saved Results
// Returns nothing
public static function RemoveSavedResults($name)
{
if (strlen(trim($name)) != 0 && array_key_exists($name, self::$savedResults))
{
unset(self::$savedResults[$name]);
}
else
{
if (strlen(trim($name)) == 0)
{
Error::LogError("Remove Saved Result Name Missing", "The name parameter was empty, the name is required so it knows which query to remove.");
}
else
{
Error::LogWarning("Remove Saved Result Name ('{$name}') Not Found", "The name provided was not a saved query.");
}
}
}
// Attempt Connect To Database
// Returns true or false depending on if the connection failed or succeeded
public static function AttemptConnectToDatabase($varType, $varHost, $varPort, $varDatabase, $varUsername, $varPassword)
{
self::$type = $varType;
self::$host = $varHost;
self::$port = $varPort;
self::$database = $varDatabase;
self::$username = $varUsername;
self::$password = $varPassword;
Error::ClearErrors();
self::$connection = self::ConnectToDatabase();
if (!Error::HasErrors())
{
return true;
}
else
{
return false;
}
}
// MySQL Version
// Returns the mysql version number
public static function MysqlVersion()
{
$version = "";
if (self::$connection)
{
switch (self::$type)
{
case "mysql":
$version = mysql_get_server_info(self::$connection);
break;
case "mysqli":
$version = mysqli_get_server_info(self::$connection);
break;
}
}
return $version;
}
## END PUBLIC METHODS
## PRIVATE METHODS
// Connect to Database
// Returns the database connection resource
private static function ConnectToDatabase()
{
$link = null;
switch (self::$type)
{
case "mysql":
if (strlen(trim(self::$port)) != 0)
{
$link = mysql_connect(self::$host . ":" . self::$port, self::$username, self::$password) or Error::LogError("Database Error", mysql_error());
}
else
{
$link = mysql_connect(self::$host, self::$username, self::$password) or Error::LogError("Database Error", mysql_error());
}
break;
case "mysqli":
$link = mysqli_connect(self::$host, self::$username, self::$password, self::$database, self::$port) or Error::LogError("Database Error", mysqli_connect_error());
break;
}
return $link;
}
// Select the Database
// Returns nothing
private static function SelectTheDatabase()
{
switch (self::$type)
{
case "mysql":
@mysql_select_db(self::$database, self::$connection) or Error::LogError("Database Selection", mysql_error(self::$connection));
break;
}
}
// Valid Database Types
// Returns true or false depending on if the database type is valid
private static function ValidDatabaseTypes($varType)
{
$types = split(',', str_replace(" ", "", self::DB_TYPES));
return in_array($varType, $types);
}
## END PRIVATE METHODS
## PROTECTED METHODS
## END PROTECTED METHODS
}
?>

View File

@ -0,0 +1,258 @@
<?php
//////////////////////////////////////////////////////////////////////////////
// Error Class
//============================================================================
// Dependencies:
//----------------------------------------------------------------------------
// none
//============================================================================
// Modification History:
//----------------------------------------------------------------------------
// 2006-11-04: Created
//////////////////////////////////////////////////////////////////////////////
class Error
{
## CONSTANT VARIABLES
## END CONSTANT VARIABLES
## PUBLIC VARIABLES
## END PUBLIC VARIABLES
## PRIVATE VARIABLES
private static $title;
private static $type;
private static $description;
private static $datetime;
private static $numErrors;
private static $numWarnings;
## END PRIVATE VARIABLES
## CONSTRUCTOR
## END CONSTRUCTOR
## DECONSTRUCTOR
## END DECONSTRUCTOR
## PUBLIC METHODS
// Initialize the Variables
// Does not return anything, but acts like a constructor for Static classes
public static function Initialize()
{
self::$title = array();
self::$type = array();
self::$description = array();
self::$datetime = array();
self::$numErrors = 0;
self::$numWarnings = 0;
}
// DeInitialize the Variables
// Does not return anything, but acts like a destructor for Static classes
public static function DeInitialize()
{
self::$title = null;
self::$type = null;
self::$description = null;
self::$datetime = null;
self::$numErrors = null;
self::$numWarnings = null;
}
// Log Error Method (receives Name and Description)
// Returns true or false depending on if the logging of the error was successful
public static function LogError($varTitle, $varDescription)
{
// Check Parameters
if (strlen(trim($varTitle)) != 0 && strlen(trim($varDescription)) != 0)
{
array_push(self::$title, $varTitle);
array_push(self::$type, "ERROR");
array_push(self::$description, $varDescription);
array_push(self::$datetime, date("m/d/Y H:i:s"));
self::$numErrors++;
return true;
}
return false;
}
// Show Error Messages
// Returns the Error Message Output (in HTML format)
public static function ShowErrorMessages()
{
$output = "";
// Check to see if 1 error occurred or more than one.
if (self::$numErrors > 0)
{
if (self::$numErrors > 1)
{
$error = "ERRORS";
}
else
{
$error = "ERROR";
}
// Loop through Error Messages
for ($i = 0; $i < sizeof(self::$title); $i++)
{
if (self::$type[$i] == "ERROR")
{
// Output each individual Error
$output .= " <div class=\"divErrorTitle\">\r\n" .
" " . self::$title[$i] . "\r\n" .
" <span class=\"spnErrorDateTime\">at " . self::$datetime[$i] . "</span>\r\n" .
" </div>\r\n" .
" <div class=\"divErrorDesc\">" . self::$description[$i] . "<br /><br /></div>\r\n";
}
}
// Write Error Template Output
$output = "<div class=\"divErrorBox\">\r\n" .
" <div class=\"divErrorBoxTitle\"><img src=\"icons/24-em-cross.png\" align=\"left\" /> {$error}:</div>\r\n" .
" <div class=\"divErrors\">\r\n" . $output . "\r\n </div>\r\n" .
"</div>\r\n";
}
// Return the Error Message Output
return $output;
}
// Retrieve Last Error
// Returns the title and description of the last error in an array
public static function RetrieveLastError()
{
$output = array();
// Check to see if 1 error occurred or more than one.
if (self::$numErrors > 0)
{
for ($i = sizeof(self::$title) - 1; $i >= 0; $i++)
{
if (self::$type[$i] == "ERROR")
{
array_push($output, self::$title[$i]);
array_push($output, self::$description[$i]);
break;
}
}
}
return $output;
}
// Clear Errors
// Returns nothing
public static function ClearErrors()
{
self::$numErrors = 0;
for ($i = 0; $i < sizeof(self::$type); $i++)
{
if (self::$type[$i] == "ERROR")
{
self::$title[$i] = null;
self::$type[$i] = null;
self::$description[$i] = null;
self::$datetime[$i] = null;
}
}
}
// Has Errors
// Returns true or false on whether errors exist
public static function HasErrors()
{
if (self::$numErrors > 0)
{
return true;
}
return false;
}
// Log Warning Method (receives Name and Description)
// Returns true or false depending on if logging the warning was successful
public static function LogWarning($varTitle, $varDescription)
{
// Check Parameters
if (strlen(trim($varTitle)) != 0 && strlen(trim($varDescription)) != 0)
{
array_push(self::$title, $varTitle);
array_push(self::$type, "WARNING");
array_push(self::$description, $varDescription);
array_push(self::$datetime, date("m/d/Y H:i:s"));
self::$numWarnings++;
return true;
}
return false;
}
// Show Warning Messages
// Returns the Warning Message Output (in HTML format)
public static function ShowWarningMessages()
{
$output = "";
// Check to see if 1 warning occurred or more than one.
if (self::$numWarnings > 0)
{
if (self::$numWarnings > 1)
{
$warning = "WARNINGS";
}
else
{
$warning = "WARNING";
}
// Loop through Warning Messages
for ($i = 0; $i < sizeof(self::$title); $i++)
{
if (self::$type[$i] == "WARNING")
{
// Output each individual Warning
$output .= " <div class=\"divWarningTitle\">\r\n" .
" " . self::$title[$i] . "\r\n" .
" <span class=\"spnWarningDateTime\">at " . self::$datetime[$i] . "</span>\r\n" .
" </div>\r\n" .
" <div class=\"divWarningDesc\">" . self::$description[$i] . "<br /><br /></div>\r\n";
}
}
// Write Warning Template Output
$output = "<div id=\"divWarningBox\">\r\n" .
" <div id=\"divWarningBoxTitle\"><img src=\"designs/icons/24-message-warn.png\" align=\"left\" /> {$warning}:</div>\r\n" .
" <div id=\"divWarnings\">\r\n" . $output . "\r\n </div>\r\n" .
"</div>\r\n";
}
// Return the Warning Message Output
return $output;
}
// Has Warnings
// Returns true or false on whether there are any Warnings
public static function HasWarnings()
{
if (self::$numWarnings > 0)
{
return true;
}
return false;
}
## END PUBLIC METHODS
## PRIVATE METHODS
## END PRIVATE METHODS
## PROTECTED METHODS
## END PROTECTED METHODS
}
?>

View File

@ -0,0 +1,7 @@
<?php
require_once("error.class.php");
require_once("database.class.php");
require_once("rating.class.php");
Database::Initialize("mysql", $dbhost, "3306", $dbname, $dbuname, $dbpass);
?>

View File

@ -0,0 +1,279 @@
<?php
class Rating
{
## PRIVATE VARIABLES
## END PRIVATE VARIABLES
## PUBLIC METHODS
// Output the Rating information
// Returns a string of HTML
public static function OutputRating($varParent, $varItem)
{
// Verify $varItem was provided
if ($varItem != null && strlen(trim($varItem)) != 0 && $varParent != null && strlen(trim($varParent)) != 0)
{
// Check if Magic QUotes is ON
if (!get_magic_quotes_gpc())
{
$varItem = addslashes($varItem);
$varParent = addslashes($varParent);
}
// Information for the Output
$averageStars = Rating::CalculateAverageRating($varParent, $varItem);
// Check to see that the user has not already rated this item
if (Rating::CheckRatingsByIp($varParent, $varItem) == 0)
{
$classes = "rating " . Rating::ShowStars($averageStars);
$cat_info = Rating::FetchCategoryInfo($varItem);
// Write Output HTML for the Rating Data
$output = "\r\n";
$output .= "<div class=\"rating-table\"><div><strong>{$cat_info['rating_cat_name']}</strong></div>\r\n";
$output .= "<div>{$cat_info['rating_cat_min']}</div><div><div class=\"rated\"><ul class=\"{$classes}\" style='margin: 0px 0px 10px 0px;' id=\"{$varParent}_{$varItem}\">\r\n";
$output .= " <li class=\"one\"><a href=\"javascript:RateItem('{$varParent}','{$varItem}', 1);\" title=\"1 Star\">1</a></li>\r\n";
$output .= " <li class=\"two\"><a href=\"javascript:RateItem('{$varParent}','{$varItem}', 2);\" title=\"2 Stars\">2</a></li>\r\n";
$output .= " <li class=\"three\"><a href=\"javascript:RateItem('{$varParent}','{$varItem}', 3);\" title=\"3 Stars\">3</a></li>\r\n";
$output .= " <li class=\"four\"><a href=\"javascript:RateItem('{$varParent}','{$varItem}', 4);\" title=\"4 Stars\">4</a></li>\r\n";
$output .= " <li class=\"five\"><a href=\"javascript:RateItem('{$varParent}','{$varItem}', 5);\" title=\"5 Stars\">5</a></li>\r\n";
$output .= "</ul></div></div><div> {$cat_info['rating_cat_max']}</div></div>\r\n";
}
else
{
$classes = "rated " . Rating::ShowStars($averageStars);
$cat_info = Rating::FetchCategoryInfo($varItem);
// Write Output HTML for the Rating Data
$output = "\r\n";
$output .= "<div class=\"rating-table\"><div><strong>{$cat_info['rating_cat_name']}</strong></div>\r\n";
$output .= "<div>{$cat_info['rating_cat_min']}</div><div><div class=\"rated\"><ul class=\"{$classes}\" style='margin: 0px 0px 10px 0px;' id=\"{$varParent}_{$varItem}\">\r\n";
$output .= " <li class=\"one\">1</li>\r\n";
$output .= " <li class=\"two\">2</li>\r\n";
$output .= " <li class=\"three\">3</li>\r\n";
$output .= " <li class=\"four\">4</li>\r\n";
$output .= " <li class=\"five\">5</li>\r\n";
$output .= "</ul></div></div><div> {$cat_info['rating_cat_max']}</div></div>\r\n";
}
}
else
{
$output = "";
// This is a major issue. NO information can be retrieve if an item name is not passed.
Error::LogError("Variable Missing", "You must provide the item name for this function to find the average.");
}
return $output;
}
public static function OutputParentRating($varParent)
{
// Verify $varParent was provided
if ($varParent != null && strlen(trim($varParent)) != 0)
{
// Check if Magic QUotes is ON
if (!get_magic_quotes_gpc())
{
$varParent = addslashes($varParent);
}
// Information for the Output
$averageStars = Rating::CalculateAverageParentRating($varParent);
$classes = "rated " . Rating::ShowStars($averageStars);
//$parent_info = Rating::FetchParentInfo($varParent);
// Write Output HTML for the Rating Data
$output = "\r\n";
//$output .= "<div style='clear:both;'>Overall Rating</div>";
$output .= "<div style='height: 16px; width: 80px; position: relative;'><ul class=\"{$classes}\" id=\"{$varParent}\" style='margin: 0px 0px 10px 0px;'>\r\n";
$output .= " <li class=\"one\">1</li>\r\n";
$output .= " <li class=\"two\">2</li>\r\n";
$output .= " <li class=\"three\">3</li>\r\n";
$output .= " <li class=\"four\">4</li>\r\n";
$output .= " <li class=\"five\">5</li>\r\n";
$output .= "</ul></div>\r\n";
}
else
{
$output = "";
// This is a major issue. NO information can be retrieve if an item name is not passed.
Error::LogError("Variable Missing", "You must provide the parent name for this function to find the average.");
}
return $output;
}
// Rate an Item
// Returns the name/value pair of new class names and the item name
public static function RateItem($varParent, $varItem, $varRating, $varClasses)
{
$newClassNames = $varClasses;
// Verify $varName was provided
if ($varParent != null && strlen(trim($varParent)) != 0
&& $varItem != null && strlen(trim($varItem)) != 0
&& $varRating != null && strlen(trim($varRating)) != 0 && is_numeric($varRating)
&& $varClasses != null && strlen(trim($varClasses)) != 0)
{
// Check if Magic Quotes is ON
if (!get_magic_quotes_gpc())
{
$varItem = addslashes($varItem);
$varParent = addslashes($varParent);
}
// Check to see that the user has not already rated this item
if (Rating::CheckRatingsByIp($varParent, $varItem) == 0)
{
$ipAddress = $_SERVER['REMOTE_ADDR'];
$tempTime = time();
Database::ExecuteQuery("INSERT INTO `gforum_CoachesRating` (`coach_id_fk`, `category_id_fk`, `rating_vote`, `rating_ip`, `rating_date`) VALUES ('{$varParent}', '{$varItem}', {$varRating}, '{$ipAddress}', '{$tempTime}')", "InsertRating");
Database::FetchResults("InsertRating");
Database::FreeResults("InsertRating");
Database::RemoveSavedResults("InsertRating");
// Information for the Output
$averageStars = Rating::CalculateAverageRating($varParent, $varItem);
$newClassNames = "rated " . Rating::ShowStars($averageStars);
$averageStars = Rating::CalculateAverageParentRating($varParent);
$newClassParent = "rated " . Rating::ShowStars($averageStars);
}
}
else
{
// This is a major issue. NOT enough information was sent to log the item
Error::LogError("Variable(s) Missing", "You must provide all of the information to log the rating of this item.");
}
// Build Name/Value Pair to return
$nameValue = "classes={$newClassNames}&item={$varItem}&parent={$varParent}&parentClass={$newClassParent}";
return $nameValue;
}
## END PUBLIC METHODS
## PRIVATE METHODS
// Fetch Category Names & Min/Max Values
private static function FetchCategoryInfo($varItem)
{
// Query Category Info for a specific Category ID
Database::ExecuteQuery("SELECT * FROM `gforum_CoachesRatingCategory` WHERE `rating_cat_id`='{$varItem}'", "CategoryInfo");
$results = Database::FetchResults("CategoryInfo");
Database::FreeResults("CategoryInfo");
Database::RemoveSavedResults("CategoryInfo");
return $results[0];
}
// Calculate Average Rating
// Returns the number of stars to show
private static function CalculateAverageRating($varParent, $varItem)
{
$averageStars = 0;
// Query Average Rating for a specific Item
Database::ExecuteQuery("SELECT AVG(`rating_vote`) AS `averageRating` FROM `gforum_CoachesRating` WHERE `category_id_fk`='{$varItem}' AND `coach_id_fk`='{$varParent}'", "AverageRating");
$results = Database::FetchResults("AverageRating");
Database::FreeResults("AverageRating");
Database::RemoveSavedResults("AverageRating");
// Round the Average into a Whole Number
if (sizeof($results) == 1)
{
if ($results[0]['averageRating'] != null)
{
$averageStars = round($results[0]["averageRating"], 0);
}
}
else
{
// This is simply a warning, as it isn't vital if no results were found, as the item may be new.
Error::LogWarning("Rating Data Missing", "No entries were found for '{$varName}', this might be the first entry.");
}
return $averageStars;
}
// Calculate Average Rating
// Returns the number of stars to show
private static function CalculateAverageParentRating($varParent)
{
$averageStars = 0;
// Query Average Rating for a specific Item
Database::ExecuteQuery("SELECT AVG(`rating_vote`) AS `averageRating` FROM `gforum_CoachesRating` WHERE `coach_id_fk`='{$varParent}'", "AverageRating");
$results = Database::FetchResults("AverageRating");
Database::FreeResults("AverageRating");
Database::RemoveSavedResults("AverageRating");
// Round the Average into a Whole Number
if (sizeof($results) == 1)
{
if ($results[0]['averageRating'] != null)
{
$averageStars = round($results[0]["averageRating"], 0);
}
}
else
{
// This is simply a warning, as it isn't vital if no results were found, as the item may be new.
Error::LogWarning("Rating Data Missing", "No entries were found for '{$varName}', this might be the first entry.");
}
return $averageStars;
}
// Show Stars
// Returns the class information for the number of stars to show
private static function ShowStars($varStars)
{
// Select the Number of Stars Class
switch ($varStars)
{
case 1:
$classes .= "onestar";
break;
case 2:
$classes .= "twostar";
break;
case 3:
$classes .= "threestar";
break;
case 4:
$classes .= "fourstar";
break;
case 5:
$classes .= "fivestar";
break;
default:
$classes .= "nostar";
break;
}
return $classes;
}
// Check Ratings By IP Address
// Returns the number of ratings for an item by an ip address
private static function CheckRatingsByIp($varParent, $varItem)
{
$ipAddress = $_SERVER['REMOTE_ADDR'];
Database::ExecuteQuery("SELECT COUNT(*) AS `totalRatings` FROM `gforum_CoachesRating` WHERE `category_id_fk`='{$varItem}' AND `coach_id_fk`='{$varParent}' AND `rating_ip`='{$ipAddress}'", "AlreadyRated");
$results = Database::FetchResults("AlreadyRated");
Database::FreeResults("AlreadyRated");
Database::RemoveSavedResults("AlreadyRated");
// Check to see that the user has not already rated this item
if ($results != null && $results[0]['totalRatings'] != null)
{
return $results[0]['totalRatings'];
}
return 0;
}
## END PRIVATE METHODS
}
?>

View File

@ -0,0 +1,55 @@
<?php
$nwords = array( "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty", 30 => "thirty", 40 => "forty", 50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty", 90 => "ninety" );
function int_to_words($x) {
global $nwords;
if(!is_numeric($x))
$w = '#';
else if(fmod($x, 1) != 0)
$w = '#';
else {
if($x < 0) {
$w = 'minus ';
$x = -$x;
} else
$w = '';
// ... now $x is a non-negative integer.
if($x < 21) // 0 to 20
$w .= $nwords[$x];
else if($x < 100) { // 21 to 99
$w .= $nwords[10 * floor($x/10)];
$r = fmod($x, 10);
if($r > 0)
$w .= '-'. $nwords[$r];
} else if($x < 1000) { // 100 to 999
$w .= $nwords[floor($x/100)] .' hundred';
$r = fmod($x, 100);
if($r > 0)
$w .= ' and '. int_to_words($r);
} else if($x < 1000000) { // 1000 to 999999
$w .= int_to_words(floor($x/1000)) .' thousand';
$r = fmod($x, 1000);
if($r > 0) {
$w .= ' ';
if($r < 100)
$w .= 'and ';
$w .= int_to_words($r);
}
} else { // millions
$w .= int_to_words(floor($x/1000000)) .' million';
$r = fmod($x, 1000000);
if($r > 0) {
$w .= ' ';
if($r < 100)
$word .= 'and ';
$w .= int_to_words($r);
}
}
}
return $w;
}
?>

View File

@ -0,0 +1,71 @@
<?php
require_once("classes/include.all.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CSS Star Rating System fully functional using AJAX</title>
<link type="text/css" href="styles/rating.css" rel="stylesheet" media="all" />
<script type="text/javascript" src="scripts/prototype.js"></script>
<script type="text/javascript" src="scripts/rating.js"></script>
</head>
<body>
<h4>Race Rating System:</h4>
<?php
$ratingData = Rating::OutputParentRating('1');
if (Error::HasErrors())
{
echo Error::ShowErrorMessages();
Error::ClearErrors();
}
else
{
echo $ratingData;
}
?>
<?php
$ratingData = Rating::OutputRating('1','1');
if (Error::HasErrors())
{
echo Error::ShowErrorMessages();
Error::ClearErrors();
}
else
{
echo $ratingData;
}
?>
<?php
$ratingData = Rating::OutputRating('1','2');
if (Error::HasErrors())
{
echo Error::ShowErrorMessages();
Error::ClearErrors();
}
else
{
echo $ratingData;
}
?>
<?php
$ratingData = Rating::OutputRating('1','3');
if (Error::HasErrors())
{
echo Error::ShowErrorMessages();
Error::ClearErrors();
}
else
{
echo $ratingData;
}
?>
</body>
</html>
<?php
Database::DeInitialize();
?>

View File

@ -0,0 +1,85 @@
<?PHP include("config.php");
require_once("rating/classes/include.all.php");
$results = mysql_query("SELECT regionlong FROM ".$prefix."CoachesRegions WHERE regionid = '".intval(mysql_escape_string($_GET[region]))."' LIMIT 1") OR die(mysql_error());
if (mysql_num_rows($results) == 0) {
header('Location: '.$site_url.'?mysql_error');
}
$row = mysql_fetch_array($results);
$regionname = $row[regionlong];
$selected_item = mysql_real_escape_string($_GET[region]);
$results = mysql_query("SELECT gf.coach_id, gf.coach_name, gf.coach_address, gf.coach_address_two, gf.coach_city, gf.coach_state, gf.coach_zip, gf.coach_phone, gf.coach_fax, gf.coach_email, gf.coach_website, gf.coach_certifications
FROM ".$prefix."Coaches AS gf
RIGHT JOIN ".$prefix."CoachesStates AS gts
ON gts.regionid = '".intval(mysql_escape_string($_GET[region]))."' AND gf.coach_state_tag = gts.statetag
WHERE gf.coach_valid = 1 ORDER BY gf.coach_name ASC") OR die(mysql_error());
$none = FALSE;
if (mysql_num_rows($results) == 0) {
$none = TRUE;
}
// set the page title
$pagetitle = $regionname;
// set meta tags
$meta_keywords = "triathlon coaches in ".$regionname;
$meta_description = "Trying to find triathlon coaches in ".$regionname."? Here is a listing of all ".$regionname." triathlon coaches.";
?>
<? include("include_common_head.php"); ?>
<body class="listings">
<? include($common_path . "/ads/ad_wallpaper.html"); ?>
<div class="container">
<? include($common_path . "/templates/include_header.php"); ?>
<div class="main">
<div class="contentwrapper clearfix">
<? include("include_breadcrumb.php"); ?>
<section class="section listings section-has-widgets section-static remove-sidebar">
<div class="sidebar-b">
<? include("include_sidebar.php"); ?>
</div>
<div class="content content-has-widgets">
<div class="grid">
<div class="clearfix">
<h1 class="float-left">Triathlon Coaches</h1>
<a href="<? echo $site_url ?>" class="btn btn-white float-right">Back</a>
<? if (is_logged_in($user)) { ?>
<a href="<? echo $site_url . "/add.php" ?>" class="btn btn-white float-right">Add Coach</a>
<? } ?>
<hr class="line" />
<? include("../runshops/include_region_list.php"); ?>
<h2><? echo $regionname ?> Region</h2>
<hr />
<?
if($none == TRUE){
echo "<p>No triathlon coaches have been entered yet for $regionname.</p>";
}
?>
<? while ($row = mysql_fetch_array($results)) {
include("include_store.php");
} ?>
</div><!-- end col-2/3 -->
</div><!-- end grid -->
</div><!-- end content -->
</section>
</div><!-- end contentwrapper -->
</div> <!-- end main -->
<? include($common_path . "/templates/include_footer.php") ?>
</div> <!-- container -->
</body>
<? include($common_path . "/templates/include_global_js.php") ?>
</html>

229
site/coaches/search.php Normal file
View File

@ -0,0 +1,229 @@
<?PHP include("config.php");
// set the page title
$pagetitle = "Search The Database";
// set meta tags
$meta_keywords = "search coaches";
$meta_description = "Do you want to search for coaches in our online triathlon coach database? Then use this form to enter your criteria.";
?>
<? include("include_common_head.php"); ?>
<?
//Array of states for use in the form
$state_list = mysql_query("SELECT * FROM ".$prefix."CoachesStates");
?>
<body class="listings">
<? include($common_path . "/ads/ad_wallpaper.html"); ?>
<div class="container">
<? include($common_path . "/templates/include_header.php"); ?>
<div class="main">
<div class="contentwrapper clearfix">
<? include("include_breadcrumb.php"); ?>
<section class="section listings section-has-widgets section-static remove-sidebar">
<div class="sidebar-b">
<? include("include_sidebar.php"); ?>
</div>
<div class="content content-has-widgets">
<div class="grid">
<div class="clearfix">
<h1>Search For A Coach</h1>
<p>If you would like to search for a coach, please use the form below. None of the fields are mandatory. Checking no box in a field indicates you don't care if a coach has or does not have certifications, a fit bike, or motion capture system. Checking regions selects all states in that region. Checking any state's box selects or deselects that state.</p>
<form enctype="multipart/form-data" action="search_X.php" method="post" name="searchform">
<p class="cont"><font color="red"><? echo $errmsg; ?></font></p>
<div class="dtable form">
<div class="drow">
<div class="dcell name">Name Search</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input type="text" name="keyword" class="txt lngtext" />
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<h3>Info</h3>
</div>
</div>
<div class="drow">
<div class="dcell name">Certifications</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table width="100%" cellpadding="2" cellspacing="2">
<?
$results = mysql_query("SELECT * FROM gforum_CoachesCertifications ORDER BY coach_certification_id ASC");
$i = 0;
$grouping = 1;
echo("<tr>");
while ($row = mysql_fetch_array($results)) {
if(($grouping != $row[coach_certification_group]) OR !($i%3)) {
if (!($i%3)) echo ("<td width=\"33%\">&nbsp;</td>");
echo "</tr><tr>";
$grouping = $row[coach_certification_group];
$i = 0;
}
echo("<td width=\"33%\"><input type=\"checkbox\" name=\"certifications[]\" value=\"$row[coach_certification_id]\" >$row[coach_certification_name]</td>\n");
$i++;
}
while($i<3) {
echo("<td width=\"33%\">&nbsp;</td>");
$i++;
}
if(!($i%3)) echo "</tr><tr>";
echo("<td width=\"33%\"><input type=\"checkbox\" name=\"certifications[]\" value=\"999\" ><strong>ANY</strong></td>\n");
$i++;
while($i<3) {
echo("<td width=\"33%\">&nbsp;</td>");
$i++;
}
if(!($i%3)) echo "</tr><tr>";
echo("</tr>");
?>
</table>
</div>
</div>
<div class="drow">
<div class="dcell name">Services Offered</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table width="100%" cellpadding="2" cellspacing="2"><?
$results = mysql_query("SELECT * FROM gforum_CoachesServices ORDER BY coach_service_id ASC");
$i = 0;
echo("<tr>");
//echo("<input type=\"hidden\" name=\"services[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
if(!($i%1)) echo "</tr><tr>";
echo("<td width=\"100%\"><input type=\"checkbox\" name=\"services[]\" value=\"$row[coach_service_id]\" >$row[coach_service_name]</td>\n");
$i++;
}
if(!($i%1)) echo "</tr><tr>";
echo("<td width=\"100%\"><input type=\"checkbox\" name=\"services[]\" value=\"999\" ><strong>ANY</strong></td>\n");
echo("</tr>");
?>
</table>
</div>
</div>
<div class="drow">
<div class="dcell name">Education</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table width="100%" cellpadding="2" cellspacing="2"><?
$results = mysql_query("SELECT * FROM gforum_CoachesDegrees ORDER BY coach_degree_id ASC");
$i = 0;
echo("<tr>");
//echo("<input type=\"hidden\" name=\"degree[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
if(!($i%2)) echo "</tr><tr>";
echo("<td><input type=\"checkbox\" name=\"degree[]\" value=\"$row[coach_degree_id]\" >$row[coach_degree_name]</td>\n");
$i++;
}
if(!($i%2)) echo "</tr><tr>";
echo("<td><input type=\"checkbox\" name=\"degree[]\" value=\"999\" ><strong>ANY</strong></td>\n<td>&nbsp;</td>");
echo("</tr>");
?>
</table>
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<h3>Location</h3>
</div>
</div>
<div class="drow">
<div class="dcell name">Region</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table width="100%" cellpadding="2" cellspacing="2">
<?
$regions = array();
$regionsql = "SELECT gts.statetag AS statetag, gtr.regionlong AS regionlong
FROM ".$prefix."CoachesStates AS gts
LEFT JOIN ".$prefix."CoachesRegions AS gtr
ON gts.regionid = gtr.regionid
ORDER BY gtr.regionid";
$region_list = mysql_query($regionsql);
//use loop for check box array
while($row = mysql_fetch_array($region_list)){
if (!is_array($regions[$row[regionlong]])) { $regions[$row[regionlong]] = array(); }
array_push($regions[$row[regionlong]], $row[statetag]);
}
$i = 0;
echo "<tr>";
foreach($regions AS $region => $statetag) {
if(!($i%4)) echo "</tr><tr>";
echo("<td><input type=\"checkbox\" name=\"region\" value=\"$region\" onClick=\"javascript: checkUncheck(this,'".implode("', '", $statetag)."');\">$region</td>\n");
$i++;
}
?>
</tr>
</table>
<p><em>*Selecting a region will select all states in that region. You can then deselect or select any additional states. Only the selected states will be included in your search. Leaving all boxes blank will select races in all states.</em></p>
</div>
</div>
<div class="drow">
<div class="dcell name">State</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table width="100%" cellpadding="2" cellspacing="2">
<? //use loop for check box array
$i = 0;
echo "<tr>";
while($row = mysql_fetch_array($state_list)){
if(!($i%4)) echo "</tr><tr>";
echo "<td><input type='checkbox' id='states' name='states[]' value=\"$row[statetag]\"> $row[statelong]</td>\n";
$i++;
}
?>
</tr>
</table>
<p><em>*Leave blank to select all.</em></p>
</div>
</div>
<div class="drow actions">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<input type="hidden" name="search_form" value="coach">
<input type="submit" value="Search" class="btn default">
</div>
</div>
</div>
</form>
</div><!-- end col-2/3 -->
</div><!-- end grid -->
</div><!-- end content -->
</section>
</div><!-- end contentwrapper -->
</div> <!-- end main -->
<? include($common_path . "/templates/include_footer.php") ?>
</div> <!-- container -->
</body>
<? include($common_path . "/templates/include_global_js.php") ?>
</html>

200
site/coaches/search_X.php Normal file
View File

@ -0,0 +1,200 @@
<?PHP
/** TO DO **
- Allow users to search by start time
- Allow users to search by entry fee
************/
include("config.php");
require_once("rating/classes/include.all.php");
if (!$_POST){ header('Location: '.$site_url); }
// build the SQL query
$sql = "SELECT coach_id, coach_name, coach_address, coach_address_two, coach_city, coach_state, coach_zip, coach_phone, coach_fax, coach_email, coach_website FROM ".$prefix."Coaches WHERE coach_valid=1 ";
// add coaches
if (isset($_POST[certifications])) {
if (in_array("999", $_POST[certifications])) {
$sql = $sql." AND coach_certifications <> ',0,'";
} else {
foreach ($_POST[certifications] AS $value) {
$sql = $sql." AND coach_certifications LIKE '%,$value,%'";
}
}
}
if (isset($_POST[services])) {
if (in_array("999", $_POST[services])) {
$sql = $sql." AND coach_services <> ',0,'";
} else {
foreach ($_POST[services] AS $value) {
$sql = $sql." AND coach_services LIKE '%,$value,%'";
}
}
}
if (isset($_POST[degree])) {
if (in_array("999", $_POST[degree])) {
$sql = $sql." AND coach_degrees <> ',0,'";
} else {
foreach ($_POST[degree] AS $value) {
$sql = $sql." AND coach_degrees LIKE '%,$value,%'";
}
}
}
// regions are checkboxes that then check off all states within that region
// add states
if (isset($_POST[states])) {
$glue = "','";
$statelist = "('".implode($glue, $_POST[states])."')";
$sql = $sql." AND coach_state_tag IN $statelist";
}
$sql = $sql." ORDER BY coach_name ASC";
//echo $sql;
$results = mysql_query($sql) OR die(mysql_error());
$none = FALSE;
if (mysql_num_rows($results) == 0) {
$none = TRUE;
}
$coach_count = mysql_num_rows($results);
//keyword search
// trim redundant keywords: triathlon, duathlon
$trim_words = array(" the ", " a ", " an ", "and ", " half ", "triathlon", "duathlon");
foreach ($trim_words AS $word) {
$_POST['keyword'] = str_ireplace($word, " ", $_POST['keyword']);
}
$bool_Keywords = false;
if (isset($_POST['keyword']) && $_POST['keyword'] != "") {
$bool_Keywords = true;
while($row_coaches = mysql_fetch_array($results)) {
// build an array that we can loop through.
$arr_coaches[$i] = $row_coaches;
$i++;
}
$arr_Matches = array();
foreach ($arr_coaches AS $coach) {
if (stripos($coach['coach_name'], $_POST['keyword']) !== false) {
// push this onto the array of matches
$coach['percent'] = 100;
array_push($arr_Matches, $coach);
} else {
$name_nospace = str_replace(" ", "", $coach['coach_name']);
$keyword_nospace = str_replace(" ", "", $_POST['keyword']);
if (stripos($name_nospace, $keyword_nospace) !== false) {
// push this onto the array of matches
$coach['percent'] = 90;
array_push($arr_Matches, $coach);
} else {
// trim redundant keywords
$coach_name = $coach['coach_name'];
foreach ($trim_words AS $word) {
$coach_name = str_ireplace($word, " ", $coach_name);
}
//$coach_name = str_ireplace(" ", "", $coach_name);
$coach_name = strtolower($coach_name);
$arr_coach_name = explode(" ", $coach_name);
$_POST['keyword'] = strtolower($_POST['keyword']);
$_POST['keyword'] = str_replace(" ", "", $_POST['keyword']);
foreach ($arr_coach_name AS $test_word) {
similar_text($test_word, $_POST['keyword'], $percent);
if ($percent >= 70) {
// push this onto the array of matches
$coach['percent'] = round($percent, 0);
//$coach['trimmed'] = $coach_name;
array_push($arr_Matches, $coach);
break;
}
}
}
}
}
if (count($arr_Matches) == 0) {
$none = TRUE;
}
$coach_count = count($arr_Matches);
//sort the array by keyword match success instead of by date
function cmp($a, $b)
{
if ($a['percent'] == $b['percent']) {
return 0;
}
return ($a['percent'] > $b['percent']) ? -1 : 1;
}
usort($arr_Matches, "cmp");
}
//end keyword search
// set the page title
$pagetitle = "Search Results";
// set meta tags
$meta_keywords = "search, coaches, triathlon, results";
$meta_description = "Triathlon coaches matching a user's search query. A list of matching coaches.";
?>
<? include("include_common_head.php"); ?>
<body class="listings">
<? include($common_path . "/ads/ad_wallpaper.html"); ?>
<div class="container">
<? include($common_path . "/templates/include_header.php"); ?>
<div class="main">
<div class="contentwrapper clearfix">
<? include("include_breadcrumb.php"); ?>
<section class="section listings section-has-widgets section-static remove-sidebar">
<div class="sidebar-b">
<? include("include_sidebar.php"); ?>
</div>
<div class="content content-has-widgets">
<div class="grid">
<div class="clearfix">
<h1>Search Results</h1>
<p><b><? echo $coach_count; ?></b> Coaches Match Your Search</p>
<table border="0" cellspacing="0" cellpadding="1" width="580">
<?
$x = 0;
if ($bool_Keywords == true) {
foreach ($arr_Matches AS $row) {
include("include_store.php");
} //end foreach
} else { //else bool_keyword
while ($row = mysql_fetch_array($results)) {
include("include_store.php");
} //end while ?>
<? } // end if/else ?>
</table>
</div><!-- end col-2/3 -->
</div><!-- end grid -->
</div><!-- end content -->
</section>
</div><!-- end contentwrapper -->
</div> <!-- end main -->
<? include($common_path . "/templates/include_footer.php") ?>
</div> <!-- container -->
</body>
<? include($common_path . "/templates/include_global_js.php") ?>
</html>

View File

@ -0,0 +1,70 @@
<?PHP include("config.php");
require_once("rating/classes/include.all.php");
include("rating/int.to.words.php");
$results = mysql_query("SELECT * FROM `".$prefix."Coaches` AS gf WHERE `coach_certifications` LIKE '%".$st_id."%'") OR die(mysql_error());
$none = FALSE;
if (mysql_num_rows($results) == 0) {
$none = TRUE;
}
// set the page title
$pagetitle = "Slowtwitch Certified Triathlon Coaches";
// set meta tags
$meta_keywords = "slowtwitch certified triathlon coaches";
$meta_description = "coaches who have completed the Slowtwitch coaching certification course.";
?>
<? include("include_common_head.php"); ?>
<body class="listings">
<? include($common_path . "/ads/ad_wallpaper.html"); ?>
<div class="container">
<? include($common_path . "/templates/include_header.php"); ?>
<div class="main">
<div class="contentwrapper clearfix">
<? include("include_breadcrumb.php"); ?>
<section class="section listings section-has-widgets section-static remove-sidebar">
<div class="sidebar-b">
<? $selected_item = 'top'; ?>
<? include("include_sidebar.php"); ?>
</div>
<div class="content content-has-widgets">
<div class="grid">
<div class="clearfix">
<h1>Slowtwitch Certified Coaches</h1>
<hr class="line" />
<? include("../runshops/include_region_list.php"); ?>
<?
if($none == TRUE){
echo "No triathlon coaches have enough votes yet.";
}
?>
<p/>
<? $rating_text = 0;
while($row = mysql_fetch_array($results)) {
include("include_store.php");
} ?>
</div><!-- end col-2/3 -->
</div><!-- end grid -->
</div><!-- end content -->
</section>
</div><!-- end contentwrapper -->
</div> <!-- end main -->
<? include($common_path . "/templates/include_footer.php") ?>
</div> <!-- container -->
</body>
<? include($common_path . "/templates/include_global_js.php") ?>
</html>

131
site/coaches/statelist.php Normal file
View File

@ -0,0 +1,131 @@
<?PHP include("config.php");
require_once("rating/classes/include.all.php");
$results = mysql_query("SELECT coach_state FROM ".$prefix."Coaches WHERE coach_state_tag='".substr(mysql_escape_string($_GET[state]),0,20)."' AND coach_valid = 1 LIMIT 1") OR die(mysql_error());
if (mysql_num_rows($results) == 0) {
header('Location: '.$site_url.'?mysql_error');
}
$row = mysql_fetch_array($results);
$none = FALSE;
$statename = $row[coach_state];
if(mysql_num_rows($results) < 1){
if($statename == "districtofcolumbia"){
$statename = "District of Columbia";
}
if($statename == "centralamerica"){
$statename = "Central America";
}
if(($statename == "newhampshire")){
$statename = "New Hampshire";
}
if($statename == "newjersey"){
$statename = "New Jersey";
}
if($statename == "newmexico"){
$statename = "New Mexico";
}
if($statename == "newyork"){
$statename = "New York";
}
if($statename == "northcarolina"){
$statename = "North Carolina";
}
if($statename == "northdakota"){
$statename = "North Dakota";
}
if($statename == "southcarolina"){
$statename = "South Carolina";
}
if($statename == "southdakota"){
$statename = "South Dakota";
}
if($statename == "westvirginia"){
$statename = "West Virginia";
}
if($statename == "britishcolumbia"){
$statename = "British Columbia";
}
if($statename == "newbrunswick"){
$statename = "New Brunswick";
}
if($statename == "novascotia"){
$statename = "Nova Scotia";
}
if($statename == "princeedwardisland"){
$statename = "Prince Edward Island";
}
$statename = ucfirst($statename);
$none = TRUE;
}
$results = mysql_query("SELECT coach_id, coach_name, coach_address, coach_address_two, coach_city, coach_state, coach_zip, coach_phone, coach_fax, coach_email, coach_website, coach_certifications FROM ".$prefix."Coaches WHERE coach_state_tag='".substr(mysql_escape_string($_GET[state]),0,20)."' AND coach_valid=1 ORDER BY coach_name ASC");
$none = FALSE;
if (mysql_num_rows($results) == 0) {
$none = TRUE;
}
// set the page title
$pagetitle = $statename;
$selected_item = substr(mysql_real_escape_string($_GET[state]),0,20);
// set meta tags
$meta_keywords = "triathlon coaches in ".$statename;
$meta_description = "Trying to find triathlon coaches in ".$statename."? Here is a listing of all ".$statename." triathlon coaches. Users can even rate and comment on these coaches.";
?>
<? include("include_common_head.php"); ?>
<body class="listings">
<? include($common_path . "/ads/ad_wallpaper.html"); ?>
<div class="container">
<? include($common_path . "/templates/include_header.php"); ?>
<div class="main">
<div class="contentwrapper clearfix">
<? include("include_breadcrumb.php"); ?>
<section class="section listings section-has-widgets section-static remove-sidebar">
<div class="sidebar-b">
<? include("include_sidebar.php"); ?>
</div>
<div class="content content-has-widgets">
<div class="grid">
<div class="clearfix">
<h1 class="float-left">Triathlon Coaches</h1>
<a href="<? echo $site_url ?>" class="btn btn-white float-right">Back</a>
<? if (is_logged_in($user)) { ?>
<a href="<? echo $site_url . "/add.php" ?>" class="btn btn-white float-right">Add Coach</a>
<? } ?>
<hr class="line" />
<? include("../runshops/include_region_list.php"); ?>
<h2><? echo $statename ?> State</h2>
<hr />
<?
if($none == TRUE){
echo "No triathlon coaches have been entered yet for $statename.";
}
?>
<? while ($row = mysql_fetch_array($results)) {
include("include_store.php");
} ?>
</div><!-- end col-2/3 -->
</div><!-- end grid -->
</div><!-- end content -->
</section>
</div><!-- end contentwrapper -->
</div> <!-- end main -->
<? include($common_path . "/templates/include_footer.php") ?>
</div> <!-- container -->
</body>
<? include($common_path . "/templates/include_global_js.php") ?>
</html>

70
site/coaches/top.php Normal file
View File

@ -0,0 +1,70 @@
<?PHP include("config.php");
require_once("rating/classes/include.all.php");
include("rating/int.to.words.php");
$results = mysql_query("SELECT COUNT(DISTINCT(gfr.rating_ip)) AS respondents, ROUND(AVG(gfr.rating_vote), 2) AS score, COUNT(gfr.rating_vote) AS votes, gf.coach_id, gf.coach_name, gf.coach_address, gf.coach_address_two, gf.coach_city, gf.coach_state, gf.coach_zip, gf.coach_phone, gf.coach_fax, gf.coach_email, gf.coach_website FROM ".$prefix."CoachesRating AS gfr RIGHT JOIN ".$prefix."Coaches AS gf ON gf.coach_id = gfr.coach_id_fk GROUP BY gfr.coach_id_fk HAVING COUNT(gfr.rating_vote) > 10 ORDER BY score DESC, votes DESC LIMIT 10") OR die(mysql_error());
$none = FALSE;
if (mysql_num_rows($results) == 0) {
$none = TRUE;
}
// set the page title
$pagetitle = "Top Triathlon Coaches";
// set meta tags
$meta_keywords = "top ranked triathlon coaches";
$meta_description = "Top ranked triathlon coaches based on rankings submitted by the user.";
?>
<? include("include_common_head.php"); ?>
<body class="listings">
<? include($common_path . "/ads/ad_wallpaper.html"); ?>
<div class="container">
<? include($common_path . "/templates/include_header.php"); ?>
<div class="main">
<div class="contentwrapper clearfix">
<? include("include_breadcrumb.php"); ?>
<section class="section listings section-has-widgets section-static remove-sidebar">
<div class="sidebar-b">
<? $selected_item = 'top'; ?>
<? include("include_sidebar.php"); ?>
</div>
<div class="content content-has-widgets">
<div class="grid">
<div class="clearfix">
<h1>Top Ranked Triathlon Coaches</h1>
<hr class="line" />
<? include("../runshops/include_region_list.php"); ?>
<?
if($none == TRUE){
echo "No triathlon coaches have enough votes yet.";
}
?>
<p/>
<? $rating_text = 1;
while($row = mysql_fetch_array($results)) {
include("include_store.php");
} ?>
</div><!-- end col-2/3 -->
</div><!-- end grid -->
</div><!-- end content -->
</section>
</div><!-- end contentwrapper -->
</div> <!-- end main -->
<? include($common_path . "/templates/include_footer.php") ?>
</div> <!-- container -->
</body>
<? include($common_path . "/templates/include_global_js.php") ?>
</html>

88
site/coaches/validate.php Normal file
View File

@ -0,0 +1,88 @@
<?PHP
include("config.php");
if(!is_admin($user)){
header('Location:'.$site_url.'/');
}
// Query to fetch non-validated races:
$results = mysql_query("SELECT coach_id, coach_name, coach_address, coach_address_two, coach_city, coach_state, coach_phone, coach_fax, coach_zip, coach_email, coach_website FROM ".$prefix."Coaches WHERE coach_valid=0 ORDER BY coach_name ASC");
// check to see if set is empty
$none = FALSE;
if (mysql_num_rows($results) == 0) { $none = TRUE; }
// set the page title
$pagetitle = "Admin: Coach Validation";
// set meta tags
$meta_keywords = "";
$meta_description = "";
?>
<? include("include_common_head.php"); ?>
<body class="listings">
<? include($common_path . "/ads/ad_wallpaper.html"); ?>
<div class="container">
<? include($common_path . "/templates/include_header.php"); ?>
<div class="main">
<div class="contentwrapper clearfix">
<? include("include_breadcrumb.php"); ?>
<section class="section listings section-has-widgets">
<div class="sidebar-b">
<? include("include_sidebar.php"); ?>
</div>
<div class="content content-has-widgets">
<div class="grid">
<div class="clearfix">
<h1><strong>Unvalidated Coaches</strong></h1>
<form method="post" action="validate_X.php" enctype="multipart/form-data">
<?
if($none == TRUE){
echo "There are no coaches waiting to be validated.";
}
?>
<div class="dtable">
<? while($row = mysql_fetch_array($results)){ ?>
<div class="drow"><div class="dcell"><a class="sub-hdr" style="margin-left: 5px;" href="<? echo "individual.php?coach_id=$row[coach_id]"; ?>"><? echo $row[coach_name]; ?></a></div></div>
<div class="drow"><div class="dcell">Address: <? echo ("$row[coach_address]"); if($row[coach_address_two]) { echo ("<br /><span class='indent'>$row[coach_address_two]</span>"); } echo("<br /><span class='indent'>$row[coach_city], $row[coach_state] $row[coach_zip]</span>"); ?></div></div>
<div class="drow">
<div class="dcell">
<?
echo "Phone: </strong>$row[coach_phone]<br /><strong class='indent'>Fax/Alt Phone: </strong> $row[coach_fax]";
?>
</div>
</div>
<div class="drow">
<div class="dcel">
<strong>Website:</strong> <? echo "<a href='$row[coach_website]' target='_blank'>$row[coach_website]</a>"; ?>
<br>
<a class="nav" href="<? echo "individual.php?coach_id=$row[coach_id]"; ?>">More information</a>
<br /><input type="checkbox" value="<? echo($row[coach_id]); ?>" name="validate[]"> Validate this coach. <input type="checkbox" value="<? echo($row[coach_id]); ?>" name="delete[]"> Delete this coach.
</div>
</div>
<? } ?>
</div>
<input type="submit" value="Validate Selected Coaches" class="btn">
</form>
</div><!-- end col-2/3 -->
</div><!-- end grid -->
</div><!-- end content -->
</section>
</div><!-- end contentwrapper -->
</div> <!-- end main -->
<? include($common_path . "/templates/include_footer.php") ?>
</div> <!-- container -->
</body>
<? include($common_path . "/templates/include_global_js.php") ?>
</html>

View File

@ -0,0 +1,35 @@
<?PHP
include("config.php");
if (!$_POST){ header('Location: '.$site_url); }
// error checking
if(!isset($_POST)) exit();
if (isset($_POST[delete])) {
// convert the array to a SQL friendly format
$deleteList = "(".implode(",", $_POST[delete]).")";
// build the SQL query to delete the edits that are bad
$sql = "DELETE FROM ".$prefix."Coaches WHERE coach_id IN $deleteList";
mysql_query($sql) or die(mysql_error());
}
if (isset($_POST[validate])) {
// convert the array to a SQL friendly format
$idlist = "(".implode(",", $_POST[validate]).")";
// build the SQL query
$sql = "UPDATE ".$prefix."Coaches
SET coach_valid = 1
WHERE coach_id IN $idlist;";
mysql_query($sql) or die(mysql_error());
}
header('Location: '.$site_url.'/validate.php');
?>

View File

@ -0,0 +1,21 @@
<?PHP
if (eregi("wiki_buttons.php", $_SERVER['SCRIPT_NAME'])) {
Header("Location: index.php"); die();
}
?>
<div>
<form method="post" action="wiki_validate_X.php" style="display: inline;">
<input type="hidden" name="validate[]" value="<? echo($row[edit_id]); ?>" />
<input type="submit" value="Validate This Edit" class="btn" onclick="return confirm('Are you sure you want to VALIDATE this coach?');" />
</form>
<form method="post" action="wiki_validate_X.php" style="display: inline;">
<input type="hidden" name="delete[]" value="<? echo($row[edit_id]); ?>" />
<input type="submit" value="Delete This Edit" class="btn" onclick="return confirm('Are you sure you want to DELETE this coach?');" />
</form>
</div>

587
site/coaches/wiki_edit.php Normal file
View File

@ -0,0 +1,587 @@
<?PHP
include("config.php");
if(!isset($_GET[coach_id]) AND !$_POST AND !is_numeric($_GET[coach_id])) {
header('Location: '.$site_url.'/?error=no_id_or_no_post');
exit();
}
if(!is_logged_in($user)){
header('Location: '.$site_url.'/?error=not_logged_in_one');
exit();
}
// Populate with post data or populate with edit return data
if (isset($_POST['edit_return']) || isset($_POST['edit_coach'])) {
$row = $_POST;
} else {
$coach_idhere = intval(mysql_escape_string($_GET[coach_id]));
$results = mysql_query("SELECT * FROM ".$prefix."Coaches WHERE coach_id='".$coach_idhere."'");
$row = mysql_fetch_array($results) OR die(mysql_error());
}
//Get user's session data information
$username = base64_decode($_SESSION['user']);
$useruid = base64_decode($_SESSION['user_id']);
if ($username != "Slowman" && $username != "Rappstar" && $username != "Herbert") {
if ( $row[coach_valid] != 1 ) {
header('Location: '.$site_url.'/?error=coach_not_valid');
exit();
}
}
// set the page title
$pagetitle = "Edit A Triathlon Coach";
// set meta tags
$meta_keywords = "edit a triathlon coach";
$meta_description = "edit screen for triathlon coach information";
?>
<? include("include_common_head.php"); ?>
<?
if($_POST[edit_coach] == true){
include("wiki_edit_X.php");
}
?>
<body class="listings">
<? include($common_path . "/ads/ad_wallpaper.html"); ?>
<div class="container">
<? include($common_path . "/templates/include_header.php"); ?>
<div class="main">
<div class="contentwrapper clearfix">
<? include("include_breadcrumb.php"); ?>
<section class="section listings section-has-widgets section-static remove-sidebar">
<div class="sidebar-b">
<? include("include_sidebar.php"); ?>
</div>
<div class="content content-has-widgets">
<div class="grid">
<div class="clearfix">
<? if( $confirm_coach == true ) { ?>
<h1 class="content-title"><strong>Edit a Coach: Step 2 of 2</strong></h1>
<? }else if( ($confirm_coach != true) || ($_POST[edit_coach] != true) ){ ?>
<h1 class="content-title"><strong>Edit a Coach: Step 1 of 2</strong></h1>
<? if (!$errmsg) { ?>
<p class="cont"><p class="cont">To edit a coach, simply change the data you wish. If you make a mistake, just hit the reset button. <span style="color: red;">To save the changes as a NEW coach (for instance, if you have multiple chapters), hit the "SAVE AS A NEW COACH" button. To save changes to the existing coach entry, hit the "SAVE CHANGES TO YOUR COACH" button. You will have a chance to review the data before confirming.</span> <span style="color: red;">You will then be prompted to confirm your information before the information is sent to us.</span></p>
<? } else { ?>
<p class="cont"><span style="color: red;"><? echo $errmsg; ?></span></p>
<? } ?>
<? }
// begin insert form
if( ($_POST[edit_coach] != true) || ($errmsg) || (($confirm_coach != true) && ($_POST[insert_coach] != true)) ) {
?>
<form enctype="multipart/form-data" action="wiki_edit.php" method="post">
<div class="dtable form">
<div class="drow">
<div class="dcell name">Name</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes($row[coach_name]); ?>" type="text" name="coach_name" class="txt lngtext">
</div>
</div>
<div class="drow">
<div class="dcell name">Street Address</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($row[coach_address])); ?>" type="text" name="coach_address" class="txt lngtext">
</div>
</div>
<div class="drow">
<div class="dcell name">Street Address Two (Optional)</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($row[coach_address_two])); ?>" type="text" name="coach_address_two" class="txt lngtext">
</div>
</div>
<div class="drow">
<div class="dcell name">City</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($row[coach_city])); ?>" type="text" name="coach_city" class="txt smltext">
</div>
</div>
<div class="drow">
<div class="dcell name">State</div>
<div class="dcell divider"></div>
<div class="dcell value">
<SELECT name="coach_state">
<OPTION value="0">Choose a State/Province/Country</OPTION>
<? //use loop for dropdown box of states
foreach($state_list as $key=>$value){
if(strcmp($row[coach_state], $value) == 0){
$str = " selected=\"selected\"";
}
echo "<option value=\"$value\"$str>$value</option>";
$str = "";
}
?>
</SELECT>
</div>
</div>
<div class="drow">
<div class="dcell name">Zip/Postal Code</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($row[coach_zip])); ?>" type="text" name="coach_zip" class="txt smltext">
</div>
</div>
<div class="drow">
<div class="dcell name">Phone</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($row[coach_phone])); ?>" type="text" name="coach_phone" class="txt smltext">
</div>
</div>
<div class="drow">
<div class="dcell name">Fax/Alternate Phone</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($row[coach_fax])); ?>" type="text" name="coach_fax" class="txt smltext">
</div>
</div>
<div class="drow">
<div class="dcell name">E-mail</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo stripslashes(htmlspecialchars($row[coach_email])); ?>" type="text" name="coach_email" class="txt medtext">
</div>
</div>
<div class="drow">
<div class="dcell name">Website</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input value="<? echo $row[coach_website]; ?>" type="text" name="coach_website" size="30" maxlength="200" class="txt lngtext">
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<h3>Info</h3>
</div>
</div>
<div class="drow">
<div class="dcell name">Certifiations</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table cellpadding=0 cellspacing=0 width="100%"><?
$explosion = array("");
if (!is_array($row[coach_certifications])){ $explosion = explode(",", $row[coach_certifications]); } else { $explosion = $row[coach_certifications]; }
$fetch = mysql_query("SELECT * FROM ".$prefix."CoachesCertifications ORDER BY coach_certification_group ASC, coach_certification_id ASC") OR die(mysql_error());
$i = 0;
$grouping = 1;
echo("<tr>");
echo("<input type=\"hidden\" name=\"coach_certifications[]\" value=\"0\" >");
while ($list = mysql_fetch_array($fetch)) {
if(($grouping != $list[coach_certification_group]) OR !($i%3)) {
if (!($i%3)) echo ("<td width=\"33%\">&nbsp;</td>");
echo "</tr><tr>";
$grouping = $list[coach_certification_group];
$i = 0;
}
echo("<td width=\"33%\"><input type=\"checkbox\" name=\"coach_certifications[]\" value=\"$list[coach_certification_id]\" ");
if (in_array($list[coach_certification_id], $explosion)){ echo "checked "; }
echo(">$list[coach_certification_name]</td>\n");
$i++;
}
while ($i<3) {
echo ("<td width=\"33%\">&nbsp;</td>\n");
$i++;
}
echo("</tr>");
?>
</table>
</div>
</div>
<div class="drow">
<div class="dcell name">Service</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table cellpadding=0 cellspacing=0 width="100%"><?
$explosion = array("");
if (!is_array($row[coach_services])){ $explosion = explode(",", $row[coach_services]); } else { $explosion = $row[coach_services]; }
$fetch = mysql_query("SELECT * FROM ".$prefix."CoachesServices ORDER BY coach_service_id ASC");
$i = 0;
echo("<tr>");
echo("<input type=\"hidden\" name=\"coach_services[]\" value=\"0\" >");
while ($list = mysql_fetch_array($fetch)) {
if(!($i%1)) echo "</tr><tr>";
echo("<td width=\"100%\"><input type=\"checkbox\" name=\"coach_services[]\" value=\"$list[coach_service_id]\" ");
if (in_array($list[coach_service_id], $explosion)){ echo "checked "; }
echo(">$list[coach_service_name]</td>\n");
$i++;
}
echo("</tr>");
?>
</table>
</div>
</div>
<div class="drow">
<div class="dcell name">Education</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table cellpadding=0 cellspacing=0 width="100%"><?
$explosion = array("");
if (!is_array($row[coach_degrees])){ $explosion = explode(",", $row[coach_degrees]); } else { $explosion = $row[coach_degrees]; }
$fetch = mysql_query("SELECT * FROM ".$prefix."CoachesDegrees ORDER BY coach_degree_id ASC");
$i = 0;
echo("<tr>");
echo("<input type=\"hidden\" name=\"coach_degrees[]\" value=\"0\" >");
while ($list = mysql_fetch_array($fetch)) {
if(!($i%2)) echo "</tr><tr>";
echo("<td width=\"50%\"><input type=\"checkbox\" name=\"coach_degrees[]\" value=\"$list[coach_degree_id]\" ");
if (in_array($list[coach_degree_id], $explosion)){ echo "checked "; }
echo(">$list[coach_degree_name]</td>\n");
$i++;
}
echo("</tr>");
?>
</table>
</div>
</div>
<div class="drow">
<div class="dcell name">General Info</div>
<div class="dcell divider"></div>
<div class="dcell value">
<textarea name="coach_info" cols="45" class="txt lngtext"><? if($row[coach_info]){ echo strip_tags(stripslashes($row[coach_info])); }else{ echo("Please write some information about your coaching business."); } ?></textarea>
</div>
</div>
<div class="drow">
<div class="dcell name">Rates &amp; Fees</div>
<div class="dcell divider"></div>
<div class="dcell value">
<textarea name="coach_cost" rows="7" class="txt lngtext"><? if($row[coach_cost]){ echo strip_tags(stripslashes($row[coach_cost])); }else{ echo("Please describe your rates and fees."); } ?></textarea>
</div>
</div>
<div class="drow">
<div class="dcell name">Camps</div>
<div class="dcell divider"></div>
<div class="dcell value">
<textarea name="coach_camps" rows="7" class="txt lngtext"><? if($row[coach_camps]){ echo strip_tags(stripslashes($row[coach_camps])); }else{ echo("Please describe any training camps you put on."); } ?></textarea>
</div>
</div>
<div class="drow actions">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<input type="submit" name="save_changes" value="Save Changes" class="btn">
<input type="submit" name="new_coach" value="Save As A New Coach" class="btn">
<input type="reset" value="Reset" class="btn">
<input type="hidden" name="edit_coach" value="true">
<input type="hidden" name="coach_id" value="<? echo($row[coach_id]); ?>">
<? // need to temporary set the field as being valid ?>
<input type="hidden" name="coach_valid" value="1">
<input type="hidden" name="coach_submitted_by" value="<? echo($row[coach_submitted_by]); ?>">
<input type="hidden" name="edited_by" value="<? echo($useruid); ?>">
</div>
</div>
</div>
</form>
<? }
// end insert form
// begin confirmation form
if($confirm_coach == true){
?>
<div class="indent">
Please confirm your information. If everything is correct, click the submit button. Otherwise, you may click the edit button to change your information before submitting.</div>
<br />
<div class="dtable form">
<div class="drow">
<div class="dcell name">Name</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes($_POST[coach_name]); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Street Address</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[coach_address])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Street Address Two</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[coach_address_two])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">City</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[coach_city])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">State</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[coach_state])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Zip/Postal Code</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[coach_zip])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Phone</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[coach_phone])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Fax/Alternate Phone</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[coach_fax])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">E-mail</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[coach_email])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Website</div>
<div class="dcell divider"></div>
<div class="dcell value">
<a href="<? echo $_POST[coach_website]; ?>" target="_blank"><? echo $_POST[coach_website]; ?></a>
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<h3>Info</h3>
</div>
</div>
<div class="drow">
<div class="dcell name">Certifications</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
$explosion = implode(",", $_POST[coach_certifications]);
$sql = ("SELECT * FROM ".$prefix."CoachesCertifications WHERE coach_certification_id IN ($explosion) ORDER BY coach_certification_name ASC");
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$certification_list = "";
while ($list = mysql_fetch_array($fetch)) {
$certification_list = $certification_list."$list[coach_certification_name], ";
}
$certification_list = rtrim($certification_list, ', ');
echo $certification_list;
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Services</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
$explosion = implode(",", $_POST[coach_services]);
$sql = ("SELECT * FROM ".$prefix."CoachesServices WHERE coach_service_id IN ($explosion) ORDER BY coach_service_name ASC");
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$service_list = "";
while ($list = mysql_fetch_array($fetch)) {
$service_list = $service_list."$list[coach_service_name], ";
}
$service_list = rtrim($service_list, ', ');
echo $service_list;
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Education</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
$explosion = implode(",", $_POST[coach_degrees]);
$sql = ("SELECT * FROM ".$prefix."CoachesDegrees WHERE coach_degree_id IN ($explosion) ORDER BY coach_degree_name ASC");
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$degree_list = "";
while ($list = mysql_fetch_array($fetch)) {
$degree_list = $degree_list."$list[coach_degree_name], ";
}
$degree_list = rtrim($degree_list, ', ');
echo $degree_list;
?>
</div>
</div>
<div class="drow">
<div class="dcell name">General Info</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo strip_tags(stripslashes($_POST[coach_info])) ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Rates &amp; Fees</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo strip_tags(stripslashes($_POST[coach_cost])) ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Camps</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo strip_tags(stripslashes($_POST[coach_camps])) ?>
</div>
</div>
<div class="drow actions">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<form action="wiki_edit.php" method="post">
<input type="hidden" name="coach_name" value="<? echo stripslashes(htmlspecialchars($_POST[coach_name])); ?>">
<input type="hidden" name="coach_address" value="<? echo stripslashes(htmlspecialchars($_POST[coach_address])); ?>">
<input type="hidden" name="coach_address_two" value="<? echo stripslashes(htmlspecialchars($_POST[coach_address_two])); ?>">
<input type="hidden" name="coach_city" value="<? echo stripslashes(htmlspecialchars($_POST[coach_city])); ?>">
<input type="hidden" name="coach_state" value="<? echo $_POST[coach_state]; ?>">
<input type="hidden" name="coach_zip" value="<? echo $_POST[coach_zip]; ?>">
<input type="hidden" name="coach_phone" value="<? echo $_POST[coach_phone]; ?>">
<input type="hidden" name="coach_fax" value="<? echo $_POST[coach_fax]; ?>">
<input type="hidden" name="coach_email" value="<? echo $_POST[coach_email]; ?>">
<input type="hidden" name="coach_website" value="<? echo $_POST[coach_website]; ?>">
<input type="hidden" name="coach_certifications" value="<? echo(implode(',', $_POST[coach_certifications])); ?>">
<input type="hidden" name="coach_services" value="<? echo(implode(',', $_POST[coach_services])); ?>">
<input type="hidden" name="coach_degrees" value="<? echo(implode(',', $_POST[coach_degrees])); ?>">
<input type="hidden" name="coach_cost" value="<? echo stripslashes(htmlspecialchars($_POST[coach_cost])); ?>">
<input type="hidden" name="coach_info" value="<? echo stripslashes(htmlspecialchars($_POST[coach_info])); ?>">
<input type="hidden" name="coach_camps" value="<? echo stripslashes(htmlspecialchars($_POST[coach_camps])); ?>">
<? // need to temporary set the field as being valid ?>
<input type="hidden" name="coach_valid" value="1">
<input type="hidden" name="edit_coach" value="true">
<input type="hidden" name="insert_coach" value="true">
<input type="hidden" name="coach_submitted_by" value="<? echo $useruid; ?>" >
<? if(isset($_POST[new_coach])){ ?>
This data will be saved as a NEW COACH.
<input type="hidden" name="new_coach" value="1" />
<input type="hidden" name="coach_submitted_by" value="<? echo($_POST[edited_by]); ?>" />
<? } else { ?>
This data will be saved as a modification to the EXISTING COACH.
<input type="hidden" name="save_changes" value="1" />
<input type="hidden" name="edited_by" value="<? echo($_POST[edited_by]); ?>">
<input type="hidden" name="coach_submitted_by" value="<? echo($_POST[coach_submitted_by]); ?>" />
<input type="hidden" name="coach_id" value="<? echo($_POST[coach_id]); ?>" />
<? } ?>
<br><input type="submit" name="coach_submit" value="Submit Info" class="btn float-left" style="margin-right: 5px">
</form>
<form action="wiki_edit.php" method="post">
<input type="hidden" name="coach_name" value="<? echo stripslashes(htmlspecialchars($_POST[coach_name])); ?>">
<input type="hidden" name="coach_address" value="<? echo stripslashes(htmlspecialchars($_POST[coach_address])); ?>">
<input type="hidden" name="coach_address_two" value="<? echo stripslashes(htmlspecialchars($_POST[coach_address_two])); ?>">
<input type="hidden" name="coach_city" value="<? echo stripslashes(htmlspecialchars($_POST[coach_city])); ?>">
<input type="hidden" name="coach_state" value="<? echo $_POST[coach_state]; ?>">
<input type="hidden" name="coach_zip" value="<? echo $_POST[coach_zip]; ?>">
<input type="hidden" name="coach_phone" value="<? echo $_POST[coach_phone]; ?>">
<input type="hidden" name="coach_fax" value="<? echo $_POST[coach_fax]; ?>">
<input type="hidden" name="coach_email" value="<? echo $_POST[coach_email]; ?>">
<input type="hidden" name="coach_website" value="<? echo $_POST[coach_website]; ?>">
<input type="hidden" name="coach_certifications" value="<? echo(implode(',', $_POST[coach_certifications])); ?>">
<input type="hidden" name="coach_services" value="<? echo(implode(',', $_POST[coach_services])); ?>">
<input type="hidden" name="coach_degrees" value="<? echo(implode(',', $_POST[coach_degrees])); ?>">
<input type="hidden" name="coach_cost" value="<? echo stripslashes(htmlspecialchars($_POST[coach_cost])); ?>">
<input type="hidden" name="coach_info" value="<? echo stripslashes(htmlspecialchars($_POST[coach_info])); ?>">
<input type="hidden" name="coach_camps" value="<? echo stripslashes(htmlspecialchars($_POST[coach_camps])); ?>">
<input type="hidden" name="confirm_coach" value="0">
<input type="hidden" name="edit_return" value="true">
<? // need to temporary set the field as being valid ?>
<input type="hidden" name="coach_valid" value="1">
<input type="hidden" name="coach_id" value="<? echo($_POST[coach_id]); ?>" />
<input type="hidden" name="coach_submitted_by" value="<? echo $submitted_by; ?>">
<input type="submit" name="submit" value="Edit Information" class="btn btn-left">
</form>
</div>
</div>
</div>
<?
}
//end confirmation form
?>
</div><!-- end col-2/3 -->
</div><!-- end grid -->
</div><!-- end content -->
</section>
</div><!-- end contentwrapper -->
</div> <!-- end main -->
<? include($common_path . "/templates/include_footer.php") ?>
</div> <!-- container -->
</body>
<? include($common_path . "/templates/include_global_js.php") ?>
</html>

View File

@ -0,0 +1,124 @@
<?PHP
if (!$_POST){ header('Location: '.$site_url.'/?error=no_post'); }
/*
FIELD NAMES:
coach_id
coach_name
coach_name_tag
coach_address
coach_address_two
coach_city
coach_state
coach_state_tag
coach_zip
coach_phone
coach_fax
coach_email
coach_website
coach_certifications
coach_services
coach_degrees
coach_cost
coach_info
coach_camps
coach_submitted_by
coach_valid
coach_user_tags
*/
/* Need to ltrim and rtrim commas before insertion */
//Insert into database
$errmsg = NULL;
//Check for blank fields
if ((!$_POST[coach_name])) $errmsg = $errmsg."Shop name, ";
if (!$_POST[coach_city]) $errmsg = $errmsg."City, ";
if (!$_POST[coach_state]) $errmsg = $errmsg."State, ";
if (!$_POST[coach_address]) $errmsg = $errmsg."Address, ";
if (!$_POST[coach_phone]) $errmsg = $errmsg."Phone, ";
if (!$_POST[coach_email]) $errmsg = $errmsg."Email, ";
if (!$_POST[coach_website]) $errmsg = $errmsg."Website, ";
if (strlen($_POST[coach_cost]) < 4) $errmsg = $errmsg."Rates &amp; Fees, ";
if (strlen($_POST[coach_info]) < 4) $errmsg = $errmsg."General Info, ";
if (strlen($_POST[coach_camps]) < 4) $errmsg = $errmsg."Camps, ";
if (isset($errmsg)) {
$errmsg = "The following fields cannot be left blank: ".$errmsg."<br />";
$errmsg = rtrim($errmsg, ", ");
}
$start_url = "(http(s)?\:\/\/)?"; // start url
$dots = "([\w_-]{2,}\.)+"; // one or more parts containing a '.' at the end
$last_part = "([\w_-]{2,})"; // last part doesn't contain a dot
$user = "((\/)(\~)[\w_=-]+)?((\/)[\w_=-]+)*"; // maybe subdirectories - possibly with user ~
$end = "((\/)|(\/)[\w_-]+\.[\w]{2,})?"; // maybe a slash at the end or slash+file+extension
$qstring1 = "((\?[\w_-]+\=([^\#]+)){0,1}"; // querystring - first argument (?a=b)
$qstring2 = "(\&[\w_-]+\=([^\#]+))*)?"; // querystring - following arguments (&c=d)
$bkmrk = "(#[\w_-]+)?"; // bookmark
$exp = "/^".$start_url.$dots.$last_part.$user.$end.$qstring1.$qstring2.$bkmrk."$/i";
if( !preg_match($exp, $_POST[coach_website]) ) {
// Contains invalid characters.
$errmsg = $errmsg."Invalid Web Address<br />";
}
if( preg_match('/[^a-zA-Z0-9\. ]/', $_POST[coach_name]) ) {
// Contains invalid characters.
$errmsg = $errmsg."Please use only letters and numbers in the name<br />";
}
if(!$errmsg){
$name = trim($_POST[coach_name]);
$name_tag = strtolower(str_replace(" ","", $name));
if(strlen($nametag) > 12){ //Shorten it
$name_tag = substr($nametag, 0, 12);
}
$address = mysql_escape_string(trim($_POST[coach_address]));
if (isset($_POST['coach_address_two'])) { $address_two = mysql_escape_string(trim($_POST[coach_address_two])); } else { $address_two = NULL; }
$city = mysql_escape_string(trim($_POST[coach_city]));
$state = $_POST[coach_state];
$state_tag = strtolower(str_replace(" ","", $state));
$zip = mysql_escape_string(trim($_POST[coach_zip]));
$phone = trim($_POST[coach_phone]);
$fax = trim($_POST[coach_fax]);
$email = mysql_escape_string(trim($_POST[coach_email]));
$website = mysql_escape_string(trim($_POST[coach_website]));
$certifications = $_POST[coach_certifications];
$services = $_POST[coach_services];
$degrees = $_POST[coach_degrees];
$cost = mysql_escape_string(nl2br(substr(trim($_POST[coach_cost]), 0, 4096)));
$info = mysql_escape_string(nl2br(substr(trim($_POST[coach_info]), 0, 4096)));
$camps = mysql_escape_string(nl2br(substr(trim($_POST[coach_camps]), 0, 4096)));
$submitted_by = $_POST[coach_submitted_by];
$id = $_POST[coach_id];
$edited_by = $_POST[edited_by];
$edit_timestamp = time();
// BEGIN CONFIRM ENTRY CHECK
if($_POST[insert_coach] == true){
if(isset($_POST[new_coach])){
$sql = "INSERT INTO ".$prefix."Coaches (coach_name, coach_name_tag, coach_address, coach_address_two, coach_city, coach_state, coach_state_tag, coach_zip, coach_phone, coach_fax, coach_email, coach_website, coach_certifications, coach_services, coach_degrees, coach_cost, coach_info, coach_camps, coach_submitted_by, coach_valid) VALUES ('$name', '$name_tag', '$address', '$address_two', '$city', '$state', '$state_tag', '$zip', '$phone', '$fax', '$email', '$website', ',$certifications,', ',$services,', ',$degrees,', '$cost', '$info', '$camps', $submitted_by, 0)";
//echo("coach entered!");
//echo($sql);
mysql_query($sql) OR die(mysql_error());
header('Location: '.$site_url.'/add.php?confirmed=yes');
} elseif(isset($_POST[save_changes])) {
$sql = "INSERT INTO ".$prefix."CoachesEdits (coach_id_fk, editor_user_id_fk, edit_timestamp, coach_name, coach_name_tag, coach_address, coach_address_two, coach_city, coach_state, coach_state_tag, coach_zip, coach_phone, coach_fax, coach_email, coach_website, coach_certifications, coach_services, coach_degrees, coach_cost, coach_info, coach_camps, coach_submitted_by, coach_valid) VALUES ('$id', '$edited_by', '$edit_timestamp', '$name', '$name_tag', '$address', '$address_two', '$city', '$state', '$state_tag', '$zip', '$phone', '$fax', '$email', '$website', ',$certifications,', ',$services,', ',$degrees,', '$cost', '$info', '$camps', $submitted_by, 0)";
//echo $sql;
//exit;
mysql_query($sql) OR die(mysql_error());
header('Location: '.$site_url.'/individual.php?coach_id='.$id.'&wiki_change=success');
} else {
header('Location: '.$site_url.'/individual.php?coach_id='.$id.'&changes=failure');
}
} else {
//echo("coach NOT entered.");
$confirm_coach = true;
}
// END CONFIRM ENTRY CHECK
}
// END ERROR MESSAGE CHECK
?>

View File

@ -0,0 +1,92 @@
<?PHP include("config.php");
if(!is_admin($user)){
header('Location:'.$site_url.'/');
}
// Query to fetch non-validated coaches:
$results = mysql_query("SELECT edit_id, coach_name, coach_city, coach_state, coach_info, edit_timestamp, coach_submitted_by, editor_user_id_fk FROM ".$prefix."CoachesEdits ORDER BY edit_timestamp ASC");
// check to see if set is empty
$none = FALSE;
if (mysql_num_rows($results) == 0) { $none = TRUE; }
// set the page title
$pagetitle = "Admin: Coach Edit Validation";
// set meta tags
$meta_keywords = "";
$meta_description = "";
?>
<? include("include_common_head.php"); ?>
<body class="listings">
<? include($common_path . "/ads/ad_wallpaper.html"); ?>
<div class="container">
<? include($common_path . "/templates/include_header.php"); ?>
<div class="main">
<div class="contentwrapper clearfix">
<? include("include_breadcrumb.php"); ?>
<section class="section listings section-has-widgets">
<div class="sidebar-b">
<? include("include_sidebar.php"); ?>
</div>
<div class="content content-has-widgets">
<div class="grid">
<div class="clearfix">
<h1><strong>Unvalidated Public Edits</strong></h1>
<form method="post" action="wiki_validate_X.php" enctype="multipart/form-data">
<?
if($none == TRUE){
echo "There are no edits waiting to be validated.";
}
?>
<div class="dtable">
<?
while($row = mysql_fetch_array($results)){
$arrEditors = mysql_fetch_array(mysql_query("SELECT user_username FROM ".$prefix."User WHERE user_id = ".$row[editor_user_id_fk]." LIMIT 1"));
$editor_user_username = $arrEditors[user_username];
$boolEditorIsOwner = false;
if ($row[editor_user_id_fk] == $row[coach_submitted_by]) { $boolEditorIsOwner = true; }
?>
<div class="drow"><div class="dcell"><a class="sub-hdr" style="margin-left: 5px;" href="<? echo "wiki_view.php?edit_id=$row[edit_id]"; ?>"><? echo $row[coach_name]; ?></a></div></div>
<div class="drow"><div class="dcell"><strong class="indent">Edited on:</strong> <? echo date("F j, Y", $row[edit_timestamp]); ?> by <? echo "<a href=\"http://forum.slowtwitch.com/gforum.cgi?username=".$editor_user_username.";\" target=\"_blank\">".$editor_user_username."</a>"; if ($boolEditorIsOwner) { echo " (original coach submitter)"; } else { echo ""; } ?></div></div>
<div class="drow"><div class="dcell"><strong>Info:</strong>
<?
if(strlen($row[coach_info]) > 400){
$phrase = "&hellip;"; }else{
$phrase = ""; }
echo substr(htmlspecialchars(strip_tags(stripslashes($row[coach_info]))), 0, 160);
echo $phrase;
?>
</div></div>
<div class="drow"><div class="dcell">
<strong>Location:</strong> <? echo "$row[coach_city], $row[coach_state]"; ?><br />
<a class="nav" href="<? echo "wiki_view.php?edit_id=$row[edit_id]"; ?>">More information</a>
<br /><input type="checkbox" value="<? echo($row[edit_id]); ?>" name="validate[]"> Validate this edit. <input type="checkbox" value="<? echo($row[edit_id]); ?>" name="delete[]"> Delete this edit.<br />
</div></div>
<? } ?>
</div>
<input type="submit" value="Process Selected Coaches" class="btn">
</form>
</div><!-- end col-2/3 -->
</div><!-- end grid -->
</div><!-- end content -->
</section>
</div><!-- end contentwrapper -->
</div> <!-- end main -->
<? include($common_path . "/templates/include_footer.php") ?>
</div> <!-- container -->
</body>
<? include($common_path . "/templates/include_global_js.php") ?>
</html>

View File

@ -0,0 +1,97 @@
<?PHP
// do I need to do additional security checks to make sure the script is being called appropriately?
/*
FIELD NAMES:
coach_id
coach_name
coach_name_tag
coach_address
coach_address_two
coach_city
coach_state
coach_state_tag
coach_zip
coach_phone
coach_fax
coach_email
coach_website
coach_certifications
coach_services
coach_degrees
coach_cost
coach_info
coach_camps
coach_submitted_by
coach_valid
coach_user_tags
*/
include("config.php");
if (!$_POST){ header('Location: '.$site_url.'/'); }
// error checking
if(!isset($_POST)) exit();
if (isset($_POST[delete])) {
// convert the array to a SQL friendly format
$deleteList = "(".implode(",", $_POST[delete]).")";
// build the SQL query to delete the edits that are bad
$sql = "DELETE FROM ".$prefix."CoachesEdits WHERE edit_id IN $deleteList";
mysql_query($sql) or die(mysql_error());
}
if (isset($_POST[validate])) {
// convert the array to a SQL friendly format
$validateList = "(".implode(",", $_POST[validate]).")";
$sql = "SELECT * FROM ".$prefix."CoachesEdits WHERE edit_id IN $validateList";
$results = mysql_query($sql) OR die(mysql_error());
// Loop through coaches shifting edits over
while($row = mysql_fetch_array($results)) {
$sql = "UPDATE ".$prefix."Coaches
SET coach_name = '".mysql_escape_string($row[coach_name])."',
coach_name_tag = '".mysql_escape_string($row[coach_name_tag])."',
coach_address = '".mysql_escape_string($row[coach_address])."',
coach_address_two = '".mysql_escape_string($row[coach_address_two])."',
coach_city = '".mysql_escape_string($row[coach_city])."',
coach_state = '".mysql_escape_string($row[coach_state])."',
coach_state_tag = '".mysql_escape_string($row[coach_state_tag])."',
coach_phone = '".mysql_escape_string($row[coach_phone])."',
coach_fax = '".mysql_escape_string($row[coach_fax])."',
coach_zip = '".mysql_escape_string($row[coach_zip])."',
coach_email = '".mysql_escape_string($row[coach_email])."',
coach_website = '".mysql_escape_string($row[coach_website])."',
coach_certifications = '".mysql_escape_string($row[coach_certifications])."',
coach_services = '".mysql_escape_string($row[coach_services])."',
coach_degrees = '".mysql_escape_string($row[coach_degrees])."',
coach_cost = '".mysql_escape_string($row[coach_cost])."',
coach_info = '".mysql_escape_string($row[coach_info])."',
coach_camps = '".mysql_escape_string($row[coach_camps])."'
WHERE coach_id = '".mysql_escape_string($row[coach_id_fk])."'";
//echo $sql;
//exit();
mysql_query($sql) OR die(mysql_error());
$sql = "INSERT INTO ".$prefix."CoachesEditors (coach_id_fk, user_id_fk, edit_timestamp) VALUES ('$row[coach_id_fk]', '$row[editor_user_id_fk]', '$row[edit_timestamp]')";
mysql_query($sql) OR die(mysql_error());
$sql = "DELETE FROM ".$prefix."CoachesEdits WHERE edit_id = $row[edit_id]";
mysql_query($sql) OR die(mysql_error());
}
}
header('Location: '.$site_url.'/wiki_validate.php');
?>

198
site/coaches/wiki_view.php Normal file
View File

@ -0,0 +1,198 @@
<?PHP
if (!is_numeric($_GET[edit_id])) { header('Location:'.$site_url.'/?error=invalid_id'); }
include("config.php");
// only admins can validate
if(!is_admin($user)){
header('Location:'.$site_url.'/');
exit();
}
// get the info for the edit based on ID
// if the ID isn't valid, punt the user
$edit_id_here = intval(mysql_escape_string($_GET[edit_id]));
$results = mysql_query("SELECT * FROM ".$prefix."CoachesEdits WHERE edit_id = '".$edit_id_here."'");
$row = mysql_fetch_array($results);
if (!$row) { header('Location:'.$site_url.'/?error=no_entry'); }
// set the page title
$pagetitle = $row[coach_name];
// set meta tags
$meta_keywords = "triathlon, ".$row[coach_name].", ".$row[coach_state]." triathlon coach";
$meta_description = "Considering getting fit by ".$row[coach_name]."? Here is all of the information about this coach.";
include("include_common_head.php");
?>
<body class="listings">
<? include($common_path . "/ads/ad_wallpaper.html"); ?>
<div class="container">
<? include($common_path . "/templates/include_header.php"); ?>
<div class="main">
<div class="contentwrapper clearfix">
<? include("include_breadcrumb.php"); ?>
<section class="section listings section-has-widgets section-static remove-sidebar">
<div class="sidebar-b">
<? include("include_sidebar.php"); ?>
</div>
<div class="content content-has-widgets">
<div class="grid">
<div class="clearfix">
<h2><!-- class="content-title"--><? echo stripslashes($row[coach_name]) ;
echo" "; ?></h2>
<?
// wiki control buttons
include("wiki_buttons.php")
?>
<div style="margin-top: 10px;">
<?
$sqlWikiFetch = "SELECT user_username FROM ".$prefix."User WHERE user_id = ".mysql_escape_string($row[editor_user_id_fk])." LIMIT 1";
$arrUser = mysql_fetch_array(mysql_query($sqlWikiFetch));
$strEditor = $arrUser[user_username];
?>
<strong>Editor:</strong> <? echo "<a href=\"http://forum.slowtwitch.com/gforum.cgi?username=".$strEditor.";\" target=\"_blank\">".$strEditor."</a>"; ?>
<br />
<strong>Edit Date:</strong> <? echo date("F j, Y", $row[edit_timestamp]); ?>
<br />
<strong>Street Address: </strong><? echo stripslashes(htmlspecialchars($row[coach_address])); ?>
<br />
<strong>Street Address Two: </strong><? echo stripslashes(htmlspecialchars($row[coach_address_two])); ?>
<br />
<strong>City: </strong><? echo stripslashes(htmlspecialchars($row[coach_city])); ?>
<br />
<strong>State: </strong><? echo stripslashes(htmlspecialchars($row[coach_state])); ?>
<br />
<strong>Zip/Postal Code: </strong><? echo stripslashes(htmlspecialchars($row[coach_zip])); ?>
<br />
<strong>Phone: </strong><? echo stripslashes(htmlspecialchars($row[coach_phone])); ?>
<br />
<strong>Fax/Alt Phone: </strong><? echo stripslashes(htmlspecialchars($row[coach_fax])); ?>
<br />
<strong>E-mail: </strong><a href="mailto:<? echo $row[coach_email]; ?>"><? echo stripslashes(htmlspecialchars($row[coach_email])); ?></a>
<br />
<strong>Website: </strong><a href="<? echo $row[coach_website]; ?>" target="_blank"><? echo $row[coach_website]; ?></a>
<br />
<br />
<div class="indentlarge">
<?
for ($i = 0; $i < 39; $i++) echo("*");
echo (" INFO ");
for ($i = 0; $i < 39; $i++) echo("*");
?>
</div>
<br />
<strong>Education: </strong><?
$row[coach_degrees] = ltrim(rtrim($row[coach_degrees], ", "), ", ");
$sql = ("SELECT * FROM gforum_CoachesDegrees WHERE coach_degree_id IN ($row[coach_degrees]) ORDER BY coach_degree_name ASC");
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$degree_list = "";
while ($list = mysql_fetch_array($fetch)) {
$degree_list = $degree_list."$list[coach_degree_name], ";
}
$degree_list = rtrim($degree_list, ', ');
if ($degree_list) {echo $degree_list;} else {echo "None";}
?>
<br />
<strong>Certifications: </strong><?
$row[coach_certifications] = ltrim(rtrim($row[coach_certifications], ", "), ", ");
$sql = ("SELECT * FROM gforum_CoachesCertifications WHERE coach_certification_id IN ($row[coach_certifications]) ORDER BY coach_certification_name ASC");
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$certification_list = "";
while ($list = mysql_fetch_array($fetch)) {
$certification_list = $certification_list."$list[coach_certification_name], ";
}
$certification_list = rtrim($certification_list, ', ');
if ($certification_list) {echo $certification_list;} else {echo "None";}
?>
<br />
<strong>Services: </strong><?
$row[coach_services] = ltrim(rtrim($row[coach_services], ", "), ", ");
$sql = ("SELECT * FROM gforum_CoachesServices WHERE coach_service_id IN ($row[coach_services]) ORDER BY coach_service_name ASC");
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$service_list = "";
while ($list = mysql_fetch_array($fetch)) {
$service_list = $service_list."$list[coach_service_name], ";
}
$service_list = rtrim($service_list, ', ');
if ($service_list) {echo $service_list;} else {echo "None";}
?>
<br /><br />
<div class="indentlarge">
<?
for ($i = 0; $i < 80; $i++) echo("*");
?>
</div>
<br />
<strong>General Info: </strong><? echo stripslashes(stripslashes($row[coach_info])) ?>
<br /><br />
<strong>Rates &amp; Fees: </strong><? echo stripslashes(stripslashes($row[coach_cost])); ?>
<br /><br />
<strong>Training Camps Offered: </strong><? echo stripslashes(stripslashes($row[coach_camps])); ?>
<br />
</div>
</div><!-- end col-2/3 -->
</div><!-- end grid -->
</div><!-- end content -->
</section>
</div><!-- end contentwrapper -->
</div> <!-- end main -->
<? include($common_path . "/templates/include_footer.php") ?>
</div> <!-- container -->
</body>
<? include($common_path . "/templates/include_global_js.php") ?>
</html>